@ethersproject/contracts
Advanced tools
Comparing version 5.0.0-beta.123 to 5.0.0-beta.124
@@ -1,1 +0,1 @@ | ||
export declare const version = "5.0.0-beta.123"; | ||
export declare const version = "5.0.0-beta.124"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = "5.0.0-beta.123"; | ||
exports.version = "5.0.0-beta.124"; |
@@ -25,6 +25,6 @@ import { EventFragment, Fragment, Indexed, Interface, JsonFragment } from "@ethersproject/abi"; | ||
export interface Event extends Log { | ||
args?: Array<any>; | ||
decode?: (data: string, topics?: Array<string>) => any; | ||
event?: string; | ||
eventSignature?: string; | ||
values?: Array<any>; | ||
decode?: (data: string, topics?: Array<string>) => any; | ||
removeListener: () => void; | ||
@@ -31,0 +31,0 @@ getBlock: () => Promise<Block>; |
58
index.js
@@ -26,13 +26,13 @@ "use strict"; | ||
// @TODO: Expand this to resolve any promises too | ||
function resolveAddresses(provider, value, paramType) { | ||
function resolveAddresses(signerOrProvider, value, paramType) { | ||
if (Array.isArray(paramType)) { | ||
return Promise.all(paramType.map(function (paramType, index) { | ||
return resolveAddresses(provider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); | ||
return resolveAddresses(signerOrProvider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); | ||
})); | ||
} | ||
if (paramType.type === "address") { | ||
return provider.resolveName(value); | ||
return signerOrProvider.resolveName(value); | ||
} | ||
if (paramType.type === "tuple") { | ||
return resolveAddresses(provider, value, paramType.components); | ||
return resolveAddresses(signerOrProvider, value, paramType.components); | ||
} | ||
@@ -45,3 +45,3 @@ // Strips one level of array indexing off the end to recuse into | ||
} | ||
return Promise.all(value.map(function (v) { return resolveAddresses(provider, v, paramType.arrayChildren); })); | ||
return Promise.all(value.map(function (v) { return resolveAddresses(signerOrProvider, v, paramType.arrayChildren); })); | ||
} | ||
@@ -81,4 +81,4 @@ return Promise.resolve(value); | ||
}); | ||
// Send to the contract address (after checking the contract is deployed; if supported) | ||
if (contract.provider != null) { | ||
// If the contract was just deployed, wait until it is minded | ||
if (contract.deployTransaction != null) { | ||
tx.to = contract._deployed(blockTag).then(function () { | ||
@@ -91,3 +91,3 @@ return contract.addressPromise; | ||
} | ||
return resolveAddresses(contract.provider, params, method.inputs).then(function (params) { | ||
return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then(function (params) { | ||
tx.data = contract.interface.encodeFunctionData(method, params); | ||
@@ -99,4 +99,4 @@ if (method.constant || options.callStatic) { | ||
} | ||
if (!contract.provider) { | ||
errors.throwError("call (constant functions) require a provider or a signer with a provider", errors.UNSUPPORTED_OPERATION, { operation: "call" }); | ||
if (!contract.provider && !contract.signer) { | ||
errors.throwError("call (constant functions) require a provider or signer", errors.UNSUPPORTED_OPERATION, { operation: "call" }); | ||
} | ||
@@ -109,9 +109,6 @@ // Check overrides make sense | ||
}); | ||
if (tx.from == null && contract.signer) { | ||
tx.from = contract.signer.getAddress(); | ||
} | ||
if (options.transaction) { | ||
return properties_1.resolveProperties(tx); | ||
} | ||
return contract.provider.call(tx, blockTag).then(function (value) { | ||
return (contract.signer || contract.provider).call(tx, blockTag).then(function (value) { | ||
try { | ||
@@ -136,9 +133,6 @@ var result = contract.interface.decodeFunctionResult(method, value); | ||
if (options.estimate) { | ||
if (!contract.provider) { | ||
errors.throwError("estimate gas require a provider or a signer with a provider", errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); | ||
if (!contract.provider && !contract.signer) { | ||
errors.throwError("estimate require a provider or signer", errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); | ||
} | ||
if (tx.from == null && contract.signer) { | ||
tx.from = contract.signer.getAddress(); | ||
} | ||
return contract.provider.estimateGas(tx); | ||
return (contract.signer || contract.provider).estimateGas(tx); | ||
} | ||
@@ -158,7 +152,2 @@ if (tx.gasLimit == null && method.gas != null) { | ||
} | ||
// @TODO: Allow from IFF it matches the signer address | ||
// Make sure they are not overriding something they should not | ||
if (tx.from != null) { | ||
errors.throwError("cannot override from in a transaction", errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); | ||
} | ||
if (options.transaction) { | ||
@@ -175,3 +164,3 @@ return tx; | ||
if (parsed) { | ||
event.args = parsed.values; | ||
event.values = parsed.values; | ||
event.decode = function (data, topics) { | ||
@@ -293,7 +282,2 @@ return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
/* | ||
_getAddress(address: string): string { | ||
return getAddress(address); | ||
} | ||
*/ | ||
Contract.getInterface = function (contractInterface) { | ||
@@ -383,3 +367,3 @@ if (properties_1.isNamedInstance(abi_1.Interface, contractInterface)) { | ||
if (parsed) { | ||
e.args = parsed.values; | ||
e.values = parsed.values; | ||
e.decode = function (data, topics) { | ||
@@ -406,3 +390,3 @@ return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
prepareEvent: function (e) { | ||
e.args = _this.interface.decodeEventLog(fragment_1, e.data, e.topics); | ||
e.values = _this.interface.decodeEventLog(fragment_1, e.data, e.topics); | ||
}, | ||
@@ -429,3 +413,3 @@ fragment: fragment_1, | ||
} | ||
e.args = _this.interface.decodeEventLog(fragment, e.data, e.topics); | ||
e.values = _this.interface.decodeEventLog(fragment, e.data, e.topics); | ||
}, | ||
@@ -468,5 +452,5 @@ fragment: fragment, | ||
var event = _this._wrapEvent(eventFilter, log, listener); | ||
var args = (event.args || []); | ||
args.push(event); | ||
_this.emit.apply(_this, [eventFilter.filter].concat(args)); | ||
var values = (event.values || []); | ||
values.push(event); | ||
_this.emit.apply(_this, [eventFilter.filter].concat(values)); | ||
}; | ||
@@ -473,0 +457,0 @@ this.provider.on(eventFilter.filter, wrappedListener); |
{ | ||
"name": "@ethersproject/contracts", | ||
"version": "5.0.0-beta.123", | ||
"version": "5.0.0-beta.124", | ||
"description": "Error utility functions for ethers.", | ||
@@ -30,3 +30,3 @@ "main": "index.js", | ||
}, | ||
"tarballHash": "0x71662a1eed0299a38d432a32484d33084b4d056522e6839f7538c9517bc4e1f6" | ||
"tarballHash": "0x66d957ce3a27a50ab7f7dc672f394a5e103dec2eebe3a34823a4e3e80e42f3e1" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38543
800