admin: update dist files

This commit is contained in:
Richard Moore 2022-09-15 22:58:45 -04:00
parent 067536a837
commit 406a1d3d57
431 changed files with 13441 additions and 8554 deletions

10596
dist/ethers.js vendored

File diff suppressed because it is too large Load Diff

1
dist/ethers.js.map vendored Normal file

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

1020
dist/wordlists-extra.js vendored

File diff suppressed because it is too large Load Diff

1
dist/wordlists-extra.js.map vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,111 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.connect = exports.getProvider = exports.getProviderNetworks = exports.providerNames = void 0;
const index_js_1 = require("../index.js");
;
const ethNetworks = ["default", "homestead", "rinkeby", "ropsten", "goerli"];
//const maticNetworks = [ "matic", "maticmum" ];
const ProviderCreators = [
{
name: "AlchemyProvider",
networks: ethNetworks,
create: function (network) {
return new index_js_1.AlchemyProvider(network, "YrPw6SWb20vJDRFkhWq8aKnTQ8JRNRHM");
}
},
{
name: "AnkrProvider",
networks: ethNetworks.concat(["matic", "arbitrum"]),
create: function (network) {
return new index_js_1.AnkrProvider(network);
}
},
{
name: "CloudflareProvider",
networks: ["default", "homestead"],
create: function (network) {
return new index_js_1.CloudflareProvider(network);
}
},
{
name: "EtherscanProvider",
networks: ethNetworks,
create: function (network) {
return new index_js_1.EtherscanProvider(network, "FPFGK6JSW2UHJJ2666FG93KP7WC999MNW7");
}
},
{
name: "InfuraProvider",
networks: ethNetworks,
create: function (network) {
return new index_js_1.InfuraProvider(network, "49a0efa3aaee4fd99797bfa94d8ce2f1");
}
},
/*
{
name: "PocketProvider",
networks: ethNetworks,
create: function(network: string) {
const apiKeys: Record<string, string> = {
homestead: "6004bcd10040261633ade990",
ropsten: "6004bd4d0040261633ade991",
rinkeby: "6004bda20040261633ade994",
goerli: "6004bd860040261633ade992",
};
return new PocketProvider(network, apiKeys[network]);
}
},
*/
{
name: "FallbackProvider",
networks: ethNetworks,
create: function (network) {
const providers = [];
for (const creator of ProviderCreators) {
if (creator.name === "FallbackProvider") {
continue;
}
if (creator.networks.indexOf(network) >= 0) {
const provider = creator.create(network);
if (provider) {
providers.push(provider);
}
}
}
return new index_js_1.FallbackProvider(providers);
}
},
];
exports.providerNames = Object.freeze(ProviderCreators.map((c) => (c.name)));
function getCreator(provider) {
const creators = ProviderCreators.filter((c) => (c.name === provider));
if (creators.length === 1) {
return creators[0];
}
return null;
}
function getProviderNetworks(provider) {
const creator = getCreator(provider);
if (creator) {
return creator.networks;
}
return [];
}
exports.getProviderNetworks = getProviderNetworks;
function getProvider(provider, network) {
const creator = getCreator(provider);
if (creator) {
return creator.create(network);
}
return null;
}
exports.getProvider = getProvider;
function connect(network) {
const provider = getProvider("InfuraProvider", network);
if (provider == null) {
throw new Error(`could not connect to ${network}`);
}
return provider;
}
exports.connect = connect;
//# sourceMappingURL=create-provider.js.map

@ -0,0 +1 @@
{"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":";;;AAAA,0CASqB;AAQpB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAE,CAAC;AAC/E,gDAAgD;AAEhD,MAAM,gBAAgB,GAA2B;IAC7C;QACI,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,0BAAe,CAAC,OAAO,EAAE,kCAAkC,CAAC,CAAC;QAC5E,CAAC;KACJ;IACD;QACI,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAE,OAAO,EAAE,UAAU,CAAE,CAAC;QACrD,MAAM,EAAE,UAAS,OAAe;YAC5B,OAAO,IAAI,uBAAY,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;KACJ;IACD;QACI,IA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AI,CAAC,CAAC,CAAC,CAAC;AAElF,SAAS,UAAU,CAAC,QAAgB;IAChC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;IACvE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;KAAE;IAClD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAgB,mBAAmB,CAAC,QAAgB;IAChD,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,OAAO,EAAE;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC;KAAE;IACzC,OAAO,EAAG,CAAC;AACf,CAAC;AAJD,kDAIC;AAED,SAAgB,WAAW,CAAC,QAAgB,EAAE,OAAe;IACzD,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,IAAI,OAAO,EAAE;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KAAE;IAChD,OAAO,IAAI,CAAC;AAChB,CAAC;AAJD,kCAIC;AAED,SAAgB,OAAO,CAAC,OAAe;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACxD,IAAI,QAAQ,IAAI,IAAI,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,wBAAyB,OAAQ,EAAE,CAAC,CAAC;KAAE;IAC/E,OAAO,QAAQ,CAAC;AACpB,CAAC;AAJD,0BAIC"}

@ -0,0 +1,33 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const create_provider_js_1 = require("./create-provider.js");
describe("Resolve ENS avatar", function () {
[
{ title: "data", name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dW1lbnRJRD0ieG1wLmRpZDo1RDg1MTI1QTI4QjAxMUVDODQ1MEM1NTZEOTU1MDk3OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PkbM0uMAAAAGUExURQAA/wAAAHtivz4AAAAOSURBVHjaYmDABAABBgAAFAABaEkyYwAAAABJRU5ErkJggg==" },
{ title: "ipfs", name: "ipfs-avatar.tests.eth", value: "https:/\/gateway.ipfs.io/ipfs/QmQsQgpda6JAYkFoeVcj5iPbwV3xRcvaiXv3bhp1VuYUqw" },
{ title: "url", name: "url-avatar.tests.eth", value: "https:/\/ethers.org/static/logo.png" },
].forEach((test) => {
it(`Resolves avatar for ${test.title}`, async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
const avatar = await provider.getAvatar(test.name);
assert_1.default.equal(test.value, avatar, "avatar url");
});
});
[
{ title: "ERC-1155", name: "nick.eth", value: "https:/\/lh3.googleusercontent.com/hKHZTZSTmcznonu8I6xcVZio1IF76fq0XmcxnvUykC-FGuVJ75UPdLDlKJsfgVXH9wOSmkyHw0C39VAYtsGyxT7WNybjQ6s3fM3macE" },
// { title: "ERC-721", name: "brantly.eth", value: "https:/\/api.wrappedpunks.com/images/punks/2430.png" }
].forEach((test) => {
it(`Resolves avatar for ${test.title}`, async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("homestead");
const avatar = await provider.getAvatar(test.name);
assert_1.default.equal(avatar, test.value, "avatar url");
});
});
});
//# sourceMappingURL=test-providers-avatar.js.map

@ -0,0 +1 @@
{"version":3,"file":"test-providers-avatar.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-avatar.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,6DAA+C;AAE/C,QAAQ,CAAC,oBAAoB,EAAE;IAC3B;QACI,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAA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,141 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const index_js_1 = require("../index.js");
const create_provider_js_1 = require("./create-provider.js");
describe("Test CCIP execution", function () {
// This matches the verify method in the Solidity contract against the
// processed data from the endpoint
const verify = function (sender, data, result) {
const check = (0, index_js_1.concat)([
(0, index_js_1.toArray)((0, index_js_1.dataLength)(sender)), sender,
(0, index_js_1.toArray)((0, index_js_1.dataLength)(data)), data
]);
assert_1.default.equal(result, (0, index_js_1.keccak256)(check), "response is equal");
};
const address = "0xAe375B05A08204C809b3cA67C680765661998886";
const calldata = "0x1234";
it("testGet passes under normal operation", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testGet(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0xa5f3271e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
const result = await provider.call(tx);
verify(address, calldata, result);
});
it("testGet should fail with CCIP not explicitly enabled by overrides", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testGet(bytes callData = "0x1234")
const tx = {
to: address,
data: "0xa5f3271e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
await assert_1.default.rejects(async function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const offchainErrorData = "0x556f1830000000000000000000000000ae375b05a08204c809b3ca67c68076566199888600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData);
});
});
it("testGet should fail with CCIP explicitly disabled on provider", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
provider.disableCcipRead = true;
// testGetFail(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0xa5f3271e000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
await assert_1.default.rejects(async function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const offchainErrorData = "0x556f1830000000000000000000000000ae375b05a08204c809b3ca67c68076566199888600000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData);
});
});
it("testGetFail should fail if all URLs 5xx", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testGetFail(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0x36f9cea6000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
await assert_1.default.rejects(async function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const infoJson = '{"urls":["https:/\/ethers.ricmoo.workers.dev/status/500/{sender}/{data}"],"errorMessages":["hello world"]}';
return ((0, index_js_1.isError)(error, "OFFCHAIN_FAULT") && error.reason === "500_SERVER_ERROR" &&
JSON.stringify(error.info) === infoJson);
});
});
it("testGetSenderFail should fail if sender does not match", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testGetSenderFail(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0x64bff6d1000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000",
};
await assert_1.default.rejects(async function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const errorArgsJson = '["0x0000000000000000000000000000000000000000",["https://ethers.ricmoo.workers.dev/test-ccip-read/{sender}/{data}"],"0x1234","0xb1494be1","0x4d792065787472612064617461"]';
const offchainErrorData = "0x556f1830000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000140b1494be100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004068747470733a2f2f6574686572732e7269636d6f6f2e776f726b6572732e6465762f746573742d636369702d726561642f7b73656e6465727d2f7b646174617d00000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d4d79206578747261206461746100000000000000000000000000000000000000";
return ((0, index_js_1.isCallException)(error) && error.data === offchainErrorData &&
error.errorSignature === "OffchainLookup(address,string[],bytes,bytes4,bytes)" &&
JSON.stringify(error.errorArgs) === errorArgsJson);
});
});
it("testGetMissing should fail if early URL 4xx", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testGetMissing(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0x4ece8d7d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
await assert_1.default.rejects(async function () {
const result = await provider.call(tx);
console.log(result);
}, (error) => {
const infoJson = '{"url":"https:/\/ethers.ricmoo.workers.dev/status/404/{sender}/{data}","errorMessage":"hello world"}';
return ((0, index_js_1.isError)(error, "OFFCHAIN_FAULT") && error.reason === "404_MISSING_RESOURCE" &&
JSON.stringify(error.info || "") === infoJson);
});
});
it("testGetFallback passes if any URL returns correctly", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testGetFallback(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0xedf4a021000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
const result = await provider.call(tx);
verify(address, calldata, result);
});
it("testPost passes under normal operation", async function () {
this.timeout(60000);
const provider = (0, create_provider_js_1.connect)("ropsten");
// testPost(bytes callData = "0x1234")
const tx = {
to: address, enableCcipRead: true,
data: "0x66cab49d000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000021234000000000000000000000000000000000000000000000000000000000000"
};
const result = await provider.call(tx);
verify(address, calldata, result);
});
});
//# sourceMappingURL=test-providers-ccip.js.map

@ -0,0 +1 @@
{"version":3,"file":"test-providers-ccip.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-ccip.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,0CAKqB;AAErB,6DAA+C;AAE/C,QAAQ,CAAC,qBAAqB,EAAE;IAE5B,sEAAsE;IACtE,mCAAmC;IACnC,MAAM,MAAM,GAAG,UAAS,MAAc,EAAE,IAAY,EAAE,MAAc;QAChE,MAAM,KAAK,GAAG,IAAA,iBAAM,EAAC;YACjB,IAAA,kBAAO,EAAC,IAAA,qBAAU,EAAC,MAAM,CAAC,CAAC,EAAE,MAAM;YACnC,IAAA,k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AAC;QAEpB,MAAM,QAAQ,GAAG,IAAA,4BAAO,EAAC,SAAS,CAAC,CAAC;QAEpC,sCAAsC;QACtC,MAAM,EAAE,GAAG;YACP,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI;YACjC,IAAI,EAAE,4MAA4M;SACrN,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACvC,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAA"}

@ -0,0 +1,20 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = __importDefault(require("assert"));
const create_provider_js_1 = require("./create-provider.js");
describe("Test EIP-2544 ENS wildcards", function () {
const provider = (0, create_provider_js_1.connect)("ropsten");
it("Resolves recursively", async function () {
const resolver = await provider.getResolver("ricmoose.hatch.eth");
assert_1.default.ok(resolver, "failed to get resolver");
assert_1.default.equal(resolver.address, "0x8fc4C380c5d539aE631daF3Ca9182b40FB21D1ae", "address");
assert_1.default.equal(await resolver.supportsWildcard(), true, "supportsWildcard()");
// Test pass-through avatar
assert_1.default.equal(await resolver.getAvatar(), "https:/\/static.ricmoo.com/uploads/profile-06cb9c3031c9.jpg", "getAvatar()");
assert_1.default.equal(await resolver.getAddress(), "0x4FaBE0A3a4DDd9968A7b4565184Ad0eFA7BE5411", "getAddress()");
});
});
//# sourceMappingURL=test-providers-wildcard.js.map

@ -0,0 +1 @@
{"version":3,"file":"test-providers-wildcard.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-wildcard.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,6DAA+C;AAE/C,QAAQ,CAAC,6BAA6B,EAAE;IACpC,MAAM,QAAQ,GAAG,IAAA,4BAAO,EAAC,SAAS,CAAC,CAAC;IAEpC,EAAE,CAAC,sBAAsB,EAAE,KAAK;QAC5B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;QAClE,gBAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;QAE9C,gBAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,4CAA4C,EAAE,SAAS,CAAC,CAAC;QACxF,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,oBAAoB,CAAC,CAAC;QAE5E,2BAA2B;QAC3B,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,SAAS,EAAE,EAAE,6DAA6D,EAAE,aAAa,CAAC,CAAC;QAEvH,gBAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,UAAU,EAAE,EAAE,4CAA4C,EAAE,cAAc,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}

@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.log = exports.loadTests = void 0;
exports.stats = exports.Stats = exports.retryIt = exports.log = exports.loadTests = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const zlib_1 = __importDefault(require("zlib"));
@ -37,4 +37,91 @@ function log(context, text) {
}
}
exports.log = log;
async function stall(duration) {
return new Promise((resolve) => { setTimeout(resolve, duration); });
}
const ATTEMPTS = 5;
async function retryIt(name, func) {
it(name, async function () {
this.timeout(ATTEMPTS * 5000);
for (let i = 0; i < ATTEMPTS; i++) {
try {
await func.call(this);
return;
}
catch (error) {
if (error.message === "sync skip; aborting execution") {
// Skipping a test; let mocha handle it
throw error;
}
else if (error.code === "ERR_ASSERTION") {
// Assertion error; let mocha scold us
throw error;
}
else {
if (i === ATTEMPTS - 1) {
exports.stats.pushRetry(i, name, error);
}
else {
await stall(500 * (1 << i));
exports.stats.pushRetry(i, name, null);
}
}
}
}
// All hope is lost.
throw new Error(`Failed after ${ATTEMPTS} attempts; ${name}`);
});
}
exports.retryIt = retryIt;
const _guard = {};
class Stats {
#stats;
constructor(guard) {
if (guard !== _guard) {
throw new Error("private constructor");
}
this.#stats = [];
}
#currentStats() {
if (this.#stats.length === 0) {
throw new Error("no active stats");
}
return this.#stats[this.#stats.length - 1];
}
pushRetry(attempt, line, error) {
const { retries } = this.#currentStats();
if (attempt > 0) {
retries.pop();
}
if (retries.length < 100) {
retries.push({
message: `${attempt + 1} failures: ${line}`,
error
});
}
}
start(name) {
this.#stats.push({ name, retries: [] });
}
end(context) {
let log = console.log.bind(console);
if (context && typeof (context._ethersLog) === "function") {
log = context._ethersLog;
}
const { name, retries } = this.#currentStats();
if (retries.length === 0) {
return;
}
log(`Warning: The following tests required retries (${name})`);
retries.forEach(({ error, message }) => {
log(" " + message);
if (error) {
log(error);
}
});
}
}
exports.Stats = Stats;
exports.stats = new Stats(_guard);
//# sourceMappingURL=utils.js.map

