@ethersproject/contracts
Advanced tools
Comparing version 5.4.1 to 5.5.0
@@ -1,2 +0,2 @@ | ||
export declare const version = "contracts/5.4.1"; | ||
export declare const version = "contracts/5.5.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export const version = "contracts/5.4.1"; | ||
export const version = "contracts/5.5.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -15,2 +15,3 @@ import { Fragment, Indexed, Interface, JsonFragment, Result } from "@ethersproject/abi"; | ||
accessList?: AccessListish; | ||
customData?: Record<string, any>; | ||
} | ||
@@ -37,2 +38,3 @@ export interface PayableOverrides extends Overrides { | ||
maxPriorityFeePerGas?: BigNumber; | ||
customData?: Record<string, any>; | ||
} | ||
@@ -39,0 +41,0 @@ export declare type EventFilter = { |
@@ -28,3 +28,4 @@ "use strict"; | ||
type: true, accessList: true, | ||
maxFeePerGas: true, maxPriorityFeePerGas: true | ||
maxFeePerGas: true, maxPriorityFeePerGas: true, | ||
customData: true | ||
}; | ||
@@ -34,2 +35,5 @@ function resolveName(resolver, nameOrPromise) { | ||
const name = yield nameOrPromise; | ||
if (typeof (name) !== "string") { | ||
logger.throwArgumentError("invalid address or ENS name", "name", name); | ||
} | ||
// If it is already an address, just use it (after adding checksum) | ||
@@ -68,3 +72,6 @@ try { | ||
if (!Array.isArray(value)) { | ||
return Promise.reject(new Error("invalid value for array")); | ||
return Promise.reject(logger.makeError("invalid value for array", Logger.errors.INVALID_ARGUMENT, { | ||
argument: "value", | ||
value | ||
})); | ||
} | ||
@@ -154,3 +161,3 @@ return yield Promise.all(value.map((v) => resolveAddresses(resolver, v, paramType.arrayChildren))); | ||
if (tx.gasLimit == null && fragment.gas != null) { | ||
// Conmpute the intrinisic gas cost for this transaction | ||
// Compute the intrinsic gas cost for this transaction | ||
// @TODO: This is based on the yellow paper as of Petersburg; this is something | ||
@@ -181,3 +188,6 @@ // we may wish to parameterize in v6 as part of the Network object. Since this | ||
} | ||
// Remvoe the overrides | ||
if (ro.customData) { | ||
tx.customData = shallowCopy(ro.customData); | ||
} | ||
// Remove the overrides | ||
delete overrides.nonce; | ||
@@ -192,2 +202,3 @@ delete overrides.gasLimit; | ||
delete overrides.maxPriorityFeePerGas; | ||
delete overrides.customData; | ||
// Make sure there are no stray overrides, which may indicate a | ||
@@ -224,2 +235,39 @@ // typo or using an unsupported key. | ||
} | ||
function addContractWait(contract, tx) { | ||
const wait = tx.wait.bind(tx); | ||
tx.wait = (confirmations) => { | ||
return wait(confirmations).then((receipt) => { | ||
receipt.events = receipt.logs.map((log) => { | ||
let event = deepCopy(log); | ||
let parsed = null; | ||
try { | ||
parsed = contract.interface.parseLog(log); | ||
} | ||
catch (e) { } | ||
// Successfully parsed the event log; include it | ||
if (parsed) { | ||
event.args = parsed.args; | ||
event.decode = (data, topics) => { | ||
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
event.event = parsed.name; | ||
event.eventSignature = parsed.signature; | ||
} | ||
// Useful operations | ||
event.removeListener = () => { return contract.provider; }; | ||
event.getBlock = () => { | ||
return contract.provider.getBlock(receipt.blockHash); | ||
}; | ||
event.getTransaction = () => { | ||
return contract.provider.getTransaction(receipt.transactionHash); | ||
}; | ||
event.getTransactionReceipt = () => { | ||
return Promise.resolve(receipt); | ||
}; | ||
return event; | ||
}); | ||
return receipt; | ||
}); | ||
}; | ||
} | ||
function buildCall(contract, fragment, collapseSimple) { | ||
@@ -272,3 +320,3 @@ const signerOrProvider = (contract.signer || contract.provider); | ||
} | ||
// If the contract was just deployed, wait until it is minded | ||
// If the contract was just deployed, wait until it is mined | ||
if (contract.deployTransaction != null) { | ||
@@ -279,38 +327,4 @@ yield contract._deployed(); | ||
const tx = yield contract.signer.sendTransaction(txRequest); | ||
// Tweak the tw.wait so the receipt has extra properties | ||
const wait = tx.wait.bind(tx); | ||
tx.wait = (confirmations) => { | ||
return wait(confirmations).then((receipt) => { | ||
receipt.events = receipt.logs.map((log) => { | ||
let event = deepCopy(log); | ||
let parsed = null; | ||
try { | ||
parsed = contract.interface.parseLog(log); | ||
} | ||
catch (e) { } | ||
// Successfully parsed the event log; include it | ||
if (parsed) { | ||
event.args = parsed.args; | ||
event.decode = (data, topics) => { | ||
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
event.event = parsed.name; | ||
event.eventSignature = parsed.signature; | ||
} | ||
// Useful operations | ||
event.removeListener = () => { return contract.provider; }; | ||
event.getBlock = () => { | ||
return contract.provider.getBlock(receipt.blockHash); | ||
}; | ||
event.getTransaction = () => { | ||
return contract.provider.getTransaction(receipt.transactionHash); | ||
}; | ||
event.getTransactionReceipt = () => { | ||
return Promise.resolve(receipt); | ||
}; | ||
return event; | ||
}); | ||
return receipt; | ||
}); | ||
}; | ||
// Tweak the tx.wait so the receipt has extra properties | ||
addContractWait(contract, tx); | ||
return tx; | ||
@@ -394,3 +408,3 @@ }); | ||
// A Fragment Event will populate all the properties that Wildcard | ||
// will, and additioanlly dereference the arguments when emitting | ||
// will, and additionally dereference the arguments when emitting | ||
class FragmentRunningEvent extends RunningEvent { | ||
@@ -441,3 +455,3 @@ constructor(address, contractInterface, fragment, topics) { | ||
} | ||
// A Wildard Event will attempt to populate: | ||
// A Wildcard Event will attempt to populate: | ||
// - event The name of the event name | ||
@@ -474,3 +488,3 @@ // - eventSignature The full signature of the event | ||
//address = getAddress(address); | ||
defineReadOnly(this, "interface", getStatic((new.target), "getInterface")(contractInterface)); | ||
defineReadOnly(this, "interface", getStatic(new.target, "getInterface")(contractInterface)); | ||
if (signerOrProvider == null) { | ||
@@ -556,6 +570,6 @@ defineReadOnly(this, "provider", null); | ||
const name = fragment.name; | ||
if (!uniqueNames[name]) { | ||
uniqueNames[name] = []; | ||
if (!uniqueNames[`%${name}`]) { | ||
uniqueNames[`%${name}`] = []; | ||
} | ||
uniqueNames[name].push(signature); | ||
uniqueNames[`%${name}`].push(signature); | ||
} | ||
@@ -587,2 +601,4 @@ if (this[signature] == null) { | ||
} | ||
// Strip off the leading "%" used for prototype protection | ||
name = name.substring(1); | ||
const signature = signatures[0]; | ||
@@ -923,6 +939,6 @@ // If overwriting a member property that is null, swallow the error | ||
defineReadOnly(this, "bytecode", bytecodeHex); | ||
defineReadOnly(this, "interface", getStatic((new.target), "getInterface")(contractInterface)); | ||
defineReadOnly(this, "interface", getStatic(new.target, "getInterface")(contractInterface)); | ||
defineReadOnly(this, "signer", signer || null); | ||
} | ||
// @TODO: Future; rename to populteTransaction? | ||
// @TODO: Future; rename to populateTransaction? | ||
getDeployTransaction(...args) { | ||
@@ -982,2 +998,4 @@ let tx = {}; | ||
const contract = getStatic(this.constructor, "getContract")(address, this.interface, this.signer); | ||
// Add the modified wait that wraps events | ||
addContractWait(contract, tx); | ||
defineReadOnly(contract, "deployTransaction", tx); | ||
@@ -984,0 +1002,0 @@ return contract; |
@@ -1,2 +0,2 @@ | ||
export declare const version = "contracts/5.4.1"; | ||
export declare const version = "contracts/5.5.0"; | ||
//# sourceMappingURL=_version.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = void 0; | ||
exports.version = "contracts/5.4.1"; | ||
exports.version = "contracts/5.5.0"; | ||
//# sourceMappingURL=_version.js.map |
@@ -15,2 +15,3 @@ import { Fragment, Indexed, Interface, JsonFragment, Result } from "@ethersproject/abi"; | ||
accessList?: AccessListish; | ||
customData?: Record<string, any>; | ||
} | ||
@@ -37,2 +38,3 @@ export interface PayableOverrides extends Overrides { | ||
maxPriorityFeePerGas?: BigNumber; | ||
customData?: Record<string, any>; | ||
} | ||
@@ -39,0 +41,0 @@ export declare type EventFilter = { |
251
lib/index.js
@@ -53,6 +53,10 @@ "use strict"; | ||
}; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
}; | ||
@@ -78,3 +82,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
type: true, accessList: true, | ||
maxFeePerGas: true, maxPriorityFeePerGas: true | ||
maxFeePerGas: true, maxPriorityFeePerGas: true, | ||
customData: true | ||
}; | ||
@@ -89,5 +94,8 @@ function resolveName(resolver, nameOrPromise) { | ||
name = _a.sent(); | ||
if (typeof (name) !== "string") { | ||
logger.throwArgumentError("invalid address or ENS name", "name", name); | ||
} | ||
// If it is already an address, just use it (after adding checksum) | ||
try { | ||
return [2 /*return*/, address_1.getAddress(name)]; | ||
return [2 /*return*/, (0, address_1.getAddress)(name)]; | ||
} | ||
@@ -133,3 +141,6 @@ catch (error) { } | ||
if (!Array.isArray(value)) { | ||
return [2 /*return*/, Promise.reject(new Error("invalid value for array"))]; | ||
return [2 /*return*/, Promise.reject(logger.makeError("invalid value for array", logger_1.Logger.errors.INVALID_ARGUMENT, { | ||
argument: "value", | ||
value: value | ||
}))]; | ||
} | ||
@@ -152,3 +163,3 @@ return [4 /*yield*/, Promise.all(value.map(function (v) { return resolveAddresses(resolver, v, paramType.arrayChildren); }))]; | ||
if (args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object") { | ||
overrides = properties_1.shallowCopy(args.pop()); | ||
overrides = (0, properties_1.shallowCopy)(args.pop()); | ||
} | ||
@@ -162,3 +173,3 @@ // Make sure the parameter count matches | ||
// but we allow overriding "from" if it matches the signer | ||
overrides.from = properties_1.resolveProperties({ | ||
overrides.from = (0, properties_1.resolveProperties)({ | ||
override: resolveName(contract.signer, overrides.from), | ||
@@ -168,3 +179,3 @@ signer: contract.signer.getAddress() | ||
return __generator(this, function (_a) { | ||
if (address_1.getAddress(check.signer) !== check.override) { | ||
if ((0, address_1.getAddress)(check.signer) !== check.override) { | ||
logger.throwError("Contract with a Signer cannot override from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { | ||
@@ -189,6 +200,6 @@ operation: "overrides.from" | ||
} | ||
return [4 /*yield*/, properties_1.resolveProperties({ | ||
return [4 /*yield*/, (0, properties_1.resolveProperties)({ | ||
args: resolveAddresses(contract.signer || contract.provider, args, fragment.inputs), | ||
address: contract.resolvedAddress, | ||
overrides: (properties_1.resolveProperties(overrides) || {}) | ||
overrides: ((0, properties_1.resolveProperties)(overrides) || {}) | ||
})]; | ||
@@ -226,3 +237,3 @@ case 1: | ||
if (ro.accessList != null) { | ||
tx.accessList = transactions_1.accessListify(ro.accessList); | ||
tx.accessList = (0, transactions_1.accessListify)(ro.accessList); | ||
} | ||
@@ -232,3 +243,3 @@ // If there was no "gasLimit" override, but the ABI specifies a default, use it | ||
intrinsic = 21000; | ||
bytes = bytes_1.arrayify(data); | ||
bytes = (0, bytes_1.arrayify)(data); | ||
for (i = 0; i < bytes.length; i++) { | ||
@@ -253,3 +264,6 @@ intrinsic += 4; | ||
} | ||
// Remvoe the overrides | ||
if (ro.customData) { | ||
tx.customData = (0, properties_1.shallowCopy)(ro.customData); | ||
} | ||
// Remove the overrides | ||
delete overrides.nonce; | ||
@@ -264,2 +278,3 @@ delete overrides.gasLimit; | ||
delete overrides.maxPriorityFeePerGas; | ||
delete overrides.customData; | ||
leftovers = Object.keys(overrides).filter(function (key) { return (overrides[key] != null); }); | ||
@@ -313,2 +328,39 @@ if (leftovers.length) { | ||
} | ||
function addContractWait(contract, tx) { | ||
var wait = tx.wait.bind(tx); | ||
tx.wait = function (confirmations) { | ||
return wait(confirmations).then(function (receipt) { | ||
receipt.events = receipt.logs.map(function (log) { | ||
var event = (0, properties_1.deepCopy)(log); | ||
var parsed = null; | ||
try { | ||
parsed = contract.interface.parseLog(log); | ||
} | ||
catch (e) { } | ||
// Successfully parsed the event log; include it | ||
if (parsed) { | ||
event.args = parsed.args; | ||
event.decode = function (data, topics) { | ||
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
event.event = parsed.name; | ||
event.eventSignature = parsed.signature; | ||
} | ||
// Useful operations | ||
event.removeListener = function () { return contract.provider; }; | ||
event.getBlock = function () { | ||
return contract.provider.getBlock(receipt.blockHash); | ||
}; | ||
event.getTransaction = function () { | ||
return contract.provider.getTransaction(receipt.transactionHash); | ||
}; | ||
event.getTransactionReceipt = function () { | ||
return Promise.resolve(receipt); | ||
}; | ||
return event; | ||
}); | ||
return receipt; | ||
}); | ||
}; | ||
} | ||
function buildCall(contract, fragment, collapseSimple) { | ||
@@ -328,3 +380,3 @@ var signerOrProvider = (contract.signer || contract.provider); | ||
if (!(args.length === fragment.inputs.length + 1 && typeof (args[args.length - 1]) === "object")) return [3 /*break*/, 3]; | ||
overrides = properties_1.shallowCopy(args.pop()); | ||
overrides = (0, properties_1.shallowCopy)(args.pop()); | ||
if (!(overrides.blockTag != null)) return [3 /*break*/, 2]; | ||
@@ -379,3 +431,3 @@ return [4 /*yield*/, overrides.blockTag]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var txRequest, tx, wait; | ||
var txRequest, tx; | ||
return __generator(this, function (_a) { | ||
@@ -400,37 +452,4 @@ switch (_a.label) { | ||
tx = _a.sent(); | ||
wait = tx.wait.bind(tx); | ||
tx.wait = function (confirmations) { | ||
return wait(confirmations).then(function (receipt) { | ||
receipt.events = receipt.logs.map(function (log) { | ||
var event = properties_1.deepCopy(log); | ||
var parsed = null; | ||
try { | ||
parsed = contract.interface.parseLog(log); | ||
} | ||
catch (e) { } | ||
// Successfully parsed the event log; include it | ||
if (parsed) { | ||
event.args = parsed.args; | ||
event.decode = function (data, topics) { | ||
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
event.event = parsed.name; | ||
event.eventSignature = parsed.signature; | ||
} | ||
// Useful operations | ||
event.removeListener = function () { return contract.provider; }; | ||
event.getBlock = function () { | ||
return contract.provider.getBlock(receipt.blockHash); | ||
}; | ||
event.getTransaction = function () { | ||
return contract.provider.getTransaction(receipt.transactionHash); | ||
}; | ||
event.getTransactionReceipt = function () { | ||
return Promise.resolve(receipt); | ||
}; | ||
return event; | ||
}); | ||
return receipt; | ||
}); | ||
}; | ||
// Tweak the tx.wait so the receipt has extra properties | ||
addContractWait(contract, tx); | ||
return [2 /*return*/, tx]; | ||
@@ -461,4 +480,4 @@ } | ||
function RunningEvent(tag, filter) { | ||
properties_1.defineReadOnly(this, "tag", tag); | ||
properties_1.defineReadOnly(this, "filter", filter); | ||
(0, properties_1.defineReadOnly)(this, "tag", tag); | ||
(0, properties_1.defineReadOnly)(this, "filter", filter); | ||
this._listeners = []; | ||
@@ -521,3 +540,3 @@ } | ||
// A Fragment Event will populate all the properties that Wildcard | ||
// will, and additioanlly dereference the arguments when emitting | ||
// will, and additionally dereference the arguments when emitting | ||
var FragmentRunningEvent = /** @class */ (function (_super) { | ||
@@ -541,5 +560,5 @@ __extends(FragmentRunningEvent, _super); | ||
_this = _super.call(this, getEventTag(filter), filter) || this; | ||
properties_1.defineReadOnly(_this, "address", address); | ||
properties_1.defineReadOnly(_this, "interface", contractInterface); | ||
properties_1.defineReadOnly(_this, "fragment", fragment); | ||
(0, properties_1.defineReadOnly)(_this, "address", address); | ||
(0, properties_1.defineReadOnly)(_this, "interface", contractInterface); | ||
(0, properties_1.defineReadOnly)(_this, "fragment", fragment); | ||
return _this; | ||
@@ -564,3 +583,3 @@ } | ||
FragmentRunningEvent.prototype.getEmit = function (event) { | ||
var errors = abi_1.checkResultErrors(event.args); | ||
var errors = (0, abi_1.checkResultErrors)(event.args); | ||
if (errors.length) { | ||
@@ -575,3 +594,3 @@ throw errors[0].error; | ||
}(RunningEvent)); | ||
// A Wildard Event will attempt to populate: | ||
// A Wildcard Event will attempt to populate: | ||
// - event The name of the event name | ||
@@ -585,4 +604,4 @@ // - eventSignature The full signature of the event | ||
var _this = _super.call(this, "*", { address: address }) || this; | ||
properties_1.defineReadOnly(_this, "address", address); | ||
properties_1.defineReadOnly(_this, "interface", contractInterface); | ||
(0, properties_1.defineReadOnly)(_this, "address", address); | ||
(0, properties_1.defineReadOnly)(_this, "interface", contractInterface); | ||
return _this; | ||
@@ -615,14 +634,14 @@ } | ||
//address = getAddress(address); | ||
properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface)); | ||
(0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface)); | ||
if (signerOrProvider == null) { | ||
properties_1.defineReadOnly(this, "provider", null); | ||
properties_1.defineReadOnly(this, "signer", null); | ||
(0, properties_1.defineReadOnly)(this, "provider", null); | ||
(0, properties_1.defineReadOnly)(this, "signer", null); | ||
} | ||
else if (abstract_signer_1.Signer.isSigner(signerOrProvider)) { | ||
properties_1.defineReadOnly(this, "provider", signerOrProvider.provider || null); | ||
properties_1.defineReadOnly(this, "signer", signerOrProvider); | ||
(0, properties_1.defineReadOnly)(this, "provider", signerOrProvider.provider || null); | ||
(0, properties_1.defineReadOnly)(this, "signer", signerOrProvider); | ||
} | ||
else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) { | ||
properties_1.defineReadOnly(this, "provider", signerOrProvider); | ||
properties_1.defineReadOnly(this, "signer", null); | ||
(0, properties_1.defineReadOnly)(this, "provider", signerOrProvider); | ||
(0, properties_1.defineReadOnly)(this, "signer", null); | ||
} | ||
@@ -632,7 +651,7 @@ else { | ||
} | ||
properties_1.defineReadOnly(this, "callStatic", {}); | ||
properties_1.defineReadOnly(this, "estimateGas", {}); | ||
properties_1.defineReadOnly(this, "functions", {}); | ||
properties_1.defineReadOnly(this, "populateTransaction", {}); | ||
properties_1.defineReadOnly(this, "filters", {}); | ||
(0, properties_1.defineReadOnly)(this, "callStatic", {}); | ||
(0, properties_1.defineReadOnly)(this, "estimateGas", {}); | ||
(0, properties_1.defineReadOnly)(this, "functions", {}); | ||
(0, properties_1.defineReadOnly)(this, "populateTransaction", {}); | ||
(0, properties_1.defineReadOnly)(this, "filters", {}); | ||
{ | ||
@@ -642,3 +661,3 @@ var uniqueFilters_1 = {}; | ||
var event = _this.interface.events[eventSignature]; | ||
properties_1.defineReadOnly(_this.filters, eventSignature, function () { | ||
(0, properties_1.defineReadOnly)(_this.filters, eventSignature, function () { | ||
var args = []; | ||
@@ -661,3 +680,3 @@ for (var _i = 0; _i < arguments.length; _i++) { | ||
if (filters.length === 1) { | ||
properties_1.defineReadOnly(_this.filters, name, _this.filters[filters[0]]); | ||
(0, properties_1.defineReadOnly)(_this.filters, name, _this.filters[filters[0]]); | ||
} | ||
@@ -669,14 +688,14 @@ else { | ||
} | ||
properties_1.defineReadOnly(this, "_runningEvents", {}); | ||
properties_1.defineReadOnly(this, "_wrappedEmits", {}); | ||
(0, properties_1.defineReadOnly)(this, "_runningEvents", {}); | ||
(0, properties_1.defineReadOnly)(this, "_wrappedEmits", {}); | ||
if (addressOrName == null) { | ||
logger.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName); | ||
} | ||
properties_1.defineReadOnly(this, "address", addressOrName); | ||
(0, properties_1.defineReadOnly)(this, "address", addressOrName); | ||
if (this.provider) { | ||
properties_1.defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName)); | ||
(0, properties_1.defineReadOnly)(this, "resolvedAddress", resolveName(this.provider, addressOrName)); | ||
} | ||
else { | ||
try { | ||
properties_1.defineReadOnly(this, "resolvedAddress", Promise.resolve(address_1.getAddress(addressOrName))); | ||
(0, properties_1.defineReadOnly)(this, "resolvedAddress", Promise.resolve((0, address_1.getAddress)(addressOrName))); | ||
} | ||
@@ -705,9 +724,9 @@ catch (error) { | ||
var name_1 = fragment.name; | ||
if (!uniqueNames[name_1]) { | ||
uniqueNames[name_1] = []; | ||
if (!uniqueNames["%" + name_1]) { | ||
uniqueNames["%" + name_1] = []; | ||
} | ||
uniqueNames[name_1].push(signature); | ||
uniqueNames["%" + name_1].push(signature); | ||
} | ||
if (_this[signature] == null) { | ||
properties_1.defineReadOnly(_this, signature, buildDefault(_this, fragment, true)); | ||
(0, properties_1.defineReadOnly)(_this, signature, buildDefault(_this, fragment, true)); | ||
} | ||
@@ -718,12 +737,12 @@ // We do not collapse simple calls on this bucket, which allows | ||
if (_this.functions[signature] == null) { | ||
properties_1.defineReadOnly(_this.functions, signature, buildDefault(_this, fragment, false)); | ||
(0, properties_1.defineReadOnly)(_this.functions, signature, buildDefault(_this, fragment, false)); | ||
} | ||
if (_this.callStatic[signature] == null) { | ||
properties_1.defineReadOnly(_this.callStatic, signature, buildCall(_this, fragment, true)); | ||
(0, properties_1.defineReadOnly)(_this.callStatic, signature, buildCall(_this, fragment, true)); | ||
} | ||
if (_this.populateTransaction[signature] == null) { | ||
properties_1.defineReadOnly(_this.populateTransaction, signature, buildPopulate(_this, fragment)); | ||
(0, properties_1.defineReadOnly)(_this.populateTransaction, signature, buildPopulate(_this, fragment)); | ||
} | ||
if (_this.estimateGas[signature] == null) { | ||
properties_1.defineReadOnly(_this.estimateGas, signature, buildEstimate(_this, fragment)); | ||
(0, properties_1.defineReadOnly)(_this.estimateGas, signature, buildEstimate(_this, fragment)); | ||
} | ||
@@ -737,2 +756,4 @@ }); | ||
} | ||
// Strip off the leading "%" used for prototype protection | ||
name = name.substring(1); | ||
var signature = signatures[0]; | ||
@@ -742,3 +763,3 @@ // If overwriting a member property that is null, swallow the error | ||
if (_this[name] == null) { | ||
properties_1.defineReadOnly(_this, name, _this[signature]); | ||
(0, properties_1.defineReadOnly)(_this, name, _this[signature]); | ||
} | ||
@@ -748,12 +769,12 @@ } | ||
if (_this.functions[name] == null) { | ||
properties_1.defineReadOnly(_this.functions, name, _this.functions[signature]); | ||
(0, properties_1.defineReadOnly)(_this.functions, name, _this.functions[signature]); | ||
} | ||
if (_this.callStatic[name] == null) { | ||
properties_1.defineReadOnly(_this.callStatic, name, _this.callStatic[signature]); | ||
(0, properties_1.defineReadOnly)(_this.callStatic, name, _this.callStatic[signature]); | ||
} | ||
if (_this.populateTransaction[name] == null) { | ||
properties_1.defineReadOnly(_this.populateTransaction, name, _this.populateTransaction[signature]); | ||
(0, properties_1.defineReadOnly)(_this.populateTransaction, name, _this.populateTransaction[signature]); | ||
} | ||
if (_this.estimateGas[name] == null) { | ||
properties_1.defineReadOnly(_this.estimateGas, name, _this.estimateGas[signature]); | ||
(0, properties_1.defineReadOnly)(_this.estimateGas, name, _this.estimateGas[signature]); | ||
} | ||
@@ -763,3 +784,3 @@ }); | ||
BaseContract.getContractAddress = function (transaction) { | ||
return address_1.getContractAddress(transaction); | ||
return (0, address_1.getContractAddress)(transaction); | ||
}; | ||
@@ -811,3 +832,3 @@ BaseContract.getInterface = function (contractInterface) { | ||
} | ||
var tx = properties_1.shallowCopy(overrides || {}); | ||
var tx = (0, properties_1.shallowCopy)(overrides || {}); | ||
["from", "to"].forEach(function (key) { | ||
@@ -831,3 +852,3 @@ if (tx[key] == null) { | ||
if (this.deployTransaction) { | ||
properties_1.defineReadOnly(contract, "deployTransaction", this.deployTransaction); | ||
(0, properties_1.defineReadOnly)(contract, "deployTransaction", this.deployTransaction); | ||
} | ||
@@ -905,3 +926,3 @@ return contract; | ||
var _this = this; | ||
var event = properties_1.deepCopy(log); | ||
var event = (0, properties_1.deepCopy)(log); | ||
event.removeListener = function () { | ||
@@ -937,3 +958,3 @@ if (!listener) { | ||
var args = runningEvent.getEmit(event); | ||
_this.emit.apply(_this, __spreadArray([runningEvent.filter], args)); | ||
_this.emit.apply(_this, __spreadArray([runningEvent.filter], args, false)); | ||
} | ||
@@ -963,4 +984,4 @@ catch (error) { | ||
var runningEvent = this._getRunningEvent(event); | ||
var filter = properties_1.shallowCopy(runningEvent.filter); | ||
if (typeof (fromBlockOrBlockhash) === "string" && bytes_1.isHexString(fromBlockOrBlockhash, 32)) { | ||
var filter = (0, properties_1.shallowCopy)(runningEvent.filter); | ||
if (typeof (fromBlockOrBlockhash) === "string" && (0, bytes_1.isHexString)(fromBlockOrBlockhash, 32)) { | ||
if (toBlock != null) { | ||
@@ -1076,4 +1097,4 @@ logger.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); | ||
} | ||
else if (bytes_1.isBytes(bytecode)) { | ||
bytecodeHex = bytes_1.hexlify(bytecode); | ||
else if ((0, bytes_1.isBytes)(bytecode)) { | ||
bytecodeHex = (0, bytes_1.hexlify)(bytecode); | ||
} | ||
@@ -1093,3 +1114,3 @@ else if (bytecode && typeof (bytecode.object) === "string") { | ||
// Make sure the final result is valid bytecode | ||
if (!bytes_1.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { | ||
if (!(0, bytes_1.isHexString)(bytecodeHex) || (bytecodeHex.length % 2)) { | ||
logger.throwArgumentError("invalid bytecode", "bytecode", bytecode); | ||
@@ -1101,7 +1122,7 @@ } | ||
} | ||
properties_1.defineReadOnly(this, "bytecode", bytecodeHex); | ||
properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface)); | ||
properties_1.defineReadOnly(this, "signer", signer || null); | ||
(0, properties_1.defineReadOnly)(this, "bytecode", bytecodeHex); | ||
(0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface)); | ||
(0, properties_1.defineReadOnly)(this, "signer", signer || null); | ||
} | ||
// @TODO: Future; rename to populteTransaction? | ||
// @TODO: Future; rename to populateTransaction? | ||
ContractFactory.prototype.getDeployTransaction = function () { | ||
@@ -1115,3 +1136,3 @@ var args = []; | ||
if (args.length === this.interface.deploy.inputs.length + 1 && typeof (args[args.length - 1]) === "object") { | ||
tx = properties_1.shallowCopy(args.pop()); | ||
tx = (0, properties_1.shallowCopy)(args.pop()); | ||
for (var key in tx) { | ||
@@ -1142,3 +1163,3 @@ if (!allowedTransactionKeys[key]) { | ||
// Set the data to the bytecode + the encoded constructor arguments | ||
tx.data = bytes_1.hexlify(bytes_1.concat([ | ||
tx.data = (0, bytes_1.hexlify)((0, bytes_1.concat)([ | ||
this.bytecode, | ||
@@ -1174,5 +1195,7 @@ this.interface.encodeDeploy(args) | ||
tx = _a.sent(); | ||
address = properties_1.getStatic(this.constructor, "getContractAddress")(tx); | ||
contract = properties_1.getStatic(this.constructor, "getContract")(address, this.interface, this.signer); | ||
properties_1.defineReadOnly(contract, "deployTransaction", tx); | ||
address = (0, properties_1.getStatic)(this.constructor, "getContractAddress")(tx); | ||
contract = (0, properties_1.getStatic)(this.constructor, "getContract")(address, this.interface, this.signer); | ||
// Add the modified wait that wraps events | ||
addContractWait(contract, tx); | ||
(0, properties_1.defineReadOnly)(contract, "deployTransaction", tx); | ||
return [2 /*return*/, contract]; | ||
@@ -1210,3 +1233,3 @@ } | ||
ContractFactory.getContractAddress = function (tx) { | ||
return address_1.getContractAddress(tx); | ||
return (0, address_1.getContractAddress)(tx); | ||
}; | ||
@@ -1213,0 +1236,0 @@ ContractFactory.getContract = function (address, contractInterface, signer) { |
{ | ||
"author": "Richard Moore <me@ricmoo.com>", | ||
"dependencies": { | ||
"@ethersproject/abi": "^5.4.0", | ||
"@ethersproject/abstract-provider": "^5.4.0", | ||
"@ethersproject/abstract-signer": "^5.4.0", | ||
"@ethersproject/address": "^5.4.0", | ||
"@ethersproject/bignumber": "^5.4.0", | ||
"@ethersproject/bytes": "^5.4.0", | ||
"@ethersproject/constants": "^5.4.0", | ||
"@ethersproject/logger": "^5.4.0", | ||
"@ethersproject/properties": "^5.4.0", | ||
"@ethersproject/transactions": "^5.4.0" | ||
"@ethersproject/abi": "^5.5.0", | ||
"@ethersproject/abstract-provider": "^5.5.0", | ||
"@ethersproject/abstract-signer": "^5.5.0", | ||
"@ethersproject/address": "^5.5.0", | ||
"@ethersproject/bignumber": "^5.5.0", | ||
"@ethersproject/bytes": "^5.5.0", | ||
"@ethersproject/constants": "^5.5.0", | ||
"@ethersproject/logger": "^5.5.0", | ||
"@ethersproject/properties": "^5.5.0", | ||
"@ethersproject/transactions": "^5.5.0" | ||
}, | ||
@@ -27,3 +27,3 @@ "description": "Contract abstraction meta-class for ethers.", | ||
], | ||
"gitHead": "68229ac0aff790b083717dc73cd84f38d32a3926", | ||
"gitHead": "5899c8aec0600dca42d7e24fc215037aa48917f2", | ||
"keywords": [ | ||
@@ -49,5 +49,5 @@ "Ethereum", | ||
"sideEffects": false, | ||
"tarballHash": "0x010929b9f66f0069f4b3537259c5a2fa0c83aeff05a1457a0aa787937eb3864b", | ||
"tarballHash": "0x58131be143d730526df6eb67c8dca188c60f214a2466fc6a2986d688558cd121", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.4.1" | ||
"version": "5.5.0" | ||
} |
@@ -1,1 +0,1 @@ | ||
export const version = "contracts/5.4.1"; | ||
export const version = "contracts/5.5.0"; |
@@ -25,2 +25,3 @@ "use strict"; | ||
accessList?: AccessListish; | ||
customData?: Record<string, any>; | ||
}; | ||
@@ -59,2 +60,4 @@ | ||
maxPriorityFeePerGas?: BigNumber; | ||
customData?: Record<string, any>; | ||
}; | ||
@@ -111,3 +114,4 @@ | ||
type: true, accessList: true, | ||
maxFeePerGas: true, maxPriorityFeePerGas: true | ||
maxFeePerGas: true, maxPriorityFeePerGas: true, | ||
customData: true | ||
} | ||
@@ -118,2 +122,6 @@ | ||
if (typeof(name) !== "string") { | ||
logger.throwArgumentError("invalid address or ENS name", "name", name); | ||
} | ||
// If it is already an address, just use it (after adding checksum) | ||
@@ -160,3 +168,8 @@ try { | ||
if (paramType.baseType === "array") { | ||
if (!Array.isArray(value)) { return Promise.reject(new Error("invalid value for array")); } | ||
if (!Array.isArray(value)) { | ||
return Promise.reject(logger.makeError("invalid value for array", Logger.errors.INVALID_ARGUMENT, { | ||
argument: "value", | ||
value | ||
})); | ||
} | ||
return await Promise.all(value.map((v) => resolveAddresses(resolver, v, paramType.arrayChildren))); | ||
@@ -239,3 +252,3 @@ } | ||
if (tx.gasLimit == null && fragment.gas != null) { | ||
// Conmpute the intrinisic gas cost for this transaction | ||
// Compute the intrinsic gas cost for this transaction | ||
// @TODO: This is based on the yellow paper as of Petersburg; this is something | ||
@@ -266,3 +279,7 @@ // we may wish to parameterize in v6 as part of the Network object. Since this | ||
// Remvoe the overrides | ||
if (ro.customData) { | ||
tx.customData = shallowCopy(ro.customData); | ||
} | ||
// Remove the overrides | ||
delete overrides.nonce; | ||
@@ -280,2 +297,4 @@ delete overrides.gasLimit; | ||
delete overrides.customData; | ||
// Make sure there are no stray overrides, which may indicate a | ||
@@ -315,2 +334,43 @@ // typo or using an unsupported key. | ||
function addContractWait(contract: Contract, tx: TransactionResponse) { | ||
const wait = tx.wait.bind(tx); | ||
tx.wait = (confirmations?: number) => { | ||
return wait(confirmations).then((receipt: ContractReceipt) => { | ||
receipt.events = receipt.logs.map((log) => { | ||
let event: Event = (<Event>deepCopy(log)); | ||
let parsed: LogDescription = null; | ||
try { | ||
parsed = contract.interface.parseLog(log); | ||
} catch (e){ } | ||
// Successfully parsed the event log; include it | ||
if (parsed) { | ||
event.args = parsed.args; | ||
event.decode = (data: BytesLike, topics?: Array<any>) => { | ||
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
event.event = parsed.name; | ||
event.eventSignature = parsed.signature; | ||
} | ||
// Useful operations | ||
event.removeListener = () => { return contract.provider; } | ||
event.getBlock = () => { | ||
return contract.provider.getBlock(receipt.blockHash); | ||
} | ||
event.getTransaction = () => { | ||
return contract.provider.getTransaction(receipt.transactionHash); | ||
} | ||
event.getTransactionReceipt = () => { | ||
return Promise.resolve(receipt); | ||
} | ||
return event; | ||
}); | ||
return receipt; | ||
}); | ||
}; | ||
} | ||
function buildCall(contract: Contract, fragment: FunctionFragment, collapseSimple: boolean): ContractFunction { | ||
@@ -366,3 +426,3 @@ const signerOrProvider = (contract.signer || contract.provider); | ||
// If the contract was just deployed, wait until it is minded | ||
// If the contract was just deployed, wait until it is mined | ||
if (contract.deployTransaction != null) { | ||
@@ -376,41 +436,5 @@ await contract._deployed(); | ||
// Tweak the tw.wait so the receipt has extra properties | ||
const wait = tx.wait.bind(tx); | ||
tx.wait = (confirmations?: number) => { | ||
return wait(confirmations).then((receipt: ContractReceipt) => { | ||
receipt.events = receipt.logs.map((log) => { | ||
let event: Event = (<Event>deepCopy(log)); | ||
let parsed: LogDescription = null; | ||
try { | ||
parsed = contract.interface.parseLog(log); | ||
} catch (e){ } | ||
// Tweak the tx.wait so the receipt has extra properties | ||
addContractWait(contract, tx); | ||
// Successfully parsed the event log; include it | ||
if (parsed) { | ||
event.args = parsed.args; | ||
event.decode = (data: BytesLike, topics?: Array<any>) => { | ||
return contract.interface.decodeEventLog(parsed.eventFragment, data, topics); | ||
}; | ||
event.event = parsed.name; | ||
event.eventSignature = parsed.signature; | ||
} | ||
// Useful operations | ||
event.removeListener = () => { return contract.provider; } | ||
event.getBlock = () => { | ||
return contract.provider.getBlock(receipt.blockHash); | ||
} | ||
event.getTransaction = () => { | ||
return contract.provider.getTransaction(receipt.transactionHash); | ||
} | ||
event.getTransactionReceipt = () => { | ||
return Promise.resolve(receipt); | ||
} | ||
return event; | ||
}); | ||
return receipt; | ||
}); | ||
}; | ||
return tx; | ||
@@ -515,3 +539,3 @@ }; | ||
// A Fragment Event will populate all the properties that Wildcard | ||
// will, and additioanlly dereference the arguments when emitting | ||
// will, and additionally dereference the arguments when emitting | ||
class FragmentRunningEvent extends RunningEvent { | ||
@@ -570,3 +594,3 @@ readonly address: string; | ||
// A Wildard Event will attempt to populate: | ||
// A Wildcard Event will attempt to populate: | ||
// - event The name of the event name | ||
@@ -634,3 +658,3 @@ // - eventSignature The full signature of the event | ||
// A list of RunningEvents to track listsners for each event tag | ||
// A list of RunningEvents to track listeners for each event tag | ||
_runningEvents: { [ eventTag: string ]: RunningEvent }; | ||
@@ -730,4 +754,4 @@ | ||
const name = fragment.name; | ||
if (!uniqueNames[name]) { uniqueNames[name] = [ ]; } | ||
uniqueNames[name].push(signature); | ||
if (!uniqueNames[`%${ name }`]) { uniqueNames[`%${ name }`] = [ ]; } | ||
uniqueNames[`%${ name }`].push(signature); | ||
} | ||
@@ -760,3 +784,2 @@ | ||
Object.keys(uniqueNames).forEach((name) => { | ||
// Ambiguous names to not get attached as bare names | ||
@@ -766,2 +789,5 @@ const signatures = uniqueNames[name]; | ||
// Strip off the leading "%" used for prototype protection | ||
name = name.substring(1); | ||
const signature = signatures[0]; | ||
@@ -1166,3 +1192,3 @@ | ||
// @TODO: Future; rename to populteTransaction? | ||
// @TODO: Future; rename to populateTransaction? | ||
getDeployTransaction(...args: Array<any>): TransactionRequest { | ||
@@ -1233,2 +1259,6 @@ let tx: TransactionRequest = { }; | ||
const contract = getStatic<(address: string, contractInterface: ContractInterface, signer?: Signer) => Contract>(this.constructor, "getContract")(address, this.interface, this.signer); | ||
// Add the modified wait that wraps events | ||
addContractWait(contract, tx); | ||
defineReadOnly(contract, "deployTransaction", tx); | ||
@@ -1235,0 +1265,0 @@ return contract; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
248533
3562
Updated@ethersproject/abi@^5.5.0
Updated@ethersproject/bytes@^5.5.0
Updated@ethersproject/logger@^5.5.0