UNPKG

@kodex-data/multicall

Version:

`@kodex-data/multicall` is a JavaScript library that allows you to batch multiple Ethereum read-only calls into a single request, reducing the number of RPC calls and improving performance. It supports the `eth_call` method and the `multicall` contract, w

1,134 lines (1,122 loc) 39.2 kB
'use strict'; require('@kodex-data/prototypes'); var abi = require('@ethersproject/abi'); var bignumber = require('@ethersproject/bignumber'); var contracts = require('@ethersproject/contracts'); var ethers = require('ethers'); var BignumberJS = require('bignumber.js'); var providers = require('@ethersproject/providers'); var lodash = require('lodash'); /****************************************************************************** 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. ***************************************************************************** */ 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); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } const MulticallAbi = [ { constant: true, inputs: [ { components: [ { internalType: 'address', name: 'target', type: 'address' }, { internalType: 'bytes', name: 'callData', type: 'bytes' } ], internalType: 'struct Multicall.Call[]', name: 'calls', type: 'tuple[]' } ], name: 'aggregate', outputs: [ { internalType: 'uint256', name: 'blockNumber', type: 'uint256' }, { internalType: 'bytes[]', name: 'returnData', type: 'bytes[]' } ], payable: false, stateMutability: 'view', type: 'function' }, { type: 'function', stateMutability: 'view', payable: false, outputs: [ { type: 'uint256', name: 'blockNumber', internalType: 'uint256' }, { type: 'bytes32', name: 'blockHash', internalType: 'bytes32' }, { type: 'tuple[]', name: 'returnData', internalType: 'struct Multicall2.Result[]', components: [ { type: 'bool', name: 'success', internalType: 'bool' }, { type: 'bytes', name: 'returnData', internalType: 'bytes' } ] } ], name: 'blockAndAggregate', inputs: [ { type: 'tuple[]', name: 'calls', internalType: 'struct Multicall2.Call[]', components: [ { type: 'address', name: 'target', internalType: 'address' }, { type: 'bytes', name: 'callData', internalType: 'bytes' } ] } ], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'bytes32', name: 'blockHash', internalType: 'bytes32' }], name: 'getBlockHash', inputs: [{ type: 'uint256', name: 'blockNumber', internalType: 'uint256' }], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'uint256', name: 'blockNumber', internalType: 'uint256' }], name: 'getBlockNumber', inputs: [], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'address', name: 'coinbase', internalType: 'address' }], name: 'getCurrentBlockCoinbase', inputs: [], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'uint256', name: 'difficulty', internalType: 'uint256' }], name: 'getCurrentBlockDifficulty', inputs: [], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'uint256', name: 'gaslimit', internalType: 'uint256' }], name: 'getCurrentBlockGasLimit', inputs: [], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'uint256', name: 'timestamp', internalType: 'uint256' }], name: 'getCurrentBlockTimestamp', inputs: [], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'uint256', name: 'balance', internalType: 'uint256' }], name: 'getEthBalance', inputs: [{ type: 'address', name: 'addr', internalType: 'address' }], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [{ type: 'bytes32', name: 'blockHash', internalType: 'bytes32' }], name: 'getLastBlockHash', inputs: [], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [ { type: 'tuple[]', name: 'returnData', internalType: 'struct Multicall2.Result[]', components: [ { type: 'bool', name: 'success', internalType: 'bool' }, { type: 'bytes', name: 'returnData', internalType: 'bytes' } ] } ], name: 'tryAggregate', inputs: [ { type: 'bool', name: 'requireSuccess', internalType: 'bool' }, { type: 'tuple[]', name: 'calls', internalType: 'struct Multicall2.Call[]', components: [ { type: 'address', name: 'target', internalType: 'address' }, { type: 'bytes', name: 'callData', internalType: 'bytes' } ] } ], constant: true }, { type: 'function', stateMutability: 'view', payable: false, outputs: [ { type: 'uint256', name: 'blockNumber', internalType: 'uint256' }, { type: 'bytes32', name: 'blockHash', internalType: 'bytes32' }, { type: 'tuple[]', name: 'returnData', internalType: 'struct Multicall2.Result[]', components: [ { type: 'bool', name: 'success', internalType: 'bool' }, { type: 'bytes', name: 'returnData', internalType: 'bytes' } ] } ], name: 'tryBlockAndAggregate', inputs: [ { type: 'bool', name: 'requireSuccess', internalType: 'bool' }, { type: 'tuple[]', name: 'calls', internalType: 'struct Multicall2.Call[]', components: [ { type: 'address', name: 'target', internalType: 'address' }, { type: 'bytes', name: 'callData', internalType: 'bytes' } ] } ], constant: true } ]; const ERC20Abi = [ { anonymous: false, inputs: [ { indexed: true, internalType: 'address', name: 'owner', type: 'address' }, { indexed: true, internalType: 'address', name: 'spender', type: 'address' }, { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } ], name: 'Approval', type: 'event' }, { anonymous: false, inputs: [ { indexed: true, internalType: 'address', name: 'from', type: 'address' }, { indexed: true, internalType: 'address', name: 'to', type: 'address' }, { indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' } ], name: 'Transfer', type: 'event' }, { inputs: [], name: 'DOMAIN_SEPARATOR', outputs: [ { internalType: 'bytes32', name: '', type: 'bytes32' } ], stateMutability: 'view', type: 'function' }, { inputs: [ { internalType: 'address', name: 'owner', type: 'address' }, { internalType: 'address', name: 'spender', type: 'address' } ], name: 'allowance', outputs: [ { internalType: 'uint256', name: '', type: 'uint256' } ], stateMutability: 'view', type: 'function' }, { inputs: [ { internalType: 'address', name: 'spender', type: 'address' }, { internalType: 'uint256', name: 'amount', type: 'uint256' } ], name: 'approve', outputs: [ { internalType: 'bool', name: '', type: 'bool' } ], stateMutability: 'nonpayable', type: 'function' }, { inputs: [ { internalType: 'address', name: 'account', type: 'address' } ], name: 'balanceOf', outputs: [ { internalType: 'uint256', name: '', type: 'uint256' } ], stateMutability: 'view', type: 'function' }, { inputs: [], name: 'decimals', outputs: [ { internalType: 'uint8', name: '', type: 'uint8' } ], stateMutability: 'view', type: 'function' }, { inputs: [ { internalType: 'address', name: 'spender', type: 'address' }, { internalType: 'uint256', name: 'subtractedValue', type: 'uint256' } ], name: 'decreaseAllowance', outputs: [ { internalType: 'bool', name: '', type: 'bool' } ], stateMutability: 'nonpayable', type: 'function' }, { inputs: [ { internalType: 'address', name: 'spender', type: 'address' }, { internalType: 'uint256', name: 'addedValue', type: 'uint256' } ], name: 'increaseAllowance', outputs: [ { internalType: 'bool', name: '', type: 'bool' } ], stateMutability: 'nonpayable', type: 'function' }, { inputs: [], name: 'name', outputs: [ { internalType: 'string', name: '', type: 'string' } ], stateMutability: 'view', type: 'function' }, { inputs: [ { internalType: 'address', name: 'owner', type: 'address' } ], name: 'nonces', outputs: [ { internalType: 'uint256', name: '', type: 'uint256' } ], stateMutability: 'view', type: 'function' }, { inputs: [ { internalType: 'address', name: 'owner', type: 'address' }, { internalType: 'address', name: 'spender', type: 'address' }, { internalType: 'uint256', name: 'value', type: 'uint256' }, { internalType: 'uint256', name: 'deadline', type: 'uint256' }, { internalType: 'uint8', name: 'v', type: 'uint8' }, { internalType: 'bytes32', name: 'r', type: 'bytes32' }, { internalType: 'bytes32', name: 's', type: 'bytes32' } ], name: 'permit', outputs: [], stateMutability: 'nonpayable', type: 'function' }, { inputs: [], name: 'symbol', outputs: [ { internalType: 'string', name: '', type: 'string' } ], stateMutability: 'view', type: 'function' }, { inputs: [], name: 'totalSupply', outputs: [ { internalType: 'uint256', name: '', type: 'uint256' } ], stateMutability: 'view', type: 'function' }, { inputs: [ { internalType: 'address', name: 'to', type: 'address' }, { internalType: 'uint256', name: 'amount', type: 'uint256' } ], name: 'transfer', outputs: [ { internalType: 'bool', name: '', type: 'bool' } ], stateMutability: 'nonpayable', type: 'function' }, { inputs: [ { internalType: 'address', name: 'from', type: 'address' }, { internalType: 'address', name: 'to', type: 'address' }, { internalType: 'uint256', name: 'amount', type: 'uint256' } ], name: 'transferFrom', outputs: [ { internalType: 'bool', name: '', type: 'bool' } ], stateMutability: 'nonpayable', type: 'function' } ]; class MultiCall { constructor(provider) { this.operations = []; this.$fn = { addOperation: (operation) => { operation.index = this.operations.length; if (!operation.sigHash) operation.sigHash = operation.callData.slice(0, 10); if (!operation.signature) operation.signature = operation.abi.format(); this.operations.push(operation); }, //prettier-ignore aggregate: (provider = this.provider) => __awaiter(this, void 0, void 0, function* () { if (!provider) throw new Error('MultiCall: no provider attached'); if (this.operations.length === 0) throw new Error(`can not aggregate, no operations added to instance`); const network = yield provider.getNetwork(); if (!MultiCall.Contracts.has(network.chainId)) throw new Error(`unsupported network provided. chain id: ${network.chainId}`); const address = MultiCall.Contracts.get(network.chainId); const contract = new contracts.Contract(address, MulticallAbi, provider); const payloads = this.$fn.toAggregatePayload(); const results = yield contract.aggregate(payloads); if (results && results.returnData) { const coder = new abi.AbiCoder(); const resultValues = results.returnData; if (results.blockNumber instanceof bignumber.BigNumber) { this.blockNumber = results.blockNumber; } for (const index in this.operations) try { const operation = this.operations[index]; const rawValue = resultValues[index]; const decoded = coder.decode(operation.abi.outputs, rawValue); if (decoded.length < 2) this.operations[index].resultValue = decoded[0]; else this.operations[index].resultValue = decoded; } catch (error) { console.warn(`error multicall aggregate`, error); this.operations[index].resultValue = undefined; } } return this.operations; }), toCallParameters: () => { const targets = this.operations.map((x) => x.target); const values = this.operations.map((x) => x.value); const callDatas = this.operations.map((x) => x.callData); return { targets, values, callDatas }; }, toAggregatePayload: () => { const { targets, callDatas } = this.$fn.toCallParameters(); const result = []; targets.map((target, index) => { result.push([target, callDatas[index]]); }); return result; } }; this.balanceOf = { add: (token, address) => { const iface = new abi.Interface(ERC20Abi); const abi$1 = iface.getFunction('balanceOf'); const sigHash = iface.getSighash(abi$1); const callData = iface.encodeFunctionData('balanceOf', [address]); const signature = iface.functions['balanceOf(address)'].format(); //prettier-ignore const operation = { index: this.operations.length, value: bignumber.BigNumber.from(0), abi: abi$1, sigHash, signature, target: token, callData, parameters: { 0: address } }; //prettier-ignore if (!this.operations.find((o) => o.target.addrIsEqual(token) && o.sigHash === sigHash && o.parameters[0] && o.parameters[0].isAddress() && address.addrIsEqual(o.parameters[0]))) this.operations.push(operation); }, query: (provider = this.provider) => __awaiter(this, void 0, void 0, function* () { if (!provider) throw new Error('MultiCall: no provider attached'); try { const results = yield this.$fn.aggregate(provider); return results.map((x) => { const holder = x.parameters[0]; return { token: x.target.toChecksumAddress(), holder: holder.toChecksumAddress(), value: x.resultValue }; }); } catch (error) { return []; } }) }; this.provider = provider; } } MultiCall.MulticallAbi = MulticallAbi; MultiCall.isBigNumber = (input) => { return input instanceof bignumber.BigNumber; }; MultiCall.isResult = (input) => { return input && ('0' in input && '1' in input); }; MultiCall.Contracts = new Map([ [1, '0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441'], [3, '0x53C43764255c17BD724F74c4eF150724AC50a3ed'], [4, '0x42Ad527de7d4e9d9d011aC45B31D8551f8Fe9821'], [5, '0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e'], [42, '0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6'], [56, '0xC3821F0b56FA4F4794d5d760f94B812DE261361B'], [61, '0x2bAADf55fB2177e8d13708a7f09B966f671555Eb'], [100, '0xB5A6F04357Bfd9A21A8C2D32EE37e08b1BD587F6'], [250, '0x3E3D6b13E6cC2B159c7bE64e6C87BD2c3E26F3F8'], [43114, '0xB828C456Fc39AA2370A621AcE52Dc84bEA08ab58'], [42161, '0x2Ba4C95Ce2d00cE39eAa4Fb50f19024A53c73EF2'], [10, '0x8D6591F594a5ee3A7AFFf03E6e24b6B866792575'], [2001, '0x18fA376d92511Dd04090566AB6144847c03557d8'], [78, '0xa83A64E9a4aFa9378C49d17400836D402145f7a2'], [200101, '0xBBa0649cb8A6dcf69bc66bd6c5e0950C64F3c724'], // Add valid chainId / contract address pair as needed ]); /* Autogenerated file. Do not edit manually. */ const _abi = [ { inputs: [ { components: [ { internalType: "address", name: "target", type: "address", }, { internalType: "bytes", name: "callData", type: "bytes", }, ], internalType: "struct Multicall2.Call[]", name: "calls", type: "tuple[]", }, ], name: "aggregate", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256", }, { internalType: "bytes[]", name: "returnData", type: "bytes[]", }, ], stateMutability: "nonpayable", type: "function", }, { inputs: [ { components: [ { internalType: "address", name: "target", type: "address", }, { internalType: "bytes", name: "callData", type: "bytes", }, ], internalType: "struct Multicall2.Call[]", name: "calls", type: "tuple[]", }, ], name: "blockAndAggregate", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256", }, { internalType: "bytes32", name: "blockHash", type: "bytes32", }, { components: [ { internalType: "bool", name: "success", type: "bool", }, { internalType: "bytes", name: "returnData", type: "bytes", }, ], internalType: "struct Multicall2.Result[]", name: "returnData", type: "tuple[]", }, ], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256", }, ], name: "getBlockHash", outputs: [ { internalType: "bytes32", name: "blockHash", type: "bytes32", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getBlockNumber", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getCurrentBlockCoinbase", outputs: [ { internalType: "address", name: "coinbase", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getCurrentBlockDifficulty", outputs: [ { internalType: "uint256", name: "difficulty", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getCurrentBlockGasLimit", outputs: [ { internalType: "uint256", name: "gaslimit", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getCurrentBlockTimestamp", outputs: [ { internalType: "uint256", name: "timestamp", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "addr", type: "address", }, ], name: "getEthBalance", outputs: [ { internalType: "uint256", name: "balance", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getLastBlockHash", outputs: [ { internalType: "bytes32", name: "blockHash", type: "bytes32", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "bool", name: "requireSuccess", type: "bool", }, { components: [ { internalType: "address", name: "target", type: "address", }, { internalType: "bytes", name: "callData", type: "bytes", }, ], internalType: "struct Multicall2.Call[]", name: "calls", type: "tuple[]", }, ], name: "tryAggregate", outputs: [ { components: [ { internalType: "bool", name: "success", type: "bool", }, { internalType: "bytes", name: "returnData", type: "bytes", }, ], internalType: "struct Multicall2.Result[]", name: "returnData", type: "tuple[]", }, ], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "bool", name: "requireSuccess", type: "bool", }, { components: [ { internalType: "address", name: "target", type: "address", }, { internalType: "bytes", name: "callData", type: "bytes", }, ], internalType: "struct Multicall2.Call[]", name: "calls", type: "tuple[]", }, ], name: "tryBlockAndAggregate", outputs: [ { internalType: "uint256", name: "blockNumber", type: "uint256", }, { internalType: "bytes32", name: "blockHash", type: "bytes32", }, { components: [ { internalType: "bool", name: "success", type: "bool", }, { internalType: "bytes", name: "returnData", type: "bytes", }, ], internalType: "struct Multicall2.Result[]", name: "returnData", type: "tuple[]", }, ], stateMutability: "nonpayable", type: "function", }, ]; const _bytecode = "0x608060405234801561001057600080fd5b50610a3a806100206000396000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806372425d9d1161007157806372425d9d1461013a57806386d516e814610140578063a8b0574e14610146578063bce38bd714610154578063c3077fa914610174578063ee82ac5e1461018757600080fd5b80630f28c97d146100b9578063252dba42146100ce57806327e86d6e146100ef578063399542e9146100f757806342cbb15c146101195780634d2301cc1461011f575b600080fd5b425b6040519081526020015b60405180910390f35b6100e16100dc36600461071e565b610199565b6040516100c592919061088b565b6100bb610359565b61010a610105366004610759565b61036c565b6040516100c5939291906108f4565b436100bb565b6100bb61012d3660046106fd565b6001600160a01b03163190565b446100bb565b456100bb565b6040514181526020016100c5565b610167610162366004610759565b610384565b6040516100c59190610878565b61010a61018236600461071e565b610576565b6100bb6101953660046107ab565b4090565b8051439060609067ffffffffffffffff8111156101c657634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156101f957816020015b60608152602001906001900390816101e45790505b50905060005b83518110156103535760008085838151811061022b57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b031686848151811061026057634e487b7160e01b600052603260045260246000fd5b602002602001015160200151604051610279919061085c565b6000604051808303816000865af19150503d80600081146102b6576040519150601f19603f3d011682016040523d82523d6000602084013e6102bb565b606091505b5091509150816103125760405162461bcd60e51b815260206004820181905260248201527f4d756c746963616c6c206167677265676174653a2063616c6c206661696c656460448201526064015b60405180910390fd5b8084848151811061033357634e487b7160e01b600052603260045260246000fd5b60200260200101819052505050808061034b906109bd565b9150506101ff565b50915091565b6000610366600143610976565b40905090565b438040606061037b8585610384565b90509250925092565b6060815167ffffffffffffffff8111156103ae57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156103f457816020015b6040805180820190915260008152606060208201528152602001906001900390816103cc5790505b50905060005b825181101561056f5760008084838151811061042657634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b031685848151811061045b57634e487b7160e01b600052603260045260246000fd5b602002602001015160200151604051610474919061085c565b6000604051808303816000865af19150503d80600081146104b1576040519150601f19603f3d011682016040523d82523d6000602084013e6104b6565b606091505b5091509150851561051857816105185760405162461bcd60e51b815260206004820152602160248201527f4d756c746963616c6c32206167677265676174653a2063616c6c206661696c656044820152601960fa1b6064820152608401610309565b604051806040016040528083151581526020018281525084848151811061054f57634e487b7160e01b600052603260045260246000fd5b602002602001018190525050508080610567906109bd565b9150506103fa565b5092915050565b600080606061058660018561036c565b9196909550909350915050565b80356001600160a01b03811681146105aa57600080fd5b919050565b600082601f8301126105bf578081fd5b8135602067ffffffffffffffff808311156105dc576105dc6109ee565b8260051b6105eb838201610945565b8481528381019087850183890186018a1015610605578788fd5b8793505b868410156106425780358581111561061f578889fd5b61062d8b88838d010161064f565b84525060019390930192918501918501610609565b5098975050505050505050565b600060408284031215610660578081fd5b61066861091c565b905061067382610593565b815260208083013567ffffffffffffffff8082111561069157600080fd5b818501915085601f8301126106a557600080fd5b8135818111156106b7576106b76109ee565b6106c9601f8201601f19168501610945565b915080825286848285010111156106df57600080fd5b80848401858401376000908201840152918301919091525092915050565b60006020828403121561070e578081fd5b61071782610593565b9392505050565b60006020828403121561072f578081fd5b813567ffffffffffffffff811115610745578182fd5b610751848285016105af565b949350505050565b6000806040838503121561076b578081fd5b8235801515811461077a578182fd5b9150602083013567ffffffffffffffff811115610795578182fd5b6107a1858286016105af565b9150509250929050565b6000602082840312156107bc578081fd5b5035919050565b600082825180855260208086019550808260051b840101818601855b8481101561082357858303601f190189528151805115158452840151604085850181905261080f81860183610830565b9a86019a94505050908301906001016107df565b5090979650505050505050565b6000815180845261084881602086016020860161098d565b601f01601f19169290920160200192915050565b6000825161086e81846020870161098d565b9190910192915050565b60208152600061071760208301846107c3565b600060408201848352602060408185015281855180845260608601915060608160051b8701019350828701855b828110156108e657605f198887030184526108d4868351610830565b955092840192908401906001016108b8565b509398975050505050505050565b83815282602082015260606040820152600061091360608301846107c3565b95945050505050565b6040805190810167ffffffffffffffff8111828210171561093f5761093f6109ee565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561096e5761096e6109ee565b604052919050565b600082821015610988576109886109d8565b500390565b60005b838110156109a8578181015183820152602001610990565b838111156109b7576000848401525b50505050565b60006000198214156109d1576109d16109d8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fdfea26469706673582212208ce27062f90c79ed7f27c8144012cde5be3698e7a027a31b606eed6da200ac5564736f6c63430008040033"; const isSuperArgs = (xs) => xs.length > 1; class Multicall2__factory extends ethers.ContractFactory { constructor(...args) { if (isSuperArgs(args)) { super(...args); } else { super(_abi, _bytecode, args[0]); } } deploy(overrides) { return super.deploy(overrides || {}); } getDeployTransaction(overrides) { return super.getDeployTransaction(overrides || {}); } attach(address) { return super.attach(address); } connect(signer) { return super.connect(signer); } static createInterface() { return new ethers.utils.Interface(_abi); } static connect(address, signerOrProvider) { return new ethers.Contract(address, _abi, signerOrProvider); } } Multicall2__factory.bytecode = _bytecode; Multicall2__factory.abi = _abi; function resultToObject(input) { const keys = Object.keys(input).filter((key) => !key.isNumber()); const result = {}; for (const key of keys) { const value = input[key]; if (value instanceof bignumber.BigNumber) { result[key] = value.toString(); } else { result[key] = input[key]; } } return result; } function formatAllValues(data) { if (data instanceof bignumber.BigNumber) { return data.toString(); } else if (data instanceof BignumberJS) { return data.toFixed(); } else if (typeof data === 'function') { return null; } else if (typeof data === 'string' && data.isAddress()) { return data.toChecksumAddress(); } else if (Array.isArray(data)) { return data.map(formatAllValues); } else if (lodash.isObject(data)) { Object.keys(data).map((key) => { try { data[key] = formatAllValues(data[key]); } catch (error) { } }); } return data; } function parseAllBigNumbers(data) { if (data && data['type'] === 'BigNumber') { return bignumber.BigNumber.from(data['hex']); } else if (Array.isArray(data)) { return data.map(formatAllValues); } else if (lodash.isObject(data)) { Object.keys(data).map((key) => { try { data[key] = parseAllBigNumbers(data[key]); } catch (error) { } }); } return data; } function createProvider(urlOrPath) { if (urlOrPath.startsWith('ws')) return new providers.WebSocketProvider(urlOrPath); return new providers.IpcProvider(urlOrPath); } const VERSION = '0.0.1-rc.11'; Object.defineProperty(exports, 'isEmpty', { enumerable: true, get: function () { return lodash.isEmpty; } }); Object.defineProperty(exports, 'isObject', { enumerable: true, get: function () { return lodash.isObject; } }); exports.ERC20Abi = ERC20Abi; exports.MultiCall = MultiCall; exports.Multicall2__factory = Multicall2__factory; exports.MulticallAbi = MulticallAbi; exports.VERSION = VERSION; exports.createProvider = createProvider; exports.formatAllValues = formatAllValues; exports.parseAllBigNumbers = parseAllBigNumbers; exports.resultToObject = resultToObject; //# sourceMappingURL=index.js.map