admin: update dist files
This commit is contained in:
parent
62b358024b
commit
93911d7371
@ -63,23 +63,23 @@ const ProviderCreators = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
{
|
{
|
||||||
name: "FallbackProvider",
|
name: "FallbackProvider",
|
||||||
networks: ethNetworks,
|
networks: ethNetworks,
|
||||||
create: function(network: string) {
|
create: function (network) {
|
||||||
const providers: Array<AbstractProvider> = [];
|
const providers = [];
|
||||||
for (const creator of ProviderCreators) {
|
for (const providerName of ["AlchemyProvider", "AnkrProvider", "EtherscanProvider", "InfuraProvider"]) {
|
||||||
if (creator.name === "FallbackProvider") { continue; }
|
const provider = getProvider(providerName, network);
|
||||||
if (creator.networks.indexOf(network) >= 0) {
|
if (provider) {
|
||||||
const provider = creator.create(network);
|
providers.push(provider);
|
||||||
if (provider) { providers.push(provider); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new FallbackProvider(providers);
|
if (providers.length === 0) {
|
||||||
|
throw new Error("UNSUPPORTED NETWORK");
|
||||||
|
}
|
||||||
|
return new index_js_1.FallbackProvider(providers);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
*/
|
|
||||||
];
|
];
|
||||||
exports.providerNames = Object.freeze(ProviderCreators.map((c) => (c.name)));
|
exports.providerNames = Object.freeze(ProviderCreators.map((c) => (c.name)));
|
||||||
function getCreator(provider) {
|
function getCreator(provider) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"create-provider.js","sourceRoot":"","sources":["../../src.ts/_tests/create-provider.ts"],"names":[],"mappings":";;;AAAA,0CAUqB;AAQpB,CAAC;AAEF,MAAM,WAAW,GAAG,CAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAE,CAAC;AACvD,gDAAgD;AAEhD,MAAM,gBAAgB,GAA2B;IAC7C;QACI,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,WAAW;QACrB,MAAM,EAAE,UAAS,OAAe;YAC5B,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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;QACA,IAAI,OAAO,EAAE;YAAE,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;SAAE;KACnD;IAAC,OAAO,KAAK,EAAE;QACZ,IAAI,CAAC,IAAA,kBAAO,EAAC,KAAK,EAAE,kBAAkB,CAAC,EAAE;YAAE,MAAM,KAAK,CAAC;SAAE;KAC5D;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AARD,kCAQC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,OAAe;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;AAC7B,CAAC;AAHD,sCAGC;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"}
|
@ -1,39 +1,152 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
import assert from "assert";
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
import { connect } from "./create-provider.js";
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const assert_1 = __importDefault(require("assert"));
|
||||||
import { Contract } from "../index.js";
|
const create_provider_js_1 = require("./create-provider.js");
|
||||||
|
const index_js_1 = require("../index.js");
|
||||||
describe("Test Contract", function() {
|
describe("Test Contract", function () {
|
||||||
it("tests contract @TODO: expand", async function() {
|
const addr = "0x99417252Aad7B065940eBdF50d665Fb8879c5958";
|
||||||
const provider = connect("mainnet");
|
const abi = [
|
||||||
|
"error CustomError1(uint256 code, string message)",
|
||||||
const contract = new Contract("dai.tokens.ethers.eth", [
|
"event EventUint256(uint256 indexed value)",
|
||||||
"function balanceOf(address) view returns (uint)"
|
"event EventAddress(address indexed value)",
|
||||||
], provider);
|
"event EventString(string value)",
|
||||||
|
"event EventBytes(bytes value)",
|
||||||
assert.equal(await contract.balanceOf("ricmoo.firefly.eth"), BigInt("6015089439794538201631"));
|
"function testCustomError1(bool pass, uint code, string calldata message) pure returns (uint256)",
|
||||||
|
"function testErrorString(bool pass, string calldata message) pure returns (uint256)",
|
||||||
|
"function testPanic(uint256 code) returns (uint256)",
|
||||||
|
"function testEvent(uint256 valueUint256, address valueAddress, string valueString, bytes valueBytes) public",
|
||||||
|
"function testCallAdd(uint256 a, uint256 b) pure returns (uint256 result)"
|
||||||
|
];
|
||||||
|
it("tests contract calls", async function () {
|
||||||
|
this.timeout(10000);
|
||||||
|
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
|
||||||
|
const contract = new index_js_1.Contract(addr, abi, provider);
|
||||||
|
assert_1.default.equal(await contract.testCallAdd(4, 5), BigInt(9), "testCallAdd(4, 5)");
|
||||||
|
assert_1.default.equal(await contract.testCallAdd(6, 0), BigInt(6), "testCallAdd(6, 0)");
|
||||||
|
});
|
||||||
|
it("tests events", async function () {
|
||||||
|
this.timeout(60000);
|
||||||
|
const provider = (0, create_provider_js_1.getProvider)("InfuraProvider", "goerli");
|
||||||
|
assert_1.default.ok(provider);
|
||||||
|
const contract = new index_js_1.Contract(addr, abi, provider);
|
||||||
|
const signer = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY), provider);
|
||||||
|
const contractSigner = contract.connect(signer);
|
||||||
|
const vUint256 = 42;
|
||||||
|
const vAddrName = "ethers.eth";
|
||||||
|
const vAddr = "0x228568EA92aC5Bc281c1E30b1893735c60a139F1";
|
||||||
|
const vString = "Hello";
|
||||||
|
const vBytes = "0x12345678";
|
||||||
|
let hash = null;
|
||||||
|
// Test running a listener for a specific event
|
||||||
|
const specificEvent = new Promise((resolve, reject) => {
|
||||||
|
contract.on("EventUint256", async (value, event) => {
|
||||||
|
// Triggered by someone else
|
||||||
|
if (hash == null || hash !== event.log.transactionHash) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
assert_1.default.equal(event.filter, "EventUint256", "event.filter");
|
||||||
|
assert_1.default.equal(event.fragment.name, "EventUint256", "event.fragment.name");
|
||||||
|
assert_1.default.equal(event.log.address, addr, "event.log.address");
|
||||||
|
assert_1.default.equal(event.args.length, 1, "event.args.length");
|
||||||
|
assert_1.default.equal(event.args[0], BigInt(42), "event.args[0]");
|
||||||
|
const count = await contract.listenerCount("EventUint256");
|
||||||
|
await event.removeListener();
|
||||||
|
assert_1.default.equal(await contract.listenerCount("EventUint256"), count - 1, "decrement event count");
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
event.removeListener();
|
||||||
|
reject(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// Test running a listener on all (i.e. "*") events
|
||||||
|
const allEvents = new Promise((resolve, reject) => {
|
||||||
|
const waitingFor = {
|
||||||
|
EventUint256: vUint256,
|
||||||
|
EventAddress: vAddr,
|
||||||
|
EventString: vString,
|
||||||
|
EventBytes: vBytes
|
||||||
|
};
|
||||||
|
contract.on("*", (event) => {
|
||||||
|
// Triggered by someone else
|
||||||
|
if (hash == null || hash !== event.log.transactionHash) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const name = event.eventName;
|
||||||
|
assert_1.default.equal(event.args[0], waitingFor[name], `${name}`);
|
||||||
|
delete waitingFor[name];
|
||||||
|
if (Object.keys(waitingFor).length === 0) {
|
||||||
|
event.removeListener();
|
||||||
|
resolve(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// Send a transaction to trigger some events
|
||||||
|
const tx = await contractSigner.testEvent(vUint256, vAddr, vString, vBytes);
|
||||||
|
hash = tx.hash;
|
||||||
|
const checkEvent = (filter, event) => {
|
||||||
|
const values = {
|
||||||
|
EventUint256: vUint256,
|
||||||
|
EventString: vString,
|
||||||
|
EventAddress: vAddr,
|
||||||
|
EventBytes: vBytes
|
||||||
|
};
|
||||||
|
assert_1.default.ok(event instanceof index_js_1.EventLog, `queryFilter(${filter}):isEventLog`);
|
||||||
|
const name = event.eventName;
|
||||||
|
assert_1.default.equal(event.address, addr, `queryFilter(${filter}):address`);
|
||||||
|
assert_1.default.equal(event.args[0], values[name], `queryFilter(${filter}):args[0]`);
|
||||||
|
};
|
||||||
|
const checkEventFilter = async (filter) => {
|
||||||
|
const events = (await contract.queryFilter(filter, -10)).filter((e) => (e.transactionHash === hash));
|
||||||
|
assert_1.default.equal(events.length, 1, `queryFilter(${filter}).length`);
|
||||||
|
checkEvent(filter, events[0]);
|
||||||
|
return events[0];
|
||||||
|
};
|
||||||
|
const receipt = await tx.wait();
|
||||||
|
// Check the logs in the receipt
|
||||||
|
for (const log of receipt.logs) {
|
||||||
|
checkEvent("receipt", log);
|
||||||
|
}
|
||||||
|
// Various options for queryFilter
|
||||||
|
await checkEventFilter("EventUint256");
|
||||||
|
await checkEventFilter(["EventUint256"]);
|
||||||
|
await checkEventFilter([["EventUint256"]]);
|
||||||
|
await checkEventFilter("EventUint256(uint)");
|
||||||
|
await checkEventFilter(["EventUint256(uint)"]);
|
||||||
|
await checkEventFilter([["EventUint256(uint)"]]);
|
||||||
|
await checkEventFilter([["EventUint256", "EventUint256(uint)"]]);
|
||||||
|
await checkEventFilter("0x85c55bbb820e6d71c71f4894e57751de334b38c421f9c170b0e66d32eafea337");
|
||||||
|
// Query by Event
|
||||||
|
await checkEventFilter(contract.filters.EventUint256);
|
||||||
|
// Query by Deferred Topic Filter; address
|
||||||
|
await checkEventFilter(contract.filters.EventUint256(vUint256));
|
||||||
|
// Query by Deferred Topic Filter; address
|
||||||
|
await checkEventFilter(contract.filters.EventAddress(vAddr));
|
||||||
|
// Query by Deferred Topic Filter; ENS name => address
|
||||||
|
await checkEventFilter(contract.filters.EventAddress(vAddrName));
|
||||||
|
// Multiple Methods
|
||||||
|
{
|
||||||
|
const filter = [["EventUint256", "EventString"]];
|
||||||
|
const events = (await contract.queryFilter(filter, -10)).filter((e) => (e.transactionHash === hash));
|
||||||
|
assert_1.default.equal(events.length, 2, `queryFilter(${filter}).length`);
|
||||||
|
for (const event of events) {
|
||||||
|
checkEvent(filter, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await specificEvent;
|
||||||
|
await allEvents;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
/*
|
|
||||||
import { Typed } from "../abi/index.js";
|
|
||||||
import * as providers from "../providers/index.js";
|
|
||||||
|
|
||||||
import { Contract } from "../index.js";
|
|
||||||
|
|
||||||
import { log } from "./utils.js";
|
|
||||||
*/
|
|
||||||
//import type { Addressable } from "@ethersproject/address";
|
|
||||||
//import type { BigNumberish } from "@ethersproject/logger";
|
|
||||||
/*
|
|
||||||
import type {
|
|
||||||
ConstantContractMethod, ContractMethod, ContractEvent
|
|
||||||
} from "../index.js";
|
|
||||||
*/
|
|
||||||
// @TODO
|
|
||||||
/*
|
/*
|
||||||
describe("Test Contract Calls", function() {
|
describe("Test Contract Calls", function() {
|
||||||
it("finds typed methods", async function() {
|
it("finds typed methods", async function() {
|
||||||
@ -47,8 +160,7 @@ describe("Test Contract Calls", function() {
|
|||||||
contract["foo(string)"].fragment
|
contract["foo(string)"].fragment
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
/*
|
|
||||||
describe("Test Contract Interface", function() {
|
describe("Test Contract Interface", function() {
|
||||||
it("builds contract interfaces", async function() {
|
it("builds contract interfaces", async function() {
|
||||||
this.timeout(60000);
|
this.timeout(60000);
|
||||||
@ -104,15 +216,4 @@ describe("Test Contract Interface", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
describe("Test Contract Calls", function() {
|
|
||||||
it("calls ERC-20 methods", async function() {
|
|
||||||
const provider = new providers.AnkrProvider();
|
|
||||||
const contract = new Contract("0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72", [
|
|
||||||
"function balanceOf(address owner) view returns (uint)",
|
|
||||||
], provider);
|
|
||||||
log(this, `balance: ${ await contract.balanceOf("0x5555763613a12D8F3e73be831DFf8598089d3dCa") }`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
//# sourceMappingURL=test-contract.js.map
|
//# sourceMappingURL=test-contract.js.map
|
File diff suppressed because one or more lines are too long
@ -149,5 +149,20 @@ describe("Test Solidity Hash functions", function () {
|
|||||||
assert_1.default.equal((0, index_js_1.solidityPackedSha256)(test.types, test.values), test.sha256);
|
assert_1.default.equal((0, index_js_1.solidityPackedSha256)(test.types, test.values), test.sha256);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const badTypes = [
|
||||||
|
{ types: ["uint5"], values: [1] },
|
||||||
|
{ types: ["bytes0"], values: ["0x"] },
|
||||||
|
{ types: ["blorb"], values: [false] },
|
||||||
|
];
|
||||||
|
for (const { types, values } of badTypes) {
|
||||||
|
it("fails on invalid type", function () {
|
||||||
|
assert_1.default.throws(function () {
|
||||||
|
const result = (0, index_js_1.solidityPacked)(types, values);
|
||||||
|
console.log(result);
|
||||||
|
}, function (error) {
|
||||||
|
return ((0, index_js_1.isError)(error, "INVALID_ARGUMENT") && error.argument === "type");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=test-hash.js.map
|
//# sourceMappingURL=test-hash.js.map
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"test-hash.js","sourceRoot":"","sources":["../../src.ts/_tests/test-hash.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,0CAGqB;AAErB,yCAAsC;AAItC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0GE;AAEF,QAAQ,CAAC,oCAAoC,EAAE;IAC3C,MAAM,KAAK,GAAG;QACV;YACI,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,aAAa;YACtB,IAAI,EAAE,oEAAoE;SAC7E;QACD;YACI,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE,IAAI,UAAU,CAAC,CAAE,IAAI,EAAE,IAAI,CAAE,CAAC;YACvC,IAAI,EAAE,oEAAoE;SAC7E;QACD;YACI,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,oEAAoE;SAC7E;KACJ,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,EAAE,CAAC,sBAAuB,IAAI,CAAC,IAAK,EAAE,EAAE;YACpC,gBAAM,CAAC,KAAK,CAAC,IAAA,sBAAW,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,8BAA8B,EAAE;IACrC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAuB,iBAAiB,CAAC,CAAC;IAEjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,EAAE,CAAC,oCAAqC,IAAI,CAAC,IAAK,EAAE,EAAE;YAClD,gBAAM,CAAC,KAAK,CAAC,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AAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC,EAAE,UAAU,KAAK;gBACd,OAAO,CAAC,IAAA,kBAAO,EAAC,KAAK,EAAE,kBAAkB,CAAC,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC;YAC7E,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACN;AACL,CAAC,CAAC,CAAC"}
|
45
lib.commonjs/_tests/test-providers-send.js
Normal file
45
lib.commonjs/_tests/test-providers-send.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
"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("Sends Transactions", function () {
|
||||||
|
const cleanup = [];
|
||||||
|
after(function () {
|
||||||
|
for (const func of cleanup) {
|
||||||
|
func();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const wallet = new index_js_1.Wallet((process.env.FAUCET_PRIVATEKEY));
|
||||||
|
const networkName = "goerli";
|
||||||
|
for (const providerName of create_provider_js_1.providerNames) {
|
||||||
|
const provider = (0, create_provider_js_1.getProvider)(providerName, networkName);
|
||||||
|
if (provider == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Shutdown socket-based provider, otherwise its socket will prevent
|
||||||
|
// this process from exiting
|
||||||
|
if (provider.destroy) {
|
||||||
|
cleanup.push(() => { provider.destroy(); });
|
||||||
|
}
|
||||||
|
it(`tests sending: ${providerName}`, async function () {
|
||||||
|
this.timeout(60000);
|
||||||
|
const w = wallet.connect(provider);
|
||||||
|
const dustAddr = index_js_1.Wallet.createRandom().address;
|
||||||
|
const tx = await w.sendTransaction({
|
||||||
|
to: dustAddr,
|
||||||
|
value: 42,
|
||||||
|
type: 2
|
||||||
|
});
|
||||||
|
//const receipt =
|
||||||
|
await provider.waitForTransaction(tx.hash); //tx.wait();
|
||||||
|
//console.log(receipt);
|
||||||
|
const balance = await provider.getBalance(dustAddr);
|
||||||
|
assert_1.default.equal(balance, BigInt(42), "target balance after send");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=test-providers-send.js.map
|
1
lib.commonjs/_tests/test-providers-send.js.map
Normal file
1
lib.commonjs/_tests/test-providers-send.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test-providers-send.js","sourceRoot":"","sources":["../../src.ts/_tests/test-providers-send.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,0CAAqC;AAErC,6DAAkE;AAGlE,QAAQ,CAAC,oBAAoB,EAAE;IAE3B,MAAM,OAAO,GAAsB,EAAG,CAAC;IACvC,KAAK,CAAC;QACF,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YAAE,IAAI,EAAE,CAAC;SAAE;IAC3C,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAI,iBAAM,CAAS,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAEnE,MAAM,WAAW,GAAG,QAAQ,CAAC;IAC7B,KAAK,MAAM,YAAY,IAAI,kCAAa,EAAE;QACtC,MAAM,QAAQ,GAAG,IAAA,gCAAW,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC;QACxD,IAAI,QAAQ,IAAI,IAAI,EAAE;YAAE,SAAS;SAAE;QAEnC,oEAAoE;QACpE,4BAA4B;QAC5B,IAAU,QAAS,CAAC,OAAO,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAS,QAAS,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAAE;QAEpF,EAAE,CAAC,kBAAmB,YAAa,EAAE,EAAE,KAAK;YACxC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAEpB,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,iBAAM,CAAC,YAAY,EAAE,CAAC,OAAO,CAAC;YAE/C,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,eAAe,CAAC;gBAC/B,EAAE,EAAE,QAAQ;gBACZ,KAAK,EAAE,EAAE;gBACT,IAAI,EAAE,CAAC;aACV,CAAC,CAAC;YAEH,kBAAkB;YAClB,MAAM,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY;YACxD,uBAAuB;YAEvB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACpD,gBAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,2BAA2B,CAAC,CAAC;QACnE,CAAC,CAAC,CAAC;KACN;AAGL,CAAC,CAAC,CAAC"}
|
68
lib.commonjs/_tests/test-utils-units.js
Normal file
68
lib.commonjs/_tests/test-utils-units.js
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
"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 utils_js_1 = require("./utils.js");
|
||||||
|
const index_js_1 = require("../index.js");
|
||||||
|
describe("Tests unit conversion", function () {
|
||||||
|
const tests = (0, utils_js_1.loadTests)("units");
|
||||||
|
const units = [
|
||||||
|
{ unit: "ether", format: "ether_format", decimals: 18 },
|
||||||
|
{ unit: "kwei", format: "kwei_format", decimals: 3 },
|
||||||
|
{ unit: "mwei", format: "mwei_format", decimals: 6 },
|
||||||
|
{ unit: "gwei", format: "gwei_format", decimals: 9 },
|
||||||
|
{ unit: "szabo", format: "szabo_format", decimals: 12 },
|
||||||
|
{ unit: "finney", format: "finney_format", decimals: 15 },
|
||||||
|
];
|
||||||
|
for (const { unit, format, decimals } of units) {
|
||||||
|
for (const test of tests) {
|
||||||
|
const str = (test[format]);
|
||||||
|
if (str == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it(`converts wei to ${unit} string: ${test.name}`, function () {
|
||||||
|
const wei = BigInt(test.wei);
|
||||||
|
if (decimals === 18) {
|
||||||
|
assert_1.default.equal((0, index_js_1.formatEther)(wei), str, "formatEther");
|
||||||
|
assert_1.default.equal((0, index_js_1.formatUnits)(wei), str, "formatUnits");
|
||||||
|
}
|
||||||
|
assert_1.default.equal((0, index_js_1.formatUnits)(wei, unit), str, `formatUnits(${unit})`);
|
||||||
|
assert_1.default.equal((0, index_js_1.formatUnits)(wei, decimals), str, `formatUnits(${decimals})`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const test of tests) {
|
||||||
|
const str = (test[format]);
|
||||||
|
if (str == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
it(`converts ${format} string to wei: ${test.name}`, function () {
|
||||||
|
const wei = BigInt(test.wei);
|
||||||
|
if (decimals === 18) {
|
||||||
|
assert_1.default.equal((0, index_js_1.parseEther)(str), wei, "parseEther");
|
||||||
|
assert_1.default.equal((0, index_js_1.parseUnits)(str), wei, "parseUnits");
|
||||||
|
}
|
||||||
|
assert_1.default.equal((0, index_js_1.parseUnits)(str, unit), wei, `parseUnits(${unit})`);
|
||||||
|
assert_1.default.equal((0, index_js_1.parseUnits)(str, decimals), wei, `parseUnits(${decimals})`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
describe("Tests bad unit conversion", function () {
|
||||||
|
it("fails to convert non-string value", function () {
|
||||||
|
assert_1.default.throws(() => {
|
||||||
|
(0, index_js_1.parseUnits)(3, "ether");
|
||||||
|
}, (error) => {
|
||||||
|
return error.message.startsWith("value must be a string");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("fails to convert unknown unit", function () {
|
||||||
|
assert_1.default.throws(() => {
|
||||||
|
(0, index_js_1.parseUnits)("3", "foobar");
|
||||||
|
}, (error) => {
|
||||||
|
return error.message.startsWith("invalid unit");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=test-utils-units.js.map
|
1
lib.commonjs/_tests/test-utils-units.js.map
Normal file
1
lib.commonjs/_tests/test-utils-units.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test-utils-units.js","sourceRoot":"","sources":["../../src.ts/_tests/test-utils-units.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,yCAAuC;AAEvC,0CAA+E;AAK/E,QAAQ,CAAC,uBAAuB,EAAE;IAC9B,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAe,OAAO,CAAC,CAAC;IAE/C,MAAM,KAAK,GAAG;QACV,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE;QACvD,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE;QACpD,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE;QACpD,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE;QACpD,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,EAAE,EAAE;QACvD,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,EAAE,EAAE;KAC5D,CAAC;IAEF,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,KAAK,E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CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;oBACjD,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,GAAG,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;iBACpD;gBACD,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,cAAe,IAAK,GAAG,CAAC,CAAC;gBAClE,gBAAM,CAAC,KAAK,CAAC,IAAA,qBAAU,EAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,cAAe,QAAS,GAAG,CAAC,CAAC;YAC9E,CAAC,CAAC,CAAC;SACN;KAEJ;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,2BAA2B,EAAE;IAClC,EAAE,CAAC,mCAAmC,EAAE;QACpC,gBAAM,CAAC,MAAM,CAAC,GAAG,EAAE;YACf,IAAA,qBAAU,EAAM,CAAC,EAAE,OAAO,CAAC,CAAC;QAChC,CAAC,EAAE,CAAC,KAAU,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,+BAA+B,EAAE;QAChC,gBAAM,CAAC,MAAM,CAAC,GAAG,EAAE;YACf,IAAA,qBAAU,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9B,CAAC,EAAE,CAAC,KAAU,EAAE,EAAE;YACd,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
131
lib.commonjs/_tests/test-utils-utf8.js
Normal file
131
lib.commonjs/_tests/test-utils-utf8.js
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
"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");
|
||||||
|
describe("Tests UTF-8 bad strings", function () {
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
name: "unexpected continue",
|
||||||
|
bytes: new Uint8Array([0x41, 0x80, 0x42, 0x43]),
|
||||||
|
ignore: "ABC",
|
||||||
|
replace: "A\ufffdBC",
|
||||||
|
error: "UNEXPECTED_CONTINUE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bad prefix",
|
||||||
|
bytes: new Uint8Array([0x41, 0xf8, 0x42, 0x43]),
|
||||||
|
ignore: "ABC",
|
||||||
|
replace: "A\ufffdBC",
|
||||||
|
error: "BAD_PREFIX"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "bad prefix (multiple)",
|
||||||
|
bytes: new Uint8Array([0x41, 0xf8, 0x88, 0x88, 0x42, 0x43]),
|
||||||
|
ignore: "ABC",
|
||||||
|
replace: "A\ufffdBC",
|
||||||
|
error: "BAD_PREFIX"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OVERRUN",
|
||||||
|
bytes: new Uint8Array([0x41, 0x42, 0xe2, 0x82 /* 0xac */]),
|
||||||
|
ignore: "AB",
|
||||||
|
replace: "AB\ufffd",
|
||||||
|
error: "OVERRUN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "missing continue",
|
||||||
|
bytes: new Uint8Array([0x41, 0x42, 0xe2, 0xe2, 0x82, 0xac, 0x43]),
|
||||||
|
ignore: "AB\u20acC",
|
||||||
|
replace: "AB\ufffd\u20acC",
|
||||||
|
error: "MISSING_CONTINUE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "out-of-range",
|
||||||
|
bytes: new Uint8Array([0x41, 0x42, 0xf7, 0xbf, 0xbf, 0xbf, 0x43]),
|
||||||
|
ignore: "ABC",
|
||||||
|
replace: "AB\ufffdC",
|
||||||
|
error: "OUT_OF_RANGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UTF-16 surrogate (low)",
|
||||||
|
bytes: new Uint8Array([0x41, 0x42, 0xed, 0xa0, 0x80, 0x43]),
|
||||||
|
ignore: "ABC",
|
||||||
|
replace: "AB\ufffdC",
|
||||||
|
error: "UTF16_SURROGATE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "UTF-16 surrogate (high)",
|
||||||
|
bytes: new Uint8Array([0x41, 0x42, 0xed, 0xbf, 0xbf, 0x43]),
|
||||||
|
ignore: "ABC",
|
||||||
|
replace: "AB\ufffdC",
|
||||||
|
error: "UTF16_SURROGATE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "overlong",
|
||||||
|
bytes: new Uint8Array([0xf0, 0x82, 0x82, 0xac]),
|
||||||
|
ignore: "",
|
||||||
|
replace: "\u20ac",
|
||||||
|
error: "OVERLONG"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
for (const { name, bytes, ignore, replace, error } of tests) {
|
||||||
|
it(`correctly handles ${name}: replace strategy`, function () {
|
||||||
|
const result = (0, index_js_1.toUtf8String)(bytes, index_js_1.Utf8ErrorFuncs.replace);
|
||||||
|
assert_1.default.equal(result, replace);
|
||||||
|
});
|
||||||
|
it(`correctly handles ${name}: ignore strategy`, function () {
|
||||||
|
const result = (0, index_js_1.toUtf8String)(bytes, index_js_1.Utf8ErrorFuncs.ignore);
|
||||||
|
assert_1.default.equal(result, ignore);
|
||||||
|
});
|
||||||
|
it(`correctly handles ${name}: error strategy`, function () {
|
||||||
|
assert_1.default.throws(() => {
|
||||||
|
const result = (0, index_js_1.toUtf8String)(bytes);
|
||||||
|
console.log(result);
|
||||||
|
}, (e) => {
|
||||||
|
return (e.message.indexOf(error) >= 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
it("fails to get UTF-8 bytes from incomplete surrogate", function () {
|
||||||
|
assert_1.default.throws(() => {
|
||||||
|
const text = String.fromCharCode(0xd800);
|
||||||
|
;
|
||||||
|
const result = (0, index_js_1.toUtf8Bytes)(text);
|
||||||
|
console.log(result);
|
||||||
|
}, (error) => {
|
||||||
|
return (error.message.startsWith("invalid surrogate pair"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it("fails to get UTF-8 bytes from invalid surrogate pair", function () {
|
||||||
|
assert_1.default.throws(() => {
|
||||||
|
const text = String.fromCharCode(0xd800, 0xdbff);
|
||||||
|
;
|
||||||
|
const result = (0, index_js_1.toUtf8Bytes)(text);
|
||||||
|
console.log(result);
|
||||||
|
}, (error) => {
|
||||||
|
return (error.message.startsWith("invalid surrogate pair"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe("Tests UTF-8 bad strings", function () {
|
||||||
|
const tests = [
|
||||||
|
{
|
||||||
|
name: "the Euro symbol",
|
||||||
|
text: "AB\u20acC",
|
||||||
|
codepoints: [0x41, 0x42, 0x20ac, 0x43]
|
||||||
|
},
|
||||||
|
];
|
||||||
|
for (const { name, text, codepoints } of tests) {
|
||||||
|
it(`expands strings to codepoints: ${name}`, function () {
|
||||||
|
const result = (0, index_js_1.toUtf8CodePoints)(text);
|
||||||
|
assert_1.default.equal(result.length, codepoints.length, "codepoints.length");
|
||||||
|
for (let i = 0; i < result.length; i++) {
|
||||||
|
assert_1.default.equal(result[i], codepoints[i], `codepoints[${i}]`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=test-utils-utf8.js.map
|
1
lib.commonjs/_tests/test-utils-utf8.js.map
Normal file
1
lib.commonjs/_tests/test-utils-utf8.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"test-utils-utf8.js","sourceRoot":"","sources":["../../src.ts/_tests/test-utils-utf8.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAE5B,0CAGqB;AAgBrB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,CAAC,CAAC;QACxB,CAAC,EAAE,CAAC,KAAU,EAAE,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAChE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,yBAAyB,EAAE;IAEhC,MAAM,KAAK,GAA8B;QACrC;YACI,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,CAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAE;SAC3C;KACJ,CAAC;IAEF,KAAK,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,KAAK,EAAE;QAC5C,EAAE,CAAC,kCAAmC,IAAK,EAAE,EAAE;YAC3C,MAAM,MAAM,GAAG,IAAA,2BAAgB,EAAC,IAAI,CAAC,CAAC;YACtC,gBAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;YACpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,gBAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,cAAe,CAAE,GAAG,CAAC,CAAC;aAChE;QACL,CAAC,CAAC,CAAC;KACN;AAEL,CAAC,CAAC,CAAC"}
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src.ts/_tests/types.ts"],"names":[],"mappings":";;AAyOC,CAAC"}
|
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src.ts/_tests/types.ts"],"names":[],"mappings":";;AA2PC,CAAC"}
|
@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.stats = exports.Stats = exports.retryIt = exports.log = exports.loadTests = void 0;
|
exports.retryIt = exports.log = exports.loadTests = void 0;
|
||||||
const fs_1 = __importDefault(require("fs"));
|
const fs_1 = __importDefault(require("fs"));
|
||||||
const path_1 = __importDefault(require("path"));
|
const path_1 = __importDefault(require("path"));
|
||||||
const zlib_1 = __importDefault(require("zlib"));
|
const zlib_1 = __importDefault(require("zlib"));
|
||||||
@ -42,6 +42,7 @@ async function stall(duration) {
|
|||||||
}
|
}
|
||||||
const ATTEMPTS = 5;
|
const ATTEMPTS = 5;
|
||||||
async function retryIt(name, func) {
|
async function retryIt(name, func) {
|
||||||
|
//const errors: Array<Error> = [ ];
|
||||||
it(name, async function () {
|
it(name, async function () {
|
||||||
this.timeout(ATTEMPTS * 5000);
|
this.timeout(ATTEMPTS * 5000);
|
||||||
for (let i = 0; i < ATTEMPTS; i++) {
|
for (let i = 0; i < ATTEMPTS; i++) {
|
||||||
@ -59,12 +60,14 @@ async function retryIt(name, func) {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
//errors.push(error);
|
||||||
if (i === ATTEMPTS - 1) {
|
if (i === ATTEMPTS - 1) {
|
||||||
exports.stats.pushRetry(i, name, error);
|
throw error;
|
||||||
|
//stats.pushRetry(i, name, error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await stall(500 * (1 << i));
|
await stall(500 * (1 << i));
|
||||||
exports.stats.pushRetry(i, name, null);
|
//stats.pushRetry(i, name, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,54 +77,58 @@ async function retryIt(name, func) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.retryIt = retryIt;
|
exports.retryIt = retryIt;
|
||||||
const _guard = {};
|
/*
|
||||||
class Stats {
|
export interface StatSet {
|
||||||
#stats;
|
name: string;
|
||||||
constructor(guard) {
|
retries: Array<{ message: string, error: null | Error }>;
|
||||||
if (guard !== _guard) {
|
}
|
||||||
throw new Error("private constructor");
|
|
||||||
}
|
const _guard = { };
|
||||||
this.#stats = [];
|
|
||||||
}
|
export class Stats {
|
||||||
#currentStats() {
|
// #stats: Array<StatSet>;
|
||||||
if (this.#stats.length === 0) {
|
|
||||||
throw new Error("no active stats");
|
constructor(guard: any) {
|
||||||
|
if (guard !== _guard) { throw new Error("private constructor"); }
|
||||||
|
// this.#stats = [ ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#currentStats(): StatSet {
|
||||||
|
if (this.#stats.length === 0) { throw new Error("no active stats"); }
|
||||||
return this.#stats[this.#stats.length - 1];
|
return this.#stats[this.#stats.length - 1];
|
||||||
}
|
}
|
||||||
pushRetry(attempt, line, error) {
|
|
||||||
|
pushRetry(attempt: number, line: string, error: null | Error): void {
|
||||||
const { retries } = this.#currentStats();
|
const { retries } = this.#currentStats();
|
||||||
if (attempt > 0) {
|
|
||||||
retries.pop();
|
if (attempt > 0) { retries.pop(); }
|
||||||
}
|
|
||||||
if (retries.length < 100) {
|
if (retries.length < 100) {
|
||||||
retries.push({
|
retries.push({
|
||||||
message: `${attempt + 1} failures: ${line}`,
|
message: `${ attempt + 1 } failures: ${ line }`,
|
||||||
error
|
error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
start(name) {
|
|
||||||
this.#stats.push({ name, retries: [] });
|
start(name: string): void {
|
||||||
|
this.#stats.push({ name, retries: [ ] });
|
||||||
}
|
}
|
||||||
end(context) {
|
|
||||||
|
end(context?: any): void {
|
||||||
let log = console.log.bind(console);
|
let log = console.log.bind(console);
|
||||||
if (context && typeof (context._ethersLog) === "function") {
|
if (context && typeof(context._ethersLog) === "function") {
|
||||||
log = context._ethersLog;
|
log = context._ethersLog;
|
||||||
}
|
}
|
||||||
const { name, retries } = this.#currentStats();
|
const { name, retries } = this.#currentStats();
|
||||||
if (retries.length === 0) {
|
if (retries.length === 0) { return; }
|
||||||
return;
|
log(`Warning: The following tests required retries (${ name })`);
|
||||||
}
|
|
||||||
log(`Warning: The following tests required retries (${name})`);
|
|
||||||
retries.forEach(({ error, message }) => {
|
retries.forEach(({ error, message }) => {
|
||||||
log(" " + message);
|
log(" " + message);
|
||||||
if (error) {
|
if (error) { log(error); }
|
||||||
log(error);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Stats = Stats;
|
|
||||||
exports.stats = new Stats(_guard);
|
export const stats = new Stats(_guard);
|
||||||
|
*/
|
||||||
//# sourceMappingURL=utils.js.map
|
//# 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,GAAG,MAAM,CAAC;KACjB;IAED,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC,CAAC,EAAE,CAAC;AAEL,iBAAiB;AACjB,SAAgB,SAAS,CAAI,GAAW;IACrC,MAAM,QAAQ,GAA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ACZ,KAAK,UAAU,OAAO,CAAC,IAAY,EAAE,IAA4C;IACpF,mCAAmC;IAEnC,EAAE,CAAC,IAAI,EAAE,KAAK;QACV,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;QAE9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC/B,IAAI;gBACA,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO;aACV;YAAC,OAAO,KAAU,EAAE;gBACjB,IAAI,KAAK,CAAC,OAAO,KAAK,+BAA+B,EAAE;oBACnD,uCAAuC;oBACvC,MAAM,KAAK,CAAC;iBAEf;qBAAM,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,EAAE;oBACvC,sCAAsC;oBACtC,MAAM,KAAK,CAAC;iBAEf;qBAAM;oBACH,qBAAqB;oBAErB,IAAI,CAAC,KAAK,QAAQ,GAAG,CAAC,EAAE;wBACpB,MAAM,KAAK,CAAC;wBACZ,kCAAkC;qBACrC;yBAAM;wBACH,MAAM,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;wBAC5B,iCAAiC;qBACpC;iBACJ;aACJ;SACJ;QAED,oBAAoB;QACpB,MAAM,IAAI,KAAK,CAAC,gBAAiB,QAAS,cAAe,IAAK,EAAE,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACP,CAAC;AApCD,0BAoCC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqDE"}
|
@ -42,21 +42,17 @@ class AbiCoder {
|
|||||||
let match = param.type.match(paramTypeNumber);
|
let match = param.type.match(paramTypeNumber);
|
||||||
if (match) {
|
if (match) {
|
||||||
let size = parseInt(match[2] || "256");
|
let size = parseInt(match[2] || "256");
|
||||||
if (size === 0 || size > 256 || (size % 8) !== 0) {
|
(0, index_js_1.assertArgument)(size !== 0 && size <= 256 && (size % 8) === 0, "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);
|
return new number_js_1.NumberCoder(size / 8, (match[1] === "int"), param.name);
|
||||||
}
|
}
|
||||||
// bytes[0-9]+
|
// bytes[0-9]+
|
||||||
match = param.type.match(paramTypeBytes);
|
match = param.type.match(paramTypeBytes);
|
||||||
if (match) {
|
if (match) {
|
||||||
let size = parseInt(match[1]);
|
let size = parseInt(match[1]);
|
||||||
if (size === 0 || size > 32) {
|
(0, index_js_1.assertArgument)(size !== 0 && size <= 32, "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 new fixed_bytes_js_1.FixedBytesCoder(size, param.name);
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("invalid type", "type", param.type);
|
(0, index_js_1.assertArgument)(false, "invalid type", "type", param.type);
|
||||||
}
|
}
|
||||||
getDefaultValue(types) {
|
getDefaultValue(types) {
|
||||||
const coders = types.map((type) => this.#getCoder(fragments_js_1.ParamType.from(type)));
|
const coders = types.map((type) => this.#getCoder(fragments_js_1.ParamType.from(type)));
|
||||||
|
File diff suppressed because one or more lines are too long
@ -133,13 +133,7 @@ function checkResultErrors(result) {
|
|||||||
exports.checkResultErrors = checkResultErrors;
|
exports.checkResultErrors = checkResultErrors;
|
||||||
function getValue(value) {
|
function getValue(value) {
|
||||||
let bytes = (0, index_js_1.toArray)(value);
|
let bytes = (0, index_js_1.toArray)(value);
|
||||||
if (bytes.length > exports.WordSize) {
|
(0, index_js_1.assert)(bytes.length <= exports.WordSize, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: bytes, length: exports.WordSize, offset: bytes.length });
|
||||||
(0, index_js_1.throwError)("value out-of-bounds", "BUFFER_OVERRUN", {
|
|
||||||
buffer: bytes,
|
|
||||||
length: exports.WordSize,
|
|
||||||
offset: bytes.length
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (bytes.length !== exports.WordSize) {
|
if (bytes.length !== exports.WordSize) {
|
||||||
bytes = (0, index_js_1.getBytesCopy)((0, index_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]));
|
||||||
}
|
}
|
||||||
@ -165,7 +159,7 @@ class Coder {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
_throwError(message, value) {
|
_throwError(message, value) {
|
||||||
return (0, index_js_1.throwArgumentError)(message, this.localName, value);
|
(0, index_js_1.assertArgument)(false, message, this.localName, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.Coder = Coder;
|
exports.Coder = Coder;
|
||||||
@ -238,7 +232,7 @@ class Reader {
|
|||||||
alignedLength = length;
|
alignedLength = length;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, index_js_1.throwError)("data out-of-bounds", "BUFFER_OVERRUN", {
|
(0, index_js_1.assert)(false, "data out-of-bounds", "BUFFER_OVERRUN", {
|
||||||
buffer: (0, index_js_1.getBytesCopy)(this.#data),
|
buffer: (0, index_js_1.getBytesCopy)(this.#data),
|
||||||
length: this.#data.length,
|
length: this.#data.length,
|
||||||
offset: this.#offset + alignedLength
|
offset: this.#offset + alignedLength
|
||||||
|
File diff suppressed because one or more lines are too long
@ -14,30 +14,16 @@ function pack(writer, coders, values) {
|
|||||||
let unique = {};
|
let unique = {};
|
||||||
arrayValues = coders.map((coder) => {
|
arrayValues = coders.map((coder) => {
|
||||||
const name = coder.localName;
|
const name = coder.localName;
|
||||||
if (!name) {
|
(0, index_js_1.assert)(name, "cannot encode object for signature with missing names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
|
||||||
(0, index_js_1.throwError)("cannot encode object for signature with missing names", "INVALID_ARGUMENT", {
|
(0, index_js_1.assert)(unique[name], "cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", { argument: "values", info: { coder }, value: values });
|
||||||
argument: "values",
|
|
||||||
info: { coder },
|
|
||||||
value: values
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (unique[name]) {
|
|
||||||
(0, index_js_1.throwError)("cannot encode object for signature with duplicate names", "INVALID_ARGUMENT", {
|
|
||||||
argument: "values",
|
|
||||||
info: { coder },
|
|
||||||
value: values
|
|
||||||
});
|
|
||||||
}
|
|
||||||
unique[name] = true;
|
unique[name] = true;
|
||||||
return values[name];
|
return values[name];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, index_js_1.throwArgumentError)("invalid tuple value", "tuple", values);
|
(0, index_js_1.assertArgument)(false, "invalid tuple value", "tuple", values);
|
||||||
}
|
|
||||||
if (coders.length !== arrayValues.length) {
|
|
||||||
(0, index_js_1.throwArgumentError)("types/value length mismatch", "tuple", values);
|
|
||||||
}
|
}
|
||||||
|
(0, index_js_1.assertArgument)(coders.length === arrayValues.length, "types/value length mismatch", "tuple", values);
|
||||||
let staticWriter = new abstract_coder_js_1.Writer();
|
let staticWriter = new abstract_coder_js_1.Writer();
|
||||||
let dynamicWriter = new abstract_coder_js_1.Writer();
|
let dynamicWriter = new abstract_coder_js_1.Writer();
|
||||||
let updateFuncs = [];
|
let updateFuncs = [];
|
||||||
@ -157,13 +143,7 @@ class ArrayCoder extends abstract_coder_js_1.Coder {
|
|||||||
// slot requires at least 32 bytes for their value (or 32
|
// slot requires at least 32 bytes for their value (or 32
|
||||||
// bytes as a link to the data). This could use a much
|
// bytes as a link to the data). This could use a much
|
||||||
// tighter bound, but we are erroring on the side of safety.
|
// tighter bound, but we are erroring on the side of safety.
|
||||||
if (count * abstract_coder_js_1.WordSize > reader.dataLength) {
|
(0, index_js_1.assert)(count * abstract_coder_js_1.WordSize <= reader.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count * abstract_coder_js_1.WordSize, length: reader.dataLength });
|
||||||
(0, index_js_1.throwError)("insufficient data length", "BUFFER_OVERRUN", {
|
|
||||||
buffer: reader.bytes,
|
|
||||||
offset: count * abstract_coder_js_1.WordSize,
|
|
||||||
length: reader.dataLength
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let coders = [];
|
let coders = [];
|
||||||
for (let i = 0; i < count; i++) {
|
for (let i = 0; i < count; i++) {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -302,9 +302,7 @@ function consumeEoi(tokens) {
|
|||||||
const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
|
||||||
function verifyBasicType(type) {
|
function verifyBasicType(type) {
|
||||||
const match = type.match(regexType);
|
const match = type.match(regexType);
|
||||||
if (!match) {
|
(0, index_js_1.assertArgument)(match, "invalid type", "type", type);
|
||||||
return (0, index_js_1.throwArgumentError)("invalid type", "type", type);
|
|
||||||
}
|
|
||||||
if (type === "uint") {
|
if (type === "uint") {
|
||||||
return "uint256";
|
return "uint256";
|
||||||
}
|
}
|
||||||
@ -314,16 +312,12 @@ function verifyBasicType(type) {
|
|||||||
if (match[2]) {
|
if (match[2]) {
|
||||||
// bytesXX
|
// bytesXX
|
||||||
const length = parseInt(match[2]);
|
const length = parseInt(match[2]);
|
||||||
if (length === 0 || length > 32) {
|
(0, index_js_1.assertArgument)(length !== 0 && length <= 32, "invalid bytes length", "type", type);
|
||||||
(0, index_js_1.throwArgumentError)("invalid bytes length", "type", type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (match[3]) {
|
else if (match[3]) {
|
||||||
// intXX or uintXX
|
// intXX or uintXX
|
||||||
const size = parseInt(match[3]);
|
const size = parseInt(match[3]);
|
||||||
if (size === 0 || size > 256 || size % 8) {
|
(0, index_js_1.assertArgument)(size !== 0 && size <= 256 && (size % 8) === 0, "invalid numeric width", "type", type);
|
||||||
(0, index_js_1.throwArgumentError)("invalid numeric width", "type", type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@ -575,14 +569,10 @@ class ParamType {
|
|||||||
return new ParamType(_guard, name, type, baseType, indexed, comps, arrayLength, arrayChildren);
|
return new ParamType(_guard, name, type, baseType, indexed, comps, arrayLength, arrayChildren);
|
||||||
}
|
}
|
||||||
const name = obj.name;
|
const name = obj.name;
|
||||||
if (name && (typeof (name) !== "string" || !name.match(regexIdentifier))) {
|
(0, index_js_1.assertArgument)(!name || (typeof (name) === "string" && name.match(regexIdentifier)), "invalid name", "obj.name", name);
|
||||||
(0, index_js_1.throwArgumentError)("invalid name", "obj.name", name);
|
|
||||||
}
|
|
||||||
let indexed = obj.indexed;
|
let indexed = obj.indexed;
|
||||||
if (indexed != null) {
|
if (indexed != null) {
|
||||||
if (!allowIndexed) {
|
(0, index_js_1.assertArgument)(allowIndexed, "parameter cannot be indexed", "obj.indexed", obj.indexed);
|
||||||
(0, index_js_1.throwArgumentError)("parameter cannot be indexed", "obj.indexed", obj.indexed);
|
|
||||||
}
|
|
||||||
indexed = !!indexed;
|
indexed = !!indexed;
|
||||||
}
|
}
|
||||||
let type = obj.type;
|
let type = obj.type;
|
||||||
@ -669,9 +659,7 @@ class NamedFragment extends Fragment {
|
|||||||
name;
|
name;
|
||||||
constructor(guard, type, name, inputs) {
|
constructor(guard, type, name, inputs) {
|
||||||
super(guard, type, inputs);
|
super(guard, type, inputs);
|
||||||
if (typeof (name) !== "string" || !name.match(regexIdentifier)) {
|
(0, index_js_1.assertArgument)(typeof (name) === "string" && name.match(regexIdentifier), "invalid identifier", "name", name);
|
||||||
(0, index_js_1.throwArgumentError)("invalid identifier", "name", name);
|
|
||||||
}
|
|
||||||
inputs = Object.freeze(inputs.slice());
|
inputs = Object.freeze(inputs.slice());
|
||||||
(0, index_js_1.defineProperties)(this, { name });
|
(0, index_js_1.defineProperties)(this, { name });
|
||||||
}
|
}
|
||||||
@ -782,11 +770,7 @@ class ConstructorFragment extends Fragment {
|
|||||||
(0, index_js_1.defineProperties)(this, { payable, gas });
|
(0, index_js_1.defineProperties)(this, { payable, gas });
|
||||||
}
|
}
|
||||||
format(format = "sighash") {
|
format(format = "sighash") {
|
||||||
if (format === "sighash") {
|
(0, index_js_1.assert)(format !== "sighash", "cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", { operation: "format(sighash)" });
|
||||||
(0, index_js_1.throwError)("cannot format a constructor for sighash", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "format(sighash)"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (format === "json") {
|
if (format === "json") {
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
type: "constructor",
|
type: "constructor",
|
||||||
|
File diff suppressed because one or more lines are too long
@ -215,7 +215,7 @@ class Interface {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(0, index_js_3.throwArgumentError)("no matching function", "selector", key);
|
(0, index_js_3.assertArgument)(false, "no matching function", "selector", key);
|
||||||
}
|
}
|
||||||
// It is a bare name, look up the function (will return null if ambiguous)
|
// It is a bare name, look up the function (will return null if ambiguous)
|
||||||
if (key.indexOf("(") === -1) {
|
if (key.indexOf("(") === -1) {
|
||||||
@ -273,12 +273,10 @@ class Interface {
|
|||||||
matching.splice(0, 1);
|
matching.splice(0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matching.length === 0) {
|
(0, index_js_3.assertArgument)(matching.length !== 0, "no matching function", "name", key);
|
||||||
(0, index_js_3.throwArgumentError)("no matching function", "name", key);
|
if (matching.length > 1 && forceUnique) {
|
||||||
}
|
|
||||||
else if (matching.length > 1 && forceUnique) {
|
|
||||||
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(", ");
|
||||||
(0, index_js_3.throwArgumentError)(`multiple matching functions (i.e. ${matchStr})`, "name", key);
|
(0, index_js_3.assertArgument)(false, `multiple matching functions (i.e. ${matchStr})`, "name", key);
|
||||||
}
|
}
|
||||||
return matching[0];
|
return matching[0];
|
||||||
}
|
}
|
||||||
@ -287,7 +285,7 @@ class Interface {
|
|||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("no matching function", "signature", key);
|
(0, index_js_3.assertArgument)(false, "no matching function", "signature", key);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the function name for %%key%%, which may be a function selector,
|
* Get the function name for %%key%%, which may be a function selector,
|
||||||
@ -319,7 +317,7 @@ class Interface {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(0, index_js_3.throwArgumentError)("no matching event", "eventTopic", key);
|
(0, index_js_3.assertArgument)(false, "no matching event", "eventTopic", key);
|
||||||
}
|
}
|
||||||
// It is a bare name, look up the function (will return null if ambiguous)
|
// It is a bare name, look up the function (will return null if ambiguous)
|
||||||
if (key.indexOf("(") === -1) {
|
if (key.indexOf("(") === -1) {
|
||||||
@ -352,12 +350,10 @@ class Interface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (matching.length === 0) {
|
(0, index_js_3.assertArgument)(matching.length > 0, "no matching event", "name", key);
|
||||||
(0, index_js_3.throwArgumentError)("no matching event", "name", key);
|
if (matching.length > 1 && forceUnique) {
|
||||||
}
|
|
||||||
else if (matching.length > 1 && forceUnique) {
|
|
||||||
// @TODO: refine by Typed
|
// @TODO: refine by Typed
|
||||||
(0, index_js_3.throwArgumentError)("multiple matching events", "name", key);
|
(0, index_js_3.assertArgument)(false, "multiple matching events", "name", key);
|
||||||
}
|
}
|
||||||
return matching[0];
|
return matching[0];
|
||||||
}
|
}
|
||||||
@ -366,7 +362,7 @@ class Interface {
|
|||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("no matching event", "signature", key);
|
(0, index_js_3.assertArgument)(false, "no matching event", "signature", key);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the event name for %%key%%, which may be a topic hash,
|
* Get the event name for %%key%%, which may be a topic hash,
|
||||||
@ -409,7 +405,7 @@ class Interface {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(0, index_js_3.throwArgumentError)("no matching error", "selector", key);
|
(0, index_js_3.assertArgument)(false, "no matching error", "selector", key);
|
||||||
}
|
}
|
||||||
// It is a bare name, look up the function (will return null if ambiguous)
|
// It is a bare name, look up the function (will return null if ambiguous)
|
||||||
if (key.indexOf("(") === -1) {
|
if (key.indexOf("(") === -1) {
|
||||||
@ -426,11 +422,11 @@ class Interface {
|
|||||||
if (key === "Panic") {
|
if (key === "Panic") {
|
||||||
return fragments_js_1.ErrorFragment.from("error Panic(uint256)");
|
return fragments_js_1.ErrorFragment.from("error Panic(uint256)");
|
||||||
}
|
}
|
||||||
(0, index_js_3.throwArgumentError)("no matching error", "name", key);
|
(0, index_js_3.assertArgument)(false, "no matching error", "name", key);
|
||||||
}
|
}
|
||||||
else if (matching.length > 1) {
|
else if (matching.length > 1) {
|
||||||
// @TODO: refine by Typed
|
// @TODO: refine by Typed
|
||||||
(0, index_js_3.throwArgumentError)("multiple matching errors", "name", key);
|
(0, index_js_3.assertArgument)(false, "multiple matching errors", "name", key);
|
||||||
}
|
}
|
||||||
return matching[0];
|
return matching[0];
|
||||||
}
|
}
|
||||||
@ -446,7 +442,7 @@ class Interface {
|
|||||||
if (result) {
|
if (result) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("no matching error", "signature", key);
|
(0, index_js_3.assertArgument)(false, "no matching error", "signature", key);
|
||||||
}
|
}
|
||||||
// Get the 4-byte selector used by Solidity to identify a function
|
// Get the 4-byte selector used by Solidity to identify a function
|
||||||
/*
|
/*
|
||||||
@ -502,9 +498,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
if (typeof (fragment) === "string") {
|
if (typeof (fragment) === "string") {
|
||||||
fragment = this.getError(fragment);
|
fragment = this.getError(fragment);
|
||||||
}
|
}
|
||||||
if ((0, index_js_3.dataSlice)(data, 0, 4) !== fragment.selector) {
|
(0, index_js_3.assertArgument)((0, index_js_3.dataSlice)(data, 0, 4) === fragment.selector, `data signature does not match error ${fragment.name}.`, "data", data);
|
||||||
(0, index_js_3.throwArgumentError)(`data signature does not match error ${fragment.name}.`, "data", data);
|
|
||||||
}
|
|
||||||
return this._decodeParams(fragment.inputs, (0, index_js_3.dataSlice)(data, 4));
|
return this._decodeParams(fragment.inputs, (0, index_js_3.dataSlice)(data, 4));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -532,9 +526,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
*/
|
*/
|
||||||
decodeFunctionData(key, data) {
|
decodeFunctionData(key, data) {
|
||||||
const fragment = (typeof (key) === "string") ? this.getFunction(key) : key;
|
const fragment = (typeof (key) === "string") ? this.getFunction(key) : key;
|
||||||
if ((0, index_js_3.dataSlice)(data, 0, 4) !== fragment.selector) {
|
(0, index_js_3.assertArgument)((0, index_js_3.dataSlice)(data, 0, 4) === fragment.selector, `data signature does not match function ${fragment.name}.`, "data", data);
|
||||||
(0, index_js_3.throwArgumentError)(`data signature does not match function ${fragment.name}.`, "data", data);
|
|
||||||
}
|
|
||||||
return this._decodeParams(fragment.inputs, (0, index_js_3.dataSlice)(data, 4));
|
return this._decodeParams(fragment.inputs, (0, index_js_3.dataSlice)(data, 4));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -573,7 +565,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Call returned data with no error, but the data is junk
|
// Call returned data with no error, but the data is junk
|
||||||
return (0, index_js_3.throwError)(message, "BAD_DATA", {
|
(0, index_js_3.assert)(false, message, "BAD_DATA", {
|
||||||
value: (0, index_js_3.hexlify)(bytes),
|
value: (0, index_js_3.hexlify)(bytes),
|
||||||
info: { method: fragment.name, signature: fragment.format() }
|
info: { method: fragment.name, signature: fragment.format() }
|
||||||
});
|
});
|
||||||
@ -662,12 +654,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
if (typeof (eventFragment) === "string") {
|
if (typeof (eventFragment) === "string") {
|
||||||
eventFragment = this.getEvent(eventFragment);
|
eventFragment = this.getEvent(eventFragment);
|
||||||
}
|
}
|
||||||
if (values.length > eventFragment.inputs.length) {
|
(0, index_js_3.assert)(values.length <= eventFragment.inputs.length, `too many arguments for ${eventFragment.format()}`, "UNEXPECTED_ARGUMENT", { count: values.length, expectedCount: eventFragment.inputs.length });
|
||||||
(0, index_js_3.throwError)("too many arguments for " + eventFragment.format(), "UNEXPECTED_ARGUMENT", {
|
|
||||||
count: values.length,
|
|
||||||
expectedCount: eventFragment.inputs.length
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const topics = [];
|
const topics = [];
|
||||||
if (!eventFragment.anonymous) {
|
if (!eventFragment.anonymous) {
|
||||||
topics.push(eventFragment.topicHash);
|
topics.push(eventFragment.topicHash);
|
||||||
@ -696,16 +683,14 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
values.forEach((value, index) => {
|
values.forEach((value, index) => {
|
||||||
const param = eventFragment.inputs[index];
|
const param = eventFragment.inputs[index];
|
||||||
if (!param.indexed) {
|
if (!param.indexed) {
|
||||||
if (value != null) {
|
(0, index_js_3.assertArgument)(value == null, "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;
|
return;
|
||||||
}
|
}
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
topics.push(null);
|
topics.push(null);
|
||||||
}
|
}
|
||||||
else if (param.baseType === "array" || param.baseType === "tuple") {
|
else if (param.baseType === "array" || param.baseType === "tuple") {
|
||||||
(0, index_js_3.throwArgumentError)("filtering with tuples or arrays not supported", ("contract." + param.name), value);
|
(0, index_js_3.assertArgument)(false, "filtering with tuples or arrays not supported", ("contract." + param.name), value);
|
||||||
}
|
}
|
||||||
else if (Array.isArray(value)) {
|
else if (Array.isArray(value)) {
|
||||||
topics.push(value.map((value) => encodeTopic(param, value)));
|
topics.push(value.map((value) => encodeTopic(param, value)));
|
||||||
@ -730,9 +715,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
if (!eventFragment.anonymous) {
|
if (!eventFragment.anonymous) {
|
||||||
topics.push(eventFragment.topicHash);
|
topics.push(eventFragment.topicHash);
|
||||||
}
|
}
|
||||||
if (values.length !== eventFragment.inputs.length) {
|
(0, index_js_3.assertArgument)(values.length !== eventFragment.inputs.length, "event arguments/values mismatch", "values", values);
|
||||||
(0, index_js_3.throwArgumentError)("event arguments/values mismatch", "values", values);
|
|
||||||
}
|
|
||||||
eventFragment.inputs.forEach((param, index) => {
|
eventFragment.inputs.forEach((param, index) => {
|
||||||
const value = values[index];
|
const value = values[index];
|
||||||
if (param.indexed) {
|
if (param.indexed) {
|
||||||
@ -767,9 +750,7 @@ getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
|||||||
}
|
}
|
||||||
if (topics != null && !eventFragment.anonymous) {
|
if (topics != null && !eventFragment.anonymous) {
|
||||||
const eventTopic = eventFragment.topicHash;
|
const eventTopic = eventFragment.topicHash;
|
||||||
if (!(0, index_js_3.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== eventTopic) {
|
(0, index_js_3.assertArgument)((0, index_js_3.isHexString)(topics[0], 32) && topics[0].toLowerCase() === eventTopic, "fragment/topic mismatch", "topics[0]", topics[0]);
|
||||||
(0, index_js_3.throwArgumentError)("fragment/topic mismatch", "topics[0]", topics[0]);
|
|
||||||
}
|
|
||||||
topics = topics.slice(1);
|
topics = topics.slice(1);
|
||||||
}
|
}
|
||||||
const indexed = [];
|
const indexed = [];
|
||||||
|
File diff suppressed because one or more lines are too long
@ -72,9 +72,7 @@ function fromBase36(value) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
function getAddress(address) {
|
function getAddress(address) {
|
||||||
if (typeof (address) !== "string") {
|
(0, index_js_2.assertArgument)(typeof (address) === "string", "invalid address", "address", address);
|
||||||
(0, index_js_2.throwArgumentError)("invalid address", "address", address);
|
|
||||||
}
|
|
||||||
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
||||||
// Missing the 0x prefix
|
// Missing the 0x prefix
|
||||||
if (address.substring(0, 2) !== "0x") {
|
if (address.substring(0, 2) !== "0x") {
|
||||||
@ -82,24 +80,20 @@ function getAddress(address) {
|
|||||||
}
|
}
|
||||||
const result = getChecksumAddress(address);
|
const result = getChecksumAddress(address);
|
||||||
// It is a checksummed address with a bad checksum
|
// It is a checksummed address with a bad checksum
|
||||||
if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
|
(0, index_js_2.assertArgument)(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address);
|
||||||
(0, index_js_2.throwArgumentError)("bad address checksum", "address", address);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// Maybe ICAP? (we only support direct mode)
|
// Maybe ICAP? (we only support direct mode)
|
||||||
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
||||||
// It is an ICAP address with a bad checksum
|
// It is an ICAP address with a bad checksum
|
||||||
if (address.substring(2, 4) !== ibanChecksum(address)) {
|
(0, index_js_2.assertArgument)(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
|
||||||
(0, index_js_2.throwArgumentError)("bad icap checksum", "address", address);
|
|
||||||
}
|
|
||||||
let result = fromBase36(address.substring(4)).toString(16);
|
let result = fromBase36(address.substring(4)).toString(16);
|
||||||
while (result.length < 40) {
|
while (result.length < 40) {
|
||||||
result = "0" + result;
|
result = "0" + result;
|
||||||
}
|
}
|
||||||
return getChecksumAddress("0x" + result);
|
return getChecksumAddress("0x" + result);
|
||||||
}
|
}
|
||||||
return (0, index_js_2.throwArgumentError)("invalid address", "address", address);
|
(0, index_js_2.assertArgument)(false, "invalid address", "address", address);
|
||||||
}
|
}
|
||||||
exports.getAddress = getAddress;
|
exports.getAddress = getAddress;
|
||||||
function getIcapAddress(address) {
|
function getIcapAddress(address) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src.ts/address/address.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAC/C,gDAAiE;AAGjE,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;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;QACzB,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KACxC;IAED,MAAM,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4CAA4C;QAC5C,IAAA,yBAAc,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,OAAO,CAAC,EAAE,mBAAmB,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAE3G,IAAI,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC3D,OAAO,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE;YAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;SAAE;QACrD,OAAQ,kBAAkB,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC;KAC7C;IAED,IAAA,yBAAc,EAAC,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACjE,CAAC;AA7BD,gCA6BC;AAED,SAAgB,cAAc,CAAC,OAAe;IAC1C,2EAA2E;IAC3E,IAAI,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,OAAO,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE;QAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;KAAE;IACrD,OAAO,IAAI,GAAG,YAAY,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAAC;AACzD,CAAC;AALD,wCAKC"}
|
@ -19,10 +19,8 @@ exports.isAddress = isAddress;
|
|||||||
async function checkAddress(target, promise) {
|
async function checkAddress(target, promise) {
|
||||||
const result = await promise;
|
const result = await promise;
|
||||||
if (result == null || result === "0x0000000000000000000000000000000000000000") {
|
if (result == null || result === "0x0000000000000000000000000000000000000000") {
|
||||||
if (typeof (target) === "string") {
|
(0, index_js_1.assert)(typeof (target) !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target });
|
||||||
return (0, index_js_1.throwError)("unconfigured name", "UNCONFIGURED_NAME", { value: target });
|
(0, index_js_1.assertArgument)(false, "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);
|
return (0, address_js_1.getAddress)(result);
|
||||||
}
|
}
|
||||||
@ -33,11 +31,7 @@ function resolveAddress(target, resolver) {
|
|||||||
if (target.match(/^0x[0-9a-f]{40}$/i)) {
|
if (target.match(/^0x[0-9a-f]{40}$/i)) {
|
||||||
return (0, address_js_1.getAddress)(target);
|
return (0, address_js_1.getAddress)(target);
|
||||||
}
|
}
|
||||||
if (resolver == null) {
|
(0, index_js_1.assert)(resolver != null, "ENS resolution requires a provider", "UNSUPPORTED_OPERATION", { operation: "resolveName" });
|
||||||
return (0, index_js_1.throwError)("ENS resolution requires a provider", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "resolveName",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return checkAddress(target, resolver.resolveName(target));
|
return checkAddress(target, resolver.resolveName(target));
|
||||||
}
|
}
|
||||||
else if (isAddressable(target)) {
|
else if (isAddressable(target)) {
|
||||||
@ -46,7 +40,7 @@ function resolveAddress(target, resolver) {
|
|||||||
else if (typeof (target.then) === "function") {
|
else if (typeof (target.then) === "function") {
|
||||||
return checkAddress(target, target);
|
return checkAddress(target, target);
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("unsupported addressable value", "target", target);
|
(0, index_js_1.assertArgument)(false, "unsupported addressable value", "target", target);
|
||||||
}
|
}
|
||||||
exports.resolveAddress = resolveAddress;
|
exports.resolveAddress = resolveAddress;
|
||||||
//# sourceMappingURL=checks.js.map
|
//# sourceMappingURL=checks.js.map
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"checks.js","sourceRoot":"","sources":["../../src.ts/address/checks.ts"],"names":[],"mappings":";;;AAAA,gDAAmE;AAE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AAC,CAAC;KAC5G;IACD,OAAO,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAED,gEAAgE;AAChE,kCAAkC;AAClC,SAAgB,cAAc,CAAC,MAAmB,EAAE,QAA8B;IAE9E,IAAI,OAAM,CAAC,MAAM,CAAC,KAAK,QAAQ,EAAE;QAC7B,IAAI,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;YAAE,OAAO,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;SAAE;QAErE,IAAA,iBAAM,EAAC,QAAQ,IAAI,IAAI,EAAE,oCAAoC,EACzD,uBAAuB,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC;QAE3D,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,IAAA,yBAAc,EAAC,KAAK,EAAE,+BAA+B,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC;AAlBD,wCAkBC"}
|
@ -25,12 +25,8 @@ function getCreate2Address(_from, _salt, _initCodeHash) {
|
|||||||
const from = (0, address_js_1.getAddress)(_from);
|
const from = (0, address_js_1.getAddress)(_from);
|
||||||
const salt = (0, index_js_2.getBytes)(_salt, "salt");
|
const salt = (0, index_js_2.getBytes)(_salt, "salt");
|
||||||
const initCodeHash = (0, index_js_2.getBytes)(_initCodeHash, "initCodeHash");
|
const initCodeHash = (0, index_js_2.getBytes)(_initCodeHash, "initCodeHash");
|
||||||
if (salt.length !== 32) {
|
(0, index_js_2.assertArgument)(salt.length === 32, "salt must be 32 bytes", "salt", _salt);
|
||||||
(0, index_js_2.throwArgumentError)("salt must be 32 bytes", "salt", _salt);
|
(0, index_js_2.assertArgument)(initCodeHash.length === 32, "initCodeHash must be 32 bytes", "initCodeHash", _initCodeHash);
|
||||||
}
|
|
||||||
if (initCodeHash.length !== 32) {
|
|
||||||
(0, index_js_2.throwArgumentError)("initCodeHash must be 32 bytes", "initCodeHash", _initCodeHash);
|
|
||||||
}
|
|
||||||
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));
|
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;
|
exports.getCreate2Address = getCreate2Address;
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"contract-address.js","sourceRoot":"","sources":["../../src.ts/address/contract-address.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAC/C,gDAE2B;AAE3B,6CAA0C;AAK1C,sGAAsG;AACtG,SAAgB,gBAAgB,CAAC,EAAyC;IACtE,MAAM,IAAI,GAAG,IAAA,uBAAU,EAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,IAAA,oBAAS,EAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAE9C,IAAI,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,QAAQ,KAAK,GAAG,EAAE;QAClB,QAAQ,GAAG,IAAI,CAAC;KACnB;SAAM,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QAC5B,QAAQ,GAAG,KAAK,GAAG,QAAQ,CAAC;KAC/B;SAAM;QACH,QAAQ,GAAG,IAAI,GAAG,QAAQ,CAAC;KAC9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 @@ function canResolve(value) {
|
|||||||
function canSend(value) {
|
function canSend(value) {
|
||||||
return (value && typeof (value.sendTransaction) === "function");
|
return (value && typeof (value.sendTransaction) === "function");
|
||||||
}
|
}
|
||||||
function concisify(items) {
|
|
||||||
items = Array.from((new Set(items)).values());
|
|
||||||
items.sort();
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
class PreparedTopicFilter {
|
class PreparedTopicFilter {
|
||||||
#filter;
|
#filter;
|
||||||
fragment;
|
fragment;
|
||||||
@ -83,10 +78,10 @@ async function copyOverrides(arg) {
|
|||||||
// Some sanity checking; these are what these methods adds
|
// Some sanity checking; these are what these methods adds
|
||||||
//if ((<any>overrides).to) {
|
//if ((<any>overrides).to) {
|
||||||
if (overrides.to) {
|
if (overrides.to) {
|
||||||
(0, index_js_4.throwArgumentError)("cannot override to", "overrides.to", overrides.to);
|
(0, index_js_4.assertArgument)(false, "cannot override to", "overrides.to", overrides.to);
|
||||||
}
|
}
|
||||||
else if (overrides.data) {
|
else if (overrides.data) {
|
||||||
(0, index_js_4.throwArgumentError)("cannot override data", "overrides.data", overrides.data);
|
(0, index_js_4.assertArgument)(false, "cannot override data", "overrides.data", overrides.data);
|
||||||
}
|
}
|
||||||
// Resolve any from
|
// Resolve any from
|
||||||
if (overrides.from) {
|
if (overrides.from) {
|
||||||
@ -163,11 +158,7 @@ class WrappedMethod extends _WrappedMethodBase() {
|
|||||||
}
|
}
|
||||||
async send(...args) {
|
async send(...args) {
|
||||||
const runner = this._contract.runner;
|
const runner = this._contract.runner;
|
||||||
if (!canSend(runner)) {
|
(0, index_js_4.assert)(canSend(runner), "contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", { operation: "sendTransaction" });
|
||||||
return (0, index_js_4.throwError)("contract runner does not support sending transactions", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "sendTransaction"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const tx = await runner.sendTransaction(await this.populateTransaction(...args));
|
const tx = await runner.sendTransaction(await this.populateTransaction(...args));
|
||||||
const provider = getProvider(this._contract.runner);
|
const provider = getProvider(this._contract.runner);
|
||||||
// @TODO: the provider can be null; make a custom dummy provider that will throw a
|
// @TODO: the provider can be null; make a custom dummy provider that will throw a
|
||||||
@ -176,20 +167,12 @@ class WrappedMethod extends _WrappedMethodBase() {
|
|||||||
}
|
}
|
||||||
async estimateGas(...args) {
|
async estimateGas(...args) {
|
||||||
const runner = getRunner(this._contract.runner, "estimateGas");
|
const runner = getRunner(this._contract.runner, "estimateGas");
|
||||||
if (!canEstimate(runner)) {
|
(0, index_js_4.assert)(canEstimate(runner), "contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", { operation: "estimateGas" });
|
||||||
return (0, index_js_4.throwError)("contract runner does not support gas estimation", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "estimateGas"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return await runner.estimateGas(await this.populateTransaction(...args));
|
return await runner.estimateGas(await this.populateTransaction(...args));
|
||||||
}
|
}
|
||||||
async staticCallResult(...args) {
|
async staticCallResult(...args) {
|
||||||
const runner = getRunner(this._contract.runner, "call");
|
const runner = getRunner(this._contract.runner, "call");
|
||||||
if (!canCall(runner)) {
|
(0, index_js_4.assert)(canCall(runner), "contract runner does not support calling", "UNSUPPORTED_OPERATION", { operation: "call" });
|
||||||
return (0, index_js_4.throwError)("contract runner does not support calling", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "call"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const tx = await this.populateTransaction(...args);
|
const tx = await this.populateTransaction(...args);
|
||||||
let result = "0x";
|
let result = "0x";
|
||||||
try {
|
try {
|
||||||
@ -220,7 +203,7 @@ class WrappedEvent extends _WrappedEventBase() {
|
|||||||
});
|
});
|
||||||
return new Proxy(this, {
|
return new Proxy(this, {
|
||||||
// Perform the default operation for this fragment type
|
// Perform the default operation for this fragment type
|
||||||
apply: async (target, thisArg, args) => {
|
apply: (target, thisArg, args) => {
|
||||||
return new PreparedTopicFilter(contract, target.getFragment(...args), args);
|
return new PreparedTopicFilter(contract, target.getFragment(...args), args);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -250,22 +233,45 @@ function isDeferred(value) {
|
|||||||
return (value && typeof (value) === "object" && ("getTopicFilter" in value) &&
|
return (value && typeof (value) === "object" && ("getTopicFilter" in value) &&
|
||||||
(typeof (value.getTopicFilter) === "function") && value.fragment);
|
(typeof (value.getTopicFilter) === "function") && value.fragment);
|
||||||
}
|
}
|
||||||
async function getSubTag(contract, event) {
|
async function getSubInfo(contract, event) {
|
||||||
let fragment;
|
|
||||||
let topics;
|
let topics;
|
||||||
|
let fragment = null;
|
||||||
|
// Convert named events to topicHash and get the fragment for
|
||||||
|
// events which need deconstructing.
|
||||||
if (Array.isArray(event)) {
|
if (Array.isArray(event)) {
|
||||||
// Topics; e.g. `[ "0x1234...89ab" ]`
|
const topicHashify = function (name) {
|
||||||
fragment = contract.interface.getEvent(event[0]);
|
if ((0, index_js_4.isHexString)(name, 32)) {
|
||||||
topics = event;
|
return name;
|
||||||
|
}
|
||||||
|
return contract.interface.getEvent(name).topicHash;
|
||||||
|
};
|
||||||
|
// Array of Topics and Names; e.g. `[ "0x1234...89ab", "Transfer(address)" ]`
|
||||||
|
topics = event.map((e) => {
|
||||||
|
if (e == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (Array.isArray(e)) {
|
||||||
|
return e.map(topicHashify);
|
||||||
|
}
|
||||||
|
return topicHashify(e);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (event === "*") {
|
||||||
|
topics = [null];
|
||||||
}
|
}
|
||||||
else if (typeof (event) === "string") {
|
else if (typeof (event) === "string") {
|
||||||
// Event name (name or signature); `"Transfer"`
|
if ((0, index_js_4.isHexString)(event, 32)) {
|
||||||
|
// Topic Hash
|
||||||
|
topics = [event];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Name or Signature; e.g. `"Transfer", `"Transfer(address)"`
|
||||||
fragment = contract.interface.getEvent(event);
|
fragment = contract.interface.getEvent(event);
|
||||||
topics = [fragment.topicHash];
|
topics = [fragment.topicHash];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (isDeferred(event)) {
|
else if (isDeferred(event)) {
|
||||||
// Deferred Topic Filter; e.g. `contract.filter.Transfer(from)`
|
// Deferred Topic Filter; e.g. `contract.filter.Transfer(from)`
|
||||||
fragment = event.fragment;
|
|
||||||
topics = await event.getTopicFilter();
|
topics = await event.getTopicFilter();
|
||||||
}
|
}
|
||||||
else if ("fragment" in event) {
|
else if ("fragment" in event) {
|
||||||
@ -274,8 +280,7 @@ async function getSubTag(contract, event) {
|
|||||||
topics = [fragment.topicHash];
|
topics = [fragment.topicHash];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(event);
|
(0, index_js_4.assertArgument)(false, "unknown event name", "event", event);
|
||||||
throw new Error("TODO");
|
|
||||||
}
|
}
|
||||||
// Normalize topics and sort TopicSets
|
// Normalize topics and sort TopicSets
|
||||||
topics = topics.map((t) => {
|
topics = topics.map((t) => {
|
||||||
@ -283,7 +288,12 @@ async function getSubTag(contract, event) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (Array.isArray(t)) {
|
if (Array.isArray(t)) {
|
||||||
return concisify(t.map((t) => t.toLowerCase()));
|
const items = Array.from(new Set(t.map((t) => t.toLowerCase())).values());
|
||||||
|
if (items.length === 1) {
|
||||||
|
return items[0];
|
||||||
|
}
|
||||||
|
items.sort();
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
return t.toLowerCase();
|
return t.toLowerCase();
|
||||||
});
|
});
|
||||||
@ -300,25 +310,39 @@ async function getSubTag(contract, event) {
|
|||||||
}
|
}
|
||||||
async function hasSub(contract, event) {
|
async function hasSub(contract, event) {
|
||||||
const { subs } = getInternal(contract);
|
const { subs } = getInternal(contract);
|
||||||
return subs.get((await getSubTag(contract, event)).tag) || null;
|
return subs.get((await getSubInfo(contract, event)).tag) || null;
|
||||||
}
|
}
|
||||||
async function getSub(contract, event) {
|
async function getSub(contract, operation, event) {
|
||||||
// Make sure our runner can actually subscribe to events
|
// Make sure our runner can actually subscribe to events
|
||||||
const provider = getProvider(contract.runner);
|
const provider = getProvider(contract.runner);
|
||||||
if (!provider) {
|
(0, index_js_4.assert)(provider, "contract runner does not support subscribing", "UNSUPPORTED_OPERATION", { operation });
|
||||||
return (0, index_js_4.throwError)("contract runner does not support subscribing", "UNSUPPORTED_OPERATION", {
|
const { fragment, tag, topics } = await getSubInfo(contract, event);
|
||||||
operation: "on"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const { fragment, tag, topics } = await getSubTag(contract, event);
|
|
||||||
const { addr, subs } = getInternal(contract);
|
const { addr, subs } = getInternal(contract);
|
||||||
let sub = subs.get(tag);
|
let sub = subs.get(tag);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
const address = (addr ? addr : contract);
|
const address = (addr ? addr : contract);
|
||||||
const filter = { address, topics };
|
const filter = { address, topics };
|
||||||
const listener = (log) => {
|
const listener = (log) => {
|
||||||
const payload = new wrappers_js_1.ContractEventPayload(contract, null, event, fragment, log);
|
let foundFragment = fragment;
|
||||||
emit(contract, event, payload.args, payload);
|
if (foundFragment == null) {
|
||||||
|
try {
|
||||||
|
foundFragment = contract.interface.getEvent(log.topics[0]);
|
||||||
|
}
|
||||||
|
catch (error) { }
|
||||||
|
}
|
||||||
|
// If fragment is null, we do not deconstruct the args to emit
|
||||||
|
if (foundFragment) {
|
||||||
|
const _foundFragment = foundFragment;
|
||||||
|
const args = fragment ? contract.interface.decodeEventLog(fragment, log.data, log.topics) : [];
|
||||||
|
emit(contract, event, args, (listener) => {
|
||||||
|
return new wrappers_js_1.ContractEventPayload(contract, listener, event, _foundFragment, log);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit(contract, event, [], (listener) => {
|
||||||
|
return new wrappers_js_1.ContractUnknownEventPayload(contract, listener, event, log);
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let started = false;
|
let started = false;
|
||||||
const start = () => {
|
const start = () => {
|
||||||
@ -344,7 +368,7 @@ async function getSub(contract, event) {
|
|||||||
// ensure correct ordering (note this cannot throw and just adds the
|
// ensure correct ordering (note this cannot throw and just adds the
|
||||||
// notice to the event queu using setTimeout).
|
// notice to the event queu using setTimeout).
|
||||||
let lastEmit = Promise.resolve();
|
let lastEmit = Promise.resolve();
|
||||||
async function _emit(contract, event, args, payload) {
|
async function _emit(contract, event, args, payloadFunc) {
|
||||||
await lastEmit;
|
await lastEmit;
|
||||||
const sub = await hasSub(contract, event);
|
const sub = await hasSub(contract, event);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -353,8 +377,8 @@ async function _emit(contract, event, args, payload) {
|
|||||||
const count = sub.listeners.length;
|
const count = sub.listeners.length;
|
||||||
sub.listeners = sub.listeners.filter(({ listener, once }) => {
|
sub.listeners = sub.listeners.filter(({ listener, once }) => {
|
||||||
const passArgs = args.slice();
|
const passArgs = args.slice();
|
||||||
if (payload) {
|
if (payloadFunc) {
|
||||||
passArgs.push(new wrappers_js_1.ContractEventPayload(contract, (once ? null : listener), event, payload.fragment, payload.log));
|
passArgs.push(payloadFunc(once ? null : listener));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
listener.call(contract, ...passArgs);
|
listener.call(contract, ...passArgs);
|
||||||
@ -364,12 +388,12 @@ async function _emit(contract, event, args, payload) {
|
|||||||
});
|
});
|
||||||
return (count > 0);
|
return (count > 0);
|
||||||
}
|
}
|
||||||
async function emit(contract, event, args, payload) {
|
async function emit(contract, event, args, payloadFunc) {
|
||||||
try {
|
try {
|
||||||
await lastEmit;
|
await lastEmit;
|
||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
const resultPromise = _emit(contract, event, args, payload);
|
const resultPromise = _emit(contract, event, args, payloadFunc);
|
||||||
lastEmit = resultPromise;
|
lastEmit = resultPromise;
|
||||||
return await resultPromise;
|
return await resultPromise;
|
||||||
}
|
}
|
||||||
@ -458,14 +482,13 @@ class BaseContract {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
connect(runner) {
|
||||||
|
return new BaseContract(this.target, this.interface, runner);
|
||||||
|
}
|
||||||
async getAddress() { return await getInternal(this).addrPromise; }
|
async getAddress() { return await getInternal(this).addrPromise; }
|
||||||
async getDeployedCode() {
|
async getDeployedCode() {
|
||||||
const provider = getProvider(this.runner);
|
const provider = getProvider(this.runner);
|
||||||
if (!provider) {
|
(0, index_js_4.assert)(provider, "runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "getDeployedCode" });
|
||||||
return (0, index_js_4.throwError)("runner does not support .provider", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "getDeployedCode"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const code = await provider.getCode(await this.getAddress());
|
const code = await provider.getCode(await this.getAddress());
|
||||||
if (code === "0x") {
|
if (code === "0x") {
|
||||||
return null;
|
return null;
|
||||||
@ -486,11 +509,7 @@ class BaseContract {
|
|||||||
}
|
}
|
||||||
// Make sure we can subscribe to a provider event
|
// Make sure we can subscribe to a provider event
|
||||||
const provider = getProvider(this.runner);
|
const provider = getProvider(this.runner);
|
||||||
if (provider == null) {
|
(0, index_js_4.assert)(provider != null, "contract runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "waitForDeployment" });
|
||||||
return (0, index_js_4.throwError)("contract runner does not support .provider", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "waitForDeployment"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const checkCode = async () => {
|
const checkCode = async () => {
|
||||||
try {
|
try {
|
||||||
@ -529,26 +548,34 @@ class BaseContract {
|
|||||||
async queryFilter(event, fromBlock = 0, toBlock = "latest") {
|
async queryFilter(event, fromBlock = 0, toBlock = "latest") {
|
||||||
const { addr, addrPromise } = getInternal(this);
|
const { addr, addrPromise } = getInternal(this);
|
||||||
const address = (addr ? addr : (await addrPromise));
|
const address = (addr ? addr : (await addrPromise));
|
||||||
const { fragment, topics } = await getSubTag(this, event);
|
const { fragment, topics } = await getSubInfo(this, event);
|
||||||
const filter = { address, topics, fromBlock, toBlock };
|
const filter = { address, topics, fromBlock, toBlock };
|
||||||
const provider = getProvider(this.runner);
|
const provider = getProvider(this.runner);
|
||||||
if (!provider) {
|
(0, index_js_4.assert)(provider, "contract runner does not have a provider", "UNSUPPORTED_OPERATION", { operation: "queryFilter" });
|
||||||
return (0, index_js_4.throwError)("contract runner does not have a provider", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "queryFilter"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return (await provider.getLogs(filter)).map((log) => {
|
return (await provider.getLogs(filter)).map((log) => {
|
||||||
return new wrappers_js_1.EventLog(log, this.interface, fragment);
|
let foundFragment = fragment;
|
||||||
|
if (foundFragment == null) {
|
||||||
|
try {
|
||||||
|
foundFragment = this.interface.getEvent(log.topics[0]);
|
||||||
|
}
|
||||||
|
catch (error) { }
|
||||||
|
}
|
||||||
|
if (foundFragment) {
|
||||||
|
return new wrappers_js_1.EventLog(log, this.interface, foundFragment);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return new index_js_3.Log(log, provider);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async on(event, listener) {
|
async on(event, listener) {
|
||||||
const sub = await getSub(this, event);
|
const sub = await getSub(this, "on", event);
|
||||||
sub.listeners.push({ listener, once: false });
|
sub.listeners.push({ listener, once: false });
|
||||||
sub.start();
|
sub.start();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
async once(event, listener) {
|
async once(event, listener) {
|
||||||
const sub = await getSub(this, event);
|
const sub = await getSub(this, "once", event);
|
||||||
sub.listeners.push({ listener, once: true });
|
sub.listeners.push({ listener, once: true });
|
||||||
sub.start();
|
sub.start();
|
||||||
return this;
|
return this;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -45,11 +45,9 @@ class ContractFactory {
|
|||||||
}
|
}
|
||||||
async deploy(...args) {
|
async deploy(...args) {
|
||||||
const tx = await this.getDeployTransaction(...args);
|
const tx = await this.getDeployTransaction(...args);
|
||||||
if (!this.runner || typeof (this.runner.sendTransaction) !== "function") {
|
(0, index_js_3.assert)(this.runner && typeof (this.runner.sendTransaction) === "function", "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"
|
operation: "sendTransaction"
|
||||||
});
|
});
|
||||||
}
|
|
||||||
const sentTx = await this.runner.sendTransaction(tx);
|
const sentTx = await this.runner.sendTransaction(tx);
|
||||||
const address = (0, index_js_2.getCreateAddress)(sentTx);
|
const address = (0, index_js_2.getCreateAddress)(sentTx);
|
||||||
return new contract_js_1.BaseContract(address, this.interface, this.runner, sentTx);
|
return new contract_js_1.BaseContract(address, this.interface, this.runner, sentTx);
|
||||||
@ -58,9 +56,7 @@ class ContractFactory {
|
|||||||
return new ContractFactory(this.interface, this.bytecode, runner);
|
return new ContractFactory(this.interface, this.bytecode, runner);
|
||||||
}
|
}
|
||||||
static fromSolidity(output, runner) {
|
static fromSolidity(output, runner) {
|
||||||
if (output == null) {
|
(0, index_js_3.assertArgument)(output != null, "bad compiler output", "output", output);
|
||||||
(0, index_js_3.throwArgumentError)("bad compiler output", "output", output);
|
|
||||||
}
|
|
||||||
if (typeof (output) === "string") {
|
if (typeof (output) === "string") {
|
||||||
output = JSON.parse(output);
|
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,gDAG2B;AAE3B,+CAAyE;AAYzE,mCAAmC;AACnC,sC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,CAAC;SAClC;QAED,OAAO,IAAI,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;CACJ;AAzED,0CAyEC"}
|
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.ContractEventPayload = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.EventLog = void 0;
|
exports.ContractEventPayload = exports.ContractUnknownEventPayload = exports.ContractTransactionResponse = exports.ContractTransactionReceipt = exports.EventLog = void 0;
|
||||||
const index_js_1 = require("../providers/index.js");
|
const index_js_1 = require("../providers/index.js");
|
||||||
const index_js_2 = require("../utils/index.js");
|
const index_js_2 = require("../utils/index.js");
|
||||||
class EventLog extends index_js_1.Log {
|
class EventLog extends index_js_1.Log {
|
||||||
@ -50,21 +50,11 @@ class ContractTransactionResponse extends index_js_1.TransactionResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.ContractTransactionResponse = ContractTransactionResponse;
|
exports.ContractTransactionResponse = ContractTransactionResponse;
|
||||||
class ContractEventPayload extends index_js_2.EventPayload {
|
class ContractUnknownEventPayload extends index_js_2.EventPayload {
|
||||||
fragment;
|
|
||||||
log;
|
log;
|
||||||
args;
|
constructor(contract, listener, filter, log) {
|
||||||
constructor(contract, listener, filter, fragment, _log) {
|
|
||||||
super(contract, listener, filter);
|
super(contract, listener, filter);
|
||||||
const log = new EventLog(_log, contract.interface, fragment);
|
(0, index_js_2.defineProperties)(this, { log });
|
||||||
const args = contract.interface.decodeEventLog(fragment, log.data, log.topics);
|
|
||||||
(0, index_js_2.defineProperties)(this, { args, fragment, log });
|
|
||||||
}
|
|
||||||
get eventName() {
|
|
||||||
return this.fragment.name;
|
|
||||||
}
|
|
||||||
get eventSignature() {
|
|
||||||
return this.fragment.format();
|
|
||||||
}
|
}
|
||||||
async getBlock() {
|
async getBlock() {
|
||||||
return await this.log.getBlock();
|
return await this.log.getBlock();
|
||||||
@ -76,5 +66,19 @@ class ContractEventPayload extends index_js_2.EventPayload {
|
|||||||
return await this.log.getTransactionReceipt();
|
return await this.log.getTransactionReceipt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exports.ContractUnknownEventPayload = ContractUnknownEventPayload;
|
||||||
|
class ContractEventPayload extends ContractUnknownEventPayload {
|
||||||
|
constructor(contract, listener, filter, fragment, _log) {
|
||||||
|
super(contract, listener, filter, new EventLog(_log, contract.interface, fragment));
|
||||||
|
const args = contract.interface.decodeEventLog(fragment, this.log.data, this.log.topics);
|
||||||
|
(0, index_js_2.defineProperties)(this, { args, fragment });
|
||||||
|
}
|
||||||
|
get eventName() {
|
||||||
|
return this.fragment.name;
|
||||||
|
}
|
||||||
|
get eventSignature() {
|
||||||
|
return this.fragment.format();
|
||||||
|
}
|
||||||
|
}
|
||||||
exports.ContractEventPayload = ContractEventPayload;
|
exports.ContractEventPayload = ContractEventPayload;
|
||||||
//# sourceMappingURL=wrappers.js.map
|
//# sourceMappingURL=wrappers.js.map
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"wrappers.js","sourceRoot":"","sources":["../../src.ts/contract/wrappers.ts"],"names":[],"mappings":";;;AAAA,oDAE+B;AAC/B,gDAAmE;AAYnE,MAAa,QAAS,SAAQ,cAAG;IACpB,SAAS,CAAa;IACtB,QAAQ,CAAiB;IACzB,IAAI,CAAU;IAEvB,YAAY,GAAQ,EAAE,KAAgB,EAAE,QAAuB;QAC3D,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAClE,IAAA,2BAAgB,EAAW,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC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SAAQ,2BAA2B;IAMjE,YAAY,QAAsB,EAAE,QAAyB,EAAE,MAAyB,EAAE,QAAuB,EAAE,IAAS;QACxH,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzF,IAAA,2BAAgB,EAAuB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,IAAI,cAAc;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;CACJ;AAnBD,oDAmBC"}
|
@ -27,34 +27,26 @@ function createHash(algo) {
|
|||||||
case "sha256": return sha256_1.sha256.create();
|
case "sha256": return sha256_1.sha256.create();
|
||||||
case "sha512": return sha512_1.sha512.create();
|
case "sha512": return sha512_1.sha512.create();
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("invalid hashing algorithm name", "algorithm", algo);
|
(0, index_js_1.assertArgument)(false, "invalid hashing algorithm name", "algorithm", algo);
|
||||||
}
|
}
|
||||||
exports.createHash = createHash;
|
exports.createHash = createHash;
|
||||||
function createHmac(_algo, key) {
|
function createHmac(_algo, key) {
|
||||||
const algo = ({ sha256: sha256_1.sha256, sha512: sha512_1.sha512 }[_algo]);
|
const algo = ({ sha256: sha256_1.sha256, sha512: sha512_1.sha512 }[_algo]);
|
||||||
if (algo == null) {
|
(0, index_js_1.assertArgument)(algo != null, "invalid hmac algorithm", "algorithm", _algo);
|
||||||
return (0, index_js_1.throwArgumentError)("invalid hmac algorithm", "algorithm", _algo);
|
|
||||||
}
|
|
||||||
return hmac_1.hmac.create(algo, key);
|
return hmac_1.hmac.create(algo, key);
|
||||||
}
|
}
|
||||||
exports.createHmac = createHmac;
|
exports.createHmac = createHmac;
|
||||||
function pbkdf2Sync(password, salt, iterations, keylen, _algo) {
|
function pbkdf2Sync(password, salt, iterations, keylen, _algo) {
|
||||||
const algo = ({ sha256: sha256_1.sha256, sha512: sha512_1.sha512 }[_algo]);
|
const algo = ({ sha256: sha256_1.sha256, sha512: sha512_1.sha512 }[_algo]);
|
||||||
if (algo == null) {
|
(0, index_js_1.assertArgument)(algo != null, "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 });
|
return (0, pbkdf2_1.pbkdf2)(algo, password, salt, { c: iterations, dkLen: keylen });
|
||||||
}
|
}
|
||||||
exports.pbkdf2Sync = pbkdf2Sync;
|
exports.pbkdf2Sync = pbkdf2Sync;
|
||||||
function randomBytes(length) {
|
function randomBytes(length) {
|
||||||
if (crypto == null) {
|
(0, index_js_1.assert)(crypto != null, "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"
|
operation: "randomBytes"
|
||||||
});
|
});
|
||||||
}
|
(0, index_js_1.assertArgument)(Number.isInteger(length) && length > 0 && length <= 1024, "invalid length", "length", length);
|
||||||
if (!Number.isInteger(length) || length <= 0 || length > 1024) {
|
|
||||||
(0, index_js_1.throwArgumentError)("invalid length", "length", length);
|
|
||||||
}
|
|
||||||
const result = new Uint8Array(length);
|
const result = new Uint8Array(length);
|
||||||
crypto.getRandomValues(result);
|
crypto.getRandomValues(result);
|
||||||
return result;
|
return result;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,EAAN,eAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACzC,IAAA,yBAAc,EAAC,IAAI,IAAI,IAAI,EAAE,0BAA0B,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;IAC7E,OAAO,IAAA,eAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;AAC1E,CAAC;AAJD,gCAIC;AAED,SAAgB,WAAW,CAAC,MAAc;IACtC,IAAA,iBAAM,EAAC,MAAM,IAAI,IAAI,EAAE,iDAAiD,EAAE,uBAAuB,EAAE;QAC/F,SAAS,EAAE,aAAa;KAAE,CAAC,CAAC;IAEhC,IAAA,yBAAc,EAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE7G,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC;AAClB,CAAC;AATD,kCASC"}
|
@ -1,11 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.computeHmac = void 0;
|
exports.computeHmac = void 0;
|
||||||
const crypto_browser_js_1 = require("./crypto-browser.js");
|
const crypto_js_1 = require("./crypto.js");
|
||||||
const index_js_1 = require("../utils/index.js");
|
const index_js_1 = require("../utils/index.js");
|
||||||
let locked = false;
|
let locked = false;
|
||||||
const _computeHmac = function (algorithm, key, data) {
|
const _computeHmac = function (algorithm, key, data) {
|
||||||
return (0, crypto_browser_js_1.createHmac)(algorithm, key).update(data).digest();
|
return (0, crypto_js_1.createHmac)(algorithm, key).update(data).digest();
|
||||||
};
|
};
|
||||||
let __computeHmac = _computeHmac;
|
let __computeHmac = _computeHmac;
|
||||||
function computeHmac(algorithm, _key, _data) {
|
function computeHmac(algorithm, _key, _data) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src.ts/crypto/hmac.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AACjD,gDAAsD;AAKtD,IAAI,MAAM,GAAG,KAAK,CAAC;AAEnB,MAAM,YAAY,GAAG,UAAS,SAA8B,EAAE,GAAe,EAAE,IAAgB;IAC3F,OAAO,IAAA,8BAAU,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AAC5D,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"}
|
{"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,IAAA,sBAAU,EAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;AAC5D,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"}
|
@ -15,27 +15,19 @@ class Signature {
|
|||||||
#props;
|
#props;
|
||||||
get r() { return (0, index_js_2.getStore)(this.#props, "r"); }
|
get r() { return (0, index_js_2.getStore)(this.#props, "r"); }
|
||||||
set r(value) {
|
set r(value) {
|
||||||
if ((0, index_js_2.dataLength)(value) !== 32) {
|
(0, index_js_2.assertArgument)((0, index_js_2.dataLength)(value) === 32, "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));
|
(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"); }
|
get s() { return (0, index_js_2.getStore)(this.#props, "s"); }
|
||||||
set s(value) {
|
set s(value) {
|
||||||
if ((0, index_js_2.dataLength)(value) !== 32) {
|
(0, index_js_2.assertArgument)((0, index_js_2.dataLength)(value) === 32, "invalid r", "value", value);
|
||||||
(0, index_js_2.throwArgumentError)("invalid r", "value", value);
|
(0, index_js_2.assertArgument)(((0, index_js_2.getBytes)(value)[0] & 0x80) === 0, "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));
|
(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"); }
|
get v() { return (0, index_js_2.getStore)(this.#props, "v"); }
|
||||||
set v(value) {
|
set v(value) {
|
||||||
const v = (0, index_js_2.getNumber)(value, "value");
|
const v = (0, index_js_2.getNumber)(value, "value");
|
||||||
if (v !== 27 && v !== 28) {
|
(0, index_js_2.assertArgument)(v === 27 || v === 28, "invalid v", "v", value);
|
||||||
throw new Error("@TODO");
|
|
||||||
}
|
|
||||||
(0, index_js_2.setStore)(this.#props, "v", v);
|
(0, index_js_2.setStore)(this.#props, "v", v);
|
||||||
}
|
}
|
||||||
get networkV() { return (0, index_js_2.getStore)(this.#props, "networkV"); }
|
get networkV() { return (0, index_js_2.getStore)(this.#props, "networkV"); }
|
||||||
@ -92,9 +84,6 @@ class Signature {
|
|||||||
r: this.r, s: this.s, v: this.v,
|
r: this.r, s: this.s, v: this.v,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
//static create(): Signature {
|
|
||||||
// return new Signature(_guard, ZeroHash, ZeroHash, 27);
|
|
||||||
//}
|
|
||||||
// Get the chain ID from an EIP-155 v
|
// Get the chain ID from an EIP-155 v
|
||||||
static getChainId(v) {
|
static getChainId(v) {
|
||||||
const bv = (0, index_js_2.getBigInt)(v, "v");
|
const bv = (0, index_js_2.getBigInt)(v, "v");
|
||||||
@ -103,9 +92,7 @@ class Signature {
|
|||||||
return BN_0;
|
return BN_0;
|
||||||
}
|
}
|
||||||
// Bad value for an EIP-155 v
|
// Bad value for an EIP-155 v
|
||||||
if (bv < BN_35) {
|
(0, index_js_2.assertArgument)(bv >= BN_35, "invalid EIP-155 v", "v", v);
|
||||||
(0, index_js_2.throwArgumentError)("invalid EIP-155 v", "v", v);
|
|
||||||
}
|
|
||||||
return (bv - BN_35) / BN_2;
|
return (bv - BN_35) / BN_2;
|
||||||
}
|
}
|
||||||
// Get the EIP-155 v transformed for a given chainId
|
// Get the EIP-155 v transformed for a given chainId
|
||||||
@ -125,12 +112,13 @@ class Signature {
|
|||||||
return (bv & BN_1) ? 27 : 28;
|
return (bv & BN_1) ? 27 : 28;
|
||||||
}
|
}
|
||||||
static from(sig) {
|
static from(sig) {
|
||||||
|
function assertError(check, message) {
|
||||||
|
(0, index_js_2.assertArgument)(check, message, "signature", sig);
|
||||||
|
}
|
||||||
|
;
|
||||||
if (sig == null) {
|
if (sig == null) {
|
||||||
return new Signature(_guard, index_js_1.ZeroHash, index_js_1.ZeroHash, 27);
|
return new Signature(_guard, index_js_1.ZeroHash, index_js_1.ZeroHash, 27);
|
||||||
}
|
}
|
||||||
const throwError = (message) => {
|
|
||||||
return (0, index_js_2.throwArgumentError)(message, "signature", sig);
|
|
||||||
};
|
|
||||||
if (typeof (sig) === "string") {
|
if (typeof (sig) === "string") {
|
||||||
const bytes = (0, index_js_2.getBytes)(sig, "signature");
|
const bytes = (0, index_js_2.getBytes)(sig, "signature");
|
||||||
if (bytes.length === 64) {
|
if (bytes.length === 64) {
|
||||||
@ -143,46 +131,34 @@ class Signature {
|
|||||||
if (bytes.length === 65) {
|
if (bytes.length === 65) {
|
||||||
const r = (0, index_js_2.hexlify)(bytes.slice(0, 32));
|
const r = (0, index_js_2.hexlify)(bytes.slice(0, 32));
|
||||||
const s = bytes.slice(32, 64);
|
const s = bytes.slice(32, 64);
|
||||||
if (s[0] & 0x80) {
|
assertError((s[0] & 0x80) === 0, "non-canonical s");
|
||||||
throwError("non-canonical s");
|
|
||||||
}
|
|
||||||
const v = Signature.getNormalizedV(bytes[64]);
|
const v = Signature.getNormalizedV(bytes[64]);
|
||||||
return new Signature(_guard, r, (0, index_js_2.hexlify)(s), v);
|
return new Signature(_guard, r, (0, index_js_2.hexlify)(s), v);
|
||||||
}
|
}
|
||||||
return throwError("invlaid raw signature length");
|
assertError(false, "invlaid raw signature length");
|
||||||
}
|
}
|
||||||
if (sig instanceof Signature) {
|
if (sig instanceof Signature) {
|
||||||
return sig.clone();
|
return sig.clone();
|
||||||
}
|
}
|
||||||
// Get r
|
// Get r
|
||||||
const r = sig.r;
|
const r = sig.r;
|
||||||
if (r == null) {
|
assertError(r != null, "missing r");
|
||||||
throwError("missing r");
|
assertError((0, index_js_2.isHexString)(r, 32), "invalid r");
|
||||||
}
|
|
||||||
if (!(0, index_js_2.isHexString)(r, 32)) {
|
|
||||||
throwError("invalid r");
|
|
||||||
}
|
|
||||||
// Get s; by any means necessary (we check consistency below)
|
// Get s; by any means necessary (we check consistency below)
|
||||||
const s = (function (s, yParityAndS) {
|
const s = (function (s, yParityAndS) {
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
if (!(0, index_js_2.isHexString)(s, 32)) {
|
assertError((0, index_js_2.isHexString)(s, 32), "invalid s");
|
||||||
throwError("invalid s");
|
|
||||||
}
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
if (yParityAndS != null) {
|
if (yParityAndS != null) {
|
||||||
if (!(0, index_js_2.isHexString)(yParityAndS, 32)) {
|
assertError((0, index_js_2.isHexString)(yParityAndS, 32), "invalid yParityAndS");
|
||||||
throwError("invalid yParityAndS");
|
|
||||||
}
|
|
||||||
const bytes = (0, index_js_2.getBytes)(yParityAndS);
|
const bytes = (0, index_js_2.getBytes)(yParityAndS);
|
||||||
bytes[0] &= 0x7f;
|
bytes[0] &= 0x7f;
|
||||||
return (0, index_js_2.hexlify)(bytes);
|
return (0, index_js_2.hexlify)(bytes);
|
||||||
}
|
}
|
||||||
return throwError("missing s");
|
assertError(false, "missing s");
|
||||||
})(sig.s, sig.yParityAndS);
|
})(sig.s, sig.yParityAndS);
|
||||||
if ((0, index_js_2.getBytes)(s)[0] & 0x80) {
|
assertError(((0, index_js_2.getBytes)(s)[0] & 0x80) == 0, "non-canonical s");
|
||||||
throwError("non-canonical s");
|
|
||||||
}
|
|
||||||
// Get v; by any means necessary (we check consistency below)
|
// Get v; by any means necessary (we check consistency below)
|
||||||
const { networkV, v } = (function (_v, yParityAndS, yParity) {
|
const { networkV, v } = (function (_v, yParityAndS, yParity) {
|
||||||
if (_v != null) {
|
if (_v != null) {
|
||||||
@ -193,9 +169,7 @@ class Signature {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (yParityAndS != null) {
|
if (yParityAndS != null) {
|
||||||
if (!(0, index_js_2.isHexString)(yParityAndS, 32)) {
|
assertError((0, index_js_2.isHexString)(yParityAndS, 32), "invalid yParityAndS");
|
||||||
throwError("invalid yParityAndS");
|
|
||||||
}
|
|
||||||
return { v: (((0, index_js_2.getBytes)(yParityAndS)[0] & 0x80) ? 28 : 27) };
|
return { v: (((0, index_js_2.getBytes)(yParityAndS)[0] & 0x80) ? 28 : 27) };
|
||||||
}
|
}
|
||||||
if (yParity != null) {
|
if (yParity != null) {
|
||||||
@ -203,21 +177,17 @@ class Signature {
|
|||||||
case 0: return { v: 27 };
|
case 0: return { v: 27 };
|
||||||
case 1: return { v: 28 };
|
case 1: return { v: 28 };
|
||||||
}
|
}
|
||||||
return throwError("invalid yParity");
|
assertError(false, "invalid yParity");
|
||||||
}
|
}
|
||||||
return throwError("missing v");
|
assertError(false, "missing v");
|
||||||
})(sig.v, sig.yParityAndS, sig.yParity);
|
})(sig.v, sig.yParityAndS, sig.yParity);
|
||||||
const result = new Signature(_guard, r, s, v);
|
const result = new Signature(_guard, r, s, v);
|
||||||
if (networkV) {
|
if (networkV) {
|
||||||
(0, index_js_2.setStore)(result.#props, "networkV", networkV);
|
(0, index_js_2.setStore)(result.#props, "networkV", networkV);
|
||||||
}
|
}
|
||||||
// If multiple of v, yParity, yParityAndS we given, check they match
|
// If multiple of v, yParity, yParityAndS we given, check they match
|
||||||
if ("yParity" in sig && sig.yParity !== result.yParity) {
|
assertError(!("yParity" in sig && sig.yParity !== result.yParity), "yParity mismatch");
|
||||||
throwError("yParity mismatch");
|
assertError(!("yParityAndS" in sig && sig.yParityAndS !== result.yParityAndS), "yParityAndS mismatch");
|
||||||
}
|
|
||||||
else if ("yParityAndS" in sig && sig.yParityAndS !== result.yParityAndS) {
|
|
||||||
throwError("yParityAndS mismatch");
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -87,7 +87,7 @@ class SigningKey {
|
|||||||
if (pubKey != null) {
|
if (pubKey != null) {
|
||||||
return (0, index_js_1.hexlify)(pubKey);
|
return (0, index_js_1.hexlify)(pubKey);
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("invalid signautre for digest", "signature", signature);
|
(0, index_js_1.assertArgument)(false, "invalid signautre for digest", "signature", signature);
|
||||||
}
|
}
|
||||||
static _addPoints(p0, p1, compressed) {
|
static _addPoints(p0, p1, compressed) {
|
||||||
const pub0 = secp256k1.Point.fromHex(SigningKey.computePublicKey(p0).substring(2));
|
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,gDAG2B;AAE3B,uCAAwC;AACxC,iDAA2C;AAO3C,yFAAyF;AAEzF,4BAA4B;AAC5B,SAAS,CAAC,KAAK,CAAC,cAAc,GAAG,UAAS,GAAe,EAAE,GAAG,QAA2B;IACrF,OAAO,IAAA,mBAAQ,EAAC,IAAA,qBAAW,EAAC,QAAQ,EAAE,GAAG,EAAE,IAAA,iBAAM,EAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC,CAAA;AAED,MAAa,UAAU;IACnB,WAAW,CAAS;IAEpB,YAAY,UAAqB;QAC7B;;;;;UAKE;QACF,IAAI,CAAC,WAAW,GAAG,IAAA,kBAAO,EAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,UAAU,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACrD,IAAI,SAAS,KAAa,OAAO,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACjF,IAAI,mBAAmB,KAAa,OAAO,UAAU,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAEjG,IAAI,CAAC,MAAiB;QAClB,IAAA,yBAAc,EAAC,IAAA,qBAAU,EAAC,MAAM,CAAC,KAAK,EAAE,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAErF,MAAM,CAAE,MAAM,EAAE,KAAK,CAAE,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAA,uBAAY,EAAC,MAAM,CAAC,EAAE,IAAA,uBAAY,EAAC,IAAI,CAAC,WAAW,CAAC,EAAE;YA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,yBAAc,EAAC,KAAK,EAAE,8BAA8B,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IAClF,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;AA1ED,gCA0EC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCE"}
|
@ -3,9 +3,9 @@
|
|||||||
//
|
//
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
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.encodeBytes32String = exports.decodeBytes32String = exports.version = 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.encodeBytes32String = exports.decodeBytes32String = exports.version = void 0;
|
||||||
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.Network = exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.BrowserProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.AbstractProvider = 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.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.Network = exports.WebSocketProvider = exports.SocketProvider = exports.IpcSocketProvider = exports.InfuraProvider = exports.EtherscanProvider = exports.CloudflareProvider = exports.AnkrProvider = exports.AlchemyProvider = exports.BrowserProvider = exports.JsonRpcSigner = exports.JsonRpcProvider = exports.JsonRpcApiProvider = exports.FallbackProvider = exports.AbstractProvider = exports.TransactionResponse = exports.TransactionReceipt = exports.Log = exports.FeeData = exports.Block = 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.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 = 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 = void 0;
|
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.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 = exports.getBigInt = exports.parseFixed = exports.formatFixed = exports.FixedNumber = exports.FixedFormat = exports.FetchCancelSignal = exports.FetchResponse = exports.FetchRequest = exports.getIpfsGatewayFunc = exports.isError = exports.isCallException = exports.makeError = exports.assertPrivate = exports.assertNormalize = exports.assertArgumentCount = exports.assertArgument = exports.assert = exports.zeroPadValue = exports.zeroPadBytes = void 0;
|
||||||
exports.WordlistOwlA = exports.WordlistOwl = exports.wordlists = exports.LangEn = void 0;
|
exports.WordlistOwlA = exports.WordlistOwl = exports.wordlists = exports.LangEn = exports.langEn = exports.Wordlist = exports.Wallet = void 0;
|
||||||
var _version_js_1 = require("./_version.js");
|
var _version_js_1 = require("./_version.js");
|
||||||
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version_js_1.version; } });
|
Object.defineProperty(exports, "version", { enumerable: true, get: function () { return _version_js_1.version; } });
|
||||||
var index_js_1 = require("./abi/index.js");
|
var index_js_1 = require("./abi/index.js");
|
||||||
@ -77,6 +77,11 @@ Object.defineProperty(exports, "solidityPackedKeccak256", { enumerable: true, ge
|
|||||||
Object.defineProperty(exports, "solidityPackedSha256", { enumerable: true, get: function () { return index_js_6.solidityPackedSha256; } });
|
Object.defineProperty(exports, "solidityPackedSha256", { enumerable: true, get: function () { return index_js_6.solidityPackedSha256; } });
|
||||||
Object.defineProperty(exports, "TypedDataEncoder", { enumerable: true, get: function () { return index_js_6.TypedDataEncoder; } });
|
Object.defineProperty(exports, "TypedDataEncoder", { enumerable: true, get: function () { return index_js_6.TypedDataEncoder; } });
|
||||||
var index_js_7 = require("./providers/index.js");
|
var index_js_7 = require("./providers/index.js");
|
||||||
|
Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return index_js_7.Block; } });
|
||||||
|
Object.defineProperty(exports, "FeeData", { enumerable: true, get: function () { return index_js_7.FeeData; } });
|
||||||
|
Object.defineProperty(exports, "Log", { enumerable: true, get: function () { return index_js_7.Log; } });
|
||||||
|
Object.defineProperty(exports, "TransactionReceipt", { enumerable: true, get: function () { return index_js_7.TransactionReceipt; } });
|
||||||
|
Object.defineProperty(exports, "TransactionResponse", { enumerable: true, get: function () { return index_js_7.TransactionResponse; } });
|
||||||
Object.defineProperty(exports, "AbstractProvider", { enumerable: true, get: function () { return index_js_7.AbstractProvider; } });
|
Object.defineProperty(exports, "AbstractProvider", { enumerable: true, get: function () { return index_js_7.AbstractProvider; } });
|
||||||
Object.defineProperty(exports, "FallbackProvider", { enumerable: true, get: function () { return index_js_7.FallbackProvider; } });
|
Object.defineProperty(exports, "FallbackProvider", { enumerable: true, get: function () { return index_js_7.FallbackProvider; } });
|
||||||
Object.defineProperty(exports, "JsonRpcApiProvider", { enumerable: true, get: function () { return index_js_7.JsonRpcApiProvider; } });
|
Object.defineProperty(exports, "JsonRpcApiProvider", { enumerable: true, get: function () { return index_js_7.JsonRpcApiProvider; } });
|
||||||
@ -114,13 +119,12 @@ Object.defineProperty(exports, "isBytesLike", { enumerable: true, get: function
|
|||||||
Object.defineProperty(exports, "stripZerosLeft", { enumerable: true, get: function () { return index_js_9.stripZerosLeft; } });
|
Object.defineProperty(exports, "stripZerosLeft", { enumerable: true, get: function () { return index_js_9.stripZerosLeft; } });
|
||||||
Object.defineProperty(exports, "zeroPadBytes", { enumerable: true, get: function () { return index_js_9.zeroPadBytes; } });
|
Object.defineProperty(exports, "zeroPadBytes", { enumerable: true, get: function () { return index_js_9.zeroPadBytes; } });
|
||||||
Object.defineProperty(exports, "zeroPadValue", { enumerable: true, get: function () { return index_js_9.zeroPadValue; } });
|
Object.defineProperty(exports, "zeroPadValue", { enumerable: true, get: function () { return index_js_9.zeroPadValue; } });
|
||||||
|
Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return index_js_9.assert; } });
|
||||||
Object.defineProperty(exports, "assertArgument", { enumerable: true, get: function () { return index_js_9.assertArgument; } });
|
Object.defineProperty(exports, "assertArgument", { enumerable: true, get: function () { return index_js_9.assertArgument; } });
|
||||||
Object.defineProperty(exports, "assertArgumentCount", { enumerable: true, get: function () { return index_js_9.assertArgumentCount; } });
|
Object.defineProperty(exports, "assertArgumentCount", { enumerable: true, get: function () { return index_js_9.assertArgumentCount; } });
|
||||||
Object.defineProperty(exports, "assertNormalize", { enumerable: true, get: function () { return index_js_9.assertNormalize; } });
|
Object.defineProperty(exports, "assertNormalize", { enumerable: true, get: function () { return index_js_9.assertNormalize; } });
|
||||||
Object.defineProperty(exports, "assertPrivate", { enumerable: true, get: function () { return index_js_9.assertPrivate; } });
|
Object.defineProperty(exports, "assertPrivate", { enumerable: true, get: function () { return index_js_9.assertPrivate; } });
|
||||||
Object.defineProperty(exports, "makeError", { enumerable: true, get: function () { return index_js_9.makeError; } });
|
Object.defineProperty(exports, "makeError", { enumerable: true, get: function () { return index_js_9.makeError; } });
|
||||||
Object.defineProperty(exports, "throwArgumentError", { enumerable: true, get: function () { return index_js_9.throwArgumentError; } });
|
|
||||||
Object.defineProperty(exports, "throwError", { enumerable: true, get: function () { return index_js_9.throwError; } });
|
|
||||||
Object.defineProperty(exports, "isCallException", { enumerable: true, get: function () { return index_js_9.isCallException; } });
|
Object.defineProperty(exports, "isCallException", { enumerable: true, get: function () { return index_js_9.isCallException; } });
|
||||||
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return index_js_9.isError; } });
|
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return index_js_9.isError; } });
|
||||||
Object.defineProperty(exports, "getIpfsGatewayFunc", { enumerable: true, get: function () { return index_js_9.getIpfsGatewayFunc; } });
|
Object.defineProperty(exports, "getIpfsGatewayFunc", { enumerable: true, get: function () { return index_js_9.getIpfsGatewayFunc; } });
|
||||||
@ -145,7 +149,6 @@ Object.defineProperty(exports, "formatEther", { enumerable: true, get: function
|
|||||||
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return index_js_9.parseEther; } });
|
Object.defineProperty(exports, "parseEther", { enumerable: true, get: function () { return index_js_9.parseEther; } });
|
||||||
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return index_js_9.formatUnits; } });
|
Object.defineProperty(exports, "formatUnits", { enumerable: true, get: function () { return index_js_9.formatUnits; } });
|
||||||
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return index_js_9.parseUnits; } });
|
Object.defineProperty(exports, "parseUnits", { enumerable: true, get: function () { return index_js_9.parseUnits; } });
|
||||||
Object.defineProperty(exports, "_toEscapedUtf8String", { enumerable: true, get: function () { return index_js_9._toEscapedUtf8String; } });
|
|
||||||
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return index_js_9.toUtf8Bytes; } });
|
Object.defineProperty(exports, "toUtf8Bytes", { enumerable: true, get: function () { return index_js_9.toUtf8Bytes; } });
|
||||||
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return index_js_9.toUtf8CodePoints; } });
|
Object.defineProperty(exports, "toUtf8CodePoints", { enumerable: true, get: function () { return index_js_9.toUtf8CodePoints; } });
|
||||||
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return index_js_9.toUtf8String; } });
|
Object.defineProperty(exports, "toUtf8String", { enumerable: true, get: function () { return index_js_9.toUtf8String; } });
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"ethers.js","sourceR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,OAAA"}
|
@ -52,9 +52,7 @@ function isValidName(name) {
|
|||||||
exports.isValidName = isValidName;
|
exports.isValidName = isValidName;
|
||||||
function namehash(name) {
|
function namehash(name) {
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (typeof (name) !== "string") {
|
(0, index_js_2.assertArgument)(typeof (name) === "string", "invalid ENS name; not a string", "name", name);
|
||||||
(0, index_js_2.throwArgumentError)("invalid ENS name; not a string", "name", name);
|
|
||||||
}
|
|
||||||
let result = Zeros;
|
let result = Zeros;
|
||||||
const comps = ensNameSplit(name);
|
const comps = ensNameSplit(name);
|
||||||
while (comps.length) {
|
while (comps.length) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"namehash.js","sourceRoot":"","sources":["../../src.ts/hash/namehash.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAC/C,gDAE2B;AAG3B,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,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAsB,EAAG,CAAC;IAErC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;KAAE;IAExC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,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jB,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAChB,CAAC;AAbD,8BAaC"}
|
@ -27,9 +27,7 @@ function _pack(type, value, isArray) {
|
|||||||
let match = type.match(regexNumber);
|
let match = type.match(regexNumber);
|
||||||
if (match) {
|
if (match) {
|
||||||
let size = parseInt(match[2] || "256");
|
let size = parseInt(match[2] || "256");
|
||||||
if ((match[2] && String(size) !== match[2]) || (size % 8 !== 0) || size === 0 || size > 256) {
|
(0, index_js_2.assertArgument)((!match[2] || match[2] === String(size)) && (size % 8 === 0) && size !== 0 && size <= 256, "invalid number type", "type", type);
|
||||||
return (0, index_js_2.throwArgumentError)("invalid number type", "type", type);
|
|
||||||
}
|
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
size = 256;
|
size = 256;
|
||||||
}
|
}
|
||||||
@ -39,12 +37,8 @@ function _pack(type, value, isArray) {
|
|||||||
match = type.match(regexBytes);
|
match = type.match(regexBytes);
|
||||||
if (match) {
|
if (match) {
|
||||||
const size = parseInt(match[1]);
|
const size = parseInt(match[1]);
|
||||||
if (String(size) !== match[1] || size === 0 || size > 32) {
|
(0, index_js_2.assertArgument)(String(size) === match[1] && size !== 0 && size <= 32, "invalid bytes type", "type", type);
|
||||||
return (0, index_js_2.throwArgumentError)("invalid bytes type", "type", type);
|
(0, index_js_2.assertArgument)((0, index_js_2.dataLength)(value) === size, `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) {
|
if (isArray) {
|
||||||
return (0, index_js_2.getBytes)((0, index_js_2.zeroPadBytes)(value, 32));
|
return (0, index_js_2.getBytes)((0, index_js_2.zeroPadBytes)(value, 32));
|
||||||
}
|
}
|
||||||
@ -54,22 +48,18 @@ function _pack(type, value, isArray) {
|
|||||||
if (match && Array.isArray(value)) {
|
if (match && Array.isArray(value)) {
|
||||||
const baseType = match[1];
|
const baseType = match[1];
|
||||||
const count = parseInt(match[2] || String(value.length));
|
const count = parseInt(match[2] || String(value.length));
|
||||||
if (count != value.length) {
|
(0, index_js_2.assertArgument)(count === value.length, `invalid array length for ${type}`, "value", value);
|
||||||
(0, index_js_2.throwArgumentError)(`invalid array length for ${type}`, "value", value);
|
|
||||||
}
|
|
||||||
const result = [];
|
const result = [];
|
||||||
value.forEach(function (value) {
|
value.forEach(function (value) {
|
||||||
result.push(_pack(baseType, value, true));
|
result.push(_pack(baseType, value, true));
|
||||||
});
|
});
|
||||||
return (0, index_js_2.getBytes)((0, index_js_2.concat)(result));
|
return (0, index_js_2.getBytes)((0, index_js_2.concat)(result));
|
||||||
}
|
}
|
||||||
return (0, index_js_2.throwArgumentError)("invalid type", "type", type);
|
(0, index_js_2.assertArgument)(false, "invalid type", "type", type);
|
||||||
}
|
}
|
||||||
// @TODO: Array Enum
|
// @TODO: Array Enum
|
||||||
function solidityPacked(types, values) {
|
function solidityPacked(types, values) {
|
||||||
if (types.length != values.length) {
|
(0, index_js_2.assertArgument)(types.length === values.length, "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 = [];
|
const tight = [];
|
||||||
types.forEach(function (type, index) {
|
types.forEach(function (type, index) {
|
||||||
tight.push(_pack(type, values[index]));
|
tight.push(_pack(type, values[index]));
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"solidity.js","sourceRoot":"","sources":["../../src.ts/hash/solidity.ts"],"names":[],"mappings":";;;AAAA,iDAE4B;AAC5B,gDAG2B;AAG3B,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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CAAC,KAA4B,EAAE,MAA0B;IAC5F,OAAO,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"}
|
@ -36,9 +36,7 @@ const domainFieldNames = [
|
|||||||
];
|
];
|
||||||
function checkString(key) {
|
function checkString(key) {
|
||||||
return function (value) {
|
return function (value) {
|
||||||
if (typeof (value) !== "string") {
|
(0, index_js_3.assertArgument)(typeof (value) === "string", `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;
|
return value;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -53,13 +51,11 @@ const domainChecks = {
|
|||||||
return (0, index_js_1.getAddress)(value).toLowerCase();
|
return (0, index_js_1.getAddress)(value).toLowerCase();
|
||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
return (0, index_js_3.throwArgumentError)(`invalid domain value "verifyingContract"`, "domain.verifyingContract", value);
|
(0, index_js_3.assertArgument)(false, `invalid domain value "verifyingContract"`, "domain.verifyingContract", value);
|
||||||
},
|
},
|
||||||
salt: function (value) {
|
salt: function (value) {
|
||||||
const bytes = (0, index_js_3.getBytes)(value, "domain.salt");
|
const bytes = (0, index_js_3.getBytes)(value, "domain.salt");
|
||||||
if (bytes.length !== 32) {
|
(0, index_js_3.assertArgument)(bytes.length === 32, `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);
|
return (0, index_js_3.hexlify)(bytes);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -70,16 +66,12 @@ function getBaseEncoder(type) {
|
|||||||
if (match) {
|
if (match) {
|
||||||
const signed = (match[1] === "");
|
const signed = (match[1] === "");
|
||||||
const width = parseInt(match[2] || "256");
|
const width = parseInt(match[2] || "256");
|
||||||
if (width % 8 !== 0 || width > 256 || (match[2] && match[2] !== String(width))) {
|
(0, index_js_3.assertArgument)(width % 8 === 0 && width !== 0 && width <= 256 && (match[2] == null || match[2] === String(width)), "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 boundsUpper = (0, index_js_3.mask)(BN_MAX_UINT256, signed ? (width - 1) : width);
|
||||||
const boundsLower = signed ? ((boundsUpper + BN_1) * BN__1) : BN_0;
|
const boundsLower = signed ? ((boundsUpper + BN_1) * BN__1) : BN_0;
|
||||||
return function (_value) {
|
return function (_value) {
|
||||||
const value = (0, index_js_3.getBigInt)(_value, "value");
|
const value = (0, index_js_3.getBigInt)(_value, "value");
|
||||||
if (value < boundsLower || value > boundsUpper) {
|
(0, index_js_3.assertArgument)(value >= boundsLower && value <= boundsUpper, `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);
|
return (0, index_js_3.toHex)((0, index_js_3.toTwos)(value, 256), 32);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -89,14 +81,10 @@ function getBaseEncoder(type) {
|
|||||||
const match = type.match(/^bytes(\d+)$/);
|
const match = type.match(/^bytes(\d+)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const width = parseInt(match[1]);
|
const width = parseInt(match[1]);
|
||||||
if (width === 0 || width > 32 || match[1] !== String(width)) {
|
(0, index_js_3.assertArgument)(width !== 0 && width <= 32 && match[1] === String(width), "invalid bytes width", "type", type);
|
||||||
(0, index_js_3.throwArgumentError)("invalid bytes width", "type", type);
|
|
||||||
}
|
|
||||||
return function (value) {
|
return function (value) {
|
||||||
const bytes = (0, index_js_3.getBytes)(value);
|
const bytes = (0, index_js_3.getBytes)(value);
|
||||||
if (bytes.length !== width) {
|
(0, index_js_3.assertArgument)(bytes.length === width, `invalid length for ${type}`, "value", value);
|
||||||
(0, index_js_3.throwArgumentError)(`invalid length for ${type}`, "value", value);
|
|
||||||
}
|
|
||||||
return hexPadRight(value);
|
return hexPadRight(value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -147,23 +135,17 @@ class TypedDataEncoder {
|
|||||||
const uniqueNames = new Set();
|
const uniqueNames = new Set();
|
||||||
for (const field of types[name]) {
|
for (const field of types[name]) {
|
||||||
// Check each field has a unique name
|
// Check each field has a unique name
|
||||||
if (uniqueNames.has(field.name)) {
|
(0, index_js_3.assertArgument)(!uniqueNames.has(field.name), `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);
|
uniqueNames.add(field.name);
|
||||||
// Get the base type (drop any array specifiers)
|
// Get the base type (drop any array specifiers)
|
||||||
const baseType = (field.type.match(/^([^\x5b]*)(\x5b|$)/))[1] || null;
|
const baseType = (field.type.match(/^([^\x5b]*)(\x5b|$)/))[1] || null;
|
||||||
if (baseType === name) {
|
(0, index_js_3.assertArgument)(baseType !== name, `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?
|
// Is this a base encoding type?
|
||||||
const encoder = getBaseEncoder(baseType);
|
const encoder = getBaseEncoder(baseType);
|
||||||
if (encoder) {
|
if (encoder) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!parents.has(baseType)) {
|
(0, index_js_3.assertArgument)(parents.has(baseType), `unknown type ${JSON.stringify(baseType)}`, "types", types);
|
||||||
(0, index_js_3.throwArgumentError)(`unknown type ${JSON.stringify(baseType)}`, "types", types);
|
|
||||||
}
|
|
||||||
// Add linkage
|
// Add linkage
|
||||||
parents.get(baseType).push(name);
|
parents.get(baseType).push(name);
|
||||||
links.get(name).add(baseType);
|
links.get(name).add(baseType);
|
||||||
@ -171,18 +153,12 @@ class TypedDataEncoder {
|
|||||||
}
|
}
|
||||||
// Deduce the primary type
|
// Deduce the primary type
|
||||||
const primaryTypes = Array.from(parents.keys()).filter((n) => (parents.get(n).length === 0));
|
const primaryTypes = Array.from(parents.keys()).filter((n) => (parents.get(n).length === 0));
|
||||||
if (primaryTypes.length === 0) {
|
(0, index_js_3.assertArgument)(primaryTypes.length !== 0, "missing primary type", "types", types);
|
||||||
(0, index_js_3.throwArgumentError)("missing primary type", "types", types);
|
(0, index_js_3.assertArgument)(primaryTypes.length === 1, `ambiguous primary types or unused types: ${primaryTypes.map((t) => (JSON.stringify(t))).join(", ")}`, "types", types);
|
||||||
}
|
|
||||||
else if (primaryTypes.length > 1) {
|
|
||||||
(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] });
|
(0, index_js_3.defineProperties)(this, { primaryType: primaryTypes[0] });
|
||||||
// Check for circular type references
|
// Check for circular type references
|
||||||
function checkCircular(type, found) {
|
function checkCircular(type, found) {
|
||||||
if (found.has(type)) {
|
(0, index_js_3.assertArgument)(!found.has(type), `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);
|
found.add(type);
|
||||||
for (const child of links.get(type)) {
|
for (const child of links.get(type)) {
|
||||||
if (!parents.has(child)) {
|
if (!parents.has(child)) {
|
||||||
@ -226,11 +202,8 @@ class TypedDataEncoder {
|
|||||||
if (match) {
|
if (match) {
|
||||||
const subtype = match[1];
|
const subtype = match[1];
|
||||||
const subEncoder = this.getEncoder(subtype);
|
const subEncoder = this.getEncoder(subtype);
|
||||||
const length = parseInt(match[3]);
|
|
||||||
return (value) => {
|
return (value) => {
|
||||||
if (length >= 0 && value.length !== length) {
|
(0, index_js_3.assertArgument)(!match[3] || parseInt(match[3]) === value.length, `array length mismatch; expected length ${parseInt(match[3])}`, "value", value);
|
||||||
(0, index_js_3.throwArgumentError)("array length mismatch; expected length ${ arrayLength }", "value", value);
|
|
||||||
}
|
|
||||||
let result = value.map(subEncoder);
|
let result = value.map(subEncoder);
|
||||||
if (this.#fullTypes.has(subtype)) {
|
if (this.#fullTypes.has(subtype)) {
|
||||||
result = result.map(index_js_2.keccak256);
|
result = result.map(index_js_2.keccak256);
|
||||||
@ -254,13 +227,11 @@ class TypedDataEncoder {
|
|||||||
return (0, index_js_3.concat)(values);
|
return (0, index_js_3.concat)(values);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)(`unknown type: ${type}`, "type", type);
|
(0, index_js_3.assertArgument)(false, `unknown type: ${type}`, "type", type);
|
||||||
}
|
}
|
||||||
encodeType(name) {
|
encodeType(name) {
|
||||||
const result = this.#fullTypes.get(name);
|
const result = this.#fullTypes.get(name);
|
||||||
if (!result) {
|
(0, index_js_3.assertArgument)(result, `unknown type: ${JSON.stringify(name)}`, "name", name);
|
||||||
return (0, index_js_3.throwArgumentError)(`unknown type: ${JSON.stringify(name)}`, "name", name);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
encodeData(type, value) {
|
encodeData(type, value) {
|
||||||
@ -286,12 +257,8 @@ class TypedDataEncoder {
|
|||||||
// Array
|
// Array
|
||||||
const match = type.match(/^(.*)(\x5b(\d*)\x5d)$/);
|
const match = type.match(/^(.*)(\x5b(\d*)\x5d)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
const subtype = match[1];
|
(0, index_js_3.assertArgument)(!match[3] || parseInt(match[3]) === value.length, `array length mismatch; expected length ${parseInt(match[3])}`, "value", value);
|
||||||
const length = parseInt(match[3]);
|
return value.map((v) => this._visit(match[1], v, callback));
|
||||||
if (length >= 0 && value.length !== length) {
|
|
||||||
(0, index_js_3.throwArgumentError)("array length mismatch; expected length ${ arrayLength }", "value", value);
|
|
||||||
}
|
|
||||||
return value.map((v) => this._visit(subtype, v, callback));
|
|
||||||
}
|
}
|
||||||
// Struct
|
// Struct
|
||||||
const fields = this.types[type];
|
const fields = this.types[type];
|
||||||
@ -301,7 +268,7 @@ class TypedDataEncoder {
|
|||||||
return accum;
|
return accum;
|
||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)(`unknown type: ${type}`, "type", type);
|
(0, index_js_3.assertArgument)(false, `unknown type: ${type}`, "type", type);
|
||||||
}
|
}
|
||||||
visit(value, callback) {
|
visit(value, callback) {
|
||||||
return this._visit(this.primaryType, value, callback);
|
return this._visit(this.primaryType, value, callback);
|
||||||
@ -319,9 +286,7 @@ class TypedDataEncoder {
|
|||||||
const domainFields = [];
|
const domainFields = [];
|
||||||
for (const name in domain) {
|
for (const name in domain) {
|
||||||
const type = domainFieldTypes[name];
|
const type = domainFieldTypes[name];
|
||||||
if (!type) {
|
(0, index_js_3.assertArgument)(type, `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 });
|
domainFields.push({ name, type });
|
||||||
}
|
}
|
||||||
domainFields.sort((a, b) => {
|
domainFields.sort((a, b) => {
|
||||||
@ -391,12 +356,8 @@ class TypedDataEncoder {
|
|||||||
});
|
});
|
||||||
const encoder = TypedDataEncoder.from(types);
|
const encoder = TypedDataEncoder.from(types);
|
||||||
const typesWithDomain = Object.assign({}, types);
|
const typesWithDomain = Object.assign({}, types);
|
||||||
if (typesWithDomain.EIP712Domain) {
|
(0, index_js_3.assertArgument)(typesWithDomain.EIP712Domain == null, "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;
|
typesWithDomain.EIP712Domain = domainTypes;
|
||||||
}
|
|
||||||
// Validate the data structures and types
|
// Validate the data structures and types
|
||||||
encoder.encode(value);
|
encoder.encode(value);
|
||||||
return {
|
return {
|
||||||
@ -418,12 +379,10 @@ class TypedDataEncoder {
|
|||||||
case "bool":
|
case "bool":
|
||||||
return !!value;
|
return !!value;
|
||||||
case "string":
|
case "string":
|
||||||
if (typeof (value) !== "string") {
|
(0, index_js_3.assertArgument)(typeof (value) === "string", "invalid string", "value", value);
|
||||||
(0, index_js_3.throwArgumentError)(`invalid string`, "value", value);
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("unsupported type", "type", type);
|
(0, index_js_3.assertArgument)(false, "unsupported type", "type", type);
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -24,6 +24,9 @@ function isPromise(value) {
|
|||||||
}
|
}
|
||||||
function getTag(prefix, value) {
|
function getTag(prefix, value) {
|
||||||
return prefix + ":" + JSON.stringify(value, (k, v) => {
|
return prefix + ":" + JSON.stringify(value, (k, v) => {
|
||||||
|
if (v == null) {
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
if (typeof (v) === "bigint") {
|
if (typeof (v) === "bigint") {
|
||||||
return `bigint:${v.toString()}`;
|
return `bigint:${v.toString()}`;
|
||||||
}
|
}
|
||||||
@ -125,7 +128,7 @@ async function getSubscription(_event, provider) {
|
|||||||
}
|
}
|
||||||
return { filter, tag: getTag("event", filter), type: "event" };
|
return { filter, tag: getTag("event", filter), type: "event" };
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("unknown ProviderEvent", "event", _event);
|
(0, index_js_3.assertArgument)(false, "unknown ProviderEvent", "event", _event);
|
||||||
}
|
}
|
||||||
function getTime() { return (new Date()).getTime(); }
|
function getTime() { return (new Date()).getTime(); }
|
||||||
class AbstractProvider {
|
class AbstractProvider {
|
||||||
@ -175,7 +178,7 @@ class AbstractProvider {
|
|||||||
if (this.#plugins.get(plugin.name)) {
|
if (this.#plugins.get(plugin.name)) {
|
||||||
throw new Error(`cannot replace existing plugin: ${plugin.name} `);
|
throw new Error(`cannot replace existing plugin: ${plugin.name} `);
|
||||||
}
|
}
|
||||||
this.#plugins.set(plugin.name, plugin.validate(this));
|
this.#plugins.set(plugin.name, plugin.connect(this));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
getPlugin(name) {
|
getPlugin(name) {
|
||||||
@ -220,29 +223,27 @@ class AbstractProvider {
|
|||||||
if (url.indexOf("{data}") === -1) {
|
if (url.indexOf("{data}") === -1) {
|
||||||
request.body = { data, sender };
|
request.body = { data, sender };
|
||||||
}
|
}
|
||||||
|
this.emit("debug", { action: "sendCcipReadFetchRequest", request, index: i, urls });
|
||||||
let errorMessage = "unknown error";
|
let errorMessage = "unknown error";
|
||||||
const resp = await request.send();
|
const resp = await request.send();
|
||||||
try {
|
try {
|
||||||
const result = resp.bodyJson;
|
const result = resp.bodyJson;
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
|
this.emit("debug", { action: "receiveCcipReadFetchResult", request, result });
|
||||||
return result.data;
|
return result.data;
|
||||||
}
|
}
|
||||||
if (result.message) {
|
if (result.message) {
|
||||||
errorMessage = result.message;
|
errorMessage = result.message;
|
||||||
}
|
}
|
||||||
|
this.emit("debug", { action: "receiveCcipReadFetchError", request, result });
|
||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
// 4xx indicates the result is not present; stop
|
// 4xx indicates the result is not present; stop
|
||||||
if (resp.statusCode >= 400 && resp.statusCode < 500) {
|
(0, index_js_3.assert)(resp.statusCode < 400 || resp.statusCode >= 500, `response not found during CCIP fetch: ${errorMessage}`, "OFFCHAIN_FAULT", { reason: "404_MISSING_RESOURCE", transaction: tx, info: { url, errorMessage } });
|
||||||
return (0, index_js_3.throwError)(`response not found during CCIP fetch: ${errorMessage}`, "OFFCHAIN_FAULT", {
|
|
||||||
reason: "404_MISSING_RESOURCE",
|
|
||||||
transaction: tx, info: { url, errorMessage }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// 5xx indicates server issue; try the next url
|
// 5xx indicates server issue; try the next url
|
||||||
errorMessages.push(errorMessage);
|
errorMessages.push(errorMessage);
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwError)(`error encountered during CCIP fetch: ${errorMessages.map((m) => JSON.stringify(m)).join(", ")}`, "OFFCHAIN_FAULT", {
|
(0, index_js_3.assert)(false, `error encountered during CCIP fetch: ${errorMessages.map((m) => JSON.stringify(m)).join(", ")}`, "OFFCHAIN_FAULT", {
|
||||||
reason: "500_SERVER_ERROR",
|
reason: "500_SERVER_ERROR",
|
||||||
transaction: tx, info: { urls, errorMessages }
|
transaction: tx, info: { urls, errorMessages }
|
||||||
});
|
});
|
||||||
@ -263,14 +264,14 @@ class AbstractProvider {
|
|||||||
return new provider_js_1.TransactionResponse(tx, this);
|
return new provider_js_1.TransactionResponse(tx, this);
|
||||||
}
|
}
|
||||||
_detectNetwork() {
|
_detectNetwork() {
|
||||||
return (0, index_js_3.throwError)("sub-classes must implement this", "UNSUPPORTED_OPERATION", {
|
(0, index_js_3.assert)(false, "sub-classes must implement this", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "_detectNetwork"
|
operation: "_detectNetwork"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Sub-classes should override this and handle PerformActionRequest requests, calling
|
// Sub-classes should override this and handle PerformActionRequest requests, calling
|
||||||
// the super for any unhandled actions.
|
// the super for any unhandled actions.
|
||||||
async _perform(req) {
|
async _perform(req) {
|
||||||
return (0, index_js_3.throwError)(`unsupported method: ${req.method}`, "UNSUPPORTED_OPERATION", {
|
(0, index_js_3.assert)(false, `unsupported method: ${req.method}`, "UNSUPPORTED_OPERATION", {
|
||||||
operation: req.method,
|
operation: req.method,
|
||||||
info: req
|
info: req
|
||||||
});
|
});
|
||||||
@ -300,7 +301,7 @@ class AbstractProvider {
|
|||||||
return blockTag;
|
return blockTag;
|
||||||
}
|
}
|
||||||
if ((0, index_js_3.isHexString)(blockTag)) {
|
if ((0, index_js_3.isHexString)(blockTag)) {
|
||||||
if ((0, index_js_3.dataLength)(blockTag) === 32) {
|
if ((0, index_js_3.isHexString)(blockTag, 32)) {
|
||||||
return blockTag;
|
return blockTag;
|
||||||
}
|
}
|
||||||
return (0, index_js_3.toQuantity)(blockTag);
|
return (0, index_js_3.toQuantity)(blockTag);
|
||||||
@ -314,7 +315,7 @@ class AbstractProvider {
|
|||||||
}
|
}
|
||||||
return this.getBlockNumber().then((b) => (0, index_js_3.toQuantity)(b + blockTag));
|
return this.getBlockNumber().then((b) => (0, index_js_3.toQuantity)(b + blockTag));
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("invalid blockTag", "blockTag", blockTag);
|
(0, index_js_3.assertArgument)(false, "invalid blockTag", "blockTag", blockTag);
|
||||||
}
|
}
|
||||||
_getFilter(filter) {
|
_getFilter(filter) {
|
||||||
// Create a canonical representation of the topics
|
// Create a canonical representation of the topics
|
||||||
@ -456,7 +457,7 @@ class AbstractProvider {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Otherwise, we do not allow changes to the underlying network
|
// Otherwise, we do not allow changes to the underlying network
|
||||||
(0, index_js_3.throwError)(`network changed: ${expected.chainId} => ${actual.chainId} `, "NETWORK_ERROR", {
|
(0, index_js_3.assert)(false, `network changed: ${expected.chainId} => ${actual.chainId} `, "NETWORK_ERROR", {
|
||||||
event: "changed"
|
event: "changed"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -500,12 +501,10 @@ class AbstractProvider {
|
|||||||
}), "%response");
|
}), "%response");
|
||||||
}
|
}
|
||||||
async #call(tx, blockTag, attempt) {
|
async #call(tx, blockTag, attempt) {
|
||||||
if (attempt >= MAX_CCIP_REDIRECTS) {
|
(0, index_js_3.assert)(attempt < MAX_CCIP_REDIRECTS, "CCIP read exceeded maximum redirections", "OFFCHAIN_FAULT", {
|
||||||
(0, index_js_3.throwError)("CCIP read exceeded maximum redirections", "OFFCHAIN_FAULT", {
|
|
||||||
reason: "TOO_MANY_REDIRECTS",
|
reason: "TOO_MANY_REDIRECTS",
|
||||||
transaction: Object.assign({}, tx, { blockTag, enableCcipRead: true })
|
transaction: Object.assign({}, tx, { blockTag, enableCcipRead: true })
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// This came in as a PerformActionTransaction, so to/from are safe; we can cast
|
// This came in as a PerformActionTransaction, so to/from are safe; we can cast
|
||||||
const transaction = (0, provider_js_1.copyRequest)(tx);
|
const transaction = (0, provider_js_1.copyRequest)(tx);
|
||||||
try {
|
try {
|
||||||
@ -522,14 +521,12 @@ class AbstractProvider {
|
|||||||
ccipArgs = parseOffchainLookup((0, index_js_3.dataSlice)(error.data, 4));
|
ccipArgs = parseOffchainLookup((0, index_js_3.dataSlice)(error.data, 4));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return (0, index_js_3.throwError)(error.message, "OFFCHAIN_FAULT", {
|
(0, index_js_3.assert)(false, error.message, "OFFCHAIN_FAULT", {
|
||||||
reason: "BAD_DATA",
|
reason: "BAD_DATA", transaction, info: { data }
|
||||||
transaction, info: { data }
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Check the sender of the OffchainLookup matches the transaction
|
// Check the sender of the OffchainLookup matches the transaction
|
||||||
if (ccipArgs.sender.toLowerCase() !== txSender.toLowerCase()) {
|
(0, index_js_3.assert)(ccipArgs.sender.toLowerCase() === txSender.toLowerCase(), "CCIP Read sender mismatch", "CALL_EXCEPTION", {
|
||||||
return (0, index_js_3.throwError)("CCIP Read sender mismatch", "CALL_EXCEPTION", {
|
|
||||||
action: "call",
|
action: "call",
|
||||||
data,
|
data,
|
||||||
reason: "OffchainLookup",
|
reason: "OffchainLookup",
|
||||||
@ -541,20 +538,24 @@ class AbstractProvider {
|
|||||||
args: ccipArgs.errorArgs
|
args: ccipArgs.errorArgs
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
const ccipResult = await this.ccipReadFetch(transaction, ccipArgs.calldata, ccipArgs.urls);
|
const ccipResult = await this.ccipReadFetch(transaction, ccipArgs.calldata, ccipArgs.urls);
|
||||||
if (ccipResult == null) {
|
(0, index_js_3.assert)(ccipResult != null, "CCIP Read failed to fetch data", "OFFCHAIN_FAULT", {
|
||||||
return (0, index_js_3.throwError)("CCIP Read failed to fetch data", "OFFCHAIN_FAULT", {
|
reason: "FETCH_FAILED", transaction, info: { data: error.data, errorArgs: ccipArgs.errorArgs }
|
||||||
reason: "FETCH_FAILED",
|
|
||||||
transaction, info: { data: error.data, errorArgs: ccipArgs.errorArgs }
|
|
||||||
});
|
});
|
||||||
}
|
const tx = {
|
||||||
return this.#call({
|
|
||||||
to: txSender,
|
to: txSender,
|
||||||
data: (0, index_js_3.concat)([
|
data: (0, index_js_3.concat)([ccipArgs.selector, encodeBytes([ccipResult, ccipArgs.extraData])])
|
||||||
ccipArgs.selector, encodeBytes([ccipResult, ccipArgs.extraData])
|
};
|
||||||
]),
|
this.emit("debug", { action: "sendCcipReadCall", transaction: tx });
|
||||||
}, blockTag, attempt + 1);
|
try {
|
||||||
|
const result = await this.#call(tx, blockTag, attempt + 1);
|
||||||
|
this.emit("debug", { action: "receiveCcipReadCallResult", transaction: Object.assign({}, tx), result });
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
this.emit("debug", { action: "receiveCcipReadCallError", transaction: Object.assign({}, tx), error });
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -700,7 +701,7 @@ class AbstractProvider {
|
|||||||
}
|
}
|
||||||
// ENS
|
// ENS
|
||||||
_getProvider(chainId) {
|
_getProvider(chainId) {
|
||||||
return (0, index_js_3.throwError)("provider cannot connect to target network", "UNSUPPORTED_OPERATION", {
|
(0, index_js_3.assert)(false, "provider cannot connect to target network", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "_getProvider()"
|
operation: "_getProvider()"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -738,7 +739,8 @@ class AbstractProvider {
|
|||||||
throw new Error();
|
throw new Error();
|
||||||
//return "TODO";
|
//return "TODO";
|
||||||
}
|
}
|
||||||
async waitForTransaction(hash, confirms = 1, timeout) {
|
async waitForTransaction(hash, _confirms, timeout) {
|
||||||
|
const confirms = (_confirms != null) ? _confirms : 1;
|
||||||
if (confirms === 0) {
|
if (confirms === 0) {
|
||||||
return this.getTransactionReceipt(hash);
|
return this.getTransactionReceipt(hash);
|
||||||
}
|
}
|
||||||
@ -750,7 +752,7 @@ class AbstractProvider {
|
|||||||
if (receipt != null) {
|
if (receipt != null) {
|
||||||
if (blockNumber - receipt.blockNumber + 1 >= confirms) {
|
if (blockNumber - receipt.blockNumber + 1 >= confirms) {
|
||||||
resolve(receipt);
|
resolve(receipt);
|
||||||
this.off("block", listener);
|
//this.off("block", listener);
|
||||||
if (timer) {
|
if (timer) {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
timer = null;
|
timer = null;
|
||||||
@ -908,6 +910,12 @@ class AbstractProvider {
|
|||||||
catch (error) { }
|
catch (error) { }
|
||||||
return !once;
|
return !once;
|
||||||
});
|
});
|
||||||
|
if (sub.listeners.length === 0) {
|
||||||
|
if (sub.started) {
|
||||||
|
sub.subscriber.stop();
|
||||||
|
}
|
||||||
|
this.#subs.delete(sub.tag);
|
||||||
|
}
|
||||||
return (count > 0);
|
return (count > 0);
|
||||||
}
|
}
|
||||||
async listenerCount(event) {
|
async listenerCount(event) {
|
||||||
@ -1011,7 +1019,7 @@ class AbstractProvider {
|
|||||||
if (this.#pausedState == !!dropWhilePaused) {
|
if (this.#pausedState == !!dropWhilePaused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwError)("cannot change pause type; resume first", "UNSUPPORTED_OPERATION", {
|
(0, index_js_3.assert)(false, "cannot change pause type; resume first", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "pause"
|
operation: "pause"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -12,7 +12,7 @@ class AbstractSigner {
|
|||||||
if (this.provider) {
|
if (this.provider) {
|
||||||
return this.provider;
|
return this.provider;
|
||||||
}
|
}
|
||||||
return (0, index_js_2.throwError)("missing provider", "UNSUPPORTED_OPERATION", { operation });
|
(0, index_js_2.assert)(false, "missing provider", "UNSUPPORTED_OPERATION", { operation });
|
||||||
}
|
}
|
||||||
async getNonce(blockTag) {
|
async getNonce(blockTag) {
|
||||||
return this.#checkProvider("getTransactionCount").getTransactionCount(await this.getAddress(), blockTag);
|
return this.#checkProvider("getTransactionCount").getTransactionCount(await this.getAddress(), blockTag);
|
||||||
@ -23,9 +23,7 @@ class AbstractSigner {
|
|||||||
let pop = Object.assign({}, tx);
|
let pop = Object.assign({}, tx);
|
||||||
if (pop.to != null) {
|
if (pop.to != null) {
|
||||||
pop.to = provider.resolveName(pop.to).then((to) => {
|
pop.to = provider.resolveName(pop.to).then((to) => {
|
||||||
if (to == null) {
|
(0, index_js_2.assertArgument)(to != null, "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;
|
return to;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -35,9 +33,7 @@ class AbstractSigner {
|
|||||||
this.getAddress(),
|
this.getAddress(),
|
||||||
this.resolveName(from)
|
this.resolveName(from)
|
||||||
]).then(([address, from]) => {
|
]).then(([address, from]) => {
|
||||||
if (!from || address.toLowerCase() !== from.toLowerCase()) {
|
(0, index_js_2.assertArgument)(from && address.toLowerCase() === from.toLowerCase(), "transaction from mismatch", "tx.from", from);
|
||||||
return (0, index_js_2.throwArgumentError)("transaction from mismatch", "tx.from", from);
|
|
||||||
}
|
|
||||||
return address;
|
return address;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -59,9 +55,7 @@ class AbstractSigner {
|
|||||||
const network = await (this.provider).getNetwork();
|
const network = await (this.provider).getNetwork();
|
||||||
if (pop.chainId != null) {
|
if (pop.chainId != null) {
|
||||||
const chainId = (0, index_js_2.getBigInt)(pop.chainId);
|
const chainId = (0, index_js_2.getBigInt)(pop.chainId);
|
||||||
if (chainId !== network.chainId) {
|
(0, index_js_2.assertArgument)(chainId === network.chainId, "transaction chainId mismatch", "tx.chainId", tx.chainId);
|
||||||
(0, index_js_2.throwArgumentError)("transaction chainId mismatch", "tx.chainId", tx.chainId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pop.chainId = network.chainId;
|
pop.chainId = network.chainId;
|
||||||
@ -69,10 +63,10 @@ class AbstractSigner {
|
|||||||
// Do not allow mixing pre-eip-1559 and eip-1559 properties
|
// Do not allow mixing pre-eip-1559 and eip-1559 properties
|
||||||
const hasEip1559 = (pop.maxFeePerGas != null || pop.maxPriorityFeePerGas != null);
|
const hasEip1559 = (pop.maxFeePerGas != null || pop.maxPriorityFeePerGas != null);
|
||||||
if (pop.gasPrice != null && (pop.type === 2 || hasEip1559)) {
|
if (pop.gasPrice != null && (pop.type === 2 || hasEip1559)) {
|
||||||
(0, index_js_2.throwArgumentError)("eip-1559 transaction do not support gasPrice", "tx", tx);
|
(0, index_js_2.assertArgument)(false, "eip-1559 transaction do not support gasPrice", "tx", tx);
|
||||||
}
|
}
|
||||||
else if ((pop.type === 0 || pop.type === 1) && hasEip1559) {
|
else if ((pop.type === 0 || pop.type === 1) && hasEip1559) {
|
||||||
(0, index_js_2.throwArgumentError)("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "tx", tx);
|
(0, index_js_2.assertArgument)(false, "pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "tx", tx);
|
||||||
}
|
}
|
||||||
if ((pop.type === 2 || pop.type == null) && (pop.maxFeePerGas != null && pop.maxPriorityFeePerGas != null)) {
|
if ((pop.type === 2 || pop.type == null) && (pop.maxFeePerGas != null && pop.maxPriorityFeePerGas != null)) {
|
||||||
// Fully-formed EIP-1559 transaction (skip getFeeData)
|
// Fully-formed EIP-1559 transaction (skip getFeeData)
|
||||||
@ -82,11 +76,9 @@ class AbstractSigner {
|
|||||||
// Explicit Legacy or EIP-2930 transaction
|
// Explicit Legacy or EIP-2930 transaction
|
||||||
// We need to get fee data to determine things
|
// We need to get fee data to determine things
|
||||||
const feeData = await provider.getFeeData();
|
const feeData = await provider.getFeeData();
|
||||||
if (feeData.gasPrice == null) {
|
(0, index_js_2.assert)(feeData.gasPrice != null, "network does not support gasPrice", "UNSUPPORTED_OPERATION", {
|
||||||
(0, index_js_2.throwError)("network does not support gasPrice", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "getGasPrice"
|
operation: "getGasPrice"
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// Populate missing gasPrice
|
// Populate missing gasPrice
|
||||||
if (pop.gasPrice == null) {
|
if (pop.gasPrice == null) {
|
||||||
pop.gasPrice = feeData.gasPrice;
|
pop.gasPrice = feeData.gasPrice;
|
||||||
@ -122,11 +114,9 @@ class AbstractSigner {
|
|||||||
else if (feeData.gasPrice != null) {
|
else if (feeData.gasPrice != null) {
|
||||||
// Network doesn't support EIP-1559...
|
// Network doesn't support EIP-1559...
|
||||||
// ...but they are trying to use EIP-1559 properties
|
// ...but they are trying to use EIP-1559 properties
|
||||||
if (hasEip1559) {
|
(0, index_js_2.assert)(hasEip1559, "network does not support EIP-1559", "UNSUPPORTED_OPERATION", {
|
||||||
(0, index_js_2.throwError)("network does not support EIP-1559", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "populateTransaction"
|
operation: "populateTransaction"
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// Populate missing fee data
|
// Populate missing fee data
|
||||||
if (pop.gasPrice == null) {
|
if (pop.gasPrice == null) {
|
||||||
pop.gasPrice = feeData.gasPrice;
|
pop.gasPrice = feeData.gasPrice;
|
||||||
@ -137,7 +127,7 @@ class AbstractSigner {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// getFeeData has failed us.
|
// getFeeData has failed us.
|
||||||
(0, index_js_2.throwError)("failed to get consistent fee data", "UNSUPPORTED_OPERATION", {
|
(0, index_js_2.assert)(false, "failed to get consistent fee data", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "signer.getFeeData"
|
operation: "signer.getFeeData"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -186,9 +176,7 @@ class VoidSigner extends AbstractSigner {
|
|||||||
return new VoidSigner(this.address, provider);
|
return new VoidSigner(this.address, provider);
|
||||||
}
|
}
|
||||||
#throwUnsupported(suffix, operation) {
|
#throwUnsupported(suffix, operation) {
|
||||||
return (0, index_js_2.throwError)(`VoidSigner cannot sign ${suffix}`, "UNSUPPORTED_OPERATION", {
|
(0, index_js_2.assert)(false, `VoidSigner cannot sign ${suffix}`, "UNSUPPORTED_OPERATION", { operation });
|
||||||
operation
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
async signTransaction(tx) {
|
async signTransaction(tx) {
|
||||||
this.#throwUnsupported("transactions", "signTransaction");
|
this.#throwUnsupported("transactions", "signTransaction");
|
||||||
|
File diff suppressed because one or more lines are too long
@ -63,9 +63,7 @@ function encodeBytes(datas) {
|
|||||||
return (0, index_js_4.concat)(result);
|
return (0, index_js_4.concat)(result);
|
||||||
}
|
}
|
||||||
function callAddress(value) {
|
function callAddress(value) {
|
||||||
if (value.length !== 66 || (0, index_js_4.dataSlice)(value, 0, 12) !== "0x000000000000000000000000") {
|
(0, index_js_4.assertArgument)(value.length === 66 && (0, index_js_4.dataSlice)(value, 0, 12) === "0x000000000000000000000000", "invalid call address", "value", value);
|
||||||
(0, index_js_4.throwArgumentError)("invalid call address", "value", value);
|
|
||||||
}
|
|
||||||
return (0, index_js_1.getAddress)("0x" + value.substring(26));
|
return (0, index_js_1.getAddress)("0x" + value.substring(26));
|
||||||
}
|
}
|
||||||
// @TODO: This should use the fetch-data:ipfs gateway
|
// @TODO: This should use the fetch-data:ipfs gateway
|
||||||
@ -78,7 +76,7 @@ function getIpfsLink(link) {
|
|||||||
link = link.substring(7);
|
link = link.substring(7);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
(0, index_js_4.throwArgumentError)("unsupported IPFS format", "link", link);
|
(0, index_js_4.assertArgument)(false, "unsupported IPFS format", "link", link);
|
||||||
}
|
}
|
||||||
return `https:/\/gateway.ipfs.io/ipfs/${link}`;
|
return `https:/\/gateway.ipfs.io/ipfs/${link}`;
|
||||||
}
|
}
|
||||||
@ -89,7 +87,7 @@ class MulticoinProviderPlugin {
|
|||||||
constructor(name) {
|
constructor(name) {
|
||||||
(0, index_js_4.defineProperties)(this, { name });
|
(0, index_js_4.defineProperties)(this, { name });
|
||||||
}
|
}
|
||||||
validate(proivder) {
|
connect(proivder) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
supportsCoinType(coinType) {
|
supportsCoinType(coinType) {
|
||||||
@ -103,7 +101,7 @@ class MulticoinProviderPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.MulticoinProviderPlugin = MulticoinProviderPlugin;
|
exports.MulticoinProviderPlugin = MulticoinProviderPlugin;
|
||||||
const BasicMulticoinPluginId = "org.ethers.provider-prugins.basicmulticoin";
|
const BasicMulticoinPluginId = "org.ethers.plugins.BasicMulticoinProviderPlugin";
|
||||||
class BasicMulticoinProviderPlugin extends MulticoinProviderPlugin {
|
class BasicMulticoinProviderPlugin extends MulticoinProviderPlugin {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(BasicMulticoinPluginId);
|
super(BasicMulticoinPluginId);
|
||||||
@ -164,12 +162,10 @@ class EnsResolver {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let data = await this.provider.call(tx);
|
let data = await this.provider.call(tx);
|
||||||
if (((0, index_js_4.getBytes)(data).length % 32) === 4) {
|
(0, index_js_4.assert)(((0, index_js_4.getBytes)(data).length % 32) !== 4, "execution reverted during JSON-RPC call (could not parse reason; invalid data length)", "CALL_EXCEPTION", {
|
||||||
return (0, index_js_4.throwError)("execution reverted during JSON-RPC call (could not parse reason; invalid data length)", "CALL_EXCEPTION", {
|
|
||||||
action: "call", data, reason: null, transaction: tx,
|
action: "call", data, reason: null, transaction: tx,
|
||||||
invocation: null, revert: null
|
invocation: null, revert: null
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (wrapped) {
|
if (wrapped) {
|
||||||
return parseBytes(data, 0);
|
return parseBytes(data, 0);
|
||||||
}
|
}
|
||||||
@ -224,7 +220,7 @@ class EnsResolver {
|
|||||||
if (address != null) {
|
if (address != null) {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
return (0, index_js_4.throwError)(`invalid coin data`, "UNSUPPORTED_OPERATION", {
|
(0, index_js_4.assert)(false, `invalid coin data`, "UNSUPPORTED_OPERATION", {
|
||||||
operation: `getAddress(${coinType})`,
|
operation: `getAddress(${coinType})`,
|
||||||
info: { coinType, data }
|
info: { coinType, data }
|
||||||
});
|
});
|
||||||
@ -262,7 +258,7 @@ class EnsResolver {
|
|||||||
if (swarm && swarm[1].length === 64) {
|
if (swarm && swarm[1].length === 64) {
|
||||||
return `bzz:/\/${swarm[1]}`;
|
return `bzz:/\/${swarm[1]}`;
|
||||||
}
|
}
|
||||||
return (0, index_js_4.throwError)(`invalid or unsupported content hash data`, "UNSUPPORTED_OPERATION", {
|
(0, index_js_4.assert)(false, `invalid or unsupported content hash data`, "UNSUPPORTED_OPERATION", {
|
||||||
operation: "getContentHash()",
|
operation: "getContentHash()",
|
||||||
info: { data: hexBytes }
|
info: { data: hexBytes }
|
||||||
});
|
});
|
||||||
@ -419,11 +415,9 @@ class EnsResolver {
|
|||||||
const network = await provider.getNetwork();
|
const network = await provider.getNetwork();
|
||||||
const ensPlugin = network.getPlugin("org.ethers.network-plugins.ens");
|
const ensPlugin = network.getPlugin("org.ethers.network-plugins.ens");
|
||||||
// No ENS...
|
// No ENS...
|
||||||
if (!ensPlugin) {
|
(0, index_js_4.assert)(ensPlugin, "network does not support ENS", "UNSUPPORTED_OPERATION", {
|
||||||
return (0, index_js_4.throwError)("network does not support ENS", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "getResolver", info: { network: network.name }
|
operation: "getResolver", info: { network: network.name }
|
||||||
});
|
});
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// keccak256("resolver(bytes32)")
|
// keccak256("resolver(bytes32)")
|
||||||
const addrData = await provider.call({
|
const addrData = await provider.call({
|
||||||
|
File diff suppressed because one or more lines are too long
@ -48,7 +48,7 @@ function object(format, altNames) {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
const message = (error instanceof Error) ? error.message : "not-an-error";
|
const message = (error instanceof Error) ? error.message : "not-an-error";
|
||||||
(0, index_js_4.throwError)(`invalid value for value.${key} (${message})`, "BAD_DATA", { value });
|
(0, index_js_4.assert)(false, `invalid value for value.${key} (${message})`, "BAD_DATA", { value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -64,20 +64,16 @@ function formatBoolean(value) {
|
|||||||
case "false":
|
case "false":
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (0, index_js_4.throwArgumentError)(`invalid boolean; ${JSON.stringify(value)}`, "value", value);
|
(0, index_js_4.assertArgument)(false, `invalid boolean; ${JSON.stringify(value)}`, "value", value);
|
||||||
}
|
}
|
||||||
exports.formatBoolean = formatBoolean;
|
exports.formatBoolean = formatBoolean;
|
||||||
function formatData(value) {
|
function formatData(value) {
|
||||||
if (!(0, index_js_4.isHexString)(value, true)) {
|
(0, index_js_4.assertArgument)((0, index_js_4.isHexString)(value, true), "invalid data", "value", value);
|
||||||
(0, index_js_4.throwArgumentError)("", "value", value);
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
exports.formatData = formatData;
|
exports.formatData = formatData;
|
||||||
function formatHash(value) {
|
function formatHash(value) {
|
||||||
if (!(0, index_js_4.isHexString)(value, 32)) {
|
(0, index_js_4.assertArgument)((0, index_js_4.isHexString)(value, 32), "invalid hash", "value", value);
|
||||||
(0, index_js_4.throwArgumentError)("", "value", value);
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
exports.formatHash = formatHash;
|
exports.formatHash = formatHash;
|
||||||
@ -144,7 +140,7 @@ exports.formatTransactionReceipt = object({
|
|||||||
hash: formatHash,
|
hash: formatHash,
|
||||||
logs: arrayOf(exports.formatReceiptLog),
|
logs: arrayOf(exports.formatReceiptLog),
|
||||||
blockNumber: index_js_4.getNumber,
|
blockNumber: index_js_4.getNumber,
|
||||||
confirmations: allowNull(index_js_4.getNumber, null),
|
//confirmations: allowNull(getNumber, null),
|
||||||
cumulativeGasUsed: index_js_4.getBigInt,
|
cumulativeGasUsed: index_js_4.getBigInt,
|
||||||
effectiveGasPrice: allowNull(index_js_4.getBigInt),
|
effectiveGasPrice: allowNull(index_js_4.getBigInt),
|
||||||
status: allowNull(index_js_4.getNumber),
|
status: allowNull(index_js_4.getNumber),
|
||||||
@ -172,7 +168,7 @@ function formatTransactionResponse(value) {
|
|||||||
blockHash: allowNull(formatHash, null),
|
blockHash: allowNull(formatHash, null),
|
||||||
blockNumber: allowNull(index_js_4.getNumber, null),
|
blockNumber: allowNull(index_js_4.getNumber, null),
|
||||||
transactionIndex: allowNull(index_js_4.getNumber, null),
|
transactionIndex: allowNull(index_js_4.getNumber, null),
|
||||||
confirmations: allowNull(index_js_4.getNumber, null),
|
//confirmations: allowNull(getNumber, null),
|
||||||
from: index_js_1.getAddress,
|
from: index_js_1.getAddress,
|
||||||
// either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set
|
// either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) must be set
|
||||||
gasPrice: allowNull(index_js_4.getBigInt),
|
gasPrice: allowNull(index_js_4.getBigInt),
|
||||||
@ -199,7 +195,12 @@ function formatTransactionResponse(value) {
|
|||||||
result.accessList = [];
|
result.accessList = [];
|
||||||
}
|
}
|
||||||
// Compute the signature
|
// Compute the signature
|
||||||
|
if (value.signature) {
|
||||||
|
result.signature = index_js_2.Signature.from(value.signature);
|
||||||
|
}
|
||||||
|
else {
|
||||||
result.signature = index_js_2.Signature.from(value);
|
result.signature = index_js_2.Signature.from(value);
|
||||||
|
}
|
||||||
// Some backends omit ChainId on legacy transactions, but we can compute it
|
// Some backends omit ChainId on legacy transactions, but we can compute it
|
||||||
if (result.chainId == null) {
|
if (result.chainId == null) {
|
||||||
const chainId = result.signature.legacyChainId;
|
const chainId = result.signature.legacyChainId;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -149,7 +149,7 @@ class Network {
|
|||||||
if (typeof (network) === "bigint") {
|
if (typeof (network) === "bigint") {
|
||||||
return new Network("unknown", network);
|
return new Network("unknown", network);
|
||||||
}
|
}
|
||||||
(0, index_js_2.throwArgumentError)("unknown network", "network", network);
|
(0, index_js_2.assertArgument)(false, "unknown network", "network", network);
|
||||||
}
|
}
|
||||||
// Clonable with network-like abilities
|
// Clonable with network-like abilities
|
||||||
if (typeof (network.clone) === "function") {
|
if (typeof (network.clone) === "function") {
|
||||||
@ -160,9 +160,7 @@ class Network {
|
|||||||
}
|
}
|
||||||
// Networkish
|
// Networkish
|
||||||
if (typeof (network) === "object") {
|
if (typeof (network) === "object") {
|
||||||
if (typeof (network.name) !== "string" || typeof (network.chainId) !== "number") {
|
(0, index_js_2.assertArgument)(typeof (network.name) === "string" && typeof (network.chainId) === "number", "invalid network object name or chainId", "network", network);
|
||||||
(0, index_js_2.throwArgumentError)("invalid network object name or chainId", "network", network);
|
|
||||||
}
|
|
||||||
const custom = new Network((network.name), (network.chainId));
|
const custom = new Network((network.name), (network.chainId));
|
||||||
if (network.ensAddress || network.ensNetwork != null) {
|
if (network.ensAddress || network.ensNetwork != null) {
|
||||||
custom.attachPlugin(new plugins_network_js_1.EnsPlugin(network.ensAddress, network.ensNetwork));
|
custom.attachPlugin(new plugins_network_js_1.EnsPlugin(network.ensAddress, network.ensNetwork));
|
||||||
@ -172,7 +170,7 @@ class Network {
|
|||||||
//}
|
//}
|
||||||
return custom;
|
return custom;
|
||||||
}
|
}
|
||||||
return (0, index_js_2.throwArgumentError)("invalid network", "network", network);
|
(0, index_js_2.assertArgument)(false, "invalid network", "network", network);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Register %%nameOrChainId%% with a function which returns
|
* Register %%nameOrChainId%% with a function which returns
|
||||||
@ -184,7 +182,7 @@ class Network {
|
|||||||
}
|
}
|
||||||
const existing = Networks.get(nameOrChainId);
|
const existing = Networks.get(nameOrChainId);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
(0, index_js_2.throwArgumentError)(`conflicting network for ${JSON.stringify(existing.name)}`, "nameOrChainId", nameOrChainId);
|
(0, index_js_2.assertArgument)(false, `conflicting network for ${JSON.stringify(existing.name)}`, "nameOrChainId", nameOrChainId);
|
||||||
}
|
}
|
||||||
Networks.set(nameOrChainId, networkFunc);
|
Networks.set(nameOrChainId, networkFunc);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
31
lib.commonjs/providers/plugin-fallback.js
Normal file
31
lib.commonjs/providers/plugin-fallback.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.PossiblyPrunedTransactionPlugin = exports.CheckQualifiedPlugin = exports.PluginIdFallbackProvider = void 0;
|
||||||
|
const index_js_1 = require("../utils/index.js");
|
||||||
|
exports.PluginIdFallbackProvider = "org.ethers.plugins.QualifiedPlugin";
|
||||||
|
class CheckQualifiedPlugin {
|
||||||
|
constructor() {
|
||||||
|
(0, index_js_1.defineProperties)(this, { name: exports.PluginIdFallbackProvider });
|
||||||
|
}
|
||||||
|
connect(provider) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
// Retruns true if this value should be considered qualified for
|
||||||
|
// inclusion in the quorum.
|
||||||
|
isQualified(action, result) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.CheckQualifiedPlugin = CheckQualifiedPlugin;
|
||||||
|
class PossiblyPrunedTransactionPlugin extends CheckQualifiedPlugin {
|
||||||
|
isQualified(action, result) {
|
||||||
|
if (action.method === "getTransaction" || action.method === "getTransactionReceipt") {
|
||||||
|
if (result == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.isQualified(action, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.PossiblyPrunedTransactionPlugin = PossiblyPrunedTransactionPlugin;
|
||||||
|
//# sourceMappingURL=plugin-fallback.js.map
|
1
lib.commonjs/providers/plugin-fallback.js.map
Normal file
1
lib.commonjs/providers/plugin-fallback.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"plugin-fallback.js","sourceRoot":"","sources":["../../src.ts/providers/plugin-fallback.ts"],"names":[],"mappings":";;;AAEA,gDAAqD;AAKxC,QAAA,wBAAwB,GAAG,oCAAoC,CAAC;AAE7E,MAAa,oBAAoB;IAG7B;QACI,IAAA,2BAAgB,EAAuB,IAAI,EAAE,EAAE,IAAI,EAAE,gCAAwB,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,CAAC,QAA0B;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,gEAAgE;IAChE,2BAA2B;IAC3B,WAAW,CAAC,MAA4B,EAAE,MAAW;QACjD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAhBD,oDAgBC;AAED,MAAa,+BAAgC,SAAQ,oBAAoB;IACrE,WAAW,CAAC,MAA4B,EAAE,MAAW;QACjD,IAAI,MAAM,CAAC,MAAM,KAAK,gBAAgB,IAAI,MAAM,CAAC,MAAM,KAAK,uBAAuB,EAAE;YACjF,IAAI,MAAM,IAAI,IAAI,EAAE;gBAAE,OAAO,KAAK,CAAC;aAAE;SACxC;QACD,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;CACJ;AAPD,0EAOC"}
|
@ -30,9 +30,7 @@ class GasCostPlugin extends NetworkPlugin {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
value = nullish;
|
value = nullish;
|
||||||
}
|
}
|
||||||
if (typeof (value) !== "number") {
|
(0, index_js_1.assertArgument)(typeof (value) === "number", `invalud value for ${name}`, "costs", costs);
|
||||||
(0, index_js_1.throwArgumentError)(`invalud value for ${name}`, "costs", costs);
|
|
||||||
}
|
|
||||||
props[name] = value;
|
props[name] = value;
|
||||||
}
|
}
|
||||||
set("txBase", 21000);
|
set("txBase", 21000);
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"plugins-network.js","sourceRoot":"","sources":["../../src.ts/providers/plugins-network.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAE1D,gDAAuD;AAKvD,MAAM,UAAU,GAAG,4CAA4C,CAAC;AAEhE,MAAa,aAAa;IACb,IAAI,CAAU;IAEvB,YAAY,IAAY;QACpB,IAAA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,OAAO,MAAM,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAED,KAAK;QACD,OAAO,IAAI,wBAAwB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACjF,CAAC;CACJ;AArBD,4DAqBC"}
|
@ -25,7 +25,7 @@ function getHost(name) {
|
|||||||
case "optimism-goerli":
|
case "optimism-goerli":
|
||||||
return "opt-goerli.g.alchemy.com";
|
return "opt-goerli.g.alchemy.com";
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("unsupported network", "network", name);
|
(0, index_js_1.assertArgument)(false, "unsupported network", "network", name);
|
||||||
}
|
}
|
||||||
class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
||||||
apiKey;
|
apiKey;
|
||||||
@ -63,8 +63,7 @@ class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
|||||||
}
|
}
|
||||||
catch (error) { }
|
catch (error) { }
|
||||||
if (data) {
|
if (data) {
|
||||||
if (error) {
|
(0, index_js_1.assert)(!error, "an error occurred during transaction executions", "CALL_EXCEPTION", {
|
||||||
(0, index_js_1.throwError)("an error occurred during transaction executions", "CALL_EXCEPTION", {
|
|
||||||
action: "getTransactionResult",
|
action: "getTransactionResult",
|
||||||
data,
|
data,
|
||||||
reason: null,
|
reason: null,
|
||||||
@ -72,10 +71,9 @@ class AlchemyProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
|||||||
invocation: null,
|
invocation: null,
|
||||||
revert: null // @TODO
|
revert: null // @TODO
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwError)("could not parse trace result", "BAD_DATA", { value: trace });
|
(0, index_js_1.assert)(false, "could not parse trace result", "BAD_DATA", { value: trace });
|
||||||
}
|
}
|
||||||
return await super._perform(req);
|
return await super._perform(req);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"provider-alchemy.js","sourceRoot":"","sources":["../../src.ts/providers/provider-alchemy.ts"],"names":[],"mappings":";;;AACA,gDAG2B;AAE3B,iDAAqD;AACrD,6CAAuC;AACvC,+DAAwD;AAOxD,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAExD,SAAS,OAAO,CAAC,IAAY;IACzB,QAAO,IAAI,EAAE;QACT,KAAK,SAAS;YACV,OAAO,2BAA2B,CAAC;QACvC,KAAK,QAAQ;YACT,OAAO,0BAA0B,CAAC;QAEtC,KAAK,UAAU;YACX,OAAO,2BAA2B,CAAC;QACvC,KAAK,iBAAiB;YAClB,OAAO,0BAA0B,CAAC;QACtC,KAAK,OAAO;YACR,OAAO,+BAA+B,CAAC;QAC3C,KAAK,UAAU;YACX,OAAO,8BAA8B,CAAC;QAC1C,KAAK,UAAU;YACX,OAAO,2BAA2B,CAAC;QACvC,KAAK,iBAAiB;YAClB,OAAO,0BAA0B,CAAC;KACzC;IAED,OAAO,IAAA,6BAAkB,EAAC,qBAAqB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACtE,CAAC;AAED,MAAa,eAAgB,SAAQ,qCAAe;IACvC,MAAM,CAAU;IAEzB,YAAY,WAAuB,SAAS,EAAE,MAAsB;QAChE,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,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5D,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;QAEpD,IAAA,2BAAgB,EAAkB,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACxD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AAO,CAAC,IAAI,CAAE,OAAQ,MAAO,EAAE,CAAC,CAAC;QACvF,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAEzB,IAAI,MAAM,KAAK,aAAa,EAAE;YAC1B,OAAO,CAAC,SAAS,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;gBACrD,IAAA,kCAAmB,EAAC,SAAS,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YAChB,CAAC,CAAA;SACJ;QAED,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AA1ED,0CA0EC"}
|
@ -21,7 +21,7 @@ function getHost(name) {
|
|||||||
case "arbitrum":
|
case "arbitrum":
|
||||||
return "rpc.ankr.com/arbitrum";
|
return "rpc.ankr.com/arbitrum";
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("unsupported network", "network", name);
|
(0, index_js_1.assertArgument)(false, "unsupported network", "network", name);
|
||||||
}
|
}
|
||||||
class AnkrProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
class AnkrProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
||||||
apiKey;
|
apiKey;
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"provider-ankr.js","sourceRoot":"","sources":["../../src.ts/providers/provider-ankr.ts"],"names":[],"mappings":";;;AAAA,gDAE2B;AAG3B,iDAAqD;AACrD,6CAAuC;AACvC,+DAAwD;AAMxD,MAAM,aAAa,GAAG,kEAAkE,CAAC;AAEzF,SAAS,OAAO,CAAC,IAAY;IACzB,QAAQ,IAAI,EAAE;QACV,KAAK,SAAS;YACV,OAAO,kBAAkB,CAAC;QAC9B,KAAK,SAAS;YACV,OAAO,0BAA0B,CAAC;QACtC,KAAK,SAAS;YACV,OAAO,0BAA0B,CAAC;QACtC,KAAK,QAAQ;YACT,OAAO,yBAAyB,CAAC;QACrC,KAAK,OAAO;YACR,OAAO,sBAAsB,CAAC;QAClC,KAAK,UAAU;YACX,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GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzD,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAEjC,IAAA,2BAAgB,EAAe,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,YAAY,CAAC,OAAe;QACxB,IAAI;YACA,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SACjD;QAAC,OAAO,KAAK,EAAE,GAAG;QACnB,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,OAAgB,EAAE,MAAsB;QACtD,IAAI,MAAM,IAAI,IAAI,EAAE;YAAE,MAAM,GAAG,aAAa,CAAC;SAAE;QAE/C,MAAM,OAAO,GAAG,IAAI,uBAAY,CAAC,YAAa,OAAO,CAAC,OAAO,CAAC,IAAI,CAAE,IAAK,MAAO,EAAE,CAAC,CAAC;QACpF,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAEzB,IAAI,MAAM,KAAK,aAAa,EAAE;YAC1B,OAAO,CAAC,SAAS,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;gBACrD,IAAA,kCAAmB,EAAC,cAAc,CAAC,CAAC;gBACpC,OAAO,IAAI,CAAC;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"}
|
@ -7,9 +7,7 @@ const provider_jsonrpc_js_1 = require("./provider-jsonrpc.js");
|
|||||||
class CloudflareProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
class CloudflareProvider extends provider_jsonrpc_js_1.JsonRpcProvider {
|
||||||
constructor(_network = "mainnet") {
|
constructor(_network = "mainnet") {
|
||||||
const network = network_js_1.Network.from(_network);
|
const network = network_js_1.Network.from(_network);
|
||||||
if (network.name !== "mainnet") {
|
(0, index_js_1.assertArgument)(network.name === "mainnet", "unsupported network", "network", _network);
|
||||||
return (0, index_js_1.throwArgumentError)("unsupported network", "network", _network);
|
|
||||||
}
|
|
||||||
super("https:/\/cloudflare-eth.com/", network, { staticNetwork: 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":";;;AAAA,gDAAuD;AAEvD,6CAAuC;AACvC,+DAAwD;AAKxD,MAAa,kBAAmB,SAAQ,qCAAe;IACnD,YAAY,WAAuB,SAAS;QACxC,MAAM,OAAO,GAAG,oBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE;YAC5B,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"}
|
{"version":3,"file":"provider-cloudflare.js","sourceRoot":"","sources":["../../src.ts/providers/provider-cloudflare.ts"],"names":[],"mappings":";;;AAAA,gDAAmD;AAEnD,6CAAuC;AACvC,+DAAwD;AAKxD,MAAa,kBAAmB,SAAQ,qCAAe;IACnD,YAAY,WAAuB,SAAS;QACxC,MAAM,OAAO,GAAG,oBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAA,yBAAc,EAAC,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,qBAAqB,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACvF,KAAK,CAAC,8BAA8B,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/E,CAAC;CACJ;AAND,gDAMC"}
|
@ -9,7 +9,7 @@ const network_js_1 = require("./network.js");
|
|||||||
const plugins_network_js_1 = require("./plugins-network.js");
|
const plugins_network_js_1 = require("./plugins-network.js");
|
||||||
const community_js_1 = require("./community.js");
|
const community_js_1 = require("./community.js");
|
||||||
const THROTTLE = 2000;
|
const THROTTLE = 2000;
|
||||||
const EtherscanPluginId = "org.ethers.plugins.etherscan";
|
const EtherscanPluginId = "org.ethers.plugins.Etherscan";
|
||||||
class EtherscanPlugin extends plugins_network_js_1.NetworkPlugin {
|
class EtherscanPlugin extends plugins_network_js_1.NetworkPlugin {
|
||||||
baseUrl;
|
baseUrl;
|
||||||
communityApiKey;
|
communityApiKey;
|
||||||
@ -64,7 +64,7 @@ class BaseEtherscanProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
return "https:/\/api-goerli-optimistic.etherscan.io";
|
return "https:/\/api-goerli-optimistic.etherscan.io";
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwArgumentError)("unsupported network", "network", this.network);
|
(0, index_js_3.assertArgument)(false, "unsupported network", "network", this.network);
|
||||||
}
|
}
|
||||||
getUrl(module, params) {
|
getUrl(module, params) {
|
||||||
const query = Object.keys(params).reduce((accum, key) => {
|
const query = Object.keys(params).reduce((accum, key) => {
|
||||||
@ -188,7 +188,7 @@ class BaseEtherscanProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
}
|
}
|
||||||
// Quantity-types require no leading zero, unless 0
|
// Quantity-types require no leading zero, unless 0
|
||||||
if ({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true }[key]) {
|
if ({ type: true, gasLimit: true, gasPrice: true, maxFeePerGs: true, maxPriorityFeePerGas: true, nonce: true, value: true }[key]) {
|
||||||
value = (0, index_js_3.toQuantity)((0, index_js_3.hexlify)(value));
|
value = (0, index_js_3.toQuantity)(value);
|
||||||
}
|
}
|
||||||
else if (key === "accessList") {
|
else if (key === "accessList") {
|
||||||
value = "[" + (0, index_js_2.accessListify)(value).map((set) => {
|
value = "[" + (0, index_js_2.accessListify)(value).map((set) => {
|
||||||
@ -331,7 +331,7 @@ class BaseEtherscanProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
boolean: (req.includeTransactions ? "true" : "false")
|
boolean: (req.includeTransactions ? "true" : "false")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return (0, index_js_3.throwError)("getBlock by blockHash not supported by Etherscan", "UNSUPPORTED_OPERATION", {
|
(0, index_js_3.assert)(false, "getBlock by blockHash not supported by Etherscan", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "getBlock(blockHash)"
|
operation: "getBlock(blockHash)"
|
||||||
});
|
});
|
||||||
case "getTransaction":
|
case "getTransaction":
|
||||||
|
File diff suppressed because one or more lines are too long
@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
exports.FallbackProvider = void 0;
|
exports.FallbackProvider = void 0;
|
||||||
const index_js_1 = require("../utils/index.js");
|
const index_js_1 = require("../utils/index.js");
|
||||||
const abstract_provider_js_1 = require("./abstract-provider.js");
|
const abstract_provider_js_1 = require("./abstract-provider.js");
|
||||||
const format_js_1 = require("./format.js");
|
|
||||||
const network_js_1 = require("./network.js");
|
const network_js_1 = require("./network.js");
|
||||||
//const BN_0 = BigInt("0");
|
|
||||||
const BN_1 = BigInt("1");
|
const BN_1 = BigInt("1");
|
||||||
const BN_2 = BigInt("2");
|
const BN_2 = BigInt("2");
|
||||||
function shuffle(array) {
|
function shuffle(array) {
|
||||||
@ -20,6 +18,14 @@ function stall(duration) {
|
|||||||
return new Promise((resolve) => { setTimeout(resolve, duration); });
|
return new Promise((resolve) => { setTimeout(resolve, duration); });
|
||||||
}
|
}
|
||||||
function getTime() { return (new Date()).getTime(); }
|
function getTime() { return (new Date()).getTime(); }
|
||||||
|
function stringify(value) {
|
||||||
|
return JSON.stringify(value, (key, value) => {
|
||||||
|
if (typeof (value) === "bigint") {
|
||||||
|
return { type: "bigint", value: value.toString() };
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
}
|
||||||
;
|
;
|
||||||
const defaultConfig = { stallTimeout: 400, priority: 1, weight: 1 };
|
const defaultConfig = { stallTimeout: 400, priority: 1, weight: 1 };
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
@ -42,72 +48,90 @@ async function waitForSync(config, blockNumber) {
|
|||||||
config.outOfSync++;
|
config.outOfSync++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Normalizes a result to a string that can be used to compare against
|
function _normalize(value) {
|
||||||
// other results using normal string equality
|
if (value == null) {
|
||||||
function normalize(provider, value, req) {
|
return "null";
|
||||||
switch (req.method) {
|
|
||||||
case "chainId":
|
|
||||||
return (0, index_js_1.getBigInt)(value).toString();
|
|
||||||
case "getBlockNumber":
|
|
||||||
return (0, index_js_1.getNumber)(value).toString();
|
|
||||||
case "getGasPrice":
|
|
||||||
return (0, index_js_1.getBigInt)(value).toString();
|
|
||||||
case "getBalance":
|
|
||||||
return (0, index_js_1.getBigInt)(value).toString();
|
|
||||||
case "getTransactionCount":
|
|
||||||
return (0, index_js_1.getNumber)(value).toString();
|
|
||||||
case "getCode":
|
|
||||||
return (0, index_js_1.hexlify)(value);
|
|
||||||
case "getStorage":
|
|
||||||
return (0, index_js_1.hexlify)(value);
|
|
||||||
case "getBlock":
|
|
||||||
if (req.includeTransactions) {
|
|
||||||
return JSON.stringify((0, format_js_1.formatBlockWithTransactions)(value));
|
|
||||||
}
|
}
|
||||||
return JSON.stringify((0, format_js_1.formatBlock)(value));
|
if (Array.isArray(value)) {
|
||||||
case "getTransaction":
|
return "[" + (value.map(_normalize)).join(",") + "]";
|
||||||
return JSON.stringify((0, format_js_1.formatTransactionResponse)(value));
|
|
||||||
case "getTransactionReceipt":
|
|
||||||
return JSON.stringify((0, format_js_1.formatTransactionReceipt)(value));
|
|
||||||
case "call":
|
|
||||||
return (0, index_js_1.hexlify)(value);
|
|
||||||
case "estimateGas":
|
|
||||||
return (0, index_js_1.getBigInt)(value).toString();
|
|
||||||
case "getLogs":
|
|
||||||
return JSON.stringify(value.map((v) => (0, format_js_1.formatLog)(v)));
|
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwError)("unsupported method", "UNSUPPORTED_OPERATION", {
|
if (typeof (value) === "object" && typeof (value.toJSON) === "function") {
|
||||||
operation: `_perform(${JSON.stringify(req.method)})`
|
return _normalize(value.toJSON());
|
||||||
});
|
}
|
||||||
|
switch (typeof (value)) {
|
||||||
|
case "boolean":
|
||||||
|
case "symbol":
|
||||||
|
return value.toString();
|
||||||
|
case "bigint":
|
||||||
|
case "number":
|
||||||
|
return BigInt(value).toString();
|
||||||
|
case "string":
|
||||||
|
return JSON.stringify(value);
|
||||||
|
case "object": {
|
||||||
|
const keys = Object.keys(value);
|
||||||
|
keys.sort();
|
||||||
|
return "{" + keys.map((k) => `${JSON.stringify(k)}:${_normalize(value[k])}`).join(",") + "}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("Could not serialize", value);
|
||||||
|
throw new Error("Hmm...");
|
||||||
}
|
}
|
||||||
// This strategy picks the highest wieght result, as long as the weight is
|
function normalizeResult(value) {
|
||||||
|
if ("error" in value) {
|
||||||
|
const error = value.error;
|
||||||
|
return { tag: _normalize(error), value: error };
|
||||||
|
}
|
||||||
|
const result = value.result;
|
||||||
|
return { tag: _normalize(result), value: result };
|
||||||
|
}
|
||||||
|
// This strategy picks the highest weight result, as long as the weight is
|
||||||
// equal to or greater than quorum
|
// equal to or greater than quorum
|
||||||
function checkQuorum(quorum, results) {
|
function checkQuorum(quorum, results) {
|
||||||
const tally = new Map();
|
const tally = new Map();
|
||||||
for (const { result, normal, weight } of results) {
|
for (const { value, tag, weight } of results) {
|
||||||
const t = tally.get(normal) || { result, weight: 0 };
|
const t = tally.get(tag) || { value, weight: 0 };
|
||||||
t.weight += weight;
|
t.weight += weight;
|
||||||
tally.set(normal, t);
|
tally.set(tag, t);
|
||||||
}
|
}
|
||||||
let bestWeight = 0;
|
let best = null;
|
||||||
let bestResult = undefined;
|
for (const r of tally.values()) {
|
||||||
for (const { weight, result } of tally.values()) {
|
if (r.weight >= quorum && (!best || r.weight > best.weight)) {
|
||||||
if (weight >= quorum && weight > bestWeight) {
|
best = r;
|
||||||
bestWeight = weight;
|
|
||||||
bestResult = result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bestResult;
|
if (best) {
|
||||||
|
return best.value;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
}
|
}
|
||||||
/*
|
function getMedian(quorum, results) {
|
||||||
function getMean(results: Array<TallyResult>): bigint {
|
let resultWeight = 0;
|
||||||
const total = results.reduce((a, r) => (a + BigInt(r.result)), BN_0);
|
const errorMap = new Map();
|
||||||
return total / BigInt(results.length);
|
let bestError = null;
|
||||||
}
|
const values = [];
|
||||||
*/
|
for (const { value, tag, weight } of results) {
|
||||||
function getMedian(results) {
|
if (value instanceof Error) {
|
||||||
|
const e = errorMap.get(tag) || { value, weight: 0 };
|
||||||
|
e.weight += weight;
|
||||||
|
errorMap.set(tag, e);
|
||||||
|
if (bestError == null || e.weight > bestError.weight) {
|
||||||
|
bestError = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
values.push(BigInt(value));
|
||||||
|
resultWeight += weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resultWeight < quorum) {
|
||||||
|
// We have quorum for an error
|
||||||
|
if (bestError && bestError.weight >= quorum) {
|
||||||
|
return bestError.value;
|
||||||
|
}
|
||||||
|
// We do not have quorum for a result
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
// Get the sorted values
|
// Get the sorted values
|
||||||
const values = results.map((r) => BigInt(r.result));
|
|
||||||
values.sort((a, b) => ((a < b) ? -1 : (b > a) ? 1 : 0));
|
values.sort((a, b) => ((a < b) ? -1 : (b > a) ? 1 : 0));
|
||||||
const mid = values.length / 2;
|
const mid = values.length / 2;
|
||||||
// Odd-length; take the middle value
|
// Odd-length; take the middle value
|
||||||
@ -117,9 +141,24 @@ function getMedian(results) {
|
|||||||
// Even length; take the ceiling of the mean of the center two values
|
// Even length; take the ceiling of the mean of the center two values
|
||||||
return (values[mid - 1] + values[mid] + BN_1) / BN_2;
|
return (values[mid - 1] + values[mid] + BN_1) / BN_2;
|
||||||
}
|
}
|
||||||
|
function getAnyResult(quorum, results) {
|
||||||
|
// If any value or error meets quorum, that is our preferred result
|
||||||
|
const result = checkQuorum(quorum, results);
|
||||||
|
if (result !== undefined) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// Otherwise, do we have any result?
|
||||||
|
for (const r of results) {
|
||||||
|
if (r.value) {
|
||||||
|
return r.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Nope!
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
function getFuzzyMode(quorum, results) {
|
function getFuzzyMode(quorum, results) {
|
||||||
if (quorum === 1) {
|
if (quorum === 1) {
|
||||||
return (0, index_js_1.getNumber)(getMedian(results), "%internal");
|
return (0, index_js_1.getNumber)(getMedian(quorum, results), "%internal");
|
||||||
}
|
}
|
||||||
const tally = new Map();
|
const tally = new Map();
|
||||||
const add = (result, weight) => {
|
const add = (result, weight) => {
|
||||||
@ -127,8 +166,8 @@ function getFuzzyMode(quorum, results) {
|
|||||||
t.weight += weight;
|
t.weight += weight;
|
||||||
tally.set(result, t);
|
tally.set(result, t);
|
||||||
};
|
};
|
||||||
for (const { weight, result } of results) {
|
for (const { weight, value } of results) {
|
||||||
const r = (0, index_js_1.getNumber)(result);
|
const r = (0, index_js_1.getNumber)(value);
|
||||||
add(r - 1, weight);
|
add(r - 1, weight);
|
||||||
add(r, weight);
|
add(r, weight);
|
||||||
add(r + 1, weight);
|
add(r + 1, weight);
|
||||||
@ -147,7 +186,6 @@ function getFuzzyMode(quorum, results) {
|
|||||||
return bestResult;
|
return bestResult;
|
||||||
}
|
}
|
||||||
class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
||||||
//readonly providerConfigs!: ReadonlyArray<Required<Readonly<ProviderConfig>>>;
|
|
||||||
quorum;
|
quorum;
|
||||||
eventQuorum;
|
eventQuorum;
|
||||||
eventWorkers;
|
eventWorkers;
|
||||||
@ -169,13 +207,18 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
this.quorum = 2; //Math.ceil(providers.length / 2);
|
this.quorum = 2; //Math.ceil(providers.length / 2);
|
||||||
this.eventQuorum = 1;
|
this.eventQuorum = 1;
|
||||||
this.eventWorkers = 1;
|
this.eventWorkers = 1;
|
||||||
if (this.quorum > this.#configs.reduce((a, c) => (a + c.weight), 0)) {
|
(0, index_js_1.assertArgument)(this.quorum <= this.#configs.reduce((a, c) => (a + c.weight), 0), "quorum exceed provider wieght", "quorum", this.quorum);
|
||||||
(0, index_js_1.throwArgumentError)("quorum exceed provider wieght", "quorum", this.quorum);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// @TOOD: Copy these and only return public values
|
|
||||||
get providerConfigs() {
|
get providerConfigs() {
|
||||||
return this.#configs.slice();
|
return this.#configs.map((c) => {
|
||||||
|
const result = Object.assign({}, c);
|
||||||
|
for (const key in result) {
|
||||||
|
if (key[0] === "_") {
|
||||||
|
delete result[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async _detectNetwork() {
|
async _detectNetwork() {
|
||||||
return network_js_1.Network.from((0, index_js_1.getBigInt)(await this._perform({ method: "chainId" })));
|
return network_js_1.Network.from((0, index_js_1.getBigInt)(await this._perform({ method: "chainId" })));
|
||||||
@ -184,8 +227,52 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
//_getSubscriber(sub: Subscription): Subscriber {
|
//_getSubscriber(sub: Subscription): Subscriber {
|
||||||
// throw new Error("@TODO");
|
// throw new Error("@TODO");
|
||||||
//}
|
//}
|
||||||
// Grab the next (random) config that is not already part of configs
|
async _translatePerform(provider, req) {
|
||||||
#getNextConfig(configs) {
|
switch (req.method) {
|
||||||
|
case "broadcastTransaction":
|
||||||
|
return await provider.broadcastTransaction(req.signedTransaction);
|
||||||
|
case "call":
|
||||||
|
return await provider.call(Object.assign({}, req.transaction, { blockTag: req.blockTag }));
|
||||||
|
case "chainId":
|
||||||
|
return (await provider.getNetwork()).chainId;
|
||||||
|
case "estimateGas":
|
||||||
|
return await provider.estimateGas(req.transaction);
|
||||||
|
case "getBalance":
|
||||||
|
return await provider.getBalance(req.address, req.blockTag);
|
||||||
|
case "getBlock": {
|
||||||
|
const block = ("blockHash" in req) ? req.blockHash : req.blockTag;
|
||||||
|
if (req.includeTransactions) {
|
||||||
|
return await provider.getBlockWithTransactions(block);
|
||||||
|
}
|
||||||
|
return await provider.getBlock(block);
|
||||||
|
}
|
||||||
|
case "getBlockNumber":
|
||||||
|
return await provider.getBlockNumber();
|
||||||
|
case "getCode":
|
||||||
|
return await provider.getCode(req.address, req.blockTag);
|
||||||
|
case "getGasPrice":
|
||||||
|
return (await provider.getFeeData()).gasPrice;
|
||||||
|
case "getLogs":
|
||||||
|
return await provider.getLogs(req.filter);
|
||||||
|
case "getStorage":
|
||||||
|
return await provider.getStorage(req.address, req.position, req.blockTag);
|
||||||
|
case "getTransaction":
|
||||||
|
return await provider.getTransaction(req.hash);
|
||||||
|
case "getTransactionCount":
|
||||||
|
return await provider.getTransactionCount(req.address, req.blockTag);
|
||||||
|
case "getTransactionReceipt":
|
||||||
|
return await provider.getTransactionReceipt(req.hash);
|
||||||
|
case "getTransactionResult":
|
||||||
|
return await provider.getTransactionResult(req.hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Grab the next (random) config that is not already part of
|
||||||
|
// the running set
|
||||||
|
#getNextConfig(running) {
|
||||||
|
// @TODO: Maybe do a check here to favour (heavily) providers that
|
||||||
|
// do not require waitForSync and disfavour providers that
|
||||||
|
// seem down-ish or are behaving slowly
|
||||||
|
const configs = Array.from(running).map((r) => r.config);
|
||||||
// Shuffle the states, sorted by priority
|
// Shuffle the states, sorted by priority
|
||||||
const allConfigs = this.#configs.slice();
|
const allConfigs = this.#configs.slice();
|
||||||
shuffle(allConfigs);
|
shuffle(allConfigs);
|
||||||
@ -199,33 +286,35 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
}
|
}
|
||||||
// Adds a new runner (if available) to running.
|
// Adds a new runner (if available) to running.
|
||||||
#addRunner(running, req) {
|
#addRunner(running, req) {
|
||||||
const config = this.#getNextConfig(Array.from(running).map((r) => r.config));
|
const config = this.#getNextConfig(running);
|
||||||
|
// No runners available
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const result = {};
|
// Create a new runner
|
||||||
const runner = {
|
const runner = {
|
||||||
config, result, didBump: false, done: false,
|
config, result: null, didBump: false,
|
||||||
perform: null, staller: null
|
perform: null, staller: null
|
||||||
};
|
};
|
||||||
const now = getTime();
|
const now = getTime();
|
||||||
|
// Start performing this operation
|
||||||
runner.perform = (async () => {
|
runner.perform = (async () => {
|
||||||
try {
|
try {
|
||||||
config.requests++;
|
config.requests++;
|
||||||
result.result = await config.provider._perform(req);
|
const result = await this._translatePerform(config.provider, req);
|
||||||
|
runner.result = { result };
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
config.errorResponses++;
|
config.errorResponses++;
|
||||||
result.error = error;
|
runner.result = { error };
|
||||||
}
|
|
||||||
if (runner.done) {
|
|
||||||
config.lateResponses++;
|
|
||||||
}
|
}
|
||||||
const dt = (getTime() - now);
|
const dt = (getTime() - now);
|
||||||
config._totalTime += dt;
|
config._totalTime += dt;
|
||||||
config.rollingDuration = 0.95 * config.rollingDuration + 0.05 * dt;
|
config.rollingDuration = 0.95 * config.rollingDuration + 0.05 * dt;
|
||||||
runner.perform = null;
|
runner.perform = null;
|
||||||
})();
|
})();
|
||||||
|
// Start a staller; when this times out, it's time to force
|
||||||
|
// kicking off another runner because we are taking too long
|
||||||
runner.staller = (async () => {
|
runner.staller = (async () => {
|
||||||
await stall(config.stallTimeout);
|
await stall(config.stallTimeout);
|
||||||
runner.staller = null;
|
runner.staller = null;
|
||||||
@ -256,7 +345,7 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
chainId = network.chainId;
|
chainId = network.chainId;
|
||||||
}
|
}
|
||||||
else if (network.chainId !== chainId) {
|
else if (network.chainId !== chainId) {
|
||||||
(0, index_js_1.throwError)("cannot mix providers on different networks", "UNSUPPORTED_OPERATION", {
|
(0, index_js_1.assert)(false, "cannot mix providers on different networks", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "new FallbackProvider"
|
operation: "new FallbackProvider"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -269,13 +358,9 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
// Get all the result objects
|
// Get all the result objects
|
||||||
const results = [];
|
const results = [];
|
||||||
for (const runner of running) {
|
for (const runner of running) {
|
||||||
if ("result" in runner.result) {
|
if (runner.result != null) {
|
||||||
const result = runner.result.result;
|
const { tag, value } = normalizeResult(runner.result);
|
||||||
results.push({
|
results.push({ tag, value, weight: runner.config.weight });
|
||||||
result,
|
|
||||||
normal: normalize(runner.config.provider, result, req),
|
|
||||||
weight: runner.config.weight
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Are there enough results to event meet quorum?
|
// Are there enough results to event meet quorum?
|
||||||
@ -286,13 +371,14 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
case "getBlockNumber": {
|
case "getBlockNumber": {
|
||||||
// We need to get the bootstrap block height
|
// We need to get the bootstrap block height
|
||||||
if (this.#height === -2) {
|
if (this.#height === -2) {
|
||||||
const height = Math.ceil((0, index_js_1.getNumber)(getMedian(this.#configs.map((c) => ({
|
this.#height = Math.ceil((0, index_js_1.getNumber)(getMedian(this.quorum, this.#configs.map((c) => ({
|
||||||
result: c.blockNumber,
|
value: c.blockNumber,
|
||||||
normal: (0, index_js_1.getNumber)(c.blockNumber).toString(),
|
tag: (0, index_js_1.getNumber)(c.blockNumber).toString(),
|
||||||
weight: c.weight
|
weight: c.weight
|
||||||
}))), "%internal"));
|
})))));
|
||||||
this.#height = height;
|
|
||||||
}
|
}
|
||||||
|
// Find the mode across all the providers, allowing for
|
||||||
|
// a little drift between block heights
|
||||||
const mode = getFuzzyMode(this.quorum, results);
|
const mode = getFuzzyMode(this.quorum, results);
|
||||||
if (mode === undefined) {
|
if (mode === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@ -304,14 +390,15 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
}
|
}
|
||||||
case "getGasPrice":
|
case "getGasPrice":
|
||||||
case "estimateGas":
|
case "estimateGas":
|
||||||
return getMedian(results);
|
return getMedian(this.quorum, results);
|
||||||
case "getBlock":
|
case "getBlock":
|
||||||
// Pending blocks are mempool dependant and already
|
// Pending blocks are in the mempool and already
|
||||||
// quite untrustworthy
|
// quite untrustworthy; just grab anything
|
||||||
if ("blockTag" in req && req.blockTag === "pending") {
|
if ("blockTag" in req && req.blockTag === "pending") {
|
||||||
return results[0].result;
|
return getAnyResult(this.quorum, results);
|
||||||
}
|
}
|
||||||
return checkQuorum(this.quorum, results);
|
return checkQuorum(this.quorum, results);
|
||||||
|
case "call":
|
||||||
case "chainId":
|
case "chainId":
|
||||||
case "getBalance":
|
case "getBalance":
|
||||||
case "getTransactionCount":
|
case "getTransactionCount":
|
||||||
@ -321,14 +408,11 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
case "getTransactionReceipt":
|
case "getTransactionReceipt":
|
||||||
case "getLogs":
|
case "getLogs":
|
||||||
return checkQuorum(this.quorum, results);
|
return checkQuorum(this.quorum, results);
|
||||||
case "call":
|
|
||||||
// @TODO: Check errors
|
|
||||||
return checkQuorum(this.quorum, results);
|
|
||||||
case "broadcastTransaction":
|
case "broadcastTransaction":
|
||||||
throw new Error("TODO");
|
throw new Error("TODO");
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwError)("unsupported method", "UNSUPPORTED_OPERATION", {
|
(0, index_js_1.assert)(false, "unsupported method", "UNSUPPORTED_OPERATION", {
|
||||||
operation: `_perform(${JSON.stringify(req.method)})`
|
operation: `_perform(${stringify(req.method)})`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
async #waitForQuorum(running, req) {
|
async #waitForQuorum(running, req) {
|
||||||
@ -338,18 +422,8 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
// Any promises that are interesting to watch for; an expired stall
|
// Any promises that are interesting to watch for; an expired stall
|
||||||
// or a successful perform
|
// or a successful perform
|
||||||
const interesting = [];
|
const interesting = [];
|
||||||
//const results: Array<any> = [ ];
|
|
||||||
//const errors: Array<Error> = [ ];
|
|
||||||
let newRunners = 0;
|
let newRunners = 0;
|
||||||
for (const runner of running) {
|
for (const runner of running) {
|
||||||
// @TODO: use runner.perfom != null
|
|
||||||
/*
|
|
||||||
if ("result" in runner.result) {
|
|
||||||
results.push(runner.result.result);
|
|
||||||
} else if ("error" in runner.result) {
|
|
||||||
errors.push(runner.result.error);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// No responses, yet; keep an eye on it
|
// No responses, yet; keep an eye on it
|
||||||
if (runner.perform) {
|
if (runner.perform) {
|
||||||
interesting.push(runner.perform);
|
interesting.push(runner.perform);
|
||||||
@ -367,17 +441,7 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
runner.didBump = true;
|
runner.didBump = true;
|
||||||
newRunners++;
|
newRunners++;
|
||||||
}
|
}
|
||||||
// Check for quorum
|
// Check if we have reached quorum on a result (or error)
|
||||||
/*
|
|
||||||
console.log({ results, errors } );
|
|
||||||
if (results.length >= this.quorum) {
|
|
||||||
return results[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errors.length >= this.quorum) {
|
|
||||||
return errors[0];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
const value = await this.#checkQuorum(running, req);
|
const value = await this.#checkQuorum(running, req);
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
if (value instanceof Error) {
|
if (value instanceof Error) {
|
||||||
@ -390,25 +454,51 @@ class FallbackProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
for (let i = 0; i < newRunners; i++) {
|
for (let i = 0; i < newRunners; i++) {
|
||||||
this.#addRunner(running, req);
|
this.#addRunner(running, req);
|
||||||
}
|
}
|
||||||
if (interesting.length === 0) {
|
// All providers have returned, and we have no result
|
||||||
throw new Error("quorum not met");
|
(0, index_js_1.assert)(interesting.length > 0, "quorum not met", "SERVER_ERROR", {
|
||||||
// return logger.throwError("failed to meet quorum", "", {
|
request: "%sub-requests",
|
||||||
// });
|
info: { request: req, results: Array.from(running).map((r) => stringify(r.result)) }
|
||||||
}
|
});
|
||||||
// Wait for someone to either complete its perform or trigger a stall
|
// Wait for someone to either complete its perform or stall out
|
||||||
await Promise.race(interesting);
|
await Promise.race(interesting);
|
||||||
|
// This is recursive, but at worst case the depth is 2x the
|
||||||
|
// number of providers (each has a perform and a staller)
|
||||||
return await this.#waitForQuorum(running, req);
|
return await this.#waitForQuorum(running, req);
|
||||||
}
|
}
|
||||||
async _perform(req) {
|
async _perform(req) {
|
||||||
|
// Broadcasting a transaction is rare (ish) and already incurs
|
||||||
|
// a cost on the user, so spamming is safe-ish. Just send it to
|
||||||
|
// every backend.
|
||||||
|
if (req.method === "broadcastTransaction") {
|
||||||
|
const results = await Promise.all(this.#configs.map(async ({ provider, weight }) => {
|
||||||
|
try {
|
||||||
|
const result = await provider._perform(req);
|
||||||
|
return Object.assign(normalizeResult({ result }), { weight });
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
return Object.assign(normalizeResult({ error }), { weight });
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
const result = getAnyResult(this.quorum, results);
|
||||||
|
(0, index_js_1.assert)(result !== undefined, "problem multi-broadcasting", "SERVER_ERROR", {
|
||||||
|
request: "%sub-requests",
|
||||||
|
info: { request: req, results: results.map(stringify) }
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
await this.#initialSync();
|
await this.#initialSync();
|
||||||
// Bootstrap enough to meet quorum
|
// Bootstrap enough runners to meet quorum
|
||||||
const running = new Set();
|
const running = new Set();
|
||||||
for (let i = 0; i < this.quorum; i++) {
|
for (let i = 0; i < this.quorum; i++) {
|
||||||
this.#addRunner(running, req);
|
this.#addRunner(running, req);
|
||||||
}
|
}
|
||||||
const result = this.#waitForQuorum(running, req);
|
const result = await this.#waitForQuorum(running, req);
|
||||||
|
// Track requests sent to a provider that are still
|
||||||
|
// outstanding after quorum has been otherwise found
|
||||||
for (const runner of running) {
|
for (const runner of running) {
|
||||||
runner.done = true;
|
if (runner.perform && runner.result == null) {
|
||||||
|
runner.config.lateResponses++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -28,7 +28,7 @@ function getHost(name) {
|
|||||||
case "optimism-goerli":
|
case "optimism-goerli":
|
||||||
return "optimism-goerli.infura.io";
|
return "optimism-goerli.infura.io";
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwArgumentError)("unsupported network", "network", name);
|
(0, index_js_1.assertArgument)(false, "unsupported network", "network", name);
|
||||||
}
|
}
|
||||||
class InfuraWebSocketProvider extends provider_websocket_js_1.WebSocketProvider {
|
class InfuraWebSocketProvider extends provider_websocket_js_1.WebSocketProvider {
|
||||||
projectId;
|
projectId;
|
||||||
@ -36,11 +36,7 @@ class InfuraWebSocketProvider extends provider_websocket_js_1.WebSocketProvider
|
|||||||
constructor(network, apiKey) {
|
constructor(network, apiKey) {
|
||||||
const provider = new InfuraProvider(network, apiKey);
|
const provider = new InfuraProvider(network, apiKey);
|
||||||
const req = provider._getConnection();
|
const req = provider._getConnection();
|
||||||
if (req.credentials) {
|
(0, index_js_1.assert)(!req.credentials, "INFURA WebSocket project secrets unsupported", "UNSUPPORTED_OPERATION", { operation: "InfuraProvider.getWebSocketProvider()" });
|
||||||
(0, index_js_1.throwError)("INFURA WebSocket project secrets unsupported", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "InfuraProvider.getWebSocketProvider()"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
const url = req.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
|
const url = req.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/");
|
||||||
super(url, network);
|
super(url, network);
|
||||||
(0, index_js_1.defineProperties)(this, {
|
(0, index_js_1.defineProperties)(this, {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"provider-infura.js","sourceRoot":"","sources":["../../src.ts/providers/provider-infura.ts"],"names":[],"mappings":";;;AAAA,gDAE2B;AAE3B,iDAAqD;AACrD,6CAAuC;AACvC,+DAAwD;AACxD,mEAA4D;AAO5D,MAAM,gBAAgB,GAAG,kCAAkC,CAAC;AAE5D,SAAS,OAAO,CAAC,IAAY;IACzB,QAAO,IAAI,EAAE;QACT,KAAK,SAAS;YACV,OAAO,mBAAmB,CAAC;QAC/B,KAAK,QAAQ;YACT,OAAO,kBAAkB,CAAC;QAC9B,KAAK,SAAS;YACV,OAAO,mBAAmB,CAAC;QAE/B,KAAK,UAAU;YACX,OAAO,4BAA4B,CAAC;QACxC,KAAK,iBAAiB;YAClB,OAAO,2BAA2B,CAAC;QACvC,KAAK,OAAO;YACR,OAAO,2BAA2B,CAAC;QACvC,KAAK,UAAU;YACX,OAAO,0BAA0B,CAAC;QACtC,KAAK,UAAU;YACX,OAAO,4BAA4B,CAAC;QACxC,KAAK,iBAAiB;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perties)(this, { address });
|
(0, index_js_5.defineProperties)(this, { address });
|
||||||
}
|
}
|
||||||
connect(provider) {
|
connect(provider) {
|
||||||
return (0, index_js_5.throwError)("cannot reconnect JsonRpcSigner", "UNSUPPORTED_OPERATION", {
|
(0, index_js_5.assert)(false, "cannot reconnect JsonRpcSigner", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "signer.connect"
|
operation: "signer.connect"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -82,9 +82,7 @@ class JsonRpcSigner extends abstract_signer_js_1.AbstractSigner {
|
|||||||
const _from = tx.from;
|
const _from = tx.from;
|
||||||
promises.push((async () => {
|
promises.push((async () => {
|
||||||
const from = await (0, index_js_2.resolveAddress)(_from, this.provider);
|
const from = await (0, index_js_2.resolveAddress)(_from, this.provider);
|
||||||
if (from == null || from.toLowerCase() !== this.address.toLowerCase()) {
|
(0, index_js_5.assertArgument)(from != null && from.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", _tx);
|
||||||
(0, index_js_5.throwArgumentError)("from address mismatch", "transaction", _tx);
|
|
||||||
}
|
|
||||||
tx.from = from;
|
tx.from = from;
|
||||||
})());
|
})());
|
||||||
}
|
}
|
||||||
@ -141,9 +139,7 @@ class JsonRpcSigner extends abstract_signer_js_1.AbstractSigner {
|
|||||||
// Make sure the from matches the sender
|
// Make sure the from matches the sender
|
||||||
if (tx.from) {
|
if (tx.from) {
|
||||||
const from = await (0, index_js_2.resolveAddress)(tx.from, this.provider);
|
const from = await (0, index_js_2.resolveAddress)(tx.from, this.provider);
|
||||||
if (from == null || from.toLowerCase() !== this.address.toLowerCase()) {
|
(0, index_js_5.assertArgument)(from != null && from.toLowerCase() === this.address.toLowerCase(), "from address mismatch", "transaction", _tx);
|
||||||
return (0, index_js_5.throwArgumentError)("from address mismatch", "transaction", _tx);
|
|
||||||
}
|
|
||||||
tx.from = from;
|
tx.from = from;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -163,9 +159,7 @@ class JsonRpcSigner extends abstract_signer_js_1.AbstractSigner {
|
|||||||
// Populate any ENS names (in-place)
|
// Populate any ENS names (in-place)
|
||||||
const populated = await index_js_3.TypedDataEncoder.resolveNames(domain, types, value, async (value) => {
|
const populated = await index_js_3.TypedDataEncoder.resolveNames(domain, types, value, async (value) => {
|
||||||
const address = await (0, index_js_2.resolveAddress)(value);
|
const address = await (0, index_js_2.resolveAddress)(value);
|
||||||
if (address == null) {
|
(0, index_js_5.assertArgument)(address != null, "TypedData does not support null address", "value", value);
|
||||||
return (0, index_js_5.throwArgumentError)("TypedData does not support null address", "value", value);
|
|
||||||
}
|
|
||||||
return address;
|
return address;
|
||||||
});
|
});
|
||||||
return await this.provider.send("eth_signTypedData_v4", [
|
return await this.provider.send("eth_signTypedData_v4", [
|
||||||
@ -281,9 +275,7 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
// This could be relaxed in the future to just check equivalent networks
|
// This could be relaxed in the future to just check equivalent networks
|
||||||
const staticNetwork = this._getOption("staticNetwork");
|
const staticNetwork = this._getOption("staticNetwork");
|
||||||
if (staticNetwork) {
|
if (staticNetwork) {
|
||||||
if (staticNetwork !== network) {
|
(0, index_js_5.assertArgument)(staticNetwork === network, "staticNetwork MUST match network object", "options", options);
|
||||||
(0, index_js_5.throwArgumentError)("staticNetwork MUST match network object", "options", options);
|
|
||||||
}
|
|
||||||
this.#network = staticNetwork;
|
this.#network = staticNetwork;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,9 +292,7 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
* is detected, and if it has changed, the call will reject.
|
* is detected, and if it has changed, the call will reject.
|
||||||
*/
|
*/
|
||||||
get _network() {
|
get _network() {
|
||||||
if (!this.#network) {
|
(0, index_js_5.assert)(this.#network, "network is not available yet", "NETWORK_ERROR");
|
||||||
(0, index_js_5.throwError)("network is not available yet", "NETWORK_ERROR");
|
|
||||||
}
|
|
||||||
return this.#network;
|
return this.#network;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -311,7 +301,7 @@ class JsonRpcApiProvider extends abstract_provider_js_1.AbstractProvider {
|
|||||||
* Sub-classes **MUST** override this.
|
* Sub-classes **MUST** override this.
|
||||||
*/
|
*/
|
||||||
_send(payload) {
|
_send(payload) {
|
||||||
return (0, index_js_5.throwError)("sub-classes must override _send", "UNSUPPORTED_OPERATION", {
|
(0, index_js_5.assert)(false, "sub-classes must override _send", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "jsonRpcApiProvider._send"
|
operation: "jsonRpcApiProvider._send"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -44,11 +44,7 @@ class SocketSubscriber {
|
|||||||
// @TODO: pause should trap the current blockNumber, unsub, and on resume use getLogs
|
// @TODO: pause should trap the current blockNumber, unsub, and on resume use getLogs
|
||||||
// and resume
|
// and resume
|
||||||
pause(dropWhilePaused) {
|
pause(dropWhilePaused) {
|
||||||
if (!dropWhilePaused) {
|
(0, index_js_1.assert)(dropWhilePaused, "preserve logs while paused not supported by SocketSubscriber yet", "UNSUPPORTED_OPERATION", { operation: "pause(false)" });
|
||||||
(0, index_js_1.throwError)("preserve logs while paused not supported by SocketSubscriber yet", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "pause(false)"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.#paused = !!dropWhilePaused;
|
this.#paused = !!dropWhilePaused;
|
||||||
}
|
}
|
||||||
resume() {
|
resume() {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -345,11 +345,7 @@ class TransactionReceipt {
|
|||||||
return createRemovedTransactionFilter(this);
|
return createRemovedTransactionFilter(this);
|
||||||
}
|
}
|
||||||
reorderedEvent(other) {
|
reorderedEvent(other) {
|
||||||
if (other && !other.isMined()) {
|
(0, index_js_1.assert)(!other || other.isMined(), "unmined 'other' transction cannot be orphaned", "UNSUPPORTED_OPERATION", { operation: "reorderedEvent(other)" });
|
||||||
return (0, index_js_1.throwError)("unmined 'other' transction cannot be orphaned", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "reorderedEvent(other)"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return createReorderedTransactionFilter(this, other);
|
return createReorderedTransactionFilter(this, other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -506,7 +502,7 @@ class TransactionResponse {
|
|||||||
else if (tx.data === "0x" && tx.from === tx.to && tx.value === BN_0) {
|
else if (tx.data === "0x" && tx.from === tx.to && tx.value === BN_0) {
|
||||||
reason = "cancelled";
|
reason = "cancelled";
|
||||||
}
|
}
|
||||||
(0, index_js_1.throwError)("transaction was replaced", "TRANSACTION_REPLACED", {
|
(0, index_js_1.assert)(false, "transaction was replaced", "TRANSACTION_REPLACED", {
|
||||||
cancelled: (reason === "replaced" || reason === "cancelled"),
|
cancelled: (reason === "replaced" || reason === "cancelled"),
|
||||||
reason,
|
reason,
|
||||||
replacement: tx.replaceableTransaction(startBlock),
|
replacement: tx.replaceableTransaction(startBlock),
|
||||||
@ -593,24 +589,12 @@ class TransactionResponse {
|
|||||||
return (this.type === 2);
|
return (this.type === 2);
|
||||||
}
|
}
|
||||||
removedEvent() {
|
removedEvent() {
|
||||||
if (!this.isMined()) {
|
(0, index_js_1.assert)(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });
|
||||||
return (0, index_js_1.throwError)("unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "removeEvent()"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return createRemovedTransactionFilter(this);
|
return createRemovedTransactionFilter(this);
|
||||||
}
|
}
|
||||||
reorderedEvent(other) {
|
reorderedEvent(other) {
|
||||||
if (!this.isMined()) {
|
(0, index_js_1.assert)(this.isMined(), "unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });
|
||||||
return (0, index_js_1.throwError)("unmined transaction canot be orphaned", "UNSUPPORTED_OPERATION", {
|
(0, index_js_1.assert)(!other || other.isMined(), "unmined 'other' transaction canot be orphaned", "UNSUPPORTED_OPERATION", { operation: "removeEvent()" });
|
||||||
operation: "removeEvent()"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (other && !other.isMined()) {
|
|
||||||
return (0, index_js_1.throwError)("unmined 'other' transaction canot be orphaned", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "removeEvent()"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return createReorderedTransactionFilter(this, other);
|
return createReorderedTransactionFilter(this, other);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
File diff suppressed because one or more lines are too long
@ -84,7 +84,6 @@ class FilterIdEventSubscriber extends FilterIdSubscriber {
|
|||||||
}
|
}
|
||||||
async _subscribe(provider) {
|
async _subscribe(provider) {
|
||||||
const filterId = await provider.send("eth_newFilter", [this.#event]);
|
const filterId = await provider.send("eth_newFilter", [this.#event]);
|
||||||
console.log("____SUB", filterId);
|
|
||||||
return filterId;
|
return filterId;
|
||||||
}
|
}
|
||||||
async _emitResults(provider, results) {
|
async _emitResults(provider, results) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"subscriber-filterid.js","sourceRoot":"","sources":["../../src.ts/providers/subscriber-filterid.ts"],"names":[],"mappings":";;;AAAA,mEAAiE;AAQjE,SAAS,IAAI,CAAC,GAAQ;IAClB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAa,kBAAkB;IAC3B,SAAS,CAAqB;IAE9B,gBAAgB,CAAyB;IACzC,OAAO,CAA+B;IAEtC,QAAQ,CAAiB;IAEzB,YAAY,QAA4B;QACpC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,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 function getPollingSubscriber(provider, event) {
|
|||||||
if ((0, index_js_1.isHexString)(event, 32)) {
|
if ((0, index_js_1.isHexString)(event, 32)) {
|
||||||
return new PollingTransactionSubscriber(provider, event);
|
return new PollingTransactionSubscriber(provider, event);
|
||||||
}
|
}
|
||||||
return (0, index_js_1.throwError)("unsupported polling event", "UNSUPPORTED_OPERATION", {
|
(0, index_js_1.assert)(false, "unsupported polling event", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "getPollingSubscriber", info: { event }
|
operation: "getPollingSubscriber", info: { event }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -23,7 +23,7 @@ function handleData(value, param) {
|
|||||||
return (0, index_js_3.hexlify)(value);
|
return (0, index_js_3.hexlify)(value);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return (0, index_js_3.throwArgumentError)("invalid data", param, value);
|
(0, index_js_3.assertArgument)(false, "invalid data", param, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleAccessList(value, param) {
|
function handleAccessList(value, param) {
|
||||||
@ -31,7 +31,7 @@ function handleAccessList(value, param) {
|
|||||||
return (0, accesslist_js_1.accessListify)(value);
|
return (0, accesslist_js_1.accessListify)(value);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return (0, index_js_3.throwArgumentError)("invalid accessList", param, value);
|
(0, index_js_3.assertArgument)(false, "invalid accessList", param, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleNumber(_value, param) {
|
function handleNumber(_value, param) {
|
||||||
@ -45,17 +45,13 @@ function handleUint(_value, param) {
|
|||||||
return BN_0;
|
return BN_0;
|
||||||
}
|
}
|
||||||
const value = (0, index_js_3.getBigInt)(_value, param);
|
const value = (0, index_js_3.getBigInt)(_value, param);
|
||||||
if (value > BN_MAX_UINT) {
|
(0, index_js_3.assertArgument)(value <= BN_MAX_UINT, "value exceeds uint size", param, value);
|
||||||
(0, index_js_3.throwArgumentError)("value exceeds uint size", param, value);
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
function formatNumber(_value, name) {
|
function formatNumber(_value, name) {
|
||||||
const value = (0, index_js_3.getBigInt)(_value, "value");
|
const value = (0, index_js_3.getBigInt)(_value, "value");
|
||||||
const result = (0, index_js_3.toArray)(value);
|
const result = (0, index_js_3.toArray)(value);
|
||||||
if (result.length > 32) {
|
(0, index_js_3.assertArgument)(result.length <= 32, `value too large`, `tx.${name}`, value);
|
||||||
(0, index_js_3.throwArgumentError)(`value too large`, `tx.${name}`, value);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
function formatAccessList(value) {
|
function formatAccessList(value) {
|
||||||
@ -63,9 +59,7 @@ function formatAccessList(value) {
|
|||||||
}
|
}
|
||||||
function _parseLegacy(data) {
|
function _parseLegacy(data) {
|
||||||
const fields = (0, index_js_3.decodeRlp)(data);
|
const fields = (0, index_js_3.decodeRlp)(data);
|
||||||
if (!Array.isArray(fields) || (fields.length !== 9 && fields.length !== 6)) {
|
(0, index_js_3.assertArgument)(Array.isArray(fields) && (fields.length === 9 || fields.length === 6), "invalid field count for legacy transaction", "data", data);
|
||||||
return (0, index_js_3.throwArgumentError)("invalid field count for legacy transaction", "data", data);
|
|
||||||
}
|
|
||||||
const tx = {
|
const tx = {
|
||||||
type: 0,
|
type: 0,
|
||||||
nonce: handleNumber(fields[0], "nonce"),
|
nonce: handleNumber(fields[0], "nonce"),
|
||||||
@ -95,9 +89,7 @@ function _parseLegacy(data) {
|
|||||||
}
|
}
|
||||||
tx.chainId = chainId;
|
tx.chainId = chainId;
|
||||||
// Signed Legacy Transaction
|
// Signed Legacy Transaction
|
||||||
if (chainId === BN_0 && (v < BN_27 || v > BN_28)) {
|
(0, index_js_3.assertArgument)(chainId !== BN_0 || (v === BN_27 || v === BN_28), "non-canonical legacy v", "v", fields[6]);
|
||||||
(0, index_js_3.throwArgumentError)("non-canonical legacy v", "v", fields[6]);
|
|
||||||
}
|
|
||||||
tx.signature = index_js_2.Signature.from({
|
tx.signature = index_js_2.Signature.from({
|
||||||
r: (0, index_js_3.zeroPadValue)(fields[7], 32),
|
r: (0, index_js_3.zeroPadValue)(fields[7], 32),
|
||||||
s: (0, index_js_3.zeroPadValue)(fields[8], 32),
|
s: (0, index_js_3.zeroPadValue)(fields[8], 32),
|
||||||
@ -122,9 +114,7 @@ function _serializeLegacy(tx, sig) {
|
|||||||
chainId = (0, index_js_3.getBigInt)(tx.chainId, "tx.chainId");
|
chainId = (0, index_js_3.getBigInt)(tx.chainId, "tx.chainId");
|
||||||
// We have a chainId in the tx and an EIP-155 v in the signature,
|
// We have a chainId in the tx and an EIP-155 v in the signature,
|
||||||
// make sure they agree with each other
|
// make sure they agree with each other
|
||||||
if (sig && sig.networkV != null && sig.legacyChainId !== chainId) {
|
(0, index_js_3.assertArgument)(!sig || sig.networkV == null || sig.legacyChainId === chainId, "tx.chainId/sig.v mismatch", "sig", sig);
|
||||||
(0, index_js_3.throwArgumentError)("tx.chainId/sig.v mismatch", "sig", sig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (sig) {
|
else if (sig) {
|
||||||
// No chainId provided, but the signature is signing with EIP-155; derive chainId
|
// No chainId provided, but the signature is signing with EIP-155; derive chainId
|
||||||
@ -149,7 +139,7 @@ function _serializeLegacy(tx, sig) {
|
|||||||
v = index_js_2.Signature.getChainIdV(chainId, sig.v);
|
v = index_js_2.Signature.getChainIdV(chainId, sig.v);
|
||||||
}
|
}
|
||||||
else if (BigInt(sig.v) !== v) {
|
else if (BigInt(sig.v) !== v) {
|
||||||
(0, index_js_3.throwArgumentError)("tx.chainId/sig.v mismatch", "sig", sig);
|
(0, index_js_3.assertArgument)(false, "tx.chainId/sig.v mismatch", "sig", sig);
|
||||||
}
|
}
|
||||||
fields.push((0, index_js_3.toArray)(v));
|
fields.push((0, index_js_3.toArray)(v));
|
||||||
fields.push((0, index_js_3.toArray)(sig.r));
|
fields.push((0, index_js_3.toArray)(sig.r));
|
||||||
@ -165,7 +155,7 @@ function _parseEipSignature(tx, fields, serialize) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return (0, index_js_3.throwArgumentError)("invalid yParity", "yParity", fields[0]);
|
(0, index_js_3.assertArgument)(false, "invalid yParity", "yParity", fields[0]);
|
||||||
}
|
}
|
||||||
const r = (0, index_js_3.zeroPadValue)(fields[1], 32);
|
const r = (0, index_js_3.zeroPadValue)(fields[1], 32);
|
||||||
const s = (0, index_js_3.zeroPadValue)(fields[2], 32);
|
const s = (0, index_js_3.zeroPadValue)(fields[2], 32);
|
||||||
@ -174,9 +164,7 @@ function _parseEipSignature(tx, fields, serialize) {
|
|||||||
}
|
}
|
||||||
function _parseEip1559(data) {
|
function _parseEip1559(data) {
|
||||||
const fields = (0, index_js_3.decodeRlp)((0, index_js_3.getBytes)(data).slice(1));
|
const fields = (0, index_js_3.decodeRlp)((0, index_js_3.getBytes)(data).slice(1));
|
||||||
if (!Array.isArray(fields) || (fields.length !== 9 && fields.length !== 12)) {
|
(0, index_js_3.assertArgument)(Array.isArray(fields) && (fields.length === 9 || fields.length === 12), "invalid field count for transaction type: 2", "data", (0, index_js_3.hexlify)(data));
|
||||||
(0, index_js_3.throwArgumentError)("invalid field count for transaction type: 2", "data", (0, index_js_3.hexlify)(data));
|
|
||||||
}
|
|
||||||
const maxPriorityFeePerGas = handleUint(fields[2], "maxPriorityFeePerGas");
|
const maxPriorityFeePerGas = handleUint(fields[2], "maxPriorityFeePerGas");
|
||||||
const maxFeePerGas = handleUint(fields[3], "maxFeePerGas");
|
const maxFeePerGas = handleUint(fields[3], "maxFeePerGas");
|
||||||
const tx = {
|
const tx = {
|
||||||
@ -221,9 +209,7 @@ function _serializeEip1559(tx, sig) {
|
|||||||
}
|
}
|
||||||
function _parseEip2930(data) {
|
function _parseEip2930(data) {
|
||||||
const fields = (0, index_js_3.decodeRlp)((0, index_js_3.getBytes)(data).slice(1));
|
const fields = (0, index_js_3.decodeRlp)((0, index_js_3.getBytes)(data).slice(1));
|
||||||
if (!Array.isArray(fields) || (fields.length !== 8 && fields.length !== 11)) {
|
(0, index_js_3.assertArgument)(Array.isArray(fields) && (fields.length === 8 || fields.length === 11), "invalid field count for transaction type: 1", "data", (0, index_js_3.hexlify)(data));
|
||||||
(0, index_js_3.throwArgumentError)("invalid field count for transaction type: 1", "data", (0, index_js_3.hexlify)(data));
|
|
||||||
}
|
|
||||||
const tx = {
|
const tx = {
|
||||||
type: 1,
|
type: 1,
|
||||||
chainId: handleUint(fields[0], "chainId"),
|
chainId: handleUint(fields[0], "chainId"),
|
||||||
|
File diff suppressed because one or more lines are too long
@ -14,9 +14,7 @@ function getAlpha(letter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const result = Lookup[letter];
|
const result = Lookup[letter];
|
||||||
if (result == null) {
|
(0, errors_js_1.assertArgument)(result != null, `invalid base58 value`, "letter", letter);
|
||||||
(0, errors_js_1.throwArgumentError)(`invalid base58 value`, "letter", letter);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
const BN_0 = BigInt(0);
|
const BN_0 = BigInt(0);
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"base58.js","sourceRoot":"","sources":["../../src.ts/utils/base58.ts"],"names":[],"mappings":";;;AACA,uCAAqC;AACrC,2CAAiD;AACjD,yCAA6C;AAK7C,MAAM,QAAQ,GAAG,4DAA4D,CAAC;AAC9E,IAAI,MAAM,GAAkC,IAAI,CAAC;AAEjD,SAAS,QAAQ,CAAC,MAAc;IAC5B,IAAI,MAAM,IAAI,IAAI,EAAE;QAChB,MAAM,GAAG,EAAG,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,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,CAAC;QAChB,MAAM,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO,IAAA,kBAAQ,EAAC,IAAA,gBAAK,EAAC,MAAM,CAAC,CAAC,CAAC;AACnC,CAAC;AAPD,oCAOC"}
|
@ -18,7 +18,7 @@ function _getBytes(value, name, copy) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return (0, errors_js_1.throwArgumentError)("invalid BytesLike value", name || "value", value);
|
(0, errors_js_1.assertArgument)(false, "invalid BytesLike value", name || "value", value);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get a typed Uint8Array for %%value%%. If already a Uint8Array
|
* Get a typed Uint8Array for %%value%%. If already a Uint8Array
|
||||||
@ -114,7 +114,7 @@ exports.dataLength = dataLength;
|
|||||||
function dataSlice(data, start, end) {
|
function dataSlice(data, start, end) {
|
||||||
const bytes = getBytes(data);
|
const bytes = getBytes(data);
|
||||||
if (end != null && end > bytes.length) {
|
if (end != null && end > bytes.length) {
|
||||||
(0, errors_js_1.throwError)("cannot slice beyond data bounds", "BUFFER_OVERRUN", {
|
(0, errors_js_1.assert)(false, "cannot slice beyond data bounds", "BUFFER_OVERRUN", {
|
||||||
buffer: bytes, length: bytes.length, offset: end
|
buffer: bytes, length: bytes.length, offset: end
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -135,13 +135,11 @@ function stripZerosLeft(data) {
|
|||||||
exports.stripZerosLeft = stripZerosLeft;
|
exports.stripZerosLeft = stripZerosLeft;
|
||||||
function zeroPad(data, length, left) {
|
function zeroPad(data, length, left) {
|
||||||
const bytes = getBytes(data);
|
const bytes = getBytes(data);
|
||||||
if (length < bytes.length) {
|
(0, errors_js_1.assert)(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", {
|
||||||
(0, errors_js_1.throwError)("padding exceeds data length", "BUFFER_OVERRUN", {
|
|
||||||
buffer: new Uint8Array(bytes),
|
buffer: new Uint8Array(bytes),
|
||||||
length: length,
|
length: length,
|
||||||
offset: length + 1
|
offset: length + 1
|
||||||
});
|
});
|
||||||
}
|
|
||||||
const result = new Uint8Array(length);
|
const result = new Uint8Array(length);
|
||||||
result.fill(0);
|
result.fill(0);
|
||||||
if (left) {
|
if (left) {
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src.ts/utils/data.ts"],"names":[],"mappings":";;;AAAA,2CAA6D;AAK7D,SAAS,SAAS,CAAC,KAAgB,EAAE,IAAa,EAAE,IAAc;IAC9D,IAAI,KAAK,YAAY,UAAU,EAAE;QAC7B,IAAI,IAAI,EAAE;YAAE,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;SAAE;QAC3C,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,OAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE;QACvE,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9D,MAAM,IAAI,CAAC,CAAC;SACf;QACD,OAAO,MAAM,CAAC;KACjB;IAED,OAAO,IAAA,8BAAkB,EAAC,yBAAyB,EAAE,IAAI,IAAI,OAAO,EAAE,KAAK,CAAC,CAAC;AACjF,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,KAAgB,EAAE,IAAa;IACpD,OAAO,SAAS,CAAC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AE,MAAc;IACxD,OAAO,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAFD,oCAEC"}
|
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.assertPrivate = exports.assertNormalize = exports.assertArgumentCount = exports.assertArgument = exports.throwArgumentError = exports.throwError = exports.makeError = exports.isCallException = exports.isError = void 0;
|
exports.assertPrivate = exports.assertNormalize = exports.assertArgumentCount = exports.assertArgument = exports.assert = exports.makeError = exports.isCallException = exports.isError = void 0;
|
||||||
const _version_js_1 = require("../_version.js");
|
const _version_js_1 = require("../_version.js");
|
||||||
const properties_js_1 = require("./properties.js");
|
const properties_js_1 = require("./properties.js");
|
||||||
// The type of error to use for various error codes
|
// The type of error to use for various error codes
|
||||||
@ -83,25 +83,16 @@ function makeError(message, code, info) {
|
|||||||
exports.makeError = makeError;
|
exports.makeError = makeError;
|
||||||
/**
|
/**
|
||||||
* Throws an EthersError with %%message%%, %%code%% and additional error
|
* Throws an EthersError with %%message%%, %%code%% and additional error
|
||||||
* info.
|
* %%info%% when %%check%% is falsish..
|
||||||
*
|
*
|
||||||
* @see [[api:makeError]]
|
* @see [[api:makeError]]
|
||||||
*/
|
*/
|
||||||
function throwError(message, code, info) {
|
function assert(check, message, code, info) {
|
||||||
|
if (!check) {
|
||||||
throw makeError(message, code, info);
|
throw makeError(message, code, info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.throwError = throwError;
|
exports.assert = assert;
|
||||||
/**
|
|
||||||
* Throws an [[api:ArgumentError]] with %%message%% for the parameter with
|
|
||||||
* %%name%% and the %%value%%.
|
|
||||||
*/
|
|
||||||
function throwArgumentError(message, name, value) {
|
|
||||||
return throwError(message, "INVALID_ARGUMENT", {
|
|
||||||
argument: name,
|
|
||||||
value: value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.throwArgumentError = throwArgumentError;
|
|
||||||
/**
|
/**
|
||||||
* A simple helper to simply ensuring provided arguments match expected
|
* A simple helper to simply ensuring provided arguments match expected
|
||||||
* constraints, throwing if not.
|
* constraints, throwing if not.
|
||||||
@ -110,27 +101,21 @@ exports.throwArgumentError = throwArgumentError;
|
|||||||
* any further code does not need additional compile-time checks.
|
* any further code does not need additional compile-time checks.
|
||||||
*/
|
*/
|
||||||
function assertArgument(check, message, name, value) {
|
function assertArgument(check, message, name, value) {
|
||||||
if (!check) {
|
assert(check, message, "INVALID_ARGUMENT", { argument: name, value: value });
|
||||||
throwArgumentError(message, name, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.assertArgument = assertArgument;
|
exports.assertArgument = assertArgument;
|
||||||
function assertArgumentCount(count, expectedCount, message = "") {
|
function assertArgumentCount(count, expectedCount, message = "") {
|
||||||
if (message) {
|
if (message) {
|
||||||
message = ": " + message;
|
message = ": " + message;
|
||||||
}
|
}
|
||||||
if (count < expectedCount) {
|
assert(count >= expectedCount, "missing arguemnt" + message, "MISSING_ARGUMENT", {
|
||||||
throwError("missing arguemnt" + message, "MISSING_ARGUMENT", {
|
|
||||||
count: count,
|
count: count,
|
||||||
expectedCount: expectedCount
|
expectedCount: expectedCount
|
||||||
});
|
});
|
||||||
}
|
assert(count <= expectedCount, "too many arguemnts" + message, "UNEXPECTED_ARGUMENT", {
|
||||||
if (count > expectedCount) {
|
|
||||||
throwError("too many arguemnts" + message, "UNEXPECTED_ARGUMENT", {
|
|
||||||
count: count,
|
count: count,
|
||||||
expectedCount: expectedCount
|
expectedCount: expectedCount
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.assertArgumentCount = assertArgumentCount;
|
exports.assertArgumentCount = assertArgumentCount;
|
||||||
const _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
const _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
||||||
@ -160,11 +145,9 @@ const _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => {
|
|||||||
* Throws if the normalization %%form%% is not supported.
|
* Throws if the normalization %%form%% is not supported.
|
||||||
*/
|
*/
|
||||||
function assertNormalize(form) {
|
function assertNormalize(form) {
|
||||||
if (_normalizeForms.indexOf(form) === -1) {
|
assert(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", {
|
||||||
throwError("platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "String.prototype.normalize", info: { form }
|
operation: "String.prototype.normalize", info: { form }
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.assertNormalize = assertNormalize;
|
exports.assertNormalize = assertNormalize;
|
||||||
/**
|
/**
|
||||||
@ -180,7 +163,7 @@ function assertPrivate(givenGuard, guard, className = "") {
|
|||||||
method += ".";
|
method += ".";
|
||||||
operation += " " + className;
|
operation += " " + className;
|
||||||
}
|
}
|
||||||
throwError(`private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", {
|
assert(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", {
|
||||||
operation
|
operation
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src.ts/utils/errors.ts"],"names":[],"mappings":";;;AAAA,gDAAyC;AAEzC,mDAAiD;AAWjD,mDAAmD;AACnD,MAAM,iBAAiB,GAAyD,EAAG,CAAC;AACpF,iBAAiB,CAAC,gBAAgB,GAAG,SAAS,CAAC;AAC/C,iBAAiB,CAAC,aAAa,GAAG,UAAU,CAAC;AAC7C,iBAAiB,CAAC,cAAc,GAAG,UAAU,CAAC;AAkO9C;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,OAAO,CAAqD,KAAU,EAAE,IAAO;IAC3F,OAAO,CAAC,KAAK,IAAkB,KA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AAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAClD,qBAAqB;YACrB,IAAI,KAAK,KAAK,QAAQ,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAA;aAAE;YACrD,oBAAoB;SACvB;QAED,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpB;IAAC,OAAM,KAAK,EAAE,GAAG;IAElB,OAAO,KAAK,CAAC;AACjB,CAAC,EAAiB,EAAE,CAAC,CAAC;AAEtB;;GAEG;AACH,SAAgB,eAAe,CAAC,IAAY;IACxC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,6CAA6C,EAAE,uBAAuB,EAAE;QAC/G,SAAS,EAAE,4BAA4B,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE;KAC1D,CAAC,CAAC;AACP,CAAC;AAJD,0CAIC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,UAAe,EAAE,KAAU,EAAE,YAAoB,EAAE;IAC7E,IAAI,UAAU,KAAK,KAAK,EAAE;QACtB,IAAI,MAAM,GAAG,SAAS,EAAE,SAAS,GAAG,KAAK,CAAC;QAC1C,IAAI,SAAS,EAAE;YACX,MAAM,IAAI,GAAG,CAAC;YACd,SAAS,IAAI,GAAG,GAAG,SAAS,CAAC;SAChC;QACD,MAAM,CAAC,KAAK,EAAE,4BAA6B,MAAO,eAAe,EAAE,uBAAuB,EAAE;YACxF,SAAS;SACZ,CAAC,CAAC;KACN;AACL,CAAC;AAXD,sCAWC"}
|
@ -73,11 +73,9 @@ class FetchCancelSignal {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
addListener(listener) {
|
addListener(listener) {
|
||||||
if (this.#cancelled) {
|
(0, errors_js_1.assert)(this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
|
||||||
(0, errors_js_1.throwError)("singal already cancelled", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "fetchCancelSignal.addCancelListener"
|
operation: "fetchCancelSignal.addCancelListener"
|
||||||
});
|
});
|
||||||
}
|
|
||||||
this.#listeners.push(listener);
|
this.#listeners.push(listener);
|
||||||
}
|
}
|
||||||
get cancelled() { return this.#cancelled; }
|
get cancelled() { return this.#cancelled; }
|
||||||
@ -85,7 +83,7 @@ class FetchCancelSignal {
|
|||||||
if (!this.cancelled) {
|
if (!this.cancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(0, errors_js_1.throwError)("cancelled", "CANCELLED", {});
|
(0, errors_js_1.assert)(false, "cancelled", "CANCELLED", {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.FetchCancelSignal = FetchCancelSignal;
|
exports.FetchCancelSignal = FetchCancelSignal;
|
||||||
@ -263,9 +261,7 @@ class FetchRequest {
|
|||||||
* Sets an ``Authorization`` for %%username%% with %%password%%.
|
* Sets an ``Authorization`` for %%username%% with %%password%%.
|
||||||
*/
|
*/
|
||||||
setCredentials(username, password) {
|
setCredentials(username, password) {
|
||||||
if (username.match(/:/)) {
|
(0, errors_js_1.assertArgument)(!username.match(/:/), "invalid basic authentication username", "username", "[REDACTED]");
|
||||||
(0, errors_js_1.throwArgumentError)("invalid basic authentication username", "username", "[REDACTED]");
|
|
||||||
}
|
|
||||||
this.#creds = `${username}:${password}`;
|
this.#creds = `${username}:${password}`;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -357,11 +353,9 @@ class FetchRequest {
|
|||||||
if (attempt >= this.#throttle.maxAttempts) {
|
if (attempt >= this.#throttle.maxAttempts) {
|
||||||
return _response.makeServerError("exceeded maximum retry limit");
|
return _response.makeServerError("exceeded maximum retry limit");
|
||||||
}
|
}
|
||||||
if (getTime() > expires) {
|
(0, errors_js_1.assert)(getTime() <= expires, "timeout", "TIMEOUT", {
|
||||||
return (0, errors_js_1.throwError)("timeout", "TIMEOUT", {
|
|
||||||
operation: "request.send", reason: "timeout", request: _request
|
operation: "request.send", reason: "timeout", request: _request
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
await wait(delay);
|
await wait(delay);
|
||||||
}
|
}
|
||||||
@ -441,9 +435,7 @@ class FetchRequest {
|
|||||||
* Resolves to the response by sending the request.
|
* Resolves to the response by sending the request.
|
||||||
*/
|
*/
|
||||||
send() {
|
send() {
|
||||||
if (this.#signal != null) {
|
(0, errors_js_1.assert)(this.#signal == null, "request already sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.send" });
|
||||||
return (0, errors_js_1.throwError)("request already sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.send" });
|
|
||||||
}
|
|
||||||
this.#signal = new FetchCancelSignal(this);
|
this.#signal = new FetchCancelSignal(this);
|
||||||
return this.#send(0, getTime() + this.timeout, 0, this, new FetchResponse(0, "", {}, null, this));
|
return this.#send(0, getTime() + this.timeout, 0, this, new FetchResponse(0, "", {}, null, this));
|
||||||
}
|
}
|
||||||
@ -452,9 +444,7 @@ class FetchRequest {
|
|||||||
* error to be rejected from the [[send]].
|
* error to be rejected from the [[send]].
|
||||||
*/
|
*/
|
||||||
cancel() {
|
cancel() {
|
||||||
if (this.#signal == null) {
|
(0, errors_js_1.assert)(this.#signal != null, "request has not been sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.cancel" });
|
||||||
return (0, errors_js_1.throwError)("request has not been sent", "UNSUPPORTED_OPERATION", { operation: "fetchRequest.cancel" });
|
|
||||||
}
|
|
||||||
const signal = fetchSignals.get(this);
|
const signal = fetchSignals.get(this);
|
||||||
if (!signal) {
|
if (!signal) {
|
||||||
throw new Error("missing signal; should not happen");
|
throw new Error("missing signal; should not happen");
|
||||||
@ -473,11 +463,9 @@ class FetchRequest {
|
|||||||
// - non-GET requests
|
// - non-GET requests
|
||||||
// - downgrading the security (e.g. https => http)
|
// - downgrading the security (e.g. https => http)
|
||||||
// - to non-HTTP (or non-HTTPS) protocols [this could be relaxed?]
|
// - to non-HTTP (or non-HTTPS) protocols [this could be relaxed?]
|
||||||
if (this.method !== "GET" || (current === "https" && target === "http") || !location.match(/^https?:/)) {
|
(0, errors_js_1.assert)(this.method === "GET" && (current !== "https" || target !== "http") && location.match(/^https?:/), `unsupported redirect`, "UNSUPPORTED_OPERATION", {
|
||||||
return (0, errors_js_1.throwError)(`unsupported redirect`, "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: `redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(location)})`
|
operation: `redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(location)})`
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// Create a copy of this request, with a new URL
|
// Create a copy of this request, with a new URL
|
||||||
const req = new FetchRequest(location);
|
const req = new FetchRequest(location);
|
||||||
req.method = "GET";
|
req.method = "GET";
|
||||||
@ -601,7 +589,7 @@ class FetchResponse {
|
|||||||
return (this.#body == null) ? "" : (0, utf8_js_1.toUtf8String)(this.#body);
|
return (this.#body == null) ? "" : (0, utf8_js_1.toUtf8String)(this.#body);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return (0, errors_js_1.throwError)("response body is not valid UTF-8 data", "UNSUPPORTED_OPERATION", {
|
(0, errors_js_1.assert)(false, "response body is not valid UTF-8 data", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "bodyText", info: { response: this }
|
operation: "bodyText", info: { response: this }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -616,7 +604,7 @@ class FetchResponse {
|
|||||||
return JSON.parse(this.bodyText);
|
return JSON.parse(this.bodyText);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
return (0, errors_js_1.throwError)("response body is not valid JSON", "UNSUPPORTED_OPERATION", {
|
(0, errors_js_1.assert)(false, "response body is not valid JSON", "UNSUPPORTED_OPERATION", {
|
||||||
operation: "bodyJson", info: { response: this }
|
operation: "bodyJson", info: { response: this }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -674,8 +662,8 @@ class FetchResponse {
|
|||||||
if (stall == null) {
|
if (stall == null) {
|
||||||
stall = -1;
|
stall = -1;
|
||||||
}
|
}
|
||||||
else if (typeof (stall) !== "number" || !Number.isInteger(stall) || stall < 0) {
|
else {
|
||||||
return (0, errors_js_1.throwArgumentError)("invalid stall timeout", "stall", stall);
|
(0, errors_js_1.assertArgument)(Number.isInteger(stall) && stall >= 0, "invalid stall timeout", "stall", stall);
|
||||||
}
|
}
|
||||||
const error = new Error(message || "throttling requests");
|
const error = new Error(message || "throttling requests");
|
||||||
(0, properties_js_1.defineProperties)(error, { stall, throttle: true });
|
(0, properties_js_1.defineProperties)(error, { stall, throttle: true });
|
||||||
@ -714,7 +702,7 @@ class FetchResponse {
|
|||||||
if (message === "") {
|
if (message === "") {
|
||||||
message = `server response ${this.statusCode} ${this.statusMessage}`;
|
message = `server response ${this.statusCode} ${this.statusMessage}`;
|
||||||
}
|
}
|
||||||
(0, errors_js_1.throwError)(message, "SERVER_ERROR", {
|
(0, errors_js_1.assert)(false, message, "SERVER_ERROR", {
|
||||||
request: (this.request || "unknown request"), response: this, error
|
request: (this.request || "unknown request"), response: this, error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -4,14 +4,14 @@ exports.FixedNumber = exports.FixedFormat = exports.parseFixed = exports.formatF
|
|||||||
const data_js_1 = require("./data.js");
|
const data_js_1 = require("./data.js");
|
||||||
const errors_js_1 = require("./errors.js");
|
const errors_js_1 = require("./errors.js");
|
||||||
const maths_js_1 = require("./maths.js");
|
const maths_js_1 = require("./maths.js");
|
||||||
const _constructorGuard = {};
|
const _guard = {};
|
||||||
const NegativeOne = BigInt(-1);
|
const NegativeOne = BigInt(-1);
|
||||||
function throwFault(message, fault, operation, value) {
|
function throwFault(message, fault, operation, value) {
|
||||||
const params = { fault: fault, operation: operation };
|
const params = { fault: fault, operation: operation };
|
||||||
if (value !== undefined) {
|
if (value !== undefined) {
|
||||||
params.value = value;
|
params.value = value;
|
||||||
}
|
}
|
||||||
return (0, errors_js_1.throwError)(message, "NUMERIC_FAULT", params);
|
(0, errors_js_1.assert)(false, message, "NUMERIC_FAULT", params);
|
||||||
}
|
}
|
||||||
// Constant to pull zeros from for multipliers
|
// Constant to pull zeros from for multipliers
|
||||||
let zeros = "0";
|
let zeros = "0";
|
||||||
@ -20,9 +20,7 @@ while (zeros.length < 256) {
|
|||||||
}
|
}
|
||||||
// Returns a string "1" followed by decimal "0"s
|
// Returns a string "1" followed by decimal "0"s
|
||||||
function getMultiplier(decimals) {
|
function getMultiplier(decimals) {
|
||||||
if (typeof (decimals) !== "number" || decimals < 0 || decimals > 256 || decimals % 1) {
|
(0, errors_js_1.assertArgument)(Number.isInteger(decimals) && decimals >= 0 && decimals <= 256, "invalid decimal length", "decimals", decimals);
|
||||||
(0, errors_js_1.throwArgumentError)("invalid decimal length", "decimals", decimals);
|
|
||||||
}
|
|
||||||
return BigInt("1" + zeros.substring(0, decimals));
|
return BigInt("1" + zeros.substring(0, decimals));
|
||||||
}
|
}
|
||||||
function formatFixed(_value, _decimals) {
|
function formatFixed(_value, _decimals) {
|
||||||
@ -62,22 +60,16 @@ function parseFixed(value, _decimals) {
|
|||||||
}
|
}
|
||||||
const decimals = (0, maths_js_1.getNumber)(_decimals, "decimals");
|
const decimals = (0, maths_js_1.getNumber)(_decimals, "decimals");
|
||||||
const multiplier = getMultiplier(decimals);
|
const multiplier = getMultiplier(decimals);
|
||||||
if (typeof (value) !== "string" || !value.match(/^-?[0-9.]+$/)) {
|
(0, errors_js_1.assertArgument)(typeof (value) === "string" && value.match(/^-?[0-9.]+$/), "invalid decimal value", "value", value);
|
||||||
(0, errors_js_1.throwArgumentError)("invalid decimal value", "value", value);
|
|
||||||
}
|
|
||||||
// Is it negative?
|
// Is it negative?
|
||||||
const negative = (value.substring(0, 1) === "-");
|
const negative = (value.substring(0, 1) === "-");
|
||||||
if (negative) {
|
if (negative) {
|
||||||
value = value.substring(1);
|
value = value.substring(1);
|
||||||
}
|
}
|
||||||
if (value === ".") {
|
(0, errors_js_1.assertArgument)(value !== ".", "missing value", "value", value);
|
||||||
(0, errors_js_1.throwArgumentError)("missing value", "value", value);
|
|
||||||
}
|
|
||||||
// Split it into a whole and fractional part
|
// Split it into a whole and fractional part
|
||||||
const comps = value.split(".");
|
const comps = value.split(".");
|
||||||
if (comps.length > 2) {
|
(0, errors_js_1.assertArgument)(comps.length <= 2, "too many decimal points", "value", value);
|
||||||
(0, errors_js_1.throwArgumentError)("too many decimal points", "value", value);
|
|
||||||
}
|
|
||||||
let whole = (comps[0] || "0"), fraction = (comps[1] || "0");
|
let whole = (comps[0] || "0"), fraction = (comps[1] || "0");
|
||||||
// Trim trialing zeros
|
// Trim trialing zeros
|
||||||
while (fraction[fraction.length - 1] === "0") {
|
while (fraction[fraction.length - 1] === "0") {
|
||||||
@ -110,12 +102,8 @@ class FixedFormat {
|
|||||||
decimals;
|
decimals;
|
||||||
name;
|
name;
|
||||||
_multiplier;
|
_multiplier;
|
||||||
constructor(constructorGuard, signed, width, decimals) {
|
constructor(guard, signed, width, decimals) {
|
||||||
if (constructorGuard !== _constructorGuard) {
|
(0, errors_js_1.assertPrivate)(guard, _guard, "FixedFormat");
|
||||||
(0, errors_js_1.throwError)("cannot use FixedFormat constructor; use FixedFormat.from", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "new FixedFormat"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.signed = signed;
|
this.signed = signed;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.decimals = decimals;
|
this.decimals = decimals;
|
||||||
@ -142,9 +130,7 @@ class FixedFormat {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
const match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/);
|
||||||
if (!match) {
|
(0, errors_js_1.assertArgument)(match, "invalid fixed format", "format", value);
|
||||||
return (0, errors_js_1.throwArgumentError)("invalid fixed format", "format", value);
|
|
||||||
}
|
|
||||||
signed = (match[1] !== "u");
|
signed = (match[1] !== "u");
|
||||||
width = parseInt(match[2]);
|
width = parseInt(match[2]);
|
||||||
decimals = parseInt(match[3]);
|
decimals = parseInt(match[3]);
|
||||||
@ -155,22 +141,16 @@ class FixedFormat {
|
|||||||
if (value[key] == null) {
|
if (value[key] == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
if (typeof (value[key]) !== type) {
|
(0, errors_js_1.assertArgument)(typeof (value[key]) === type, "invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]);
|
||||||
(0, errors_js_1.throwArgumentError)("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]);
|
|
||||||
}
|
|
||||||
return value[key];
|
return value[key];
|
||||||
};
|
};
|
||||||
signed = check("signed", "boolean", signed);
|
signed = check("signed", "boolean", signed);
|
||||||
width = check("width", "number", width);
|
width = check("width", "number", width);
|
||||||
decimals = check("decimals", "number", decimals);
|
decimals = check("decimals", "number", decimals);
|
||||||
}
|
}
|
||||||
if (width % 8) {
|
(0, errors_js_1.assertArgument)((width % 8) === 0, "invalid fixed format width (not byte aligned)", "format.width", width);
|
||||||
(0, errors_js_1.throwArgumentError)("invalid fixed format width (not byte aligned)", "format.width", width);
|
(0, errors_js_1.assertArgument)(decimals <= 80, "invalid fixed format (decimals too large)", "format.decimals", decimals);
|
||||||
}
|
return new FixedFormat(_guard, signed, width, decimals);
|
||||||
if (decimals > 80) {
|
|
||||||
(0, errors_js_1.throwArgumentError)("invalid fixed format (decimals too large)", "format.decimals", decimals);
|
|
||||||
}
|
|
||||||
return new FixedFormat(_constructorGuard, signed, width, decimals);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.FixedFormat = FixedFormat;
|
exports.FixedFormat = FixedFormat;
|
||||||
@ -182,12 +162,8 @@ class FixedNumber {
|
|||||||
_isFixedNumber;
|
_isFixedNumber;
|
||||||
//#hex: string;
|
//#hex: string;
|
||||||
#value;
|
#value;
|
||||||
constructor(constructorGuard, hex, value, format) {
|
constructor(guard, hex, value, format) {
|
||||||
if (constructorGuard !== _constructorGuard) {
|
(0, errors_js_1.assertPrivate)(guard, _guard, "FixedNumber");
|
||||||
(0, errors_js_1.throwError)("cannot use FixedNumber constructor; use FixedNumber.from", "UNSUPPORTED_OPERATION", {
|
|
||||||
operation: "new FixedFormat"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.format = FixedFormat.from(format);
|
this.format = FixedFormat.from(format);
|
||||||
//this.#hex = hex;
|
//this.#hex = hex;
|
||||||
this.#value = value;
|
this.#value = value;
|
||||||
@ -195,9 +171,7 @@ class FixedNumber {
|
|||||||
Object.freeze(this);
|
Object.freeze(this);
|
||||||
}
|
}
|
||||||
#checkFormat(other) {
|
#checkFormat(other) {
|
||||||
if (this.format.name !== other.format.name) {
|
(0, errors_js_1.assertArgument)(this.format.name === other.format.name, "incompatible format; use fixedNumber.toFormat", "other", other);
|
||||||
(0, errors_js_1.throwArgumentError)("incompatible format; use fixedNumber.toFormat", "other", other);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a new [[FixedNumber]] with the result of this added
|
* Returns a new [[FixedNumber]] with the result of this added
|
||||||
@ -261,9 +235,7 @@ class FixedNumber {
|
|||||||
if (comps.length === 1) {
|
if (comps.length === 1) {
|
||||||
comps.push("0");
|
comps.push("0");
|
||||||
}
|
}
|
||||||
if (decimals < 0 || decimals > 80 || (decimals % 1)) {
|
(0, errors_js_1.assertArgument)(Number.isInteger(decimals) && decimals >= 0 && decimals <= 80, "invalid decimal count", "decimals", decimals);
|
||||||
(0, errors_js_1.throwArgumentError)("invalid decimal count", "decimals", decimals);
|
|
||||||
}
|
|
||||||
if (comps[1].length <= decimals) {
|
if (comps[1].length <= decimals) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -311,7 +283,7 @@ class FixedNumber {
|
|||||||
return (0, maths_js_1.toHex)(numeric, fixedFormat.width / 8);
|
return (0, maths_js_1.toHex)(numeric, fixedFormat.width / 8);
|
||||||
})();
|
})();
|
||||||
const decimal = formatFixed(numeric, fixedFormat.decimals);
|
const decimal = formatFixed(numeric, fixedFormat.decimals);
|
||||||
return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
|
return new FixedNumber(_guard, hex, decimal, fixedFormat);
|
||||||
}
|
}
|
||||||
static fromBytes(_value, format = "fixed") {
|
static fromBytes(_value, format = "fixed") {
|
||||||
const value = (0, data_js_1.getBytes)(_value, "value");
|
const value = (0, data_js_1.getBytes)(_value, "value");
|
||||||
@ -325,7 +297,7 @@ class FixedNumber {
|
|||||||
}
|
}
|
||||||
const hex = (0, maths_js_1.toHex)((0, maths_js_1.toTwos)(numeric, (fixedFormat.signed ? 0 : 1) + fixedFormat.width));
|
const hex = (0, maths_js_1.toHex)((0, maths_js_1.toTwos)(numeric, (fixedFormat.signed ? 0 : 1) + fixedFormat.width));
|
||||||
const decimal = formatFixed(numeric, fixedFormat.decimals);
|
const decimal = formatFixed(numeric, fixedFormat.decimals);
|
||||||
return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat);
|
return new FixedNumber(_guard, hex, decimal, fixedFormat);
|
||||||
}
|
}
|
||||||
static from(value, format) {
|
static from(value, format) {
|
||||||
if (typeof (value) === "string") {
|
if (typeof (value) === "string") {
|
||||||
@ -343,7 +315,7 @@ class FixedNumber {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (0, errors_js_1.throwArgumentError)("invalid FixedNumber value", "value", value);
|
(0, errors_js_1.assertArgument)(false, "invalid FixedNumber value", "value", value);
|
||||||
}
|
}
|
||||||
static isFixedNumber(value) {
|
static isFixedNumber(value) {
|
||||||
return !!(value && value._isFixedNumber);
|
return !!(value && value._isFixedNumber);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user