diff --git a/.env.development b/.env.development index 0d414c8e4b..6a5e953173 100644 --- a/.env.development +++ b/.env.development @@ -4,4 +4,4 @@ NEXT_PUBLIC_API_BASEURL=https://aave-api-v2.aave.com #NEXT_PUBLIC_FORK_CHAIN_ID=1 #NEXT_PUBLIC_FORK_URL_RPC="https://rpc.tenderly.co/fork/1234567" NEXT_PUBLIC_ENABLE_STAKING=true -NEXT_PUBLIC_ENABLE_GOVERNANCE=true \ No newline at end of file +NEXT_PUBLIC_ENABLE_GOVERNANCE=true diff --git a/.env.example b/.env.example index e8d8ff1cda..f7b31ad69d 100644 --- a/.env.example +++ b/.env.example @@ -13,3 +13,4 @@ NEXT_PUBLIC_TURNSTILE_SITE_KEY=0x4AAAAAAABe-kMUW_1JUfT7 NEXT_PUBLIC_FORK_BASE_CHAIN_ID=1 NEXT_PUBLIC_FORK_CHAIN_ID=1 NEXT_PUBLIC_FORK_URL_RPC=https://rpc.tenderly.co/fork/1234567 +NEXT_PUBLIC_MIXPANEL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 82051f381d..4aa049068b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ yarn-error.log* .env.local .env.development.local .env.test.local +.env.dev.development .env.production.local # vercel @@ -45,3 +46,4 @@ package-lock.json # IDE specific .idea .vscode +.env.development diff --git a/cypress/configs/settings.config.ts b/cypress/configs/settings.config.ts index 8b03bf0b11..ff3ccda467 100644 --- a/cypress/configs/settings.config.ts +++ b/cypress/configs/settings.config.ts @@ -8,6 +8,6 @@ export default defineConfig({ ...defaultConfig, e2e: { specPattern: [folder + '**/*.*'], - excludeSpecPattern: ['/**/mobile.cy.ts'], + excludeSpecPattern: ['/**/mobile.cy.ts', '/**/change-languages.cy.ts'], }, }); diff --git a/cypress/e2e/2-settings/change-languages.cy.ts b/cypress/e2e/2-settings/change-languages.cy.ts index 3ea742068e..a9f3a3d193 100644 --- a/cypress/e2e/2-settings/change-languages.cy.ts +++ b/cypress/e2e/2-settings/change-languages.cy.ts @@ -17,13 +17,13 @@ const verifyTranslation = (markets: string, More: string) => { }; export const verifyTranslationOnMarketsPage = (totalBorrows: string, totalMarketSize: string) => { it(`step3:Verify translation on the Markets page on the ${totalBorrows} and on the ${totalMarketSize}`, () => { - cy.get('a[href*="/markets/"]').click(); + cy.get('a[href*="/markets/"]').first().click({ multiple: true }); cy.contains(totalBorrows); cy.contains(totalMarketSize); }); }; -describe('Manipulation on the language', () => { +describe.skip('Manipulation on the language', () => { describe('CASE1:Changing the language from English to Spanish', () => { configEnvWithTenderlyMainnetFork({}); switchLanguageStep('Language', 'Spanish'); @@ -31,13 +31,13 @@ describe('Manipulation on the language', () => { verifyTranslationOnMarketsPage('Total de préstamos', 'Tamaño total del mercado'); }); - describe('CASE2: Changing the Language from Spanish to French', () => { + describe.skip('CASE2: Changing the Language from Spanish to French', () => { switchLanguageStep('Idioma', 'Francés'); verifyTranslation('Marchés', 'Plus'); verifyTranslationOnMarketsPage('Total des emprunts', 'Taille totale du marché'); }); - describe('CASE3: Change language from French to English', () => { + describe.skip('CASE3: Change language from French to English', () => { switchLanguageStep('Language', 'Anglais'); verifyTranslation('Markets', 'More'); verifyTranslationOnMarketsPage('Total borrows', 'Total market size'); diff --git a/cypress/support/steps/common.ts b/cypress/support/steps/common.ts index 5dfb9b89b0..a79d4185ee 100644 --- a/cypress/support/steps/common.ts +++ b/cypress/support/steps/common.ts @@ -26,12 +26,18 @@ export const skipSetup = ({ if (skip.get()) { this.skip(); } + cy.window().then((win) => { + win.localStorage.setItem('userAcceptedAnalytics', 'false'); + }); }); afterEach(function onAfterEach() { if ((this.currentTest as Mocha.Test).state === 'failed' && updateSkipStatus) { skip.set(true); } + cy.window().then((win) => { + win.localStorage.setItem('userAcceptedAnalytics', 'false'); + }); }); }; diff --git a/cypress/support/steps/configuration.steps.ts b/cypress/support/steps/configuration.steps.ts index 31f8da36e1..c350600f8f 100644 --- a/cypress/support/steps/configuration.steps.ts +++ b/cypress/support/steps/configuration.steps.ts @@ -57,6 +57,7 @@ export const configEnvWithTenderly = ({ win.localStorage.setItem('selectedAccount', walletAddress.toLowerCase()); win.localStorage.setItem('selectedMarket', market); win.localStorage.setItem('testnetsEnabled', enableTestnet.toString()); + // win.localStorage.setItem('userAcceptedAnalytics', 'true'); }, }); }); diff --git a/next.config.js b/next.config.js index d1a9f8e690..3ab5d60d1e 100644 --- a/next.config.js +++ b/next.config.js @@ -31,4 +31,12 @@ module.exports = withBundleAnalyzer({ // assetPrefix: "./", trailingSlash: true, pageExtensions, + async rewrites() { + return [ + { + source: '/collect/:match*', + destination: 'https://api.mixpanel.com/:match*', + }, + ]; + }, }); diff --git a/package.json b/package.json index 1f54c3bc2e..b9143b46d6 100644 --- a/package.json +++ b/package.json @@ -74,9 +74,11 @@ "gray-matter": "^4.0.3", "immer": "^9.0.15", "lowdb": "^3.0.0", + "mixpanel-browser": "^2.45.0", "next": "12.1.1", "paraswap-core": "^1.0.2", "react": "latest", + "react-cookie-consent": "^8.0.1", "react-dom": "latest", "react-infinite-scroller": "^1.2.6", "react-markdown": "^8.0.3", @@ -105,6 +107,7 @@ "@types/d3-array": "^3.0.3", "@types/d3-time-format": "^4.0.0", "@types/lodash": "^4.14.186", + "@types/mixpanel-browser": "^2.38.1", "@types/react": "latest", "@types/react-infinite-scroller": "^1.2.3", "@typescript-eslint/eslint-plugin": "^5.38.1", diff --git a/pages/_app.page.tsx b/pages/_app.page.tsx index cfad79b2a2..3cf9eb9ba3 100644 --- a/pages/_app.page.tsx +++ b/pages/_app.page.tsx @@ -11,6 +11,7 @@ import Head from 'next/head'; import * as React from 'react'; import { AddressBlocked } from 'src/components/AddressBlocked'; import { Meta } from 'src/components/Meta'; +import { TransactionEventHandler } from 'src/components/TransactionEventHandler'; import { BorrowModal } from 'src/components/transactions/Borrow/BorrowModal'; import { ClaimRewardsModal } from 'src/components/transactions/ClaimRewards/ClaimRewardsModal'; import { CollateralChangeModal } from 'src/components/transactions/CollateralChange/CollateralChangeModal'; @@ -28,6 +29,7 @@ import { AppDataProvider } from 'src/hooks/app-data-provider/useAppDataProvider' import { ModalContextProvider } from 'src/hooks/useModal'; import { PermissionProvider } from 'src/hooks/usePermissions'; import { Web3ContextProvider } from 'src/libs/web3-data-provider/Web3Provider'; +import { useRootStore } from 'src/store/root'; import { SharedDependenciesProvider } from 'src/ui-config/SharedDependenciesProvider'; import createEmotionCache from '../src/createEmotionCache'; @@ -57,6 +59,17 @@ interface MyAppProps extends AppProps { export default function MyApp(props: MyAppProps) { const { Component, emotionCache = clientSideEmotionCache, pageProps } = props; const getLayout = Component.getLayout ?? ((page: React.ReactNode) => page); + const initializeMixpanel = useRootStore((store) => store.initializeMixpanel); + + const MIXPANEL_TOKEN = process.env.NEXT_PUBLIC_MIXPANEL; + React.useEffect(() => { + if (MIXPANEL_TOKEN) { + initializeMixpanel(); + } else { + console.log('no analytics tracking'); + } + }, []); + return ( @@ -93,6 +106,7 @@ export default function MyApp(props: MyAppProps) { + diff --git a/pages/governance/proposal/[proposalId].governance.tsx b/pages/governance/proposal/[proposalId].governance.tsx index f0263c52c4..c7415fdcf0 100644 --- a/pages/governance/proposal/[proposalId].governance.tsx +++ b/pages/governance/proposal/[proposalId].governance.tsx @@ -47,7 +47,9 @@ import { isProposalStateImmutable } from 'src/modules/governance/utils/immutable import { VoteBar } from 'src/modules/governance/VoteBar'; import { Ipfs, IpfsType } from 'src/static-build/ipfs'; import { CustomProposalType, Proposal } from 'src/static-build/proposal'; +import { useRootStore } from 'src/store/root'; import { governanceConfig } from 'src/ui-config/governanceConfig'; +import { GENERAL } from 'src/utils/mixPanelEvents'; import { ContentContainer } from '../../../src/components/ContentContainer'; import { LensIcon } from '../../../src/components/icons/LensIcon'; @@ -113,6 +115,7 @@ export default function ProposalPage({ const { breakpoints, palette } = useTheme(); const lgUp = useMediaQuery(breakpoints.up('lg')); const mightBeStale = !proposal || !isProposalStateImmutable(proposal); + const trackEvent = useRootStore((store) => store.trackEvent); async function updateProposal() { if (!proposal) return; @@ -219,6 +222,9 @@ export default function ProposalPage({ sx={{ minWidth: lgUp ? '160px' : '' }} target="_blank" rel="noopener" + onClick={() => + trackEvent(GENERAL.EXTERNAL_LINK, { AIP: proposal.id, Link: 'Raw Ipfs' }) + } href={`${governanceConfig.ipfsGateway}/${ipfs.ipfsHash}`} startIcon={ @@ -233,6 +239,12 @@ export default function ProposalPage({ sx={{ minWidth: lgUp ? '160px' : '' }} target="_blank" rel="noopener noreferrer" + onClick={() => + trackEvent(GENERAL.EXTERNAL_LINK, { + AIP: proposal.id, + Link: 'Share on twitter', + }) + } href={`https://twitter.com/intent/tweet?text=${encodeURIComponent( ipfs.title )}&url=${url}`} @@ -245,6 +257,12 @@ export default function ProposalPage({ component="a" target="_blank" rel="noopener noreferrer" + onClick={() => + trackEvent(GENERAL.EXTERNAL_LINK, { + AIP: proposal.id, + Link: 'Share on lens', + }) + } href={`https://lenster.xyz/?url=${url}&text=Check out this proposal on aave governance 👻👻 - ${ipfs.title}&hashtags=Aave&preview=true`} startIcon={ + trackEvent(GENERAL.EXTERNAL_LINK, { + AIP: proposal.id, + Link: 'Forum Discussion', + }) + } href={ipfs.discussions} variant="outlined" endIcon={ @@ -606,6 +630,12 @@ export default function ProposalPage({ component={Link} target="_blank" rel="noopener" + onClick={() => + trackEvent(GENERAL.EXTERNAL_LINK, { + AIP: proposal.id, + Link: 'Seatbelt Report', + }) + } href={`https://github.com/bgd-labs/seatbelt-for-ghosts/tree/master/reports/Aave/0xEC568fffba86c094cf06b22134B23074DFE2252c/${String( proposal.id ).padStart(3, '0')}.md`} diff --git a/public/icons/lens-logo.svg b/public/icons/lens-logo.svg index a55aacb11d..a0d66efc30 100644 --- a/public/icons/lens-logo.svg +++ b/public/icons/lens-logo.svg @@ -1 +1 @@ - + diff --git a/public/icons/tokens/metis.svg b/public/icons/tokens/metis.svg index 05fd00e9a5..4466423736 100644 --- a/public/icons/tokens/metis.svg +++ b/public/icons/tokens/metis.svg @@ -1,4 +1 @@ - - - - + diff --git a/scripts/populate-cache.js b/scripts/populate-cache.js index f653e4bb7c..777ca6fb4c 100644 --- a/scripts/populate-cache.js +++ b/scripts/populate-cache.js @@ -34,9 +34,6 @@ var __objRest = (source, exclude) => { } return target; }; -var __esm = (fn, res) => function __init() { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; -}; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; @@ -53,10 +50,6 @@ var __copyProps = (to, from, except, desc) => { return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); @@ -82,368 +75,74 @@ var __async = (__this, __arguments, generator) => { }); }; -// node_modules/tslib/tslib.es6.js -var tslib_es6_exports = {}; -__export(tslib_es6_exports, { - __assign: () => __assign, - __asyncDelegator: () => __asyncDelegator, - __asyncGenerator: () => __asyncGenerator, - __asyncValues: () => __asyncValues, - __await: () => __await, - __awaiter: () => __awaiter, - __classPrivateFieldGet: () => __classPrivateFieldGet, - __classPrivateFieldSet: () => __classPrivateFieldSet, - __createBinding: () => __createBinding, - __decorate: () => __decorate, - __exportStar: () => __exportStar, - __extends: () => __extends, - __generator: () => __generator, - __importDefault: () => __importDefault, - __importStar: () => __importStar, - __makeTemplateObject: () => __makeTemplateObject, - __metadata: () => __metadata, - __param: () => __param, - __read: () => __read, - __rest: () => __rest, - __spread: () => __spread, - __spreadArray: () => __spreadArray, - __spreadArrays: () => __spreadArrays, - __values: () => __values -}); -function __extends(d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} -function __rest(s, e) { - var t = {}; - for (var p in s) - if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; -} -function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") - r = Reflect.decorate(decorators, target, key, desc); - else - for (var i = decorators.length - 1; i >= 0; i--) - if (d = decorators[i]) - r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} -function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} -function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") - return Reflect.metadata(metadataKey, metadataValue); -} -function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); +// node_modules/tslib/tslib.js +var require_tslib = __commonJS({ + "node_modules/tslib/tslib.js"(exports2, module2) { + var __extends; + var __assign; + var __rest; + var __decorate; + var __param; + var __metadata; + var __awaiter; + var __generator; + var __exportStar; + var __values; + var __read; + var __spread; + var __spreadArrays; + var __spreadArray; + var __await; + var __asyncGenerator; + var __asyncDelegator; + var __asyncValues; + var __makeTemplateObject; + var __importStar; + var __importDefault; + var __classPrivateFieldGet4; + var __classPrivateFieldSet4; + var __createBinding; + (function(factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function(exports3) { + factory(createExporter(root, createExporter(exports3))); + }); + } else if (typeof module2 === "object" && typeof module2.exports === "object") { + factory(createExporter(root, createExporter(module2.exports))); + } else { + factory(createExporter(root)); } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} -function __generator(thisArg, body) { - var _ = { label: 0, sent: function() { - if (t[0] & 1) - throw t[1]; - return t[1]; - }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([n, v]); - }; - } - function step(op) { - if (f) - throw new TypeError("Generator is already executing."); - while (_) - try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) - return t; - if (y = 0, t) - op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { value: op[1], done: false }; - case 5: - _.label++; - y = op[1]; - op = [0]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) - _.ops.pop(); - _.trys.pop(); - continue; + function createExporter(exports3, previous) { + if (exports3 !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports3, "__esModule", { value: true }); + } else { + exports3.__esModule = true; + } } - op = body.call(thisArg, _); - } catch (e) { - op = [6, e]; - y = 0; - } finally { - f = t = 0; - } - if (op[0] & 5) - throw op[1]; - return { value: op[0] ? op[1] : void 0, done: true }; - } -} -function __exportStar(m, o) { - for (var p in m) - if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) - __createBinding(o, m, p); -} -function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) - return m.call(o); - if (o && typeof o.length === "number") - return { - next: function() { - if (o && i >= o.length) - o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -} -function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) - return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) - ar.push(r.value); - } catch (error) { - e = { error }; - } finally { - try { - if (r && !r.done && (m = i["return"])) - m.call(i); - } finally { - if (e) - throw e.error; - } - } - return ar; -} -function __spread() { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; -} -function __spreadArrays() { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) - s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; -} -function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) - for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) - ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; + return function(id, v) { + return exports3[id] = previous ? previous(id, v) : v; + }; } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} -function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} -function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) - i[n] = function(v) { - return new Promise(function(a, b) { - q.push([n, v, a, b]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) - resume(q[0][0], q[0][1]); - } -} -function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; - } : f; - } -} -function __asyncValues(o) { - if (!Symbol.asyncIterator) - throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v2) { - resolve({ value: v2, done: d }); - }, reject); - } -} -function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) { - Object.defineProperty(cooked, "raw", { value: raw }); - } else { - cooked.raw = raw; - } - return cooked; -} -function __importStar(mod) { - if (mod && mod.__esModule) - return mod; - var result = {}; - if (mod != null) { - for (var k in mod) - if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding(result, mod, k); - } - __setModuleDefault(result, mod); - return result; -} -function __importDefault(mod) { - return mod && mod.__esModule ? mod : { default: mod }; -} -function __classPrivateFieldGet(receiver, state, kind, f) { - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -} -function __classPrivateFieldSet(receiver, state, value, kind, f) { - if (kind === "m") - throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) - throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) - throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; -} -var extendStatics, __assign, __createBinding, __setModuleDefault; -var init_tslib_es6 = __esm({ - "node_modules/tslib/tslib.es6.js"() { - "use strict"; - extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { - d2.__proto__ = b2; - } || function(d2, b2) { - for (var p in b2) - if (Object.prototype.hasOwnProperty.call(b2, p)) - d2[p] = b2[p]; - }; - return extendStatics(d, b); - }; - __assign = function() { - __assign = Object.assign || function __assign2(t) { + })(function(exporter) { + var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) { + d.__proto__ = b; + } || function(d, b) { + for (var p in b) + if (Object.prototype.hasOwnProperty.call(b, p)) + d[p] = b[p]; + }; + __extends = function(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { + this.constructor = d; + } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) @@ -452,31 +151,362 @@ var init_tslib_es6 = __esm({ } return t; }; - return __assign.apply(this, arguments); - }; - __createBinding = Object.create ? function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { - return m[k]; - } }); - } : function(o, m, k, k2) { - if (k2 === void 0) - k2 = k; - o[k2] = m[k]; - }; - __setModuleDefault = Object.create ? function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - } : function(o, v) { - o["default"] = v; - }; + __rest = function(s, e) { + var t = {}; + for (var p in s) + if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + }; + __decorate = function(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") + r = Reflect.decorate(decorators, target, key, desc); + else + for (var i = decorators.length - 1; i >= 0; i--) + if (d = decorators[i]) + r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + __param = function(paramIndex, decorator) { + return function(target, key) { + decorator(target, key, paramIndex); + }; + }; + __metadata = function(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") + return Reflect.metadata(metadataKey, metadataValue); + }; + __awaiter = function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + __generator = function(thisArg, body) { + var _ = { label: 0, sent: function() { + if (t[0] & 1) + throw t[1]; + return t[1]; + }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { + return this; + }), g; + function verb(n) { + return function(v) { + return step([n, v]); + }; + } + function step(op) { + if (f) + throw new TypeError("Generator is already executing."); + while (_) + try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) + return t; + if (y = 0, t) + op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: + case 1: + t = op; + break; + case 4: + _.label++; + return { value: op[1], done: false }; + case 5: + _.label++; + y = op[1]; + op = [0]; + continue; + case 7: + op = _.ops.pop(); + _.trys.pop(); + continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { + _ = 0; + continue; + } + if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { + _.label = op[1]; + break; + } + if (op[0] === 6 && _.label < t[1]) { + _.label = t[1]; + t = op; + break; + } + if (t && _.label < t[2]) { + _.label = t[2]; + _.ops.push(op); + break; + } + if (t[2]) + _.ops.pop(); + _.trys.pop(); + continue; + } + op = body.call(thisArg, _); + } catch (e) { + op = [6, e]; + y = 0; + } finally { + f = t = 0; + } + if (op[0] & 5) + throw op[1]; + return { value: op[0] ? op[1] : void 0, done: true }; + } + }; + __exportStar = function(m, o) { + for (var p in m) + if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) + __createBinding(o, m, p); + }; + __createBinding = Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }; + __values = function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) + return m.call(o); + if (o && typeof o.length === "number") + return { + next: function() { + if (o && i >= o.length) + o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + }; + __read = function(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) + return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) + ar.push(r.value); + } catch (error) { + e = { error }; + } finally { + try { + if (r && !r.done && (m = i["return"])) + m.call(i); + } finally { + if (e) + throw e.error; + } + } + return ar; + }; + __spread = function() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + __spreadArrays = function() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) + s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + __spreadArray = function(to, from, pack) { + if (pack || arguments.length === 2) + for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) + ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + }; + __await = function(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + __asyncGenerator = function(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { + return this; + }, i; + function verb(n) { + if (g[n]) + i[n] = function(v) { + return new Promise(function(a, b) { + q.push([n, v, a, b]) > 1 || resume(n, v); + }); + }; + } + function resume(n, v) { + try { + step(g[n](v)); + } catch (e) { + settle(q[0][3], e); + } + } + function step(r) { + r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); + } + function fulfill(value) { + resume("next", value); + } + function reject(value) { + resume("throw", value); + } + function settle(f, v) { + if (f(v), q.shift(), q.length) + resume(q[0][0], q[0][1]); + } + }; + __asyncDelegator = function(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function(e) { + throw e; + }), verb("return"), i[Symbol.iterator] = function() { + return this; + }, i; + function verb(n, f) { + i[n] = o[n] ? function(v) { + return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; + } : f; + } + }; + __asyncValues = function(o) { + if (!Symbol.asyncIterator) + throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { + return this; + }, i); + function verb(n) { + i[n] = o[n] && function(v) { + return new Promise(function(resolve, reject) { + v = o[n](v), settle(resolve, reject, v.done, v.value); + }); + }; + } + function settle(resolve, reject, d, v) { + Promise.resolve(v).then(function(v2) { + resolve({ value: v2, done: d }); + }, reject); + } + }; + __makeTemplateObject = function(cooked, raw) { + if (Object.defineProperty) { + Object.defineProperty(cooked, "raw", { value: raw }); + } else { + cooked.raw = raw; + } + return cooked; + }; + var __setModuleDefault = Object.create ? function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } : function(o, v) { + o["default"] = v; + }; + __importStar = function(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k in mod) + if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + } + __setModuleDefault(result, mod); + return result; + }; + __importDefault = function(mod) { + return mod && mod.__esModule ? mod : { "default": mod }; + }; + __classPrivateFieldGet4 = function(receiver, state, kind, f) { + if (kind === "a" && !f) + throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) + throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); + }; + __classPrivateFieldSet4 = function(receiver, state, value, kind, f) { + if (kind === "m") + throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) + throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) + throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; + }; + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__spreadArrays", __spreadArrays); + exporter("__spreadArray", __spreadArray); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); + exporter("__classPrivateFieldGet", __classPrivateFieldGet4); + exporter("__classPrivateFieldSet", __classPrivateFieldSet4); + }); } }); // node_modules/bn.js/lib/bn.js var require_bn = __commonJS({ "node_modules/bn.js/lib/bn.js"(exports2, module2) { - "use strict"; (function(module3, exports3) { "use strict"; function assert(val, msg) { @@ -3404,213 +3434,210 @@ var require_lib = __commonJS({ ErrorCode2["TRANSACTION_REPLACED"] = "TRANSACTION_REPLACED"; })(ErrorCode = exports2.ErrorCode || (exports2.ErrorCode = {})); var HEX = "0123456789abcdef"; - var Logger = ( - /** @class */ - function() { - function Logger2(version) { - Object.defineProperty(this, "version", { - enumerable: true, - value: version, - writable: false - }); + var Logger = function() { + function Logger2(version) { + Object.defineProperty(this, "version", { + enumerable: true, + value: version, + writable: false + }); + } + Logger2.prototype._log = function(logLevel, args) { + var level = logLevel.toLowerCase(); + if (LogLevels[level] == null) { + this.throwArgumentError("invalid log level name", "logLevel", logLevel); } - Logger2.prototype._log = function(logLevel, args) { - var level = logLevel.toLowerCase(); - if (LogLevels[level] == null) { - this.throwArgumentError("invalid log level name", "logLevel", logLevel); - } - if (_logLevel > LogLevels[level]) { - return; - } - console.log.apply(console, args); - }; - Logger2.prototype.debug = function() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger2.levels.DEBUG, args); - }; - Logger2.prototype.info = function() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger2.levels.INFO, args); - }; - Logger2.prototype.warn = function() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger2.levels.WARNING, args); - }; - Logger2.prototype.makeError = function(message, code, params) { - if (_censorErrors) { - return this.makeError("censored error", code, {}); - } - if (!code) { - code = Logger2.errors.UNKNOWN_ERROR; - } - if (!params) { - params = {}; - } - var messageDetails = []; - Object.keys(params).forEach(function(key) { - var value = params[key]; - try { - if (value instanceof Uint8Array) { - var hex = ""; - for (var i = 0; i < value.length; i++) { - hex += HEX[value[i] >> 4]; - hex += HEX[value[i] & 15]; - } - messageDetails.push(key + "=Uint8Array(0x" + hex + ")"); - } else { - messageDetails.push(key + "=" + JSON.stringify(value)); + if (_logLevel > LogLevels[level]) { + return; + } + console.log.apply(console, args); + }; + Logger2.prototype.debug = function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger2.levels.DEBUG, args); + }; + Logger2.prototype.info = function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger2.levels.INFO, args); + }; + Logger2.prototype.warn = function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger2.levels.WARNING, args); + }; + Logger2.prototype.makeError = function(message, code, params) { + if (_censorErrors) { + return this.makeError("censored error", code, {}); + } + if (!code) { + code = Logger2.errors.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + var messageDetails = []; + Object.keys(params).forEach(function(key) { + var value = params[key]; + try { + if (value instanceof Uint8Array) { + var hex = ""; + for (var i = 0; i < value.length; i++) { + hex += HEX[value[i] >> 4]; + hex += HEX[value[i] & 15]; } - } catch (error2) { - messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + messageDetails.push(key + "=Uint8Array(0x" + hex + ")"); + } else { + messageDetails.push(key + "=" + JSON.stringify(value)); } - }); - messageDetails.push("code=" + code); - messageDetails.push("version=" + this.version); - var reason = message; - if (messageDetails.length) { - message += " (" + messageDetails.join(", ") + ")"; + } catch (error2) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); } - var error = new Error(message); - error.reason = reason; - error.code = code; - Object.keys(params).forEach(function(key) { - error[key] = params[key]; + }); + messageDetails.push("code=" + code); + messageDetails.push("version=" + this.version); + var reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + var error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function(key) { + error[key] = params[key]; + }); + return error; + }; + Logger2.prototype.throwError = function(message, code, params) { + throw this.makeError(message, code, params); + }; + Logger2.prototype.throwArgumentError = function(message, name2, value) { + return this.throwError(message, Logger2.errors.INVALID_ARGUMENT, { + argument: name2, + value + }); + }; + Logger2.prototype.assert = function(condition, message, code, params) { + if (!!condition) { + return; + } + this.throwError(message, code, params); + }; + Logger2.prototype.assertArgument = function(condition, message, name2, value) { + if (!!condition) { + return; + } + this.throwArgumentError(message, name2, value); + }; + Logger2.prototype.checkNormalize = function(message) { + if (message == null) { + message = "platform missing String.prototype.normalize"; + } + if (_normalizeError) { + this.throwError("platform missing String.prototype.normalize", Logger2.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", + form: _normalizeError }); - return error; - }; - Logger2.prototype.throwError = function(message, code, params) { - throw this.makeError(message, code, params); - }; - Logger2.prototype.throwArgumentError = function(message, name2, value) { - return this.throwError(message, Logger2.errors.INVALID_ARGUMENT, { - argument: name2, + } + }; + Logger2.prototype.checkSafeUint53 = function(value, message) { + if (typeof value !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 9007199254740991) { + this.throwError(message, Logger2.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", value }); - }; - Logger2.prototype.assert = function(condition, message, code, params) { - if (!!condition) { - return; - } - this.throwError(message, code, params); - }; - Logger2.prototype.assertArgument = function(condition, message, name2, value) { - if (!!condition) { - return; - } - this.throwArgumentError(message, name2, value); - }; - Logger2.prototype.checkNormalize = function(message) { - if (message == null) { - message = "platform missing String.prototype.normalize"; - } - if (_normalizeError) { - this.throwError("platform missing String.prototype.normalize", Logger2.errors.UNSUPPORTED_OPERATION, { - operation: "String.prototype.normalize", - form: _normalizeError - }); - } - }; - Logger2.prototype.checkSafeUint53 = function(value, message) { - if (typeof value !== "number") { - return; - } - if (message == null) { - message = "value not safe"; - } - if (value < 0 || value >= 9007199254740991) { - this.throwError(message, Logger2.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "out-of-safe-range", - value - }); - } - if (value % 1) { - this.throwError(message, Logger2.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "non-integer", - value - }); - } - }; - Logger2.prototype.checkArgumentCount = function(count, expectedCount, message) { - if (message) { - message = ": " + message; - } else { - message = ""; - } - if (count < expectedCount) { - this.throwError("missing argument" + message, Logger2.errors.MISSING_ARGUMENT, { - count, - expectedCount - }); - } - if (count > expectedCount) { - this.throwError("too many arguments" + message, Logger2.errors.UNEXPECTED_ARGUMENT, { - count, - expectedCount - }); - } - }; - Logger2.prototype.checkNew = function(target, kind) { - if (target === Object || target == null) { - this.throwError("missing new", Logger2.errors.MISSING_NEW, { name: kind.name }); - } - }; - Logger2.prototype.checkAbstract = function(target, kind) { - if (target === kind) { - this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger2.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); - } else if (target === Object || target == null) { - this.throwError("missing new", Logger2.errors.MISSING_NEW, { name: kind.name }); - } - }; - Logger2.globalLogger = function() { - if (!_globalLogger) { - _globalLogger = new Logger2(_version_1.version); - } - return _globalLogger; - }; - Logger2.setCensorship = function(censorship, permanent) { - if (!censorship && permanent) { - this.globalLogger().throwError("cannot permanently disable censorship", Logger2.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }); - } - if (_permanentCensorErrors) { - if (!censorship) { - return; - } - this.globalLogger().throwError("error censorship permanent", Logger2.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }); - } - _censorErrors = !!censorship; - _permanentCensorErrors = !!permanent; - }; - Logger2.setLogLevel = function(logLevel) { - var level = LogLevels[logLevel.toLowerCase()]; - if (level == null) { - Logger2.globalLogger().warn("invalid log level - " + logLevel); + } + if (value % 1) { + this.throwError(message, Logger2.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value + }); + } + }; + Logger2.prototype.checkArgumentCount = function(count, expectedCount, message) { + if (message) { + message = ": " + message; + } else { + message = ""; + } + if (count < expectedCount) { + this.throwError("missing argument" + message, Logger2.errors.MISSING_ARGUMENT, { + count, + expectedCount + }); + } + if (count > expectedCount) { + this.throwError("too many arguments" + message, Logger2.errors.UNEXPECTED_ARGUMENT, { + count, + expectedCount + }); + } + }; + Logger2.prototype.checkNew = function(target, kind) { + if (target === Object || target == null) { + this.throwError("missing new", Logger2.errors.MISSING_NEW, { name: kind.name }); + } + }; + Logger2.prototype.checkAbstract = function(target, kind) { + if (target === kind) { + this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger2.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } else if (target === Object || target == null) { + this.throwError("missing new", Logger2.errors.MISSING_NEW, { name: kind.name }); + } + }; + Logger2.globalLogger = function() { + if (!_globalLogger) { + _globalLogger = new Logger2(_version_1.version); + } + return _globalLogger; + }; + Logger2.setCensorship = function(censorship, permanent) { + if (!censorship && permanent) { + this.globalLogger().throwError("cannot permanently disable censorship", Logger2.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + if (_permanentCensorErrors) { + if (!censorship) { return; } - _logLevel = level; - }; - Logger2.from = function(version) { - return new Logger2(version); - }; - Logger2.errors = ErrorCode; - Logger2.levels = LogLevel; - return Logger2; - }() - ); + this.globalLogger().throwError("error censorship permanent", Logger2.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; + }; + Logger2.setLogLevel = function(logLevel) { + var level = LogLevels[logLevel.toLowerCase()]; + if (level == null) { + Logger2.globalLogger().warn("invalid log level - " + logLevel); + return; + } + _logLevel = level; + }; + Logger2.from = function(version) { + return new Logger2(version); + }; + Logger2.errors = ErrorCode; + Logger2.levels = LogLevel; + return Logger2; + }(); exports2.Logger = Logger; } }); @@ -4023,12 +4050,12 @@ var require_version3 = __commonJS({ var require_bignumber = __commonJS({ "node_modules/@ethersproject/bignumber/lib/bignumber.js"(exports2) { "use strict"; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2._base16To36 = exports2._base36To16 = exports2.BigNumber = exports2.isBigNumberish = void 0; - var bn_js_1 = __importDefault2(require_bn()); + var bn_js_1 = __importDefault(require_bn()); var BN = bn_js_1.default.BN; var bytes_1 = require_lib2(); var logger_1 = require_lib(); @@ -4041,216 +4068,213 @@ var require_bignumber = __commonJS({ } exports2.isBigNumberish = isBigNumberish; var _warnedToStringRadix = false; - var BigNumber2 = ( - /** @class */ - function() { - function BigNumber3(constructorGuard, hex) { - var _newTarget = this.constructor; - logger2.checkNew(_newTarget, BigNumber3); - if (constructorGuard !== _constructorGuard) { - logger2.throwError("cannot call constructor directly; use BigNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new (BigNumber)" - }); - } - this._hex = hex; - this._isBigNumber = true; - Object.freeze(this); + var BigNumber2 = function() { + function BigNumber3(constructorGuard, hex) { + var _newTarget = this.constructor; + logger2.checkNew(_newTarget, BigNumber3); + if (constructorGuard !== _constructorGuard) { + logger2.throwError("cannot call constructor directly; use BigNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); } - BigNumber3.prototype.fromTwos = function(value) { - return toBigNumber(toBN(this).fromTwos(value)); - }; - BigNumber3.prototype.toTwos = function(value) { - return toBigNumber(toBN(this).toTwos(value)); - }; - BigNumber3.prototype.abs = function() { - if (this._hex[0] === "-") { - return BigNumber3.from(this._hex.substring(1)); - } - return this; - }; - BigNumber3.prototype.add = function(other) { - return toBigNumber(toBN(this).add(toBN(other))); - }; - BigNumber3.prototype.sub = function(other) { - return toBigNumber(toBN(this).sub(toBN(other))); - }; - BigNumber3.prototype.div = function(other) { - var o = BigNumber3.from(other); - if (o.isZero()) { - throwFault("division by zero", "div"); - } - return toBigNumber(toBN(this).div(toBN(other))); - }; - BigNumber3.prototype.mul = function(other) { - return toBigNumber(toBN(this).mul(toBN(other))); - }; - BigNumber3.prototype.mod = function(other) { - var value = toBN(other); - if (value.isNeg()) { - throwFault("cannot modulo negative values", "mod"); - } - return toBigNumber(toBN(this).umod(value)); - }; - BigNumber3.prototype.pow = function(other) { - var value = toBN(other); - if (value.isNeg()) { - throwFault("cannot raise to negative values", "pow"); - } - return toBigNumber(toBN(this).pow(value)); - }; - BigNumber3.prototype.and = function(other) { - var value = toBN(other); - if (this.isNegative() || value.isNeg()) { - throwFault("cannot 'and' negative values", "and"); - } - return toBigNumber(toBN(this).and(value)); - }; - BigNumber3.prototype.or = function(other) { - var value = toBN(other); - if (this.isNegative() || value.isNeg()) { - throwFault("cannot 'or' negative values", "or"); - } - return toBigNumber(toBN(this).or(value)); - }; - BigNumber3.prototype.xor = function(other) { - var value = toBN(other); - if (this.isNegative() || value.isNeg()) { - throwFault("cannot 'xor' negative values", "xor"); - } - return toBigNumber(toBN(this).xor(value)); - }; - BigNumber3.prototype.mask = function(value) { - if (this.isNegative() || value < 0) { - throwFault("cannot mask negative values", "mask"); - } - return toBigNumber(toBN(this).maskn(value)); - }; - BigNumber3.prototype.shl = function(value) { - if (this.isNegative() || value < 0) { - throwFault("cannot shift negative values", "shl"); - } - return toBigNumber(toBN(this).shln(value)); - }; - BigNumber3.prototype.shr = function(value) { - if (this.isNegative() || value < 0) { - throwFault("cannot shift negative values", "shr"); - } - return toBigNumber(toBN(this).shrn(value)); - }; - BigNumber3.prototype.eq = function(other) { - return toBN(this).eq(toBN(other)); - }; - BigNumber3.prototype.lt = function(other) { - return toBN(this).lt(toBN(other)); - }; - BigNumber3.prototype.lte = function(other) { - return toBN(this).lte(toBN(other)); - }; - BigNumber3.prototype.gt = function(other) { - return toBN(this).gt(toBN(other)); - }; - BigNumber3.prototype.gte = function(other) { - return toBN(this).gte(toBN(other)); - }; - BigNumber3.prototype.isNegative = function() { - return this._hex[0] === "-"; - }; - BigNumber3.prototype.isZero = function() { - return toBN(this).isZero(); - }; - BigNumber3.prototype.toNumber = function() { - try { - return toBN(this).toNumber(); - } catch (error) { - throwFault("overflow", "toNumber", this.toString()); + this._hex = hex; + this._isBigNumber = true; + Object.freeze(this); + } + BigNumber3.prototype.fromTwos = function(value) { + return toBigNumber(toBN(this).fromTwos(value)); + }; + BigNumber3.prototype.toTwos = function(value) { + return toBigNumber(toBN(this).toTwos(value)); + }; + BigNumber3.prototype.abs = function() { + if (this._hex[0] === "-") { + return BigNumber3.from(this._hex.substring(1)); + } + return this; + }; + BigNumber3.prototype.add = function(other) { + return toBigNumber(toBN(this).add(toBN(other))); + }; + BigNumber3.prototype.sub = function(other) { + return toBigNumber(toBN(this).sub(toBN(other))); + }; + BigNumber3.prototype.div = function(other) { + var o = BigNumber3.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + }; + BigNumber3.prototype.mul = function(other) { + return toBigNumber(toBN(this).mul(toBN(other))); + }; + BigNumber3.prototype.mod = function(other) { + var value = toBN(other); + if (value.isNeg()) { + throwFault("cannot modulo negative values", "mod"); + } + return toBigNumber(toBN(this).umod(value)); + }; + BigNumber3.prototype.pow = function(other) { + var value = toBN(other); + if (value.isNeg()) { + throwFault("cannot raise to negative values", "pow"); + } + return toBigNumber(toBN(this).pow(value)); + }; + BigNumber3.prototype.and = function(other) { + var value = toBN(other); + if (this.isNegative() || value.isNeg()) { + throwFault("cannot 'and' negative values", "and"); + } + return toBigNumber(toBN(this).and(value)); + }; + BigNumber3.prototype.or = function(other) { + var value = toBN(other); + if (this.isNegative() || value.isNeg()) { + throwFault("cannot 'or' negative values", "or"); + } + return toBigNumber(toBN(this).or(value)); + }; + BigNumber3.prototype.xor = function(other) { + var value = toBN(other); + if (this.isNegative() || value.isNeg()) { + throwFault("cannot 'xor' negative values", "xor"); + } + return toBigNumber(toBN(this).xor(value)); + }; + BigNumber3.prototype.mask = function(value) { + if (this.isNegative() || value < 0) { + throwFault("cannot mask negative values", "mask"); + } + return toBigNumber(toBN(this).maskn(value)); + }; + BigNumber3.prototype.shl = function(value) { + if (this.isNegative() || value < 0) { + throwFault("cannot shift negative values", "shl"); + } + return toBigNumber(toBN(this).shln(value)); + }; + BigNumber3.prototype.shr = function(value) { + if (this.isNegative() || value < 0) { + throwFault("cannot shift negative values", "shr"); + } + return toBigNumber(toBN(this).shrn(value)); + }; + BigNumber3.prototype.eq = function(other) { + return toBN(this).eq(toBN(other)); + }; + BigNumber3.prototype.lt = function(other) { + return toBN(this).lt(toBN(other)); + }; + BigNumber3.prototype.lte = function(other) { + return toBN(this).lte(toBN(other)); + }; + BigNumber3.prototype.gt = function(other) { + return toBN(this).gt(toBN(other)); + }; + BigNumber3.prototype.gte = function(other) { + return toBN(this).gte(toBN(other)); + }; + BigNumber3.prototype.isNegative = function() { + return this._hex[0] === "-"; + }; + BigNumber3.prototype.isZero = function() { + return toBN(this).isZero(); + }; + BigNumber3.prototype.toNumber = function() { + try { + return toBN(this).toNumber(); + } catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + }; + BigNumber3.prototype.toBigInt = function() { + try { + return BigInt(this.toString()); + } catch (e) { + } + return logger2.throwError("this platform does not support BigInt", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + value: this.toString() + }); + }; + BigNumber3.prototype.toString = function() { + if (arguments.length > 0) { + if (arguments[0] === 10) { + if (!_warnedToStringRadix) { + _warnedToStringRadix = true; + logger2.warn("BigNumber.toString does not accept any parameters; base-10 is assumed"); + } + } else if (arguments[0] === 16) { + logger2.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); + } else { + logger2.throwError("BigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); } - return null; - }; - BigNumber3.prototype.toBigInt = function() { - try { - return BigInt(this.toString()); - } catch (e) { + } + return toBN(this).toString(10); + }; + BigNumber3.prototype.toHexString = function() { + return this._hex; + }; + BigNumber3.prototype.toJSON = function(key) { + return { type: "BigNumber", hex: this.toHexString() }; + }; + BigNumber3.from = function(value) { + if (value instanceof BigNumber3) { + return value; + } + if (typeof value === "string") { + if (value.match(/^-?0x[0-9a-f]+$/i)) { + return new BigNumber3(_constructorGuard, toHex(value)); } - return logger2.throwError("this platform does not support BigInt", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - value: this.toString() - }); - }; - BigNumber3.prototype.toString = function() { - if (arguments.length > 0) { - if (arguments[0] === 10) { - if (!_warnedToStringRadix) { - _warnedToStringRadix = true; - logger2.warn("BigNumber.toString does not accept any parameters; base-10 is assumed"); - } - } else if (arguments[0] === 16) { - logger2.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); - } else { - logger2.throwError("BigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); - } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber3(_constructorGuard, toHex(new BN(value))); } - return toBN(this).toString(10); - }; - BigNumber3.prototype.toHexString = function() { - return this._hex; - }; - BigNumber3.prototype.toJSON = function(key) { - return { type: "BigNumber", hex: this.toHexString() }; - }; - BigNumber3.from = function(value) { - if (value instanceof BigNumber3) { - return value; + return logger2.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof value === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); } - if (typeof value === "string") { - if (value.match(/^-?0x[0-9a-f]+$/i)) { - return new BigNumber3(_constructorGuard, toHex(value)); - } - if (value.match(/^-?[0-9]+$/)) { - return new BigNumber3(_constructorGuard, toHex(new BN(value))); - } - return logger2.throwArgumentError("invalid BigNumber string", "value", value); + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); } - if (typeof value === "number") { - if (value % 1) { - throwFault("underflow", "BigNumber.from", value); + return BigNumber3.from(String(value)); + } + var anyValue = value; + if (typeof anyValue === "bigint") { + return BigNumber3.from(anyValue.toString()); + } + if ((0, bytes_1.isBytes)(anyValue)) { + return BigNumber3.from((0, bytes_1.hexlify)(anyValue)); + } + if (anyValue) { + if (anyValue.toHexString) { + var hex = anyValue.toHexString(); + if (typeof hex === "string") { + return BigNumber3.from(hex); } - if (value >= MAX_SAFE || value <= -MAX_SAFE) { - throwFault("overflow", "BigNumber.from", value); + } else { + var hex = anyValue._hex; + if (hex == null && anyValue.type === "BigNumber") { + hex = anyValue.hex; } - return BigNumber3.from(String(value)); - } - var anyValue = value; - if (typeof anyValue === "bigint") { - return BigNumber3.from(anyValue.toString()); - } - if ((0, bytes_1.isBytes)(anyValue)) { - return BigNumber3.from((0, bytes_1.hexlify)(anyValue)); - } - if (anyValue) { - if (anyValue.toHexString) { - var hex = anyValue.toHexString(); - if (typeof hex === "string") { + if (typeof hex === "string") { + if ((0, bytes_1.isHexString)(hex) || hex[0] === "-" && (0, bytes_1.isHexString)(hex.substring(1))) { return BigNumber3.from(hex); } - } else { - var hex = anyValue._hex; - if (hex == null && anyValue.type === "BigNumber") { - hex = anyValue.hex; - } - if (typeof hex === "string") { - if ((0, bytes_1.isHexString)(hex) || hex[0] === "-" && (0, bytes_1.isHexString)(hex.substring(1))) { - return BigNumber3.from(hex); - } - } } } - return logger2.throwArgumentError("invalid BigNumber value", "value", value); - }; - BigNumber3.isBigNumber = function(value) { - return !!(value && value._isBigNumber); - }; - return BigNumber3; - }() - ); + } + return logger2.throwArgumentError("invalid BigNumber value", "value", value); + }; + BigNumber3.isBigNumber = function(value) { + return !!(value && value._isBigNumber); + }; + return BigNumber3; + }(); exports2.BigNumber = BigNumber2; function toHex(value) { if (typeof value !== "string") { @@ -4420,254 +4444,248 @@ var require_fixednumber = __commonJS({ return wei; } exports2.parseFixed = parseFixed; - var FixedFormat = ( - /** @class */ - function() { - function FixedFormat2(constructorGuard, signed, width, decimals) { - if (constructorGuard !== _constructorGuard) { - logger2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new FixedFormat" - }); - } - this.signed = signed; - this.width = width; - this.decimals = decimals; - this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); - this._multiplier = getMultiplier(decimals); - Object.freeze(this); + var FixedFormat = function() { + function FixedFormat2(constructorGuard, signed, width, decimals) { + if (constructorGuard !== _constructorGuard) { + logger2.throwError("cannot use FixedFormat constructor; use FixedFormat.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new FixedFormat" + }); + } + this.signed = signed; + this.width = width; + this.decimals = decimals; + this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + this._multiplier = getMultiplier(decimals); + Object.freeze(this); + } + FixedFormat2.from = function(value) { + if (value instanceof FixedFormat2) { + return value; } - FixedFormat2.from = function(value) { - if (value instanceof FixedFormat2) { - return value; - } - if (typeof value === "number") { - value = "fixed128x" + value; - } - var signed = true; - var width = 128; - var decimals = 18; - if (typeof value === "string") { - if (value === "fixed") { - } else if (value === "ufixed") { - signed = false; - } else { - var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); - if (!match) { - logger2.throwArgumentError("invalid fixed format", "format", value); - } - signed = match[1] !== "u"; - width = parseInt(match[2]); - decimals = parseInt(match[3]); - } - } else if (value) { - var check = function(key, type, defaultValue) { - if (value[key] == null) { - return defaultValue; - } - if (typeof value[key] !== type) { - logger2.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); - } - return value[key]; - }; - signed = check("signed", "boolean", signed); - width = check("width", "number", width); - decimals = check("decimals", "number", decimals); - } - if (width % 8) { - logger2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); - } - if (decimals > 80) { - logger2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); - } - return new FixedFormat2(_constructorGuard, signed, width, decimals); - }; - return FixedFormat2; - }() - ); - exports2.FixedFormat = FixedFormat; - var FixedNumber = ( - /** @class */ - function() { - function FixedNumber2(constructorGuard, hex, value, format) { - var _newTarget = this.constructor; - logger2.checkNew(_newTarget, FixedNumber2); - if (constructorGuard !== _constructorGuard) { - logger2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new FixedFormat" - }); - } - this.format = format; - this._hex = hex; - this._value = value; - this._isFixedNumber = true; - Object.freeze(this); + if (typeof value === "number") { + value = "fixed128x" + value; } - FixedNumber2.prototype._checkFormat = function(other) { - if (this.format.name !== other.format.name) { - logger2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); - } - }; - FixedNumber2.prototype.addUnsafe = function(other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber2.fromValue(a.add(b), this.format.decimals, this.format); - }; - FixedNumber2.prototype.subUnsafe = function(other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber2.fromValue(a.sub(b), this.format.decimals, this.format); - }; - FixedNumber2.prototype.mulUnsafe = function(other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber2.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); - }; - FixedNumber2.prototype.divUnsafe = function(other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber2.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); - }; - FixedNumber2.prototype.floor = function() { - var comps = this.toString().split("."); - if (comps.length === 1) { - comps.push("0"); - } - var result = FixedNumber2.from(comps[0], this.format); - var hasFraction = !comps[1].match(/^(0*)$/); - if (this.isNegative() && hasFraction) { - result = result.subUnsafe(ONE.toFormat(result.format)); - } - return result; - }; - FixedNumber2.prototype.ceiling = function() { - var comps = this.toString().split("."); - if (comps.length === 1) { - comps.push("0"); - } - var result = FixedNumber2.from(comps[0], this.format); - var hasFraction = !comps[1].match(/^(0*)$/); - if (!this.isNegative() && hasFraction) { - result = result.addUnsafe(ONE.toFormat(result.format)); - } - return result; - }; - FixedNumber2.prototype.round = function(decimals) { - if (decimals == null) { - decimals = 0; - } - var comps = this.toString().split("."); - if (comps.length === 1) { - comps.push("0"); - } - if (decimals < 0 || decimals > 80 || decimals % 1) { - logger2.throwArgumentError("invalid decimal count", "decimals", decimals); - } - if (comps[1].length <= decimals) { - return this; - } - var factor = FixedNumber2.from("1" + zeros.substring(0, decimals), this.format); - var bump = BUMP.toFormat(this.format); - return this.mulUnsafe(factor).addUnsafe(bump).floor().divUnsafe(factor); - }; - FixedNumber2.prototype.isZero = function() { - return this._value === "0.0" || this._value === "0"; - }; - FixedNumber2.prototype.isNegative = function() { - return this._value[0] === "-"; - }; - FixedNumber2.prototype.toString = function() { - return this._value; - }; - FixedNumber2.prototype.toHexString = function(width) { - if (width == null) { - return this._hex; - } - if (width % 8) { - logger2.throwArgumentError("invalid byte width", "width", width); - } - var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); - return (0, bytes_1.hexZeroPad)(hex, width / 8); - }; - FixedNumber2.prototype.toUnsafeFloat = function() { - return parseFloat(this.toString()); - }; - FixedNumber2.prototype.toFormat = function(format) { - return FixedNumber2.fromString(this._value, format); - }; - FixedNumber2.fromValue = function(value, decimals, format) { - if (format == null && decimals != null && !(0, bignumber_1.isBigNumberish)(decimals)) { - format = decimals; - decimals = null; - } - if (decimals == null) { - decimals = 0; - } - if (format == null) { - format = "fixed"; - } - return FixedNumber2.fromString(formatFixed(value, decimals), FixedFormat.from(format)); - }; - FixedNumber2.fromString = function(value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - var numeric = parseFixed(value, fixedFormat.decimals); - if (!fixedFormat.signed && numeric.lt(Zero)) { - throwFault("unsigned value cannot be negative", "overflow", "value", value); - } - var hex = null; - if (fixedFormat.signed) { - hex = numeric.toTwos(fixedFormat.width).toHexString(); + var signed = true; + var width = 128; + var decimals = 18; + if (typeof value === "string") { + if (value === "fixed") { + } else if (value === "ufixed") { + signed = false; } else { - hex = numeric.toHexString(); - hex = (0, bytes_1.hexZeroPad)(hex, fixedFormat.width / 8); - } - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber2(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber2.fromBytes = function(value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - if ((0, bytes_1.arrayify)(value).length > fixedFormat.width / 8) { - throw new Error("overflow"); - } - var numeric = bignumber_1.BigNumber.from(value); - if (fixedFormat.signed) { - numeric = numeric.fromTwos(fixedFormat.width); - } - var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber2(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber2.from = function(value, format) { - if (typeof value === "string") { - return FixedNumber2.fromString(value, format); - } - if ((0, bytes_1.isBytes)(value)) { - return FixedNumber2.fromBytes(value, format); + var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + logger2.throwArgumentError("invalid fixed format", "format", value); + } + signed = match[1] !== "u"; + width = parseInt(match[2]); + decimals = parseInt(match[3]); } - try { - return FixedNumber2.fromValue(value, 0, format); - } catch (error) { - if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) { - throw error; + } else if (value) { + var check = function(key, type, defaultValue) { + if (value[key] == null) { + return defaultValue; + } + if (typeof value[key] !== type) { + logger2.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + logger2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + logger2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat2(_constructorGuard, signed, width, decimals); + }; + return FixedFormat2; + }(); + exports2.FixedFormat = FixedFormat; + var FixedNumber = function() { + function FixedNumber2(constructorGuard, hex, value, format) { + var _newTarget = this.constructor; + logger2.checkNew(_newTarget, FixedNumber2); + if (constructorGuard !== _constructorGuard) { + logger2.throwError("cannot use FixedNumber constructor; use FixedNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new FixedFormat" + }); + } + this.format = format; + this._hex = hex; + this._value = value; + this._isFixedNumber = true; + Object.freeze(this); + } + FixedNumber2.prototype._checkFormat = function(other) { + if (this.format.name !== other.format.name) { + logger2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + }; + FixedNumber2.prototype.addUnsafe = function(other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber2.fromValue(a.add(b), this.format.decimals, this.format); + }; + FixedNumber2.prototype.subUnsafe = function(other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber2.fromValue(a.sub(b), this.format.decimals, this.format); + }; + FixedNumber2.prototype.mulUnsafe = function(other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber2.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + }; + FixedNumber2.prototype.divUnsafe = function(other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber2.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + }; + FixedNumber2.prototype.floor = function() { + var comps = this.toString().split("."); + if (comps.length === 1) { + comps.push("0"); + } + var result = FixedNumber2.from(comps[0], this.format); + var hasFraction = !comps[1].match(/^(0*)$/); + if (this.isNegative() && hasFraction) { + result = result.subUnsafe(ONE.toFormat(result.format)); + } + return result; + }; + FixedNumber2.prototype.ceiling = function() { + var comps = this.toString().split("."); + if (comps.length === 1) { + comps.push("0"); + } + var result = FixedNumber2.from(comps[0], this.format); + var hasFraction = !comps[1].match(/^(0*)$/); + if (!this.isNegative() && hasFraction) { + result = result.addUnsafe(ONE.toFormat(result.format)); + } + return result; + }; + FixedNumber2.prototype.round = function(decimals) { + if (decimals == null) { + decimals = 0; + } + var comps = this.toString().split("."); + if (comps.length === 1) { + comps.push("0"); + } + if (decimals < 0 || decimals > 80 || decimals % 1) { + logger2.throwArgumentError("invalid decimal count", "decimals", decimals); + } + if (comps[1].length <= decimals) { + return this; + } + var factor = FixedNumber2.from("1" + zeros.substring(0, decimals), this.format); + var bump = BUMP.toFormat(this.format); + return this.mulUnsafe(factor).addUnsafe(bump).floor().divUnsafe(factor); + }; + FixedNumber2.prototype.isZero = function() { + return this._value === "0.0" || this._value === "0"; + }; + FixedNumber2.prototype.isNegative = function() { + return this._value[0] === "-"; + }; + FixedNumber2.prototype.toString = function() { + return this._value; + }; + FixedNumber2.prototype.toHexString = function(width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + logger2.throwArgumentError("invalid byte width", "width", width); + } + var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return (0, bytes_1.hexZeroPad)(hex, width / 8); + }; + FixedNumber2.prototype.toUnsafeFloat = function() { + return parseFloat(this.toString()); + }; + FixedNumber2.prototype.toFormat = function(format) { + return FixedNumber2.fromString(this._value, format); + }; + FixedNumber2.fromValue = function(value, decimals, format) { + if (format == null && decimals != null && !(0, bignumber_1.isBigNumberish)(decimals)) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + return FixedNumber2.fromString(formatFixed(value, decimals), FixedFormat.from(format)); + }; + FixedNumber2.fromString = function(value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + var numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + var hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } else { + hex = numeric.toHexString(); + hex = (0, bytes_1.hexZeroPad)(hex, fixedFormat.width / 8); + } + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber2(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber2.fromBytes = function(value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + if ((0, bytes_1.arrayify)(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + var numeric = bignumber_1.BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber2(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber2.from = function(value, format) { + if (typeof value === "string") { + return FixedNumber2.fromString(value, format); + } + if ((0, bytes_1.isBytes)(value)) { + return FixedNumber2.fromBytes(value, format); + } + try { + return FixedNumber2.fromValue(value, 0, format); + } catch (error) { + if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) { + throw error; } - return logger2.throwArgumentError("invalid FixedNumber value", "value", value); - }; - FixedNumber2.isFixedNumber = function(value) { - return !!(value && value._isFixedNumber); - }; - return FixedNumber2; - }() - ); + } + return logger2.throwArgumentError("invalid FixedNumber value", "value", value); + }; + FixedNumber2.isFixedNumber = function(value) { + return !!(value && value._isFixedNumber); + }; + return FixedNumber2; + }(); exports2.FixedNumber = FixedNumber; var ONE = FixedNumber.from(1); var BUMP = FixedNumber.from("0.5"); @@ -4721,7 +4739,7 @@ var require_version4 = __commonJS({ var require_lib4 = __commonJS({ "node_modules/@ethersproject/properties/lib/index.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -4748,7 +4766,7 @@ var require_lib4 = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -4851,9 +4869,9 @@ var require_lib4 = __commonJS({ } exports2.getStatic = getStatic; function resolveProperties(object) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var promises, results; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: promises = Object.keys(object).map(function(key) { @@ -4944,17 +4962,14 @@ var require_lib4 = __commonJS({ return _deepCopy(object); } exports2.deepCopy = deepCopy; - var Description = ( - /** @class */ - function() { - function Description2(info) { - for (var key in info) { - this[key] = deepCopy(info[key]); - } + var Description = function() { + function Description2(info) { + for (var key in info) { + this[key] = deepCopy(info[key]); } - return Description2; - }() - ); + } + return Description2; + }(); exports2.Description = Description; } }); @@ -4973,21 +4988,21 @@ var require_version5 = __commonJS({ var require_fragments = __commonJS({ "node_modules/@ethersproject/abi/lib/fragments.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -5179,286 +5194,273 @@ var require_fragments = __commonJS({ } } exports2.FormatTypes = Object.freeze({ - // Bare formatting, as is needed for computing a sighash of an event or function sighash: "sighash", - // Human-Readable with Minimal spacing and without names (compact human-readable) minimal: "minimal", - // Human-Readable with nice spacing, including all names full: "full", - // JSON-format a la Solidity json: "json" }); var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); - var ParamType = ( - /** @class */ - function() { - function ParamType2(constructorGuard, params) { - if (constructorGuard !== _constructorGuard) { - logger2.throwError("use fromString", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new ParamType()" - }); + var ParamType = function() { + function ParamType2(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + logger2.throwError("use fromString", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new ParamType()" + }); + } + populate(this, params); + var match = this.type.match(paramTypeArray); + if (match) { + populate(this, { + arrayLength: parseInt(match[2] || "-1"), + arrayChildren: ParamType2.fromObject({ + type: match[1], + components: this.components + }), + baseType: "array" + }); + } else { + populate(this, { + arrayLength: null, + arrayChildren: null, + baseType: this.components != null ? "tuple" : this.type + }); + } + this._isParamType = true; + Object.freeze(this); + } + ParamType2.prototype.format = function(format) { + if (!format) { + format = exports2.FormatTypes.sighash; + } + if (!exports2.FormatTypes[format]) { + logger2.throwArgumentError("invalid format type", "format", format); + } + if (format === exports2.FormatTypes.json) { + var result_1 = { + type: this.baseType === "tuple" ? "tuple" : this.type, + name: this.name || void 0 + }; + if (typeof this.indexed === "boolean") { + result_1.indexed = this.indexed; } - populate(this, params); - var match = this.type.match(paramTypeArray); - if (match) { - populate(this, { - arrayLength: parseInt(match[2] || "-1"), - arrayChildren: ParamType2.fromObject({ - type: match[1], - components: this.components - }), - baseType: "array" - }); - } else { - populate(this, { - arrayLength: null, - arrayChildren: null, - baseType: this.components != null ? "tuple" : this.type + if (this.components) { + result_1.components = this.components.map(function(comp) { + return JSON.parse(comp.format(format)); }); } - this._isParamType = true; - Object.freeze(this); + return JSON.stringify(result_1); } - ParamType2.prototype.format = function(format) { - if (!format) { - format = exports2.FormatTypes.sighash; - } - if (!exports2.FormatTypes[format]) { - logger2.throwArgumentError("invalid format type", "format", format); - } - if (format === exports2.FormatTypes.json) { - var result_1 = { - type: this.baseType === "tuple" ? "tuple" : this.type, - name: this.name || void 0 - }; - if (typeof this.indexed === "boolean") { - result_1.indexed = this.indexed; - } - if (this.components) { - result_1.components = this.components.map(function(comp) { - return JSON.parse(comp.format(format)); - }); - } - return JSON.stringify(result_1); - } - var result = ""; - if (this.baseType === "array") { - result += this.arrayChildren.format(format); - result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; - } else { - if (this.baseType === "tuple") { - if (format !== exports2.FormatTypes.sighash) { - result += this.type; - } - result += "(" + this.components.map(function(comp) { - return comp.format(format); - }).join(format === exports2.FormatTypes.full ? ", " : ",") + ")"; - } else { + var result = ""; + if (this.baseType === "array") { + result += this.arrayChildren.format(format); + result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; + } else { + if (this.baseType === "tuple") { + if (format !== exports2.FormatTypes.sighash) { result += this.type; } + result += "(" + this.components.map(function(comp) { + return comp.format(format); + }).join(format === exports2.FormatTypes.full ? ", " : ",") + ")"; + } else { + result += this.type; } - if (format !== exports2.FormatTypes.sighash) { - if (this.indexed === true) { - result += " indexed"; - } - if (format === exports2.FormatTypes.full && this.name) { - result += " " + this.name; - } + } + if (format !== exports2.FormatTypes.sighash) { + if (this.indexed === true) { + result += " indexed"; } - return result; - }; - ParamType2.from = function(value, allowIndexed) { - if (typeof value === "string") { - return ParamType2.fromString(value, allowIndexed); + if (format === exports2.FormatTypes.full && this.name) { + result += " " + this.name; } - return ParamType2.fromObject(value); - }; - ParamType2.fromObject = function(value) { - if (ParamType2.isParamType(value)) { - return value; - } - return new ParamType2(_constructorGuard, { - name: value.name || null, - type: verifyType(value.type), - indexed: value.indexed == null ? null : !!value.indexed, - components: value.components ? value.components.map(ParamType2.fromObject) : null + } + return result; + }; + ParamType2.from = function(value, allowIndexed) { + if (typeof value === "string") { + return ParamType2.fromString(value, allowIndexed); + } + return ParamType2.fromObject(value); + }; + ParamType2.fromObject = function(value) { + if (ParamType2.isParamType(value)) { + return value; + } + return new ParamType2(_constructorGuard, { + name: value.name || null, + type: verifyType(value.type), + indexed: value.indexed == null ? null : !!value.indexed, + components: value.components ? value.components.map(ParamType2.fromObject) : null + }); + }; + ParamType2.fromString = function(value, allowIndexed) { + function ParamTypify(node) { + return ParamType2.fromObject({ + name: node.name, + type: node.type, + indexed: node.indexed, + components: node.components }); - }; - ParamType2.fromString = function(value, allowIndexed) { - function ParamTypify(node) { - return ParamType2.fromObject({ - name: node.name, - type: node.type, - indexed: node.indexed, - components: node.components - }); - } - return ParamTypify(parseParamType(value, !!allowIndexed)); - }; - ParamType2.isParamType = function(value) { - return !!(value != null && value._isParamType); - }; - return ParamType2; - }() - ); + } + return ParamTypify(parseParamType(value, !!allowIndexed)); + }; + ParamType2.isParamType = function(value) { + return !!(value != null && value._isParamType); + }; + return ParamType2; + }(); exports2.ParamType = ParamType; function parseParams(value, allowIndex) { return splitNesting(value).map(function(param) { return ParamType.fromString(param, allowIndex); }); } - var Fragment = ( - /** @class */ - function() { - function Fragment2(constructorGuard, params) { - if (constructorGuard !== _constructorGuard) { - logger2.throwError("use a static from method", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new Fragment()" - }); - } - populate(this, params); - this._isFragment = true; - Object.freeze(this); + var Fragment = function() { + function Fragment2(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + logger2.throwError("use a static from method", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new Fragment()" + }); } - Fragment2.from = function(value) { - if (Fragment2.isFragment(value)) { - return value; - } - if (typeof value === "string") { - return Fragment2.fromString(value); - } - return Fragment2.fromObject(value); - }; - Fragment2.fromObject = function(value) { - if (Fragment2.isFragment(value)) { - return value; - } - switch (value.type) { - case "function": - return FunctionFragment.fromObject(value); - case "event": - return EventFragment.fromObject(value); - case "constructor": - return ConstructorFragment.fromObject(value); - case "error": - return ErrorFragment.fromObject(value); - case "fallback": - case "receive": - return null; - } - return logger2.throwArgumentError("invalid fragment object", "value", value); - }; - Fragment2.fromString = function(value) { - value = value.replace(/\s/g, " "); - value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); - value = value.trim(); - if (value.split(" ")[0] === "event") { - return EventFragment.fromString(value.substring(5).trim()); - } else if (value.split(" ")[0] === "function") { - return FunctionFragment.fromString(value.substring(8).trim()); - } else if (value.split("(")[0].trim() === "constructor") { - return ConstructorFragment.fromString(value.trim()); - } else if (value.split(" ")[0] === "error") { - return ErrorFragment.fromString(value.substring(5).trim()); - } - return logger2.throwArgumentError("unsupported fragment", "value", value); - }; - Fragment2.isFragment = function(value) { - return !!(value && value._isFragment); - }; - return Fragment2; - }() - ); + populate(this, params); + this._isFragment = true; + Object.freeze(this); + } + Fragment2.from = function(value) { + if (Fragment2.isFragment(value)) { + return value; + } + if (typeof value === "string") { + return Fragment2.fromString(value); + } + return Fragment2.fromObject(value); + }; + Fragment2.fromObject = function(value) { + if (Fragment2.isFragment(value)) { + return value; + } + switch (value.type) { + case "function": + return FunctionFragment.fromObject(value); + case "event": + return EventFragment.fromObject(value); + case "constructor": + return ConstructorFragment.fromObject(value); + case "error": + return ErrorFragment.fromObject(value); + case "fallback": + case "receive": + return null; + } + return logger2.throwArgumentError("invalid fragment object", "value", value); + }; + Fragment2.fromString = function(value) { + value = value.replace(/\s/g, " "); + value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); + value = value.trim(); + if (value.split(" ")[0] === "event") { + return EventFragment.fromString(value.substring(5).trim()); + } else if (value.split(" ")[0] === "function") { + return FunctionFragment.fromString(value.substring(8).trim()); + } else if (value.split("(")[0].trim() === "constructor") { + return ConstructorFragment.fromString(value.trim()); + } else if (value.split(" ")[0] === "error") { + return ErrorFragment.fromString(value.substring(5).trim()); + } + return logger2.throwArgumentError("unsupported fragment", "value", value); + }; + Fragment2.isFragment = function(value) { + return !!(value && value._isFragment); + }; + return Fragment2; + }(); exports2.Fragment = Fragment; - var EventFragment = ( - /** @class */ - function(_super) { - __extends2(EventFragment2, _super); - function EventFragment2() { - return _super !== null && _super.apply(this, arguments) || this; - } - EventFragment2.prototype.format = function(format) { - if (!format) { - format = exports2.FormatTypes.sighash; - } - if (!exports2.FormatTypes[format]) { - logger2.throwArgumentError("invalid format type", "format", format); - } - if (format === exports2.FormatTypes.json) { - return JSON.stringify({ - type: "event", - anonymous: this.anonymous, - name: this.name, - inputs: this.inputs.map(function(input) { - return JSON.parse(input.format(format)); - }) - }); - } - var result = ""; - if (format !== exports2.FormatTypes.sighash) { - result += "event "; - } - result += this.name + "(" + this.inputs.map(function(input) { - return input.format(format); - }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; - if (format !== exports2.FormatTypes.sighash) { - if (this.anonymous) { - result += "anonymous "; - } - } - return result.trim(); - }; - EventFragment2.from = function(value) { - if (typeof value === "string") { - return EventFragment2.fromString(value); + var EventFragment = function(_super) { + __extends(EventFragment2, _super); + function EventFragment2() { + return _super !== null && _super.apply(this, arguments) || this; + } + EventFragment2.prototype.format = function(format) { + if (!format) { + format = exports2.FormatTypes.sighash; + } + if (!exports2.FormatTypes[format]) { + logger2.throwArgumentError("invalid format type", "format", format); + } + if (format === exports2.FormatTypes.json) { + return JSON.stringify({ + type: "event", + anonymous: this.anonymous, + name: this.name, + inputs: this.inputs.map(function(input) { + return JSON.parse(input.format(format)); + }) + }); + } + var result = ""; + if (format !== exports2.FormatTypes.sighash) { + result += "event "; + } + result += this.name + "(" + this.inputs.map(function(input) { + return input.format(format); + }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; + if (format !== exports2.FormatTypes.sighash) { + if (this.anonymous) { + result += "anonymous "; } - return EventFragment2.fromObject(value); + } + return result.trim(); + }; + EventFragment2.from = function(value) { + if (typeof value === "string") { + return EventFragment2.fromString(value); + } + return EventFragment2.fromObject(value); + }; + EventFragment2.fromObject = function(value) { + if (EventFragment2.isEventFragment(value)) { + return value; + } + if (value.type !== "event") { + logger2.throwArgumentError("invalid event object", "value", value); + } + var params = { + name: verifyIdentifier(value.name), + anonymous: value.anonymous, + inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], + type: "event" }; - EventFragment2.fromObject = function(value) { - if (EventFragment2.isEventFragment(value)) { - return value; - } - if (value.type !== "event") { - logger2.throwArgumentError("invalid event object", "value", value); + return new EventFragment2(_constructorGuard, params); + }; + EventFragment2.fromString = function(value) { + var match = value.match(regexParen); + if (!match) { + logger2.throwArgumentError("invalid event string", "value", value); + } + var anonymous = false; + match[3].split(" ").forEach(function(modifier) { + switch (modifier.trim()) { + case "anonymous": + anonymous = true; + break; + case "": + break; + default: + logger2.warn("unknown modifier: " + modifier); } - var params = { - name: verifyIdentifier(value.name), - anonymous: value.anonymous, - inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], - type: "event" - }; - return new EventFragment2(_constructorGuard, params); - }; - EventFragment2.fromString = function(value) { - var match = value.match(regexParen); - if (!match) { - logger2.throwArgumentError("invalid event string", "value", value); - } - var anonymous = false; - match[3].split(" ").forEach(function(modifier) { - switch (modifier.trim()) { - case "anonymous": - anonymous = true; - break; - case "": - break; - default: - logger2.warn("unknown modifier: " + modifier); - } - }); - return EventFragment2.fromObject({ - name: match[1].trim(), - anonymous, - inputs: parseParams(match[2], true), - type: "event" - }); - }; - EventFragment2.isEventFragment = function(value) { - return value && value._isFragment && value.type === "event"; - }; - return EventFragment2; - }(Fragment) - ); + }); + return EventFragment2.fromObject({ + name: match[1].trim(), + anonymous, + inputs: parseParams(match[2], true), + type: "event" + }); + }; + EventFragment2.isEventFragment = function(value) { + return value && value._isFragment && value.type === "event"; + }; + return EventFragment2; + }(Fragment); exports2.EventFragment = EventFragment; function parseGas(value, params) { params.gas = null; @@ -5552,205 +5554,199 @@ var require_fragments = __commonJS({ } return result; } - var ConstructorFragment = ( - /** @class */ - function(_super) { - __extends2(ConstructorFragment2, _super); - function ConstructorFragment2() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstructorFragment2.prototype.format = function(format) { - if (!format) { - format = exports2.FormatTypes.sighash; - } - if (!exports2.FormatTypes[format]) { - logger2.throwArgumentError("invalid format type", "format", format); - } - if (format === exports2.FormatTypes.json) { - return JSON.stringify({ - type: "constructor", - stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0, - payable: this.payable, - gas: this.gas ? this.gas.toNumber() : void 0, - inputs: this.inputs.map(function(input) { - return JSON.parse(input.format(format)); - }) - }); - } - if (format === exports2.FormatTypes.sighash) { - logger2.throwError("cannot format a constructor for sighash", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "format(sighash)" - }); - } - var result = "constructor(" + this.inputs.map(function(input) { - return input.format(format); - }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; - if (this.stateMutability && this.stateMutability !== "nonpayable") { - result += this.stateMutability + " "; - } - return result.trim(); - }; - ConstructorFragment2.from = function(value) { - if (typeof value === "string") { - return ConstructorFragment2.fromString(value); - } - return ConstructorFragment2.fromObject(value); - }; - ConstructorFragment2.fromObject = function(value) { - if (ConstructorFragment2.isConstructorFragment(value)) { - return value; - } - if (value.type !== "constructor") { - logger2.throwArgumentError("invalid constructor object", "value", value); - } - var state = verifyState(value); - if (state.constant) { - logger2.throwArgumentError("constructor cannot be constant", "value", value); - } - var params = { - name: null, - type: value.type, - inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], - payable: state.payable, - stateMutability: state.stateMutability, - gas: value.gas ? bignumber_1.BigNumber.from(value.gas) : null - }; - return new ConstructorFragment2(_constructorGuard, params); - }; - ConstructorFragment2.fromString = function(value) { - var params = { type: "constructor" }; - value = parseGas(value, params); - var parens = value.match(regexParen); - if (!parens || parens[1].trim() !== "constructor") { - logger2.throwArgumentError("invalid constructor string", "value", value); - } - params.inputs = parseParams(parens[2].trim(), false); - parseModifiers(parens[3].trim(), params); - return ConstructorFragment2.fromObject(params); - }; - ConstructorFragment2.isConstructorFragment = function(value) { - return value && value._isFragment && value.type === "constructor"; + var ConstructorFragment = function(_super) { + __extends(ConstructorFragment2, _super); + function ConstructorFragment2() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConstructorFragment2.prototype.format = function(format) { + if (!format) { + format = exports2.FormatTypes.sighash; + } + if (!exports2.FormatTypes[format]) { + logger2.throwArgumentError("invalid format type", "format", format); + } + if (format === exports2.FormatTypes.json) { + return JSON.stringify({ + type: "constructor", + stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0, + payable: this.payable, + gas: this.gas ? this.gas.toNumber() : void 0, + inputs: this.inputs.map(function(input) { + return JSON.parse(input.format(format)); + }) + }); + } + if (format === exports2.FormatTypes.sighash) { + logger2.throwError("cannot format a constructor for sighash", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "format(sighash)" + }); + } + var result = "constructor(" + this.inputs.map(function(input) { + return input.format(format); + }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; + if (this.stateMutability && this.stateMutability !== "nonpayable") { + result += this.stateMutability + " "; + } + return result.trim(); + }; + ConstructorFragment2.from = function(value) { + if (typeof value === "string") { + return ConstructorFragment2.fromString(value); + } + return ConstructorFragment2.fromObject(value); + }; + ConstructorFragment2.fromObject = function(value) { + if (ConstructorFragment2.isConstructorFragment(value)) { + return value; + } + if (value.type !== "constructor") { + logger2.throwArgumentError("invalid constructor object", "value", value); + } + var state = verifyState(value); + if (state.constant) { + logger2.throwArgumentError("constructor cannot be constant", "value", value); + } + var params = { + name: null, + type: value.type, + inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], + payable: state.payable, + stateMutability: state.stateMutability, + gas: value.gas ? bignumber_1.BigNumber.from(value.gas) : null }; - return ConstructorFragment2; - }(Fragment) - ); + return new ConstructorFragment2(_constructorGuard, params); + }; + ConstructorFragment2.fromString = function(value) { + var params = { type: "constructor" }; + value = parseGas(value, params); + var parens = value.match(regexParen); + if (!parens || parens[1].trim() !== "constructor") { + logger2.throwArgumentError("invalid constructor string", "value", value); + } + params.inputs = parseParams(parens[2].trim(), false); + parseModifiers(parens[3].trim(), params); + return ConstructorFragment2.fromObject(params); + }; + ConstructorFragment2.isConstructorFragment = function(value) { + return value && value._isFragment && value.type === "constructor"; + }; + return ConstructorFragment2; + }(Fragment); exports2.ConstructorFragment = ConstructorFragment; - var FunctionFragment = ( - /** @class */ - function(_super) { - __extends2(FunctionFragment2, _super); - function FunctionFragment2() { - return _super !== null && _super.apply(this, arguments) || this; - } - FunctionFragment2.prototype.format = function(format) { - if (!format) { - format = exports2.FormatTypes.sighash; - } - if (!exports2.FormatTypes[format]) { - logger2.throwArgumentError("invalid format type", "format", format); - } - if (format === exports2.FormatTypes.json) { - return JSON.stringify({ - type: "function", - name: this.name, - constant: this.constant, - stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0, - payable: this.payable, - gas: this.gas ? this.gas.toNumber() : void 0, - inputs: this.inputs.map(function(input) { - return JSON.parse(input.format(format)); - }), - outputs: this.outputs.map(function(output) { - return JSON.parse(output.format(format)); - }) - }); - } - var result = ""; - if (format !== exports2.FormatTypes.sighash) { - result += "function "; - } - result += this.name + "(" + this.inputs.map(function(input) { - return input.format(format); - }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; - if (format !== exports2.FormatTypes.sighash) { - if (this.stateMutability) { - if (this.stateMutability !== "nonpayable") { - result += this.stateMutability + " "; - } - } else if (this.constant) { - result += "view "; - } - if (this.outputs && this.outputs.length) { - result += "returns (" + this.outputs.map(function(output) { - return output.format(format); - }).join(", ") + ") "; - } - if (this.gas != null) { - result += "@" + this.gas.toString() + " "; + var FunctionFragment = function(_super) { + __extends(FunctionFragment2, _super); + function FunctionFragment2() { + return _super !== null && _super.apply(this, arguments) || this; + } + FunctionFragment2.prototype.format = function(format) { + if (!format) { + format = exports2.FormatTypes.sighash; + } + if (!exports2.FormatTypes[format]) { + logger2.throwArgumentError("invalid format type", "format", format); + } + if (format === exports2.FormatTypes.json) { + return JSON.stringify({ + type: "function", + name: this.name, + constant: this.constant, + stateMutability: this.stateMutability !== "nonpayable" ? this.stateMutability : void 0, + payable: this.payable, + gas: this.gas ? this.gas.toNumber() : void 0, + inputs: this.inputs.map(function(input) { + return JSON.parse(input.format(format)); + }), + outputs: this.outputs.map(function(output) { + return JSON.parse(output.format(format)); + }) + }); + } + var result = ""; + if (format !== exports2.FormatTypes.sighash) { + result += "function "; + } + result += this.name + "(" + this.inputs.map(function(input) { + return input.format(format); + }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; + if (format !== exports2.FormatTypes.sighash) { + if (this.stateMutability) { + if (this.stateMutability !== "nonpayable") { + result += this.stateMutability + " "; } + } else if (this.constant) { + result += "view "; } - return result.trim(); - }; - FunctionFragment2.from = function(value) { - if (typeof value === "string") { - return FunctionFragment2.fromString(value); + if (this.outputs && this.outputs.length) { + result += "returns (" + this.outputs.map(function(output) { + return output.format(format); + }).join(", ") + ") "; } - return FunctionFragment2.fromObject(value); - }; - FunctionFragment2.fromObject = function(value) { - if (FunctionFragment2.isFunctionFragment(value)) { - return value; + if (this.gas != null) { + result += "@" + this.gas.toString() + " "; } - if (value.type !== "function") { - logger2.throwArgumentError("invalid function object", "value", value); - } - var state = verifyState(value); - var params = { - type: value.type, - name: verifyIdentifier(value.name), - constant: state.constant, - inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], - outputs: value.outputs ? value.outputs.map(ParamType.fromObject) : [], - payable: state.payable, - stateMutability: state.stateMutability, - gas: value.gas ? bignumber_1.BigNumber.from(value.gas) : null - }; - return new FunctionFragment2(_constructorGuard, params); - }; - FunctionFragment2.fromString = function(value) { - var params = { type: "function" }; - value = parseGas(value, params); - var comps = value.split(" returns "); - if (comps.length > 2) { - logger2.throwArgumentError("invalid function string", "value", value); - } - var parens = comps[0].match(regexParen); - if (!parens) { - logger2.throwArgumentError("invalid function signature", "value", value); - } - params.name = parens[1].trim(); - if (params.name) { - verifyIdentifier(params.name); - } - params.inputs = parseParams(parens[2], false); - parseModifiers(parens[3].trim(), params); - if (comps.length > 1) { - var returns = comps[1].match(regexParen); - if (returns[1].trim() != "" || returns[3].trim() != "") { - logger2.throwArgumentError("unexpected tokens", "value", value); - } - params.outputs = parseParams(returns[2], false); - } else { - params.outputs = []; + } + return result.trim(); + }; + FunctionFragment2.from = function(value) { + if (typeof value === "string") { + return FunctionFragment2.fromString(value); + } + return FunctionFragment2.fromObject(value); + }; + FunctionFragment2.fromObject = function(value) { + if (FunctionFragment2.isFunctionFragment(value)) { + return value; + } + if (value.type !== "function") { + logger2.throwArgumentError("invalid function object", "value", value); + } + var state = verifyState(value); + var params = { + type: value.type, + name: verifyIdentifier(value.name), + constant: state.constant, + inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [], + outputs: value.outputs ? value.outputs.map(ParamType.fromObject) : [], + payable: state.payable, + stateMutability: state.stateMutability, + gas: value.gas ? bignumber_1.BigNumber.from(value.gas) : null + }; + return new FunctionFragment2(_constructorGuard, params); + }; + FunctionFragment2.fromString = function(value) { + var params = { type: "function" }; + value = parseGas(value, params); + var comps = value.split(" returns "); + if (comps.length > 2) { + logger2.throwArgumentError("invalid function string", "value", value); + } + var parens = comps[0].match(regexParen); + if (!parens) { + logger2.throwArgumentError("invalid function signature", "value", value); + } + params.name = parens[1].trim(); + if (params.name) { + verifyIdentifier(params.name); + } + params.inputs = parseParams(parens[2], false); + parseModifiers(parens[3].trim(), params); + if (comps.length > 1) { + var returns = comps[1].match(regexParen); + if (returns[1].trim() != "" || returns[3].trim() != "") { + logger2.throwArgumentError("unexpected tokens", "value", value); } - return FunctionFragment2.fromObject(params); - }; - FunctionFragment2.isFunctionFragment = function(value) { - return value && value._isFragment && value.type === "function"; - }; - return FunctionFragment2; - }(ConstructorFragment) - ); + params.outputs = parseParams(returns[2], false); + } else { + params.outputs = []; + } + return FunctionFragment2.fromObject(params); + }; + FunctionFragment2.isFunctionFragment = function(value) { + return value && value._isFragment && value.type === "function"; + }; + return FunctionFragment2; + }(ConstructorFragment); exports2.FunctionFragment = FunctionFragment; function checkForbidden(fragment) { var sig = fragment.format(); @@ -5759,77 +5755,74 @@ var require_fragments = __commonJS({ } return fragment; } - var ErrorFragment = ( - /** @class */ - function(_super) { - __extends2(ErrorFragment2, _super); - function ErrorFragment2() { - return _super !== null && _super.apply(this, arguments) || this; - } - ErrorFragment2.prototype.format = function(format) { - if (!format) { - format = exports2.FormatTypes.sighash; - } - if (!exports2.FormatTypes[format]) { - logger2.throwArgumentError("invalid format type", "format", format); - } - if (format === exports2.FormatTypes.json) { - return JSON.stringify({ - type: "error", - name: this.name, - inputs: this.inputs.map(function(input) { - return JSON.parse(input.format(format)); - }) - }); - } - var result = ""; - if (format !== exports2.FormatTypes.sighash) { - result += "error "; - } - result += this.name + "(" + this.inputs.map(function(input) { - return input.format(format); - }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; - return result.trim(); - }; - ErrorFragment2.from = function(value) { - if (typeof value === "string") { - return ErrorFragment2.fromString(value); - } - return ErrorFragment2.fromObject(value); - }; - ErrorFragment2.fromObject = function(value) { - if (ErrorFragment2.isErrorFragment(value)) { - return value; - } - if (value.type !== "error") { - logger2.throwArgumentError("invalid error object", "value", value); - } - var params = { - type: value.type, - name: verifyIdentifier(value.name), - inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [] - }; - return checkForbidden(new ErrorFragment2(_constructorGuard, params)); - }; - ErrorFragment2.fromString = function(value) { - var params = { type: "error" }; - var parens = value.match(regexParen); - if (!parens) { - logger2.throwArgumentError("invalid error signature", "value", value); - } - params.name = parens[1].trim(); - if (params.name) { - verifyIdentifier(params.name); - } - params.inputs = parseParams(parens[2], false); - return checkForbidden(ErrorFragment2.fromObject(params)); - }; - ErrorFragment2.isErrorFragment = function(value) { - return value && value._isFragment && value.type === "error"; + var ErrorFragment = function(_super) { + __extends(ErrorFragment2, _super); + function ErrorFragment2() { + return _super !== null && _super.apply(this, arguments) || this; + } + ErrorFragment2.prototype.format = function(format) { + if (!format) { + format = exports2.FormatTypes.sighash; + } + if (!exports2.FormatTypes[format]) { + logger2.throwArgumentError("invalid format type", "format", format); + } + if (format === exports2.FormatTypes.json) { + return JSON.stringify({ + type: "error", + name: this.name, + inputs: this.inputs.map(function(input) { + return JSON.parse(input.format(format)); + }) + }); + } + var result = ""; + if (format !== exports2.FormatTypes.sighash) { + result += "error "; + } + result += this.name + "(" + this.inputs.map(function(input) { + return input.format(format); + }).join(format === exports2.FormatTypes.full ? ", " : ",") + ") "; + return result.trim(); + }; + ErrorFragment2.from = function(value) { + if (typeof value === "string") { + return ErrorFragment2.fromString(value); + } + return ErrorFragment2.fromObject(value); + }; + ErrorFragment2.fromObject = function(value) { + if (ErrorFragment2.isErrorFragment(value)) { + return value; + } + if (value.type !== "error") { + logger2.throwArgumentError("invalid error object", "value", value); + } + var params = { + type: value.type, + name: verifyIdentifier(value.name), + inputs: value.inputs ? value.inputs.map(ParamType.fromObject) : [] }; - return ErrorFragment2; - }(Fragment) - ); + return checkForbidden(new ErrorFragment2(_constructorGuard, params)); + }; + ErrorFragment2.fromString = function(value) { + var params = { type: "error" }; + var parens = value.match(regexParen); + if (!parens) { + logger2.throwArgumentError("invalid error signature", "value", value); + } + params.name = parens[1].trim(); + if (params.name) { + verifyIdentifier(params.name); + } + params.inputs = parseParams(parens[2], false); + return checkForbidden(ErrorFragment2.fromObject(params)); + }; + ErrorFragment2.isErrorFragment = function(value) { + return value && value._isFragment && value.type === "error"; + }; + return ErrorFragment2; + }(Fragment); exports2.ErrorFragment = ErrorFragment; function verifyType(type) { if (type.match(/^uint($|[^1-9])/)) { @@ -5909,155 +5902,146 @@ var require_abstract_coder = __commonJS({ return errors; } exports2.checkResultErrors = checkResultErrors; - var Coder = ( - /** @class */ - function() { - function Coder2(name2, type, localName, dynamic) { - this.name = name2; - this.type = type; - this.localName = localName; - this.dynamic = dynamic; - } - Coder2.prototype._throwError = function(message, value) { - logger2.throwArgumentError(message, this.localName, value); - }; - return Coder2; - }() - ); + var Coder = function() { + function Coder2(name2, type, localName, dynamic) { + this.name = name2; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + Coder2.prototype._throwError = function(message, value) { + logger2.throwArgumentError(message, this.localName, value); + }; + return Coder2; + }(); exports2.Coder = Coder; - var Writer2 = ( - /** @class */ - function() { - function Writer3(wordSize) { - (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32); - this._data = []; - this._dataLength = 0; - this._padding = new Uint8Array(wordSize); - } - Object.defineProperty(Writer3.prototype, "data", { - get: function() { - return (0, bytes_1.hexConcat)(this._data); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Writer3.prototype, "length", { - get: function() { - return this._dataLength; - }, - enumerable: false, - configurable: true - }); - Writer3.prototype._writeData = function(data) { - this._data.push(data); - this._dataLength += data.length; - return data.length; - }; - Writer3.prototype.appendWriter = function(writer) { - return this._writeData((0, bytes_1.concat)(writer._data)); - }; - Writer3.prototype.writeBytes = function(value) { - var bytes = (0, bytes_1.arrayify)(value); - var paddingOffset = bytes.length % this.wordSize; - if (paddingOffset) { - bytes = (0, bytes_1.concat)([bytes, this._padding.slice(paddingOffset)]); - } - return this._writeData(bytes); - }; - Writer3.prototype._getValue = function(value) { - var bytes = (0, bytes_1.arrayify)(bignumber_1.BigNumber.from(value)); - if (bytes.length > this.wordSize) { - logger2.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { - length: this.wordSize, - offset: bytes.length - }); - } - if (bytes.length % this.wordSize) { - bytes = (0, bytes_1.concat)([this._padding.slice(bytes.length % this.wordSize), bytes]); - } - return bytes; - }; - Writer3.prototype.writeValue = function(value) { - return this._writeData(this._getValue(value)); - }; - Writer3.prototype.writeUpdatableValue = function() { - var _this = this; - var offset = this._data.length; - this._data.push(this._padding); - this._dataLength += this.wordSize; - return function(value) { - _this._data[offset] = _this._getValue(value); - }; + var Writer2 = function() { + function Writer3(wordSize) { + (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32); + this._data = []; + this._dataLength = 0; + this._padding = new Uint8Array(wordSize); + } + Object.defineProperty(Writer3.prototype, "data", { + get: function() { + return (0, bytes_1.hexConcat)(this._data); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Writer3.prototype, "length", { + get: function() { + return this._dataLength; + }, + enumerable: false, + configurable: true + }); + Writer3.prototype._writeData = function(data) { + this._data.push(data); + this._dataLength += data.length; + return data.length; + }; + Writer3.prototype.appendWriter = function(writer) { + return this._writeData((0, bytes_1.concat)(writer._data)); + }; + Writer3.prototype.writeBytes = function(value) { + var bytes = (0, bytes_1.arrayify)(value); + var paddingOffset = bytes.length % this.wordSize; + if (paddingOffset) { + bytes = (0, bytes_1.concat)([bytes, this._padding.slice(paddingOffset)]); + } + return this._writeData(bytes); + }; + Writer3.prototype._getValue = function(value) { + var bytes = (0, bytes_1.arrayify)(bignumber_1.BigNumber.from(value)); + if (bytes.length > this.wordSize) { + logger2.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes.length + }); + } + if (bytes.length % this.wordSize) { + bytes = (0, bytes_1.concat)([this._padding.slice(bytes.length % this.wordSize), bytes]); + } + return bytes; + }; + Writer3.prototype.writeValue = function(value) { + return this._writeData(this._getValue(value)); + }; + Writer3.prototype.writeUpdatableValue = function() { + var _this = this; + var offset = this._data.length; + this._data.push(this._padding); + this._dataLength += this.wordSize; + return function(value) { + _this._data[offset] = _this._getValue(value); }; - return Writer3; - }() - ); + }; + return Writer3; + }(); exports2.Writer = Writer2; - var Reader = ( - /** @class */ - function() { - function Reader2(data, wordSize, coerceFunc, allowLoose) { - (0, properties_1.defineReadOnly)(this, "_data", (0, bytes_1.arrayify)(data)); - (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32); - (0, properties_1.defineReadOnly)(this, "_coerceFunc", coerceFunc); - (0, properties_1.defineReadOnly)(this, "allowLoose", allowLoose); - this._offset = 0; - } - Object.defineProperty(Reader2.prototype, "data", { - get: function() { - return (0, bytes_1.hexlify)(this._data); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Reader2.prototype, "consumed", { - get: function() { - return this._offset; - }, - enumerable: false, - configurable: true - }); - Reader2.coerce = function(name2, value) { - var match = name2.match("^u?int([0-9]+)$"); - if (match && parseInt(match[1]) <= 48) { - value = value.toNumber(); - } - return value; - }; - Reader2.prototype.coerce = function(name2, value) { - if (this._coerceFunc) { - return this._coerceFunc(name2, value); - } - return Reader2.coerce(name2, value); - }; - Reader2.prototype._peekBytes = function(offset, length, loose) { - var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; - if (this._offset + alignedLength > this._data.length) { - if (this.allowLoose && loose && this._offset + length <= this._data.length) { - alignedLength = length; - } else { - logger2.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { - length: this._data.length, - offset: this._offset + alignedLength - }); - } + var Reader = function() { + function Reader2(data, wordSize, coerceFunc, allowLoose) { + (0, properties_1.defineReadOnly)(this, "_data", (0, bytes_1.arrayify)(data)); + (0, properties_1.defineReadOnly)(this, "wordSize", wordSize || 32); + (0, properties_1.defineReadOnly)(this, "_coerceFunc", coerceFunc); + (0, properties_1.defineReadOnly)(this, "allowLoose", allowLoose); + this._offset = 0; + } + Object.defineProperty(Reader2.prototype, "data", { + get: function() { + return (0, bytes_1.hexlify)(this._data); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Reader2.prototype, "consumed", { + get: function() { + return this._offset; + }, + enumerable: false, + configurable: true + }); + Reader2.coerce = function(name2, value) { + var match = name2.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { + value = value.toNumber(); + } + return value; + }; + Reader2.prototype.coerce = function(name2, value) { + if (this._coerceFunc) { + return this._coerceFunc(name2, value); + } + return Reader2.coerce(name2, value); + }; + Reader2.prototype._peekBytes = function(offset, length, loose) { + var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + if (this.allowLoose && loose && this._offset + length <= this._data.length) { + alignedLength = length; + } else { + logger2.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); } - return this._data.slice(this._offset, this._offset + alignedLength); - }; - Reader2.prototype.subReader = function(offset) { - return new Reader2(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc, this.allowLoose); - }; - Reader2.prototype.readBytes = function(length, loose) { - var bytes = this._peekBytes(0, length, !!loose); - this._offset += bytes.length; - return bytes.slice(0, length); - }; - Reader2.prototype.readValue = function() { - return bignumber_1.BigNumber.from(this.readBytes(this.wordSize)); - }; - return Reader2; - }() - ); + } + return this._data.slice(this._offset, this._offset + alignedLength); + }; + Reader2.prototype.subReader = function(offset) { + return new Reader2(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc, this.allowLoose); + }; + Reader2.prototype.readBytes = function(length, loose) { + var bytes = this._peekBytes(0, length, !!loose); + this._offset += bytes.length; + return bytes.slice(0, length); + }; + Reader2.prototype.readValue = function() { + return bignumber_1.BigNumber.from(this.readBytes(this.wordSize)); + }; + return Reader2; + }(); exports2.Reader = Reader; } }); @@ -6065,7 +6049,6 @@ var require_abstract_coder = __commonJS({ // node_modules/js-sha3/src/sha3.js var require_sha3 = __commonJS({ "node_modules/js-sha3/src/sha3.js"(exports2, module2) { - "use strict"; (function() { "use strict"; var INPUT_ERROR = "input is invalid type"; @@ -6716,12 +6699,12 @@ var require_sha3 = __commonJS({ var require_lib5 = __commonJS({ "node_modules/@ethersproject/keccak256/lib/index.js"(exports2) { "use strict"; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.keccak256 = void 0; - var js_sha3_1 = __importDefault2(require_sha3()); + var js_sha3_1 = __importDefault(require_sha3()); var bytes_1 = require_lib2(); function keccak256(data) { return "0x" + js_sha3_1.default.keccak_256((0, bytes_1.arrayify)(data)); @@ -7012,21 +6995,21 @@ var require_lib7 = __commonJS({ var require_address = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/address.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7038,30 +7021,27 @@ var require_address = __commonJS({ var address_1 = require_lib7(); var bytes_1 = require_lib2(); var abstract_coder_1 = require_abstract_coder(); - var AddressCoder = ( - /** @class */ - function(_super) { - __extends2(AddressCoder2, _super); - function AddressCoder2(localName) { - return _super.call(this, "address", "address", localName, false) || this; - } - AddressCoder2.prototype.defaultValue = function() { - return "0x0000000000000000000000000000000000000000"; - }; - AddressCoder2.prototype.encode = function(writer, value) { - try { - value = (0, address_1.getAddress)(value); - } catch (error) { - this._throwError(error.message, value); - } - return writer.writeValue(value); - }; - AddressCoder2.prototype.decode = function(reader) { - return (0, address_1.getAddress)((0, bytes_1.hexZeroPad)(reader.readValue().toHexString(), 20)); - }; - return AddressCoder2; - }(abstract_coder_1.Coder) - ); + var AddressCoder = function(_super) { + __extends(AddressCoder2, _super); + function AddressCoder2(localName) { + return _super.call(this, "address", "address", localName, false) || this; + } + AddressCoder2.prototype.defaultValue = function() { + return "0x0000000000000000000000000000000000000000"; + }; + AddressCoder2.prototype.encode = function(writer, value) { + try { + value = (0, address_1.getAddress)(value); + } catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + }; + AddressCoder2.prototype.decode = function(reader) { + return (0, address_1.getAddress)((0, bytes_1.hexZeroPad)(reader.readValue().toHexString(), 20)); + }; + return AddressCoder2; + }(abstract_coder_1.Coder); exports2.AddressCoder = AddressCoder; } }); @@ -7070,21 +7050,21 @@ var require_address = __commonJS({ var require_anonymous = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/anonymous.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7094,27 +7074,24 @@ var require_anonymous = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.AnonymousCoder = void 0; var abstract_coder_1 = require_abstract_coder(); - var AnonymousCoder = ( - /** @class */ - function(_super) { - __extends2(AnonymousCoder2, _super); - function AnonymousCoder2(coder) { - var _this = _super.call(this, coder.name, coder.type, void 0, coder.dynamic) || this; - _this.coder = coder; - return _this; - } - AnonymousCoder2.prototype.defaultValue = function() { - return this.coder.defaultValue(); - }; - AnonymousCoder2.prototype.encode = function(writer, value) { - return this.coder.encode(writer, value); - }; - AnonymousCoder2.prototype.decode = function(reader) { - return this.coder.decode(reader); - }; - return AnonymousCoder2; - }(abstract_coder_1.Coder) - ); + var AnonymousCoder = function(_super) { + __extends(AnonymousCoder2, _super); + function AnonymousCoder2(coder) { + var _this = _super.call(this, coder.name, coder.type, void 0, coder.dynamic) || this; + _this.coder = coder; + return _this; + } + AnonymousCoder2.prototype.defaultValue = function() { + return this.coder.defaultValue(); + }; + AnonymousCoder2.prototype.encode = function(writer, value) { + return this.coder.encode(writer, value); + }; + AnonymousCoder2.prototype.decode = function(reader) { + return this.coder.decode(reader); + }; + return AnonymousCoder2; + }(abstract_coder_1.Coder); exports2.AnonymousCoder = AnonymousCoder; } }); @@ -7123,21 +7100,21 @@ var require_anonymous = __commonJS({ var require_array = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/array.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7292,63 +7269,60 @@ var require_array = __commonJS({ return Object.freeze(values); } exports2.unpack = unpack; - var ArrayCoder = ( - /** @class */ - function(_super) { - __extends2(ArrayCoder2, _super); - function ArrayCoder2(coder, length, localName) { - var _this = this; - var type = coder.type + "[" + (length >= 0 ? length : "") + "]"; - var dynamic = length === -1 || coder.dynamic; - _this = _super.call(this, "array", type, localName, dynamic) || this; - _this.coder = coder; - _this.length = length; - return _this; - } - ArrayCoder2.prototype.defaultValue = function() { - var defaultChild = this.coder.defaultValue(); - var result = []; - for (var i = 0; i < this.length; i++) { - result.push(defaultChild); - } - return result; - }; - ArrayCoder2.prototype.encode = function(writer, value) { - if (!Array.isArray(value)) { - this._throwError("expected array value", value); - } - var count = this.length; - if (count === -1) { - count = value.length; - writer.writeValue(value.length); - } - logger2.checkArgumentCount(value.length, count, "coder array" + (this.localName ? " " + this.localName : "")); - var coders = []; - for (var i = 0; i < value.length; i++) { - coders.push(this.coder); - } - return pack(writer, coders, value); - }; - ArrayCoder2.prototype.decode = function(reader) { - var count = this.length; - if (count === -1) { - count = reader.readValue().toNumber(); - if (count * 32 > reader._data.length) { - logger2.throwError("insufficient data length", logger_1.Logger.errors.BUFFER_OVERRUN, { - length: reader._data.length, - count - }); - } - } - var coders = []; - for (var i = 0; i < count; i++) { - coders.push(new anonymous_1.AnonymousCoder(this.coder)); + var ArrayCoder = function(_super) { + __extends(ArrayCoder2, _super); + function ArrayCoder2(coder, length, localName) { + var _this = this; + var type = coder.type + "[" + (length >= 0 ? length : "") + "]"; + var dynamic = length === -1 || coder.dynamic; + _this = _super.call(this, "array", type, localName, dynamic) || this; + _this.coder = coder; + _this.length = length; + return _this; + } + ArrayCoder2.prototype.defaultValue = function() { + var defaultChild = this.coder.defaultValue(); + var result = []; + for (var i = 0; i < this.length; i++) { + result.push(defaultChild); + } + return result; + }; + ArrayCoder2.prototype.encode = function(writer, value) { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + var count = this.length; + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + logger2.checkArgumentCount(value.length, count, "coder array" + (this.localName ? " " + this.localName : "")); + var coders = []; + for (var i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + }; + ArrayCoder2.prototype.decode = function(reader) { + var count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + if (count * 32 > reader._data.length) { + logger2.throwError("insufficient data length", logger_1.Logger.errors.BUFFER_OVERRUN, { + length: reader._data.length, + count + }); } - return reader.coerce(this.name, unpack(reader, coders)); - }; - return ArrayCoder2; - }(abstract_coder_1.Coder) - ); + } + var coders = []; + for (var i = 0; i < count; i++) { + coders.push(new anonymous_1.AnonymousCoder(this.coder)); + } + return reader.coerce(this.name, unpack(reader, coders)); + }; + return ArrayCoder2; + }(abstract_coder_1.Coder); exports2.ArrayCoder = ArrayCoder; } }); @@ -7357,21 +7331,21 @@ var require_array = __commonJS({ var require_boolean = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/boolean.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7381,25 +7355,22 @@ var require_boolean = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.BooleanCoder = void 0; var abstract_coder_1 = require_abstract_coder(); - var BooleanCoder = ( - /** @class */ - function(_super) { - __extends2(BooleanCoder2, _super); - function BooleanCoder2(localName) { - return _super.call(this, "bool", "bool", localName, false) || this; - } - BooleanCoder2.prototype.defaultValue = function() { - return false; - }; - BooleanCoder2.prototype.encode = function(writer, value) { - return writer.writeValue(value ? 1 : 0); - }; - BooleanCoder2.prototype.decode = function(reader) { - return reader.coerce(this.type, !reader.readValue().isZero()); - }; - return BooleanCoder2; - }(abstract_coder_1.Coder) - ); + var BooleanCoder = function(_super) { + __extends(BooleanCoder2, _super); + function BooleanCoder2(localName) { + return _super.call(this, "bool", "bool", localName, false) || this; + } + BooleanCoder2.prototype.defaultValue = function() { + return false; + }; + BooleanCoder2.prototype.encode = function(writer, value) { + return writer.writeValue(value ? 1 : 0); + }; + BooleanCoder2.prototype.decode = function(reader) { + return reader.coerce(this.type, !reader.readValue().isZero()); + }; + return BooleanCoder2; + }(abstract_coder_1.Coder); exports2.BooleanCoder = BooleanCoder; } }); @@ -7408,21 +7379,21 @@ var require_boolean = __commonJS({ var require_bytes = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/bytes.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7433,42 +7404,36 @@ var require_bytes = __commonJS({ exports2.BytesCoder = exports2.DynamicBytesCoder = void 0; var bytes_1 = require_lib2(); var abstract_coder_1 = require_abstract_coder(); - var DynamicBytesCoder = ( - /** @class */ - function(_super) { - __extends2(DynamicBytesCoder2, _super); - function DynamicBytesCoder2(type, localName) { - return _super.call(this, type, type, localName, true) || this; - } - DynamicBytesCoder2.prototype.defaultValue = function() { - return "0x"; - }; - DynamicBytesCoder2.prototype.encode = function(writer, value) { - value = (0, bytes_1.arrayify)(value); - var length = writer.writeValue(value.length); - length += writer.writeBytes(value); - return length; - }; - DynamicBytesCoder2.prototype.decode = function(reader) { - return reader.readBytes(reader.readValue().toNumber(), true); - }; - return DynamicBytesCoder2; - }(abstract_coder_1.Coder) - ); + var DynamicBytesCoder = function(_super) { + __extends(DynamicBytesCoder2, _super); + function DynamicBytesCoder2(type, localName) { + return _super.call(this, type, type, localName, true) || this; + } + DynamicBytesCoder2.prototype.defaultValue = function() { + return "0x"; + }; + DynamicBytesCoder2.prototype.encode = function(writer, value) { + value = (0, bytes_1.arrayify)(value); + var length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + }; + DynamicBytesCoder2.prototype.decode = function(reader) { + return reader.readBytes(reader.readValue().toNumber(), true); + }; + return DynamicBytesCoder2; + }(abstract_coder_1.Coder); exports2.DynamicBytesCoder = DynamicBytesCoder; - var BytesCoder = ( - /** @class */ - function(_super) { - __extends2(BytesCoder2, _super); - function BytesCoder2(localName) { - return _super.call(this, "bytes", localName) || this; - } - BytesCoder2.prototype.decode = function(reader) { - return reader.coerce(this.name, (0, bytes_1.hexlify)(_super.prototype.decode.call(this, reader))); - }; - return BytesCoder2; - }(DynamicBytesCoder) - ); + var BytesCoder = function(_super) { + __extends(BytesCoder2, _super); + function BytesCoder2(localName) { + return _super.call(this, "bytes", localName) || this; + } + BytesCoder2.prototype.decode = function(reader) { + return reader.coerce(this.name, (0, bytes_1.hexlify)(_super.prototype.decode.call(this, reader))); + }; + return BytesCoder2; + }(DynamicBytesCoder); exports2.BytesCoder = BytesCoder; } }); @@ -7477,21 +7442,21 @@ var require_bytes = __commonJS({ var require_fixed_bytes = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/fixed-bytes.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7502,33 +7467,30 @@ var require_fixed_bytes = __commonJS({ exports2.FixedBytesCoder = void 0; var bytes_1 = require_lib2(); var abstract_coder_1 = require_abstract_coder(); - var FixedBytesCoder = ( - /** @class */ - function(_super) { - __extends2(FixedBytesCoder2, _super); - function FixedBytesCoder2(size, localName) { - var _this = this; - var name2 = "bytes" + String(size); - _this = _super.call(this, name2, name2, localName, false) || this; - _this.size = size; - return _this; + var FixedBytesCoder = function(_super) { + __extends(FixedBytesCoder2, _super); + function FixedBytesCoder2(size, localName) { + var _this = this; + var name2 = "bytes" + String(size); + _this = _super.call(this, name2, name2, localName, false) || this; + _this.size = size; + return _this; + } + FixedBytesCoder2.prototype.defaultValue = function() { + return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0, 2 + this.size * 2); + }; + FixedBytesCoder2.prototype.encode = function(writer, value) { + var data = (0, bytes_1.arrayify)(value); + if (data.length !== this.size) { + this._throwError("incorrect data length", value); } - FixedBytesCoder2.prototype.defaultValue = function() { - return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0, 2 + this.size * 2); - }; - FixedBytesCoder2.prototype.encode = function(writer, value) { - var data = (0, bytes_1.arrayify)(value); - if (data.length !== this.size) { - this._throwError("incorrect data length", value); - } - return writer.writeBytes(data); - }; - FixedBytesCoder2.prototype.decode = function(reader) { - return reader.coerce(this.name, (0, bytes_1.hexlify)(reader.readBytes(this.size))); - }; - return FixedBytesCoder2; - }(abstract_coder_1.Coder) - ); + return writer.writeBytes(data); + }; + FixedBytesCoder2.prototype.decode = function(reader) { + return reader.coerce(this.name, (0, bytes_1.hexlify)(reader.readBytes(this.size))); + }; + return FixedBytesCoder2; + }(abstract_coder_1.Coder); exports2.FixedBytesCoder = FixedBytesCoder; } }); @@ -7537,21 +7499,21 @@ var require_fixed_bytes = __commonJS({ var require_null = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/null.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7561,29 +7523,26 @@ var require_null = __commonJS({ Object.defineProperty(exports2, "__esModule", { value: true }); exports2.NullCoder = void 0; var abstract_coder_1 = require_abstract_coder(); - var NullCoder = ( - /** @class */ - function(_super) { - __extends2(NullCoder2, _super); - function NullCoder2(localName) { - return _super.call(this, "null", "", localName, false) || this; - } - NullCoder2.prototype.defaultValue = function() { - return null; - }; - NullCoder2.prototype.encode = function(writer, value) { - if (value != null) { - this._throwError("not null", value); - } - return writer.writeBytes([]); - }; - NullCoder2.prototype.decode = function(reader) { - reader.readBytes(0); - return reader.coerce(this.name, null); - }; - return NullCoder2; - }(abstract_coder_1.Coder) - ); + var NullCoder = function(_super) { + __extends(NullCoder2, _super); + function NullCoder2(localName) { + return _super.call(this, "null", "", localName, false) || this; + } + NullCoder2.prototype.defaultValue = function() { + return null; + }; + NullCoder2.prototype.encode = function(writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes([]); + }; + NullCoder2.prototype.decode = function(reader) { + reader.readBytes(0); + return reader.coerce(this.name, null); + }; + return NullCoder2; + }(abstract_coder_1.Coder); exports2.NullCoder = NullCoder; } }); @@ -7694,21 +7653,21 @@ var require_lib8 = __commonJS({ var require_number = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/number.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -7720,48 +7679,45 @@ var require_number = __commonJS({ var bignumber_1 = require_lib3(); var constants_1 = require_lib8(); var abstract_coder_1 = require_abstract_coder(); - var NumberCoder = ( - /** @class */ - function(_super) { - __extends2(NumberCoder2, _super); - function NumberCoder2(size, signed, localName) { - var _this = this; - var name2 = (signed ? "int" : "uint") + size * 8; - _this = _super.call(this, name2, name2, localName, false) || this; - _this.size = size; - _this.signed = signed; - return _this; - } - NumberCoder2.prototype.defaultValue = function() { - return 0; - }; - NumberCoder2.prototype.encode = function(writer, value) { - var v = bignumber_1.BigNumber.from(value); - var maxUintValue = constants_1.MaxUint256.mask(writer.wordSize * 8); - if (this.signed) { - var bounds = maxUintValue.mask(this.size * 8 - 1); - if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { - this._throwError("value out-of-bounds", value); - } - } else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.mask(this.size * 8))) { + var NumberCoder = function(_super) { + __extends(NumberCoder2, _super); + function NumberCoder2(size, signed, localName) { + var _this = this; + var name2 = (signed ? "int" : "uint") + size * 8; + _this = _super.call(this, name2, name2, localName, false) || this; + _this.size = size; + _this.signed = signed; + return _this; + } + NumberCoder2.prototype.defaultValue = function() { + return 0; + }; + NumberCoder2.prototype.encode = function(writer, value) { + var v = bignumber_1.BigNumber.from(value); + var maxUintValue = constants_1.MaxUint256.mask(writer.wordSize * 8); + if (this.signed) { + var bounds = maxUintValue.mask(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { this._throwError("value out-of-bounds", value); } - v = v.toTwos(this.size * 8).mask(this.size * 8); - if (this.signed) { - v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); - } - return writer.writeValue(v); - }; - NumberCoder2.prototype.decode = function(reader) { - var value = reader.readValue().mask(this.size * 8); - if (this.signed) { - value = value.fromTwos(this.size * 8); - } - return reader.coerce(this.name, value); - }; - return NumberCoder2; - }(abstract_coder_1.Coder) - ); + } else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.mask(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + v = v.toTwos(this.size * 8).mask(this.size * 8); + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + return writer.writeValue(v); + }; + NumberCoder2.prototype.decode = function(reader) { + var value = reader.readValue().mask(this.size * 8); + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + return reader.coerce(this.name, value); + }; + return NumberCoder2; + }(abstract_coder_1.Coder); exports2.NumberCoder = NumberCoder; } }); @@ -8267,21 +8223,21 @@ var require_lib9 = __commonJS({ var require_string = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/string.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -8292,25 +8248,22 @@ var require_string = __commonJS({ exports2.StringCoder = void 0; var strings_1 = require_lib9(); var bytes_1 = require_bytes(); - var StringCoder = ( - /** @class */ - function(_super) { - __extends2(StringCoder2, _super); - function StringCoder2(localName) { - return _super.call(this, "string", localName) || this; - } - StringCoder2.prototype.defaultValue = function() { - return ""; - }; - StringCoder2.prototype.encode = function(writer, value) { - return _super.prototype.encode.call(this, writer, (0, strings_1.toUtf8Bytes)(value)); - }; - StringCoder2.prototype.decode = function(reader) { - return (0, strings_1.toUtf8String)(_super.prototype.decode.call(this, reader)); - }; - return StringCoder2; - }(bytes_1.DynamicBytesCoder) - ); + var StringCoder = function(_super) { + __extends(StringCoder2, _super); + function StringCoder2(localName) { + return _super.call(this, "string", localName) || this; + } + StringCoder2.prototype.defaultValue = function() { + return ""; + }; + StringCoder2.prototype.encode = function(writer, value) { + return _super.prototype.encode.call(this, writer, (0, strings_1.toUtf8Bytes)(value)); + }; + StringCoder2.prototype.decode = function(reader) { + return (0, strings_1.toUtf8String)(_super.prototype.decode.call(this, reader)); + }; + return StringCoder2; + }(bytes_1.DynamicBytesCoder); exports2.StringCoder = StringCoder; } }); @@ -8319,21 +8272,21 @@ var require_string = __commonJS({ var require_tuple = __commonJS({ "node_modules/@ethersproject/abi/lib/coders/tuple.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -8344,64 +8297,61 @@ var require_tuple = __commonJS({ exports2.TupleCoder = void 0; var abstract_coder_1 = require_abstract_coder(); var array_1 = require_array(); - var TupleCoder = ( - /** @class */ - function(_super) { - __extends2(TupleCoder2, _super); - function TupleCoder2(coders, localName) { - var _this = this; - var dynamic = false; - var types = []; - coders.forEach(function(coder) { - if (coder.dynamic) { - dynamic = true; - } - types.push(coder.type); - }); - var type = "tuple(" + types.join(",") + ")"; - _this = _super.call(this, "tuple", type, localName, dynamic) || this; - _this.coders = coders; - return _this; - } - TupleCoder2.prototype.defaultValue = function() { - var values = []; - this.coders.forEach(function(coder) { - values.push(coder.defaultValue()); - }); - var uniqueNames = this.coders.reduce(function(accum, coder) { - var name2 = coder.localName; - if (name2) { - if (!accum[name2]) { - accum[name2] = 0; - } - accum[name2]++; - } - return accum; - }, {}); - this.coders.forEach(function(coder, index) { - var name2 = coder.localName; - if (!name2 || uniqueNames[name2] !== 1) { - return; - } - if (name2 === "length") { - name2 = "_length"; - } - if (values[name2] != null) { - return; + var TupleCoder = function(_super) { + __extends(TupleCoder2, _super); + function TupleCoder2(coders, localName) { + var _this = this; + var dynamic = false; + var types = []; + coders.forEach(function(coder) { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + var type = "tuple(" + types.join(",") + ")"; + _this = _super.call(this, "tuple", type, localName, dynamic) || this; + _this.coders = coders; + return _this; + } + TupleCoder2.prototype.defaultValue = function() { + var values = []; + this.coders.forEach(function(coder) { + values.push(coder.defaultValue()); + }); + var uniqueNames = this.coders.reduce(function(accum, coder) { + var name2 = coder.localName; + if (name2) { + if (!accum[name2]) { + accum[name2] = 0; } - values[name2] = values[index]; - }); - return Object.freeze(values); - }; - TupleCoder2.prototype.encode = function(writer, value) { - return (0, array_1.pack)(writer, this.coders, value); - }; - TupleCoder2.prototype.decode = function(reader) { - return reader.coerce(this.name, (0, array_1.unpack)(reader, this.coders)); - }; - return TupleCoder2; - }(abstract_coder_1.Coder) - ); + accum[name2]++; + } + return accum; + }, {}); + this.coders.forEach(function(coder, index) { + var name2 = coder.localName; + if (!name2 || uniqueNames[name2] !== 1) { + return; + } + if (name2 === "length") { + name2 = "_length"; + } + if (values[name2] != null) { + return; + } + values[name2] = values[index]; + }); + return Object.freeze(values); + }; + TupleCoder2.prototype.encode = function(writer, value) { + return (0, array_1.pack)(writer, this.coders, value); + }; + TupleCoder2.prototype.decode = function(reader) { + return reader.coerce(this.name, (0, array_1.unpack)(reader, this.coders)); + }; + return TupleCoder2; + }(abstract_coder_1.Coder); exports2.TupleCoder = TupleCoder; } }); @@ -8430,96 +8380,93 @@ var require_abi_coder = __commonJS({ var fragments_1 = require_fragments(); var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); - var AbiCoder = ( - /** @class */ - function() { - function AbiCoder2(coerceFunc) { - var _newTarget = this.constructor; - logger2.checkNew(_newTarget, AbiCoder2); - (0, properties_1.defineReadOnly)(this, "coerceFunc", coerceFunc || null); - } - AbiCoder2.prototype._getCoder = function(param) { - var _this = this; - switch (param.baseType) { - case "address": - return new address_1.AddressCoder(param.name); - case "bool": - return new boolean_1.BooleanCoder(param.name); - case "string": - return new string_1.StringCoder(param.name); - case "bytes": - return new bytes_2.BytesCoder(param.name); - case "array": - return new array_1.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); - case "tuple": - return new tuple_1.TupleCoder((param.components || []).map(function(component) { - return _this._getCoder(component); - }), param.name); - case "": - return new null_1.NullCoder(param.name); - } - var match = param.type.match(paramTypeNumber); - if (match) { - var size = parseInt(match[2] || "256"); - if (size === 0 || size > 256 || size % 8 !== 0) { - logger2.throwArgumentError("invalid " + match[1] + " bit length", "param", param); - } - return new number_1.NumberCoder(size / 8, match[1] === "int", param.name); - } - match = param.type.match(paramTypeBytes); - if (match) { - var size = parseInt(match[1]); - if (size === 0 || size > 32) { - logger2.throwArgumentError("invalid bytes length", "param", param); - } - return new fixed_bytes_1.FixedBytesCoder(size, param.name); + var AbiCoder = function() { + function AbiCoder2(coerceFunc) { + var _newTarget = this.constructor; + logger2.checkNew(_newTarget, AbiCoder2); + (0, properties_1.defineReadOnly)(this, "coerceFunc", coerceFunc || null); + } + AbiCoder2.prototype._getCoder = function(param) { + var _this = this; + switch (param.baseType) { + case "address": + return new address_1.AddressCoder(param.name); + case "bool": + return new boolean_1.BooleanCoder(param.name); + case "string": + return new string_1.StringCoder(param.name); + case "bytes": + return new bytes_2.BytesCoder(param.name); + case "array": + return new array_1.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); + case "tuple": + return new tuple_1.TupleCoder((param.components || []).map(function(component) { + return _this._getCoder(component); + }), param.name); + case "": + return new null_1.NullCoder(param.name); + } + var match = param.type.match(paramTypeNumber); + if (match) { + var size = parseInt(match[2] || "256"); + if (size === 0 || size > 256 || size % 8 !== 0) { + logger2.throwArgumentError("invalid " + match[1] + " bit length", "param", param); } - return logger2.throwArgumentError("invalid type", "type", param.type); - }; - AbiCoder2.prototype._getWordSize = function() { - return 32; - }; - AbiCoder2.prototype._getReader = function(data, allowLoose) { - return new abstract_coder_1.Reader(data, this._getWordSize(), this.coerceFunc, allowLoose); - }; - AbiCoder2.prototype._getWriter = function() { - return new abstract_coder_1.Writer(this._getWordSize()); - }; - AbiCoder2.prototype.getDefaultValue = function(types) { - var _this = this; - var coders = types.map(function(type) { - return _this._getCoder(fragments_1.ParamType.from(type)); - }); - var coder = new tuple_1.TupleCoder(coders, "_"); - return coder.defaultValue(); - }; - AbiCoder2.prototype.encode = function(types, values) { - var _this = this; - if (types.length !== values.length) { - logger2.throwError("types/values length mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { - count: { types: types.length, values: values.length }, - value: { types, values } - }); + return new number_1.NumberCoder(size / 8, match[1] === "int", param.name); + } + match = param.type.match(paramTypeBytes); + if (match) { + var size = parseInt(match[1]); + if (size === 0 || size > 32) { + logger2.throwArgumentError("invalid bytes length", "param", param); } - var coders = types.map(function(type) { - return _this._getCoder(fragments_1.ParamType.from(type)); - }); - var coder = new tuple_1.TupleCoder(coders, "_"); - var writer = this._getWriter(); - coder.encode(writer, values); - return writer.data; - }; - AbiCoder2.prototype.decode = function(types, data, loose) { - var _this = this; - var coders = types.map(function(type) { - return _this._getCoder(fragments_1.ParamType.from(type)); + return new fixed_bytes_1.FixedBytesCoder(size, param.name); + } + return logger2.throwArgumentError("invalid type", "type", param.type); + }; + AbiCoder2.prototype._getWordSize = function() { + return 32; + }; + AbiCoder2.prototype._getReader = function(data, allowLoose) { + return new abstract_coder_1.Reader(data, this._getWordSize(), this.coerceFunc, allowLoose); + }; + AbiCoder2.prototype._getWriter = function() { + return new abstract_coder_1.Writer(this._getWordSize()); + }; + AbiCoder2.prototype.getDefaultValue = function(types) { + var _this = this; + var coders = types.map(function(type) { + return _this._getCoder(fragments_1.ParamType.from(type)); + }); + var coder = new tuple_1.TupleCoder(coders, "_"); + return coder.defaultValue(); + }; + AbiCoder2.prototype.encode = function(types, values) { + var _this = this; + if (types.length !== values.length) { + logger2.throwError("types/values length mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { + count: { types: types.length, values: values.length }, + value: { types, values } }); - var coder = new tuple_1.TupleCoder(coders, "_"); - return coder.decode(this._getReader((0, bytes_1.arrayify)(data), loose)); - }; - return AbiCoder2; - }() - ); + } + var coders = types.map(function(type) { + return _this._getCoder(fragments_1.ParamType.from(type)); + }); + var coder = new tuple_1.TupleCoder(coders, "_"); + var writer = this._getWriter(); + coder.encode(writer, values); + return writer.data; + }; + AbiCoder2.prototype.decode = function(types, data, loose) { + var _this = this; + var coders = types.map(function(type) { + return _this._getCoder(fragments_1.ParamType.from(type)); + }); + var coder = new tuple_1.TupleCoder(coders, "_"); + return coder.decode(this._getReader((0, bytes_1.arrayify)(data), loose)); + }; + return AbiCoder2; + }(); exports2.AbiCoder = AbiCoder; exports2.defaultAbiCoder = new AbiCoder(); } @@ -8628,7 +8575,7 @@ var require_message = __commonJS({ var require_typed_data = __commonJS({ "node_modules/@ethersproject/hash/lib/typed-data.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -8655,7 +8602,7 @@ var require_typed_data = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -8871,315 +8818,312 @@ var require_typed_data = __commonJS({ return type + " " + name3; }).join(",") + ")"; } - var TypedDataEncoder = ( - /** @class */ - function() { - function TypedDataEncoder2(types) { - (0, properties_1.defineReadOnly)(this, "types", Object.freeze((0, properties_1.deepCopy)(types))); - (0, properties_1.defineReadOnly)(this, "_encoderCache", {}); - (0, properties_1.defineReadOnly)(this, "_types", {}); - var links = {}; - var parents = {}; - var subtypes = {}; - Object.keys(types).forEach(function(type) { - links[type] = {}; - parents[type] = []; - subtypes[type] = {}; - }); - var _loop_1 = function(name_12) { - var uniqueNames = {}; - types[name_12].forEach(function(field) { - if (uniqueNames[field.name]) { - logger2.throwArgumentError("duplicate variable name " + JSON.stringify(field.name) + " in " + JSON.stringify(name_12), "types", types); - } - uniqueNames[field.name] = true; - var baseType = field.type.match(/^([^\x5b]*)(\x5b|$)/)[1]; - if (baseType === name_12) { - logger2.throwArgumentError("circular type reference to " + JSON.stringify(baseType), "types", types); - } - var encoder = getBaseEncoder(baseType); - if (encoder) { - return; - } - if (!parents[baseType]) { - logger2.throwArgumentError("unknown type " + JSON.stringify(baseType), "types", types); - } - parents[baseType].push(name_12); - links[name_12][baseType] = true; - }); - }; - for (var name_1 in types) { - _loop_1(name_1); - } - var primaryTypes = Object.keys(parents).filter(function(n) { - return parents[n].length === 0; - }); - if (primaryTypes.length === 0) { - logger2.throwArgumentError("missing primary type", "types", types); - } else if (primaryTypes.length > 1) { - logger2.throwArgumentError("ambiguous primary types or unused types: " + primaryTypes.map(function(t) { - return JSON.stringify(t); - }).join(", "), "types", types); - } - (0, properties_1.defineReadOnly)(this, "primaryType", primaryTypes[0]); - function checkCircular(type, found) { - if (found[type]) { - logger2.throwArgumentError("circular type reference to " + JSON.stringify(type), "types", types); - } - found[type] = true; - Object.keys(links[type]).forEach(function(child) { - if (!parents[child]) { - return; - } - checkCircular(child, found); - Object.keys(found).forEach(function(subtype) { - subtypes[subtype][child] = true; - }); - }); - delete found[type]; - } - checkCircular(this.primaryType, {}); - for (var name_2 in subtypes) { - var st = Object.keys(subtypes[name_2]); - st.sort(); - this._types[name_2] = encodeType(name_2, types[name_2]) + st.map(function(t) { - return encodeType(t, types[t]); - }).join(""); - } - } - TypedDataEncoder2.prototype.getEncoder = function(type) { - var encoder = this._encoderCache[type]; - if (!encoder) { - encoder = this._encoderCache[type] = this._getEncoder(type); - } - return encoder; - }; - TypedDataEncoder2.prototype._getEncoder = function(type) { - var _this = this; - { - var encoder = getBaseEncoder(type); + var TypedDataEncoder = function() { + function TypedDataEncoder2(types) { + (0, properties_1.defineReadOnly)(this, "types", Object.freeze((0, properties_1.deepCopy)(types))); + (0, properties_1.defineReadOnly)(this, "_encoderCache", {}); + (0, properties_1.defineReadOnly)(this, "_types", {}); + var links = {}; + var parents = {}; + var subtypes = {}; + Object.keys(types).forEach(function(type) { + links[type] = {}; + parents[type] = []; + subtypes[type] = {}; + }); + var _loop_1 = function(name_12) { + var uniqueNames = {}; + types[name_12].forEach(function(field) { + if (uniqueNames[field.name]) { + logger2.throwArgumentError("duplicate variable name " + JSON.stringify(field.name) + " in " + JSON.stringify(name_12), "types", types); + } + uniqueNames[field.name] = true; + var baseType = field.type.match(/^([^\x5b]*)(\x5b|$)/)[1]; + if (baseType === name_12) { + logger2.throwArgumentError("circular type reference to " + JSON.stringify(baseType), "types", types); + } + var encoder = getBaseEncoder(baseType); if (encoder) { - return encoder; + return; } - } - var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/); - if (match) { - var subtype_1 = match[1]; - var subEncoder_1 = this.getEncoder(subtype_1); - var length_1 = parseInt(match[3]); - return function(value) { - if (length_1 >= 0 && value.length !== length_1) { - logger2.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value); - } - var result = value.map(subEncoder_1); - if (_this._types[subtype_1]) { - result = result.map(keccak256_1.keccak256); - } - return (0, keccak256_1.keccak256)((0, bytes_1.hexConcat)(result)); - }; - } - var fields = this.types[type]; - if (fields) { - var encodedType_1 = (0, id_1.id)(this._types[type]); - return function(value) { - var values = fields.map(function(_a7) { - var name2 = _a7.name, type2 = _a7.type; - var result = _this.getEncoder(type2)(value[name2]); - if (_this._types[type2]) { - return (0, keccak256_1.keccak256)(result); - } - return result; - }); - values.unshift(encodedType_1); - return (0, bytes_1.hexConcat)(values); - }; - } - return logger2.throwArgumentError("unknown type: " + type, "type", type); + if (!parents[baseType]) { + logger2.throwArgumentError("unknown type " + JSON.stringify(baseType), "types", types); + } + parents[baseType].push(name_12); + links[name_12][baseType] = true; + }); }; - TypedDataEncoder2.prototype.encodeType = function(name2) { - var result = this._types[name2]; - if (!result) { - logger2.throwArgumentError("unknown type: " + JSON.stringify(name2), "name", name2); + for (var name_1 in types) { + _loop_1(name_1); + } + var primaryTypes = Object.keys(parents).filter(function(n) { + return parents[n].length === 0; + }); + if (primaryTypes.length === 0) { + logger2.throwArgumentError("missing primary type", "types", types); + } else if (primaryTypes.length > 1) { + logger2.throwArgumentError("ambiguous primary types or unused types: " + primaryTypes.map(function(t) { + return JSON.stringify(t); + }).join(", "), "types", types); + } + (0, properties_1.defineReadOnly)(this, "primaryType", primaryTypes[0]); + function checkCircular(type, found) { + if (found[type]) { + logger2.throwArgumentError("circular type reference to " + JSON.stringify(type), "types", types); } - return result; - }; - TypedDataEncoder2.prototype.encodeData = function(type, value) { - return this.getEncoder(type)(value); - }; - TypedDataEncoder2.prototype.hashStruct = function(name2, value) { - return (0, keccak256_1.keccak256)(this.encodeData(name2, value)); - }; - TypedDataEncoder2.prototype.encode = function(value) { - return this.encodeData(this.primaryType, value); - }; - TypedDataEncoder2.prototype.hash = function(value) { - return this.hashStruct(this.primaryType, value); - }; - TypedDataEncoder2.prototype._visit = function(type, value, callback) { - var _this = this; - { - var encoder = getBaseEncoder(type); - if (encoder) { - return callback(type, value); + found[type] = true; + Object.keys(links[type]).forEach(function(child) { + if (!parents[child]) { + return; } + checkCircular(child, found); + Object.keys(found).forEach(function(subtype) { + subtypes[subtype][child] = true; + }); + }); + delete found[type]; + } + checkCircular(this.primaryType, {}); + for (var name_2 in subtypes) { + var st = Object.keys(subtypes[name_2]); + st.sort(); + this._types[name_2] = encodeType(name_2, types[name_2]) + st.map(function(t) { + return encodeType(t, types[t]); + }).join(""); + } + } + TypedDataEncoder2.prototype.getEncoder = function(type) { + var encoder = this._encoderCache[type]; + if (!encoder) { + encoder = this._encoderCache[type] = this._getEncoder(type); + } + return encoder; + }; + TypedDataEncoder2.prototype._getEncoder = function(type) { + var _this = this; + { + var encoder = getBaseEncoder(type); + if (encoder) { + return encoder; } - var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/); - if (match) { - var subtype_2 = match[1]; - var length_2 = parseInt(match[3]); - if (length_2 >= 0 && value.length !== length_2) { + } + var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/); + if (match) { + var subtype_1 = match[1]; + var subEncoder_1 = this.getEncoder(subtype_1); + var length_1 = parseInt(match[3]); + return function(value) { + if (length_1 >= 0 && value.length !== length_1) { logger2.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value); } - return value.map(function(v) { - return _this._visit(subtype_2, v, callback); - }); - } - var fields = this.types[type]; - if (fields) { - return fields.reduce(function(accum, _a7) { + var result = value.map(subEncoder_1); + if (_this._types[subtype_1]) { + result = result.map(keccak256_1.keccak256); + } + return (0, keccak256_1.keccak256)((0, bytes_1.hexConcat)(result)); + }; + } + var fields = this.types[type]; + if (fields) { + var encodedType_1 = (0, id_1.id)(this._types[type]); + return function(value) { + var values = fields.map(function(_a7) { var name2 = _a7.name, type2 = _a7.type; - accum[name2] = _this._visit(type2, value[name2], callback); - return accum; - }, {}); + var result = _this.getEncoder(type2)(value[name2]); + if (_this._types[type2]) { + return (0, keccak256_1.keccak256)(result); + } + return result; + }); + values.unshift(encodedType_1); + return (0, bytes_1.hexConcat)(values); + }; + } + return logger2.throwArgumentError("unknown type: " + type, "type", type); + }; + TypedDataEncoder2.prototype.encodeType = function(name2) { + var result = this._types[name2]; + if (!result) { + logger2.throwArgumentError("unknown type: " + JSON.stringify(name2), "name", name2); + } + return result; + }; + TypedDataEncoder2.prototype.encodeData = function(type, value) { + return this.getEncoder(type)(value); + }; + TypedDataEncoder2.prototype.hashStruct = function(name2, value) { + return (0, keccak256_1.keccak256)(this.encodeData(name2, value)); + }; + TypedDataEncoder2.prototype.encode = function(value) { + return this.encodeData(this.primaryType, value); + }; + TypedDataEncoder2.prototype.hash = function(value) { + return this.hashStruct(this.primaryType, value); + }; + TypedDataEncoder2.prototype._visit = function(type, value, callback) { + var _this = this; + { + var encoder = getBaseEncoder(type); + if (encoder) { + return callback(type, value); } - return logger2.throwArgumentError("unknown type: " + type, "type", type); - }; - TypedDataEncoder2.prototype.visit = function(value, callback) { - return this._visit(this.primaryType, value, callback); - }; - TypedDataEncoder2.from = function(types) { - return new TypedDataEncoder2(types); - }; - TypedDataEncoder2.getPrimaryType = function(types) { - return TypedDataEncoder2.from(types).primaryType; - }; - TypedDataEncoder2.hashStruct = function(name2, types, value) { - return TypedDataEncoder2.from(types).hashStruct(name2, value); - }; - TypedDataEncoder2.hashDomain = function(domain) { - var domainFields = []; - for (var name_3 in domain) { - var type = domainFieldTypes[name_3]; - if (!type) { - logger2.throwArgumentError("invalid typed-data domain key: " + JSON.stringify(name_3), "domain", domain); - } - domainFields.push({ name: name_3, type }); + } + var match = type.match(/^(.*)(\x5b(\d*)\x5d)$/); + if (match) { + var subtype_2 = match[1]; + var length_2 = parseInt(match[3]); + if (length_2 >= 0 && value.length !== length_2) { + logger2.throwArgumentError("array length mismatch; expected length ${ arrayLength }", "value", value); } - domainFields.sort(function(a, b) { - return domainFieldNames.indexOf(a.name) - domainFieldNames.indexOf(b.name); + return value.map(function(v) { + return _this._visit(subtype_2, v, callback); }); - return TypedDataEncoder2.hashStruct("EIP712Domain", { EIP712Domain: domainFields }, domain); - }; - TypedDataEncoder2.encode = function(domain, types, value) { - return (0, bytes_1.hexConcat)([ - "0x1901", - TypedDataEncoder2.hashDomain(domain), - TypedDataEncoder2.from(types).hash(value) - ]); - }; - TypedDataEncoder2.hash = function(domain, types, value) { - return (0, keccak256_1.keccak256)(TypedDataEncoder2.encode(domain, types, value)); - }; - TypedDataEncoder2.resolveNames = function(domain, types, value, resolveName) { - return __awaiter2(this, void 0, void 0, function() { - var ensCache, encoder, _a7, _b, _i, name_4, _c, _d; - return __generator2(this, function(_e) { - switch (_e.label) { - case 0: - domain = (0, properties_1.shallowCopy)(domain); - ensCache = {}; - if (domain.verifyingContract && !(0, bytes_1.isHexString)(domain.verifyingContract, 20)) { - ensCache[domain.verifyingContract] = "0x"; + } + var fields = this.types[type]; + if (fields) { + return fields.reduce(function(accum, _a7) { + var name2 = _a7.name, type2 = _a7.type; + accum[name2] = _this._visit(type2, value[name2], callback); + return accum; + }, {}); + } + return logger2.throwArgumentError("unknown type: " + type, "type", type); + }; + TypedDataEncoder2.prototype.visit = function(value, callback) { + return this._visit(this.primaryType, value, callback); + }; + TypedDataEncoder2.from = function(types) { + return new TypedDataEncoder2(types); + }; + TypedDataEncoder2.getPrimaryType = function(types) { + return TypedDataEncoder2.from(types).primaryType; + }; + TypedDataEncoder2.hashStruct = function(name2, types, value) { + return TypedDataEncoder2.from(types).hashStruct(name2, value); + }; + TypedDataEncoder2.hashDomain = function(domain) { + var domainFields = []; + for (var name_3 in domain) { + var type = domainFieldTypes[name_3]; + if (!type) { + logger2.throwArgumentError("invalid typed-data domain key: " + JSON.stringify(name_3), "domain", domain); + } + domainFields.push({ name: name_3, type }); + } + domainFields.sort(function(a, b) { + return domainFieldNames.indexOf(a.name) - domainFieldNames.indexOf(b.name); + }); + return TypedDataEncoder2.hashStruct("EIP712Domain", { EIP712Domain: domainFields }, domain); + }; + TypedDataEncoder2.encode = function(domain, types, value) { + return (0, bytes_1.hexConcat)([ + "0x1901", + TypedDataEncoder2.hashDomain(domain), + TypedDataEncoder2.from(types).hash(value) + ]); + }; + TypedDataEncoder2.hash = function(domain, types, value) { + return (0, keccak256_1.keccak256)(TypedDataEncoder2.encode(domain, types, value)); + }; + TypedDataEncoder2.resolveNames = function(domain, types, value, resolveName) { + return __awaiter(this, void 0, void 0, function() { + var ensCache, encoder, _a7, _b, _i, name_4, _c, _d; + return __generator(this, function(_e) { + switch (_e.label) { + case 0: + domain = (0, properties_1.shallowCopy)(domain); + ensCache = {}; + if (domain.verifyingContract && !(0, bytes_1.isHexString)(domain.verifyingContract, 20)) { + ensCache[domain.verifyingContract] = "0x"; + } + encoder = TypedDataEncoder2.from(types); + encoder.visit(value, function(type, value2) { + if (type === "address" && !(0, bytes_1.isHexString)(value2, 20)) { + ensCache[value2] = "0x"; } - encoder = TypedDataEncoder2.from(types); - encoder.visit(value, function(type, value2) { - if (type === "address" && !(0, bytes_1.isHexString)(value2, 20)) { - ensCache[value2] = "0x"; - } - return value2; - }); - _a7 = []; - for (_b in ensCache) - _a7.push(_b); - _i = 0; - _e.label = 1; - case 1: - if (!(_i < _a7.length)) - return [3, 4]; - name_4 = _a7[_i]; - _c = ensCache; - _d = name_4; - return [4, resolveName(name_4)]; - case 2: - _c[_d] = _e.sent(); - _e.label = 3; - case 3: - _i++; - return [3, 1]; - case 4: - if (domain.verifyingContract && ensCache[domain.verifyingContract]) { - domain.verifyingContract = ensCache[domain.verifyingContract]; + return value2; + }); + _a7 = []; + for (_b in ensCache) + _a7.push(_b); + _i = 0; + _e.label = 1; + case 1: + if (!(_i < _a7.length)) + return [3, 4]; + name_4 = _a7[_i]; + _c = ensCache; + _d = name_4; + return [4, resolveName(name_4)]; + case 2: + _c[_d] = _e.sent(); + _e.label = 3; + case 3: + _i++; + return [3, 1]; + case 4: + if (domain.verifyingContract && ensCache[domain.verifyingContract]) { + domain.verifyingContract = ensCache[domain.verifyingContract]; + } + value = encoder.visit(value, function(type, value2) { + if (type === "address" && ensCache[value2]) { + return ensCache[value2]; } - value = encoder.visit(value, function(type, value2) { - if (type === "address" && ensCache[value2]) { - return ensCache[value2]; - } - return value2; - }); - return [2, { domain, value }]; - } - }); - }); - }; - TypedDataEncoder2.getPayload = function(domain, types, value) { - TypedDataEncoder2.hashDomain(domain); - var domainValues = {}; - var domainTypes = []; - domainFieldNames.forEach(function(name2) { - var value2 = domain[name2]; - if (value2 == null) { - return; + return value2; + }); + return [2, { domain, value }]; } - domainValues[name2] = domainChecks[name2](value2); - domainTypes.push({ name: name2, type: domainFieldTypes[name2] }); }); - var encoder = TypedDataEncoder2.from(types); - var typesWithDomain = (0, properties_1.shallowCopy)(types); - if (typesWithDomain.EIP712Domain) { - logger2.throwArgumentError("types must not contain EIP712Domain type", "types.EIP712Domain", types); - } else { - typesWithDomain.EIP712Domain = domainTypes; + }); + }; + TypedDataEncoder2.getPayload = function(domain, types, value) { + TypedDataEncoder2.hashDomain(domain); + var domainValues = {}; + var domainTypes = []; + domainFieldNames.forEach(function(name2) { + var value2 = domain[name2]; + if (value2 == null) { + return; } - encoder.encode(value); - return { - types: typesWithDomain, - domain: domainValues, - primaryType: encoder.primaryType, - message: encoder.visit(value, function(type, value2) { - if (type.match(/^bytes(\d*)/)) { - return (0, bytes_1.hexlify)((0, bytes_1.arrayify)(value2)); - } - if (type.match(/^u?int/)) { - return bignumber_1.BigNumber.from(value2).toString(); - } - switch (type) { - case "address": - return value2.toLowerCase(); - case "bool": - return !!value2; - case "string": - if (typeof value2 !== "string") { - logger2.throwArgumentError("invalid string", "value", value2); - } - return value2; - } - return logger2.throwArgumentError("unsupported type", "type", type); - }) - }; + domainValues[name2] = domainChecks[name2](value2); + domainTypes.push({ name: name2, type: domainFieldTypes[name2] }); + }); + var encoder = TypedDataEncoder2.from(types); + var typesWithDomain = (0, properties_1.shallowCopy)(types); + if (typesWithDomain.EIP712Domain) { + logger2.throwArgumentError("types must not contain EIP712Domain type", "types.EIP712Domain", types); + } else { + typesWithDomain.EIP712Domain = domainTypes; + } + encoder.encode(value); + return { + types: typesWithDomain, + domain: domainValues, + primaryType: encoder.primaryType, + message: encoder.visit(value, function(type, value2) { + if (type.match(/^bytes(\d*)/)) { + return (0, bytes_1.hexlify)((0, bytes_1.arrayify)(value2)); + } + if (type.match(/^u?int/)) { + return bignumber_1.BigNumber.from(value2).toString(); + } + switch (type) { + case "address": + return value2.toLowerCase(); + case "bool": + return !!value2; + case "string": + if (typeof value2 !== "string") { + logger2.throwArgumentError("invalid string", "value", value2); + } + return value2; + } + return logger2.throwArgumentError("unsupported type", "type", type); + }) }; - return TypedDataEncoder2; - }() - ); + }; + return TypedDataEncoder2; + }(); exports2.TypedDataEncoder = TypedDataEncoder; } }); @@ -9219,21 +9163,21 @@ var require_lib10 = __commonJS({ var require_interface = __commonJS({ "node_modules/@ethersproject/abi/lib/interface.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -9257,52 +9201,40 @@ var require_interface = __commonJS({ var logger_1 = require_lib(); var _version_1 = require_version5(); var logger2 = new logger_1.Logger(_version_1.version); - var LogDescription = ( - /** @class */ - function(_super) { - __extends2(LogDescription2, _super); - function LogDescription2() { - return _super !== null && _super.apply(this, arguments) || this; - } - return LogDescription2; - }(properties_1.Description) - ); + var LogDescription = function(_super) { + __extends(LogDescription2, _super); + function LogDescription2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return LogDescription2; + }(properties_1.Description); exports2.LogDescription = LogDescription; - var TransactionDescription = ( - /** @class */ - function(_super) { - __extends2(TransactionDescription2, _super); - function TransactionDescription2() { - return _super !== null && _super.apply(this, arguments) || this; - } - return TransactionDescription2; - }(properties_1.Description) - ); + var TransactionDescription = function(_super) { + __extends(TransactionDescription2, _super); + function TransactionDescription2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TransactionDescription2; + }(properties_1.Description); exports2.TransactionDescription = TransactionDescription; - var ErrorDescription = ( - /** @class */ - function(_super) { - __extends2(ErrorDescription2, _super); - function ErrorDescription2() { - return _super !== null && _super.apply(this, arguments) || this; - } - return ErrorDescription2; - }(properties_1.Description) - ); + var ErrorDescription = function(_super) { + __extends(ErrorDescription2, _super); + function ErrorDescription2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ErrorDescription2; + }(properties_1.Description); exports2.ErrorDescription = ErrorDescription; - var Indexed = ( - /** @class */ - function(_super) { - __extends2(Indexed2, _super); - function Indexed2() { - return _super !== null && _super.apply(this, arguments) || this; - } - Indexed2.isIndexed = function(value) { - return !!(value && value._isIndexed); - }; - return Indexed2; - }(properties_1.Description) - ); + var Indexed = function(_super) { + __extends(Indexed2, _super); + function Indexed2() { + return _super !== null && _super.apply(this, arguments) || this; + } + Indexed2.isIndexed = function(value) { + return !!(value && value._isIndexed); + }; + return Indexed2; + }(properties_1.Description); exports2.Indexed = Indexed; var BuiltinErrors = { "0x08c379a0": { signature: "Error(string)", name: "Error", inputs: ["string"], reason: true }, @@ -9313,524 +9245,512 @@ var require_interface = __commonJS({ wrap2.error = error; return wrap2; } - var Interface = ( - /** @class */ - function() { - function Interface2(fragments) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, Interface2); - var abi = []; - if (typeof fragments === "string") { - abi = JSON.parse(fragments); - } else { - abi = fragments; - } - (0, properties_1.defineReadOnly)(this, "fragments", abi.map(function(fragment) { - return fragments_1.Fragment.from(fragment); - }).filter(function(fragment) { - return fragment != null; - })); - (0, properties_1.defineReadOnly)(this, "_abiCoder", (0, properties_1.getStatic)(_newTarget, "getAbiCoder")()); - (0, properties_1.defineReadOnly)(this, "functions", {}); - (0, properties_1.defineReadOnly)(this, "errors", {}); - (0, properties_1.defineReadOnly)(this, "events", {}); - (0, properties_1.defineReadOnly)(this, "structs", {}); - this.fragments.forEach(function(fragment) { - var bucket = null; - switch (fragment.type) { - case "constructor": - if (_this.deploy) { - logger2.warn("duplicate definition - constructor"); - return; - } - (0, properties_1.defineReadOnly)(_this, "deploy", fragment); - return; - case "function": - bucket = _this.functions; - break; - case "event": - bucket = _this.events; - break; - case "error": - bucket = _this.errors; - break; - default: + var Interface = function() { + function Interface2(fragments) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, Interface2); + var abi = []; + if (typeof fragments === "string") { + abi = JSON.parse(fragments); + } else { + abi = fragments; + } + (0, properties_1.defineReadOnly)(this, "fragments", abi.map(function(fragment) { + return fragments_1.Fragment.from(fragment); + }).filter(function(fragment) { + return fragment != null; + })); + (0, properties_1.defineReadOnly)(this, "_abiCoder", (0, properties_1.getStatic)(_newTarget, "getAbiCoder")()); + (0, properties_1.defineReadOnly)(this, "functions", {}); + (0, properties_1.defineReadOnly)(this, "errors", {}); + (0, properties_1.defineReadOnly)(this, "events", {}); + (0, properties_1.defineReadOnly)(this, "structs", {}); + this.fragments.forEach(function(fragment) { + var bucket = null; + switch (fragment.type) { + case "constructor": + if (_this.deploy) { + logger2.warn("duplicate definition - constructor"); return; - } - var signature = fragment.format(); - if (bucket[signature]) { - logger2.warn("duplicate definition - " + signature); + } + (0, properties_1.defineReadOnly)(_this, "deploy", fragment); + return; + case "function": + bucket = _this.functions; + break; + case "event": + bucket = _this.events; + break; + case "error": + bucket = _this.errors; + break; + default: return; - } - bucket[signature] = fragment; - }); - if (!this.deploy) { - (0, properties_1.defineReadOnly)(this, "deploy", fragments_1.ConstructorFragment.from({ - payable: false, - type: "constructor" - })); } - (0, properties_1.defineReadOnly)(this, "_isInterface", true); - } - Interface2.prototype.format = function(format) { - if (!format) { - format = fragments_1.FormatTypes.full; + var signature = fragment.format(); + if (bucket[signature]) { + logger2.warn("duplicate definition - " + signature); + return; } - if (format === fragments_1.FormatTypes.sighash) { - logger2.throwArgumentError("interface does not support formatting sighash", "format", format); + bucket[signature] = fragment; + }); + if (!this.deploy) { + (0, properties_1.defineReadOnly)(this, "deploy", fragments_1.ConstructorFragment.from({ + payable: false, + type: "constructor" + })); + } + (0, properties_1.defineReadOnly)(this, "_isInterface", true); + } + Interface2.prototype.format = function(format) { + if (!format) { + format = fragments_1.FormatTypes.full; + } + if (format === fragments_1.FormatTypes.sighash) { + logger2.throwArgumentError("interface does not support formatting sighash", "format", format); + } + var abi = this.fragments.map(function(fragment) { + return fragment.format(format); + }); + if (format === fragments_1.FormatTypes.json) { + return JSON.stringify(abi.map(function(j) { + return JSON.parse(j); + })); + } + return abi; + }; + Interface2.getAbiCoder = function() { + return abi_coder_1.defaultAbiCoder; + }; + Interface2.getAddress = function(address) { + return (0, address_1.getAddress)(address); + }; + Interface2.getSighash = function(fragment) { + return (0, bytes_1.hexDataSlice)((0, hash_1.id)(fragment.format()), 0, 4); + }; + Interface2.getEventTopic = function(eventFragment) { + return (0, hash_1.id)(eventFragment.format()); + }; + Interface2.prototype.getFunction = function(nameOrSignatureOrSighash) { + if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) { + for (var name_1 in this.functions) { + if (nameOrSignatureOrSighash === this.getSighash(name_1)) { + return this.functions[name_1]; + } } - var abi = this.fragments.map(function(fragment) { - return fragment.format(format); + logger2.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash); + } + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + var name_2 = nameOrSignatureOrSighash.trim(); + var matching = Object.keys(this.functions).filter(function(f) { + return f.split("(")[0] === name_2; }); - if (format === fragments_1.FormatTypes.json) { - return JSON.stringify(abi.map(function(j) { - return JSON.parse(j); - })); - } - return abi; - }; - Interface2.getAbiCoder = function() { - return abi_coder_1.defaultAbiCoder; - }; - Interface2.getAddress = function(address) { - return (0, address_1.getAddress)(address); - }; - Interface2.getSighash = function(fragment) { - return (0, bytes_1.hexDataSlice)((0, hash_1.id)(fragment.format()), 0, 4); - }; - Interface2.getEventTopic = function(eventFragment) { - return (0, hash_1.id)(eventFragment.format()); - }; - Interface2.prototype.getFunction = function(nameOrSignatureOrSighash) { - if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) { - for (var name_1 in this.functions) { - if (nameOrSignatureOrSighash === this.getSighash(name_1)) { - return this.functions[name_1]; - } - } - logger2.throwArgumentError("no matching function", "sighash", nameOrSignatureOrSighash); + if (matching.length === 0) { + logger2.throwArgumentError("no matching function", "name", name_2); + } else if (matching.length > 1) { + logger2.throwArgumentError("multiple matching functions", "name", name_2); } - if (nameOrSignatureOrSighash.indexOf("(") === -1) { - var name_2 = nameOrSignatureOrSighash.trim(); - var matching = Object.keys(this.functions).filter(function(f) { - return f.split( - "(" - /* fix:) */ - )[0] === name_2; - }); - if (matching.length === 0) { - logger2.throwArgumentError("no matching function", "name", name_2); - } else if (matching.length > 1) { - logger2.throwArgumentError("multiple matching functions", "name", name_2); + return this.functions[matching[0]]; + } + var result = this.functions[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + if (!result) { + logger2.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash); + } + return result; + }; + Interface2.prototype.getEvent = function(nameOrSignatureOrTopic) { + if ((0, bytes_1.isHexString)(nameOrSignatureOrTopic)) { + var topichash = nameOrSignatureOrTopic.toLowerCase(); + for (var name_3 in this.events) { + if (topichash === this.getEventTopic(name_3)) { + return this.events[name_3]; } - return this.functions[matching[0]]; } - var result = this.functions[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; - if (!result) { - logger2.throwArgumentError("no matching function", "signature", nameOrSignatureOrSighash); - } - return result; - }; - Interface2.prototype.getEvent = function(nameOrSignatureOrTopic) { - if ((0, bytes_1.isHexString)(nameOrSignatureOrTopic)) { - var topichash = nameOrSignatureOrTopic.toLowerCase(); - for (var name_3 in this.events) { - if (topichash === this.getEventTopic(name_3)) { - return this.events[name_3]; - } - } - logger2.throwArgumentError("no matching event", "topichash", topichash); + logger2.throwArgumentError("no matching event", "topichash", topichash); + } + if (nameOrSignatureOrTopic.indexOf("(") === -1) { + var name_4 = nameOrSignatureOrTopic.trim(); + var matching = Object.keys(this.events).filter(function(f) { + return f.split("(")[0] === name_4; + }); + if (matching.length === 0) { + logger2.throwArgumentError("no matching event", "name", name_4); + } else if (matching.length > 1) { + logger2.throwArgumentError("multiple matching events", "name", name_4); } - if (nameOrSignatureOrTopic.indexOf("(") === -1) { - var name_4 = nameOrSignatureOrTopic.trim(); - var matching = Object.keys(this.events).filter(function(f) { - return f.split( - "(" - /* fix:) */ - )[0] === name_4; - }); - if (matching.length === 0) { - logger2.throwArgumentError("no matching event", "name", name_4); - } else if (matching.length > 1) { - logger2.throwArgumentError("multiple matching events", "name", name_4); + return this.events[matching[0]]; + } + var result = this.events[fragments_1.EventFragment.fromString(nameOrSignatureOrTopic).format()]; + if (!result) { + logger2.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic); + } + return result; + }; + Interface2.prototype.getError = function(nameOrSignatureOrSighash) { + if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) { + var getSighash = (0, properties_1.getStatic)(this.constructor, "getSighash"); + for (var name_5 in this.errors) { + var error = this.errors[name_5]; + if (nameOrSignatureOrSighash === getSighash(error)) { + return this.errors[name_5]; } - return this.events[matching[0]]; } - var result = this.events[fragments_1.EventFragment.fromString(nameOrSignatureOrTopic).format()]; - if (!result) { - logger2.throwArgumentError("no matching event", "signature", nameOrSignatureOrTopic); - } - return result; - }; - Interface2.prototype.getError = function(nameOrSignatureOrSighash) { - if ((0, bytes_1.isHexString)(nameOrSignatureOrSighash)) { - var getSighash = (0, properties_1.getStatic)(this.constructor, "getSighash"); - for (var name_5 in this.errors) { - var error = this.errors[name_5]; - if (nameOrSignatureOrSighash === getSighash(error)) { - return this.errors[name_5]; - } - } - logger2.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash); + logger2.throwArgumentError("no matching error", "sighash", nameOrSignatureOrSighash); + } + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + var name_6 = nameOrSignatureOrSighash.trim(); + var matching = Object.keys(this.errors).filter(function(f) { + return f.split("(")[0] === name_6; + }); + if (matching.length === 0) { + logger2.throwArgumentError("no matching error", "name", name_6); + } else if (matching.length > 1) { + logger2.throwArgumentError("multiple matching errors", "name", name_6); } - if (nameOrSignatureOrSighash.indexOf("(") === -1) { - var name_6 = nameOrSignatureOrSighash.trim(); - var matching = Object.keys(this.errors).filter(function(f) { - return f.split( - "(" - /* fix:) */ - )[0] === name_6; - }); - if (matching.length === 0) { - logger2.throwArgumentError("no matching error", "name", name_6); - } else if (matching.length > 1) { - logger2.throwArgumentError("multiple matching errors", "name", name_6); + return this.errors[matching[0]]; + } + var result = this.errors[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + if (!result) { + logger2.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash); + } + return result; + }; + Interface2.prototype.getSighash = function(fragment) { + if (typeof fragment === "string") { + try { + fragment = this.getFunction(fragment); + } catch (error) { + try { + fragment = this.getError(fragment); + } catch (_) { + throw error; } - return this.errors[matching[0]]; } - var result = this.errors[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; - if (!result) { - logger2.throwArgumentError("no matching error", "signature", nameOrSignatureOrSighash); - } - return result; - }; - Interface2.prototype.getSighash = function(fragment) { - if (typeof fragment === "string") { + } + return (0, properties_1.getStatic)(this.constructor, "getSighash")(fragment); + }; + Interface2.prototype.getEventTopic = function(eventFragment) { + if (typeof eventFragment === "string") { + eventFragment = this.getEvent(eventFragment); + } + return (0, properties_1.getStatic)(this.constructor, "getEventTopic")(eventFragment); + }; + Interface2.prototype._decodeParams = function(params, data) { + return this._abiCoder.decode(params, data); + }; + Interface2.prototype._encodeParams = function(params, values) { + return this._abiCoder.encode(params, values); + }; + Interface2.prototype.encodeDeploy = function(values) { + return this._encodeParams(this.deploy.inputs, values || []); + }; + Interface2.prototype.decodeErrorResult = function(fragment, data) { + if (typeof fragment === "string") { + fragment = this.getError(fragment); + } + var bytes = (0, bytes_1.arrayify)(data); + if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(fragment)) { + logger2.throwArgumentError("data signature does not match error " + fragment.name + ".", "data", (0, bytes_1.hexlify)(bytes)); + } + return this._decodeParams(fragment.inputs, bytes.slice(4)); + }; + Interface2.prototype.encodeErrorResult = function(fragment, values) { + if (typeof fragment === "string") { + fragment = this.getError(fragment); + } + return (0, bytes_1.hexlify)((0, bytes_1.concat)([ + this.getSighash(fragment), + this._encodeParams(fragment.inputs, values || []) + ])); + }; + Interface2.prototype.decodeFunctionData = function(functionFragment, data) { + if (typeof functionFragment === "string") { + functionFragment = this.getFunction(functionFragment); + } + var bytes = (0, bytes_1.arrayify)(data); + if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) { + logger2.throwArgumentError("data signature does not match function " + functionFragment.name + ".", "data", (0, bytes_1.hexlify)(bytes)); + } + return this._decodeParams(functionFragment.inputs, bytes.slice(4)); + }; + Interface2.prototype.encodeFunctionData = function(functionFragment, values) { + if (typeof functionFragment === "string") { + functionFragment = this.getFunction(functionFragment); + } + return (0, bytes_1.hexlify)((0, bytes_1.concat)([ + this.getSighash(functionFragment), + this._encodeParams(functionFragment.inputs, values || []) + ])); + }; + Interface2.prototype.decodeFunctionResult = function(functionFragment, data) { + if (typeof functionFragment === "string") { + functionFragment = this.getFunction(functionFragment); + } + var bytes = (0, bytes_1.arrayify)(data); + var reason = null; + var errorArgs = null; + var errorName = null; + var errorSignature = null; + switch (bytes.length % this._abiCoder._getWordSize()) { + case 0: try { - fragment = this.getFunction(fragment); - } catch (error) { - try { - fragment = this.getError(fragment); - } catch (_) { - throw error; - } + return this._abiCoder.decode(functionFragment.outputs, bytes); + } catch (error2) { } - } - return (0, properties_1.getStatic)(this.constructor, "getSighash")(fragment); - }; - Interface2.prototype.getEventTopic = function(eventFragment) { - if (typeof eventFragment === "string") { - eventFragment = this.getEvent(eventFragment); - } - return (0, properties_1.getStatic)(this.constructor, "getEventTopic")(eventFragment); - }; - Interface2.prototype._decodeParams = function(params, data) { - return this._abiCoder.decode(params, data); - }; - Interface2.prototype._encodeParams = function(params, values) { - return this._abiCoder.encode(params, values); - }; - Interface2.prototype.encodeDeploy = function(values) { - return this._encodeParams(this.deploy.inputs, values || []); - }; - Interface2.prototype.decodeErrorResult = function(fragment, data) { - if (typeof fragment === "string") { - fragment = this.getError(fragment); - } - var bytes = (0, bytes_1.arrayify)(data); - if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(fragment)) { - logger2.throwArgumentError("data signature does not match error " + fragment.name + ".", "data", (0, bytes_1.hexlify)(bytes)); - } - return this._decodeParams(fragment.inputs, bytes.slice(4)); - }; - Interface2.prototype.encodeErrorResult = function(fragment, values) { - if (typeof fragment === "string") { - fragment = this.getError(fragment); - } - return (0, bytes_1.hexlify)((0, bytes_1.concat)([ - this.getSighash(fragment), - this._encodeParams(fragment.inputs, values || []) - ])); - }; - Interface2.prototype.decodeFunctionData = function(functionFragment, data) { - if (typeof functionFragment === "string") { - functionFragment = this.getFunction(functionFragment); - } - var bytes = (0, bytes_1.arrayify)(data); - if ((0, bytes_1.hexlify)(bytes.slice(0, 4)) !== this.getSighash(functionFragment)) { - logger2.throwArgumentError("data signature does not match function " + functionFragment.name + ".", "data", (0, bytes_1.hexlify)(bytes)); - } - return this._decodeParams(functionFragment.inputs, bytes.slice(4)); - }; - Interface2.prototype.encodeFunctionData = function(functionFragment, values) { - if (typeof functionFragment === "string") { - functionFragment = this.getFunction(functionFragment); - } - return (0, bytes_1.hexlify)((0, bytes_1.concat)([ - this.getSighash(functionFragment), - this._encodeParams(functionFragment.inputs, values || []) - ])); - }; - Interface2.prototype.decodeFunctionResult = function(functionFragment, data) { - if (typeof functionFragment === "string") { - functionFragment = this.getFunction(functionFragment); - } - var bytes = (0, bytes_1.arrayify)(data); - var reason = null; - var errorArgs = null; - var errorName = null; - var errorSignature = null; - switch (bytes.length % this._abiCoder._getWordSize()) { - case 0: + break; + case 4: { + var selector = (0, bytes_1.hexlify)(bytes.slice(0, 4)); + var builtin = BuiltinErrors[selector]; + if (builtin) { + errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4)); + errorName = builtin.name; + errorSignature = builtin.signature; + if (builtin.reason) { + reason = errorArgs[0]; + } + } else { try { - return this._abiCoder.decode(functionFragment.outputs, bytes); + var error = this.getError(selector); + errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4)); + errorName = error.name; + errorSignature = error.format(); } catch (error2) { + console.log(error2); } - break; - case 4: { - var selector = (0, bytes_1.hexlify)(bytes.slice(0, 4)); - var builtin = BuiltinErrors[selector]; - if (builtin) { - errorArgs = this._abiCoder.decode(builtin.inputs, bytes.slice(4)); - errorName = builtin.name; - errorSignature = builtin.signature; - if (builtin.reason) { - reason = errorArgs[0]; - } - } else { - try { - var error = this.getError(selector); - errorArgs = this._abiCoder.decode(error.inputs, bytes.slice(4)); - errorName = error.name; - errorSignature = error.format(); - } catch (error2) { - console.log(error2); - } - } - break; } + break; } - return logger2.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, { - method: functionFragment.format(), - errorArgs, - errorName, - errorSignature, - reason + } + return logger2.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, { + method: functionFragment.format(), + errorArgs, + errorName, + errorSignature, + reason + }); + }; + Interface2.prototype.encodeFunctionResult = function(functionFragment, values) { + if (typeof functionFragment === "string") { + functionFragment = this.getFunction(functionFragment); + } + return (0, bytes_1.hexlify)(this._abiCoder.encode(functionFragment.outputs, values || [])); + }; + Interface2.prototype.encodeFilterTopics = function(eventFragment, values) { + var _this = this; + if (typeof eventFragment === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (values.length > eventFragment.inputs.length) { + logger2.throwError("too many arguments for " + eventFragment.format(), logger_1.Logger.errors.UNEXPECTED_ARGUMENT, { + argument: "values", + value: values }); - }; - Interface2.prototype.encodeFunctionResult = function(functionFragment, values) { - if (typeof functionFragment === "string") { - functionFragment = this.getFunction(functionFragment); + } + var topics = []; + if (!eventFragment.anonymous) { + topics.push(this.getEventTopic(eventFragment)); + } + var encodeTopic = function(param, value) { + if (param.type === "string") { + return (0, hash_1.id)(value); + } else if (param.type === "bytes") { + return (0, keccak256_1.keccak256)((0, bytes_1.hexlify)(value)); } - return (0, bytes_1.hexlify)(this._abiCoder.encode(functionFragment.outputs, values || [])); - }; - Interface2.prototype.encodeFilterTopics = function(eventFragment, values) { - var _this = this; - if (typeof eventFragment === "string") { - eventFragment = this.getEvent(eventFragment); + if (param.type === "address") { + _this._abiCoder.encode(["address"], [value]); } - if (values.length > eventFragment.inputs.length) { - logger2.throwError("too many arguments for " + eventFragment.format(), logger_1.Logger.errors.UNEXPECTED_ARGUMENT, { - argument: "values", - value: values - }); + return (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(value), 32); + }; + values.forEach(function(value, index) { + var param = eventFragment.inputs[index]; + if (!param.indexed) { + if (value != null) { + logger2.throwArgumentError("cannot filter non-indexed parameters; must be null", "contract." + param.name, value); + } + return; } - var topics = []; - if (!eventFragment.anonymous) { - topics.push(this.getEventTopic(eventFragment)); + if (value == null) { + topics.push(null); + } else if (param.baseType === "array" || param.baseType === "tuple") { + logger2.throwArgumentError("filtering with tuples or arrays not supported", "contract." + param.name, value); + } else if (Array.isArray(value)) { + topics.push(value.map(function(value2) { + return encodeTopic(param, value2); + })); + } else { + topics.push(encodeTopic(param, value)); } - var encodeTopic = function(param, value) { + }); + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + return topics; + }; + Interface2.prototype.encodeEventLog = function(eventFragment, values) { + var _this = this; + if (typeof eventFragment === "string") { + eventFragment = this.getEvent(eventFragment); + } + var topics = []; + var dataTypes = []; + var dataValues = []; + if (!eventFragment.anonymous) { + topics.push(this.getEventTopic(eventFragment)); + } + if (values.length !== eventFragment.inputs.length) { + logger2.throwArgumentError("event arguments/values mismatch", "values", values); + } + eventFragment.inputs.forEach(function(param, index) { + var value = values[index]; + if (param.indexed) { if (param.type === "string") { - return (0, hash_1.id)(value); + topics.push((0, hash_1.id)(value)); } else if (param.type === "bytes") { - return (0, keccak256_1.keccak256)((0, bytes_1.hexlify)(value)); - } - if (param.type === "address") { - _this._abiCoder.encode(["address"], [value]); - } - return (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(value), 32); - }; - values.forEach(function(value, index) { - var param = eventFragment.inputs[index]; - if (!param.indexed) { - if (value != null) { - logger2.throwArgumentError("cannot filter non-indexed parameters; must be null", "contract." + param.name, value); - } - return; - } - if (value == null) { - topics.push(null); - } else if (param.baseType === "array" || param.baseType === "tuple") { - logger2.throwArgumentError("filtering with tuples or arrays not supported", "contract." + param.name, value); - } else if (Array.isArray(value)) { - topics.push(value.map(function(value2) { - return encodeTopic(param, value2); - })); + topics.push((0, keccak256_1.keccak256)(value)); + } else if (param.baseType === "tuple" || param.baseType === "array") { + throw new Error("not implemented"); } else { - topics.push(encodeTopic(param, value)); + topics.push(_this._abiCoder.encode([param.type], [value])); } - }); - while (topics.length && topics[topics.length - 1] === null) { - topics.pop(); + } else { + dataTypes.push(param); + dataValues.push(value); } - return topics; - }; - Interface2.prototype.encodeEventLog = function(eventFragment, values) { - var _this = this; - if (typeof eventFragment === "string") { - eventFragment = this.getEvent(eventFragment); - } - var topics = []; - var dataTypes = []; - var dataValues = []; - if (!eventFragment.anonymous) { - topics.push(this.getEventTopic(eventFragment)); - } - if (values.length !== eventFragment.inputs.length) { - logger2.throwArgumentError("event arguments/values mismatch", "values", values); - } - eventFragment.inputs.forEach(function(param, index) { - var value = values[index]; - if (param.indexed) { - if (param.type === "string") { - topics.push((0, hash_1.id)(value)); - } else if (param.type === "bytes") { - topics.push((0, keccak256_1.keccak256)(value)); - } else if (param.baseType === "tuple" || param.baseType === "array") { - throw new Error("not implemented"); - } else { - topics.push(_this._abiCoder.encode([param.type], [value])); - } - } else { - dataTypes.push(param); - dataValues.push(value); - } - }); - return { - data: this._abiCoder.encode(dataTypes, dataValues), - topics - }; + }); + return { + data: this._abiCoder.encode(dataTypes, dataValues), + topics }; - Interface2.prototype.decodeEventLog = function(eventFragment, data, topics) { - if (typeof eventFragment === "string") { - eventFragment = this.getEvent(eventFragment); - } - if (topics != null && !eventFragment.anonymous) { - var topicHash = this.getEventTopic(eventFragment); - if (!(0, bytes_1.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { - logger2.throwError("fragment/topic mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); - } - topics = topics.slice(1); - } - var indexed = []; - var nonIndexed = []; - var dynamic = []; - eventFragment.inputs.forEach(function(param, index) { - if (param.indexed) { - if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { - indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name })); - dynamic.push(true); - } else { - indexed.push(param); - dynamic.push(false); - } + }; + Interface2.prototype.decodeEventLog = function(eventFragment, data, topics) { + if (typeof eventFragment === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (topics != null && !eventFragment.anonymous) { + var topicHash = this.getEventTopic(eventFragment); + if (!(0, bytes_1.isHexString)(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { + logger2.throwError("fragment/topic mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); + } + topics = topics.slice(1); + } + var indexed = []; + var nonIndexed = []; + var dynamic = []; + eventFragment.inputs.forEach(function(param, index) { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name })); + dynamic.push(true); } else { - nonIndexed.push(param); + indexed.push(param); dynamic.push(false); } - }); - var resultIndexed = topics != null ? this._abiCoder.decode(indexed, (0, bytes_1.concat)(topics)) : null; - var resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true); - var result = []; - var nonIndexedIndex = 0, indexedIndex = 0; - eventFragment.inputs.forEach(function(param, index) { - if (param.indexed) { - if (resultIndexed == null) { - result[index] = new Indexed({ _isIndexed: true, hash: null }); - } else if (dynamic[index]) { - result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); - } else { - try { - result[index] = resultIndexed[indexedIndex++]; - } catch (error) { - result[index] = error; - } - } + } else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + var resultIndexed = topics != null ? this._abiCoder.decode(indexed, (0, bytes_1.concat)(topics)) : null; + var resultNonIndexed = this._abiCoder.decode(nonIndexed, data, true); + var result = []; + var nonIndexedIndex = 0, indexedIndex = 0; + eventFragment.inputs.forEach(function(param, index) { + if (param.indexed) { + if (resultIndexed == null) { + result[index] = new Indexed({ _isIndexed: true, hash: null }); + } else if (dynamic[index]) { + result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); } else { try { - result[index] = resultNonIndexed[nonIndexedIndex++]; + result[index] = resultIndexed[indexedIndex++]; } catch (error) { result[index] = error; } } - if (param.name && result[param.name] == null) { - var value_1 = result[index]; - if (value_1 instanceof Error) { - Object.defineProperty(result, param.name, { - enumerable: true, - get: function() { - throw wrapAccessError("property " + JSON.stringify(param.name), value_1); - } - }); - } else { - result[param.name] = value_1; - } + } else { + try { + result[index] = resultNonIndexed[nonIndexedIndex++]; + } catch (error) { + result[index] = error; } - }); - var _loop_1 = function(i2) { - var value = result[i2]; - if (value instanceof Error) { - Object.defineProperty(result, i2, { + } + if (param.name && result[param.name] == null) { + var value_1 = result[index]; + if (value_1 instanceof Error) { + Object.defineProperty(result, param.name, { enumerable: true, get: function() { - throw wrapAccessError("index " + i2, value); + throw wrapAccessError("property " + JSON.stringify(param.name), value_1); } }); + } else { + result[param.name] = value_1; } - }; - for (var i = 0; i < result.length; i++) { - _loop_1(i); } - return Object.freeze(result); - }; - Interface2.prototype.parseTransaction = function(tx) { - var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); - if (!fragment) { - return null; - } - return new TransactionDescription({ - args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), - functionFragment: fragment, - name: fragment.name, - signature: fragment.format(), - sighash: this.getSighash(fragment), - value: bignumber_1.BigNumber.from(tx.value || "0") - }); - }; - Interface2.prototype.parseLog = function(log) { - var fragment = this.getEvent(log.topics[0]); - if (!fragment || fragment.anonymous) { - return null; - } - return new LogDescription({ - eventFragment: fragment, - name: fragment.name, - signature: fragment.format(), - topic: this.getEventTopic(fragment), - args: this.decodeEventLog(fragment, log.data, log.topics) - }); - }; - Interface2.prototype.parseError = function(data) { - var hexData = (0, bytes_1.hexlify)(data); - var fragment = this.getError(hexData.substring(0, 10).toLowerCase()); - if (!fragment) { - return null; + }); + var _loop_1 = function(i2) { + var value = result[i2]; + if (value instanceof Error) { + Object.defineProperty(result, i2, { + enumerable: true, + get: function() { + throw wrapAccessError("index " + i2, value); + } + }); } - return new ErrorDescription({ - args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)), - errorFragment: fragment, - name: fragment.name, - signature: fragment.format(), - sighash: this.getSighash(fragment) - }); }; - Interface2.isInterface = function(value) { - return !!(value && value._isInterface); - }; - return Interface2; - }() - ); + for (var i = 0; i < result.length; i++) { + _loop_1(i); + } + return Object.freeze(result); + }; + Interface2.prototype.parseTransaction = function(tx) { + var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); + if (!fragment) { + return null; + } + return new TransactionDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), + functionFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment), + value: bignumber_1.BigNumber.from(tx.value || "0") + }); + }; + Interface2.prototype.parseLog = function(log) { + var fragment = this.getEvent(log.topics[0]); + if (!fragment || fragment.anonymous) { + return null; + } + return new LogDescription({ + eventFragment: fragment, + name: fragment.name, + signature: fragment.format(), + topic: this.getEventTopic(fragment), + args: this.decodeEventLog(fragment, log.data, log.topics) + }); + }; + Interface2.prototype.parseError = function(data) { + var hexData = (0, bytes_1.hexlify)(data); + var fragment = this.getError(hexData.substring(0, 10).toLowerCase()); + if (!fragment) { + return null; + } + return new ErrorDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + hexData.substring(10)), + errorFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment) + }); + }; + Interface2.isInterface = function(value) { + return !!(value && value._isInterface); + }; + return Interface2; + }(); exports2.Interface = Interface; } }); @@ -9931,78 +9851,75 @@ var require_lib13 = __commonJS({ exports2.Base58 = exports2.Base32 = exports2.BaseX = void 0; var bytes_1 = require_lib2(); var properties_1 = require_lib4(); - var BaseX = ( - /** @class */ - function() { - function BaseX2(alphabet) { - (0, properties_1.defineReadOnly)(this, "alphabet", alphabet); - (0, properties_1.defineReadOnly)(this, "base", alphabet.length); - (0, properties_1.defineReadOnly)(this, "_alphabetMap", {}); - (0, properties_1.defineReadOnly)(this, "_leader", alphabet.charAt(0)); - for (var i = 0; i < alphabet.length; i++) { - this._alphabetMap[alphabet.charAt(i)] = i; - } - } - BaseX2.prototype.encode = function(value) { - var source = (0, bytes_1.arrayify)(value); - if (source.length === 0) { - return ""; - } - var digits = [0]; - for (var i = 0; i < source.length; ++i) { - var carry = source[i]; - for (var j = 0; j < digits.length; ++j) { - carry += digits[j] << 8; - digits[j] = carry % this.base; - carry = carry / this.base | 0; - } - while (carry > 0) { - digits.push(carry % this.base); - carry = carry / this.base | 0; - } + var BaseX = function() { + function BaseX2(alphabet) { + (0, properties_1.defineReadOnly)(this, "alphabet", alphabet); + (0, properties_1.defineReadOnly)(this, "base", alphabet.length); + (0, properties_1.defineReadOnly)(this, "_alphabetMap", {}); + (0, properties_1.defineReadOnly)(this, "_leader", alphabet.charAt(0)); + for (var i = 0; i < alphabet.length; i++) { + this._alphabetMap[alphabet.charAt(i)] = i; + } + } + BaseX2.prototype.encode = function(value) { + var source = (0, bytes_1.arrayify)(value); + if (source.length === 0) { + return ""; + } + var digits = [0]; + for (var i = 0; i < source.length; ++i) { + var carry = source[i]; + for (var j = 0; j < digits.length; ++j) { + carry += digits[j] << 8; + digits[j] = carry % this.base; + carry = carry / this.base | 0; } - var string = ""; - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) { - string += this._leader; + while (carry > 0) { + digits.push(carry % this.base); + carry = carry / this.base | 0; } - for (var q = digits.length - 1; q >= 0; --q) { - string += this.alphabet[digits[q]]; + } + var string = ""; + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) { + string += this._leader; + } + for (var q = digits.length - 1; q >= 0; --q) { + string += this.alphabet[digits[q]]; + } + return string; + }; + BaseX2.prototype.decode = function(value) { + if (typeof value !== "string") { + throw new TypeError("Expected String"); + } + var bytes = []; + if (value.length === 0) { + return new Uint8Array(bytes); + } + bytes.push(0); + for (var i = 0; i < value.length; i++) { + var byte = this._alphabetMap[value[i]]; + if (byte === void 0) { + throw new Error("Non-base" + this.base + " character"); } - return string; - }; - BaseX2.prototype.decode = function(value) { - if (typeof value !== "string") { - throw new TypeError("Expected String"); + var carry = byte; + for (var j = 0; j < bytes.length; ++j) { + carry += bytes[j] * this.base; + bytes[j] = carry & 255; + carry >>= 8; } - var bytes = []; - if (value.length === 0) { - return new Uint8Array(bytes); + while (carry > 0) { + bytes.push(carry & 255); + carry >>= 8; } + } + for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) { bytes.push(0); - for (var i = 0; i < value.length; i++) { - var byte = this._alphabetMap[value[i]]; - if (byte === void 0) { - throw new Error("Non-base" + this.base + " character"); - } - var carry = byte; - for (var j = 0; j < bytes.length; ++j) { - carry += bytes[j] * this.base; - bytes[j] = carry & 255; - carry >>= 8; - } - while (carry > 0) { - bytes.push(carry & 255); - carry >>= 8; - } - } - for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) { - bytes.push(0); - } - return (0, bytes_1.arrayify)(new Uint8Array(bytes.reverse())); - }; - return BaseX2; - }() - ); + } + return (0, bytes_1.arrayify)(new Uint8Array(bytes.reverse())); + }; + return BaseX2; + }(); exports2.BaseX = BaseX; var Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); exports2.Base32 = Base32; @@ -10107,7 +10024,6 @@ var require_package = __commonJS({ // node_modules/minimalistic-assert/index.js var require_minimalistic_assert = __commonJS({ "node_modules/minimalistic-assert/index.js"(exports2, module2) { - "use strict"; module2.exports = assert; function assert(val, msg) { if (!val) @@ -10285,7 +10201,6 @@ var require_utils2 = __commonJS({ // node_modules/brorand/index.js var require_brorand = __commonJS({ "node_modules/brorand/index.js"(exports2, module2) { - "use strict"; var r; module2.exports = function rand(len) { if (!r) @@ -10464,13 +10379,9 @@ var require_base = __commonJS({ } var comb = [ points[a], - /* 1 */ null, - /* 3 */ null, - /* 5 */ points[b] - /* 7 */ ]; if (points[a].y.cmp(points[b].y) === 0) { comb[1] = points[a].add(points[b]); @@ -10484,23 +10395,14 @@ var require_base = __commonJS({ } var index = [ -3, - /* -1 -1 */ -1, - /* -1 0 */ -5, - /* -1 1 */ -7, - /* 0 -1 */ 0, - /* 0 0 */ 7, - /* 0 1 */ 5, - /* 1 -1 */ 1, - /* 1 0 */ 3 - /* 1 1 */ ]; var jsf = getJSF(coeffs[a], coeffs[b]); max = Math.max(jsf[0].length, max); @@ -10665,7 +10567,6 @@ var require_base = __commonJS({ // node_modules/inherits/inherits_browser.js var require_inherits_browser = __commonJS({ "node_modules/inherits/inherits_browser.js"(exports2, module2) { - "use strict"; if (typeof Object.create === "function") { module2.exports = function inherits(ctor, superCtor) { if (superCtor) { @@ -10698,7 +10599,6 @@ var require_inherits_browser = __commonJS({ // node_modules/inherits/inherits.js var require_inherits = __commonJS({ "node_modules/inherits/inherits.js"(exports2, module2) { - "use strict"; try { util = require("util"); if (typeof util.inherits !== "function") @@ -13460,7 +13360,6 @@ var require_hmac = __commonJS({ // node_modules/hash.js/lib/hash.js var require_hash = __commonJS({ "node_modules/hash.js/lib/hash.js"(exports2) { - "use strict"; var hash = exports2; hash.utils = require_utils3(); hash.common = require_common(); @@ -13479,7 +13378,6 @@ var require_hash = __commonJS({ // node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js var require_secp256k1 = __commonJS({ "node_modules/elliptic/lib/elliptic/precomputed/secp256k1.js"(exports2, module2) { - "use strict"; module2.exports = { doubles: { step: 4, @@ -14390,14 +14288,12 @@ var require_curves = __commonJS({ p: "7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed", a: "-1", c: "1", - // -121665 * (121666^(-1)) (mod P) d: "52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3", n: "1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed", hash: hash.sha256, gRed: false, g: [ "216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a", - // 4/5 "6666666666666666666666666666666666666666666666666666666666666658" ] }); @@ -14416,7 +14312,6 @@ var require_curves = __commonJS({ n: "ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141", h: "1", hash: hash.sha256, - // Precomputed endomorphism beta: "7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee", lambda: "5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72", basis: [ @@ -15180,12 +15075,12 @@ var require_elliptic = __commonJS({ var require_elliptic2 = __commonJS({ "node_modules/@ethersproject/signing-key/lib/elliptic.js"(exports2) { "use strict"; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.EC = void 0; - var elliptic_1 = __importDefault2(require_elliptic()); + var elliptic_1 = __importDefault(require_elliptic()); var EC = elliptic_1.default.ec; exports2.EC = EC; } @@ -15220,46 +15115,43 @@ var require_lib15 = __commonJS({ } return _curve; } - var SigningKey = ( - /** @class */ - function() { - function SigningKey2(privateKey) { - (0, properties_1.defineReadOnly)(this, "curve", "secp256k1"); - (0, properties_1.defineReadOnly)(this, "privateKey", (0, bytes_1.hexlify)(privateKey)); - var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey)); - (0, properties_1.defineReadOnly)(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); - (0, properties_1.defineReadOnly)(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); - (0, properties_1.defineReadOnly)(this, "_isSigningKey", true); - } - SigningKey2.prototype._addPoint = function(other) { - var p0 = getCurve().keyFromPublic((0, bytes_1.arrayify)(this.publicKey)); - var p1 = getCurve().keyFromPublic((0, bytes_1.arrayify)(other)); - return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); - }; - SigningKey2.prototype.signDigest = function(digest) { - var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey)); - var digestBytes = (0, bytes_1.arrayify)(digest); - if (digestBytes.length !== 32) { - logger2.throwArgumentError("bad digest length", "digest", digest); - } - var signature = keyPair.sign(digestBytes, { canonical: true }); - return (0, bytes_1.splitSignature)({ - recoveryParam: signature.recoveryParam, - r: (0, bytes_1.hexZeroPad)("0x" + signature.r.toString(16), 32), - s: (0, bytes_1.hexZeroPad)("0x" + signature.s.toString(16), 32) - }); - }; - SigningKey2.prototype.computeSharedSecret = function(otherKey) { - var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey)); - var otherKeyPair = getCurve().keyFromPublic((0, bytes_1.arrayify)(computePublicKey(otherKey))); - return (0, bytes_1.hexZeroPad)("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); - }; - SigningKey2.isSigningKey = function(value) { - return !!(value && value._isSigningKey); - }; - return SigningKey2; - }() - ); + var SigningKey = function() { + function SigningKey2(privateKey) { + (0, properties_1.defineReadOnly)(this, "curve", "secp256k1"); + (0, properties_1.defineReadOnly)(this, "privateKey", (0, bytes_1.hexlify)(privateKey)); + var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey)); + (0, properties_1.defineReadOnly)(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + (0, properties_1.defineReadOnly)(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + (0, properties_1.defineReadOnly)(this, "_isSigningKey", true); + } + SigningKey2.prototype._addPoint = function(other) { + var p0 = getCurve().keyFromPublic((0, bytes_1.arrayify)(this.publicKey)); + var p1 = getCurve().keyFromPublic((0, bytes_1.arrayify)(other)); + return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); + }; + SigningKey2.prototype.signDigest = function(digest) { + var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey)); + var digestBytes = (0, bytes_1.arrayify)(digest); + if (digestBytes.length !== 32) { + logger2.throwArgumentError("bad digest length", "digest", digest); + } + var signature = keyPair.sign(digestBytes, { canonical: true }); + return (0, bytes_1.splitSignature)({ + recoveryParam: signature.recoveryParam, + r: (0, bytes_1.hexZeroPad)("0x" + signature.r.toString(16), 32), + s: (0, bytes_1.hexZeroPad)("0x" + signature.s.toString(16), 32) + }); + }; + SigningKey2.prototype.computeSharedSecret = function(otherKey) { + var keyPair = getCurve().keyFromPrivate((0, bytes_1.arrayify)(this.privateKey)); + var otherKeyPair = getCurve().keyFromPublic((0, bytes_1.arrayify)(computePublicKey(otherKey))); + return (0, bytes_1.hexZeroPad)("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + }; + SigningKey2.isSigningKey = function(value) { + return !!(value && value._isSigningKey); + }; + return SigningKey2; + }(); exports2.SigningKey = SigningKey; function recoverPublicKey(digest, signature) { var sig = (0, bytes_1.splitSignature)(signature); @@ -15393,7 +15285,7 @@ var require_version12 = __commonJS({ var require_lib17 = __commonJS({ "node_modules/@ethersproject/transactions/lib/index.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -15404,21 +15296,21 @@ var require_lib17 = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); @@ -15429,7 +15321,7 @@ var require_lib17 = __commonJS({ var constants_1 = require_lib8(); var keccak256_1 = require_lib5(); var properties_1 = require_lib4(); - var RLP = __importStar2(require_lib6()); + var RLP = __importStar(require_lib6()); var signing_key_1 = require_lib15(); var logger_1 = require_lib(); var _version_1 = require_version12(); @@ -15818,50 +15710,47 @@ var require_wordlist = __commonJS({ var logger_1 = require_lib(); var _version_1 = require_version13(); exports2.logger = new logger_1.Logger(_version_1.version); - var Wordlist = ( - /** @class */ - function() { - function Wordlist2(locale) { - var _newTarget = this.constructor; - exports2.logger.checkAbstract(_newTarget, Wordlist2); - (0, properties_1.defineReadOnly)(this, "locale", locale); - } - Wordlist2.prototype.split = function(mnemonic) { - return mnemonic.toLowerCase().split(/ +/g); - }; - Wordlist2.prototype.join = function(words) { - return words.join(" "); - }; - Wordlist2.check = function(wordlist) { - var words = []; - for (var i = 0; i < 2048; i++) { - var word = wordlist.getWord(i); - if (i !== wordlist.getWordIndex(word)) { - return "0x"; - } - words.push(word); - } - return (0, hash_1.id)(words.join("\n") + "\n"); - }; - Wordlist2.register = function(lang, name2) { - if (!name2) { - name2 = lang.locale; + var Wordlist = function() { + function Wordlist2(locale) { + var _newTarget = this.constructor; + exports2.logger.checkAbstract(_newTarget, Wordlist2); + (0, properties_1.defineReadOnly)(this, "locale", locale); + } + Wordlist2.prototype.split = function(mnemonic) { + return mnemonic.toLowerCase().split(/ +/g); + }; + Wordlist2.prototype.join = function(words) { + return words.join(" "); + }; + Wordlist2.check = function(wordlist) { + var words = []; + for (var i = 0; i < 2048; i++) { + var word = wordlist.getWord(i); + if (i !== wordlist.getWordIndex(word)) { + return "0x"; } - if (exportWordlist) { - try { - var anyGlobal = window; - if (anyGlobal._ethers && anyGlobal._ethers.wordlists) { - if (!anyGlobal._ethers.wordlists[name2]) { - (0, properties_1.defineReadOnly)(anyGlobal._ethers.wordlists, name2, lang); - } + words.push(word); + } + return (0, hash_1.id)(words.join("\n") + "\n"); + }; + Wordlist2.register = function(lang, name2) { + if (!name2) { + name2 = lang.locale; + } + if (exportWordlist) { + try { + var anyGlobal = window; + if (anyGlobal._ethers && anyGlobal._ethers.wordlists) { + if (!anyGlobal._ethers.wordlists[name2]) { + (0, properties_1.defineReadOnly)(anyGlobal._ethers.wordlists, name2, lang); } - } catch (error) { } + } catch (error) { } - }; - return Wordlist2; - }() - ); + } + }; + return Wordlist2; + }(); exports2.Wordlist = Wordlist; } }); @@ -15870,21 +15759,21 @@ var require_wordlist = __commonJS({ var require_lang_cz = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-cz.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -15906,24 +15795,21 @@ var require_lang_cz = __commonJS({ throw new Error("BIP39 Wordlist for en (English) FAILED"); } } - var LangCz = ( - /** @class */ - function(_super) { - __extends2(LangCz2, _super); - function LangCz2() { - return _super.call(this, "cz") || this; - } - LangCz2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangCz2.prototype.getWordIndex = function(word) { - loadWords(this); - return wordlist.indexOf(word); - }; - return LangCz2; - }(wordlist_1.Wordlist) - ); + var LangCz = function(_super) { + __extends(LangCz2, _super); + function LangCz2() { + return _super.call(this, "cz") || this; + } + LangCz2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangCz2.prototype.getWordIndex = function(word) { + loadWords(this); + return wordlist.indexOf(word); + }; + return LangCz2; + }(wordlist_1.Wordlist); var langCz = new LangCz(); exports2.langCz = langCz; wordlist_1.Wordlist.register(langCz); @@ -15934,21 +15820,21 @@ var require_lang_cz = __commonJS({ var require_lang_en = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-en.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -15970,24 +15856,21 @@ var require_lang_en = __commonJS({ throw new Error("BIP39 Wordlist for en (English) FAILED"); } } - var LangEn = ( - /** @class */ - function(_super) { - __extends2(LangEn2, _super); - function LangEn2() { - return _super.call(this, "en") || this; - } - LangEn2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangEn2.prototype.getWordIndex = function(word) { - loadWords(this); - return wordlist.indexOf(word); - }; - return LangEn2; - }(wordlist_1.Wordlist) - ); + var LangEn = function(_super) { + __extends(LangEn2, _super); + function LangEn2() { + return _super.call(this, "en") || this; + } + LangEn2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangEn2.prototype.getWordIndex = function(word) { + loadWords(this); + return wordlist.indexOf(word); + }; + return LangEn2; + }(wordlist_1.Wordlist); var langEn = new LangEn(); exports2.langEn = langEn; wordlist_1.Wordlist.register(langEn); @@ -15998,21 +15881,21 @@ var require_lang_en = __commonJS({ var require_lang_es = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-es.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -16063,24 +15946,21 @@ var require_lang_es = __commonJS({ throw new Error("BIP39 Wordlist for es (Spanish) FAILED"); } } - var LangEs = ( - /** @class */ - function(_super) { - __extends2(LangEs2, _super); - function LangEs2() { - return _super.call(this, "es") || this; - } - LangEs2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangEs2.prototype.getWordIndex = function(word) { - loadWords(this); - return lookup[dropDiacritic(word)]; - }; - return LangEs2; - }(wordlist_1.Wordlist) - ); + var LangEs = function(_super) { + __extends(LangEs2, _super); + function LangEs2() { + return _super.call(this, "es") || this; + } + LangEs2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangEs2.prototype.getWordIndex = function(word) { + loadWords(this); + return lookup[dropDiacritic(word)]; + }; + return LangEs2; + }(wordlist_1.Wordlist); var langEs = new LangEs(); exports2.langEs = langEs; wordlist_1.Wordlist.register(langEs); @@ -16091,21 +15971,21 @@ var require_lang_es = __commonJS({ var require_lang_fr = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-fr.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -16155,24 +16035,21 @@ var require_lang_fr = __commonJS({ throw new Error("BIP39 Wordlist for fr (French) FAILED"); } } - var LangFr = ( - /** @class */ - function(_super) { - __extends2(LangFr2, _super); - function LangFr2() { - return _super.call(this, "fr") || this; - } - LangFr2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangFr2.prototype.getWordIndex = function(word) { - loadWords(this); - return lookup[dropDiacritic(word)]; - }; - return LangFr2; - }(wordlist_1.Wordlist) - ); + var LangFr = function(_super) { + __extends(LangFr2, _super); + function LangFr2() { + return _super.call(this, "fr") || this; + } + LangFr2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangFr2.prototype.getWordIndex = function(word) { + loadWords(this); + return lookup[dropDiacritic(word)]; + }; + return LangFr2; + }(wordlist_1.Wordlist); var langFr = new LangFr(); exports2.langFr = langFr; wordlist_1.Wordlist.register(langFr); @@ -16183,21 +16060,21 @@ var require_lang_fr = __commonJS({ var require_lang_ja = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-ja.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -16210,19 +16087,12 @@ var require_lang_ja = __commonJS({ var strings_1 = require_lib9(); var wordlist_1 = require_wordlist(); var data = [ - // 4-kana words "AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXBCDBCHBGFBEQBpBBpQBIkBHNBeOBgFBVCBhBBhNBmOBmRBiHBiFBUFBZDBvFBsXBkFBlcBjYBwDBMBBTBBTRBWBBWXXaQXaRXQWXSRXCFXYBXpHXOQXHRXhRXuRXmXXbRXlXXwDXTRXrCXWQXWGaBWaKcaYgasFadQalmaMBacAKaRKKBKKXKKjKQRKDRKCYKCRKIDKeVKHcKlXKjHKrYNAHNBWNaRNKcNIBNIONmXNsXNdXNnBNMBNRBNrXNWDNWMNFOQABQAHQBrQXBQXFQaRQKXQKDQKOQKFQNBQNDQQgQCXQCDQGBQGDQGdQYXQpBQpQQpHQLXQHuQgBQhBQhCQuFQmXQiDQUFQZDQsFQdRQkHQbRQlOQlmQPDQjDQwXQMBQMDQcFQTBQTHQrDDXQDNFDGBDGQDGRDpFDhFDmXDZXDbRDMYDRdDTRDrXSAhSBCSBrSGQSEQSHBSVRShYShkSyQSuFSiBSdcSoESocSlmSMBSFBSFKSFNSFdSFcCByCaRCKcCSBCSRCCrCGbCEHCYXCpBCpQCIBCIHCeNCgBCgFCVECVcCmkCmwCZXCZFCdRClOClmClFCjDCjdCnXCwBCwXCcRCFQCFjGXhGNhGDEGDMGCDGCHGIFGgBGVXGVEGVRGmXGsXGdYGoSGbRGnXGwXGwDGWRGFNGFLGFOGFdGFkEABEBDEBFEXOEaBEKSENBENDEYXEIgEIkEgBEgQEgHEhFEudEuFEiBEiHEiFEZDEvBEsXEsFEdXEdREkFEbBEbRElFEPCEfkEFNYAEYAhYBNYQdYDXYSRYCEYYoYgQYgRYuRYmCYZTYdBYbEYlXYjQYRbYWRpKXpQopQnpSFpCXpIBpISphNpdBpdRpbRpcZpFBpFNpFDpFopFrLADLBuLXQLXcLaFLCXLEhLpBLpFLHXLeVLhILdHLdRLoDLbRLrXIABIBQIBCIBsIBoIBMIBRIXaIaRIKYIKRINBINuICDIGBIIDIIkIgRIxFIyQIiHIdRIbYIbRIlHIwRIMYIcRIRVITRIFBIFNIFQOABOAFOBQOaFONBONMOQFOSFOCDOGBOEQOpBOLXOIBOIFOgQOgFOyQOycOmXOsXOdIOkHOMEOMkOWWHBNHXNHXWHNXHDuHDRHSuHSRHHoHhkHmRHdRHkQHlcHlRHwBHWcgAEgAggAkgBNgBQgBEgXOgYcgLXgHjgyQgiBgsFgdagMYgWSgFQgFEVBTVXEVKBVKNVKDVKYVKRVNBVNYVDBVDxVSBVSRVCjVGNVLXVIFVhBVhcVsXVdRVbRVlRhBYhKYhDYhGShxWhmNhdahdkhbRhjohMXhTRxAXxXSxKBxNBxEQxeNxeQxhXxsFxdbxlHxjcxFBxFNxFQxFOxFoyNYyYoybcyMYuBQuBRuBruDMuCouHBudQukkuoBulVuMXuFEmCYmCRmpRmeDmiMmjdmTFmFQiADiBOiaRiKRiNBiNRiSFiGkiGFiERipRiLFiIFihYibHijBijEiMXiWBiFBiFCUBQUXFUaRUNDUNcUNRUNFUDBUSHUCDUGBUGFUEqULNULoUIRUeEUeYUgBUhFUuRUiFUsXUdFUkHUbBUjSUjYUwXUMDUcHURdUTBUrBUrXUrQZAFZXZZaRZKFZNBZQFZCXZGBZYdZpBZLDZIFZHXZHNZeQZVRZVFZmXZiBZvFZdFZkFZbHZbFZwXZcCZcRZRBvBQvBGvBLvBWvCovMYsAFsBDsaRsKFsNFsDrsSHsSFsCXsCRsEBsEHsEfspBsLBsLDsIgsIRseGsbRsFBsFQsFSdNBdSRdCVdGHdYDdHcdVbdySduDdsXdlRdwXdWYdWcdWRkBMkXOkaRkNIkNFkSFkCFkYBkpRkeNkgBkhVkmXksFklVkMBkWDkFNoBNoaQoaFoNBoNXoNaoNEoSRoEroYXoYCoYbopRopFomXojkowXorFbBEbEIbdBbjYlaRlDElMXlFDjKjjSRjGBjYBjYkjpRjLXjIBjOFjeVjbRjwBnXQnSHnpFnLXnINnMBnTRwXBwXNwXYwNFwQFwSBwGFwLXwLDweNwgBwuHwjDwnXMBXMpFMIBMeNMTHcaQcNBcDHcSFcCXcpBcLXcLDcgFcuFcnXcwXccDcTQcrFTQErXNrCHrpFrgFrbFrTHrFcWNYWNbWEHWMXWTR", - // 5-kana words "ABGHABIJAEAVAYJQALZJAIaRAHNXAHdcAHbRAZJMAZJRAZTRAdVJAklmAbcNAjdRAMnRAMWYAWpRAWgRAFgBAFhBAFdcBNJBBNJDBQKBBQhcBQlmBDEJBYJkBYJTBpNBBpJFBIJBBIJDBIcABOKXBOEJBOVJBOiJBOZJBepBBeLXBeIFBegBBgGJBVJXBuocBiJRBUJQBlXVBlITBwNFBMYVBcqXBTlmBWNFBWiJBWnRBFGHBFwXXKGJXNJBXNZJXDTTXSHSXSVRXSlHXCJDXGQJXEhXXYQJXYbRXOfXXeNcXVJFXhQJXhEJXdTRXjdXXMhBXcQTXRGBXTEBXTnQXFCXXFOFXFgFaBaFaBNJaBCJaBpBaBwXaNJKaNJDaQIBaDpRaEPDaHMFamDJalEJaMZJaFaFaFNBaFQJaFLDaFVHKBCYKBEBKBHDKXaFKXGdKXEJKXpHKXIBKXZDKXwXKKwLKNacKNYJKNJoKNWcKDGdKDTRKChXKGaRKGhBKGbRKEBTKEaRKEPTKLMDKLWRKOHDKVJcKdBcKlIBKlOPKFSBKFEPKFpFNBNJNJBQNBGHNBEPNBHXNBgFNBVXNBZDNBsXNBwXNNaRNNJDNNJENNJkNDCJNDVDNGJRNJiDNZJNNsCJNJFNNFSBNFCXNFEPNFLXNFIFQJBFQCaRQJEQQLJDQLJFQIaRQOqXQHaFQHHQQVJXQVJDQhNJQmEIQZJFQsJXQJrFQWbRDJABDBYJDXNFDXCXDXLXDXZDDXsJDQqXDSJFDJCXDEPkDEqXDYmQDpSJDOCkDOGQDHEIDVJDDuDuDWEBDJFgSBNDSBSFSBGHSBIBSBTQSKVYSJQNSJQiSJCXSEqXSJYVSIiJSOMYSHAHSHaQSeCFSepQSegBSHdHSHrFShSJSJuHSJUFSkNRSrSrSWEBSFaHSJFQSFCXSFGDSFYXSFODSFgBSFVXSFhBSFxFSFkFSFbBSFMFCADdCJXBCXaFCXKFCXNFCXCXCXGBCXEJCXYBCXLDCXIBCXOPCXHXCXgBCXhBCXiBCXlDCXcHCJNBCJNFCDCJCDGBCDVXCDhBCDiDCDJdCCmNCpJFCIaRCOqXCHCHCHZJCViJCuCuCmddCJiFCdNBCdHhClEJCnUJCreSCWlgCWTRCFBFCFNBCFYBCFVFCFhFCFdSCFTBCFWDGBNBGBQFGJBCGBEqGBpBGBgQGNBEGNJYGNkOGNJRGDUFGJpQGHaBGJeNGJeEGVBlGVKjGiJDGvJHGsVJGkEBGMIJGWjNGFBFGFCXGFGBGFYXGFpBGFMFEASJEAWpEJNFECJVEIXSEIQJEOqXEOcFEeNcEHEJEHlFEJgFEhlmEmDJEmZJEiMBEUqXEoSREPBFEPXFEPKFEPSFEPEFEPpFEPLXEPIBEJPdEPcFEPTBEJnXEqlHEMpREFCXEFODEFcFYASJYJAFYBaBYBVXYXpFYDhBYCJBYJGFYYbRYeNcYJeVYiIJYZJcYvJgYvJRYJsXYsJFYMYMYreVpBNHpBEJpBwXpQxFpYEJpeNDpJeDpeSFpeCHpHUJpHbBpHcHpmUJpiiJpUJrpsJuplITpFaBpFQqpFGBpFEfpFYBpFpBpFLJpFIDpFgBpFVXpFyQpFuFpFlFpFjDpFnXpFwXpJFMpFTBLXCJLXEFLXhFLXUJLXbFLalmLNJBLSJQLCLCLGJBLLDJLHaFLeNFLeSHLeCXLepFLhaRLZsJLsJDLsJrLocaLlLlLMdbLFNBLFSBLFEHLFkFIBBFIBXFIBaQIBKXIBSFIBpHIBLXIBgBIBhBIBuHIBmXIBiFIBZXIBvFIBbFIBjQIBwXIBWFIKTRIQUJIDGFICjQIYSRIINXIJeCIVaRImEkIZJFIvJRIsJXIdCJIJoRIbBQIjYBIcqXITFVIreVIFKFIFSFIFCJIFGFIFLDIFIBIJFOIFgBIFVXIJFhIFxFIFmXIFdHIFbBIJFrIJFWOBGBOQfXOOKjOUqXOfXBOqXEOcqXORVJOFIBOFlDHBIOHXiFHNTRHCJXHIaRHHJDHHEJHVbRHZJYHbIBHRsJHRkDHWlmgBKFgBSBgBCDgBGHgBpBgBIBgBVJgBuBgBvFgKDTgQVXgDUJgGSJgOqXgmUMgZIJgTUJgWIEgFBFgFNBgFDJgFSFgFGBgFYXgJFOgFgQgFVXgFhBgFbHgJFWVJABVQKcVDgFVOfXVeDFVhaRVmGdViJYVMaRVFNHhBNDhBCXhBEqhBpFhBLXhNJBhSJRheVXhhKEhxlmhZIJhdBQhkIJhbMNhMUJhMZJxNJgxQUJxDEkxDdFxSJRxplmxeSBxeCXxeGFxeYXxepQxegBxWVcxFEQxFLXxFIBxFgBxFxDxFZtxFdcxFbBxFwXyDJXyDlcuASJuDJpuDIBuCpJuGSJuIJFueEFuZIJusJXudWEuoIBuWGJuFBcuFKEuFNFuFQFuFDJuFGJuFVJuFUtuFdHuFTBmBYJmNJYmQhkmLJDmLJomIdXmiJYmvJRmsJRmklmmMBymMuCmclmmcnQiJABiJBNiJBDiBSFiBCJiBEFiBYBiBpFiBLXiBTHiJNciDEfiCZJiECJiJEqiOkHiHKFieNDiHJQieQcieDHieSFieCXieGFieEFieIHiegFihUJixNoioNXiFaBiFKFiFNDiFEPiFYXitFOitFHiFgBiFVEiFmXiFitiFbBiFMFiFrFUCXQUIoQUIJcUHQJUeCEUHwXUUJDUUqXUdWcUcqXUrnQUFNDUFSHUFCFUFEfUFLXUtFOZBXOZXSBZXpFZXVXZEQJZEJkZpDJZOqXZeNHZeCDZUqXZFBQZFEHZFLXvBAFvBKFvBCXvBEPvBpHvBIDvBgFvBuHvQNJvFNFvFGBvFIBvJFcsXCDsXLXsXsXsXlFsXcHsQqXsJQFsEqXseIFsFEHsFjDdBxOdNpRdNJRdEJbdpJRdhZJdnSJdrjNdFNJdFQHdFhNkNJDkYaRkHNRkHSRkVbRkuMRkjSJkcqDoSJFoEiJoYZJoOfXohEBoMGQocqXbBAFbBXFbBaFbBNDbBGBbBLXbBTBbBWDbGJYbIJHbFQqbFpQlDgQlOrFlVJRjGEBjZJRnXvJnXbBnEfHnOPDngJRnxfXnUJWwXEJwNpJwDpBwEfXwrEBMDCJMDGHMDIJMLJDcQGDcQpHcqXccqNFcqCXcFCJRBSBRBGBRBEJRBpQTBNFTBQJTBpBTBVXTFABTFSBTFCFTFGBTFMDrXCJrXLDrDNJrEfHrFQJrFitWNjdWNTR", - // 6-kana words "AKLJMANOPFASNJIAEJWXAYJNRAIIbRAIcdaAeEfDAgidRAdjNYAMYEJAMIbRAFNJBAFpJFBBIJYBDZJFBSiJhBGdEBBEJfXBEJqXBEJWRBpaUJBLXrXBIYJMBOcfXBeEfFBestXBjNJRBcDJOBFEqXXNvJRXDMBhXCJNYXOAWpXONJWXHDEBXeIaRXhYJDXZJSJXMDJOXcASJXFVJXaBQqXaBZJFasXdQaFSJQaFEfXaFpJHaFOqXKBNSRKXvJBKQJhXKEJQJKEJGFKINJBKIJjNKgJNSKVElmKVhEBKiJGFKlBgJKjnUJKwsJYKMFIJKFNJDKFIJFKFOfXNJBSFNJBCXNBpJFNJBvQNJBMBNJLJXNJOqXNJeCXNJeGFNdsJCNbTKFNwXUJQNFEPQDiJcQDMSJQSFpBQGMQJQJeOcQyCJEQUJEBQJFBrQFEJqDXDJFDJXpBDJXIMDGiJhDIJGRDJeYcDHrDJDVXgFDkAWpDkIgRDjDEqDMvJRDJFNFDJFIBSKclmSJQOFSJQVHSJQjDSJGJBSJGJFSECJoSHEJqSJHTBSJVJDSViJYSZJNBSJsJDSFSJFSFEfXSJFLXCBUJVCJXSBCJXpBCXVJXCJXsXCJXdFCJNJHCLIJgCHiJFCVNJMChCJhCUHEJCsJTRCJdYcCoQJCCFEfXCFIJgCFUJxCFstFGJBaQGJBIDGQJqXGYJNRGJHKFGeQqDGHEJFGJeLXGHIiJGHdBlGUJEBGkIJTGFQPDGJFEqEAGegEJIJBEJVJXEhQJTEiJNcEJZJFEJoEqEjDEqEPDsXEPGJBEPOqXEPeQFEfDiDEJfEFEfepQEfMiJEqXNBEqDIDEqeSFEqVJXEMvJRYXNJDYXEJHYKVJcYYJEBYJeEcYJUqXYFpJFYFstXpAZJMpBSJFpNBNFpeQPDpHLJDpHIJFpHgJFpeitFpHZJFpJFADpFSJFpJFCJpFOqXpFitBpJFZJLXIJFLIJgRLVNJWLVHJMLwNpJLFGJBLFLJDLFOqXLJFUJIBDJXIBGJBIJBYQIJBIBIBOqXIBcqDIEGJFILNJTIIJEBIOiJhIJeNBIJeIBIhiJIIWoTRIJFAHIJFpBIJFuHIFUtFIJFTHOSBYJOEcqXOHEJqOvBpFOkVJrObBVJOncqDOcNJkHhNJRHuHJuHdMhBgBUqXgBsJXgONJBgHNJDgHHJQgJeitgHsJXgJyNagyDJBgZJDrgsVJQgkEJNgkjSJgJFAHgFCJDgFZtMVJXNFVXQfXVJXDJVXoQJVQVJQVDEfXVDvJHVEqNFVeQfXVHpJFVHxfXVVJSRVVmaRVlIJOhCXVJhHjYkhxCJVhWVUJhWiJcxBNJIxeEqDxfXBFxcFEPxFSJFxFYJXyBDQJydaUJyFOPDuYCJYuLvJRuHLJXuZJLDuFOPDuFZJHuFcqXmKHJdmCQJcmOsVJiJAGFitLCFieOfXiestXiZJMEikNJQirXzFiFQqXiFIJFiFZJFiFvtFUHpJFUteIcUteOcUVCJkUhdHcUbEJEUJqXQUMNJhURjYkUFitFZDGJHZJIxDZJVJXZJFDJZJFpQvBNJBvBSJFvJxBrseQqDsVFVJdFLJDkEJNBkmNJYkFLJDoQJOPoGsJRoEAHBoEJfFbBQqDbBZJHbFVJXlFIJBjYIrXjeitcjjCEBjWMNBwXQfXwXOaFwDsJXwCJTRwrCZJMDNJQcDDJFcqDOPRYiJFTBsJXTQIJBTFEfXTFLJDrXEJFrEJXMrFZJFWEJdEWYTlm", - // 7-kana words "ABCDEFACNJTRAMBDJdAcNJVXBLNJEBXSIdWRXErNJkXYDJMBXZJCJaXMNJaYKKVJKcKDEJqXKDcNJhKVJrNYKbgJVXKFVJSBNBYBwDNJeQfXNJeEqXNhGJWENJFiJRQlIJbEQJfXxDQqXcfXQFNDEJQFwXUJDYcnUJDJIBgQDIUJTRDJFEqDSJQSJFSJQIJFSOPeZtSJFZJHCJXQfXCTDEqFGJBSJFGJBOfXGJBcqXGJHNJDGJRLiJEJfXEqEJFEJPEFpBEJYJBZJFYBwXUJYiJMEBYJZJyTYTONJXpQMFXFpeGIDdpJFstXpJFcPDLBVSJRLHQJqXLJFZJFIJBNJDIJBUqXIBkFDJIJEJPTIYJGWRIJeQPDIJeEfHIJFsJXOqGDSFHXEJqXgJCsJCgGQJqXgdQYJEgFMFNBgJFcqDVJwXUJVJFZJchIgJCCxOEJqXxOwXUJyDJBVRuscisciJBiJBieUtqXiJFDJkiFsJXQUGEZJcUJFsJXZtXIrXZDZJDrZJFNJDZJFstXvJFQqXvJFCJEsJXQJqkhkNGBbDJdTRbYJMEBlDwXUJMEFiJFcfXNJDRcNJWMTBLJXC", - // 8-kana words "BraFUtHBFSJFdbNBLJXVJQoYJNEBSJBEJfHSJHwXUJCJdAZJMGjaFVJXEJPNJBlEJfFiJFpFbFEJqIJBVJCrIBdHiJhOPFChvJVJZJNJWxGFNIFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD", - // 9-kana words "QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD", - // 10-kana words "IJBEJqXZJ" ]; var mapping = "~~AzB~X~a~KN~Q~D~S~C~G~E~Y~p~L~I~O~eH~g~V~hxyumi~~U~~Z~~v~~s~~dkoblPjfnqwMcRTr~W~~~F~~~~~Jt"; @@ -16294,31 +16164,28 @@ var require_lang_ja = __commonJS({ throw new Error("BIP39 Wordlist for ja (Japanese) FAILED"); } } - var LangJa = ( - /** @class */ - function(_super) { - __extends2(LangJa2, _super); - function LangJa2() { - return _super.call(this, "ja") || this; - } - LangJa2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangJa2.prototype.getWordIndex = function(word) { - loadWords(this); - return wordlist.indexOf(word); - }; - LangJa2.prototype.split = function(mnemonic) { - wordlist_1.logger.checkNormalize(); - return mnemonic.split(/(?:\u3000| )+/g); - }; - LangJa2.prototype.join = function(words) { - return words.join("\u3000"); - }; - return LangJa2; - }(wordlist_1.Wordlist) - ); + var LangJa = function(_super) { + __extends(LangJa2, _super); + function LangJa2() { + return _super.call(this, "ja") || this; + } + LangJa2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangJa2.prototype.getWordIndex = function(word) { + loadWords(this); + return wordlist.indexOf(word); + }; + LangJa2.prototype.split = function(mnemonic) { + wordlist_1.logger.checkNormalize(); + return mnemonic.split(/(?:\u3000| )+/g); + }; + LangJa2.prototype.join = function(words) { + return words.join("\u3000"); + }; + return LangJa2; + }(wordlist_1.Wordlist); var langJa = new LangJa(); exports2.langJa = langJa; wordlist_1.Wordlist.register(langJa); @@ -16329,21 +16196,21 @@ var require_lang_ja = __commonJS({ var require_lang_ko = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-ko.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -16395,24 +16262,21 @@ var require_lang_ko = __commonJS({ throw new Error("BIP39 Wordlist for ko (Korean) FAILED"); } } - var LangKo = ( - /** @class */ - function(_super) { - __extends2(LangKo2, _super); - function LangKo2() { - return _super.call(this, "ko") || this; - } - LangKo2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangKo2.prototype.getWordIndex = function(word) { - loadWords(this); - return wordlist.indexOf(word); - }; - return LangKo2; - }(wordlist_1.Wordlist) - ); + var LangKo = function(_super) { + __extends(LangKo2, _super); + function LangKo2() { + return _super.call(this, "ko") || this; + } + LangKo2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangKo2.prototype.getWordIndex = function(word) { + loadWords(this); + return wordlist.indexOf(word); + }; + return LangKo2; + }(wordlist_1.Wordlist); var langKo = new LangKo(); exports2.langKo = langKo; wordlist_1.Wordlist.register(langKo); @@ -16423,21 +16287,21 @@ var require_lang_ko = __commonJS({ var require_lang_it = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-it.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -16459,24 +16323,21 @@ var require_lang_it = __commonJS({ throw new Error("BIP39 Wordlist for it (Italian) FAILED"); } } - var LangIt = ( - /** @class */ - function(_super) { - __extends2(LangIt2, _super); - function LangIt2() { - return _super.call(this, "it") || this; - } - LangIt2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[index]; - }; - LangIt2.prototype.getWordIndex = function(word) { - loadWords(this); - return wordlist.indexOf(word); - }; - return LangIt2; - }(wordlist_1.Wordlist) - ); + var LangIt = function(_super) { + __extends(LangIt2, _super); + function LangIt2() { + return _super.call(this, "it") || this; + } + LangIt2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[index]; + }; + LangIt2.prototype.getWordIndex = function(word) { + loadWords(this); + return wordlist.indexOf(word); + }; + return LangIt2; + }(wordlist_1.Wordlist); var langIt = new LangIt(); exports2.langIt = langIt; wordlist_1.Wordlist.register(langIt); @@ -16487,21 +16348,21 @@ var require_lang_it = __commonJS({ var require_lang_zh = __commonJS({ "node_modules/@ethersproject/wordlists/lib/lang-zh.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -16550,28 +16411,25 @@ var require_lang_zh = __commonJS({ throw new Error("BIP39 Wordlist for " + lang.locale + " (Chinese) FAILED"); } } - var LangZh = ( - /** @class */ - function(_super) { - __extends2(LangZh2, _super); - function LangZh2(country) { - return _super.call(this, "zh_" + country) || this; - } - LangZh2.prototype.getWord = function(index) { - loadWords(this); - return wordlist[this.locale][index]; - }; - LangZh2.prototype.getWordIndex = function(word) { - loadWords(this); - return wordlist[this.locale].indexOf(word); - }; - LangZh2.prototype.split = function(mnemonic) { - mnemonic = mnemonic.replace(/(?:\u3000| )+/g, ""); - return mnemonic.split(""); - }; - return LangZh2; - }(wordlist_1.Wordlist) - ); + var LangZh = function(_super) { + __extends(LangZh2, _super); + function LangZh2(country) { + return _super.call(this, "zh_" + country) || this; + } + LangZh2.prototype.getWord = function(index) { + loadWords(this); + return wordlist[this.locale][index]; + }; + LangZh2.prototype.getWordIndex = function(word) { + loadWords(this); + return wordlist[this.locale].indexOf(word); + }; + LangZh2.prototype.split = function(mnemonic) { + mnemonic = mnemonic.replace(/(?:\u3000| )+/g, ""); + return mnemonic.split(""); + }; + return LangZh2; + }(wordlist_1.Wordlist); var langZhCn = new LangZh("cn"); exports2.langZhCn = langZhCn; wordlist_1.Wordlist.register(langZhCn); @@ -16690,180 +16548,177 @@ var require_lib19 = __commonJS({ } var _constructorGuard = {}; exports2.defaultPath = "m/44'/60'/0'/0/0"; - var HDNode = ( - /** @class */ - function() { - function HDNode2(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonicOrPath) { - var _newTarget = this.constructor; - logger2.checkNew(_newTarget, HDNode2); - if (constructorGuard !== _constructorGuard) { - throw new Error("HDNode constructor cannot be called directly"); - } - if (privateKey) { - var signingKey = new signing_key_1.SigningKey(privateKey); - (0, properties_1.defineReadOnly)(this, "privateKey", signingKey.privateKey); - (0, properties_1.defineReadOnly)(this, "publicKey", signingKey.compressedPublicKey); - } else { - (0, properties_1.defineReadOnly)(this, "privateKey", null); - (0, properties_1.defineReadOnly)(this, "publicKey", (0, bytes_1.hexlify)(publicKey)); - } - (0, properties_1.defineReadOnly)(this, "parentFingerprint", parentFingerprint); - (0, properties_1.defineReadOnly)(this, "fingerprint", (0, bytes_1.hexDataSlice)((0, sha2_1.ripemd160)((0, sha2_1.sha256)(this.publicKey)), 0, 4)); - (0, properties_1.defineReadOnly)(this, "address", (0, transactions_1.computeAddress)(this.publicKey)); - (0, properties_1.defineReadOnly)(this, "chainCode", chainCode); - (0, properties_1.defineReadOnly)(this, "index", index); - (0, properties_1.defineReadOnly)(this, "depth", depth); - if (mnemonicOrPath == null) { - (0, properties_1.defineReadOnly)(this, "mnemonic", null); - (0, properties_1.defineReadOnly)(this, "path", null); - } else if (typeof mnemonicOrPath === "string") { - (0, properties_1.defineReadOnly)(this, "mnemonic", null); - (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath); - } else { - (0, properties_1.defineReadOnly)(this, "mnemonic", mnemonicOrPath); - (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath.path); - } + var HDNode = function() { + function HDNode2(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonicOrPath) { + var _newTarget = this.constructor; + logger2.checkNew(_newTarget, HDNode2); + if (constructorGuard !== _constructorGuard) { + throw new Error("HDNode constructor cannot be called directly"); + } + if (privateKey) { + var signingKey = new signing_key_1.SigningKey(privateKey); + (0, properties_1.defineReadOnly)(this, "privateKey", signingKey.privateKey); + (0, properties_1.defineReadOnly)(this, "publicKey", signingKey.compressedPublicKey); + } else { + (0, properties_1.defineReadOnly)(this, "privateKey", null); + (0, properties_1.defineReadOnly)(this, "publicKey", (0, bytes_1.hexlify)(publicKey)); + } + (0, properties_1.defineReadOnly)(this, "parentFingerprint", parentFingerprint); + (0, properties_1.defineReadOnly)(this, "fingerprint", (0, bytes_1.hexDataSlice)((0, sha2_1.ripemd160)((0, sha2_1.sha256)(this.publicKey)), 0, 4)); + (0, properties_1.defineReadOnly)(this, "address", (0, transactions_1.computeAddress)(this.publicKey)); + (0, properties_1.defineReadOnly)(this, "chainCode", chainCode); + (0, properties_1.defineReadOnly)(this, "index", index); + (0, properties_1.defineReadOnly)(this, "depth", depth); + if (mnemonicOrPath == null) { + (0, properties_1.defineReadOnly)(this, "mnemonic", null); + (0, properties_1.defineReadOnly)(this, "path", null); + } else if (typeof mnemonicOrPath === "string") { + (0, properties_1.defineReadOnly)(this, "mnemonic", null); + (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath); + } else { + (0, properties_1.defineReadOnly)(this, "mnemonic", mnemonicOrPath); + (0, properties_1.defineReadOnly)(this, "path", mnemonicOrPath.path); } - Object.defineProperty(HDNode2.prototype, "extendedKey", { - get: function() { - if (this.depth >= 256) { - throw new Error("Depth too large!"); - } - return base58check((0, bytes_1.concat)([ - this.privateKey != null ? "0x0488ADE4" : "0x0488B21E", - (0, bytes_1.hexlify)(this.depth), - this.parentFingerprint, - (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(this.index), 4), - this.chainCode, - this.privateKey != null ? (0, bytes_1.concat)(["0x00", this.privateKey]) : this.publicKey - ])); - }, - enumerable: false, - configurable: true - }); - HDNode2.prototype.neuter = function() { - return new HDNode2(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, this.path); - }; - HDNode2.prototype._derive = function(index) { - if (index > 4294967295) { - throw new Error("invalid index - " + String(index)); + } + Object.defineProperty(HDNode2.prototype, "extendedKey", { + get: function() { + if (this.depth >= 256) { + throw new Error("Depth too large!"); + } + return base58check((0, bytes_1.concat)([ + this.privateKey != null ? "0x0488ADE4" : "0x0488B21E", + (0, bytes_1.hexlify)(this.depth), + this.parentFingerprint, + (0, bytes_1.hexZeroPad)((0, bytes_1.hexlify)(this.index), 4), + this.chainCode, + this.privateKey != null ? (0, bytes_1.concat)(["0x00", this.privateKey]) : this.publicKey + ])); + }, + enumerable: false, + configurable: true + }); + HDNode2.prototype.neuter = function() { + return new HDNode2(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, this.path); + }; + HDNode2.prototype._derive = function(index) { + if (index > 4294967295) { + throw new Error("invalid index - " + String(index)); + } + var path2 = this.path; + if (path2) { + path2 += "/" + (index & ~HardenedBit); + } + var data = new Uint8Array(37); + if (index & HardenedBit) { + if (!this.privateKey) { + throw new Error("cannot derive child of neutered node"); } - var path2 = this.path; + data.set((0, bytes_1.arrayify)(this.privateKey), 1); if (path2) { - path2 += "/" + (index & ~HardenedBit); + path2 += "'"; } - var data = new Uint8Array(37); - if (index & HardenedBit) { - if (!this.privateKey) { - throw new Error("cannot derive child of neutered node"); + } else { + data.set((0, bytes_1.arrayify)(this.publicKey)); + } + for (var i = 24; i >= 0; i -= 8) { + data[33 + (i >> 3)] = index >> 24 - i & 255; + } + var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, this.chainCode, data)); + var IL = I.slice(0, 32); + var IR = I.slice(32); + var ki = null; + var Ki = null; + if (this.privateKey) { + ki = bytes32(bignumber_1.BigNumber.from(IL).add(this.privateKey).mod(N)); + } else { + var ek = new signing_key_1.SigningKey((0, bytes_1.hexlify)(IL)); + Ki = ek._addPoint(this.publicKey); + } + var mnemonicOrPath = path2; + var srcMnemonic = this.mnemonic; + if (srcMnemonic) { + mnemonicOrPath = Object.freeze({ + phrase: srcMnemonic.phrase, + path: path2, + locale: srcMnemonic.locale || "en" + }); + } + return new HDNode2(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, mnemonicOrPath); + }; + HDNode2.prototype.derivePath = function(path2) { + var components = path2.split("/"); + if (components.length === 0 || components[0] === "m" && this.depth !== 0) { + throw new Error("invalid path - " + path2); + } + if (components[0] === "m") { + components.shift(); + } + var result = this; + for (var i = 0; i < components.length; i++) { + var component = components[i]; + if (component.match(/^[0-9]+'$/)) { + var index = parseInt(component.substring(0, component.length - 1)); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); } - data.set((0, bytes_1.arrayify)(this.privateKey), 1); - if (path2) { - path2 += "'"; + result = result._derive(HardenedBit + index); + } else if (component.match(/^[0-9]+$/)) { + var index = parseInt(component); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); } + result = result._derive(index); } else { - data.set((0, bytes_1.arrayify)(this.publicKey)); - } - for (var i = 24; i >= 0; i -= 8) { - data[33 + (i >> 3)] = index >> 24 - i & 255; - } - var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, this.chainCode, data)); - var IL = I.slice(0, 32); - var IR = I.slice(32); - var ki = null; - var Ki = null; - if (this.privateKey) { - ki = bytes32(bignumber_1.BigNumber.from(IL).add(this.privateKey).mod(N)); - } else { - var ek = new signing_key_1.SigningKey((0, bytes_1.hexlify)(IL)); - Ki = ek._addPoint(this.publicKey); - } - var mnemonicOrPath = path2; - var srcMnemonic = this.mnemonic; - if (srcMnemonic) { - mnemonicOrPath = Object.freeze({ - phrase: srcMnemonic.phrase, - path: path2, - locale: srcMnemonic.locale || "en" - }); + throw new Error("invalid path component - " + component); } - return new HDNode2(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, mnemonicOrPath); - }; - HDNode2.prototype.derivePath = function(path2) { - var components = path2.split("/"); - if (components.length === 0 || components[0] === "m" && this.depth !== 0) { - throw new Error("invalid path - " + path2); - } - if (components[0] === "m") { - components.shift(); - } - var result = this; - for (var i = 0; i < components.length; i++) { - var component = components[i]; - if (component.match(/^[0-9]+'$/)) { - var index = parseInt(component.substring(0, component.length - 1)); - if (index >= HardenedBit) { - throw new Error("invalid path index - " + component); - } - result = result._derive(HardenedBit + index); - } else if (component.match(/^[0-9]+$/)) { - var index = parseInt(component); - if (index >= HardenedBit) { - throw new Error("invalid path index - " + component); - } - result = result._derive(index); - } else { - throw new Error("invalid path component - " + component); + } + return result; + }; + HDNode2._fromSeed = function(seed, mnemonic) { + var seedArray = (0, bytes_1.arrayify)(seed); + if (seedArray.length < 16 || seedArray.length > 64) { + throw new Error("invalid seed"); + } + var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, MasterSecret, seedArray)); + return new HDNode2(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic); + }; + HDNode2.fromMnemonic = function(mnemonic, password, wordlist) { + wordlist = getWordlist(wordlist); + mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist); + return HDNode2._fromSeed(mnemonicToSeed(mnemonic, password), { + phrase: mnemonic, + path: "m", + locale: wordlist.locale + }); + }; + HDNode2.fromSeed = function(seed) { + return HDNode2._fromSeed(seed, null); + }; + HDNode2.fromExtendedKey = function(extendedKey) { + var bytes = basex_1.Base58.decode(extendedKey); + if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { + logger2.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); + } + var depth = bytes[4]; + var parentFingerprint = (0, bytes_1.hexlify)(bytes.slice(5, 9)); + var index = parseInt((0, bytes_1.hexlify)(bytes.slice(9, 13)).substring(2), 16); + var chainCode = (0, bytes_1.hexlify)(bytes.slice(13, 45)); + var key = bytes.slice(45, 78); + switch ((0, bytes_1.hexlify)(bytes.slice(0, 4))) { + case "0x0488b21e": + case "0x043587cf": + return new HDNode2(_constructorGuard, null, (0, bytes_1.hexlify)(key), parentFingerprint, chainCode, index, depth, null); + case "0x0488ade4": + case "0x04358394 ": + if (key[0] !== 0) { + break; } - } - return result; - }; - HDNode2._fromSeed = function(seed, mnemonic) { - var seedArray = (0, bytes_1.arrayify)(seed); - if (seedArray.length < 16 || seedArray.length > 64) { - throw new Error("invalid seed"); - } - var I = (0, bytes_1.arrayify)((0, sha2_1.computeHmac)(sha2_1.SupportedAlgorithm.sha512, MasterSecret, seedArray)); - return new HDNode2(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic); - }; - HDNode2.fromMnemonic = function(mnemonic, password, wordlist) { - wordlist = getWordlist(wordlist); - mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist); - return HDNode2._fromSeed(mnemonicToSeed(mnemonic, password), { - phrase: mnemonic, - path: "m", - locale: wordlist.locale - }); - }; - HDNode2.fromSeed = function(seed) { - return HDNode2._fromSeed(seed, null); - }; - HDNode2.fromExtendedKey = function(extendedKey) { - var bytes = basex_1.Base58.decode(extendedKey); - if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { - logger2.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); - } - var depth = bytes[4]; - var parentFingerprint = (0, bytes_1.hexlify)(bytes.slice(5, 9)); - var index = parseInt((0, bytes_1.hexlify)(bytes.slice(9, 13)).substring(2), 16); - var chainCode = (0, bytes_1.hexlify)(bytes.slice(13, 45)); - var key = bytes.slice(45, 78); - switch ((0, bytes_1.hexlify)(bytes.slice(0, 4))) { - case "0x0488b21e": - case "0x043587cf": - return new HDNode2(_constructorGuard, null, (0, bytes_1.hexlify)(key), parentFingerprint, chainCode, index, depth, null); - case "0x0488ade4": - case "0x04358394 ": - if (key[0] !== 0) { - break; - } - return new HDNode2(_constructorGuard, (0, bytes_1.hexlify)(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null); - } - return logger2.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); - }; - return HDNode2; - }() - ); + return new HDNode2(_constructorGuard, (0, bytes_1.hexlify)(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null); + } + return logger2.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); + }; + return HDNode2; + }(); exports2.HDNode = HDNode; function mnemonicToSeed(mnemonic, password) { if (!password) { @@ -17584,33 +17439,33 @@ var require_utils4 = __commonJS({ var require_crowdsale = __commonJS({ "node_modules/@ethersproject/json-wallets/lib/crowdsale.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.decrypt = exports2.CrowdsaleAccount = void 0; - var aes_js_1 = __importDefault2(require_aes_js()); + var aes_js_1 = __importDefault(require_aes_js()); var address_1 = require_lib7(); var bytes_1 = require_lib2(); var keccak256_1 = require_lib5(); @@ -17621,19 +17476,16 @@ var require_crowdsale = __commonJS({ var _version_1 = require_version15(); var logger2 = new logger_1.Logger(_version_1.version); var utils_1 = require_utils4(); - var CrowdsaleAccount = ( - /** @class */ - function(_super) { - __extends2(CrowdsaleAccount2, _super); - function CrowdsaleAccount2() { - return _super !== null && _super.apply(this, arguments) || this; - } - CrowdsaleAccount2.prototype.isCrowdsaleAccount = function(value) { - return !!(value && value._isCrowdsaleAccount); - }; - return CrowdsaleAccount2; - }(properties_1.Description) - ); + var CrowdsaleAccount = function(_super) { + __extends(CrowdsaleAccount2, _super); + function CrowdsaleAccount2() { + return _super !== null && _super.apply(this, arguments) || this; + } + CrowdsaleAccount2.prototype.isCrowdsaleAccount = function(value) { + return !!(value && value._isCrowdsaleAccount); + }; + return CrowdsaleAccount2; + }(properties_1.Description); exports2.CrowdsaleAccount = CrowdsaleAccount; function decrypt(json, password) { var data = JSON.parse(json); @@ -18242,28 +18094,28 @@ var require_lib20 = __commonJS({ var require_keystore = __commonJS({ "node_modules/@ethersproject/json-wallets/lib/keystore.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -18290,7 +18142,7 @@ var require_keystore = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -18366,13 +18218,13 @@ var require_keystore = __commonJS({ return { value: op[0] ? op[1] : void 0, done: true }; } }; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.encrypt = exports2.decrypt = exports2.decryptSync = exports2.KeystoreAccount = void 0; - var aes_js_1 = __importDefault2(require_aes_js()); - var scrypt_js_1 = __importDefault2(require_scrypt()); + var aes_js_1 = __importDefault(require_aes_js()); + var scrypt_js_1 = __importDefault(require_scrypt()); var address_1 = require_lib7(); var bytes_1 = require_lib2(); var hdnode_1 = require_lib19(); @@ -18388,19 +18240,16 @@ var require_keystore = __commonJS({ function hasMnemonic(value) { return value != null && value.mnemonic && value.mnemonic.phrase; } - var KeystoreAccount = ( - /** @class */ - function(_super) { - __extends2(KeystoreAccount2, _super); - function KeystoreAccount2() { - return _super !== null && _super.apply(this, arguments) || this; - } - KeystoreAccount2.prototype.isKeystoreAccount = function(value) { - return !!(value && value._isKeystoreAccount); - }; - return KeystoreAccount2; - }(properties_1.Description) - ); + var KeystoreAccount = function(_super) { + __extends(KeystoreAccount2, _super); + function KeystoreAccount2() { + return _super !== null && _super.apply(this, arguments) || this; + } + KeystoreAccount2.prototype.isKeystoreAccount = function(value) { + return !!(value && value._isKeystoreAccount); + }; + return KeystoreAccount2; + }(properties_1.Description); exports2.KeystoreAccount = KeystoreAccount; function _decrypt(data, key, ciphertext) { var cipher = (0, utils_1.searchPath)(data, "crypto/cipher"); @@ -18520,9 +18369,9 @@ var require_keystore = __commonJS({ } exports2.decryptSync = decryptSync; function decrypt(json, password, progressCallback) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var data, key; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: data = JSON.parse(json); @@ -18644,7 +18493,7 @@ var require_keystore = __commonJS({ var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); var mnemonicCiphertext = (0, bytes_1.arrayify)(mnemonicAesCtr.encrypt(entropy)); - var now = /* @__PURE__ */ new Date(); + var now = new Date(); var timestamp = now.getUTCFullYear() + "-" + (0, utils_1.zpad)(now.getUTCMonth() + 1, 2) + "-" + (0, utils_1.zpad)(now.getUTCDate(), 2) + "T" + (0, utils_1.zpad)(now.getUTCHours(), 2) + "-" + (0, utils_1.zpad)(now.getUTCMinutes(), 2) + "-" + (0, utils_1.zpad)(now.getUTCSeconds(), 2) + ".0Z"; data["x-ethers"] = { client, @@ -18947,28 +18796,28 @@ var require_version18 = __commonJS({ var require_lib24 = __commonJS({ "node_modules/@ethersproject/abstract-provider/lib/index.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -18995,7 +18844,7 @@ var require_lib24 = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -19079,131 +18928,116 @@ var require_lib24 = __commonJS({ var logger_1 = require_lib(); var _version_1 = require_version18(); var logger2 = new logger_1.Logger(_version_1.version); - var ForkEvent = ( - /** @class */ - function(_super) { - __extends2(ForkEvent2, _super); - function ForkEvent2() { - return _super !== null && _super.apply(this, arguments) || this; - } - ForkEvent2.isForkEvent = function(value) { - return !!(value && value._isForkEvent); - }; - return ForkEvent2; - }(properties_1.Description) - ); + var ForkEvent = function(_super) { + __extends(ForkEvent2, _super); + function ForkEvent2() { + return _super !== null && _super.apply(this, arguments) || this; + } + ForkEvent2.isForkEvent = function(value) { + return !!(value && value._isForkEvent); + }; + return ForkEvent2; + }(properties_1.Description); exports2.ForkEvent = ForkEvent; - var BlockForkEvent = ( - /** @class */ - function(_super) { - __extends2(BlockForkEvent2, _super); - function BlockForkEvent2(blockHash, expiry) { - var _this = this; - if (!(0, bytes_1.isHexString)(blockHash, 32)) { - logger2.throwArgumentError("invalid blockHash", "blockHash", blockHash); - } - _this = _super.call(this, { - _isForkEvent: true, - _isBlockForkEvent: true, - expiry: expiry || 0, - blockHash - }) || this; - return _this; - } - return BlockForkEvent2; - }(ForkEvent) - ); + var BlockForkEvent = function(_super) { + __extends(BlockForkEvent2, _super); + function BlockForkEvent2(blockHash, expiry) { + var _this = this; + if (!(0, bytes_1.isHexString)(blockHash, 32)) { + logger2.throwArgumentError("invalid blockHash", "blockHash", blockHash); + } + _this = _super.call(this, { + _isForkEvent: true, + _isBlockForkEvent: true, + expiry: expiry || 0, + blockHash + }) || this; + return _this; + } + return BlockForkEvent2; + }(ForkEvent); exports2.BlockForkEvent = BlockForkEvent; - var TransactionForkEvent = ( - /** @class */ - function(_super) { - __extends2(TransactionForkEvent2, _super); - function TransactionForkEvent2(hash, expiry) { - var _this = this; - if (!(0, bytes_1.isHexString)(hash, 32)) { - logger2.throwArgumentError("invalid transaction hash", "hash", hash); - } - _this = _super.call(this, { - _isForkEvent: true, - _isTransactionForkEvent: true, - expiry: expiry || 0, - hash - }) || this; - return _this; - } - return TransactionForkEvent2; - }(ForkEvent) - ); + var TransactionForkEvent = function(_super) { + __extends(TransactionForkEvent2, _super); + function TransactionForkEvent2(hash, expiry) { + var _this = this; + if (!(0, bytes_1.isHexString)(hash, 32)) { + logger2.throwArgumentError("invalid transaction hash", "hash", hash); + } + _this = _super.call(this, { + _isForkEvent: true, + _isTransactionForkEvent: true, + expiry: expiry || 0, + hash + }) || this; + return _this; + } + return TransactionForkEvent2; + }(ForkEvent); exports2.TransactionForkEvent = TransactionForkEvent; - var TransactionOrderForkEvent = ( - /** @class */ - function(_super) { - __extends2(TransactionOrderForkEvent2, _super); - function TransactionOrderForkEvent2(beforeHash, afterHash, expiry) { - var _this = this; - if (!(0, bytes_1.isHexString)(beforeHash, 32)) { - logger2.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); - } - if (!(0, bytes_1.isHexString)(afterHash, 32)) { - logger2.throwArgumentError("invalid transaction hash", "afterHash", afterHash); - } - _this = _super.call(this, { - _isForkEvent: true, - _isTransactionOrderForkEvent: true, - expiry: expiry || 0, - beforeHash, - afterHash - }) || this; - return _this; - } - return TransactionOrderForkEvent2; - }(ForkEvent) - ); + var TransactionOrderForkEvent = function(_super) { + __extends(TransactionOrderForkEvent2, _super); + function TransactionOrderForkEvent2(beforeHash, afterHash, expiry) { + var _this = this; + if (!(0, bytes_1.isHexString)(beforeHash, 32)) { + logger2.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + } + if (!(0, bytes_1.isHexString)(afterHash, 32)) { + logger2.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + } + _this = _super.call(this, { + _isForkEvent: true, + _isTransactionOrderForkEvent: true, + expiry: expiry || 0, + beforeHash, + afterHash + }) || this; + return _this; + } + return TransactionOrderForkEvent2; + }(ForkEvent); exports2.TransactionOrderForkEvent = TransactionOrderForkEvent; - var Provider = ( - /** @class */ - function() { - function Provider2() { - var _newTarget = this.constructor; - logger2.checkAbstract(_newTarget, Provider2); - (0, properties_1.defineReadOnly)(this, "_isProvider", true); - } - Provider2.prototype.getFeeData = function() { - return __awaiter2(this, void 0, void 0, function() { - var _a7, block, gasPrice, maxFeePerGas, maxPriorityFeePerGas; - return __generator2(this, function(_b) { - switch (_b.label) { - case 0: - return [4, (0, properties_1.resolveProperties)({ - block: this.getBlock("latest"), - gasPrice: this.getGasPrice().catch(function(error) { - return null; - }) - })]; - case 1: - _a7 = _b.sent(), block = _a7.block, gasPrice = _a7.gasPrice; - maxFeePerGas = null, maxPriorityFeePerGas = null; - if (block && block.baseFeePerGas) { - maxPriorityFeePerGas = bignumber_1.BigNumber.from("2500000000"); - maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas); - } - return [2, { maxFeePerGas, maxPriorityFeePerGas, gasPrice }]; - } - }); + var Provider = function() { + function Provider2() { + var _newTarget = this.constructor; + logger2.checkAbstract(_newTarget, Provider2); + (0, properties_1.defineReadOnly)(this, "_isProvider", true); + } + Provider2.prototype.getFeeData = function() { + return __awaiter(this, void 0, void 0, function() { + var _a7, block, gasPrice, maxFeePerGas, maxPriorityFeePerGas; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + return [4, (0, properties_1.resolveProperties)({ + block: this.getBlock("latest"), + gasPrice: this.getGasPrice().catch(function(error) { + return null; + }) + })]; + case 1: + _a7 = _b.sent(), block = _a7.block, gasPrice = _a7.gasPrice; + maxFeePerGas = null, maxPriorityFeePerGas = null; + if (block && block.baseFeePerGas) { + maxPriorityFeePerGas = bignumber_1.BigNumber.from("2500000000"); + maxFeePerGas = block.baseFeePerGas.mul(2).add(maxPriorityFeePerGas); + } + return [2, { maxFeePerGas, maxPriorityFeePerGas, gasPrice }]; + } }); - }; - Provider2.prototype.addListener = function(eventName, listener) { - return this.on(eventName, listener); - }; - Provider2.prototype.removeListener = function(eventName, listener) { - return this.off(eventName, listener); - }; - Provider2.isProvider = function(value) { - return !!(value && value._isProvider); - }; - return Provider2; - }() - ); + }); + }; + Provider2.prototype.addListener = function(eventName, listener) { + return this.on(eventName, listener); + }; + Provider2.prototype.removeListener = function(eventName, listener) { + return this.off(eventName, listener); + }; + Provider2.isProvider = function(value) { + return !!(value && value._isProvider); + }; + return Provider2; + }(); exports2.Provider = Provider; } }); @@ -19222,28 +19056,28 @@ var require_version19 = __commonJS({ var require_lib25 = __commonJS({ "node_modules/@ethersproject/abstract-signer/lib/index.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -19270,7 +19104,7 @@ var require_lib25 = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -19372,350 +19206,344 @@ var require_lib25 = __commonJS({ logger_1.Logger.errors.NONCE_EXPIRED, logger_1.Logger.errors.REPLACEMENT_UNDERPRICED ]; - var Signer = ( - /** @class */ - function() { - function Signer2() { - var _newTarget = this.constructor; - logger2.checkAbstract(_newTarget, Signer2); - (0, properties_1.defineReadOnly)(this, "_isSigner", true); - } - Signer2.prototype.getBalance = function(blockTag) { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("getBalance"); - return [4, this.provider.getBalance(this.getAddress(), blockTag)]; - case 1: - return [2, _a7.sent()]; - } - }); - }); - }; - Signer2.prototype.getTransactionCount = function(blockTag) { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("getTransactionCount"); - return [4, this.provider.getTransactionCount(this.getAddress(), blockTag)]; - case 1: - return [2, _a7.sent()]; - } - }); + var Signer = function() { + function Signer2() { + var _newTarget = this.constructor; + logger2.checkAbstract(_newTarget, Signer2); + (0, properties_1.defineReadOnly)(this, "_isSigner", true); + } + Signer2.prototype.getBalance = function(blockTag) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("getBalance"); + return [4, this.provider.getBalance(this.getAddress(), blockTag)]; + case 1: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.estimateGas = function(transaction) { - return __awaiter2(this, void 0, void 0, function() { - var tx; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("estimateGas"); - return [4, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))]; - case 1: - tx = _a7.sent(); - return [4, this.provider.estimateGas(tx)]; - case 2: - return [2, _a7.sent()]; - } - }); + }); + }; + Signer2.prototype.getTransactionCount = function(blockTag) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("getTransactionCount"); + return [4, this.provider.getTransactionCount(this.getAddress(), blockTag)]; + case 1: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.call = function(transaction, blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var tx; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("call"); - return [4, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))]; - case 1: - tx = _a7.sent(); - return [4, this.provider.call(tx, blockTag)]; - case 2: - return [2, _a7.sent()]; - } - }); + }); + }; + Signer2.prototype.estimateGas = function(transaction) { + return __awaiter(this, void 0, void 0, function() { + var tx; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("estimateGas"); + return [4, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))]; + case 1: + tx = _a7.sent(); + return [4, this.provider.estimateGas(tx)]; + case 2: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.sendTransaction = function(transaction) { - return __awaiter2(this, void 0, void 0, function() { - var tx, signedTx; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("sendTransaction"); - return [4, this.populateTransaction(transaction)]; - case 1: - tx = _a7.sent(); - return [4, this.signTransaction(tx)]; - case 2: - signedTx = _a7.sent(); - return [4, this.provider.sendTransaction(signedTx)]; - case 3: - return [2, _a7.sent()]; - } - }); + }); + }; + Signer2.prototype.call = function(transaction, blockTag) { + return __awaiter(this, void 0, void 0, function() { + var tx; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("call"); + return [4, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))]; + case 1: + tx = _a7.sent(); + return [4, this.provider.call(tx, blockTag)]; + case 2: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.getChainId = function() { - return __awaiter2(this, void 0, void 0, function() { - var network; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("getChainId"); - return [4, this.provider.getNetwork()]; - case 1: - network = _a7.sent(); - return [2, network.chainId]; - } - }); + }); + }; + Signer2.prototype.sendTransaction = function(transaction) { + return __awaiter(this, void 0, void 0, function() { + var tx, signedTx; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("sendTransaction"); + return [4, this.populateTransaction(transaction)]; + case 1: + tx = _a7.sent(); + return [4, this.signTransaction(tx)]; + case 2: + signedTx = _a7.sent(); + return [4, this.provider.sendTransaction(signedTx)]; + case 3: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.getGasPrice = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("getGasPrice"); - return [4, this.provider.getGasPrice()]; - case 1: - return [2, _a7.sent()]; - } - }); + }); + }; + Signer2.prototype.getChainId = function() { + return __awaiter(this, void 0, void 0, function() { + var network; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("getChainId"); + return [4, this.provider.getNetwork()]; + case 1: + network = _a7.sent(); + return [2, network.chainId]; + } }); - }; - Signer2.prototype.getFeeData = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("getFeeData"); - return [4, this.provider.getFeeData()]; - case 1: - return [2, _a7.sent()]; - } - }); + }); + }; + Signer2.prototype.getGasPrice = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("getGasPrice"); + return [4, this.provider.getGasPrice()]; + case 1: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.resolveName = function(name2) { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - this._checkProvider("resolveName"); - return [4, this.provider.resolveName(name2)]; - case 1: - return [2, _a7.sent()]; - } - }); + }); + }; + Signer2.prototype.getFeeData = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("getFeeData"); + return [4, this.provider.getFeeData()]; + case 1: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype.checkTransaction = function(transaction) { - for (var key in transaction) { - if (allowedTransactionKeys.indexOf(key) === -1) { - logger2.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + }); + }; + Signer2.prototype.resolveName = function(name2) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + this._checkProvider("resolveName"); + return [4, this.provider.resolveName(name2)]; + case 1: + return [2, _a7.sent()]; } + }); + }); + }; + Signer2.prototype.checkTransaction = function(transaction) { + for (var key in transaction) { + if (allowedTransactionKeys.indexOf(key) === -1) { + logger2.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); } - var tx = (0, properties_1.shallowCopy)(transaction); - if (tx.from == null) { - tx.from = this.getAddress(); - } else { - tx.from = Promise.all([ - Promise.resolve(tx.from), - this.getAddress() - ]).then(function(result) { - if (result[0].toLowerCase() !== result[1].toLowerCase()) { - logger2.throwArgumentError("from address mismatch", "transaction", transaction); - } - return result[0]; - }); - } - return tx; - }; - Signer2.prototype.populateTransaction = function(transaction) { - return __awaiter2(this, void 0, void 0, function() { - var tx, hasEip1559, feeData, gasPrice; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))]; - case 1: - tx = _a7.sent(); - if (tx.to != null) { - tx.to = Promise.resolve(tx.to).then(function(to) { - return __awaiter2(_this, void 0, void 0, function() { - var address; - return __generator2(this, function(_a8) { - switch (_a8.label) { - case 0: - if (to == null) { - return [2, null]; - } - return [4, this.resolveName(to)]; - case 1: - address = _a8.sent(); - if (address == null) { - logger2.throwArgumentError("provided ENS name resolves to null", "tx.to", to); - } - return [2, address]; - } - }); + } + var tx = (0, properties_1.shallowCopy)(transaction); + if (tx.from == null) { + tx.from = this.getAddress(); + } else { + tx.from = Promise.all([ + Promise.resolve(tx.from), + this.getAddress() + ]).then(function(result) { + if (result[0].toLowerCase() !== result[1].toLowerCase()) { + logger2.throwArgumentError("from address mismatch", "transaction", transaction); + } + return result[0]; + }); + } + return tx; + }; + Signer2.prototype.populateTransaction = function(transaction) { + return __awaiter(this, void 0, void 0, function() { + var tx, hasEip1559, feeData, gasPrice; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, (0, properties_1.resolveProperties)(this.checkTransaction(transaction))]; + case 1: + tx = _a7.sent(); + if (tx.to != null) { + tx.to = Promise.resolve(tx.to).then(function(to) { + return __awaiter(_this, void 0, void 0, function() { + var address; + return __generator(this, function(_a8) { + switch (_a8.label) { + case 0: + if (to == null) { + return [2, null]; + } + return [4, this.resolveName(to)]; + case 1: + address = _a8.sent(); + if (address == null) { + logger2.throwArgumentError("provided ENS name resolves to null", "tx.to", to); + } + return [2, address]; + } }); }); - tx.to.catch(function(error) { - }); - } - hasEip1559 = tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null; - if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) { - logger2.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction); - } else if ((tx.type === 0 || tx.type === 1) && hasEip1559) { - logger2.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction); - } - if (!((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null))) - return [3, 2]; - tx.type = 2; - return [3, 5]; - case 2: - if (!(tx.type === 0 || tx.type === 1)) - return [3, 3]; - if (tx.gasPrice == null) { - tx.gasPrice = this.getGasPrice(); - } - return [3, 5]; - case 3: - return [4, this.getFeeData()]; - case 4: - feeData = _a7.sent(); - if (tx.type == null) { - if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) { - tx.type = 2; - if (tx.gasPrice != null) { - gasPrice = tx.gasPrice; - delete tx.gasPrice; - tx.maxFeePerGas = gasPrice; - tx.maxPriorityFeePerGas = gasPrice; - } else { - if (tx.maxFeePerGas == null) { - tx.maxFeePerGas = feeData.maxFeePerGas; - } - if (tx.maxPriorityFeePerGas == null) { - tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; - } - } - } else if (feeData.gasPrice != null) { - if (hasEip1559) { - logger2.throwError("network does not support EIP-1559", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "populateTransaction" - }); + }); + tx.to.catch(function(error) { + }); + } + hasEip1559 = tx.maxFeePerGas != null || tx.maxPriorityFeePerGas != null; + if (tx.gasPrice != null && (tx.type === 2 || hasEip1559)) { + logger2.throwArgumentError("eip-1559 transaction do not support gasPrice", "transaction", transaction); + } else if ((tx.type === 0 || tx.type === 1) && hasEip1559) { + logger2.throwArgumentError("pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas", "transaction", transaction); + } + if (!((tx.type === 2 || tx.type == null) && (tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null))) + return [3, 2]; + tx.type = 2; + return [3, 5]; + case 2: + if (!(tx.type === 0 || tx.type === 1)) + return [3, 3]; + if (tx.gasPrice == null) { + tx.gasPrice = this.getGasPrice(); + } + return [3, 5]; + case 3: + return [4, this.getFeeData()]; + case 4: + feeData = _a7.sent(); + if (tx.type == null) { + if (feeData.maxFeePerGas != null && feeData.maxPriorityFeePerGas != null) { + tx.type = 2; + if (tx.gasPrice != null) { + gasPrice = tx.gasPrice; + delete tx.gasPrice; + tx.maxFeePerGas = gasPrice; + tx.maxPriorityFeePerGas = gasPrice; + } else { + if (tx.maxFeePerGas == null) { + tx.maxFeePerGas = feeData.maxFeePerGas; } - if (tx.gasPrice == null) { - tx.gasPrice = feeData.gasPrice; + if (tx.maxPriorityFeePerGas == null) { + tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; } - tx.type = 0; - } else { - logger2.throwError("failed to get consistent fee data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "signer.getFeeData" - }); } - } else if (tx.type === 2) { - if (tx.maxFeePerGas == null) { - tx.maxFeePerGas = feeData.maxFeePerGas; + } else if (feeData.gasPrice != null) { + if (hasEip1559) { + logger2.throwError("network does not support EIP-1559", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "populateTransaction" + }); } - if (tx.maxPriorityFeePerGas == null) { - tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; + if (tx.gasPrice == null) { + tx.gasPrice = feeData.gasPrice; } + tx.type = 0; + } else { + logger2.throwError("failed to get consistent fee data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "signer.getFeeData" + }); } - _a7.label = 5; - case 5: - if (tx.nonce == null) { - tx.nonce = this.getTransactionCount("pending"); + } else if (tx.type === 2) { + if (tx.maxFeePerGas == null) { + tx.maxFeePerGas = feeData.maxFeePerGas; } - if (tx.gasLimit == null) { - tx.gasLimit = this.estimateGas(tx).catch(function(error) { - if (forwardErrors.indexOf(error.code) >= 0) { - throw error; - } - return logger2.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { - error, - tx - }); - }); + if (tx.maxPriorityFeePerGas == null) { + tx.maxPriorityFeePerGas = feeData.maxPriorityFeePerGas; } - if (tx.chainId == null) { - tx.chainId = this.getChainId(); - } else { - tx.chainId = Promise.all([ - Promise.resolve(tx.chainId), - this.getChainId() - ]).then(function(results) { - if (results[1] !== 0 && results[0] !== results[1]) { - logger2.throwArgumentError("chainId address mismatch", "transaction", transaction); - } - return results[0]; + } + _a7.label = 5; + case 5: + if (tx.nonce == null) { + tx.nonce = this.getTransactionCount("pending"); + } + if (tx.gasLimit == null) { + tx.gasLimit = this.estimateGas(tx).catch(function(error) { + if (forwardErrors.indexOf(error.code) >= 0) { + throw error; + } + return logger2.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { + error, + tx }); - } - return [4, (0, properties_1.resolveProperties)(tx)]; - case 6: - return [2, _a7.sent()]; - } - }); + }); + } + if (tx.chainId == null) { + tx.chainId = this.getChainId(); + } else { + tx.chainId = Promise.all([ + Promise.resolve(tx.chainId), + this.getChainId() + ]).then(function(results) { + if (results[1] !== 0 && results[0] !== results[1]) { + logger2.throwArgumentError("chainId address mismatch", "transaction", transaction); + } + return results[0]; + }); + } + return [4, (0, properties_1.resolveProperties)(tx)]; + case 6: + return [2, _a7.sent()]; + } }); - }; - Signer2.prototype._checkProvider = function(operation) { - if (!this.provider) { - logger2.throwError("missing provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: operation || "_checkProvider" - }); - } - }; - Signer2.isSigner = function(value) { - return !!(value && value._isSigner); - }; - return Signer2; - }() - ); - exports2.Signer = Signer; - var VoidSigner = ( - /** @class */ - function(_super) { - __extends2(VoidSigner2, _super); - function VoidSigner2(address, provider) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, VoidSigner2); - _this = _super.call(this) || this; - (0, properties_1.defineReadOnly)(_this, "address", address); - (0, properties_1.defineReadOnly)(_this, "provider", provider || null); - return _this; - } - VoidSigner2.prototype.getAddress = function() { - return Promise.resolve(this.address); - }; - VoidSigner2.prototype._fail = function(message, operation) { - return Promise.resolve().then(function() { - logger2.throwError(message, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation }); + }); + }; + Signer2.prototype._checkProvider = function(operation) { + if (!this.provider) { + logger2.throwError("missing provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: operation || "_checkProvider" }); - }; - VoidSigner2.prototype.signMessage = function(message) { - return this._fail("VoidSigner cannot sign messages", "signMessage"); - }; - VoidSigner2.prototype.signTransaction = function(transaction) { - return this._fail("VoidSigner cannot sign transactions", "signTransaction"); - }; - VoidSigner2.prototype._signTypedData = function(domain, types, value) { - return this._fail("VoidSigner cannot sign typed data", "signTypedData"); - }; - VoidSigner2.prototype.connect = function(provider) { - return new VoidSigner2(this.address, provider); - }; - return VoidSigner2; - }(Signer) - ); + } + }; + Signer2.isSigner = function(value) { + return !!(value && value._isSigner); + }; + return Signer2; + }(); + exports2.Signer = Signer; + var VoidSigner = function(_super) { + __extends(VoidSigner2, _super); + function VoidSigner2(address, provider) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, VoidSigner2); + _this = _super.call(this) || this; + (0, properties_1.defineReadOnly)(_this, "address", address); + (0, properties_1.defineReadOnly)(_this, "provider", provider || null); + return _this; + } + VoidSigner2.prototype.getAddress = function() { + return Promise.resolve(this.address); + }; + VoidSigner2.prototype._fail = function(message, operation) { + return Promise.resolve().then(function() { + logger2.throwError(message, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation }); + }); + }; + VoidSigner2.prototype.signMessage = function(message) { + return this._fail("VoidSigner cannot sign messages", "signMessage"); + }; + VoidSigner2.prototype.signTransaction = function(transaction) { + return this._fail("VoidSigner cannot sign transactions", "signTransaction"); + }; + VoidSigner2.prototype._signTypedData = function(domain, types, value) { + return this._fail("VoidSigner cannot sign typed data", "signTypedData"); + }; + VoidSigner2.prototype.connect = function(provider) { + return new VoidSigner2(this.address, provider); + }; + return VoidSigner2; + }(Signer); exports2.VoidSigner = VoidSigner; } }); @@ -19734,28 +19562,28 @@ var require_version20 = __commonJS({ var require_lib26 = __commonJS({ "node_modules/@ethersproject/wallet/lib/index.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -19782,7 +19610,7 @@ var require_lib26 = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -19882,184 +19710,181 @@ var require_lib26 = __commonJS({ var mnemonic = value.mnemonic; return mnemonic && mnemonic.phrase; } - var Wallet = ( - /** @class */ - function(_super) { - __extends2(Wallet2, _super); - function Wallet2(privateKey, provider) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, Wallet2); - _this = _super.call(this) || this; - if (isAccount(privateKey)) { - var signingKey_1 = new signing_key_1.SigningKey(privateKey.privateKey); - (0, properties_1.defineReadOnly)(_this, "_signingKey", function() { - return signingKey_1; + var Wallet = function(_super) { + __extends(Wallet2, _super); + function Wallet2(privateKey, provider) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, Wallet2); + _this = _super.call(this) || this; + if (isAccount(privateKey)) { + var signingKey_1 = new signing_key_1.SigningKey(privateKey.privateKey); + (0, properties_1.defineReadOnly)(_this, "_signingKey", function() { + return signingKey_1; + }); + (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey)); + if (_this.address !== (0, address_1.getAddress)(privateKey.address)) { + logger2.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDACTED]"); + } + if (hasMnemonic(privateKey)) { + var srcMnemonic_1 = privateKey.mnemonic; + (0, properties_1.defineReadOnly)(_this, "_mnemonic", function() { + return { + phrase: srcMnemonic_1.phrase, + path: srcMnemonic_1.path || hdnode_1.defaultPath, + locale: srcMnemonic_1.locale || "en" + }; }); - (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey)); - if (_this.address !== (0, address_1.getAddress)(privateKey.address)) { - logger2.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDACTED]"); - } - if (hasMnemonic(privateKey)) { - var srcMnemonic_1 = privateKey.mnemonic; - (0, properties_1.defineReadOnly)(_this, "_mnemonic", function() { - return { - phrase: srcMnemonic_1.phrase, - path: srcMnemonic_1.path || hdnode_1.defaultPath, - locale: srcMnemonic_1.locale || "en" - }; - }); - var mnemonic = _this.mnemonic; - var node = hdnode_1.HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path); - if ((0, transactions_1.computeAddress)(node.privateKey) !== _this.address) { - logger2.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDACTED]"); - } - } else { - (0, properties_1.defineReadOnly)(_this, "_mnemonic", function() { - return null; - }); + var mnemonic = _this.mnemonic; + var node = hdnode_1.HDNode.fromMnemonic(mnemonic.phrase, null, mnemonic.locale).derivePath(mnemonic.path); + if ((0, transactions_1.computeAddress)(node.privateKey) !== _this.address) { + logger2.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDACTED]"); } } else { - if (signing_key_1.SigningKey.isSigningKey(privateKey)) { - if (privateKey.curve !== "secp256k1") { - logger2.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); - } - (0, properties_1.defineReadOnly)(_this, "_signingKey", function() { - return privateKey; - }); - } else { - if (typeof privateKey === "string") { - if (privateKey.match(/^[0-9a-f]*$/i) && privateKey.length === 64) { - privateKey = "0x" + privateKey; - } - } - var signingKey_2 = new signing_key_1.SigningKey(privateKey); - (0, properties_1.defineReadOnly)(_this, "_signingKey", function() { - return signingKey_2; - }); - } (0, properties_1.defineReadOnly)(_this, "_mnemonic", function() { return null; }); - (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey)); - } - if (provider && !abstract_provider_1.Provider.isProvider(provider)) { - logger2.throwArgumentError("invalid provider", "provider", provider); } - (0, properties_1.defineReadOnly)(_this, "provider", provider || null); - return _this; - } - Object.defineProperty(Wallet2.prototype, "mnemonic", { - get: function() { - return this._mnemonic(); - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Wallet2.prototype, "privateKey", { - get: function() { - return this._signingKey().privateKey; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Wallet2.prototype, "publicKey", { - get: function() { - return this._signingKey().publicKey; - }, - enumerable: false, - configurable: true - }); - Wallet2.prototype.getAddress = function() { - return Promise.resolve(this.address); - }; - Wallet2.prototype.connect = function(provider) { - return new Wallet2(this, provider); - }; - Wallet2.prototype.signTransaction = function(transaction) { - var _this = this; - return (0, properties_1.resolveProperties)(transaction).then(function(tx) { - if (tx.from != null) { - if ((0, address_1.getAddress)(tx.from) !== _this.address) { - logger2.throwArgumentError("transaction from address mismatch", "transaction.from", transaction.from); - } - delete tx.from; + } else { + if (signing_key_1.SigningKey.isSigningKey(privateKey)) { + if (privateKey.curve !== "secp256k1") { + logger2.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); } - var signature = _this._signingKey().signDigest((0, keccak256_1.keccak256)((0, transactions_1.serialize)(tx))); - return (0, transactions_1.serialize)(tx, signature); - }); - }; - Wallet2.prototype.signMessage = function(message) { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - return [2, (0, bytes_1.joinSignature)(this._signingKey().signDigest((0, hash_1.hashMessage)(message)))]; + (0, properties_1.defineReadOnly)(_this, "_signingKey", function() { + return privateKey; }); - }); - }; - Wallet2.prototype._signTypedData = function(domain, types, value) { - return __awaiter2(this, void 0, void 0, function() { - var populated; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function(name2) { - if (_this.provider == null) { - logger2.throwError("cannot resolve ENS names without a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "resolveName", - value: name2 - }); - } - return _this.provider.resolveName(name2); - })]; - case 1: - populated = _a7.sent(); - return [2, (0, bytes_1.joinSignature)(this._signingKey().signDigest(hash_1._TypedDataEncoder.hash(populated.domain, types, populated.value)))]; + } else { + if (typeof privateKey === "string") { + if (privateKey.match(/^[0-9a-f]*$/i) && privateKey.length === 64) { + privateKey = "0x" + privateKey; } + } + var signingKey_2 = new signing_key_1.SigningKey(privateKey); + (0, properties_1.defineReadOnly)(_this, "_signingKey", function() { + return signingKey_2; }); - }); - }; - Wallet2.prototype.encrypt = function(password, options2, progressCallback) { - if (typeof options2 === "function" && !progressCallback) { - progressCallback = options2; - options2 = {}; - } - if (progressCallback && typeof progressCallback !== "function") { - throw new Error("invalid callback"); } - if (!options2) { - options2 = {}; - } - return (0, json_wallets_1.encryptKeystore)(this, password, options2, progressCallback); - }; - Wallet2.createRandom = function(options2) { - var entropy = (0, random_1.randomBytes)(16); - if (!options2) { - options2 = {}; - } - if (options2.extraEntropy) { - entropy = (0, bytes_1.arrayify)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.concat)([entropy, options2.extraEntropy])), 0, 16)); - } - var mnemonic = (0, hdnode_1.entropyToMnemonic)(entropy, options2.locale); - return Wallet2.fromMnemonic(mnemonic, options2.path, options2.locale); - }; - Wallet2.fromEncryptedJson = function(json, password, progressCallback) { - return (0, json_wallets_1.decryptJsonWallet)(json, password, progressCallback).then(function(account) { - return new Wallet2(account); + (0, properties_1.defineReadOnly)(_this, "_mnemonic", function() { + return null; }); - }; - Wallet2.fromEncryptedJsonSync = function(json, password) { - return new Wallet2((0, json_wallets_1.decryptJsonWalletSync)(json, password)); - }; - Wallet2.fromMnemonic = function(mnemonic, path2, wordlist) { - if (!path2) { - path2 = hdnode_1.defaultPath; + (0, properties_1.defineReadOnly)(_this, "address", (0, transactions_1.computeAddress)(_this.publicKey)); + } + if (provider && !abstract_provider_1.Provider.isProvider(provider)) { + logger2.throwArgumentError("invalid provider", "provider", provider); + } + (0, properties_1.defineReadOnly)(_this, "provider", provider || null); + return _this; + } + Object.defineProperty(Wallet2.prototype, "mnemonic", { + get: function() { + return this._mnemonic(); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Wallet2.prototype, "privateKey", { + get: function() { + return this._signingKey().privateKey; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Wallet2.prototype, "publicKey", { + get: function() { + return this._signingKey().publicKey; + }, + enumerable: false, + configurable: true + }); + Wallet2.prototype.getAddress = function() { + return Promise.resolve(this.address); + }; + Wallet2.prototype.connect = function(provider) { + return new Wallet2(this, provider); + }; + Wallet2.prototype.signTransaction = function(transaction) { + var _this = this; + return (0, properties_1.resolveProperties)(transaction).then(function(tx) { + if (tx.from != null) { + if ((0, address_1.getAddress)(tx.from) !== _this.address) { + logger2.throwArgumentError("transaction from address mismatch", "transaction.from", transaction.from); + } + delete tx.from; } - return new Wallet2(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path2)); - }; - return Wallet2; - }(abstract_signer_1.Signer) - ); + var signature = _this._signingKey().signDigest((0, keccak256_1.keccak256)((0, transactions_1.serialize)(tx))); + return (0, transactions_1.serialize)(tx, signature); + }); + }; + Wallet2.prototype.signMessage = function(message) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + return [2, (0, bytes_1.joinSignature)(this._signingKey().signDigest((0, hash_1.hashMessage)(message)))]; + }); + }); + }; + Wallet2.prototype._signTypedData = function(domain, types, value) { + return __awaiter(this, void 0, void 0, function() { + var populated; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function(name2) { + if (_this.provider == null) { + logger2.throwError("cannot resolve ENS names without a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "resolveName", + value: name2 + }); + } + return _this.provider.resolveName(name2); + })]; + case 1: + populated = _a7.sent(); + return [2, (0, bytes_1.joinSignature)(this._signingKey().signDigest(hash_1._TypedDataEncoder.hash(populated.domain, types, populated.value)))]; + } + }); + }); + }; + Wallet2.prototype.encrypt = function(password, options2, progressCallback) { + if (typeof options2 === "function" && !progressCallback) { + progressCallback = options2; + options2 = {}; + } + if (progressCallback && typeof progressCallback !== "function") { + throw new Error("invalid callback"); + } + if (!options2) { + options2 = {}; + } + return (0, json_wallets_1.encryptKeystore)(this, password, options2, progressCallback); + }; + Wallet2.createRandom = function(options2) { + var entropy = (0, random_1.randomBytes)(16); + if (!options2) { + options2 = {}; + } + if (options2.extraEntropy) { + entropy = (0, bytes_1.arrayify)((0, bytes_1.hexDataSlice)((0, keccak256_1.keccak256)((0, bytes_1.concat)([entropy, options2.extraEntropy])), 0, 16)); + } + var mnemonic = (0, hdnode_1.entropyToMnemonic)(entropy, options2.locale); + return Wallet2.fromMnemonic(mnemonic, options2.path, options2.locale); + }; + Wallet2.fromEncryptedJson = function(json, password, progressCallback) { + return (0, json_wallets_1.decryptJsonWallet)(json, password, progressCallback).then(function(account) { + return new Wallet2(account); + }); + }; + Wallet2.fromEncryptedJsonSync = function(json, password) { + return new Wallet2((0, json_wallets_1.decryptJsonWalletSync)(json, password)); + }; + Wallet2.fromMnemonic = function(mnemonic, path2, wordlist) { + if (!path2) { + path2 = hdnode_1.defaultPath; + } + return new Wallet2(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path2)); + }; + return Wallet2; + }(abstract_signer_1.Signer); exports2.Wallet = Wallet; function verifyMessage(message, signature) { return (0, transactions_1.recoverAddress)((0, hash_1.hashMessage)(message), signature); @@ -20086,7 +19911,7 @@ var require_version21 = __commonJS({ var require_geturl = __commonJS({ "node_modules/@ethersproject/web/lib/geturl.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -20113,7 +19938,7 @@ var require_geturl = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -20189,13 +20014,13 @@ var require_geturl = __commonJS({ return { value: op[0] ? op[1] : void 0, done: true }; } }; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getUrl = void 0; - var http_1 = __importDefault2(require("http")); - var https_1 = __importDefault2(require("https")); + var http_1 = __importDefault(require("http")); + var https_1 = __importDefault(require("https")); var zlib_1 = require("zlib"); var url_1 = require("url"); var bytes_1 = require_lib2(); @@ -20248,9 +20073,9 @@ var require_geturl = __commonJS({ return value; } function getUrl(href, options2) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var url, request, req, response; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: if (options2 == null) { @@ -20302,7 +20127,7 @@ var require_geturl = __commonJS({ var require_lib27 = __commonJS({ "node_modules/@ethersproject/web/lib/index.js"(exports2) { "use strict"; - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -20329,7 +20154,7 @@ var require_lib27 = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -20551,9 +20376,9 @@ var require_lib27 = __commonJS({ return { promise, cancel }; }(); var runningFetch = function() { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var attempt, response2, location_1, tryAgain, stall, retryAfter, error_1, body_1, result2, error_2, tryAgain, timeout_1; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: attempt = 0; @@ -20809,7 +20634,7 @@ var require_lib27 = __commonJS({ var require_utils5 = __commonJS({ "node_modules/ethers/lib/utils.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -20820,21 +20645,21 @@ var require_utils5 = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); @@ -20899,7 +20724,7 @@ var require_utils5 = __commonJS({ Object.defineProperty(exports2, "isAddress", { enumerable: true, get: function() { return address_1.isAddress; } }); - var base64 = __importStar2(require_lib12()); + var base64 = __importStar(require_lib12()); exports2.base64 = base64; var basex_1 = require_lib13(); Object.defineProperty(exports2, "base58", { enumerable: true, get: function() { @@ -21053,7 +20878,7 @@ var require_utils5 = __commonJS({ Object.defineProperty(exports2, "shallowCopy", { enumerable: true, get: function() { return properties_1.shallowCopy; } }); - var RLP = __importStar2(require_lib6()); + var RLP = __importStar(require_lib6()); exports2.RLP = RLP; var signing_key_1 = require_lib15(); Object.defineProperty(exports2, "computePublicKey", { enumerable: true, get: function() { @@ -21170,28 +20995,28 @@ var require_version22 = __commonJS({ var require_lib28 = __commonJS({ "node_modules/@ethersproject/contracts/lib/index.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -21218,7 +21043,7 @@ var require_lib28 = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -21294,7 +21119,7 @@ var require_lib28 = __commonJS({ return { value: op[0] ? op[1] : void 0, done: true }; } }; - var __spreadArray2 = exports2 && exports2.__spreadArray || function(to, from, pack) { + var __spreadArray = exports2 && exports2.__spreadArray || function(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { @@ -21334,9 +21159,9 @@ var require_lib28 = __commonJS({ customData: true }; function resolveName(resolver, nameOrPromise) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var name2, address; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: return [4, nameOrPromise]; @@ -21366,8 +21191,8 @@ var require_lib28 = __commonJS({ }); } function resolveAddresses(resolver, value, paramType) { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: if (!Array.isArray(paramType)) @@ -21410,10 +21235,10 @@ var require_lib28 = __commonJS({ }); } function populateTransaction(contract, fragment, args) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var overrides, resolved, data, tx, ro, intrinsic, bytes, i, roValue, leftovers; var _this = this; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: overrides = {}; @@ -21427,8 +21252,8 @@ var require_lib28 = __commonJS({ override: resolveName(contract.signer, overrides.from), signer: contract.signer.getAddress() }).then(function(check) { - return __awaiter2(_this, void 0, void 0, function() { - return __generator2(this, function(_a8) { + return __awaiter(_this, void 0, void 0, function() { + return __generator(this, function(_a8) { if ((0, address_1.getAddress)(check.signer) !== check.override) { logger2.throwError("Contract with a Signer cannot override from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "overrides.from" @@ -21547,9 +21372,9 @@ var require_lib28 = __commonJS({ for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var tx; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: if (!signerOrProvider) { @@ -21612,9 +21437,9 @@ var require_lib28 = __commonJS({ for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var blockTag, overrides, tx, result, value; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: blockTag = void 0; @@ -21659,10 +21484,7 @@ var require_lib28 = __commonJS({ } throw error; } - return [ - 2 - /*return*/ - ]; + return [2]; } }); }); @@ -21674,9 +21496,9 @@ var require_lib28 = __commonJS({ for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var txRequest, tx; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { switch (_a7.label) { case 0: if (!contract.signer) { @@ -21721,683 +21543,662 @@ var require_lib28 = __commonJS({ return topic; }).join(":") : ""); } - var RunningEvent = ( - /** @class */ - function() { - function RunningEvent2(tag, filter) { - (0, properties_1.defineReadOnly)(this, "tag", tag); - (0, properties_1.defineReadOnly)(this, "filter", filter); - this._listeners = []; + var RunningEvent = function() { + function RunningEvent2(tag, filter) { + (0, properties_1.defineReadOnly)(this, "tag", tag); + (0, properties_1.defineReadOnly)(this, "filter", filter); + this._listeners = []; + } + RunningEvent2.prototype.addListener = function(listener, once) { + this._listeners.push({ listener, once }); + }; + RunningEvent2.prototype.removeListener = function(listener) { + var done = false; + this._listeners = this._listeners.filter(function(item) { + if (done || item.listener !== listener) { + return true; + } + done = true; + return false; + }); + }; + RunningEvent2.prototype.removeAllListeners = function() { + this._listeners = []; + }; + RunningEvent2.prototype.listeners = function() { + return this._listeners.map(function(i) { + return i.listener; + }); + }; + RunningEvent2.prototype.listenerCount = function() { + return this._listeners.length; + }; + RunningEvent2.prototype.run = function(args) { + var _this = this; + var listenerCount = this.listenerCount(); + this._listeners = this._listeners.filter(function(item) { + var argsCopy = args.slice(); + setTimeout(function() { + item.listener.apply(_this, argsCopy); + }, 0); + return !item.once; + }); + return listenerCount; + }; + RunningEvent2.prototype.prepareEvent = function(event) { + }; + RunningEvent2.prototype.getEmit = function(event) { + return [event]; + }; + return RunningEvent2; + }(); + var ErrorRunningEvent = function(_super) { + __extends(ErrorRunningEvent2, _super); + function ErrorRunningEvent2() { + return _super.call(this, "error", null) || this; + } + return ErrorRunningEvent2; + }(RunningEvent); + var FragmentRunningEvent = function(_super) { + __extends(FragmentRunningEvent2, _super); + function FragmentRunningEvent2(address, contractInterface, fragment, topics) { + var _this = this; + var filter = { + address + }; + var topic = contractInterface.getEventTopic(fragment); + if (topics) { + if (topic !== topics[0]) { + logger2.throwArgumentError("topic mismatch", "topics", topics); + } + filter.topics = topics.slice(); + } else { + filter.topics = [topic]; } - RunningEvent2.prototype.addListener = function(listener, once) { - this._listeners.push({ listener, once }); + _this = _super.call(this, getEventTag(filter), filter) || this; + (0, properties_1.defineReadOnly)(_this, "address", address); + (0, properties_1.defineReadOnly)(_this, "interface", contractInterface); + (0, properties_1.defineReadOnly)(_this, "fragment", fragment); + return _this; + } + FragmentRunningEvent2.prototype.prepareEvent = function(event) { + var _this = this; + _super.prototype.prepareEvent.call(this, event); + event.event = this.fragment.name; + event.eventSignature = this.fragment.format(); + event.decode = function(data, topics) { + return _this.interface.decodeEventLog(_this.fragment, data, topics); }; - RunningEvent2.prototype.removeListener = function(listener) { - var done = false; - this._listeners = this._listeners.filter(function(item) { - if (done || item.listener !== listener) { - return true; + try { + event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics); + } catch (error) { + event.args = null; + event.decodeError = error; + } + }; + FragmentRunningEvent2.prototype.getEmit = function(event) { + var errors = (0, abi_1.checkResultErrors)(event.args); + if (errors.length) { + throw errors[0].error; + } + var args = (event.args || []).slice(); + args.push(event); + return args; + }; + return FragmentRunningEvent2; + }(RunningEvent); + var WildcardRunningEvent = function(_super) { + __extends(WildcardRunningEvent2, _super); + function WildcardRunningEvent2(address, contractInterface) { + var _this = _super.call(this, "*", { address }) || this; + (0, properties_1.defineReadOnly)(_this, "address", address); + (0, properties_1.defineReadOnly)(_this, "interface", contractInterface); + return _this; + } + WildcardRunningEvent2.prototype.prepareEvent = function(event) { + var _this = this; + _super.prototype.prepareEvent.call(this, event); + try { + var parsed_1 = this.interface.parseLog(event); + event.event = parsed_1.name; + event.eventSignature = parsed_1.signature; + event.decode = function(data, topics) { + return _this.interface.decodeEventLog(parsed_1.eventFragment, data, topics); + }; + event.args = parsed_1.args; + } catch (error) { + } + }; + return WildcardRunningEvent2; + }(RunningEvent); + var BaseContract = function() { + function BaseContract2(addressOrName, contractInterface, signerOrProvider) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, Contract); + (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface)); + if (signerOrProvider == null) { + (0, properties_1.defineReadOnly)(this, "provider", null); + (0, properties_1.defineReadOnly)(this, "signer", null); + } else if (abstract_signer_1.Signer.isSigner(signerOrProvider)) { + (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider.provider || null); + (0, properties_1.defineReadOnly)(this, "signer", signerOrProvider); + } else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) { + (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider); + (0, properties_1.defineReadOnly)(this, "signer", null); + } else { + logger2.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); + } + (0, properties_1.defineReadOnly)(this, "callStatic", {}); + (0, properties_1.defineReadOnly)(this, "estimateGas", {}); + (0, properties_1.defineReadOnly)(this, "functions", {}); + (0, properties_1.defineReadOnly)(this, "populateTransaction", {}); + (0, properties_1.defineReadOnly)(this, "filters", {}); + { + var uniqueFilters_1 = {}; + Object.keys(this.interface.events).forEach(function(eventSignature) { + var event = _this.interface.events[eventSignature]; + (0, properties_1.defineReadOnly)(_this.filters, eventSignature, function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return { + address: _this.address, + topics: _this.interface.encodeFilterTopics(event, args) + }; + }); + if (!uniqueFilters_1[event.name]) { + uniqueFilters_1[event.name] = []; } - done = true; - return false; - }); - }; - RunningEvent2.prototype.removeAllListeners = function() { - this._listeners = []; - }; - RunningEvent2.prototype.listeners = function() { - return this._listeners.map(function(i) { - return i.listener; + uniqueFilters_1[event.name].push(eventSignature); }); - }; - RunningEvent2.prototype.listenerCount = function() { - return this._listeners.length; - }; - RunningEvent2.prototype.run = function(args) { - var _this = this; - var listenerCount = this.listenerCount(); - this._listeners = this._listeners.filter(function(item) { - var argsCopy = args.slice(); - setTimeout(function() { - item.listener.apply(_this, argsCopy); - }, 0); - return !item.once; - }); - return listenerCount; - }; - RunningEvent2.prototype.prepareEvent = function(event) { - }; - RunningEvent2.prototype.getEmit = function(event) { - return [event]; - }; - return RunningEvent2; - }() - ); - var ErrorRunningEvent = ( - /** @class */ - function(_super) { - __extends2(ErrorRunningEvent2, _super); - function ErrorRunningEvent2() { - return _super.call(this, "error", null) || this; - } - return ErrorRunningEvent2; - }(RunningEvent) - ); - var FragmentRunningEvent = ( - /** @class */ - function(_super) { - __extends2(FragmentRunningEvent2, _super); - function FragmentRunningEvent2(address, contractInterface, fragment, topics) { - var _this = this; - var filter = { - address - }; - var topic = contractInterface.getEventTopic(fragment); - if (topics) { - if (topic !== topics[0]) { - logger2.throwArgumentError("topic mismatch", "topics", topics); + Object.keys(uniqueFilters_1).forEach(function(name2) { + var filters = uniqueFilters_1[name2]; + if (filters.length === 1) { + (0, properties_1.defineReadOnly)(_this.filters, name2, _this.filters[filters[0]]); + } else { + logger2.warn("Duplicate definition of " + name2 + " (" + filters.join(", ") + ")"); } - filter.topics = topics.slice(); - } else { - filter.topics = [topic]; - } - _this = _super.call(this, getEventTag(filter), filter) || this; - (0, properties_1.defineReadOnly)(_this, "address", address); - (0, properties_1.defineReadOnly)(_this, "interface", contractInterface); - (0, properties_1.defineReadOnly)(_this, "fragment", fragment); - return _this; + }); } - FragmentRunningEvent2.prototype.prepareEvent = function(event) { - var _this = this; - _super.prototype.prepareEvent.call(this, event); - event.event = this.fragment.name; - event.eventSignature = this.fragment.format(); - event.decode = function(data, topics) { - return _this.interface.decodeEventLog(_this.fragment, data, topics); - }; - try { - event.args = this.interface.decodeEventLog(this.fragment, event.data, event.topics); - } catch (error) { - event.args = null; - event.decodeError = error; - } - }; - FragmentRunningEvent2.prototype.getEmit = function(event) { - var errors = (0, abi_1.checkResultErrors)(event.args); - if (errors.length) { - throw errors[0].error; - } - var args = (event.args || []).slice(); - args.push(event); - return args; - }; - return FragmentRunningEvent2; - }(RunningEvent) - ); - var WildcardRunningEvent = ( - /** @class */ - function(_super) { - __extends2(WildcardRunningEvent2, _super); - function WildcardRunningEvent2(address, contractInterface) { - var _this = _super.call(this, "*", { address }) || this; - (0, properties_1.defineReadOnly)(_this, "address", address); - (0, properties_1.defineReadOnly)(_this, "interface", contractInterface); - return _this; - } - WildcardRunningEvent2.prototype.prepareEvent = function(event) { - var _this = this; - _super.prototype.prepareEvent.call(this, event); + (0, properties_1.defineReadOnly)(this, "_runningEvents", {}); + (0, properties_1.defineReadOnly)(this, "_wrappedEmits", {}); + if (addressOrName == null) { + logger2.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName); + } + (0, properties_1.defineReadOnly)(this, "address", addressOrName); + if (this.provider) { + (0, properties_1.defineReadOnly)(this, "resolvedAddress", resolveName(this.provider, addressOrName)); + } else { try { - var parsed_1 = this.interface.parseLog(event); - event.event = parsed_1.name; - event.eventSignature = parsed_1.signature; - event.decode = function(data, topics) { - return _this.interface.decodeEventLog(parsed_1.eventFragment, data, topics); - }; - event.args = parsed_1.args; + (0, properties_1.defineReadOnly)(this, "resolvedAddress", Promise.resolve((0, address_1.getAddress)(addressOrName))); } catch (error) { - } - }; - return WildcardRunningEvent2; - }(RunningEvent) - ); - var BaseContract = ( - /** @class */ - function() { - function BaseContract2(addressOrName, contractInterface, signerOrProvider) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, Contract); - (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface)); - if (signerOrProvider == null) { - (0, properties_1.defineReadOnly)(this, "provider", null); - (0, properties_1.defineReadOnly)(this, "signer", null); - } else if (abstract_signer_1.Signer.isSigner(signerOrProvider)) { - (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider.provider || null); - (0, properties_1.defineReadOnly)(this, "signer", signerOrProvider); - } else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) { - (0, properties_1.defineReadOnly)(this, "provider", signerOrProvider); - (0, properties_1.defineReadOnly)(this, "signer", null); - } else { - logger2.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); - } - (0, properties_1.defineReadOnly)(this, "callStatic", {}); - (0, properties_1.defineReadOnly)(this, "estimateGas", {}); - (0, properties_1.defineReadOnly)(this, "functions", {}); - (0, properties_1.defineReadOnly)(this, "populateTransaction", {}); - (0, properties_1.defineReadOnly)(this, "filters", {}); - { - var uniqueFilters_1 = {}; - Object.keys(this.interface.events).forEach(function(eventSignature) { - var event = _this.interface.events[eventSignature]; - (0, properties_1.defineReadOnly)(_this.filters, eventSignature, function() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return { - address: _this.address, - topics: _this.interface.encodeFilterTopics(event, args) - }; - }); - if (!uniqueFilters_1[event.name]) { - uniqueFilters_1[event.name] = []; - } - uniqueFilters_1[event.name].push(eventSignature); - }); - Object.keys(uniqueFilters_1).forEach(function(name2) { - var filters = uniqueFilters_1[name2]; - if (filters.length === 1) { - (0, properties_1.defineReadOnly)(_this.filters, name2, _this.filters[filters[0]]); - } else { - logger2.warn("Duplicate definition of " + name2 + " (" + filters.join(", ") + ")"); - } + logger2.throwError("provider is required to use ENS name as contract address", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new Contract" }); } - (0, properties_1.defineReadOnly)(this, "_runningEvents", {}); - (0, properties_1.defineReadOnly)(this, "_wrappedEmits", {}); - if (addressOrName == null) { - logger2.throwArgumentError("invalid contract address or ENS name", "addressOrName", addressOrName); + } + var uniqueNames = {}; + var uniqueSignatures = {}; + Object.keys(this.interface.functions).forEach(function(signature) { + var fragment = _this.interface.functions[signature]; + if (uniqueSignatures[signature]) { + logger2.warn("Duplicate ABI entry for " + JSON.stringify(signature)); + return; } - (0, properties_1.defineReadOnly)(this, "address", addressOrName); - if (this.provider) { - (0, properties_1.defineReadOnly)(this, "resolvedAddress", resolveName(this.provider, addressOrName)); - } else { - try { - (0, properties_1.defineReadOnly)(this, "resolvedAddress", Promise.resolve((0, address_1.getAddress)(addressOrName))); - } catch (error) { - logger2.throwError("provider is required to use ENS name as contract address", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new Contract" - }); + uniqueSignatures[signature] = true; + { + var name_1 = fragment.name; + if (!uniqueNames["%" + name_1]) { + uniqueNames["%" + name_1] = []; } + uniqueNames["%" + name_1].push(signature); } - var uniqueNames = {}; - var uniqueSignatures = {}; - Object.keys(this.interface.functions).forEach(function(signature) { - var fragment = _this.interface.functions[signature]; - if (uniqueSignatures[signature]) { - logger2.warn("Duplicate ABI entry for " + JSON.stringify(signature)); - return; - } - uniqueSignatures[signature] = true; - { - var name_1 = fragment.name; - if (!uniqueNames["%" + name_1]) { - uniqueNames["%" + name_1] = []; - } - uniqueNames["%" + name_1].push(signature); - } - if (_this[signature] == null) { - (0, properties_1.defineReadOnly)(_this, signature, buildDefault(_this, fragment, true)); - } - if (_this.functions[signature] == null) { - (0, properties_1.defineReadOnly)(_this.functions, signature, buildDefault(_this, fragment, false)); - } - if (_this.callStatic[signature] == null) { - (0, properties_1.defineReadOnly)(_this.callStatic, signature, buildCall(_this, fragment, true)); - } - if (_this.populateTransaction[signature] == null) { - (0, properties_1.defineReadOnly)(_this.populateTransaction, signature, buildPopulate(_this, fragment)); - } - if (_this.estimateGas[signature] == null) { - (0, properties_1.defineReadOnly)(_this.estimateGas, signature, buildEstimate(_this, fragment)); - } - }); - Object.keys(uniqueNames).forEach(function(name2) { - var signatures = uniqueNames[name2]; - if (signatures.length > 1) { - return; - } - name2 = name2.substring(1); - var signature = signatures[0]; - try { - if (_this[name2] == null) { - (0, properties_1.defineReadOnly)(_this, name2, _this[signature]); - } - } catch (e) { - } - if (_this.functions[name2] == null) { - (0, properties_1.defineReadOnly)(_this.functions, name2, _this.functions[signature]); - } - if (_this.callStatic[name2] == null) { - (0, properties_1.defineReadOnly)(_this.callStatic, name2, _this.callStatic[signature]); - } - if (_this.populateTransaction[name2] == null) { - (0, properties_1.defineReadOnly)(_this.populateTransaction, name2, _this.populateTransaction[signature]); - } - if (_this.estimateGas[name2] == null) { - (0, properties_1.defineReadOnly)(_this.estimateGas, name2, _this.estimateGas[signature]); - } - }); - } - BaseContract2.getContractAddress = function(transaction) { - return (0, address_1.getContractAddress)(transaction); - }; - BaseContract2.getInterface = function(contractInterface) { - if (abi_1.Interface.isInterface(contractInterface)) { - return contractInterface; + if (_this[signature] == null) { + (0, properties_1.defineReadOnly)(_this, signature, buildDefault(_this, fragment, true)); } - return new abi_1.Interface(contractInterface); - }; - BaseContract2.prototype.deployed = function() { - return this._deployed(); - }; - BaseContract2.prototype._deployed = function(blockTag) { - var _this = this; - if (!this._deployedPromise) { - if (this.deployTransaction) { - this._deployedPromise = this.deployTransaction.wait().then(function() { - return _this; - }); - } else { - this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function(code) { - if (code === "0x") { - logger2.throwError("contract not deployed", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - contractAddress: _this.address, - operation: "getDeployed" - }); - } - return _this; - }); - } + if (_this.functions[signature] == null) { + (0, properties_1.defineReadOnly)(_this.functions, signature, buildDefault(_this, fragment, false)); } - return this._deployedPromise; - }; - BaseContract2.prototype.fallback = function(overrides) { - var _this = this; - if (!this.signer) { - logger2.throwError("sending a transactions require a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + if (_this.callStatic[signature] == null) { + (0, properties_1.defineReadOnly)(_this.callStatic, signature, buildCall(_this, fragment, true)); } - var tx = (0, properties_1.shallowCopy)(overrides || {}); - ["from", "to"].forEach(function(key) { - if (tx[key] == null) { - return; - } - logger2.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); - }); - tx.to = this.resolvedAddress; - return this.deployed().then(function() { - return _this.signer.sendTransaction(tx); - }); - }; - BaseContract2.prototype.connect = function(signerOrProvider) { - if (typeof signerOrProvider === "string") { - signerOrProvider = new abstract_signer_1.VoidSigner(signerOrProvider, this.provider); + if (_this.populateTransaction[signature] == null) { + (0, properties_1.defineReadOnly)(_this.populateTransaction, signature, buildPopulate(_this, fragment)); } - var contract = new this.constructor(this.address, this.interface, signerOrProvider); - if (this.deployTransaction) { - (0, properties_1.defineReadOnly)(contract, "deployTransaction", this.deployTransaction); + if (_this.estimateGas[signature] == null) { + (0, properties_1.defineReadOnly)(_this.estimateGas, signature, buildEstimate(_this, fragment)); } - return contract; - }; - BaseContract2.prototype.attach = function(addressOrName) { - return new this.constructor(addressOrName, this.interface, this.signer || this.provider); - }; - BaseContract2.isIndexed = function(value) { - return abi_1.Indexed.isIndexed(value); - }; - BaseContract2.prototype._normalizeRunningEvent = function(runningEvent) { - if (this._runningEvents[runningEvent.tag]) { - return this._runningEvents[runningEvent.tag]; + }); + Object.keys(uniqueNames).forEach(function(name2) { + var signatures = uniqueNames[name2]; + if (signatures.length > 1) { + return; } - return runningEvent; - }; - BaseContract2.prototype._getRunningEvent = function(eventName) { - if (typeof eventName === "string") { - if (eventName === "error") { - return this._normalizeRunningEvent(new ErrorRunningEvent()); - } - if (eventName === "event") { - return this._normalizeRunningEvent(new RunningEvent("event", null)); - } - if (eventName === "*") { - return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); + name2 = name2.substring(1); + var signature = signatures[0]; + try { + if (_this[name2] == null) { + (0, properties_1.defineReadOnly)(_this, name2, _this[signature]); } - var fragment = this.interface.getEvent(eventName); - return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); + } catch (e) { } - if (eventName.topics && eventName.topics.length > 0) { - try { - var topic = eventName.topics[0]; - if (typeof topic !== "string") { - throw new Error("invalid topic"); - } - var fragment = this.interface.getEvent(topic); - return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); - } catch (error) { - } - var filter = { - address: this.address, - topics: eventName.topics - }; - return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter)); + if (_this.functions[name2] == null) { + (0, properties_1.defineReadOnly)(_this.functions, name2, _this.functions[signature]); } - return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); - }; - BaseContract2.prototype._checkRunningEvents = function(runningEvent) { - if (runningEvent.listenerCount() === 0) { - delete this._runningEvents[runningEvent.tag]; - var emit = this._wrappedEmits[runningEvent.tag]; - if (emit && runningEvent.filter) { - this.provider.off(runningEvent.filter, emit); - delete this._wrappedEmits[runningEvent.tag]; - } + if (_this.callStatic[name2] == null) { + (0, properties_1.defineReadOnly)(_this.callStatic, name2, _this.callStatic[signature]); } - }; - BaseContract2.prototype._wrapEvent = function(runningEvent, log, listener) { - var _this = this; - var event = (0, properties_1.deepCopy)(log); - event.removeListener = function() { - if (!listener) { - return; - } - runningEvent.removeListener(listener); - _this._checkRunningEvents(runningEvent); - }; - event.getBlock = function() { - return _this.provider.getBlock(log.blockHash); - }; - event.getTransaction = function() { - return _this.provider.getTransaction(log.transactionHash); - }; - event.getTransactionReceipt = function() { - return _this.provider.getTransactionReceipt(log.transactionHash); - }; - runningEvent.prepareEvent(event); - return event; - }; - BaseContract2.prototype._addEventListener = function(runningEvent, listener, once) { - var _this = this; - if (!this.provider) { - logger2.throwError("events require a provider or a signer with a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); - } - runningEvent.addListener(listener, once); - this._runningEvents[runningEvent.tag] = runningEvent; - if (!this._wrappedEmits[runningEvent.tag]) { - var wrappedEmit = function(log) { - var event = _this._wrapEvent(runningEvent, log, listener); - if (event.decodeError == null) { - try { - var args = runningEvent.getEmit(event); - _this.emit.apply(_this, __spreadArray2([runningEvent.filter], args, false)); - } catch (error) { - event.decodeError = error.error; - } - } - if (runningEvent.filter != null) { - _this.emit("event", event); - } - if (event.decodeError != null) { - _this.emit("error", event.decodeError, event); - } - }; - this._wrappedEmits[runningEvent.tag] = wrappedEmit; - if (runningEvent.filter != null) { - this.provider.on(runningEvent.filter, wrappedEmit); - } + if (_this.populateTransaction[name2] == null) { + (0, properties_1.defineReadOnly)(_this.populateTransaction, name2, _this.populateTransaction[signature]); } - }; - BaseContract2.prototype.queryFilter = function(event, fromBlockOrBlockhash, toBlock) { - var _this = this; - var runningEvent = this._getRunningEvent(event); - var filter = (0, properties_1.shallowCopy)(runningEvent.filter); - if (typeof fromBlockOrBlockhash === "string" && (0, bytes_1.isHexString)(fromBlockOrBlockhash, 32)) { - if (toBlock != null) { - logger2.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); - } - filter.blockHash = fromBlockOrBlockhash; - } else { - filter.fromBlock = fromBlockOrBlockhash != null ? fromBlockOrBlockhash : 0; - filter.toBlock = toBlock != null ? toBlock : "latest"; + if (_this.estimateGas[name2] == null) { + (0, properties_1.defineReadOnly)(_this.estimateGas, name2, _this.estimateGas[signature]); } - return this.provider.getLogs(filter).then(function(logs) { - return logs.map(function(log) { - return _this._wrapEvent(runningEvent, log, null); + }); + } + BaseContract2.getContractAddress = function(transaction) { + return (0, address_1.getContractAddress)(transaction); + }; + BaseContract2.getInterface = function(contractInterface) { + if (abi_1.Interface.isInterface(contractInterface)) { + return contractInterface; + } + return new abi_1.Interface(contractInterface); + }; + BaseContract2.prototype.deployed = function() { + return this._deployed(); + }; + BaseContract2.prototype._deployed = function(blockTag) { + var _this = this; + if (!this._deployedPromise) { + if (this.deployTransaction) { + this._deployedPromise = this.deployTransaction.wait().then(function() { + return _this; + }); + } else { + this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function(code) { + if (code === "0x") { + logger2.throwError("contract not deployed", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + contractAddress: _this.address, + operation: "getDeployed" + }); + } + return _this; }); - }); - }; - BaseContract2.prototype.on = function(event, listener) { - this._addEventListener(this._getRunningEvent(event), listener, false); - return this; - }; - BaseContract2.prototype.once = function(event, listener) { - this._addEventListener(this._getRunningEvent(event), listener, true); - return this; - }; - BaseContract2.prototype.emit = function(eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; } - if (!this.provider) { - return false; + } + return this._deployedPromise; + }; + BaseContract2.prototype.fallback = function(overrides) { + var _this = this; + if (!this.signer) { + logger2.throwError("sending a transactions require a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + } + var tx = (0, properties_1.shallowCopy)(overrides || {}); + ["from", "to"].forEach(function(key) { + if (tx[key] == null) { + return; } - var runningEvent = this._getRunningEvent(eventName); - var result = runningEvent.run(args) > 0; - this._checkRunningEvents(runningEvent); - return result; - }; - BaseContract2.prototype.listenerCount = function(eventName) { - var _this = this; - if (!this.provider) { - return 0; + logger2.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + tx.to = this.resolvedAddress; + return this.deployed().then(function() { + return _this.signer.sendTransaction(tx); + }); + }; + BaseContract2.prototype.connect = function(signerOrProvider) { + if (typeof signerOrProvider === "string") { + signerOrProvider = new abstract_signer_1.VoidSigner(signerOrProvider, this.provider); + } + var contract = new this.constructor(this.address, this.interface, signerOrProvider); + if (this.deployTransaction) { + (0, properties_1.defineReadOnly)(contract, "deployTransaction", this.deployTransaction); + } + return contract; + }; + BaseContract2.prototype.attach = function(addressOrName) { + return new this.constructor(addressOrName, this.interface, this.signer || this.provider); + }; + BaseContract2.isIndexed = function(value) { + return abi_1.Indexed.isIndexed(value); + }; + BaseContract2.prototype._normalizeRunningEvent = function(runningEvent) { + if (this._runningEvents[runningEvent.tag]) { + return this._runningEvents[runningEvent.tag]; + } + return runningEvent; + }; + BaseContract2.prototype._getRunningEvent = function(eventName) { + if (typeof eventName === "string") { + if (eventName === "error") { + return this._normalizeRunningEvent(new ErrorRunningEvent()); } - if (eventName == null) { - return Object.keys(this._runningEvents).reduce(function(accum, key) { - return accum + _this._runningEvents[key].listenerCount(); - }, 0); + if (eventName === "event") { + return this._normalizeRunningEvent(new RunningEvent("event", null)); } - return this._getRunningEvent(eventName).listenerCount(); - }; - BaseContract2.prototype.listeners = function(eventName) { - if (!this.provider) { - return []; + if (eventName === "*") { + return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); } - if (eventName == null) { - var result_1 = []; - for (var tag in this._runningEvents) { - this._runningEvents[tag].listeners().forEach(function(listener) { - result_1.push(listener); - }); + var fragment = this.interface.getEvent(eventName); + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); + } + if (eventName.topics && eventName.topics.length > 0) { + try { + var topic = eventName.topics[0]; + if (typeof topic !== "string") { + throw new Error("invalid topic"); } - return result_1; - } - return this._getRunningEvent(eventName).listeners(); - }; - BaseContract2.prototype.removeAllListeners = function(eventName) { - if (!this.provider) { - return this; + var fragment = this.interface.getEvent(topic); + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); + } catch (error) { } - if (eventName == null) { - for (var tag in this._runningEvents) { - var runningEvent_1 = this._runningEvents[tag]; - runningEvent_1.removeAllListeners(); - this._checkRunningEvents(runningEvent_1); - } - return this; + var filter = { + address: this.address, + topics: eventName.topics + }; + return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter)); + } + return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); + }; + BaseContract2.prototype._checkRunningEvents = function(runningEvent) { + if (runningEvent.listenerCount() === 0) { + delete this._runningEvents[runningEvent.tag]; + var emit = this._wrappedEmits[runningEvent.tag]; + if (emit && runningEvent.filter) { + this.provider.off(runningEvent.filter, emit); + delete this._wrappedEmits[runningEvent.tag]; } - var runningEvent = this._getRunningEvent(eventName); - runningEvent.removeAllListeners(); - this._checkRunningEvents(runningEvent); - return this; - }; - BaseContract2.prototype.off = function(eventName, listener) { - if (!this.provider) { - return this; + } + }; + BaseContract2.prototype._wrapEvent = function(runningEvent, log, listener) { + var _this = this; + var event = (0, properties_1.deepCopy)(log); + event.removeListener = function() { + if (!listener) { + return; } - var runningEvent = this._getRunningEvent(eventName); runningEvent.removeListener(listener); - this._checkRunningEvents(runningEvent); - return this; + _this._checkRunningEvents(runningEvent); }; - BaseContract2.prototype.removeListener = function(eventName, listener) { - return this.off(eventName, listener); + event.getBlock = function() { + return _this.provider.getBlock(log.blockHash); }; - return BaseContract2; - }() - ); - exports2.BaseContract = BaseContract; - var Contract = ( - /** @class */ - function(_super) { - __extends2(Contract2, _super); - function Contract2() { - return _super !== null && _super.apply(this, arguments) || this; - } - return Contract2; - }(BaseContract) - ); - exports2.Contract = Contract; - var ContractFactory = ( - /** @class */ - function() { - function ContractFactory2(contractInterface, bytecode, signer) { - var _newTarget = this.constructor; - var bytecodeHex = null; - if (typeof bytecode === "string") { - bytecodeHex = bytecode; - } else if ((0, bytes_1.isBytes)(bytecode)) { - bytecodeHex = (0, bytes_1.hexlify)(bytecode); - } else if (bytecode && typeof bytecode.object === "string") { - bytecodeHex = bytecode.object; - } else { - bytecodeHex = "!"; - } - if (bytecodeHex.substring(0, 2) !== "0x") { - bytecodeHex = "0x" + bytecodeHex; + event.getTransaction = function() { + return _this.provider.getTransaction(log.transactionHash); + }; + event.getTransactionReceipt = function() { + return _this.provider.getTransactionReceipt(log.transactionHash); + }; + runningEvent.prepareEvent(event); + return event; + }; + BaseContract2.prototype._addEventListener = function(runningEvent, listener, once) { + var _this = this; + if (!this.provider) { + logger2.throwError("events require a provider or a signer with a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); + } + runningEvent.addListener(listener, once); + this._runningEvents[runningEvent.tag] = runningEvent; + if (!this._wrappedEmits[runningEvent.tag]) { + var wrappedEmit = function(log) { + var event = _this._wrapEvent(runningEvent, log, listener); + if (event.decodeError == null) { + try { + var args = runningEvent.getEmit(event); + _this.emit.apply(_this, __spreadArray([runningEvent.filter], args, false)); + } catch (error) { + event.decodeError = error.error; + } + } + if (runningEvent.filter != null) { + _this.emit("event", event); + } + if (event.decodeError != null) { + _this.emit("error", event.decodeError, event); + } + }; + this._wrappedEmits[runningEvent.tag] = wrappedEmit; + if (runningEvent.filter != null) { + this.provider.on(runningEvent.filter, wrappedEmit); } - if (!(0, bytes_1.isHexString)(bytecodeHex) || bytecodeHex.length % 2) { - logger2.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + }; + BaseContract2.prototype.queryFilter = function(event, fromBlockOrBlockhash, toBlock) { + var _this = this; + var runningEvent = this._getRunningEvent(event); + var filter = (0, properties_1.shallowCopy)(runningEvent.filter); + if (typeof fromBlockOrBlockhash === "string" && (0, bytes_1.isHexString)(fromBlockOrBlockhash, 32)) { + if (toBlock != null) { + logger2.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); } - if (signer && !abstract_signer_1.Signer.isSigner(signer)) { - logger2.throwArgumentError("invalid signer", "signer", signer); + filter.blockHash = fromBlockOrBlockhash; + } else { + filter.fromBlock = fromBlockOrBlockhash != null ? fromBlockOrBlockhash : 0; + filter.toBlock = toBlock != null ? toBlock : "latest"; + } + return this.provider.getLogs(filter).then(function(logs) { + return logs.map(function(log) { + return _this._wrapEvent(runningEvent, log, null); + }); + }); + }; + BaseContract2.prototype.on = function(event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, false); + return this; + }; + BaseContract2.prototype.once = function(event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, true); + return this; + }; + BaseContract2.prototype.emit = function(eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + if (!this.provider) { + return false; + } + var runningEvent = this._getRunningEvent(eventName); + var result = runningEvent.run(args) > 0; + this._checkRunningEvents(runningEvent); + return result; + }; + BaseContract2.prototype.listenerCount = function(eventName) { + var _this = this; + if (!this.provider) { + return 0; + } + if (eventName == null) { + return Object.keys(this._runningEvents).reduce(function(accum, key) { + return accum + _this._runningEvents[key].listenerCount(); + }, 0); + } + return this._getRunningEvent(eventName).listenerCount(); + }; + BaseContract2.prototype.listeners = function(eventName) { + if (!this.provider) { + return []; + } + if (eventName == null) { + var result_1 = []; + for (var tag in this._runningEvents) { + this._runningEvents[tag].listeners().forEach(function(listener) { + result_1.push(listener); + }); } - (0, properties_1.defineReadOnly)(this, "bytecode", bytecodeHex); - (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface)); - (0, properties_1.defineReadOnly)(this, "signer", signer || null); + return result_1; } - ContractFactory2.prototype.getDeployTransaction = function() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; + return this._getRunningEvent(eventName).listeners(); + }; + BaseContract2.prototype.removeAllListeners = function(eventName) { + if (!this.provider) { + return this; + } + if (eventName == null) { + for (var tag in this._runningEvents) { + var runningEvent_1 = this._runningEvents[tag]; + runningEvent_1.removeAllListeners(); + this._checkRunningEvents(runningEvent_1); } - var tx = {}; - if (args.length === this.interface.deploy.inputs.length + 1 && typeof args[args.length - 1] === "object") { - tx = (0, properties_1.shallowCopy)(args.pop()); - for (var key in tx) { - if (!allowedTransactionKeys[key]) { - throw new Error("unknown transaction override " + key); - } + return this; + } + var runningEvent = this._getRunningEvent(eventName); + runningEvent.removeAllListeners(); + this._checkRunningEvents(runningEvent); + return this; + }; + BaseContract2.prototype.off = function(eventName, listener) { + if (!this.provider) { + return this; + } + var runningEvent = this._getRunningEvent(eventName); + runningEvent.removeListener(listener); + this._checkRunningEvents(runningEvent); + return this; + }; + BaseContract2.prototype.removeListener = function(eventName, listener) { + return this.off(eventName, listener); + }; + return BaseContract2; + }(); + exports2.BaseContract = BaseContract; + var Contract = function(_super) { + __extends(Contract2, _super); + function Contract2() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Contract2; + }(BaseContract); + exports2.Contract = Contract; + var ContractFactory = function() { + function ContractFactory2(contractInterface, bytecode, signer) { + var _newTarget = this.constructor; + var bytecodeHex = null; + if (typeof bytecode === "string") { + bytecodeHex = bytecode; + } else if ((0, bytes_1.isBytes)(bytecode)) { + bytecodeHex = (0, bytes_1.hexlify)(bytecode); + } else if (bytecode && typeof bytecode.object === "string") { + bytecodeHex = bytecode.object; + } else { + bytecodeHex = "!"; + } + if (bytecodeHex.substring(0, 2) !== "0x") { + bytecodeHex = "0x" + bytecodeHex; + } + if (!(0, bytes_1.isHexString)(bytecodeHex) || bytecodeHex.length % 2) { + logger2.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + if (signer && !abstract_signer_1.Signer.isSigner(signer)) { + logger2.throwArgumentError("invalid signer", "signer", signer); + } + (0, properties_1.defineReadOnly)(this, "bytecode", bytecodeHex); + (0, properties_1.defineReadOnly)(this, "interface", (0, properties_1.getStatic)(_newTarget, "getInterface")(contractInterface)); + (0, properties_1.defineReadOnly)(this, "signer", signer || null); + } + ContractFactory2.prototype.getDeployTransaction = function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var tx = {}; + if (args.length === this.interface.deploy.inputs.length + 1 && typeof args[args.length - 1] === "object") { + tx = (0, properties_1.shallowCopy)(args.pop()); + for (var key in tx) { + if (!allowedTransactionKeys[key]) { + throw new Error("unknown transaction override " + key); } } - ["data", "from", "to"].forEach(function(key2) { - if (tx[key2] == null) { - return; - } - logger2.throwError("cannot override " + key2, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key2 }); - }); - if (tx.value) { - var value = bignumber_1.BigNumber.from(tx.value); - if (!value.isZero() && !this.interface.deploy.payable) { - logger2.throwError("non-payable constructor cannot override value", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "overrides.value", - value: tx.value - }); - } + } + ["data", "from", "to"].forEach(function(key2) { + if (tx[key2] == null) { + return; } - logger2.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); - tx.data = (0, bytes_1.hexlify)((0, bytes_1.concat)([ - this.bytecode, - this.interface.encodeDeploy(args) - ])); - return tx; - }; - ContractFactory2.prototype.deploy = function() { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return __awaiter2(this, void 0, void 0, function() { - var overrides, params, unsignedTx, tx, address, contract; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - overrides = {}; - if (args.length === this.interface.deploy.inputs.length + 1) { - overrides = args.pop(); - } - logger2.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); - return [4, resolveAddresses(this.signer, args, this.interface.deploy.inputs)]; - case 1: - params = _a7.sent(); - params.push(overrides); - unsignedTx = this.getDeployTransaction.apply(this, params); - return [4, this.signer.sendTransaction(unsignedTx)]; - case 2: - tx = _a7.sent(); - address = (0, properties_1.getStatic)(this.constructor, "getContractAddress")(tx); - contract = (0, properties_1.getStatic)(this.constructor, "getContract")(address, this.interface, this.signer); - addContractWait(contract, tx); - (0, properties_1.defineReadOnly)(contract, "deployTransaction", tx); - return [2, contract]; - } + logger2.throwError("cannot override " + key2, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key2 }); + }); + if (tx.value) { + var value = bignumber_1.BigNumber.from(tx.value); + if (!value.isZero() && !this.interface.deploy.payable) { + logger2.throwError("non-payable constructor cannot override value", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "overrides.value", + value: tx.value }); - }); - }; - ContractFactory2.prototype.attach = function(address) { - return this.constructor.getContract(address, this.interface, this.signer); - }; - ContractFactory2.prototype.connect = function(signer) { - return new this.constructor(this.interface, this.bytecode, signer); - }; - ContractFactory2.fromSolidity = function(compilerOutput, signer) { - if (compilerOutput == null) { - logger2.throwError("missing compiler output", logger_1.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); - } - if (typeof compilerOutput === "string") { - compilerOutput = JSON.parse(compilerOutput); } - var abi = compilerOutput.abi; - var bytecode = null; - if (compilerOutput.bytecode) { - bytecode = compilerOutput.bytecode; - } else if (compilerOutput.evm && compilerOutput.evm.bytecode) { - bytecode = compilerOutput.evm.bytecode; - } - return new this(abi, bytecode, signer); - }; - ContractFactory2.getInterface = function(contractInterface) { - return Contract.getInterface(contractInterface); - }; - ContractFactory2.getContractAddress = function(tx) { - return (0, address_1.getContractAddress)(tx); - }; - ContractFactory2.getContract = function(address, contractInterface, signer) { - return new Contract(address, contractInterface, signer); - }; - return ContractFactory2; - }() - ); + } + logger2.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + tx.data = (0, bytes_1.hexlify)((0, bytes_1.concat)([ + this.bytecode, + this.interface.encodeDeploy(args) + ])); + return tx; + }; + ContractFactory2.prototype.deploy = function() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return __awaiter(this, void 0, void 0, function() { + var overrides, params, unsignedTx, tx, address, contract; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + overrides = {}; + if (args.length === this.interface.deploy.inputs.length + 1) { + overrides = args.pop(); + } + logger2.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + return [4, resolveAddresses(this.signer, args, this.interface.deploy.inputs)]; + case 1: + params = _a7.sent(); + params.push(overrides); + unsignedTx = this.getDeployTransaction.apply(this, params); + return [4, this.signer.sendTransaction(unsignedTx)]; + case 2: + tx = _a7.sent(); + address = (0, properties_1.getStatic)(this.constructor, "getContractAddress")(tx); + contract = (0, properties_1.getStatic)(this.constructor, "getContract")(address, this.interface, this.signer); + addContractWait(contract, tx); + (0, properties_1.defineReadOnly)(contract, "deployTransaction", tx); + return [2, contract]; + } + }); + }); + }; + ContractFactory2.prototype.attach = function(address) { + return this.constructor.getContract(address, this.interface, this.signer); + }; + ContractFactory2.prototype.connect = function(signer) { + return new this.constructor(this.interface, this.bytecode, signer); + }; + ContractFactory2.fromSolidity = function(compilerOutput, signer) { + if (compilerOutput == null) { + logger2.throwError("missing compiler output", logger_1.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + } + if (typeof compilerOutput === "string") { + compilerOutput = JSON.parse(compilerOutput); + } + var abi = compilerOutput.abi; + var bytecode = null; + if (compilerOutput.bytecode) { + bytecode = compilerOutput.bytecode; + } else if (compilerOutput.evm && compilerOutput.evm.bytecode) { + bytecode = compilerOutput.evm.bytecode; + } + return new this(abi, bytecode, signer); + }; + ContractFactory2.getInterface = function(contractInterface) { + return Contract.getInterface(contractInterface); + }; + ContractFactory2.getContractAddress = function(tx) { + return (0, address_1.getContractAddress)(tx); + }; + ContractFactory2.getContract = function(address, contractInterface, signer) { + return new Contract(address, contractInterface, signer); + }; + return ContractFactory2; + }(); exports2.ContractFactory = ContractFactory; } }); @@ -22890,7 +22691,6 @@ var require_lib29 = __commonJS({ _defaultProvider: ethDefaultProvider("goerli") }, kintsugi: { chainId: 1337702, name: "kintsugi" }, - // ETC (See: #351) classic: { chainId: 61, name: "classic", @@ -23169,393 +22969,387 @@ var require_formatter = __commonJS({ var logger_1 = require_lib(); var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); - var Formatter = ( - /** @class */ - function() { - function Formatter2() { - var _newTarget = this.constructor; - logger2.checkNew(_newTarget, Formatter2); - this.formats = this.getDefaultFormats(); - } - Formatter2.prototype.getDefaultFormats = function() { - var _this = this; - var formats = {}; - var address = this.address.bind(this); - var bigNumber = this.bigNumber.bind(this); - var blockTag = this.blockTag.bind(this); - var data = this.data.bind(this); - var hash = this.hash.bind(this); - var hex = this.hex.bind(this); - var number = this.number.bind(this); - var type = this.type.bind(this); - var strictData = function(v) { - return _this.data(v, true); - }; - formats.transaction = { - hash, - type, - accessList: Formatter2.allowNull(this.accessList.bind(this), null), - blockHash: Formatter2.allowNull(hash, null), - blockNumber: Formatter2.allowNull(number, null), - transactionIndex: Formatter2.allowNull(number, null), - confirmations: Formatter2.allowNull(number, null), - from: address, - // either (gasPrice) or (maxPriorityFeePerGas + maxFeePerGas) - // must be set - gasPrice: Formatter2.allowNull(bigNumber), - maxPriorityFeePerGas: Formatter2.allowNull(bigNumber), - maxFeePerGas: Formatter2.allowNull(bigNumber), - gasLimit: bigNumber, - to: Formatter2.allowNull(address, null), - value: bigNumber, - nonce: number, - data, - r: Formatter2.allowNull(this.uint256), - s: Formatter2.allowNull(this.uint256), - v: Formatter2.allowNull(number), - creates: Formatter2.allowNull(address, null), - raw: Formatter2.allowNull(data) - }; - formats.transactionRequest = { - from: Formatter2.allowNull(address), - nonce: Formatter2.allowNull(number), - gasLimit: Formatter2.allowNull(bigNumber), - gasPrice: Formatter2.allowNull(bigNumber), - maxPriorityFeePerGas: Formatter2.allowNull(bigNumber), - maxFeePerGas: Formatter2.allowNull(bigNumber), - to: Formatter2.allowNull(address), - value: Formatter2.allowNull(bigNumber), - data: Formatter2.allowNull(strictData), - type: Formatter2.allowNull(number), - accessList: Formatter2.allowNull(this.accessList.bind(this), null) - }; - formats.receiptLog = { - transactionIndex: number, - blockNumber: number, - transactionHash: hash, - address, - topics: Formatter2.arrayOf(hash), - data, - logIndex: number, - blockHash: hash - }; - formats.receipt = { - to: Formatter2.allowNull(this.address, null), - from: Formatter2.allowNull(this.address, null), - contractAddress: Formatter2.allowNull(address, null), - transactionIndex: number, - // should be allowNull(hash), but broken-EIP-658 support is handled in receipt - root: Formatter2.allowNull(hex), - gasUsed: bigNumber, - logsBloom: Formatter2.allowNull(data), - blockHash: hash, - transactionHash: hash, - logs: Formatter2.arrayOf(this.receiptLog.bind(this)), - blockNumber: number, - confirmations: Formatter2.allowNull(number, null), - cumulativeGasUsed: bigNumber, - effectiveGasPrice: Formatter2.allowNull(bigNumber), - status: Formatter2.allowNull(number), - type - }; - formats.block = { - hash, - parentHash: hash, - number, - timestamp: number, - nonce: Formatter2.allowNull(hex), - difficulty: this.difficulty.bind(this), - gasLimit: bigNumber, - gasUsed: bigNumber, - miner: address, - extraData: data, - transactions: Formatter2.allowNull(Formatter2.arrayOf(hash)), - baseFeePerGas: Formatter2.allowNull(bigNumber) - }; - formats.blockWithTransactions = (0, properties_1.shallowCopy)(formats.block); - formats.blockWithTransactions.transactions = Formatter2.allowNull(Formatter2.arrayOf(this.transactionResponse.bind(this))); - formats.filter = { - fromBlock: Formatter2.allowNull(blockTag, void 0), - toBlock: Formatter2.allowNull(blockTag, void 0), - blockHash: Formatter2.allowNull(hash, void 0), - address: Formatter2.allowNull(address, void 0), - topics: Formatter2.allowNull(this.topics.bind(this), void 0) - }; - formats.filterLog = { - blockNumber: Formatter2.allowNull(number), - blockHash: Formatter2.allowNull(hash), - transactionIndex: number, - removed: Formatter2.allowNull(this.boolean.bind(this)), - address, - data: Formatter2.allowFalsish(data, "0x"), - topics: Formatter2.arrayOf(hash), - transactionHash: hash, - logIndex: number - }; - return formats; - }; - Formatter2.prototype.accessList = function(accessList) { - return (0, transactions_1.accessListify)(accessList || []); - }; - Formatter2.prototype.number = function(number) { - if (number === "0x") { - return 0; - } - return bignumber_1.BigNumber.from(number).toNumber(); - }; - Formatter2.prototype.type = function(number) { - if (number === "0x" || number == null) { - return 0; + var Formatter = function() { + function Formatter2() { + var _newTarget = this.constructor; + logger2.checkNew(_newTarget, Formatter2); + this.formats = this.getDefaultFormats(); + } + Formatter2.prototype.getDefaultFormats = function() { + var _this = this; + var formats = {}; + var address = this.address.bind(this); + var bigNumber = this.bigNumber.bind(this); + var blockTag = this.blockTag.bind(this); + var data = this.data.bind(this); + var hash = this.hash.bind(this); + var hex = this.hex.bind(this); + var number = this.number.bind(this); + var type = this.type.bind(this); + var strictData = function(v) { + return _this.data(v, true); + }; + formats.transaction = { + hash, + type, + accessList: Formatter2.allowNull(this.accessList.bind(this), null), + blockHash: Formatter2.allowNull(hash, null), + blockNumber: Formatter2.allowNull(number, null), + transactionIndex: Formatter2.allowNull(number, null), + confirmations: Formatter2.allowNull(number, null), + from: address, + gasPrice: Formatter2.allowNull(bigNumber), + maxPriorityFeePerGas: Formatter2.allowNull(bigNumber), + maxFeePerGas: Formatter2.allowNull(bigNumber), + gasLimit: bigNumber, + to: Formatter2.allowNull(address, null), + value: bigNumber, + nonce: number, + data, + r: Formatter2.allowNull(this.uint256), + s: Formatter2.allowNull(this.uint256), + v: Formatter2.allowNull(number), + creates: Formatter2.allowNull(address, null), + raw: Formatter2.allowNull(data) + }; + formats.transactionRequest = { + from: Formatter2.allowNull(address), + nonce: Formatter2.allowNull(number), + gasLimit: Formatter2.allowNull(bigNumber), + gasPrice: Formatter2.allowNull(bigNumber), + maxPriorityFeePerGas: Formatter2.allowNull(bigNumber), + maxFeePerGas: Formatter2.allowNull(bigNumber), + to: Formatter2.allowNull(address), + value: Formatter2.allowNull(bigNumber), + data: Formatter2.allowNull(strictData), + type: Formatter2.allowNull(number), + accessList: Formatter2.allowNull(this.accessList.bind(this), null) + }; + formats.receiptLog = { + transactionIndex: number, + blockNumber: number, + transactionHash: hash, + address, + topics: Formatter2.arrayOf(hash), + data, + logIndex: number, + blockHash: hash + }; + formats.receipt = { + to: Formatter2.allowNull(this.address, null), + from: Formatter2.allowNull(this.address, null), + contractAddress: Formatter2.allowNull(address, null), + transactionIndex: number, + root: Formatter2.allowNull(hex), + gasUsed: bigNumber, + logsBloom: Formatter2.allowNull(data), + blockHash: hash, + transactionHash: hash, + logs: Formatter2.arrayOf(this.receiptLog.bind(this)), + blockNumber: number, + confirmations: Formatter2.allowNull(number, null), + cumulativeGasUsed: bigNumber, + effectiveGasPrice: Formatter2.allowNull(bigNumber), + status: Formatter2.allowNull(number), + type + }; + formats.block = { + hash, + parentHash: hash, + number, + timestamp: number, + nonce: Formatter2.allowNull(hex), + difficulty: this.difficulty.bind(this), + gasLimit: bigNumber, + gasUsed: bigNumber, + miner: address, + extraData: data, + transactions: Formatter2.allowNull(Formatter2.arrayOf(hash)), + baseFeePerGas: Formatter2.allowNull(bigNumber) + }; + formats.blockWithTransactions = (0, properties_1.shallowCopy)(formats.block); + formats.blockWithTransactions.transactions = Formatter2.allowNull(Formatter2.arrayOf(this.transactionResponse.bind(this))); + formats.filter = { + fromBlock: Formatter2.allowNull(blockTag, void 0), + toBlock: Formatter2.allowNull(blockTag, void 0), + blockHash: Formatter2.allowNull(hash, void 0), + address: Formatter2.allowNull(address, void 0), + topics: Formatter2.allowNull(this.topics.bind(this), void 0) + }; + formats.filterLog = { + blockNumber: Formatter2.allowNull(number), + blockHash: Formatter2.allowNull(hash), + transactionIndex: number, + removed: Formatter2.allowNull(this.boolean.bind(this)), + address, + data: Formatter2.allowFalsish(data, "0x"), + topics: Formatter2.arrayOf(hash), + transactionHash: hash, + logIndex: number + }; + return formats; + }; + Formatter2.prototype.accessList = function(accessList) { + return (0, transactions_1.accessListify)(accessList || []); + }; + Formatter2.prototype.number = function(number) { + if (number === "0x") { + return 0; + } + return bignumber_1.BigNumber.from(number).toNumber(); + }; + Formatter2.prototype.type = function(number) { + if (number === "0x" || number == null) { + return 0; + } + return bignumber_1.BigNumber.from(number).toNumber(); + }; + Formatter2.prototype.bigNumber = function(value) { + return bignumber_1.BigNumber.from(value); + }; + Formatter2.prototype.boolean = function(value) { + if (typeof value === "boolean") { + return value; + } + if (typeof value === "string") { + value = value.toLowerCase(); + if (value === "true") { + return true; } - return bignumber_1.BigNumber.from(number).toNumber(); - }; - Formatter2.prototype.bigNumber = function(value) { - return bignumber_1.BigNumber.from(value); - }; - Formatter2.prototype.boolean = function(value) { - if (typeof value === "boolean") { - return value; + if (value === "false") { + return false; } - if (typeof value === "string") { - value = value.toLowerCase(); - if (value === "true") { - return true; - } - if (value === "false") { - return false; - } + } + throw new Error("invalid boolean - " + value); + }; + Formatter2.prototype.hex = function(value, strict) { + if (typeof value === "string") { + if (!strict && value.substring(0, 2) !== "0x") { + value = "0x" + value; } - throw new Error("invalid boolean - " + value); - }; - Formatter2.prototype.hex = function(value, strict) { - if (typeof value === "string") { - if (!strict && value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - if ((0, bytes_1.isHexString)(value)) { - return value.toLowerCase(); - } + if ((0, bytes_1.isHexString)(value)) { + return value.toLowerCase(); } + } + return logger2.throwArgumentError("invalid hash", "value", value); + }; + Formatter2.prototype.data = function(value, strict) { + var result = this.hex(value, strict); + if (result.length % 2 !== 0) { + throw new Error("invalid data; odd-length - " + value); + } + return result; + }; + Formatter2.prototype.address = function(value) { + return (0, address_1.getAddress)(value); + }; + Formatter2.prototype.callAddress = function(value) { + if (!(0, bytes_1.isHexString)(value, 32)) { + return null; + } + var address = (0, address_1.getAddress)((0, bytes_1.hexDataSlice)(value, 12)); + return address === constants_1.AddressZero ? null : address; + }; + Formatter2.prototype.contractAddress = function(value) { + return (0, address_1.getContractAddress)(value); + }; + Formatter2.prototype.blockTag = function(blockTag) { + if (blockTag == null) { + return "latest"; + } + if (blockTag === "earliest") { + return "0x0"; + } + if (blockTag === "latest" || blockTag === "pending") { + return blockTag; + } + if (typeof blockTag === "number" || (0, bytes_1.isHexString)(blockTag)) { + return (0, bytes_1.hexValue)(blockTag); + } + throw new Error("invalid blockTag"); + }; + Formatter2.prototype.hash = function(value, strict) { + var result = this.hex(value, strict); + if ((0, bytes_1.hexDataLength)(result) !== 32) { return logger2.throwArgumentError("invalid hash", "value", value); - }; - Formatter2.prototype.data = function(value, strict) { - var result = this.hex(value, strict); - if (result.length % 2 !== 0) { - throw new Error("invalid data; odd-length - " + value); - } - return result; - }; - Formatter2.prototype.address = function(value) { - return (0, address_1.getAddress)(value); - }; - Formatter2.prototype.callAddress = function(value) { - if (!(0, bytes_1.isHexString)(value, 32)) { - return null; - } - var address = (0, address_1.getAddress)((0, bytes_1.hexDataSlice)(value, 12)); - return address === constants_1.AddressZero ? null : address; - }; - Formatter2.prototype.contractAddress = function(value) { - return (0, address_1.getContractAddress)(value); - }; - Formatter2.prototype.blockTag = function(blockTag) { - if (blockTag == null) { - return "latest"; - } - if (blockTag === "earliest") { - return "0x0"; - } - if (blockTag === "latest" || blockTag === "pending") { - return blockTag; - } - if (typeof blockTag === "number" || (0, bytes_1.isHexString)(blockTag)) { - return (0, bytes_1.hexValue)(blockTag); - } - throw new Error("invalid blockTag"); - }; - Formatter2.prototype.hash = function(value, strict) { - var result = this.hex(value, strict); - if ((0, bytes_1.hexDataLength)(result) !== 32) { - return logger2.throwArgumentError("invalid hash", "value", value); - } - return result; - }; - Formatter2.prototype.difficulty = function(value) { - if (value == null) { - return null; - } - var v = bignumber_1.BigNumber.from(value); - try { - return v.toNumber(); - } catch (error) { - } + } + return result; + }; + Formatter2.prototype.difficulty = function(value) { + if (value == null) { return null; - }; - Formatter2.prototype.uint256 = function(value) { - if (!(0, bytes_1.isHexString)(value)) { - throw new Error("invalid uint256"); - } - return (0, bytes_1.hexZeroPad)(value, 32); - }; - Formatter2.prototype._block = function(value, format) { - if (value.author != null && value.miner == null) { - value.miner = value.author; - } - var difficulty = value._difficulty != null ? value._difficulty : value.difficulty; - var result = Formatter2.check(format, value); - result._difficulty = difficulty == null ? null : bignumber_1.BigNumber.from(difficulty); - return result; - }; - Formatter2.prototype.block = function(value) { - return this._block(value, this.formats.block); - }; - Formatter2.prototype.blockWithTransactions = function(value) { - return this._block(value, this.formats.blockWithTransactions); - }; - Formatter2.prototype.transactionRequest = function(value) { - return Formatter2.check(this.formats.transactionRequest, value); - }; - Formatter2.prototype.transactionResponse = function(transaction) { - if (transaction.gas != null && transaction.gasLimit == null) { - transaction.gasLimit = transaction.gas; - } - if (transaction.to && bignumber_1.BigNumber.from(transaction.to).isZero()) { - transaction.to = "0x0000000000000000000000000000000000000000"; - } - if (transaction.input != null && transaction.data == null) { - transaction.data = transaction.input; + } + var v = bignumber_1.BigNumber.from(value); + try { + return v.toNumber(); + } catch (error) { + } + return null; + }; + Formatter2.prototype.uint256 = function(value) { + if (!(0, bytes_1.isHexString)(value)) { + throw new Error("invalid uint256"); + } + return (0, bytes_1.hexZeroPad)(value, 32); + }; + Formatter2.prototype._block = function(value, format) { + if (value.author != null && value.miner == null) { + value.miner = value.author; + } + var difficulty = value._difficulty != null ? value._difficulty : value.difficulty; + var result = Formatter2.check(format, value); + result._difficulty = difficulty == null ? null : bignumber_1.BigNumber.from(difficulty); + return result; + }; + Formatter2.prototype.block = function(value) { + return this._block(value, this.formats.block); + }; + Formatter2.prototype.blockWithTransactions = function(value) { + return this._block(value, this.formats.blockWithTransactions); + }; + Formatter2.prototype.transactionRequest = function(value) { + return Formatter2.check(this.formats.transactionRequest, value); + }; + Formatter2.prototype.transactionResponse = function(transaction) { + if (transaction.gas != null && transaction.gasLimit == null) { + transaction.gasLimit = transaction.gas; + } + if (transaction.to && bignumber_1.BigNumber.from(transaction.to).isZero()) { + transaction.to = "0x0000000000000000000000000000000000000000"; + } + if (transaction.input != null && transaction.data == null) { + transaction.data = transaction.input; + } + if (transaction.to == null && transaction.creates == null) { + transaction.creates = this.contractAddress(transaction); + } + if ((transaction.type === 1 || transaction.type === 2) && transaction.accessList == null) { + transaction.accessList = []; + } + var result = Formatter2.check(this.formats.transaction, transaction); + if (transaction.chainId != null) { + var chainId = transaction.chainId; + if ((0, bytes_1.isHexString)(chainId)) { + chainId = bignumber_1.BigNumber.from(chainId).toNumber(); } - if (transaction.to == null && transaction.creates == null) { - transaction.creates = this.contractAddress(transaction); + result.chainId = chainId; + } else { + var chainId = transaction.networkId; + if (chainId == null && result.v == null) { + chainId = transaction.chainId; } - if ((transaction.type === 1 || transaction.type === 2) && transaction.accessList == null) { - transaction.accessList = []; + if ((0, bytes_1.isHexString)(chainId)) { + chainId = bignumber_1.BigNumber.from(chainId).toNumber(); } - var result = Formatter2.check(this.formats.transaction, transaction); - if (transaction.chainId != null) { - var chainId = transaction.chainId; - if ((0, bytes_1.isHexString)(chainId)) { - chainId = bignumber_1.BigNumber.from(chainId).toNumber(); - } - result.chainId = chainId; - } else { - var chainId = transaction.networkId; - if (chainId == null && result.v == null) { - chainId = transaction.chainId; - } - if ((0, bytes_1.isHexString)(chainId)) { - chainId = bignumber_1.BigNumber.from(chainId).toNumber(); - } - if (typeof chainId !== "number" && result.v != null) { - chainId = (result.v - 35) / 2; - if (chainId < 0) { - chainId = 0; - } - chainId = parseInt(chainId); - } - if (typeof chainId !== "number") { + if (typeof chainId !== "number" && result.v != null) { + chainId = (result.v - 35) / 2; + if (chainId < 0) { chainId = 0; } - result.chainId = chainId; + chainId = parseInt(chainId); } - if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { - result.blockHash = null; + if (typeof chainId !== "number") { + chainId = 0; } - return result; - }; - Formatter2.prototype.transaction = function(value) { - return (0, transactions_1.parse)(value); - }; - Formatter2.prototype.receiptLog = function(value) { - return Formatter2.check(this.formats.receiptLog, value); - }; - Formatter2.prototype.receipt = function(value) { - var result = Formatter2.check(this.formats.receipt, value); - if (result.root != null) { - if (result.root.length <= 4) { - var value_1 = bignumber_1.BigNumber.from(result.root).toNumber(); - if (value_1 === 0 || value_1 === 1) { - if (result.status != null && result.status !== value_1) { - logger2.throwArgumentError("alt-root-status/status mismatch", "value", { root: result.root, status: result.status }); - } - result.status = value_1; - delete result.root; - } else { - logger2.throwArgumentError("invalid alt-root-status", "value.root", result.root); + result.chainId = chainId; + } + if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { + result.blockHash = null; + } + return result; + }; + Formatter2.prototype.transaction = function(value) { + return (0, transactions_1.parse)(value); + }; + Formatter2.prototype.receiptLog = function(value) { + return Formatter2.check(this.formats.receiptLog, value); + }; + Formatter2.prototype.receipt = function(value) { + var result = Formatter2.check(this.formats.receipt, value); + if (result.root != null) { + if (result.root.length <= 4) { + var value_1 = bignumber_1.BigNumber.from(result.root).toNumber(); + if (value_1 === 0 || value_1 === 1) { + if (result.status != null && result.status !== value_1) { + logger2.throwArgumentError("alt-root-status/status mismatch", "value", { root: result.root, status: result.status }); } - } else if (result.root.length !== 66) { - logger2.throwArgumentError("invalid root hash", "value.root", result.root); + result.status = value_1; + delete result.root; + } else { + logger2.throwArgumentError("invalid alt-root-status", "value.root", result.root); } + } else if (result.root.length !== 66) { + logger2.throwArgumentError("invalid root hash", "value.root", result.root); } - if (result.status != null) { - result.byzantium = true; + } + if (result.status != null) { + result.byzantium = true; + } + return result; + }; + Formatter2.prototype.topics = function(value) { + var _this = this; + if (Array.isArray(value)) { + return value.map(function(v) { + return _this.topics(v); + }); + } else if (value != null) { + return this.hash(value, true); + } + return null; + }; + Formatter2.prototype.filter = function(value) { + return Formatter2.check(this.formats.filter, value); + }; + Formatter2.prototype.filterLog = function(value) { + return Formatter2.check(this.formats.filterLog, value); + }; + Formatter2.check = function(format, object) { + var result = {}; + for (var key in format) { + try { + var value = format[key](object[key]); + if (value !== void 0) { + result[key] = value; + } + } catch (error) { + error.checkKey = key; + error.checkValue = object[key]; + throw error; } - return result; - }; - Formatter2.prototype.topics = function(value) { - var _this = this; - if (Array.isArray(value)) { - return value.map(function(v) { - return _this.topics(v); - }); - } else if (value != null) { - return this.hash(value, true); + } + return result; + }; + Formatter2.allowNull = function(format, nullValue) { + return function(value) { + if (value == null) { + return nullValue; } - return null; - }; - Formatter2.prototype.filter = function(value) { - return Formatter2.check(this.formats.filter, value); + return format(value); }; - Formatter2.prototype.filterLog = function(value) { - return Formatter2.check(this.formats.filterLog, value); + }; + Formatter2.allowFalsish = function(format, replaceValue) { + return function(value) { + if (!value) { + return replaceValue; + } + return format(value); }; - Formatter2.check = function(format, object) { - var result = {}; - for (var key in format) { - try { - var value = format[key](object[key]); - if (value !== void 0) { - result[key] = value; - } - } catch (error) { - error.checkKey = key; - error.checkValue = object[key]; - throw error; - } + }; + Formatter2.arrayOf = function(format) { + return function(array) { + if (!Array.isArray(array)) { + throw new Error("not an array"); } + var result = []; + array.forEach(function(value) { + result.push(format(value)); + }); return result; }; - Formatter2.allowNull = function(format, nullValue) { - return function(value) { - if (value == null) { - return nullValue; - } - return format(value); - }; - }; - Formatter2.allowFalsish = function(format, replaceValue) { - return function(value) { - if (!value) { - return replaceValue; - } - return format(value); - }; - }; - Formatter2.arrayOf = function(format) { - return function(array) { - if (!Array.isArray(array)) { - throw new Error("not an array"); - } - var result = []; - array.forEach(function(value) { - result.push(format(value)); - }); - return result; - }; - }; - return Formatter2; - }() - ); + }; + return Formatter2; + }(); exports2.Formatter = Formatter; function isCommunityResourcable(value) { return value && typeof value.isCommunityResource === "function"; @@ -23592,28 +23386,28 @@ var require_formatter = __commonJS({ var require_base_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/base-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -23640,7 +23434,7 @@ var require_base_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -23716,7 +23510,7 @@ var require_base_provider = __commonJS({ return { value: op[0] ? op[1] : void 0, done: true }; } }; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); @@ -23732,7 +23526,7 @@ var require_base_provider = __commonJS({ var sha2_1 = require_lib16(); var strings_1 = require_lib9(); var web_1 = require_lib27(); - var bech32_1 = __importDefault2(require_bech32()); + var bech32_1 = __importDefault(require_bech32()); var logger_1 = require_lib(); var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); @@ -23799,7 +23593,7 @@ var require_base_provider = __commonJS({ throw new Error("invalid event - " + eventName); } function getTime() { - return (/* @__PURE__ */ new Date()).getTime(); + return new Date().getTime(); } function stall(duration) { return new Promise(function(resolve) { @@ -23807,71 +23601,68 @@ var require_base_provider = __commonJS({ }); } var PollableEvents = ["block", "network", "pending", "poll"]; - var Event = ( - /** @class */ - function() { - function Event2(tag, listener, once) { - (0, properties_1.defineReadOnly)(this, "tag", tag); - (0, properties_1.defineReadOnly)(this, "listener", listener); - (0, properties_1.defineReadOnly)(this, "once", once); - } - Object.defineProperty(Event2.prototype, "event", { - get: function() { - switch (this.type) { - case "tx": - return this.hash; - case "filter": - return this.filter; - } - return this.tag; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Event2.prototype, "type", { - get: function() { - return this.tag.split(":")[0]; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Event2.prototype, "hash", { - get: function() { - var comps = this.tag.split(":"); - if (comps[0] !== "tx") { - return null; - } - return comps[1]; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(Event2.prototype, "filter", { - get: function() { - var comps = this.tag.split(":"); - if (comps[0] !== "filter") { - return null; - } - var address = comps[1]; - var topics = deserializeTopics(comps[2]); - var filter = {}; - if (topics.length > 0) { - filter.topics = topics; - } - if (address && address !== "*") { - filter.address = address; - } - return filter; - }, - enumerable: false, - configurable: true - }); - Event2.prototype.pollable = function() { - return this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0; - }; - return Event2; - }() - ); + var Event = function() { + function Event2(tag, listener, once) { + (0, properties_1.defineReadOnly)(this, "tag", tag); + (0, properties_1.defineReadOnly)(this, "listener", listener); + (0, properties_1.defineReadOnly)(this, "once", once); + } + Object.defineProperty(Event2.prototype, "event", { + get: function() { + switch (this.type) { + case "tx": + return this.hash; + case "filter": + return this.filter; + } + return this.tag; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Event2.prototype, "type", { + get: function() { + return this.tag.split(":")[0]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Event2.prototype, "hash", { + get: function() { + var comps = this.tag.split(":"); + if (comps[0] !== "tx") { + return null; + } + return comps[1]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Event2.prototype, "filter", { + get: function() { + var comps = this.tag.split(":"); + if (comps[0] !== "filter") { + return null; + } + var address = comps[1]; + var topics = deserializeTopics(comps[2]); + var filter = {}; + if (topics.length > 0) { + filter.topics = topics; + } + if (address && address !== "*") { + filter.address = address; + } + return filter; + }, + enumerable: false, + configurable: true + }); + Event2.prototype.pollable = function() { + return this.tag.indexOf(":") >= 0 || PollableEvents.indexOf(this.tag) >= 0; + }; + return Event2; + }(); exports2.Event = Event; var coinInfos = { "0": { symbol: "btc", p2pkh: 0, p2sh: 5, prefix: "bc" }, @@ -23919,2100 +23710,2016 @@ var require_base_provider = __commonJS({ } return "https://gateway.ipfs.io/ipfs/" + link; } - var Resolver = ( - /** @class */ - function() { - function Resolver2(provider, address, name2, resolvedAddress) { - (0, properties_1.defineReadOnly)(this, "provider", provider); - (0, properties_1.defineReadOnly)(this, "name", name2); - (0, properties_1.defineReadOnly)(this, "address", provider.formatter.address(address)); - (0, properties_1.defineReadOnly)(this, "_resolvedAddress", resolvedAddress); - } - Resolver2.prototype._fetchBytes = function(selector, parameters) { - return __awaiter2(this, void 0, void 0, function() { - var tx, _a7, error_1; - return __generator2(this, function(_b) { - switch (_b.label) { - case 0: - tx = { - to: this.address, - data: (0, bytes_1.hexConcat)([selector, (0, hash_1.namehash)(this.name), parameters || "0x"]) - }; - _b.label = 1; - case 1: - _b.trys.push([1, 3, , 4]); - _a7 = _parseBytes; - return [4, this.provider.call(tx)]; - case 2: - return [2, _a7.apply(void 0, [_b.sent()])]; - case 3: - error_1 = _b.sent(); - if (error_1.code === logger_1.Logger.errors.CALL_EXCEPTION) { - return [2, null]; - } + var Resolver = function() { + function Resolver2(provider, address, name2, resolvedAddress) { + (0, properties_1.defineReadOnly)(this, "provider", provider); + (0, properties_1.defineReadOnly)(this, "name", name2); + (0, properties_1.defineReadOnly)(this, "address", provider.formatter.address(address)); + (0, properties_1.defineReadOnly)(this, "_resolvedAddress", resolvedAddress); + } + Resolver2.prototype._fetchBytes = function(selector, parameters) { + return __awaiter(this, void 0, void 0, function() { + var tx, _a7, error_1; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + tx = { + to: this.address, + data: (0, bytes_1.hexConcat)([selector, (0, hash_1.namehash)(this.name), parameters || "0x"]) + }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + _a7 = _parseBytes; + return [4, this.provider.call(tx)]; + case 2: + return [2, _a7.apply(void 0, [_b.sent()])]; + case 3: + error_1 = _b.sent(); + if (error_1.code === logger_1.Logger.errors.CALL_EXCEPTION) { return [2, null]; - case 4: - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2, null]; + case 4: + return [2]; + } }); - }; - Resolver2.prototype._getAddress = function(coinType, hexBytes) { - var coinInfo = coinInfos[String(coinType)]; - if (coinInfo == null) { - logger2.throwError("unsupported coin type: " + coinType, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "getAddress(" + coinType + ")" - }); - } - if (coinInfo.ilk === "eth") { - return this.provider.formatter.address(hexBytes); - } - var bytes = (0, bytes_1.arrayify)(hexBytes); - if (coinInfo.p2pkh != null) { - var p2pkh = hexBytes.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/); - if (p2pkh) { - var length_1 = parseInt(p2pkh[1], 16); - if (p2pkh[2].length === length_1 * 2 && length_1 >= 1 && length_1 <= 75) { - return base58Encode((0, bytes_1.concat)([[coinInfo.p2pkh], "0x" + p2pkh[2]])); - } + }); + }; + Resolver2.prototype._getAddress = function(coinType, hexBytes) { + var coinInfo = coinInfos[String(coinType)]; + if (coinInfo == null) { + logger2.throwError("unsupported coin type: " + coinType, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getAddress(" + coinType + ")" + }); + } + if (coinInfo.ilk === "eth") { + return this.provider.formatter.address(hexBytes); + } + var bytes = (0, bytes_1.arrayify)(hexBytes); + if (coinInfo.p2pkh != null) { + var p2pkh = hexBytes.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/); + if (p2pkh) { + var length_1 = parseInt(p2pkh[1], 16); + if (p2pkh[2].length === length_1 * 2 && length_1 >= 1 && length_1 <= 75) { + return base58Encode((0, bytes_1.concat)([[coinInfo.p2pkh], "0x" + p2pkh[2]])); } } - if (coinInfo.p2sh != null) { - var p2sh = hexBytes.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/); - if (p2sh) { - var length_2 = parseInt(p2sh[1], 16); - if (p2sh[2].length === length_2 * 2 && length_2 >= 1 && length_2 <= 75) { - return base58Encode((0, bytes_1.concat)([[coinInfo.p2sh], "0x" + p2sh[2]])); - } + } + if (coinInfo.p2sh != null) { + var p2sh = hexBytes.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/); + if (p2sh) { + var length_2 = parseInt(p2sh[1], 16); + if (p2sh[2].length === length_2 * 2 && length_2 >= 1 && length_2 <= 75) { + return base58Encode((0, bytes_1.concat)([[coinInfo.p2sh], "0x" + p2sh[2]])); } } - if (coinInfo.prefix != null) { - var length_3 = bytes[1]; - var version_1 = bytes[0]; - if (version_1 === 0) { - if (length_3 !== 20 && length_3 !== 32) { - version_1 = -1; - } - } else { + } + if (coinInfo.prefix != null) { + var length_3 = bytes[1]; + var version_1 = bytes[0]; + if (version_1 === 0) { + if (length_3 !== 20 && length_3 !== 32) { version_1 = -1; } - if (version_1 >= 0 && bytes.length === 2 + length_3 && length_3 >= 1 && length_3 <= 75) { - var words = bech32_1.default.toWords(bytes.slice(2)); - words.unshift(version_1); - return bech32_1.default.encode(coinInfo.prefix, words); - } + } else { + version_1 = -1; } - return null; - }; - Resolver2.prototype.getAddress = function(coinType) { - return __awaiter2(this, void 0, void 0, function() { - var transaction, hexBytes_1, error_2, hexBytes, address; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (coinType == null) { - coinType = 60; - } - if (!(coinType === 60)) - return [3, 4]; - _a7.label = 1; - case 1: - _a7.trys.push([1, 3, , 4]); - transaction = { - to: this.address, - data: "0x3b3b57de" + (0, hash_1.namehash)(this.name).substring(2) - }; - return [4, this.provider.call(transaction)]; - case 2: - hexBytes_1 = _a7.sent(); - if (hexBytes_1 === "0x" || hexBytes_1 === constants_1.HashZero) { - return [2, null]; - } - return [2, this.provider.formatter.callAddress(hexBytes_1)]; - case 3: - error_2 = _a7.sent(); - if (error_2.code === logger_1.Logger.errors.CALL_EXCEPTION) { - return [2, null]; - } - throw error_2; - case 4: - return [4, this._fetchBytes("0xf1cb7e06", bytes32ify(coinType))]; - case 5: - hexBytes = _a7.sent(); - if (hexBytes == null || hexBytes === "0x") { - return [2, null]; - } - address = this._getAddress(coinType, hexBytes); - if (address == null) { - logger2.throwError("invalid or unsupported coin data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "getAddress(" + coinType + ")", - coinType, - data: hexBytes - }); - } - return [2, address]; - } - }); + if (version_1 >= 0 && bytes.length === 2 + length_3 && length_3 >= 1 && length_3 <= 75) { + var words = bech32_1.default.toWords(bytes.slice(2)); + words.unshift(version_1); + return bech32_1.default.encode(coinInfo.prefix, words); + } + } + return null; + }; + Resolver2.prototype.getAddress = function(coinType) { + return __awaiter(this, void 0, void 0, function() { + var transaction, hexBytes_1, error_2, hexBytes, address; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (coinType == null) { + coinType = 60; + } + if (!(coinType === 60)) + return [3, 4]; + _a7.label = 1; + case 1: + _a7.trys.push([1, 3, , 4]); + transaction = { + to: this.address, + data: "0x3b3b57de" + (0, hash_1.namehash)(this.name).substring(2) + }; + return [4, this.provider.call(transaction)]; + case 2: + hexBytes_1 = _a7.sent(); + if (hexBytes_1 === "0x" || hexBytes_1 === constants_1.HashZero) { + return [2, null]; + } + return [2, this.provider.formatter.callAddress(hexBytes_1)]; + case 3: + error_2 = _a7.sent(); + if (error_2.code === logger_1.Logger.errors.CALL_EXCEPTION) { + return [2, null]; + } + throw error_2; + case 4: + return [4, this._fetchBytes("0xf1cb7e06", bytes32ify(coinType))]; + case 5: + hexBytes = _a7.sent(); + if (hexBytes == null || hexBytes === "0x") { + return [2, null]; + } + address = this._getAddress(coinType, hexBytes); + if (address == null) { + logger2.throwError("invalid or unsupported coin data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getAddress(" + coinType + ")", + coinType, + data: hexBytes + }); + } + return [2, address]; + } }); - }; - Resolver2.prototype.getAvatar = function() { - return __awaiter2(this, void 0, void 0, function() { - var linkage, avatar, i, match, scheme, _a7, selector, owner, _b, comps, addr, tokenId, tokenOwner, _c, _d, balance, _e, _f, tx, metadataUrl, _g, metadata, imageUrl, ipfs, error_3; - return __generator2(this, function(_h) { - switch (_h.label) { - case 0: - linkage = [{ type: "name", content: this.name }]; - _h.label = 1; - case 1: - _h.trys.push([1, 19, , 20]); - return [4, this.getText("avatar")]; - case 2: - avatar = _h.sent(); - if (avatar == null) { - return [2, null]; - } - i = 0; - _h.label = 3; - case 3: - if (!(i < matchers.length)) - return [3, 18]; - match = avatar.match(matchers[i]); - if (match == null) { - return [3, 17]; - } - scheme = match[1].toLowerCase(); - _a7 = scheme; - switch (_a7) { - case "https": - return [3, 4]; - case "data": - return [3, 5]; - case "ipfs": - return [3, 6]; - case "erc721": - return [3, 7]; - case "erc1155": - return [3, 7]; - } + }); + }; + Resolver2.prototype.getAvatar = function() { + return __awaiter(this, void 0, void 0, function() { + var linkage, avatar, i, match, scheme, _a7, selector, owner, _b, comps, addr, tokenId, tokenOwner, _c, _d, balance, _e, _f, tx, metadataUrl, _g, metadata, imageUrl, ipfs, error_3; + return __generator(this, function(_h) { + switch (_h.label) { + case 0: + linkage = [{ type: "name", content: this.name }]; + _h.label = 1; + case 1: + _h.trys.push([1, 19, , 20]); + return [4, this.getText("avatar")]; + case 2: + avatar = _h.sent(); + if (avatar == null) { + return [2, null]; + } + i = 0; + _h.label = 3; + case 3: + if (!(i < matchers.length)) + return [3, 18]; + match = avatar.match(matchers[i]); + if (match == null) { return [3, 17]; - case 4: - linkage.push({ type: "url", content: avatar }); - return [2, { linkage, url: avatar }]; - case 5: - linkage.push({ type: "data", content: avatar }); - return [2, { linkage, url: avatar }]; - case 6: - linkage.push({ type: "ipfs", content: avatar }); - return [2, { linkage, url: getIpfsLink(avatar) }]; - case 7: - selector = scheme === "erc721" ? "0xc87b56dd" : "0x0e89341c"; - linkage.push({ type: scheme, content: avatar }); - _b = this._resolvedAddress; - if (_b) - return [3, 9]; - return [4, this.getAddress()]; - case 8: - _b = _h.sent(); - _h.label = 9; - case 9: - owner = _b; - comps = (match[2] || "").split("/"); - if (comps.length !== 2) { - return [2, null]; - } - return [4, this.provider.formatter.address(comps[0])]; - case 10: - addr = _h.sent(); - tokenId = (0, bytes_1.hexZeroPad)(bignumber_1.BigNumber.from(comps[1]).toHexString(), 32); - if (!(scheme === "erc721")) - return [3, 12]; - _d = (_c = this.provider.formatter).callAddress; - return [4, this.provider.call({ - to: addr, - data: (0, bytes_1.hexConcat)(["0x6352211e", tokenId]) - })]; - case 11: - tokenOwner = _d.apply(_c, [_h.sent()]); - if (owner !== tokenOwner) { - return [2, null]; - } - linkage.push({ type: "owner", content: tokenOwner }); + } + scheme = match[1].toLowerCase(); + _a7 = scheme; + switch (_a7) { + case "https": + return [3, 4]; + case "data": + return [3, 5]; + case "ipfs": + return [3, 6]; + case "erc721": + return [3, 7]; + case "erc1155": + return [3, 7]; + } + return [3, 17]; + case 4: + linkage.push({ type: "url", content: avatar }); + return [2, { linkage, url: avatar }]; + case 5: + linkage.push({ type: "data", content: avatar }); + return [2, { linkage, url: avatar }]; + case 6: + linkage.push({ type: "ipfs", content: avatar }); + return [2, { linkage, url: getIpfsLink(avatar) }]; + case 7: + selector = scheme === "erc721" ? "0xc87b56dd" : "0x0e89341c"; + linkage.push({ type: scheme, content: avatar }); + _b = this._resolvedAddress; + if (_b) + return [3, 9]; + return [4, this.getAddress()]; + case 8: + _b = _h.sent(); + _h.label = 9; + case 9: + owner = _b; + comps = (match[2] || "").split("/"); + if (comps.length !== 2) { + return [2, null]; + } + return [4, this.provider.formatter.address(comps[0])]; + case 10: + addr = _h.sent(); + tokenId = (0, bytes_1.hexZeroPad)(bignumber_1.BigNumber.from(comps[1]).toHexString(), 32); + if (!(scheme === "erc721")) + return [3, 12]; + _d = (_c = this.provider.formatter).callAddress; + return [4, this.provider.call({ + to: addr, + data: (0, bytes_1.hexConcat)(["0x6352211e", tokenId]) + })]; + case 11: + tokenOwner = _d.apply(_c, [_h.sent()]); + if (owner !== tokenOwner) { + return [2, null]; + } + linkage.push({ type: "owner", content: tokenOwner }); + return [3, 14]; + case 12: + if (!(scheme === "erc1155")) return [3, 14]; - case 12: - if (!(scheme === "erc1155")) - return [3, 14]; - _f = (_e = bignumber_1.BigNumber).from; - return [4, this.provider.call({ - to: addr, - data: (0, bytes_1.hexConcat)(["0x00fdd58e", (0, bytes_1.hexZeroPad)(owner, 32), tokenId]) - })]; - case 13: - balance = _f.apply(_e, [_h.sent()]); - if (balance.isZero()) { - return [2, null]; - } - linkage.push({ type: "balance", content: balance.toString() }); - _h.label = 14; - case 14: - tx = { - to: this.provider.formatter.address(comps[0]), - data: (0, bytes_1.hexConcat)([selector, tokenId]) - }; - _g = _parseString; - return [4, this.provider.call(tx)]; - case 15: - metadataUrl = _g.apply(void 0, [_h.sent()]); - if (metadataUrl == null) { - return [2, null]; - } - linkage.push({ type: "metadata-url-base", content: metadataUrl }); - if (scheme === "erc1155") { - metadataUrl = metadataUrl.replace("{id}", tokenId.substring(2)); - linkage.push({ type: "metadata-url-expanded", content: metadataUrl }); - } - if (metadataUrl.match(/^ipfs:/i)) { - metadataUrl = getIpfsLink(metadataUrl); - } - linkage.push({ type: "metadata-url", content: metadataUrl }); - return [4, (0, web_1.fetchJson)(metadataUrl)]; - case 16: - metadata = _h.sent(); - if (!metadata) { - return [2, null]; - } - linkage.push({ type: "metadata", content: JSON.stringify(metadata) }); - imageUrl = metadata.image; - if (typeof imageUrl !== "string") { - return [2, null]; - } - if (imageUrl.match(/^(https:\/\/|data:)/i)) { - } else { - ipfs = imageUrl.match(matcherIpfs); - if (ipfs == null) { - return [2, null]; - } - linkage.push({ type: "url-ipfs", content: imageUrl }); - imageUrl = getIpfsLink(imageUrl); - } - linkage.push({ type: "url", content: imageUrl }); - return [2, { linkage, url: imageUrl }]; - case 17: - i++; - return [3, 3]; - case 18: - return [3, 20]; - case 19: - error_3 = _h.sent(); - return [3, 20]; - case 20: + _f = (_e = bignumber_1.BigNumber).from; + return [4, this.provider.call({ + to: addr, + data: (0, bytes_1.hexConcat)(["0x00fdd58e", (0, bytes_1.hexZeroPad)(owner, 32), tokenId]) + })]; + case 13: + balance = _f.apply(_e, [_h.sent()]); + if (balance.isZero()) { return [2, null]; - } - }); - }); - }; - Resolver2.prototype.getContentHash = function() { - return __awaiter2(this, void 0, void 0, function() { - var hexBytes, ipfs, length_4, swarm; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this._fetchBytes("0xbc1c58d1")]; - case 1: - hexBytes = _a7.sent(); - if (hexBytes == null || hexBytes === "0x") { + } + linkage.push({ type: "balance", content: balance.toString() }); + _h.label = 14; + case 14: + tx = { + to: this.provider.formatter.address(comps[0]), + data: (0, bytes_1.hexConcat)([selector, tokenId]) + }; + _g = _parseString; + return [4, this.provider.call(tx)]; + case 15: + metadataUrl = _g.apply(void 0, [_h.sent()]); + if (metadataUrl == null) { + return [2, null]; + } + linkage.push({ type: "metadata-url-base", content: metadataUrl }); + if (scheme === "erc1155") { + metadataUrl = metadataUrl.replace("{id}", tokenId.substring(2)); + linkage.push({ type: "metadata-url-expanded", content: metadataUrl }); + } + if (metadataUrl.match(/^ipfs:/i)) { + metadataUrl = getIpfsLink(metadataUrl); + } + linkage.push({ type: "metadata-url", content: metadataUrl }); + return [4, (0, web_1.fetchJson)(metadataUrl)]; + case 16: + metadata = _h.sent(); + if (!metadata) { + return [2, null]; + } + linkage.push({ type: "metadata", content: JSON.stringify(metadata) }); + imageUrl = metadata.image; + if (typeof imageUrl !== "string") { + return [2, null]; + } + if (imageUrl.match(/^(https:\/\/|data:)/i)) { + } else { + ipfs = imageUrl.match(matcherIpfs); + if (ipfs == null) { return [2, null]; } - ipfs = hexBytes.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/); - if (ipfs) { - length_4 = parseInt(ipfs[3], 16); - if (ipfs[4].length === length_4 * 2) { - return [2, "ipfs://" + basex_1.Base58.encode("0x" + ipfs[1])]; - } - } - swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/); - if (swarm) { - if (swarm[1].length === 32 * 2) { - return [2, "bzz://" + swarm[1]]; - } - } - return [2, logger2.throwError("invalid or unsupported content hash data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "getContentHash()", - data: hexBytes - })]; - } - }); + linkage.push({ type: "url-ipfs", content: imageUrl }); + imageUrl = getIpfsLink(imageUrl); + } + linkage.push({ type: "url", content: imageUrl }); + return [2, { linkage, url: imageUrl }]; + case 17: + i++; + return [3, 3]; + case 18: + return [3, 20]; + case 19: + error_3 = _h.sent(); + return [3, 20]; + case 20: + return [2, null]; + } }); - }; - Resolver2.prototype.getText = function(key) { - return __awaiter2(this, void 0, void 0, function() { - var keyBytes, hexBytes; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - keyBytes = (0, strings_1.toUtf8Bytes)(key); - keyBytes = (0, bytes_1.concat)([bytes32ify(64), bytes32ify(keyBytes.length), keyBytes]); - if (keyBytes.length % 32 !== 0) { - keyBytes = (0, bytes_1.concat)([keyBytes, (0, bytes_1.hexZeroPad)("0x", 32 - key.length % 32)]); + }); + }; + Resolver2.prototype.getContentHash = function() { + return __awaiter(this, void 0, void 0, function() { + var hexBytes, ipfs, length_4, swarm; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this._fetchBytes("0xbc1c58d1")]; + case 1: + hexBytes = _a7.sent(); + if (hexBytes == null || hexBytes === "0x") { + return [2, null]; + } + ipfs = hexBytes.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/); + if (ipfs) { + length_4 = parseInt(ipfs[3], 16); + if (ipfs[4].length === length_4 * 2) { + return [2, "ipfs://" + basex_1.Base58.encode("0x" + ipfs[1])]; } - return [4, this._fetchBytes("0x59d1d43c", (0, bytes_1.hexlify)(keyBytes))]; - case 1: - hexBytes = _a7.sent(); - if (hexBytes == null || hexBytes === "0x") { - return [2, null]; + } + swarm = hexBytes.match(/^0xe40101fa011b20([0-9a-f]*)$/); + if (swarm) { + if (swarm[1].length === 32 * 2) { + return [2, "bzz://" + swarm[1]]; } - return [2, (0, strings_1.toUtf8String)(hexBytes)]; - } - }); + } + return [2, logger2.throwError("invalid or unsupported content hash data", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getContentHash()", + data: hexBytes + })]; + } }); - }; - return Resolver2; - }() - ); + }); + }; + Resolver2.prototype.getText = function(key) { + return __awaiter(this, void 0, void 0, function() { + var keyBytes, hexBytes; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + keyBytes = (0, strings_1.toUtf8Bytes)(key); + keyBytes = (0, bytes_1.concat)([bytes32ify(64), bytes32ify(keyBytes.length), keyBytes]); + if (keyBytes.length % 32 !== 0) { + keyBytes = (0, bytes_1.concat)([keyBytes, (0, bytes_1.hexZeroPad)("0x", 32 - key.length % 32)]); + } + return [4, this._fetchBytes("0x59d1d43c", (0, bytes_1.hexlify)(keyBytes))]; + case 1: + hexBytes = _a7.sent(); + if (hexBytes == null || hexBytes === "0x") { + return [2, null]; + } + return [2, (0, strings_1.toUtf8String)(hexBytes)]; + } + }); + }); + }; + return Resolver2; + }(); exports2.Resolver = Resolver; var defaultFormatter = null; var nextPollId = 1; - var BaseProvider2 = ( - /** @class */ - function(_super) { - __extends2(BaseProvider3, _super); - function BaseProvider3(network) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, abstract_provider_1.Provider); - _this = _super.call(this) || this; - _this._events = []; - _this._emitted = { block: -2 }; - _this.formatter = _newTarget.getFormatter(); - (0, properties_1.defineReadOnly)(_this, "anyNetwork", network === "any"); - if (_this.anyNetwork) { - network = _this.detectNetwork(); - } - if (network instanceof Promise) { - _this._networkPromise = network; - network.catch(function(error) { - }); - _this._ready().catch(function(error) { - }); + var BaseProvider2 = function(_super) { + __extends(BaseProvider3, _super); + function BaseProvider3(network) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, abstract_provider_1.Provider); + _this = _super.call(this) || this; + _this._events = []; + _this._emitted = { block: -2 }; + _this.formatter = _newTarget.getFormatter(); + (0, properties_1.defineReadOnly)(_this, "anyNetwork", network === "any"); + if (_this.anyNetwork) { + network = _this.detectNetwork(); + } + if (network instanceof Promise) { + _this._networkPromise = network; + network.catch(function(error) { + }); + _this._ready().catch(function(error) { + }); + } else { + var knownNetwork = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network); + if (knownNetwork) { + (0, properties_1.defineReadOnly)(_this, "_network", knownNetwork); + _this.emit("network", knownNetwork, null); } else { - var knownNetwork = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network); - if (knownNetwork) { - (0, properties_1.defineReadOnly)(_this, "_network", knownNetwork); - _this.emit("network", knownNetwork, null); - } else { - logger2.throwArgumentError("invalid network", "network", network); - } + logger2.throwArgumentError("invalid network", "network", network); } - _this._maxInternalBlockNumber = -1024; - _this._lastBlockNumber = -2; - _this._pollingInterval = 4e3; - _this._fastQueryDate = 0; - return _this; } - BaseProvider3.prototype._ready = function() { - return __awaiter2(this, void 0, void 0, function() { - var network, error_4; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (!(this._network == null)) - return [3, 7]; - network = null; - if (!this._networkPromise) - return [3, 4]; - _a7.label = 1; - case 1: - _a7.trys.push([1, 3, , 4]); - return [4, this._networkPromise]; - case 2: - network = _a7.sent(); - return [3, 4]; - case 3: - error_4 = _a7.sent(); + _this._maxInternalBlockNumber = -1024; + _this._lastBlockNumber = -2; + _this._pollingInterval = 4e3; + _this._fastQueryDate = 0; + return _this; + } + BaseProvider3.prototype._ready = function() { + return __awaiter(this, void 0, void 0, function() { + var network, error_4; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (!(this._network == null)) + return [3, 7]; + network = null; + if (!this._networkPromise) return [3, 4]; - case 4: - if (!(network == null)) - return [3, 6]; - return [4, this.detectNetwork()]; - case 5: - network = _a7.sent(); - _a7.label = 6; - case 6: - if (!network) { - logger2.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {}); - } - if (this._network == null) { - if (this.anyNetwork) { - this._network = network; - } else { - (0, properties_1.defineReadOnly)(this, "_network", network); - } - this.emit("network", network, null); + _a7.label = 1; + case 1: + _a7.trys.push([1, 3, , 4]); + return [4, this._networkPromise]; + case 2: + network = _a7.sent(); + return [3, 4]; + case 3: + error_4 = _a7.sent(); + return [3, 4]; + case 4: + if (!(network == null)) + return [3, 6]; + return [4, this.detectNetwork()]; + case 5: + network = _a7.sent(); + _a7.label = 6; + case 6: + if (!network) { + logger2.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {}); + } + if (this._network == null) { + if (this.anyNetwork) { + this._network = network; + } else { + (0, properties_1.defineReadOnly)(this, "_network", network); } - _a7.label = 7; - case 7: - return [2, this._network]; + this.emit("network", network, null); + } + _a7.label = 7; + case 7: + return [2, this._network]; + } + }); + }); + }; + Object.defineProperty(BaseProvider3.prototype, "ready", { + get: function() { + var _this = this; + return (0, web_1.poll)(function() { + return _this._ready().then(function(network) { + return network; + }, function(error) { + if (error.code === logger_1.Logger.errors.NETWORK_ERROR && error.event === "noNetwork") { + return void 0; } + throw error; }); }); - }; - Object.defineProperty(BaseProvider3.prototype, "ready", { - // This will always return the most recently established network. - // For "any", this can change (a "network" event is emitted before - // any change is reflected); otherwise this cannot change - get: function() { - var _this = this; - return (0, web_1.poll)(function() { - return _this._ready().then(function(network) { - return network; - }, function(error) { - if (error.code === logger_1.Logger.errors.NETWORK_ERROR && error.event === "noNetwork") { - return void 0; - } - throw error; - }); - }); - }, - enumerable: false, - configurable: true - }); - BaseProvider3.getFormatter = function() { - if (defaultFormatter == null) { - defaultFormatter = new formatter_1.Formatter(); - } - return defaultFormatter; - }; - BaseProvider3.getNetwork = function(network) { - return (0, networks_1.getNetwork)(network == null ? "homestead" : network); - }; - BaseProvider3.prototype._getInternalBlockNumber = function(maxAge) { - return __awaiter2(this, void 0, void 0, function() { - var internalBlockNumber, result, error_5, reqTime, checkInternalBlockNumber; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this._ready()]; - case 1: - _a7.sent(); - if (!(maxAge > 0)) - return [3, 7]; - _a7.label = 2; - case 2: - if (!this._internalBlockNumber) - return [3, 7]; - internalBlockNumber = this._internalBlockNumber; - _a7.label = 3; - case 3: - _a7.trys.push([3, 5, , 6]); - return [4, internalBlockNumber]; - case 4: - result = _a7.sent(); - if (getTime() - result.respTime <= maxAge) { - return [2, result.blockNumber]; - } + }, + enumerable: false, + configurable: true + }); + BaseProvider3.getFormatter = function() { + if (defaultFormatter == null) { + defaultFormatter = new formatter_1.Formatter(); + } + return defaultFormatter; + }; + BaseProvider3.getNetwork = function(network) { + return (0, networks_1.getNetwork)(network == null ? "homestead" : network); + }; + BaseProvider3.prototype._getInternalBlockNumber = function(maxAge) { + return __awaiter(this, void 0, void 0, function() { + var internalBlockNumber, result, error_5, reqTime, checkInternalBlockNumber; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this._ready()]; + case 1: + _a7.sent(); + if (!(maxAge > 0)) return [3, 7]; - case 5: - error_5 = _a7.sent(); - if (this._internalBlockNumber === internalBlockNumber) { - return [3, 7]; - } - return [3, 6]; - case 6: - return [3, 2]; - case 7: - reqTime = getTime(); - checkInternalBlockNumber = (0, properties_1.resolveProperties)({ - blockNumber: this.perform("getBlockNumber", {}), - networkError: this.getNetwork().then(function(network) { - return null; - }, function(error) { - return error; - }) - }).then(function(_a8) { - var blockNumber = _a8.blockNumber, networkError = _a8.networkError; - if (networkError) { - if (_this._internalBlockNumber === checkInternalBlockNumber) { - _this._internalBlockNumber = null; - } - throw networkError; - } - var respTime = getTime(); - blockNumber = bignumber_1.BigNumber.from(blockNumber).toNumber(); - if (blockNumber < _this._maxInternalBlockNumber) { - blockNumber = _this._maxInternalBlockNumber; - } - _this._maxInternalBlockNumber = blockNumber; - _this._setFastBlockNumber(blockNumber); - return { blockNumber, reqTime, respTime }; - }); - this._internalBlockNumber = checkInternalBlockNumber; - checkInternalBlockNumber.catch(function(error) { + _a7.label = 2; + case 2: + if (!this._internalBlockNumber) + return [3, 7]; + internalBlockNumber = this._internalBlockNumber; + _a7.label = 3; + case 3: + _a7.trys.push([3, 5, , 6]); + return [4, internalBlockNumber]; + case 4: + result = _a7.sent(); + if (getTime() - result.respTime <= maxAge) { + return [2, result.blockNumber]; + } + return [3, 7]; + case 5: + error_5 = _a7.sent(); + if (this._internalBlockNumber === internalBlockNumber) { + return [3, 7]; + } + return [3, 6]; + case 6: + return [3, 2]; + case 7: + reqTime = getTime(); + checkInternalBlockNumber = (0, properties_1.resolveProperties)({ + blockNumber: this.perform("getBlockNumber", {}), + networkError: this.getNetwork().then(function(network) { + return null; + }, function(error) { + return error; + }) + }).then(function(_a8) { + var blockNumber = _a8.blockNumber, networkError = _a8.networkError; + if (networkError) { if (_this._internalBlockNumber === checkInternalBlockNumber) { _this._internalBlockNumber = null; } - }); - return [4, checkInternalBlockNumber]; - case 8: - return [2, _a7.sent().blockNumber]; - } - }); - }); - }; - BaseProvider3.prototype.poll = function() { - return __awaiter2(this, void 0, void 0, function() { - var pollId, runners, blockNumber, error_6, i; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - pollId = nextPollId++; - runners = []; - blockNumber = null; - _a7.label = 1; - case 1: - _a7.trys.push([1, 3, , 4]); - return [4, this._getInternalBlockNumber(100 + this.pollingInterval / 2)]; - case 2: - blockNumber = _a7.sent(); - return [3, 4]; - case 3: - error_6 = _a7.sent(); - this.emit("error", error_6); - return [ - 2 - /*return*/ - ]; - case 4: - this._setFastBlockNumber(blockNumber); - this.emit("poll", pollId, blockNumber); - if (blockNumber === this._lastBlockNumber) { - this.emit("didPoll", pollId); - return [ - 2 - /*return*/ - ]; + throw networkError; } - if (this._emitted.block === -2) { - this._emitted.block = blockNumber - 1; + var respTime = getTime(); + blockNumber = bignumber_1.BigNumber.from(blockNumber).toNumber(); + if (blockNumber < _this._maxInternalBlockNumber) { + blockNumber = _this._maxInternalBlockNumber; } - if (Math.abs(this._emitted.block - blockNumber) > 1e3) { - logger2.warn("network block skew detected; skipping block events (emitted=" + this._emitted.block + " blockNumber" + blockNumber + ")"); - this.emit("error", logger2.makeError("network block skew detected", logger_1.Logger.errors.NETWORK_ERROR, { - blockNumber, - event: "blockSkew", - previousBlockNumber: this._emitted.block - })); - this.emit("block", blockNumber); - } else { - for (i = this._emitted.block + 1; i <= blockNumber; i++) { - this.emit("block", i); - } - } - if (this._emitted.block !== blockNumber) { - this._emitted.block = blockNumber; - Object.keys(this._emitted).forEach(function(key) { - if (key === "block") { - return; - } - var eventBlockNumber = _this._emitted[key]; - if (eventBlockNumber === "pending") { - return; - } - if (blockNumber - eventBlockNumber > 12) { - delete _this._emitted[key]; - } - }); + _this._maxInternalBlockNumber = blockNumber; + _this._setFastBlockNumber(blockNumber); + return { blockNumber, reqTime, respTime }; + }); + this._internalBlockNumber = checkInternalBlockNumber; + checkInternalBlockNumber.catch(function(error) { + if (_this._internalBlockNumber === checkInternalBlockNumber) { + _this._internalBlockNumber = null; } - if (this._lastBlockNumber === -2) { - this._lastBlockNumber = blockNumber - 1; + }); + return [4, checkInternalBlockNumber]; + case 8: + return [2, _a7.sent().blockNumber]; + } + }); + }); + }; + BaseProvider3.prototype.poll = function() { + return __awaiter(this, void 0, void 0, function() { + var pollId, runners, blockNumber, error_6, i; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + pollId = nextPollId++; + runners = []; + blockNumber = null; + _a7.label = 1; + case 1: + _a7.trys.push([1, 3, , 4]); + return [4, this._getInternalBlockNumber(100 + this.pollingInterval / 2)]; + case 2: + blockNumber = _a7.sent(); + return [3, 4]; + case 3: + error_6 = _a7.sent(); + this.emit("error", error_6); + return [2]; + case 4: + this._setFastBlockNumber(blockNumber); + this.emit("poll", pollId, blockNumber); + if (blockNumber === this._lastBlockNumber) { + this.emit("didPoll", pollId); + return [2]; + } + if (this._emitted.block === -2) { + this._emitted.block = blockNumber - 1; + } + if (Math.abs(this._emitted.block - blockNumber) > 1e3) { + logger2.warn("network block skew detected; skipping block events (emitted=" + this._emitted.block + " blockNumber" + blockNumber + ")"); + this.emit("error", logger2.makeError("network block skew detected", logger_1.Logger.errors.NETWORK_ERROR, { + blockNumber, + event: "blockSkew", + previousBlockNumber: this._emitted.block + })); + this.emit("block", blockNumber); + } else { + for (i = this._emitted.block + 1; i <= blockNumber; i++) { + this.emit("block", i); } - this._events.forEach(function(event) { - switch (event.type) { - case "tx": { - var hash_2 = event.hash; - var runner = _this.getTransactionReceipt(hash_2).then(function(receipt) { - if (!receipt || receipt.blockNumber == null) { - return null; - } - _this._emitted["t:" + hash_2] = receipt.blockNumber; - _this.emit(hash_2, receipt); + } + if (this._emitted.block !== blockNumber) { + this._emitted.block = blockNumber; + Object.keys(this._emitted).forEach(function(key) { + if (key === "block") { + return; + } + var eventBlockNumber = _this._emitted[key]; + if (eventBlockNumber === "pending") { + return; + } + if (blockNumber - eventBlockNumber > 12) { + delete _this._emitted[key]; + } + }); + } + if (this._lastBlockNumber === -2) { + this._lastBlockNumber = blockNumber - 1; + } + this._events.forEach(function(event) { + switch (event.type) { + case "tx": { + var hash_2 = event.hash; + var runner = _this.getTransactionReceipt(hash_2).then(function(receipt) { + if (!receipt || receipt.blockNumber == null) { return null; - }).catch(function(error) { - _this.emit("error", error); - }); - runners.push(runner); - break; - } - case "filter": { - var filter_1 = event.filter; - filter_1.fromBlock = _this._lastBlockNumber + 1; - filter_1.toBlock = blockNumber; - var runner = _this.getLogs(filter_1).then(function(logs) { - if (logs.length === 0) { - return; - } - logs.forEach(function(log) { - _this._emitted["b:" + log.blockHash] = log.blockNumber; - _this._emitted["t:" + log.transactionHash] = log.blockNumber; - _this.emit(filter_1, log); - }); - }).catch(function(error) { - _this.emit("error", error); + } + _this._emitted["t:" + hash_2] = receipt.blockNumber; + _this.emit(hash_2, receipt); + return null; + }).catch(function(error) { + _this.emit("error", error); + }); + runners.push(runner); + break; + } + case "filter": { + var filter_1 = event.filter; + filter_1.fromBlock = _this._lastBlockNumber + 1; + filter_1.toBlock = blockNumber; + var runner = _this.getLogs(filter_1).then(function(logs) { + if (logs.length === 0) { + return; + } + logs.forEach(function(log) { + _this._emitted["b:" + log.blockHash] = log.blockNumber; + _this._emitted["t:" + log.transactionHash] = log.blockNumber; + _this.emit(filter_1, log); }); - runners.push(runner); - break; - } + }).catch(function(error) { + _this.emit("error", error); + }); + runners.push(runner); + break; } - }); - this._lastBlockNumber = blockNumber; - Promise.all(runners).then(function() { - _this.emit("didPoll", pollId); - }).catch(function(error) { - _this.emit("error", error); - }); - return [ - 2 - /*return*/ - ]; - } - }); - }); - }; - BaseProvider3.prototype.resetEventsBlock = function(blockNumber) { - this._lastBlockNumber = blockNumber - 1; - if (this.polling) { - this.poll(); - } - }; - Object.defineProperty(BaseProvider3.prototype, "network", { - get: function() { - return this._network; - }, - enumerable: false, - configurable: true - }); - BaseProvider3.prototype.detectNetwork = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - return [2, logger2.throwError("provider does not support network detection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "provider.detectNetwork" - })]; - }); + } + }); + this._lastBlockNumber = blockNumber; + Promise.all(runners).then(function() { + _this.emit("didPoll", pollId); + }).catch(function(error) { + _this.emit("error", error); + }); + return [2]; + } }); - }; - BaseProvider3.prototype.getNetwork = function() { - return __awaiter2(this, void 0, void 0, function() { - var network, currentNetwork, error; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this._ready()]; - case 1: - network = _a7.sent(); - return [4, this.detectNetwork()]; - case 2: - currentNetwork = _a7.sent(); - if (!(network.chainId !== currentNetwork.chainId)) - return [3, 5]; - if (!this.anyNetwork) - return [3, 4]; - this._network = currentNetwork; - this._lastBlockNumber = -2; - this._fastBlockNumber = null; - this._fastBlockNumberPromise = null; - this._fastQueryDate = 0; - this._emitted.block = -2; - this._maxInternalBlockNumber = -1024; - this._internalBlockNumber = null; - this.emit("network", currentNetwork, network); - return [4, stall(0)]; - case 3: - _a7.sent(); - return [2, this._network]; - case 4: - error = logger2.makeError("underlying network changed", logger_1.Logger.errors.NETWORK_ERROR, { - event: "changed", - network, - detectedNetwork: currentNetwork - }); - this.emit("error", error); - throw error; - case 5: - return [2, network]; - } - }); + }); + }; + BaseProvider3.prototype.resetEventsBlock = function(blockNumber) { + this._lastBlockNumber = blockNumber - 1; + if (this.polling) { + this.poll(); + } + }; + Object.defineProperty(BaseProvider3.prototype, "network", { + get: function() { + return this._network; + }, + enumerable: false, + configurable: true + }); + BaseProvider3.prototype.detectNetwork = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + return [2, logger2.throwError("provider does not support network detection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "provider.detectNetwork" + })]; }); - }; - Object.defineProperty(BaseProvider3.prototype, "blockNumber", { - get: function() { - var _this = this; - this._getInternalBlockNumber(100 + this.pollingInterval / 2).then(function(blockNumber) { - _this._setFastBlockNumber(blockNumber); - }, function(error) { - }); - return this._fastBlockNumber != null ? this._fastBlockNumber : -1; - }, - enumerable: false, - configurable: true }); - Object.defineProperty(BaseProvider3.prototype, "polling", { - get: function() { - return this._poller != null; - }, - set: function(value) { - var _this = this; - if (value && !this._poller) { - this._poller = setInterval(function() { - _this.poll(); - }, this.pollingInterval); - if (!this._bootstrapPoll) { - this._bootstrapPoll = setTimeout(function() { - _this.poll(); - _this._bootstrapPoll = setTimeout(function() { - if (!_this._poller) { - _this.poll(); - } - _this._bootstrapPoll = null; - }, _this.pollingInterval); - }, 0); - } - } else if (!value && this._poller) { - clearInterval(this._poller); - this._poller = null; + }; + BaseProvider3.prototype.getNetwork = function() { + return __awaiter(this, void 0, void 0, function() { + var network, currentNetwork, error; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this._ready()]; + case 1: + network = _a7.sent(); + return [4, this.detectNetwork()]; + case 2: + currentNetwork = _a7.sent(); + if (!(network.chainId !== currentNetwork.chainId)) + return [3, 5]; + if (!this.anyNetwork) + return [3, 4]; + this._network = currentNetwork; + this._lastBlockNumber = -2; + this._fastBlockNumber = null; + this._fastBlockNumberPromise = null; + this._fastQueryDate = 0; + this._emitted.block = -2; + this._maxInternalBlockNumber = -1024; + this._internalBlockNumber = null; + this.emit("network", currentNetwork, network); + return [4, stall(0)]; + case 3: + _a7.sent(); + return [2, this._network]; + case 4: + error = logger2.makeError("underlying network changed", logger_1.Logger.errors.NETWORK_ERROR, { + event: "changed", + network, + detectedNetwork: currentNetwork + }); + this.emit("error", error); + throw error; + case 5: + return [2, network]; } - }, - enumerable: false, - configurable: true + }); }); - Object.defineProperty(BaseProvider3.prototype, "pollingInterval", { - get: function() { - return this._pollingInterval; - }, - set: function(value) { - var _this = this; - if (typeof value !== "number" || value <= 0 || parseInt(String(value)) != value) { - throw new Error("invalid polling interval"); - } - this._pollingInterval = value; - if (this._poller) { - clearInterval(this._poller); - this._poller = setInterval(function() { + }; + Object.defineProperty(BaseProvider3.prototype, "blockNumber", { + get: function() { + var _this = this; + this._getInternalBlockNumber(100 + this.pollingInterval / 2).then(function(blockNumber) { + _this._setFastBlockNumber(blockNumber); + }, function(error) { + }); + return this._fastBlockNumber != null ? this._fastBlockNumber : -1; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseProvider3.prototype, "polling", { + get: function() { + return this._poller != null; + }, + set: function(value) { + var _this = this; + if (value && !this._poller) { + this._poller = setInterval(function() { + _this.poll(); + }, this.pollingInterval); + if (!this._bootstrapPoll) { + this._bootstrapPoll = setTimeout(function() { _this.poll(); - }, this._pollingInterval); + _this._bootstrapPoll = setTimeout(function() { + if (!_this._poller) { + _this.poll(); + } + _this._bootstrapPoll = null; + }, _this.pollingInterval); + }, 0); } - }, - enumerable: false, - configurable: true - }); - BaseProvider3.prototype._getFastBlockNumber = function() { - var _this = this; - var now = getTime(); - if (now - this._fastQueryDate > 2 * this._pollingInterval) { - this._fastQueryDate = now; - this._fastBlockNumberPromise = this.getBlockNumber().then(function(blockNumber) { - if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) { - _this._fastBlockNumber = blockNumber; - } - return _this._fastBlockNumber; - }); + } else if (!value && this._poller) { + clearInterval(this._poller); + this._poller = null; } - return this._fastBlockNumberPromise; - }; - BaseProvider3.prototype._setFastBlockNumber = function(blockNumber) { - if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { - return; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(BaseProvider3.prototype, "pollingInterval", { + get: function() { + return this._pollingInterval; + }, + set: function(value) { + var _this = this; + if (typeof value !== "number" || value <= 0 || parseInt(String(value)) != value) { + throw new Error("invalid polling interval"); } - this._fastQueryDate = getTime(); - if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { - this._fastBlockNumber = blockNumber; - this._fastBlockNumberPromise = Promise.resolve(blockNumber); + this._pollingInterval = value; + if (this._poller) { + clearInterval(this._poller); + this._poller = setInterval(function() { + _this.poll(); + }, this._pollingInterval); } - }; - BaseProvider3.prototype.waitForTransaction = function(transactionHash, confirmations, timeout) { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - return [2, this._waitForTransaction(transactionHash, confirmations == null ? 1 : confirmations, timeout || 0, null)]; - }); + }, + enumerable: false, + configurable: true + }); + BaseProvider3.prototype._getFastBlockNumber = function() { + var _this = this; + var now = getTime(); + if (now - this._fastQueryDate > 2 * this._pollingInterval) { + this._fastQueryDate = now; + this._fastBlockNumberPromise = this.getBlockNumber().then(function(blockNumber) { + if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) { + _this._fastBlockNumber = blockNumber; + } + return _this._fastBlockNumber; }); - }; - BaseProvider3.prototype._waitForTransaction = function(transactionHash, confirmations, timeout, replaceable) { - return __awaiter2(this, void 0, void 0, function() { - var receipt; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getTransactionReceipt(transactionHash)]; - case 1: - receipt = _a7.sent(); - if ((receipt ? receipt.confirmations : 0) >= confirmations) { - return [2, receipt]; - } - return [2, new Promise(function(resolve, reject) { - var cancelFuncs = []; - var done = false; - var alreadyDone = function() { - if (done) { - return true; - } - done = true; - cancelFuncs.forEach(function(func) { - func(); - }); - return false; - }; - var minedHandler = function(receipt2) { - if (receipt2.confirmations < confirmations) { - return; - } - if (alreadyDone()) { - return; - } - resolve(receipt2); - }; - _this.on(transactionHash, minedHandler); - cancelFuncs.push(function() { - _this.removeListener(transactionHash, minedHandler); + } + return this._fastBlockNumberPromise; + }; + BaseProvider3.prototype._setFastBlockNumber = function(blockNumber) { + if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { + return; + } + this._fastQueryDate = getTime(); + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + this._fastBlockNumberPromise = Promise.resolve(blockNumber); + } + }; + BaseProvider3.prototype.waitForTransaction = function(transactionHash, confirmations, timeout) { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + return [2, this._waitForTransaction(transactionHash, confirmations == null ? 1 : confirmations, timeout || 0, null)]; + }); + }); + }; + BaseProvider3.prototype._waitForTransaction = function(transactionHash, confirmations, timeout, replaceable) { + return __awaiter(this, void 0, void 0, function() { + var receipt; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getTransactionReceipt(transactionHash)]; + case 1: + receipt = _a7.sent(); + if ((receipt ? receipt.confirmations : 0) >= confirmations) { + return [2, receipt]; + } + return [2, new Promise(function(resolve, reject) { + var cancelFuncs = []; + var done = false; + var alreadyDone = function() { + if (done) { + return true; + } + done = true; + cancelFuncs.forEach(function(func) { + func(); }); - if (replaceable) { - var lastBlockNumber_1 = replaceable.startBlock; - var scannedBlock_1 = null; - var replaceHandler_1 = function(blockNumber) { - return __awaiter2(_this, void 0, void 0, function() { - var _this2 = this; - return __generator2(this, function(_a8) { - switch (_a8.label) { - case 0: - if (done) { - return [ - 2 - /*return*/ - ]; - } - return [4, stall(1e3)]; - case 1: - _a8.sent(); - this.getTransactionCount(replaceable.from).then(function(nonce) { - return __awaiter2(_this2, void 0, void 0, function() { - var mined, block, ti, tx, receipt_1, reason; - return __generator2(this, function(_a9) { - switch (_a9.label) { - case 0: - if (done) { - return [ - 2 - /*return*/ - ]; + return false; + }; + var minedHandler = function(receipt2) { + if (receipt2.confirmations < confirmations) { + return; + } + if (alreadyDone()) { + return; + } + resolve(receipt2); + }; + _this.on(transactionHash, minedHandler); + cancelFuncs.push(function() { + _this.removeListener(transactionHash, minedHandler); + }); + if (replaceable) { + var lastBlockNumber_1 = replaceable.startBlock; + var scannedBlock_1 = null; + var replaceHandler_1 = function(blockNumber) { + return __awaiter(_this, void 0, void 0, function() { + var _this2 = this; + return __generator(this, function(_a8) { + switch (_a8.label) { + case 0: + if (done) { + return [2]; + } + return [4, stall(1e3)]; + case 1: + _a8.sent(); + this.getTransactionCount(replaceable.from).then(function(nonce) { + return __awaiter(_this2, void 0, void 0, function() { + var mined, block, ti, tx, receipt_1, reason; + return __generator(this, function(_a9) { + switch (_a9.label) { + case 0: + if (done) { + return [2]; + } + if (!(nonce <= replaceable.nonce)) + return [3, 1]; + lastBlockNumber_1 = blockNumber; + return [3, 9]; + case 1: + return [4, this.getTransaction(transactionHash)]; + case 2: + mined = _a9.sent(); + if (mined && mined.blockNumber != null) { + return [2]; + } + if (scannedBlock_1 == null) { + scannedBlock_1 = lastBlockNumber_1 - 3; + if (scannedBlock_1 < replaceable.startBlock) { + scannedBlock_1 = replaceable.startBlock; } - if (!(nonce <= replaceable.nonce)) - return [3, 1]; - lastBlockNumber_1 = blockNumber; + } + _a9.label = 3; + case 3: + if (!(scannedBlock_1 <= blockNumber)) return [3, 9]; - case 1: - return [4, this.getTransaction(transactionHash)]; - case 2: - mined = _a9.sent(); - if (mined && mined.blockNumber != null) { - return [ - 2 - /*return*/ - ]; - } - if (scannedBlock_1 == null) { - scannedBlock_1 = lastBlockNumber_1 - 3; - if (scannedBlock_1 < replaceable.startBlock) { - scannedBlock_1 = replaceable.startBlock; - } - } - _a9.label = 3; - case 3: - if (!(scannedBlock_1 <= blockNumber)) - return [3, 9]; - if (done) { - return [ - 2 - /*return*/ - ]; - } - return [4, this.getBlockWithTransactions(scannedBlock_1)]; - case 4: - block = _a9.sent(); - ti = 0; - _a9.label = 5; - case 5: - if (!(ti < block.transactions.length)) - return [3, 8]; - tx = block.transactions[ti]; - if (tx.hash === transactionHash) { - return [ - 2 - /*return*/ - ]; - } - if (!(tx.from === replaceable.from && tx.nonce === replaceable.nonce)) - return [3, 7]; - if (done) { - return [ - 2 - /*return*/ - ]; - } - return [4, this.waitForTransaction(tx.hash, confirmations)]; - case 6: - receipt_1 = _a9.sent(); - if (alreadyDone()) { - return [ - 2 - /*return*/ - ]; - } - reason = "replaced"; - if (tx.data === replaceable.data && tx.to === replaceable.to && tx.value.eq(replaceable.value)) { - reason = "repriced"; - } else if (tx.data === "0x" && tx.from === tx.to && tx.value.isZero()) { - reason = "cancelled"; - } - reject(logger2.makeError("transaction was replaced", logger_1.Logger.errors.TRANSACTION_REPLACED, { - cancelled: reason === "replaced" || reason === "cancelled", - reason, - replacement: this._wrapTransaction(tx), - hash: transactionHash, - receipt: receipt_1 - })); - return [ - 2 - /*return*/ - ]; - case 7: - ti++; - return [3, 5]; - case 8: - scannedBlock_1++; - return [3, 3]; - case 9: - if (done) { - return [ - 2 - /*return*/ - ]; - } - this.once("block", replaceHandler_1); - return [ - 2 - /*return*/ - ]; - } - }); + if (done) { + return [2]; + } + return [4, this.getBlockWithTransactions(scannedBlock_1)]; + case 4: + block = _a9.sent(); + ti = 0; + _a9.label = 5; + case 5: + if (!(ti < block.transactions.length)) + return [3, 8]; + tx = block.transactions[ti]; + if (tx.hash === transactionHash) { + return [2]; + } + if (!(tx.from === replaceable.from && tx.nonce === replaceable.nonce)) + return [3, 7]; + if (done) { + return [2]; + } + return [4, this.waitForTransaction(tx.hash, confirmations)]; + case 6: + receipt_1 = _a9.sent(); + if (alreadyDone()) { + return [2]; + } + reason = "replaced"; + if (tx.data === replaceable.data && tx.to === replaceable.to && tx.value.eq(replaceable.value)) { + reason = "repriced"; + } else if (tx.data === "0x" && tx.from === tx.to && tx.value.isZero()) { + reason = "cancelled"; + } + reject(logger2.makeError("transaction was replaced", logger_1.Logger.errors.TRANSACTION_REPLACED, { + cancelled: reason === "replaced" || reason === "cancelled", + reason, + replacement: this._wrapTransaction(tx), + hash: transactionHash, + receipt: receipt_1 + })); + return [2]; + case 7: + ti++; + return [3, 5]; + case 8: + scannedBlock_1++; + return [3, 3]; + case 9: + if (done) { + return [2]; + } + this.once("block", replaceHandler_1); + return [2]; + } }); - }, function(error) { - if (done) { - return; - } - _this2.once("block", replaceHandler_1); }); - return [ - 2 - /*return*/ - ]; - } - }); + }, function(error) { + if (done) { + return; + } + _this2.once("block", replaceHandler_1); + }); + return [2]; + } }); - }; - if (done) { - return; - } - _this.once("block", replaceHandler_1); - cancelFuncs.push(function() { - _this.removeListener("block", replaceHandler_1); }); + }; + if (done) { + return; } - if (typeof timeout === "number" && timeout > 0) { - var timer_1 = setTimeout(function() { - if (alreadyDone()) { - return; - } - reject(logger2.makeError("timeout exceeded", logger_1.Logger.errors.TIMEOUT, { timeout })); - }, timeout); - if (timer_1.unref) { - timer_1.unref(); + _this.once("block", replaceHandler_1); + cancelFuncs.push(function() { + _this.removeListener("block", replaceHandler_1); + }); + } + if (typeof timeout === "number" && timeout > 0) { + var timer_1 = setTimeout(function() { + if (alreadyDone()) { + return; } - cancelFuncs.push(function() { - clearTimeout(timer_1); - }); + reject(logger2.makeError("timeout exceeded", logger_1.Logger.errors.TIMEOUT, { timeout })); + }, timeout); + if (timer_1.unref) { + timer_1.unref(); } - })]; - } - }); - }); - }; - BaseProvider3.prototype.getBlockNumber = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - return [2, this._getInternalBlockNumber(0)]; - }); - }); - }; - BaseProvider3.prototype.getGasPrice = function() { - return __awaiter2(this, void 0, void 0, function() { - var result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, this.perform("getGasPrice", {})]; - case 2: - result = _a7.sent(); - try { - return [2, bignumber_1.BigNumber.from(result)]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "getGasPrice", - result, - error - })]; + cancelFuncs.push(function() { + clearTimeout(timer_1); + }); } - return [ - 2 - /*return*/ - ]; - } - }); + })]; + } }); - }; - BaseProvider3.prototype.getBalance = function(addressOrName, blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ - address: this._getAddress(addressOrName), - blockTag: this._getBlockTag(blockTag) + }); + }; + BaseProvider3.prototype.getBlockNumber = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + return [2, this._getInternalBlockNumber(0)]; + }); + }); + }; + BaseProvider3.prototype.getGasPrice = function() { + return __awaiter(this, void 0, void 0, function() { + var result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, this.perform("getGasPrice", {})]; + case 2: + result = _a7.sent(); + try { + return [2, bignumber_1.BigNumber.from(result)]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "getGasPrice", + result, + error })]; - case 2: - params = _a7.sent(); - return [4, this.perform("getBalance", params)]; - case 3: - result = _a7.sent(); - try { - return [2, bignumber_1.BigNumber.from(result)]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "getBalance", - params, - result, - error - })]; - } - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2]; + } }); - }; - BaseProvider3.prototype.getTransactionCount = function(addressOrName, blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ - address: this._getAddress(addressOrName), - blockTag: this._getBlockTag(blockTag) + }); + }; + BaseProvider3.prototype.getBalance = function(addressOrName, blockTag) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ + address: this._getAddress(addressOrName), + blockTag: this._getBlockTag(blockTag) + })]; + case 2: + params = _a7.sent(); + return [4, this.perform("getBalance", params)]; + case 3: + result = _a7.sent(); + try { + return [2, bignumber_1.BigNumber.from(result)]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "getBalance", + params, + result, + error })]; - case 2: - params = _a7.sent(); - return [4, this.perform("getTransactionCount", params)]; - case 3: - result = _a7.sent(); - try { - return [2, bignumber_1.BigNumber.from(result).toNumber()]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "getTransactionCount", - params, - result, - error - })]; - } - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2]; + } }); - }; - BaseProvider3.prototype.getCode = function(addressOrName, blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ - address: this._getAddress(addressOrName), - blockTag: this._getBlockTag(blockTag) + }); + }; + BaseProvider3.prototype.getTransactionCount = function(addressOrName, blockTag) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ + address: this._getAddress(addressOrName), + blockTag: this._getBlockTag(blockTag) + })]; + case 2: + params = _a7.sent(); + return [4, this.perform("getTransactionCount", params)]; + case 3: + result = _a7.sent(); + try { + return [2, bignumber_1.BigNumber.from(result).toNumber()]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "getTransactionCount", + params, + result, + error })]; - case 2: - params = _a7.sent(); - return [4, this.perform("getCode", params)]; - case 3: - result = _a7.sent(); - try { - return [2, (0, bytes_1.hexlify)(result)]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "getCode", - params, - result, - error - })]; - } - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2]; + } }); - }; - BaseProvider3.prototype.getStorageAt = function(addressOrName, position, blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ - address: this._getAddress(addressOrName), - blockTag: this._getBlockTag(blockTag), - position: Promise.resolve(position).then(function(p) { - return (0, bytes_1.hexValue)(p); - }) + }); + }; + BaseProvider3.prototype.getCode = function(addressOrName, blockTag) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ + address: this._getAddress(addressOrName), + blockTag: this._getBlockTag(blockTag) + })]; + case 2: + params = _a7.sent(); + return [4, this.perform("getCode", params)]; + case 3: + result = _a7.sent(); + try { + return [2, (0, bytes_1.hexlify)(result)]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "getCode", + params, + result, + error })]; - case 2: - params = _a7.sent(); - return [4, this.perform("getStorageAt", params)]; - case 3: - result = _a7.sent(); - try { - return [2, (0, bytes_1.hexlify)(result)]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "getStorageAt", - params, - result, - error - })]; - } - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2]; + } }); - }; - BaseProvider3.prototype._wrapTransaction = function(tx, hash, startBlock) { - var _this = this; - if (hash != null && (0, bytes_1.hexDataLength)(hash) !== 32) { - throw new Error("invalid response - sendTransaction"); - } - var result = tx; - if (hash != null && tx.hash !== hash) { - logger2.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger_1.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); - } - result.wait = function(confirms, timeout) { - return __awaiter2(_this, void 0, void 0, function() { - var replacement, receipt; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (confirms == null) { - confirms = 1; - } - if (timeout == null) { - timeout = 0; - } - replacement = void 0; - if (confirms !== 0 && startBlock != null) { - replacement = { - data: tx.data, - from: tx.from, - nonce: tx.nonce, - to: tx.to, - value: tx.value, - startBlock - }; - } - return [4, this._waitForTransaction(tx.hash, confirms, timeout, replacement)]; - case 1: - receipt = _a7.sent(); - if (receipt == null && confirms === 0) { - return [2, null]; - } - this._emitted["t:" + tx.hash] = receipt.blockNumber; - if (receipt.status === 0) { - logger2.throwError("transaction failed", logger_1.Logger.errors.CALL_EXCEPTION, { - transactionHash: tx.hash, - transaction: tx, - receipt - }); - } - return [2, receipt]; + }); + }; + BaseProvider3.prototype.getStorageAt = function(addressOrName, position, blockTag) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ + address: this._getAddress(addressOrName), + blockTag: this._getBlockTag(blockTag), + position: Promise.resolve(position).then(function(p) { + return (0, bytes_1.hexValue)(p); + }) + })]; + case 2: + params = _a7.sent(); + return [4, this.perform("getStorageAt", params)]; + case 3: + result = _a7.sent(); + try { + return [2, (0, bytes_1.hexlify)(result)]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "getStorageAt", + params, + result, + error + })]; } - }); - }); - }; - return result; - }; - BaseProvider3.prototype.sendTransaction = function(signedTransaction) { - return __awaiter2(this, void 0, void 0, function() { - var hexTx, tx, blockNumber, hash, error_7; - return __generator2(this, function(_a7) { + return [2]; + } + }); + }); + }; + BaseProvider3.prototype._wrapTransaction = function(tx, hash, startBlock) { + var _this = this; + if (hash != null && (0, bytes_1.hexDataLength)(hash) !== 32) { + throw new Error("invalid response - sendTransaction"); + } + var result = tx; + if (hash != null && tx.hash !== hash) { + logger2.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger_1.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + } + result.wait = function(confirms, timeout) { + return __awaiter(_this, void 0, void 0, function() { + var replacement, receipt; + return __generator(this, function(_a7) { switch (_a7.label) { case 0: - return [4, this.getNetwork()]; + if (confirms == null) { + confirms = 1; + } + if (timeout == null) { + timeout = 0; + } + replacement = void 0; + if (confirms !== 0 && startBlock != null) { + replacement = { + data: tx.data, + from: tx.from, + nonce: tx.nonce, + to: tx.to, + value: tx.value, + startBlock + }; + } + return [4, this._waitForTransaction(tx.hash, confirms, timeout, replacement)]; case 1: - _a7.sent(); - return [4, Promise.resolve(signedTransaction).then(function(t) { - return (0, bytes_1.hexlify)(t); - })]; - case 2: - hexTx = _a7.sent(); - tx = this.formatter.transaction(signedTransaction); - if (tx.confirmations == null) { - tx.confirmations = 0; + receipt = _a7.sent(); + if (receipt == null && confirms === 0) { + return [2, null]; } - return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; - case 3: - blockNumber = _a7.sent(); - _a7.label = 4; - case 4: - _a7.trys.push([4, 6, , 7]); - return [4, this.perform("sendTransaction", { signedTransaction: hexTx })]; - case 5: - hash = _a7.sent(); - return [2, this._wrapTransaction(tx, hash, blockNumber)]; - case 6: - error_7 = _a7.sent(); - error_7.transaction = tx; - error_7.transactionHash = tx.hash; - throw error_7; - case 7: - return [ - 2 - /*return*/ - ]; + this._emitted["t:" + tx.hash] = receipt.blockNumber; + if (receipt.status === 0) { + logger2.throwError("transaction failed", logger_1.Logger.errors.CALL_EXCEPTION, { + transactionHash: tx.hash, + transaction: tx, + receipt + }); + } + return [2, receipt]; } }); }); }; - BaseProvider3.prototype._getTransactionRequest = function(transaction) { - return __awaiter2(this, void 0, void 0, function() { - var values, tx, _a7, _b; - var _this = this; - return __generator2(this, function(_c) { - switch (_c.label) { - case 0: - return [4, transaction]; - case 1: - values = _c.sent(); - tx = {}; - ["from", "to"].forEach(function(key) { - if (values[key] == null) { - return; - } - tx[key] = Promise.resolve(values[key]).then(function(v) { - return v ? _this._getAddress(v) : null; - }); + return result; + }; + BaseProvider3.prototype.sendTransaction = function(signedTransaction) { + return __awaiter(this, void 0, void 0, function() { + var hexTx, tx, blockNumber, hash, error_7; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, Promise.resolve(signedTransaction).then(function(t) { + return (0, bytes_1.hexlify)(t); + })]; + case 2: + hexTx = _a7.sent(); + tx = this.formatter.transaction(signedTransaction); + if (tx.confirmations == null) { + tx.confirmations = 0; + } + return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; + case 3: + blockNumber = _a7.sent(); + _a7.label = 4; + case 4: + _a7.trys.push([4, 6, , 7]); + return [4, this.perform("sendTransaction", { signedTransaction: hexTx })]; + case 5: + hash = _a7.sent(); + return [2, this._wrapTransaction(tx, hash, blockNumber)]; + case 6: + error_7 = _a7.sent(); + error_7.transaction = tx; + error_7.transactionHash = tx.hash; + throw error_7; + case 7: + return [2]; + } + }); + }); + }; + BaseProvider3.prototype._getTransactionRequest = function(transaction) { + return __awaiter(this, void 0, void 0, function() { + var values, tx, _a7, _b; + var _this = this; + return __generator(this, function(_c) { + switch (_c.label) { + case 0: + return [4, transaction]; + case 1: + values = _c.sent(); + tx = {}; + ["from", "to"].forEach(function(key) { + if (values[key] == null) { + return; + } + tx[key] = Promise.resolve(values[key]).then(function(v) { + return v ? _this._getAddress(v) : null; }); - ["gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "value"].forEach(function(key) { - if (values[key] == null) { - return; - } - tx[key] = Promise.resolve(values[key]).then(function(v) { - return v ? bignumber_1.BigNumber.from(v) : null; - }); + }); + ["gasLimit", "gasPrice", "maxFeePerGas", "maxPriorityFeePerGas", "value"].forEach(function(key) { + if (values[key] == null) { + return; + } + tx[key] = Promise.resolve(values[key]).then(function(v) { + return v ? bignumber_1.BigNumber.from(v) : null; }); - ["type"].forEach(function(key) { - if (values[key] == null) { - return; - } - tx[key] = Promise.resolve(values[key]).then(function(v) { - return v != null ? v : null; - }); + }); + ["type"].forEach(function(key) { + if (values[key] == null) { + return; + } + tx[key] = Promise.resolve(values[key]).then(function(v) { + return v != null ? v : null; }); - if (values.accessList) { - tx.accessList = this.formatter.accessList(values.accessList); + }); + if (values.accessList) { + tx.accessList = this.formatter.accessList(values.accessList); + } + ["data"].forEach(function(key) { + if (values[key] == null) { + return; } - ["data"].forEach(function(key) { - if (values[key] == null) { - return; - } - tx[key] = Promise.resolve(values[key]).then(function(v) { - return v ? (0, bytes_1.hexlify)(v) : null; - }); + tx[key] = Promise.resolve(values[key]).then(function(v) { + return v ? (0, bytes_1.hexlify)(v) : null; }); - _b = (_a7 = this.formatter).transactionRequest; - return [4, (0, properties_1.resolveProperties)(tx)]; - case 2: - return [2, _b.apply(_a7, [_c.sent()])]; - } - }); + }); + _b = (_a7 = this.formatter).transactionRequest; + return [4, (0, properties_1.resolveProperties)(tx)]; + case 2: + return [2, _b.apply(_a7, [_c.sent()])]; + } }); - }; - BaseProvider3.prototype._getFilter = function(filter) { - return __awaiter2(this, void 0, void 0, function() { - var result, _a7, _b; - var _this = this; - return __generator2(this, function(_c) { - switch (_c.label) { - case 0: - return [4, filter]; - case 1: - filter = _c.sent(); - result = {}; - if (filter.address != null) { - result.address = this._getAddress(filter.address); + }); + }; + BaseProvider3.prototype._getFilter = function(filter) { + return __awaiter(this, void 0, void 0, function() { + var result, _a7, _b; + var _this = this; + return __generator(this, function(_c) { + switch (_c.label) { + case 0: + return [4, filter]; + case 1: + filter = _c.sent(); + result = {}; + if (filter.address != null) { + result.address = this._getAddress(filter.address); + } + ["blockHash", "topics"].forEach(function(key) { + if (filter[key] == null) { + return; } - ["blockHash", "topics"].forEach(function(key) { - if (filter[key] == null) { - return; - } - result[key] = filter[key]; - }); - ["fromBlock", "toBlock"].forEach(function(key) { - if (filter[key] == null) { - return; - } - result[key] = _this._getBlockTag(filter[key]); - }); - _b = (_a7 = this.formatter).filter; - return [4, (0, properties_1.resolveProperties)(result)]; - case 2: - return [2, _b.apply(_a7, [_c.sent()])]; - } - }); + result[key] = filter[key]; + }); + ["fromBlock", "toBlock"].forEach(function(key) { + if (filter[key] == null) { + return; + } + result[key] = _this._getBlockTag(filter[key]); + }); + _b = (_a7 = this.formatter).filter; + return [4, (0, properties_1.resolveProperties)(result)]; + case 2: + return [2, _b.apply(_a7, [_c.sent()])]; + } }); - }; - BaseProvider3.prototype.call = function(transaction, blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ - transaction: this._getTransactionRequest(transaction), - blockTag: this._getBlockTag(blockTag) + }); + }; + BaseProvider3.prototype.call = function(transaction, blockTag) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ + transaction: this._getTransactionRequest(transaction), + blockTag: this._getBlockTag(blockTag) + })]; + case 2: + params = _a7.sent(); + return [4, this.perform("call", params)]; + case 3: + result = _a7.sent(); + try { + return [2, (0, bytes_1.hexlify)(result)]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "call", + params, + result, + error })]; - case 2: - params = _a7.sent(); - return [4, this.perform("call", params)]; - case 3: - result = _a7.sent(); - try { - return [2, (0, bytes_1.hexlify)(result)]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "call", - params, - result, - error - })]; - } - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2]; + } }); - }; - BaseProvider3.prototype.estimateGas = function(transaction) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ - transaction: this._getTransactionRequest(transaction) + }); + }; + BaseProvider3.prototype.estimateGas = function(transaction) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ + transaction: this._getTransactionRequest(transaction) + })]; + case 2: + params = _a7.sent(); + return [4, this.perform("estimateGas", params)]; + case 3: + result = _a7.sent(); + try { + return [2, bignumber_1.BigNumber.from(result)]; + } catch (error) { + return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { + method: "estimateGas", + params, + result, + error })]; - case 2: - params = _a7.sent(); - return [4, this.perform("estimateGas", params)]; - case 3: - result = _a7.sent(); - try { - return [2, bignumber_1.BigNumber.from(result)]; - } catch (error) { - return [2, logger2.throwError("bad result from backend", logger_1.Logger.errors.SERVER_ERROR, { - method: "estimateGas", - params, - result, - error - })]; - } - return [ - 2 - /*return*/ - ]; - } - }); + } + return [2]; + } }); - }; - BaseProvider3.prototype._getAddress = function(addressOrName) { - return __awaiter2(this, void 0, void 0, function() { - var address; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, addressOrName]; - case 1: - addressOrName = _a7.sent(); - if (typeof addressOrName !== "string") { - logger2.throwArgumentError("invalid address or ENS name", "name", addressOrName); - } - return [4, this.resolveName(addressOrName)]; - case 2: - address = _a7.sent(); - if (address == null) { - logger2.throwError("ENS name not configured", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "resolveName(" + JSON.stringify(addressOrName) + ")" - }); - } - return [2, address]; - } - }); + }); + }; + BaseProvider3.prototype._getAddress = function(addressOrName) { + return __awaiter(this, void 0, void 0, function() { + var address; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, addressOrName]; + case 1: + addressOrName = _a7.sent(); + if (typeof addressOrName !== "string") { + logger2.throwArgumentError("invalid address or ENS name", "name", addressOrName); + } + return [4, this.resolveName(addressOrName)]; + case 2: + address = _a7.sent(); + if (address == null) { + logger2.throwError("ENS name not configured", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "resolveName(" + JSON.stringify(addressOrName) + ")" + }); + } + return [2, address]; + } }); - }; - BaseProvider3.prototype._getBlock = function(blockHashOrBlockTag, includeTransactions) { - return __awaiter2(this, void 0, void 0, function() { - var blockNumber, params, _a7, error_8; - var _this = this; - return __generator2(this, function(_b) { - switch (_b.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _b.sent(); - return [4, blockHashOrBlockTag]; - case 2: - blockHashOrBlockTag = _b.sent(); - blockNumber = -128; - params = { - includeTransactions: !!includeTransactions - }; - if (!(0, bytes_1.isHexString)(blockHashOrBlockTag, 32)) - return [3, 3]; - params.blockHash = blockHashOrBlockTag; - return [3, 6]; - case 3: - _b.trys.push([3, 5, , 6]); - _a7 = params; - return [4, this._getBlockTag(blockHashOrBlockTag)]; - case 4: - _a7.blockTag = _b.sent(); - if ((0, bytes_1.isHexString)(params.blockTag)) { - blockNumber = parseInt(params.blockTag.substring(2), 16); - } - return [3, 6]; - case 5: - error_8 = _b.sent(); - logger2.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); - return [3, 6]; - case 6: - return [2, (0, web_1.poll)(function() { - return __awaiter2(_this, void 0, void 0, function() { - var block, blockNumber_1, i, tx, confirmations, blockWithTxs; - var _this2 = this; - return __generator2(this, function(_a8) { - switch (_a8.label) { - case 0: - return [4, this.perform("getBlock", params)]; - case 1: - block = _a8.sent(); - if (block == null) { - if (params.blockHash != null) { - if (this._emitted["b:" + params.blockHash] == null) { - return [2, null]; - } + }); + }; + BaseProvider3.prototype._getBlock = function(blockHashOrBlockTag, includeTransactions) { + return __awaiter(this, void 0, void 0, function() { + var blockNumber, params, _a7, error_8; + var _this = this; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _b.sent(); + return [4, blockHashOrBlockTag]; + case 2: + blockHashOrBlockTag = _b.sent(); + blockNumber = -128; + params = { + includeTransactions: !!includeTransactions + }; + if (!(0, bytes_1.isHexString)(blockHashOrBlockTag, 32)) + return [3, 3]; + params.blockHash = blockHashOrBlockTag; + return [3, 6]; + case 3: + _b.trys.push([3, 5, , 6]); + _a7 = params; + return [4, this._getBlockTag(blockHashOrBlockTag)]; + case 4: + _a7.blockTag = _b.sent(); + if ((0, bytes_1.isHexString)(params.blockTag)) { + blockNumber = parseInt(params.blockTag.substring(2), 16); + } + return [3, 6]; + case 5: + error_8 = _b.sent(); + logger2.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + return [3, 6]; + case 6: + return [2, (0, web_1.poll)(function() { + return __awaiter(_this, void 0, void 0, function() { + var block, blockNumber_1, i, tx, confirmations, blockWithTxs; + var _this2 = this; + return __generator(this, function(_a8) { + switch (_a8.label) { + case 0: + return [4, this.perform("getBlock", params)]; + case 1: + block = _a8.sent(); + if (block == null) { + if (params.blockHash != null) { + if (this._emitted["b:" + params.blockHash] == null) { + return [2, null]; } - if (params.blockTag != null) { - if (blockNumber > this._emitted.block) { - return [2, null]; - } + } + if (params.blockTag != null) { + if (blockNumber > this._emitted.block) { + return [2, null]; } - return [2, void 0]; } - if (!includeTransactions) - return [3, 8]; - blockNumber_1 = null; - i = 0; - _a8.label = 2; - case 2: - if (!(i < block.transactions.length)) - return [3, 7]; - tx = block.transactions[i]; - if (!(tx.blockNumber == null)) - return [3, 3]; - tx.confirmations = 0; + return [2, void 0]; + } + if (!includeTransactions) + return [3, 8]; + blockNumber_1 = null; + i = 0; + _a8.label = 2; + case 2: + if (!(i < block.transactions.length)) + return [3, 7]; + tx = block.transactions[i]; + if (!(tx.blockNumber == null)) + return [3, 3]; + tx.confirmations = 0; + return [3, 6]; + case 3: + if (!(tx.confirmations == null)) return [3, 6]; - case 3: - if (!(tx.confirmations == null)) - return [3, 6]; - if (!(blockNumber_1 == null)) - return [3, 5]; - return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; - case 4: - blockNumber_1 = _a8.sent(); - _a8.label = 5; - case 5: - confirmations = blockNumber_1 - tx.blockNumber + 1; - if (confirmations <= 0) { - confirmations = 1; - } - tx.confirmations = confirmations; - _a8.label = 6; - case 6: - i++; - return [3, 2]; - case 7: - blockWithTxs = this.formatter.blockWithTransactions(block); - blockWithTxs.transactions = blockWithTxs.transactions.map(function(tx2) { - return _this2._wrapTransaction(tx2); - }); - return [2, blockWithTxs]; - case 8: - return [2, this.formatter.block(block)]; - } - }); + if (!(blockNumber_1 == null)) + return [3, 5]; + return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; + case 4: + blockNumber_1 = _a8.sent(); + _a8.label = 5; + case 5: + confirmations = blockNumber_1 - tx.blockNumber + 1; + if (confirmations <= 0) { + confirmations = 1; + } + tx.confirmations = confirmations; + _a8.label = 6; + case 6: + i++; + return [3, 2]; + case 7: + blockWithTxs = this.formatter.blockWithTransactions(block); + blockWithTxs.transactions = blockWithTxs.transactions.map(function(tx2) { + return _this2._wrapTransaction(tx2); + }); + return [2, blockWithTxs]; + case 8: + return [2, this.formatter.block(block)]; + } }); - }, { oncePoll: this })]; - } - }); + }); + }, { oncePoll: this })]; + } }); - }; - BaseProvider3.prototype.getBlock = function(blockHashOrBlockTag) { - return this._getBlock(blockHashOrBlockTag, false); - }; - BaseProvider3.prototype.getBlockWithTransactions = function(blockHashOrBlockTag) { - return this._getBlock(blockHashOrBlockTag, true); - }; - BaseProvider3.prototype.getTransaction = function(transactionHash) { - return __awaiter2(this, void 0, void 0, function() { - var params; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, transactionHash]; - case 2: - transactionHash = _a7.sent(); - params = { transactionHash: this.formatter.hash(transactionHash, true) }; - return [2, (0, web_1.poll)(function() { - return __awaiter2(_this, void 0, void 0, function() { - var result, tx, blockNumber, confirmations; - return __generator2(this, function(_a8) { - switch (_a8.label) { - case 0: - return [4, this.perform("getTransaction", params)]; - case 1: - result = _a8.sent(); - if (result == null) { - if (this._emitted["t:" + transactionHash] == null) { - return [2, null]; - } - return [2, void 0]; + }); + }; + BaseProvider3.prototype.getBlock = function(blockHashOrBlockTag) { + return this._getBlock(blockHashOrBlockTag, false); + }; + BaseProvider3.prototype.getBlockWithTransactions = function(blockHashOrBlockTag) { + return this._getBlock(blockHashOrBlockTag, true); + }; + BaseProvider3.prototype.getTransaction = function(transactionHash) { + return __awaiter(this, void 0, void 0, function() { + var params; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, transactionHash]; + case 2: + transactionHash = _a7.sent(); + params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return [2, (0, web_1.poll)(function() { + return __awaiter(_this, void 0, void 0, function() { + var result, tx, blockNumber, confirmations; + return __generator(this, function(_a8) { + switch (_a8.label) { + case 0: + return [4, this.perform("getTransaction", params)]; + case 1: + result = _a8.sent(); + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return [2, null]; } - tx = this.formatter.transactionResponse(result); - if (!(tx.blockNumber == null)) - return [3, 2]; - tx.confirmations = 0; + return [2, void 0]; + } + tx = this.formatter.transactionResponse(result); + if (!(tx.blockNumber == null)) + return [3, 2]; + tx.confirmations = 0; + return [3, 4]; + case 2: + if (!(tx.confirmations == null)) return [3, 4]; - case 2: - if (!(tx.confirmations == null)) - return [3, 4]; - return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; - case 3: - blockNumber = _a8.sent(); - confirmations = blockNumber - tx.blockNumber + 1; - if (confirmations <= 0) { - confirmations = 1; - } - tx.confirmations = confirmations; - _a8.label = 4; - case 4: - return [2, this._wrapTransaction(tx)]; - } - }); + return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; + case 3: + blockNumber = _a8.sent(); + confirmations = blockNumber - tx.blockNumber + 1; + if (confirmations <= 0) { + confirmations = 1; + } + tx.confirmations = confirmations; + _a8.label = 4; + case 4: + return [2, this._wrapTransaction(tx)]; + } }); - }, { oncePoll: this })]; - } - }); + }); + }, { oncePoll: this })]; + } }); - }; - BaseProvider3.prototype.getTransactionReceipt = function(transactionHash) { - return __awaiter2(this, void 0, void 0, function() { - var params; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, transactionHash]; - case 2: - transactionHash = _a7.sent(); - params = { transactionHash: this.formatter.hash(transactionHash, true) }; - return [2, (0, web_1.poll)(function() { - return __awaiter2(_this, void 0, void 0, function() { - var result, receipt, blockNumber, confirmations; - return __generator2(this, function(_a8) { - switch (_a8.label) { - case 0: - return [4, this.perform("getTransactionReceipt", params)]; - case 1: - result = _a8.sent(); - if (result == null) { - if (this._emitted["t:" + transactionHash] == null) { - return [2, null]; - } - return [2, void 0]; - } - if (result.blockHash == null) { - return [2, void 0]; + }); + }; + BaseProvider3.prototype.getTransactionReceipt = function(transactionHash) { + return __awaiter(this, void 0, void 0, function() { + var params; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, transactionHash]; + case 2: + transactionHash = _a7.sent(); + params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return [2, (0, web_1.poll)(function() { + return __awaiter(_this, void 0, void 0, function() { + var result, receipt, blockNumber, confirmations; + return __generator(this, function(_a8) { + switch (_a8.label) { + case 0: + return [4, this.perform("getTransactionReceipt", params)]; + case 1: + result = _a8.sent(); + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return [2, null]; } - receipt = this.formatter.receipt(result); - if (!(receipt.blockNumber == null)) - return [3, 2]; - receipt.confirmations = 0; + return [2, void 0]; + } + if (result.blockHash == null) { + return [2, void 0]; + } + receipt = this.formatter.receipt(result); + if (!(receipt.blockNumber == null)) + return [3, 2]; + receipt.confirmations = 0; + return [3, 4]; + case 2: + if (!(receipt.confirmations == null)) return [3, 4]; - case 2: - if (!(receipt.confirmations == null)) - return [3, 4]; - return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; - case 3: - blockNumber = _a8.sent(); - confirmations = blockNumber - receipt.blockNumber + 1; - if (confirmations <= 0) { - confirmations = 1; - } - receipt.confirmations = confirmations; - _a8.label = 4; - case 4: - return [2, receipt]; - } - }); + return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; + case 3: + blockNumber = _a8.sent(); + confirmations = blockNumber - receipt.blockNumber + 1; + if (confirmations <= 0) { + confirmations = 1; + } + receipt.confirmations = confirmations; + _a8.label = 4; + case 4: + return [2, receipt]; + } }); - }, { oncePoll: this })]; - } - }); - }); - }; - BaseProvider3.prototype.getLogs = function(filter) { - return __awaiter2(this, void 0, void 0, function() { - var params, logs; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [4, (0, properties_1.resolveProperties)({ filter: this._getFilter(filter) })]; - case 2: - params = _a7.sent(); - return [4, this.perform("getLogs", params)]; - case 3: - logs = _a7.sent(); - logs.forEach(function(log) { - if (log.removed == null) { - log.removed = false; - } }); - return [2, formatter_1.Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(logs)]; - } - }); - }); - }; - BaseProvider3.prototype.getEtherPrice = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - _a7.sent(); - return [2, this.perform("getEtherPrice", {})]; - } - }); - }); - }; - BaseProvider3.prototype._getBlockTag = function(blockTag) { - return __awaiter2(this, void 0, void 0, function() { - var blockNumber; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, blockTag]; - case 1: - blockTag = _a7.sent(); - if (!(typeof blockTag === "number" && blockTag < 0)) - return [3, 3]; - if (blockTag % 1) { - logger2.throwArgumentError("invalid BlockTag", "blockTag", blockTag); - } - return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; - case 2: - blockNumber = _a7.sent(); - blockNumber += blockTag; - if (blockNumber < 0) { - blockNumber = 0; - } - return [2, this.formatter.blockTag(blockNumber)]; - case 3: - return [2, this.formatter.blockTag(blockTag)]; - } - }); + }, { oncePoll: this })]; + } }); - }; - BaseProvider3.prototype.getResolver = function(name2) { - return __awaiter2(this, void 0, void 0, function() { - var address, error_9; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - _a7.trys.push([0, 2, , 3]); - return [4, this._getResolver(name2)]; - case 1: - address = _a7.sent(); - if (address == null) { - return [2, null]; - } - return [2, new Resolver(this, address, name2)]; - case 2: - error_9 = _a7.sent(); - if (error_9.code === logger_1.Logger.errors.CALL_EXCEPTION) { - return [2, null]; + }); + }; + BaseProvider3.prototype.getLogs = function(filter) { + return __awaiter(this, void 0, void 0, function() { + var params, logs; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [4, (0, properties_1.resolveProperties)({ filter: this._getFilter(filter) })]; + case 2: + params = _a7.sent(); + return [4, this.perform("getLogs", params)]; + case 3: + logs = _a7.sent(); + logs.forEach(function(log) { + if (log.removed == null) { + log.removed = false; } - throw error_9; - case 3: - return [ - 2 - /*return*/ - ]; - } - }); + }); + return [2, formatter_1.Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(logs)]; + } }); - }; - BaseProvider3.prototype._getResolver = function(name2) { - return __awaiter2(this, void 0, void 0, function() { - var network, transaction, _a7, _b, error_10; - return __generator2(this, function(_c) { - switch (_c.label) { - case 0: - return [4, this.getNetwork()]; - case 1: - network = _c.sent(); - if (!network.ensAddress) { - logger2.throwError("network does not support ENS", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); - } - transaction = { - to: network.ensAddress, - data: "0x0178b8bf" + (0, hash_1.namehash)(name2).substring(2) - }; - _c.label = 2; - case 2: - _c.trys.push([2, 4, , 5]); - _b = (_a7 = this.formatter).callAddress; - return [4, this.call(transaction)]; - case 3: - return [2, _b.apply(_a7, [_c.sent()])]; - case 4: - error_10 = _c.sent(); - if (error_10.code === logger_1.Logger.errors.CALL_EXCEPTION) { - return [2, null]; - } - throw error_10; - case 5: - return [ - 2 - /*return*/ - ]; - } - }); + }); + }; + BaseProvider3.prototype.getEtherPrice = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + _a7.sent(); + return [2, this.perform("getEtherPrice", {})]; + } }); - }; - BaseProvider3.prototype.resolveName = function(name2) { - return __awaiter2(this, void 0, void 0, function() { - var resolver; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, name2]; - case 1: - name2 = _a7.sent(); - try { - return [2, Promise.resolve(this.formatter.address(name2))]; - } catch (error) { - if ((0, bytes_1.isHexString)(name2)) { - throw error; - } - } - if (typeof name2 !== "string") { - logger2.throwArgumentError("invalid ENS name", "name", name2); - } - return [4, this.getResolver(name2)]; - case 2: - resolver = _a7.sent(); - if (!resolver) { - return [2, null]; - } - return [4, resolver.getAddress()]; - case 3: - return [2, _a7.sent()]; - } - }); + }); + }; + BaseProvider3.prototype._getBlockTag = function(blockTag) { + return __awaiter(this, void 0, void 0, function() { + var blockNumber; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, blockTag]; + case 1: + blockTag = _a7.sent(); + if (!(typeof blockTag === "number" && blockTag < 0)) + return [3, 3]; + if (blockTag % 1) { + logger2.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + } + return [4, this._getInternalBlockNumber(100 + 2 * this.pollingInterval)]; + case 2: + blockNumber = _a7.sent(); + blockNumber += blockTag; + if (blockNumber < 0) { + blockNumber = 0; + } + return [2, this.formatter.blockTag(blockNumber)]; + case 3: + return [2, this.formatter.blockTag(blockTag)]; + } }); - }; - BaseProvider3.prototype.lookupAddress = function(address) { - return __awaiter2(this, void 0, void 0, function() { - var reverseName, resolverAddress, bytes, _a7, length, name2, addr; - return __generator2(this, function(_b) { - switch (_b.label) { - case 0: - return [4, address]; - case 1: - address = _b.sent(); - address = this.formatter.address(address); - reverseName = address.substring(2).toLowerCase() + ".addr.reverse"; - return [4, this._getResolver(reverseName)]; - case 2: - resolverAddress = _b.sent(); - if (!resolverAddress) { - return [2, null]; - } - _a7 = bytes_1.arrayify; - return [4, this.call({ - to: resolverAddress, - data: "0x691f3431" + (0, hash_1.namehash)(reverseName).substring(2) - })]; - case 3: - bytes = _a7.apply(void 0, [_b.sent()]); - if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) { - return [2, null]; - } - bytes = bytes.slice(32); - if (bytes.length < 32) { - return [2, null]; - } - length = bignumber_1.BigNumber.from(bytes.slice(0, 32)).toNumber(); - bytes = bytes.slice(32); - if (length > bytes.length) { - return [2, null]; - } - name2 = (0, strings_1.toUtf8String)(bytes.slice(0, length)); - return [4, this.resolveName(name2)]; - case 4: - addr = _b.sent(); - if (addr != address) { - return [2, null]; - } - return [2, name2]; - } - }); + }); + }; + BaseProvider3.prototype.getResolver = function(name2) { + return __awaiter(this, void 0, void 0, function() { + var address, error_9; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + _a7.trys.push([0, 2, , 3]); + return [4, this._getResolver(name2)]; + case 1: + address = _a7.sent(); + if (address == null) { + return [2, null]; + } + return [2, new Resolver(this, address, name2)]; + case 2: + error_9 = _a7.sent(); + if (error_9.code === logger_1.Logger.errors.CALL_EXCEPTION) { + return [2, null]; + } + throw error_9; + case 3: + return [2]; + } }); - }; - BaseProvider3.prototype.getAvatar = function(nameOrAddress) { - return __awaiter2(this, void 0, void 0, function() { - var resolver, address, reverseName, resolverAddress, avatar; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - resolver = null; - if (!(0, bytes_1.isHexString)(nameOrAddress)) - return [3, 2]; - address = this.formatter.address(nameOrAddress); - reverseName = address.substring(2).toLowerCase() + ".addr.reverse"; - return [4, this._getResolver(reverseName)]; - case 1: - resolverAddress = _a7.sent(); - if (!resolverAddress) { - return [2, null]; - } - resolver = new Resolver(this, resolverAddress, "_", address); - return [3, 4]; - case 2: - return [4, this.getResolver(nameOrAddress)]; - case 3: - resolver = _a7.sent(); - if (!resolver) { - return [2, null]; - } - _a7.label = 4; - case 4: - return [4, resolver.getAvatar()]; - case 5: - avatar = _a7.sent(); - if (avatar == null) { - return [2, null]; - } - return [2, avatar.url]; - } - }); + }); + }; + BaseProvider3.prototype._getResolver = function(name2) { + return __awaiter(this, void 0, void 0, function() { + var network, transaction, _a7, _b, error_10; + return __generator(this, function(_c) { + switch (_c.label) { + case 0: + return [4, this.getNetwork()]; + case 1: + network = _c.sent(); + if (!network.ensAddress) { + logger2.throwError("network does not support ENS", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); + } + transaction = { + to: network.ensAddress, + data: "0x0178b8bf" + (0, hash_1.namehash)(name2).substring(2) + }; + _c.label = 2; + case 2: + _c.trys.push([2, 4, , 5]); + _b = (_a7 = this.formatter).callAddress; + return [4, this.call(transaction)]; + case 3: + return [2, _b.apply(_a7, [_c.sent()])]; + case 4: + error_10 = _c.sent(); + if (error_10.code === logger_1.Logger.errors.CALL_EXCEPTION) { + return [2, null]; + } + throw error_10; + case 5: + return [2]; + } }); - }; - BaseProvider3.prototype.perform = function(method, params) { - return logger2.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); - }; - BaseProvider3.prototype._startEvent = function(event) { - this.polling = this._events.filter(function(e) { - return e.pollable(); - }).length > 0; - }; - BaseProvider3.prototype._stopEvent = function(event) { - this.polling = this._events.filter(function(e) { - return e.pollable(); - }).length > 0; - }; - BaseProvider3.prototype._addEventListener = function(eventName, listener, once) { - var event = new Event(getEventTag(eventName), listener, once); - this._events.push(event); - this._startEvent(event); - return this; - }; - BaseProvider3.prototype.on = function(eventName, listener) { - return this._addEventListener(eventName, listener, false); - }; - BaseProvider3.prototype.once = function(eventName, listener) { - return this._addEventListener(eventName, listener, true); - }; - BaseProvider3.prototype.emit = function(eventName) { - var _this = this; - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var result = false; - var stopped = []; - var eventTag = getEventTag(eventName); - this._events = this._events.filter(function(event) { - if (event.tag !== eventTag) { - return true; + }); + }; + BaseProvider3.prototype.resolveName = function(name2) { + return __awaiter(this, void 0, void 0, function() { + var resolver; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, name2]; + case 1: + name2 = _a7.sent(); + try { + return [2, Promise.resolve(this.formatter.address(name2))]; + } catch (error) { + if ((0, bytes_1.isHexString)(name2)) { + throw error; + } + } + if (typeof name2 !== "string") { + logger2.throwArgumentError("invalid ENS name", "name", name2); + } + return [4, this.getResolver(name2)]; + case 2: + resolver = _a7.sent(); + if (!resolver) { + return [2, null]; + } + return [4, resolver.getAddress()]; + case 3: + return [2, _a7.sent()]; } - setTimeout(function() { - event.listener.apply(_this, args); - }, 0); - result = true; - if (event.once) { - stopped.push(event); - return false; + }); + }); + }; + BaseProvider3.prototype.lookupAddress = function(address) { + return __awaiter(this, void 0, void 0, function() { + var reverseName, resolverAddress, bytes, _a7, length, name2, addr; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + return [4, address]; + case 1: + address = _b.sent(); + address = this.formatter.address(address); + reverseName = address.substring(2).toLowerCase() + ".addr.reverse"; + return [4, this._getResolver(reverseName)]; + case 2: + resolverAddress = _b.sent(); + if (!resolverAddress) { + return [2, null]; + } + _a7 = bytes_1.arrayify; + return [4, this.call({ + to: resolverAddress, + data: "0x691f3431" + (0, hash_1.namehash)(reverseName).substring(2) + })]; + case 3: + bytes = _a7.apply(void 0, [_b.sent()]); + if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) { + return [2, null]; + } + bytes = bytes.slice(32); + if (bytes.length < 32) { + return [2, null]; + } + length = bignumber_1.BigNumber.from(bytes.slice(0, 32)).toNumber(); + bytes = bytes.slice(32); + if (length > bytes.length) { + return [2, null]; + } + name2 = (0, strings_1.toUtf8String)(bytes.slice(0, length)); + return [4, this.resolveName(name2)]; + case 4: + addr = _b.sent(); + if (addr != address) { + return [2, null]; + } + return [2, name2]; } - return true; }); - stopped.forEach(function(event) { - _this._stopEvent(event); + }); + }; + BaseProvider3.prototype.getAvatar = function(nameOrAddress) { + return __awaiter(this, void 0, void 0, function() { + var resolver, address, reverseName, resolverAddress, avatar; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + resolver = null; + if (!(0, bytes_1.isHexString)(nameOrAddress)) + return [3, 2]; + address = this.formatter.address(nameOrAddress); + reverseName = address.substring(2).toLowerCase() + ".addr.reverse"; + return [4, this._getResolver(reverseName)]; + case 1: + resolverAddress = _a7.sent(); + if (!resolverAddress) { + return [2, null]; + } + resolver = new Resolver(this, resolverAddress, "_", address); + return [3, 4]; + case 2: + return [4, this.getResolver(nameOrAddress)]; + case 3: + resolver = _a7.sent(); + if (!resolver) { + return [2, null]; + } + _a7.label = 4; + case 4: + return [4, resolver.getAvatar()]; + case 5: + avatar = _a7.sent(); + if (avatar == null) { + return [2, null]; + } + return [2, avatar.url]; + } }); - return result; - }; - BaseProvider3.prototype.listenerCount = function(eventName) { - if (!eventName) { - return this._events.length; - } - var eventTag = getEventTag(eventName); - return this._events.filter(function(event) { - return event.tag === eventTag; - }).length; - }; - BaseProvider3.prototype.listeners = function(eventName) { - if (eventName == null) { - return this._events.map(function(event) { - return event.listener; - }); + }); + }; + BaseProvider3.prototype.perform = function(method, params) { + return logger2.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); + }; + BaseProvider3.prototype._startEvent = function(event) { + this.polling = this._events.filter(function(e) { + return e.pollable(); + }).length > 0; + }; + BaseProvider3.prototype._stopEvent = function(event) { + this.polling = this._events.filter(function(e) { + return e.pollable(); + }).length > 0; + }; + BaseProvider3.prototype._addEventListener = function(eventName, listener, once) { + var event = new Event(getEventTag(eventName), listener, once); + this._events.push(event); + this._startEvent(event); + return this; + }; + BaseProvider3.prototype.on = function(eventName, listener) { + return this._addEventListener(eventName, listener, false); + }; + BaseProvider3.prototype.once = function(eventName, listener) { + return this._addEventListener(eventName, listener, true); + }; + BaseProvider3.prototype.emit = function(eventName) { + var _this = this; + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var result = false; + var stopped = []; + var eventTag = getEventTag(eventName); + this._events = this._events.filter(function(event) { + if (event.tag !== eventTag) { + return true; + } + setTimeout(function() { + event.listener.apply(_this, args); + }, 0); + result = true; + if (event.once) { + stopped.push(event); + return false; } - var eventTag = getEventTag(eventName); - return this._events.filter(function(event) { - return event.tag === eventTag; - }).map(function(event) { + return true; + }); + stopped.forEach(function(event) { + _this._stopEvent(event); + }); + return result; + }; + BaseProvider3.prototype.listenerCount = function(eventName) { + if (!eventName) { + return this._events.length; + } + var eventTag = getEventTag(eventName); + return this._events.filter(function(event) { + return event.tag === eventTag; + }).length; + }; + BaseProvider3.prototype.listeners = function(eventName) { + if (eventName == null) { + return this._events.map(function(event) { return event.listener; }); - }; - BaseProvider3.prototype.off = function(eventName, listener) { - var _this = this; - if (listener == null) { - return this.removeAllListeners(eventName); + } + var eventTag = getEventTag(eventName); + return this._events.filter(function(event) { + return event.tag === eventTag; + }).map(function(event) { + return event.listener; + }); + }; + BaseProvider3.prototype.off = function(eventName, listener) { + var _this = this; + if (listener == null) { + return this.removeAllListeners(eventName); + } + var stopped = []; + var found = false; + var eventTag = getEventTag(eventName); + this._events = this._events.filter(function(event) { + if (event.tag !== eventTag || event.listener != listener) { + return true; + } + if (found) { + return true; } - var stopped = []; - var found = false; - var eventTag = getEventTag(eventName); + found = true; + stopped.push(event); + return false; + }); + stopped.forEach(function(event) { + _this._stopEvent(event); + }); + return this; + }; + BaseProvider3.prototype.removeAllListeners = function(eventName) { + var _this = this; + var stopped = []; + if (eventName == null) { + stopped = this._events; + this._events = []; + } else { + var eventTag_1 = getEventTag(eventName); this._events = this._events.filter(function(event) { - if (event.tag !== eventTag || event.listener != listener) { + if (event.tag !== eventTag_1) { return true; } - if (found) { - return true; - } - found = true; stopped.push(event); return false; }); - stopped.forEach(function(event) { - _this._stopEvent(event); - }); - return this; - }; - BaseProvider3.prototype.removeAllListeners = function(eventName) { - var _this = this; - var stopped = []; - if (eventName == null) { - stopped = this._events; - this._events = []; - } else { - var eventTag_1 = getEventTag(eventName); - this._events = this._events.filter(function(event) { - if (event.tag !== eventTag_1) { - return true; - } - stopped.push(event); - return false; - }); - } - stopped.forEach(function(event) { - _this._stopEvent(event); - }); - return this; - }; - return BaseProvider3; - }(abstract_provider_1.Provider) - ); + } + stopped.forEach(function(event) { + _this._stopEvent(event); + }); + return this; + }; + return BaseProvider3; + }(abstract_provider_1.Provider); exports2.BaseProvider = BaseProvider2; } }); @@ -26021,28 +25728,28 @@ var require_base_provider = __commonJS({ var require_json_rpc_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/json-rpc-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -26069,7 +25776,7 @@ var require_json_rpc_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -26239,271 +25946,262 @@ var require_json_rpc_provider = __commonJS({ return value; } var _constructorGuard = {}; - var JsonRpcSigner = ( - /** @class */ - function(_super) { - __extends2(JsonRpcSigner2, _super); - function JsonRpcSigner2(constructorGuard, provider, addressOrIndex) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, JsonRpcSigner2); - _this = _super.call(this) || this; - if (constructorGuard !== _constructorGuard) { - throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); - } - (0, properties_1.defineReadOnly)(_this, "provider", provider); - if (addressOrIndex == null) { - addressOrIndex = 0; - } - if (typeof addressOrIndex === "string") { - (0, properties_1.defineReadOnly)(_this, "_address", _this.provider.formatter.address(addressOrIndex)); - (0, properties_1.defineReadOnly)(_this, "_index", null); - } else if (typeof addressOrIndex === "number") { - (0, properties_1.defineReadOnly)(_this, "_index", addressOrIndex); - (0, properties_1.defineReadOnly)(_this, "_address", null); - } else { - logger2.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); - } - return _this; + var JsonRpcSigner = function(_super) { + __extends(JsonRpcSigner2, _super); + function JsonRpcSigner2(constructorGuard, provider, addressOrIndex) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, JsonRpcSigner2); + _this = _super.call(this) || this; + if (constructorGuard !== _constructorGuard) { + throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); + } + (0, properties_1.defineReadOnly)(_this, "provider", provider); + if (addressOrIndex == null) { + addressOrIndex = 0; + } + if (typeof addressOrIndex === "string") { + (0, properties_1.defineReadOnly)(_this, "_address", _this.provider.formatter.address(addressOrIndex)); + (0, properties_1.defineReadOnly)(_this, "_index", null); + } else if (typeof addressOrIndex === "number") { + (0, properties_1.defineReadOnly)(_this, "_index", addressOrIndex); + (0, properties_1.defineReadOnly)(_this, "_address", null); + } else { + logger2.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); } - JsonRpcSigner2.prototype.connect = function(provider) { - return logger2.throwError("cannot alter JSON-RPC Signer connection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "connect" - }); - }; - JsonRpcSigner2.prototype.connectUnchecked = function() { - return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); - }; - JsonRpcSigner2.prototype.getAddress = function() { - var _this = this; - if (this._address) { - return Promise.resolve(this._address); + return _this; + } + JsonRpcSigner2.prototype.connect = function(provider) { + return logger2.throwError("cannot alter JSON-RPC Signer connection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "connect" + }); + }; + JsonRpcSigner2.prototype.connectUnchecked = function() { + return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); + }; + JsonRpcSigner2.prototype.getAddress = function() { + var _this = this; + if (this._address) { + return Promise.resolve(this._address); + } + return this.provider.send("eth_accounts", []).then(function(accounts) { + if (accounts.length <= _this._index) { + logger2.throwError("unknown account #" + _this._index, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getAddress" + }); } - return this.provider.send("eth_accounts", []).then(function(accounts) { - if (accounts.length <= _this._index) { - logger2.throwError("unknown account #" + _this._index, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "getAddress" + return _this.provider.formatter.address(accounts[_this._index]); + }); + }; + JsonRpcSigner2.prototype.sendUncheckedTransaction = function(transaction) { + var _this = this; + transaction = (0, properties_1.shallowCopy)(transaction); + var fromAddress = this.getAddress().then(function(address) { + if (address) { + address = address.toLowerCase(); + } + return address; + }); + if (transaction.gasLimit == null) { + var estimate = (0, properties_1.shallowCopy)(transaction); + estimate.from = fromAddress; + transaction.gasLimit = this.provider.estimateGas(estimate); + } + if (transaction.to != null) { + transaction.to = Promise.resolve(transaction.to).then(function(to) { + return __awaiter(_this, void 0, void 0, function() { + var address; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (to == null) { + return [2, null]; + } + return [4, this.provider.resolveName(to)]; + case 1: + address = _a7.sent(); + if (address == null) { + logger2.throwArgumentError("provided ENS name resolves to null", "tx.to", to); + } + return [2, address]; + } }); + }); + }); + } + return (0, properties_1.resolveProperties)({ + tx: (0, properties_1.resolveProperties)(transaction), + sender: fromAddress + }).then(function(_a7) { + var tx = _a7.tx, sender = _a7.sender; + if (tx.from != null) { + if (tx.from.toLowerCase() !== sender) { + logger2.throwArgumentError("from address mismatch", "transaction", transaction); } - return _this.provider.formatter.address(accounts[_this._index]); + } else { + tx.from = sender; + } + var hexTx = _this.provider.constructor.hexlifyTransaction(tx, { from: true }); + return _this.provider.send("eth_sendTransaction", [hexTx]).then(function(hash) { + return hash; + }, function(error) { + return checkError("sendTransaction", error, hexTx); }); - }; - JsonRpcSigner2.prototype.sendUncheckedTransaction = function(transaction) { + }); + }; + JsonRpcSigner2.prototype.signTransaction = function(transaction) { + return logger2.throwError("signing transactions is unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "signTransaction" + }); + }; + JsonRpcSigner2.prototype.sendTransaction = function(transaction) { + return __awaiter(this, void 0, void 0, function() { + var blockNumber, hash, error_1; var _this = this; - transaction = (0, properties_1.shallowCopy)(transaction); - var fromAddress = this.getAddress().then(function(address) { - if (address) { - address = address.toLowerCase(); - } - return address; - }); - if (transaction.gasLimit == null) { - var estimate = (0, properties_1.shallowCopy)(transaction); - estimate.from = fromAddress; - transaction.gasLimit = this.provider.estimateGas(estimate); - } - if (transaction.to != null) { - transaction.to = Promise.resolve(transaction.to).then(function(to) { - return __awaiter2(_this, void 0, void 0, function() { - var address; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (to == null) { - return [2, null]; - } - return [4, this.provider.resolveName(to)]; - case 1: - address = _a7.sent(); - if (address == null) { - logger2.throwArgumentError("provided ENS name resolves to null", "tx.to", to); + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval)]; + case 1: + blockNumber = _a7.sent(); + return [4, this.sendUncheckedTransaction(transaction)]; + case 2: + hash = _a7.sent(); + _a7.label = 3; + case 3: + _a7.trys.push([3, 5, , 6]); + return [4, (0, web_1.poll)(function() { + return __awaiter(_this, void 0, void 0, function() { + var tx; + return __generator(this, function(_a8) { + switch (_a8.label) { + case 0: + return [4, this.provider.getTransaction(hash)]; + case 1: + tx = _a8.sent(); + if (tx === null) { + return [2, void 0]; + } + return [2, this.provider._wrapTransaction(tx, hash, blockNumber)]; } - return [2, address]; - } - }); - }); - }); - } - return (0, properties_1.resolveProperties)({ - tx: (0, properties_1.resolveProperties)(transaction), - sender: fromAddress - }).then(function(_a7) { - var tx = _a7.tx, sender = _a7.sender; - if (tx.from != null) { - if (tx.from.toLowerCase() !== sender) { - logger2.throwArgumentError("from address mismatch", "transaction", transaction); - } - } else { - tx.from = sender; - } - var hexTx = _this.provider.constructor.hexlifyTransaction(tx, { from: true }); - return _this.provider.send("eth_sendTransaction", [hexTx]).then(function(hash) { - return hash; - }, function(error) { - return checkError("sendTransaction", error, hexTx); - }); - }); - }; - JsonRpcSigner2.prototype.signTransaction = function(transaction) { - return logger2.throwError("signing transactions is unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "signTransaction" - }); - }; - JsonRpcSigner2.prototype.sendTransaction = function(transaction) { - return __awaiter2(this, void 0, void 0, function() { - var blockNumber, hash, error_1; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, this.provider._getInternalBlockNumber(100 + 2 * this.provider.pollingInterval)]; - case 1: - blockNumber = _a7.sent(); - return [4, this.sendUncheckedTransaction(transaction)]; - case 2: - hash = _a7.sent(); - _a7.label = 3; - case 3: - _a7.trys.push([3, 5, , 6]); - return [4, (0, web_1.poll)(function() { - return __awaiter2(_this, void 0, void 0, function() { - var tx; - return __generator2(this, function(_a8) { - switch (_a8.label) { - case 0: - return [4, this.provider.getTransaction(hash)]; - case 1: - tx = _a8.sent(); - if (tx === null) { - return [2, void 0]; - } - return [2, this.provider._wrapTransaction(tx, hash, blockNumber)]; - } - }); }); - }, { oncePoll: this.provider })]; - case 4: - return [2, _a7.sent()]; - case 5: - error_1 = _a7.sent(); - error_1.transactionHash = hash; - throw error_1; - case 6: - return [ - 2 - /*return*/ - ]; - } - }); + }); + }, { oncePoll: this.provider })]; + case 4: + return [2, _a7.sent()]; + case 5: + error_1 = _a7.sent(); + error_1.transactionHash = hash; + throw error_1; + case 6: + return [2]; + } }); - }; - JsonRpcSigner2.prototype.signMessage = function(message) { - return __awaiter2(this, void 0, void 0, function() { - var data, address; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - data = typeof message === "string" ? (0, strings_1.toUtf8Bytes)(message) : message; - return [4, this.getAddress()]; - case 1: - address = _a7.sent(); - return [4, this.provider.send("personal_sign", [(0, bytes_1.hexlify)(data), address.toLowerCase()])]; - case 2: - return [2, _a7.sent()]; - } - }); + }); + }; + JsonRpcSigner2.prototype.signMessage = function(message) { + return __awaiter(this, void 0, void 0, function() { + var data, address; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + data = typeof message === "string" ? (0, strings_1.toUtf8Bytes)(message) : message; + return [4, this.getAddress()]; + case 1: + address = _a7.sent(); + return [4, this.provider.send("personal_sign", [(0, bytes_1.hexlify)(data), address.toLowerCase()])]; + case 2: + return [2, _a7.sent()]; + } }); - }; - JsonRpcSigner2.prototype._legacySignMessage = function(message) { - return __awaiter2(this, void 0, void 0, function() { - var data, address; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - data = typeof message === "string" ? (0, strings_1.toUtf8Bytes)(message) : message; - return [4, this.getAddress()]; - case 1: - address = _a7.sent(); - return [4, this.provider.send("eth_sign", [address.toLowerCase(), (0, bytes_1.hexlify)(data)])]; - case 2: - return [2, _a7.sent()]; - } - }); + }); + }; + JsonRpcSigner2.prototype._legacySignMessage = function(message) { + return __awaiter(this, void 0, void 0, function() { + var data, address; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + data = typeof message === "string" ? (0, strings_1.toUtf8Bytes)(message) : message; + return [4, this.getAddress()]; + case 1: + address = _a7.sent(); + return [4, this.provider.send("eth_sign", [address.toLowerCase(), (0, bytes_1.hexlify)(data)])]; + case 2: + return [2, _a7.sent()]; + } }); - }; - JsonRpcSigner2.prototype._signTypedData = function(domain, types, value) { - return __awaiter2(this, void 0, void 0, function() { - var populated, address; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function(name2) { - return _this.provider.resolveName(name2); - })]; - case 1: - populated = _a7.sent(); - return [4, this.getAddress()]; - case 2: - address = _a7.sent(); - return [4, this.provider.send("eth_signTypedData_v4", [ - address.toLowerCase(), - JSON.stringify(hash_1._TypedDataEncoder.getPayload(populated.domain, types, populated.value)) - ])]; - case 3: - return [2, _a7.sent()]; - } - }); + }); + }; + JsonRpcSigner2.prototype._signTypedData = function(domain, types, value) { + return __awaiter(this, void 0, void 0, function() { + var populated, address; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, hash_1._TypedDataEncoder.resolveNames(domain, types, value, function(name2) { + return _this.provider.resolveName(name2); + })]; + case 1: + populated = _a7.sent(); + return [4, this.getAddress()]; + case 2: + address = _a7.sent(); + return [4, this.provider.send("eth_signTypedData_v4", [ + address.toLowerCase(), + JSON.stringify(hash_1._TypedDataEncoder.getPayload(populated.domain, types, populated.value)) + ])]; + case 3: + return [2, _a7.sent()]; + } }); - }; - JsonRpcSigner2.prototype.unlock = function(password) { - return __awaiter2(this, void 0, void 0, function() { - var provider, address; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - provider = this.provider; - return [4, this.getAddress()]; - case 1: - address = _a7.sent(); - return [2, provider.send("personal_unlockAccount", [address.toLowerCase(), password, null])]; - } - }); + }); + }; + JsonRpcSigner2.prototype.unlock = function(password) { + return __awaiter(this, void 0, void 0, function() { + var provider, address; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + provider = this.provider; + return [4, this.getAddress()]; + case 1: + address = _a7.sent(); + return [2, provider.send("personal_unlockAccount", [address.toLowerCase(), password, null])]; + } }); - }; - return JsonRpcSigner2; - }(abstract_signer_1.Signer) - ); + }); + }; + return JsonRpcSigner2; + }(abstract_signer_1.Signer); exports2.JsonRpcSigner = JsonRpcSigner; - var UncheckedJsonRpcSigner = ( - /** @class */ - function(_super) { - __extends2(UncheckedJsonRpcSigner2, _super); - function UncheckedJsonRpcSigner2() { - return _super !== null && _super.apply(this, arguments) || this; - } - UncheckedJsonRpcSigner2.prototype.sendTransaction = function(transaction) { - var _this = this; - return this.sendUncheckedTransaction(transaction).then(function(hash) { - return { - hash, - nonce: null, - gasLimit: null, - gasPrice: null, - data: null, - value: null, - chainId: null, - confirmations: 0, - from: null, - wait: function(confirmations) { - return _this.provider.waitForTransaction(hash, confirmations); - } - }; - }); - }; - return UncheckedJsonRpcSigner2; - }(JsonRpcSigner) - ); + var UncheckedJsonRpcSigner = function(_super) { + __extends(UncheckedJsonRpcSigner2, _super); + function UncheckedJsonRpcSigner2() { + return _super !== null && _super.apply(this, arguments) || this; + } + UncheckedJsonRpcSigner2.prototype.sendTransaction = function(transaction) { + var _this = this; + return this.sendUncheckedTransaction(transaction).then(function(hash) { + return { + hash, + nonce: null, + gasLimit: null, + gasPrice: null, + data: null, + value: null, + chainId: null, + confirmations: 0, + from: null, + wait: function(confirmations) { + return _this.provider.waitForTransaction(hash, confirmations); + } + }; + }); + }; + return UncheckedJsonRpcSigner2; + }(JsonRpcSigner); var allowedTransactionKeys = { chainId: true, data: true, @@ -26517,350 +26215,344 @@ var require_json_rpc_provider = __commonJS({ maxFeePerGas: true, maxPriorityFeePerGas: true }; - var JsonRpcProvider = ( - /** @class */ - function(_super) { - __extends2(JsonRpcProvider2, _super); - function JsonRpcProvider2(url, network) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, JsonRpcProvider2); - var networkOrReady = network; - if (networkOrReady == null) { - networkOrReady = new Promise(function(resolve, reject) { - setTimeout(function() { - _this.detectNetwork().then(function(network2) { - resolve(network2); - }, function(error) { - reject(error); - }); - }, 0); - }); - } - _this = _super.call(this, networkOrReady) || this; - if (!url) { - url = (0, properties_1.getStatic)(_this.constructor, "defaultUrl")(); - } - if (typeof url === "string") { - (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze({ - url - })); - } else { - (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze((0, properties_1.shallowCopy)(url))); - } - _this._nextId = 42; - return _this; - } - Object.defineProperty(JsonRpcProvider2.prototype, "_cache", { - get: function() { - if (this._eventLoopCache == null) { - this._eventLoopCache = {}; - } - return this._eventLoopCache; - }, - enumerable: false, - configurable: true - }); - JsonRpcProvider2.defaultUrl = function() { - return "http://localhost:8545"; - }; - JsonRpcProvider2.prototype.detectNetwork = function() { - var _this = this; - if (!this._cache["detectNetwork"]) { - this._cache["detectNetwork"] = this._uncachedDetectNetwork(); + var JsonRpcProvider = function(_super) { + __extends(JsonRpcProvider2, _super); + function JsonRpcProvider2(url, network) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, JsonRpcProvider2); + var networkOrReady = network; + if (networkOrReady == null) { + networkOrReady = new Promise(function(resolve, reject) { setTimeout(function() { - _this._cache["detectNetwork"] = null; + _this.detectNetwork().then(function(network2) { + resolve(network2); + }, function(error) { + reject(error); + }); }, 0); + }); + } + _this = _super.call(this, networkOrReady) || this; + if (!url) { + url = (0, properties_1.getStatic)(_this.constructor, "defaultUrl")(); + } + if (typeof url === "string") { + (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze({ + url + })); + } else { + (0, properties_1.defineReadOnly)(_this, "connection", Object.freeze((0, properties_1.shallowCopy)(url))); + } + _this._nextId = 42; + return _this; + } + Object.defineProperty(JsonRpcProvider2.prototype, "_cache", { + get: function() { + if (this._eventLoopCache == null) { + this._eventLoopCache = {}; } - return this._cache["detectNetwork"]; - }; - JsonRpcProvider2.prototype._uncachedDetectNetwork = function() { - return __awaiter2(this, void 0, void 0, function() { - var chainId, error_2, error_3, getNetwork; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, timer(0)]; - case 1: - _a7.sent(); - chainId = null; - _a7.label = 2; - case 2: - _a7.trys.push([2, 4, , 9]); - return [4, this.send("eth_chainId", [])]; - case 3: - chainId = _a7.sent(); - return [3, 9]; - case 4: - error_2 = _a7.sent(); - _a7.label = 5; - case 5: - _a7.trys.push([5, 7, , 8]); - return [4, this.send("net_version", [])]; - case 6: - chainId = _a7.sent(); - return [3, 8]; - case 7: - error_3 = _a7.sent(); - return [3, 8]; - case 8: - return [3, 9]; - case 9: - if (chainId != null) { - getNetwork = (0, properties_1.getStatic)(this.constructor, "getNetwork"); - try { - return [2, getNetwork(bignumber_1.BigNumber.from(chainId).toNumber())]; - } catch (error) { - return [2, logger2.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, { - chainId, - event: "invalidNetwork", - serverError: error - })]; - } + return this._eventLoopCache; + }, + enumerable: false, + configurable: true + }); + JsonRpcProvider2.defaultUrl = function() { + return "http://localhost:8545"; + }; + JsonRpcProvider2.prototype.detectNetwork = function() { + var _this = this; + if (!this._cache["detectNetwork"]) { + this._cache["detectNetwork"] = this._uncachedDetectNetwork(); + setTimeout(function() { + _this._cache["detectNetwork"] = null; + }, 0); + } + return this._cache["detectNetwork"]; + }; + JsonRpcProvider2.prototype._uncachedDetectNetwork = function() { + return __awaiter(this, void 0, void 0, function() { + var chainId, error_2, error_3, getNetwork; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, timer(0)]; + case 1: + _a7.sent(); + chainId = null; + _a7.label = 2; + case 2: + _a7.trys.push([2, 4, , 9]); + return [4, this.send("eth_chainId", [])]; + case 3: + chainId = _a7.sent(); + return [3, 9]; + case 4: + error_2 = _a7.sent(); + _a7.label = 5; + case 5: + _a7.trys.push([5, 7, , 8]); + return [4, this.send("net_version", [])]; + case 6: + chainId = _a7.sent(); + return [3, 8]; + case 7: + error_3 = _a7.sent(); + return [3, 8]; + case 8: + return [3, 9]; + case 9: + if (chainId != null) { + getNetwork = (0, properties_1.getStatic)(this.constructor, "getNetwork"); + try { + return [2, getNetwork(bignumber_1.BigNumber.from(chainId).toNumber())]; + } catch (error) { + return [2, logger2.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, { + chainId, + event: "invalidNetwork", + serverError: error + })]; } - return [2, logger2.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, { - event: "noNetwork" - })]; - } - }); + } + return [2, logger2.throwError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR, { + event: "noNetwork" + })]; + } }); - }; - JsonRpcProvider2.prototype.getSigner = function(addressOrIndex) { - return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); - }; - JsonRpcProvider2.prototype.getUncheckedSigner = function(addressOrIndex) { - return this.getSigner(addressOrIndex).connectUnchecked(); - }; - JsonRpcProvider2.prototype.listAccounts = function() { - var _this = this; - return this.send("eth_accounts", []).then(function(accounts) { - return accounts.map(function(a) { - return _this.formatter.address(a); - }); + }); + }; + JsonRpcProvider2.prototype.getSigner = function(addressOrIndex) { + return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); + }; + JsonRpcProvider2.prototype.getUncheckedSigner = function(addressOrIndex) { + return this.getSigner(addressOrIndex).connectUnchecked(); + }; + JsonRpcProvider2.prototype.listAccounts = function() { + var _this = this; + return this.send("eth_accounts", []).then(function(accounts) { + return accounts.map(function(a) { + return _this.formatter.address(a); }); + }); + }; + JsonRpcProvider2.prototype.send = function(method, params) { + var _this = this; + var request = { + method, + params, + id: this._nextId++, + jsonrpc: "2.0" }; - JsonRpcProvider2.prototype.send = function(method, params) { - var _this = this; - var request = { - method, - params, - id: this._nextId++, - jsonrpc: "2.0" - }; - this.emit("debug", { - action: "request", - request: (0, properties_1.deepCopy)(request), - provider: this - }); - var cache = ["eth_chainId", "eth_blockNumber"].indexOf(method) >= 0; - if (cache && this._cache[method]) { - return this._cache[method]; - } - var result = (0, web_1.fetchJson)(this.connection, JSON.stringify(request), getResult).then(function(result2) { - _this.emit("debug", { - action: "response", - request, - response: result2, - provider: _this - }); - return result2; - }, function(error) { - _this.emit("debug", { - action: "response", - error, - request, - provider: _this - }); - throw error; + this.emit("debug", { + action: "request", + request: (0, properties_1.deepCopy)(request), + provider: this + }); + var cache = ["eth_chainId", "eth_blockNumber"].indexOf(method) >= 0; + if (cache && this._cache[method]) { + return this._cache[method]; + } + var result = (0, web_1.fetchJson)(this.connection, JSON.stringify(request), getResult).then(function(result2) { + _this.emit("debug", { + action: "response", + request, + response: result2, + provider: _this }); - if (cache) { - this._cache[method] = result; - setTimeout(function() { - _this._cache[method] = null; - }, 0); - } - return result; - }; - JsonRpcProvider2.prototype.prepareRequest = function(method, params) { - switch (method) { - case "getBlockNumber": - return ["eth_blockNumber", []]; - case "getGasPrice": - return ["eth_gasPrice", []]; - case "getBalance": - return ["eth_getBalance", [getLowerCase(params.address), params.blockTag]]; - case "getTransactionCount": - return ["eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]]; - case "getCode": - return ["eth_getCode", [getLowerCase(params.address), params.blockTag]]; - case "getStorageAt": - return ["eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]]; - case "sendTransaction": - return ["eth_sendRawTransaction", [params.signedTransaction]]; - case "getBlock": - if (params.blockTag) { - return ["eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]]; - } else if (params.blockHash) { - return ["eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]]; - } - return null; - case "getTransaction": - return ["eth_getTransactionByHash", [params.transactionHash]]; - case "getTransactionReceipt": - return ["eth_getTransactionReceipt", [params.transactionHash]]; - case "call": { - var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction"); - return ["eth_call", [hexlifyTransaction(params.transaction, { from: true }), params.blockTag]]; - } - case "estimateGas": { - var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction"); - return ["eth_estimateGas", [hexlifyTransaction(params.transaction, { from: true })]]; - } - case "getLogs": - if (params.filter && params.filter.address != null) { - params.filter.address = getLowerCase(params.filter.address); - } - return ["eth_getLogs", [params.filter]]; - default: - break; - } - return null; - }; - JsonRpcProvider2.prototype.perform = function(method, params) { - return __awaiter2(this, void 0, void 0, function() { - var tx, feeData, args, error_4; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (!(method === "call" || method === "estimateGas")) - return [3, 2]; - tx = params.transaction; - if (!(tx && tx.type != null && bignumber_1.BigNumber.from(tx.type).isZero())) - return [3, 2]; - if (!(tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null)) - return [3, 2]; - return [4, this.getFeeData()]; - case 1: - feeData = _a7.sent(); - if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) { - params = (0, properties_1.shallowCopy)(params); - params.transaction = (0, properties_1.shallowCopy)(tx); - delete params.transaction.type; - } - _a7.label = 2; - case 2: - args = this.prepareRequest(method, params); - if (args == null) { - logger2.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); - } - _a7.label = 3; - case 3: - _a7.trys.push([3, 5, , 6]); - return [4, this.send(args[0], args[1])]; - case 4: - return [2, _a7.sent()]; - case 5: - error_4 = _a7.sent(); - return [2, checkError(method, error_4, params)]; - case 6: - return [ - 2 - /*return*/ - ]; - } - }); + return result2; + }, function(error) { + _this.emit("debug", { + action: "response", + error, + request, + provider: _this }); - }; - JsonRpcProvider2.prototype._startEvent = function(event) { - if (event.tag === "pending") { - this._startPending(); - } - _super.prototype._startEvent.call(this, event); - }; - JsonRpcProvider2.prototype._startPending = function() { - if (this._pendingFilter != null) { - return; - } - var self2 = this; - var pendingFilter = this.send("eth_newPendingTransactionFilter", []); - this._pendingFilter = pendingFilter; - pendingFilter.then(function(filterId) { - function poll() { - self2.send("eth_getFilterChanges", [filterId]).then(function(hashes) { - if (self2._pendingFilter != pendingFilter) { - return null; + throw error; + }); + if (cache) { + this._cache[method] = result; + setTimeout(function() { + _this._cache[method] = null; + }, 0); + } + return result; + }; + JsonRpcProvider2.prototype.prepareRequest = function(method, params) { + switch (method) { + case "getBlockNumber": + return ["eth_blockNumber", []]; + case "getGasPrice": + return ["eth_gasPrice", []]; + case "getBalance": + return ["eth_getBalance", [getLowerCase(params.address), params.blockTag]]; + case "getTransactionCount": + return ["eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]]; + case "getCode": + return ["eth_getCode", [getLowerCase(params.address), params.blockTag]]; + case "getStorageAt": + return ["eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]]; + case "sendTransaction": + return ["eth_sendRawTransaction", [params.signedTransaction]]; + case "getBlock": + if (params.blockTag) { + return ["eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]]; + } else if (params.blockHash) { + return ["eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]]; + } + return null; + case "getTransaction": + return ["eth_getTransactionByHash", [params.transactionHash]]; + case "getTransactionReceipt": + return ["eth_getTransactionReceipt", [params.transactionHash]]; + case "call": { + var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction"); + return ["eth_call", [hexlifyTransaction(params.transaction, { from: true }), params.blockTag]]; + } + case "estimateGas": { + var hexlifyTransaction = (0, properties_1.getStatic)(this.constructor, "hexlifyTransaction"); + return ["eth_estimateGas", [hexlifyTransaction(params.transaction, { from: true })]]; + } + case "getLogs": + if (params.filter && params.filter.address != null) { + params.filter.address = getLowerCase(params.filter.address); + } + return ["eth_getLogs", [params.filter]]; + default: + break; + } + return null; + }; + JsonRpcProvider2.prototype.perform = function(method, params) { + return __awaiter(this, void 0, void 0, function() { + var tx, feeData, args, error_4; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (!(method === "call" || method === "estimateGas")) + return [3, 2]; + tx = params.transaction; + if (!(tx && tx.type != null && bignumber_1.BigNumber.from(tx.type).isZero())) + return [3, 2]; + if (!(tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null)) + return [3, 2]; + return [4, this.getFeeData()]; + case 1: + feeData = _a7.sent(); + if (feeData.maxFeePerGas == null && feeData.maxPriorityFeePerGas == null) { + params = (0, properties_1.shallowCopy)(params); + params.transaction = (0, properties_1.shallowCopy)(tx); + delete params.transaction.type; } - var seq = Promise.resolve(); - hashes.forEach(function(hash) { - self2._emitted["t:" + hash.toLowerCase()] = "pending"; - seq = seq.then(function() { - return self2.getTransaction(hash).then(function(tx) { - self2.emit("pending", tx); - return null; - }); - }); - }); - return seq.then(function() { - return timer(1e3); - }); - }).then(function() { - if (self2._pendingFilter != pendingFilter) { - self2.send("eth_uninstallFilter", [filterId]); - return; + _a7.label = 2; + case 2: + args = this.prepareRequest(method, params); + if (args == null) { + logger2.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); } - setTimeout(function() { - poll(); - }, 0); - return null; - }).catch(function(error) { - }); + _a7.label = 3; + case 3: + _a7.trys.push([3, 5, , 6]); + return [4, this.send(args[0], args[1])]; + case 4: + return [2, _a7.sent()]; + case 5: + error_4 = _a7.sent(); + return [2, checkError(method, error_4, params)]; + case 6: + return [2]; } - poll(); - return filterId; - }).catch(function(error) { }); - }; - JsonRpcProvider2.prototype._stopEvent = function(event) { - if (event.tag === "pending" && this.listenerCount("pending") === 0) { - this._pendingFilter = null; - } - _super.prototype._stopEvent.call(this, event); - }; - JsonRpcProvider2.hexlifyTransaction = function(transaction, allowExtra) { - var allowed = (0, properties_1.shallowCopy)(allowedTransactionKeys); - if (allowExtra) { - for (var key in allowExtra) { - if (allowExtra[key]) { - allowed[key] = true; + }); + }; + JsonRpcProvider2.prototype._startEvent = function(event) { + if (event.tag === "pending") { + this._startPending(); + } + _super.prototype._startEvent.call(this, event); + }; + JsonRpcProvider2.prototype._startPending = function() { + if (this._pendingFilter != null) { + return; + } + var self2 = this; + var pendingFilter = this.send("eth_newPendingTransactionFilter", []); + this._pendingFilter = pendingFilter; + pendingFilter.then(function(filterId) { + function poll() { + self2.send("eth_getFilterChanges", [filterId]).then(function(hashes) { + if (self2._pendingFilter != pendingFilter) { + return null; } - } + var seq = Promise.resolve(); + hashes.forEach(function(hash) { + self2._emitted["t:" + hash.toLowerCase()] = "pending"; + seq = seq.then(function() { + return self2.getTransaction(hash).then(function(tx) { + self2.emit("pending", tx); + return null; + }); + }); + }); + return seq.then(function() { + return timer(1e3); + }); + }).then(function() { + if (self2._pendingFilter != pendingFilter) { + self2.send("eth_uninstallFilter", [filterId]); + return; + } + setTimeout(function() { + poll(); + }, 0); + return null; + }).catch(function(error) { + }); } - (0, properties_1.checkProperties)(transaction, allowed); - var result = {}; - ["gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach(function(key2) { - if (transaction[key2] == null) { - return; - } - var value = (0, bytes_1.hexValue)(transaction[key2]); - if (key2 === "gasLimit") { - key2 = "gas"; - } - result[key2] = value; - }); - ["from", "to", "data"].forEach(function(key2) { - if (transaction[key2] == null) { - return; + poll(); + return filterId; + }).catch(function(error) { + }); + }; + JsonRpcProvider2.prototype._stopEvent = function(event) { + if (event.tag === "pending" && this.listenerCount("pending") === 0) { + this._pendingFilter = null; + } + _super.prototype._stopEvent.call(this, event); + }; + JsonRpcProvider2.hexlifyTransaction = function(transaction, allowExtra) { + var allowed = (0, properties_1.shallowCopy)(allowedTransactionKeys); + if (allowExtra) { + for (var key in allowExtra) { + if (allowExtra[key]) { + allowed[key] = true; } - result[key2] = (0, bytes_1.hexlify)(transaction[key2]); - }); - if (transaction.accessList) { - result["accessList"] = (0, transactions_1.accessListify)(transaction.accessList); } - return result; - }; - return JsonRpcProvider2; - }(base_provider_1.BaseProvider) - ); + } + (0, properties_1.checkProperties)(transaction, allowed); + var result = {}; + ["gasLimit", "gasPrice", "type", "maxFeePerGas", "maxPriorityFeePerGas", "nonce", "value"].forEach(function(key2) { + if (transaction[key2] == null) { + return; + } + var value = (0, bytes_1.hexValue)(transaction[key2]); + if (key2 === "gasLimit") { + key2 = "gas"; + } + result[key2] = value; + }); + ["from", "to", "data"].forEach(function(key2) { + if (transaction[key2] == null) { + return; + } + result[key2] = (0, bytes_1.hexlify)(transaction[key2]); + }); + if (transaction.accessList) { + result["accessList"] = (0, transactions_1.accessListify)(transaction.accessList); + } + return result; + }; + return JsonRpcProvider2; + }(base_provider_1.BaseProvider); exports2.JsonRpcProvider = JsonRpcProvider; } }); @@ -26884,7 +26576,6 @@ var require_constants = __commonJS({ // node_modules/node-gyp-build/index.js var require_node_gyp_build = __commonJS({ "node_modules/node-gyp-build/index.js"(exports2, module2) { - "use strict"; var fs3 = require("fs"); var path2 = require("path"); var os = require("os"); @@ -26935,7 +26626,6 @@ var require_node_gyp_build = __commonJS({ "node=" + process.versions.node, process.versions.electron ? "electron=" + process.versions.electron : "", typeof __webpack_require__ === "function" ? "webpack=true" : "" - // eslint-disable-line ].filter(Boolean).join(" "); throw new Error("No native build was found for " + target + "\n loaded from: " + dir + "\n"); function resolve(dir2) { @@ -27193,12 +26883,6 @@ var require_limiter = __commonJS({ var kDone = Symbol("kDone"); var kRun = Symbol("kRun"); var Limiter = class { - /** - * Creates a new `Limiter`. - * - * @param {Number} [concurrency=Infinity] The maximum number of jobs allowed - * to run concurrently - */ constructor(concurrency) { this[kDone] = () => { this.pending--; @@ -27208,21 +26892,10 @@ var require_limiter = __commonJS({ this.jobs = []; this.pending = 0; } - /** - * Adds a job to the queue. - * - * @param {Function} job The job to run - * @public - */ add(job) { this.jobs.push(job); this[kRun](); } - /** - * Removes a job from the queue and runs it if possible. - * - * @private - */ [kRun]() { if (this.pending === this.concurrency) return; @@ -27253,30 +26926,6 @@ var require_permessage_deflate = __commonJS({ var kError = Symbol("error"); var zlibLimiter; var PerMessageDeflate = class { - /** - * Creates a PerMessageDeflate instance. - * - * @param {Object} [options] Configuration options - * @param {Boolean} [options.serverNoContextTakeover=false] Request/accept - * disabling of server context takeover - * @param {Boolean} [options.clientNoContextTakeover=false] Advertise/ - * acknowledge disabling of client context takeover - * @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the - * use of a custom server window size - * @param {(Boolean|Number)} [options.clientMaxWindowBits] Advertise support - * for, or request, a custom client window size - * @param {Object} [options.zlibDeflateOptions] Options to pass to zlib on - * deflate - * @param {Object} [options.zlibInflateOptions] Options to pass to zlib on - * inflate - * @param {Number} [options.threshold=1024] Size (in bytes) below which - * messages should not be compressed - * @param {Number} [options.concurrencyLimit=10] The number of concurrent - * calls to zlib - * @param {Boolean} [isServer=false] Create the instance in either server or - * client mode - * @param {Number} [maxPayload=0] The maximum allowed message length - */ constructor(options2, isServer, maxPayload) { this._maxPayload = maxPayload | 0; this._options = options2 || {}; @@ -27290,18 +26939,9 @@ var require_permessage_deflate = __commonJS({ zlibLimiter = new Limiter(concurrency); } } - /** - * @type {String} - */ static get extensionName() { return "permessage-deflate"; } - /** - * Create an extension negotiation offer. - * - * @return {Object} Extension parameters - * @public - */ offer() { const params = {}; if (this._options.serverNoContextTakeover) { @@ -27320,23 +26960,11 @@ var require_permessage_deflate = __commonJS({ } return params; } - /** - * Accept an extension negotiation offer/response. - * - * @param {Array} configurations The extension negotiation offers/reponse - * @return {Object} Accepted configuration - * @public - */ accept(configurations) { configurations = this.normalizeParams(configurations); this.params = this._isServer ? this.acceptAsServer(configurations) : this.acceptAsClient(configurations); return this.params; } - /** - * Releases all resources used by the extension. - * - * @public - */ cleanup() { if (this._inflate) { this._inflate.close(); @@ -27355,13 +26983,6 @@ var require_permessage_deflate = __commonJS({ } } } - /** - * Accept an extension negotiation offer. - * - * @param {Array} offers The extension negotiation offers - * @return {Object} Accepted configuration - * @private - */ acceptAsServer(offers) { const opts = this._options; const accepted = offers.find((params) => { @@ -27389,13 +27010,6 @@ var require_permessage_deflate = __commonJS({ } return accepted; } - /** - * Accept the extension negotiation response. - * - * @param {Array} response The extension negotiation response - * @return {Object} Accepted configuration - * @private - */ acceptAsClient(response) { const params = response[0]; if (this._options.clientNoContextTakeover === false && params.client_no_context_takeover) { @@ -27412,13 +27026,6 @@ var require_permessage_deflate = __commonJS({ } return params; } - /** - * Normalize parameters. - * - * @param {Array} configurations The extension negotiation offers/reponse - * @return {Array} The offers/response with normalized parameters - * @private - */ normalizeParams(configurations) { configurations.forEach((params) => { Object.keys(params).forEach((key) => { @@ -27463,14 +27070,6 @@ var require_permessage_deflate = __commonJS({ }); return configurations; } - /** - * Decompress data. Concurrency limited. - * - * @param {Buffer} data Compressed data - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @public - */ decompress(data, fin, callback) { zlibLimiter.add((done) => { this._decompress(data, fin, (err, result) => { @@ -27479,14 +27078,6 @@ var require_permessage_deflate = __commonJS({ }); }); } - /** - * Compress data. Concurrency limited. - * - * @param {Buffer} data Data to compress - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @public - */ compress(data, fin, callback) { zlibLimiter.add((done) => { this._compress(data, fin, (err, result) => { @@ -27495,14 +27086,6 @@ var require_permessage_deflate = __commonJS({ }); }); } - /** - * Decompress data. - * - * @param {Buffer} data Compressed data - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @private - */ _decompress(data, fin, callback) { const endpoint = this._isServer ? "client" : "server"; if (!this._inflate) { @@ -27546,14 +27129,6 @@ var require_permessage_deflate = __commonJS({ callback(null, data2); }); } - /** - * Compress data. - * - * @param {Buffer} data Data to compress - * @param {Boolean} fin Specifies whether or not this is the last fragment - * @param {Function} callback Callback - * @private - */ _compress(data, fin, callback) { const endpoint = this._isServer ? "server" : "client"; if (!this._deflate) { @@ -27629,14 +27204,12 @@ var require_fallback2 = __commonJS({ } i += 2; } else if ((buf[i] & 240) === 224) { - if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // overlong - buf[i] === 237 && (buf[i + 1] & 224) === 160) { + if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || buf[i] === 237 && (buf[i + 1] & 224) === 160) { return false; } i += 3; } else if ((buf[i] & 248) === 240) { - if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // overlong - buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) { + if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) { return false; } i += 4; @@ -27681,14 +27254,12 @@ var require_validation = __commonJS({ } i += 2; } else if ((buf[i] & 240) === 224) { - if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || // Overlong - buf[i] === 237 && (buf[i + 1] & 224) === 160) { + if (i + 2 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || buf[i] === 224 && (buf[i + 1] & 224) === 128 || buf[i] === 237 && (buf[i + 1] & 224) === 160) { return false; } i += 3; } else if ((buf[i] & 248) === 240) { - if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || // Overlong - buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) { + if (i + 3 >= len || (buf[i + 1] & 192) !== 128 || (buf[i + 2] & 192) !== 128 || (buf[i + 3] & 192) !== 128 || buf[i] === 240 && (buf[i + 1] & 240) === 128 || buf[i] === 244 && buf[i + 1] > 143 || buf[i] > 244) { return false; } i += 4; @@ -27739,15 +27310,6 @@ var require_receiver = __commonJS({ var GET_DATA = 4; var INFLATING = 5; var Receiver = class extends Writable { - /** - * Creates a Receiver instance. - * - * @param {String} [binaryType=nodebuffer] The type for binary data - * @param {Object} [extensions] An object containing the negotiated extensions - * @param {Boolean} [isServer=false] Specifies whether to operate in client or - * server mode - * @param {Number} [maxPayload=0] The maximum allowed message length - */ constructor(binaryType, extensions, isServer, maxPayload) { super(); this._binaryType = binaryType || BINARY_TYPES[0]; @@ -27770,14 +27332,6 @@ var require_receiver = __commonJS({ this._state = GET_INFO; this._loop = false; } - /** - * Implements `Writable.prototype._write()`. - * - * @param {Buffer} chunk The chunk of data to write - * @param {String} encoding The character encoding of `chunk` - * @param {Function} cb Callback - * @private - */ _write(chunk, encoding, cb) { if (this._opcode === 8 && this._state == GET_INFO) return cb(); @@ -27785,13 +27339,6 @@ var require_receiver = __commonJS({ this._buffers.push(chunk); this.startLoop(cb); } - /** - * Consumes `n` bytes from the buffered data. - * - * @param {Number} n The number of bytes to consume - * @return {Buffer} The consumed bytes - * @private - */ consume(n) { this._bufferedBytes -= n; if (n === this._buffers[0].length) @@ -27815,12 +27362,6 @@ var require_receiver = __commonJS({ } while (n > 0); return dst; } - /** - * Starts the parsing loop. - * - * @param {Function} cb Callback - * @private - */ startLoop(cb) { let err; this._loop = true; @@ -27848,12 +27389,6 @@ var require_receiver = __commonJS({ } while (this._loop); cb(err); } - /** - * Reads the first two bytes of a frame. - * - * @return {(RangeError|undefined)} A possible error - * @private - */ getInfo() { if (this._bufferedBytes < 2) { this._loop = false; @@ -27929,12 +27464,6 @@ var require_receiver = __commonJS({ else return this.haveLength(); } - /** - * Gets extended payload length (7+16). - * - * @return {(RangeError|undefined)} A possible error - * @private - */ getPayloadLength16() { if (this._bufferedBytes < 2) { this._loop = false; @@ -27943,12 +27472,6 @@ var require_receiver = __commonJS({ this._payloadLength = this.consume(2).readUInt16BE(0); return this.haveLength(); } - /** - * Gets extended payload length (7+64). - * - * @return {(RangeError|undefined)} A possible error - * @private - */ getPayloadLength64() { if (this._bufferedBytes < 8) { this._loop = false; @@ -27968,12 +27491,6 @@ var require_receiver = __commonJS({ this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4); return this.haveLength(); } - /** - * Payload length has been read. - * - * @return {(RangeError|undefined)} A possible error - * @private - */ haveLength() { if (this._payloadLength && this._opcode < 8) { this._totalPayloadLength += this._payloadLength; @@ -27987,11 +27504,6 @@ var require_receiver = __commonJS({ else this._state = GET_DATA; } - /** - * Reads mask bytes. - * - * @private - */ getMask() { if (this._bufferedBytes < 4) { this._loop = false; @@ -28000,13 +27512,6 @@ var require_receiver = __commonJS({ this._mask = this.consume(4); this._state = GET_DATA; } - /** - * Reads data bytes. - * - * @param {Function} cb Callback - * @return {(Error|RangeError|undefined)} A possible error - * @private - */ getData(cb) { let data = EMPTY_BUFFER; if (this._payloadLength) { @@ -28031,13 +27536,6 @@ var require_receiver = __commonJS({ } return this.dataMessage(); } - /** - * Decompresses data. - * - * @param {Buffer} data Compressed data - * @param {Function} cb Callback - * @private - */ decompress(data, cb) { const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName]; perMessageDeflate.decompress(data, this._fin, (err, buf) => { @@ -28058,12 +27556,6 @@ var require_receiver = __commonJS({ this.startLoop(cb); }); } - /** - * Handles a data message. - * - * @return {(Error|undefined)} A possible error - * @private - */ dataMessage() { if (this._fin) { const messageLength = this._messageLength; @@ -28093,13 +27585,6 @@ var require_receiver = __commonJS({ } this._state = GET_INFO; } - /** - * Handles a control message. - * - * @param {Buffer} data Data to handle - * @return {(Error|RangeError|undefined)} A possible error - * @private - */ controlMessage(data) { if (this._opcode === 8) { this._loop = false; @@ -28151,12 +27636,6 @@ var require_sender = __commonJS({ var { mask: applyMask, toBuffer } = require_buffer_util(); var mask = Buffer.alloc(4); var Sender = class { - /** - * Creates a Sender instance. - * - * @param {net.Socket} socket The connection socket - * @param {Object} [extensions] An object containing the negotiated extensions - */ constructor(socket, extensions) { this._extensions = extensions || {}; this._socket = socket; @@ -28166,23 +27645,6 @@ var require_sender = __commonJS({ this._deflating = false; this._queue = []; } - /** - * Frames a piece of data according to the HyBi WebSocket protocol. - * - * @param {Buffer} data The data to frame - * @param {Object} options Options object - * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified - * @param {Boolean} [options.fin=false] Specifies whether or not to set the - * FIN bit - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the - * RSV1 bit - * @return {Buffer[]} The framed data as a list of `Buffer` instances - * @public - */ static frame(data, options2) { const merge = options2.mask && options2.readOnly; let offset = options2.mask ? 6 : 2; @@ -28220,15 +27682,6 @@ var require_sender = __commonJS({ applyMask(data, mask, data, 0, data.length); return [target, data]; } - /** - * Sends a close message to the other peer. - * - * @param {Number} [code] The status code component of the body - * @param {String} [data] The message component of the body - * @param {Boolean} [mask=false] Specifies whether or not to mask the message - * @param {Function} [cb] Callback - * @public - */ close(code, data, mask2, cb) { let buf; if (code === void 0) { @@ -28253,14 +27706,6 @@ var require_sender = __commonJS({ this.doClose(buf, mask2, cb); } } - /** - * Frames and sends a close message. - * - * @param {Buffer} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback - * @private - */ doClose(data, mask2, cb) { this.sendFrame( Sender.frame(data, { @@ -28273,14 +27718,6 @@ var require_sender = __commonJS({ cb ); } - /** - * Sends a ping message to the other peer. - * - * @param {*} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback - * @public - */ ping(data, mask2, cb) { const buf = toBuffer(data); if (buf.length > 125) { @@ -28292,15 +27729,6 @@ var require_sender = __commonJS({ this.doPing(buf, mask2, toBuffer.readOnly, cb); } } - /** - * Frames and sends a ping message. - * - * @param {Buffer} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified - * @param {Function} [cb] Callback - * @private - */ doPing(data, mask2, readOnly, cb) { this.sendFrame( Sender.frame(data, { @@ -28313,14 +27741,6 @@ var require_sender = __commonJS({ cb ); } - /** - * Sends a pong message to the other peer. - * - * @param {*} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback - * @public - */ pong(data, mask2, cb) { const buf = toBuffer(data); if (buf.length > 125) { @@ -28332,15 +27752,6 @@ var require_sender = __commonJS({ this.doPong(buf, mask2, toBuffer.readOnly, cb); } } - /** - * Frames and sends a pong message. - * - * @param {Buffer} data The message to send - * @param {Boolean} [mask=false] Specifies whether or not to mask `data` - * @param {Boolean} [readOnly=false] Specifies whether `data` can be modified - * @param {Function} [cb] Callback - * @private - */ doPong(data, mask2, readOnly, cb) { this.sendFrame( Sender.frame(data, { @@ -28353,22 +27764,6 @@ var require_sender = __commonJS({ cb ); } - /** - * Sends a data message to the other peer. - * - * @param {*} data The message to send - * @param {Object} options Options object - * @param {Boolean} [options.compress=false] Specifies whether or not to - * compress `data` - * @param {Boolean} [options.binary=false] Specifies whether `data` is binary - * or text - * @param {Boolean} [options.fin=false] Specifies whether the fragment is the - * last one - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Function} [cb] Callback - * @public - */ send(data, options2, cb) { const buf = toBuffer(data); const perMessageDeflate = this._extensions[PerMessageDeflate.extensionName]; @@ -28412,25 +27807,6 @@ var require_sender = __commonJS({ ); } } - /** - * Dispatches a data message. - * - * @param {Buffer} data The message to send - * @param {Boolean} [compress=false] Specifies whether or not to compress - * `data` - * @param {Object} options Options object - * @param {Number} options.opcode The opcode - * @param {Boolean} [options.readOnly=false] Specifies whether `data` can be - * modified - * @param {Boolean} [options.fin=false] Specifies whether or not to set the - * FIN bit - * @param {Boolean} [options.mask=false] Specifies whether or not to mask - * `data` - * @param {Boolean} [options.rsv1=false] Specifies whether or not to set the - * RSV1 bit - * @param {Function} [cb] Callback - * @private - */ dispatch(data, compress, options2, cb) { if (!compress) { this.sendFrame(Sender.frame(data, options2), cb); @@ -28460,11 +27836,6 @@ var require_sender = __commonJS({ this.dequeue(); }); } - /** - * Executes queued send operations. - * - * @private - */ dequeue() { while (!this._deflating && this._queue.length) { const params = this._queue.shift(); @@ -28472,23 +27843,10 @@ var require_sender = __commonJS({ Reflect.apply(params[0], this, params.slice(1)); } } - /** - * Enqueues a send operation. - * - * @param {Array} params Send operation parameters. - * @private - */ enqueue(params) { this._bufferedBytes += params[1].length; this._queue.push(params); } - /** - * Sends a frame. - * - * @param {Buffer[]} list The frame to send - * @param {Function} [cb] Callback - * @private - */ sendFrame(list, cb) { if (list.length === 2) { this._socket.cork(); @@ -28509,42 +27867,18 @@ var require_event_target = __commonJS({ "node_modules/@ethersproject/providers/node_modules/ws/lib/event-target.js"(exports2, module2) { "use strict"; var Event = class { - /** - * Create a new `Event`. - * - * @param {String} type The name of the event - * @param {Object} target A reference to the target to which the event was - * dispatched - */ constructor(type, target) { this.target = target; this.type = type; } }; var MessageEvent = class extends Event { - /** - * Create a new `MessageEvent`. - * - * @param {(String|Buffer|ArrayBuffer|Buffer[])} data The received data - * @param {WebSocket} target A reference to the target to which the event was - * dispatched - */ constructor(data, target) { super("message", target); this.data = data; } }; var CloseEvent = class extends Event { - /** - * Create a new `CloseEvent`. - * - * @param {Number} code The status code explaining why the connection is being - * closed - * @param {String} reason A human-readable string explaining why the - * connection is closing - * @param {WebSocket} target A reference to the target to which the event was - * dispatched - */ constructor(code, reason, target) { super("close", target); this.wasClean = target._closeFrameReceived && target._closeFrameSent; @@ -28553,24 +27887,11 @@ var require_event_target = __commonJS({ } }; var OpenEvent = class extends Event { - /** - * Create a new `OpenEvent`. - * - * @param {WebSocket} target A reference to the target to which the event was - * dispatched - */ constructor(target) { super("open", target); } }; var ErrorEvent = class extends Event { - /** - * Create a new `ErrorEvent`. - * - * @param {Object} error The error that generated this event - * @param {WebSocket} target A reference to the target to which the event was - * dispatched - */ constructor(error, target) { super("error", target); this.message = error.message; @@ -28578,18 +27899,6 @@ var require_event_target = __commonJS({ } }; var EventTarget = { - /** - * Register an event listener. - * - * @param {String} type A string representing the event type to listen for - * @param {Function} listener The listener to add - * @param {Object} [options] An options object specifies characteristics about - * the event listener - * @param {Boolean} [options.once=false] A `Boolean`` indicating that the - * listener should be invoked at most once after being added. If `true`, - * the listener would be automatically removed when invoked. - * @public - */ addEventListener(type, listener, options2) { if (typeof listener !== "function") return; @@ -28622,13 +27931,6 @@ var require_event_target = __commonJS({ this[method](type, listener); } }, - /** - * Remove an event listener. - * - * @param {String} type A string representing the event type to remove - * @param {Function} listener The listener to remove - * @public - */ removeEventListener(type, listener) { const listeners = this.listeners(type); for (let i = 0; i < listeners.length; i++) { @@ -28663,7 +27965,6 @@ var require_extension = __commonJS({ 0, 0, 0, - // 0 - 15 0, 0, 0, @@ -28680,7 +27981,6 @@ var require_extension = __commonJS({ 0, 0, 0, - // 16 - 31 0, 1, 0, @@ -28697,7 +27997,6 @@ var require_extension = __commonJS({ 1, 1, 0, - // 32 - 47 1, 1, 1, @@ -28714,7 +28013,6 @@ var require_extension = __commonJS({ 0, 0, 0, - // 48 - 63 0, 1, 1, @@ -28731,7 +28029,6 @@ var require_extension = __commonJS({ 1, 1, 1, - // 64 - 79 1, 1, 1, @@ -28748,7 +28045,6 @@ var require_extension = __commonJS({ 0, 1, 1, - // 80 - 95 1, 1, 1, @@ -28765,7 +28061,6 @@ var require_extension = __commonJS({ 1, 1, 1, - // 96 - 111 1, 1, 1, @@ -28782,7 +28077,6 @@ var require_extension = __commonJS({ 0, 1, 0 - // 112 - 127 ]; function push(dest, name2, elem) { if (dest[name2] === void 0) @@ -28979,13 +28273,6 @@ var require_websocket = __commonJS({ var protocolVersions = [8, 13]; var closeTimeout = 30 * 1e3; var WebSocket = class extends EventEmitter { - /** - * Create a new `WebSocket`. - * - * @param {(String|url.URL)} address The URL to which to connect - * @param {(String|String[])} [protocols] The subprotocols - * @param {Object} [options] Connection options - */ constructor(address, protocols, options2) { super(); this._binaryType = BINARY_TYPES[0]; @@ -29015,13 +28302,6 @@ var require_websocket = __commonJS({ this._isServer = true; } } - /** - * This deviates from the WHATWG interface since ws doesn't support the - * required default "blob" type (instead we define a custom "nodebuffer" - * type). - * - * @type {String} - */ get binaryType() { return this._binaryType; } @@ -29032,46 +28312,23 @@ var require_websocket = __commonJS({ if (this._receiver) this._receiver._binaryType = type; } - /** - * @type {Number} - */ get bufferedAmount() { if (!this._socket) return this._bufferedAmount; return this._socket._writableState.length + this._sender._bufferedBytes; } - /** - * @type {String} - */ get extensions() { return Object.keys(this._extensions).join(); } - /** - * @type {String} - */ get protocol() { return this._protocol; } - /** - * @type {Number} - */ get readyState() { return this._readyState; } - /** - * @type {String} - */ get url() { return this._url; } - /** - * Set up the socket and the internal resources. - * - * @param {net.Socket} socket The network socket between the server and client - * @param {Buffer} head The first packet of the upgraded stream - * @param {Number} [maxPayload=0] The maximum allowed message size - * @private - */ setSocket(socket, head, maxPayload) { const receiver = new Receiver( this.binaryType, @@ -29101,11 +28358,6 @@ var require_websocket = __commonJS({ this._readyState = WebSocket.OPEN; this.emit("open"); } - /** - * Emit the `'close'` event. - * - * @private - */ emitClose() { if (!this._socket) { this._readyState = WebSocket.CLOSED; @@ -29119,25 +28371,6 @@ var require_websocket = __commonJS({ this._readyState = WebSocket.CLOSED; this.emit("close", this._closeCode, this._closeMessage); } - /** - * Start a closing handshake. - * - * +----------+ +-----------+ +----------+ - * - - -|ws.close()|-->|close frame|-->|ws.close()|- - - - * | +----------+ +-----------+ +----------+ | - * +----------+ +-----------+ | - * CLOSING |ws.close()|<--|close frame|<--+-----+ CLOSING - * +----------+ +-----------+ | - * | | | +---+ | - * +------------------------+-->|fin| - - - - - * | +---+ | +---+ - * - - - - -|fin|<---------------------+ - * +---+ - * - * @param {Number} [code] Status code explaining why the connection is closing - * @param {String} [data] A string explaining why the connection is closing - * @public - */ close(code, data) { if (this.readyState === WebSocket.CLOSED) return; @@ -29163,14 +28396,6 @@ var require_websocket = __commonJS({ closeTimeout ); } - /** - * Send a ping. - * - * @param {*} [data] The data to send - * @param {Boolean} [mask] Indicates whether or not to mask `data` - * @param {Function} [cb] Callback which is executed when the ping is sent - * @public - */ ping(data, mask, cb) { if (this.readyState === WebSocket.CONNECTING) { throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); @@ -29192,14 +28417,6 @@ var require_websocket = __commonJS({ mask = !this._isServer; this._sender.ping(data || EMPTY_BUFFER, mask, cb); } - /** - * Send a pong. - * - * @param {*} [data] The data to send - * @param {Boolean} [mask] Indicates whether or not to mask `data` - * @param {Function} [cb] Callback which is executed when the pong is sent - * @public - */ pong(data, mask, cb) { if (this.readyState === WebSocket.CONNECTING) { throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); @@ -29221,21 +28438,6 @@ var require_websocket = __commonJS({ mask = !this._isServer; this._sender.pong(data || EMPTY_BUFFER, mask, cb); } - /** - * Send a data message. - * - * @param {*} data The message to send - * @param {Object} [options] Options object - * @param {Boolean} [options.compress] Specifies whether or not to compress - * `data` - * @param {Boolean} [options.binary] Specifies whether `data` is binary or - * text - * @param {Boolean} [options.fin=true] Specifies whether the fragment is the - * last one - * @param {Boolean} [options.mask] Specifies whether or not to mask `data` - * @param {Function} [cb] Callback which is executed when data is written out - * @public - */ send(data, options2, cb) { if (this.readyState === WebSocket.CONNECTING) { throw new Error("WebSocket is not open: readyState 0 (CONNECTING)"); @@ -29261,11 +28463,6 @@ var require_websocket = __commonJS({ } this._sender.send(data || EMPTY_BUFFER, opts, cb); } - /** - * Forcibly close the connection. - * - * @public - */ terminate() { if (this.readyState === WebSocket.CLOSED) return; @@ -29298,12 +28495,6 @@ var require_websocket = __commonJS({ Object.defineProperty(WebSocket.prototype, `on${method}`, { configurable: true, enumerable: true, - /** - * Return the listener of the event. - * - * @return {(Function|undefined)} The event listener or `undefined` - * @public - */ get() { const listeners = this.listeners(method); for (let i = 0; i < listeners.length; i++) { @@ -29312,12 +28503,6 @@ var require_websocket = __commonJS({ } return void 0; }, - /** - * Add a listener for the event. - * - * @param {Function} listener The listener to add - * @public - */ set(listener) { const listeners = this.listeners(method); for (let i = 0; i < listeners.length; i++) { @@ -29741,27 +28926,6 @@ var require_websocket_server = __commonJS({ var { GUID, kWebSocket } = require_constants(); var keyRegex = /^[+/0-9A-Za-z]{22}==$/; var WebSocketServer = class extends EventEmitter { - /** - * Create a `WebSocketServer` instance. - * - * @param {Object} options Configuration options - * @param {Number} [options.backlog=511] The maximum length of the queue of - * pending connections - * @param {Boolean} [options.clientTracking=true] Specifies whether or not to - * track clients - * @param {Function} [options.handleProtocols] A hook to handle protocols - * @param {String} [options.host] The hostname where to bind the server - * @param {Number} [options.maxPayload=104857600] The maximum allowed message - * size - * @param {Boolean} [options.noServer=false] Enable no server mode - * @param {String} [options.path] Accept only connections matching this path - * @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable - * permessage-deflate - * @param {Number} [options.port] The port where to bind the server - * @param {http.Server} [options.server] A pre-created HTTP/S server to use - * @param {Function} [options.verifyClient] A hook to reject connections - * @param {Function} [callback] A listener for the `listening` event - */ constructor(options2, callback) { super(); options2 = __spreadValues({ @@ -29772,7 +28936,6 @@ var require_websocket_server = __commonJS({ verifyClient: null, noServer: false, backlog: null, - // use default (511 as implemented in net.js) server: null, host: null, path: null, @@ -29817,15 +28980,6 @@ var require_websocket_server = __commonJS({ this.clients = /* @__PURE__ */ new Set(); this.options = options2; } - /** - * Returns the bound address, the address family name, and port of the server - * as reported by the operating system if listening on an IP socket. - * If the server is listening on a pipe or UNIX domain socket, the name is - * returned as a string. - * - * @return {(Object|String|null)} The address of the server - * @public - */ address() { if (this.options.noServer) { throw new Error('The server is operating in "noServer" mode'); @@ -29834,12 +28988,6 @@ var require_websocket_server = __commonJS({ return null; return this._server.address(); } - /** - * Close the server. - * - * @param {Function} [cb] Callback - * @public - */ close(cb) { if (cb) this.once("close", cb); @@ -29858,13 +29006,6 @@ var require_websocket_server = __commonJS({ } process.nextTick(emitClose, this); } - /** - * See if a given request should be handled by this server instance. - * - * @param {http.IncomingMessage} req Request object to inspect - * @return {Boolean} `true` if the request is valid, else `false` - * @public - */ shouldHandle(req) { if (this.options.path) { const index = req.url.indexOf("?"); @@ -29874,15 +29015,6 @@ var require_websocket_server = __commonJS({ } return true; } - /** - * Handle a HTTP Upgrade request. - * - * @param {http.IncomingMessage} req The request object - * @param {net.Socket} socket The network socket between the server and client - * @param {Buffer} head The first packet of the upgraded stream - * @param {Function} cb Callback - * @public - */ handleUpgrade(req, socket, head, cb) { socket.on("error", socketOnError); const key = req.headers["sec-websocket-key"] !== void 0 ? req.headers["sec-websocket-key"].trim() : false; @@ -29927,18 +29059,6 @@ var require_websocket_server = __commonJS({ } this.completeUpgrade(key, extensions, req, socket, head, cb); } - /** - * Upgrade the connection to WebSocket. - * - * @param {String} key The value of the `Sec-WebSocket-Key` header - * @param {Object} extensions The accepted extensions - * @param {http.IncomingMessage} req The request object - * @param {net.Socket} socket The network socket between the server and client - * @param {Buffer} head The first packet of the upgraded stream - * @param {Function} cb Callback - * @throws {Error} If called more than once with the same socket - * @private - */ completeUpgrade(key, extensions, req, socket, head, cb) { if (!socket.readable || !socket.writable) return socket.destroy(); @@ -30042,12 +29162,12 @@ var require_ws = __commonJS({ var require_ws2 = __commonJS({ "node_modules/@ethersproject/providers/lib/ws.js"(exports2) { "use strict"; - var __importDefault2 = exports2 && exports2.__importDefault || function(mod) { + var __importDefault = exports2 && exports2.__importDefault || function(mod) { return mod && mod.__esModule ? mod : { "default": mod }; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.WebSocket = void 0; - var ws_1 = __importDefault2(require_ws()); + var ws_1 = __importDefault(require_ws()); exports2.WebSocket = ws_1.default; } }); @@ -30056,28 +29176,28 @@ var require_ws2 = __commonJS({ var require_websocket_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/websocket-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -30104,7 +29224,7 @@ var require_websocket_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -30190,285 +29310,276 @@ var require_websocket_provider = __commonJS({ var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); var NextId = 1; - var WebSocketProvider = ( - /** @class */ - function(_super) { - __extends2(WebSocketProvider2, _super); - function WebSocketProvider2(url, network) { - var _this = this; - if (network === "any") { - logger2.throwError("WebSocketProvider does not support 'any' network yet", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "network:any" - }); - } - _this = _super.call(this, url, network) || this; - _this._pollingInterval = -1; - _this._wsReady = false; - (0, properties_1.defineReadOnly)(_this, "_websocket", new ws_1.WebSocket(_this.connection.url)); - (0, properties_1.defineReadOnly)(_this, "_requests", {}); - (0, properties_1.defineReadOnly)(_this, "_subs", {}); - (0, properties_1.defineReadOnly)(_this, "_subIds", {}); - (0, properties_1.defineReadOnly)(_this, "_detectNetwork", _super.prototype.detectNetwork.call(_this)); - _this._websocket.onopen = function() { - _this._wsReady = true; - Object.keys(_this._requests).forEach(function(id) { - _this._websocket.send(_this._requests[id].payload); - }); - }; - _this._websocket.onmessage = function(messageEvent) { - var data = messageEvent.data; - var result = JSON.parse(data); - if (result.id != null) { - var id = String(result.id); - var request = _this._requests[id]; - delete _this._requests[id]; - if (result.result !== void 0) { - request.callback(null, result.result); - _this.emit("debug", { - action: "response", - request: JSON.parse(request.payload), - response: result.result, - provider: _this - }); + var WebSocketProvider = function(_super) { + __extends(WebSocketProvider2, _super); + function WebSocketProvider2(url, network) { + var _this = this; + if (network === "any") { + logger2.throwError("WebSocketProvider does not support 'any' network yet", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "network:any" + }); + } + _this = _super.call(this, url, network) || this; + _this._pollingInterval = -1; + _this._wsReady = false; + (0, properties_1.defineReadOnly)(_this, "_websocket", new ws_1.WebSocket(_this.connection.url)); + (0, properties_1.defineReadOnly)(_this, "_requests", {}); + (0, properties_1.defineReadOnly)(_this, "_subs", {}); + (0, properties_1.defineReadOnly)(_this, "_subIds", {}); + (0, properties_1.defineReadOnly)(_this, "_detectNetwork", _super.prototype.detectNetwork.call(_this)); + _this._websocket.onopen = function() { + _this._wsReady = true; + Object.keys(_this._requests).forEach(function(id) { + _this._websocket.send(_this._requests[id].payload); + }); + }; + _this._websocket.onmessage = function(messageEvent) { + var data = messageEvent.data; + var result = JSON.parse(data); + if (result.id != null) { + var id = String(result.id); + var request = _this._requests[id]; + delete _this._requests[id]; + if (result.result !== void 0) { + request.callback(null, result.result); + _this.emit("debug", { + action: "response", + request: JSON.parse(request.payload), + response: result.result, + provider: _this + }); + } else { + var error = null; + if (result.error) { + error = new Error(result.error.message || "unknown error"); + (0, properties_1.defineReadOnly)(error, "code", result.error.code || null); + (0, properties_1.defineReadOnly)(error, "response", data); } else { - var error = null; - if (result.error) { - error = new Error(result.error.message || "unknown error"); - (0, properties_1.defineReadOnly)(error, "code", result.error.code || null); - (0, properties_1.defineReadOnly)(error, "response", data); - } else { - error = new Error("unknown error"); - } - request.callback(error, void 0); - _this.emit("debug", { - action: "response", - error, - request: JSON.parse(request.payload), - provider: _this - }); + error = new Error("unknown error"); } - } else if (result.method === "eth_subscription") { - var sub = _this._subs[result.params.subscription]; - if (sub) { - sub.processFunc(result.params.result); - } - } else { - console.warn("this should not happen"); + request.callback(error, void 0); + _this.emit("debug", { + action: "response", + error, + request: JSON.parse(request.payload), + provider: _this + }); } - }; - var fauxPoll = setInterval(function() { - _this.emit("poll"); - }, 1e3); - if (fauxPoll.unref) { - fauxPoll.unref(); + } else if (result.method === "eth_subscription") { + var sub = _this._subs[result.params.subscription]; + if (sub) { + sub.processFunc(result.params.result); + } + } else { + console.warn("this should not happen"); } - return _this; - } - WebSocketProvider2.prototype.detectNetwork = function() { - return this._detectNetwork; }; - Object.defineProperty(WebSocketProvider2.prototype, "pollingInterval", { - get: function() { - return 0; - }, - set: function(value) { - logger2.throwError("cannot set polling interval on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "setPollingInterval" - }); - }, - enumerable: false, - configurable: true + var fauxPoll = setInterval(function() { + _this.emit("poll"); + }, 1e3); + if (fauxPoll.unref) { + fauxPoll.unref(); + } + return _this; + } + WebSocketProvider2.prototype.detectNetwork = function() { + return this._detectNetwork; + }; + Object.defineProperty(WebSocketProvider2.prototype, "pollingInterval", { + get: function() { + return 0; + }, + set: function(value) { + logger2.throwError("cannot set polling interval on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setPollingInterval" + }); + }, + enumerable: false, + configurable: true + }); + WebSocketProvider2.prototype.resetEventsBlock = function(blockNumber) { + logger2.throwError("cannot reset events block on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "resetEventBlock" }); - WebSocketProvider2.prototype.resetEventsBlock = function(blockNumber) { - logger2.throwError("cannot reset events block on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "resetEventBlock" + }; + WebSocketProvider2.prototype.poll = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + return [2, null]; }); - }; - WebSocketProvider2.prototype.poll = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - return [2, null]; - }); + }); + }; + Object.defineProperty(WebSocketProvider2.prototype, "polling", { + set: function(value) { + if (!value) { + return; + } + logger2.throwError("cannot set polling on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setPolling" }); - }; - Object.defineProperty(WebSocketProvider2.prototype, "polling", { - set: function(value) { - if (!value) { - return; + }, + enumerable: false, + configurable: true + }); + WebSocketProvider2.prototype.send = function(method, params) { + var _this = this; + var rid = NextId++; + return new Promise(function(resolve, reject) { + function callback(error, result) { + if (error) { + return reject(error); } - logger2.throwError("cannot set polling on WebSocketProvider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "setPolling" - }); - }, - enumerable: false, - configurable: true + return resolve(result); + } + var payload = JSON.stringify({ + method, + params, + id: rid, + jsonrpc: "2.0" + }); + _this.emit("debug", { + action: "request", + request: JSON.parse(payload), + provider: _this + }); + _this._requests[String(rid)] = { callback, payload }; + if (_this._wsReady) { + _this._websocket.send(payload); + } }); - WebSocketProvider2.prototype.send = function(method, params) { + }; + WebSocketProvider2.defaultUrl = function() { + return "ws://localhost:8546"; + }; + WebSocketProvider2.prototype._subscribe = function(tag, param, processFunc) { + return __awaiter(this, void 0, void 0, function() { + var subIdPromise, subId; var _this = this; - var rid = NextId++; - return new Promise(function(resolve, reject) { - function callback(error, result) { - if (error) { - return reject(error); - } - return resolve(result); + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + subIdPromise = this._subIds[tag]; + if (subIdPromise == null) { + subIdPromise = Promise.all(param).then(function(param2) { + return _this.send("eth_subscribe", param2); + }); + this._subIds[tag] = subIdPromise; + } + return [4, subIdPromise]; + case 1: + subId = _a7.sent(); + this._subs[subId] = { tag, processFunc }; + return [2]; } - var payload = JSON.stringify({ - method, - params, - id: rid, - jsonrpc: "2.0" + }); + }); + }; + WebSocketProvider2.prototype._startEvent = function(event) { + var _this = this; + switch (event.type) { + case "block": + this._subscribe("block", ["newHeads"], function(result) { + var blockNumber = bignumber_1.BigNumber.from(result.number).toNumber(); + _this._emitted.block = blockNumber; + _this.emit("block", blockNumber); }); - _this.emit("debug", { - action: "request", - request: JSON.parse(payload), - provider: _this + break; + case "pending": + this._subscribe("pending", ["newPendingTransactions"], function(result) { + _this.emit("pending", result); }); - _this._requests[String(rid)] = { callback, payload }; - if (_this._wsReady) { - _this._websocket.send(payload); - } - }); - }; - WebSocketProvider2.defaultUrl = function() { - return "ws://localhost:8546"; - }; - WebSocketProvider2.prototype._subscribe = function(tag, param, processFunc) { - return __awaiter2(this, void 0, void 0, function() { - var subIdPromise, subId; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - subIdPromise = this._subIds[tag]; - if (subIdPromise == null) { - subIdPromise = Promise.all(param).then(function(param2) { - return _this.send("eth_subscribe", param2); - }); - this._subIds[tag] = subIdPromise; - } - return [4, subIdPromise]; - case 1: - subId = _a7.sent(); - this._subs[subId] = { tag, processFunc }; - return [ - 2 - /*return*/ - ]; + break; + case "filter": + this._subscribe(event.tag, ["logs", this._getFilter(event.filter)], function(result) { + if (result.removed == null) { + result.removed = false; } + _this.emit(event.filter, _this.formatter.filterLog(result)); }); - }); - }; - WebSocketProvider2.prototype._startEvent = function(event) { - var _this = this; - switch (event.type) { - case "block": - this._subscribe("block", ["newHeads"], function(result) { - var blockNumber = bignumber_1.BigNumber.from(result.number).toNumber(); - _this._emitted.block = blockNumber; - _this.emit("block", blockNumber); - }); - break; - case "pending": - this._subscribe("pending", ["newPendingTransactions"], function(result) { - _this.emit("pending", result); - }); - break; - case "filter": - this._subscribe(event.tag, ["logs", this._getFilter(event.filter)], function(result) { - if (result.removed == null) { - result.removed = false; + break; + case "tx": { + var emitReceipt_1 = function(event2) { + var hash = event2.hash; + _this.getTransactionReceipt(hash).then(function(receipt) { + if (!receipt) { + return; } - _this.emit(event.filter, _this.formatter.filterLog(result)); + _this.emit(hash, receipt); }); - break; - case "tx": { - var emitReceipt_1 = function(event2) { - var hash = event2.hash; - _this.getTransactionReceipt(hash).then(function(receipt) { - if (!receipt) { - return; - } - _this.emit(hash, receipt); - }); - }; - emitReceipt_1(event); - this._subscribe("tx", ["newHeads"], function(result) { - _this._events.filter(function(e) { - return e.type === "tx"; - }).forEach(emitReceipt_1); - }); - break; - } - case "debug": - case "poll": - case "willPoll": - case "didPoll": - case "error": - break; - default: - console.log("unhandled:", event); - break; + }; + emitReceipt_1(event); + this._subscribe("tx", ["newHeads"], function(result) { + _this._events.filter(function(e) { + return e.type === "tx"; + }).forEach(emitReceipt_1); + }); + break; } - }; - WebSocketProvider2.prototype._stopEvent = function(event) { - var _this = this; - var tag = event.tag; - if (event.type === "tx") { - if (this._events.filter(function(e) { - return e.type === "tx"; - }).length) { - return; - } - tag = "tx"; - } else if (this.listenerCount(event.event)) { + case "debug": + case "poll": + case "willPoll": + case "didPoll": + case "error": + break; + default: + console.log("unhandled:", event); + break; + } + }; + WebSocketProvider2.prototype._stopEvent = function(event) { + var _this = this; + var tag = event.tag; + if (event.type === "tx") { + if (this._events.filter(function(e) { + return e.type === "tx"; + }).length) { return; } - var subId = this._subIds[tag]; - if (!subId) { + tag = "tx"; + } else if (this.listenerCount(event.event)) { + return; + } + var subId = this._subIds[tag]; + if (!subId) { + return; + } + delete this._subIds[tag]; + subId.then(function(subId2) { + if (!_this._subs[subId2]) { return; } - delete this._subIds[tag]; - subId.then(function(subId2) { - if (!_this._subs[subId2]) { - return; + delete _this._subs[subId2]; + _this.send("eth_unsubscribe", [subId2]); + }); + }; + WebSocketProvider2.prototype.destroy = function() { + return __awaiter(this, void 0, void 0, function() { + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (!(this._websocket.readyState === ws_1.WebSocket.CONNECTING)) + return [3, 2]; + return [4, new Promise(function(resolve) { + _this._websocket.onopen = function() { + resolve(true); + }; + _this._websocket.onerror = function() { + resolve(false); + }; + })]; + case 1: + _a7.sent(); + _a7.label = 2; + case 2: + this._websocket.close(1e3); + return [2]; } - delete _this._subs[subId2]; - _this.send("eth_unsubscribe", [subId2]); }); - }; - WebSocketProvider2.prototype.destroy = function() { - return __awaiter2(this, void 0, void 0, function() { - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (!(this._websocket.readyState === ws_1.WebSocket.CONNECTING)) - return [3, 2]; - return [4, new Promise(function(resolve) { - _this._websocket.onopen = function() { - resolve(true); - }; - _this._websocket.onerror = function() { - resolve(false); - }; - })]; - case 1: - _a7.sent(); - _a7.label = 2; - case 2: - this._websocket.close(1e3); - return [ - 2 - /*return*/ - ]; - } - }); - }); - }; - return WebSocketProvider2; - }(json_rpc_provider_1.JsonRpcProvider) - ); + }); + }; + return WebSocketProvider2; + }(json_rpc_provider_1.JsonRpcProvider); exports2.WebSocketProvider = WebSocketProvider; } }); @@ -30477,28 +29588,28 @@ var require_websocket_provider = __commonJS({ var require_url_json_rpc_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/url-json-rpc-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -30525,7 +29636,7 @@ var require_url_json_rpc_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -30608,87 +29719,81 @@ var require_url_json_rpc_provider = __commonJS({ var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); var json_rpc_provider_1 = require_json_rpc_provider(); - var StaticJsonRpcProvider3 = ( - /** @class */ - function(_super) { - __extends2(StaticJsonRpcProvider4, _super); - function StaticJsonRpcProvider4() { - return _super !== null && _super.apply(this, arguments) || this; - } - StaticJsonRpcProvider4.prototype.detectNetwork = function() { - return __awaiter2(this, void 0, void 0, function() { - var network; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - network = this.network; - if (!(network == null)) - return [3, 2]; - return [4, _super.prototype.detectNetwork.call(this)]; - case 1: - network = _a7.sent(); - if (!network) { - logger2.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {}); - } - if (this._network == null) { - (0, properties_1.defineReadOnly)(this, "_network", network); - this.emit("network", network, null); - } - _a7.label = 2; - case 2: - return [2, network]; - } - }); + var StaticJsonRpcProvider3 = function(_super) { + __extends(StaticJsonRpcProvider4, _super); + function StaticJsonRpcProvider4() { + return _super !== null && _super.apply(this, arguments) || this; + } + StaticJsonRpcProvider4.prototype.detectNetwork = function() { + return __awaiter(this, void 0, void 0, function() { + var network; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + network = this.network; + if (!(network == null)) + return [3, 2]; + return [4, _super.prototype.detectNetwork.call(this)]; + case 1: + network = _a7.sent(); + if (!network) { + logger2.throwError("no network detected", logger_1.Logger.errors.UNKNOWN_ERROR, {}); + } + if (this._network == null) { + (0, properties_1.defineReadOnly)(this, "_network", network); + this.emit("network", network, null); + } + _a7.label = 2; + case 2: + return [2, network]; + } }); - }; - return StaticJsonRpcProvider4; - }(json_rpc_provider_1.JsonRpcProvider) - ); + }); + }; + return StaticJsonRpcProvider4; + }(json_rpc_provider_1.JsonRpcProvider); exports2.StaticJsonRpcProvider = StaticJsonRpcProvider3; - var UrlJsonRpcProvider = ( - /** @class */ - function(_super) { - __extends2(UrlJsonRpcProvider2, _super); - function UrlJsonRpcProvider2(network, apiKey) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkAbstract(_newTarget, UrlJsonRpcProvider2); - network = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network); - apiKey = (0, properties_1.getStatic)(_newTarget, "getApiKey")(apiKey); - var connection = (0, properties_1.getStatic)(_newTarget, "getUrl")(network, apiKey); - _this = _super.call(this, connection, network) || this; - if (typeof apiKey === "string") { - (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey); - } else if (apiKey != null) { - Object.keys(apiKey).forEach(function(key) { - (0, properties_1.defineReadOnly)(_this, key, apiKey[key]); - }); - } - return _this; - } - UrlJsonRpcProvider2.prototype._startPending = function() { - logger2.warn("WARNING: API provider does not support pending filters"); - }; - UrlJsonRpcProvider2.prototype.isCommunityResource = function() { - return false; - }; - UrlJsonRpcProvider2.prototype.getSigner = function(address) { - return logger2.throwError("API provider does not support signing", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); - }; - UrlJsonRpcProvider2.prototype.listAccounts = function() { - return Promise.resolve([]); - }; - UrlJsonRpcProvider2.getApiKey = function(apiKey) { - return apiKey; - }; - UrlJsonRpcProvider2.getUrl = function(network, apiKey) { - return logger2.throwError("not implemented; sub-classes must override getUrl", logger_1.Logger.errors.NOT_IMPLEMENTED, { - operation: "getUrl" + var UrlJsonRpcProvider = function(_super) { + __extends(UrlJsonRpcProvider2, _super); + function UrlJsonRpcProvider2(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkAbstract(_newTarget, UrlJsonRpcProvider2); + network = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network); + apiKey = (0, properties_1.getStatic)(_newTarget, "getApiKey")(apiKey); + var connection = (0, properties_1.getStatic)(_newTarget, "getUrl")(network, apiKey); + _this = _super.call(this, connection, network) || this; + if (typeof apiKey === "string") { + (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey); + } else if (apiKey != null) { + Object.keys(apiKey).forEach(function(key) { + (0, properties_1.defineReadOnly)(_this, key, apiKey[key]); }); - }; - return UrlJsonRpcProvider2; - }(StaticJsonRpcProvider3) - ); + } + return _this; + } + UrlJsonRpcProvider2.prototype._startPending = function() { + logger2.warn("WARNING: API provider does not support pending filters"); + }; + UrlJsonRpcProvider2.prototype.isCommunityResource = function() { + return false; + }; + UrlJsonRpcProvider2.prototype.getSigner = function(address) { + return logger2.throwError("API provider does not support signing", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); + }; + UrlJsonRpcProvider2.prototype.listAccounts = function() { + return Promise.resolve([]); + }; + UrlJsonRpcProvider2.getApiKey = function(apiKey) { + return apiKey; + }; + UrlJsonRpcProvider2.getUrl = function(network, apiKey) { + return logger2.throwError("not implemented; sub-classes must override getUrl", logger_1.Logger.errors.NOT_IMPLEMENTED, { + operation: "getUrl" + }); + }; + return UrlJsonRpcProvider2; + }(StaticJsonRpcProvider3); exports2.UrlJsonRpcProvider = UrlJsonRpcProvider; } }); @@ -30697,21 +29802,21 @@ var require_url_json_rpc_provider = __commonJS({ var require_alchemy_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/alchemy-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -30728,100 +29833,94 @@ var require_alchemy_provider = __commonJS({ var logger2 = new logger_1.Logger(_version_1.version); var url_json_rpc_provider_1 = require_url_json_rpc_provider(); var defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"; - var AlchemyWebSocketProvider = ( - /** @class */ - function(_super) { - __extends2(AlchemyWebSocketProvider2, _super); - function AlchemyWebSocketProvider2(network, apiKey) { - var _this = this; - var provider = new AlchemyProvider(network, apiKey); - var url = provider.connection.url.replace(/^http/i, "ws").replace(".alchemyapi.", ".ws.alchemyapi."); - _this = _super.call(this, url, provider.network) || this; - (0, properties_1.defineReadOnly)(_this, "apiKey", provider.apiKey); - return _this; - } - AlchemyWebSocketProvider2.prototype.isCommunityResource = function() { - return this.apiKey === defaultApiKey; - }; - return AlchemyWebSocketProvider2; - }(websocket_provider_1.WebSocketProvider) - ); + var AlchemyWebSocketProvider = function(_super) { + __extends(AlchemyWebSocketProvider2, _super); + function AlchemyWebSocketProvider2(network, apiKey) { + var _this = this; + var provider = new AlchemyProvider(network, apiKey); + var url = provider.connection.url.replace(/^http/i, "ws").replace(".alchemyapi.", ".ws.alchemyapi."); + _this = _super.call(this, url, provider.network) || this; + (0, properties_1.defineReadOnly)(_this, "apiKey", provider.apiKey); + return _this; + } + AlchemyWebSocketProvider2.prototype.isCommunityResource = function() { + return this.apiKey === defaultApiKey; + }; + return AlchemyWebSocketProvider2; + }(websocket_provider_1.WebSocketProvider); exports2.AlchemyWebSocketProvider = AlchemyWebSocketProvider; - var AlchemyProvider = ( - /** @class */ - function(_super) { - __extends2(AlchemyProvider2, _super); - function AlchemyProvider2() { - return _super !== null && _super.apply(this, arguments) || this; - } - AlchemyProvider2.getWebSocketProvider = function(network, apiKey) { - return new AlchemyWebSocketProvider(network, apiKey); - }; - AlchemyProvider2.getApiKey = function(apiKey) { - if (apiKey == null) { - return defaultApiKey; - } - if (apiKey && typeof apiKey !== "string") { - logger2.throwArgumentError("invalid apiKey", "apiKey", apiKey); - } - return apiKey; - }; - AlchemyProvider2.getUrl = function(network, apiKey) { - var host = null; - switch (network.name) { - case "homestead": - host = "eth-mainnet.alchemyapi.io/v2/"; - break; - case "ropsten": - host = "eth-ropsten.alchemyapi.io/v2/"; - break; - case "rinkeby": - host = "eth-rinkeby.alchemyapi.io/v2/"; - break; - case "goerli": - host = "eth-goerli.alchemyapi.io/v2/"; - break; - case "kovan": - host = "eth-kovan.alchemyapi.io/v2/"; - break; - case "matic": - host = "polygon-mainnet.g.alchemy.com/v2/"; - break; - case "maticmum": - host = "polygon-mumbai.g.alchemy.com/v2/"; - break; - case "arbitrum": - host = "arb-mainnet.g.alchemy.com/v2/"; - break; - case "arbitrum-rinkeby": - host = "arb-rinkeby.g.alchemy.com/v2/"; - break; - case "optimism": - host = "opt-mainnet.g.alchemy.com/v2/"; - break; - case "optimism-kovan": - host = "opt-kovan.g.alchemy.com/v2/"; - break; - default: - logger2.throwArgumentError("unsupported network", "network", arguments[0]); - } - return { - allowGzip: true, - url: "https://" + host + apiKey, - throttleCallback: function(attempt, url) { - if (apiKey === defaultApiKey) { - (0, formatter_1.showThrottleMessage)(); - } - return Promise.resolve(true); + var AlchemyProvider = function(_super) { + __extends(AlchemyProvider2, _super); + function AlchemyProvider2() { + return _super !== null && _super.apply(this, arguments) || this; + } + AlchemyProvider2.getWebSocketProvider = function(network, apiKey) { + return new AlchemyWebSocketProvider(network, apiKey); + }; + AlchemyProvider2.getApiKey = function(apiKey) { + if (apiKey == null) { + return defaultApiKey; + } + if (apiKey && typeof apiKey !== "string") { + logger2.throwArgumentError("invalid apiKey", "apiKey", apiKey); + } + return apiKey; + }; + AlchemyProvider2.getUrl = function(network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "eth-mainnet.alchemyapi.io/v2/"; + break; + case "ropsten": + host = "eth-ropsten.alchemyapi.io/v2/"; + break; + case "rinkeby": + host = "eth-rinkeby.alchemyapi.io/v2/"; + break; + case "goerli": + host = "eth-goerli.alchemyapi.io/v2/"; + break; + case "kovan": + host = "eth-kovan.alchemyapi.io/v2/"; + break; + case "matic": + host = "polygon-mainnet.g.alchemy.com/v2/"; + break; + case "maticmum": + host = "polygon-mumbai.g.alchemy.com/v2/"; + break; + case "arbitrum": + host = "arb-mainnet.g.alchemy.com/v2/"; + break; + case "arbitrum-rinkeby": + host = "arb-rinkeby.g.alchemy.com/v2/"; + break; + case "optimism": + host = "opt-mainnet.g.alchemy.com/v2/"; + break; + case "optimism-kovan": + host = "opt-kovan.g.alchemy.com/v2/"; + break; + default: + logger2.throwArgumentError("unsupported network", "network", arguments[0]); + } + return { + allowGzip: true, + url: "https://" + host + apiKey, + throttleCallback: function(attempt, url) { + if (apiKey === defaultApiKey) { + (0, formatter_1.showThrottleMessage)(); } - }; - }; - AlchemyProvider2.prototype.isCommunityResource = function() { - return this.apiKey === defaultApiKey; + return Promise.resolve(true); + } }; - return AlchemyProvider2; - }(url_json_rpc_provider_1.UrlJsonRpcProvider) - ); + }; + AlchemyProvider2.prototype.isCommunityResource = function() { + return this.apiKey === defaultApiKey; + }; + return AlchemyProvider2; + }(url_json_rpc_provider_1.UrlJsonRpcProvider); exports2.AlchemyProvider = AlchemyProvider; } }); @@ -30830,28 +29929,28 @@ var require_alchemy_provider = __commonJS({ var require_cloudflare_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/cloudflare-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -30878,7 +29977,7 @@ var require_cloudflare_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -30960,51 +30059,48 @@ var require_cloudflare_provider = __commonJS({ var logger_1 = require_lib(); var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); - var CloudflareProvider = ( - /** @class */ - function(_super) { - __extends2(CloudflareProvider2, _super); - function CloudflareProvider2() { - return _super !== null && _super.apply(this, arguments) || this; + var CloudflareProvider = function(_super) { + __extends(CloudflareProvider2, _super); + function CloudflareProvider2() { + return _super !== null && _super.apply(this, arguments) || this; + } + CloudflareProvider2.getApiKey = function(apiKey) { + if (apiKey != null) { + logger2.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); } - CloudflareProvider2.getApiKey = function(apiKey) { - if (apiKey != null) { - logger2.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); - } - return null; - }; - CloudflareProvider2.getUrl = function(network, apiKey) { - var host = null; - switch (network.name) { - case "homestead": - host = "https://cloudflare-eth.com/"; - break; - default: - logger2.throwArgumentError("unsupported network", "network", arguments[0]); - } - return host; - }; - CloudflareProvider2.prototype.perform = function(method, params) { - return __awaiter2(this, void 0, void 0, function() { - var block; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (!(method === "getBlockNumber")) - return [3, 2]; - return [4, _super.prototype.perform.call(this, "getBlock", { blockTag: "latest" })]; - case 1: - block = _a7.sent(); - return [2, block.number]; - case 2: - return [2, _super.prototype.perform.call(this, method, params)]; - } - }); + return null; + }; + CloudflareProvider2.getUrl = function(network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "https://cloudflare-eth.com/"; + break; + default: + logger2.throwArgumentError("unsupported network", "network", arguments[0]); + } + return host; + }; + CloudflareProvider2.prototype.perform = function(method, params) { + return __awaiter(this, void 0, void 0, function() { + var block; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (!(method === "getBlockNumber")) + return [3, 2]; + return [4, _super.prototype.perform.call(this, "getBlock", { blockTag: "latest" })]; + case 1: + block = _a7.sent(); + return [2, block.number]; + case 2: + return [2, _super.prototype.perform.call(this, method, params)]; + } }); - }; - return CloudflareProvider2; - }(url_json_rpc_provider_1.UrlJsonRpcProvider) - ); + }); + }; + return CloudflareProvider2; + }(url_json_rpc_provider_1.UrlJsonRpcProvider); exports2.CloudflareProvider = CloudflareProvider; } }); @@ -31013,28 +30109,28 @@ var require_cloudflare_provider = __commonJS({ var require_etherscan_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/etherscan-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -31061,7 +30157,7 @@ var require_etherscan_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -31277,340 +30373,337 @@ var require_etherscan_provider = __commonJS({ } throw error; } - var EtherscanProvider = ( - /** @class */ - function(_super) { - __extends2(EtherscanProvider2, _super); - function EtherscanProvider2(network, apiKey) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, EtherscanProvider2); - _this = _super.call(this, network) || this; - (0, properties_1.defineReadOnly)(_this, "baseUrl", _this.getBaseUrl()); - (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey || defaultApiKey); - return _this; - } - EtherscanProvider2.prototype.getBaseUrl = function() { - switch (this.network ? this.network.name : "invalid") { - case "homestead": - return "https://api.etherscan.io"; - case "ropsten": - return "https://api-ropsten.etherscan.io"; - case "rinkeby": - return "https://api-rinkeby.etherscan.io"; - case "kovan": - return "https://api-kovan.etherscan.io"; - case "goerli": - return "https://api-goerli.etherscan.io"; - default: + var EtherscanProvider = function(_super) { + __extends(EtherscanProvider2, _super); + function EtherscanProvider2(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, EtherscanProvider2); + _this = _super.call(this, network) || this; + (0, properties_1.defineReadOnly)(_this, "baseUrl", _this.getBaseUrl()); + (0, properties_1.defineReadOnly)(_this, "apiKey", apiKey || defaultApiKey); + return _this; + } + EtherscanProvider2.prototype.getBaseUrl = function() { + switch (this.network ? this.network.name : "invalid") { + case "homestead": + return "https://api.etherscan.io"; + case "ropsten": + return "https://api-ropsten.etherscan.io"; + case "rinkeby": + return "https://api-rinkeby.etherscan.io"; + case "kovan": + return "https://api-kovan.etherscan.io"; + case "goerli": + return "https://api-goerli.etherscan.io"; + default: + } + return logger2.throwArgumentError("unsupported network", "network", name); + }; + EtherscanProvider2.prototype.getUrl = function(module3, params) { + var query = Object.keys(params).reduce(function(accum, key) { + var value = params[key]; + if (value != null) { + accum += "&" + key + "=" + value; } - return logger2.throwArgumentError("unsupported network", "network", name); - }; - EtherscanProvider2.prototype.getUrl = function(module3, params) { - var query = Object.keys(params).reduce(function(accum, key) { - var value = params[key]; - if (value != null) { - accum += "&" + key + "=" + value; - } - return accum; - }, ""); - var apiKey = this.apiKey ? "&apikey=" + this.apiKey : ""; - return this.baseUrl + "/api?module=" + module3 + query + apiKey; - }; - EtherscanProvider2.prototype.getPostUrl = function() { - return this.baseUrl + "/api"; - }; - EtherscanProvider2.prototype.getPostData = function(module3, params) { - params.module = module3; - params.apikey = this.apiKey; - return params; - }; - EtherscanProvider2.prototype.fetch = function(module3, params, post) { - return __awaiter2(this, void 0, void 0, function() { - var url, payload, procFunc, connection, payloadStr, result; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - url = post ? this.getPostUrl() : this.getUrl(module3, params); - payload = post ? this.getPostData(module3, params) : null; - procFunc = module3 === "proxy" ? getJsonResult : getResult; - this.emit("debug", { - action: "request", - request: url, - provider: this - }); - connection = { - url, - throttleSlotInterval: 1e3, - throttleCallback: function(attempt, url2) { - if (_this.isCommunityResource()) { - (0, formatter_1.showThrottleMessage)(); - } - return Promise.resolve(true); + return accum; + }, ""); + var apiKey = this.apiKey ? "&apikey=" + this.apiKey : ""; + return this.baseUrl + "/api?module=" + module3 + query + apiKey; + }; + EtherscanProvider2.prototype.getPostUrl = function() { + return this.baseUrl + "/api"; + }; + EtherscanProvider2.prototype.getPostData = function(module3, params) { + params.module = module3; + params.apikey = this.apiKey; + return params; + }; + EtherscanProvider2.prototype.fetch = function(module3, params, post) { + return __awaiter(this, void 0, void 0, function() { + var url, payload, procFunc, connection, payloadStr, result; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + url = post ? this.getPostUrl() : this.getUrl(module3, params); + payload = post ? this.getPostData(module3, params) : null; + procFunc = module3 === "proxy" ? getJsonResult : getResult; + this.emit("debug", { + action: "request", + request: url, + provider: this + }); + connection = { + url, + throttleSlotInterval: 1e3, + throttleCallback: function(attempt, url2) { + if (_this.isCommunityResource()) { + (0, formatter_1.showThrottleMessage)(); } - }; - payloadStr = null; - if (payload) { - connection.headers = { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" }; - payloadStr = Object.keys(payload).map(function(key) { - return key + "=" + payload[key]; - }).join("&"); + return Promise.resolve(true); } - return [4, (0, web_1.fetchJson)(connection, payloadStr, procFunc || getJsonResult)]; - case 1: - result = _a7.sent(); - this.emit("debug", { - action: "response", - request: url, - response: (0, properties_1.deepCopy)(result), - provider: this - }); - return [2, result]; - } - }); + }; + payloadStr = null; + if (payload) { + connection.headers = { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" }; + payloadStr = Object.keys(payload).map(function(key) { + return key + "=" + payload[key]; + }).join("&"); + } + return [4, (0, web_1.fetchJson)(connection, payloadStr, procFunc || getJsonResult)]; + case 1: + result = _a7.sent(); + this.emit("debug", { + action: "response", + request: url, + response: (0, properties_1.deepCopy)(result), + provider: this + }); + return [2, result]; + } }); - }; - EtherscanProvider2.prototype.detectNetwork = function() { - return __awaiter2(this, void 0, void 0, function() { - return __generator2(this, function(_a7) { - return [2, this.network]; - }); + }); + }; + EtherscanProvider2.prototype.detectNetwork = function() { + return __awaiter(this, void 0, void 0, function() { + return __generator(this, function(_a7) { + return [2, this.network]; }); - }; - EtherscanProvider2.prototype.perform = function(method, params) { - return __awaiter2(this, void 0, void 0, function() { - var _a7, postData, error_1, postData, error_2, args, topic0, logs, blocks, i, log, block, _b; - return __generator2(this, function(_c) { - switch (_c.label) { - case 0: - _a7 = method; - switch (_a7) { - case "getBlockNumber": - return [3, 1]; - case "getGasPrice": - return [3, 2]; - case "getBalance": - return [3, 3]; - case "getTransactionCount": - return [3, 4]; - case "getCode": - return [3, 5]; - case "getStorageAt": - return [3, 6]; - case "sendTransaction": - return [3, 7]; - case "getBlock": - return [3, 8]; - case "getTransaction": - return [3, 9]; - case "getTransactionReceipt": - return [3, 10]; - case "call": - return [3, 11]; - case "estimateGas": - return [3, 15]; - case "getLogs": - return [3, 19]; - case "getEtherPrice": - return [3, 26]; - } - return [3, 28]; - case 1: - return [2, this.fetch("proxy", { action: "eth_blockNumber" })]; - case 2: - return [2, this.fetch("proxy", { action: "eth_gasPrice" })]; - case 3: - return [2, this.fetch("account", { - action: "balance", - address: params.address, - tag: params.blockTag - })]; - case 4: - return [2, this.fetch("proxy", { - action: "eth_getTransactionCount", - address: params.address, - tag: params.blockTag - })]; - case 5: - return [2, this.fetch("proxy", { - action: "eth_getCode", - address: params.address, - tag: params.blockTag - })]; - case 6: - return [2, this.fetch("proxy", { - action: "eth_getStorageAt", - address: params.address, - position: params.position, - tag: params.blockTag - })]; - case 7: - return [2, this.fetch("proxy", { - action: "eth_sendRawTransaction", - hex: params.signedTransaction - }, true).catch(function(error) { - return checkError("sendTransaction", error, params.signedTransaction); - })]; - case 8: - if (params.blockTag) { - return [2, this.fetch("proxy", { - action: "eth_getBlockByNumber", - tag: params.blockTag, - boolean: params.includeTransactions ? "true" : "false" - })]; - } - throw new Error("getBlock by blockHash not implemented"); - case 9: - return [2, this.fetch("proxy", { - action: "eth_getTransactionByHash", - txhash: params.transactionHash - })]; - case 10: + }); + }; + EtherscanProvider2.prototype.perform = function(method, params) { + return __awaiter(this, void 0, void 0, function() { + var _a7, postData, error_1, postData, error_2, args, topic0, logs, blocks, i, log, block, _b; + return __generator(this, function(_c) { + switch (_c.label) { + case 0: + _a7 = method; + switch (_a7) { + case "getBlockNumber": + return [3, 1]; + case "getGasPrice": + return [3, 2]; + case "getBalance": + return [3, 3]; + case "getTransactionCount": + return [3, 4]; + case "getCode": + return [3, 5]; + case "getStorageAt": + return [3, 6]; + case "sendTransaction": + return [3, 7]; + case "getBlock": + return [3, 8]; + case "getTransaction": + return [3, 9]; + case "getTransactionReceipt": + return [3, 10]; + case "call": + return [3, 11]; + case "estimateGas": + return [3, 15]; + case "getLogs": + return [3, 19]; + case "getEtherPrice": + return [3, 26]; + } + return [3, 28]; + case 1: + return [2, this.fetch("proxy", { action: "eth_blockNumber" })]; + case 2: + return [2, this.fetch("proxy", { action: "eth_gasPrice" })]; + case 3: + return [2, this.fetch("account", { + action: "balance", + address: params.address, + tag: params.blockTag + })]; + case 4: + return [2, this.fetch("proxy", { + action: "eth_getTransactionCount", + address: params.address, + tag: params.blockTag + })]; + case 5: + return [2, this.fetch("proxy", { + action: "eth_getCode", + address: params.address, + tag: params.blockTag + })]; + case 6: + return [2, this.fetch("proxy", { + action: "eth_getStorageAt", + address: params.address, + position: params.position, + tag: params.blockTag + })]; + case 7: + return [2, this.fetch("proxy", { + action: "eth_sendRawTransaction", + hex: params.signedTransaction + }, true).catch(function(error) { + return checkError("sendTransaction", error, params.signedTransaction); + })]; + case 8: + if (params.blockTag) { return [2, this.fetch("proxy", { - action: "eth_getTransactionReceipt", - txhash: params.transactionHash + action: "eth_getBlockByNumber", + tag: params.blockTag, + boolean: params.includeTransactions ? "true" : "false" })]; - case 11: - if (params.blockTag !== "latest") { - throw new Error("EtherscanProvider does not support blockTag for call"); - } - postData = getTransactionPostData(params.transaction); - postData.module = "proxy"; - postData.action = "eth_call"; - _c.label = 12; - case 12: - _c.trys.push([12, 14, , 15]); - return [4, this.fetch("proxy", postData, true)]; - case 13: - return [2, _c.sent()]; - case 14: - error_1 = _c.sent(); - return [2, checkError("call", error_1, params.transaction)]; - case 15: - postData = getTransactionPostData(params.transaction); - postData.module = "proxy"; - postData.action = "eth_estimateGas"; - _c.label = 16; - case 16: - _c.trys.push([16, 18, , 19]); - return [4, this.fetch("proxy", postData, true)]; - case 17: - return [2, _c.sent()]; - case 18: - error_2 = _c.sent(); - return [2, checkError("estimateGas", error_2, params.transaction)]; - case 19: - args = { action: "getLogs" }; - if (params.filter.fromBlock) { - args.fromBlock = checkLogTag(params.filter.fromBlock); - } - if (params.filter.toBlock) { - args.toBlock = checkLogTag(params.filter.toBlock); - } - if (params.filter.address) { - args.address = params.filter.address; + } + throw new Error("getBlock by blockHash not implemented"); + case 9: + return [2, this.fetch("proxy", { + action: "eth_getTransactionByHash", + txhash: params.transactionHash + })]; + case 10: + return [2, this.fetch("proxy", { + action: "eth_getTransactionReceipt", + txhash: params.transactionHash + })]; + case 11: + if (params.blockTag !== "latest") { + throw new Error("EtherscanProvider does not support blockTag for call"); + } + postData = getTransactionPostData(params.transaction); + postData.module = "proxy"; + postData.action = "eth_call"; + _c.label = 12; + case 12: + _c.trys.push([12, 14, , 15]); + return [4, this.fetch("proxy", postData, true)]; + case 13: + return [2, _c.sent()]; + case 14: + error_1 = _c.sent(); + return [2, checkError("call", error_1, params.transaction)]; + case 15: + postData = getTransactionPostData(params.transaction); + postData.module = "proxy"; + postData.action = "eth_estimateGas"; + _c.label = 16; + case 16: + _c.trys.push([16, 18, , 19]); + return [4, this.fetch("proxy", postData, true)]; + case 17: + return [2, _c.sent()]; + case 18: + error_2 = _c.sent(); + return [2, checkError("estimateGas", error_2, params.transaction)]; + case 19: + args = { action: "getLogs" }; + if (params.filter.fromBlock) { + args.fromBlock = checkLogTag(params.filter.fromBlock); + } + if (params.filter.toBlock) { + args.toBlock = checkLogTag(params.filter.toBlock); + } + if (params.filter.address) { + args.address = params.filter.address; + } + if (params.filter.topics && params.filter.topics.length > 0) { + if (params.filter.topics.length > 1) { + logger2.throwError("unsupported topic count", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topics: params.filter.topics }); } - if (params.filter.topics && params.filter.topics.length > 0) { - if (params.filter.topics.length > 1) { - logger2.throwError("unsupported topic count", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topics: params.filter.topics }); - } - if (params.filter.topics.length === 1) { - topic0 = params.filter.topics[0]; - if (typeof topic0 !== "string" || topic0.length !== 66) { - logger2.throwError("unsupported topic format", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topic0 }); - } - args.topic0 = topic0; + if (params.filter.topics.length === 1) { + topic0 = params.filter.topics[0]; + if (typeof topic0 !== "string" || topic0.length !== 66) { + logger2.throwError("unsupported topic format", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { topic0 }); } + args.topic0 = topic0; } - return [4, this.fetch("logs", args)]; - case 20: - logs = _c.sent(); - blocks = {}; - i = 0; - _c.label = 21; - case 21: - if (!(i < logs.length)) - return [3, 25]; - log = logs[i]; - if (log.blockHash != null) { - return [3, 24]; - } - if (!(blocks[log.blockNumber] == null)) - return [3, 23]; - return [4, this.getBlock(log.blockNumber)]; - case 22: - block = _c.sent(); - if (block) { - blocks[log.blockNumber] = block.hash; - } - _c.label = 23; - case 23: - log.blockHash = blocks[log.blockNumber]; - _c.label = 24; - case 24: - i++; - return [3, 21]; - case 25: - return [2, logs]; - case 26: - if (this.network.name !== "homestead") { - return [2, 0]; - } - _b = parseFloat; - return [4, this.fetch("stats", { action: "ethprice" })]; - case 27: - return [2, _b.apply(void 0, [_c.sent().ethusd])]; - case 28: - return [3, 29]; - case 29: - return [2, _super.prototype.perform.call(this, method, params)]; - } - }); + } + return [4, this.fetch("logs", args)]; + case 20: + logs = _c.sent(); + blocks = {}; + i = 0; + _c.label = 21; + case 21: + if (!(i < logs.length)) + return [3, 25]; + log = logs[i]; + if (log.blockHash != null) { + return [3, 24]; + } + if (!(blocks[log.blockNumber] == null)) + return [3, 23]; + return [4, this.getBlock(log.blockNumber)]; + case 22: + block = _c.sent(); + if (block) { + blocks[log.blockNumber] = block.hash; + } + _c.label = 23; + case 23: + log.blockHash = blocks[log.blockNumber]; + _c.label = 24; + case 24: + i++; + return [3, 21]; + case 25: + return [2, logs]; + case 26: + if (this.network.name !== "homestead") { + return [2, 0]; + } + _b = parseFloat; + return [4, this.fetch("stats", { action: "ethprice" })]; + case 27: + return [2, _b.apply(void 0, [_c.sent().ethusd])]; + case 28: + return [3, 29]; + case 29: + return [2, _super.prototype.perform.call(this, method, params)]; + } }); - }; - EtherscanProvider2.prototype.getHistory = function(addressOrName, startBlock, endBlock) { - return __awaiter2(this, void 0, void 0, function() { - var params, result; - var _a7; - var _this = this; - return __generator2(this, function(_b) { - switch (_b.label) { - case 0: - _a7 = { - action: "txlist" - }; - return [4, this.resolveName(addressOrName)]; - case 1: - params = (_a7.address = _b.sent(), _a7.startblock = startBlock == null ? 0 : startBlock, _a7.endblock = endBlock == null ? 99999999 : endBlock, _a7.sort = "asc", _a7); - return [4, this.fetch("account", params)]; - case 2: - result = _b.sent(); - return [2, result.map(function(tx) { - ["contractAddress", "to"].forEach(function(key) { - if (tx[key] == "") { - delete tx[key]; - } - }); - if (tx.creates == null && tx.contractAddress != null) { - tx.creates = tx.contractAddress; - } - var item = _this.formatter.transactionResponse(tx); - if (tx.timeStamp) { - item.timestamp = parseInt(tx.timeStamp); + }); + }; + EtherscanProvider2.prototype.getHistory = function(addressOrName, startBlock, endBlock) { + return __awaiter(this, void 0, void 0, function() { + var params, result; + var _a7; + var _this = this; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + _a7 = { + action: "txlist" + }; + return [4, this.resolveName(addressOrName)]; + case 1: + params = (_a7.address = _b.sent(), _a7.startblock = startBlock == null ? 0 : startBlock, _a7.endblock = endBlock == null ? 99999999 : endBlock, _a7.sort = "asc", _a7); + return [4, this.fetch("account", params)]; + case 2: + result = _b.sent(); + return [2, result.map(function(tx) { + ["contractAddress", "to"].forEach(function(key) { + if (tx[key] == "") { + delete tx[key]; } - return item; - })]; - } - }); + }); + if (tx.creates == null && tx.contractAddress != null) { + tx.creates = tx.contractAddress; + } + var item = _this.formatter.transactionResponse(tx); + if (tx.timeStamp) { + item.timestamp = parseInt(tx.timeStamp); + } + return item; + })]; + } }); - }; - EtherscanProvider2.prototype.isCommunityResource = function() { - return this.apiKey === defaultApiKey; - }; - return EtherscanProvider2; - }(base_provider_1.BaseProvider) - ); + }); + }; + EtherscanProvider2.prototype.isCommunityResource = function() { + return this.apiKey === defaultApiKey; + }; + return EtherscanProvider2; + }(base_provider_1.BaseProvider); exports2.EtherscanProvider = EtherscanProvider; } }); @@ -31619,28 +30712,28 @@ var require_etherscan_provider = __commonJS({ var require_fallback_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/fallback-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; }(); - var __awaiter2 = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { + var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); @@ -31667,7 +30760,7 @@ var require_fallback_provider = __commonJS({ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; - var __generator2 = exports2 && exports2.__generator || function(thisArg, body) { + var __generator = exports2 && exports2.__generator || function(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; @@ -31757,7 +30850,7 @@ var require_fallback_provider = __commonJS({ var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); function now() { - return (/* @__PURE__ */ new Date()).getTime(); + return new Date().getTime(); } function checkNetworks2(networks) { var result = null; @@ -31981,9 +31074,9 @@ var require_fallback_provider = __commonJS({ return normalizedTally(normalize, provider.quorum); } function waitForSync(config, blockNumber) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var provider; - return __generator2(this, function(_a7) { + return __generator(this, function(_a7) { provider = config.provider; if (provider.blockNumber != null && provider.blockNumber >= blockNumber || blockNumber === -1) { return [2, provider]; @@ -32005,9 +31098,9 @@ var require_fallback_provider = __commonJS({ }); } function getRunner(config, currentBlockNumber, method, params) { - return __awaiter2(this, void 0, void 0, function() { + return __awaiter(this, void 0, void 0, function() { var provider, _a7, filter; - return __generator2(this, function(_b) { + return __generator(this, function(_b) { switch (_b.label) { case 0: provider = config.provider; @@ -32105,303 +31198,295 @@ var require_fallback_provider = __commonJS({ }); }); } - var FallbackProvider = ( - /** @class */ - function(_super) { - __extends2(FallbackProvider2, _super); - function FallbackProvider2(providers2, quorum) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, FallbackProvider2); - if (providers2.length === 0) { - logger2.throwArgumentError("missing providers", "providers", providers2); + var FallbackProvider = function(_super) { + __extends(FallbackProvider2, _super); + function FallbackProvider2(providers2, quorum) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, FallbackProvider2); + if (providers2.length === 0) { + logger2.throwArgumentError("missing providers", "providers", providers2); + } + var providerConfigs = providers2.map(function(configOrProvider, index) { + if (abstract_provider_1.Provider.isProvider(configOrProvider)) { + var stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2e3 : 750; + var priority = 1; + return Object.freeze({ provider: configOrProvider, weight: 1, stallTimeout, priority }); } - var providerConfigs = providers2.map(function(configOrProvider, index) { - if (abstract_provider_1.Provider.isProvider(configOrProvider)) { - var stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2e3 : 750; - var priority = 1; - return Object.freeze({ provider: configOrProvider, weight: 1, stallTimeout, priority }); - } - var config = (0, properties_1.shallowCopy)(configOrProvider); - if (config.priority == null) { - config.priority = 1; - } - if (config.stallTimeout == null) { - config.stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2e3 : 750; - } - if (config.weight == null) { - config.weight = 1; - } - var weight = config.weight; - if (weight % 1 || weight > 512 || weight < 1) { - logger2.throwArgumentError("invalid weight; must be integer in [1, 512]", "providers[" + index + "].weight", weight); - } - return Object.freeze(config); - }); - var total = providerConfigs.reduce(function(accum, c) { - return accum + c.weight; - }, 0); - if (quorum == null) { - quorum = total / 2; - } else if (quorum > total) { - logger2.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + var config = (0, properties_1.shallowCopy)(configOrProvider); + if (config.priority == null) { + config.priority = 1; } - var networkOrReady = checkNetworks2(providerConfigs.map(function(c) { - return c.provider.network; - })); - if (networkOrReady == null) { - networkOrReady = new Promise(function(resolve, reject) { - setTimeout(function() { - _this.detectNetwork().then(resolve, reject); - }, 0); - }); + if (config.stallTimeout == null) { + config.stallTimeout = (0, formatter_1.isCommunityResource)(configOrProvider) ? 2e3 : 750; } - _this = _super.call(this, networkOrReady) || this; - (0, properties_1.defineReadOnly)(_this, "providerConfigs", Object.freeze(providerConfigs)); - (0, properties_1.defineReadOnly)(_this, "quorum", quorum); - _this._highestBlockNumber = -1; - return _this; + if (config.weight == null) { + config.weight = 1; + } + var weight = config.weight; + if (weight % 1 || weight > 512 || weight < 1) { + logger2.throwArgumentError("invalid weight; must be integer in [1, 512]", "providers[" + index + "].weight", weight); + } + return Object.freeze(config); + }); + var total = providerConfigs.reduce(function(accum, c) { + return accum + c.weight; + }, 0); + if (quorum == null) { + quorum = total / 2; + } else if (quorum > total) { + logger2.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); } - FallbackProvider2.prototype.detectNetwork = function() { - return __awaiter2(this, void 0, void 0, function() { - var networks; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - return [4, Promise.all(this.providerConfigs.map(function(c) { - return c.provider.getNetwork(); - }))]; - case 1: - networks = _a7.sent(); - return [2, checkNetworks2(networks)]; - } - }); + var networkOrReady = checkNetworks2(providerConfigs.map(function(c) { + return c.provider.network; + })); + if (networkOrReady == null) { + networkOrReady = new Promise(function(resolve, reject) { + setTimeout(function() { + _this.detectNetwork().then(resolve, reject); + }, 0); }); - }; - FallbackProvider2.prototype.perform = function(method, params) { - return __awaiter2(this, void 0, void 0, function() { - var results, i_1, result, processFunc, configs, currentBlockNumber, i, first, _loop_1, this_1, state_1; - var _this = this; - return __generator2(this, function(_a7) { - switch (_a7.label) { - case 0: - if (!(method === "sendTransaction")) - return [3, 2]; - return [4, Promise.all(this.providerConfigs.map(function(c) { - return c.provider.sendTransaction(params.signedTransaction).then(function(result2) { - return result2.hash; - }, function(error) { - return error; - }); - }))]; - case 1: - results = _a7.sent(); - for (i_1 = 0; i_1 < results.length; i_1++) { - result = results[i_1]; - if (typeof result === "string") { - return [2, result]; - } - } - throw results[0]; - case 2: - if (!(this._highestBlockNumber === -1 && method !== "getBlockNumber")) - return [3, 4]; - return [4, this.getBlockNumber()]; - case 3: - _a7.sent(); - _a7.label = 4; - case 4: - processFunc = getProcessFunc(this, method, params); - configs = (0, random_1.shuffled)(this.providerConfigs.map(properties_1.shallowCopy)); - configs.sort(function(a, b) { - return a.priority - b.priority; + } + _this = _super.call(this, networkOrReady) || this; + (0, properties_1.defineReadOnly)(_this, "providerConfigs", Object.freeze(providerConfigs)); + (0, properties_1.defineReadOnly)(_this, "quorum", quorum); + _this._highestBlockNumber = -1; + return _this; + } + FallbackProvider2.prototype.detectNetwork = function() { + return __awaiter(this, void 0, void 0, function() { + var networks; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + return [4, Promise.all(this.providerConfigs.map(function(c) { + return c.provider.getNetwork(); + }))]; + case 1: + networks = _a7.sent(); + return [2, checkNetworks2(networks)]; + } + }); + }); + }; + FallbackProvider2.prototype.perform = function(method, params) { + return __awaiter(this, void 0, void 0, function() { + var results, i_1, result, processFunc, configs, currentBlockNumber, i, first, _loop_1, this_1, state_1; + var _this = this; + return __generator(this, function(_a7) { + switch (_a7.label) { + case 0: + if (!(method === "sendTransaction")) + return [3, 2]; + return [4, Promise.all(this.providerConfigs.map(function(c) { + return c.provider.sendTransaction(params.signedTransaction).then(function(result2) { + return result2.hash; + }, function(error) { + return error; }); - currentBlockNumber = this._highestBlockNumber; - i = 0; - first = true; - _loop_1 = function() { - var t0, inflightWeight, _loop_2, waiting, results2, result2, errors; - return __generator2(this, function(_b) { - switch (_b.label) { - case 0: - t0 = now(); - inflightWeight = configs.filter(function(c) { - return c.runner && t0 - c.start < c.stallTimeout; - }).reduce(function(accum, c) { - return accum + c.weight; - }, 0); - _loop_2 = function() { - var config = configs[i++]; - var rid = nextRid++; - config.start = now(); - config.staller = stall(config.stallTimeout); - config.staller.wait(function() { - config.staller = null; - }); - config.runner = getRunner(config, currentBlockNumber, method, params).then(function(result3) { - config.done = true; - config.result = result3; - if (_this.listenerCount("debug")) { - _this.emit("debug", { - action: "request", - rid, - backend: exposeDebugConfig(config, now()), - request: { method, params: (0, properties_1.deepCopy)(params) }, - provider: _this - }); - } - }, function(error) { - config.done = true; - config.error = error; - if (_this.listenerCount("debug")) { - _this.emit("debug", { - action: "request", - rid, - backend: exposeDebugConfig(config, now()), - request: { method, params: (0, properties_1.deepCopy)(params) }, - provider: _this - }); - } - }); - if (this_1.listenerCount("debug")) { - this_1.emit("debug", { + }))]; + case 1: + results = _a7.sent(); + for (i_1 = 0; i_1 < results.length; i_1++) { + result = results[i_1]; + if (typeof result === "string") { + return [2, result]; + } + } + throw results[0]; + case 2: + if (!(this._highestBlockNumber === -1 && method !== "getBlockNumber")) + return [3, 4]; + return [4, this.getBlockNumber()]; + case 3: + _a7.sent(); + _a7.label = 4; + case 4: + processFunc = getProcessFunc(this, method, params); + configs = (0, random_1.shuffled)(this.providerConfigs.map(properties_1.shallowCopy)); + configs.sort(function(a, b) { + return a.priority - b.priority; + }); + currentBlockNumber = this._highestBlockNumber; + i = 0; + first = true; + _loop_1 = function() { + var t0, inflightWeight, _loop_2, waiting, results2, result2, errors; + return __generator(this, function(_b) { + switch (_b.label) { + case 0: + t0 = now(); + inflightWeight = configs.filter(function(c) { + return c.runner && t0 - c.start < c.stallTimeout; + }).reduce(function(accum, c) { + return accum + c.weight; + }, 0); + _loop_2 = function() { + var config = configs[i++]; + var rid = nextRid++; + config.start = now(); + config.staller = stall(config.stallTimeout); + config.staller.wait(function() { + config.staller = null; + }); + config.runner = getRunner(config, currentBlockNumber, method, params).then(function(result3) { + config.done = true; + config.result = result3; + if (_this.listenerCount("debug")) { + _this.emit("debug", { + action: "request", + rid, + backend: exposeDebugConfig(config, now()), + request: { method, params: (0, properties_1.deepCopy)(params) }, + provider: _this + }); + } + }, function(error) { + config.done = true; + config.error = error; + if (_this.listenerCount("debug")) { + _this.emit("debug", { action: "request", rid, - backend: exposeDebugConfig(config, null), + backend: exposeDebugConfig(config, now()), request: { method, params: (0, properties_1.deepCopy)(params) }, - provider: this_1 + provider: _this }); } - inflightWeight += config.weight; - }; - while (inflightWeight < this_1.quorum && i < configs.length) { - _loop_2(); + }); + if (this_1.listenerCount("debug")) { + this_1.emit("debug", { + action: "request", + rid, + backend: exposeDebugConfig(config, null), + request: { method, params: (0, properties_1.deepCopy)(params) }, + provider: this_1 + }); + } + inflightWeight += config.weight; + }; + while (inflightWeight < this_1.quorum && i < configs.length) { + _loop_2(); + } + waiting = []; + configs.forEach(function(c) { + if (c.done || !c.runner) { + return; + } + waiting.push(c.runner); + if (c.staller) { + waiting.push(c.staller.getPromise()); } - waiting = []; + }); + if (!waiting.length) + return [3, 2]; + return [4, Promise.race(waiting)]; + case 1: + _b.sent(); + _b.label = 2; + case 2: + results2 = configs.filter(function(c) { + return c.done && c.error == null; + }); + if (!(results2.length >= this_1.quorum)) + return [3, 5]; + result2 = processFunc(results2); + if (result2 !== void 0) { configs.forEach(function(c) { - if (c.done || !c.runner) { - return; - } - waiting.push(c.runner); if (c.staller) { - waiting.push(c.staller.getPromise()); + c.staller.cancel(); } + c.cancelled = true; }); - if (!waiting.length) - return [3, 2]; - return [4, Promise.race(waiting)]; - case 1: - _b.sent(); - _b.label = 2; - case 2: - results2 = configs.filter(function(c) { - return c.done && c.error == null; - }); - if (!(results2.length >= this_1.quorum)) - return [3, 5]; - result2 = processFunc(results2); - if (result2 !== void 0) { - configs.forEach(function(c) { - if (c.staller) { - c.staller.cancel(); - } - c.cancelled = true; - }); - return [2, { value: result2 }]; + return [2, { value: result2 }]; + } + if (!!first) + return [3, 4]; + return [4, stall(100).getPromise()]; + case 3: + _b.sent(); + _b.label = 4; + case 4: + first = false; + _b.label = 5; + case 5: + errors = configs.reduce(function(accum, c) { + if (!c.done || c.error == null) { + return accum; } - if (!!first) - return [3, 4]; - return [4, stall(100).getPromise()]; - case 3: - _b.sent(); - _b.label = 4; - case 4: - first = false; - _b.label = 5; - case 5: - errors = configs.reduce(function(accum, c) { - if (!c.done || c.error == null) { - return accum; + var code = c.error.code; + if (ForwardErrors.indexOf(code) >= 0) { + if (!accum[code]) { + accum[code] = { error: c.error, weight: 0 }; } - var code = c.error.code; - if (ForwardErrors.indexOf(code) >= 0) { - if (!accum[code]) { - accum[code] = { error: c.error, weight: 0 }; - } - accum[code].weight += c.weight; + accum[code].weight += c.weight; + } + return accum; + }, {}); + Object.keys(errors).forEach(function(errorCode) { + var tally = errors[errorCode]; + if (tally.weight < _this.quorum) { + return; + } + configs.forEach(function(c) { + if (c.staller) { + c.staller.cancel(); } - return accum; - }, {}); - Object.keys(errors).forEach(function(errorCode) { - var tally = errors[errorCode]; - if (tally.weight < _this.quorum) { + c.cancelled = true; + }); + var e = tally.error; + var props = {}; + ForwardProperties.forEach(function(name2) { + if (e[name2] == null) { return; } - configs.forEach(function(c) { - if (c.staller) { - c.staller.cancel(); - } - c.cancelled = true; - }); - var e = tally.error; - var props = {}; - ForwardProperties.forEach(function(name2) { - if (e[name2] == null) { - return; - } - props[name2] = e[name2]; - }); - logger2.throwError(e.reason || e.message, errorCode, props); + props[name2] = e[name2]; }); - if (configs.filter(function(c) { - return !c.done; - }).length === 0) { - return [2, "break"]; - } - return [ - 2 - /*return*/ - ]; - } - }); - }; - this_1 = this; - _a7.label = 5; - case 5: - if (false) - return [3, 7]; - return [5, _loop_1()]; - case 6: - state_1 = _a7.sent(); - if (typeof state_1 === "object") - return [2, state_1.value]; - if (state_1 === "break") - return [3, 7]; - return [3, 5]; - case 7: - configs.forEach(function(c) { - if (c.staller) { - c.staller.cancel(); + logger2.throwError(e.reason || e.message, errorCode, props); + }); + if (configs.filter(function(c) { + return !c.done; + }).length === 0) { + return [2, "break"]; + } + return [2]; } - c.cancelled = true; }); - return [2, logger2.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, { - method, - params, - //results: configs.map((c) => c.result), - //errors: configs.map((c) => c.error), - results: configs.map(function(c) { - return exposeDebugConfig(c); - }), - provider: this - })]; - } - }); + }; + this_1 = this; + _a7.label = 5; + case 5: + if (false) + return [3, 7]; + return [5, _loop_1()]; + case 6: + state_1 = _a7.sent(); + if (typeof state_1 === "object") + return [2, state_1.value]; + if (state_1 === "break") + return [3, 7]; + return [3, 5]; + case 7: + configs.forEach(function(c) { + if (c.staller) { + c.staller.cancel(); + } + c.cancelled = true; + }); + return [2, logger2.throwError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, { + method, + params, + results: configs.map(function(c) { + return exposeDebugConfig(c); + }), + provider: this + })]; + } }); - }; - return FallbackProvider2; - }(base_provider_1.BaseProvider) - ); + }); + }; + return FallbackProvider2; + }(base_provider_1.BaseProvider); exports2.FallbackProvider = FallbackProvider; } }); @@ -32410,21 +31495,21 @@ var require_fallback_provider = __commonJS({ var require_ipc_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/ipc-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -32439,55 +31524,52 @@ var require_ipc_provider = __commonJS({ var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); var json_rpc_provider_1 = require_json_rpc_provider(); - var IpcProvider = ( - /** @class */ - function(_super) { - __extends2(IpcProvider2, _super); - function IpcProvider2(path2, network) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, IpcProvider2); - if (path2 == null) { - logger2.throwError("missing path", logger_1.Logger.errors.MISSING_ARGUMENT, { arg: "path" }); - } - _this = _super.call(this, "ipc://" + path2, network) || this; - (0, properties_1.defineReadOnly)(_this, "path", path2); - return _this; + var IpcProvider = function(_super) { + __extends(IpcProvider2, _super); + function IpcProvider2(path2, network) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, IpcProvider2); + if (path2 == null) { + logger2.throwError("missing path", logger_1.Logger.errors.MISSING_ARGUMENT, { arg: "path" }); } - IpcProvider2.prototype.send = function(method, params) { - var _this = this; - var payload = JSON.stringify({ - method, - params, - id: 42, - jsonrpc: "2.0" + _this = _super.call(this, "ipc://" + path2, network) || this; + (0, properties_1.defineReadOnly)(_this, "path", path2); + return _this; + } + IpcProvider2.prototype.send = function(method, params) { + var _this = this; + var payload = JSON.stringify({ + method, + params, + id: 42, + jsonrpc: "2.0" + }); + return new Promise(function(resolve, reject) { + var response = Buffer.alloc(0); + var stream = (0, net_1.connect)(_this.path); + stream.on("data", function(data) { + response = Buffer.concat([response, data]); }); - return new Promise(function(resolve, reject) { - var response = Buffer.alloc(0); - var stream = (0, net_1.connect)(_this.path); - stream.on("data", function(data) { - response = Buffer.concat([response, data]); - }); - stream.on("end", function() { - try { - resolve(JSON.parse(response.toString()).result); - stream.destroy(); - } catch (error) { - reject(error); - stream.destroy(); - } - }); - stream.on("error", function(error) { + stream.on("end", function() { + try { + resolve(JSON.parse(response.toString()).result); + stream.destroy(); + } catch (error) { reject(error); stream.destroy(); - }); - stream.write(payload); - stream.end(); + } }); - }; - return IpcProvider2; - }(json_rpc_provider_1.JsonRpcProvider) - ); + stream.on("error", function(error) { + reject(error); + stream.destroy(); + }); + stream.write(payload); + stream.end(); + }); + }; + return IpcProvider2; + }(json_rpc_provider_1.JsonRpcProvider); exports2.IpcProvider = IpcProvider; } }); @@ -32496,21 +31578,21 @@ var require_ipc_provider = __commonJS({ var require_infura_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/infura-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -32527,129 +31609,123 @@ var require_infura_provider = __commonJS({ var logger2 = new logger_1.Logger(_version_1.version); var url_json_rpc_provider_1 = require_url_json_rpc_provider(); var defaultProjectId = "84842078b09946638c03157f83405213"; - var InfuraWebSocketProvider = ( - /** @class */ - function(_super) { - __extends2(InfuraWebSocketProvider2, _super); - function InfuraWebSocketProvider2(network, apiKey) { - var _this = this; - var provider = new InfuraProvider(network, apiKey); - var connection = provider.connection; - if (connection.password) { - logger2.throwError("INFURA WebSocket project secrets unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "InfuraProvider.getWebSocketProvider()" - }); - } - var url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/"); - _this = _super.call(this, url, network) || this; - (0, properties_1.defineReadOnly)(_this, "apiKey", provider.projectId); - (0, properties_1.defineReadOnly)(_this, "projectId", provider.projectId); - (0, properties_1.defineReadOnly)(_this, "projectSecret", provider.projectSecret); - return _this; + var InfuraWebSocketProvider = function(_super) { + __extends(InfuraWebSocketProvider2, _super); + function InfuraWebSocketProvider2(network, apiKey) { + var _this = this; + var provider = new InfuraProvider(network, apiKey); + var connection = provider.connection; + if (connection.password) { + logger2.throwError("INFURA WebSocket project secrets unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "InfuraProvider.getWebSocketProvider()" + }); } - InfuraWebSocketProvider2.prototype.isCommunityResource = function() { - return this.projectId === defaultProjectId; - }; - return InfuraWebSocketProvider2; - }(websocket_provider_1.WebSocketProvider) - ); + var url = connection.url.replace(/^http/i, "ws").replace("/v3/", "/ws/v3/"); + _this = _super.call(this, url, network) || this; + (0, properties_1.defineReadOnly)(_this, "apiKey", provider.projectId); + (0, properties_1.defineReadOnly)(_this, "projectId", provider.projectId); + (0, properties_1.defineReadOnly)(_this, "projectSecret", provider.projectSecret); + return _this; + } + InfuraWebSocketProvider2.prototype.isCommunityResource = function() { + return this.projectId === defaultProjectId; + }; + return InfuraWebSocketProvider2; + }(websocket_provider_1.WebSocketProvider); exports2.InfuraWebSocketProvider = InfuraWebSocketProvider; - var InfuraProvider = ( - /** @class */ - function(_super) { - __extends2(InfuraProvider2, _super); - function InfuraProvider2() { - return _super !== null && _super.apply(this, arguments) || this; - } - InfuraProvider2.getWebSocketProvider = function(network, apiKey) { - return new InfuraWebSocketProvider(network, apiKey); + var InfuraProvider = function(_super) { + __extends(InfuraProvider2, _super); + function InfuraProvider2() { + return _super !== null && _super.apply(this, arguments) || this; + } + InfuraProvider2.getWebSocketProvider = function(network, apiKey) { + return new InfuraWebSocketProvider(network, apiKey); + }; + InfuraProvider2.getApiKey = function(apiKey) { + var apiKeyObj = { + apiKey: defaultProjectId, + projectId: defaultProjectId, + projectSecret: null }; - InfuraProvider2.getApiKey = function(apiKey) { - var apiKeyObj = { - apiKey: defaultProjectId, - projectId: defaultProjectId, - projectSecret: null - }; - if (apiKey == null) { - return apiKeyObj; - } - if (typeof apiKey === "string") { - apiKeyObj.projectId = apiKey; - } else if (apiKey.projectSecret != null) { - logger2.assertArgument(typeof apiKey.projectId === "string", "projectSecret requires a projectId", "projectId", apiKey.projectId); - logger2.assertArgument(typeof apiKey.projectSecret === "string", "invalid projectSecret", "projectSecret", "[REDACTED]"); - apiKeyObj.projectId = apiKey.projectId; - apiKeyObj.projectSecret = apiKey.projectSecret; - } else if (apiKey.projectId) { - apiKeyObj.projectId = apiKey.projectId; - } - apiKeyObj.apiKey = apiKeyObj.projectId; + if (apiKey == null) { return apiKeyObj; - }; - InfuraProvider2.getUrl = function(network, apiKey) { - var host = null; - switch (network ? network.name : "unknown") { - case "homestead": - host = "mainnet.infura.io"; - break; - case "ropsten": - host = "ropsten.infura.io"; - break; - case "rinkeby": - host = "rinkeby.infura.io"; - break; - case "kovan": - host = "kovan.infura.io"; - break; - case "goerli": - host = "goerli.infura.io"; - break; - case "matic": - host = "polygon-mainnet.infura.io"; - break; - case "maticmum": - host = "polygon-mumbai.infura.io"; - break; - case "optimism": - host = "optimism-mainnet.infura.io"; - break; - case "optimism-kovan": - host = "optimism-kovan.infura.io"; - break; - case "arbitrum": - host = "arbitrum-mainnet.infura.io"; - break; - case "arbitrum-rinkeby": - host = "arbitrum-rinkeby.infura.io"; - break; - default: - logger2.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { - argument: "network", - value: network - }); - } - var connection = { - allowGzip: true, - url: "https://" + host + "/v3/" + apiKey.projectId, - throttleCallback: function(attempt, url) { - if (apiKey.projectId === defaultProjectId) { - (0, formatter_1.showThrottleMessage)(); - } - return Promise.resolve(true); + } + if (typeof apiKey === "string") { + apiKeyObj.projectId = apiKey; + } else if (apiKey.projectSecret != null) { + logger2.assertArgument(typeof apiKey.projectId === "string", "projectSecret requires a projectId", "projectId", apiKey.projectId); + logger2.assertArgument(typeof apiKey.projectSecret === "string", "invalid projectSecret", "projectSecret", "[REDACTED]"); + apiKeyObj.projectId = apiKey.projectId; + apiKeyObj.projectSecret = apiKey.projectSecret; + } else if (apiKey.projectId) { + apiKeyObj.projectId = apiKey.projectId; + } + apiKeyObj.apiKey = apiKeyObj.projectId; + return apiKeyObj; + }; + InfuraProvider2.getUrl = function(network, apiKey) { + var host = null; + switch (network ? network.name : "unknown") { + case "homestead": + host = "mainnet.infura.io"; + break; + case "ropsten": + host = "ropsten.infura.io"; + break; + case "rinkeby": + host = "rinkeby.infura.io"; + break; + case "kovan": + host = "kovan.infura.io"; + break; + case "goerli": + host = "goerli.infura.io"; + break; + case "matic": + host = "polygon-mainnet.infura.io"; + break; + case "maticmum": + host = "polygon-mumbai.infura.io"; + break; + case "optimism": + host = "optimism-mainnet.infura.io"; + break; + case "optimism-kovan": + host = "optimism-kovan.infura.io"; + break; + case "arbitrum": + host = "arbitrum-mainnet.infura.io"; + break; + case "arbitrum-rinkeby": + host = "arbitrum-rinkeby.infura.io"; + break; + default: + logger2.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + var connection = { + allowGzip: true, + url: "https://" + host + "/v3/" + apiKey.projectId, + throttleCallback: function(attempt, url) { + if (apiKey.projectId === defaultProjectId) { + (0, formatter_1.showThrottleMessage)(); } - }; - if (apiKey.projectSecret != null) { - connection.user = ""; - connection.password = apiKey.projectSecret; + return Promise.resolve(true); } - return connection; }; - InfuraProvider2.prototype.isCommunityResource = function() { - return this.projectId === defaultProjectId; - }; - return InfuraProvider2; - }(url_json_rpc_provider_1.UrlJsonRpcProvider) - ); + if (apiKey.projectSecret != null) { + connection.user = ""; + connection.password = apiKey.projectSecret; + } + return connection; + }; + InfuraProvider2.prototype.isCommunityResource = function() { + return this.projectId === defaultProjectId; + }; + return InfuraProvider2; + }(url_json_rpc_provider_1.UrlJsonRpcProvider); exports2.InfuraProvider = InfuraProvider; } }); @@ -32658,21 +31734,21 @@ var require_infura_provider = __commonJS({ var require_json_rpc_batch_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/json-rpc-batch-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -32684,79 +31760,76 @@ var require_json_rpc_batch_provider = __commonJS({ var properties_1 = require_lib4(); var web_1 = require_lib27(); var json_rpc_provider_1 = require_json_rpc_provider(); - var JsonRpcBatchProvider = ( - /** @class */ - function(_super) { - __extends2(JsonRpcBatchProvider2, _super); - function JsonRpcBatchProvider2() { - return _super !== null && _super.apply(this, arguments) || this; - } - JsonRpcBatchProvider2.prototype.send = function(method, params) { - var _this = this; - var request = { - method, - params, - id: this._nextId++, - jsonrpc: "2.0" - }; - if (this._pendingBatch == null) { - this._pendingBatch = []; - } - var inflightRequest = { request, resolve: null, reject: null }; - var promise = new Promise(function(resolve, reject) { - inflightRequest.resolve = resolve; - inflightRequest.reject = reject; - }); - this._pendingBatch.push(inflightRequest); - if (!this._pendingBatchAggregator) { - this._pendingBatchAggregator = setTimeout(function() { - var batch = _this._pendingBatch; - _this._pendingBatch = null; - _this._pendingBatchAggregator = null; - var request2 = batch.map(function(inflight) { - return inflight.request; - }); + var JsonRpcBatchProvider = function(_super) { + __extends(JsonRpcBatchProvider2, _super); + function JsonRpcBatchProvider2() { + return _super !== null && _super.apply(this, arguments) || this; + } + JsonRpcBatchProvider2.prototype.send = function(method, params) { + var _this = this; + var request = { + method, + params, + id: this._nextId++, + jsonrpc: "2.0" + }; + if (this._pendingBatch == null) { + this._pendingBatch = []; + } + var inflightRequest = { request, resolve: null, reject: null }; + var promise = new Promise(function(resolve, reject) { + inflightRequest.resolve = resolve; + inflightRequest.reject = reject; + }); + this._pendingBatch.push(inflightRequest); + if (!this._pendingBatchAggregator) { + this._pendingBatchAggregator = setTimeout(function() { + var batch = _this._pendingBatch; + _this._pendingBatch = null; + _this._pendingBatchAggregator = null; + var request2 = batch.map(function(inflight) { + return inflight.request; + }); + _this.emit("debug", { + action: "requestBatch", + request: (0, properties_1.deepCopy)(request2), + provider: _this + }); + return (0, web_1.fetchJson)(_this.connection, JSON.stringify(request2)).then(function(result) { _this.emit("debug", { - action: "requestBatch", - request: (0, properties_1.deepCopy)(request2), + action: "response", + request: request2, + response: result, provider: _this }); - return (0, web_1.fetchJson)(_this.connection, JSON.stringify(request2)).then(function(result) { - _this.emit("debug", { - action: "response", - request: request2, - response: result, - provider: _this - }); - batch.forEach(function(inflightRequest2, index) { - var payload = result[index]; - if (payload.error) { - var error = new Error(payload.error.message); - error.code = payload.error.code; - error.data = payload.error.data; - inflightRequest2.reject(error); - } else { - inflightRequest2.resolve(payload.result); - } - }); - }, function(error) { - _this.emit("debug", { - action: "response", - error, - request: request2, - provider: _this - }); - batch.forEach(function(inflightRequest2) { + batch.forEach(function(inflightRequest2, index) { + var payload = result[index]; + if (payload.error) { + var error = new Error(payload.error.message); + error.code = payload.error.code; + error.data = payload.error.data; inflightRequest2.reject(error); - }); + } else { + inflightRequest2.resolve(payload.result); + } }); - }, 10); - } - return promise; - }; - return JsonRpcBatchProvider2; - }(json_rpc_provider_1.JsonRpcProvider) - ); + }, function(error) { + _this.emit("debug", { + action: "response", + error, + request: request2, + provider: _this + }); + batch.forEach(function(inflightRequest2) { + inflightRequest2.reject(error); + }); + }); + }, 10); + } + return promise; + }; + return JsonRpcBatchProvider2; + }(json_rpc_provider_1.JsonRpcProvider); exports2.JsonRpcBatchProvider = JsonRpcBatchProvider; } }); @@ -32765,21 +31838,21 @@ var require_json_rpc_batch_provider = __commonJS({ var require_nodesmith_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/nodesmith-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -32793,46 +31866,43 @@ var require_nodesmith_provider = __commonJS({ var _version_1 = require_version24(); var logger2 = new logger_1.Logger(_version_1.version); var defaultApiKey = "ETHERS_JS_SHARED"; - var NodesmithProvider = ( - /** @class */ - function(_super) { - __extends2(NodesmithProvider2, _super); - function NodesmithProvider2() { - return _super !== null && _super.apply(this, arguments) || this; - } - NodesmithProvider2.getApiKey = function(apiKey) { - if (apiKey && typeof apiKey !== "string") { - logger2.throwArgumentError("invalid apiKey", "apiKey", apiKey); - } - return apiKey || defaultApiKey; - }; - NodesmithProvider2.getUrl = function(network, apiKey) { - logger2.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform."); - var host = null; - switch (network.name) { - case "homestead": - host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; - break; - case "ropsten": - host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; - break; - case "rinkeby": - host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; - break; - case "goerli": - host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; - break; - case "kovan": - host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; - break; - default: - logger2.throwArgumentError("unsupported network", "network", arguments[0]); - } - return host + "?apiKey=" + apiKey; - }; - return NodesmithProvider2; - }(url_json_rpc_provider_1.UrlJsonRpcProvider) - ); + var NodesmithProvider = function(_super) { + __extends(NodesmithProvider2, _super); + function NodesmithProvider2() { + return _super !== null && _super.apply(this, arguments) || this; + } + NodesmithProvider2.getApiKey = function(apiKey) { + if (apiKey && typeof apiKey !== "string") { + logger2.throwArgumentError("invalid apiKey", "apiKey", apiKey); + } + return apiKey || defaultApiKey; + }; + NodesmithProvider2.getUrl = function(network, apiKey) { + logger2.warn("NodeSmith will be discontinued on 2019-12-20; please migrate to another platform."); + var host = null; + switch (network.name) { + case "homestead": + host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; + break; + case "ropsten": + host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; + break; + case "rinkeby": + host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; + break; + case "goerli": + host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; + break; + case "kovan": + host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; + break; + default: + logger2.throwArgumentError("unsupported network", "network", arguments[0]); + } + return host + "?apiKey=" + apiKey; + }; + return NodesmithProvider2; + }(url_json_rpc_provider_1.UrlJsonRpcProvider); exports2.NodesmithProvider = NodesmithProvider; } }); @@ -32841,21 +31911,21 @@ var require_nodesmith_provider = __commonJS({ var require_pocket_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/pocket-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -32875,101 +31945,98 @@ var require_pocket_provider = __commonJS({ rinkeby: "6004bda20040261633ade994", goerli: "6004bd860040261633ade992" }; - var PocketProvider = ( - /** @class */ - function(_super) { - __extends2(PocketProvider2, _super); - function PocketProvider2(network, apiKey) { - var _newTarget = this.constructor; - var _this = this; - if (apiKey == null) { - var n = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network); - if (n) { - var applicationId = defaultApplicationIds[n.name]; - if (applicationId) { - apiKey = { - applicationId, - loadBalancer: true - }; - } - } - if (apiKey == null) { - logger2.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { - argument: "network", - value: network - }); + var PocketProvider = function(_super) { + __extends(PocketProvider2, _super); + function PocketProvider2(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + if (apiKey == null) { + var n = (0, properties_1.getStatic)(_newTarget, "getNetwork")(network); + if (n) { + var applicationId = defaultApplicationIds[n.name]; + if (applicationId) { + apiKey = { + applicationId, + loadBalancer: true + }; } } - _this = _super.call(this, network, apiKey) || this; - return _this; - } - PocketProvider2.getApiKey = function(apiKey) { if (apiKey == null) { - logger2.throwArgumentError("PocketProvider.getApiKey does not support null apiKey", "apiKey", apiKey); - } - var apiKeyObj = { - applicationId: null, - loadBalancer: false, - applicationSecretKey: null - }; - if (typeof apiKey === "string") { - apiKeyObj.applicationId = apiKey; - } else if (apiKey.applicationSecretKey != null) { - logger2.assertArgument(typeof apiKey.applicationId === "string", "applicationSecretKey requires an applicationId", "applicationId", apiKey.applicationId); - logger2.assertArgument(typeof apiKey.applicationSecretKey === "string", "invalid applicationSecretKey", "applicationSecretKey", "[REDACTED]"); - apiKeyObj.applicationId = apiKey.applicationId; - apiKeyObj.applicationSecretKey = apiKey.applicationSecretKey; - apiKeyObj.loadBalancer = !!apiKey.loadBalancer; - } else if (apiKey.applicationId) { - logger2.assertArgument(typeof apiKey.applicationId === "string", "apiKey.applicationId must be a string", "apiKey.applicationId", apiKey.applicationId); - apiKeyObj.applicationId = apiKey.applicationId; - apiKeyObj.loadBalancer = !!apiKey.loadBalancer; - } else { - logger2.throwArgumentError("unsupported PocketProvider apiKey", "apiKey", apiKey); - } - return apiKeyObj; - }; - PocketProvider2.getUrl = function(network, apiKey) { - var host = null; - switch (network ? network.name : "unknown") { - case "homestead": - host = "eth-mainnet.gateway.pokt.network"; - break; - case "ropsten": - host = "eth-ropsten.gateway.pokt.network"; - break; - case "rinkeby": - host = "eth-rinkeby.gateway.pokt.network"; - break; - case "goerli": - host = "eth-goerli.gateway.pokt.network"; - break; - default: - logger2.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { - argument: "network", - value: network - }); - } - var url = null; - if (apiKey.loadBalancer) { - url = "https://" + host + "/v1/lb/" + apiKey.applicationId; - } else { - url = "https://" + host + "/v1/" + apiKey.applicationId; - } - var connection = { url }; - connection.headers = {}; - if (apiKey.applicationSecretKey != null) { - connection.user = ""; - connection.password = apiKey.applicationSecretKey; + logger2.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); } - return connection; - }; - PocketProvider2.prototype.isCommunityResource = function() { - return this.applicationId === defaultApplicationIds[this.network.name]; - }; - return PocketProvider2; - }(url_json_rpc_provider_1.UrlJsonRpcProvider) - ); + } + _this = _super.call(this, network, apiKey) || this; + return _this; + } + PocketProvider2.getApiKey = function(apiKey) { + if (apiKey == null) { + logger2.throwArgumentError("PocketProvider.getApiKey does not support null apiKey", "apiKey", apiKey); + } + var apiKeyObj = { + applicationId: null, + loadBalancer: false, + applicationSecretKey: null + }; + if (typeof apiKey === "string") { + apiKeyObj.applicationId = apiKey; + } else if (apiKey.applicationSecretKey != null) { + logger2.assertArgument(typeof apiKey.applicationId === "string", "applicationSecretKey requires an applicationId", "applicationId", apiKey.applicationId); + logger2.assertArgument(typeof apiKey.applicationSecretKey === "string", "invalid applicationSecretKey", "applicationSecretKey", "[REDACTED]"); + apiKeyObj.applicationId = apiKey.applicationId; + apiKeyObj.applicationSecretKey = apiKey.applicationSecretKey; + apiKeyObj.loadBalancer = !!apiKey.loadBalancer; + } else if (apiKey.applicationId) { + logger2.assertArgument(typeof apiKey.applicationId === "string", "apiKey.applicationId must be a string", "apiKey.applicationId", apiKey.applicationId); + apiKeyObj.applicationId = apiKey.applicationId; + apiKeyObj.loadBalancer = !!apiKey.loadBalancer; + } else { + logger2.throwArgumentError("unsupported PocketProvider apiKey", "apiKey", apiKey); + } + return apiKeyObj; + }; + PocketProvider2.getUrl = function(network, apiKey) { + var host = null; + switch (network ? network.name : "unknown") { + case "homestead": + host = "eth-mainnet.gateway.pokt.network"; + break; + case "ropsten": + host = "eth-ropsten.gateway.pokt.network"; + break; + case "rinkeby": + host = "eth-rinkeby.gateway.pokt.network"; + break; + case "goerli": + host = "eth-goerli.gateway.pokt.network"; + break; + default: + logger2.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + var url = null; + if (apiKey.loadBalancer) { + url = "https://" + host + "/v1/lb/" + apiKey.applicationId; + } else { + url = "https://" + host + "/v1/" + apiKey.applicationId; + } + var connection = { url }; + connection.headers = {}; + if (apiKey.applicationSecretKey != null) { + connection.user = ""; + connection.password = apiKey.applicationSecretKey; + } + return connection; + }; + PocketProvider2.prototype.isCommunityResource = function() { + return this.applicationId === defaultApplicationIds[this.network.name]; + }; + return PocketProvider2; + }(url_json_rpc_provider_1.UrlJsonRpcProvider); exports2.PocketProvider = PocketProvider; } }); @@ -32978,21 +32045,21 @@ var require_pocket_provider = __commonJS({ var require_web3_provider = __commonJS({ "node_modules/@ethersproject/providers/lib/web3-provider.js"(exports2) { "use strict"; - var __extends2 = exports2 && exports2.__extends || function() { - var extendStatics2 = function(d, b) { - extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { + var __extends = exports2 && exports2.__extends || function() { + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { d2.__proto__ = b2; } || function(d2, b2) { for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p]; }; - return extendStatics2(d, b); + return extendStatics(d, b); }; return function(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics2(d, b); + extendStatics(d, b); function __() { this.constructor = d; } @@ -33087,56 +32154,53 @@ var require_web3_provider = __commonJS({ }); }; } - var Web3Provider = ( - /** @class */ - function(_super) { - __extends2(Web3Provider2, _super); - function Web3Provider2(provider, network) { - var _newTarget = this.constructor; - var _this = this; - logger2.checkNew(_newTarget, Web3Provider2); - if (provider == null) { - logger2.throwArgumentError("missing provider", "provider", provider); - } - var path2 = null; - var jsonRpcFetchFunc = null; - var subprovider = null; - if (typeof provider === "function") { - path2 = "unknown:"; - jsonRpcFetchFunc = provider; + var Web3Provider = function(_super) { + __extends(Web3Provider2, _super); + function Web3Provider2(provider, network) { + var _newTarget = this.constructor; + var _this = this; + logger2.checkNew(_newTarget, Web3Provider2); + if (provider == null) { + logger2.throwArgumentError("missing provider", "provider", provider); + } + var path2 = null; + var jsonRpcFetchFunc = null; + var subprovider = null; + if (typeof provider === "function") { + path2 = "unknown:"; + jsonRpcFetchFunc = provider; + } else { + path2 = provider.host || provider.path || ""; + if (!path2 && provider.isMetaMask) { + path2 = "metamask"; + } + subprovider = provider; + if (provider.request) { + if (path2 === "") { + path2 = "eip-1193:"; + } + jsonRpcFetchFunc = buildEip1193Fetcher(provider); + } else if (provider.sendAsync) { + jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider)); + } else if (provider.send) { + jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider)); } else { - path2 = provider.host || provider.path || ""; - if (!path2 && provider.isMetaMask) { - path2 = "metamask"; - } - subprovider = provider; - if (provider.request) { - if (path2 === "") { - path2 = "eip-1193:"; - } - jsonRpcFetchFunc = buildEip1193Fetcher(provider); - } else if (provider.sendAsync) { - jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.sendAsync.bind(provider)); - } else if (provider.send) { - jsonRpcFetchFunc = buildWeb3LegacyFetcher(provider, provider.send.bind(provider)); - } else { - logger2.throwArgumentError("unsupported provider", "provider", provider); - } - if (!path2) { - path2 = "unknown:"; - } + logger2.throwArgumentError("unsupported provider", "provider", provider); + } + if (!path2) { + path2 = "unknown:"; } - _this = _super.call(this, path2, network) || this; - (0, properties_1.defineReadOnly)(_this, "jsonRpcFetchFunc", jsonRpcFetchFunc); - (0, properties_1.defineReadOnly)(_this, "provider", subprovider); - return _this; } - Web3Provider2.prototype.send = function(method, params) { - return this.jsonRpcFetchFunc(method, params); - }; - return Web3Provider2; - }(json_rpc_provider_1.JsonRpcProvider) - ); + _this = _super.call(this, path2, network) || this; + (0, properties_1.defineReadOnly)(_this, "jsonRpcFetchFunc", jsonRpcFetchFunc); + (0, properties_1.defineReadOnly)(_this, "provider", subprovider); + return _this; + } + Web3Provider2.prototype.send = function(method, params) { + return this.jsonRpcFetchFunc(method, params); + }; + return Web3Provider2; + }(json_rpc_provider_1.JsonRpcProvider); exports2.Web3Provider = Web3Provider; } }); @@ -33297,7 +32361,7 @@ var require_version25 = __commonJS({ var require_ethers = __commonJS({ "node_modules/ethers/lib/ethers.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -33308,21 +32372,21 @@ var require_ethers = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); @@ -33355,9 +32419,9 @@ var require_ethers = __commonJS({ Object.defineProperty(exports2, "Wallet", { enumerable: true, get: function() { return wallet_1.Wallet; } }); - var constants = __importStar2(require_lib8()); + var constants = __importStar(require_lib8()); exports2.constants = constants; - var providers2 = __importStar2(require_lib30()); + var providers2 = __importStar(require_lib30()); exports2.providers = providers2; var providers_1 = require_lib30(); Object.defineProperty(exports2, "getDefaultProvider", { enumerable: true, get: function() { @@ -33370,7 +32434,7 @@ var require_ethers = __commonJS({ Object.defineProperty(exports2, "wordlists", { enumerable: true, get: function() { return wordlists_1.wordlists; } }); - var utils = __importStar2(require_utils5()); + var utils = __importStar(require_utils5()); exports2.utils = utils; var logger_1 = require_lib(); Object.defineProperty(exports2, "errors", { enumerable: true, get: function() { @@ -33389,7 +32453,7 @@ var require_ethers = __commonJS({ var require_lib31 = __commonJS({ "node_modules/ethers/lib/index.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { @@ -33400,26 +32464,26 @@ var require_lib31 = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.Wordlist = exports2.version = exports2.wordlists = exports2.utils = exports2.logger = exports2.errors = exports2.constants = exports2.FixedNumber = exports2.BigNumber = exports2.ContractFactory = exports2.Contract = exports2.BaseContract = exports2.providers = exports2.getDefaultProvider = exports2.VoidSigner = exports2.Wallet = exports2.Signer = exports2.ethers = void 0; - var ethers = __importStar2(require_ethers()); + var ethers = __importStar(require_ethers()); exports2.ethers = ethers; try { anyGlobal = window; @@ -33619,7 +32683,7 @@ var require_cl_feed_registry = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.ChainlinkFeedsRegistry = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var utils_1 = require_utils5(); var FeedRegistryInterface__factory_1 = require_FeedRegistryInterface_factory(); var ChainlinkFeedsRegistryTypes_1 = require_ChainlinkFeedsRegistryTypes(); @@ -33802,7 +32866,6 @@ var require_gasStation = __commonJS({ // node_modules/bignumber.js/bignumber.js var require_bignumber2 = __commonJS({ "node_modules/bignumber.js/bignumber.js"(exports2, module2) { - "use strict"; (function(globalObject) { "use strict"; var BigNumber2, isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i, mathceil = Math.ceil, mathfloor = Math.floor, bignumberError = "[BigNumber Error] ", tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ", BASE = 1e14, LOG_BASE = 14, MAX_SAFE_INTEGER = 9007199254740991, POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13], SQRT_BASE = 1e7, MAX = 1e9; @@ -33815,7 +32878,6 @@ var require_bignumber2 = __commonJS({ decimalSeparator: ".", fractionGroupSize: 0, fractionGroupSeparator: "\xA0", - // non-breaking space suffix: "" }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true; function BigNumber3(v, b) { @@ -34300,11 +33362,7 @@ var require_bignumber2 = __commonJS({ var cmp, e, i, more, n, prod, prodL, q, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s = x.s == y.s ? 1 : -1, xc = x.c, yc = y.c; if (!xc || !xc[0] || !yc || !yc[0]) { return new BigNumber3( - // Return NaN if either NaN, or both Infinity or 0. - !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : ( - // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0. - xc && xc[0] == 0 || !yc ? s * 0 : s / 0 - ) + !x.s || !y.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : xc && xc[0] == 0 || !yc ? s * 0 : s / 0 ); } q = new BigNumber3(s); @@ -34542,12 +33600,8 @@ var require_bignumber2 = __commonJS({ rd = j < 0 ? 0 : n / pows10[d - j - 1] % 10 | 0; } } - r = r || sd < 0 || // Are there any non-zero digits after the rounding digit? - // The expression n % pows10[d - j - 1] returns all digits of n to the right - // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714. - xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); - r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && // Check whether the digit to the left of the rounding digit is odd. - (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7)); + r = r || sd < 0 || xc[ni + 1] != null || (j < 0 ? n : n % pows10[d - j - 1]); + r = rm < 4 ? (rd || r) && (rm == 0 || rm == (x.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r || rm == 6 && (i > 0 ? j > 0 ? n / pows10[d - j] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x.s < 0 ? 8 : 7)); if (sd < 1 || !xc[0]) { xc.length = 0; if (r) { @@ -34782,10 +33836,7 @@ var require_bignumber2 = __commonJS({ if (!xc || !yc) return xc ? (y.s = -b, y) : new BigNumber3(yc ? x : NaN); if (!xc[0] || !yc[0]) { - return yc[0] ? (y.s = -b, y) : new BigNumber3(xc[0] ? x : ( - // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity - ROUNDING_MODE == 3 ? -0 : 0 - )); + return yc[0] ? (y.s = -b, y) : new BigNumber3(xc[0] ? x : ROUNDING_MODE == 3 ? -0 : 0); } } xe = bitFloor(xe); @@ -35520,7 +34571,6 @@ var require_BaseService = __commonJS({ // node_modules/reflect-metadata/Reflect.js var require_Reflect = __commonJS({ "node_modules/reflect-metadata/Reflect.js"() { - "use strict"; var Reflect2; (function(Reflect3) { (function(factory) { @@ -35550,7 +34600,6 @@ var require_Reflect = __commonJS({ var supportsProto = { __proto__: [] } instanceof Array; var downLevel = !supportsCreate && !supportsProto; var HashMap = { - // create an object in dictionary mode (a.k.a. "slow" mode in v8) create: supportsCreate ? function() { return MakeDictionary(/* @__PURE__ */ Object.create(null)); } : supportsProto ? function() { @@ -35668,12 +34717,7 @@ var require_Reflect = __commonJS({ throw new TypeError(); if (!IsUndefined(propertyKey)) propertyKey = ToPropertyKey(propertyKey); - var metadataMap = GetOrCreateMetadataMap( - target, - propertyKey, - /*Create*/ - false - ); + var metadataMap = GetOrCreateMetadataMap(target, propertyKey, false); if (IsUndefined(metadataMap)) return false; if (!metadataMap.delete(metadataKey)) @@ -35739,12 +34783,7 @@ var require_Reflect = __commonJS({ return false; } function OrdinaryHasOwnMetadata(MetadataKey, O, P) { - var metadataMap = GetOrCreateMetadataMap( - O, - P, - /*Create*/ - false - ); + var metadataMap = GetOrCreateMetadataMap(O, P, false); if (IsUndefined(metadataMap)) return false; return ToBoolean(metadataMap.has(MetadataKey)); @@ -35759,23 +34798,13 @@ var require_Reflect = __commonJS({ return void 0; } function OrdinaryGetOwnMetadata(MetadataKey, O, P) { - var metadataMap = GetOrCreateMetadataMap( - O, - P, - /*Create*/ - false - ); + var metadataMap = GetOrCreateMetadataMap(O, P, false); if (IsUndefined(metadataMap)) return void 0; return metadataMap.get(MetadataKey); } function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) { - var metadataMap = GetOrCreateMetadataMap( - O, - P, - /*Create*/ - true - ); + var metadataMap = GetOrCreateMetadataMap(O, P, true); metadataMap.set(MetadataKey, MetadataValue); } function OrdinaryMetadataKeys(O, P) { @@ -35810,12 +34839,7 @@ var require_Reflect = __commonJS({ } function OrdinaryOwnMetadataKeys(O, P) { var keys = []; - var metadataMap = GetOrCreateMetadataMap( - O, - P, - /*Create*/ - false - ); + var metadataMap = GetOrCreateMetadataMap(O, P, false); if (IsUndefined(metadataMap)) return keys; var keysObj = metadataMap.keys(); @@ -35934,11 +34958,7 @@ var require_Reflect = __commonJS({ return "" + argument; } function ToPropertyKey(argument) { - var key = ToPrimitive( - argument, - 3 - /* String */ - ); + var key = ToPrimitive(argument, 3); if (IsSymbol(key)) return key; return ToString(key); @@ -36011,152 +35031,130 @@ var require_Reflect = __commonJS({ function CreateMapPolyfill() { var cacheSentinel = {}; var arraySentinel = []; - var MapIterator = ( - /** @class */ - function() { - function MapIterator2(keys, values, selector) { - this._index = 0; - this._keys = keys; - this._values = values; - this._selector = selector; - } - MapIterator2.prototype["@@iterator"] = function() { - return this; - }; - MapIterator2.prototype[iteratorSymbol] = function() { - return this; - }; - MapIterator2.prototype.next = function() { - var index = this._index; - if (index >= 0 && index < this._keys.length) { - var result = this._selector(this._keys[index], this._values[index]); - if (index + 1 >= this._keys.length) { - this._index = -1; - this._keys = arraySentinel; - this._values = arraySentinel; - } else { - this._index++; - } - return { value: result, done: false }; - } - return { value: void 0, done: true }; - }; - MapIterator2.prototype.throw = function(error) { - if (this._index >= 0) { - this._index = -1; - this._keys = arraySentinel; - this._values = arraySentinel; - } - throw error; - }; - MapIterator2.prototype.return = function(value) { - if (this._index >= 0) { + var MapIterator = function() { + function MapIterator2(keys, values, selector) { + this._index = 0; + this._keys = keys; + this._values = values; + this._selector = selector; + } + MapIterator2.prototype["@@iterator"] = function() { + return this; + }; + MapIterator2.prototype[iteratorSymbol] = function() { + return this; + }; + MapIterator2.prototype.next = function() { + var index = this._index; + if (index >= 0 && index < this._keys.length) { + var result = this._selector(this._keys[index], this._values[index]); + if (index + 1 >= this._keys.length) { this._index = -1; this._keys = arraySentinel; this._values = arraySentinel; + } else { + this._index++; } - return { value, done: true }; - }; - return MapIterator2; - }() - ); - return ( - /** @class */ - function() { - function Map2() { - this._keys = []; - this._values = []; - this._cacheKey = cacheSentinel; - this._cacheIndex = -2; + return { value: result, done: false }; } - Object.defineProperty(Map2.prototype, "size", { - get: function() { - return this._keys.length; - }, - enumerable: true, - configurable: true - }); - Map2.prototype.has = function(key) { - return this._find( - key, - /*insert*/ - false - ) >= 0; - }; - Map2.prototype.get = function(key) { - var index = this._find( - key, - /*insert*/ - false - ); - return index >= 0 ? this._values[index] : void 0; - }; - Map2.prototype.set = function(key, value) { - var index = this._find( - key, - /*insert*/ - true - ); - this._values[index] = value; - return this; - }; - Map2.prototype.delete = function(key) { - var index = this._find( - key, - /*insert*/ - false - ); - if (index >= 0) { - var size = this._keys.length; - for (var i = index + 1; i < size; i++) { - this._keys[i - 1] = this._keys[i]; - this._values[i - 1] = this._values[i]; - } - this._keys.length--; - this._values.length--; - if (key === this._cacheKey) { - this._cacheKey = cacheSentinel; - this._cacheIndex = -2; - } - return true; - } - return false; - }; - Map2.prototype.clear = function() { - this._keys.length = 0; - this._values.length = 0; - this._cacheKey = cacheSentinel; - this._cacheIndex = -2; - }; - Map2.prototype.keys = function() { - return new MapIterator(this._keys, this._values, getKey); - }; - Map2.prototype.values = function() { - return new MapIterator(this._keys, this._values, getValue); - }; - Map2.prototype.entries = function() { - return new MapIterator(this._keys, this._values, getEntry); - }; - Map2.prototype["@@iterator"] = function() { - return this.entries(); - }; - Map2.prototype[iteratorSymbol] = function() { - return this.entries(); - }; - Map2.prototype._find = function(key, insert) { - if (this._cacheKey !== key) { - this._cacheIndex = this._keys.indexOf(this._cacheKey = key); + return { value: void 0, done: true }; + }; + MapIterator2.prototype.throw = function(error) { + if (this._index >= 0) { + this._index = -1; + this._keys = arraySentinel; + this._values = arraySentinel; + } + throw error; + }; + MapIterator2.prototype.return = function(value) { + if (this._index >= 0) { + this._index = -1; + this._keys = arraySentinel; + this._values = arraySentinel; + } + return { value, done: true }; + }; + return MapIterator2; + }(); + return function() { + function Map2() { + this._keys = []; + this._values = []; + this._cacheKey = cacheSentinel; + this._cacheIndex = -2; + } + Object.defineProperty(Map2.prototype, "size", { + get: function() { + return this._keys.length; + }, + enumerable: true, + configurable: true + }); + Map2.prototype.has = function(key) { + return this._find(key, false) >= 0; + }; + Map2.prototype.get = function(key) { + var index = this._find(key, false); + return index >= 0 ? this._values[index] : void 0; + }; + Map2.prototype.set = function(key, value) { + var index = this._find(key, true); + this._values[index] = value; + return this; + }; + Map2.prototype.delete = function(key) { + var index = this._find(key, false); + if (index >= 0) { + var size = this._keys.length; + for (var i = index + 1; i < size; i++) { + this._keys[i - 1] = this._keys[i]; + this._values[i - 1] = this._values[i]; } - if (this._cacheIndex < 0 && insert) { - this._cacheIndex = this._keys.length; - this._keys.push(key); - this._values.push(void 0); + this._keys.length--; + this._values.length--; + if (key === this._cacheKey) { + this._cacheKey = cacheSentinel; + this._cacheIndex = -2; } - return this._cacheIndex; - }; - return Map2; - }() - ); + return true; + } + return false; + }; + Map2.prototype.clear = function() { + this._keys.length = 0; + this._values.length = 0; + this._cacheKey = cacheSentinel; + this._cacheIndex = -2; + }; + Map2.prototype.keys = function() { + return new MapIterator(this._keys, this._values, getKey); + }; + Map2.prototype.values = function() { + return new MapIterator(this._keys, this._values, getValue); + }; + Map2.prototype.entries = function() { + return new MapIterator(this._keys, this._values, getEntry); + }; + Map2.prototype["@@iterator"] = function() { + return this.entries(); + }; + Map2.prototype[iteratorSymbol] = function() { + return this.entries(); + }; + Map2.prototype._find = function(key, insert) { + if (this._cacheKey !== key) { + this._cacheIndex = this._keys.indexOf(this._cacheKey = key); + } + if (this._cacheIndex < 0 && insert) { + this._cacheIndex = this._keys.length; + this._keys.push(key); + this._values.push(void 0); + } + return this._cacheIndex; + }; + return Map2; + }(); function getKey(key, _) { return key; } @@ -36168,99 +35166,77 @@ var require_Reflect = __commonJS({ } } function CreateSetPolyfill() { - return ( - /** @class */ - function() { - function Set2() { - this._map = new _Map(); - } - Object.defineProperty(Set2.prototype, "size", { - get: function() { - return this._map.size; - }, - enumerable: true, - configurable: true - }); - Set2.prototype.has = function(value) { - return this._map.has(value); - }; - Set2.prototype.add = function(value) { - return this._map.set(value, value), this; - }; - Set2.prototype.delete = function(value) { - return this._map.delete(value); - }; - Set2.prototype.clear = function() { - this._map.clear(); - }; - Set2.prototype.keys = function() { - return this._map.keys(); - }; - Set2.prototype.values = function() { - return this._map.values(); - }; - Set2.prototype.entries = function() { - return this._map.entries(); - }; - Set2.prototype["@@iterator"] = function() { - return this.keys(); - }; - Set2.prototype[iteratorSymbol] = function() { - return this.keys(); - }; - return Set2; - }() - ); + return function() { + function Set2() { + this._map = new _Map(); + } + Object.defineProperty(Set2.prototype, "size", { + get: function() { + return this._map.size; + }, + enumerable: true, + configurable: true + }); + Set2.prototype.has = function(value) { + return this._map.has(value); + }; + Set2.prototype.add = function(value) { + return this._map.set(value, value), this; + }; + Set2.prototype.delete = function(value) { + return this._map.delete(value); + }; + Set2.prototype.clear = function() { + this._map.clear(); + }; + Set2.prototype.keys = function() { + return this._map.keys(); + }; + Set2.prototype.values = function() { + return this._map.values(); + }; + Set2.prototype.entries = function() { + return this._map.entries(); + }; + Set2.prototype["@@iterator"] = function() { + return this.keys(); + }; + Set2.prototype[iteratorSymbol] = function() { + return this.keys(); + }; + return Set2; + }(); } function CreateWeakMapPolyfill() { var UUID_SIZE = 16; var keys = HashMap.create(); var rootKey = CreateUniqueKey(); - return ( - /** @class */ - function() { - function WeakMap2() { - this._key = CreateUniqueKey(); - } - WeakMap2.prototype.has = function(target) { - var table = GetOrCreateWeakMapTable( - target, - /*create*/ - false - ); - return table !== void 0 ? HashMap.has(table, this._key) : false; - }; - WeakMap2.prototype.get = function(target) { - var table = GetOrCreateWeakMapTable( - target, - /*create*/ - false - ); - return table !== void 0 ? HashMap.get(table, this._key) : void 0; - }; - WeakMap2.prototype.set = function(target, value) { - var table = GetOrCreateWeakMapTable( - target, - /*create*/ - true - ); - table[this._key] = value; - return this; - }; - WeakMap2.prototype.delete = function(target) { - var table = GetOrCreateWeakMapTable( - target, - /*create*/ - false - ); - return table !== void 0 ? delete table[this._key] : false; - }; - WeakMap2.prototype.clear = function() { - this._key = CreateUniqueKey(); - }; - return WeakMap2; - }() - ); + return function() { + function WeakMap2() { + this._key = CreateUniqueKey(); + } + WeakMap2.prototype.has = function(target) { + var table = GetOrCreateWeakMapTable(target, false); + return table !== void 0 ? HashMap.has(table, this._key) : false; + }; + WeakMap2.prototype.get = function(target) { + var table = GetOrCreateWeakMapTable(target, false); + return table !== void 0 ? HashMap.get(table, this._key) : void 0; + }; + WeakMap2.prototype.set = function(target, value) { + var table = GetOrCreateWeakMapTable(target, true); + table[this._key] = value; + return this; + }; + WeakMap2.prototype.delete = function(target) { + var table = GetOrCreateWeakMapTable(target, false); + return table !== void 0 ? delete table[this._key] : false; + }; + WeakMap2.prototype.clear = function() { + this._key = CreateUniqueKey(); + }; + return WeakMap2; + }(); function CreateUniqueKey() { var key; do @@ -36608,11 +35584,7 @@ var require_methodValidators = __commonJS({ function LPFlashLiquidationValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.lendingPoolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.flashLiquidationAddress) - ) { + if (!ethers_1.utils.isAddress(this.lendingPoolAddress) || !ethers_1.utils.isAddress(this.flashLiquidationAddress)) { console.error(`[LPFlahsLiquidationValidator] You need to pass valid addresses`); return []; } @@ -36626,11 +35598,7 @@ var require_methodValidators = __commonJS({ function LPFlashLiquidationValidatorV3(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.poolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.flashLiquidationAddress) - ) { + if (!ethers_1.utils.isAddress(this.poolAddress) || !ethers_1.utils.isAddress(this.flashLiquidationAddress)) { console.error(`[LPFlahsLiquidationValidator] You need to pass valid addresses`); return []; } @@ -36644,11 +35612,7 @@ var require_methodValidators = __commonJS({ function LPRepayWithCollateralValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.lendingPoolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.repayWithCollateralAddress) - ) { + if (!ethers_1.utils.isAddress(this.lendingPoolAddress) || !ethers_1.utils.isAddress(this.repayWithCollateralAddress)) { console.error(`[LPRepayWithCollateralValidator] You need to pass valid addresses`); return []; } @@ -36661,11 +35625,7 @@ var require_methodValidators = __commonJS({ function LPSwapCollateralValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.lendingPoolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.swapCollateralAddress) - ) { + if (!ethers_1.utils.isAddress(this.lendingPoolAddress) || !ethers_1.utils.isAddress(this.swapCollateralAddress)) { console.error(`[LPSwapCollateralValidator] You need to pass valid addresses`); return []; } @@ -36678,11 +35638,7 @@ var require_methodValidators = __commonJS({ function LPRepayWithCollateralValidatorV3(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.poolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.repayWithCollateralAddress) - ) { + if (!ethers_1.utils.isAddress(this.poolAddress) || !ethers_1.utils.isAddress(this.repayWithCollateralAddress)) { console.error(`[LPRepayWithCollateralValidator] You need to pass valid addresses`); return []; } @@ -36695,11 +35651,7 @@ var require_methodValidators = __commonJS({ function LPSwapCollateralValidatorV3(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.poolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.swapCollateralAddress) - ) { + if (!ethers_1.utils.isAddress(this.poolAddress) || !ethers_1.utils.isAddress(this.swapCollateralAddress)) { console.error(`[LPSwapCollateralValidator] You need to pass valid addresses`); return []; } @@ -36727,13 +35679,8 @@ var require_methodValidators = __commonJS({ function L2PValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.l2PoolAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.encoderAddress) - ) { + if (!ethers_1.utils.isAddress(this.l2PoolAddress) || !ethers_1.utils.isAddress(this.encoderAddress)) { console.error( - // @ts-expect-error todo: check why this ignore is needed `[L2PoolValidator] You need to pass valid addresses: l2pool: ${this.l2PoolAddress} encoder: ${this.encoderAddress}` ); return []; @@ -36839,10 +35786,7 @@ var require_methodValidators = __commonJS({ function StakingValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.stakingContractAddress) - ) { + if (!ethers_1.utils.isAddress(this.stakingContractAddress)) { console.error(`[StakingValidator] You need to pass valid addresses`); return []; } @@ -36856,11 +35800,7 @@ var require_methodValidators = __commonJS({ function SignStakingValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.stakingContractAddress) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.stakingHelperContractAddress) - ) { + if (!ethers_1.utils.isAddress(this.stakingContractAddress) || !ethers_1.utils.isAddress(this.stakingHelperContractAddress)) { console.error(`[StakingValidator] You need to pass valid addresses`); return []; } @@ -36902,11 +35842,7 @@ var require_methodValidators = __commonJS({ function GovHelperValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.aaveGovernanceV2Address) || // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.aaveGovernanceV2HelperAddress) - ) { + if (!ethers_1.utils.isAddress(this.aaveGovernanceV2Address) || !ethers_1.utils.isAddress(this.aaveGovernanceV2HelperAddress)) { console.error(`[GovernanceValidator] You need to pass valid addresses`); return []; } @@ -36920,10 +35856,7 @@ var require_methodValidators = __commonJS({ function GovValidator(target, propertyName, descriptor) { const method = descriptor.value; descriptor.value = function() { - if ( - // @ts-expect-error todo: check why this ignore is needed - !ethers_1.utils.isAddress(this.aaveGovernanceV2Address) - ) { + if (!ethers_1.utils.isAddress(this.aaveGovernanceV2Address)) { console.error(`[GovernanceValidator] You need to pass valid addresses`); return []; } @@ -37958,7 +36891,7 @@ var require_v3_UiIncentiveDataProvider_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UiIncentiveDataProvider = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var utils_1 = require_utils5(); var index_1 = require_cl_feed_registry(); var ChainlinkFeedsRegistryTypes_1 = require_ChainlinkFeedsRegistryTypes(); @@ -37968,10 +36901,6 @@ var require_v3_UiIncentiveDataProvider_contract = __commonJS({ var IUiIncentiveDataProviderV3__factory_1 = require_IUiIncentiveDataProviderV3_factory(); tslib_1.__exportStar(require_types3(), exports2); var UiIncentiveDataProvider = class extends BaseService_1.default { - /** - * Constructor - * @param context The ui incentive data provider context - */ constructor({ provider, uiIncentiveDataProviderAddress, chainId }) { super(provider, IUiIncentiveDataProviderV3__factory_1.IUiIncentiveDataProviderV3__factory); this._getFeed = (rewardToken, chainlinkFeedsRegistry, quote) => __async(this, null, function* () { @@ -37982,29 +36911,18 @@ var require_v3_UiIncentiveDataProvider_contract = __commonJS({ this._chainlinkFeedsRegistries = {}; this.chainId = chainId; } - /** - * Get the full reserve incentive data for the lending pool and the user - * @param user The user address - */ getFullReservesIncentiveData(_0) { return __async(this, arguments, function* ({ user, lendingPoolAddressProvider }) { const uiIncentiveContract = this.getContractInstance(this.uiIncentiveDataProviderAddress); return uiIncentiveContract.getFullReservesIncentiveData(lendingPoolAddressProvider, user); }); } - /** - * Get the reserve incentive data for the lending pool - */ getReservesIncentivesData(_0) { return __async(this, arguments, function* ({ lendingPoolAddressProvider }) { const uiIncentiveContract = this.getContractInstance(this.uiIncentiveDataProviderAddress); return uiIncentiveContract.getReservesIncentivesData(lendingPoolAddressProvider); }); } - /** - * Get the reserve incentive data for the user - * @param user The user address - */ getUserReservesIncentivesData(_0) { return __async(this, arguments, function* ({ user, lendingPoolAddressProvider }) { const uiIncentiveContract = this.getContractInstance(this.uiIncentiveDataProviderAddress); @@ -38610,7 +37528,7 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UiPoolDataProvider = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var utils_1 = require_utils5(); var IUiPoolDataProviderV3__factory_1 = require_IUiPoolDataProviderV3_factory(); tslib_1.__exportStar(require_types4(), exports2); @@ -38633,10 +37551,6 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ "0x59a19d8c652fa0284f44113d0ff9aba70bd46fb4": "BPTBALWETH" }; var UiPoolDataProvider = class { - /** - * Constructor - * @param context The ui pool data provider context - */ constructor(context) { if (!(0, utils_1.isAddress)(context.uiPoolDataProviderAddress)) { throw new Error("contract address is not valid"); @@ -38644,9 +37558,6 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ this._contract = IUiPoolDataProviderV3__factory_1.IUiPoolDataProviderV3__factory.connect(context.uiPoolDataProviderAddress, context.provider); this.chainId = context.chainId; } - /** - * Get the underlying asset address for each lending pool reserve - */ getReservesList(_0) { return __async(this, arguments, function* ({ lendingPoolAddressProvider }) { if (!(0, utils_1.isAddress)(lendingPoolAddressProvider)) { @@ -38655,9 +37566,6 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ return this._contract.getReservesList(lendingPoolAddressProvider); }); } - /** - * Get data for each lending pool reserve - */ getReservesData(_0) { return __async(this, arguments, function* ({ lendingPoolAddressProvider }) { if (!(0, utils_1.isAddress)(lendingPoolAddressProvider)) { @@ -38666,9 +37574,6 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ return this._contract.getReservesData(lendingPoolAddressProvider); }); } - /** - * Get data for each user reserve on the lending pool - */ getUserReservesData(_0) { return __async(this, arguments, function* ({ lendingPoolAddressProvider, user }) { if (!(0, utils_1.isAddress)(lendingPoolAddressProvider)) { @@ -38722,7 +37627,6 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ baseStableBorrowRate: reserveRaw.baseStableBorrowRate.toString(), baseVariableBorrowRate: reserveRaw.baseVariableBorrowRate.toString(), optimalUsageRatio: reserveRaw.optimalUsageRatio.toString(), - // new fields isPaused: reserveRaw.isPaused, debtCeiling: reserveRaw.debtCeiling.toString(), eModeCategoryId: reserveRaw.eModeCategoryId, @@ -38742,7 +37646,6 @@ var require_v3_UiPoolDataProvider_contract = __commonJS({ flashLoanEnabled: reserveRaw.flashLoanEnabled })); const baseCurrencyData = { - // this is to get the decimals from the unit so 1e18 = string length of 19 - 1 to get the number of 0 marketReferenceCurrencyDecimals: poolBaseCurrencyRaw.marketReferenceCurrencyUnit.toString().length - 1, marketReferenceCurrencyPriceInUsd: poolBaseCurrencyRaw.marketReferenceCurrencyPriceInUsd.toString(), networkBaseTokenPriceInUsd: poolBaseCurrencyRaw.networkBaseTokenPriceInUsd.toString(), @@ -38894,23 +37797,14 @@ var require_wallet_balance_provider = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.WalletBalanceProvider = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var utils_1 = require_utils5(); var WalletBalanceProviderFactory_1 = require_WalletBalanceProviderFactory(); tslib_1.__exportStar(require_WalletBalanceProviderTypes(), exports2); var WalletBalanceProvider = class { - /** - * Constructor - * @param context The wallet balance provider context - */ constructor(context) { this._contract = WalletBalanceProviderFactory_1.WalletBalanceProviderFactory.connect(context.walletBalanceProviderAddress, context.provider); } - /** - * Get the balance for a user on a token - * @param user The user address - * @param token The token address - */ balanceOf(user, token) { return __async(this, null, function* () { if (!(0, utils_1.isAddress)(user)) { @@ -38922,11 +37816,6 @@ var require_wallet_balance_provider = __commonJS({ return this._contract.balanceOf(user, token); }); } - /** - * Get the balance for a user on a token - * @param users The users addresses - * @param tokens The tokens addresses - */ batchBalanceOf(users, tokens) { return __async(this, null, function* () { if (!users.every((u) => (0, utils_1.isAddress)(u))) { @@ -38938,11 +37827,6 @@ var require_wallet_balance_provider = __commonJS({ return this._contract.batchBalanceOf(users, tokens); }); } - /** - * Provides balances of user wallet for all reserves available on the pool - * @param user The user - * @param lendingPoolAddressProvider The lending pool address provider - */ getUserWalletBalancesForLendingPoolProvider(user, lendingPoolAddressProvider) { return __async(this, null, function* () { if (!(0, utils_1.isAddress)(user)) { @@ -39771,7 +38655,7 @@ var require_uiStakeDataProvider_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.UiStakeDataProvider = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var methodValidators_1 = require_methodValidators(); var paramValidators_1 = require_paramValidators(); var StakedTokenDataProviderFactory_1 = require_StakedTokenDataProviderFactory(); @@ -39925,7 +38809,7 @@ var require_incentive_controller = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.IncentivesController = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -40826,7 +39710,7 @@ var require_incentive_controller_v2 = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.IncentivesControllerV2 = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -41009,7 +39893,7 @@ var require_erc20_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.ERC20Service = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var utils_1 = require_utils5(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); @@ -41030,14 +39914,6 @@ var require_erc20_contract = __commonJS({ this.decimalsOf = this.decimalsOf.bind(this); this.contractInterface = IERC20Detailed__factory_1.IERC20Detailed__factory.createInterface(); } - /** - * Generate approval tx data with legacy method, call tx() and gas() callbacks for tx data and gas estimation respectively - * @param {string} user - Address to check allowance for - * @param {string} token - Token which the user is spending - * @param {string} spender - Address which is spending the tokens - * @param {string} amount - Amount to approve - * @returns {EthereumTransactionTypeExtended} legacy transaction response - */ approve({ user, token, spender, amount }) { const erc20Contract = this.getContractInstance(token); const txCallback = this.generateTxCallback({ @@ -41052,14 +39928,6 @@ var require_erc20_contract = __commonJS({ gas: this.generateTxPriceEstimation([], txCallback) }; } - /** - * Generate approval tx data, ready to sign and submit to blockchain - * @param {string} user - Address to check allowance for - * @param {string} token - Token which the user is spending - * @param {string} spender - Address which is spending the tokens - * @param {string} amount - Amount to approve - * @returns {PopulatedTransaction} Transaction response - */ approveTxData({ user, token, spender, amount }) { const tx = {}; const txData = this.contractInterface.encodeFunctionData("approve", [ @@ -41072,14 +39940,6 @@ var require_erc20_contract = __commonJS({ tx.gasLimit = ethers_1.BigNumber.from(utils_2.gasLimitRecommendations[types_1.ProtocolAction.approval].recommended); return tx; } - /** - * Qeuries whether user has approved spender to transfer tokens up to the specific amount - * @param {string} user - Address to check allowance for - * @param {string} token - Token which the user is spending - * @param {string} spender - Address which is spending the tokens - * @param {string} amount - Amount of token to checkif spender has allowance for - * @returns {boolean} true if user has approved spender contract for greater than passed amount, false otherwise - */ isApproved(_0) { return __async(this, arguments, function* ({ user, token, spender, amount, nativeDecimals }) { if (token.toLowerCase() === utils_2.API_ETH_MOCK_ADDRESS.toLowerCase()) @@ -41091,13 +39951,6 @@ var require_erc20_contract = __commonJS({ return allowance.gte(amountBNWithDecimals); }); } - /** - * Fetches the approval allowance of a user for a specific token and spender - * @param {string} user - Address to check allowance for - * @param {string} token - Token which the user is spending - * @param {string} spender - Address which is spending the tokens - * @returns {number} The user's approved allowance, in standard decimal units, -1 for max allowance - */ approvedAmount(_0) { return __async(this, arguments, function* ({ user, token, spender }) { if (token.toLowerCase() === utils_2.API_ETH_MOCK_ADDRESS.toLowerCase()) @@ -41111,11 +39964,6 @@ var require_erc20_contract = __commonJS({ return Number(ethers_1.ethers.utils.formatUnits(allowance, decimals)); }); } - /** - * Fetches the decimals of an ERC20 token, used for formatting amounts - * @param {string} token - ERC20 token address - * @returns {number} Decimal units of token amounts - */ decimalsOf(token) { return __async(this, null, function* () { if (token.toLowerCase() === utils_2.API_ETH_MOCK_ADDRESS.toLowerCase()) @@ -41127,11 +39975,6 @@ var require_erc20_contract = __commonJS({ return this.tokenDecimals[token]; }); } - /** - * Return basic details of an ERC20 - * @param {string} token - ERC20 token address - * @returns {TokenMetadataType} ERC20 token metadata - */ getTokenData(token) { return __async(this, null, function* () { if (token.toLowerCase() === utils_2.API_ETH_MOCK_ADDRESS.toLowerCase()) { @@ -41324,7 +40167,7 @@ var require_paraswap_liquiditySwapAdapter_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.LiquiditySwapAdapterService = exports2.augustusFromAmountOffsetFromCalldata = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); var methodValidators_1 = require_methodValidators(); @@ -41763,7 +40606,7 @@ var require_paraswap_repayWithCollateralAdapter_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.ParaswapRepayWithCollateral = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -41904,7 +40747,7 @@ var require_repayWithCollateralAdapter_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.RepayWithCollateralAdapterService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); var methodValidators_1 = require_methodValidators(); @@ -41990,7 +40833,7 @@ var require_synthetix_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.SynthetixService = exports2.synthetixProxyByChainId = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -42010,7 +40853,6 @@ var require_synthetix_contract = __commonJS({ user, reserve, amount - // wei }) { const { chainId } = yield this.provider.getNetwork(); if (exports2.synthetixProxyByChainId[chainId] && reserve.toLowerCase() === exports2.synthetixProxyByChainId[chainId].toLowerCase()) { @@ -42104,7 +40946,7 @@ var require_baseDebtToken_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.BaseDebtToken = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -42332,7 +41174,7 @@ var require_wethgateway_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.WETHGatewayService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var baseDebtToken_contract_1 = require_baseDebtToken_contract(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); @@ -42809,7 +41651,7 @@ var require_lendingPool_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.LendingPool = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -43154,7 +41996,6 @@ var require_lendingPool_contract = __commonJS({ [fromAsset], swapAll ? [convertedAmountWithSurplus] : [convertedAmount], [0], - // interest rate mode to NONE for flashloan to not open debt onBehalfOf !== null && onBehalfOf !== void 0 ? onBehalfOf : user, params, referralCode !== null && referralCode !== void 0 ? referralCode : "0" @@ -43246,7 +42087,6 @@ var require_lendingPool_contract = __commonJS({ [assetToRepay], [convertedRepayAmount], [0], - // interest rate mode to NONE for flashloan to not open debt onBehalfOf !== null && onBehalfOf !== void 0 ? onBehalfOf : user, params, referralCode !== null && referralCode !== void 0 ? referralCode : "0" @@ -43341,7 +42181,6 @@ var require_lendingPool_contract = __commonJS({ [fromAsset], repayAllDebt ? [convertedRepayWithAmountWithSurplus] : [convertedRepayWithAmount], [0], - // interest rate mode to NONE for flashloan to not open debt onBehalfOf !== null && onBehalfOf !== void 0 ? onBehalfOf : user, params, referralCode !== null && referralCode !== void 0 ? referralCode : "0" @@ -43537,7 +42376,7 @@ var require_lendingPool_contract_bundle = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.LendingPoolBundle = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -43694,7 +42533,7 @@ var require_faucet_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.FaucetService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); var utils_1 = require_utils6(); @@ -43818,7 +42657,7 @@ var require_v3_faucet_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.V3FaucetService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); var utils_1 = require_utils6(); @@ -43830,10 +42669,6 @@ var require_v3_faucet_contract = __commonJS({ super(provider, IERC20FaucetOwnable__factory_1.IERC20FaucetOwnable__factory); this.faucetAddress = faucetAddress !== null && faucetAddress !== void 0 ? faucetAddress : ""; } - /** - * @dev This mint function will only work if the IERC20FaucetOwnable "isPermissioned()" boolean getter returns "false". - * If the "isPermissioned" returns true, them only the owner can sign the function. - */ mint({ userAddress, reserve, tokenSymbol, owner }) { const defaultAmount = (0, utils_1.valueToWei)("1000", 18); const amount = utils_1.mintAmountsPerToken[tokenSymbol] ? utils_1.mintAmountsPerToken[tokenSymbol] : defaultAmount; @@ -44034,7 +42869,7 @@ var require_staking_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.StakingService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -45598,7 +44433,7 @@ var require_governance_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.AaveGovernanceService = exports2.humanizeProposal = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var utils_1 = require_utils5(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -46107,7 +44942,7 @@ var require_governance_power_delegation_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.GovernancePowerDelegationTokenService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var bytes_1 = require_lib2(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var types_1 = require_types2(); @@ -46462,7 +45297,7 @@ var require_erc20_2612 = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.ERC20_2612Service = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); var methodValidators_1 = require_methodValidators(); var paramValidators_1 = require_paramValidators(); @@ -48799,7 +47634,7 @@ var require_v3_pool_rollups = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.L2Pool = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var ethers_1 = require_lib31(); var utils_1 = require_utils5(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); @@ -49176,7 +48011,7 @@ var require_v3_pool_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.Pool = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var bytes_1 = require_lib2(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); @@ -49342,7 +48177,6 @@ var require_v3_pool_contract = __commonJS({ return txs; }); } - // Sign permit supply signERC20Approval(_0) { return __async(this, arguments, function* ({ user, reserve, amount, deadline }) { const { getTokenData, isApproved } = this.erc20Service; @@ -50185,7 +49019,7 @@ var require_v3_pool_contract_bundle = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.PoolBundle = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var bytes_1 = require_lib2(); var ethers_1 = require_lib31(); var BaseService_1 = tslib_1.__importDefault(require_BaseService()); @@ -50641,7 +49475,7 @@ var require_v3_migration_contract = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.V3MigrationHelperService = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var bignumber_js_1 = tslib_1.__importDefault(require_bignumber2()); var ethers_1 = require_lib31(); var baseDebtToken_contract_1 = require_baseDebtToken_contract(); @@ -50806,7 +49640,6 @@ var require_v3_migration_contract = __commonJS({ // node_modules/unfetch/dist/unfetch.js var require_unfetch = __commonJS({ "node_modules/unfetch/dist/unfetch.js"(exports2, module2) { - "use strict"; module2.exports = function(e, n) { return n = n || {}, new Promise(function(t, r) { var s = new XMLHttpRequest(), o = [], u = [], i = {}, a = function() { @@ -51957,9 +50790,7 @@ var require_url_state_machine = __commonJS({ this.url.fragment = ""; this.state = "fragment"; } else { - if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points - !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points - !fileOtherwiseCodePoints.has(this.input[this.pointer + 2])) { + if (this.input.length - this.pointer - 1 === 0 || !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || this.input.length - this.pointer - 1 >= 2 && !fileOtherwiseCodePoints.has(this.input[this.pointer + 2])) { this.url.host = this.base.host; this.url.path = this.base.path.slice(); shortenPath(this.url); @@ -52790,26 +51621,15 @@ var require_lib33 = __commonJS({ get bodyUsed() { return this[INTERNALS].disturbed; }, - /** - * Decode response as ArrayBuffer - * - * @return Promise - */ arrayBuffer() { return consumeBody.call(this).then(function(buf) { return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength); }); }, - /** - * Return raw response as Blob - * - * @return Promise - */ blob() { let ct = this.headers && this.headers.get("content-type") || ""; return consumeBody.call(this).then(function(buf) { return Object.assign( - // Prevent copying new Blob2([], { type: ct.toLowerCase() }), @@ -52819,11 +51639,6 @@ var require_lib33 = __commonJS({ ); }); }, - /** - * Decode response as json - * - * @return Promise - */ json() { var _this2 = this; return consumeBody.call(this).then(function(buffer) { @@ -52834,30 +51649,14 @@ var require_lib33 = __commonJS({ } }); }, - /** - * Decode response as text - * - * @return Promise - */ text() { return consumeBody.call(this).then(function(buffer) { return buffer.toString(); }); }, - /** - * Decode response as buffer (non-spec api) - * - * @return Promise - */ buffer() { return consumeBody.call(this); }, - /** - * Decode response as text, while automatically detecting the encoding and - * trying to decode to UTF-8 (non-spec api) - * - * @return Promise - */ textConverted() { var _this3 = this; return consumeBody.call(this).then(function(buffer) { @@ -53041,8 +51840,7 @@ var require_lib33 = __commonJS({ } else if (Buffer.isBuffer(body)) { return body.length; } else if (body && typeof body.getLengthSync === "function") { - if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || // 1.x - body.hasKnownLength && body.hasKnownLength()) { + if (body._lengthRetrievers && body._lengthRetrievers.length == 0 || body.hasKnownLength && body.hasKnownLength()) { return body.getLengthSync(); } return null; @@ -53089,12 +51887,6 @@ var require_lib33 = __commonJS({ } var MAP = Symbol("map"); var Headers = class { - /** - * Headers class - * - * @param Object headers Response headers - * @return Void - */ constructor() { let init = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : void 0; this[MAP] = /* @__PURE__ */ Object.create(null); @@ -53139,12 +51931,6 @@ var require_lib33 = __commonJS({ throw new TypeError("Provided initializer must be an object"); } } - /** - * Return combined header value given name - * - * @param String name Header name - * @return Mixed - */ get(name2) { name2 = `${name2}`; validateName(name2); @@ -53154,13 +51940,6 @@ var require_lib33 = __commonJS({ } return this[MAP][key].join(", "); } - /** - * Iterate over all headers - * - * @param Function callback Executed for each item with parameters (value, name, thisArg) - * @param Boolean thisArg `this` context for callback function - * @return Void - */ forEach(callback) { let thisArg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : void 0; let pairs = getHeaders(this); @@ -53173,13 +51952,6 @@ var require_lib33 = __commonJS({ i++; } } - /** - * Overwrite header values given name - * - * @param String name Header name - * @param String value Header value - * @return Void - */ set(name2, value) { name2 = `${name2}`; value = `${value}`; @@ -53188,13 +51960,6 @@ var require_lib33 = __commonJS({ const key = find(this[MAP], name2); this[MAP][key !== void 0 ? key : name2] = [value]; } - /** - * Append a value onto existing header - * - * @param String name Header name - * @param String value Header value - * @return Void - */ append(name2, value) { name2 = `${name2}`; value = `${value}`; @@ -53207,23 +51972,11 @@ var require_lib33 = __commonJS({ this[MAP][name2] = [value]; } } - /** - * Check for header name existence - * - * @param String name Header name - * @return Boolean - */ has(name2) { name2 = `${name2}`; validateName(name2); return find(this[MAP], name2) !== void 0; } - /** - * Delete all header values given name - * - * @param String name Header name - * @return Void - */ delete(name2) { name2 = `${name2}`; validateName(name2); @@ -53232,37 +51985,15 @@ var require_lib33 = __commonJS({ delete this[MAP][key]; } } - /** - * Return raw headers (non-spec api) - * - * @return Object - */ raw() { return this[MAP]; } - /** - * Get an iterator on keys. - * - * @return Iterator - */ keys() { return createHeadersIterator(this, "key"); } - /** - * Get an iterator on values. - * - * @return Iterator - */ values() { return createHeadersIterator(this, "value"); } - /** - * Get an iterator on entries. - * - * This is the default iterator of the Headers object. - * - * @return Iterator - */ [Symbol.iterator]() { return createHeadersIterator(this, "key+value"); } @@ -53394,9 +52125,6 @@ var require_lib33 = __commonJS({ get status() { return this[INTERNALS$1].status; } - /** - * Convenience property representing if the request ended normally - */ get ok() { return this[INTERNALS$1].status >= 200 && this[INTERNALS$1].status < 300; } @@ -53409,11 +52137,6 @@ var require_lib33 = __commonJS({ get headers() { return this[INTERNALS$1].headers; } - /** - * Clone this response - * - * @return Response - */ clone() { return new Response(clone(this), { url: this.url, @@ -53523,11 +52246,6 @@ var require_lib33 = __commonJS({ get signal() { return this[INTERNALS$2].signal; } - /** - * Clone this request - * - * @return Request - */ clone() { return new Request(this); } @@ -53804,7 +52522,6 @@ var require_lib33 = __commonJS({ // node_modules/isomorphic-unfetch/index.js var require_isomorphic_unfetch = __commonJS({ "node_modules/isomorphic-unfetch/index.js"(exports2, module2) { - "use strict"; function r(m) { return m && m.default || m; } @@ -53820,7 +52537,7 @@ var require_ipfs = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.getProposalMetadata = exports2.getLink = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); var utils_1 = require_utils5(); var isomorphic_unfetch_1 = tslib_1.__importDefault(require_isomorphic_unfetch()); function getLink2(hash, gateway) { @@ -53874,7 +52591,7 @@ var require_cjs = __commonJS({ "use strict"; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.PERMISSION_MAP = exports2.PERMISSION = void 0; - var tslib_1 = (init_tslib_es6(), __toCommonJS(tslib_es6_exports)); + var tslib_1 = require_tslib(); tslib_1.__exportStar(require_permissions_manager(), exports2); var PermissionManagerTypes_1 = require_PermissionManagerTypes(); Object.defineProperty(exports2, "PERMISSION", { enumerable: true, get: function() { @@ -54702,7 +53419,7 @@ var require_AaveV3Metis = __commonJS({ var require_AaveAddressBook = __commonJS({ "node_modules/@bgd-labs/aave-address-book/dist/AaveAddressBook.js"(exports2) { "use strict"; - var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { + var __createBinding = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) { if (k2 === void 0) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); @@ -54717,59 +53434,58 @@ var require_AaveAddressBook = __commonJS({ k2 = k; o[k2] = m[k]; }); - var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { + var __setModuleDefault = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function(o, v) { o["default"] = v; }); - var __importStar2 = exports2 && exports2.__importStar || function(mod) { + var __importStar = exports2 && exports2.__importStar || function(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) { for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) - __createBinding2(result, mod, k); + __createBinding(result, mod, k); } - __setModuleDefault2(result, mod); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports2, "__esModule", { value: true }); exports2.AaveV3Metis = exports2.AaveV3ScrollAlpha = exports2.AaveV3OptimismGoerli = exports2.AaveV3Optimism = exports2.AaveV3Harmony = exports2.AaveV3Fantom = exports2.AaveV3FantomTestnet = exports2.AaveV3ArbitrumGoerli = exports2.AaveV3Arbitrum = exports2.AaveV3Avalanche = exports2.AaveV2Avalanche = exports2.AaveV3Fuji = exports2.AaveV2Fuji = exports2.AaveV3Polygon = exports2.AaveV2Polygon = exports2.AaveV3Mumbai = exports2.AaveV2Mumbai = exports2.AaveV3GoerliGho = exports2.AaveV3Goerli = exports2.AaveV3Sepolia = exports2.AaveV2Goerli = exports2.AaveV2EthereumArc = exports2.AaveV2EthereumAMM = exports2.AaveV3Ethereum = exports2.AaveV2Ethereum = exports2.AaveSafetyModule = exports2.AaveGovernanceV2 = void 0; - exports2.AaveGovernanceV2 = __importStar2(require_AaveGovernanceV2()); - exports2.AaveSafetyModule = __importStar2(require_AaveSafetyModule()); - exports2.AaveV2Ethereum = __importStar2(require_AaveV2Ethereum()); - exports2.AaveV3Ethereum = __importStar2(require_AaveV3Ethereum()); - exports2.AaveV2EthereumAMM = __importStar2(require_AaveV2EthereumAMM()); - exports2.AaveV2EthereumArc = __importStar2(require_AaveV2EthereumArc()); - exports2.AaveV2Goerli = __importStar2(require_AaveV2Goerli()); - exports2.AaveV3Sepolia = __importStar2(require_AaveV3Sepolia()); - exports2.AaveV3Goerli = __importStar2(require_AaveV3Goerli()); - exports2.AaveV3GoerliGho = __importStar2(require_AaveV3GoerliGho()); - exports2.AaveV2Mumbai = __importStar2(require_AaveV2Mumbai()); - exports2.AaveV3Mumbai = __importStar2(require_AaveV3Mumbai()); - exports2.AaveV2Polygon = __importStar2(require_AaveV2Polygon()); - exports2.AaveV3Polygon = __importStar2(require_AaveV3Polygon()); - exports2.AaveV2Fuji = __importStar2(require_AaveV2Fuji()); - exports2.AaveV3Fuji = __importStar2(require_AaveV3Fuji()); - exports2.AaveV2Avalanche = __importStar2(require_AaveV2Avalanche()); - exports2.AaveV3Avalanche = __importStar2(require_AaveV3Avalanche()); - exports2.AaveV3Arbitrum = __importStar2(require_AaveV3Arbitrum()); - exports2.AaveV3ArbitrumGoerli = __importStar2(require_AaveV3ArbitrumGoerli()); - exports2.AaveV3FantomTestnet = __importStar2(require_AaveV3FantomTestnet()); - exports2.AaveV3Fantom = __importStar2(require_AaveV3Fantom()); - exports2.AaveV3Harmony = __importStar2(require_AaveV3Harmony()); - exports2.AaveV3Optimism = __importStar2(require_AaveV3Optimism()); - exports2.AaveV3OptimismGoerli = __importStar2(require_AaveV3OptimismGoerli()); - exports2.AaveV3ScrollAlpha = __importStar2(require_AaveV3ScrollAlpha()); - exports2.AaveV3Metis = __importStar2(require_AaveV3Metis()); + exports2.AaveGovernanceV2 = __importStar(require_AaveGovernanceV2()); + exports2.AaveSafetyModule = __importStar(require_AaveSafetyModule()); + exports2.AaveV2Ethereum = __importStar(require_AaveV2Ethereum()); + exports2.AaveV3Ethereum = __importStar(require_AaveV3Ethereum()); + exports2.AaveV2EthereumAMM = __importStar(require_AaveV2EthereumAMM()); + exports2.AaveV2EthereumArc = __importStar(require_AaveV2EthereumArc()); + exports2.AaveV2Goerli = __importStar(require_AaveV2Goerli()); + exports2.AaveV3Sepolia = __importStar(require_AaveV3Sepolia()); + exports2.AaveV3Goerli = __importStar(require_AaveV3Goerli()); + exports2.AaveV3GoerliGho = __importStar(require_AaveV3GoerliGho()); + exports2.AaveV2Mumbai = __importStar(require_AaveV2Mumbai()); + exports2.AaveV3Mumbai = __importStar(require_AaveV3Mumbai()); + exports2.AaveV2Polygon = __importStar(require_AaveV2Polygon()); + exports2.AaveV3Polygon = __importStar(require_AaveV3Polygon()); + exports2.AaveV2Fuji = __importStar(require_AaveV2Fuji()); + exports2.AaveV3Fuji = __importStar(require_AaveV3Fuji()); + exports2.AaveV2Avalanche = __importStar(require_AaveV2Avalanche()); + exports2.AaveV3Avalanche = __importStar(require_AaveV3Avalanche()); + exports2.AaveV3Arbitrum = __importStar(require_AaveV3Arbitrum()); + exports2.AaveV3ArbitrumGoerli = __importStar(require_AaveV3ArbitrumGoerli()); + exports2.AaveV3FantomTestnet = __importStar(require_AaveV3FantomTestnet()); + exports2.AaveV3Fantom = __importStar(require_AaveV3Fantom()); + exports2.AaveV3Harmony = __importStar(require_AaveV3Harmony()); + exports2.AaveV3Optimism = __importStar(require_AaveV3Optimism()); + exports2.AaveV3OptimismGoerli = __importStar(require_AaveV3OptimismGoerli()); + exports2.AaveV3ScrollAlpha = __importStar(require_AaveV3ScrollAlpha()); + exports2.AaveV3Metis = __importStar(require_AaveV3Metis()); } }); // node_modules/lodash/lodash.js var require_lodash = __commonJS({ "node_modules/lodash/lodash.js"(exports2, module2) { - "use strict"; (function() { var undefined2; var VERSION = "4.17.21"; @@ -54878,7 +53594,6 @@ var require_lodash = __commonJS({ cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false; var deburredLetters = { - // Latin-1 Supplement block. "\xC0": "A", "\xC1": "A", "\xC2": "A", @@ -54941,7 +53656,6 @@ var require_lodash = __commonJS({ "\xDE": "Th", "\xFE": "th", "\xDF": "ss", - // Latin Extended-A block. "\u0100": "A", "\u0102": "A", "\u0104": "A", @@ -55527,47 +54241,11 @@ var require_lodash = __commonJS({ this.__values__ = undefined2; } lodash2.templateSettings = { - /** - * Used to detect `data` property values to be HTML-escaped. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ "escape": reEscape, - /** - * Used to detect code to be evaluated. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ "evaluate": reEvaluate, - /** - * Used to detect `data` property values to inject. - * - * @memberOf _.templateSettings - * @type {RegExp} - */ "interpolate": reInterpolate, - /** - * Used to reference the data object in the template text. - * - * @memberOf _.templateSettings - * @type {string} - */ "variable": "", - /** - * Used to import variables into the compiled template. - * - * @memberOf _.templateSettings - * @type {Object} - */ "imports": { - /** - * A reference to the `lodash` function. - * - * @memberOf _.templateSettings.imports - * @type {Function} - */ "_": lodash2 } }; @@ -55817,11 +54495,7 @@ var require_lodash = __commonJS({ function arrayLikeKeys(value, inherited) { var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result2 = skipIndexes ? baseTimes(value.length, String2) : [], length = result2.length; for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode. - (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers. - isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays. - isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties. - isIndex(key, length)))) { + if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex(key, length)))) { result2.push(key); } } @@ -60250,7 +58924,6 @@ var require_lodash = __commonJS({ // node_modules/kind-of/index.js var require_kind_of = __commonJS({ "node_modules/kind-of/index.js"(exports2, module2) { - "use strict"; var toString = Object.prototype.toString; module2.exports = function kindOf(val) { if (val === void 0) @@ -61081,7 +59754,6 @@ var require_int = __commonJS({ decimal: function(obj) { return obj.toString(10); }, - /* eslint-disable max-len */ hexadecimal: function(obj) { return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1); } @@ -61104,15 +59776,12 @@ var require_float = __commonJS({ var common = require_common3(); var Type = require_type(); var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers "^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$" ); function resolveYamlFloat(data) { if (data === null) return false; - if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === "_") { + if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") { return false; } return true; @@ -63010,8 +61679,7 @@ var require_dumper = __commonJS({ if (char === CHAR_LINE_FEED) { hasLineBreak = true; if (shouldTrackWidth) { - hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented. - i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "; + hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " "; previousLineBreak = i; } } else if (!isPrintable(char)) { @@ -63905,28 +62573,6 @@ var marketsData = { marketName: "aavev2" } }, - // [CustomMarket.permissioned_market]: { - // marketTitle: 'Ethereum Permissioned Market example', - // chainId: ChainId.mainnet, - // enabledFeatures: { - // // liquiditySwap: true, - // // collateralRepay: true, - // // incentives: true, - // permissions: true, - // }, - // permissionComponent: , - // addresses: { - // LENDING_POOL_ADDRESS_PROVIDER: markets..POOL_ADDRESSES_PROVIDER, - // LENDING_POOL: markets..POOL, - // WETH_GATEWAY: markets..WETH_GATEWAY, - // // REPAY_WITH_COLLATERAL_ADAPTER: markets..REPAY_WITH_COLLATERAL_ADAPTER, - // // SWAP_COLLATERAL_ADAPTER: markets..SWAP_COLLATERAL_ADAPTER, - // WALLET_BALANCE_PROVIDER: markets..WALLET_BALANCE_PROVIDER, - // UI_POOL_DATA_PROVIDER: markets..UI_POOL_DATA_PROVIDER, - // // UI_INCENTIVE_DATA_PROVIDER: markets..UI_INCENTIVE_DATA_PROVIDER, - // PERMISSION_MANAGER: '
', - // }, - // }, ["amm_mainnet" /* amm_mainnet */]: { marketTitle: "Ethereum AMM", chainId: import_contract_helpers2.ChainId.mainnet, @@ -63993,7 +62639,6 @@ var marketsData = { marketName: "aaveavalanche" } }, - // v3 ["proto_sepolia_v3" /* proto_sepolia_v3 */]: { marketTitle: "Ethereum Sepolia", v3: true, @@ -64018,7 +62663,6 @@ var marketsData = { enabledFeatures: { faucet: true }, - // subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-goerli', needs re-deployment addresses: { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3Goerli.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3Goerli.POOL, @@ -64064,7 +62708,6 @@ var marketsData = { faucet: true, incentives: true }, - //subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-arbitrum-goerli', needs re-deployment addresses: { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3ArbitrumGoerli.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3ArbitrumGoerli.POOL, @@ -64110,7 +62753,6 @@ var marketsData = { faucet: true, incentives: true }, - // subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-fuji', needs re-deployment addresses: { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3Fuji.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3Fuji.POOL, @@ -64129,7 +62771,6 @@ var marketsData = { faucet: true, incentives: true }, - // subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-optimism-goerli', needs re-deployment addresses: { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3OptimismGoerli.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3OptimismGoerli.POOL, @@ -64194,7 +62835,6 @@ var marketsData = { faucet: true, incentives: true }, - // subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-fantom-testnet', needs re-deployment addresses: { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3FantomTestnet.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3FantomTestnet.POOL, @@ -64279,7 +62919,6 @@ var marketsData = { incentives: true, faucet: true }, - // subgraphUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v3-mumbai', needs re-deployment addresses: { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3Mumbai.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3Mumbai.POOL, @@ -64356,7 +62995,6 @@ var marketsData = { LENDING_POOL_ADDRESS_PROVIDER: markets.AaveV3Metis.POOL_ADDRESSES_PROVIDER, LENDING_POOL: markets.AaveV3Metis.POOL, WETH_GATEWAY: "0x0", - // not applicable for Metis WALLET_BALANCE_PROVIDER: markets.AaveV3Metis.WALLET_BALANCE_PROVIDER, UI_POOL_DATA_PROVIDER: markets.AaveV3Metis.UI_POOL_DATA_PROVIDER, UI_INCENTIVE_DATA_PROVIDER: markets.AaveV3Metis.UI_INCENTIVE_DATA_PROVIDER, @@ -64380,14 +63018,11 @@ var networkConfigs = { "https://rpc.sepolia.online", "https://www.sepoliarpc.space" ], - // publicJsonRPCWSUrl: 'wss://eth-goerli.public.blastapi.io', - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ETH", wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://sepolia.etherscan.io", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/ethereum.svg" }, @@ -64399,13 +63034,11 @@ var networkConfigs = { "https://goerli.prylabs.net" ], publicJsonRPCWSUrl: "wss://eth-goerli.public.blastapi.io", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ETH", wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://goerli.etherscan.io", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/ethereum.svg" }, @@ -64419,9 +63052,6 @@ var networkConfigs = { "https://cloudflare-eth.com/v1/mainnet" ], publicJsonRPCWSUrl: "wss://eth-mainnet.alchemyapi.io/v2/demo", - // cachingServerUrl: 'https://cache-api-1.aave.com/graphql', - // cachingWSServerUrl: 'wss://cache-api-1.aave.com/graphql', - // protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2', baseUniswapAdapter: "0xc3efa200a60883a96ffe3d5b492b121d6e9a1f3f", baseAssetSymbol: "ETH", wrappedBaseAssetSymbol: "WETH", @@ -64439,9 +63069,6 @@ var networkConfigs = { "https://rpc-mainnet.matic.quiknode.pro" ], publicJsonRPCWSUrl: "wss://polygon-rpc.com", - // cachingServerUrl: 'https://cache-api-137.aave.com/graphql', - // cachingWSServerUrl: 'wss://cache-api-137.aave.com/graphql', - // protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/aave-v2-matic', baseAssetSymbol: "MATIC", wrappedBaseAssetSymbol: "WMATIC", baseAssetDecimals: 18, @@ -64463,7 +63090,6 @@ var networkConfigs = { "https://polygon-mumbai.g.alchemy.com/v2/demo" ], publicJsonRPCWSUrl: "wss://polygon-mumbai.g.alchemy.com/v2/demo", - // protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/aave-v2-polygon-mumbai', baseAssetSymbol: "MATIC", wrappedBaseAssetSymbol: "WMATIC", baseAssetDecimals: 18, @@ -64479,13 +63105,11 @@ var networkConfigs = { "https://ava-testnet.public.blastapi.io/ext/bc/C/rpc" ], publicJsonRPCWSUrl: "wss://api.avax-test.network/ext/bc/C/rpc", - // protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2-fuji', baseUniswapAdapter: "0x0", baseAssetSymbol: "AVAX", wrappedBaseAssetSymbol: "WAVAX", baseAssetDecimals: 18, explorerLink: "https://cchain.explorer.avax-test.network", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/avalanche.svg", bridge: { @@ -64503,15 +63127,11 @@ var networkConfigs = { "https://rpc.ankr.com/avalanche" ], publicJsonRPCWSUrl: "wss://api.avax.network/ext/bc/C/rpc", - // protocolDataUrl: 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2-avalanche', - // cachingServerUrl: 'https://cache-api-43114.aave.com/graphql', - // cachingWSServerUrl: 'wss://cache-api-43114.aave.com/graphql', baseUniswapAdapter: "0x0", baseAssetSymbol: "AVAX", wrappedBaseAssetSymbol: "WAVAX", baseAssetDecimals: 18, explorerLink: "https://cchain.explorer.avax.network", - // usdMarket: true, networkLogoPath: "/icons/networks/avalanche.svg", bridge: { icon: "/icons/bridge/avalanche.svg", @@ -64532,7 +63152,6 @@ var networkConfigs = { wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://goerli.arbiscan.io", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/arbitrum.svg", bridge: { @@ -64549,13 +63168,11 @@ var networkConfigs = { "https://1rpc.io/arb" ], publicJsonRPCWSUrl: "wss://arb1.arbitrum.io/rpc", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ETH", wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://arbiscan.io", - // usdMarket: true, networkLogoPath: "/icons/networks/arbitrum.svg", bridge: { icon: "/icons/bridge/arbitrum.svg", @@ -64573,13 +63190,11 @@ var networkConfigs = { "https://rpc.ankr.com/harmony" ], publicJsonRPCWSUrl: "wss://ws.s0.t.hmny.io", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ONE", wrappedBaseAssetSymbol: "WONE", baseAssetDecimals: 18, explorerLink: "https://explorer.harmony.one", - // usdMarket: true, networkLogoPath: "/icons/networks/harmony.svg", bridge: { icon: "/icons/bridge/harmony.svg", @@ -64597,14 +63212,11 @@ var networkConfigs = { "https://rpc.ankr.com/optimism" ], publicJsonRPCWSUrl: "wss://optimism-mainnet.public.blastapi.io", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ETH", - // OETH wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://optimistic.etherscan.io", - // usdMarket: true, networkLogoPath: "/icons/networks/optimism.svg", bridge: { icon: "/icons/bridge/optimism.svg", @@ -64617,20 +63229,13 @@ var networkConfigs = { name: "Optimism G\xF6rli", publicJsonRPCUrl: ["https://goerli.optimism.io", "https://opt-goerli.g.alchemy.com/v2/demo"], publicJsonRPCWSUrl: "wss://goerli.optimism.io", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ETH", wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://l2-explorer.surge.sh", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/optimism.svg" - // bridge: { - // icon: '/icons/bridge/optimism.svg', - // name: 'Optimism Bridge', - // url: 'https://app.optimism.io/bridge', - // }, }, [import_contract_helpers3.ChainId.scroll_alpha]: { name: "Scroll Alpha", @@ -64639,20 +63244,13 @@ var networkConfigs = { "https://scroll-alphanet.public.blastapi.io" ], publicJsonRPCWSUrl: "wss://scroll-alphanet.public.blastapi.io", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "ETH", wrappedBaseAssetSymbol: "WETH", baseAssetDecimals: 18, explorerLink: "https://blockscout.scroll.io", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/scroll.svg" - // bridge: { - // icon: '/icons/bridge/scroll.svg', - // name: 'Scroll Alpha Bridge', - // url: 'https://scroll.io/alpha/bridge', - // }, }, [import_contract_helpers3.ChainId.fantom]: { name: "Fantom", @@ -64662,14 +63260,11 @@ var networkConfigs = { "https://rpc.ankr.com/fantom", "https://fantom-mainnet.public.blastapi.io" ], - // publicJsonRPCWSUrl: 'wss://wsapi.fantom.network', - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "FTM", wrappedBaseAssetSymbol: "WFTM", baseAssetDecimals: 18, explorerLink: "https://ftmscan.com", - // usdMarket: true, networkLogoPath: "/icons/networks/fantom.svg", bridge: { icon: "/icons/bridge/fantom.svg", @@ -64686,13 +63281,11 @@ var networkConfigs = { "https://rpc.ankr.com/fantom_testnet" ], publicJsonRPCWSUrl: "", - // protocolDataUrl: '', baseUniswapAdapter: "0x0", baseAssetSymbol: "FTM", wrappedBaseAssetSymbol: "WFTM", baseAssetDecimals: 18, explorerLink: "https://testnet.ftmscan.com", - // usdMarket: true, isTestnet: true, networkLogoPath: "/icons/networks/fantom.svg", bridge: { @@ -64706,11 +63299,8 @@ var networkConfigs = { privateJsonRPCUrl: "https://metis-mainnet.gateway.pokt.network/v1/lb/62b3314e123e6f00397f19ca", publicJsonRPCUrl: ["https://andromeda.metis.io/?owner=1088"], baseAssetSymbol: "", - // N/A wrappedBaseAssetSymbol: "", - // N/A baseAssetDecimals: 0, - // N/A explorerLink: "https://andromeda-explorer.metis.io", networkLogoPath: "/icons/networks/metis.svg" } @@ -64753,7 +63343,6 @@ var RotationProvider = class extends import_providers.BaseProvider { super(chainId); this.currentProviderIndex = 0; this.firstRotationTimestamp = 0; - // number of full loops through provider array before throwing an error this.maxRetries = 0; this.retries = 0; this.lastError = ""; @@ -64761,12 +63350,9 @@ var RotationProvider = class extends import_providers.BaseProvider { this.maxRetries = (config == null ? void 0 : config.maxRetries) || MAX_RETRIES; this.fallForwardDelay = (config == null ? void 0 : config.fallFowardDelay) || DEFAULT_FALL_FORWARD_DELAY; } - /** - * If we rotate away from the first RPC, rotate back after a set interval to prioritize using most reliable RPC - */ fallForwardRotation() { return __async(this, null, function* () { - const now = (/* @__PURE__ */ new Date()).getTime(); + const now = new Date().getTime(); const diff = now - this.firstRotationTimestamp; if (diff < this.fallForwardDelay) { yield sleep(this.fallForwardDelay - diff); @@ -64774,17 +63360,13 @@ var RotationProvider = class extends import_providers.BaseProvider { } }); } - /** - * If rpc fails, rotate to next available and trigger rotation or fall forward delay where applicable - * @param prevIndex last updated index, checked to avoid having multiple active rotations - */ rotateUrl(prevIndex) { return __async(this, null, function* () { if (prevIndex !== this.currentProviderIndex) return; if (this.currentProviderIndex === 0) { this.currentProviderIndex += 1; - this.firstRotationTimestamp = (/* @__PURE__ */ new Date()).getTime(); + this.firstRotationTimestamp = new Date().getTime(); this.fallForwardRotation(); } else if (this.currentProviderIndex === this.providers.length - 1) { this.retries += 1; @@ -64806,7 +63388,6 @@ var RotationProvider = class extends import_providers.BaseProvider { return checkNetworks(networks); }); } - // eslint-disable-next-line perform(method, params) { return __async(this, null, function* () { const index = this.currentProviderIndex; @@ -64994,7 +63575,7 @@ var import_lodash = __toESM(require_lodash()); // node_modules/steno/lib/index.js var import_fs = __toESM(require("fs"), 1); -var __classPrivateFieldSet2 = function(receiver, state, value, kind, f) { +var __classPrivateFieldSet = function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) @@ -65003,7 +63584,7 @@ var __classPrivateFieldSet2 = function(receiver, state, value, kind, f) { throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; -var __classPrivateFieldGet2 = function(receiver, state, kind, f) { +var __classPrivateFieldGet = function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) @@ -65021,33 +63602,32 @@ var _Writer_nextData; var _Writer_add; var _Writer_write; _Writer_filename = /* @__PURE__ */ new WeakMap(), _Writer_tempFilename = /* @__PURE__ */ new WeakMap(), _Writer_locked = /* @__PURE__ */ new WeakMap(), _Writer_prev = /* @__PURE__ */ new WeakMap(), _Writer_next = /* @__PURE__ */ new WeakMap(), _Writer_nextPromise = /* @__PURE__ */ new WeakMap(), _Writer_nextData = /* @__PURE__ */ new WeakMap(), _Writer_instances = /* @__PURE__ */ new WeakSet(), _Writer_add = function _Writer_add2(data) { - __classPrivateFieldSet2(this, _Writer_nextData, data, "f"); - __classPrivateFieldSet2(this, _Writer_nextPromise, __classPrivateFieldGet2(this, _Writer_nextPromise, "f") || new Promise((resolve, reject) => { - __classPrivateFieldSet2(this, _Writer_next, [resolve, reject], "f"); + __classPrivateFieldSet(this, _Writer_nextData, data, "f"); + __classPrivateFieldSet(this, _Writer_nextPromise, __classPrivateFieldGet(this, _Writer_nextPromise, "f") || new Promise((resolve, reject) => { + __classPrivateFieldSet(this, _Writer_next, [resolve, reject], "f"); }), "f"); return new Promise((resolve, reject) => { var _a7; - (_a7 = __classPrivateFieldGet2(this, _Writer_nextPromise, "f")) === null || _a7 === void 0 ? void 0 : _a7.then(resolve).catch(reject); + (_a7 = __classPrivateFieldGet(this, _Writer_nextPromise, "f")) === null || _a7 === void 0 ? void 0 : _a7.then(resolve).catch(reject); }); -}, _Writer_write = // File isn't locked, write data -function _Writer_write2(data) { +}, _Writer_write = function _Writer_write2(data) { return __async(this, null, function* () { var _a7, _b; - __classPrivateFieldSet2(this, _Writer_locked, true, "f"); + __classPrivateFieldSet(this, _Writer_locked, true, "f"); try { - yield import_fs.default.promises.writeFile(__classPrivateFieldGet2(this, _Writer_tempFilename, "f"), data, "utf-8"); - yield import_fs.default.promises.rename(__classPrivateFieldGet2(this, _Writer_tempFilename, "f"), __classPrivateFieldGet2(this, _Writer_filename, "f")); - (_a7 = __classPrivateFieldGet2(this, _Writer_prev, "f")) === null || _a7 === void 0 ? void 0 : _a7[0](); + yield import_fs.default.promises.writeFile(__classPrivateFieldGet(this, _Writer_tempFilename, "f"), data, "utf-8"); + yield import_fs.default.promises.rename(__classPrivateFieldGet(this, _Writer_tempFilename, "f"), __classPrivateFieldGet(this, _Writer_filename, "f")); + (_a7 = __classPrivateFieldGet(this, _Writer_prev, "f")) === null || _a7 === void 0 ? void 0 : _a7[0](); } catch (err) { - (_b = __classPrivateFieldGet2(this, _Writer_prev, "f")) === null || _b === void 0 ? void 0 : _b[1](err); + (_b = __classPrivateFieldGet(this, _Writer_prev, "f")) === null || _b === void 0 ? void 0 : _b[1](err); throw err; } finally { - __classPrivateFieldSet2(this, _Writer_locked, false, "f"); - __classPrivateFieldSet2(this, _Writer_prev, __classPrivateFieldGet2(this, _Writer_next, "f"), "f"); - __classPrivateFieldSet2(this, _Writer_next, __classPrivateFieldSet2(this, _Writer_nextPromise, null, "f"), "f"); - if (__classPrivateFieldGet2(this, _Writer_nextData, "f") !== null) { - const nextData = __classPrivateFieldGet2(this, _Writer_nextData, "f"); - __classPrivateFieldSet2(this, _Writer_nextData, null, "f"); + __classPrivateFieldSet(this, _Writer_locked, false, "f"); + __classPrivateFieldSet(this, _Writer_prev, __classPrivateFieldGet(this, _Writer_next, "f"), "f"); + __classPrivateFieldSet(this, _Writer_next, __classPrivateFieldSet(this, _Writer_nextPromise, null, "f"), "f"); + if (__classPrivateFieldGet(this, _Writer_nextData, "f") !== null) { + const nextData = __classPrivateFieldGet(this, _Writer_nextData, "f"); + __classPrivateFieldSet(this, _Writer_nextData, null, "f"); yield this.write(nextData); } } @@ -65066,7 +63646,7 @@ _JSONFile_adapter = /* @__PURE__ */ new WeakMap(); // node_modules/lowdb/lib/adapters/TextFileSync.js var import_fs2 = __toESM(require("fs"), 1); var import_path = __toESM(require("path"), 1); -var __classPrivateFieldSet3 = function(receiver, state, value, kind, f) { +var __classPrivateFieldSet2 = function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) @@ -65075,7 +63655,7 @@ var __classPrivateFieldSet3 = function(receiver, state, value, kind, f) { throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; -var __classPrivateFieldGet3 = function(receiver, state, kind, f) { +var __classPrivateFieldGet2 = function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) @@ -65088,13 +63668,13 @@ var TextFileSync = class { constructor(filename) { _TextFileSync_tempFilename.set(this, void 0); _TextFileSync_filename.set(this, void 0); - __classPrivateFieldSet3(this, _TextFileSync_filename, filename, "f"); - __classPrivateFieldSet3(this, _TextFileSync_tempFilename, import_path.default.join(import_path.default.dirname(filename), `.${import_path.default.basename(filename)}.tmp`), "f"); + __classPrivateFieldSet2(this, _TextFileSync_filename, filename, "f"); + __classPrivateFieldSet2(this, _TextFileSync_tempFilename, import_path.default.join(import_path.default.dirname(filename), `.${import_path.default.basename(filename)}.tmp`), "f"); } read() { let data; try { - data = import_fs2.default.readFileSync(__classPrivateFieldGet3(this, _TextFileSync_filename, "f"), "utf-8"); + data = import_fs2.default.readFileSync(__classPrivateFieldGet2(this, _TextFileSync_filename, "f"), "utf-8"); } catch (e) { if (e.code === "ENOENT") { return null; @@ -65104,14 +63684,14 @@ var TextFileSync = class { return data; } write(str2) { - import_fs2.default.writeFileSync(__classPrivateFieldGet3(this, _TextFileSync_tempFilename, "f"), str2); - import_fs2.default.renameSync(__classPrivateFieldGet3(this, _TextFileSync_tempFilename, "f"), __classPrivateFieldGet3(this, _TextFileSync_filename, "f")); + import_fs2.default.writeFileSync(__classPrivateFieldGet2(this, _TextFileSync_tempFilename, "f"), str2); + import_fs2.default.renameSync(__classPrivateFieldGet2(this, _TextFileSync_tempFilename, "f"), __classPrivateFieldGet2(this, _TextFileSync_filename, "f")); } }; _TextFileSync_tempFilename = /* @__PURE__ */ new WeakMap(), _TextFileSync_filename = /* @__PURE__ */ new WeakMap(); // node_modules/lowdb/lib/adapters/JSONFileSync.js -var __classPrivateFieldSet4 = function(receiver, state, value, kind, f) { +var __classPrivateFieldSet3 = function(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) @@ -65120,7 +63700,7 @@ var __classPrivateFieldSet4 = function(receiver, state, value, kind, f) { throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; }; -var __classPrivateFieldGet4 = function(receiver, state, kind, f) { +var __classPrivateFieldGet3 = function(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) @@ -65131,10 +63711,10 @@ var _JSONFileSync_adapter; var JSONFileSync = class { constructor(filename) { _JSONFileSync_adapter.set(this, void 0); - __classPrivateFieldSet4(this, _JSONFileSync_adapter, new TextFileSync(filename), "f"); + __classPrivateFieldSet3(this, _JSONFileSync_adapter, new TextFileSync(filename), "f"); } read() { - const data = __classPrivateFieldGet4(this, _JSONFileSync_adapter, "f").read(); + const data = __classPrivateFieldGet3(this, _JSONFileSync_adapter, "f").read(); if (data === null) { return null; } else { @@ -65142,7 +63722,7 @@ var JSONFileSync = class { } } write(obj) { - __classPrivateFieldGet4(this, _JSONFileSync_adapter, "f").write(JSON.stringify(obj, null, 2)); + __classPrivateFieldGet3(this, _JSONFileSync_adapter, "f").write(JSON.stringify(obj, null, 2)); } }; _JSONFileSync_adapter = /* @__PURE__ */ new WeakMap(); @@ -65396,73 +63976,59 @@ populateCache().then(() => console.log("finished")); 0 && (module.exports = { populateCache }); -/*! Bundled license information: - -tslib/tslib.es6.js: - (*! ***************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** *) - -js-sha3/src/sha3.js: - (** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.8.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2018 - * @license MIT - *) - -reflect-metadata/Reflect.js: - (*! ***************************************************************************** - Copyright (C) Microsoft. All rights reserved. - Licensed under the Apache License, Version 2.0 (the "License"); you may not use - this file except in compliance with the License. You may obtain a copy of the - License at http://www.apache.org/licenses/LICENSE-2.0 - - THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED - WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, - MERCHANTABLITY OR NON-INFRINGEMENT. - - See the Apache Version 2.0 License for specific language governing permissions - and limitations under the License. - ***************************************************************************** *) - -lodash/lodash.js: - (** - * @license - * Lodash - * Copyright OpenJS Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - *) - -is-extendable/index.js: - (*! - * is-extendable - * - * Copyright (c) 2015, Jon Schlinkert. - * Licensed under the MIT License. - *) - -strip-bom-string/index.js: - (*! - * strip-bom-string - * - * Copyright (c) 2015, 2017, Jon Schlinkert. - * Released under the MIT License. - *) -*/ +/*! + * is-extendable + * + * Copyright (c) 2015, Jon Schlinkert. + * Licensed under the MIT License. + */ +/*! + * strip-bom-string + * + * Copyright (c) 2015, 2017, Jon Schlinkert. + * Released under the MIT License. + */ +/*! ***************************************************************************** +Copyright (C) Microsoft. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/** + * @license + * Lodash + * Copyright OpenJS Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.8.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2018 + * @license MIT + */ diff --git a/src/components/Analytics/AnalyticsConsent.tsx b/src/components/Analytics/AnalyticsConsent.tsx new file mode 100644 index 0000000000..c59f74a2b9 --- /dev/null +++ b/src/components/Analytics/AnalyticsConsent.tsx @@ -0,0 +1,127 @@ +import { Box, Typography, useMediaQuery, useTheme } from '@mui/material'; +import React, { useEffect, useState } from 'react'; +import { CookieConsent as AnalyticsConsentBanner } from 'react-cookie-consent'; +import { Link } from 'src/components/primitives/Link'; +import { useRootStore } from 'src/store/root'; + +export default function AnalyticsBanner() { + const [optInAnalytics, optOutAnalytics, analyticsConfigOpen] = useRootStore((store) => [ + store.acceptAnalytics, + store.rejectAnalytics, + store.analyticsConfigOpen, + ]); + + const [bannerVisible, setBannerVisible] = useState(false); + + useEffect(() => { + // Adds a delay before showing the banner. + const timerId = setTimeout(() => { + setBannerVisible(true); + }, 1000); // Start sliding in after 1 second. + + return () => clearTimeout(timerId); + }, []); + + const theme = useTheme(); + + const { breakpoints } = useTheme(); + const isMobile = useMediaQuery(breakpoints.down('sm')); + + const hasUserMadeChoice = + typeof window !== 'undefined' && localStorage.getItem('userAcceptedAnalytics') !== null; + + // Note: If they have already chosen don't show again unless configured from footer + if (hasUserMadeChoice) return null; + + return ( + <> + Allow analytics } + declineButtonText={Opt-out} + disableStyles={true} + visible={analyticsConfigOpen ? 'show' : 'hidden'} + flipButtons + style={{ + background: theme.palette.background.paper, + bottom: isMobile ? '24px' : '24px', + right: isMobile ? '50%' : '24px', + left: isMobile ? '50%' : 'auto', + position: 'fixed', + width: '400px', + // height: '184px', + gap: '16px', + display: 'flex', + flexDirection: 'column', + flexFlow: 'column', + justifyContent: 'space-between', + alignItems: 'center', + color: theme.palette.text.primary, + marginBottom: '16px', + fontSize: '14px', + lineHeight: '20.02px', + padding: '16px 16px', + zIndex: 100, + borderRadius: '12px', + border: '0.5px solid rgba(235, 235, 239, 0.42)', + boxShadow: '0px 0px 2px rgba(0, 0, 0, 0.2), 0px 2px 10px rgba(0, 0, 0, 0.1)', + transition: 'transform 0.5s ease-out', // Add this + + transform: bannerVisible + ? isMobile + ? 'translateX(-50%)' + : 'none' + : 'translateX(100%) translateY(100%)', + }} + buttonStyle={{ + background: theme.palette.mode === 'dark' ? '#F7F7F9' : '#383D51', + color: theme.palette.mode === 'dark' ? '#383D51' : '#F7F7F9', + + fontSize: '14px', + borderRadius: '4px', + margin: '0px', + border: '1px solid #000', + width: '172px', + height: '36px', + fontWeight: '700', + cursor: 'pointer', + }} + declineButtonStyle={{ + // background: '#F7F7F9', + background: theme.palette.mode === 'dark' ? '#383D51' : '#F7F7F9', + color: theme.palette.mode === 'dark' ? '#EAEBEF' : '#383D51', + + fontFamily: 'Inter', + fontWeight: '500', + lineHeight: '24px', + fontSize: '14px', + borderRadius: '4px', + margin: '10px', + // padding: '10px 20px', + border: `1px solid ${theme.palette.mode === 'dark' ? '#383D51' : '#EAEBEF'}`, + width: '172px', + height: '36px', + // padding: '0px', + cursor: 'pointer', + }} + enableDeclineButton + onDecline={() => { + optOutAnalytics(); + }} + onAccept={() => { + optInAnalytics(); + }} + cookieName="userAcceptedAnalytics" + > + + We may employ on-the-spot tracking techniques during your browsing session to collect data + on your interactions, preferences, and behaviour. This data helps us personalise your + experience and improve our services. See our + + {' '} + Privacy Policy. + + + + + ); +} diff --git a/src/components/ConnectWalletPaperStaking.tsx b/src/components/ConnectWalletPaperStaking.tsx index a4af4ca58e..b35a275c17 100644 --- a/src/components/ConnectWalletPaperStaking.tsx +++ b/src/components/ConnectWalletPaperStaking.tsx @@ -45,7 +45,7 @@ export const ConnectWalletPaperStaking = ({ )} - + diff --git a/src/components/HALLink.tsx b/src/components/HALLink.tsx index 88fe1458d8..298473b205 100644 --- a/src/components/HALLink.tsx +++ b/src/components/HALLink.tsx @@ -13,6 +13,8 @@ import { } from '@mui/material'; import BigNumber from 'bignumber.js'; import { useMemo } from 'react'; +import { useRootStore } from 'src/store/root'; +import { DASHBOARD } from 'src/utils/mixPanelEvents'; import Hal from '/public/icons/healthFactor/HAL.svg'; import HalHover from '/public/icons/healthFactor/HALHover.svg'; @@ -54,6 +56,7 @@ interface Props { export default function HALLink({ healthFactor, marketName, integrationURL }: Props) { const { currentAccount } = useWeb3Context(); + const trackEvent = useRootStore((store) => store.trackEvent); const urlString = useMemo(() => { const formattedHealthFactor = valueToBigNumber(healthFactor).toFixed(2, BigNumber.ROUND_DOWN); @@ -105,6 +108,12 @@ export default function HALLink({ healthFactor, marketName, integrationURL }: Pr target="_blank" rel="noopener" component={Link} + onClick={() => + trackEvent(DASHBOARD.NOTIFY_DASHBOARD, { + market: marketName, + healthFactor: healthFactor, + }) + } sx={{ pl: 6, position: 'relative', diff --git a/src/components/MarketSwitcher.tsx b/src/components/MarketSwitcher.tsx index 81142bdfb7..0472cf88fb 100644 --- a/src/components/MarketSwitcher.tsx +++ b/src/components/MarketSwitcher.tsx @@ -12,7 +12,9 @@ import { useTheme, } from '@mui/material'; import React, { useState } from 'react'; +import { useRootStore } from 'src/store/root'; import { BaseNetworkConfig } from 'src/ui-config/networksConfig'; +import { DASHBOARD } from 'src/utils/mixPanelEvents'; import { useProtocolDataContext } from '../hooks/useProtocolDataContext'; import { @@ -112,6 +114,7 @@ export const MarketSwitcher = () => { const theme = useTheme(); const upToLG = useMediaQuery(theme.breakpoints.up('lg')); const downToXSM = useMediaQuery(theme.breakpoints.down('xsm')); + const trackEvent = useRootStore((store) => store.trackEvent); const isV3MarketsAvailable = availableMarkets .map((marketId: CustomMarket) => { @@ -121,13 +124,18 @@ export const MarketSwitcher = () => { }) .some((item) => !!item); + const handleMarketSelect = (e: React.ChangeEvent) => { + trackEvent(DASHBOARD.CHANGE_MARKET, { market: e.target.value }); + setCurrentMarket(e.target.value as unknown as CustomMarket); + }; + return ( setCurrentMarket(e.target.value as unknown as CustomMarket)} + onChange={handleMarketSelect} sx={{ mr: 2, '& .MuiOutlinedInput-notchedOutline': { diff --git a/src/components/TextWithTooltip.tsx b/src/components/TextWithTooltip.tsx index a59e363a5e..41922bac89 100644 --- a/src/components/TextWithTooltip.tsx +++ b/src/components/TextWithTooltip.tsx @@ -2,6 +2,8 @@ import { InformationCircleIcon } from '@heroicons/react/outline'; import { Box, BoxProps, IconButton, SvgIcon, Typography } from '@mui/material'; import { TypographyProps } from '@mui/material/Typography'; import { JSXElementConstructor, ReactElement, ReactNode, useState } from 'react'; +import { TrackEventProps } from 'src/store/analyticsSlice'; +import { useRootStore } from 'src/store/root'; import { ContentWithTooltip } from './ContentWithTooltip'; @@ -15,6 +17,7 @@ export interface TextWithTooltipProps extends TypographyProps { // eslint-disable-next-line children?: ReactElement>; wrapperProps?: BoxProps; + event?: TrackEventProps; } export const TextWithTooltip = ({ @@ -26,9 +29,11 @@ export const TextWithTooltip = ({ children, textColor, wrapperProps: { sx: boxSx, ...boxRest } = {}, + event, ...rest }: TextWithTooltipProps) => { const [open, setOpen] = useState(false); + const trackEvent = useRootStore((store) => store.trackEvent); return ( {text && ( @@ -50,6 +55,11 @@ export const TextWithTooltip = ({ minWidth: 0, ml: iconMargin || 0.5, }} + onClick={() => { + if (event) { + trackEvent(event.eventName, { ...event.eventParams }); + } + }} > { + const [postedTransactions, setPostedTransactions] = useState<{ [chainId: string]: string[] }>({}); + + const { trackEvent } = useRootStore(); + const successfulTransactions = useRootStore(selectSuccessfulTransactions); + + const actionToEvent = (action: ProtocolAction) => { + switch (action) { + case ProtocolAction.supply: + return SUPPLY_MODAL.SUPPLY_TOKEN; + case ProtocolAction.supplyWithPermit: + return SUPPLY_MODAL.SUPPLY_WITH_PERMIT; + case ProtocolAction.borrow: + return BORROW_MODAL.BORROW_TOKEN; + case ProtocolAction.repay: + return REPAY_MODAL.REPAY_TOKEN; + default: + return ''; + } + }; + + useEffect(() => { + Object.keys(successfulTransactions).forEach((chainId) => { + const chainIdNumber = +chainId; + Object.keys(successfulTransactions[chainIdNumber]).forEach((txHash) => { + if (!postedTransactions[chainIdNumber]?.includes(txHash)) { + const tx = successfulTransactions[chainIdNumber][txHash]; + + const event = actionToEvent(tx.action); + trackEvent(event, { + amount: tx.amount, + asset: tx.asset, + market: tx.market, + }); + + // update local state + if (postedTransactions[chainIdNumber]) { + setPostedTransactions((prev) => ({ + ...prev, + [chainIdNumber]: [...prev[chainIdNumber], txHash], + })); + } else { + setPostedTransactions((prev) => ({ + ...prev, + [+chainId]: [txHash], + })); + } + } + }); + }); + }, [trackEvent, postedTransactions, successfulTransactions]); + + return null; +}; diff --git a/src/components/UserDisplay.tsx b/src/components/UserDisplay.tsx index 7b17c28434..d5e9b83f5e 100644 --- a/src/components/UserDisplay.tsx +++ b/src/components/UserDisplay.tsx @@ -16,6 +16,7 @@ type UserDisplayProps = { titleProps?: Omit; subtitleProps?: Omit; withLink?: boolean; + funnel?: string; }; export const UserDisplay: React.FC = ({ @@ -24,6 +25,7 @@ export const UserDisplay: React.FC = ({ titleProps, subtitleProps, withLink, + funnel, }) => { const { account, defaultDomain, domainsLoading, accountLoading } = useRootStore( (state) => ({ @@ -56,6 +58,7 @@ export const UserDisplay: React.FC = ({ domainName={defaultDomain.name} variant="h4" link={withLink ? `https://etherscan.io/address/${account}` : undefined} + funnel={funnel} {...titleProps} /> = ({ loading={loading} variant="h4" link={withLink ? `https://etherscan.io/address/${account}` : undefined} + funnel={funnel} {...titleProps} /> )} @@ -104,6 +108,7 @@ export const ExternalUserDisplay: React.FC = ({ link={`https://etherscan.io/address/${address}`} iconSize={14} {...titleProps} + funnel={'Delegation power panel: Governance'} /> ); diff --git a/src/components/UserNameText.tsx b/src/components/UserNameText.tsx index bc8c57ee6a..276f7be672 100644 --- a/src/components/UserNameText.tsx +++ b/src/components/UserNameText.tsx @@ -1,5 +1,7 @@ import { ExternalLinkIcon } from '@heroicons/react/solid'; import { Box, Link, SvgIcon, TypographyProps } from '@mui/material'; +import { useRootStore } from 'src/store/root'; +import { GENERAL } from 'src/utils/mixPanelEvents'; import { CompactableTypography, CompactMode } from './CompactableTypography'; import { DarkTooltip } from './infoTooltips/DarkTooltip'; @@ -12,6 +14,7 @@ export interface UserNameTextProps extends TypographyProps { address: string; link?: string; iconSize?: number; + funnel?: string; } export const UserNameText: React.FC = ({ @@ -22,11 +25,13 @@ export const UserNameText: React.FC = ({ address, link, iconSize = 16, + funnel, ...rest }) => { const isDomainNameLong = Boolean(domainName && domainName?.length > 18); const shouldCompact = !domainName || isDomainNameLong; + const trackEvent = useRootStore((store) => store.trackEvent); return ( @@ -40,7 +45,12 @@ export const UserNameText: React.FC = ({ {link && ( - + trackEvent(GENERAL.EXTERNAL_LINK, { funnel: funnel, Link: 'Etherscan' })} + > diff --git a/src/components/WalletConnection/ConnectWalletButton.tsx b/src/components/WalletConnection/ConnectWalletButton.tsx index 176981a3de..694a9d090a 100644 --- a/src/components/WalletConnection/ConnectWalletButton.tsx +++ b/src/components/WalletConnection/ConnectWalletButton.tsx @@ -1,15 +1,28 @@ import { Trans } from '@lingui/macro'; import { Button } from '@mui/material'; import { useWalletModalContext } from 'src/hooks/useWalletModal'; +import { useRootStore } from 'src/store/root'; +import { AUTH } from 'src/utils/mixPanelEvents'; import { WalletModal } from './WalletModal'; -export const ConnectWalletButton = () => { +export interface ConnectWalletProps { + funnel?: string; +} + +export const ConnectWalletButton: React.FC = ({ funnel }) => { const { setWalletModalOpen } = useWalletModalContext(); + const trackEvent = useRootStore((store) => store.trackEvent); return ( <> - diff --git a/src/components/WalletConnection/WalletSelector.tsx b/src/components/WalletConnection/WalletSelector.tsx index c117588236..b2c70693a2 100644 --- a/src/components/WalletConnection/WalletSelector.tsx +++ b/src/components/WalletConnection/WalletSelector.tsx @@ -8,7 +8,9 @@ import { useEffect, useState } from 'react'; import { ReadOnlyModeTooltip } from 'src/components/infoTooltips/ReadOnlyModeTooltip'; import { useWeb3Context } from 'src/libs/hooks/useWeb3Context'; import { WalletType } from 'src/libs/web3-data-provider/WalletOptions'; +import { useRootStore } from 'src/store/root'; import { getENSProvider } from 'src/utils/marketsAndNetworksConfig'; +import { AUTH } from 'src/utils/mixPanelEvents'; import { Warning } from '../primitives/Warning'; import { TxModalTitle } from '../transactions/FlowCommons/TxModalTitle'; @@ -17,9 +19,9 @@ export type WalletRowProps = { walletName: string; walletType: WalletType; }; - const WalletRow = ({ walletName, walletType }: WalletRowProps) => { const { connectWallet } = useWeb3Context(); + const trackEvent = useRootStore((store) => store.trackEvent); const getWalletIcon = (walletType: WalletType) => { switch (walletType) { @@ -73,6 +75,10 @@ const WalletRow = ({ walletName, walletType }: WalletRowProps) => { } }; + const connectWalletClick = () => { + trackEvent(AUTH.CONNECT_WALLET, { walletType: walletType, walletName: walletName }); + connectWallet(walletType); + }; return ( @@ -80,6 +84,13 @@ export const BorrowAssetsListItem = ({ variant="outlined" component={Link} href={ROUTES.reserveOverview(underlyingAsset, currentMarket)} + onClick={() => { + trackEvent(DASHBOARD.DETAILS_BUTTON_DASHBOARD, { + market: currentMarket, + assetName: name, + asset: underlyingAsset, + }); + }} > Details diff --git a/src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsListMobileItem.tsx b/src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsListMobileItem.tsx index 508d3dcb0f..4eeb27a3c8 100644 --- a/src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsListMobileItem.tsx +++ b/src/modules/dashboard/lists/BorrowAssetsList/BorrowAssetsListMobileItem.tsx @@ -101,7 +101,7 @@ export const BorrowAssetsListMobileItem = ({ diff --git a/src/modules/dashboard/lists/BorrowedPositionsList/BorrowedPositionsListMobileItem.tsx b/src/modules/dashboard/lists/BorrowedPositionsList/BorrowedPositionsListMobileItem.tsx index 980d8f9167..78e33f1f20 100644 --- a/src/modules/dashboard/lists/BorrowedPositionsList/BorrowedPositionsListMobileItem.tsx +++ b/src/modules/dashboard/lists/BorrowedPositionsList/BorrowedPositionsListMobileItem.tsx @@ -100,7 +100,9 @@ export const BorrowedPositionsListMobileItem = ({ @@ -89,7 +102,16 @@ export const SuppliedPositionsListItem = ({ diff --git a/src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx b/src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx index 6402c69c00..d55cc6837a 100644 --- a/src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx +++ b/src/modules/dashboard/lists/SuppliedPositionsList/SuppliedPositionsListMobileItem.tsx @@ -81,7 +81,15 @@ export const SuppliedPositionsListMobileItem = ({ isIsolated={isIsolated} usageAsCollateralEnabledOnUser={usageAsCollateralEnabledOnUser} canBeEnabledAsCollateral={canBeEnabledAsCollateral} - onToggleSwitch={() => openCollateralChange(underlyingAsset)} + onToggleSwitch={() => + openCollateralChange( + underlyingAsset, + currentMarket, + reserve.name, + 'dashboard', + usageAsCollateralEnabledOnUser + ) + } /> @@ -89,13 +97,12 @@ export const SuppliedPositionsListMobileItem = ({ - {isSwapButton ? ( @@ -93,6 +98,13 @@ export const SupplyAssetsListItem = ({ variant="outlined" component={Link} href={ROUTES.reserveOverview(detailsAddress, currentMarket)} + onClick={() => { + trackEvent(DASHBOARD.DETAILS_BUTTON_DASHBOARD, { + market: currentMarket, + assetName: name, + asset: underlyingAsset, + }); + }} > Details diff --git a/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx b/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx index b56b350de7..6e2076bf9b 100644 --- a/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx +++ b/src/modules/dashboard/lists/SupplyAssetsList/SupplyAssetsListMobileItem.tsx @@ -94,7 +94,7 @@ export const SupplyAssetsListMobileItem = ({ diff --git a/src/modules/markets/MarketAssetsListMobileItem.tsx b/src/modules/markets/MarketAssetsListMobileItem.tsx index f621caa0a1..a861f0ed22 100644 --- a/src/modules/markets/MarketAssetsListMobileItem.tsx +++ b/src/modules/markets/MarketAssetsListMobileItem.tsx @@ -5,6 +5,8 @@ import { VariableAPYTooltip } from 'src/components/infoTooltips/VariableAPYToolt import { NoData } from 'src/components/primitives/NoData'; import { ReserveSubheader } from 'src/components/ReserveSubheader'; import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext'; +import { useRootStore } from 'src/store/root'; +import { MARKETS } from 'src/utils/mixPanelEvents'; import { IncentivesCard } from '../../components/incentives/IncentivesCard'; import { FormattedNumber } from '../../components/primitives/FormattedNumber'; @@ -15,6 +17,8 @@ import { ListMobileItemWrapper } from '../dashboard/lists/ListMobileItemWrapper' export const MarketAssetsListMobileItem = ({ ...reserve }: ComputedReserveData) => { const { currentMarket } = useProtocolDataContext(); + const trackEvent = useRootStore((store) => store.trackEvent); + return ( { + trackEvent(MARKETS.DETAILS_BUTTON, { + asset: reserve.underlyingAsset, + market: currentMarket, + assetName: reserve.name, + }); + }} > View details diff --git a/src/modules/reserve-overview/AddTokenDropdown.tsx b/src/modules/reserve-overview/AddTokenDropdown.tsx index 7039dadfef..c80688a4ec 100644 --- a/src/modules/reserve-overview/AddTokenDropdown.tsx +++ b/src/modules/reserve-overview/AddTokenDropdown.tsx @@ -7,6 +7,8 @@ import { WalletIcon } from 'src/components/icons/WalletIcon'; import { Base64Token, TokenIcon } from 'src/components/primitives/TokenIcon'; import { ComputedReserveData } from 'src/hooks/app-data-provider/useAppDataProvider'; import { ERC20TokenType } from 'src/libs/web3-data-provider/Web3Provider'; +import { useRootStore } from 'src/store/root'; +import { RESERVE_DETAILS } from 'src/utils/mixPanelEvents'; interface AddTokenDropdownProps { poolReserve: ComputedReserveData; @@ -30,6 +32,8 @@ export const AddTokenDropdown = ({ const [underlyingBase64, setUnderlyingBase64] = useState(''); const [aTokenBase64, setATokenBase64] = useState(''); const open = Boolean(anchorEl); + const trackEvent = useRootStore((store) => store.trackEvent); + const handleClick = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; @@ -80,6 +84,12 @@ export const AddTokenDropdown = ({ { + trackEvent(RESERVE_DETAILS.ADD_TOKEN_TO_WALLET_DROPDOWN, { + asset: poolReserve.underlyingAsset, + assetName: poolReserve.name, + }); + }} sx={{ display: 'inline-flex', alignItems: 'center', @@ -120,6 +130,11 @@ export const AddTokenDropdown = ({ setChangingNetwork(true); }); } else { + trackEvent(RESERVE_DETAILS.ADD_UNDERLYING_TO_WALLET, { + asset: poolReserve.underlyingAsset, + assetName: poolReserve.name, + }); + addERC20Token({ address: poolReserve.underlyingAsset, decimals: poolReserve.decimals, @@ -149,6 +164,11 @@ export const AddTokenDropdown = ({ setChangingNetwork(true); }); } else { + trackEvent(RESERVE_DETAILS.ADD_ATOKEN_TO_WALLET, { + asset: poolReserve.underlyingAsset, + assetName: poolReserve.name, + }); + addERC20Token({ address: poolReserve.aTokenAddress, decimals: poolReserve.decimals, diff --git a/src/modules/reserve-overview/BorrowInfo.tsx b/src/modules/reserve-overview/BorrowInfo.tsx index 9e67df7745..b7cc1eb54a 100644 --- a/src/modules/reserve-overview/BorrowInfo.tsx +++ b/src/modules/reserve-overview/BorrowInfo.tsx @@ -12,6 +12,7 @@ import { TextWithTooltip } from 'src/components/TextWithTooltip'; import { ComputedReserveData } from 'src/hooks/app-data-provider/useAppDataProvider'; import { AssetCapHookData } from 'src/hooks/useAssetCaps'; import { MarketDataType, NetworkConfig } from 'src/utils/marketsAndNetworksConfig'; +import { GENERAL } from 'src/utils/mixPanelEvents'; import { ApyGraphContainer } from './graphs/ApyGraphContainer'; import { ReserveFactorOverview } from './ReserveFactorOverview'; @@ -77,7 +78,16 @@ export const BorrowInfo = ({ title={ Total borrowed - + <> Borrowing of this asset is limited to a certain amount to minimize liquidity @@ -136,6 +146,14 @@ export const BorrowInfo = ({ APY, variable} key="APY_res_variable_type" variant="description" @@ -153,6 +171,14 @@ export const BorrowInfo = ({ APY, stable} key="APY_res_stable_type" variant="description" @@ -194,6 +220,8 @@ export const BorrowInfo = ({ collectorContract={currentMarketData.addresses.COLLECTOR} explorerLinkBuilder={currentNetworkConfig.explorerLinkBuilder} reserveFactor={reserve.reserveFactor} + reserveName={reserve.name} + reserveAsset={reserve.underlyingAsset} /> )} diff --git a/src/modules/reserve-overview/ReserveActions.tsx b/src/modules/reserve-overview/ReserveActions.tsx index 83dfdcfde2..2d00458c72 100644 --- a/src/modules/reserve-overview/ReserveActions.tsx +++ b/src/modules/reserve-overview/ReserveActions.tsx @@ -32,6 +32,7 @@ import { BuyWithFiat } from 'src/modules/staking/BuyWithFiat'; import { useRootStore } from 'src/store/root'; import { getMaxAmountAvailableToBorrow } from 'src/utils/getMaxAmountAvailableToBorrow'; import { getMaxAmountAvailableToSupply } from 'src/utils/getMaxAmountAvailableToSupply'; +import { GENERAL } from 'src/utils/mixPanelEvents'; import { amountToUsd } from 'src/utils/utils'; import { CapType } from '../../components/caps/helper'; @@ -52,6 +53,7 @@ export const ReserveActions = ({ reserve }: ReserveActionsProps) => { const { currentMarket, currentNetworkConfig } = useProtocolDataContext(); const { user, loading: loadingReserves, marketReferencePriceInUsd } = useAppDataContext(); const { walletBalances, loading: loadingWalletBalance } = useWalletBalances(); + const { poolComputed: { minRemainingBaseTokenBalance }, } = useRootStore(); @@ -100,9 +102,9 @@ export const ReserveActions = ({ reserve }: ReserveActionsProps) => { const onSupplyClicked = () => { if (reserve.isWrappedBaseAsset && selectedAsset === baseAssetSymbol) { - openSupply(API_ETH_MOCK_ADDRESS.toLowerCase()); + openSupply(API_ETH_MOCK_ADDRESS.toLowerCase(), currentMarket, reserve.name, 'reserve', true); } else { - openSupply(reserve.underlyingAsset); + openSupply(reserve.underlyingAsset, currentMarket, reserve.name, 'reserve', true); } }; @@ -132,6 +134,7 @@ export const ReserveActions = ({ reserve }: ReserveActionsProps) => { { /> {reserve.borrowingEnabled && ( openBorrow(reserve.underlyingAsset)} + onActionClicked={() => { + openBorrow(reserve.underlyingAsset, currentMarket, reserve.name, 'reserve', true); + }} /> )} {alerts} @@ -251,15 +257,31 @@ interface ActionProps { symbol: string; disable: boolean; onActionClicked: () => void; + reserve: ComputedReserveData; } -const SupplyAction = ({ value, usdValue, symbol, disable, onActionClicked }: ActionProps) => { +const SupplyAction = ({ + reserve, + value, + usdValue, + symbol, + disable, + onActionClicked, +}: ActionProps) => { return ( Available to supply} capType={CapType.supplyCap} + event={{ + eventName: GENERAL.TOOL_TIP, + eventParams: { + tooltip: 'Available to supply: your info', + asset: reserve.underlyingAsset, + assetName: reserve.name, + }, + }} /> { +const BorrowAction = ({ + reserve, + value, + usdValue, + symbol, + disable, + onActionClicked, +}: ActionProps) => { return ( Available to borrow} capType={CapType.borrowCap} + event={{ + eventName: GENERAL.TOOL_TIP, + eventParams: { + tooltip: 'Available to borrow: your info', + asset: reserve.underlyingAsset, + assetName: reserve.name, + }, + }} /> - Borrow + Borrow diff --git a/src/modules/reserve-overview/ReserveConfiguration.tsx b/src/modules/reserve-overview/ReserveConfiguration.tsx index 0e174c5a38..0dcf0f7aa2 100644 --- a/src/modules/reserve-overview/ReserveConfiguration.tsx +++ b/src/modules/reserve-overview/ReserveConfiguration.tsx @@ -17,6 +17,8 @@ import { ComputedReserveData } from 'src/hooks/app-data-provider/useAppDataProvi import { useAssetCaps } from 'src/hooks/useAssetCaps'; import { useProtocolDataContext } from 'src/hooks/useProtocolDataContext'; import { BROKEN_ASSETS } from 'src/hooks/useReservesHistory'; +import { useRootStore } from 'src/store/root'; +import { GENERAL, RESERVE_DETAILS } from 'src/utils/mixPanelEvents'; import LightningBoltGradient from '/public/lightningBoltGradient.svg'; @@ -40,6 +42,7 @@ export const ReserveConfiguration: React.FC = ({ rese const { supplyCap, borrowCap, debtCeiling } = useAssetCaps(); const showSupplyCapStatus: boolean = reserve.supplyCap !== '0'; const showBorrowCapStatus: boolean = reserve.borrowCap !== '0'; + const trackEvent = useRootStore((store) => store.trackEvent); return ( @@ -163,7 +166,20 @@ export const ReserveConfiguration: React.FC = ({ rese }} > Max LTV} />} + title={ + Max LTV} + /> + } > = ({ rese Liquidation threshold} /> @@ -190,6 +214,14 @@ export const ReserveConfiguration: React.FC = ({ rese Liquidation penalty} /> @@ -214,6 +246,9 @@ export const ReserveConfiguration: React.FC = ({ rese sx={{ textDecoration: 'underline' }} variant="caption" color="text.secondary" + onClick={() => { + trackEvent(RESERVE_DETAILS.GO_DASHBOARD_EMODE); + }} > Dashboard @@ -223,6 +258,9 @@ export const ReserveConfiguration: React.FC = ({ rese sx={{ textDecoration: 'underline' }} variant="caption" color="text.secondary" + onClick={() => { + trackEvent(GENERAL.EXTERNAL_LINK, { Link: 'E-mode FAQ' }); + }} > FAQ {' '} @@ -232,6 +270,9 @@ export const ReserveConfiguration: React.FC = ({ rese sx={{ textDecoration: 'underline' }} variant="caption" color="text.secondary" + onClick={() => { + trackEvent(GENERAL.EXTERNAL_LINK, { Link: 'V3 Tech Paper' }); + }} > Aave V3 Technical Paper @@ -267,6 +308,13 @@ export const ReserveConfiguration: React.FC = ({ rese /> - -); +export const GetABPTokenModal = ({ open, close }: GetABPTokenModalProps) => { + const trackEvent = useRootStore((store) => store.trackEvent); + + return ( + <> + + + Get ABP Token + + + + The Aave Balancer Pool Token (ABPT) is a liquidity pool token. You can receive ABPT by + depositing a combination of AAVE + ETH in the Balancer liquidity pool. You can then + stake your BPT in the Safety Module to secure the protocol and earn Safety Incentives. + + + + + + ); +}; diff --git a/src/modules/staking/StakingHeader.tsx b/src/modules/staking/StakingHeader.tsx index 3aa2183fa6..49ae162541 100644 --- a/src/modules/staking/StakingHeader.tsx +++ b/src/modules/staking/StakingHeader.tsx @@ -4,6 +4,8 @@ import { Box, Typography, useMediaQuery, useTheme } from '@mui/material'; import { ChainAvailabilityText } from 'src/components/ChainAvailabilityText'; import { FormattedNumber } from 'src/components/primitives/FormattedNumber'; import { TopInfoPanel } from 'src/components/TopInfoPanel/TopInfoPanel'; +import { useRootStore } from 'src/store/root'; +import { GENERAL } from 'src/utils/mixPanelEvents'; import EmissionIcon from '../../../public/icons/staking/emission-staking-icon.svg'; import TrustIcon from '../../../public/icons/staking/trust-staking-icon.svg'; @@ -24,6 +26,7 @@ export const StakingHeader: React.FC = ({ tvl, stkEmission, const valueTypographyVariant = downToSM ? 'main16' : 'main21'; const symbolsTypographyVariant = downToSM ? 'secondary16' : 'secondary21'; + const trackEvent = useRootStore((store) => store.trackEvent); return ( = ({ tvl, stkEmission, + trackEvent(GENERAL.EXTERNAL_LINK, { + Link: 'Staking Risks', + }) + } > Learn more about risks involved diff --git a/src/modules/staking/StakingPanel.tsx b/src/modules/staking/StakingPanel.tsx index 2b05e5a915..3c885238b5 100644 --- a/src/modules/staking/StakingPanel.tsx +++ b/src/modules/staking/StakingPanel.tsx @@ -23,6 +23,7 @@ import { FormattedNumber } from 'src/components/primitives/FormattedNumber'; import { TokenIcon } from 'src/components/primitives/TokenIcon'; import { TextWithTooltip } from 'src/components/TextWithTooltip'; import { useCurrentTimestamp } from 'src/hooks/useCurrentTimestamp'; +import { GENERAL } from 'src/utils/mixPanelEvents'; import { StakeActionBox } from './StakeActionBox'; @@ -299,6 +300,14 @@ export const StakingPanel: React.FC = ({ Cooldown period ) } + event={{ + eventName: GENERAL.TOOL_TIP, + eventParams: { + tooltip: 'Staking cooldown', + funnel: 'Staking Page', + assetName: stakedToken, + }, + }} > <> {isCooldownActive && !isUnstakeWindowActive ? ( diff --git a/src/static-build/proposals.json b/src/static-build/proposals.json index 30a32330d4..c19b643528 100644 --- a/src/static-build/proposals.json +++ b/src/static-build/proposals.json @@ -9570,7 +9570,7 @@ "executionTime": 0, "forVotes": "236058095466285732829883", "againstVotes": "0", - "executed": false, + "executed": true, "canceled": false, "strategy": "0xb7e383ef9B1E9189Fc0F71fb30af8aa14377429e", "state": "Active", diff --git a/src/store/analyticsSlice.ts b/src/store/analyticsSlice.ts new file mode 100644 index 0000000000..946bd785dd --- /dev/null +++ b/src/store/analyticsSlice.ts @@ -0,0 +1,100 @@ +import mixpanel from 'mixpanel-browser'; +import { StateCreator } from 'zustand'; + +import { RootStore } from './root'; + +const MIXPANEL_TOKEN = process.env.NEXT_PUBLIC_MIXPANEL || ''; + +export type TrackEventProperties = { + [key: string]: string | number | boolean | Date | undefined; +}; + +export type TrackEventProps = { + eventName: string; + eventParams?: TrackEventProperties; +}; + +export type AnalyticsSlice = { + trackEvent: (eventName: string, properties?: TrackEventProperties) => void; + isTrackingEnabled: boolean; + initializeMixpanel: () => void; + acceptAnalytics: () => void; + rejectAnalytics: () => void; + analyticsConfigOpen: boolean; + setAnalyticsConfigOpen: (eventName: boolean) => void; + mixpanelInitialized: boolean; +}; + +export const MIXPANEL_API_HOST = '/collect'; + +export const createAnalyticsSlice: StateCreator< + RootStore, + [['zustand/subscribeWithSelector', never], ['zustand/devtools', never]], + [], + AnalyticsSlice + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore +> = (set, get) => { + return { + trackEvent: (eventName: string, properties?: TrackEventProperties) => { + const trackingEnable = get().isTrackingEnabled; + + if (!trackingEnable) return null; + + const eventProperties = { + ...properties, + walletAddress: get().account, + }; + + try { + mixpanel.track(eventName, eventProperties); + } catch (err) { + console.log('something went wrong tracking event', err); + } + }, + + isTrackingEnabled: false, + analyticsConfigOpen: true, + mixpanelInitialized: false, + + initializeMixpanel: () => { + const userAcceptedAnalytics = localStorage.getItem('userAcceptedAnalytics') === 'true'; + const isInitialized = get().mixpanelInitialized; + + if (!MIXPANEL_TOKEN) return; + + if (userAcceptedAnalytics) { + if (!isInitialized) { + mixpanel.init(MIXPANEL_TOKEN, { api_host: MIXPANEL_API_HOST, ip: false }); + set({ mixpanelInitialized: true }); + } + + mixpanel.opt_in_tracking(); + set({ isTrackingEnabled: true }); + } else { + if (!isInitialized) { + mixpanel.init(MIXPANEL_TOKEN, { api_host: MIXPANEL_API_HOST, ip: false }); + set({ mixpanelInitialized: true }); + } + mixpanel.opt_out_tracking(); + set({ isTrackingEnabled: false }); + } + }, + acceptAnalytics: () => { + localStorage.setItem('userAcceptedAnalytics', 'true'); + set({ isTrackingEnabled: true, analyticsConfigOpen: false }); + + get().initializeMixpanel(); + }, + rejectAnalytics: () => { + localStorage.setItem('userAcceptedAnalytics', 'false'); + // mixpanel.opt_out_tracking(); + set({ isTrackingEnabled: false, analyticsConfigOpen: false }); + }, + setAnalyticsConfigOpen: (value: boolean) => { + localStorage.removeItem('userAcceptedAnalytics'); + + set({ analyticsConfigOpen: value }); + }, + }; +}; diff --git a/src/store/root.ts b/src/store/root.ts index dec4f28c96..403226e706 100644 --- a/src/store/root.ts +++ b/src/store/root.ts @@ -5,12 +5,14 @@ import { ENABLE_TESTNET, STAGING_ENV } from 'src/utils/marketsAndNetworksConfig' import create from 'zustand'; import { devtools, subscribeWithSelector } from 'zustand/middleware'; +import { AnalyticsSlice, createAnalyticsSlice } from './analyticsSlice'; import { createGovernanceSlice, GovernanceSlice } from './governanceSlice'; import { createIncentiveSlice, IncentiveSlice } from './incentiveSlice'; import { createLayoutSlice, LayoutSlice } from './layoutSlice'; import { createPoolSlice, PoolSlice } from './poolSlice'; import { createProtocolDataSlice, ProtocolDataSlice } from './protocolDataSlice'; import { createStakeSlice, StakeSlice } from './stakeSlice'; +import { createTransactionsSlice, TransactionsSlice } from './transactionsSlice'; import { createSingletonSubscriber } from './utils/createSingletonSubscriber'; import { getQueryParameter } from './utils/queryParams'; import { createV3MigrationSlice, V3MigrationSlice } from './v3MigrationSlice'; @@ -27,6 +29,8 @@ export type RootStore = StakeSlice & GovernanceSlice & V3MigrationSlice & WalletDomainsSlice & + AnalyticsSlice & + TransactionsSlice & LayoutSlice; export const useRootStore = create()( @@ -41,6 +45,8 @@ export const useRootStore = create()( ...createGovernanceSlice(...args), ...createV3MigrationSlice(...args), ...createWalletDomainsSlice(...args), + ...createAnalyticsSlice(...args), + ...createTransactionsSlice(...args), ...createLayoutSlice(...args), }; }) diff --git a/src/store/transactionsSelectors.ts b/src/store/transactionsSelectors.ts new file mode 100644 index 0000000000..3edc13a6a9 --- /dev/null +++ b/src/store/transactionsSelectors.ts @@ -0,0 +1,21 @@ +import { RootStore } from './root'; +import { TransactionEvent, Transactions } from './transactionsSlice'; + +export const selectSuccessfulTransactions = (state: RootStore) => { + const successfulTransactions: Transactions = {}; + + Object.keys(state.transactions).forEach((chainId) => { + const chainIdNumber = +chainId; + const successfulTxHashes = Object.keys(state.transactions[chainIdNumber]).filter( + (txHash) => state.transactions[chainIdNumber][txHash].txState === 'success' + ); + successfulTransactions[chainIdNumber] = successfulTxHashes.reduce<{ + [hash: string]: TransactionEvent; + }>((acc, txHash) => { + acc[txHash] = state.transactions[chainIdNumber][txHash]; + return acc; + }, {}); + }); + + return successfulTransactions; +}; diff --git a/src/store/transactionsSlice.ts b/src/store/transactionsSlice.ts new file mode 100644 index 0000000000..5d3391a6e0 --- /dev/null +++ b/src/store/transactionsSlice.ts @@ -0,0 +1,56 @@ +import { ProtocolAction } from '@aave/contract-helpers'; +import { produce } from 'immer'; +import { StateCreator } from 'zustand'; + +import { RootStore } from './root'; + +export type Transactions = { + [chainId: number]: { + [hash: string]: TransactionEvent; + }; +}; + +export type TransactionDetails = { + action: ProtocolAction; + txState: TransactionState; + asset?: string; + amount?: string; + assetName?: string; +}; + +export type TransactionEvent = TransactionDetails & { + market: string; +}; + +type TransactionState = 'success' | 'failed'; + +export interface TransactionsSlice { + transactions: Transactions; + addTransaction: (txHash: string, transaction: TransactionDetails) => void; +} + +export const createTransactionsSlice: StateCreator< + RootStore, + [['zustand/subscribeWithSelector', never], ['zustand/devtools', never]], + [], + TransactionsSlice +> = (set, get) => { + return { + transactions: [], + addTransaction: (txHash: string, transaction: TransactionDetails) => { + const chainId = get().currentChainId; + const market = get().currentMarket; + set((state) => + produce(state, (draft) => { + draft.transactions[chainId] = { + ...draft.transactions[chainId], + [txHash]: { + ...transaction, + market, + }, + }; + }) + ); + }, + }; +}; diff --git a/src/ui-config/menu-items/index.tsx b/src/ui-config/menu-items/index.tsx index 970ba31562..6aca0dd470 100644 --- a/src/ui-config/menu-items/index.tsx +++ b/src/ui-config/menu-items/index.tsx @@ -4,9 +4,6 @@ import { ReactNode } from 'react'; import { ROUTES } from 'src/components/primitives/Link'; import { ENABLE_TESTNET } from 'src/utils/marketsAndNetworksConfig'; -import DiscordIcon from '/public/icons/discord.svg'; -import GithubIcon from '/public/icons/github.svg'; - import { MarketDataType } from '../marketsConfig'; interface Navigation { @@ -68,16 +65,6 @@ const moreMenuItems: MoreMenuItem[] = [ title: t`Developers`, icon: , }, - { - link: 'https://discord.gg/7kHKnkDEUf', - title: t`Discord`, - icon: , - }, - { - link: 'https://github.com/aave/interface', - title: t`Github`, - icon: , - }, { link: 'https://global.transak.com', makeLink: (walletAddress) => diff --git a/src/utils/marketsAndNetworksConfig.ts b/src/utils/marketsAndNetworksConfig.ts index 69ebbd1072..e25926b3ec 100644 --- a/src/utils/marketsAndNetworksConfig.ts +++ b/src/utils/marketsAndNetworksConfig.ts @@ -26,7 +26,7 @@ export const ENABLE_TESTNET = PROD_ENV && global?.window?.localStorage.getItem('testnetsEnabled') === 'true'; // determines if forks should be shown -const FORK_ENABLED = +export const FORK_ENABLED = !!process.env.NEXT_PUBLIC_FORK_URL_RPC || global?.window?.localStorage.getItem('forkEnabled') === 'true'; // specifies which network was forked diff --git a/src/utils/mixPanelEvents.ts b/src/utils/mixPanelEvents.ts new file mode 100644 index 0000000000..4b093f8ebf --- /dev/null +++ b/src/utils/mixPanelEvents.ts @@ -0,0 +1,172 @@ +export const PAGEVIEW = 'Pageview'; + +export const AUTH = { + CONNECT_WALLET_MODAL: 'Open Connect Wallet Modal', //done + CONNECT_WALLET: 'Connect wallet', //done + SWITCH_WALLET: 'Switch wallet', //done + MOCK_WALLET: 'Mock wallet', //done + DISCONNECT_WALLET: 'Disconnect wallet', //done + COPY_ADDRESS: 'Copy address', // done + VIEW_EXPLORER: 'View explorer', // done + VIEW_TX_HISTORY: 'View Tx History', +}; + +export const GENERAL = { + SWITCH_NETWORK: 'Switch network', + OPEN_BUY_WITH_FIAT: 'Open buy with fiat modal', //done + BUY_WITH_FIAT: 'Navigate to fiat onramp', //done + TOOL_TIP: 'Tool Tip', //done + EXTERNAL_LINK: 'External Link Navigaton', + SET_SLIPPAGE: 'Set slippage', +}; + +export const DASHBOARD = { + CHANGE_MARKET: 'Change market on dashboard', //done + VIEW_MARKETS: 'View markets on dashboard', // can be viewed in PAGEVIEW + VIEW_RISK_DETAILS: 'View risk details on dashboard', // done + SUPPLY_DASHBOARD: 'Supply dashboard', //done + REPAY_DASHBOARD: 'Repay dashboard', // done + SWAP_DASHBOARD: 'Swap dashboard', //done + WITHDRAWL_DASHBOARD: 'Withdrawl dashboard', //done + + BORROW_DASHBOARD: 'Borrow dashboard', // done + DETAILS_ROW_DASHBOARD: 'Details Row dashboard', // done + DETAILS_BUTTON_DASHBOARD: 'Details button dashboard', // done + COLLATERAL_TOGGLE_DASHBOARD: 'Collateral toggle dashboard', // done + APY_DROPDOWN_DASHBOARD: 'APY dropdown dashboard', // todo + APY_CHANGE_DASHBOARD: 'Change APY type dashboard', // todo + APY_SEE_CHARTS_DASHBOARD: 'See APY charts dashboard', + E_MODE_INFO_DASHBOARD: 'E-Mode toggle dashboard', // done + E_MODE_ACTION_ENABLE_DASHBOARD: 'E-Mode action button enable dashboard', //done + E_MODE_ACTION_DISABLE_DASHBOARD: 'E-Mode action button disable dashboard', // done + E_MODE_ACTION_SWITCH_DASHBOARD: 'E-Mode action button switch dashboard', //done + + VIEW_LM_DETAILS_DASHBOARD: 'View LM details dashboard', // done + NOTIFY_DASHBOARD: 'Notify dashboard', // done + HIDE_SUPPLY_TILE: 'Hide supply tile dashboard', // done + HIDE_BORROW_TILE: 'Hide borrow tile dashboard', // done + HIDE_YOUR_SUPPLY_TILE: 'Hide your supply tile dashboard', // done + HIDE_YOUR_BORROW_TILE: 'Hide your borrow tile dashboard', // done + SHOW_ASSETS_0_BALANCE: 'Show assets with zero balance dashboard', // done +}; + +export const MARKETS = { + SEARCH_ASSET: 'Search asset markets', // how to handle + DETAILS_BUTTON: 'Details button markets page', // done + DETAILS_ROW_CLICK: 'Details row markets page', // done + VIEW_LM_DETAILS_MARKETS: 'View LM details markets page', + SORT_ASSET_MARKET: 'Sort by asset on markets page', // done + SORT_SUPPLY_MARKET: 'Sort by supply on markets page', // done + SORT_SUPPY_APY_MARKET: 'Sort by supply APY on markets page', //done + SORT_BORROW_MARKET: 'Sort by borrow on markets page', //done + SORT_BORROW_APY_V_MARKET: 'Sort by borrow APY variable on markets page', //done + SORT_BORROW_APY_S_MARKET: 'Sort by borrow APY stable on markets page', //done + VIEW_FROZEN_GOV_POST_MARKET: 'View frozen gov post from markets page', //done +}; + +export const RESERVE_DETAILS = { + RESERVE_TOKENS_DROPDOWN: 'View reserve tokens', // done + RESERVE_TOKENS_UNDERLYING: 'View underlying reserve token: ', //done + RESERVE_TOKENS_ATOKEN: 'View underlying aTOKEN: ', //done + RESERVE_TOKENS_DEBT_TOKEN: 'View underlying debt token: ', //done + RESERVE_TOKENS_STABLE_DEBT_TOKEN: 'View underlying stable debt token: ', //done + ADD_TOKEN_TO_WALLET_DROPDOWN: 'View add token to wallet dropdown', //done + ADD_UNDERLYING_TO_WALLET: 'Add underlying token to wallet reserve page: ', //done + ADD_ATOKEN_TO_WALLET: 'Add aToken to wallet reserve page: ', // done + GO_DASHBOARD_EMODE: 'Click Dashboard from E-Mode section', //done + GRAPH_TIME_PERIOD: 'Graph Time Period Selector', +}; + +export const YOUR_INFO_RESERVE_DETAILS = { + SUPPLY_RESERVE: 'Supply assets your info reserve page', // done removed for DASHBOARD.BORROW_DASHBOARD with funnel property + BORROW_RESERVE: 'Borrow assets your info reserve page', // done removed for DASHBOARD.BORROW_DASHBOARD with funnel property +}; + +export const TRANSACTION_HISTORY = { + COPY_TX_ADDRESS: 'Copy Tx Address', + DOWNLOAD: 'Tx Histoy Download', + FILTER: 'Tx History Filter Selected', +}; + +export const SUPPLY_MODAL = { + SWITCH_NETWORK: 'Switch network supply modal', // done + MAX_SUPPLY: 'Max supply input supply modal', // done + APPROVE_TOKEN: 'Approve token', + SUPPLY_TOKEN: 'Supply token', + SUPPLY_WITH_PERMIT: 'Supply token with permit', // done +}; + +export const BORROW_MODAL = { + SWITCH_NETWORK: 'Switch network borrow modal', // done + MAX_BORROW: 'Max borrow input borrow modal', // done + BORROW_TOKEN: 'Borrow token', // done + UNWRAP_UNDERLYING: 'Unwrap toggle borrow modal', //done + ACCEPT_RISK: 'Accept risk check box borrow modal', // done +}; + +export const WITHDRAW_MODAL = { + SWITCH_NETWORK: 'Switch network Withdraw modal', // done + MAX_WITHDRAW: 'Max Withdraw input Withdraw modal', // done + WITHDRAW_TOKEN: ' token', // done + ACCEPT_RISK: 'Accept risk check box Withdraw modal', // done +}; + +// TODO proper events here +export const REPAY_MODAL = { + // SWITCH_NETWORK: 'Switch network borrow modal', + // MAX_BORROW: 'Max supply input borrow modal', + // BORROW_TOKEN: 'Borrow token', + // UNWRAP_UNDERLYING: 'Unwrap toggle borrow modal', + // ACCEPT_RISK: 'Accept risk check box borrow modal', + REPAY_TOKEN: 'Repays borrowed position', + SWITCH_REPAY_TYPE: 'Change repay type', +}; + +export const STAKE = { + OPEN_STAKE_MODAL: 'Open stake modal staking page', //done + OPEN_UNSTAKE_MODAL: 'Open unstake modal staking page', //done + STAKE_TOKEN: 'Stake Action', + MAX_AMOUNT_AAVE: 'Max amount of AAVE to stake in staking modal', + OPEN_COOLDOWN_MODAL: 'Open cooldown modal staking page', //done + ACCEPT_COOLDOWN_CHECKBOX: 'Accept cooldown risks cooldwon modal', //done + ACTIVATE_COOLDOWN: 'Activate cooldown button cooldown modal', + OPEN_CLAIM_STAKE_REWARDS: 'Open claim stake rewards modal staking page', //done + CLAIM_STAKE_REWARDS: 'Claim staking rewards button', + OPEN_GET_ABP_TOKEN: 'Open get abpt token', //done + CONNECT_WALLET_STAKING: 'Connect wallet staking page', //--done +}; + +export const GOVERNANCE_PAGE = { + FILTER: 'Filter governance page', // done + SEARCH_GOVERNANCE_PAGE: 'Search governance page: Term = ', //not sure how to do this + VIEW_AIP: 'View aip information governance page', //done + SET_UP_DELEGATION_BUTTON: 'Set up delegation governance page', //done + REVOKE_POWER_BUTTON: 'Revoke power button governance page', //done + LEARN_MORE_DELEGATION: 'Learn More Delgation Panel', //done +}; + +export const AIP = { + VIEW_ALL_VOTES: 'View all votes modal AIP page', //done (not sure why we don't use normal modal context) + VOTE: 'Vote on proposal transaction', //need help + VOTE_BUTTON_MODAL: 'Vote on AIP modal', //done + GO_BACK: 'GO Back: AIP', //done + SHARE_VOTE_ON_LENS: 'Share vote to lens: Vote Modal', //done +}; + +export const DELEGATION = { + DELEGATE_BUTTON: 'Delegate power', //will be in the txhander section + REVOKE_POWER: 'Revoke power', //will be in the txhandler section +}; + +export const NAV_BAR = { + MAIN_MENU: 'Main menu navigation', //done + MORE: 'More View', //done + MORE_NAV: 'More navigation', //done +}; + +export const SETTINGS = { + DARK_MODE: 'Dark Mode Toggle', + TESTNET_MODE: 'Testnet mode toggled: ', + LANGUAGE: 'Language selector', + LANGUAGE_SELECTED: 'Language selected', +}; diff --git a/yarn.lock b/yarn.lock index f6b457a0b7..703c54089e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3387,6 +3387,11 @@ resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c" integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ== +"@types/mixpanel-browser@^2.38.1": + version "2.38.1" + resolved "https://registry.yarnpkg.com/@types/mixpanel-browser/-/mixpanel-browser-2.38.1.tgz#914cc726194cc0358129b6d84657f078e47f7697" + integrity sha512-XzQbwgiOPsFXUQnjz3vSwcwrvJDbQ35bCiwa/1VXGrHvU1ti9+eqO1GY91DShzkEzKkkEEkxfNshS5dbBZqd7w== + "@types/ms@*": version "0.7.31" resolved "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz" @@ -8301,6 +8306,11 @@ jest@^29.2.0: import-local "^3.0.2" jest-cli "^29.2.0" +js-cookie@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8" + integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ== + js-sdsl@^4.1.4: version "4.1.5" resolved "https://registry.yarnpkg.com/js-sdsl/-/js-sdsl-4.1.5.tgz#1ff1645e6b4d1b028cd3f862db88c9d887f26e2a" @@ -9318,6 +9328,11 @@ minimist@^1.2.6: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== +mixpanel-browser@^2.45.0: + version "2.45.0" + resolved "https://registry.yarnpkg.com/mixpanel-browser/-/mixpanel-browser-2.45.0.tgz#a2973be5b66e6d2799ef95a1e55b8ad8eede57e8" + integrity sha512-PQ1DaTk68yyYtLA0iejmzPA9iNDhT4uIZpqZjRTw7HWpYfl123fydHb2laKanaKjm8YDmrGGz3+xZ4Q6joogyg== + mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz" @@ -10121,6 +10136,13 @@ randombytes@^2.1.0: dependencies: safe-buffer "^5.1.0" +react-cookie-consent@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/react-cookie-consent/-/react-cookie-consent-8.0.1.tgz#83526a39c19be82872e9374c6fef98d05e12e5ba" + integrity sha512-4A2jzPQDFfBhtxIz4hYX+vJ0QnOknGdOXpEoetXzgwUrMtxVJVow8YgBsGerNt5rJI7WhKkHwr8LmxekxgVejg== + dependencies: + js-cookie "^2.2.1" + react-dom@latest: version "17.0.2" resolved "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz"