@ethersproject/contracts
Advanced tools
Comparing version 5.0.4 to 5.0.5
@@ -1,1 +0,1 @@ | ||
export declare const version = "contracts/5.0.4"; | ||
export declare const version = "contracts/5.0.5"; |
@@ -1,2 +0,2 @@ | ||
export const version = "contracts/5.0.4"; | ||
export const version = "contracts/5.0.5"; | ||
//# sourceMappingURL=_version.js.map |
@@ -16,4 +16,3 @@ "use strict"; | ||
import { BigNumber } from "@ethersproject/bignumber"; | ||
import { concat, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; | ||
//import { AddressZero } from "@ethersproject/constants"; | ||
import { arrayify, concat, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; | ||
import { defineReadOnly, deepCopy, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties"; | ||
@@ -43,3 +42,7 @@ // @TOOD remove dependences transactions | ||
} | ||
return yield resolver.resolveName(name); | ||
const address = yield resolver.resolveName(name); | ||
if (address == null) { | ||
logger.throwArgumentError("resolver or addr is not configured for ENS name", "name", name); | ||
} | ||
return address; | ||
}); | ||
@@ -49,20 +52,22 @@ } | ||
function resolveAddresses(resolver, value, paramType) { | ||
if (Array.isArray(paramType)) { | ||
return Promise.all(paramType.map((paramType, index) => { | ||
return resolveAddresses(resolver, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); | ||
})); | ||
} | ||
if (paramType.type === "address") { | ||
return resolveName(resolver, value); | ||
} | ||
if (paramType.type === "tuple") { | ||
return resolveAddresses(resolver, value, paramType.components); | ||
} | ||
if (paramType.baseType === "array") { | ||
if (!Array.isArray(value)) { | ||
throw new Error("invalid value for array"); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (Array.isArray(paramType)) { | ||
return yield Promise.all(paramType.map((paramType, index) => { | ||
return resolveAddresses(resolver, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); | ||
})); | ||
} | ||
return Promise.all(value.map((v) => resolveAddresses(resolver, v, paramType.arrayChildren))); | ||
} | ||
return Promise.resolve(value); | ||
if (paramType.type === "address") { | ||
return yield resolveName(resolver, value); | ||
} | ||
if (paramType.type === "tuple") { | ||
return yield resolveAddresses(resolver, value, paramType.components); | ||
} | ||
if (paramType.baseType === "array") { | ||
if (!Array.isArray(value)) { | ||
return Promise.reject(new Error("invalid value for array")); | ||
} | ||
return yield Promise.all(value.map((v) => resolveAddresses(resolver, v, paramType.arrayChildren))); | ||
} | ||
return value; | ||
}); | ||
} | ||
@@ -113,4 +118,5 @@ function populateTransaction(contract, fragment, args) { | ||
// The ABI coded transaction | ||
const data = contract.interface.encodeFunctionData(fragment, resolved.args); | ||
const tx = { | ||
data: contract.interface.encodeFunctionData(fragment, resolved.args), | ||
data: data, | ||
to: resolved.address | ||
@@ -135,3 +141,16 @@ }; | ||
if (tx.gasLimit == null && fragment.gas != null) { | ||
tx.gasLimit = BigNumber.from(fragment.gas).add(21000); | ||
// Conmpute the intrinisic gas cost for this transaction | ||
// @TODO: This is based on the yellow paper as of Petersburg; this is something | ||
// we may wish to parameterize in v6 as part of the Network object. Since this | ||
// is always a non-nil to address, we can ignore G_create, but may wish to add | ||
// similar logic to the ContractFactory. | ||
let intrinsic = 21000; | ||
const bytes = arrayify(data); | ||
for (let i = 0; i < bytes.length; i++) { | ||
intrinsic += 4; | ||
if (bytes[i]) { | ||
intrinsic += 64; | ||
} | ||
} | ||
tx.gasLimit = BigNumber.from(fragment.gas).add(intrinsic); | ||
} | ||
@@ -169,5 +188,3 @@ // Populate "value" override | ||
return function (...args) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return populateTransaction(contract, fragment, args); | ||
}); | ||
return populateTransaction(contract, fragment, args); | ||
}; | ||
@@ -484,11 +501,3 @@ } | ||
if (this.provider) { | ||
defineReadOnly(this, "resolvedAddress", this.provider.resolveName(addressOrName).then((address) => { | ||
if (address == null) { | ||
throw new Error("name not found"); | ||
} | ||
return address; | ||
}).catch((error) => { | ||
console.log("ERROR: Cannot find Contract - " + addressOrName); | ||
throw error; | ||
})); | ||
defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName)); | ||
} | ||
@@ -495,0 +504,0 @@ else { |
@@ -1,1 +0,1 @@ | ||
export declare const version = "contracts/5.0.4"; | ||
export declare const version = "contracts/5.0.5"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.version = "contracts/5.0.4"; | ||
exports.version = "contracts/5.0.5"; | ||
//# sourceMappingURL=_version.js.map |
@@ -65,3 +65,2 @@ "use strict"; | ||
var bytes_1 = require("@ethersproject/bytes"); | ||
//import { AddressZero } from "@ethersproject/constants"; | ||
var properties_1 = require("@ethersproject/properties"); | ||
@@ -80,3 +79,3 @@ // @TOOD remove dependences transactions | ||
return __awaiter(this, void 0, void 0, function () { | ||
var name; | ||
var name, address; | ||
return __generator(this, function (_a) { | ||
@@ -98,3 +97,8 @@ switch (_a.label) { | ||
return [4 /*yield*/, resolver.resolveName(name)]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
address = _a.sent(); | ||
if (address == null) { | ||
logger.throwArgumentError("resolver or addr is not configured for ENS name", "name", name); | ||
} | ||
return [2 /*return*/, address]; | ||
} | ||
@@ -106,24 +110,34 @@ }); | ||
function resolveAddresses(resolver, value, paramType) { | ||
if (Array.isArray(paramType)) { | ||
return Promise.all(paramType.map(function (paramType, index) { | ||
return resolveAddresses(resolver, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); | ||
})); | ||
} | ||
if (paramType.type === "address") { | ||
return resolveName(resolver, value); | ||
} | ||
if (paramType.type === "tuple") { | ||
return resolveAddresses(resolver, value, paramType.components); | ||
} | ||
if (paramType.baseType === "array") { | ||
if (!Array.isArray(value)) { | ||
throw new Error("invalid value for array"); | ||
} | ||
return Promise.all(value.map(function (v) { return resolveAddresses(resolver, v, paramType.arrayChildren); })); | ||
} | ||
return Promise.resolve(value); | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (!Array.isArray(paramType)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, Promise.all(paramType.map(function (paramType, index) { | ||
return resolveAddresses(resolver, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); | ||
}))]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
if (!(paramType.type === "address")) return [3 /*break*/, 4]; | ||
return [4 /*yield*/, resolveName(resolver, value)]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
case 4: | ||
if (!(paramType.type === "tuple")) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, resolveAddresses(resolver, value, paramType.components)]; | ||
case 5: return [2 /*return*/, _a.sent()]; | ||
case 6: | ||
if (!(paramType.baseType === "array")) return [3 /*break*/, 8]; | ||
if (!Array.isArray(value)) { | ||
return [2 /*return*/, Promise.reject(new Error("invalid value for array"))]; | ||
} | ||
return [4 /*yield*/, Promise.all(value.map(function (v) { return resolveAddresses(resolver, v, paramType.arrayChildren); }))]; | ||
case 7: return [2 /*return*/, _a.sent()]; | ||
case 8: return [2 /*return*/, value]; | ||
} | ||
}); | ||
}); | ||
} | ||
function populateTransaction(contract, fragment, args) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var overrides, resolved, tx, ro, roValue, leftovers; | ||
var overrides, resolved, data, tx, ro, intrinsic, bytes, i, roValue, leftovers; | ||
var _this = this; | ||
@@ -176,4 +190,5 @@ return __generator(this, function (_a) { | ||
resolved = _a.sent(); | ||
data = contract.interface.encodeFunctionData(fragment, resolved.args); | ||
tx = { | ||
data: contract.interface.encodeFunctionData(fragment, resolved.args), | ||
data: data, | ||
to: resolved.address | ||
@@ -197,3 +212,11 @@ }; | ||
if (tx.gasLimit == null && fragment.gas != null) { | ||
tx.gasLimit = bignumber_1.BigNumber.from(fragment.gas).add(21000); | ||
intrinsic = 21000; | ||
bytes = bytes_1.arrayify(data); | ||
for (i = 0; i < bytes.length; i++) { | ||
intrinsic += 4; | ||
if (bytes[i]) { | ||
intrinsic += 64; | ||
} | ||
} | ||
tx.gasLimit = bignumber_1.BigNumber.from(fragment.gas).add(intrinsic); | ||
} | ||
@@ -235,7 +258,3 @@ // Populate "value" override | ||
} | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, populateTransaction(contract, fragment, args)]; | ||
}); | ||
}); | ||
return populateTransaction(contract, fragment, args); | ||
}; | ||
@@ -616,11 +635,3 @@ } | ||
if (this.provider) { | ||
properties_1.defineReadOnly(this, "resolvedAddress", this.provider.resolveName(addressOrName).then(function (address) { | ||
if (address == null) { | ||
throw new Error("name not found"); | ||
} | ||
return address; | ||
}).catch(function (error) { | ||
console.log("ERROR: Cannot find Contract - " + addressOrName); | ||
throw error; | ||
})); | ||
properties_1.defineReadOnly(this, "resolvedAddress", resolveName(this.provider, addressOrName)); | ||
} | ||
@@ -627,0 +638,0 @@ else { |
@@ -16,2 +16,3 @@ { | ||
"ethereum": "donations.ethers.eth", | ||
"gitHead": "22dee96f512ad7d7cae5d278cc607cdff6112f05", | ||
"keywords": [ | ||
@@ -35,5 +36,5 @@ "Ethereum", | ||
}, | ||
"tarballHash": "0xd0aff3ce335bf7127682dba635cd151f1076281e3917c7076c33b36c8f7b4afa", | ||
"tarballHash": "0x82fb83236d1d58cf1e61bbb0b5cb6c268733ce68facdc1d247aa11527808fd20", | ||
"types": "./lib/index.d.ts", | ||
"version": "5.0.4" | ||
"version": "5.0.5" | ||
} |
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
176131
2374