@ -1 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src.ts/_tests/utils.ts"],"names":[],"mappings":";;;;;;AACA,4CAAmB;AACnB,gDAAwB;AACxB,gDAAwB;AAExB,0DAA0D;AAC1D,MAAM,IAAI,GAAG,CAAC;IACV,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAEzB,OAAO,IAAI,EAAE;QACT,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC;SAAE;QAC9D,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,MAAM,KAAK,IAAI,EAAE;YAAE,MAAM;SAAE;QAC/B,IAAI,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iki/Ethereum-Contract-ABI
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultAbiCoder = exports.AbiCoder = void 0;
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../utils/index.js");
const abstract_coder_js_1 = require("./coders/abstract-coder.js");
const address_js_1 = require("./coders/address.js");
const array_js_1 = require("./coders/array.js");
@ -41,7 +41,7 @@ class AbiCoder {
if (match) {
let size = parseInt(match[2] || "256");
if (size === 0 || size > 256 || (size % 8) !== 0) {
logger_js_1.logger.throwArgumentError("invalid " + match[1] + " bit length", "param", param);
(0, index_js_1.throwArgumentError)("invalid " + match[1] + " bit length", "param", param);
}
return new number_js_1.NumberCoder(size / 8, (match[1] === "int"), param.name);
}
@ -50,11 +50,11 @@ class AbiCoder {
if (match) {
let size = parseInt(match[1]);
if (size === 0 || size > 32) {
logger_js_1.logger.throwArgumentError("invalid bytes length", "param", param);
(0, index_js_1.throwArgumentError)("invalid bytes length", "param", param);
}
return new fixed_bytes_js_1.FixedBytesCoder(size, param.name);
}
return logger_js_1.logger.throwArgumentError("invalid type", "type", param.type);
return (0, index_js_1.throwArgumentError)("invalid type", "type", param.type);
}
getDefaultValue(types) {
const coders = types.map((type) => this.#getCoder(fragments_js_1.ParamType.from(type)));
@ -62,7 +62,7 @@ class AbiCoder {
return coder.defaultValue();
}
encode(types, values) {
logger_js_1.logger.assertArgumentCount(values.length, types.length, "types/values length mismatch");
(0, index_js_1.assertArgumentCount)(values.length, types.length, "types/values length mismatch");
const coders = types.map((type) => this.#getCoder(fragments_js_1.ParamType.from(type)));
const coder = (new tuple_js_1.TupleCoder(coders, "_"));
const writer = new abstract_coder_js_1.Writer();

@ -1 +1 @@
{"version":3,"file":"abi-coder.js","sourceRoot":"","sources":["../../src.ts/abi/abi-coder.ts"],"names":[],"mappings":";AAAA,mEAAmE;;;AAEnE,kDAA4C;AAE5C,kEAA2E;AAC3E,oDAAmD;AACnD,gDAA+C;AAC/C,oDAAmD;AACnD,gDAA+C;AAC/C,4DAA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AAC;IAChC,CAAC;IAED,MAAM,CAAC,KAAwC,EAAE,MAA0B;QACvE,IAAA,8BAAmB,EAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;QAEjF,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,wBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,CAAC,IAAI,qBAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAG,IAAI,0BAAM,EAAE,CAAC;QAC5B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,KAAwC,EAAE,IAAe,EAAE,KAAe;QAC7E,MAAM,MAAM,GAAiB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,wBAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACvF,MAAM,KAAK,GAAG,IAAI,qBAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC1C,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,0BAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACjD,CAAC;CACJ;AArED,4BAqEC;AAGY,QAAA,eAAe,GAAa,IAAI,QAAQ,EAAE,CAAC"}

@ -1,22 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseBytes32String = exports.formatBytes32String = void 0;
const data_js_1 = require("../utils/data.js");
const logger_js_1 = require("../utils/logger.js");
const utf8_js_1 = require("../utils/utf8.js");
const index_js_1 = require("../utils/index.js");
function formatBytes32String(text) {
// Get the bytes
const bytes = (0, utf8_js_1.toUtf8Bytes)(text);
const bytes = (0, index_js_1.toUtf8Bytes)(text);
// Check we have room for null-termination
if (bytes.length > 31) {
throw new Error("bytes32 string must be less than 32 bytes");
}
// Zero-pad (implicitly null-terminates)
return (0, data_js_1.zeroPadBytes)(bytes, 32);
return (0, index_js_1.zeroPadBytes)(bytes, 32);
}
exports.formatBytes32String = formatBytes32String;
function parseBytes32String(_bytes) {
const data = logger_js_1.logger.getBytes(_bytes, "bytes");
const data = (0, index_js_1.getBytes)(_bytes, "bytes");
// Must be 32 bytes with a null-termination
if (data.length !== 32) {
throw new Error("invalid bytes32 - not 32 bytes long");
@ -30,7 +28,7 @@ function parseBytes32String(_bytes) {
length--;
}
// Determine the string value
return (0, utf8_js_1.toUtf8String)(data.slice(0, length));
return (0, index_js_1.toUtf8String)(data.slice(0, length));
}
exports.parseBytes32String = parseBytes32String;
//# sourceMappingURL=bytes32.js.map

@ -1 +1 @@
{"version":3,"file":"bytes32.js","sourceRoot":"","sources":["../../src.ts/abi/bytes32.ts"],"names":[],"mappings":";;;AACA,8CAAgD;AAEhD,kDAA4C;AAE5C,8CAA6D;AAK7D,SAAgB,mBAAmB,CAAC,IAAY;IAE5C,gBAAgB;IAChB,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,IAAI,CAAC,CAAC;IAEhC,0CAA0C;IAC1C,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAAE;IAExF,wCAAwC;IACxC,OAAO,IAAA,sBAAY,EAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAVD,kDAUC;AAED,SAAgB,kBAAkB,CAAC,MAAiB;IAChD,MAAM,IAAI,GAAG,kBAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE9C,2CAA2C;IAC3C,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE;QAAE,MAAM,IAAI,K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GAAG,EAAE,CAAC;IAChB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE;QAAE,MAAM,EAAE,CAAC;KAAE;IAE5C,6BAA6B;IAC7B,OAAO,IAAA,uBAAY,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/C,CAAC;AAbD,gDAaC"}

@ -1,10 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Reader = exports.Writer = exports.Coder = exports.checkResultErrors = exports.Result = exports.WordSize = void 0;
const maths_js_1 = require("../../utils/maths.js");
const data_js_1 = require("../../utils/data.js");
const properties_js_1 = require("../../utils/properties.js");
const logger_js_1 = require("../../utils/logger.js");
const index_js_1 = require("../../utils/index.js");
exports.WordSize = 32;
const Padding = new Uint8Array(exports.WordSize);
// Properties used to immediate pass through to the underlying object
@ -14,7 +11,7 @@ const _guard = {};
class Result extends Array {
#indices;
constructor(guard, items, keys) {
logger_js_1.logger.assertPrivate(guard, _guard, "Result");
(0, index_js_1.assertPrivate)(guard, _guard, "Result");
super(...items);
// Name lookup table
this.#indices = new Map();
@ -36,7 +33,7 @@ class Result extends Array {
get: (target, prop, receiver) => {
if (typeof (prop) === "string") {
if (prop.match(/^[0-9]+$/)) {
const index = logger_js_1.logger.getNumber(prop, "%index");
const index = (0, index_js_1.getNumber)(prop, "%index");
if (index < 0 || index >= this.length) {
throw new RangeError("out of result range");
}
@ -135,16 +132,16 @@ function checkResultErrors(result) {
}
exports.checkResultErrors = checkResultErrors;
function getValue(value) {
let bytes = (0, maths_js_1.toArray)(value);
let bytes = (0, index_js_1.toArray)(value);
if (bytes.length > exports.WordSize) {
logger_js_1.logger.throwError("value out-of-bounds", "BUFFER_OVERRUN", {
(0, index_js_1.throwError)("value out-of-bounds", "BUFFER_OVERRUN", {
buffer: bytes,
length: exports.WordSize,
offset: bytes.length
});
}
if (bytes.length !== exports.WordSize) {
bytes = logger_js_1.logger.getBytesCopy((0, data_js_1.concat)([Padding.slice(bytes.length % exports.WordSize), bytes]));
bytes = (0, index_js_1.getBytesCopy)((0, index_js_1.concat)([Padding.slice(bytes.length % exports.WordSize), bytes]));
}
return bytes;
}
@ -163,12 +160,12 @@ class Coder {
// - Not Dynamic: address, uint256, boolean[3], tuple(address, uint8)
dynamic;
constructor(name, type, localName, dynamic) {
(0, properties_js_1.defineProperties)(this, { name, type, localName, dynamic }, {
(0, index_js_1.defineProperties)(this, { name, type, localName, dynamic }, {
name: "string", type: "string", localName: "string", dynamic: "boolean"
});
}
_throwError(message, value) {
return logger_js_1.logger.throwArgumentError(message, this.localName, value);
return (0, index_js_1.throwArgumentError)(message, this.localName, value);
}
}
exports.Coder = Coder;
@ -181,7 +178,7 @@ class Writer {
this.#dataLength = 0;
}
get data() {
return (0, data_js_1.concat)(this.#data);
return (0, index_js_1.concat)(this.#data);
}
get length() { return this.#dataLength; }
#writeData(data) {
@ -190,14 +187,14 @@ class Writer {
return data.length;
}
appendWriter(writer) {
return this.#writeData(logger_js_1.logger.getBytesCopy(writer.data));
return this.#writeData((0, index_js_1.getBytesCopy)(writer.data));
}
// Arrayish item; pad on the right to *nearest* WordSize
writeBytes(value) {
let bytes = logger_js_1.logger.getBytesCopy(value);
let bytes = (0, index_js_1.getBytesCopy)(value);
const paddingOffset = bytes.length % exports.WordSize;
if (paddingOffset) {
bytes = logger_js_1.logger.getBytesCopy((0, data_js_1.concat)([bytes, Padding.slice(paddingOffset)]));
bytes = (0, index_js_1.getBytesCopy)((0, index_js_1.concat)([bytes, Padding.slice(paddingOffset)]));
}
return this.#writeData(bytes);
}
@ -226,11 +223,11 @@ class Reader {
#data;
#offset;
constructor(data, allowLoose) {
(0, properties_js_1.defineProperties)(this, { allowLoose: !!allowLoose });
this.#data = logger_js_1.logger.getBytesCopy(data);
(0, index_js_1.defineProperties)(this, { allowLoose: !!allowLoose });
this.#data = (0, index_js_1.getBytesCopy)(data);
this.#offset = 0;
}
get data() { return (0, data_js_1.hexlify)(this.#data); }
get data() { return (0, index_js_1.hexlify)(this.#data); }
get dataLength() { return this.#data.length; }
get consumed() { return this.#offset; }
get bytes() { return new Uint8Array(this.#data); }
@ -241,8 +238,8 @@ class Reader {
alignedLength = length;
}
else {
logger_js_1.logger.throwError("data out-of-bounds", "BUFFER_OVERRUN", {
buffer: logger_js_1.logger.getBytesCopy(this.#data),
(0, index_js_1.throwError)("data out-of-bounds", "BUFFER_OVERRUN", {
buffer: (0, index_js_1.getBytesCopy)(this.#data),
length: this.#data.length,
offset: this.#offset + alignedLength
});
@ -263,10 +260,10 @@ class Reader {
}
// Read a numeric values
readValue() {
return (0, maths_js_1.toBigInt)(this.readBytes(exports.WordSize));
return (0, index_js_1.toBigInt)(this.readBytes(exports.WordSize));
}
readIndex() {
return (0, maths_js_1.toNumber)(this.readBytes(exports.WordSize));
return (0, index_js_1.toNumber)(this.readBytes(exports.WordSize));
}
}
exports.Reader = Reader;

File diff suppressed because one or more lines are too long

@ -1,9 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ArrayCoder = exports.unpack = exports.pack = void 0;
const properties_js_1 = require("../../utils/properties.js");
const errors_js_1 = require("../../utils/errors.js");
const logger_js_1 = require("../../utils/logger.js");
const index_js_1 = require("../../utils/index.js");
const typed_js_1 = require("../typed.js");
const abstract_coder_js_1 = require("./abstract-coder.js");
const anonymous_js_1 = require("./anonymous.js");
@ -17,14 +15,14 @@ function pack(writer, coders, values) {
arrayValues = coders.map((coder) => {
const name = coder.localName;
if (!name) {
logger_js_1.logger.throwError("cannot encode object for signature with missing names", "INVALID_ARGUMENT", {
(0, index_js_1.throwError)("cannot encode object for signature with missing names", "INVALID_ARGUMENT", {
argument: "values",
info: { coder },
value: values
});
}
if (unique[name]) {
logger_js_1.logger.throwError("cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", {
(0, index_js_1.throwError)("cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", {
argument: "values",
info: { coder },
value: values
@ -35,10 +33,10 @@ function pack(writer, coders, values) {
});
}
else {
logger_js_1.logger.throwArgumentError("invalid tuple value", "tuple", values);
(0, index_js_1.throwArgumentError)("invalid tuple value", "tuple", values);
}
if (coders.length !== arrayValues.length) {
logger_js_1.logger.throwArgumentError("types/value length mismatch", "tuple", values);
(0, index_js_1.throwArgumentError)("types/value length mismatch", "tuple", values);
}
let staticWriter = new abstract_coder_js_1.Writer();
let dynamicWriter = new abstract_coder_js_1.Writer();
@ -82,7 +80,7 @@ function unpack(reader, coders) {
}
catch (error) {
// Cannot recover from this
if ((0, errors_js_1.isError)(error, "BUFFER_OVERRUN")) {
if ((0, index_js_1.isError)(error, "BUFFER_OVERRUN")) {
throw error;
}
value = error;
@ -97,7 +95,7 @@ function unpack(reader, coders) {
}
catch (error) {
// Cannot recover from this
if ((0, errors_js_1.isError)(error, "BUFFER_OVERRUN")) {
if ((0, index_js_1.isError)(error, "BUFFER_OVERRUN")) {
throw error;
}
value = error;
@ -122,7 +120,7 @@ class ArrayCoder extends abstract_coder_js_1.Coder {
const type = (coder.type + "[" + (length >= 0 ? length : "") + "]");
const dynamic = (length === -1 || coder.dynamic);
super("array", type, localName, dynamic);
(0, properties_js_1.defineProperties)(this, { coder, length });
(0, index_js_1.defineProperties)(this, { coder, length });
}
defaultValue() {
// Verifies the child coder is valid (even if the array is dynamic or 0-length)
@ -143,7 +141,7 @@ class ArrayCoder extends abstract_coder_js_1.Coder {
count = value.length;
writer.writeValue(value.length);
}
logger_js_1.logger.assertArgumentCount(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : ""));
(0, index_js_1.assertArgumentCount)(value.length, count, "coder array" + (this.localName ? (" " + this.localName) : ""));
let coders = [];
for (let i = 0; i < value.length; i++) {
coders.push(this.coder);
@ -160,7 +158,7 @@ class ArrayCoder extends abstract_coder_js_1.Coder {
// bytes as a link to the data). This could use a much
// tighter bound, but we are erroring on the side of safety.
if (count * abstract_coder_js_1.WordSize > reader.dataLength) {
logger_js_1.logger.throwError("insufficient data length", "BUFFER_OVERRUN", {
(0, index_js_1.throwError)("insufficient data length", "BUFFER_OVERRUN", {
buffer: reader.bytes,
offset: count * abstract_coder_js_1.WordSize,
length: reader.dataLength

File diff suppressed because one or more lines are too long

@ -1,8 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BytesCoder = exports.DynamicBytesCoder = void 0;
const logger_js_1 = require("../../utils/logger.js");
const data_js_1 = require("../../utils/data.js");
const index_js_1 = require("../../utils/index.js");
const abstract_coder_js_1 = require("./abstract-coder.js");
class DynamicBytesCoder extends abstract_coder_js_1.Coder {
constructor(type, localName) {
@ -12,7 +11,7 @@ class DynamicBytesCoder extends abstract_coder_js_1.Coder {
return "0x";
}
encode(writer, value) {
value = logger_js_1.logger.getBytesCopy(value);
value = (0, index_js_1.getBytesCopy)(value);
let length = writer.writeValue(value.length);
length += writer.writeBytes(value);
return length;
@ -27,7 +26,7 @@ class BytesCoder extends DynamicBytesCoder {
super("bytes", localName);
}
decode(reader) {
return (0, data_js_1.hexlify)(super.decode(reader));
return (0, index_js_1.hexlify)(super.decode(reader));
}
}
exports.BytesCoder = BytesCoder;

@ -1 +1 @@
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../../src.ts/abi/coders/bytes.ts"],"names":[],"mappings":";;;AAAA,qDAA+C;AAC/C,iDAA8C;AAE9C,2DAA4C;AAK5C,MAAa,iBAAkB,SAAQ,yBAAK;IACxC,YAAY,IAAY,EAAE,SAAiB;QACxC,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,YAAY;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,KAAU;QAC7B,KAAK,GAAG,kBAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;Q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IAC7C,YAAY,SAAiB;QACzB,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,OAAO,IAAA,kBAAO,EAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACzC,CAAC;CACJ;AARD,gCAQC"}

@ -1,9 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FixedBytesCoder = void 0;
const logger_js_1 = require("../../utils/logger.js");
const data_js_1 = require("../../utils/data.js");
const properties_js_1 = require("../../utils/properties.js");
const index_js_1 = require("../../utils/index.js");
const typed_js_1 = require("../typed.js");
const abstract_coder_js_1 = require("./abstract-coder.js");
class FixedBytesCoder extends abstract_coder_js_1.Coder {
@ -11,20 +9,20 @@ class FixedBytesCoder extends abstract_coder_js_1.Coder {
constructor(size, localName) {
let name = "bytes" + String(size);
super(name, name, localName, false);
(0, properties_js_1.defineProperties)(this, { size }, { size: "number" });
(0, index_js_1.defineProperties)(this, { size }, { size: "number" });
}
defaultValue() {
return ("0x0000000000000000000000000000000000000000000000000000000000000000").substring(0, 2 + this.size * 2);
}
encode(writer, _value) {
let data = logger_js_1.logger.getBytesCopy(typed_js_1.Typed.dereference(_value, this.type));
let data = (0, index_js_1.getBytesCopy)(typed_js_1.Typed.dereference(_value, this.type));
if (data.length !== this.size) {
this._throwError("incorrect data length", _value);
}
return writer.writeBytes(data);
}
decode(reader) {
return (0, data_js_1.hexlify)(reader.readBytes(this.size));
return (0, index_js_1.hexlify)(reader.readBytes(this.size));
}
}
exports.FixedBytesCoder = FixedBytesCoder;

@ -1 +1 @@
{"version":3,"file":"fixed-bytes.js","sourceRoot":"","sources":["../../../src.ts/abi/coders/fixed-bytes.ts"],"names":[],"mappings":";;;AACA,qDAA+C;AAC/C,iDAA8C;AAC9C,6DAA6D;AAE7D,0CAAoC;AACpC,2DAA4C;AAO5C,MAAa,eAAgB,SAAQ,yBAAK;IAC7B,IAAI,CA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,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACpC,IAAA,2BAAgB,EAAkB,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,YAAY;QACR,OAAO,CAAC,oEAAoE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,MAAyB;QAC5C,IAAI,IAAI,GAAG,IAAA,uBAAY,EAAC,gBAAK,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9D,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE;YAAE,IAAI,CAAC,WAAW,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC;SAAE;QACrF,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,OAAO,IAAA,kBAAO,EAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AAtBD,0CAsBC"}

@ -1,9 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NumberCoder = void 0;
const maths_js_1 = require("../../utils/maths.js");
const properties_js_1 = require("../../utils/properties.js");
const logger_js_1 = require("../../utils/logger.js");
const index_js_1 = require("../../utils/index.js");
const typed_js_1 = require("../typed.js");
const abstract_coder_js_1 = require("./abstract-coder.js");
const BN_0 = BigInt(0);
@ -15,34 +13,34 @@ class NumberCoder extends abstract_coder_js_1.Coder {
constructor(size, signed, localName) {
const name = ((signed ? "int" : "uint") + (size * 8));
super(name, name, localName, false);
(0, properties_js_1.defineProperties)(this, { size, signed }, { size: "number", signed: "boolean" });
(0, index_js_1.defineProperties)(this, { size, signed }, { size: "number", signed: "boolean" });
}
defaultValue() {
return 0;
}
encode(writer, _value) {
let value = logger_js_1.logger.getBigInt(typed_js_1.Typed.dereference(_value, this.type));
let value = (0, index_js_1.getBigInt)(typed_js_1.Typed.dereference(_value, this.type));
// Check bounds are safe for encoding
let maxUintValue = (0, maths_js_1.mask)(BN_MAX_UINT256, abstract_coder_js_1.WordSize * 8);
let maxUintValue = (0, index_js_1.mask)(BN_MAX_UINT256, abstract_coder_js_1.WordSize * 8);
if (this.signed) {
let bounds = (0, maths_js_1.mask)(maxUintValue, (this.size * 8) - 1);
let bounds = (0, index_js_1.mask)(maxUintValue, (this.size * 8) - 1);
if (value > bounds || value < -(bounds + BN_1)) {
this._throwError("value out-of-bounds", _value);
}
}
else if (value < BN_0 || value > (0, maths_js_1.mask)(maxUintValue, this.size * 8)) {
else if (value < BN_0 || value > (0, index_js_1.mask)(maxUintValue, this.size * 8)) {
this._throwError("value out-of-bounds", _value);
}
value = (0, maths_js_1.mask)((0, maths_js_1.toTwos)(value, this.size * 8), this.size * 8);
value = (0, index_js_1.mask)((0, index_js_1.toTwos)(value, this.size * 8), this.size * 8);
if (this.signed) {
value = (0, maths_js_1.toTwos)((0, maths_js_1.fromTwos)(value, this.size * 8), 8 * abstract_coder_js_1.WordSize);
value = (0, index_js_1.toTwos)((0, index_js_1.fromTwos)(value, this.size * 8), 8 * abstract_coder_js_1.WordSize);
}
return writer.writeValue(value);
}
decode(reader) {
let value = (0, maths_js_1.mask)(reader.readValue(), this.size * 8);
let value = (0, index_js_1.mask)(reader.readValue(), this.size * 8);
if (this.signed) {
value = (0, maths_js_1.fromTwos)(value, this.size * 8);
value = (0, index_js_1.fromTwos)(value, this.size * 8);
}
return value;
}

@ -1 +1 @@
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../src.ts/abi/coders/number.ts"],"names":[],"mappings":";;;AAAA,mDAA8D;AAC9D,6DAA6D;AAE7D,qDAA+C;AAC/C,0CAAoC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AC,IAAI,GAAG,CAAC,CAAC,EAAE;YAClE,IAAI,CAAC,WAAW,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;SACnD;QAED,KAAK,GAAG,IAAA,eAAI,EAAC,IAAA,iBAAM,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;QAE1D,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,GAAG,IAAA,iBAAM,EAAC,IAAA,mBAAQ,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,4BAAQ,CAAC,CAAC;SAChE;QAED,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,IAAI,KAAK,GAAG,IAAA,eAAI,EAAC,MAAM,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;QAEpD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,KAAK,GAAG,IAAA,mBAAQ,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;SAC1C;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA/CD,kCA+CC"}

@ -1,20 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StructFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.ErrorFragment = exports.NamedFragment = exports.Fragment = exports.FragmentType = exports.ParamType = exports.lex = exports.TokenString = exports.FormatType = void 0;
const logger_js_1 = require("../utils/logger.js");
exports.StructFragment = exports.FunctionFragment = exports.ConstructorFragment = exports.EventFragment = exports.ErrorFragment = exports.NamedFragment = exports.Fragment = exports.ParamType = void 0;
const index_js_1 = require("../utils/index.js");
;
var FormatType;
(function (FormatType) {
// Bare formatting, as is needed for computing a sighash of an event or function
FormatType["sighash"] = "sighash";
// Human-Readable with Minimal spacing and without names (compact human-readable)
FormatType["minimal"] = "minimal";
// Human-Readable with nice spacing, including all names
FormatType["full"] = "full";
// JSON-format a la Solidity
FormatType["json"] = "json";
})(FormatType = exports.FormatType || (exports.FormatType = {}));
const index_js_2 = require("../hash/index.js");
;
// [ "a", "b" ] => { "a": 1, "b": 1 }
function setify(items) {
@ -140,7 +128,6 @@ class TokenString {
return `<TokenString ${tokens.join(" ")}>`;
}
}
exports.TokenString = TokenString;
function lex(text) {
const tokens = [];
const throwError = (message) => {
@ -193,7 +180,7 @@ function lex(text) {
if (tokens.length > 0 && tokens[tokens.length - 1].type === "NUMBER") {
const value = tokens.pop().text;
suffix = value + suffix;
(tokens[tokens.length - 1]).value = logger_js_1.logger.getNumber(value);
(tokens[tokens.length - 1]).value = (0, index_js_1.getNumber)(value);
}
if (tokens.length === 0 || tokens[tokens.length - 1].type !== "BRACKET") {
throw new Error("missing opening bracket");
@ -228,7 +215,6 @@ function lex(text) {
}
return new TokenString(tokens.map((t) => Object.freeze(t)));
}
exports.lex = lex;
// Check only one of `allowed` is in `set`
function allowSingle(set, allowed) {
let included = [];
@ -302,7 +288,7 @@ function consumeGas(tokens) {
if (tokens.peekType("AT")) {
tokens.pop();
if (tokens.peekType("NUMBER")) {
return logger_js_1.logger.getBigInt(tokens.pop().text);
return (0, index_js_1.getBigInt)(tokens.pop().text);
}
throw new Error("invalid gas");
}
@ -317,7 +303,7 @@ const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
function verifyBasicType(type) {
const match = type.match(regexType);
if (!match) {
return logger_js_1.logger.throwArgumentError("invalid type", "type", type);
return (0, index_js_1.throwArgumentError)("invalid type", "type", type);
}
if (type === "uint") {
return "uint256";
@ -329,14 +315,14 @@ function verifyBasicType(type) {
// bytesXX
const length = parseInt(match[2]);
if (length === 0 || length > 32) {
logger_js_1.logger.throwArgumentError("invalid bytes length", "type", type);
(0, index_js_1.throwArgumentError)("invalid bytes length", "type", type);
}
}
else if (match[3]) {
// intXX or uintXX
const size = parseInt(match[3]);
if (size === 0 || size > 256 || size % 8) {
logger_js_1.logger.throwArgumentError("invalid numeric width", "type", type);
(0, index_js_1.throwArgumentError)("invalid numeric width", "type", type);
}
}
return type;
@ -363,7 +349,7 @@ class ParamType {
arrayLength;
arrayChildren;
constructor(guard, name, type, baseType, indexed, components, arrayLength, arrayChildren) {
logger_js_1.logger.assertPrivate(guard, _guard, "ParamType");
(0, index_js_1.assertPrivate)(guard, _guard, "ParamType");
Object.defineProperty(this, internal, { value: ParamTypeInternal });
if (components) {
components = Object.freeze(components.slice());
@ -392,11 +378,8 @@ class ParamType {
// - sighash: "(uint256,address)"
// - minimal: "tuple(uint256,address) indexed"
// - full: "tuple(uint256 foo, address bar) indexed baz"
format(format = FormatType.sighash) {
if (!FormatType[format]) {
logger_js_1.logger.throwArgumentError("invalid format type", "format", format);
}
if (format === FormatType.json) {
format(format = "sighash") {
if (format === "json") {
let result = {
type: ((this.baseType === "tuple") ? "tuple" : this.type),
name: (this.name || undefined)
@ -417,20 +400,20 @@ class ParamType {
}
else {
if (this.isTuple()) {
if (format !== FormatType.sighash) {
if (format !== "sighash") {
result += this.type;
}
result += "(" + this.components.map((comp) => comp.format(format)).join((format === FormatType.full) ? ", " : ",") + ")";
result += "(" + this.components.map((comp) => comp.format(format)).join((format === "full") ? ", " : ",") + ")";
}
else {
result += this.type;
}
}
if (format !== FormatType.sighash) {
if (format !== "sighash") {
if (this.indexed === true) {
result += " indexed";
}
if (format === FormatType.full && this.name) {
if (format === "full" && this.name) {
result += " " + this.name;
}
}
@ -456,7 +439,8 @@ class ParamType {
if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
throw new Error("array is wrong length");
}
return value.map((v) => (this.arrayChildren.walk(v, process)));
const _this = this;
return value.map((v) => (_this.arrayChildren.walk(v, process)));
}
if (this.isTuple()) {
if (!Array.isArray(value)) {
@ -465,7 +449,8 @@ class ParamType {
if (value.length !== this.components.length) {
throw new Error("array is wrong length");
}
return value.map((v, i) => (this.components[i].walk(v, process)));
const _this = this;
return value.map((v, i) => (_this.components[i].walk(v, process)));
}
return process(this.type, value);
}
@ -550,12 +535,12 @@ class ParamType {
}
const name = obj.name;
if (name && (typeof (name) !== "string" || !name.match(regexIdentifier))) {
logger_js_1.logger.throwArgumentError("invalid name", "obj.name", name);
(0, index_js_1.throwArgumentError)("invalid name", "obj.name", name);
}
let indexed = obj.indexed;
if (indexed != null) {
if (!allowIndexed) {
logger_js_1.logger.throwArgumentError("parameter cannot be indexed", "obj.indexed", obj.indexed);
(0, index_js_1.throwArgumentError)("parameter cannot be indexed", "obj.indexed", obj.indexed);
}
indexed = !!indexed;
}
@ -625,20 +610,11 @@ class ParamType {
}
}
exports.ParamType = ParamType;
var FragmentType;
(function (FragmentType) {
FragmentType["constructor"] = "constructor";
FragmentType["error"] = "error";
FragmentType["event"] = "event";
FragmentType["function"] = "function";
FragmentType["struct"] = "struct";
})(FragmentType = exports.FragmentType || (exports.FragmentType = {}));
;
class Fragment {
type;
inputs;
constructor(guard, type, inputs) {
logger_js_1.logger.assertPrivate(guard, _guard, "Fragment");
(0, index_js_1.assertPrivate)(guard, _guard, "Fragment");
inputs = Object.freeze(inputs.slice());
(0, index_js_1.defineProperties)(this, { type, inputs });
}
@ -727,17 +703,17 @@ class NamedFragment extends Fragment {
}
exports.NamedFragment = NamedFragment;
function joinParams(format, params) {
return "(" + params.map((p) => p.format(format)).join((format === FormatType.full) ? ", " : ",") + ")";
return "(" + params.map((p) => p.format(format)).join((format === "full") ? ", " : ",") + ")";
}
class ErrorFragment extends NamedFragment {
constructor(guard, name, inputs) {
super(guard, FragmentType.error, name, inputs);
super(guard, "error", name, inputs);
}
format(format = FormatType.sighash) {
if (!FormatType[format]) {
logger_js_1.logger.throwArgumentError("invalid format type", "format", format);
}
if (format === FormatType.json) {
get selector() {
return (0, index_js_2.id)(this.format("sighash")).substring(0, 10);
}
format(format = "sighash") {
if (format === "json") {
return JSON.stringify({
type: "error",
name: this.name,
@ -745,7 +721,7 @@ class ErrorFragment extends NamedFragment {
});
}
const result = [];
if (format !== FormatType.sighash) {
if (format !== "sighash") {
result.push("error");
}
result.push(this.name + joinParams(format, this.inputs));
@ -765,14 +741,14 @@ exports.ErrorFragment = ErrorFragment;
class EventFragment extends NamedFragment {
anonymous;
constructor(guard, name, inputs, anonymous) {
super(guard, FragmentType.event, name, inputs);
super(guard, "event", name, inputs);
(0, index_js_1.defineProperties)(this, { anonymous });
}
format(format = FormatType.sighash) {
if (!FormatType[format]) {
logger_js_1.logger.throwArgumentError("invalid format type", "format", format);
}
if (format === FormatType.json) {
get topicHash() {
return (0, index_js_2.id)(this.format("sighash"));
}
format(format = "sighash") {
if (format === "json") {
return JSON.stringify({
type: "event",
anonymous: this.anonymous,
@ -781,11 +757,11 @@ class EventFragment extends NamedFragment {
});
}
const result = [];
if (format !== FormatType.sighash) {
if (format !== "sighash") {
result.push("event");
}
result.push(this.name + joinParams(format, this.inputs));
if (format !== FormatType.sighash && this.anonymous) {
if (format !== "sighash" && this.anonymous) {
result.push("anonymous");
}
return result.join(" ");
@ -809,16 +785,13 @@ class ConstructorFragment extends Fragment {
super(guard, type, inputs);
(0, index_js_1.defineProperties)(this, { payable, gas });
}
format(format = FormatType.sighash) {
if (!FormatType[format]) {
logger_js_1.logger.throwArgumentError("invalid format type", "format", format);
}
if (format === FormatType.sighash) {
logger_js_1.logger.throwError("cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", {
format(format = "sighash") {
if (format === "sighash") {
(0, index_js_1.throwError)("cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", {
operation: "format(sighash)"
});
}
if (format === FormatType.json) {
if (format === "json") {
return JSON.stringify({
type: "constructor",
stateMutability: (this.payable ? "payable" : "undefined"),
@ -846,7 +819,7 @@ class ConstructorFragment extends Fragment {
const payable = !!consumeKeywords(tokens, setify(["payable"])).has("payable");
const gas = consumeGas(tokens);
consumeEoi(tokens);
return new ConstructorFragment(_guard, FragmentType.constructor, inputs, payable, gas);
return new ConstructorFragment(_guard, "constructor", inputs, payable, gas);
}
}
exports.ConstructorFragment = ConstructorFragment;
@ -857,17 +830,17 @@ class FunctionFragment extends NamedFragment {
payable;
gas;
constructor(guard, name, stateMutability, inputs, outputs, gas) {
super(guard, FragmentType.function, name, inputs);
super(guard, "function", name, inputs);
outputs = Object.freeze(outputs.slice());
const constant = (stateMutability === "view" || stateMutability === "pure");
const payable = (stateMutability === "payable");
(0, index_js_1.defineProperties)(this, { constant, gas, outputs, payable, stateMutability });
}
format(format = FormatType.sighash) {
if (!FormatType[format]) {
logger_js_1.logger.throwArgumentError("invalid format type", "format", format);
}
if (format === FormatType.json) {
get selector() {
return (0, index_js_2.id)(this.format("sighash")).substring(0, 10);
}
format(format = "sighash") {
if (format === "json") {
return JSON.stringify({
type: "function",
name: this.name,
@ -880,11 +853,11 @@ class FunctionFragment extends NamedFragment {
});
}
const result = [];
if (format !== FormatType.sighash) {
if (format !== "sighash") {
result.push("function");
}
result.push(this.name + joinParams(format, this.inputs));
if (format !== FormatType.sighash) {
if (format !== "sighash") {
if (this.stateMutability !== "nonpayable") {
result.push(this.stateMutability);
}
@ -926,7 +899,7 @@ class StructFragment extends NamedFragment {
const name = consumeName("struct", tokens);
const inputs = consumeParams(tokens);
consumeEoi(tokens);
return new StructFragment(_guard, FragmentType.struct, name, inputs);
return new StructFragment(_guard, "struct", name, inputs);
}
}
exports.StructFragment = StructFragment;

File diff suppressed because one or more lines are too long

@ -1,6 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Typed = exports.TransactionDescription = exports.Result = exports.LogDescription = exports.Interface = exports.Indexed = exports.checkResultErrors = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.parseBytes32String = exports.formatBytes32String = exports.defaultAbiCoder = exports.AbiCoder = void 0;
exports.Typed = exports.Result = exports.TransactionDescription = exports.LogDescription = exports.ErrorDescription = exports.Interface = exports.Indexed = exports.checkResultErrors = exports.StructFragment = exports.ParamType = exports.NamedFragment = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.parseBytes32String = exports.formatBytes32String = exports.defaultAbiCoder = exports.AbiCoder = void 0;
//////
var abi_coder_js_1 = require("./abi-coder.js");
Object.defineProperty(exports, "AbiCoder", { enumerable: true, get: function () { return abi_coder_js_1.AbiCoder; } });
Object.defineProperty(exports, "defaultAbiCoder", { enumerable: true, get: function () { return abi_coder_js_1.defaultAbiCoder; } });
@ -13,14 +14,17 @@ Object.defineProperty(exports, "ErrorFragment", { enumerable: true, get: functio
Object.defineProperty(exports, "EventFragment", { enumerable: true, get: function () { return fragments_js_1.EventFragment; } });
Object.defineProperty(exports, "Fragment", { enumerable: true, get: function () { return fragments_js_1.Fragment; } });
Object.defineProperty(exports, "FunctionFragment", { enumerable: true, get: function () { return fragments_js_1.FunctionFragment; } });
Object.defineProperty(exports, "NamedFragment", { enumerable: true, get: function () { return fragments_js_1.NamedFragment; } });
Object.defineProperty(exports, "ParamType", { enumerable: true, get: function () { return fragments_js_1.ParamType; } });
Object.defineProperty(exports, "StructFragment", { enumerable: true, get: function () { return fragments_js_1.StructFragment; } });
var interface_js_1 = require("./interface.js");
Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return interface_js_1.checkResultErrors; } });
Object.defineProperty(exports, "Indexed", { enumerable: true, get: function () { return interface_js_1.Indexed; } });
Object.defineProperty(exports, "Interface", { enumerable: true, get: function () { return interface_js_1.Interface; } });
Object.defineProperty(exports, "ErrorDescription", { enumerable: true, get: function () { return interface_js_1.ErrorDescription; } });
Object.defineProperty(exports, "LogDescription", { enumerable: true, get: function () { return interface_js_1.LogDescription; } });
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return interface_js_1.Result; } });
Object.defineProperty(exports, "TransactionDescription", { enumerable: true, get: function () { return interface_js_1.TransactionDescription; } });
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return interface_js_1.Result; } });
var typed_js_1 = require("./typed.js");
Object.defineProperty(exports, "Typed", { enumerable: true, get: function () { return typed_js_1.Typed; } });
//# sourceMappingURL=index.js.map

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":";;;AACA,+CAGwB;AAFpB,wGAAA,QAAQ,OAAA;AACR,+GAAA,eAAe,OAAA;AAGnB,2CAAuE;AAA9D,iHAAA,mBAAmB,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AAEhD,+CAOwB;AANpB,mHAAA,mBAAmB,OAAA;AACnB,6GAAA,aAAa,OAAA;AACb,6GAAA,aAAa,OAAA;AACb,wGAAA,QAAQ,OAAA;AACR,gHAAA,gBAAgB,OAAA;AAChB,yGAAA,SAAS,OAAA;AAGb,+CAOwB;AANpB,iHAAA,iBAAiB,OAAA;AACjB,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,8GAAA,cAAc,OAAA;AACd,sGAAA,MAAM,OAAA;AACN,sHAAA,sBAAsB,OAAA;AAG1B,uCAAmC;AAA1B,iGAAA,KAAK,OAAA"}
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/abi/index.ts"],"names":[],"mappings":";;;AAGA,MAAM;AACN,+CAGwB;AAFpB,wGAAA,QAAQ,OAAA;AACR,+GAAA,eAAe,OAAA;AAGnB,2CAAuE;AAA9D,iHAAA,mBAAmB,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AAEhD,+CAGwB;AAFpB,mHAAA,mBAAmB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAC3D,gHAAA,gBAAgB,OAAA;AAAE,6GAAA,aAAa,OAAA;AAAE,yGAAA,SAAS,OAAA;AAAE,8GAAA,cAAc,OAAA;AAG9D,+CAMwB;AALpB,iHAAA,iBAAiB,OAAA;AACjB,uGAAA,OAAO,OAAA;AACP,yGAAA,SAAS,OAAA;AACT,gHAAA,gBAAgB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,sHAAA,sBAAsB,OAAA;AACxD,sGAAA,MAAM,OAAA;AAGV,uCAAmC;AAA1B,iGAAA,KAAK,OAAA"}

@ -1,12 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Interface = exports.Indexed = exports.ErrorDescription = exports.TransactionDescription = exports.LogDescription = exports.Result = exports.checkResultErrors = void 0;
const data_js_1 = require("../utils/data.js");
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../hash/index.js");
const logger_js_1 = require("../utils/logger.js");
const properties_js_1 = require("../utils/properties.js");
const maths_js_1 = require("../utils/maths.js");
const index_js_3 = require("../utils/index.js");
const abi_coder_js_1 = require("./abi-coder.js");
const abstract_coder_js_1 = require("./coders/abstract-coder.js");
Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return abstract_coder_js_1.checkResultErrors; } });
@ -21,7 +18,7 @@ class LogDescription {
args;
constructor(fragment, topic, args) {
const name = fragment.name, signature = fragment.format();
(0, properties_js_1.defineProperties)(this, {
(0, index_js_3.defineProperties)(this, {
fragment, name, signature, topic, args
});
}
@ -36,7 +33,7 @@ class TransactionDescription {
value;
constructor(fragment, selector, args, value) {
const name = fragment.name, signature = fragment.format();
(0, properties_js_1.defineProperties)(this, {
(0, index_js_3.defineProperties)(this, {
fragment, name, args, signature, selector, value
});
}
@ -50,7 +47,7 @@ class ErrorDescription {
selector;
constructor(fragment, selector, args) {
const name = fragment.name, signature = fragment.format();
(0, properties_js_1.defineProperties)(this, {
(0, index_js_3.defineProperties)(this, {
fragment, name, args, signature, selector
});
}
@ -63,7 +60,7 @@ class Indexed {
return !!(value && value._isIndexed);
}
constructor(hash) {
(0, properties_js_1.defineProperties)(this, { hash, _isIndexed: true });
(0, index_js_3.defineProperties)(this, { hash, _isIndexed: true });
}
}
exports.Indexed = Indexed;
@ -103,7 +100,13 @@ const BuiltinErrors = {
}
};
class Interface {
/**
* All the Contract ABI members (i.e. methods, events, errors, etc).
*/
fragments;
/**
* The Contract constructor.
*/
deploy;
#errors;
#events;
@ -122,7 +125,7 @@ class Interface {
this.#errors = new Map();
this.#events = new Map();
// this.#structs = new Map();
(0, properties_js_1.defineProperties)(this, {
(0, index_js_3.defineProperties)(this, {
fragments: Object.freeze(abi.map((f) => fragments_js_1.Fragment.from(f)).filter((f) => (f != null))),
});
this.#abiCoder = this.getAbiCoder();
@ -132,11 +135,11 @@ class Interface {
switch (fragment.type) {
case "constructor":
if (this.deploy) {
logger_js_1.logger.warn("duplicate definition - constructor");
console.log("duplicate definition - constructor");
return;
}
//checkNames(fragment, "input", fragment.inputs);
(0, properties_js_1.defineProperties)(this, { deploy: fragment });
(0, index_js_3.defineProperties)(this, { deploy: fragment });
return;
case "function":
//checkNames(fragment, "input", fragment.inputs);
@ -153,58 +156,57 @@ class Interface {
default:
return;
}
// Two identical entries; ignore it
const signature = fragment.format();
if (bucket.has(signature)) {
logger_js_1.logger.warn("duplicate definition - " + signature);
return;
}
bucket.set(signature, fragment);
});
// If we do not have a constructor add a default
if (!this.deploy) {
(0, properties_js_1.defineProperties)(this, {
(0, index_js_3.defineProperties)(this, {
deploy: fragments_js_1.ConstructorFragment.fromString("constructor()")
});
}
}
// @TODO: multi sig?
format(format) {
if (!format) {
format = fragments_js_1.FormatType.full;
}
if (format === fragments_js_1.FormatType.sighash) {
logger_js_1.logger.throwArgumentError("interface does not support formatting sighash", "format", format);
}
/**
* Returns the entire Human-Readable ABI, as an array of
* signatures, optionally as %%minimal%% strings, which
* removes parameter names and unneceesary spaces.
*/
format(minimal) {
const format = (minimal ? "minimal" : "full");
const abi = this.fragments.map((f) => f.format(format));
// We need to re-bundle the JSON fragments a bit
if (format === fragments_js_1.FormatType.json) {
return JSON.stringify(abi.map((j) => JSON.parse(j)));
}
return abi;
}
/**
* Return the JSON-encoded ABI. This is the format Solidiy
* returns.
*/
formatJson() {
const abi = this.fragments.map((f) => f.format("json"));
// We need to re-bundle the JSON fragments a bit
return JSON.stringify(abi.map((j) => JSON.parse(j)));
}
/**
* The ABI coder that will be used to encode and decode binary
* data.
*/
getAbiCoder() {
return abi_coder_js_1.defaultAbiCoder;
}
//static getAddress(address: string): string {
// return getAddress(address);
//}
//static getSelector(fragment: ErrorFragment | FunctionFragment): string {
// return dataSlice(id(fragment.format()), 0, 4);
//}
//static getEventTopic(eventFragment: EventFragment): string {
// return id(eventFragment.format());
//}
// Find a function definition by any means necessary (unless it is ambiguous)
#getFunction(key, values, forceUnique) {
// Selector
if ((0, data_js_1.isHexString)(key)) {
if ((0, index_js_3.isHexString)(key)) {
const selector = key.toLowerCase();
for (const fragment of this.#functions.values()) {
if (selector === this.getSelector(fragment)) {
if (selector === fragment.selector) {
return fragment;
}
}
logger_js_1.logger.throwArgumentError("no matching function", "selector", key);
(0, index_js_3.throwArgumentError)("no matching function", "selector", key);
}
// It is a bare name, look up the function (will return null if ambiguous)
if (key.indexOf("(") === -1) {
@ -263,11 +265,11 @@ class Interface {
}
}
if (matching.length === 0) {
logger_js_1.logger.throwArgumentError("no matching function", "name", key);
(0, index_js_3.throwArgumentError)("no matching function", "name", key);
}
else if (matching.length > 1 && forceUnique) {
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
logger_js_1.logger.throwArgumentError(`multiple matching functions (i.e. ${matchStr})`, "name", key);
(0, index_js_3.throwArgumentError)(`multiple matching functions (i.e. ${matchStr})`, "name", key);
}
return matching[0];
}
@ -276,25 +278,39 @@ class Interface {
if (result) {
return result;
}
return logger_js_1.logger.throwArgumentError("no matching function", "signature", key);
return (0, index_js_3.throwArgumentError)("no matching function", "signature", key);
}
/**
* Get the function name for %%key%%, which may be a function selector,
* function name or function signature that belongs to the ABI.
*/
getFunctionName(key) {
return (this.#getFunction(key, null, false)).name;
}
/**
* Get the [[FunctionFragment]] for %%key%%, which may be a function
* selector, function name or function signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple functions match by name.
*
* If the %%key%% and %%values%% do not refine to a single function in
* the ABI, this will throw.
*/
getFunction(key, values) {
return this.#getFunction(key, values || null, true);
}
// Find an event definition by any means necessary (unless it is ambiguous)
#getEvent(key, values, forceUnique) {
// EventTopic
if ((0, data_js_1.isHexString)(key)) {
if ((0, index_js_3.isHexString)(key)) {
const eventTopic = key.toLowerCase();
for (const fragment of this.#events.values()) {
if (eventTopic === this.getEventTopic(fragment)) {
if (eventTopic === fragment.topicHash) {
return fragment;
}
}
logger_js_1.logger.throwArgumentError("no matching event", "eventTopic", key);
(0, index_js_3.throwArgumentError)("no matching event", "eventTopic", key);
}
// It is a bare name, look up the function (will return null if ambiguous)
if (key.indexOf("(") === -1) {
@ -328,11 +344,11 @@ class Interface {
}
}
if (matching.length === 0) {
logger_js_1.logger.throwArgumentError("no matching event", "name", key);
(0, index_js_3.throwArgumentError)("no matching event", "name", key);
}
else if (matching.length > 1 && forceUnique) {
// @TODO: refine by Typed
logger_js_1.logger.throwArgumentError("multiple matching events", "name", key);
(0, index_js_3.throwArgumentError)("multiple matching events", "name", key);
}
return matching[0];
}
@ -341,27 +357,50 @@ class Interface {
if (result) {
return result;
}
return logger_js_1.logger.throwArgumentError("no matching event", "signature", key);
return (0, index_js_3.throwArgumentError)("no matching event", "signature", key);
}
/**
* Get the event name for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*/
getEventName(key) {
return (this.#getEvent(key, null, false)).name;
}
/**
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
* event name or event signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple events match by name.
*
* If the %%key%% and %%values%% do not refine to a single event in
* the ABI, this will throw.
*/
getEvent(key, values) {
return this.#getEvent(key, values || null, true);
}
// Find a function definition by any means necessary (unless it is ambiguous)
/**
* Get the [[ErrorFragment]] for %%key%%, which may be an error
* selector, error name or error signature that belongs to the ABI.
*
* If %%values%% is provided, it will use the Typed API to handle
* ambiguous cases where multiple errors match by name.
*
* If the %%key%% and %%values%% do not refine to a single error in
* the ABI, this will throw.
*/
getError(key, values) {
if ((0, data_js_1.isHexString)(key)) {
if ((0, index_js_3.isHexString)(key)) {
const selector = key.toLowerCase();
if (BuiltinErrors[selector]) {
return fragments_js_1.ErrorFragment.fromString(BuiltinErrors[selector].signature);
}
for (const fragment of this.#errors.values()) {
if (selector === this.getSelector(fragment)) {
if (selector === fragment.selector) {
return fragment;
}
}
logger_js_1.logger.throwArgumentError("no matching error", "selector", key);
(0, index_js_3.throwArgumentError)("no matching error", "selector", key);
}
// It is a bare name, look up the function (will return null if ambiguous)
if (key.indexOf("(") === -1) {
@ -378,11 +417,11 @@ class Interface {
if (key === "Panic") {
return fragments_js_1.ErrorFragment.fromString("error Panic(uint256)");
}
logger_js_1.logger.throwArgumentError("no matching error", "name", key);
(0, index_js_3.throwArgumentError)("no matching error", "name", key);
}
else if (matching.length > 1) {
// @TODO: refine by Typed
logger_js_1.logger.throwArgumentError("multiple matching errors", "name", key);
(0, index_js_3.throwArgumentError)("multiple matching errors", "name", key);
}
return matching[0];
}
@ -398,87 +437,124 @@ class Interface {
if (result) {
return result;
}
return logger_js_1.logger.throwArgumentError("no matching error", "signature", key);
return (0, index_js_3.throwArgumentError)("no matching error", "signature", key);
}
// Get the 4-byte selector used by Solidity to identify a function
getSelector(fragment) {
/*
if (typeof(fragment) === "string") {
const matches: Array<Fragment> = [ ];
/*
getSelector(fragment: ErrorFragment | FunctionFragment): string {
if (typeof(fragment) === "string") {
const matches: Array<Fragment> = [ ];
try { matches.push(this.getFunction(fragment)); } catch (error) { }
try { matches.push(this.getError(<string>fragment)); } catch (_) { }
try { matches.push(this.getFunction(fragment)); } catch (error) { }
try { matches.push(this.getError(<string>fragment)); } catch (_) { }
if (matches.length === 0) {
logger.throwArgumentError("unknown fragment", "key", fragment);
} else if (matches.length > 1) {
logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment);
}
fragment = matches[0];
if (matches.length === 0) {
logger.throwArgumentError("unknown fragment", "key", fragment);
} else if (matches.length > 1) {
logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment);
}
*/
return (0, data_js_1.dataSlice)((0, index_js_2.id)(fragment.format()), 0, 4);
fragment = matches[0];
}
return dataSlice(id(fragment.format()), 0, 4);
}
*/
// Get the 32-byte topic hash used by Solidity to identify an event
getEventTopic(fragment) {
/*
getEventTopic(fragment: EventFragment): string {
//if (typeof(fragment) === "string") { fragment = this.getEvent(eventFragment); }
return (0, index_js_2.id)(fragment.format());
return id(fragment.format());
}
*/
_decodeParams(params, data) {
return this.#abiCoder.decode(params, data);
}
_encodeParams(params, values) {
return this.#abiCoder.encode(params, values);
}
/**
* Encodes a ``tx.data`` object for deploying the Contract with
* the %%values%% as the constructor arguments.
*/
encodeDeploy(values) {
return this._encodeParams(this.deploy.inputs, values || []);
}
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeErrorResult(fragment, data) {
if (typeof (fragment) === "string") {
fragment = this.getError(fragment);
}
if ((0, data_js_1.dataSlice)(data, 0, 4) !== this.getSelector(fragment)) {
logger_js_1.logger.throwArgumentError(`data signature does not match error ${fragment.name}.`, "data", data);
if ((0, index_js_3.dataSlice)(data, 0, 4) !== fragment.selector) {
(0, index_js_3.throwArgumentError)(`data signature does not match error ${fragment.name}.`, "data", data);
}
return this._decodeParams(fragment.inputs, (0, data_js_1.dataSlice)(data, 4));
return this._decodeParams(fragment.inputs, (0, index_js_3.dataSlice)(data, 4));
}
encodeErrorResult(fragment, values) {
if (typeof (fragment) === "string") {
fragment = this.getError(fragment);
}
return (0, data_js_1.concat)([
this.getSelector(fragment),
/**
* Encodes the transaction revert data for a call result that
* reverted from the the Contract with the sepcified %%error%%
* (see [[getError]] for valid values for %%key%%) with the %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeErrorResult(key, values) {
const fragment = (typeof (key) === "string") ? this.getError(key) : key;
return (0, index_js_3.concat)([
fragment.selector,
this._encodeParams(fragment.inputs, values || [])
]);
}
// Decode the data for a function call (e.g. tx.data)
decodeFunctionData(fragment, data) {
if (typeof (fragment) === "string") {
fragment = this.getFunction(fragment);
/**
* Decodes the %%data%% from a transaction ``tx.data`` for
* the function specified (see [[getFunction]] for valid values
* for %%key%%).
*
* Most developers should prefer the [[parseTransaction]] method
* instead, which will automatically detect the fragment.
*/
decodeFunctionData(key, data) {
const fragment = (typeof (key) === "string") ? this.getFunction(key) : key;
if ((0, index_js_3.dataSlice)(data, 0, 4) !== fragment.selector) {
(0, index_js_3.throwArgumentError)(`data signature does not match function ${fragment.name}.`, "data", data);
}
if ((0, data_js_1.dataSlice)(data, 0, 4) !== this.getSelector(fragment)) {
logger_js_1.logger.throwArgumentError(`data signature does not match function ${fragment.name}.`, "data", data);
}
return this._decodeParams(fragment.inputs, (0, data_js_1.dataSlice)(data, 4));
return this._decodeParams(fragment.inputs, (0, index_js_3.dataSlice)(data, 4));
}
// Encode the data for a function call (e.g. tx.data)
encodeFunctionData(fragment, values) {
if (typeof (fragment) === "string") {
fragment = this.getFunction(fragment);
}
return (0, data_js_1.concat)([
this.getSelector(fragment),
/**
* Encodes the ``tx.data`` for a transaction that calls the function
* specified (see [[getFunction]] for valid values for %%key%%) with
* the %%values%%.
*/
encodeFunctionData(key, values) {
const fragment = (typeof (key) === "string") ? this.getFunction(key) : key;
return (0, index_js_3.concat)([
fragment.selector,
this._encodeParams(fragment.inputs, values || [])
]);
}
// Decode the result from a function call (e.g. from eth_call)
/**
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
decodeFunctionResult(fragment, data) {
if (typeof (fragment) === "string") {
fragment = this.getFunction(fragment);
}
let message = "invalid length for result data";
const bytes = logger_js_1.logger.getBytesCopy(data);
const bytes = (0, index_js_3.getBytesCopy)(data);
if ((bytes.length % 32) === 0) {
try {
return this.#abiCoder.decode(fragment.outputs, bytes);
@ -488,8 +564,8 @@ class Interface {
}
}
// Call returned data with no error, but the data is junk
return logger_js_1.logger.throwError(message, "BAD_DATA", {
value: (0, data_js_1.hexlify)(bytes),
return (0, index_js_3.throwError)(message, "BAD_DATA", {
value: (0, index_js_3.hexlify)(bytes),
info: { method: fragment.name, signature: fragment.format() }
});
}
@ -497,7 +573,7 @@ class Interface {
if (typeof (fragment) === "string") {
fragment = this.getFunction(fragment);
}
const data = logger_js_1.logger.getBytes(_data);
const data = (0, index_js_3.getBytes)(_data);
let args = undefined;
if (tx) {
try {
@ -515,7 +591,7 @@ class Interface {
reason = "missing error reason";
}
else if ((data.length % 32) === 4) {
const selector = (0, data_js_1.hexlify)(data.slice(0, 4));
const selector = (0, index_js_3.hexlify)(data.slice(0, 4));
const builtin = BuiltinErrors[selector];
if (builtin) {
try {
@ -547,18 +623,23 @@ class Interface {
}
}
}
return logger_js_1.logger.makeError("call revert exception", "CALL_EXCEPTION", {
data: (0, data_js_1.hexlify)(data), transaction: null,
return (0, index_js_3.makeError)("call revert exception", "CALL_EXCEPTION", {
data: (0, index_js_3.hexlify)(data), transaction: null,
method: fragment.name, signature: fragment.format(), args,
errorArgs, errorName, errorSignature, reason
});
}
// Encode the result for a function call (e.g. for eth_call)
encodeFunctionResult(functionFragment, values) {
if (typeof (functionFragment) === "string") {
functionFragment = this.getFunction(functionFragment);
}
return (0, data_js_1.hexlify)(this.#abiCoder.encode(functionFragment.outputs, values || []));
/**
* Encodes the result data (e.g. from an ``eth_call``) for the
* specified function (see [[getFunction]] for valid values
* for %%key%%) with %%values%%.
*
* This is generally not used by most developers, unless trying to mock
* a result from a Contract.
*/
encodeFunctionResult(key, values) {
const fragment = (typeof (key) === "string") ? this.getFunction(key) : key;
return (0, index_js_3.hexlify)(this.#abiCoder.encode(fragment.outputs, values || []));
}
/*
spelunk(inputs: Array<ParamType>, values: ReadonlyArray<any>, processfunc: (type: string, value: any) => Promise<any>): Promise<Array<any>> {
@ -596,14 +677,14 @@ class Interface {
eventFragment = this.getEvent(eventFragment);
}
if (values.length > eventFragment.inputs.length) {
logger_js_1.logger.throwError("too many arguments for " + eventFragment.format(), "UNEXPECTED_ARGUMENT", {
(0, index_js_3.throwError)("too many arguments for " + eventFragment.format(), "UNEXPECTED_ARGUMENT", {
count: values.length,
expectedCount: eventFragment.inputs.length
});
}
const topics = [];
if (!eventFragment.anonymous) {
topics.push(this.getEventTopic(eventFragment));
topics.push(eventFragment.topicHash);
}
// @TODO: Use the coders for this; to properly support tuples, etc.
const encodeTopic = (param, value) => {
@ -611,26 +692,26 @@ class Interface {
return (0, index_js_2.id)(value);
}
else if (param.type === "bytes") {
return (0, index_js_1.keccak256)((0, data_js_1.hexlify)(value));
return (0, index_js_1.keccak256)((0, index_js_3.hexlify)(value));
}
if (param.type === "bool" && typeof (value) === "boolean") {
value = (value ? "0x01" : "0x00");
}
if (param.type.match(/^u?int/)) {
value = (0, maths_js_1.toHex)(value);
value = (0, index_js_3.toHex)(value);
}
// Check addresses are valid
if (param.type === "address") {
this.#abiCoder.encode(["address"], [value]);
}
return (0, data_js_1.zeroPadValue)((0, data_js_1.hexlify)(value), 32);
return (0, index_js_3.zeroPadValue)((0, index_js_3.hexlify)(value), 32);
//@TOOD should probably be return toHex(value, 32)
};
values.forEach((value, index) => {
const param = eventFragment.inputs[index];
if (!param.indexed) {
if (value != null) {
logger_js_1.logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
(0, index_js_3.throwArgumentError)("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
}
return;
}
@ -638,7 +719,7 @@ class Interface {
topics.push(null);
}
else if (param.baseType === "array" || param.baseType === "tuple") {
logger_js_1.logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
(0, index_js_3.throwArgumentError)("filtering with tuples or arrays not supported", ("contract." + param.name), value);
}
else if (Array.isArray(value)) {
topics.push(value.map((value) => encodeTopic(param, value)));
@ -661,10 +742,10 @@ class Interface {
const dataTypes = [];
const dataValues = [];
if (!eventFragment.anonymous) {
topics.push(this.getEventTopic(eventFragment));
topics.push(eventFragment.topicHash);
}
if (values.length !== eventFragment.inputs.length) {
logger_js_1.logger.throwArgumentError("event arguments/values mismatch", "values", values);
(0, index_js_3.throwArgumentError)("event arguments/values mismatch", "values", values);
}
eventFragment.inputs.forEach((param, index) => {
const value = values[index];
@ -699,9 +780,9 @@ class Interface {
eventFragment = this.getEvent(eventFragment);
}
if (topics != null && !eventFragment.anonymous) {
const eventTopic = this.getEventTopic(eventFragment);
if (!(0, data_js_1.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== eventTopic) {
logger_js_1.logger.throwArgumentError("fragment/topic mismatch", "topics[0]", topics[0]);
const eventTopic = eventFragment.topicHash;
if (!(0, index_js_3.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== eventTopic) {
(0, index_js_3.throwArgumentError)("fragment/topic mismatch", "topics[0]", topics[0]);
}
topics = topics.slice(1);
}
@ -724,7 +805,7 @@ class Interface {
dynamic.push(false);
}
});
const resultIndexed = (topics != null) ? this.#abiCoder.decode(indexed, (0, data_js_1.concat)(topics)) : null;
const resultIndexed = (topics != null) ? this.#abiCoder.decode(indexed, (0, index_js_3.concat)(topics)) : null;
const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data, true);
//const result: (Array<any> & { [ key: string ]: any }) = [ ];
const values = [];
@ -761,22 +842,31 @@ class Interface {
});
return abstract_coder_js_1.Result.fromItems(values, keys);
}
// Given a transaction, find the matching function fragment (if any) and
// determine all its properties and call parameters
/**
* Parses a transaction, finding the matching function and extracts
* the parameter values along with other useful function details.
*
* If the matching function cannot be found, return null.
*/
parseTransaction(tx) {
const data = logger_js_1.logger.getBytes(tx.data, "tx.data");
const value = logger_js_1.logger.getBigInt((tx.value != null) ? tx.value : 0, "tx.value");
const fragment = this.getFunction((0, data_js_1.hexlify)(data.slice(0, 4)));
const data = (0, index_js_3.getBytes)(tx.data, "tx.data");
const value = (0, index_js_3.getBigInt)((tx.value != null) ? tx.value : 0, "tx.value");
const fragment = this.getFunction((0, index_js_3.hexlify)(data.slice(0, 4)));
if (!fragment) {
return null;
}
const args = this.#abiCoder.decode(fragment.inputs, data.slice(4));
return new TransactionDescription(fragment, this.getSelector(fragment), args, value);
return new TransactionDescription(fragment, fragment.selector, args, value);
}
// @TODO
//parseCallResult(data: BytesLike): ??
// Given an event log, find the matching event fragment (if any) and
// determine all its properties and values
parseCallResult(data) {
throw new Error("@TODO");
}
/**
* Parses a receipt log, finding the matching event and extracts
* the parameter values along with other useful event details.
*
* If the matching event cannot be found, returns null.
*/
parseLog(log) {
const fragment = this.getEvent(log.topics[0]);
if (!fragment || fragment.anonymous) {
@ -785,17 +875,29 @@ class Interface {
// @TODO: If anonymous, and the only method, and the input count matches, should we parse?
// Probably not, because just because it is the only event in the ABI does
// not mean we have the full ABI; maybe just a fragment?
return new LogDescription(fragment, this.getEventTopic(fragment), this.decodeEventLog(fragment, log.data, log.topics));
return new LogDescription(fragment, fragment.topicHash, this.decodeEventLog(fragment, log.data, log.topics));
}
/**
* Parses a revert data, finding the matching error and extracts
* the parameter values along with other useful error details.
*
* If the matching event cannot be found, returns null.
*/
parseError(data) {
const hexData = (0, data_js_1.hexlify)(data);
const fragment = this.getError((0, data_js_1.dataSlice)(hexData, 0, 4));
const hexData = (0, index_js_3.hexlify)(data);
const fragment = this.getError((0, index_js_3.dataSlice)(hexData, 0, 4));
if (!fragment) {
return null;
}
const args = this.#abiCoder.decode(fragment.inputs, (0, data_js_1.dataSlice)(hexData, 4));
return new ErrorDescription(fragment, this.getSelector(fragment), args);
const args = this.#abiCoder.decode(fragment.inputs, (0, index_js_3.dataSlice)(hexData, 4));
return new ErrorDescription(fragment, fragment.selector, args);
}
/**
* Creates a new [[Interface]] from the ABI %%value%%.
*
* The %%value%% may be provided as an existing [[Interface]] object,
* a JSON-encoded ABI or any Human-Readable ABI format.
*/
static from(value) {
// Already an Interface, which is immutable
if (value instanceof Interface) {
@ -807,7 +909,7 @@ class Interface {
}
// Maybe an interface from an older version, or from a symlinked copy
if (typeof (value.format) === "function") {
return new Interface(value.format(fragments_js_1.FormatType.json));
return new Interface(value.format("json"));
}
// Array of fragments
return new Interface(value);

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Typed = void 0;
const properties_js_1 = require("../utils/properties.js");
const index_js_1 = require("../utils/index.js");
const _gaurd = {};
function n(value, width) {
let signed = false;
@ -26,7 +26,7 @@ class Typed {
if (gaurd !== _gaurd) {
throw new Error("private constructor");
}
(0, properties_js_1.defineProperties)(this, { _typedSymbol, type, value });
(0, index_js_1.defineProperties)(this, { _typedSymbol, type, value });
this.#options = options;
// Check the value is valid
this.format();

File diff suppressed because one or more lines are too long

@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIcapAddress = exports.getAddress = void 0;
const keccak_js_1 = require("../crypto/keccak.js");
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../utils/index.js");
const BN_0 = BigInt(0);
const BN_36 = BigInt(36);
function getChecksumAddress(address) {
@ -15,7 +15,7 @@ function getChecksumAddress(address) {
for (let i = 0; i < 40; i++) {
expanded[i] = chars[i].charCodeAt(0);
}
const hashed = logger_js_1.logger.getBytes((0, keccak_js_1.keccak256)(expanded));
const hashed = (0, index_js_2.getBytes)((0, index_js_1.keccak256)(expanded));
for (let i = 0; i < 40; i += 2) {
if ((hashed[i >> 1] >> 4) >= 8) {
chars[i] = chars[i].toUpperCase();
@ -73,7 +73,7 @@ function fromBase36(value) {
}
function getAddress(address) {
if (typeof (address) !== "string") {
logger_js_1.logger.throwArgumentError("invalid address", "address", address);
(0, index_js_2.throwArgumentError)("invalid address", "address", address);
}
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
// Missing the 0x prefix
@ -83,7 +83,7 @@ function getAddress(address) {
const result = getChecksumAddress(address);
// It is a checksummed address with a bad checksum
if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
logger_js_1.logger.throwArgumentError("bad address checksum", "address", address);
(0, index_js_2.throwArgumentError)("bad address checksum", "address", address);
}
return result;
}
@ -91,7 +91,7 @@ function getAddress(address) {
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
// It is an ICAP address with a bad checksum
if (address.substring(2, 4) !== ibanChecksum(address)) {
logger_js_1.logger.throwArgumentError("bad icap checksum", "address", address);
(0, index_js_2.throwArgumentError)("bad icap checksum", "address", address);
}
let result = fromBase36(address.substring(4)).toString(16);
while (result.length < 40) {
@ -99,7 +99,7 @@ function getAddress(address) {
}
return getChecksumAddress("0x" + result);
}
return logger_js_1.logger.throwArgumentError("invalid address", "address", address);
return (0, index_js_2.throwArgumentError)("invalid address", "address", address);
}
exports.getAddress = getAddress;
function getIcapAddress(address) {

@ -1 +1 @@
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src.ts/address/address.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,kDAA4C;AAG5C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AACvB,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzB,SAAS,kBAAkB,CAAC,OAAe;IAC3C,sCAAsC;IACtC,2EAA2E;IAC3E,OAAO;IAEH,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEhC,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAE7C,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;I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"__esModule", { value: true });
exports.resolveAddress = exports.isAddress = exports.isAddressable = void 0;
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../utils/index.js");
const address_js_1 = require("./address.js");
function isAddressable(value) {
return (value && typeof (value.getAddress) === "function");
@ -20,9 +20,9 @@ async function checkAddress(target, promise) {
const result = await promise;
if (result == null || result === "0x0000000000000000000000000000000000000000") {
if (typeof (target) === "string") {
return logger_js_1.logger.throwError("unconfigured name", "UNCONFIGURED_NAME", { value: target });
return (0, index_js_1.throwError)("unconfigured name", "UNCONFIGURED_NAME", { value: target });
}
return logger_js_1.logger.throwArgumentError("invalid AddressLike value; did not resolve to a value address", "target", target);
return (0, index_js_1.throwArgumentError)("invalid AddressLike value; did not resolve to a value address", "target", target);
}
return (0, address_js_1.getAddress)(result);
}
@ -34,7 +34,7 @@ function resolveAddress(target, resolver) {
return (0, address_js_1.getAddress)(target);
}
if (resolver == null) {
return logger_js_1.logger.throwError("ENS resolution requires a provider", "UNSUPPORTED_OPERATION", {
return (0, index_js_1.throwError)("ENS resolution requires a provider", "UNSUPPORTED_OPERATION", {
operation: "resolveName",
});
}
@ -46,7 +46,7 @@ function resolveAddress(target, resolver) {
else if (typeof (target.then) === "function") {
return checkAddress(target, target);
}
return logger_js_1.logger.throwArgumentError("unsupported addressable value", "target", target);
return (0, index_js_1.throwArgumentError)("unsupported addressable value", "target", target);
}
exports.resolveAddress = resolveAddress;
//# sourceMappingURL=checks.js.map

@ -1 +1 @@
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src.ts/address/checks.ts"],"names":[],"mappings":";;;AAAA,kDAA4C;AAE5C,6CAA0C;AAK1C,SAAgB,aAAa,CAAC,KAAU;IACpC,OAAO,CAAC,KAAK,IAAI,OAAM,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC,CAAC;AAC9D,CAAC;AAFD,sCAEC;AAED,SAAgB,SAAS,CAAC,KAAU;IAChC,IAAI;QACA,IAAA,uBAAU,EAAC,KAAK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AAK,QAAQ,EAAE;QAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;YAAE,OAAO,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;SAAE;QAErE,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,OAAO,IAAA,qBAAU,EAAC,oCAAoC,EAAE,uBAAuB,EAAE;gBAC7E,SAAS,EAAE,aAAa;aAC3B,CAAC,CAAC;SACN;QAED,OAAO,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;KAE7D;SAAM,IAAI,aAAa,CAAC,MAAM,CAAC,EAAE;QAC9B,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;KAEpD;SAAM,IAAI,OAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE;QAC3C,OAAO,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACvC;IAED,OAAO,IAAA,6BAAkB,EAAC,+BAA+B,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AArBD,wCAqBC"}

@ -1,13 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCreate2Address = exports.getCreateAddress = void 0;
const keccak_js_1 = require("../crypto/keccak.js");
const index_js_1 = require("../utils/index.js");
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../utils/index.js");
const address_js_1 = require("./address.js");
// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed
function getCreateAddress(tx) {
const from = (0, address_js_1.getAddress)(tx.from);
const nonce = index_js_1.logger.getBigInt(tx.nonce, "tx.nonce");
const nonce = (0, index_js_2.getBigInt)(tx.nonce, "tx.nonce");
let nonceHex = nonce.toString(16);
if (nonceHex === "0") {
nonceHex = "0x";
@ -18,20 +18,20 @@ function getCreateAddress(tx) {
else {
nonceHex = "0x" + nonceHex;
}
return (0, address_js_1.getAddress)((0, index_js_1.dataSlice)((0, keccak_js_1.keccak256)((0, index_js_1.encodeRlp)([from, nonceHex])), 12));
return (0, address_js_1.getAddress)((0, index_js_2.dataSlice)((0, index_js_1.keccak256)((0, index_js_2.encodeRlp)([from, nonceHex])), 12));
}
exports.getCreateAddress = getCreateAddress;
function getCreate2Address(_from, _salt, _initCodeHash) {
const from = (0, address_js_1.getAddress)(_from);
const salt = index_js_1.logger.getBytes(_salt, "salt");
const initCodeHash = index_js_1.logger.getBytes(_initCodeHash, "initCodeHash");
const salt = (0, index_js_2.getBytes)(_salt, "salt");
const initCodeHash = (0, index_js_2.getBytes)(_initCodeHash, "initCodeHash");
if (salt.length !== 32) {
index_js_1.logger.throwArgumentError("salt must be 32 bytes", "salt", _salt);
(0, index_js_2.throwArgumentError)("salt must be 32 bytes", "salt", _salt);
}
if (initCodeHash.length !== 32) {
index_js_1.logger.throwArgumentError("initCodeHash must be 32 bytes", "initCodeHash", _initCodeHash);
(0, index_js_2.throwArgumentError)("initCodeHash must be 32 bytes", "initCodeHash", _initCodeHash);
}
return (0, address_js_1.getAddress)((0, index_js_1.dataSlice)((0, keccak_js_1.keccak256)((0, index_js_1.concat)(["0xff", from, salt, initCodeHash])), 12));
return (0, address_js_1.getAddress)((0, index_js_2.dataSlice)((0, index_js_1.keccak256)((0, index_js_2.concat)(["0xff", from, salt, initCodeHash])), 12));
}
exports.getCreate2Address = getCreate2Address;
//# sourceMappingURL=contract-address.js.map

@ -1 +1 @@
{"version":3,"file":"contract-address.js","sourceRoot":"","sources":["../../src.ts/address/contract-address.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,gDAAyE;AAEzE,6CAA0C;AAK1C,sGAAsG;AACtG,SAAgB,gBAAgB,CAAC,EAAyC;IACtE,MAAM,IAAI,GAAG,IAAA,uBAAU,EAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,iBAAM,CAAC,SAAS,CAAC,EAAE,CAAC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,MAAM,EAAE,KAAK,CAAC,CAAC;KAC9D;IAED,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,EAAE;QAC5B,IAAA,6BAAkB,EAAC,+BAA+B,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;KACtF;IAED,OAAO,IAAA,uBAAU,EAAC,IAAA,oBAAS,EAAC,IAAA,oBAAS,EAAC,IAAA,iBAAM,EAAC,CAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,CAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAC7F,CAAC;AAdD,8CAcC"}

@ -1,10 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Contract = exports.BaseContract = exports.resolveArgs = exports.copyOverrides = void 0;
const index_js_1 = require("../address/index.js");
const index_js_2 = require("../abi/index.js");
const index_js_3 = require("../utils/index.js");
const index_js_4 = require("../providers/index.js");
const index_js_1 = require("../abi/index.js");
const index_js_2 = require("../address/index.js");
const index_js_3 = require("../providers/index.js");
const index_js_4 = require("../utils/index.js");
const wrappers_js_1 = require("./wrappers.js");
function canCall(value) {
return (value && typeof (value.call) === "function");
@ -27,7 +27,7 @@ class PreparedTopicFilter {
#filter;
fragment;
constructor(contract, fragment, args) {
(0, index_js_3.defineProperties)(this, { fragment });
(0, index_js_4.defineProperties)(this, { fragment });
if (fragment.inputs.length < args.length) {
throw new Error("too many arguments");
}
@ -38,7 +38,7 @@ class PreparedTopicFilter {
const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => {
return param.walkAsync(args[index], (type, value) => {
if (type === "address") {
return (0, index_js_1.resolveAddress)(value, resolver);
return (0, index_js_2.resolveAddress)(value, resolver);
}
return value;
});
@ -79,18 +79,18 @@ function getProvider(value) {
}
async function copyOverrides(arg) {
// Create a shallow copy (we'll deep-ify anything needed during normalizing)
const overrides = (0, index_js_4.copyRequest)(index_js_2.Typed.dereference(arg, "overrides"));
const overrides = (0, index_js_3.copyRequest)(index_js_1.Typed.dereference(arg, "overrides"));
// Some sanity checking; these are what these methods adds
//if ((<any>overrides).to) {
if (overrides.to) {
index_js_3.logger.throwArgumentError("cannot override to", "overrides.to", overrides.to);
(0, index_js_4.throwArgumentError)("cannot override to", "overrides.to", overrides.to);
}
else if (overrides.data) {
index_js_3.logger.throwArgumentError("cannot override data", "overrides.data", overrides.data);
(0, index_js_4.throwArgumentError)("cannot override data", "overrides.data", overrides.data);
}
// Resolve any from
if (overrides.from) {
overrides.from = await (0, index_js_1.resolveAddress)(overrides.from);
overrides.from = await (0, index_js_2.resolveAddress)(overrides.from);
}
return overrides;
}
@ -102,7 +102,7 @@ async function resolveArgs(_runner, inputs, args) {
return await Promise.all(inputs.map((param, index) => {
return param.walkAsync(args[index], (type, value) => {
if (type === "address") {
return (0, index_js_1.resolveAddress)(value, resolver);
return (0, index_js_2.resolveAddress)(value, resolver);
}
return value;
});
@ -115,7 +115,7 @@ class WrappedMethod extends _WrappedMethodBase() {
_key;
constructor(contract, key) {
super();
(0, index_js_3.defineProperties)(this, {
(0, index_js_4.defineProperties)(this, {
name: contract.interface.getFunctionName(key),
_contract: contract, _key: key
});
@ -149,7 +149,7 @@ class WrappedMethod extends _WrappedMethodBase() {
throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");
}
const resolvedArgs = await resolveArgs(this._contract.runner, fragment.inputs, args);
return Object.assign({}, overrides, await (0, index_js_3.resolveProperties)({
return Object.assign({}, overrides, await (0, index_js_4.resolveProperties)({
to: this._contract.getAddress(),
data: this._contract.interface.encodeFunctionData(fragment, resolvedArgs)
}));
@ -164,7 +164,7 @@ class WrappedMethod extends _WrappedMethodBase() {
async send(...args) {
const runner = this._contract.runner;
if (!canSend(runner)) {
return index_js_3.logger.throwError("contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
operation: "sendTransaction"
});
}
@ -175,7 +175,7 @@ class WrappedMethod extends _WrappedMethodBase() {
async estimateGas(...args) {
const runner = getRunner(this._contract.runner, "estimateGas");
if (!canEstimate(runner)) {
return index_js_3.logger.throwError("contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", {
operation: "estimateGas"
});
}
@ -184,7 +184,7 @@ class WrappedMethod extends _WrappedMethodBase() {
async staticCallResult(...args) {
const runner = getRunner(this._contract.runner, "call");
if (!canCall(runner)) {
return index_js_3.logger.throwError("contract runner does not support calling", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("contract runner does not support calling", "UNSUPPORTED_OPERATION", {
operation: "call"
});
}
@ -195,7 +195,7 @@ class WrappedMethod extends _WrappedMethodBase() {
result = await runner.call(tx);
}
catch (error) {
if ((0, index_js_3.isCallException)(error)) {
if ((0, index_js_4.isCallException)(error)) {
throw this._contract.interface.makeError(fragment, error.data, tx);
}
throw error;
@ -212,7 +212,7 @@ class WrappedEvent extends _WrappedEventBase() {
_key;
constructor(contract, key) {
super();
(0, index_js_3.defineProperties)(this, {
(0, index_js_4.defineProperties)(this, {
name: contract.interface.getEventName(key),
_contract: contract, _key: key
});
@ -259,7 +259,7 @@ async function getSubTag(contract, event) {
else if (typeof (event) === "string") {
// Event name (name or signature); `"Transfer"`
fragment = contract.interface.getEvent(event);
topics = [contract.interface.getEventTopic(fragment)];
topics = [fragment.topicHash];
}
else if (isDeferred(event)) {
// Deferred Topic Filter; e.g. `contract.filter.Transfer(from)`
@ -269,7 +269,7 @@ async function getSubTag(contract, event) {
else if ("fragment" in event) {
// ContractEvent; e.g. `contract.filter.Transfer`
fragment = event.fragment;
topics = [contract.interface.getEventTopic(fragment)];
topics = [fragment.topicHash];
}
else {
console.log(event);
@ -304,7 +304,7 @@ async function getSub(contract, event) {
// Make sure our runner can actually subscribe to events
const provider = getProvider(contract.runner);
if (!provider) {
return index_js_3.logger.throwError("contract runner does not support subscribing", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("contract runner does not support subscribing", "UNSUPPORTED_OPERATION", {
operation: "on"
});
}
@ -379,8 +379,8 @@ class BaseContract {
filters;
[internal];
constructor(target, abi, runner = null, _deployTx) {
const iface = index_js_2.Interface.from(abi);
(0, index_js_3.defineProperties)(this, { target, runner, interface: iface });
const iface = index_js_1.Interface.from(abi);
(0, index_js_4.defineProperties)(this, { target, runner, interface: iface });
Object.defineProperty(this, internal, { value: {} });
let addrPromise;
let addr = null;
@ -392,14 +392,14 @@ class BaseContract {
let subs = new Map();
// Resolve the target as the address
if (typeof (target) === "string") {
if ((0, index_js_3.isHexString)(target)) {
if ((0, index_js_4.isHexString)(target)) {
addr = target;
addrPromise = Promise.resolve(target);
}
else {
const resolver = getRunner(runner, "resolveName");
if (!canResolve(resolver)) {
throw index_js_3.logger.makeError("contract runner does not support name resolution", "UNSUPPORTED_OPERATION", {
throw (0, index_js_4.makeError)("contract runner does not support name resolution", "UNSUPPORTED_OPERATION", {
operation: "resolveName"
});
}
@ -438,7 +438,7 @@ class BaseContract {
throw new Error(`unknown contract event: ${prop}`);
}
});
(0, index_js_3.defineProperties)(this, { filters });
(0, index_js_4.defineProperties)(this, { filters });
// Return a Proxy that will respond to functions
return new Proxy(this, {
get: (target, _prop, receiver) => {
@ -458,7 +458,7 @@ class BaseContract {
async getDeployedCode() {
const provider = getProvider(this.runner);
if (!provider) {
return index_js_3.logger.throwError("runner does not support .provider", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("runner does not support .provider", "UNSUPPORTED_OPERATION", {
operation: "getDeployedCode"
});
}
@ -483,7 +483,7 @@ class BaseContract {
// Make sure we can subscribe to a provider event
const provider = getProvider(this.runner);
if (provider == null) {
return index_js_3.logger.throwError("contract runner does not support .provider", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("contract runner does not support .provider", "UNSUPPORTED_OPERATION", {
operation: "waitForDeployment"
});
}
@ -529,7 +529,7 @@ class BaseContract {
const filter = { address, topics, fromBlock, toBlock };
const provider = getProvider(this.runner);
if (!provider) {
return index_js_3.logger.throwError("contract runner does not have a provider", "UNSUPPORTED_OPERATION", {
return (0, index_js_4.throwError)("contract runner does not have a provider", "UNSUPPORTED_OPERATION", {
operation: "queryFilter"
});
}

File diff suppressed because one or more lines are too long

@ -15,7 +15,7 @@ class ContractFactory {
const iface = index_js_1.Interface.from(abi);
// Dereference Solidity bytecode objects and allow a missing `0x`-prefix
if (bytecode instanceof Uint8Array) {
bytecode = (0, index_js_3.hexlify)(index_js_3.logger.getBytes(bytecode));
bytecode = (0, index_js_3.hexlify)((0, index_js_3.getBytes)(bytecode));
}
else {
if (typeof (bytecode) === "object") {
@ -24,7 +24,7 @@ class ContractFactory {
if (bytecode.substring(0, 2) !== "0x") {
bytecode = "0x" + bytecode;
}
bytecode = (0, index_js_3.hexlify)(index_js_3.logger.getBytes(bytecode));
bytecode = (0, index_js_3.hexlify)((0, index_js_3.getBytes)(bytecode));
}
(0, index_js_3.defineProperties)(this, {
bytecode, interface: iface, runner: (runner || null)
@ -46,7 +46,7 @@ class ContractFactory {
async deploy(...args) {
const tx = await this.getDeployTransaction(...args);
if (!this.runner || typeof (this.runner.sendTransaction) !== "function") {
return index_js_3.logger.throwError("factory runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
return (0, index_js_3.throwError)("factory runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
operation: "sendTransaction"
});
}
@ -59,7 +59,7 @@ class ContractFactory {
}
static fromSolidity(output, runner) {
if (output == null) {
index_js_3.logger.throwArgumentError("bad compiler output", "output", output);
(0, index_js_3.throwArgumentError)("bad compiler output", "output", output);
}
if (typeof (output) === "string") {
output = JSON.parse(output);

@ -1 +1 @@
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src.ts/contract/factory.ts"],"names":[],"mappings":";;;AACA,8CAA4C;AAC5C,kDAAuD;AACvD,gDAA8E;AAE9E,+CAAyE;AAYzE,mCAAmC;AACnC,sCAAsC;AACtC,MAAa,eAAe;IACf,SAA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AAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;SAClC;QAED,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;CACJ;AA7ED,0CA6EC"}

@ -6,7 +6,7 @@ const hmac_1 = require("@noble/hashes/hmac");
const pbkdf2_1 = require("@noble/hashes/pbkdf2");
const sha256_1 = require("@noble/hashes/sha256");
const sha512_1 = require("@noble/hashes/sha512");
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../utils/index.js");
function getGlobal() {
if (typeof self !== 'undefined') {
return self;
@ -27,13 +27,13 @@ function createHash(algo) {
case "sha256": return sha256_1.sha256.create();
case "sha512": return sha512_1.sha512.create();
}
return logger_js_1.logger.throwArgumentError("invalid hashing algorithm name", "algorithm", algo);
return (0, index_js_1.throwArgumentError)("invalid hashing algorithm name", "algorithm", algo);
}
exports.createHash = createHash;
function createHmac(_algo, key) {
const algo = ({ sha256: sha256_1.sha256, sha512: sha512_1.sha512 }[_algo]);
if (algo == null) {
return logger_js_1.logger.throwArgumentError("invalid hmac algorithm", "algorithm", _algo);
return (0, index_js_1.throwArgumentError)("invalid hmac algorithm", "algorithm", _algo);
}
return hmac_1.hmac.create(algo, key);
}
@ -41,19 +41,19 @@ exports.createHmac = createHmac;
function pbkdf2Sync(password, salt, iterations, keylen, _algo) {
const algo = ({ sha256: sha256_1.sha256, sha512: sha512_1.sha512 }[_algo]);
if (algo == null) {
return logger_js_1.logger.throwArgumentError("invalid pbkdf2 algorithm", "algorithm", _algo);
return (0, index_js_1.throwArgumentError)("invalid pbkdf2 algorithm", "algorithm", _algo);
}
return (0, pbkdf2_1.pbkdf2)(algo, password, salt, { c: iterations, dkLen: keylen });
}
exports.pbkdf2Sync = pbkdf2Sync;
function randomBytes(length) {
if (crypto == null) {
return logger_js_1.logger.throwError("platform does not support secure random numbers", "UNSUPPORTED_OPERATION", {
return (0, index_js_1.throwError)("platform does not support secure random numbers", "UNSUPPORTED_OPERATION", {
operation: "randomBytes"
});
}
if (!Number.isInteger(length) || length <= 0 || length > 1024) {
logger_js_1.logger.throwArgumentError("invalid length", "length", length);
(0, index_js_1.throwArgumentError)("invalid length", "length", length);
}
const result = new Uint8Array(length);
crypto.getRandomValues(result);

@ -1 +1 @@
{"version":3,"file":"crypto-browser.js","sourceRoot":"","sources":["../../src.ts/crypto/crypto-browser.ts"],"names":[],"mappings":";AAAA,0BAA0B;;;AAE1B,6CAA0C;AAC1C,iDAA8C;AAC9C,iDAA8C;AAC9C,iDAA8C;AAE9C,kDAA4C;AAW5C,SAAS,SAAS;IAChB,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE;QAAE,OAAO,IAAI,CAAC;KAAE;IACjD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAAE,OAAO,MAAM,CAAC;KAAE;IACrD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QAAE,OAAO,MAAM,CAAC;KAAE;IACrD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;AACpD,CAAC;AAAA,CAAC;AAEF,MAAM,SAAS,GAAG,SAAS,EAAE,CAAC;AAC9B,MAAM,MAAM,GAAQ,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC;AAQ3D,SAAgB,UAAU,CAAC,IAAY;IACnC,QAAQ,IAAI,EAAE;QACV,KAAK,QAAQ,CAAC,CAAC,OAAO,eAAM,CAAC,MAAM,EAAE,CAAC;QACtC,KAAK,QAAQ,CAAC,CAAC,OAAO,eAAM,CAAC,MAAM,EAAE,CAAC;KACzC;IACD,OAAO,kBAAM,CAAC,kBAAkB,CAAC,gCAAgC,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;AAC1F,CAAC;AAND,gCAMC;AAED,SAAgB,UAAU,CAAC,KAAa,EAAE,GAAe;IACrD,MAAM,IAAI,GAAG,CAAC,EAAE,MAAM,EAAN,eAAM,EAAE,MAAM,EAAN,eAAM,EAAE,CAAC,KAAK,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EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAND,gCAMC;AAED,SAAgB,UAAU,CAAC,QAAoB,EAAE,IAAgB,EAAE,UAAkB,EAAE,MAAc,EAAE,KAA0B;IAC7H,MAAM,IAAI,GAAG,CAAC,EAAE,MAAM,EAAN,eAAM,EAAE,MAAM,EAAN,eAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,IAAI,IAAI,IAAI,IAAI,EAAE;QACd,OAAO,IAAA,6BAAkB,EAAC,0BAA0B,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;KAC7E;IACD,OAAO,IAAA,eAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1E,CAAC;AAND,gCAMC;AAED,SAAgB,WAAW,CAAC,MAAc;IACtC,IAAI,MAAM,IAAI,IAAI,EAAE;QAChB,OAAO,IAAA,qBAAU,EAAC,iDAAiD,EAAE,uBAAuB,EAAE;YAC1F,SAAS,EAAE,aAAa;SAC3B,CAAC,CAAC;KACN;IAED,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,MAAM,GAAG,IAAI,EAAE;QAC3D,IAAA,6BAAkB,EAAC,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;KAC1D;IAED,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC;AAClB,CAAC;AAdD,kCAcC"}

@ -9,8 +9,8 @@ const _computeHmac = function (algorithm, key, data) {
};
let __computeHmac = _computeHmac;
function computeHmac(algorithm, _key, _data) {
const key = index_js_1.logger.getBytes(_key, "key");
const data = index_js_1.logger.getBytes(_data, "data");
const key = (0, index_js_1.getBytes)(_key, "key");
const data = (0, index_js_1.getBytes)(_data, "data");
return (0, index_js_1.hexlify)(__computeHmac(algorithm, key, data));
}
exports.computeHmac = computeHmac;

@ -1 +1 @@
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src.ts/crypto/hmac.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,gDAAoD;AAKpD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,YAAY,GAAG,UAAS,SAA8B,EAAE,GAAe,EAAE,IAAgB;IAC3F,OAAO,IAAI,GAAG,IAAA,sBAAU,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC,CAAA;AAED,IAAI,aAAa,GAAG,YAAY,CAAC;AAEjC,SAAgB,WAAW,CAAC,SAA8B,EAAE,IAAe,EAAE,KAAgB;IACzF,MAAM,GAAG,GAAG,iBAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,iBAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,IAAA,kBAAO,EAAC,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC;AAJD,kCAIC;AACD,WAAW,CAAC,CAAC,GAAG,YAAY,CAAC;AAC7B,WAAW,CAAC,IAAI,GAAI,cAAa,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACjD,WAAW,CAAC,QAAQ,GAAG,UAAS,IAAsF;IAClH,IAAI,MAAM,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAAE;IACzD,aAAa,GAAG,IAAI,CAAC;AACzB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC"}
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src.ts/crypto/hmac.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AACzC,gDAAsD;AAKtD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,YAAY,GAAG,UAAS,SAA8B,EAAE,GAAe,EAAE,IAAgB;IAC3F,OAAO,IAAI,GAAG,IAAA,sBAAU,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC,CAAA;AAED,IAAI,aAAa,GAAG,YAAY,CAAC;AAEjC,SAAgB,WAAW,CAAC,SAA8B,EAAE,IAAe,EAAE,KAAgB;IACzF,MAAM,GAAG,GAAG,IAAA,mBAAQ,EAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAA,mBAAQ,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,IAAA,kBAAO,EAAC,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AACxD,CAAC;AAJD,kCAIC;AACD,WAAW,CAAC,CAAC,GAAG,YAAY,CAAC;AAC7B,WAAW,CAAC,IAAI,GAAI,cAAa,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACjD,WAAW,CAAC,QAAQ,GAAG,UAAS,IAAsF;IAClH,IAAI,MAAM,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;KAAE;IACzD,aAAa,GAAG,IAAI,CAAC;AACzB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC"}

@ -9,7 +9,7 @@ const _keccak256 = function (data) {
};
let __keccak256 = _keccak256;
function keccak256(_data) {
const data = index_js_1.logger.getBytes(_data, "data");
const data = (0, index_js_1.getBytes)(_data, "data");
return (0, index_js_1.hexlify)(__keccak256(data));
}
exports.keccak256 = keccak256;

@ -1 +1 @@
{"version":3,"file":"keccak.js","sourceRoot":"","sources":["../../src.ts/cryp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,CAAC,CAAC,CAAC;AACtC,CAAC;AAHD,8BAGC;AACD,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC;AACzB,SAAS,CAAC,IAAI,GAAG,cAAmB,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACpD,SAAS,CAAC,QAAQ,GAAG,UAAS,IAAqC;IAC/D,IAAI,MAAM,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAC;KAAE;IAC3D,WAAW,GAAG,IAAI,CAAC;AACvB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC"}

@ -9,8 +9,8 @@ const _pbkdf2 = function (password, salt, iterations, keylen, algo) {
};
let __pbkdf2 = _pbkdf2;
function pbkdf2(_password, _salt, iterations, keylen, algo) {
const password = index_js_1.logger.getBytes(_password, "password");
const salt = index_js_1.logger.getBytes(_salt, "salt");
const password = (0, index_js_1.getBytes)(_password, "password");
const salt = (0, index_js_1.getBytes)(_salt, "salt");
return (0, index_js_1.hexlify)(__pbkdf2(password, salt, iterations, keylen, algo));
}
exports.pbkdf2 = pbkdf2;

@ -1 +1 @@
{"version":3,"file":"pbkdf2.js","sourceRoot":"","sources":["../../src.ts/crypto/pbkdf2.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC,gDAAoD;AAKpD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,OAAO,GAAG,UAAS,QAAoB,EAAE,IAAgB,EAAE,UAAkB,EAAE,MAAc,EAAE,IAAyB;IAC1H,OAAO,IAAA,sBAAU,EAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC,CAAA;AAED,IAAI,QAAQ,GAAG,OAAO,CAAC;AAEvB,SAAgB,MAAM,CAAC,SAAoB,EAAE,KAAgB,EAAE,UAAkB,EAAE,MAAc,EAAE,IAAyB;IACxH,MAAM,QAAQ,GAAG,iBAAM,CAAC,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AC,CAAC;IACrC,OAAO,IAAA,kBAAO,EAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC;AAJD,wBAIC;AACD,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC;AACnB,MAAM,CAAC,IAAI,GAAG,cAAmB,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACjD,MAAM,CAAC,QAAQ,GAAG,UAAS,IAA0H;IACjJ,IAAI,MAAM,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KAAE;IACpD,QAAQ,GAAG,IAAI,CAAC;AACpB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC"}

@ -9,7 +9,7 @@ const _ripemd160 = function (data) {
};
let __ripemd160 = _ripemd160;
function ripemd160(_data) {
const data = index_js_1.logger.getBytes(_data, "data");
const data = (0, index_js_1.getBytes)(_data, "data");
return (0, index_js_1.hexlify)(__ripemd160(data));
}
exports.ripemd160 = ripemd160;

@ -1 +1 @@
{"version":3,"file":"ripemd160.js","sourceRoot":"","sources":["../../src.ts/crypto/ripemd160.ts"],"names":[],"mappings":";;;AAAA,uDAAuE;AAEvE,gDAAoD;AAKpD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,UAAU,GAAG,UAAS,IAAgB;IACxC,OAAO,IAAA,qBAAe,EAAC,IAAI,CAAC,CAAC;AACjC,CAAC,CAAA;AAED,IAAI,WAAW,GAAoC,UAAU,CAAC;AAE9D,SAAgB,SAAS,CAAC,KAAgB;IACtC,MAAM,IAAI,GAAG,iBAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,IAAA,kBAAO,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAHD,8BAGC;AACD,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC;AACzB,SAAS,CAAC,IAAI,GAAG,cAAmB,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACpD,SAAS,CAAC,QAAQ,GAAG,UAAS,IAAqC;IAC/D,IAAI,MAAM,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAC;KAAE;IAC3D,WAAW,GAAG,IAAI,CAAC;AACvB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC"}
{"version":3,"file":"ripemd160.js","sourceRoot":"","sources":["../../src.ts/crypto/ripemd160.ts"],"names":[],"mappings":";;;AAAA,uDAAuE;AAEvE,gDAAuD;AAKvD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,UAAU,GAAG,UAAS,IAAgB;IACxC,OAAO,IAAA,qBAAe,EAAC,IAAI,CAAC,CAAC;AACjC,CAAC,CAAA;AAED,IAAI,WAAW,GAAoC,UAAU,CAAC;AAE9D,SAAgB,SAAS,CAAC,KAAgB;IACtC,MAAM,IAAI,GAAG,IAAA,mBAAQ,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrC,OAAO,IAAA,kBAAO,EAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AAHD,8BAGC;AACD,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC;AACzB,SAAS,CAAC,IAAI,GAAG,cAAmB,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;AACpD,SAAS,CAAC,QAAQ,GAAG,UAAS,IAAqC;IAC/D,IAAI,MAAM,EAAE;QAAE,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAC;KAAE;IAC3D,WAAW,GAAG,IAAI,CAAC;AACvB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC"}

@ -13,8 +13,8 @@ const _scryptSync = function (passwd, salt, N, r, p, dkLen) {
let __scryptAsync = _scryptAsync;
let __scryptSync = _scryptSync;
async function scrypt(_passwd, _salt, N, r, p, dkLen, progress) {
const passwd = index_js_1.logger.getBytes(_passwd, "passwd");
const salt = index_js_1.logger.getBytes(_salt, "salt");
const passwd = (0, index_js_1.getBytes)(_passwd, "passwd");
const salt = (0, index_js_1.getBytes)(_salt, "salt");
return (0, index_js_1.hexlify)(await __scryptAsync(passwd, salt, N, r, p, dkLen, progress));
}
exports.scrypt = scrypt;
@ -28,8 +28,8 @@ scrypt.register = function (func) {
};
Object.freeze(scrypt);
function scryptSync(_passwd, _salt, N, r, p, dkLen) {
const passwd = index_js_1.logger.getBytes(_passwd, "passwd");
const salt = index_js_1.logger.getBytes(_salt, "salt");
const passwd = (0, index_js_1.getBytes)(_passwd, "passwd");
const salt = (0, index_js_1.getBytes)(_salt, "salt");
return (0, index_js_1.hexlify)(__scryptSync(passwd, salt, N, r, p, dkLen));
}
exports.scryptSync = scryptSync;

@ -1 +1 @@
{"version":3,"file":"scrypt.js","sourceRoot":"","sources":["../../src.ts/crypto/scrypt.ts"],"names":[],"mappings":";;;AAAA,iDAAwF;AAExF,gDAAyD;AAQzD,IAAI,UAAU,GAAG,KAAK,EAAE,WAAW,GAAG,KAAK,CAAC;AAE5C,MAAM,YAAY,GAAG,KAAK,WAAU,MAAkB,EAAE,IAAgB,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa,EAAE,UAA6B;IACnJ,OAAO,MAAM,IAAA,oBAAW,EAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAA;AACD,MAAM,WAAW,GAAG,UAAS,MAAkB,EAAE,IAAgB,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa;IAC7G,OAAO,IAAA,eAAU,EAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC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AC,CAAA;AACzD,UAAU,CAAC,QAAQ,GAAG,UAAS,IAAyG;IACpI,IAAI,UAAU,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;KAAE;IAC5D,YAAY,GAAG,IAAI,CAAC;AACxB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC"}

@ -13,7 +13,7 @@ let __sha256 = _sha256;
let __sha512 = _sha512;
let locked256 = false, locked512 = false;
function sha256(_data) {
const data = index_js_1.logger.getBytes(_data, "data");
const data = (0, index_js_1.getBytes)(_data, "data");
return (0, index_js_1.hexlify)(__sha256(data));
}
exports.sha256 = sha256;
@ -27,7 +27,7 @@ sha256.register = function (func) {
};
Object.freeze(sha256);
function sha512(_data) {
const data = index_js_1.logger.getBytes(_data, "data");
const data = (0, index_js_1.getBytes)(_data, "data");
return (0, index_js_1.hexlify)(__sha512(data));
}
exports.sha512 = sha512;

@ -1 +1 @@
{"version":3,"file":"sha2.js","sourceRoot":"","sources":["../../src.ts/crypto/sha2.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAEzC,gDAAoD;AAKpD,MAAM,OAAO,GAAG,UAAS,IAAgB;IACrC,OAAO,IAAA,sBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AACtD,CAAC,CAAA;AAED,MAAM,OAAO,GAAG,UAAS,IAAgB;IACrC,OAAO,IAAA,sBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AACtD,CAAC,CAAA;AAED,IAAI,QAAQ,GAAoC,OAAO,CAAC;AACxD,IAAI,QAAQ,GAAoC,OAAO,CAAC;AAExD,IAAI,SAAS,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC;AAGzC,SAAgB,MAAM,CAAC,KAAgB;IACnC,MAAM,IAAI,GAAG,iBAAM,CAAC,QAAQ,CAAC,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AAG,UAAS,IAAqC;IAC5D,IAAI,SAAS,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KAAE;IACvD,QAAQ,GAAG,IAAI,CAAC;AACpB,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC"}

@ -16,23 +16,23 @@ class Signature {
get r() { return (0, index_js_2.getStore)(this.#props, "r"); }
set r(value) {
if ((0, index_js_2.dataLength)(value) !== 32) {
index_js_2.logger.throwArgumentError("invalid r", "value", value);
(0, index_js_2.throwArgumentError)("invalid r", "value", value);
}
(0, index_js_2.setStore)(this.#props, "r", (0, index_js_2.hexlify)(value));
}
get s() { return (0, index_js_2.getStore)(this.#props, "s"); }
set s(value) {
if ((0, index_js_2.dataLength)(value) !== 32) {
index_js_2.logger.throwArgumentError("invalid r", "value", value);
(0, index_js_2.throwArgumentError)("invalid r", "value", value);
}
else if (index_js_2.logger.getBytes(value)[0] & 0x80) {
index_js_2.logger.throwArgumentError("non-canonical s", "value", value);
else if ((0, index_js_2.getBytes)(value)[0] & 0x80) {
(0, index_js_2.throwArgumentError)("non-canonical s", "value", value);
}
(0, index_js_2.setStore)(this.#props, "s", (0, index_js_2.hexlify)(value));
}
get v() { return (0, index_js_2.getStore)(this.#props, "v"); }
set v(value) {
const v = index_js_2.logger.getNumber(value, "value");
const v = (0, index_js_2.getNumber)(value, "value");
if (v !== 27 && v !== 28) {
throw new Error("@TODO");
}
@ -62,7 +62,7 @@ class Signature {
}
get yParityAndS() {
// The EIP-2098 compact representation
const yParityAndS = index_js_2.logger.getBytes(this.s);
const yParityAndS = (0, index_js_2.getBytes)(this.s);
if (this.yParity) {
yParityAndS[0] |= 0x80;
}
@ -75,7 +75,7 @@ class Signature {
return (0, index_js_2.concat)([this.r, this.s, (this.yParity ? "0x1c" : "0x1b")]);
}
constructor(guard, r, s, v) {
index_js_2.logger.assertPrivate(guard, _guard, "Signature");
(0, index_js_2.assertPrivate)(guard, _guard, "Signature");
this.#props = { r, s, v, networkV: null };
}
[Symbol.for('nodejs.util.inspect.custom')]() {
@ -108,24 +108,24 @@ class Signature {
}
// Get the chain ID from an EIP-155 v
static getChainId(v) {
const bv = index_js_2.logger.getBigInt(v, "v");
const bv = (0, index_js_2.getBigInt)(v, "v");
// The v is not an EIP-155 v, so it is the unspecified chain ID
if ((bv == BN_27) || (bv == BN_28)) {
return BN_0;
}
// Bad value for an EIP-155 v
if (bv < BN_35) {
index_js_2.logger.throwArgumentError("invalid EIP-155 v", "v", v);
(0, index_js_2.throwArgumentError)("invalid EIP-155 v", "v", v);
}
return (bv - BN_35) / BN_2;
}
// Get the EIP-155 v transformed for a given chainId
static getChainIdV(chainId, v) {
return (index_js_2.logger.getBigInt(chainId) * BN_2) + BigInt(35 + v - 27);
return ((0, index_js_2.getBigInt)(chainId) * BN_2) + BigInt(35 + v - 27);
}
// Convert an EIP-155 v into a normalized v
static getNormalizedV(v) {
const bv = index_js_2.logger.getBigInt(v);
const bv = (0, index_js_2.getBigInt)(v);
if (bv == BN_0) {
return 27;
}
@ -137,10 +137,10 @@ class Signature {
}
static from(sig) {
const throwError = (message) => {
return index_js_2.logger.throwArgumentError(message, "signature", sig);
return (0, index_js_2.throwArgumentError)(message, "signature", sig);
};
if (typeof (sig) === "string") {
const bytes = index_js_2.logger.getBytes(sig, "signature");
const bytes = (0, index_js_2.getBytes)(sig, "signature");
if (bytes.length === 64) {
const r = (0, index_js_2.hexlify)(bytes.slice(0, 32));
const s = bytes.slice(32, 64);
@ -182,19 +182,19 @@ class Signature {
if (!(0, index_js_2.isHexString)(yParityAndS, 32)) {
throwError("invalid yParityAndS");
}
const bytes = index_js_2.logger.getBytes(yParityAndS);
const bytes = (0, index_js_2.getBytes)(yParityAndS);
bytes[0] &= 0x7f;
return (0, index_js_2.hexlify)(bytes);
}
return throwError("missing s");
})(sig.s, sig.yParityAndS);
if (index_js_2.logger.getBytes(s)[0] & 0x80) {
if ((0, index_js_2.getBytes)(s)[0] & 0x80) {
throwError("non-canonical s");
}
// Get v; by any means necessary (we check consistency below)
const { networkV, v } = (function (_v, yParityAndS, yParity) {
if (_v != null) {
const v = index_js_2.logger.getBigInt(_v);
const v = (0, index_js_2.getBigInt)(_v);
return {
networkV: ((v >= BN_35) ? v : undefined),
v: Signature.getNormalizedV(v)
@ -204,7 +204,7 @@ class Signature {
if (!(0, index_js_2.isHexString)(yParityAndS, 32)) {
throwError("invalid yParityAndS");
}
return { v: ((index_js_2.logger.getBytes(yParityAndS)[0] & 0x80) ? 28 : 27) };
return { v: (((0, index_js_2.getBytes)(yParityAndS)[0] & 0x80) ? 28 : 27) };
}
if (yParity != null) {
switch (yParity) {

File diff suppressed because one or more lines are too long

@ -31,7 +31,7 @@ const signature_js_1 = require("./signature.js");
//const N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
// Make noble-secp256k1 sync
secp256k1.utils.hmacSha256Sync = function (key, ...messages) {
return index_js_1.logger.getBytes((0, hmac_js_1.computeHmac)("sha256", key, (0, index_js_1.concat)(messages)));
return (0, index_js_1.getBytes)((0, hmac_js_1.computeHmac)("sha256", key, (0, index_js_1.concat)(messages)));
};
class SigningKey {
#privateKey;
@ -51,7 +51,7 @@ class SigningKey {
/* @TODO
logger.assertArgument(() => (dataLength(digest) === 32), "invalid digest length", "digest", digest);
*/
const [sigDer, recid] = secp256k1.signSync(index_js_1.logger.getBytesCopy(digest), index_js_1.logger.getBytesCopy(this.#privateKey), {
const [sigDer, recid] = secp256k1.signSync((0, index_js_1.getBytesCopy)(digest), (0, index_js_1.getBytesCopy)(this.#privateKey), {
recovered: true,
canonical: true
});
@ -64,10 +64,10 @@ class SigningKey {
}
computeShardSecret(other) {
const pubKey = SigningKey.computePublicKey(other);
return (0, index_js_1.hexlify)(secp256k1.getSharedSecret(index_js_1.logger.getBytesCopy(this.#privateKey), pubKey));
return (0, index_js_1.hexlify)(secp256k1.getSharedSecret((0, index_js_1.getBytesCopy)(this.#privateKey), pubKey));
}
static computePublicKey(key, compressed) {
let bytes = index_js_1.logger.getBytes(key, "key");
let bytes = (0, index_js_1.getBytes)(key, "key");
if (bytes.length === 32) {
const pubKey = secp256k1.getPublicKey(bytes, !!compressed);
return (0, index_js_1.hexlify)(pubKey);
@ -83,12 +83,12 @@ class SigningKey {
}
static recoverPublicKey(digest, signature) {
const sig = signature_js_1.Signature.from(signature);
const der = secp256k1.Signature.fromCompact(index_js_1.logger.getBytesCopy((0, index_js_1.concat)([sig.r, sig.s]))).toDERRawBytes();
const pubKey = secp256k1.recoverPublicKey(index_js_1.logger.getBytesCopy(digest), der, sig.yParity);
const der = secp256k1.Signature.fromCompact((0, index_js_1.getBytesCopy)((0, index_js_1.concat)([sig.r, sig.s]))).toDERRawBytes();
const pubKey = secp256k1.recoverPublicKey((0, index_js_1.getBytesCopy)(digest), der, sig.yParity);
if (pubKey != null) {
return (0, index_js_1.hexlify)(pubKey);
}
return index_js_1.logger.throwArgumentError("invalid signautre for digest", "signature", signature);
return (0, index_js_1.throwArgumentError)("invalid signautre for digest", "signature", signature);
}
static _addPoints(p0, p1, compressed) {
const pub0 = secp256k1.Point.fromHex(SigningKey.computePublicKey(p0).substring(2));

@ -1 +1 @@
{"version":3,"file":"signing-key.js","sourceRoot":"","sources":["../../src.ts/crypto/signing-key.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4DAA8C;AAE9C,gDAAmE;AAEnE,uCAAwC;AACxC,iDAA2C;AAO3C,yFAAyF;AAEzF,4BAA4B;AAC5B,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,UAAS,GAAe,EAAE,GAAG,QAA2B;IACrF,OAAO,iBAAM,CAAC,QAAQ,CAAC,IAAA,qBAAW,EAAC,QAAQ,EAAE,GAAG,EAAE,IAAA,iBAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC,CAAA;AAED,MAAa,UAAU;IACnB,WAAW,CAAS;IAEpB,YAAY,UAAqB;Q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,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;QAEpG,MAAM,MAAM,GAAG,SAAS,CAAC,gBAAgB,CAAC,IAAA,uBAAY,EAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QAClF,IAAI,MAAM,IAAI,IAAI,EAAE;YAAE,OAAO,IAAA,kBAAO,EAAC,MAAM,CAAC,CAAC;SAAE;QAE/C,OAAO,IAAA,6BAAkB,EAAC,8BAA8B,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,EAAa,EAAE,EAAa,EAAE,UAAoB;QAChE,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACnF,OAAO,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;IACpD,CAAC;CACJ;AA3ED,gCA2EC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCE"}

@ -2,9 +2,10 @@
/////////////////////////////
//
Object.defineProperty(exports, "__esModule", { value: true });
exports.scryptSync = exports.scrypt = exports.pbkdf2 = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.keccak256 = exports.randomBytes = exports.computeHmac = exports.EventLog = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.ContractEventPayload = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.MessagePrefix = exports.EtherSymbol = exports.ZeroHash = exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = exports.ZeroAddress = exports.getCreate2Address = exports.getCreateAddress = exports.getIcapAddress = exports.getAddress = exports.Typed = exports.TransactionDescription = exports.Result = exports.LogDescription = exports.Interface = exports.Indexed = exports.checkResultErrors = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.defaultAbiCoder = exports.AbiCoder = exports.parseBytes32String = exports.formatBytes32String = exports.version = void 0;
exports.isCrowdsaleJson = exports.HDNodeWalletManager = exports.HDNodeVoidWallet = exports.HDNodeWallet = exports.getAccountPath = exports.defaultPath = exports.encodeRlp = exports.decodeRlp = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.toNumber = exports.toHex = exports.toBigInt = exports.toArray = exports.mask = exports.toTwos = exports.fromTwos = exports.logger = exports.Logger = exports.assertArgument = exports.parseFixed = exports.formatFixed = exports.FixedNumber = exports.FixedFormat = exports.FetchResponse = exports.FetchRequest = exports.isError = exports.isCallException = exports.encodeBase58 = exports.decodeBase58 = exports.Transaction = exports.recoverAddress = exports.computeAddress = exports.accessListify = exports.TypedDataEncoder = exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = exports.hashMessage = exports.id = exports.SigningKey = exports.Signature = exports.lock = void 0;
exports.Network = exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.WordlistOwlA = exports.WordlistOwl = exports.wordlists = exports.LangEn = exports.langEn = exports.Wordlist = exports.Wallet = exports.Mnemonic = exports.encryptKeystoreJson = exports.decryptKeystoreJson = exports.decryptKeystoreJsonSync = exports.isKeystoreJson = exports.decryptCrowdsaleJson = void 0;
exports.scrypt = exports.pbkdf2 = exports.sha512 = exports.sha256 = exports.ripemd160 = exports.keccak256 = exports.randomBytes = exports.computeHmac = exports.EventLog = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.ContractEventPayload = exports.ContractFactory = exports.Contract = exports.BaseContract = exports.MessagePrefix = exports.EtherSymbol = exports.ZeroHash = exports.N = exports.MaxInt256 = exports.MinInt256 = exports.MaxUint256 = exports.WeiPerEther = exports.Two = exports.One = exports.Zero = exports.NegativeOne = exports.ZeroAddress = exports.getCreate2Address = exports.getCreateAddress = exports.getIcapAddress = exports.getAddress = exports.Typed = exports.TransactionDescription = exports.Result = exports.LogDescription = exports.Interface = exports.Indexed = exports.checkResultErrors = exports.ParamType = exports.FunctionFragment = exports.Fragment = exports.EventFragment = exports.ErrorFragment = exports.ConstructorFragment = exports.defaultAbiCoder = exports.AbiCoder = exports.parseBytes32String = exports.formatBytes32String = exports.version = void 0;
exports.getBigInt = exports.parseFixed = exports.formatFixed = exports.FixedNumber = exports.FixedFormat = exports.FetchCancelSignal = exports.FetchResponse = exports.FetchRequest = exports.getIpfsGatewayFunc = exports.isError = exports.isCallException = exports.throwError = exports.throwArgumentError = exports.makeError = exports.assertPrivate = exports.assertNormalize = exports.assertArgumentCount = exports.assertArgument = exports.zeroPadValue = exports.zeroPadBytes = exports.stripZerosLeft = exports.isBytesLike = exports.isHexString = exports.hexlify = exports.getBytesCopy = exports.getBytes = exports.dataSlice = exports.dataLength = exports.concat = exports.encodeBase64 = exports.decodeBase64 = exports.encodeBase58 = exports.decodeBase58 = exports.Transaction = exports.recoverAddress = exports.computeAddress = exports.accessListify = exports.TypedDataEncoder = exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = exports.hashMessage = exports.dnsEncode = exports.namehash = exports.isValidName = exports.id = exports.SigningKey = exports.Signature = exports.lock = exports.scryptSync = void 0;
exports.IpcSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.AbstractProvider = exports.WordlistOwlA = exports.WordlistOwl = exports.wordlists = exports.LangEn = exports.langEn = exports.Wordlist = exports.Wallet = exports.Mnemonic = exports.encryptKeystoreJson = exports.decryptKeystoreJson = exports.decryptKeystoreJsonSync = exports.isKeystoreJson = exports.decryptCrowdsaleJson = exports.isCrowdsaleJson = exports.HDNodeWalletManager = exports.HDNodeVoidWallet = exports.HDNodeWallet = exports.getAccountPath = exports.defaultPath = exports.encodeRlp = exports.decodeRlp = exports.Utf8ErrorFuncs = exports.toUtf8String = exports.toUtf8CodePoints = exports.toUtf8Bytes = exports._toEscapedUtf8String = exports.parseUnits = exports.formatUnits = exports.parseEther = exports.formatEther = exports.mask = exports.toTwos = exports.fromTwos = exports.toQuantity = exports.toNumber = exports.toHex = exports.toBigInt = exports.toArray = exports.getNumber = void 0;
exports.Network = exports.WebSocketProvider = exports.SocketProvider = void 0;
var _version_js_1 = require("./_version.js");
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version_js_1.version; } });
var index_js_1 = require("./abi/index.js");
@ -40,6 +41,7 @@ Object.defineProperty(exports, "WeiPerEther", { enumerable: true, get: function
Object.defineProperty(exports, "MaxUint256", { enumerable: true, get: function () { return index_js_3.MaxUint256; } });
Object.defineProperty(exports, "MinInt256", { enumerable: true, get: function () { return index_js_3.MinInt256; } });
Object.defineProperty(exports, "MaxInt256", { enumerable: true, get: function () { return index_js_3.MaxInt256; } });
Object.defineProperty(exports, "N", { enumerable: true, get: function () { return index_js_3.N; } });
Object.defineProperty(exports, "ZeroHash", { enumerable: true, get: function () { return index_js_3.ZeroHash; } });
Object.defineProperty(exports, "EtherSymbol", { enumerable: true, get: function () { return index_js_3.EtherSymbol; } });
Object.defineProperty(exports, "MessagePrefix", { enumerable: true, get: function () { return index_js_3.MessagePrefix; } });
@ -66,7 +68,9 @@ Object.defineProperty(exports, "Signature", { enumerable: true, get: function ()
Object.defineProperty(exports, "SigningKey", { enumerable: true, get: function () { return index_js_5.SigningKey; } });
var index_js_6 = require("./hash/index.js");
Object.defineProperty(exports, "id", { enumerable: true, get: function () { return index_js_6.id; } });
//isValidName, namehash, dnsEncode
Object.defineProperty(exports, "isValidName", { enumerable: true, get: function () { return index_js_6.isValidName; } });
Object.defineProperty(exports, "namehash", { enumerable: true, get: function () { return index_js_6.namehash; } });
Object.defineProperty(exports, "dnsEncode", { enumerable: true, get: function () { return index_js_6.dnsEncode; } });
Object.defineProperty(exports, "hashMessage", { enumerable: true, get: function () { return index_js_6.hashMessage; } });
Object.defineProperty(exports, "solidityPacked", { enumerable: true, get: function () { return index_js_6.solidityPacked; } });
Object.defineProperty(exports, "solidityPackedKeccak256", { enumerable: true, get: function () { return index_js_6.solidityPackedKeccak256; } });
@ -80,24 +84,46 @@ Object.defineProperty(exports, "Transaction", { enumerable: true, get: function
var index_js_8 = require("./utils/index.js");
Object.defineProperty(exports, "decodeBase58", { enumerable: true, get: function () { return index_js_8.decodeBase58; } });
Object.defineProperty(exports, "encodeBase58", { enumerable: true, get: function () { return index_js_8.encodeBase58; } });
Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return index_js_8.decodeBase64; } });
Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return index_js_8.encodeBase64; } });
Object.defineProperty(exports, "concat", { enumerable: true, get: function () { return index_js_8.concat; } });
Object.defineProperty(exports, "dataLength", { enumerable: true, get: function () { return index_js_8.dataLength; } });
Object.defineProperty(exports, "dataSlice", { enumerable: true, get: function () { return index_js_8.dataSlice; } });
Object.defineProperty(exports, "getBytes", { enumerable: true, get: function () { return index_js_8.getBytes; } });
Object.defineProperty(exports, "getBytesCopy", { enumerable: true, get: function () { return index_js_8.getBytesCopy; } });
Object.defineProperty(exports, "hexlify", { enumerable: true, get: function () { return index_js_8.hexlify; } });
Object.defineProperty(exports, "isHexString", { enumerable: true, get: function () { return index_js_8.isHexString; } });
Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function () { return index_js_8.isBytesLike; } });
Object.defineProperty(exports, "stripZerosLeft", { enumerable: true, get: function () { return index_js_8.stripZerosLeft; } });
Object.defineProperty(exports, "zeroPadBytes", { enumerable: true, get: function () { return index_js_8.zeroPadBytes; } });
Object.defineProperty(exports, "zeroPadValue", { enumerable: true, get: function () { return index_js_8.zeroPadValue; } });
Object.defineProperty(exports, "assertArgument", { enumerable: true, get: function () { return index_js_8.assertArgument; } });
Object.defineProperty(exports, "assertArgumentCount", { enumerable: true, get: function () { return index_js_8.assertArgumentCount; } });
Object.defineProperty(exports, "assertNormalize", { enumerable: true, get: function () { return index_js_8.assertNormalize; } });
Object.defineProperty(exports, "assertPrivate", { enumerable: true, get: function () { return index_js_8.assertPrivate; } });
Object.defineProperty(exports, "makeError", { enumerable: true, get: function () { return index_js_8.makeError; } });
Object.defineProperty(exports, "throwArgumentError", { enumerable: true, get: function () { return index_js_8.throwArgumentError; } });
Object.defineProperty(exports, "throwError", { enumerable: true, get: function () { return index_js_8.throwError; } });
Object.defineProperty(exports, "isCallException", { enumerable: true, get: function () { return index_js_8.isCallException; } });
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return index_js_8.isError; } });
Object.defineProperty(exports, "getIpfsGatewayFunc", { enumerable: true, get: function () { return index_js_8.getIpfsGatewayFunc; } });
Object.defineProperty(exports, "FetchRequest", { enumerable: true, get: function () { return index_js_8.FetchRequest; } });
Object.defineProperty(exports, "FetchResponse", { enumerable: true, get: function () { return index_js_8.FetchResponse; } });
Object.defineProperty(exports, "FetchCancelSignal", { enumerable: true, get: function () { return index_js_8.FetchCancelSignal; } });
Object.defineProperty(exports, "FixedFormat", { enumerable: true, get: function () { return index_js_8.FixedFormat; } });
Object.defineProperty(exports, "FixedNumber", { enumerable: true, get: function () { return index_js_8.FixedNumber; } });
Object.defineProperty(exports, "formatFixed", { enumerable: true, get: function () { return index_js_8.formatFixed; } });
Object.defineProperty(exports, "parseFixed", { enumerable: true, get: function () { return index_js_8.parseFixed; } });
Object.defineProperty(exports, "assertArgument", { enumerable: true, get: function () { return index_js_8.assertArgument; } });
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return index_js_8.Logger; } });
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return index_js_8.logger; } });
Object.defineProperty(exports, "fromTwos", { enumerable: true, get: function () { return index_js_8.fromTwos; } });
Object.defineProperty(exports, "toTwos", { enumerable: true, get: function () { return index_js_8.toTwos; } });
Object.defineProperty(exports, "mask", { enumerable: true, get: function () { return index_js_8.mask; } });
Object.defineProperty(exports, "getBigInt", { enumerable: true, get: function () { return index_js_8.getBigInt; } });
Object.defineProperty(exports, "getNumber", { enumerable: true, get: function () { return index_js_8.getNumber; } });
Object.defineProperty(exports, "toArray", { enumerable: true, get: function () { return index_js_8.toArray; } });
Object.defineProperty(exports, "toBigInt", { enumerable: true, get: function () { return index_js_8.toBigInt; } });
Object.defineProperty(exports, "toHex", { enumerable: true, get: function () { return index_js_8.toHex; } });
Object.defineProperty(exports, "toNumber", { enumerable: true, get: function () { return index_js_8.toNumber; } });
Object.defineProperty(exports, "toQuantity", { enumerable: true, get: function () { return index_js_8.toQuantity; } });
Object.defineProperty(exports, "fromTwos", { enumerable: true, get: function () { return index_js_8.fromTwos; } });
Object.defineProperty(exports, "toTwos", { enumerable: true, get: function () { return index_js_8.toTwos; } });
Object.defineProperty(exports, "mask", { enumerable: true, get: function () { return index_js_8.mask; } });
Object.defineProperty(exports, "formatEther", { enumerable: true, get: function () { return index_js_8.formatEther; } });
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return index_js_8.parseEther; } });
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return index_js_8.formatUnits; } });
@ -131,6 +157,7 @@ Object.defineProperty(exports, "wordlists", { enumerable: true, get: function ()
Object.defineProperty(exports, "WordlistOwl", { enumerable: true, get: function () { return index_js_10.WordlistOwl; } });
Object.defineProperty(exports, "WordlistOwlA", { enumerable: true, get: function () { return index_js_10.WordlistOwlA; } });
var index_js_11 = require("./providers/index.js");
Object.defineProperty(exports, "AbstractProvider", { enumerable: true, get: function () { return index_js_11.AbstractProvider; } });
Object.defineProperty(exports, "FallbackProvider", { enumerable: true, get: function () { return index_js_11.FallbackProvider; } });
Object.defineProperty(exports, "JsonRpcApiProvider", { enumerable: true, get: function () { return index_js_11.JsonRpcApiProvider; } });
Object.defineProperty(exports, "JsonRpcProvider", { enumerable: true, get: function () { return index_js_11.JsonRpcProvider; } });

@ -1 +1 @@
{"version":3,"file":"ethers.js","sourceRoot":"","sources":["../src.ts/ethers.ts"],"names":[],"mappings":";AAEA,6BAA6B;AAC7B,EAAE;;;;;AAEF,6CAAwC;AAA/B,sGAAA,OAAO,OAAA;AAEhB,2CAQwB;AAPpB,+GAAA,mBAAmB,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAEvC,oGAAA,QAAQ,OAAA;AAAE,2GAAA,eAAe,OAAA;AACzB,+GAAA,mBAAmB,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,yGAAA,aAAa,OAAA;AAAE,oGAAA,QAAQ,OAAA;AAAE,4GAAA,gBAAgB,OAAA;AAAE,qGAAA,SAAS,OAAA;AAExF,6GAAA,iBAAiB,OAAA;AAAE,mGAAA,OAAO,OAAA;AAAE,qGAAA,SAAS,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,kGAAA,MAAM,OAAA;AAAE,kHAAA,sBAAsB,OAAA;AACrF,iGAAA,KAAK,OAAA;AAGT,+CAG4B;AAFxB,sGAAA,UAAU,OAAA;AAAE,0GAAA,cAAc,OAAA;AAC1B,4GAAA,gBAAgB,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAGvC,iDAK8B;AAJ1B,uGAAA,WAAW,OAAA;AACX,uGAAA,WAAW,OAAA;AAAE,gGAAA,IAAI,OAAA;AAAE,+FAAA,GAAG,OAAA;AAAE,+FAAA,GAAG,OAAA;A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;AAAE,+GAAA,mBAAmB,OAAA;AACnD,2GAAA,eAAe,OAAA;AAAE,gHAAA,oBAAoB,OAAA;AACrC,0GAAA,cAAc,OAAA;AAAE,mHAAA,uBAAuB,OAAA;AAAE,+GAAA,mBAAmB,OAAA;AAC5D,+GAAA,mBAAmB,OAAA;AACnB,oGAAA,QAAQ,OAAA;AACR,kGAAA,MAAM,OAAA;AAGV,kDAE8B;AAD1B,qGAAA,QAAQ,OAAA;AAAE,mGAAA,MAAM,OAAA;AAAE,mGAAA,MAAM,OAAA;AAAE,sGAAA,SAAS,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,yGAAA,YAAY,OAAA;AAyBlE,kDAY8B;AAX1B,6GAAA,gBAAgB,OAAA;AAEhB,6GAAA,gBAAgB,OAAA;AAChB,+GAAA,kBAAkB,OAAA;AAAE,4GAAA,eAAe,OAAA;AAAE,0GAAA,aAAa,OAAA;AAElD,4GAAA,eAAe,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAAE,2GAAA,cAAc,OAAA;AACpF,+CAA+C;AAE/C,8GAAA,iBAAiB,OAAA;AAAE,2GAAA,cAAc,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAEpD,oGAAA,OAAO,OAAA"}

@ -1,10 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.id = void 0;
const keccak_js_1 = require("../crypto/keccak.js");
const index_js_1 = require("../utils/index.js");
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../utils/index.js");
function id(value) {
return (0, keccak_js_1.keccak256)((0, index_js_1.toUtf8Bytes)(value));
return (0, index_js_1.keccak256)((0, index_js_2.toUtf8Bytes)(value));
}
exports.id = id;
//# sourceMappingURL=id.js.map

@ -1 +1 @@
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src.ts/hash/id.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,gDAAgD;AAEhD,SAAgB,EAAE,CAAC,KAAa;IAC5B,OAAO,IAAA,qBAAS,EAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC;AAFD,gBAEC"}
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src.ts/hash/id.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAC/C,gDAAgD;AAEhD,SAAgB,EAAE,CAAC,KAAa;IAC5B,OAAO,IAAA,oBAAS,EAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,CAAC,CAAC;AACzC,CAAC;AAFD,gBAEC"}

@ -1,16 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hashMessage = void 0;
const keccak_js_1 = require("../crypto/keccak.js");
const index_js_1 = require("../constants/index.js");
const index_js_2 = require("../utils/index.js");
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../constants/index.js");
const index_js_3 = require("../utils/index.js");
function hashMessage(message) {
if (typeof (message) === "string") {
message = (0, index_js_2.toUtf8Bytes)(message);
message = (0, index_js_3.toUtf8Bytes)(message);
}
return (0, keccak_js_1.keccak256)((0, index_js_2.concat)([
(0, index_js_2.toUtf8Bytes)(index_js_1.MessagePrefix),
(0, index_js_2.toUtf8Bytes)(String(message.length)),
return (0, index_js_1.keccak256)((0, index_js_3.concat)([
(0, index_js_3.toUtf8Bytes)(index_js_2.MessagePrefix),
(0, index_js_3.toUtf8Bytes)(String(message.length)),
message
]));
}

@ -1 +1 @@
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src.ts/hash/message.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,oDAAsD;AACtD,gDAAwD;AAGxD,SAAgB,WAAW,CAAC,OAA4B;IACpD,IAAI,OAAM,CAAC,OAAO,CAAC,KAAK,QAAQ,EAAE;QAAE,OAAO,GAAG,IAAA,sBAAW,EAAC,OAAO,CAAC,CAAC;KAAE;IACrE,OAAO,IAAA,qBAAS,EAAC,IAAA,iBAAM,EAAC;QACpB,IAAA,sBAAW,EAAC,wBAAa,CAAC;QAC1B,IAAA,sBAAW,EAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,OAAO;KACV,CAAC,CAAC,CAAC;AACR,CAAC;AAPD,kCAOC"}
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src.ts/hash/message.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAC/C,oDAAsD;AACtD,gDAAwD;AAGxD,SAAgB,WAAW,CAAC,OAA4B;IACpD,IAAI,OAAM,CAAC,OAAO,CAAC,KAAK,QAAQ,EAAE;QAAE,OAAO,GAAG,IAAA,sBAAW,EAAC,OAAO,CAAC,CAAC;KAAE;IACrE,OAAO,IAAA,oBAAS,EAAC,IAAA,iBAAM,EAAC;QACpB,IAAA,sBAAW,EAAC,wBAAa,CAAC;QAC1B,IAAA,sBAAW,EAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,OAAO;KACV,CAAC,CAAC,CAAC;AACR,CAAC;AAPD,kCAOC"}

@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dnsEncode = exports.namehash = exports.isValidName = exports.ensNormalize = void 0;
const keccak_js_1 = require("../crypto/keccak.js");
const index_js_1 = require("../utils/index.js");
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../utils/index.js");
//import { ens_normalize } from "./ens-normalize/lib";
// @TOOD:
function ens_normalize(name) {
@ -17,7 +17,7 @@ function checkComponent(comp) {
return comp;
}
function ensNameSplit(name) {
const bytes = (0, index_js_1.toUtf8Bytes)(ens_normalize(name));
const bytes = (0, index_js_2.toUtf8Bytes)(ens_normalize(name));
const comps = [];
if (name.length === 0) {
return comps;
@ -39,7 +39,7 @@ function ensNameSplit(name) {
return comps;
}
function ensNormalize(name) {
return ensNameSplit(name).map((comp) => (0, index_js_1.toUtf8String)(comp)).join(".");
return ensNameSplit(name).map((comp) => (0, index_js_2.toUtf8String)(comp)).join(".");
}
exports.ensNormalize = ensNormalize;
function isValidName(name) {
@ -53,18 +53,18 @@ exports.isValidName = isValidName;
function namehash(name) {
/* istanbul ignore if */
if (typeof (name) !== "string") {
index_js_1.logger.throwArgumentError("invalid ENS name; not a string", "name", name);
(0, index_js_2.throwArgumentError)("invalid ENS name; not a string", "name", name);
}
let result = Zeros;
const comps = ensNameSplit(name);
while (comps.length) {
result = (0, keccak_js_1.keccak256)((0, index_js_1.concat)([result, (0, keccak_js_1.keccak256)((comps.pop()))]));
result = (0, index_js_1.keccak256)((0, index_js_2.concat)([result, (0, index_js_1.keccak256)((comps.pop()))]));
}
return (0, index_js_1.hexlify)(result);
return (0, index_js_2.hexlify)(result);
}
exports.namehash = namehash;
function dnsEncode(name) {
return (0, index_js_1.hexlify)((0, index_js_1.concat)(ensNameSplit(name).map((comp) => {
return (0, index_js_2.hexlify)((0, index_js_2.concat)(ensNameSplit(name).map((comp) => {
// DNS does not allow components over 63 bytes in length
if (comp.length > 63) {
throw new Error("invalid DNS encoded entry; length exceeds 63 bytes");

@ -1 +1 @@
{"version":3,"file":"namehash.js","sourceRoot":"","sources":["../../src.ts/hash/namehash.ts"],"names":[],"mappings":";;;AACA,mDAAgD;AAChD,gDAAuF;AAGvF,sDAAsD;AACtD,SAAS;AACT,SAAS,aAAa,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AACjC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEd,SAAS,cAAc,CAAC,IAAgB;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KAAE;IAChF,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAC9B,MAAM,KAAK,GAAG,IAAA,sBAAW,EAAC,aAAa,CAAC,IAAI,CAAC,CAA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AM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC9C,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACnB,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IAEjB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAChB,CAAC;AAbD,8BAaC"}

@ -1,9 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.solidityPackedSha256 = exports.test = exports.solidityPackedKeccak256 = exports.solidityPacked = void 0;
const index_js_1 = require("../utils/index.js");
const keccak_js_1 = require("../crypto/keccak.js");
const sha2_js_1 = require("../crypto/sha2.js");
exports.solidityPackedSha256 = exports.solidityPackedKeccak256 = exports.solidityPacked = void 0;
const index_js_1 = require("../crypto/index.js");
const index_js_2 = require("../utils/index.js");
const regexBytes = new RegExp("^bytes([0-9]+)$");
const regexNumber = new RegExp("^(u?int)([0-9]*)$");
const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$");
@ -11,43 +10,43 @@ function _pack(type, value, isArray) {
switch (type) {
case "address":
if (isArray) {
return index_js_1.logger.getBytes((0, index_js_1.zeroPadValue)(value, 32));
return (0, index_js_2.getBytes)((0, index_js_2.zeroPadValue)(value, 32));
}
return index_js_1.logger.getBytes(value);
return (0, index_js_2.getBytes)(value);
case "string":
return (0, index_js_1.toUtf8Bytes)(value);
return (0, index_js_2.toUtf8Bytes)(value);
case "bytes":
return index_js_1.logger.getBytes(value);
return (0, index_js_2.getBytes)(value);
case "bool":
value = (!!value ? "0x01" : "0x00");
if (isArray) {
return index_js_1.logger.getBytes((0, index_js_1.zeroPadValue)(value, 32));
return (0, index_js_2.getBytes)((0, index_js_2.zeroPadValue)(value, 32));
}
return index_js_1.logger.getBytes(value);
return (0, index_js_2.getBytes)(value);
}
let match = type.match(regexNumber);
if (match) {
let size = parseInt(match[2] || "256");
if ((match[2] && String(size) !== match[2]) || (size % 8 !== 0) || size === 0 || size > 256) {
return index_js_1.logger.throwArgumentError("invalid number type", "type", type);
return (0, index_js_2.throwArgumentError)("invalid number type", "type", type);
}
if (isArray) {
size = 256;
}
value = (0, index_js_1.toTwos)(value, size);
return index_js_1.logger.getBytes((0, index_js_1.zeroPadValue)((0, index_js_1.toArray)(value), size / 8));
value = (0, index_js_2.toTwos)(value, size);
return (0, index_js_2.getBytes)((0, index_js_2.zeroPadValue)((0, index_js_2.toArray)(value), size / 8));
}
match = type.match(regexBytes);
if (match) {
const size = parseInt(match[1]);
if (String(size) !== match[1] || size === 0 || size > 32) {
return index_js_1.logger.throwArgumentError("invalid bytes type", "type", type);
return (0, index_js_2.throwArgumentError)("invalid bytes type", "type", type);
}
if ((0, index_js_1.dataLength)(value) !== size) {
return index_js_1.logger.throwArgumentError(`invalid value for ${type}`, "value", value);
if ((0, index_js_2.dataLength)(value) !== size) {
return (0, index_js_2.throwArgumentError)(`invalid value for ${type}`, "value", value);
}
if (isArray) {
return index_js_1.logger.getBytes((0, index_js_1.zeroPadBytes)(value, 32));
return (0, index_js_2.getBytes)((0, index_js_2.zeroPadBytes)(value, 32));
}
return value;
}
@ -56,26 +55,26 @@ function _pack(type, value, isArray) {
const baseType = match[1];
const count = parseInt(match[2] || String(value.length));
if (count != value.length) {
index_js_1.logger.throwArgumentError(`invalid array length for ${type}`, "value", value);
(0, index_js_2.throwArgumentError)(`invalid array length for ${type}`, "value", value);
}
const result = [];
value.forEach(function (value) {
result.push(_pack(baseType, value, true));
});
return index_js_1.logger.getBytes((0, index_js_1.concat)(result));
return (0, index_js_2.getBytes)((0, index_js_2.concat)(result));
}
return index_js_1.logger.throwArgumentError("invalid type", "type", type);
return (0, index_js_2.throwArgumentError)("invalid type", "type", type);
}
// @TODO: Array Enum
function solidityPacked(types, values) {
if (types.length != values.length) {
index_js_1.logger.throwArgumentError("wrong number of values; expected ${ types.length }", "values", values);
(0, index_js_2.throwArgumentError)("wrong number of values; expected ${ types.length }", "values", values);
}
const tight = [];
types.forEach(function (type, index) {
tight.push(_pack(type, values[index]));
});
return (0, index_js_1.hexlify)((0, index_js_1.concat)(tight));
return (0, index_js_2.hexlify)((0, index_js_2.concat)(tight));
}
exports.solidityPacked = solidityPacked;
/**
@ -93,19 +92,11 @@ exports.solidityPacked = solidityPacked;
* @see https://docs.soliditylang.org/en/v0.8.14/abi-spec.html#non-standard-packed-mode
*/
function solidityPackedKeccak256(types, values) {
return (0, keccak_js_1.keccak256)(solidityPacked(types, values));
return (0, index_js_1.keccak256)(solidityPacked(types, values));
}
exports.solidityPackedKeccak256 = solidityPackedKeccak256;
/**
* Test Function, for fun
*
* @param foo - something fun
*/
function test(foo) {
}
exports.test = test;
function solidityPackedSha256(types, values) {
return (0, sha2_js_1.sha256)(solidityPacked(types, values));
return (0, index_js_1.sha256)(solidityPacked(types, values));
}
exports.solidityPackedSha256 = solidityPackedSha256;
//# sourceMappingURL=solidity.js.map

@ -1 +1 @@
{"version":3,"file":"solidity.js","sourceRoot":"","sources":["../../src.ts/hash/solidity.ts"],"names":[],"mappings":";;;AAAA,gDAE2B;AAC3B,mDAA8D;AAC9D,+CAAsD;AAGtD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACjD,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACpD,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAGtD,SAAS,KAAK,CAAC,IAAY,EAAE,KAAU,EAAE,OAAiB;IACtD,QAAO,IAAI,EAAE;QACT,KAAK,SAAS;YACV,IAAI,OAAO,EAAE;gBAAE,OAAO,iBAAM,CAAC,QAAQ,CAAC,IAAA,uBAAY,EAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;aAAE;YACjE,OAAO,iBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC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AAO,IAAA,oBAAU,EAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACrD,CAAC;AAFD,0DAEC;AAED,SAAgB,oBAAoB,CAAC,KAA4B,EAAE,MAA0B;IACzF,OAAO,IAAA,iBAAO,EAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAClD,CAAC;AAFD,oDAEC"}

@ -6,7 +6,6 @@ const index_js_1 = require("../address/index.js");
const index_js_2 = require("../crypto/index.js");
const index_js_3 = require("../utils/index.js");
const id_js_1 = require("./id.js");
const logger_js_1 = require("../utils/logger.js");
const padding = new Uint8Array(32);
padding.fill(0);
const BN__1 = BigInt(-1);
@ -16,7 +15,7 @@ const BN_MAX_UINT256 = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffff
;
;
function hexPadRight(value) {
const bytes = logger_js_1.logger.getBytes(value);
const bytes = (0, index_js_3.getBytes)(value);
const padOffset = bytes.length % 32;
if (padOffset) {
return (0, index_js_3.concat)([bytes, padding.slice(padOffset)]);
@ -38,7 +37,7 @@ const domainFieldNames = [
function checkString(key) {
return function (value) {
if (typeof (value) !== "string") {
logger_js_1.logger.throwArgumentError(`invalid domain value for ${JSON.stringify(key)}`, `domain.${key}`, value);
(0, index_js_3.throwArgumentError)(`invalid domain value for ${JSON.stringify(key)}`, `domain.${key}`, value);
}
return value;
};
@ -47,19 +46,19 @@ const domainChecks = {
name: checkString("name"),
version: checkString("version"),
chainId: function (value) {
return logger_js_1.logger.getBigInt(value, "domain.chainId");
return (0, index_js_3.getBigInt)(value, "domain.chainId");
},
verifyingContract: function (value) {
try {
return (0, index_js_1.getAddress)(value).toLowerCase();
}
catch (error) { }
return logger_js_1.logger.throwArgumentError(`invalid domain value "verifyingContract"`, "domain.verifyingContract", value);
return (0, index_js_3.throwArgumentError)(`invalid domain value "verifyingContract"`, "domain.verifyingContract", value);
},
salt: function (value) {
const bytes = logger_js_1.logger.getBytes(value, "domain.salt");
const bytes = (0, index_js_3.getBytes)(value, "domain.salt");
if (bytes.length !== 32) {
logger_js_1.logger.throwArgumentError(`invalid domain value "salt"`, "domain.salt", value);
(0, index_js_3.throwArgumentError)(`invalid domain value "salt"`, "domain.salt", value);
}
return (0, index_js_3.hexlify)(bytes);
}
@ -72,14 +71,14 @@ function getBaseEncoder(type) {
const signed = (match[1] === "");
const width = parseInt(match[2] || "256");
if (width % 8 !== 0 || width > 256 || (match[2] && match[2] !== String(width))) {
logger_js_1.logger.throwArgumentError("invalid numeric width", "type", type);
(0, index_js_3.throwArgumentError)("invalid numeric width", "type", type);
}
const boundsUpper = (0, index_js_3.mask)(BN_MAX_UINT256, signed ? (width - 1) : width);
const boundsLower = signed ? ((boundsUpper + BN_1) * BN__1) : BN_0;
return function (_value) {
const value = logger_js_1.logger.getBigInt(_value, "value");
const value = (0, index_js_3.getBigInt)(_value, "value");
if (value < boundsLower || value > boundsUpper) {
logger_js_1.logger.throwArgumentError(`value out-of-bounds for ${type}`, "value", value);
(0, index_js_3.throwArgumentError)(`value out-of-bounds for ${type}`, "value", value);
}
return (0, index_js_3.toHex)((0, index_js_3.toTwos)(value, 256), 32);
};
@ -91,12 +90,12 @@ function getBaseEncoder(type) {
if (match) {
const width = parseInt(match[1]);
if (width === 0 || width > 32 || match[1] !== String(width)) {
logger_js_1.logger.throwArgumentError("invalid bytes width", "type", type);
(0, index_js_3.throwArgumentError)("invalid bytes width", "type", type);
}
return function (value) {
const bytes = logger_js_1.logger.getBytes(value);
const bytes = (0, index_js_3.getBytes)(value);
if (bytes.length !== width) {
logger_js_1.logger.throwArgumentError(`invalid length for ${type}`, "value", value);
(0, index_js_3.throwArgumentError)(`invalid length for ${type}`, "value", value);
}
return hexPadRight(value);
};
@ -149,13 +148,13 @@ class TypedDataEncoder {
for (const field of types[name]) {
// Check each field has a unique name
if (uniqueNames.has(field.name)) {
logger_js_1.logger.throwArgumentError(`duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", types);
(0, index_js_3.throwArgumentError)(`duplicate variable name ${JSON.stringify(field.name)} in ${JSON.stringify(name)}`, "types", types);
}
uniqueNames.add(field.name);
// Get the base type (drop any array specifiers)
const baseType = (field.type.match(/^([^\x5b]*)(\x5b|$)/))[1] || null;
if (baseType === name) {
logger_js_1.logger.throwArgumentError(`circular type reference to ${JSON.stringify(baseType)}`, "types", types);
(0, index_js_3.throwArgumentError)(`circular type reference to ${JSON.stringify(baseType)}`, "types", types);
}
// Is this a base encoding type?
const encoder = getBaseEncoder(baseType);
@ -163,7 +162,7 @@ class TypedDataEncoder {
continue;
}
if (!parents.has(baseType)) {
logger_js_1.logger.throwArgumentError(`unknown type ${JSON.stringify(baseType)}`, "types", types);
(0, index_js_3.throwArgumentError)(`unknown type ${JSON.stringify(baseType)}`, "types", types);
}
// Add linkage
parents.get(baseType).push(name);
@ -173,16 +172,16 @@ class TypedDataEncoder {
// Deduce the primary type
const primaryTypes = Array.from(parents.keys()).filter((n) => (parents.get(n).length === 0));
if (primaryTypes.length === 0) {
logger_js_1.logger.throwArgumentError("missing primary type", "types", types);
(0, index_js_3.throwArgumentError)("missing primary type", "types", types);
}
else if (primaryTypes.length > 1) {
logger_js_1.logger.throwArgumentError(`ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", types);
(0, index_js_3.throwArgumentError)(`ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", types);
}
(0, index_js_3.defineProperties)(this, { primaryType: primaryTypes[0] });
// Check for circular type references
function checkCircular(type, found) {
if (found.has(type)) {
logger_js_1.logger.throwArgumentError(`circular type reference to ${JSON.stringify(type)}`, "types", types);
(0, index_js_3.throwArgumentError)(`circular type reference to ${JSON.stringify(type)}`, "types", types);
}
found.add(type);
for (const child of links.get(type)) {
@ -230,7 +229,7 @@ class TypedDataEncoder {
const length = parseInt(match[3]);
return (value) => {
if (length >= 0 && value.length !== length) {
logger_js_1.logger.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value);
(0, index_js_3.throwArgumentError)("array length mismatch; expected length ${ arrayLength }", "value", value);
}
let result = value.map(subEncoder);
if (this.#fullTypes.has(subtype)) {
@ -255,12 +254,12 @@ class TypedDataEncoder {
return (0, index_js_3.concat)(values);
};
}
return logger_js_1.logger.throwArgumentError(`unknown type: ${type}`, "type", type);
return (0, index_js_3.throwArgumentError)(`unknown type: ${type}`, "type", type);
}
encodeType(name) {
const result = this.#fullTypes.get(name);
if (!result) {
return logger_js_1.logger.throwArgumentError(`unknown type: ${JSON.stringify(name)}`, "name", name);
return (0, index_js_3.throwArgumentError)(`unknown type: ${JSON.stringify(name)}`, "name", name);
}
return result;
}
@ -290,7 +289,7 @@ class TypedDataEncoder {
const subtype = match[1];
const length = parseInt(match[3]);
if (length >= 0 && value.length !== length) {
logger_js_1.logger.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value);
(0, index_js_3.throwArgumentError)("array length mismatch; expected length ${ arrayLength }", "value", value);
}
return value.map((v) => this._visit(subtype, v, callback));
}
@ -302,7 +301,7 @@ class TypedDataEncoder {
return accum;
}, {});
}
return logger_js_1.logger.throwArgumentError(`unknown type: ${type}`, "type", type);
return (0, index_js_3.throwArgumentError)(`unknown type: ${type}`, "type", type);
}
visit(value, callback) {
return this._visit(this.primaryType, value, callback);
@ -321,7 +320,7 @@ class TypedDataEncoder {
for (const name in domain) {
const type = domainFieldTypes[name];
if (!type) {
logger_js_1.logger.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(name)}`, "domain", domain);
(0, index_js_3.throwArgumentError)(`invalid typed-data domain key: ${JSON.stringify(name)}`, "domain", domain);
}
domainFields.push({ name, type });
}
@ -393,7 +392,7 @@ class TypedDataEncoder {
const encoder = TypedDataEncoder.from(types);
const typesWithDomain = Object.assign({}, types);
if (typesWithDomain.EIP712Domain) {
logger_js_1.logger.throwArgumentError("types must not contain EIP712Domain type", "types.EIP712Domain", types);
(0, index_js_3.throwArgumentError)("types must not contain EIP712Domain type", "types.EIP712Domain", types);
}
else {
typesWithDomain.EIP712Domain = domainTypes;
@ -407,11 +406,11 @@ class TypedDataEncoder {
message: encoder.visit(value, (type, value) => {
// bytes
if (type.match(/^bytes(\d*)/)) {
return (0, index_js_3.hexlify)(logger_js_1.logger.getBytes(value));
return (0, index_js_3.hexlify)((0, index_js_3.getBytes)(value));
}
// uint or int
if (type.match(/^u?int/)) {
return logger_js_1.logger.getBigInt(value).toString();
return (0, index_js_3.getBigInt)(value).toString();
}
switch (type) {
case "address":
@ -420,11 +419,11 @@ class TypedDataEncoder {
return !!value;
case "string":
if (typeof (value) !== "string") {
logger_js_1.logger.throwArgumentError(`invalid string`, "value", value);
(0, index_js_3.throwArgumentError)(`invalid string`, "value", value);
}
return value;
}
return logger_js_1.logger.throwArgumentError("unsupported type", "type", type);
return (0, index_js_3.throwArgumentError)("unsupported type", "type", type);
})
};
}

File diff suppressed because one or more lines are too long

@ -9,14 +9,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractProvider = exports.copyRequest = exports.UnmanagedSubscriber = void 0;
const index_js_1 = require("../address/index.js");
const data_js_1 = require("../utils/data.js");
const errors_js_1 = require("../utils/errors.js");
const fetch_js_1 = require("../utils/fetch.js");
const maths_js_1 = require("../utils/maths.js");
const index_js_2 = require("../utils/index.js");
const index_js_3 = require("../utils/index.js");
;
const logger_js_1 = require("../utils/logger.js");
const ens_resolver_js_1 = require("./ens-resolver.js");
const network_js_1 = require("./network.js");
const provider_js_1 = require("./provider.js");
@ -83,7 +76,7 @@ async function getSubscription(_event, provider) {
}
}
}
if ((0, data_js_1.isHexString)(_event, 32)) {
if ((0, index_js_2.isHexString)(_event, 32)) {
const hash = _event.toLowerCase();
return { type: "transaction", tag: getTag("tx", { hash }), hash };
}
@ -109,7 +102,7 @@ async function getSubscription(_event, provider) {
const addresses = [];
const promises = [];
const addAddress = (addr) => {
if ((0, data_js_1.isHexString)(addr)) {
if ((0, index_js_2.isHexString)(addr)) {
addresses.push(addr);
}
else {
@ -131,7 +124,7 @@ async function getSubscription(_event, provider) {
}
return { filter, tag: getTag("event", filter), type: "event" };
}
return logger_js_1.logger.throwArgumentError("unknown ProviderEvent", "event", _event);
return (0, index_js_2.throwArgumentError)("unknown ProviderEvent", "event", _event);
}
function getTime() { return (new Date()).getTime(); }
function copyRequest(tx) {
@ -224,7 +217,7 @@ class AbstractProvider {
// value.status = response.statusCode;
// return value;
//});
const request = new fetch_js_1.FetchRequest(href);
const request = new index_js_2.FetchRequest(href);
if (url.indexOf("{data}") === -1) {
request.body = { data, sender };
}
@ -242,7 +235,7 @@ class AbstractProvider {
catch (error) { }
// 4xx indicates the result is not present; stop
if (resp.statusCode >= 400 && resp.statusCode < 500) {
return logger_js_1.logger.throwError(`response not found during CCIP fetch: ${errorMessage}`, "OFFCHAIN_FAULT", {
return (0, index_js_2.throwError)(`response not found during CCIP fetch: ${errorMessage}`, "OFFCHAIN_FAULT", {
reason: "404_MISSING_RESOURCE",
transaction: tx, info: { url, errorMessage }
});
@ -250,7 +243,7 @@ class AbstractProvider {
// 5xx indicates server issue; try the next url
errorMessages.push(errorMessage);
}
return logger_js_1.logger.throwError(`error encountered during CCIP fetch: ${errorMessages.map((m) => JSON.stringify(m)).join(", ")}`, "OFFCHAIN_FAULT", {
return (0, index_js_2.throwError)(`error encountered during CCIP fetch: ${errorMessages.map((m) => JSON.stringify(m)).join(", ")}`, "OFFCHAIN_FAULT", {
reason: "500_SERVER_ERROR",
transaction: tx, info: { urls, errorMessages }
});
@ -259,21 +252,21 @@ class AbstractProvider {
return tx;
}
_detectNetwork() {
return logger_js_1.logger.throwError("sub-classes must implement this", "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)("sub-classes must implement this", "UNSUPPORTED_OPERATION", {
operation: "_detectNetwork"
});
}
// Sub-classes should override this and handle PerformActionRequest requests, calling
// the super for any unhandled actions.
async _perform(req) {
return logger_js_1.logger.throwError(`unsupported method: ${req.method}`, "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)(`unsupported method: ${req.method}`, "UNSUPPORTED_OPERATION", {
operation: req.method,
info: req
});
}
// State
async getBlockNumber() {
return logger_js_1.logger.getNumber(await this.#perform({ method: "getBlockNumber" }), "%response");
return (0, index_js_2.getNumber)(await this.#perform({ method: "getBlockNumber" }), "%response");
}
// @TODO: Make this string | Promsie<string> so no await needed if sync is possible
_getAddress(address) {
@ -301,19 +294,19 @@ class AbstractProvider {
case "finalized":
return blockTag;
}
if ((0, data_js_1.isHexString)(blockTag)) {
if ((0, data_js_1.dataLength)(blockTag) === 32) {
if ((0, index_js_2.isHexString)(blockTag)) {
if ((0, index_js_2.dataLength)(blockTag) === 32) {
return blockTag;
}
return (0, maths_js_1.toQuantity)(blockTag);
return (0, index_js_2.toQuantity)(blockTag);
}
if (typeof (blockTag) === "number") {
if (blockTag >= 0) {
return (0, maths_js_1.toQuantity)(blockTag);
return (0, index_js_2.toQuantity)(blockTag);
}
return this.getBlockNumber().then((b) => (0, maths_js_1.toQuantity)(b + blockTag));
return this.getBlockNumber().then((b) => (0, index_js_2.toQuantity)(b + blockTag));
}
return logger_js_1.logger.throwArgumentError("invalid blockTag", "blockTag", blockTag);
return (0, index_js_2.throwArgumentError)("invalid blockTag", "blockTag", blockTag);
}
async getNetwork() {
// No explicit network was set and this is our first time
@ -348,7 +341,7 @@ class AbstractProvider {
}
else {
// Otherwise, we do not allow changes to the underlying network
logger_js_1.logger.throwError(`network changed: ${expected.chainId} => ${actual.chainId} `, "NETWORK_ERROR", {
(0, index_js_2.throwError)(`network changed: ${expected.chainId} => ${actual.chainId} `, "NETWORK_ERROR", {
event: "changed"
});
}
@ -361,7 +354,7 @@ class AbstractProvider {
gasPrice: ((async () => {
try {
const gasPrice = await this.#perform({ method: "getGasPrice" });
return logger_js_1.logger.getBigInt(gasPrice, "%response");
return (0, index_js_2.getBigInt)(gasPrice, "%response");
}
catch (error) { }
return null;
@ -393,40 +386,40 @@ class AbstractProvider {
}
async estimateGas(_tx) {
const transaction = await this._getTransaction(_tx);
return logger_js_1.logger.getBigInt(await this.#perform({
return (0, index_js_2.getBigInt)(await this.#perform({
method: "estimateGas", transaction
}), "%response");
}
async #call(tx, blockTag, attempt) {
if (attempt >= MAX_CCIP_REDIRECTS) {
logger_js_1.logger.throwError("CCIP read exceeded maximum redirections", "OFFCHAIN_FAULT", {
(0, index_js_2.throwError)("CCIP read exceeded maximum redirections", "OFFCHAIN_FAULT", {
reason: "TOO_MANY_REDIRECTS",
transaction: Object.assign({}, tx, { blockTag, enableCcipRead: true })
});
}
const transaction = copyRequest(tx);
try {
return (0, data_js_1.hexlify)(await this._perform({ method: "call", transaction, blockTag }));
return (0, index_js_2.hexlify)(await this._perform({ method: "call", transaction, blockTag }));
}
catch (error) {
// CCIP Read OffchainLookup
if (!this.disableCcipRead && (0, errors_js_1.isCallException)(error) && attempt >= 0 && blockTag === "latest" && transaction.to != null && (0, data_js_1.dataSlice)(error.data, 0, 4) === "0x556f1830") {
if (!this.disableCcipRead && (0, index_js_2.isCallException)(error) && attempt >= 0 && blockTag === "latest" && transaction.to != null && (0, index_js_2.dataSlice)(error.data, 0, 4) === "0x556f1830") {
const data = error.data;
const txSender = await (0, index_js_1.resolveAddress)(transaction.to, this);
// Parse the CCIP Read Arguments
let ccipArgs;
try {
ccipArgs = parseOffchainLookup((0, data_js_1.dataSlice)(error.data, 4));
ccipArgs = parseOffchainLookup((0, index_js_2.dataSlice)(error.data, 4));
}
catch (error) {
return logger_js_1.logger.throwError(error.message, "OFFCHAIN_FAULT", {
return (0, index_js_2.throwError)(error.message, "OFFCHAIN_FAULT", {
reason: "BAD_DATA",
transaction, info: { data }
});
}
// Check the sender of the OffchainLookup matches the transaction
if (ccipArgs.sender.toLowerCase() !== txSender.toLowerCase()) {
return logger_js_1.logger.throwError("CCIP Read sender mismatch", "CALL_EXCEPTION", {
return (0, index_js_2.throwError)("CCIP Read sender mismatch", "CALL_EXCEPTION", {
data, transaction,
errorSignature: "OffchainLookup(address,string[],bytes,bytes4,bytes)",
errorName: "OffchainLookup",
@ -435,14 +428,14 @@ class AbstractProvider {
}
const ccipResult = await this.ccipReadFetch(transaction, ccipArgs.calldata, ccipArgs.urls);
if (ccipResult == null) {
return logger_js_1.logger.throwError("CCIP Read failed to fetch data", "OFFCHAIN_FAULT", {
return (0, index_js_2.throwError)("CCIP Read failed to fetch data", "OFFCHAIN_FAULT", {
reason: "FETCH_FAILED",
transaction, info: { data: error.data, errorArgs: ccipArgs.errorArgs }
});
}
return this.#call({
to: txSender,
data: (0, data_js_1.concat)([
data: (0, index_js_2.concat)([
ccipArgs.selector, encodeBytes([ccipResult, ccipArgs.extraData])
]),
}, blockTag, attempt + 1);
@ -466,17 +459,17 @@ class AbstractProvider {
return await this.#perform(Object.assign(request, { address, blockTag }));
}
async getBalance(address, blockTag) {
return logger_js_1.logger.getBigInt(await this.#getAccountValue({ method: "getBalance" }, address, blockTag), "%response");
return (0, index_js_2.getBigInt)(await this.#getAccountValue({ method: "getBalance" }, address, blockTag), "%response");
}
async getTransactionCount(address, blockTag) {
return logger_js_1.logger.getNumber(await this.#getAccountValue({ method: "getTransactionCount" }, address, blockTag), "%response");
return (0, index_js_2.getNumber)(await this.#getAccountValue({ method: "getTransactionCount" }, address, blockTag), "%response");
}
async getCode(address, blockTag) {
return (0, data_js_1.hexlify)(await this.#getAccountValue({ method: "getCode" }, address, blockTag));
return (0, index_js_2.hexlify)(await this.#getAccountValue({ method: "getCode" }, address, blockTag));
}
async getStorageAt(address, _position, blockTag) {
const position = logger_js_1.logger.getBigInt(_position, "position");
return (0, data_js_1.hexlify)(await this.#getAccountValue({ method: "getStorageAt", position }, address, blockTag));
const position = (0, index_js_2.getBigInt)(_position, "position");
return (0, index_js_2.hexlify)(await this.#getAccountValue({ method: "getStorageAt", position }, address, blockTag));
}
// Write
async broadcastTransaction(signedTx) {
@ -484,7 +477,7 @@ class AbstractProvider {
return {};
}
async #getBlock(block, includeTransactions) {
if ((0, data_js_1.isHexString)(block, 32)) {
if ((0, index_js_2.isHexString)(block, 32)) {
return await this.#perform({
method: "getBlock", blockHash: block, includeTransactions
});
@ -539,7 +532,7 @@ class AbstractProvider {
if (result == null) {
return null;
}
return (0, data_js_1.hexlify)(result);
return (0, index_js_2.hexlify)(result);
}
_getFilter(filter) {
// Create a canonical representation of the topics
@ -628,7 +621,7 @@ class AbstractProvider {
}
// ENS
_getProvider(chainId) {
return logger_js_1.logger.throwError("provider cannot connect to target network", "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)("provider cannot connect to target network", "UNSUPPORTED_OPERATION", {
operation: "_getProvider()"
});
}
@ -643,6 +636,9 @@ class AbstractProvider {
return null;
}
async resolveName(name) {
if ((0, index_js_2.isHexString)(name, 20)) {
return name;
}
//if (typeof(name) === "string") {
const resolver = await this.getResolver(name);
if (resolver) {
@ -696,7 +692,7 @@ class AbstractProvider {
}
timer = null;
this.off("block", listener);
reject(logger_js_1.logger.makeError("timeout", "TIMEOUT", { reason: "timeout" }));
reject((0, index_js_2.makeError)("timeout", "TIMEOUT", { reason: "timeout" }));
}, timeout);
}
listener(await this.getBlockNumber());
@ -935,7 +931,7 @@ class AbstractProvider {
if (this.#pausedState == !!dropWhilePaused) {
return;
}
return logger_js_1.logger.throwError("cannot change pause type; resume first", "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)("cannot change pause type; resume first", "UNSUPPORTED_OPERATION", {
operation: "pause"
});
}
@ -974,7 +970,7 @@ function _parseString(result, start) {
try {
const bytes = _parseBytes(result, start);
if (bytes) {
return (0, index_js_3.toUtf8String)(bytes);
return (0, index_js_2.toUtf8String)(bytes);
}
}
catch (error) { }
@ -985,15 +981,15 @@ function _parseBytes(result, start) {
return null;
}
try {
const offset = logger_js_1.logger.getNumber((0, data_js_1.dataSlice)(result, start, start + 32));
const length = logger_js_1.logger.getNumber((0, data_js_1.dataSlice)(result, offset, offset + 32));
return (0, data_js_1.dataSlice)(result, offset + 32, offset + 32 + length);
const offset = (0, index_js_2.getNumber)((0, index_js_2.dataSlice)(result, start, start + 32));
const length = (0, index_js_2.getNumber)((0, index_js_2.dataSlice)(result, offset, offset + 32));
return (0, index_js_2.dataSlice)(result, offset + 32, offset + 32 + length);
}
catch (error) { }
return null;
}
function numPad(value) {
const result = (0, maths_js_1.toArray)(value);
const result = (0, index_js_2.toArray)(value);
if (result.length > 32) {
throw new Error("internal; should not happen");
}
@ -1020,7 +1016,7 @@ function encodeBytes(datas) {
byteCount += 32;
}
for (let i = 0; i < datas.length; i++) {
const data = logger_js_1.logger.getBytes(datas[i]);
const data = (0, index_js_2.getBytes)(datas[i]);
// Update the bytes offset
result[i] = numPad(byteCount);
// The length and padded value of data
@ -1028,27 +1024,27 @@ function encodeBytes(datas) {
result.push(bytesPad(data));
byteCount += 32 + Math.ceil(data.length / 32) * 32;
}
return (0, data_js_1.concat)(result);
return (0, index_js_2.concat)(result);
}
const zeros = "0x0000000000000000000000000000000000000000000000000000000000000000";
function parseOffchainLookup(data) {
const result = {
sender: "", urls: [], calldata: "", selector: "", extraData: "", errorArgs: []
};
if ((0, data_js_1.dataLength)(data) < 5 * 32) {
if ((0, index_js_2.dataLength)(data) < 5 * 32) {
throw new Error("insufficient OffchainLookup data");
}
const sender = (0, data_js_1.dataSlice)(data, 0, 32);
if ((0, data_js_1.dataSlice)(sender, 0, 12) !== (0, data_js_1.dataSlice)(zeros, 0, 12)) {
const sender = (0, index_js_2.dataSlice)(data, 0, 32);
if ((0, index_js_2.dataSlice)(sender, 0, 12) !== (0, index_js_2.dataSlice)(zeros, 0, 12)) {
throw new Error("corrupt OffchainLookup sender");
}
result.sender = (0, data_js_1.dataSlice)(sender, 12);
result.sender = (0, index_js_2.dataSlice)(sender, 12);
// Read the URLs from the response
try {
const urls = [];
const urlsOffset = logger_js_1.logger.getNumber((0, data_js_1.dataSlice)(data, 32, 64));
const urlsLength = logger_js_1.logger.getNumber((0, data_js_1.dataSlice)(data, urlsOffset, urlsOffset + 32));
const urlsData = (0, data_js_1.dataSlice)(data, urlsOffset + 32);
const urlsOffset = (0, index_js_2.getNumber)((0, index_js_2.dataSlice)(data, 32, 64));
const urlsLength = (0, index_js_2.getNumber)((0, index_js_2.dataSlice)(data, urlsOffset, urlsOffset + 32));
const urlsData = (0, index_js_2.dataSlice)(data, urlsOffset + 32);
for (let u = 0; u < urlsLength; u++) {
const url = _parseString(urlsData, u * 32);
if (url == null) {
@ -1073,10 +1069,10 @@ function parseOffchainLookup(data) {
throw new Error("corrupt OffchainLookup calldata");
}
// Get the callbackSelector (bytes4)
if ((0, data_js_1.dataSlice)(data, 100, 128) !== (0, data_js_1.dataSlice)(zeros, 0, 28)) {
if ((0, index_js_2.dataSlice)(data, 100, 128) !== (0, index_js_2.dataSlice)(zeros, 0, 28)) {
throw new Error("corrupt OffchainLookup callbaackSelector");
}
result.selector = (0, data_js_1.dataSlice)(data, 96, 100);
result.selector = (0, index_js_2.dataSlice)(data, 96, 100);
// Get the extra data to send back to the contract as context
try {
const extraData = _parseBytes(data, 128);

File diff suppressed because one or more lines are too long

@ -1,7 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WrappedSigner = exports.VoidSigner = exports.AbstractSigner = void 0;
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../transaction/index.js");
const index_js_2 = require("../utils/index.js");
class AbstractSigner {
@ -13,7 +12,7 @@ class AbstractSigner {
if (this.provider) {
return this.provider;
}
return logger_js_1.logger.throwError("missing provider", "UNSUPPORTED_OPERATION", { operation });
return (0, index_js_2.throwError)("missing provider", "UNSUPPORTED_OPERATION", { operation });
}
async getNonce(blockTag) {
return this.#checkProvider("getTransactionCount").getTransactionCount(await this.getAddress(), blockTag);
@ -25,7 +24,7 @@ class AbstractSigner {
if (pop.to != null) {
pop.to = provider.resolveName(pop.to).then((to) => {
if (to == null) {
return logger_js_1.logger.throwArgumentError("transaction to ENS name not configured", "tx.to", pop.to);
return (0, index_js_2.throwArgumentError)("transaction to ENS name not configured", "tx.to", pop.to);
}
return to;
});
@ -37,7 +36,7 @@ class AbstractSigner {
this.resolveName(from)
]).then(([address, from]) => {
if (!from || address.toLowerCase() !== from.toLowerCase()) {
return logger_js_1.logger.throwArgumentError("transaction from mismatch", "tx.from", from);
return (0, index_js_2.throwArgumentError)("transaction from mismatch", "tx.from", from);
}
return address;
});
@ -56,7 +55,21 @@ class AbstractSigner {
if (pop.gasLimit == null) {
pop.gasLimit = await this.estimateGas(pop);
}
// Populate the chain ID
const network = await (this.provider).getNetwork();
if (pop.chainId != null) {
const chainId = (0, index_js_2.getBigInt)(pop.chainId);
if (chainId !== network.chainId) {
(0, index_js_2.throwArgumentError)("transaction chainId mismatch", "tx.chainId", tx.chainId);
}
}
else {
pop.chainId = network.chainId;
}
//@TOOD: Don't await all over the place; save them up for
// the end for better batching
//@TODO: Copy type logic from AbstractSigner in v5
// Test how many batches is actually sent for sending a tx; compare before/after
return await (0, index_js_2.resolveProperties)(pop);
}
async estimateGas(tx) {
@ -87,7 +100,7 @@ class VoidSigner extends AbstractSigner {
return new VoidSigner(this.address, provider);
}
#throwUnsupported(suffix, operation) {
return logger_js_1.logger.throwError(`VoidSigner cannot sign ${suffix}`, "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)(`VoidSigner cannot sign ${suffix}`, "UNSUPPORTED_OPERATION", {
operation
});
}

File diff suppressed because one or more lines are too long

@ -4,18 +4,15 @@ exports.EnsResolver = exports.BasicMulticoinProviderPlugin = exports.MulticoinPr
const hashes_js_1 = require("../constants/hashes.js");
const index_js_1 = require("../hash/index.js");
const index_js_2 = require("../utils/index.js");
const data_js_1 = require("../utils/data.js");
const fetch_js_1 = require("../utils/fetch.js");
const logger_js_1 = require("../utils/logger.js");
const BN_1 = BigInt(1);
const Empty = new Uint8Array([]);
function parseBytes(result, start) {
if (result === "0x") {
return null;
}
const offset = (0, index_js_2.toNumber)((0, data_js_1.dataSlice)(result, start, start + 32));
const length = (0, index_js_2.toNumber)((0, data_js_1.dataSlice)(result, offset, offset + 32));
return (0, data_js_1.dataSlice)(result, offset + 32, offset + 32 + length);
const offset = (0, index_js_2.toNumber)((0, index_js_2.dataSlice)(result, start, start + 32));
const length = (0, index_js_2.toNumber)((0, index_js_2.dataSlice)(result, offset, offset + 32));
return (0, index_js_2.dataSlice)(result, offset + 32, offset + 32 + length);
}
function parseString(result, start) {
try {
@ -54,7 +51,7 @@ function encodeBytes(datas) {
byteCount += 32;
}
for (let i = 0; i < datas.length; i++) {
const data = logger_js_1.logger.getBytes(datas[i]);
const data = (0, index_js_2.getBytes)(datas[i]);
// Update the bytes offset
result[i] = numPad(byteCount);
// The length and padded value of data
@ -62,7 +59,7 @@ function encodeBytes(datas) {
result.push(bytesPad(data));
byteCount += 32 + Math.ceil(data.length / 32) * 32;
}
return (0, data_js_1.concat)(result);
return (0, index_js_2.concat)(result);
}
// @TODO: This should use the fetch-data:ipfs gateway
// Trim off the ipfs:// prefix and return the default gateway URL
@ -74,7 +71,7 @@ function getIpfsLink(link) {
link = link.substring(7);
}
else {
logger_js_1.logger.throwArgumentError("unsupported IPFS format", "link", link);
(0, index_js_2.throwArgumentError)("unsupported IPFS format", "link", link);
}
return `https:/\/gateway.ipfs.io/ipfs/${link}`;
}
@ -130,7 +127,7 @@ class EnsResolver {
to: this.address,
data: "0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"
}).then((result) => {
return (logger_js_1.logger.getBigInt(result) === BN_1);
return ((0, index_js_2.getBigInt)(result) === BN_1);
}).catch((error) => {
if (error.code === "CALL_EXCEPTION") {
return false;
@ -144,7 +141,7 @@ class EnsResolver {
}
async _fetch(selector, parameters = "0x") {
// e.g. keccak256("addr(bytes32,uint256)")
const addrData = (0, data_js_1.concat)([selector, (0, index_js_1.namehash)(this.name), parameters]);
const addrData = (0, index_js_2.concat)([selector, (0, index_js_1.namehash)(this.name), parameters]);
const tx = {
to: this.address,
enableCcipRead: true,
@ -155,12 +152,12 @@ class EnsResolver {
if (await this.supportsWildcard()) {
wrapped = true;
// selector("resolve(bytes,bytes)")
tx.data = (0, data_js_1.concat)(["0x9061b923", encodeBytes([(0, index_js_1.dnsEncode)(this.name), addrData])]);
tx.data = (0, index_js_2.concat)(["0x9061b923", encodeBytes([(0, index_js_1.dnsEncode)(this.name), addrData])]);
}
try {
let data = await this.provider.call(tx);
if ((logger_js_1.logger.getBytes(data).length % 32) === 4) {
return logger_js_1.logger.throwError("resolver threw error", "CALL_EXCEPTION", {
if (((0, index_js_2.getBytes)(data).length % 32) === 4) {
return (0, index_js_2.throwError)("resolver threw error", "CALL_EXCEPTION", {
transaction: tx, data
});
}
@ -219,7 +216,7 @@ class EnsResolver {
if (address != null) {
return address;
}
return logger_js_1.logger.throwError(`invalid coin data`, "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)(`invalid coin data`, "UNSUPPORTED_OPERATION", {
operation: `getAddress(${coinType})`,
info: { coinType, data }
});
@ -229,7 +226,7 @@ class EnsResolver {
let keyBytes = (0, index_js_2.toUtf8Bytes)(key);
// The nodehash consumes the first slot, so the string pointer targets
// offset 64, with the length at offset 64 and data starting at offset 96
const calldata = logger_js_1.logger.getBytes((0, data_js_1.concat)([numPad(64), numPad(keyBytes.length), keyBytes]));
const calldata = (0, index_js_2.getBytes)((0, index_js_2.concat)([numPad(64), numPad(keyBytes.length), keyBytes]));
const hexBytes = parseBytes((await this._fetch("0x59d1d43c", bytesPad(calldata))) || "0x", 0);
if (hexBytes == null || hexBytes === "0x") {
return null;
@ -257,7 +254,7 @@ class EnsResolver {
if (swarm && swarm[1].length === 64) {
return `bzz:/\/${swarm[1]}`;
}
return logger_js_1.logger.throwError(`invalid or unsupported content hash data`, "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)(`invalid or unsupported content hash data`, "UNSUPPORTED_OPERATION", {
operation: "getContentHash()",
info: { data: hexBytes }
});
@ -316,7 +313,7 @@ class EnsResolver {
if (scheme === "erc721") {
// ownerOf(uint256 tokenId)
const tokenOwner = formatter.callAddress(await this.provider.call({
to: addr, data: (0, data_js_1.concat)(["0x6352211e", tokenId])
to: addr, data: (0, index_js_2.concat)(["0x6352211e", tokenId])
}));
if (owner !== tokenOwner) {
linkage.push({ type: "!owner", value: tokenOwner });
@ -326,8 +323,8 @@ class EnsResolver {
}
else if (scheme === "erc1155") {
// balanceOf(address owner, uint256 tokenId)
const balance = logger_js_1.logger.getBigInt(await this.provider.call({
to: addr, data: (0, data_js_1.concat)(["0x00fdd58e", (0, data_js_1.zeroPadValue)(owner, 32), tokenId])
const balance = (0, index_js_2.getBigInt)(await this.provider.call({
to: addr, data: (0, index_js_2.concat)(["0x00fdd58e", (0, index_js_2.zeroPadValue)(owner, 32), tokenId])
}));
if (!balance) {
linkage.push({ type: "!balance", value: "0" });
@ -338,7 +335,7 @@ class EnsResolver {
// Call the token contract for the metadata URL
const tx = {
to: comps[0],
data: (0, data_js_1.concat)([selector, tokenId])
data: (0, index_js_2.concat)([selector, tokenId])
};
let metadataUrl = parseString(await this.provider.call(tx), 0);
if (metadataUrl == null) {
@ -348,7 +345,7 @@ class EnsResolver {
linkage.push({ type: "metadata-url-base", value: metadataUrl });
// ERC-1155 allows a generic {id} in the URL
if (scheme === "erc1155") {
metadataUrl = metadataUrl.replace("{id}", (0, data_js_1.hexlify)(tokenId).substring(2));
metadataUrl = metadataUrl.replace("{id}", (0, index_js_2.hexlify)(tokenId).substring(2));
linkage.push({ type: "metadata-url-expanded", value: metadataUrl });
}
// Transform IPFS metadata links
@ -358,7 +355,7 @@ class EnsResolver {
linkage.push({ type: "metadata-url", value: metadataUrl });
// Get the token metadata
let metadata = {};
const response = await (new fetch_js_1.FetchRequest(metadataUrl)).send();
const response = await (new index_js_2.FetchRequest(metadataUrl)).send();
response.assertOk();
try {
metadata = response.bodyJson;
@ -370,7 +367,7 @@ class EnsResolver {
catch (error) {
const bytes = response.body;
if (bytes) {
linkage.push({ type: "!metadata", value: (0, data_js_1.hexlify)(bytes) });
linkage.push({ type: "!metadata", value: (0, index_js_2.hexlify)(bytes) });
}
throw error;
}
@ -416,7 +413,7 @@ class EnsResolver {
const ensPlugin = network.getPlugin("org.ethers.network-plugins.ens");
// No ENS...
if (!ensPlugin) {
return logger_js_1.logger.throwError("network does not support ENS", "UNSUPPORTED_OPERATION", {
return (0, index_js_2.throwError)("network does not support ENS", "UNSUPPORTED_OPERATION", {
operation: "getResolver", info: { network: network.name }
});
}
@ -424,11 +421,11 @@ class EnsResolver {
// keccak256("resolver(bytes32)")
const addrData = await provider.call({
to: ensPlugin.address,
data: (0, data_js_1.concat)(["0x0178b8bf", (0, index_js_1.namehash)(name)]),
data: (0, index_js_2.concat)(["0x0178b8bf", (0, index_js_1.namehash)(name)]),
enableCcipRead: true
});
const addr = network.formatter.callAddress(addrData);
if (addr === (0, data_js_1.dataSlice)(hashes_js_1.ZeroHash, 0, 20)) {
if (addr === (0, index_js_2.dataSlice)(hashes_js_1.ZeroHash, 0, 20)) {
return null;
}
return addr;

File diff suppressed because one or more lines are too long

@ -17,11 +17,9 @@ exports.Formatter = void 0;
* to be fairly simple to adapt to ethers.
*/
const index_js_1 = require("../address/index.js");
const data_js_1 = require("../utils/data.js");
const maths_js_1 = require("../utils/maths.js");
const logger_js_1 = require("../utils/logger.js");
const index_js_2 = require("../utils/index.js");
const signature_js_1 = require("../crypto/signature.js");
const index_js_2 = require("../transaction/index.js");
const index_js_3 = require("../transaction/index.js");
const provider_js_1 = require("./provider.js");
const BN_MAX_UINT256 = BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
//export type AccessListSet = { address: string, storageKeys: Array<string> };
@ -121,16 +119,16 @@ class Formatter {
}
// An address from a call result; may be zero-padded
callAddress(value) {
if ((0, data_js_1.dataLength)(value) !== 32 || (0, data_js_1.dataSlice)(value, 0, 12) !== "0x000000000000000000000000") {
logger_js_1.logger.throwArgumentError("invalid call address", "value", value);
if ((0, index_js_2.dataLength)(value) !== 32 || (0, index_js_2.dataSlice)(value, 0, 12) !== "0x000000000000000000000000") {
(0, index_js_2.throwArgumentError)("invalid call address", "value", value);
}
return this.address((0, data_js_1.dataSlice)(value, 12));
return this.address((0, index_js_2.dataSlice)(value, 12));
}
// An address from a transaction (e.g. { from: string, nonce: number })
contractAddress(value) {
return (0, index_js_1.getCreateAddress)({
from: this.address(value.from),
nonce: logger_js_1.logger.getNumber(value.nonce, "value.nonce")
nonce: (0, index_js_2.getNumber)(value.nonce, "value.nonce")
});
}
// Block Tag
@ -147,10 +145,10 @@ class Formatter {
case "finalized":
return value;
}
if (typeof (value) === "number" || ((0, data_js_1.isHexString)(value) && (0, data_js_1.dataLength)(value) < 32)) {
return (0, maths_js_1.toQuantity)(value);
if (typeof (value) === "number" || ((0, index_js_2.isHexString)(value) && (0, index_js_2.dataLength)(value) < 32)) {
return (0, index_js_2.toQuantity)(value);
}
return logger_js_1.logger.throwArgumentError("invalid blockTag", "value", value);
return (0, index_js_2.throwArgumentError)("invalid blockTag", "value", value);
}
// Block objects
block(value, provider) {
@ -229,7 +227,7 @@ class Formatter {
if (value === 0 || value === 1) {
// Make sure if both are specified, they match
if (receipt.status != null && receipt.status !== value) {
return logger_js_1.logger.throwError("alt-root-status/status mismatch", "BAD_DATA", {
return (0, index_js_2.throwError)("alt-root-status/status mismatch", "BAD_DATA", {
value: { root: receipt.root, status: receipt.status }
});
}
@ -237,14 +235,14 @@ class Formatter {
delete receipt.root;
}
else {
return logger_js_1.logger.throwError("invalid alt-root-status", "BAD_DATA", {
return (0, index_js_2.throwError)("invalid alt-root-status", "BAD_DATA", {
value: receipt.root
});
}
}
else if (!(0, data_js_1.isHexString)(receipt.root, 32)) {
else if (!(0, index_js_2.isHexString)(receipt.root, 32)) {
// Must be a valid bytes32
return logger_js_1.logger.throwError("invalid receipt root hash", "BAD_DATA", {
return (0, index_js_2.throwError)("invalid receipt root hash", "BAD_DATA", {
value: receipt.root
});
}
@ -271,7 +269,7 @@ class Formatter {
// methods within the formatter to ensure internal compatibility
// Access List; converts an AccessListish to an AccessList
accessList(value) {
return (0, index_js_2.accessListify)(value);
return (0, index_js_3.accessListify)(value);
}
// Converts falsish values to a specific value, otherwise use the formatter. Calls preserve `this`.
allowFalsish(format, ifFalse) {
@ -302,12 +300,12 @@ class Formatter {
}
// Requires a value which is a value BigNumber
bigNumber(value) {
return logger_js_1.logger.getBigInt(value, "value");
return (0, index_js_2.getBigInt)(value, "value");
}
uint256(value) {
const result = this.bigNumber(value);
if (result < 0 || result > BN_MAX_UINT256) {
logger_js_1.logger.throwArgumentError("invalid uint256", "value", value);
(0, index_js_2.throwArgumentError)("invalid uint256", "value", value);
}
return result;
}
@ -321,7 +319,7 @@ class Formatter {
case "false":
return false;
}
return logger_js_1.logger.throwArgumentError(`invalid boolean; ${JSON.stringify(value)}`, "value", value);
return (0, index_js_2.throwArgumentError)(`invalid boolean; ${JSON.stringify(value)}`, "value", value);
}
// Requires a value which is a valid hexstring. If dataOrLength is true,
// the length must be even (i.e. a datahexstring) or if it is a number,
@ -331,28 +329,28 @@ class Formatter {
dataOrLength = false;
}
return (function (value) {
if ((0, data_js_1.isHexString)(value, dataOrLength)) {
if ((0, index_js_2.isHexString)(value, dataOrLength)) {
return value.toLowerCase();
}
throw new Error("bad hexstring");
});
}
data(value) {
if ((0, data_js_1.dataLength)(value) == null) {
logger_js_1.logger.throwArgumentError("", "value", value);
if ((0, index_js_2.dataLength)(value) == null) {
(0, index_js_2.throwArgumentError)("", "value", value);
}
return value;
}
// Requires a network-native hash
hash(value) {
if ((0, data_js_1.dataLength)(value) !== 32) {
logger_js_1.logger.throwArgumentError("", "value", value);
if ((0, index_js_2.dataLength)(value) !== 32) {
(0, index_js_2.throwArgumentError)("", "value", value);
}
return this.#format.data(value);
}
// Requires a valid number, within the IEEE 754 safe range
number(value) {
return logger_js_1.logger.getNumber(value);
return (0, index_js_2.getNumber)(value);
}
// Requires an object which matches a fleet of other formatters
// Any FormatFunc may return `undefined` to have the value omitted
@ -378,7 +376,7 @@ class Formatter {
}
catch (error) {
const message = (error instanceof Error) ? error.message : "not-an-error";
logger_js_1.logger.throwError(`invalid value for value.${key} (${message})`, "BAD_DATA", { value });
(0, index_js_2.throwError)(`invalid value for value.${key} (${message})`, "BAD_DATA", { value });
}
}
return result;

File diff suppressed because one or more lines are too long

@ -1,11 +1,10 @@
"use strict";
/*
export {
AbstractProvider, UnmanagedSubscriber
} from "./abstract-provider.js";
*/
/////
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.copyRequest = exports.dummyProvider = exports.TransactionResponse = exports.TransactionReceipt = exports.Log = exports.FeeData = exports.Block = exports.EnsPlugin = exports.GasCostPlugin = exports.NetworkPlugin = exports.Network = exports.Formatter = exports.WrappedSigner = exports.VoidSigner = exports.AbstractSigner = void 0;
exports.SocketEventSubscriber = exports.SocketPendingSubscriber = exports.SocketBlockSubscriber = exports.SocketSubscriber = exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.copyRequest = exports.dummyProvider = exports.TransactionResponse = exports.TransactionReceipt = exports.Log = exports.FeeData = exports.Block = exports.EnsPlugin = exports.GasCostPlugin = exports.NetworkPlugin = exports.Network = exports.Formatter = exports.WrappedSigner = exports.VoidSigner = exports.AbstractSigner = exports.UnmanagedSubscriber = exports.AbstractProvider = void 0;
var abstract_provider_js_1 = require("./abstract-provider.js");
Object.defineProperty(exports, "AbstractProvider", { enumerable: true, get: function () { return abstract_provider_js_1.AbstractProvider; } });
Object.defineProperty(exports, "UnmanagedSubscriber", { enumerable: true, get: function () { return abstract_provider_js_1.UnmanagedSubscriber; } });
var abstract_signer_js_1 = require("./abstract-signer.js");
Object.defineProperty(exports, "AbstractSigner", { enumerable: true, get: function () { return abstract_signer_js_1.AbstractSigner; } });
Object.defineProperty(exports, "VoidSigner", { enumerable: true, get: function () { return abstract_signer_js_1.VoidSigner; } });
@ -58,4 +57,9 @@ var provider_socket_js_1 = require("./provider-socket.js");
Object.defineProperty(exports, "SocketProvider", { enumerable: true, get: function () { return provider_socket_js_1.SocketProvider; } });
var provider_websocket_js_1 = require("./provider-websocket.js");
Object.defineProperty(exports, "WebSocketProvider", { enumerable: true, get: function () { return provider_websocket_js_1.WebSocketProvider; } });
var provider_socket_js_2 = require("./provider-socket.js");
Object.defineProperty(exports, "SocketSubscriber", { enumerable: true, get: function () { return provider_socket_js_2.SocketSubscriber; } });
Object.defineProperty(exports, "SocketBlockSubscriber", { enumerable: true, get: function () { return provider_socket_js_2.SocketBlockSubscriber; } });
Object.defineProperty(exports, "SocketPendingSubscriber", { enumerable: true, get: function () { return provider_socket_js_2.SocketPendingSubscriber; } });
Object.defineProperty(exports, "SocketEventSubscriber", { enumerable: true, get: function () { return provider_socket_js_2.SocketEventSubscriber; } });
//# sourceMappingURL=index.js.map

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src.ts/providers/index.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;;AAEF,2DAI8B;AAH1B,oHAAA,cAAc,OAAA;AACd,gHAAA,UAAU,OAAA;AACV,mHAAA,aAAa,OAAA;AAEjB;;;;;;;;EAQE;AAEF,+CAA2C;AAAlC,yGAAA,SAAS,OAAA;AAElB,2DAA+C;AAAtC,6GAAA,OAAO,OAAA;AAEhB,2DAO8B;AAN1B,mHAAA,aAAa,OAAA;AACb,mHAAA,aAAa,OAAA;AACb,+GAAA,SAAS,OAAA;AAMb,6CAWuB;AAVnB,oGAAA,KAAK,OAAA;AACL,sGAAA,OAAO,OAAA;AACP,kGAAA,GAAG,OAAA;AACH,iHAAA,kBAAkB,OAAA;AAClB,kHAAA,mB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,OAAA;AACzB,6DAA0F;AAAjF,yHAAA,kBAAkB,OAAA;AAAE,sHAAA,eAAe,OAAA;AAAE,oHAAA,aAAa,OAAA;AAE3D,6DAAwD;AAA/C,sHAAA,eAAe,OAAA;AACxB,uDAAkD;AAAzC,gHAAA,YAAY,OAAA;AACrB,mEAA8D;AAArD,4HAAA,kBAAkB,OAAA;AAC3B,iEAA4D;AAAnD,0HAAA,iBAAiB,OAAA;AAC1B,2DAAsD;AAA7C,oHAAA,cAAc,OAAA;AACvB,wDAAwD;AAExD,mEAA4D,CAAC,YAAY;AAChE,kGADA,yCAAiB,OACA;AAC1B,2DAAsD;AAA7C,oHAAA,cAAc,OAAA;AACvB,iEAA4D;AAAnD,0HAAA,iBAAiB,OAAA;AAE1B,2DAG8B;AAF1B,sHAAA,gBAAgB,OAAA;AAAE,2HAAA,qBAAqB,OAAA;AAAE,6HAAA,uBAAuB,OAAA;AAChE,2HAAA,qBAAqB,OAAA"}

@ -1,8 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Network = void 0;
const logger_js_1 = require("../utils/logger.js");
const storage_js_1 = require("../utils/storage.js");
const index_js_1 = require("../utils/index.js");
const formatter_js_1 = require("./formatter.js");
const plugins_network_js_1 = require("./plugins-network.js");
/* * * *
@ -60,7 +59,7 @@ const defaultFormatter = new formatter_js_1.Formatter();
class Network {
#props;
constructor(name, _chainId, formatter) {
const chainId = logger_js_1.logger.getBigInt(_chainId);
const chainId = (0, index_js_1.getBigInt)(_chainId);
if (formatter == null) {
formatter = defaultFormatter;
}
@ -70,12 +69,12 @@ class Network {
toJSON() {
return { name: this.name, chainId: this.chainId };
}
get name() { return (0, storage_js_1.getStore)(this.#props, "name"); }
set name(value) { (0, storage_js_1.setStore)(this.#props, "name", value); }
get chainId() { return (0, storage_js_1.getStore)(this.#props, "chainId"); }
set chainId(value) { (0, storage_js_1.setStore)(this.#props, "chainId", logger_js_1.logger.getBigInt(value, "chainId")); }
get formatter() { return (0, storage_js_1.getStore)(this.#props, "formatter"); }
set formatter(value) { (0, storage_js_1.setStore)(this.#props, "formatter", value); }
get name() { return (0, index_js_1.getStore)(this.#props, "name"); }
set name(value) { (0, index_js_1.setStore)(this.#props, "name", value); }
get chainId() { return (0, index_js_1.getStore)(this.#props, "chainId"); }
set chainId(value) { (0, index_js_1.setStore)(this.#props, "chainId", (0, index_js_1.getBigInt)(value, "chainId")); }
get formatter() { return (0, index_js_1.getStore)(this.#props, "formatter"); }
set formatter(value) { (0, index_js_1.setStore)(this.#props, "formatter", value); }
get plugins() {
return Array.from(this.#props.plugins.values());
}
@ -134,6 +133,9 @@ class Network {
}
return gas;
}
/**
* Returns a new Network for the %%network%% name or chainId.
*/
static from(network) {
// Default network
if (network == null) {
@ -151,7 +153,7 @@ class Network {
if (typeof (network) === "bigint") {
return new Network("unknown", network);
}
logger_js_1.logger.throwArgumentError("unknown network", "network", network);
(0, index_js_1.throwArgumentError)("unknown network", "network", network);
}
// Clonable with network-like abilities
if (typeof (network.clone) === "function") {
@ -163,7 +165,7 @@ class Network {
// Networkish
if (typeof (network) === "object") {
if (typeof (network.name) !== "string" || typeof (network.chainId) !== "number") {
logger_js_1.logger.throwArgumentError("invalid network object name or chainId", "network", network);
(0, index_js_1.throwArgumentError)("invalid network object name or chainId", "network", network);
}
const custom = new Network((network.name), (network.chainId));
if (network.ensAddress || network.ensNetwork != null) {
@ -174,15 +176,19 @@ class Network {
//}
return custom;
}
return logger_js_1.logger.throwArgumentError("invalid network", "network", network);
return (0, index_js_1.throwArgumentError)("invalid network", "network", network);
}
/**
* Register %%nameOrChainId%% with a function which returns
* an instance of a Network representing that chain.
*/
static register(nameOrChainId, networkFunc) {
if (typeof (nameOrChainId) === "number") {
nameOrChainId = BigInt(nameOrChainId);
}
const existing = Networks.get(nameOrChainId);
if (existing) {
logger_js_1.logger.throwArgumentError(`conflicting network for ${JSON.stringify(existing.name)}`, "nameOrChainId", nameOrChainId);
(0, index_js_1.throwArgumentError)(`conflicting network for ${JSON.stringify(existing.name)}`, "nameOrChainId", nameOrChainId);
}
Networks.set(nameOrChainId, networkFunc);
}

File diff suppressed because one or more lines are too long

@ -2,7 +2,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeeDataNetworkPlugin = exports.EnsPlugin = exports.GasCostPlugin = exports.NetworkPlugin = void 0;
const properties_js_1 = require("../utils/properties.js");
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../utils/index.js");
const EnsAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
class NetworkPlugin {
name;
@ -34,7 +34,7 @@ class GasCostPlugin extends NetworkPlugin {
value = nullish;
}
if (typeof (value) !== "number") {
logger_js_1.logger.throwArgumentError(`invalud value for ${name}`, "costs", costs);
(0, index_js_1.throwArgumentError)(`invalud value for ${name}`, "costs", costs);
}
props[name] = value;
}

@ -1 +1 @@
{"version":3,"file":"plugins-network.js","sourceRoot":"","sources":["../../src.ts/providers/plugins-network.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAE1D,kDAA4C;AAQ5C,MAAM,UAAU,GAAG,4CAA4C,CAAC;AAEhE,MAAa,aAAa;IACb,IAAI,CAAU;IAEvB,YAAY,IAAY;QACpB,IAAA,gCAAgB,EAAgB,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,KAAK;QACD,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAED,QAAQ,CAAC,OAAgB;QACrB,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAdD,sCAcC;AAcD,MAAa,aAAc,SAAQ,aAAa;IACnC,cAAc,CAAU;IAExB,MAAM,CAAU;IAChB,QAAQ,CAAU;IAClB,UAAU,CAAU;IACpB,aAAa,CAAU;IACvB,sBAAsB,CAAU;IAChC,mBAAmB,CAAU;IAEtC,YAAY,iBAAyB,CAAC,EAAE,KAAyB;QAC7D,KAAK,CAAC,uCAAwC,CAAC,cAAc,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AAC,YAAY,CAAC,CAAC;IACvD,CAAC;CACJ;AAjBD,oDAiBC"}

@ -1,10 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlchemyProvider = void 0;
const properties_js_1 = require("../utils/properties.js");
const fetch_js_1 = require("../utils/fetch.js");
const index_js_1 = require("../utils/index.js");
const community_js_1 = require("./community.js");
const logger_js_1 = require("../utils/logger.js");
const network_js_1 = require("./network.js");
const provider_jsonrpc_js_1 = require("./provider-jsonrpc.js");
const defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";
@ -33,7 +31,7 @@ function getHost(name) {
case "optimism-kovan":
return "opt-kovan.g.alchemy.com";
}
return logger_js_1.logger.throwArgumentError("unsupported network", "network", name);
return (0, index_js_1.throwArgumentError)("unsupported network", "network", name);
}
class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
apiKey;
@ -44,7 +42,7 @@ class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
}
const request = AlchemyProvider.getRequest(network, apiKey);
super(request, network, { staticNetwork: network });
(0, properties_js_1.defineProperties)(this, { apiKey });
(0, index_js_1.defineProperties)(this, { apiKey });
}
_getProvider(chainId) {
try {
@ -69,13 +67,13 @@ class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
catch (error) { }
if (data) {
if (error) {
logger_js_1.logger.throwError("an error occurred during transaction executions", "CALL_EXCEPTION", {
(0, index_js_1.throwError)("an error occurred during transaction executions", "CALL_EXCEPTION", {
data
});
}
return data;
}
return logger_js_1.logger.throwError("could not parse trace result", "BAD_DATA", { value: trace });
return (0, index_js_1.throwError)("could not parse trace result", "BAD_DATA", { value: trace });
}
return await super._perform(req);
}
@ -86,7 +84,7 @@ class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
if (apiKey == null) {
apiKey = defaultApiKey;
}
const request = new fetch_js_1.FetchRequest(`https:/\/${getHost(network.name)}/v2/${apiKey}`);
const request = new index_js_1.FetchRequest(`https:/\/${getHost(network.name)}/v2/${apiKey}`);
request.allowGzip = true;
if (apiKey === defaultApiKey) {
request.retryFunc = async (request, response, attempt) => {

@ -1 +1 @@
{"version":3,"file":"provider-alchemy.js","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":";;;AACA,0DAA0D;AAC1D,gDAAiD;AAEjD,iDAAqD;AACrD,kDAA4C;AAC5C,6CAAuC;AACvC,+DAAwD;AAOxD,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAExD,SAAS,OAAO,CAAC,IAAY;IACzB,QAAO,IAAI,EAAE;QACT,KAAK,WAAW;YACZ,OAAO,2BAA2B,CAAC;QACvC,KAAK,SAAS;YACV,OAAO,2BAA2B,CAAC;QACvC,KAAK,SAAS;YACV,OAAO,2BAA2B,CAAC;QACvC,KAAK,QAAQ;YACT,OAAO,0BAA0B,CAAC;QACtC,KAAK,OAAO;YACR,OAAO,yBAAyB,CAAC;QACrC,KAAK,OAAO;YACR,OAAO,+BAA+B,CAAC;QAC3C,KAAK,UAAU;YACX,OAAO,8BAA8B,CAAC;QAC1C,KAAK,UAAU;YACX,OAAO,2BAA2B,CAAC;QACvC,KAAK,kBAAkB;YACnB,OAAO,2BAA2B,CAAC;QACvC,KAAK,UAAU;YACX,OAAO,2BAA2B,CAAC;QACvC,KAAK,gBAAgB;YACjB,OAAO,yBAAyB,CAAC;KACxC;IAED,OAAO,kBAAM,CAAC,kBAAkB,CAAC,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAC7E,CAAC;AAED,MAAa,eAAgB,SAAQ,qCAAe;IACvC,MAAM,CAAU;IAEzB,YAAY,WAAuB,WAAW,EAAE,MAAsB;QAClE,MAAM,OAAO,GAAG,oBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,MAAM,IAAI,IAAI,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC;SAAE;QAE/C,MAAM,OAAO,GAAG,eAAe,CAAC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O,IAAI,CAAC;YAChB,CAAC,CAAA;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AApED,0CAoEC"}

@ -1,10 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnkrProvider = void 0;
const properties_js_1 = require("../utils/properties.js");
const fetch_js_1 = require("../utils/fetch.js");
const index_js_1 = require("../utils/index.js");
const community_js_1 = require("./community.js");
const logger_js_1 = require("../utils/logger.js");
const network_js_1 = require("./network.js");
const provider_jsonrpc_js_1 = require("./provider-jsonrpc.js");
const defaultApiKey = "9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";
@ -23,7 +21,7 @@ function getHost(name) {
case "arbitrum":
return "rpc.ankr.com/arbitrum";
}
return logger_js_1.logger.throwArgumentError("unsupported network", "network", name);
return (0, index_js_1.throwArgumentError)("unsupported network", "network", name);
}
class AnkrProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
apiKey;
@ -36,7 +34,7 @@ class AnkrProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
const options = { polling: true, staticNetwork: network };
const request = AnkrProvider.getRequest(network, apiKey);
super(request, network, options);
(0, properties_js_1.defineProperties)(this, { apiKey });
(0, index_js_1.defineProperties)(this, { apiKey });
}
_getProvider(chainId) {
try {
@ -49,7 +47,7 @@ class AnkrProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
if (apiKey == null) {
apiKey = defaultApiKey;
}
const request = new fetch_js_1.FetchRequest(`https:/\/${getHost(network.name)}/${apiKey}`);
const request = new index_js_1.FetchRequest(`https:/\/${getHost(network.name)}/${apiKey}`);
request.allowGzip = true;
if (apiKey === defaultApiKey) {
request.retryFunc = async (request, response, attempt) => {

@ -1 +1 @@
{"version":3,"file":"provider-ankr.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ankr.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAC1D,gDAAiD;AAGjD,iDAAqD;AACrD,kDAA4C;AAC5C,6CAAuC;AACvC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AC;YAChB,CAAC,CAAC;SACL;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,mBAAmB;QACf,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,aAAa,CAAC,CAAC;IAC3C,CAAC;CACJ;AA1CD,oCA0CC"}

@ -1,14 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CloudflareProvider = void 0;
const logger_js_1 = require("../utils/logger.js");
const index_js_1 = require("../utils/index.js");
const network_js_1 = require("./network.js");
const provider_jsonrpc_js_1 = require("./provider-jsonrpc.js");
class CloudflareProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
constructor(_network = "homestead") {
const network = network_js_1.Network.from(_network);
if (network.name !== "homestead") {
return logger_js_1.logger.throwArgumentError("unsupported network", "network", _network);
return (0, index_js_1.throwArgumentError)("unsupported network", "network", _network);
}
super("https:/\/cloudflare-eth.com/", network, { staticNetwork: network });
}

@ -1 +1 @@
{"version":3,"file":"provider-cloudflare.js","sourceRoot":"","sources":["../../src.ts/providers/provider-cloudflare.ts"],"names":[],"mappings":";;;AACA,kDAA4C;AAC5C,6CAAuC;AACvC,+DAAwD;AAKxD,MAAa,kBAAmB,SAAQ,qCAAe;IACnD,YAAY,WAAuB,WAAW;QAC1C,MAAM,OAAO,GAAG,oBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE;YAC9B,OAAO,kBAAM,CAAC,kBAAkB,CAAC,qBAAqB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;SAChF;QACD,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;CACJ;AARD,gDAQC"}
{"version":3,"file":"provider-cloudflare.js","sourceRoot":"","sources":["../../src.ts/providers/provider-cloudflare.ts"],"names":[],"mappings":";;;AAAA,gDAAuD;AAEvD,6CAAuC;AACvC,+DAAwD;AAKxD,MAAa,kBAAmB,SAAQ,qCAAe;IACnD,YAAY,WAAuB,WAAW;QAC1C,MAAM,OAAO,GAAG,oBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE;YAC9B,OAAO,IAAA,6BAAkB,EAAC,qBAAqB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;SACzE;QACD,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;CACJ;AARD,gDAQC"}

@ -1,19 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EtherscanProvider = exports.EtherscanPlugin = void 0;
const data_js_1 = require("../utils/data.js");
const maths_js_1 = require("../utils/maths.js");
const errors_js_1 = require("../utils/errors.js");
const properties_js_1 = require("../utils/properties.js");
const utf8_js_1 = require("../utils/utf8.js");
const fetch_js_1 = require("../utils/fetch.js");
if (false) {
console.log(data_js_1.isHexString, errors_js_1.isError);
} // @TODO
const index_js_1 = require("../utils/index.js");
const abstract_provider_js_1 = require("./abstract-provider.js");
const network_js_1 = require("./network.js");
const plugins_network_js_1 = require("./plugins-network.js");
const logger_js_1 = require("../utils/logger.js");
const defaultApiKey = "9D13ZE7XSBTJ94N9BNJ2MA33VMAY2YPIRB";
const EtherscanPluginId = "org.ethers.plugins.etherscan";
class EtherscanPlugin extends plugins_network_js_1.NetworkPlugin {
@ -22,7 +13,7 @@ class EtherscanPlugin extends plugins_network_js_1.NetworkPlugin {
constructor(baseUrl, communityApiKey) {
super(EtherscanPluginId);
//if (communityApiKey == null) { communityApiKey = null; }
(0, properties_js_1.defineProperties)(this, { baseUrl, communityApiKey });
(0, index_js_1.defineProperties)(this, { baseUrl, communityApiKey });
}
clone() {
return new EtherscanPlugin(this.baseUrl, this.communityApiKey);
@ -44,7 +35,7 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
apiKey = defaultApiKey;
}
}
(0, properties_js_1.defineProperties)(this, { apiKey, network });
(0, index_js_1.defineProperties)(this, { apiKey, network });
// Test that the network is supported by Etherscan
this.getBaseUrl();
}
@ -66,7 +57,7 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
return "https:/\/api-goerli.etherscan.io";
default:
}
return logger_js_1.logger.throwArgumentError("unsupported network", "network", this.network);
return (0, index_js_1.throwArgumentError)("unsupported network", "network", this.network);
}
getUrl(module, params) {
const query = Object.keys(params).reduce((accum, key) => {
@ -100,9 +91,9 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
provider: this
});
*/
const request = new fetch_js_1.FetchRequest(url);
const request = new index_js_1.FetchRequest(url);
request.processFunc = async (request, response) => {
const result = response.hasBody() ? JSON.parse((0, utf8_js_1.toUtf8String)(response.body)) : {};
const result = response.hasBody() ? JSON.parse((0, index_js_1.toUtf8String)(response.body)) : {};
const throttle = ((typeof (result.result) === "string") ? result.result : "").toLowerCase().indexOf("rate limit") >= 0;
if (module === "proxy") {
// This JSON response indicates we are being throttled
@ -136,7 +127,7 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
provider: this
});
*/
const result = JSON.parse((0, utf8_js_1.toUtf8String)(response.body));
const result = JSON.parse((0, index_js_1.toUtf8String)(response.body));
if (module === "proxy") {
if (result.jsonrpc != "2.0") {
// @TODO: not any
@ -186,7 +177,7 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
}
// Quantity-types require no leading zero, unless 0
if ({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true }[key]) {
value = (0, maths_js_1.toQuantity)((0, data_js_1.hexlify)(value));
value = (0, index_js_1.toQuantity)((0, index_js_1.hexlify)(value));
}
else if (key === "accessList") {
value = "[" + this.network.formatter.accessList(value).map((set) => {
@ -194,7 +185,7 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
}).join(",") + "]";
}
else {
value = (0, data_js_1.hexlify)(value);
value = (0, index_js_1.hexlify)(value);
}
result[key] = value;
}
@ -322,7 +313,7 @@ class EtherscanProvider extends abstract_provider_js_1.AbstractProvider {
boolean: (req.includeTransactions ? "true" : "false")
});
}
return logger_js_1.logger.throwError("getBlock by blockHash not supported by Etherscan", "UNSUPPORTED_OPERATION", {
return (0, index_js_1.throwError)("getBlock by blockHash not supported by Etherscan", "UNSUPPORTED_OPERATION", {
operation: "getBlock(blockHash)"
});
case "getTransaction":

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More