dequanto 0.0.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +51 -0
- package/.github/workflows/npm-publish.yml +32 -0
- package/.vscode/settings.json +42 -11
- package/actions/chains.act.ts +136 -0
- package/actions/contracts.act.ts +178 -0
- package/actions/gen.act.ts +38 -38
- package/actions/logs.act.ts +7 -0
- package/actions/rpc.act.ts +918 -0
- package/actions/safe.act.ts +7 -0
- package/actions/tokens.act.ts +41 -12
- package/configs/defi.yml +28 -0
- package/configs/dequanto.yml +377 -51
- package/data/cex/eth.csv +356 -356
- package/data/chainlink/feeds.json +3674 -0
- package/data/chains/chains.json +972 -0
- package/data/evm/eventHashes.json +19314 -0
- package/data/evm/events.json +19314 -0
- package/data/evm/functionHashes.json +121138 -0
- package/data/evm/functions.json +121140 -0
- package/data/rpc/coregeth.json +1786 -0
- package/data/rpc/eth.json +5873 -0
- package/data/rpc/flashbots.json +662 -0
- package/data/rpc/metamask.json +3673 -0
- package/data/rpc/overrides.json +104 -0
- package/data/tokens/1inch.json +11107 -4733
- package/data/tokens/arbitrum.json +1 -1
- package/data/tokens/coingecko.json +118642 -0
- package/data/tokens/sushi.json +6067 -48632
- package/exports/core.lib.ts +103 -0
- package/hardhat.config.js +41 -1
- package/importmap.json +27 -0
- package/package-bundler.json +181 -0
- package/package.json +121 -49
- package/readme.md +22 -4
- package/src/ChainAccountService.ts +216 -0
- package/src/abi/$abiCoder.ts +62 -0
- package/src/abi/$rlp.ts +126 -0
- package/src/abi/Logger.ts +24 -0
- package/src/abi/_version.ts +1 -0
- package/src/abi/abi-coder-packed.ts +90 -0
- package/src/abi/abi-coder.ts +163 -0
- package/src/abi/coders/abstract-coder.ts +455 -0
- package/src/abi/coders/address.ts +39 -0
- package/src/abi/coders/anonymous.ts +29 -0
- package/src/abi/coders/array.ts +190 -0
- package/src/abi/coders/boolean.ts +25 -0
- package/src/abi/coders/bytes.ts +41 -0
- package/src/abi/coders/fixed-bytes.ts +36 -0
- package/src/abi/coders/null.ts +28 -0
- package/src/abi/coders/number.ts +59 -0
- package/src/abi/coders/string.ts +23 -0
- package/src/abi/coders/tuple.ts +61 -0
- package/src/abi/fragments.ts +1632 -0
- package/src/blocks/BlockDateResolver.ts +159 -149
- package/src/bridges/BridgeFactory.ts +16 -16
- package/src/bridges/hop/HopAddresses.ts +1 -1
- package/src/bridges/hop/HopBridge.ts +437 -430
- package/src/bridges/hop/contracts/gen.act.ts +51 -50
- package/src/bridges/models/IBridge.ts +44 -43
- package/src/chains/PlatformFactory.ts +46 -45
- package/src/chains/arbitrum/ArbTokenProvider.ts +39 -39
- package/src/chains/arbitrum/ArbWeb3Client.ts +21 -39
- package/src/chains/arbitrum/Arbiscan.ts +21 -24
- package/src/chains/arbitrum/TokensServiceArbitrum.ts +19 -0
- package/src/chains/boba/BobaWeb3Client.ts +21 -49
- package/src/chains/boba/Bobascan.ts +22 -25
- package/src/chains/xdai/XDaiWeb3Client.ts +56 -82
- package/src/chains/xdai/XDaiscan.ts +21 -24
- package/src/class/PackedRanges.ts +213 -0
- package/src/class/PromiseEvent.ts +21 -0
- package/src/class/SubjectKind.ts +5 -0
- package/src/class/SubjectStream.ts +137 -0
- package/src/class/Subscription.ts +7 -0
- package/src/clients/BscWeb3Client.ts +21 -38
- package/src/clients/ClientEventsStream.ts +95 -33
- package/src/clients/ClientPool.ts +616 -207
- package/src/clients/ClientPoolStats.ts +70 -64
- package/src/clients/EthWeb3Client.ts +23 -36
- package/src/clients/EvmWeb3Client.ts +26 -0
- package/src/clients/PolyWeb3Client.ts +42 -91
- package/src/clients/Web3BatchRequests.ts +119 -0
- package/src/clients/Web3Client.ts +700 -134
- package/src/clients/Web3ClientFactory.ts +31 -1
- package/src/clients/compatibility/Web3.ts +186 -0
- package/src/clients/debug/ClientDebugMethods.ts +100 -0
- package/src/clients/handlers/RateLimitGuard.ts +353 -0
- package/src/clients/interfaces/IWeb3Client.ts +63 -14
- package/src/clients/interfaces/IWeb3ClientStatus.ts +21 -23
- package/src/clients/interfaces/IWeb3EndpointOptions.ts +16 -9
- package/src/clients/model/ClientStatus.ts +6 -5
- package/src/clients/model/PromiEventWrap.ts +62 -61
- package/src/clients/model/SubscriptionWrap.ts +53 -53
- package/src/clients/utils/$web3Abi.ts +29 -0
- package/src/clients/utils/ClientEndpoints.ts +32 -26
- package/src/clients/utils/ClientErrorUtil.ts +29 -26
- package/src/clients/utils/TxFactory.ts +5 -17
- package/src/config/AConfigBase.ts +35 -0
- package/src/config/Config.ts +45 -0
- package/src/config/ConfigProvider.ts +4 -0
- package/src/config/ConfigProviderBrowser.ts +21 -0
- package/src/config/ConfigProviderIsoPlatform.ts +90 -0
- package/src/config/dequanto.d.ts +5 -0
- package/src/config/interface/IConfigData.ts +63 -0
- package/src/contracts/BscContract.ts +28 -28
- package/src/contracts/Contract.ts +120 -126
- package/src/contracts/ContractAbiProvider.ts +69 -0
- package/src/contracts/ContractBase.ts +496 -60
- package/src/contracts/ContractClassFactory.ts +114 -0
- package/src/contracts/ContractCreationResolver.ts +85 -0
- package/src/contracts/ContractProvider.ts +55 -55
- package/src/contracts/ContractReader.ts +339 -87
- package/src/contracts/ContractStorageReaderBase.ts +29 -0
- package/src/contracts/ContractStream.ts +34 -18
- package/src/contracts/ContractWriter.ts +139 -97
- package/src/contracts/EthContract.ts +29 -29
- package/src/contracts/TxContract.ts +39 -43
- package/src/contracts/deploy/ContractDeployer.ts +155 -0
- package/src/contracts/deploy/ContractDeployment.ts +53 -0
- package/src/contracts/deploy/ContractSource.ts +3 -0
- package/src/contracts/deploy/Deployments.ts +672 -0
- package/src/contracts/deploy/proxy/$proxyDeploy.ts +302 -0
- package/src/contracts/deploy/proxy/ProxyDeployment.ts +401 -0
- package/src/contracts/deploy/storage/DeploymentsStorage.ts +368 -0
- package/src/contracts/utils/AbiDeserializer.ts +111 -98
- package/src/contracts/utils/ContractBaseUtils.ts +105 -0
- package/src/contracts/utils/ConvertUtils.ts +16 -16
- package/src/contracts/utils/InputDataUtils.ts +32 -93
- package/src/contracts/utils/TypeUtils.ts +21 -21
- package/src/contracts/wrappers/FnRequestWrapper.ts +15 -0
- package/src/contracts/wrappers/FnSignedWrapper.ts +42 -0
- package/src/env/BigIntSerializer.ts +19 -18
- package/src/erc4337/Erc4337Factory.ts +54 -0
- package/src/erc4337/Erc4337Service.ts +219 -0
- package/src/erc4337/Erc4337TxWriter.ts +169 -0
- package/src/erc4337/models/Erc4337Abi.ts +7 -0
- package/src/erc4337/models/IErc4337Info.ts +8 -0
- package/src/erc4337/models/UserOperation.ts +18 -0
- package/src/erc4337/utils/$erc4337.ts +31 -0
- package/src/evm/EvmBytecode.ts +298 -0
- package/src/evm/OpcodesInfo.ts +211 -0
- package/src/evm/OpcodesWalker.ts +156 -0
- package/src/evm/Stack.ts +58 -0
- package/src/evm/functions/$opcodes.ts +122 -0
- package/src/evm/functions/opcodes.spec.ts +47 -0
- package/src/evm/interfaces/IJumps.ts +3 -0
- package/src/evm/interfaces/IMemory.ts +3 -0
- package/src/evm/interfaces/IOpcode.ts +11 -0
- package/src/evm/interfaces/IStorage.ts +3 -0
- package/src/evm/opcodes/add.ts +49 -0
- package/src/evm/opcodes/addmod.ts +19 -0
- package/src/evm/opcodes/address.ts +22 -0
- package/src/evm/opcodes/and.ts +58 -0
- package/src/evm/opcodes/balance.ts +25 -0
- package/src/evm/opcodes/blockhash.ts +25 -0
- package/src/evm/opcodes/byte.ts +34 -0
- package/src/evm/opcodes/call.ts +69 -0
- package/src/evm/opcodes/callcode.ts +69 -0
- package/src/evm/opcodes/calldatacopy.ts +36 -0
- package/src/evm/opcodes/calldataload.ts +40 -0
- package/src/evm/opcodes/calldatasize.ts +21 -0
- package/src/evm/opcodes/caller.ts +22 -0
- package/src/evm/opcodes/callvalue.ts +21 -0
- package/src/evm/opcodes/codecopy.ts +37 -0
- package/src/evm/opcodes/codesize.ts +21 -0
- package/src/evm/opcodes/coinbase.ts +21 -0
- package/src/evm/opcodes/create.ts +42 -0
- package/src/evm/opcodes/create2.ts +41 -0
- package/src/evm/opcodes/delegatecall.ts +63 -0
- package/src/evm/opcodes/difficulty.ts +21 -0
- package/src/evm/opcodes/div.ts +35 -0
- package/src/evm/opcodes/dup.ts +7 -0
- package/src/evm/opcodes/eq.ts +92 -0
- package/src/evm/opcodes/exp.ts +34 -0
- package/src/evm/opcodes/extcodecopy.ts +42 -0
- package/src/evm/opcodes/extcodehash.ts +25 -0
- package/src/evm/opcodes/extcodesize.ts +25 -0
- package/src/evm/opcodes/gas.ts +21 -0
- package/src/evm/opcodes/gaslimit.ts +21 -0
- package/src/evm/opcodes/gasprice.ts +21 -0
- package/src/evm/opcodes/gt.ts +39 -0
- package/src/evm/opcodes/invalid.ts +24 -0
- package/src/evm/opcodes/iszero.ts +48 -0
- package/src/evm/opcodes/jump.ts +66 -0
- package/src/evm/opcodes/jumpdest.ts +6 -0
- package/src/evm/opcodes/jumpi.ts +367 -0
- package/src/evm/opcodes/log.ts +89 -0
- package/src/evm/opcodes/lt.ts +39 -0
- package/src/evm/opcodes/mload.ts +30 -0
- package/src/evm/opcodes/mod.ts +33 -0
- package/src/evm/opcodes/msize.ts +21 -0
- package/src/evm/opcodes/mstore.ts +33 -0
- package/src/evm/opcodes/mul.ts +38 -0
- package/src/evm/opcodes/mulmod.ts +19 -0
- package/src/evm/opcodes/not.ts +30 -0
- package/src/evm/opcodes/number.ts +21 -0
- package/src/evm/opcodes/or.ts +33 -0
- package/src/evm/opcodes/origin.ts +21 -0
- package/src/evm/opcodes/pc.ts +7 -0
- package/src/evm/opcodes/pop.ts +6 -0
- package/src/evm/opcodes/push.ts +8 -0
- package/src/evm/opcodes/return.ts +78 -0
- package/src/evm/opcodes/returndatacopy.ts +37 -0
- package/src/evm/opcodes/returndatasize.ts +21 -0
- package/src/evm/opcodes/revert.ts +64 -0
- package/src/evm/opcodes/sar.ts +33 -0
- package/src/evm/opcodes/selfdestruct.ts +26 -0
- package/src/evm/opcodes/sha3.ts +63 -0
- package/src/evm/opcodes/shl.ts +42 -0
- package/src/evm/opcodes/shr.ts +33 -0
- package/src/evm/opcodes/signextend.ts +25 -0
- package/src/evm/opcodes/sload.ts +190 -0
- package/src/evm/opcodes/sstore.ts +259 -0
- package/src/evm/opcodes/staticcall.ts +63 -0
- package/src/evm/opcodes/stop.ts +22 -0
- package/src/evm/opcodes/sub.ts +33 -0
- package/src/evm/opcodes/swap.ts +7 -0
- package/src/evm/opcodes/timestamp.ts +21 -0
- package/src/evm/opcodes/xor.ts +33 -0
- package/src/evm/utils/$bytecode.ts +76 -0
- package/src/evm/utils/BigNumber.ts +9 -0
- package/src/evm/utils/hex.ts +37 -0
- package/src/evm/utils/opcodes.ts +213 -0
- package/src/evm/utils/stringify.ts +12 -0
- package/src/evm/utils/stringifyEvents.ts +37 -0
- package/src/evm/utils/stringifyFunctions.ts +41 -0
- package/src/evm/utils/stringifyInstructions.ts +38 -0
- package/src/evm/utils/stringifyMappings.ts +65 -0
- package/src/evm/utils/stringifyStructs.ts +16 -0
- package/src/evm/utils/stringifyVariables.ts +32 -0
- package/src/explorer/BlockChainExplorerFactory.ts +644 -0
- package/src/explorer/BlockChainExplorerProvider.ts +57 -0
- package/src/explorer/BlockChainExplorerStorage.ts +124 -0
- package/src/explorer/BlockNumberCache.ts +47 -0
- package/src/explorer/Bscscan.ts +24 -0
- package/src/explorer/ContractVerifier.ts +289 -0
- package/src/explorer/ContractVerifierHtml.ts +207 -0
- package/src/explorer/Etherscan.ts +37 -0
- package/src/explorer/Evmscan.ts +8 -0
- package/src/explorer/IAbiProvider.ts +5 -0
- package/src/explorer/IBlockChainExplorer.ts +69 -0
- package/src/explorer/Polyscan.ts +24 -0
- package/src/explorer/verifiers/FsHtmlVerifier.ts +195 -0
- package/src/explorer/verifiers/IVerifier.ts +14 -0
- package/src/flashbots/FlashbotWeb3Client.ts +24 -0
- package/src/flashbots/FlashbotsProvider.ts +163 -0
- package/src/gen/Ast.ts +12 -12
- package/src/gen/ContractStorageReaderTemplate.ts +18 -0
- package/src/gen/ContractTemplate.ts +134 -36
- package/src/gen/Generator.ts +414 -227
- package/src/gen/GeneratorFromAbi.ts +451 -128
- package/src/gen/GeneratorStorageReader.ts +114 -0
- package/src/gen/utils/$gen.ts +11 -0
- package/src/gen/utils/Str.ts +40 -0
- package/src/handlers/TokenHandler.ts +77 -78
- package/src/hardhat/HardhatProvider.ts +469 -0
- package/src/hardhat/HardhatWeb3Client.ts +66 -0
- package/src/indexer/BlocksTxIndexer.ts +116 -69
- package/src/indexer/EventsIndexer.ts +379 -0
- package/src/indexer/PendingTxIndexer.ts +123 -124
- package/src/indexer/handlers/BlocksWalker.ts +420 -390
- package/src/indexer/handlers/TxQueueLoader.ts +144 -143
- package/src/indexer/storage/FsEventsIndexerStore.ts +182 -0
- package/src/indexer/storage/FsEventsMetaStore.ts +65 -0
- package/src/indexer/storage/FsEventsStoreUtils.ts +43 -0
- package/src/indexer/storage/interfaces.ts +25 -0
- package/src/json/JsonArrayMultiStore.ts +219 -0
- package/src/json/JsonArrayStore.ts +193 -310
- package/src/json/JsonObjectStore.ts +78 -239
- package/src/json/JsonStoreFs.ts +187 -0
- package/src/loggers/ILogger.ts +6 -3
- package/src/loggers/LoggerService.ts +83 -39
- package/src/loggers/TxLoggerService.ts +144 -146
- package/src/models/IContractDetails.ts +10 -8
- package/src/models/IToken.ts +35 -11
- package/src/models/ITokenGlob.ts +14 -14
- package/src/models/ITransactionDetails.ts +10 -11
- package/src/models/TAccount.ts +53 -0
- package/src/models/TAddress.ts +2 -1
- package/src/models/TBufferLike.ts +2 -2
- package/src/models/TError.ts +4 -0
- package/src/models/TEth.ts +223 -0
- package/src/models/THex.ts +1 -1
- package/src/models/TPlatform.ts +16 -1
- package/src/models/TResult.ts +6 -6
- package/src/models/TTx.ts +42 -0
- package/src/ns/NameService.ts +54 -21
- package/src/ns/providers/ANsProvider.ts +110 -0
- package/src/ns/providers/EnsProvider.ts +109 -45
- package/src/ns/providers/INsProvider.ts +31 -6
- package/src/ns/providers/SpaceIdProvider.ts +17 -0
- package/src/ns/providers/UDProvider.ts +77 -49
- package/src/ns/utils/$ns.ts +27 -15
- package/src/prebuilt/1inch/OneInchRouterContract/OneInchRouterContract.ts +313 -0
- package/src/prebuilt/amm/AmmFactoryV2Contract/AmmFactoryV2Contract.ts +298 -0
- package/src/prebuilt/amm/AmmMasterChefV2Contract/AmmMasterChefV2Contract.ts +642 -0
- package/src/prebuilt/amm/AmmPairV2Contract/AmmPairV2Contract.ts +700 -0
- package/src/prebuilt/amm/AmmPairV3Contract/AmmPairV3Contract.ts +686 -0
- package/src/prebuilt/amm/AmmRouterV2Contract/AmmRouterV2Contract.ts +404 -0
- package/src/prebuilt/amm/AmmVaultV2Contract/AmmVaultV2Contract.ts +818 -0
- package/src/prebuilt/ens/EnsBaseRegistrar/EnsBaseRegistrar.ts +711 -0
- package/src/prebuilt/ens/EnsDnsRegistrar/EnsDnsRegistrar.ts +333 -0
- package/src/prebuilt/ens/EnsEthRegistrarController/EnsEthRegistrarController.ts +477 -0
- package/src/prebuilt/ens/EnsNameWrapper/EnsNameWrapper.ts +1003 -0
- package/src/prebuilt/ens/EnsPublicResolver/EnsPublicResolver.ts +873 -0
- package/src/prebuilt/ens/EnsRegistry/EnsRegistry.ts +415 -0
- package/src/prebuilt/ens/EnsReverseRegistrar/EnsReverseRegistrar.ts +407 -0
- package/src/prebuilt/erc4337/EntryPoint/EntryPoint.ts +640 -0
- package/src/prebuilt/erc4337/SimpleAccount/SimpleAccount.ts +501 -0
- package/src/prebuilt/erc4337/SimpleAccountFactory/SimpleAccountFactory.ts +184 -0
- package/src/prebuilt/openzeppelin/AccessControl.json +206 -0
- package/src/prebuilt/openzeppelin/AccessControl.ts +257 -0
- package/src/prebuilt/openzeppelin/AccessControlCrossChain.json +219 -0
- package/src/prebuilt/openzeppelin/AccessControlCrossChain.ts +266 -0
- package/src/prebuilt/openzeppelin/AccessControlDefaultAdminRules.json +391 -0
- package/src/prebuilt/openzeppelin/AccessControlDefaultAdminRules.ts +450 -0
- package/src/prebuilt/openzeppelin/AccessControlEnumerable.json +249 -0
- package/src/prebuilt/openzeppelin/AccessControlEnumerable.ts +275 -0
- package/src/prebuilt/openzeppelin/ConditionalEscrow.json +156 -0
- package/src/prebuilt/openzeppelin/ConditionalEscrow.ts +259 -0
- package/src/prebuilt/openzeppelin/CrossChainEnabledPolygonChild.json +30 -0
- package/src/prebuilt/openzeppelin/CrossChainEnabledPolygonChild.ts +150 -0
- package/src/prebuilt/openzeppelin/EIP712.json +67 -0
- package/src/prebuilt/openzeppelin/EIP712.ts +170 -0
- package/src/prebuilt/openzeppelin/ERC1155.json +325 -0
- package/src/prebuilt/openzeppelin/ERC1155.ts +291 -0
- package/src/prebuilt/openzeppelin/ERC1155Burnable.json +360 -0
- package/src/prebuilt/openzeppelin/ERC1155Burnable.ts +309 -0
- package/src/prebuilt/openzeppelin/ERC1155Holder.json +99 -0
- package/src/prebuilt/openzeppelin/ERC1155Holder.ts +163 -0
- package/src/prebuilt/openzeppelin/ERC1155Pausable.json +353 -0
- package/src/prebuilt/openzeppelin/ERC1155Pausable.ts +338 -0
- package/src/prebuilt/openzeppelin/ERC1155PresetMinterPauser.json +734 -0
- package/src/prebuilt/openzeppelin/ERC1155PresetMinterPauser.ts +567 -0
- package/src/prebuilt/openzeppelin/ERC1155Receiver.json +99 -0
- package/src/prebuilt/openzeppelin/ERC1155Receiver.ts +163 -0
- package/src/prebuilt/openzeppelin/ERC1155Supply.json +352 -0
- package/src/prebuilt/openzeppelin/ERC1155Supply.ts +305 -0
- package/src/prebuilt/openzeppelin/ERC1155URIStorage.json +314 -0
- package/src/prebuilt/openzeppelin/ERC1155URIStorage.ts +287 -0
- package/src/prebuilt/openzeppelin/ERC165.json +21 -0
- package/src/prebuilt/openzeppelin/ERC165.ts +143 -0
- package/src/prebuilt/openzeppelin/ERC165Storage.json +21 -0
- package/src/prebuilt/openzeppelin/ERC165Storage.ts +143 -0
- package/src/prebuilt/openzeppelin/ERC1820Implementer.json +26 -0
- package/src/prebuilt/openzeppelin/ERC1820Implementer.ts +143 -0
- package/src/prebuilt/openzeppelin/ERC20.json +288 -0
- package/src/prebuilt/openzeppelin/ERC20.ts +280 -0
- package/src/prebuilt/openzeppelin/ERC20Burnable.json +303 -0
- package/src/prebuilt/openzeppelin/ERC20Burnable.ts +298 -0
- package/src/prebuilt/openzeppelin/ERC20Capped.json +285 -0
- package/src/prebuilt/openzeppelin/ERC20Capped.ts +285 -0
- package/src/prebuilt/openzeppelin/ERC20FlashMint.json +349 -0
- package/src/prebuilt/openzeppelin/ERC20FlashMint.ts +305 -0
- package/src/prebuilt/openzeppelin/ERC20Pausable.json +311 -0
- package/src/prebuilt/openzeppelin/ERC20Pausable.ts +327 -0
- package/src/prebuilt/openzeppelin/ERC20Permit.json +412 -0
- package/src/prebuilt/openzeppelin/ERC20Permit.ts +348 -0
- package/src/prebuilt/openzeppelin/ERC20PresetFixedSupply.json +329 -0
- package/src/prebuilt/openzeppelin/ERC20PresetFixedSupply.ts +302 -0
- package/src/prebuilt/openzeppelin/ERC20PresetMinterPauser.json +663 -0
- package/src/prebuilt/openzeppelin/ERC20PresetMinterPauser.ts +554 -0
- package/src/prebuilt/openzeppelin/ERC20Snapshot.json +328 -0
- package/src/prebuilt/openzeppelin/ERC20Snapshot.ts +315 -0
- package/src/prebuilt/openzeppelin/ERC20Votes.json +675 -0
- package/src/prebuilt/openzeppelin/ERC20Votes.ts +484 -0
- package/src/prebuilt/openzeppelin/ERC20VotesComp.json +718 -0
- package/src/prebuilt/openzeppelin/ERC20VotesComp.ts +502 -0
- package/src/prebuilt/openzeppelin/ERC20Wrapper.json +333 -0
- package/src/prebuilt/openzeppelin/ERC20Wrapper.ts +307 -0
- package/src/prebuilt/openzeppelin/ERC2771Context.json +21 -0
- package/src/prebuilt/openzeppelin/ERC2771Context.ts +143 -0
- package/src/prebuilt/openzeppelin/ERC2981.json +50 -0
- package/src/prebuilt/openzeppelin/ERC2981.ts +152 -0
- package/src/prebuilt/openzeppelin/ERC4626.json +662 -0
- package/src/prebuilt/openzeppelin/ERC4626.ts +470 -0
- package/src/prebuilt/openzeppelin/ERC721.json +348 -0
- package/src/prebuilt/openzeppelin/ERC721.ts +314 -0
- package/src/prebuilt/openzeppelin/ERC721Burnable.json +345 -0
- package/src/prebuilt/openzeppelin/ERC721Burnable.ts +321 -0
- package/src/prebuilt/openzeppelin/ERC721Consecutive.json +363 -0
- package/src/prebuilt/openzeppelin/ERC721Consecutive.ts +331 -0
- package/src/prebuilt/openzeppelin/ERC721Enumerable.json +388 -0
- package/src/prebuilt/openzeppelin/ERC721Enumerable.ts +337 -0
- package/src/prebuilt/openzeppelin/ERC721Holder.json +36 -0
- package/src/prebuilt/openzeppelin/ERC721Holder.ts +143 -0
- package/src/prebuilt/openzeppelin/ERC721Pausable.json +371 -0
- package/src/prebuilt/openzeppelin/ERC721Pausable.ts +361 -0
- package/src/prebuilt/openzeppelin/ERC721PresetMinterPauserAutoId.json +742 -0
- package/src/prebuilt/openzeppelin/ERC721PresetMinterPauserAutoId.ts +595 -0
- package/src/prebuilt/openzeppelin/ERC721Royalty.json +361 -0
- package/src/prebuilt/openzeppelin/ERC721Royalty.ts +319 -0
- package/src/prebuilt/openzeppelin/ERC721URIStorage.json +364 -0
- package/src/prebuilt/openzeppelin/ERC721URIStorage.ts +352 -0
- package/src/prebuilt/openzeppelin/ERC721Votes.json +637 -0
- package/src/prebuilt/openzeppelin/ERC721Votes.ts +489 -0
- package/src/prebuilt/openzeppelin/ERC721Wrapper.json +427 -0
- package/src/prebuilt/openzeppelin/ERC721Wrapper.ts +352 -0
- package/src/prebuilt/openzeppelin/ERC777.json +578 -0
- package/src/prebuilt/openzeppelin/ERC777.ts +456 -0
- package/src/prebuilt/openzeppelin/ERC777PresetFixedSupply.json +588 -0
- package/src/prebuilt/openzeppelin/ERC777PresetFixedSupply.ts +456 -0
- package/src/prebuilt/openzeppelin/Escrow.json +137 -0
- package/src/prebuilt/openzeppelin/Escrow.ts +250 -0
- package/src/prebuilt/openzeppelin/Governor.json +1010 -0
- package/src/prebuilt/openzeppelin/Governor.ts +590 -0
- package/src/prebuilt/openzeppelin/GovernorCompatibilityBravo.json +1325 -0
- package/src/prebuilt/openzeppelin/GovernorCompatibilityBravo.ts +700 -0
- package/src/prebuilt/openzeppelin/GovernorCountingSimple.json +1039 -0
- package/src/prebuilt/openzeppelin/GovernorCountingSimple.ts +599 -0
- package/src/prebuilt/openzeppelin/GovernorPreventLateQuorum.json +1074 -0
- package/src/prebuilt/openzeppelin/GovernorPreventLateQuorum.ts +652 -0
- package/src/prebuilt/openzeppelin/GovernorProposalThreshold.json +1010 -0
- package/src/prebuilt/openzeppelin/GovernorProposalThreshold.ts +590 -0
- package/src/prebuilt/openzeppelin/GovernorSettings.json +1106 -0
- package/src/prebuilt/openzeppelin/GovernorSettings.ts +686 -0
- package/src/prebuilt/openzeppelin/GovernorTimelockCompound.json +1134 -0
- package/src/prebuilt/openzeppelin/GovernorTimelockCompound.ts +683 -0
- package/src/prebuilt/openzeppelin/GovernorTimelockControl.json +1127 -0
- package/src/prebuilt/openzeppelin/GovernorTimelockControl.ts +672 -0
- package/src/prebuilt/openzeppelin/GovernorVotes.json +1023 -0
- package/src/prebuilt/openzeppelin/GovernorVotes.ts +599 -0
- package/src/prebuilt/openzeppelin/GovernorVotesComp.json +1023 -0
- package/src/prebuilt/openzeppelin/GovernorVotesComp.ts +599 -0
- package/src/prebuilt/openzeppelin/GovernorVotesQuorumFraction.json +1100 -0
- package/src/prebuilt/openzeppelin/GovernorVotesQuorumFraction.ts +653 -0
- package/src/prebuilt/openzeppelin/IAMB.json +327 -0
- package/src/prebuilt/openzeppelin/IAMB.ts +330 -0
- package/src/prebuilt/openzeppelin/IAccessControl.json +174 -0
- package/src/prebuilt/openzeppelin/IAccessControl.ts +239 -0
- package/src/prebuilt/openzeppelin/IAccessControlDefaultAdminRules.json +346 -0
- package/src/prebuilt/openzeppelin/IAccessControlDefaultAdminRules.ts +423 -0
- package/src/prebuilt/openzeppelin/IAccessControlEnumerable.json +217 -0
- package/src/prebuilt/openzeppelin/IAccessControlEnumerable.ts +257 -0
- package/src/prebuilt/openzeppelin/IArbSys.json +355 -0
- package/src/prebuilt/openzeppelin/IArbSys.ts +300 -0
- package/src/prebuilt/openzeppelin/IBeacon.json +15 -0
- package/src/prebuilt/openzeppelin/IBeacon.ts +143 -0
- package/src/prebuilt/openzeppelin/IBridge.json +529 -0
- package/src/prebuilt/openzeppelin/IBridge.ts +430 -0
- package/src/prebuilt/openzeppelin/ICompoundTimelock.json +415 -0
- package/src/prebuilt/openzeppelin/ICompoundTimelock.ts +380 -0
- package/src/prebuilt/openzeppelin/ICrossDomainMessenger.json +101 -0
- package/src/prebuilt/openzeppelin/ICrossDomainMessenger.ts +208 -0
- package/src/prebuilt/openzeppelin/IERC1155.json +295 -0
- package/src/prebuilt/openzeppelin/IERC1155.ts +278 -0
- package/src/prebuilt/openzeppelin/IERC1155MetadataURI.json +314 -0
- package/src/prebuilt/openzeppelin/IERC1155MetadataURI.ts +287 -0
- package/src/prebuilt/openzeppelin/IERC1155Receiver.json +99 -0
- package/src/prebuilt/openzeppelin/IERC1155Receiver.ts +163 -0
- package/src/prebuilt/openzeppelin/IERC1271.json +26 -0
- package/src/prebuilt/openzeppelin/IERC1271.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC1363.json +373 -0
- package/src/prebuilt/openzeppelin/IERC1363.ts +287 -0
- package/src/prebuilt/openzeppelin/IERC1363Receiver.json +36 -0
- package/src/prebuilt/openzeppelin/IERC1363Receiver.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC1363Spender.json +31 -0
- package/src/prebuilt/openzeppelin/IERC1363Spender.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC165.json +21 -0
- package/src/prebuilt/openzeppelin/IERC165.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC1820Implementer.json +26 -0
- package/src/prebuilt/openzeppelin/IERC1820Implementer.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC1820Registry.json +215 -0
- package/src/prebuilt/openzeppelin/IERC1820Registry.ts +245 -0
- package/src/prebuilt/openzeppelin/IERC1822Proxiable.json +15 -0
- package/src/prebuilt/openzeppelin/IERC1822Proxiable.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC20.json +185 -0
- package/src/prebuilt/openzeppelin/IERC20.ts +227 -0
- package/src/prebuilt/openzeppelin/IERC20Metadata.json +224 -0
- package/src/prebuilt/openzeppelin/IERC20Metadata.ts +254 -0
- package/src/prebuilt/openzeppelin/IERC20Permit.json +77 -0
- package/src/prebuilt/openzeppelin/IERC20Permit.ts +161 -0
- package/src/prebuilt/openzeppelin/IERC2612.json +77 -0
- package/src/prebuilt/openzeppelin/IERC2612.ts +161 -0
- package/src/prebuilt/openzeppelin/IERC2981.json +50 -0
- package/src/prebuilt/openzeppelin/IERC2981.ts +152 -0
- package/src/prebuilt/openzeppelin/IERC3156FlashBorrower.json +41 -0
- package/src/prebuilt/openzeppelin/IERC3156FlashBorrower.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC3156FlashLender.json +79 -0
- package/src/prebuilt/openzeppelin/IERC3156FlashLender.ts +161 -0
- package/src/prebuilt/openzeppelin/IERC4626.json +614 -0
- package/src/prebuilt/openzeppelin/IERC4626.ts +448 -0
- package/src/prebuilt/openzeppelin/IERC4906.json +319 -0
- package/src/prebuilt/openzeppelin/IERC4906.ts +325 -0
- package/src/prebuilt/openzeppelin/IERC5267.json +51 -0
- package/src/prebuilt/openzeppelin/IERC5267.ts +157 -0
- package/src/prebuilt/openzeppelin/IERC5313.json +15 -0
- package/src/prebuilt/openzeppelin/IERC5313.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC5805.json +210 -0
- package/src/prebuilt/openzeppelin/IERC5805.ts +243 -0
- package/src/prebuilt/openzeppelin/IERC6372.json +28 -0
- package/src/prebuilt/openzeppelin/IERC6372.ts +152 -0
- package/src/prebuilt/openzeppelin/IERC721.json +287 -0
- package/src/prebuilt/openzeppelin/IERC721.ts +283 -0
- package/src/prebuilt/openzeppelin/IERC721Enumerable.json +343 -0
- package/src/prebuilt/openzeppelin/IERC721Enumerable.ts +310 -0
- package/src/prebuilt/openzeppelin/IERC721Metadata.json +332 -0
- package/src/prebuilt/openzeppelin/IERC721Metadata.ts +310 -0
- package/src/prebuilt/openzeppelin/IERC721Receiver.json +36 -0
- package/src/prebuilt/openzeppelin/IERC721Receiver.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC777.json +393 -0
- package/src/prebuilt/openzeppelin/IERC777.ts +359 -0
- package/src/prebuilt/openzeppelin/IERC777Recipient.json +40 -0
- package/src/prebuilt/openzeppelin/IERC777Recipient.ts +143 -0
- package/src/prebuilt/openzeppelin/IERC777Sender.json +40 -0
- package/src/prebuilt/openzeppelin/IERC777Sender.ts +143 -0
- package/src/prebuilt/openzeppelin/IFxMessageProcessor.json +25 -0
- package/src/prebuilt/openzeppelin/IFxMessageProcessor.ts +143 -0
- package/src/prebuilt/openzeppelin/IGovernor.json +762 -0
- package/src/prebuilt/openzeppelin/IGovernor.ts +471 -0
- package/src/prebuilt/openzeppelin/IGovernorCompatibilityBravo.json +992 -0
- package/src/prebuilt/openzeppelin/IGovernorCompatibilityBravo.ts +536 -0
- package/src/prebuilt/openzeppelin/IGovernorTimelock.json +847 -0
- package/src/prebuilt/openzeppelin/IGovernorTimelock.ts +521 -0
- package/src/prebuilt/openzeppelin/IInbox.json +444 -0
- package/src/prebuilt/openzeppelin/IInbox.ts +337 -0
- package/src/prebuilt/openzeppelin/IOutbox.json +410 -0
- package/src/prebuilt/openzeppelin/IOutbox.ts +317 -0
- package/src/prebuilt/openzeppelin/ITransparentUpgradeableProxy.json +117 -0
- package/src/prebuilt/openzeppelin/ITransparentUpgradeableProxy.ts +239 -0
- package/src/prebuilt/openzeppelin/IVotes.json +184 -0
- package/src/prebuilt/openzeppelin/IVotes.ts +225 -0
- package/src/prebuilt/openzeppelin/LibArbitrumL2.json +15 -0
- package/src/prebuilt/openzeppelin/LibArbitrumL2.ts +143 -0
- package/src/prebuilt/openzeppelin/MinimalForwarder.json +208 -0
- package/src/prebuilt/openzeppelin/MinimalForwarder.ts +201 -0
- package/src/prebuilt/openzeppelin/Multicall.json +21 -0
- package/src/prebuilt/openzeppelin/Multicall.ts +143 -0
- package/src/prebuilt/openzeppelin/Ownable.json +54 -0
- package/src/prebuilt/openzeppelin/Ownable.ts +177 -0
- package/src/prebuilt/openzeppelin/Ownable2Step.json +93 -0
- package/src/prebuilt/openzeppelin/Ownable2Step.ts +218 -0
- package/src/prebuilt/openzeppelin/Pausable.json +41 -0
- package/src/prebuilt/openzeppelin/Pausable.ts +178 -0
- package/src/prebuilt/openzeppelin/PaymentSplitter.json +304 -0
- package/src/prebuilt/openzeppelin/PaymentSplitter.ts +296 -0
- package/src/prebuilt/openzeppelin/ProxyAdmin.json +151 -0
- package/src/prebuilt/openzeppelin/ProxyAdmin.ts +228 -0
- package/src/prebuilt/openzeppelin/PullPayment.json +34 -0
- package/src/prebuilt/openzeppelin/PullPayment.ts +152 -0
- package/src/prebuilt/openzeppelin/RefundEscrow.json +226 -0
- package/src/prebuilt/openzeppelin/RefundEscrow.ts +356 -0
- package/src/prebuilt/openzeppelin/TimelockController.json +891 -0
- package/src/prebuilt/openzeppelin/TimelockController.ts +573 -0
- package/src/prebuilt/openzeppelin/TokenTimelock.json +69 -0
- package/src/prebuilt/openzeppelin/TokenTimelock.ts +174 -0
- package/src/prebuilt/openzeppelin/UUPSUpgradeable.json +91 -0
- package/src/prebuilt/openzeppelin/UUPSUpgradeable.ts +219 -0
- package/src/prebuilt/openzeppelin/UpgradeableBeacon.json +104 -0
- package/src/prebuilt/openzeppelin/UpgradeableBeacon.ts +222 -0
- package/src/prebuilt/openzeppelin/VestingWallet.json +225 -0
- package/src/prebuilt/openzeppelin/VestingWallet.ts +254 -0
- package/src/prebuilt/openzeppelin/Votes.json +307 -0
- package/src/prebuilt/openzeppelin/Votes.ts +304 -0
- package/src/prebuilt/openzeppelin/compiled/TransparentUpgradeableProxy/TransparentUpgradeableProxy.ts +214 -0
- package/src/prebuilt/safe/CreateCall.ts +168 -0
- package/src/prebuilt/safe/GnosisSafe.ts +683 -0
- package/src/prebuilt/safe/MultiSend.ts +147 -0
- package/src/prebuilt/safe/Safe.ts +742 -0
- package/src/prebuilt/safe/SafeL2.ts +780 -0
- package/src/prebuilt/safe/SafeProxyFactory.ts +197 -0
- package/src/prebuilt/weth/WETH/WETH.ts +390 -0
- package/src/rpc/$rpc.ts +124 -0
- package/src/rpc/Rpc.ts +3010 -0
- package/src/rpc/RpcBase.ts +154 -0
- package/src/rpc/RpcContract.ts +179 -0
- package/src/rpc/RpcError.ts +41 -0
- package/src/rpc/RpcFunction.ts +42 -0
- package/src/rpc/RpcHandler.ts +3 -0
- package/src/rpc/RpcModelMiddleware.ts +110 -0
- package/src/rpc/RpcSubscription.ts +46 -0
- package/src/rpc/transports/HttpTransport.ts +54 -0
- package/src/rpc/transports/ITransport.ts +87 -0
- package/src/rpc/transports/MessageBasedTransport.ts +133 -0
- package/src/rpc/transports/RpcTransport.ts +66 -0
- package/src/rpc/transports/WsTransport.ts +87 -0
- package/src/rpc/transports/WsTransportIsomorphic.ts +26 -0
- package/src/rpc/transports/compatibility/EIP1193Transport.ts +38 -0
- package/src/rpc/transports/compatibility/Web3Transport.ts +35 -0
- package/src/safe/$gnosis.ts +7 -0
- package/src/safe/GnosisSafeFactory.ts +104 -0
- package/src/safe/GnosisSafeHandler.ts +472 -0
- package/src/safe/GnosisSafeService.ts +86 -0
- package/src/safe/SafeTx.ts +93 -0
- package/src/safe/abi/GnosisSafe.json +979 -0
- package/src/safe/abi/v1_4_1/CreateCall.json +68 -0
- package/src/safe/abi/v1_4_1/MultiSend.json +20 -0
- package/src/safe/abi/v1_4_1/Safe.json +999 -0
- package/src/safe/abi/v1_4_1/SafeL2.json +1104 -0
- package/src/safe/abi/v1_4_1/SafeProxyFactory.json +139 -0
- package/src/safe/transport/FileServiceTransport.ts +109 -0
- package/src/safe/transport/ISafeServiceTransport.ts +20 -0
- package/src/safe/transport/InMemoryServiceTransport.ts +84 -0
- package/src/safe/transport/SafeServiceTransport.ts +148 -0
- package/src/safe/types/SafeServiceTypes.ts +326 -0
- package/src/services/TimelockService.ts +666 -0
- package/src/solidity/SlotsDump.ts +245 -0
- package/src/solidity/SlotsParser/Ast.ts +601 -0
- package/src/solidity/SlotsParser/MappingSettersResolver.ts +681 -0
- package/src/solidity/SlotsParser/SourceFile.ts +240 -0
- package/src/solidity/SlotsParser/models.ts +32 -0
- package/src/solidity/SlotsParser.ts +497 -0
- package/src/solidity/SlotsStorage.ts +209 -0
- package/src/solidity/SolidityParser.ts +108 -0
- package/src/solidity/SourceCodeProvider.ts +83 -0
- package/src/solidity/storage/Accessor.spec.ts +45 -0
- package/src/solidity/storage/Accessor.ts +136 -0
- package/src/solidity/storage/MappingKeysLoader.ts +112 -0
- package/src/solidity/storage/SlotDynamicArray.ts +46 -0
- package/src/solidity/storage/SlotFixedArray.ts +31 -0
- package/src/solidity/storage/SlotsStorageHandler.ts +18 -0
- package/src/solidity/storage/SlotsStorageTransport.ts +215 -0
- package/src/solidity/storage/handlers/SlotBytesHandler.ts +135 -0
- package/src/solidity/storage/handlers/SlotDynamicArrayHandler.ts +58 -0
- package/src/solidity/storage/handlers/SlotFixedArrayHandler.ts +58 -0
- package/src/solidity/storage/handlers/SlotMappingHandler.ts +75 -0
- package/src/solidity/storage/handlers/SlotStringHandler.ts +27 -0
- package/src/solidity/storage/handlers/SlotStructHandler.ts +47 -0
- package/src/solidity/storage/handlers/SlotValueConstantHandler.ts +30 -0
- package/src/solidity/storage/handlers/SlotValueHandler.ts +36 -0
- package/src/solidity/storage/handlers/SlotValueImmutableHandler.ts +49 -0
- package/src/solidity/utils/$str.ts +73 -0
- package/src/solidity/utils/$types.ts +61 -0
- package/src/tokens/TokenDataProvider.ts +284 -0
- package/src/tokens/TokenExchangeService.ts +129 -126
- package/src/tokens/TokenExchanges/AmmBase/AmmUtilts.ts +16 -16
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.ts +228 -208
- package/src/tokens/TokenExchanges/AmmV2ExchangeBase.ts +242 -242
- package/src/tokens/TokenExchanges/AmmV2PriceQuote.ts +433 -0
- package/src/tokens/TokenExchanges/OneInchExchange.ts +114 -111
- package/src/tokens/TokenExchanges/PancakeswapExchange.ts +25 -30
- package/src/tokens/TokenExchanges/SushiswapPolygonExchange.ts +33 -30
- package/src/tokens/TokenExchanges/UniswapV2Exchange.ts +28 -0
- package/src/tokens/TokenOracles/IOracle.ts +36 -0
- package/src/tokens/TokenOracles/TokenPriceStore.ts +130 -129
- package/src/tokens/TokenOracles/amm/AmmV1Oracle.ts +219 -0
- package/src/tokens/TokenOracles/amm/AmmV2Oracle.ts +57 -0
- package/src/tokens/TokenOracles/chainlink/ChainlinkFeedProvider.ts +133 -0
- package/src/tokens/TokenOracles/chainlink/ChainlinkOracle.ts +135 -0
- package/src/tokens/TokenOracles/coingecko/CoingeckoOracle.ts +121 -0
- package/src/tokens/TokenOracles/coingecko/CoingeckoTokenProvider.ts +51 -0
- package/src/tokens/TokenPriceService.ts +273 -276
- package/src/tokens/TokenPriceServiceProvider.ts +36 -36
- package/src/tokens/TokenProviders/ITokenProvider.ts +9 -9
- package/src/tokens/TokenProviders/TPChain.ts +53 -41
- package/src/tokens/TokenProviders/TPCoingecko.ts +177 -0
- package/src/tokens/TokenProviders/TPCoinmarketcap.ts +82 -82
- package/src/tokens/TokenProviders/TPConfig.ts +53 -0
- package/src/tokens/TokenProviders/TPExplorer.ts +41 -0
- package/src/tokens/TokenProviders/TPOneInch.ts +71 -71
- package/src/tokens/TokenProviders/TPSushiswap.ts +88 -96
- package/src/tokens/TokenProviders/TPUniswap.ts +87 -85
- package/src/tokens/TokenService.ts +142 -128
- package/src/tokens/TokenSwapService.ts +44 -47
- package/src/tokens/TokenTransferService.ts +233 -216
- package/src/tokens/TokensService.ts +42 -186
- package/src/tokens/TokensServiceBsc.ts +17 -17
- package/src/tokens/TokensServiceEth.ts +9 -9
- package/src/tokens/TokensServiceFactory.ts +15 -1
- package/src/tokens/TokensServicePolygon.ts +17 -17
- package/src/tokens/TokensServiceXDai.ts +26 -26
- package/src/tokens/defi/ISwapService.ts +12 -12
- package/src/tokens/defi/paraswap/Paraswap.ts +242 -244
- package/src/tokens/utils/TokenUtils.ts +63 -63
- package/src/txs/ITxBuilderOptions.ts +41 -0
- package/src/txs/TxDataBuilder.ts +308 -207
- package/src/txs/TxLogger.ts +120 -121
- package/src/txs/TxNonceManager.ts +86 -0
- package/src/txs/TxProvider.ts +70 -68
- package/src/txs/TxService.ts +20 -19
- package/src/txs/TxWriter.ts +342 -78
- package/src/txs/agents/Erc4337Agent.ts +32 -0
- package/src/txs/agents/SafeAgent.ts +20 -0
- package/src/txs/agents/TxWriterAccountAgents.ts +27 -0
- package/src/txs/conditional/GasWatcherLogger.ts +57 -57
- package/src/txs/conditional/GasWatcherService.ts +116 -117
- package/src/txs/conditional/GasWatcherStore.ts +41 -40
- package/src/txs/conditional/GasWatcherTx.ts +142 -143
- package/src/txs/receipt/ITxLogItem.ts +31 -25
- package/src/txs/receipt/TxLogParser.ts +56 -29
- package/src/txs/receipt/TxLogsTransfer.ts +61 -61
- package/src/txs/receipt/TxTopicInMemoryProvider.ts +45 -45
- package/src/txs/receipt/TxTopicProvider.ts +29 -29
- package/src/txs/sig-transports/SigFileTransport.ts +49 -0
- package/src/types/TAbi.ts +32 -0
- package/src/utils/$abiParser.ts +245 -179
- package/src/utils/$abiType.ts +277 -85
- package/src/utils/$abiUtils.ts +332 -38
- package/src/utils/$account.ts +48 -0
- package/src/utils/$address.ts +71 -37
- package/src/utils/$array.ts +113 -57
- package/src/utils/$base.ts +67 -0
- package/src/utils/$bigfloat.ts +562 -0
- package/src/utils/$bigint.ts +238 -127
- package/src/utils/$block.ts +20 -7
- package/src/utils/$bloom.ts +43 -0
- package/src/utils/$buffer.ts +196 -0
- package/src/utils/$cache.ts +7 -0
- package/src/utils/$class.ts +8 -8
- package/src/utils/$cli.ts +42 -0
- package/src/utils/$color.ts +213 -0
- package/src/utils/$config.ts +80 -17
- package/src/utils/$const.ts +1 -0
- package/src/utils/$contract.ts +309 -67
- package/src/utils/$crypto.ts +223 -0
- package/src/utils/$csv.ts +70 -54
- package/src/utils/$date.ts +697 -473
- package/src/utils/$error.ts +16 -0
- package/src/utils/$fn.ts +134 -134
- package/src/utils/$gas.ts +26 -0
- package/src/utils/$hex.ts +133 -0
- package/src/utils/$http.ts +219 -0
- package/src/utils/$is.ts +73 -37
- package/src/utils/$logger.ts +216 -10
- package/src/utils/$machine.ts +85 -0
- package/src/utils/$number.ts +135 -89
- package/src/utils/$object.ts +95 -95
- package/src/utils/$path.ts +76 -32
- package/src/utils/$perf.ts +20 -0
- package/src/utils/$platform.ts +5 -0
- package/src/utils/$promise.ts +154 -7
- package/src/utils/$regexp.ts +16 -0
- package/src/utils/$require.ts +212 -118
- package/src/utils/$secret.ts +27 -0
- package/src/utils/$semver.ts +27 -0
- package/src/utils/$sig.ts +722 -0
- package/src/utils/$sign.ts +136 -36
- package/src/utils/$signRaw.ts +50 -0
- package/src/utils/$signRawNative.ts +105 -0
- package/src/utils/$signSerializer.ts +27 -21
- package/src/utils/$txData.ts +23 -0
- package/src/utils/$wallet.ts +3 -10
- package/src/utils/types.ts +58 -29
- package/src/wallets/Wallet.ts +33 -33
- package/src/wallets/WalletBsc.ts +13 -13
- package/src/wallets/WalletService.ts +43 -43
- package/test/Batch.spec.ts +89 -0
- package/test/BlockChainExplorer.spec.ts +24 -0
- package/test/ChainAccount.spec.ts +52 -9
- package/test/Fixtures.ts +36 -0
- package/test/Web3Client.spec.ts +81 -0
- package/test/browser/block.spec.ts +9 -0
- package/test/client/block.spec.ts +19 -0
- package/test/config.js +68 -0
- package/test/config.spec.ts +31 -0
- package/test/config.yml +4 -0
- package/test/contracts/ContractCreationResolver.spec.ts +26 -0
- package/test/ecrecover.spec.ts +63 -0
- package/test/erc2612/PermitToken.sol +10 -0
- package/test/erc4337/erc4337.spec.ts +407 -0
- package/test/fixtures/DaiTokenContract.ts +13 -13
- package/test/fixtures/abi/deployments.json +105 -0
- package/test/fixtures/abi/encode.json +23798 -0
- package/test/fixtures/abi/encodePacked.json +34586 -0
- package/test/fixtures/artifacts/AnyERC20/AnyERC20.json +340 -0
- package/test/fixtures/artifacts/AnyERC20/AnyERC20.sol +15 -0
- package/test/fixtures/contracts/AlphaKlimaSimple.sol +36 -0
- package/test/fixtures/contracts/Counter.sol +25 -0
- package/test/fixtures/contracts/Ecrecover.sol +33 -0
- package/test/fixtures/contracts/Foo.sol +49 -0
- package/test/fixtures/contracts/FooErc20.sol +7 -0
- package/test/fixtures/contracts/FooNestedModel.sol +6 -0
- package/test/fixtures/contracts/FreeToken.sol +263 -0
- package/test/fixtures/deployments/DeploymentsFoo.sol +14 -0
- package/test/fixtures/deployments/DeploymentsFooV2.sol +11 -0
- package/test/fixtures/deployments/DeploymentsFooV3.sol +12 -0
- package/test/fixtures/erc4337/core/BaseAccount.sol +107 -0
- package/test/fixtures/erc4337/core/BasePaymaster.sol +112 -0
- package/test/fixtures/erc4337/core/EntryPoint.sol +631 -0
- package/test/fixtures/erc4337/core/Helpers.sol +81 -0
- package/test/fixtures/erc4337/core/NonceManager.sol +40 -0
- package/test/fixtures/erc4337/core/SenderCreator.sol +28 -0
- package/test/fixtures/erc4337/core/StakeManager.sol +124 -0
- package/test/fixtures/erc4337/interfaces/IAccount.sol +34 -0
- package/test/fixtures/erc4337/interfaces/IAggregator.sol +36 -0
- package/test/fixtures/erc4337/interfaces/IEntryPoint.sol +205 -0
- package/test/fixtures/erc4337/interfaces/INonceManager.sol +27 -0
- package/test/fixtures/erc4337/interfaces/IPaymaster.sol +51 -0
- package/test/fixtures/erc4337/interfaces/IStakeManager.sol +104 -0
- package/test/fixtures/erc4337/interfaces/UserOperation.sol +91 -0
- package/test/fixtures/erc4337/samples/DepositPaymaster.sol +167 -0
- package/test/fixtures/erc4337/samples/IOracle.sol +11 -0
- package/test/fixtures/erc4337/samples/SimpleAccount.sol +138 -0
- package/test/fixtures/erc4337/samples/SimpleAccountFactory.sol +52 -0
- package/test/fixtures/erc4337/samples/TokenPaymaster.sol +113 -0
- package/test/fixtures/erc4337/samples/VerifyingPaymaster.sol +104 -0
- package/test/fixtures/erc4337/samples/bls/BLSAccount.sol +64 -0
- package/test/fixtures/erc4337/samples/bls/BLSAccountFactory.sol +61 -0
- package/test/fixtures/erc4337/samples/bls/BLSHelper.sol +232 -0
- package/test/fixtures/erc4337/samples/bls/BLSSignatureAggregator.sol +164 -0
- package/test/fixtures/erc4337/samples/bls/IBLSAccount.sol +16 -0
- package/test/fixtures/erc4337/samples/bls/lib/BLSOpen.sol +64 -0
- package/test/fixtures/erc4337/samples/bls/lib/hubble-contracts/contracts/libs/BLS.sol +440 -0
- package/test/fixtures/erc4337/samples/bls/lib/hubble-contracts/contracts/libs/BNPairingPrecompileCostEstimator.sol +108 -0
- package/test/fixtures/erc4337/samples/bls/lib/hubble-contracts/contracts/libs/ModExp.sol +652 -0
- package/test/fixtures/erc4337/samples/callback/TokenCallbackHandler.sol +61 -0
- package/test/fixtures/erc4337/utils/Exec.sol +70 -0
- package/test/fixtures/explorer/0xfbD2aa7efA2B46Ce3c58D7ab0D92C176c71499C0.html +2788 -0
- package/test/fixtures/gnosis/GnosisSafe.sol +422 -0
- package/test/fixtures/gnosis/GnosisSafeL2.sol +86 -0
- package/test/fixtures/gnosis/accessors/SimulateTxAccessor.sol +52 -0
- package/test/fixtures/gnosis/base/Executor.sol +27 -0
- package/test/fixtures/gnosis/base/FallbackManager.sol +53 -0
- package/test/fixtures/gnosis/base/GuardManager.sol +62 -0
- package/test/fixtures/gnosis/base/ModuleManager.sol +133 -0
- package/test/fixtures/gnosis/base/OwnerManager.sol +149 -0
- package/test/fixtures/gnosis/common/Enum.sol +8 -0
- package/test/fixtures/gnosis/common/EtherPaymentFallback.sol +13 -0
- package/test/fixtures/gnosis/common/SecuredTokenTransfer.sol +35 -0
- package/test/fixtures/gnosis/common/SelfAuthorized.sol +16 -0
- package/test/fixtures/gnosis/common/SignatureDecoder.sol +36 -0
- package/test/fixtures/gnosis/common/Singleton.sol +11 -0
- package/test/fixtures/gnosis/common/StorageAccessible.sol +47 -0
- package/test/fixtures/gnosis/external/GnosisSafeMath.sol +54 -0
- package/test/fixtures/gnosis/interfaces/ERC1155TokenReceiver.sol +49 -0
- package/test/fixtures/gnosis/interfaces/ERC721TokenReceiver.sol +24 -0
- package/test/fixtures/gnosis/interfaces/ERC777TokensRecipient.sol +13 -0
- package/test/fixtures/gnosis/interfaces/IERC165.sol +15 -0
- package/test/fixtures/gnosis/interfaces/ISignatureValidator.sol +20 -0
- package/test/fixtures/gnosis/interfaces/ViewStorageAccessible.sol +11 -0
- package/test/fixtures/gnosis/libraries/CreateCall.sol +30 -0
- package/test/fixtures/gnosis/libraries/GnosisSafeStorage.sol +21 -0
- package/test/fixtures/gnosis/libraries/MultiSend.sol +66 -0
- package/test/fixtures/gnosis/libraries/MultiSendCallOnly.sol +61 -0
- package/test/fixtures/gnosis/libraries/SignMessageLib.sol +34 -0
- package/test/fixtures/gnosis/proxies/GnosisSafeProxy.sol +44 -0
- package/test/fixtures/gnosis/proxies/GnosisSafeProxyFactory.sol +107 -0
- package/test/fixtures/gnosis/proxies/IProxyCreationCallback.sol +12 -0
- package/test/fixtures/mapping-setters/GTC.sol +611 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/Address.sol +189 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/FullMath.sol +124 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC165.sol +24 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC20.sol +77 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC20Minimal.sol +52 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721.sol +129 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Enumerable.sol +29 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Metadata.sol +27 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Permit.sol +32 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Receiver.sol +21 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IMulticall.sol +13 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/INonfungiblePositionManager.sol +180 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IPeripheryImmutableState.sol +12 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IPeripheryPayments.sol +28 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IPoolInitializer.sol +22 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3Factory.sol +78 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3Pool.sol +24 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolActions.sol +103 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolDerivedState.sol +40 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolEvents.sol +121 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolImmutables.sol +35 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolOwnerActions.sol +23 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolState.sol +116 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3Staker.sol +183 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/IncentiveId.sol +14 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/Math.sol +31 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/Multicall.sol +28 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/NFTPositionInfo.sol +47 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/PoolAddress.sol +48 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/RewardMath.sol +42 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/TransferHelper.sol +60 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/TransferHelperExtended.sol +39 -0
- package/test/fixtures/mapping-setters/UniswapV3Staker/UniswapV3Staker.sol +350 -0
- package/test/fixtures/openzeppelin/Proxy.sol +11 -0
- package/test/fixtures/openzeppelin/ProxyAdmin.sol +11 -0
- package/test/fixtures/openzeppelin/beacon/BeaconProxy.sol +11 -0
- package/test/fixtures/openzeppelin/beacon/UpgradeableBeacon.sol +11 -0
- package/test/fixtures/parser/AlphaKlima.sol +36 -0
- package/test/fixtures/parser/CToken/CErc20.sol +228 -0
- package/test/fixtures/parser/CToken/CErc20Delegate.sol +44 -0
- package/test/fixtures/parser/CToken/CErc20Delegator.sol +476 -0
- package/test/fixtures/parser/CToken/CToken.sol +1156 -0
- package/test/fixtures/parser/CToken/CTokenInterfaces.sol +293 -0
- package/test/fixtures/parser/CToken/ComptrollerInterface.sol +72 -0
- package/test/fixtures/parser/CToken/EIP20Interface.sol +63 -0
- package/test/fixtures/parser/CToken/EIP20NonStandardInterface.sol +71 -0
- package/test/fixtures/parser/CToken/ErrorReporter.sol +127 -0
- package/test/fixtures/parser/CToken/ExponentialNoError.sol +171 -0
- package/test/fixtures/parser/CToken/InterestRateModel.sol +30 -0
- package/test/fixtures/parser/DAI.sol +194 -0
- package/test/fixtures/parser/PriceOracle.sol +1964 -0
- package/test/fixtures/parser/SAFE/Context.sol +24 -0
- package/test/fixtures/parser/SAFE/ERC20.sol +383 -0
- package/test/fixtures/parser/SAFE/IERC20.sol +82 -0
- package/test/fixtures/parser/SAFE/IERC20Metadata.sol +28 -0
- package/test/fixtures/parser/SAFE/Ownable.sol +76 -0
- package/test/fixtures/parser/SAFE/Pausable.sol +91 -0
- package/test/fixtures/parser/SAFE/SafeToken.sol +48 -0
- package/test/fixtures/parser/SAFE/TokenRescuer.sol +29 -0
- package/test/fixtures/parser/SomeERC20/Context.sol +24 -0
- package/test/fixtures/parser/SomeERC20/ERC20.sol +389 -0
- package/test/fixtures/parser/SomeERC20/IERC20.sol +82 -0
- package/test/fixtures/parser/SomeERC20/IERC20Metadata.sol +28 -0
- package/test/fixtures/parser/SomeERC20/Ownable.sol +83 -0
- package/test/fixtures/parser/SomeERC20/SomeToken.sol +210 -0
- package/test/fixtures/parser/TetherToken.sol +447 -0
- package/test/fixtures/parser/USDC.sol +2231 -0
- package/test/fixtures/parser/v04/ENJToken.sol +493 -0
- package/test/fixtures/parser/v04/MultiSigWallet.sol +371 -0
- package/test/fixtures/receipts/swap.json +93 -93
- package/test/fixtures/scan/WETH.sol +1533 -0
- package/test/fixtures/slots/FooStorage.sol +8 -0
- package/test/fixtures/slots/FooStorageBase.sol +6 -0
- package/test/fixtures/slots/Vault.sol +85 -0
- package/test/flashbots/flashbots.spec.ts +79 -0
- package/test/generate/class.spec.ts +293 -5
- package/test/generate/evm.spec.ts +71 -0
- package/test/generate/gen.spec.ts +69 -0
- package/test/generate/openzeppelin.spec.ts +22 -0
- package/test/generate/slotreader.spec.ts +34 -0
- package/test/hardhat/TestNode.ts +76 -61
- package/test/hardhat/compile.spec.ts +22 -0
- package/test/hardhat/deploy.spec.ts +579 -0
- package/test/hardhat/deployments/deployments.spec.ts +233 -0
- package/test/hardhat/deployments/proxy-layout.spec.ts +296 -0
- package/test/hardhat/forked.spec.ts +56 -0
- package/test/hardhat/gas.spec.ts +40 -0
- package/test/hardhat/permit.ts +33 -0
- package/test/hardhat/revert.spec.ts +30 -0
- package/test/indexer/BlocksWalker.spec.ts +51 -0
- package/test/indexer/EventsIndexer.spec.ts +170 -0
- package/test/json/JsonStore.spec.ts +170 -0
- package/test/node/block.spec.ts +11 -0
- package/test/ns.spec.ts +67 -30
- package/test/perf/calldata.spec.ts +93 -0
- package/test/receipt.spec.ts +52 -27
- package/test/rpc/rpc.spec.ts +353 -0
- package/test/rpc/rpcUtil.spec.ts +31 -0
- package/test/safe/safe.spec.ts +352 -0
- package/test/services/timelock.spec.ts +97 -0
- package/test/solidity/AbiExtractor.spec.ts +468 -0
- package/test/solidity/MappingSettersResolver.spec.ts +516 -0
- package/test/solidity/SlotsDump.spec.ts +154 -0
- package/test/solidity/SlotsParser.spec.ts +536 -0
- package/test/solidity/SlotsReader.spec.ts +388 -0
- package/test/solidity/Storage.spec.ts +404 -0
- package/test/structs/PackedRanges.spec.ts +56 -0
- package/test/subscriptions.spec.ts +127 -0
- package/test/token.spec.ts +17 -0
- package/test/tokens/oracles.spec.ts +51 -0
- package/test/utils/abi-parser-args.spec.ts +143 -0
- package/test/utils/abi-parser.spec.ts +141 -117
- package/test/utils/abi-types.spec.ts +31 -0
- package/test/utils/abi-utils.spec.ts +23 -0
- package/test/utils/abi.spec.ts +178 -0
- package/test/utils/address.spec.ts +66 -0
- package/test/utils/bigfloat/div.spec.ts +1919 -0
- package/test/utils/bigfloat/mod.spec.ts +1745 -0
- package/test/utils/bigfloat/mul.spec.ts +2085 -0
- package/test/utils/bigfloat/round.spec.ts +174 -0
- package/test/utils/bigfloat/sqrt.spec.ts +420 -0
- package/test/utils/bigint.spec.ts +39 -40
- package/test/utils/bytecode.spec.ts +107 -0
- package/test/utils/crypto.spec.ts +37 -0
- package/test/utils/date.spec.ts +9 -8
- package/test/utils/fn.spec.ts +39 -39
- package/test/utils/logbloom.spec.ts +17 -0
- package/test/utils/number.spec.ts +52 -41
- package/test/utils/rlp.spec.ts +142 -0
- package/test/utils/sign.spec.ts +327 -22
- package/tools/build-dts.ts +111 -0
- package/tools/copy-dts.ts +48 -0
- package/tsconfig-build.json +24 -24
- package/tsconfig-src.json +44 -36
- package/tsconfig.esm.json +12 -0
- package/tsconfig.json +34 -27
- package/tsconfig.umd.json +28 -0
- package/typings/globals/axios/index.d.ts +6 -6
- package/typings.json +6 -6
- package/contracts/abi/erc20.abi.json +0 -222
- package/contracts/gen/amm/AmmFactoryV2ContractBase.ts +0 -66
- package/contracts/gen/amm/AmmMasterChefV2ContractBase.ts +0 -158
- package/contracts/gen/amm/AmmPairContractV2Base.ts +0 -158
- package/contracts/gen/amm/AmmPairContractV3Base.ts +0 -125
- package/contracts/gen/amm/AmmRouterV2ContractBase.ts +0 -124
- package/contracts/gen/amm/AmmVaultV2ContractBase.ts +0 -214
- package/contracts/gen/base/ERC20Base.ts +0 -90
- package/contracts/gen/bsc/OneInchRouterV3Base.ts +0 -57
- package/contracts/gen/eth/WETHBase/WETHBase.sol +0 -756
- package/contracts/gen/eth/WETHBase.ts +0 -136
- package/contracts/gen/polygon/ERC20PolygonBase.ts +0 -305
- package/contracts/gen/polygon/WormholeBridgeContractBase/Address.sol +0 -216
- package/contracts/gen/polygon/WormholeBridgeContractBase/BeaconProxy.sol +0 -61
- package/contracts/gen/polygon/WormholeBridgeContractBase/Bridge.sol +0 -437
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeGetters.sol +0 -70
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeGovernance.sol +0 -142
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeImplementation.sol +0 -34
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeSetters.sol +0 -57
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeState.sol +0 -52
- package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeStructs.sol +0 -66
- package/contracts/gen/polygon/WormholeBridgeContractBase/BytesLib.sol +0 -510
- package/contracts/gen/polygon/WormholeBridgeContractBase/Context.sol +0 -23
- package/contracts/gen/polygon/WormholeBridgeContractBase/ERC1967Proxy.sol +0 -32
- package/contracts/gen/polygon/WormholeBridgeContractBase/ERC1967Upgrade.sol +0 -193
- package/contracts/gen/polygon/WormholeBridgeContractBase/IBeacon.sol +0 -15
- package/contracts/gen/polygon/WormholeBridgeContractBase/IERC20.sol +0 -81
- package/contracts/gen/polygon/WormholeBridgeContractBase/IWormhole.sol +0 -42
- package/contracts/gen/polygon/WormholeBridgeContractBase/Ownable.sol +0 -71
- package/contracts/gen/polygon/WormholeBridgeContractBase/Proxy.sol +0 -85
- package/contracts/gen/polygon/WormholeBridgeContractBase/SafeERC20.sol +0 -98
- package/contracts/gen/polygon/WormholeBridgeContractBase/StorageSlot.sol +0 -83
- package/contracts/gen/polygon/WormholeBridgeContractBase/Structs.sol +0 -40
- package/contracts/gen/polygon/WormholeBridgeContractBase/Token.sol +0 -12
- package/contracts/gen/polygon/WormholeBridgeContractBase/TokenBridge.sol +0 -15
- package/contracts/gen/polygon/WormholeBridgeContractBase/TokenImplementation.sol +0 -177
- package/contracts/gen/polygon/WormholeBridgeContractBase/TokenState.sol +0 -31
- package/contracts/gen/polygon/WormholeBridgeContractBase.ts +0 -231
- package/contracts/gen/xdai/WXDaiTokenContractBase.ts +0 -136
- package/dist/contracts/gen/amm/AmmFactoryV2ContractBase.js +0 -53
- package/dist/contracts/gen/amm/AmmMasterChefV2ContractBase.js +0 -122
- package/dist/contracts/gen/amm/AmmPairContractV2Base.js +0 -122
- package/dist/contracts/gen/amm/AmmPairContractV3Base.js +0 -98
- package/dist/contracts/gen/amm/AmmRouterV2ContractBase.js +0 -95
- package/dist/contracts/gen/amm/AmmVaultV2ContractBase.js +0 -164
- package/dist/contracts/gen/base/ERC20Base.js +0 -64
- package/dist/contracts/gen/bsc/OneInchRouterV3Base.js +0 -47
- package/dist/contracts/gen/eth/WETHBase.js +0 -96
- package/dist/contracts/gen/polygon/ERC20PolygonBase.js +0 -233
- package/dist/contracts/gen/polygon/WormholeBridgeContractBase.js +0 -172
- package/dist/contracts/gen/xdai/WXDaiTokenContractBase.js +0 -96
- package/dist/src/BlockchainExplorer/BlockChainExplorerFactory.js +0 -227
- package/dist/src/BlockchainExplorer/BlockChainExplorerProvider.js +0 -32
- package/dist/src/BlockchainExplorer/BlockNumberCache.js +0 -33
- package/dist/src/BlockchainExplorer/Bscscan.js +0 -27
- package/dist/src/BlockchainExplorer/Etherscan.js +0 -27
- package/dist/src/BlockchainExplorer/IAbiProvider.js +0 -2
- package/dist/src/BlockchainExplorer/IBlockChainExplorer.js +0 -2
- package/dist/src/BlockchainExplorer/Polyscan.js +0 -27
- package/dist/src/ChainAccounts.js +0 -69
- package/dist/src/ChainAccountsService.js +0 -75
- package/dist/src/Config.js +0 -7
- package/dist/src/blocks/BlockDateResolver.js +0 -125
- package/dist/src/bridges/BridgeFactory.js +0 -19
- package/dist/src/bridges/hop/HopAddresses.js +0 -520
- package/dist/src/bridges/hop/HopBridge.js +0 -327
- package/dist/src/bridges/hop/contracts/gen.act.js +0 -43
- package/dist/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.js +0 -52
- package/dist/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.js +0 -319
- package/dist/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.js +0 -178
- package/dist/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.js +0 -52
- package/dist/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.js +0 -319
- package/dist/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.js +0 -178
- package/dist/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.js +0 -52
- package/dist/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.js +0 -319
- package/dist/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.js +0 -178
- package/dist/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.js +0 -52
- package/dist/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.js +0 -319
- package/dist/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.js +0 -178
- package/dist/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.js +0 -52
- package/dist/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.js +0 -319
- package/dist/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.js +0 -178
- package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.js +0 -52
- package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.js +0 -319
- package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.js +0 -178
- package/dist/src/bridges/models/IBridge.js +0 -2
- package/dist/src/bridges/wormhole/contracts/WormholeBridgeContract.js +0 -15
- package/dist/src/chains/PlatformFactory.js +0 -42
- package/dist/src/chains/arbitrum/ArbTokenProvider.js +0 -40
- package/dist/src/chains/arbitrum/ArbWeb3Client.js +0 -39
- package/dist/src/chains/arbitrum/Arbiscan.js +0 -27
- package/dist/src/chains/boba/BobaWeb3Client.js +0 -47
- package/dist/src/chains/boba/Bobascan.js +0 -28
- package/dist/src/chains/xdai/XDaiWeb3Client.js +0 -87
- package/dist/src/chains/xdai/XDaiscan.js +0 -27
- package/dist/src/chains/xdai/tokens/WXDaiTokenContract.js +0 -15
- package/dist/src/clients/BscWeb3Client.js +0 -38
- package/dist/src/clients/ClientEventsStream.js +0 -34
- package/dist/src/clients/ClientPool.js +0 -560
- package/dist/src/clients/ClientPoolStats.js +0 -52
- package/dist/src/clients/EthWeb3Client.js +0 -35
- package/dist/src/clients/HardhatWeb3Client.js +0 -56
- package/dist/src/clients/PolyWeb3Client.js +0 -77
- package/dist/src/clients/Web3Client.js +0 -186
- package/dist/src/clients/Web3ClientFactory.js +0 -32
- package/dist/src/clients/interfaces/IWeb3Client.js +0 -2
- package/dist/src/clients/interfaces/IWeb3ClientStatus.js +0 -2
- package/dist/src/clients/interfaces/IWeb3EndpointOptions.js +0 -2
- package/dist/src/clients/model/ClientStatus.js +0 -9
- package/dist/src/clients/model/PromiEventWrap.js +0 -52
- package/dist/src/clients/model/SubscriptionWrap.js +0 -42
- package/dist/src/clients/utils/ClientEndpoints.js +0 -27
- package/dist/src/clients/utils/ClientErrorUtil.js +0 -30
- package/dist/src/clients/utils/TxFactory.js +0 -14
- package/dist/src/contracts/BscContract.js +0 -30
- package/dist/src/contracts/Contract.js +0 -90
- package/dist/src/contracts/ContractBase.js +0 -139
- package/dist/src/contracts/ContractFactory.js +0 -17
- package/dist/src/contracts/ContractProvider.js +0 -40
- package/dist/src/contracts/ContractReader.js +0 -76
- package/dist/src/contracts/ContractStream.js +0 -20
- package/dist/src/contracts/ContractWriter.js +0 -62
- package/dist/src/contracts/EthContract.js +0 -31
- package/dist/src/contracts/TxContract.js +0 -37
- package/dist/src/contracts/common/ERC20.js +0 -14
- package/dist/src/contracts/common/ERC20Polygon.js +0 -14
- package/dist/src/contracts/common/PoolPair.js +0 -23
- package/dist/src/contracts/utils/AbiDeserializer.js +0 -89
- package/dist/src/contracts/utils/ConvertUtils.js +0 -21
- package/dist/src/contracts/utils/InputDataUtils.js +0 -87
- package/dist/src/contracts/utils/TypeUtils.js +0 -24
- package/dist/src/defi/OneInch/OneInchRouter.js +0 -14
- package/dist/src/env/BigIntSerializer.js +0 -19
- package/dist/src/gen/Ast.js +0 -12
- package/dist/src/gen/ContractTemplate.js +0 -27
- package/dist/src/gen/Generator.js +0 -180
- package/dist/src/gen/GeneratorFromAbi.js +0 -361
- package/dist/src/handlers/TokenHandler.js +0 -69
- package/dist/src/indexer/BlocksTxIndexer.js +0 -52
- package/dist/src/indexer/PendingTxIndexer.js +0 -96
- package/dist/src/indexer/handlers/BlocksWalker.js +0 -306
- package/dist/src/indexer/handlers/TxQueueLoader.js +0 -117
- package/dist/src/json/JsonArrayStore.js +0 -296
- package/dist/src/json/JsonObjectStore.js +0 -214
- package/dist/src/json/JsonStore.spec.js +0 -83
- package/dist/src/loggers/ILogger.js +0 -2
- package/dist/src/loggers/LoggerService.js +0 -34
- package/dist/src/loggers/TxLoggerService.js +0 -122
- package/dist/src/models/IContractDetails.js +0 -2
- package/dist/src/models/IToken.js +0 -2
- package/dist/src/models/ITokenGlob.js +0 -6
- package/dist/src/models/ITransactionDetails.js +0 -2
- package/dist/src/models/TAddress.js +0 -2
- package/dist/src/models/TBufferLike.js +0 -2
- package/dist/src/models/THex.js +0 -2
- package/dist/src/models/TPlatform.js +0 -2
- package/dist/src/models/TResult.js +0 -2
- package/dist/src/ns/NameService.js +0 -19
- package/dist/src/ns/providers/EnsProvider.js +0 -41
- package/dist/src/ns/providers/INsProvider.js +0 -2
- package/dist/src/ns/providers/UDProvider.js +0 -39
- package/dist/src/ns/utils/$ns.js +0 -17
- package/dist/src/structs/PackedRanges.js +0 -186
- package/dist/src/structs/PackedRanges.spec.js +0 -30
- package/dist/src/tokens/TokenExchangeService.js +0 -110
- package/dist/src/tokens/TokenExchanges/AmmBase/AmmUtilts.js +0 -17
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmFactoryV2Contract.js +0 -15
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmMasterChefV2Contract.js +0 -15
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Contract.js +0 -16
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js +0 -144
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmRouterV2Contract.js +0 -15
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmVaultV2Contract.js +0 -15
- package/dist/src/tokens/TokenExchanges/AmmBase/V3/AmmPairV3Contract.js +0 -22
- package/dist/src/tokens/TokenExchanges/AmmV2ExchangeBase.js +0 -194
- package/dist/src/tokens/TokenExchanges/OneInchExchange.js +0 -92
- package/dist/src/tokens/TokenExchanges/PancakeswapExchange.js +0 -28
- package/dist/src/tokens/TokenExchanges/SushiswapPolygonExchange.js +0 -28
- package/dist/src/tokens/TokenExchanges/UniswapExchange.js +0 -28
- package/dist/src/tokens/TokenOracles/AmmPriceV2Oracle.js +0 -319
- package/dist/src/tokens/TokenOracles/TokenPriceStore.js +0 -108
- package/dist/src/tokens/TokenPriceService.js +0 -196
- package/dist/src/tokens/TokenPriceServiceProvider.js +0 -31
- package/dist/src/tokens/TokenProviders/ATokenProvider.js +0 -38
- package/dist/src/tokens/TokenProviders/ITokenProvider.js +0 -2
- package/dist/src/tokens/TokenProviders/TPChain.js +0 -35
- package/dist/src/tokens/TokenProviders/TPCoinmarketcap.js +0 -63
- package/dist/src/tokens/TokenProviders/TPOneInch.js +0 -65
- package/dist/src/tokens/TokenProviders/TPSushiswap.js +0 -89
- package/dist/src/tokens/TokenProviders/TPUniswap.js +0 -84
- package/dist/src/tokens/TokenService.js +0 -115
- package/dist/src/tokens/TokenSwapService.js +0 -37
- package/dist/src/tokens/TokenTransferService.js +0 -189
- package/dist/src/tokens/TokensService.js +0 -236
- package/dist/src/tokens/TokensServiceBsc.js +0 -18
- package/dist/src/tokens/TokensServiceEth.js +0 -15
- package/dist/src/tokens/TokensServiceFactory.js +0 -29
- package/dist/src/tokens/TokensServicePolygon.js +0 -18
- package/dist/src/tokens/TokensServiceXDai.js +0 -24
- package/dist/src/tokens/defi/ISwapService.js +0 -2
- package/dist/src/tokens/defi/paraswap/Paraswap.js +0 -135
- package/dist/src/tokens/erc20/eth/WETH.js +0 -14
- package/dist/src/tokens/utils/TokenUtils.js +0 -66
- package/dist/src/txs/ITxConfig.js +0 -2
- package/dist/src/txs/TxDataBuilder.js +0 -159
- package/dist/src/txs/TxLogger.js +0 -119
- package/dist/src/txs/TxProvider.js +0 -73
- package/dist/src/txs/TxService.js +0 -19
- package/dist/src/txs/TxWriter.js +0 -287
- package/dist/src/txs/conditional/GasWatcherLogger.js +0 -61
- package/dist/src/txs/conditional/GasWatcherService.js +0 -103
- package/dist/src/txs/conditional/GasWatcherStore.js +0 -25
- package/dist/src/txs/conditional/GasWatcherTx.js +0 -126
- package/dist/src/txs/receipt/ITxLogItem.js +0 -2
- package/dist/src/txs/receipt/TxLogParser.js +0 -27
- package/dist/src/txs/receipt/TxLogsTransfer.js +0 -50
- package/dist/src/txs/receipt/TxTopicInMemoryProvider.js +0 -41
- package/dist/src/txs/receipt/TxTopicProvider.js +0 -25
- package/dist/src/utils/$abiParser.js +0 -159
- package/dist/src/utils/$abiType.js +0 -77
- package/dist/src/utils/$abiUtils.js +0 -43
- package/dist/src/utils/$address.js +0 -41
- package/dist/src/utils/$array.js +0 -60
- package/dist/src/utils/$bigint.js +0 -130
- package/dist/src/utils/$block.js +0 -10
- package/dist/src/utils/$class.js +0 -13
- package/dist/src/utils/$config.js +0 -18
- package/dist/src/utils/$contract.js +0 -67
- package/dist/src/utils/$csv.js +0 -79
- package/dist/src/utils/$date.js +0 -496
- package/dist/src/utils/$fn.js +0 -117
- package/dist/src/utils/$is.js +0 -40
- package/dist/src/utils/$logger.js +0 -15
- package/dist/src/utils/$number.js +0 -95
- package/dist/src/utils/$object.js +0 -82
- package/dist/src/utils/$path.js +0 -33
- package/dist/src/utils/$promise.js +0 -13
- package/dist/src/utils/$require.js +0 -127
- package/dist/src/utils/$sign.js +0 -35
- package/dist/src/utils/$signSerializer.js +0 -264
- package/dist/src/utils/$wallet.js +0 -13
- package/dist/src/utils/types.js +0 -2
- package/dist/src/wallets/Wallet.js +0 -26
- package/dist/src/wallets/WalletBsc.js +0 -17
- package/dist/src/wallets/WalletService.js +0 -35
- package/dist/src/www/utils/BlockChainExplorerFormatter.js +0 -15
- package/src/BlockchainExplorer/BlockChainExplorerFactory.ts +0 -273
- package/src/BlockchainExplorer/BlockChainExplorerProvider.ts +0 -26
- package/src/BlockchainExplorer/BlockNumberCache.ts +0 -46
- package/src/BlockchainExplorer/Bscscan.ts +0 -23
- package/src/BlockchainExplorer/Etherscan.ts +0 -25
- package/src/BlockchainExplorer/IAbiProvider.ts +0 -5
- package/src/BlockchainExplorer/IBlockChainExplorer.ts +0 -37
- package/src/BlockchainExplorer/Polyscan.ts +0 -23
- package/src/ChainAccounts.ts +0 -72
- package/src/ChainAccountsService.ts +0 -74
- package/src/Config.ts +0 -34
- package/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.ts +0 -69
- package/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.ts +0 -453
- package/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.ts +0 -264
- package/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.ts +0 -69
- package/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.ts +0 -453
- package/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.ts +0 -264
- package/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.ts +0 -69
- package/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.ts +0 -453
- package/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.ts +0 -264
- package/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.ts +0 -69
- package/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.ts +0 -453
- package/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.ts +0 -264
- package/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.ts +0 -69
- package/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.ts +0 -453
- package/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.ts +0 -264
- package/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.ts +0 -69
- package/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.ts +0 -453
- package/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.ts +0 -264
- package/src/bridges/wormhole/contracts/WormholeBridgeContract.ts +0 -14
- package/src/chains/xdai/tokens/WXDaiTokenContract.json +0 -279
- package/src/chains/xdai/tokens/WXDaiTokenContract.ts +0 -14
- package/src/clients/HardhatWeb3Client.ts +0 -60
- package/src/contracts/ContractFactory.ts +0 -19
- package/src/contracts/common/ERC20.ts +0 -13
- package/src/contracts/common/ERC20Polygon.ts +0 -13
- package/src/contracts/common/PoolPair.ts +0 -22
- package/src/defi/OneInch/OneInchRouter.ts +0 -13
- package/src/json/JsonStore.spec.ts +0 -98
- package/src/structs/PackedRanges.spec.ts +0 -38
- package/src/structs/PackedRanges.ts +0 -207
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmFactoryV2Contract.ts +0 -15
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmMasterChefV2Contract.ts +0 -15
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Contract.ts +0 -17
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmRouterV2Contract.ts +0 -15
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmVaultV2Contract.ts +0 -15
- package/src/tokens/TokenExchanges/AmmBase/V3/AmmPairV3Contract.ts +0 -24
- package/src/tokens/TokenExchanges/UniswapExchange.ts +0 -31
- package/src/tokens/TokenOracles/AmmPriceV2Oracle.ts +0 -440
- package/src/tokens/erc20/eth/WETH.ts +0 -13
- package/src/txs/ITxConfig.ts +0 -27
- package/src/www/utils/BlockChainExplorerFormatter.ts +0 -13
- package/test/client.spec.ts +0 -59
|
@@ -1,61 +1,159 @@
|
|
|
1
1
|
import alot from 'alot';
|
|
2
2
|
import memd from 'memd';
|
|
3
|
-
import Web3 from 'web3';
|
|
4
|
-
import { AbiItem } from 'web3-utils';
|
|
5
3
|
import { $date } from '@dequanto/utils/$date';
|
|
6
4
|
import { $number } from '@dequanto/utils/$number';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { $require } from '@dequanto/utils/$require';
|
|
6
|
+
import { $contract } from '@dequanto/utils/$contract';
|
|
7
|
+
import { $logger, l } from '@dequanto/utils/$logger';
|
|
8
|
+
import { $promise } from '@dequanto/utils/$promise';
|
|
9
|
+
import { $array } from '@dequanto/utils/$array';
|
|
10
|
+
import { $bigint } from '@dequanto/utils/$bigint';
|
|
11
|
+
|
|
12
|
+
import { PromiseEventWrap } from './model/PromiEventWrap';
|
|
9
13
|
import { IWeb3ClientStatus } from './interfaces/IWeb3ClientStatus';
|
|
10
14
|
import { ClientStatus } from './model/ClientStatus';
|
|
11
|
-
import { ClientPoolTrace, ClientPoolTraceError } from './ClientPoolStats';
|
|
12
|
-
import { class_Dfr } from 'atma-utils';
|
|
13
|
-
import { TAddress } from '@dequanto/models/TAddress';
|
|
14
|
-
import { ClientEventsStream } from './ClientEventsStream';
|
|
15
|
-
import { Subscription } from 'web3-core-subscriptions';
|
|
15
|
+
import { ClientPoolTrace, ClientPoolTraceError, ErrorCode } from './ClientPoolStats';
|
|
16
|
+
import { class_Dfr, obj_extendDefaults } from 'atma-utils';
|
|
16
17
|
import { ClientErrorUtil } from './utils/ClientErrorUtil';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
18
|
+
import { IWeb3ClientOptions } from './interfaces/IWeb3Client';
|
|
19
|
+
import { RateLimitGuard } from './handlers/RateLimitGuard';
|
|
20
|
+
import { Web3BatchRequests } from './Web3BatchRequests';
|
|
21
|
+
|
|
22
|
+
import { HttpTransport } from '@dequanto/rpc/transports/HttpTransport';
|
|
23
|
+
import { WsTransport } from '@dequanto/rpc/transports/WsTransport';
|
|
24
|
+
import { Rpc } from '@dequanto/rpc/Rpc';
|
|
25
|
+
|
|
26
|
+
import { Web3Transport } from '@dequanto/rpc/transports/compatibility/Web3Transport';
|
|
27
|
+
import { PromiseEvent } from '@dequanto/class/PromiseEvent';
|
|
28
|
+
import { TTransport } from '@dequanto/rpc/transports/ITransport';
|
|
29
|
+
|
|
30
|
+
import { TRpc } from '@dequanto/rpc/RpcBase';
|
|
31
|
+
import { TEth } from '@dequanto/models/TEth';
|
|
32
|
+
import { $rpc } from '@dequanto/rpc/$rpc';
|
|
33
|
+
import { Web3 } from './compatibility/Web3';
|
|
19
34
|
|
|
35
|
+
export interface IPoolClientConfig {
|
|
36
|
+
url?: string
|
|
37
|
+
options?: TTransport.Options.Http | TTransport.Options.Ws
|
|
20
38
|
|
|
21
|
-
|
|
22
|
-
url: string
|
|
39
|
+
/** Will be a pefered node for submitting transactions */
|
|
23
40
|
safe?: boolean
|
|
24
41
|
distinct?: boolean
|
|
42
|
+
|
|
43
|
+
web3?: TTransport.Transport
|
|
44
|
+
|
|
45
|
+
name?: string
|
|
46
|
+
/** Will be used only if manually requested with .getWeb3, or .getNodeUrl */
|
|
47
|
+
manual?: boolean
|
|
48
|
+
|
|
49
|
+
/** max block range per request when getting for example the past logs*/
|
|
50
|
+
fetchableBlockRange?: number
|
|
51
|
+
|
|
52
|
+
/** True if the node supports traceTransaction calls */
|
|
53
|
+
traceable?: boolean
|
|
54
|
+
|
|
55
|
+
// requestCout/timeSpan: e.g. 100/1min
|
|
56
|
+
rateLimit?: string
|
|
57
|
+
|
|
58
|
+
// the max block range to fetch per single request when getting Logs
|
|
59
|
+
blockRangeLimit?: string | number
|
|
60
|
+
|
|
61
|
+
// maximum of requests to be batched, otherwise batches will be paginated
|
|
62
|
+
batchLimit?: number
|
|
63
|
+
|
|
64
|
+
// Will be used only for the specified methods
|
|
65
|
+
methods?: {
|
|
66
|
+
exclude?: string[]
|
|
67
|
+
only?: string[]
|
|
68
|
+
}
|
|
25
69
|
}
|
|
26
70
|
export interface IPoolWeb3Request {
|
|
27
71
|
ws?: boolean
|
|
28
72
|
preferSafe?: boolean
|
|
29
73
|
distinct?: boolean
|
|
74
|
+
name?: string
|
|
75
|
+
|
|
76
|
+
/** HTTP Web3 Client traces */
|
|
30
77
|
trace?: ClientPoolTrace
|
|
78
|
+
|
|
79
|
+
/** Supported node features */
|
|
80
|
+
node?: {
|
|
81
|
+
// For specific url
|
|
82
|
+
url?: string
|
|
83
|
+
|
|
84
|
+
/** Supports traceTransaction */
|
|
85
|
+
traceable?: boolean
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** RPC method - will find the node that has the configuration */
|
|
89
|
+
method?: string
|
|
90
|
+
|
|
91
|
+
// Amount of batch requests to be performed, sothat we can choose the appropriate wClient and handle the rate limits correctly
|
|
92
|
+
batchRequestCount?: number
|
|
93
|
+
|
|
94
|
+
// By fetching logs, specifies the desired block range to query
|
|
95
|
+
blockRangeCount?: number
|
|
31
96
|
}
|
|
97
|
+
|
|
32
98
|
export class ClientPool {
|
|
33
99
|
|
|
34
100
|
private discoveredPartial = false;
|
|
35
101
|
private discoveredFull = false;
|
|
36
|
-
private clients
|
|
102
|
+
private clients: WClient[];
|
|
37
103
|
private ws: WClient;
|
|
38
104
|
|
|
39
|
-
|
|
105
|
+
/** Minimum rate limit range to assume the RPC is alive */
|
|
106
|
+
MINIMUM_BLOCK_RANGE = 200
|
|
107
|
+
|
|
108
|
+
constructor(config: IWeb3ClientOptions) {
|
|
40
109
|
|
|
110
|
+
if (config.endpoints != null && config.endpoints.length > 0) {
|
|
111
|
+
this.clients = config.endpoints.map(cfg => new WClient(cfg))
|
|
112
|
+
} else if (config.web3 || config.provider) {
|
|
113
|
+
this.clients = [new WClient({ web3: config.web3 ?? config.provider })];
|
|
114
|
+
} else {
|
|
115
|
+
console.dir(config, { depth: null });
|
|
116
|
+
throw new Error(`Neither Node endpoints nor Web3 instance`)
|
|
117
|
+
}
|
|
41
118
|
if (this.clients.length < 2) {
|
|
42
119
|
this.discoveredPartial = true;
|
|
43
120
|
this.discoveredFull = true;
|
|
44
121
|
}
|
|
45
122
|
}
|
|
46
123
|
|
|
47
|
-
callSync
|
|
124
|
+
// callSync<TResult>(fn: (web3: Web3) => TResult): TResult {
|
|
48
125
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
126
|
+
// let arr = this.clients.filter(x => x.status === 'ok');
|
|
127
|
+
// let wClient = arr[$number.randomInt(0, arr.length)];
|
|
128
|
+
// let { status, result } = wClient.callSync(fn);
|
|
129
|
+
// if (status == ClientStatus.Ok) {
|
|
130
|
+
// return result;
|
|
131
|
+
// }
|
|
132
|
+
// throw result;
|
|
133
|
+
// }
|
|
134
|
+
|
|
135
|
+
async callBatched(data: {
|
|
136
|
+
requests: (rpc: Rpc) => Promise<Web3BatchRequests.IRpcRequest[]>
|
|
137
|
+
map?: (results: any[]) => any
|
|
138
|
+
}, opts?: IPoolWeb3Request) {
|
|
139
|
+
return this.call(async (wClient) => {
|
|
140
|
+
let requests = await data.requests(wClient.rpc);
|
|
141
|
+
let results = await wClient.callBatched(requests);
|
|
142
|
+
let mapped = data?.map?.(results) ?? results;
|
|
143
|
+
return mapped;
|
|
144
|
+
}, {
|
|
145
|
+
...(opts ?? {}),
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* web3@1.6.0 has a bug with batch request via websockets, as the callback can stuck if a single response contains multiple IDs, as only the first one will be taken
|
|
149
|
+
* https://github.com/web3/web3.js/blob/9238e106294784b4a6a20af020765973f0437022/packages/web3-providers-ws/src/index.js#L128
|
|
150
|
+
*/
|
|
151
|
+
ws: false
|
|
152
|
+
});
|
|
56
153
|
}
|
|
57
154
|
|
|
58
|
-
async call
|
|
155
|
+
async call<TResult>(fn: (wClient: WClient) => Promise<TResult>, opts?: IPoolWeb3Request): Promise<TResult> {
|
|
156
|
+
// Client - Retries
|
|
59
157
|
let used = new Map<WClient, number>();
|
|
60
158
|
let errors = [];
|
|
61
159
|
|
|
@@ -71,55 +169,94 @@ export class ClientPool {
|
|
|
71
169
|
|
|
72
170
|
error = new Error(`Live clients not found in \n${urls}`);
|
|
73
171
|
}
|
|
74
|
-
throw ClientPoolTraceError.create(error, opts?.trace);
|
|
172
|
+
throw ClientPoolTraceError.create(error, opts?.trace, ErrorCode.NO_LIVE_CLIENT);
|
|
75
173
|
}
|
|
76
|
-
let { status, result, error, time } = await wClient.call(fn);
|
|
77
174
|
|
|
175
|
+
let wClientUsage = used.get(wClient);
|
|
176
|
+
let { status, result, error, time } = await wClient.call(fn, opts);
|
|
177
|
+
|
|
178
|
+
if (error != null && error.data != null) {
|
|
179
|
+
error.data = $contract.decodeCustomError(error.data, []);
|
|
180
|
+
}
|
|
78
181
|
opts
|
|
79
182
|
?.trace
|
|
80
183
|
?.onComplete({ status, error, time, url: wClient.config.url })
|
|
81
184
|
|
|
82
|
-
|
|
185
|
+
|
|
186
|
+
if (wClientUsage == null) {
|
|
187
|
+
// per default NO_RETRIES
|
|
188
|
+
used.set(wClient, 0);
|
|
189
|
+
} else {
|
|
190
|
+
// decrease retry count
|
|
191
|
+
used.set(wClient, wClientUsage - 1);
|
|
192
|
+
}
|
|
193
|
+
|
|
83
194
|
errors.push(error ?? result);
|
|
84
195
|
|
|
85
196
|
if (status == ClientStatus.Ok) {
|
|
86
197
|
return result;
|
|
87
198
|
}
|
|
199
|
+
if (status == ClientStatus.RateLimited) {
|
|
200
|
+
if (wClientUsage == null) {
|
|
201
|
+
const RETRIES = 5;
|
|
202
|
+
used.set(wClient, RETRIES);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
88
205
|
if (status === ClientStatus.CallError) {
|
|
89
|
-
let error = ClientPoolTraceError.create(errors.pop(), opts?.trace);
|
|
90
|
-
//console.log(`Errored ${error.message}`);
|
|
206
|
+
let error = ClientPoolTraceError.create(errors.pop(), opts?.trace, ErrorCode.CALL);
|
|
91
207
|
throw error;
|
|
92
208
|
return result;
|
|
93
209
|
}
|
|
210
|
+
|
|
211
|
+
// if not the CallError, process the while loop to check another NodeProvider
|
|
94
212
|
}
|
|
95
213
|
}
|
|
96
|
-
async
|
|
97
|
-
let wClient = await this.
|
|
214
|
+
async getRpc(options?: IPoolWeb3Request) {
|
|
215
|
+
let wClient = await this.getWrappedWeb3(options);
|
|
216
|
+
return wClient?.rpc;
|
|
217
|
+
}
|
|
218
|
+
async getWrappedWeb3(options?: IPoolWeb3Request) {
|
|
219
|
+
let wClient = await this.next(null, options, { manual: true });
|
|
98
220
|
if (wClient == null) {
|
|
99
|
-
throw new Error(`
|
|
221
|
+
throw new Error(`No client found in ${this.clients.length} Clients with options: ${JSON.stringify(options)}`);
|
|
100
222
|
}
|
|
101
|
-
return wClient
|
|
223
|
+
return wClient;
|
|
102
224
|
}
|
|
103
|
-
async getNodeURL
|
|
104
|
-
let wClient = await this.next(null, options);
|
|
225
|
+
async getNodeURL(options?: IPoolWeb3Request) {
|
|
226
|
+
let wClient = await this.next(null, options, { manual: true });
|
|
105
227
|
if (wClient == null) {
|
|
106
|
-
|
|
228
|
+
let stats = await this.getNodeStats();
|
|
229
|
+
let info = stats.map(x => ` ${x.url}. ERR: ${x.fail}; OK: ${x.success}; Ping: ${x.ping}`).join('\n');
|
|
230
|
+
let requirements = JSON.stringify(options);
|
|
231
|
+
throw new Error(`No alive node for ${requirements} found. \n ${info}`);
|
|
107
232
|
}
|
|
108
233
|
return wClient?.config.url;
|
|
109
234
|
}
|
|
110
|
-
async releaseWeb3
|
|
235
|
+
async releaseWeb3() {
|
|
111
236
|
|
|
112
237
|
}
|
|
113
238
|
|
|
114
|
-
|
|
115
|
-
|
|
239
|
+
getOptionForFetchableRange(blockRangeLimits?: WClient['blockRangeLimits']): number {
|
|
240
|
+
const DEFAULT = blockRangeLimits?.blocks;
|
|
241
|
+
let max = alot(this.clients).max(x => x.config?.fetchableBlockRange ?? 0);
|
|
242
|
+
if (max === 0) {
|
|
243
|
+
return DEFAULT;
|
|
244
|
+
}
|
|
245
|
+
if (typeof DEFAULT === 'number') {
|
|
246
|
+
return Math.min(DEFAULT, max);
|
|
247
|
+
}
|
|
248
|
+
return max;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
callPromiEvent<TResult extends PromiseEvent<any>>(
|
|
252
|
+
fn: (web3: WClient) => TResult
|
|
116
253
|
, opts?: { preferSafe?: boolean, parallel?: number, silent?: boolean, distinct?: boolean }
|
|
117
|
-
, used:
|
|
254
|
+
, used: Map<WClient, number> = new Map<WClient, number>()
|
|
118
255
|
, errors = []
|
|
119
|
-
, root?:
|
|
256
|
+
, root?: PromiseEventWrap
|
|
120
257
|
): TResult {
|
|
121
258
|
|
|
122
|
-
root = root ?? new
|
|
259
|
+
root = root ?? new PromiseEventWrap();
|
|
123
260
|
|
|
124
261
|
(async () => {
|
|
125
262
|
let wClient = await this.next(used, opts);
|
|
@@ -141,12 +278,11 @@ export class ClientPool {
|
|
|
141
278
|
return root as any as TResult;
|
|
142
279
|
}
|
|
143
280
|
|
|
144
|
-
let
|
|
281
|
+
let promiseEvent = wClient.callPromiEvent(fn);
|
|
145
282
|
|
|
146
|
-
root.bind(
|
|
283
|
+
root.bind(promiseEvent);
|
|
147
284
|
|
|
148
|
-
|
|
149
|
-
console.log('!!client ERROR', error);
|
|
285
|
+
promiseEvent.on('error', async error => {
|
|
150
286
|
error.message += ` (RPC: ${wClient.config.url})`;
|
|
151
287
|
if (ClientErrorUtil.isConnectionFailed(error)) {
|
|
152
288
|
this.callPromiEvent(
|
|
@@ -155,23 +291,16 @@ export class ClientPool {
|
|
|
155
291
|
return;
|
|
156
292
|
}
|
|
157
293
|
if (ClientErrorUtil.isAlreadyKnown(error)) {
|
|
158
|
-
|
|
159
|
-
let
|
|
160
|
-
let txs = await
|
|
161
|
-
|
|
162
|
-
// throw
|
|
163
|
-
// this.callPromiEvent(
|
|
164
|
-
// fn, opts, used, errors, root
|
|
165
|
-
// );
|
|
166
|
-
// return;
|
|
294
|
+
$logger.log(`TxWriter ERROR ${error.message}. Check pending...`);
|
|
295
|
+
let rpc = await this.getRpc();
|
|
296
|
+
let txs = await rpc.eth_pendingTransactions();
|
|
297
|
+
$logger.log('PENDING ', txs?.map(x => x.hash));
|
|
298
|
+
// throw anyway
|
|
167
299
|
}
|
|
168
300
|
root.emit('error', error);
|
|
169
301
|
root.reject(error);
|
|
170
302
|
});
|
|
171
|
-
|
|
172
|
-
console.log('!!client CATCH', error);
|
|
173
|
-
//root.reject(error);
|
|
174
|
-
});
|
|
303
|
+
|
|
175
304
|
|
|
176
305
|
used.set(wClient, 1);
|
|
177
306
|
|
|
@@ -196,15 +325,15 @@ export class ClientPool {
|
|
|
196
325
|
return root as any as TResult;
|
|
197
326
|
}
|
|
198
327
|
|
|
199
|
-
getEventStream (address: TAddress, abi:
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
328
|
+
// getEventStream (address: TAddress, abi: TAbiItem[], event: string) {
|
|
329
|
+
// if (this.ws == null) {
|
|
330
|
+
// this.ws = this.clients.find(x => x.config.url?.startsWith('ws'));
|
|
331
|
+
// }
|
|
332
|
+
// let stream = this.ws.getEventStream(address, abi, event);
|
|
333
|
+
// return stream;
|
|
334
|
+
// }
|
|
206
335
|
|
|
207
|
-
getNodeStats
|
|
336
|
+
getNodeStats() {
|
|
208
337
|
return this
|
|
209
338
|
.clients
|
|
210
339
|
.filter(client => client.getRequestCount() > 0)
|
|
@@ -216,34 +345,79 @@ export class ClientPool {
|
|
|
216
345
|
});
|
|
217
346
|
}
|
|
218
347
|
|
|
219
|
-
async getNodeInfos
|
|
348
|
+
async getNodeInfos(options?: {
|
|
349
|
+
timeout?: number
|
|
350
|
+
calls?: ('net_peerCount' | 'eth_blockNumber' | 'eth_syncing' | 'net_version')[]
|
|
351
|
+
}): Promise<IWeb3ClientStatus[]> {
|
|
352
|
+
const Calls = {
|
|
353
|
+
async net_peerCount(wClient: WClient) {
|
|
354
|
+
/** @TODO Public nodes smt. do not allow net_peerCount methods. Allow to switch this on/off on node-url-config level */
|
|
355
|
+
try {
|
|
356
|
+
return await wClient.rpc.net_peerCount();
|
|
357
|
+
} catch (error) {
|
|
358
|
+
return `ERROR: ${error.message}`;
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
async eth_syncing(wClient: WClient): Promise<IWeb3ClientStatus['syncing']> {
|
|
362
|
+
let syncing = await wClient.rpc.eth_syncing();
|
|
363
|
+
if (syncing == null || typeof syncing === 'boolean') {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
return syncing as any;
|
|
367
|
+
},
|
|
368
|
+
async net_version(wClient: WClient): Promise<IWeb3ClientStatus['node']> {
|
|
369
|
+
return await wClient.rpc.net_version()
|
|
370
|
+
},
|
|
371
|
+
async eth_blockNumber(wClient: WClient): Promise<IWeb3ClientStatus['blockNumber']> {
|
|
372
|
+
return await wClient.rpc.eth_blockNumber()
|
|
373
|
+
}
|
|
374
|
+
} as const;
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
async function query<TReturn extends Promise<any>>(wClient: WClient, method: (wClient: WClient) => TReturn): Promise<TReturn> {
|
|
378
|
+
let methodName = method.name;
|
|
379
|
+
let shouldCall = methodName === 'eth_blockNumber' || options?.calls == null || options?.calls.includes(methodName as any);
|
|
380
|
+
if (shouldCall === false) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
let promise = method(wClient);
|
|
384
|
+
return options?.timeout == null ? promise : $promise.timeout(promise, options.timeout);
|
|
385
|
+
}
|
|
386
|
+
|
|
220
387
|
let nodes = await alot(this.clients).mapAsync(async (wClient, idx) => {
|
|
221
388
|
|
|
222
389
|
let url = wClient.config.url;
|
|
223
390
|
try {
|
|
224
391
|
let start = Date.now();
|
|
225
|
-
let [
|
|
226
|
-
wClient.
|
|
227
|
-
wClient.
|
|
228
|
-
|
|
229
|
-
wClient.
|
|
392
|
+
let [syncing, blockNumberUint, peers, node] = await Promise.all([
|
|
393
|
+
query(wClient, Calls.eth_syncing),
|
|
394
|
+
query(wClient, Calls.eth_blockNumber),
|
|
395
|
+
query(wClient, Calls.net_peerCount),
|
|
396
|
+
query(wClient, Calls.net_version),
|
|
230
397
|
]);
|
|
398
|
+
let blockNumber = Number(blockNumberUint);
|
|
231
399
|
|
|
232
|
-
let ping = Math.round((Date.now() - start) /
|
|
233
|
-
let
|
|
234
|
-
|
|
400
|
+
let ping = Math.round((Date.now() - start) / 4);
|
|
401
|
+
let blockNumberBehind = 0;
|
|
402
|
+
if (syncing?.currentBlock && syncing.currentBlock < blockNumber) {
|
|
403
|
+
blockNumberBehind = blockNumber - Number(syncing.currentBlock);
|
|
404
|
+
blockNumber = Number(syncing.currentBlock);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return <IWeb3ClientStatus>{
|
|
235
408
|
url: url,
|
|
236
|
-
status: 'live',
|
|
237
|
-
syncing:
|
|
409
|
+
status: syncing ? 'sync' : (isNaN(blockNumber) ? 'off': 'live'),
|
|
410
|
+
syncing: syncing,
|
|
238
411
|
blockNumber: blockNumber,
|
|
239
|
-
blockNumberBehind:
|
|
240
|
-
peers: peers,
|
|
412
|
+
blockNumberBehind: blockNumberBehind,
|
|
413
|
+
peers: Number(peers),
|
|
241
414
|
pingMs: ping,
|
|
415
|
+
node: node,
|
|
242
416
|
i: idx,
|
|
243
417
|
};
|
|
244
418
|
|
|
245
419
|
} catch (error) {
|
|
246
|
-
return <IWeb3ClientStatus>
|
|
420
|
+
return <IWeb3ClientStatus>{
|
|
247
421
|
url,
|
|
248
422
|
status: 'error',
|
|
249
423
|
error: error,
|
|
@@ -261,57 +435,53 @@ export class ClientPool {
|
|
|
261
435
|
return nodes;
|
|
262
436
|
}
|
|
263
437
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
// fn, opts, used, errors, root
|
|
292
|
-
// );
|
|
293
|
-
// return;
|
|
294
|
-
// }
|
|
295
|
-
// root.emit('error', error);
|
|
296
|
-
// root.reject(error);
|
|
297
|
-
// });
|
|
298
|
-
|
|
299
|
-
// used.set(wClient, 1);
|
|
300
|
-
// return root as any as TResult;
|
|
301
|
-
// }
|
|
438
|
+
private async next(used?: Map<WClient, number>, opts?: IPoolWeb3Request, params?: { manual?: boolean }): Promise<WClient> {
|
|
439
|
+
let clients = this.clients;
|
|
440
|
+
if (params?.manual !== true) {
|
|
441
|
+
clients = clients.filter(x => x.config.manual !== true);
|
|
442
|
+
}
|
|
443
|
+
if (opts?.method != null) {
|
|
444
|
+
let clientsWithSupportedMethod = clients.filter(x => {
|
|
445
|
+
let methods = x.config.methods;
|
|
446
|
+
if (methods == null) {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
if (methods.exclude?.includes(opts.method) === true) {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
if (methods.only != null) {
|
|
453
|
+
return methods.only.includes(opts.method) === true;
|
|
454
|
+
}
|
|
455
|
+
return true;
|
|
456
|
+
});
|
|
457
|
+
if (clientsWithSupportedMethod.length > 0) {
|
|
458
|
+
// if there are no clients with manually specified method, use all clients
|
|
459
|
+
clients = clientsWithSupportedMethod;
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
// Unspecified method, so exclude clients with specific methods
|
|
463
|
+
clients = clients.filter(x => x.config.methods == null);
|
|
464
|
+
}
|
|
302
465
|
|
|
303
|
-
private async next (used?: Map<WClient, number>, opts?: IPoolWeb3Request): Promise<WClient> {
|
|
304
466
|
if (opts?.ws === true) {
|
|
305
467
|
if (this.ws == null) {
|
|
306
|
-
this.ws =
|
|
468
|
+
this.ws = clients.find(x => x.config.url?.startsWith('ws'));
|
|
469
|
+
}
|
|
470
|
+
if (this.ws == null) {
|
|
471
|
+
this.ws = clients.find(x => x.config.web3 != null);
|
|
307
472
|
}
|
|
308
473
|
return this.ws;
|
|
309
474
|
}
|
|
310
475
|
|
|
311
|
-
let clients = this.clients;
|
|
312
|
-
|
|
313
476
|
if (opts?.ws === false) {
|
|
314
|
-
|
|
477
|
+
// filter out all WS providers (important for batched requests, as web3js has issues submitting multiple batch requests and handle response IDs)
|
|
478
|
+
clients = clients.filter(x => x.config.url?.startsWith('http') || x.config.url == null);
|
|
479
|
+
}
|
|
480
|
+
if (opts?.node?.traceable === true) {
|
|
481
|
+
clients = clients.filter(x => x.config.traceable === true);
|
|
482
|
+
}
|
|
483
|
+
if (opts?.node?.url != null) {
|
|
484
|
+
clients = clients.filter(x => x.config.url === opts.node.url);
|
|
315
485
|
}
|
|
316
486
|
|
|
317
487
|
if (this.discoveredPartial === false) {
|
|
@@ -320,7 +490,7 @@ export class ClientPool {
|
|
|
320
490
|
}
|
|
321
491
|
|
|
322
492
|
// we check OK clients first
|
|
323
|
-
let okClients = clients.filter(x => x.status === 'ok'
|
|
493
|
+
let okClients = clients.filter(x => x.status === 'ok');
|
|
324
494
|
if (okClients.length === 0) {
|
|
325
495
|
// then switch to at least not off
|
|
326
496
|
let notOffClients = clients.filter(x => x.status !== 'off');
|
|
@@ -333,7 +503,7 @@ export class ClientPool {
|
|
|
333
503
|
|
|
334
504
|
let available = used == null
|
|
335
505
|
? clients
|
|
336
|
-
: clients.filter(x => used.has(x) === false);
|
|
506
|
+
: clients.filter(x => used.has(x) === false || used.get(x) > 0);
|
|
337
507
|
|
|
338
508
|
if (available.length === 0) {
|
|
339
509
|
if (this.discoveredFull === false) {
|
|
@@ -344,7 +514,7 @@ export class ClientPool {
|
|
|
344
514
|
}
|
|
345
515
|
return null;
|
|
346
516
|
}
|
|
347
|
-
let healthy = available.filter(x =>
|
|
517
|
+
let healthy = available.filter(x => x.healthy());
|
|
348
518
|
|
|
349
519
|
if (opts?.preferSafe === true) {
|
|
350
520
|
let safe = healthy.filter(x => x.config.safe === true);
|
|
@@ -362,9 +532,53 @@ export class ClientPool {
|
|
|
362
532
|
let arr = healthy.length > 0
|
|
363
533
|
? healthy
|
|
364
534
|
: available;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
535
|
+
|
|
536
|
+
if (opts?.blockRangeCount != null) {
|
|
537
|
+
let upperThreshold = alot(arr).max(x => x.blockRangeLimits.blocks) * .5;
|
|
538
|
+
arr = arr.filter(x => {
|
|
539
|
+
let blocks = x.blockRangeLimits.blocks;
|
|
540
|
+
if (blocks == null) {
|
|
541
|
+
// Block limit is unknown yet
|
|
542
|
+
return true;
|
|
543
|
+
}
|
|
544
|
+
if (blocks < this.MINIMUM_BLOCK_RANGE) {
|
|
545
|
+
// Was not possible to load a minimum amount of blocks
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
// Get if higher than 50% of max supported limit
|
|
549
|
+
return x.blockRangeLimits.blocks >= upperThreshold
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
return await this.getClientWithLowestWaitTime(arr);
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
private async getClientWithLowestWaitTime(clients: WClient[]): Promise<WClient> {
|
|
557
|
+
if (clients.length === 0) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
clients = $array.shuffle(clients);
|
|
562
|
+
|
|
563
|
+
let minWait = Infinity;
|
|
564
|
+
let minClient: WClient = null;
|
|
565
|
+
for (let i = 0; i < clients.length; i++) {
|
|
566
|
+
let client = clients[i];
|
|
567
|
+
let waitMs = client.getRateLimitGuardTime();
|
|
568
|
+
if (waitMs === 0) {
|
|
569
|
+
return client;
|
|
570
|
+
}
|
|
571
|
+
if (minWait > waitMs) {
|
|
572
|
+
minWait = waitMs;
|
|
573
|
+
minClient = client;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
const MAX_WAIT = 60_000;
|
|
578
|
+
if (minWait > MAX_WAIT) {
|
|
579
|
+
throw new Error(`rate limit overflows. Waiting ${minWait}ms`);
|
|
580
|
+
}
|
|
581
|
+
return minClient;
|
|
368
582
|
}
|
|
369
583
|
|
|
370
584
|
/**
|
|
@@ -375,7 +589,7 @@ export class ClientPool {
|
|
|
375
589
|
* - Complete Promise - when all clients are resolved
|
|
376
590
|
*/
|
|
377
591
|
@memd.deco.memoize({ perInstance: true })
|
|
378
|
-
private discoverLive
|
|
592
|
+
private discoverLive(): { ready: class_Dfr, completed: class_Dfr } {
|
|
379
593
|
|
|
380
594
|
this.clients.forEach(x => x.status = 'ping');
|
|
381
595
|
|
|
@@ -397,17 +611,17 @@ export class ClientPool {
|
|
|
397
611
|
(async () => {
|
|
398
612
|
let nodeInfosAsync = clients.map(async (wClient, idx) => {
|
|
399
613
|
try {
|
|
400
|
-
let clientInfo = {
|
|
614
|
+
let clientInfo = <TClientInfo>{
|
|
401
615
|
i: idx,
|
|
402
616
|
error: null,
|
|
403
617
|
status: null,
|
|
404
618
|
blockNumberBehind: 0,
|
|
405
|
-
blockNumber: await $
|
|
619
|
+
blockNumber: await $promise.timeout(wClient.rpc.eth_blockNumber(), 20_000)
|
|
406
620
|
};
|
|
407
621
|
onIntermediateSuccess(clientInfo);
|
|
408
622
|
return clientInfo;
|
|
409
623
|
} catch (error) {
|
|
410
|
-
return <TClientInfo>
|
|
624
|
+
return <TClientInfo>{
|
|
411
625
|
i: idx,
|
|
412
626
|
error: error,
|
|
413
627
|
status: 'off',
|
|
@@ -423,6 +637,7 @@ export class ClientPool {
|
|
|
423
637
|
let messages = nodeInfos.map(x => {
|
|
424
638
|
let url = clients[x.i]?.config.url;
|
|
425
639
|
let message = x.error?.message;
|
|
640
|
+
console.log(`Stack`, x.error?.stack);
|
|
426
641
|
return ` ${url}: ${message}`;
|
|
427
642
|
}).join('\n');
|
|
428
643
|
|
|
@@ -435,8 +650,8 @@ export class ClientPool {
|
|
|
435
650
|
|
|
436
651
|
const blockLatest = alot(nodeInfos).max(x => x.blockNumber);
|
|
437
652
|
|
|
438
|
-
nodeInfos.forEach(
|
|
439
|
-
|
|
653
|
+
nodeInfos.forEach(info => {
|
|
654
|
+
info.blockNumberBehind = info.blockNumber - blockLatest;
|
|
440
655
|
});
|
|
441
656
|
nodeInfos.forEach(info => {
|
|
442
657
|
this.clients[info.i].status = isOk(info);
|
|
@@ -450,23 +665,24 @@ export class ClientPool {
|
|
|
450
665
|
}
|
|
451
666
|
})();
|
|
452
667
|
|
|
453
|
-
function isOk
|
|
668
|
+
function isOk(info: TClientInfo): WClient['status'] {
|
|
454
669
|
if (info.error) {
|
|
455
670
|
return 'off';
|
|
456
671
|
}
|
|
457
|
-
if (
|
|
672
|
+
if (info.blockNumber == null || info.blockNumberBehind < -200n) {
|
|
458
673
|
return 'off';
|
|
459
674
|
}
|
|
460
675
|
return 'ok';
|
|
461
676
|
}
|
|
462
|
-
function onIntermediateSuccess
|
|
463
|
-
const TOLERATE_BLOCK_COUNT =
|
|
677
|
+
function onIntermediateSuccess(info: TClientInfo) {
|
|
678
|
+
const TOLERATE_BLOCK_COUNT = 5n;
|
|
464
679
|
const WAIT_POOL_OK = Math.min(3, clientInfos.length);
|
|
680
|
+
const count = clientInfos.push(info);
|
|
465
681
|
|
|
466
682
|
if (isReady === true) {
|
|
467
683
|
return;
|
|
468
684
|
}
|
|
469
|
-
if (
|
|
685
|
+
if (count < WAIT_POOL_OK) {
|
|
470
686
|
return;
|
|
471
687
|
}
|
|
472
688
|
|
|
@@ -480,8 +696,9 @@ export class ClientPool {
|
|
|
480
696
|
}
|
|
481
697
|
if (ok.length >= WAIT_POOL_OK) {
|
|
482
698
|
ok.forEach(info => {
|
|
483
|
-
clients[info.i].status = 'ok';
|
|
699
|
+
clients[info.i].status = info.status = 'ok';
|
|
484
700
|
});
|
|
701
|
+
|
|
485
702
|
isReady = true;
|
|
486
703
|
ready.resolve();
|
|
487
704
|
}
|
|
@@ -491,9 +708,9 @@ export class ClientPool {
|
|
|
491
708
|
}
|
|
492
709
|
}
|
|
493
710
|
|
|
494
|
-
class WClient {
|
|
711
|
+
export class WClient {
|
|
495
712
|
lastStatus = 0;
|
|
496
|
-
lastDate
|
|
713
|
+
lastDate = new Date(2000).getTime();
|
|
497
714
|
|
|
498
715
|
status: 'ok' | 'off' | 'ping' = 'ok'
|
|
499
716
|
|
|
@@ -503,10 +720,21 @@ class WClient {
|
|
|
503
720
|
ping: 0
|
|
504
721
|
};
|
|
505
722
|
|
|
506
|
-
|
|
507
|
-
|
|
723
|
+
rpc: Rpc
|
|
724
|
+
|
|
725
|
+
config: IPoolClientConfig
|
|
726
|
+
rateLimitGuard: RateLimitGuard
|
|
508
727
|
|
|
509
|
-
|
|
728
|
+
/** For getLogs method, as some providers limit the range request or page result value */
|
|
729
|
+
blockRangeLimits: {
|
|
730
|
+
blocks?: number
|
|
731
|
+
results?: number
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// Max requests per single Web3 Batch request
|
|
735
|
+
batchLimit?: number
|
|
736
|
+
|
|
737
|
+
healthy() {
|
|
510
738
|
if (this.getRequestCount() === 0) {
|
|
511
739
|
return true;
|
|
512
740
|
}
|
|
@@ -517,21 +745,91 @@ class WClient {
|
|
|
517
745
|
if (health > .5) {
|
|
518
746
|
return true;
|
|
519
747
|
}
|
|
520
|
-
if (Date.now() - this.lastDate
|
|
748
|
+
if (Date.now() - this.lastDate > $date.parseTimespan('10m')) {
|
|
521
749
|
return true;
|
|
522
750
|
}
|
|
523
751
|
return false;
|
|
524
752
|
}
|
|
525
753
|
|
|
526
|
-
|
|
527
|
-
this.
|
|
528
|
-
|
|
529
|
-
|
|
754
|
+
private updateRateLimitInfo(info: ReturnType<typeof RateLimitGuard['extractRateLimitFromError']>) {
|
|
755
|
+
if (this.rateLimitGuard == null) {
|
|
756
|
+
this.rateLimitGuard = new RateLimitGuard({
|
|
757
|
+
id: this.config.url ?? 'web3',
|
|
758
|
+
rates: []
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
this.rateLimitGuard.updateRateLimitInfo(info);
|
|
530
762
|
}
|
|
763
|
+
public updateBlockRangeInfo(info: WClient['blockRangeLimits']) {
|
|
764
|
+
if (this.blockRangeLimits == null) {
|
|
765
|
+
this.blockRangeLimits = {};
|
|
766
|
+
}
|
|
767
|
+
if (info.blocks != null) {
|
|
768
|
+
this.blockRangeLimits.blocks = info.blocks;
|
|
769
|
+
}
|
|
770
|
+
if (info.results != null) {
|
|
771
|
+
this.blockRangeLimits.results = info.results;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
constructor(mix: IPoolClientConfig) {
|
|
776
|
+
const hasUrl = 'url' in mix && typeof mix.url === 'string';
|
|
777
|
+
const hasWeb3 = 'web3' in mix && typeof mix.web3 != null;
|
|
778
|
+
if (hasUrl || hasWeb3) {
|
|
779
|
+
this.config = mix;
|
|
780
|
+
let transport = mix as TTransport.Options.Any;
|
|
781
|
+
this.rpc = new Rpc(transport);
|
|
782
|
+
} else {
|
|
783
|
+
throw new Error(`Neither Node URL nor Web3 Instance in argument`);
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
this.blockRangeLimits = { blocks: Infinity };
|
|
787
|
+
|
|
788
|
+
if (mix.rateLimit) {
|
|
789
|
+
let rates = RateLimitGuard.parseRateLimit(mix.rateLimit);
|
|
790
|
+
this.rateLimitGuard = new RateLimitGuard({
|
|
791
|
+
id: this.config?.url ?? 'web3',
|
|
792
|
+
rates: rates
|
|
793
|
+
})
|
|
794
|
+
}
|
|
795
|
+
if (mix.blockRangeLimit) {
|
|
796
|
+
this.updateBlockRangeInfo({
|
|
797
|
+
blocks: $number.parse(mix.blockRangeLimit)
|
|
798
|
+
})
|
|
799
|
+
}
|
|
800
|
+
if (mix.batchLimit) {
|
|
801
|
+
this.batchLimit = $number.parse(mix.batchLimit);
|
|
802
|
+
}
|
|
803
|
+
if (mix.fetchableBlockRange) {
|
|
804
|
+
this.updateBlockRangeInfo({
|
|
805
|
+
blocks: $number.parse(mix.fetchableBlockRange)
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
|
|
811
|
+
// @memd.deco.memoize()
|
|
812
|
+
// private createWebSocketClient(url: string) {
|
|
813
|
+
// let { options } = this.config;
|
|
814
|
+
|
|
815
|
+
// // options = obj_extendDefaults(options ?? {}, { clientConfig: {} });
|
|
816
|
+
// // obj_extendDefaults((options as TTransport.Options.Ws).clientConfig, {
|
|
817
|
+
// // // default frame size is too small
|
|
818
|
+
// // maxReceivedFrameSize: 50_000_000,
|
|
819
|
+
// // maxReceivedMessageSize: 50_000_000,
|
|
820
|
+
// // });
|
|
821
|
+
|
|
822
|
+
// let transport = new WsTransport({ url, ...options });
|
|
823
|
+
|
|
824
|
+
// // transport.on('close', ev => this.websocket.code = ev.code);
|
|
825
|
+
// // transport.on('connect', _ => this.websocket.code = WS_STATE.CONNECTED);
|
|
826
|
+
|
|
827
|
+
// return transport;
|
|
828
|
+
// }
|
|
531
829
|
|
|
532
|
-
async send
|
|
830
|
+
async send<TResult>(fn: (web3: WClient) => PromiseEvent<TResult>): Promise<{ status: ClientStatus, error?, result?: PromiseEvent<TResult> }> {
|
|
533
831
|
return new Promise((resolve, reject) => {
|
|
534
|
-
let result = fn(this
|
|
832
|
+
let result = fn(this);
|
|
535
833
|
|
|
536
834
|
result.then(
|
|
537
835
|
_ => {
|
|
@@ -540,7 +838,7 @@ class WClient {
|
|
|
540
838
|
resolve({ status: ClientStatus.Ok, result })
|
|
541
839
|
},
|
|
542
840
|
error => {
|
|
543
|
-
if (ClientErrorUtil.isConnectionFailed
|
|
841
|
+
if (ClientErrorUtil.isConnectionFailed(error)) {
|
|
544
842
|
this.lastStatus = ClientStatus.NetworkError;
|
|
545
843
|
this.requests.fail++;
|
|
546
844
|
resolve({ status: ClientStatus.NetworkError, error });
|
|
@@ -550,43 +848,117 @@ class WClient {
|
|
|
550
848
|
);
|
|
551
849
|
});
|
|
552
850
|
}
|
|
851
|
+
sendSignedTransaction (tx: TEth.Hex) {
|
|
852
|
+
let promise = new PromiseEvent<TEth.TxReceipt>();
|
|
853
|
+
this
|
|
854
|
+
.rpc
|
|
855
|
+
.eth_sendRawTransaction(tx)
|
|
856
|
+
.then(async hash => {
|
|
857
|
+
promise.emit('transactionHash', hash);
|
|
858
|
+
let receipt = await $rpc.waitForReceipt(this.rpc, hash);
|
|
859
|
+
promise.resolve(receipt);
|
|
860
|
+
}, error => {
|
|
861
|
+
promise.reject(error);
|
|
862
|
+
});
|
|
863
|
+
return promise;
|
|
864
|
+
}
|
|
865
|
+
sendTransaction (tx) {
|
|
866
|
+
let promise = new PromiseEvent<TEth.TxReceipt>();
|
|
867
|
+
this
|
|
868
|
+
.rpc
|
|
869
|
+
.eth_sendTransaction(tx)
|
|
870
|
+
.then(async hash => {
|
|
871
|
+
promise.emit('transactionHash', hash);
|
|
872
|
+
let receipt = await $rpc.waitForReceipt(this.rpc, hash);
|
|
873
|
+
promise.resolve(receipt);
|
|
874
|
+
}, error => {
|
|
875
|
+
promise.reject(error);
|
|
876
|
+
});
|
|
877
|
+
return promise;
|
|
878
|
+
}
|
|
553
879
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
880
|
+
async callBatched<TResult = any>(requests: TRpc.IRpcAction[]): Promise<TResult[]> {
|
|
881
|
+
let total = requests.length;
|
|
882
|
+
let spanLimit = this.getSpanLimit(requests.length);
|
|
883
|
+
let output = [] as TResult[];
|
|
884
|
+
let errors = [];
|
|
885
|
+
let pageIdx = 0;
|
|
886
|
+
while (requests.length > 0) {
|
|
887
|
+
++pageIdx;
|
|
888
|
+
let page = requests.splice(0, spanLimit);
|
|
889
|
+
if (requests.length > 0 || pageIdx > 1) {
|
|
890
|
+
$logger.throttled(`Sending ${page.length} batched requests. Loaded ${output.length}/${total}`);
|
|
891
|
+
}
|
|
892
|
+
let { status, error, result: pageResult } = await this.call(async (client) => {
|
|
893
|
+
let batch = new Web3BatchRequests.BatchRequest(client.rpc, page);
|
|
894
|
+
let results = await batch.execute();
|
|
895
|
+
return results;
|
|
896
|
+
});
|
|
897
|
+
if (status === ClientStatus.Ok) {
|
|
898
|
+
output.push(...pageResult);
|
|
899
|
+
continue;
|
|
900
|
+
}
|
|
901
|
+
if (status === ClientStatus.RateLimited) {
|
|
902
|
+
spanLimit = this.getSpanLimit(requests.length);
|
|
903
|
+
}
|
|
904
|
+
errors.push(error);
|
|
905
|
+
if (errors.length > 2) {
|
|
906
|
+
throw error;
|
|
907
|
+
}
|
|
908
|
+
requests.unshift(...page);
|
|
909
|
+
}
|
|
910
|
+
return output;
|
|
911
|
+
}
|
|
560
912
|
|
|
561
|
-
|
|
913
|
+
async call<TResult extends PromiseLike<any>>(fn: (wClient: WClient) => TResult, options?: {
|
|
914
|
+
// For the rate limit guard, to make sure we wait enough time to proceed with batch request for example
|
|
915
|
+
batchRequestCount?: number
|
|
916
|
+
}): Promise<{ status: ClientStatus, error?, result?: Awaited<TResult>, time: number }> {
|
|
917
|
+
let now = Date.now();
|
|
918
|
+
await this.rateLimitGuard?.wait(options?.batchRequestCount ?? 1, now);
|
|
919
|
+
|
|
920
|
+
let connectionError = await this.ensureConnected();
|
|
921
|
+
if (connectionError) {
|
|
922
|
+
return {
|
|
923
|
+
status: ClientStatus.NetworkError,
|
|
924
|
+
result: null,
|
|
925
|
+
error: connectionError,
|
|
926
|
+
time: Date.now() - now
|
|
927
|
+
};
|
|
928
|
+
}
|
|
562
929
|
|
|
563
|
-
// } catch (error) {
|
|
564
|
-
// console.log(error);
|
|
565
|
-
// if (this.isConnectionFailed (error)) {
|
|
566
|
-
// this.lastStatus = Status.NetworkError;
|
|
567
|
-
// this.requests.fail++;
|
|
568
|
-
// return { status: Status.NetworkError, result: error };
|
|
569
|
-
// }
|
|
570
|
-
// return { status: Status.CallError, result: error }
|
|
571
|
-
// }
|
|
572
|
-
// }
|
|
573
|
-
async call <TResult extends PromiseLike<any>> (fn: (web3: Web3) => TResult ): Promise<{ status: ClientStatus, error?, result?: TResult, time: number }> {
|
|
574
930
|
return new Promise((resolve, reject) => {
|
|
575
931
|
let start = Date.now();
|
|
576
|
-
let result = fn(this
|
|
932
|
+
let result = fn(this);
|
|
577
933
|
|
|
578
934
|
result.then(
|
|
579
|
-
|
|
935
|
+
result => {
|
|
580
936
|
let time = Date.now() - start;
|
|
581
937
|
let status = ClientStatus.Ok;
|
|
582
938
|
this.onComplete(status, time);
|
|
939
|
+
this.rateLimitGuard?.onComplete(now);
|
|
583
940
|
resolve({ status, result, time })
|
|
584
941
|
},
|
|
585
942
|
error => {
|
|
586
943
|
let time = Date.now() - start;
|
|
587
|
-
let status =
|
|
944
|
+
let status = ClientStatus.CallError;
|
|
945
|
+
|
|
946
|
+
if (RateLimitGuard.isRateLimited(error)) {
|
|
947
|
+
status = ClientStatus.RateLimited;
|
|
588
948
|
|
|
589
|
-
|
|
949
|
+
let rateLimitInfo = RateLimitGuard.extractRateLimitFromError(error);
|
|
950
|
+
if (rateLimitInfo == null) {
|
|
951
|
+
l`RateLimit not extracted: ${error.message}`;
|
|
952
|
+
}
|
|
953
|
+
this.updateRateLimitInfo(rateLimitInfo);
|
|
954
|
+
} else if (RateLimitGuard.isBatchLimit(error)) {
|
|
955
|
+
status = ClientStatus.RateLimited;
|
|
956
|
+
let limit = RateLimitGuard.extractBatchLimitFromError(error);
|
|
957
|
+
if (limit !== this.batchLimit) {
|
|
958
|
+
l`yellow<New BatchLimit> for "${this.config.url}" bold<${limit}>`;
|
|
959
|
+
this.batchLimit = limit;
|
|
960
|
+
}
|
|
961
|
+
} else if (ClientErrorUtil.isConnectionFailed(error)) {
|
|
590
962
|
status = ClientStatus.NetworkError;
|
|
591
963
|
}
|
|
592
964
|
this.onComplete(status, time);
|
|
@@ -596,10 +968,10 @@ class WClient {
|
|
|
596
968
|
});
|
|
597
969
|
}
|
|
598
970
|
|
|
599
|
-
callPromiEvent
|
|
600
|
-
let result = fn(this
|
|
971
|
+
callPromiEvent<TResult extends PromiseEvent<any>>(fn: (web3: WClient) => TResult): TResult {
|
|
972
|
+
let result = fn(this);
|
|
601
973
|
result.on('error', error => {
|
|
602
|
-
if (ClientErrorUtil.isConnectionFailed
|
|
974
|
+
if (ClientErrorUtil.isConnectionFailed(error)) {
|
|
603
975
|
this.lastStatus = ClientStatus.NetworkError;
|
|
604
976
|
this.requests.fail++;
|
|
605
977
|
}
|
|
@@ -610,10 +982,10 @@ class WClient {
|
|
|
610
982
|
})
|
|
611
983
|
return result;
|
|
612
984
|
}
|
|
613
|
-
callSubscription
|
|
614
|
-
let result = fn(this
|
|
985
|
+
callSubscription<TResult extends PromiseEvent<any>>(fn: (web3: WClient) => TResult): TResult {
|
|
986
|
+
let result = fn(this);
|
|
615
987
|
result.on('error', error => {
|
|
616
|
-
if (ClientErrorUtil.isConnectionFailed
|
|
988
|
+
if (ClientErrorUtil.isConnectionFailed(error)) {
|
|
617
989
|
this.lastStatus = ClientStatus.NetworkError;
|
|
618
990
|
this.requests.fail++;
|
|
619
991
|
}
|
|
@@ -625,32 +997,18 @@ class WClient {
|
|
|
625
997
|
return result;
|
|
626
998
|
}
|
|
627
999
|
|
|
628
|
-
getEventStream (address: TAddress, abi: AbiItem[], event: string, options = {}): ClientEventsStream {
|
|
629
|
-
let eventAbi = abi.find(x => x.type === 'event' && x.name === event);
|
|
630
|
-
if (eventAbi == null) {
|
|
631
|
-
let events = abi.filter(x => x.type === 'event').map(x => x.name).join(', ');
|
|
632
|
-
throw new Error(`Event "${event}" not present in ABI. Events: ${ events }`);
|
|
633
|
-
}
|
|
634
|
-
const contract = new this.eth.Contract(abi, address);
|
|
635
|
-
const stream = contract
|
|
636
|
-
.events
|
|
637
|
-
[event](options);
|
|
638
|
-
|
|
639
|
-
const worker = new ClientEventsStream(contract, eventAbi, stream)
|
|
640
|
-
return worker;
|
|
641
|
-
}
|
|
642
1000
|
|
|
643
|
-
callSync
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
1001
|
+
// callSync<TResult>(fn: (web3: Web3) => TResult): { status: number, result?: TResult } {
|
|
1002
|
+
// try {
|
|
1003
|
+
// let result = fn(this.web3);
|
|
1004
|
+
// return { status: ClientStatus.Ok, result };
|
|
647
1005
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
1006
|
+
// } catch (error) {
|
|
1007
|
+
// return { status: ClientStatus.CallError, result: error }
|
|
1008
|
+
// }
|
|
1009
|
+
// }
|
|
652
1010
|
|
|
653
|
-
onComplete
|
|
1011
|
+
onComplete(status: ClientStatus, timeMs: number) {
|
|
654
1012
|
let callCount = this.getRequestCount();
|
|
655
1013
|
let ping = this.requests.ping;
|
|
656
1014
|
|
|
@@ -666,8 +1024,59 @@ class WClient {
|
|
|
666
1024
|
this.requests.ping = (ping * callCount + timeMs) / (callCount + 1);
|
|
667
1025
|
}
|
|
668
1026
|
|
|
669
|
-
|
|
1027
|
+
async ensureConnected(): Promise<Error> {
|
|
1028
|
+
// if (this.config.url?.startsWith('ws')) {
|
|
1029
|
+
// if (this.websocket.code === WS_STATE.ECONNRESET) {
|
|
1030
|
+
// // recreate connection when ERRCONNRESET was thrown previously
|
|
1031
|
+
// this.createWebSocketClient();
|
|
1032
|
+
// }
|
|
1033
|
+
|
|
1034
|
+
// let web3 = this.web3;
|
|
1035
|
+
// let provider = web3.eth.currentProvider as WebsocketProvider & { url };
|
|
1036
|
+
// if (provider.connected === false) {
|
|
1037
|
+
// provider.connect();
|
|
1038
|
+
// try {
|
|
1039
|
+
// await $promise.waitForTrue(() => provider.connected, {
|
|
1040
|
+
// intervalMs: 200,
|
|
1041
|
+
// timeoutMessage: `Couldn't connect to WS ${provider.url}`,
|
|
1042
|
+
// timeoutMs: 20_000
|
|
1043
|
+
// });
|
|
1044
|
+
// return null;
|
|
1045
|
+
// } catch (error) {
|
|
1046
|
+
// return error;
|
|
1047
|
+
// }
|
|
1048
|
+
// }
|
|
1049
|
+
// }
|
|
1050
|
+
return null;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
getRequestCount() {
|
|
670
1054
|
return this.requests.success + this.requests.fail;
|
|
671
1055
|
}
|
|
672
1056
|
|
|
1057
|
+
/**
|
|
1058
|
+
* Checks the rate limit wait time, so that the POOL can select the wClient with shortest wait time
|
|
1059
|
+
**/
|
|
1060
|
+
getRateLimitGuardTime() {
|
|
1061
|
+
return this.rateLimitGuard?.checkWaitTime() ?? 0;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
private getSpanLimit(requestCount: number) {
|
|
1065
|
+
let a = this.rateLimitGuard?.getSpanLimit() ?? Infinity;
|
|
1066
|
+
let b = this.batchLimit ?? Infinity;
|
|
1067
|
+
|
|
1068
|
+
let min = requestCount === 0
|
|
1069
|
+
? Math.min(a, b)
|
|
1070
|
+
: Math.min(a, b, requestCount);
|
|
1071
|
+
$require.gt(min, 0, `Span-limit must be > 0. ${a}/${b}/${requestCount}`);
|
|
1072
|
+
return min;
|
|
1073
|
+
}
|
|
673
1074
|
}
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
const WS_STATE = {
|
|
1079
|
+
NOTSET: 0,
|
|
1080
|
+
CONNECTED: 1,
|
|
1081
|
+
ECONNRESET: 1006
|
|
1082
|
+
};
|