dequanto 0.0.1 → 0.0.7
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 +28 -0
- package/actions/contracts.act.ts +50 -0
- package/actions/logs.act.ts +7 -0
- package/actions/safe.act.ts +7 -0
- package/actions/tokens.act.ts +20 -2
- package/configs/defi.yml +24 -0
- package/configs/dequanto.yml +49 -2
- package/contracts/abi/gnosis/GnosisSafe.json +979 -0
- package/contracts/gen/base/{ERC20Base.ts → ERC20Base/ERC20Base.ts} +136 -90
- package/contracts/gen/eth/WETHBase.ts +35 -35
- package/contracts/gnosis/GnosisSafe.ts +750 -0
- package/contracts/openzeppelin/AccessControl.json +206 -0
- package/contracts/openzeppelin/AccessControl.ts +236 -0
- package/contracts/openzeppelin/AccessControlCrossChain.json +219 -0
- package/contracts/openzeppelin/AccessControlCrossChain.ts +247 -0
- package/contracts/openzeppelin/AccessControlEnumerable.json +249 -0
- package/contracts/openzeppelin/AccessControlEnumerable.ts +258 -0
- package/contracts/openzeppelin/Address.json +1 -0
- package/contracts/openzeppelin/Address.ts +83 -0
- package/contracts/openzeppelin/Arrays.json +1 -0
- package/contracts/openzeppelin/Arrays.ts +83 -0
- package/contracts/openzeppelin/Base64.json +1 -0
- package/contracts/openzeppelin/Base64.ts +83 -0
- package/contracts/openzeppelin/BeaconProxy.json +71 -0
- package/contracts/openzeppelin/BeaconProxy.ts +163 -0
- package/contracts/openzeppelin/BitMaps.json +1 -0
- package/contracts/openzeppelin/BitMaps.ts +83 -0
- package/contracts/openzeppelin/Checkpoints.json +1 -0
- package/contracts/openzeppelin/Checkpoints.ts +83 -0
- package/contracts/openzeppelin/Clones.json +1 -0
- package/contracts/openzeppelin/Clones.ts +83 -0
- package/contracts/openzeppelin/ConditionalEscrow.json +156 -0
- package/contracts/openzeppelin/ConditionalEscrow.ts +236 -0
- package/contracts/openzeppelin/Context.json +1 -0
- package/contracts/openzeppelin/Context.ts +83 -0
- package/contracts/openzeppelin/Counters.json +1 -0
- package/contracts/openzeppelin/Counters.ts +83 -0
- package/contracts/openzeppelin/Create2.json +1 -0
- package/contracts/openzeppelin/Create2.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabled.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabled.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledAMB.json +13 -0
- package/contracts/openzeppelin/CrossChainEnabledAMB.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL1.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL1.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL2.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabledArbitrumL2.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledOptimism.json +1 -0
- package/contracts/openzeppelin/CrossChainEnabledOptimism.ts +83 -0
- package/contracts/openzeppelin/CrossChainEnabledPolygonChild.json +30 -0
- package/contracts/openzeppelin/CrossChainEnabledPolygonChild.ts +90 -0
- package/contracts/openzeppelin/DoubleEndedQueue.json +12 -0
- package/contracts/openzeppelin/DoubleEndedQueue.ts +83 -0
- package/contracts/openzeppelin/ECDSA.json +1 -0
- package/contracts/openzeppelin/ECDSA.ts +83 -0
- package/contracts/openzeppelin/EIP712.json +1 -0
- package/contracts/openzeppelin/EIP712.ts +83 -0
- package/contracts/openzeppelin/ERC1155.json +325 -0
- package/contracts/openzeppelin/ERC1155.ts +276 -0
- package/contracts/openzeppelin/ERC1155Burnable.json +360 -0
- package/contracts/openzeppelin/ERC1155Burnable.ts +298 -0
- package/contracts/openzeppelin/ERC1155Holder.json +99 -0
- package/contracts/openzeppelin/ERC1155Holder.ts +112 -0
- package/contracts/openzeppelin/ERC1155Pausable.json +353 -0
- package/contracts/openzeppelin/ERC1155Pausable.ts +345 -0
- package/contracts/openzeppelin/ERC1155PresetMinterPauser.json +734 -0
- package/contracts/openzeppelin/ERC1155PresetMinterPauser.ts +608 -0
- package/contracts/openzeppelin/ERC1155Receiver.json +99 -0
- package/contracts/openzeppelin/ERC1155Receiver.ts +112 -0
- package/contracts/openzeppelin/ERC1155Supply.json +352 -0
- package/contracts/openzeppelin/ERC1155Supply.ts +298 -0
- package/contracts/openzeppelin/ERC1155URIStorage.json +314 -0
- package/contracts/openzeppelin/ERC1155URIStorage.ts +276 -0
- package/contracts/openzeppelin/ERC165.json +21 -0
- package/contracts/openzeppelin/ERC165.ts +90 -0
- package/contracts/openzeppelin/ERC165Checker.json +1 -0
- package/contracts/openzeppelin/ERC165Checker.ts +83 -0
- package/contracts/openzeppelin/ERC165Storage.json +21 -0
- package/contracts/openzeppelin/ERC165Storage.ts +90 -0
- package/contracts/openzeppelin/ERC1820Implementer.json +26 -0
- package/contracts/openzeppelin/ERC1820Implementer.ts +90 -0
- package/contracts/openzeppelin/ERC1967Proxy.json +71 -0
- package/contracts/openzeppelin/ERC1967Proxy.ts +163 -0
- package/contracts/openzeppelin/ERC1967Upgrade.json +47 -0
- package/contracts/openzeppelin/ERC1967Upgrade.ts +163 -0
- package/contracts/openzeppelin/ERC20.json +288 -0
- package/contracts/openzeppelin/ERC20.ts +251 -0
- package/contracts/openzeppelin/ERC20Burnable.json +303 -0
- package/contracts/openzeppelin/ERC20Burnable.ts +273 -0
- package/contracts/openzeppelin/ERC20Capped.json +285 -0
- package/contracts/openzeppelin/ERC20Capped.ts +262 -0
- package/contracts/openzeppelin/ERC20FlashMint.json +349 -0
- package/contracts/openzeppelin/ERC20FlashMint.ts +284 -0
- package/contracts/openzeppelin/ERC20Pausable.json +311 -0
- package/contracts/openzeppelin/ERC20Pausable.ts +320 -0
- package/contracts/openzeppelin/ERC20Permit.json +347 -0
- package/contracts/openzeppelin/ERC20Permit.ts +284 -0
- package/contracts/openzeppelin/ERC20PresetFixedSupply.json +329 -0
- package/contracts/openzeppelin/ERC20PresetFixedSupply.ts +273 -0
- package/contracts/openzeppelin/ERC20PresetMinterPauser.json +663 -0
- package/contracts/openzeppelin/ERC20PresetMinterPauser.ts +583 -0
- package/contracts/openzeppelin/ERC20Snapshot.json +328 -0
- package/contracts/openzeppelin/ERC20Snapshot.ts +302 -0
- package/contracts/openzeppelin/ERC20Votes.json +584 -0
- package/contracts/openzeppelin/ERC20Votes.ts +430 -0
- package/contracts/openzeppelin/ERC20VotesComp.json +627 -0
- package/contracts/openzeppelin/ERC20VotesComp.ts +452 -0
- package/contracts/openzeppelin/ERC20Wrapper.json +333 -0
- package/contracts/openzeppelin/ERC20Wrapper.ts +284 -0
- package/contracts/openzeppelin/ERC2771Context.json +21 -0
- package/contracts/openzeppelin/ERC2771Context.ts +90 -0
- package/contracts/openzeppelin/ERC2981.json +50 -0
- package/contracts/openzeppelin/ERC2981.ts +101 -0
- package/contracts/openzeppelin/ERC4626.json +662 -0
- package/contracts/openzeppelin/ERC4626.ts +485 -0
- package/contracts/openzeppelin/ERC721.json +348 -0
- package/contracts/openzeppelin/ERC721.ts +295 -0
- package/contracts/openzeppelin/ERC721Burnable.json +345 -0
- package/contracts/openzeppelin/ERC721Burnable.ts +306 -0
- package/contracts/openzeppelin/ERC721Enumerable.json +388 -0
- package/contracts/openzeppelin/ERC721Enumerable.ts +328 -0
- package/contracts/openzeppelin/ERC721Holder.json +36 -0
- package/contracts/openzeppelin/ERC721Holder.ts +90 -0
- package/contracts/openzeppelin/ERC721Pausable.json +371 -0
- package/contracts/openzeppelin/ERC721Pausable.ts +364 -0
- package/contracts/openzeppelin/ERC721PresetMinterPauserAutoId.json +742 -0
- package/contracts/openzeppelin/ERC721PresetMinterPauserAutoId.ts +638 -0
- package/contracts/openzeppelin/ERC721Royalty.json +361 -0
- package/contracts/openzeppelin/ERC721Royalty.ts +306 -0
- package/contracts/openzeppelin/ERC721URIStorage.json +332 -0
- package/contracts/openzeppelin/ERC721URIStorage.ts +295 -0
- package/contracts/openzeppelin/ERC721Votes.json +546 -0
- package/contracts/openzeppelin/ERC721Votes.ts +441 -0
- package/contracts/openzeppelin/ERC777.json +578 -0
- package/contracts/openzeppelin/ERC777.ts +473 -0
- package/contracts/openzeppelin/ERC777PresetFixedSupply.json +588 -0
- package/contracts/openzeppelin/ERC777PresetFixedSupply.ts +473 -0
- package/contracts/openzeppelin/EnumerableMap.json +1 -0
- package/contracts/openzeppelin/EnumerableMap.ts +83 -0
- package/contracts/openzeppelin/EnumerableSet.json +1 -0
- package/contracts/openzeppelin/EnumerableSet.ts +83 -0
- package/contracts/openzeppelin/Escrow.json +137 -0
- package/contracts/openzeppelin/Escrow.ts +225 -0
- package/contracts/openzeppelin/Governor.json +866 -0
- package/contracts/openzeppelin/Governor.ts +525 -0
- package/contracts/openzeppelin/GovernorCompatibilityBravo.json +1181 -0
- package/contracts/openzeppelin/GovernorCompatibilityBravo.ts +654 -0
- package/contracts/openzeppelin/GovernorCountingSimple.json +895 -0
- package/contracts/openzeppelin/GovernorCountingSimple.ts +536 -0
- package/contracts/openzeppelin/GovernorPreventLateQuorum.json +930 -0
- package/contracts/openzeppelin/GovernorPreventLateQuorum.ts +605 -0
- package/contracts/openzeppelin/GovernorProposalThreshold.json +866 -0
- package/contracts/openzeppelin/GovernorProposalThreshold.ts +525 -0
- package/contracts/openzeppelin/GovernorSettings.json +962 -0
- package/contracts/openzeppelin/GovernorSettings.ts +645 -0
- package/contracts/openzeppelin/GovernorTimelockCompound.json +990 -0
- package/contracts/openzeppelin/GovernorTimelockCompound.ts +638 -0
- package/contracts/openzeppelin/GovernorTimelockControl.json +983 -0
- package/contracts/openzeppelin/GovernorTimelockControl.ts +627 -0
- package/contracts/openzeppelin/GovernorVotes.json +879 -0
- package/contracts/openzeppelin/GovernorVotes.ts +536 -0
- package/contracts/openzeppelin/GovernorVotesComp.json +879 -0
- package/contracts/openzeppelin/GovernorVotesComp.ts +536 -0
- package/contracts/openzeppelin/GovernorVotesQuorumFraction.json +937 -0
- package/contracts/openzeppelin/GovernorVotesQuorumFraction.ts +598 -0
- package/contracts/openzeppelin/IAMB.json +327 -0
- package/contracts/openzeppelin/IAMB.ts +331 -0
- package/contracts/openzeppelin/IAccessControl.json +174 -0
- package/contracts/openzeppelin/IAccessControl.ts +214 -0
- package/contracts/openzeppelin/IAccessControlEnumerable.json +217 -0
- package/contracts/openzeppelin/IAccessControlEnumerable.ts +236 -0
- package/contracts/openzeppelin/IArbSys.json +270 -0
- package/contracts/openzeppelin/IArbSys.ts +233 -0
- package/contracts/openzeppelin/IBeacon.json +15 -0
- package/contracts/openzeppelin/IBeacon.ts +90 -0
- package/contracts/openzeppelin/IBridge.json +296 -0
- package/contracts/openzeppelin/IBridge.ts +287 -0
- package/contracts/openzeppelin/ICompoundTimelock.json +415 -0
- package/contracts/openzeppelin/ICompoundTimelock.ts +389 -0
- package/contracts/openzeppelin/ICrossDomainMessenger.json +101 -0
- package/contracts/openzeppelin/ICrossDomainMessenger.ts +181 -0
- package/contracts/openzeppelin/IERC1155.json +295 -0
- package/contracts/openzeppelin/IERC1155.ts +265 -0
- package/contracts/openzeppelin/IERC1155MetadataURI.json +314 -0
- package/contracts/openzeppelin/IERC1155MetadataURI.ts +276 -0
- package/contracts/openzeppelin/IERC1155Receiver.json +99 -0
- package/contracts/openzeppelin/IERC1155Receiver.ts +112 -0
- package/contracts/openzeppelin/IERC1271.json +26 -0
- package/contracts/openzeppelin/IERC1271.ts +90 -0
- package/contracts/openzeppelin/IERC1363.json +373 -0
- package/contracts/openzeppelin/IERC1363.ts +252 -0
- package/contracts/openzeppelin/IERC1363Receiver.json +36 -0
- package/contracts/openzeppelin/IERC1363Receiver.ts +90 -0
- package/contracts/openzeppelin/IERC1363Spender.json +31 -0
- package/contracts/openzeppelin/IERC1363Spender.ts +90 -0
- package/contracts/openzeppelin/IERC165.json +21 -0
- package/contracts/openzeppelin/IERC165.ts +90 -0
- package/contracts/openzeppelin/IERC1820Implementer.json +26 -0
- package/contracts/openzeppelin/IERC1820Implementer.ts +90 -0
- package/contracts/openzeppelin/IERC1820Registry.json +215 -0
- package/contracts/openzeppelin/IERC1820Registry.ts +218 -0
- package/contracts/openzeppelin/IERC1822Proxiable.json +15 -0
- package/contracts/openzeppelin/IERC1822Proxiable.ts +90 -0
- package/contracts/openzeppelin/IERC20.json +185 -0
- package/contracts/openzeppelin/IERC20.ts +196 -0
- package/contracts/openzeppelin/IERC20Metadata.json +224 -0
- package/contracts/openzeppelin/IERC20Metadata.ts +229 -0
- package/contracts/openzeppelin/IERC20Permit.json +77 -0
- package/contracts/openzeppelin/IERC20Permit.ts +112 -0
- package/contracts/openzeppelin/IERC2612.json +77 -0
- package/contracts/openzeppelin/IERC2612.ts +112 -0
- package/contracts/openzeppelin/IERC2981.json +50 -0
- package/contracts/openzeppelin/IERC2981.ts +101 -0
- package/contracts/openzeppelin/IERC3156FlashBorrower.json +41 -0
- package/contracts/openzeppelin/IERC3156FlashBorrower.ts +90 -0
- package/contracts/openzeppelin/IERC3156FlashLender.json +79 -0
- package/contracts/openzeppelin/IERC3156FlashLender.ts +112 -0
- package/contracts/openzeppelin/IERC4626.json +614 -0
- package/contracts/openzeppelin/IERC4626.ts +463 -0
- package/contracts/openzeppelin/IERC721.json +287 -0
- package/contracts/openzeppelin/IERC721.ts +262 -0
- package/contracts/openzeppelin/IERC721Enumerable.json +343 -0
- package/contracts/openzeppelin/IERC721Enumerable.ts +295 -0
- package/contracts/openzeppelin/IERC721Metadata.json +332 -0
- package/contracts/openzeppelin/IERC721Metadata.ts +295 -0
- package/contracts/openzeppelin/IERC721Receiver.json +36 -0
- package/contracts/openzeppelin/IERC721Receiver.ts +90 -0
- package/contracts/openzeppelin/IERC777.json +393 -0
- package/contracts/openzeppelin/IERC777.ts +360 -0
- package/contracts/openzeppelin/IERC777Recipient.json +40 -0
- package/contracts/openzeppelin/IERC777Recipient.ts +90 -0
- package/contracts/openzeppelin/IERC777Sender.json +40 -0
- package/contracts/openzeppelin/IERC777Sender.ts +90 -0
- package/contracts/openzeppelin/IFxMessageProcessor.json +25 -0
- package/contracts/openzeppelin/IFxMessageProcessor.ts +90 -0
- package/contracts/openzeppelin/IGovernor.json +683 -0
- package/contracts/openzeppelin/IGovernor.ts +448 -0
- package/contracts/openzeppelin/IGovernorCompatibilityBravo.json +913 -0
- package/contracts/openzeppelin/IGovernorCompatibilityBravo.ts +522 -0
- package/contracts/openzeppelin/IGovernorTimelock.json +768 -0
- package/contracts/openzeppelin/IGovernorTimelock.ts +510 -0
- package/contracts/openzeppelin/IInbox.json +377 -0
- package/contracts/openzeppelin/IInbox.ts +273 -0
- package/contracts/openzeppelin/IMessageProvider.json +34 -0
- package/contracts/openzeppelin/IMessageProvider.ts +134 -0
- package/contracts/openzeppelin/IOutbox.json +179 -0
- package/contracts/openzeppelin/IOutbox.ts +218 -0
- package/contracts/openzeppelin/IVotes.json +184 -0
- package/contracts/openzeppelin/IVotes.ts +196 -0
- package/contracts/openzeppelin/Initializable.json +15 -0
- package/contracts/openzeppelin/Initializable.ts +105 -0
- package/contracts/openzeppelin/LibAMB.json +1 -0
- package/contracts/openzeppelin/LibAMB.ts +83 -0
- package/contracts/openzeppelin/LibArbitrumL1.json +1 -0
- package/contracts/openzeppelin/LibArbitrumL1.ts +83 -0
- package/contracts/openzeppelin/LibArbitrumL2.json +15 -0
- package/contracts/openzeppelin/LibArbitrumL2.ts +90 -0
- package/contracts/openzeppelin/LibOptimism.json +1 -0
- package/contracts/openzeppelin/LibOptimism.ts +83 -0
- package/contracts/openzeppelin/Math.json +1 -0
- package/contracts/openzeppelin/Math.ts +83 -0
- package/contracts/openzeppelin/MerkleProof.json +1 -0
- package/contracts/openzeppelin/MerkleProof.ts +83 -0
- package/contracts/openzeppelin/MinimalForwarder.json +143 -0
- package/contracts/openzeppelin/MinimalForwarder.ts +112 -0
- package/contracts/openzeppelin/Multicall.json +21 -0
- package/contracts/openzeppelin/Multicall.ts +90 -0
- package/contracts/openzeppelin/Ownable.json +54 -0
- package/contracts/openzeppelin/Ownable.ts +134 -0
- package/contracts/openzeppelin/Pausable.json +41 -0
- package/contracts/openzeppelin/Pausable.ts +141 -0
- package/contracts/openzeppelin/PaymentSplitter.json +304 -0
- package/contracts/openzeppelin/PaymentSplitter.ts +281 -0
- package/contracts/openzeppelin/Proxy.json +10 -0
- package/contracts/openzeppelin/Proxy.ts +83 -0
- package/contracts/openzeppelin/ProxyAdmin.json +151 -0
- package/contracts/openzeppelin/ProxyAdmin.ts +189 -0
- package/contracts/openzeppelin/PullPayment.json +34 -0
- package/contracts/openzeppelin/PullPayment.ts +101 -0
- package/contracts/openzeppelin/ReentrancyGuard.json +1 -0
- package/contracts/openzeppelin/ReentrancyGuard.ts +83 -0
- package/contracts/openzeppelin/RefundEscrow.json +226 -0
- package/contracts/openzeppelin/RefundEscrow.ts +349 -0
- package/contracts/openzeppelin/SafeCast.json +1 -0
- package/contracts/openzeppelin/SafeCast.ts +83 -0
- package/contracts/openzeppelin/SafeERC20.json +1 -0
- package/contracts/openzeppelin/SafeERC20.ts +83 -0
- package/contracts/openzeppelin/SafeMath.json +1 -0
- package/contracts/openzeppelin/SafeMath.ts +83 -0
- package/contracts/openzeppelin/SignatureChecker.json +1 -0
- package/contracts/openzeppelin/SignatureChecker.ts +83 -0
- package/contracts/openzeppelin/SignedMath.json +1 -0
- package/contracts/openzeppelin/SignedMath.ts +83 -0
- package/contracts/openzeppelin/SignedSafeMath.json +1 -0
- package/contracts/openzeppelin/SignedSafeMath.ts +83 -0
- package/contracts/openzeppelin/StorageSlot.json +1 -0
- package/contracts/openzeppelin/StorageSlot.ts +83 -0
- package/contracts/openzeppelin/Strings.json +1 -0
- package/contracts/openzeppelin/Strings.ts +83 -0
- package/contracts/openzeppelin/TimelockController.json +867 -0
- package/contracts/openzeppelin/TimelockController.ts +583 -0
- package/contracts/openzeppelin/Timers.json +1 -0
- package/contracts/openzeppelin/Timers.ts +83 -0
- package/contracts/openzeppelin/TokenTimelock.json +69 -0
- package/contracts/openzeppelin/TokenTimelock.ts +123 -0
- package/contracts/openzeppelin/TransparentUpgradeableProxy.json +146 -0
- package/contracts/openzeppelin/TransparentUpgradeableProxy.ts +214 -0
- package/contracts/openzeppelin/UUPSUpgradeable.json +91 -0
- package/contracts/openzeppelin/UUPSUpgradeable.ts +192 -0
- package/contracts/openzeppelin/UpgradeableBeacon.json +104 -0
- package/contracts/openzeppelin/UpgradeableBeacon.ts +185 -0
- package/contracts/openzeppelin/VestingWallet.json +193 -0
- package/contracts/openzeppelin/VestingWallet.ts +208 -0
- package/contracts/openzeppelin/Votes.json +216 -0
- package/contracts/openzeppelin/Votes.ts +218 -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/tokens/coingecko.json +137409 -0
- package/dist/contracts/gen/base/ERC20Base/ERC20Base.js +94 -0
- package/dist/contracts/gnosis/GnosisSafe.js +357 -0
- package/dist/src/BlockchainExplorer/BlockChainExplorerFactory.js +114 -20
- package/dist/src/BlockchainExplorer/BlockChainExplorerProvider.js +8 -0
- package/dist/src/BlockchainExplorer/Bscscan.js +1 -0
- package/dist/src/BlockchainExplorer/Etherscan.js +14 -4
- package/dist/src/BlockchainExplorer/Evmscan.js +9 -0
- package/dist/src/BlockchainExplorer/Polyscan.js +1 -0
- package/dist/src/ChainAccountProvider.js +89 -0
- package/dist/src/ChainAccountsService.js +20 -2
- package/dist/src/Config.js +76 -0
- package/dist/src/blocks/BlockDateResolver.js +9 -8
- package/dist/src/bridges/hop/HopBridge.js +5 -2
- package/dist/src/chains/PlatformFactory.js +2 -2
- package/dist/src/chains/arbitrum/ArbWeb3Client.js +5 -24
- package/dist/src/chains/arbitrum/TokensServiceArbitrum.js +18 -0
- package/dist/src/chains/boba/BobaWeb3Client.js +5 -33
- package/dist/src/chains/xdai/XDaiWeb3Client.js +6 -30
- package/dist/src/class/SubjectKind.js +9 -0
- package/dist/src/class/SubjectStream.js +104 -0
- package/dist/src/class/Subscription.js +13 -0
- package/dist/src/clients/BscWeb3Client.js +5 -24
- package/dist/src/clients/ClientEventsStream.js +62 -18
- package/dist/src/clients/ClientPool.js +115 -55
- package/dist/src/clients/EthWeb3Client.js +7 -22
- package/dist/src/clients/EvmWeb3Client.js +25 -0
- package/dist/src/clients/HardhatWeb3Client.js +19 -40
- package/dist/src/clients/PolyWeb3Client.js +5 -51
- package/dist/src/clients/Web3Client.js +355 -10
- package/dist/src/clients/Web3ClientFactory.js +15 -0
- package/dist/src/clients/debug/ClientDebugMethods.js +64 -0
- package/dist/src/clients/utils/ClientEndpoints.js +6 -0
- package/dist/src/clients/utils/TxFactory.js +7 -12
- package/dist/src/contracts/Contract.js +2 -1
- package/dist/src/contracts/ContractAbiProvider.js +58 -0
- package/dist/src/contracts/ContractBase.js +161 -26
- package/dist/src/contracts/ContractReader.js +78 -2
- package/dist/src/contracts/ContractStorageReaderBase.js +15 -0
- package/dist/src/contracts/ContractStream.js +21 -8
- package/dist/src/contracts/ContractWriter.js +47 -20
- package/dist/src/contracts/TxContract.js +6 -3
- package/dist/src/contracts/common/ERC20.js +1 -1
- package/dist/src/contracts/utils/AbiDeserializer.js +15 -5
- package/dist/src/contracts/utils/InputDataUtils.js +5 -2
- package/dist/src/env/BigIntSerializer.js +2 -1
- package/dist/src/evm/EVM.js +214 -0
- package/dist/src/evm/OpcodesWalker.js +137 -0
- package/dist/src/evm/Stack.js +57 -0
- package/dist/src/evm/interfaces/IJumps.js +2 -0
- package/dist/src/evm/interfaces/IMemory.js +2 -0
- package/dist/src/evm/interfaces/IOpcode.js +2 -0
- package/dist/src/evm/interfaces/IStorage.js +2 -0
- package/dist/src/evm/opcodes/add.js +50 -0
- package/dist/src/evm/opcodes/addmod.js +19 -0
- package/dist/src/evm/opcodes/address.js +17 -0
- package/dist/src/evm/opcodes/and.js +56 -0
- package/dist/src/evm/opcodes/balance.js +22 -0
- package/dist/src/evm/opcodes/blockhash.js +22 -0
- package/dist/src/evm/opcodes/byte.js +30 -0
- package/dist/src/evm/opcodes/call.js +48 -0
- package/dist/src/evm/opcodes/callcode.js +48 -0
- package/dist/src/evm/opcodes/calldatacopy.js +27 -0
- package/dist/src/evm/opcodes/calldataload.js +33 -0
- package/dist/src/evm/opcodes/calldatasize.js +16 -0
- package/dist/src/evm/opcodes/caller.js +17 -0
- package/dist/src/evm/opcodes/callvalue.js +16 -0
- package/dist/src/evm/opcodes/codecopy.js +31 -0
- package/dist/src/evm/opcodes/codesize.js +16 -0
- package/dist/src/evm/opcodes/coinbase.js +16 -0
- package/dist/src/evm/opcodes/create.js +35 -0
- package/dist/src/evm/opcodes/create2.js +34 -0
- package/dist/src/evm/opcodes/delegatecall.js +44 -0
- package/dist/src/evm/opcodes/difficulty.js +16 -0
- package/dist/src/evm/opcodes/div.js +33 -0
- package/dist/src/evm/opcodes/dup.js +6 -0
- package/dist/src/evm/opcodes/eq.js +69 -0
- package/dist/src/evm/opcodes/exp.js +30 -0
- package/dist/src/evm/opcodes/extcodecopy.js +35 -0
- package/dist/src/evm/opcodes/extcodehash.js +22 -0
- package/dist/src/evm/opcodes/extcodesize.js +22 -0
- package/dist/src/evm/opcodes/gas.js +16 -0
- package/dist/src/evm/opcodes/gaslimit.js +16 -0
- package/dist/src/evm/opcodes/gasprice.js +16 -0
- package/dist/src/evm/opcodes/gt.js +36 -0
- package/dist/src/evm/opcodes/invalid.js +18 -0
- package/dist/src/evm/opcodes/iszero.js +51 -0
- package/dist/src/evm/opcodes/jump.js +66 -0
- package/dist/src/evm/opcodes/jumpdest.js +5 -0
- package/dist/src/evm/opcodes/jumpi.js +298 -0
- package/dist/src/evm/opcodes/log.js +74 -0
- package/dist/src/evm/opcodes/lt.js +36 -0
- package/dist/src/evm/opcodes/mload.js +28 -0
- package/dist/src/evm/opcodes/mod.js +30 -0
- package/dist/src/evm/opcodes/msize.js +16 -0
- package/dist/src/evm/opcodes/mstore.js +30 -0
- package/dist/src/evm/opcodes/mul.js +34 -0
- package/dist/src/evm/opcodes/mulmod.js +19 -0
- package/dist/src/evm/opcodes/not.js +28 -0
- package/dist/src/evm/opcodes/number.js +16 -0
- package/dist/src/evm/opcodes/or.js +30 -0
- package/dist/src/evm/opcodes/origin.js +16 -0
- package/dist/src/evm/opcodes/pc.js +5 -0
- package/dist/src/evm/opcodes/pop.js +5 -0
- package/dist/src/evm/opcodes/push.js +6 -0
- package/dist/src/evm/opcodes/return.js +70 -0
- package/dist/src/evm/opcodes/returndatacopy.js +31 -0
- package/dist/src/evm/opcodes/returndatasize.js +16 -0
- package/dist/src/evm/opcodes/revert.js +57 -0
- package/dist/src/evm/opcodes/sar.js +30 -0
- package/dist/src/evm/opcodes/selfdestruct.js +23 -0
- package/dist/src/evm/opcodes/sha3.js +56 -0
- package/dist/src/evm/opcodes/shl.js +35 -0
- package/dist/src/evm/opcodes/shr.js +30 -0
- package/dist/src/evm/opcodes/signextend.js +19 -0
- package/dist/src/evm/opcodes/sload.js +140 -0
- package/dist/src/evm/opcodes/sstore.js +189 -0
- package/dist/src/evm/opcodes/staticcall.js +44 -0
- package/dist/src/evm/opcodes/stop.js +17 -0
- package/dist/src/evm/opcodes/sub.js +30 -0
- package/dist/src/evm/opcodes/swap.js +6 -0
- package/dist/src/evm/opcodes/timestamp.js +16 -0
- package/dist/src/evm/opcodes/xor.js +30 -0
- package/dist/src/evm/opcodes.js +192 -0
- package/dist/src/evm/tx.class.js +154 -0
- package/dist/src/evm/utils/BigNumber.js +14 -0
- package/dist/src/evm/utils/hex.js +44 -0
- package/dist/src/evm/utils/opcodes.js +217 -0
- package/dist/src/evm/utils/stringify.js +14 -0
- package/dist/src/evm/utils/stringifyEvents.js +38 -0
- package/dist/src/evm/utils/stringifyFunctions.js +70 -0
- package/dist/src/evm/utils/stringifyInstructions.js +44 -0
- package/dist/src/evm/utils/stringifyMappings.js +62 -0
- package/dist/src/evm/utils/stringifyStructs.js +16 -0
- package/dist/src/evm/utils/stringifyVariables.js +33 -0
- package/dist/src/gen/ContractStorageReaderTemplate.js +11 -0
- package/dist/src/gen/Generator.js +37 -16
- package/dist/src/gen/GeneratorFromAbi.js +225 -72
- package/dist/src/gen/GeneratorStorageReader.js +89 -0
- package/dist/src/gen/utils/$gen.js +14 -0
- package/dist/src/gen/utils/Str.js +47 -0
- package/dist/src/hardhat/HardhatProvider.js +177 -0
- package/dist/src/indexer/BlocksTxIndexer.js +19 -7
- package/dist/src/indexer/handlers/BlocksWalker.js +65 -54
- package/dist/src/loggers/LoggerService.js +8 -5
- package/dist/src/models/TAccount.js +2 -0
- package/dist/src/ns/NameService.js +3 -0
- package/dist/src/ns/utils/$ns.js +6 -3
- package/dist/src/safe/$gnosis.js +23 -0
- package/dist/src/safe/GnosisSafeFactory.js +27 -0
- package/dist/src/safe/GnosisSafeHandler.js +361 -0
- package/dist/src/safe/transport/FileServiceTransport.js +92 -0
- package/dist/src/safe/transport/GnosisServiceTransport.js +78 -0
- package/dist/src/safe/transport/ISafeServiceTransport.js +2 -0
- package/dist/src/safe/transport/InMemoryServiceTransport.js +56 -0
- package/dist/src/solidity/SlotsParser.js +594 -0
- package/dist/src/solidity/SlotsStorage.js +158 -0
- package/dist/src/solidity/storage/Accessor.js +126 -0
- package/dist/src/solidity/storage/SlotDynamicArray.js +17 -0
- package/dist/src/solidity/storage/SlotFixedArray.js +28 -0
- package/dist/src/solidity/storage/SlotsStorageHandler.js +10 -0
- package/dist/src/solidity/storage/SlotsStorageTransport.js +126 -0
- package/dist/src/solidity/storage/handlers/SlotDynamicArrayHandler.js +47 -0
- package/dist/src/solidity/storage/handlers/SlotFixedArrayHandler.js +50 -0
- package/dist/src/solidity/storage/handlers/SlotMappingHandler.js +42 -0
- package/dist/src/solidity/storage/handlers/SlotStringHandler.js +109 -0
- package/dist/src/solidity/storage/handlers/SlotStructHandler.js +45 -0
- package/dist/src/solidity/storage/handlers/SlotValueHandler.js +30 -0
- package/dist/src/solidity/utils/$str.js +38 -0
- package/dist/src/solidity/utils/$types.js +22 -0
- package/dist/src/structs/PackedRanges.js +8 -1
- package/dist/src/tokens/TokenDataProvider.js +251 -0
- package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js +3 -1
- package/dist/src/tokens/TokenExchanges/AmmV2ExchangeBase.js +4 -4
- package/dist/src/tokens/TokenExchanges/PancakeswapExchange.js +4 -7
- package/dist/src/tokens/TokenExchanges/SushiswapPolygonExchange.js +4 -5
- package/dist/src/tokens/TokenExchanges/UniswapExchange.js +4 -7
- package/dist/src/tokens/TokenOracles/AmmPriceV2Oracle.js +2 -4
- package/dist/src/tokens/TokenOracles/CoingeckoOracle.js +12 -0
- package/dist/src/tokens/TokenOracles/TokenPriceStore.js +1 -1
- package/dist/src/tokens/TokenProviders/TPChain.js +14 -7
- package/dist/src/tokens/TokenProviders/TPCoingecko.js +117 -0
- package/dist/src/tokens/TokenProviders/TPConfig.js +46 -0
- package/dist/src/tokens/TokenProviders/TPExplorer.js +35 -0
- package/dist/src/tokens/TokenService.js +5 -2
- package/dist/src/tokens/TokenTransferService.js +28 -18
- package/dist/src/tokens/TokensService.js +32 -177
- package/dist/src/tokens/TokensServiceFactory.js +13 -1
- package/dist/src/txs/TxDataBuilder.js +54 -22
- package/dist/src/txs/TxLogger.js +3 -3
- package/dist/src/txs/TxWriter.js +169 -37
- package/dist/src/txs/receipt/TxLogParser.js +11 -1
- package/dist/src/txs/receipt/TxLogsTransfer.js +14 -13
- package/dist/src/txs/receipt/TxTopicProvider.js +10 -6
- package/dist/src/txs/sig-transports/SigFileTransport.js +48 -0
- package/dist/src/utils/$abiParser.js +55 -20
- package/dist/src/utils/$abiType.js +184 -3
- package/dist/src/utils/$abiUtils.js +54 -5
- package/dist/src/utils/$account.js +30 -0
- package/dist/src/utils/$address.js +8 -0
- package/dist/src/utils/$bigint.js +52 -3
- package/dist/src/utils/$block.js +16 -0
- package/dist/src/utils/$bloom.js +42 -0
- package/dist/src/utils/$buffer.js +94 -0
- package/dist/src/utils/$cli.js +20 -0
- package/dist/src/utils/$color.js +171 -0
- package/dist/src/utils/$config.js +65 -5
- package/dist/src/utils/$const.js +4 -0
- package/dist/src/utils/$contract.js +20 -2
- package/dist/src/utils/$crypto.js +25 -0
- package/dist/src/utils/$csv.js +17 -27
- package/dist/src/utils/$date.js +129 -25
- package/dist/src/utils/$gas.js +15 -0
- package/dist/src/utils/$hex.js +77 -0
- package/dist/src/utils/$is.js +24 -21
- package/dist/src/utils/$logger.js +56 -3
- package/dist/src/utils/$machine.js +77 -0
- package/dist/src/utils/$number.js +24 -1
- package/dist/src/utils/$path.js +17 -0
- package/dist/src/utils/$promise.js +81 -0
- package/dist/src/utils/$require.js +15 -1
- package/dist/src/utils/$secret.js +29 -0
- package/dist/src/utils/$sign.js +96 -14
- package/dist/src/utils/$signRaw.js +48 -0
- package/dist/src/utils/$signSerializer.js +5 -4
- package/dist/src/utils/$txData.js +19 -0
- package/hardhat.config.js +21 -1
- package/package.json +28 -14
- package/readme.md +21 -4
- package/src/BlockchainExplorer/BlockChainExplorerFactory.ts +149 -39
- package/src/BlockchainExplorer/BlockChainExplorerProvider.ts +10 -0
- package/src/BlockchainExplorer/Bscscan.ts +1 -0
- package/src/BlockchainExplorer/Etherscan.ts +17 -5
- package/src/BlockchainExplorer/Evmscan.ts +8 -0
- package/src/BlockchainExplorer/IBlockChainExplorer.ts +3 -2
- package/src/BlockchainExplorer/Polyscan.ts +1 -0
- package/src/ChainAccountProvider.ts +84 -0
- package/src/ChainAccountsService.ts +21 -2
- package/src/Config.ts +85 -0
- package/src/blocks/BlockDateResolver.ts +10 -12
- package/src/bridges/hop/HopBridge.ts +9 -2
- package/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.ts +35 -35
- package/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.ts +35 -35
- package/src/bridges/models/IBridge.ts +1 -1
- package/src/chains/PlatformFactory.ts +3 -2
- package/src/chains/arbitrum/ArbWeb3Client.ts +7 -22
- package/src/chains/arbitrum/TokensServiceArbitrum.ts +19 -0
- package/src/chains/boba/BobaWeb3Client.ts +5 -33
- package/src/chains/xdai/XDaiWeb3Client.ts +6 -32
- package/src/class/SubjectKind.ts +5 -0
- package/src/class/SubjectStream.ts +111 -0
- package/src/class/Subscription.ts +7 -0
- package/src/clients/BscWeb3Client.ts +5 -22
- package/src/clients/ClientEventsStream.ts +86 -19
- package/src/clients/ClientPool.ts +145 -61
- package/src/clients/EthWeb3Client.ts +8 -21
- package/src/clients/EvmWeb3Client.ts +26 -0
- package/src/clients/HardhatWeb3Client.ts +17 -39
- package/src/clients/PolyWeb3Client.ts +5 -54
- package/src/clients/Web3Client.ts +430 -32
- package/src/clients/Web3ClientFactory.ts +17 -1
- package/src/clients/debug/ClientDebugMethods.ts +75 -0
- package/src/clients/interfaces/IWeb3Client.ts +33 -5
- package/src/clients/interfaces/IWeb3EndpointOptions.ts +6 -0
- package/src/clients/utils/ClientEndpoints.ts +6 -0
- package/src/clients/utils/TxFactory.ts +13 -13
- package/src/contracts/Contract.ts +3 -2
- package/src/contracts/ContractAbiProvider.ts +68 -0
- package/src/contracts/ContractBase.ts +205 -36
- package/src/contracts/ContractReader.ts +116 -3
- package/src/contracts/ContractStorageReaderBase.ts +26 -0
- package/src/contracts/ContractStream.ts +24 -6
- package/src/contracts/ContractWriter.ts +58 -28
- package/src/contracts/TxContract.ts +7 -4
- package/src/contracts/common/ERC20.ts +1 -1
- package/src/contracts/utils/AbiDeserializer.ts +16 -7
- package/src/contracts/utils/InputDataUtils.ts +8 -6
- package/src/env/BigIntSerializer.ts +3 -1
- package/src/evm/EVM.ts +246 -0
- package/src/evm/OpcodesWalker.ts +149 -0
- package/src/evm/Stack.ts +58 -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/opcodes.ts +207 -0
- package/src/evm/tx.class.ts +137 -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/gen/ContractStorageReaderTemplate.ts +18 -0
- package/src/gen/ContractTemplate.ts +41 -7
- package/src/gen/Generator.ts +50 -19
- package/src/gen/GeneratorFromAbi.ts +239 -67
- package/src/gen/GeneratorStorageReader.ts +113 -0
- package/src/gen/utils/$gen.ts +11 -0
- package/src/gen/utils/Str.ts +40 -0
- package/src/handlers/TokenHandler.ts +1 -1
- package/src/hardhat/HardhatProvider.ts +207 -0
- package/src/indexer/BlocksTxIndexer.ts +36 -10
- package/src/indexer/handlers/BlocksWalker.ts +81 -62
- package/src/indexer/handlers/TxQueueLoader.ts +7 -7
- package/src/json/JsonObjectStore.ts +1 -1
- package/src/loggers/LoggerService.ts +9 -5
- package/src/loggers/TxLoggerService.ts +1 -1
- package/src/models/IToken.ts +9 -0
- package/src/models/TAccount.ts +30 -0
- package/src/models/TBufferLike.ts +2 -2
- package/src/models/TPlatform.ts +1 -1
- package/src/ns/NameService.ts +3 -0
- package/src/ns/utils/$ns.ts +3 -4
- package/src/safe/$gnosis.ts +20 -0
- package/src/safe/GnosisSafeFactory.ts +40 -0
- package/src/safe/GnosisSafeHandler.ts +432 -0
- package/src/safe/transport/FileServiceTransport.ts +115 -0
- package/src/safe/transport/GnosisServiceTransport.ts +83 -0
- package/src/safe/transport/ISafeServiceTransport.ts +26 -0
- package/src/safe/transport/InMemoryServiceTransport.ts +79 -0
- package/src/solidity/SlotsParser.ts +650 -0
- package/src/solidity/SlotsStorage.ts +177 -0
- package/src/solidity/storage/Accessor.spec.ts +45 -0
- package/src/solidity/storage/Accessor.ts +136 -0
- package/src/solidity/storage/SlotDynamicArray.ts +46 -0
- package/src/solidity/storage/SlotFixedArray.ts +31 -0
- package/src/solidity/storage/SlotsStorageHandler.ts +17 -0
- package/src/solidity/storage/SlotsStorageTransport.ts +152 -0
- package/src/solidity/storage/handlers/SlotDynamicArrayHandler.ts +52 -0
- package/src/solidity/storage/handlers/SlotFixedArrayHandler.ts +52 -0
- package/src/solidity/storage/handlers/SlotMappingHandler.ts +52 -0
- package/src/solidity/storage/handlers/SlotStringHandler.ts +130 -0
- package/src/solidity/storage/handlers/SlotStructHandler.ts +46 -0
- package/src/solidity/storage/handlers/SlotValueHandler.ts +36 -0
- package/src/solidity/utils/$str.ts +36 -0
- package/src/solidity/utils/$types.ts +16 -0
- package/src/structs/PackedRanges.ts +9 -3
- package/src/tokens/TokenDataProvider.ts +271 -0
- package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.ts +3 -1
- package/src/tokens/TokenExchanges/AmmV2ExchangeBase.ts +4 -3
- package/src/tokens/TokenExchanges/OneInchExchange.ts +1 -1
- package/src/tokens/TokenExchanges/PancakeswapExchange.ts +5 -10
- package/src/tokens/TokenExchanges/SushiswapPolygonExchange.ts +8 -5
- package/src/tokens/TokenExchanges/UniswapExchange.ts +6 -9
- package/src/tokens/TokenOracles/AmmPriceV2Oracle.ts +5 -5
- package/src/tokens/TokenOracles/CoingeckoOracle.ts +13 -0
- package/src/tokens/TokenOracles/TokenPriceStore.ts +1 -1
- package/src/tokens/TokenPriceService.ts +0 -1
- package/src/tokens/TokenProviders/ITokenProvider.ts +1 -1
- package/src/tokens/TokenProviders/TPChain.ts +20 -8
- package/src/tokens/TokenProviders/TPCoingecko.ts +121 -0
- package/src/tokens/TokenProviders/TPConfig.ts +53 -0
- package/src/tokens/TokenProviders/TPExplorer.ts +41 -0
- package/src/tokens/TokenService.ts +6 -3
- package/src/tokens/TokenSwapService.ts +1 -1
- package/src/tokens/TokenTransferService.ts +40 -24
- package/src/tokens/TokensService.ts +34 -179
- package/src/tokens/TokensServiceFactory.ts +13 -1
- package/src/tokens/defi/ISwapService.ts +1 -1
- package/src/tokens/defi/paraswap/Paraswap.ts +2 -1
- package/src/txs/ITxConfig.ts +1 -1
- package/src/txs/TxDataBuilder.ts +78 -34
- package/src/txs/TxLogger.ts +4 -4
- package/src/txs/TxWriter.ts +245 -48
- package/src/txs/conditional/GasWatcherTx.ts +0 -1
- package/src/txs/receipt/ITxLogItem.ts +8 -5
- package/src/txs/receipt/TxLogParser.ts +13 -2
- package/src/txs/receipt/TxLogsTransfer.ts +15 -15
- package/src/txs/receipt/TxTopicInMemoryProvider.ts +1 -1
- package/src/txs/receipt/TxTopicProvider.ts +7 -7
- package/src/txs/sig-transports/SigFileTransport.ts +52 -0
- package/src/utils/$abiParser.spec.ts +90 -0
- package/src/utils/$abiParser.ts +60 -25
- package/src/utils/$abiType.ts +195 -5
- package/src/utils/$abiUtils.ts +57 -6
- package/src/utils/$account.ts +30 -0
- package/src/utils/$address.ts +5 -0
- package/src/utils/$bigint.ts +56 -3
- package/src/utils/$block.ts +14 -1
- package/src/utils/$bloom.ts +43 -0
- package/src/utils/$buffer.ts +114 -0
- package/src/utils/$cli.ts +16 -0
- package/src/utils/$color.ts +211 -0
- package/src/utils/$config.ts +70 -7
- package/src/utils/$const.ts +1 -0
- package/src/utils/$contract.ts +21 -3
- package/src/utils/$crypto.ts +33 -0
- package/src/utils/$csv.ts +23 -7
- package/src/utils/$date.ts +194 -40
- package/src/utils/$gas.ts +17 -0
- package/src/utils/$hex.ts +72 -0
- package/src/utils/$is.ts +24 -22
- package/src/utils/$logger.ts +60 -2
- package/src/utils/$machine.ts +85 -0
- package/src/utils/$number.ts +24 -1
- package/src/utils/$path.ts +17 -1
- package/src/utils/$promise.ts +101 -0
- package/src/utils/$require.ts +15 -1
- package/src/utils/$secret.ts +27 -0
- package/src/utils/$sign.ts +115 -16
- package/src/utils/$signRaw.ts +50 -0
- package/src/utils/$signSerializer.ts +8 -6
- package/src/utils/$txData.ts +16 -0
- package/src/utils/$wallet.ts +1 -1
- package/test/Batch.spec.ts +89 -0
- package/test/BlockChainExplorer.spec.ts +33 -0
- package/test/ChainAccount.spec.ts +1 -1
- package/test/client.spec.ts +10 -11
- package/test/config.js +8 -0
- package/test/config.spec.ts +31 -0
- package/test/ecrecover.spec.ts +49 -0
- package/test/fixtures/contracts/Counter.sol +25 -0
- package/test/fixtures/contracts/Ecrecover.sol +33 -0
- package/test/fixtures/contracts/Foo.sol +32 -0
- package/test/fixtures/contracts/Foo.ts +78 -0
- package/test/fixtures/contracts/FreeToken.sol +263 -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/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/generate/class.spec.ts +144 -6
- package/test/generate/evm.spec.ts +64 -0
- package/test/generate/openzeppelin.spec.ts +18 -0
- package/test/generate/slotreader.spec.ts +34 -0
- package/test/hardhat/TestNode.ts +37 -9
- package/test/hardhat/deploy.spec.ts +22 -0
- package/test/indexer/BlocksWalker.spec.ts +51 -0
- package/test/ns.spec.ts +4 -0
- package/test/receipt.spec.ts +1 -4
- package/test/safe/tx.act.ts +194 -0
- package/test/solidity/SlotsParser.spec.ts +186 -0
- package/test/solidity/SlotsReader.spec.ts +168 -0
- package/test/solidity/Storage.spec.ts +328 -0
- package/test/structs/PackedRanges.spec.ts +56 -0
- package/test/subscriptions.spec.ts +127 -0
- package/test/token.spec.ts +11 -0
- package/test/utils/abi-types.spec.ts +31 -0
- package/test/utils/abi-utils.spec.ts +23 -0
- package/test/utils/bigint.spec.ts +0 -1
- package/test/utils/date.spec.ts +3 -2
- package/test/utils/logbloom.spec.ts +17 -0
- package/test/utils/number.spec.ts +14 -3
- package/test/utils/sign.spec.ts +43 -7
- package/src/ChainAccounts.ts +0 -72
- package/src/structs/PackedRanges.spec.ts +0 -38
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import Common from '@ethereumjs/common'
|
|
2
1
|
import { $config } from '@dequanto/utils/$config';
|
|
3
|
-
import { FeeMarketEIP1559Transaction, Transaction, TxData } from '@ethereumjs/tx'
|
|
4
2
|
import { Web3Client } from './Web3Client';
|
|
5
3
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
6
4
|
import { ClientEndpoints } from './utils/ClientEndpoints';
|
|
7
5
|
import { IWeb3EndpointOptions } from './interfaces/IWeb3EndpointOptions';
|
|
8
6
|
import { $bigint } from '@dequanto/utils/$bigint';
|
|
9
|
-
import { TxFactory } from './utils/TxFactory';
|
|
10
7
|
|
|
11
8
|
export class PolyWeb3Client extends Web3Client {
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
10
|
platform: TPlatform = 'polygon';
|
|
16
|
-
chainId: number = 137;
|
|
11
|
+
chainId: number = this.options.chainId ?? 137;
|
|
17
12
|
chainToken = 'MATIC';
|
|
18
13
|
defaultGasLimit = 2_000_000;
|
|
19
14
|
|
|
20
15
|
constructor (opts?: IWeb3EndpointOptions) {
|
|
21
|
-
super(
|
|
16
|
+
super({
|
|
17
|
+
...(opts ?? {}),
|
|
18
|
+
endpoints: ClientEndpoints.filterEndpoints($config.get('web3.polygon.endpoints'), opts)
|
|
19
|
+
});
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
async getGasPrice() {
|
|
@@ -41,51 +39,4 @@ export class PolyWeb3Client extends Web3Client {
|
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
// https://raw.githubusercontent.com/maticnetwork/launch/master/mainnet-v1/sentry/sentry/bor/genesis.json
|
|
45
|
-
// https://raw.githubusercontent.com/maticnetwork/launch/master/mainnet-v1/sentry/sentry/heimdall/config/genesis.json
|
|
46
|
-
sign(txData: TxData, privateKey: string): Buffer {
|
|
47
|
-
|
|
48
|
-
const key = Buffer.from(privateKey, 'hex');
|
|
49
|
-
|
|
50
|
-
const common = new Common({
|
|
51
|
-
chain: 137,
|
|
52
|
-
hardfork: 'london',
|
|
53
|
-
customChains: [
|
|
54
|
-
<any> {
|
|
55
|
-
chainId: 137,
|
|
56
|
-
networkId: 137,
|
|
57
|
-
url: 'https://rpc-mainnet.maticvigil.com',
|
|
58
|
-
name: 'MATIC',
|
|
59
|
-
comment: '',
|
|
60
|
-
hardforks: [
|
|
61
|
-
{
|
|
62
|
-
name: "spuriousDragon",
|
|
63
|
-
block: 0
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: 'berlin',
|
|
67
|
-
block: 14750000
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'london',
|
|
71
|
-
block: 23850000
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
genesis: {
|
|
75
|
-
hash: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
76
|
-
timestamp: '0x5ED20F84',
|
|
77
|
-
difficulty: 0x1,
|
|
78
|
-
gasLimit: 0x989680,
|
|
79
|
-
nonce: '0x0',
|
|
80
|
-
stateRoot: '',
|
|
81
|
-
extraData: '',
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const tx = TxFactory.fromTxData(txData as any, { common });
|
|
88
|
-
const signedTx = tx.sign(key);
|
|
89
|
-
return signedTx.serialize();
|
|
90
|
-
}
|
|
91
42
|
}
|
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
import di from 'a-di';
|
|
1
2
|
import memd from 'memd';
|
|
2
3
|
import Web3 from 'web3';
|
|
3
|
-
import {
|
|
4
|
-
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
5
|
-
import { TxData } from '@ethereumjs/tx';
|
|
6
|
-
import { BlockHeader, BlockTransactionString, Syncing } from 'web3-eth';
|
|
7
|
-
import { ClientPool, IPoolWeb3Request } from './ClientPool';
|
|
8
|
-
import { ClientPoolTrace } from './ClientPoolStats';
|
|
9
|
-
import { IWeb3Client } from './interfaces/IWeb3Client';
|
|
10
|
-
import { Log, LogsOptions } from 'web3-core';
|
|
11
|
-
import { Subscription } from 'web3-core-subscriptions';
|
|
4
|
+
import { Wallet } from 'ethers';
|
|
12
5
|
|
|
6
|
+
import type { AbiItem } from 'web3-utils';
|
|
7
|
+
import type { TAddress } from '@dequanto/models/TAddress';
|
|
8
|
+
import type { TPlatform } from '@dequanto/models/TPlatform';
|
|
9
|
+
import type { TransactionRequest } from '@ethersproject/abstract-provider';
|
|
10
|
+
import type { BlockTransactionString, Syncing } from 'web3-eth';
|
|
11
|
+
import type { IWeb3Client, IWeb3ClientOptions } from './interfaces/IWeb3Client';
|
|
12
|
+
import type { BlockNumber, Log, LogsOptions, PastLogsOptions, TransactionConfig, Transaction, TransactionReceipt, WebsocketProvider } from 'web3-core';
|
|
13
|
+
import type { Subscription } from 'web3-core-subscriptions';
|
|
14
|
+
import { ClientPool, IPoolClientConfig, IPoolWeb3Request } from './ClientPool';
|
|
15
|
+
import { ClientPoolTrace } from './ClientPoolStats';
|
|
16
|
+
import { BlockDateResolver } from '@dequanto/blocks/BlockDateResolver';
|
|
17
|
+
import { $number } from '@dequanto/utils/$number';
|
|
18
|
+
import { $txData } from '@dequanto/utils/$txData';
|
|
19
|
+
import { $logger } from '@dequanto/utils/$logger';
|
|
20
|
+
import { class_Dfr } from 'atma-utils';
|
|
21
|
+
import { $promise } from '@dequanto/utils/$promise';
|
|
22
|
+
import { ClientEventsStream } from './ClientEventsStream';
|
|
23
|
+
import { $abiUtils } from '@dequanto/utils/$abiUtils';
|
|
24
|
+
import { ClientDebugMethods } from './debug/ClientDebugMethods';
|
|
13
25
|
|
|
14
26
|
export abstract class Web3Client implements IWeb3Client {
|
|
15
27
|
|
|
@@ -20,17 +32,59 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
20
32
|
abstract chainToken: string;
|
|
21
33
|
abstract defaultGasLimit: number;
|
|
22
34
|
|
|
23
|
-
|
|
35
|
+
defaultTxType: 1 | 2 = 2;
|
|
36
|
+
|
|
37
|
+
async sign(txData: TransactionRequest, privateKey: string): Promise<string> {
|
|
38
|
+
let wallet = new Wallet(privateKey);
|
|
39
|
+
let json = $txData.getJson(txData, this);
|
|
40
|
+
let tx = await wallet.signTransaction(json);
|
|
41
|
+
return tx;
|
|
42
|
+
}
|
|
24
43
|
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
public options: IWeb3ClientOptions;
|
|
46
|
+
public pool: ClientPool;
|
|
47
|
+
public debug:ClientDebugMethods;
|
|
27
48
|
|
|
28
|
-
constructor (
|
|
49
|
+
constructor (options: IWeb3ClientOptions)
|
|
50
|
+
constructor (endpoints: IPoolClientConfig[] )
|
|
51
|
+
constructor (mix: IWeb3ClientOptions | IPoolClientConfig[]) {
|
|
52
|
+
if (Array.isArray(mix)) {
|
|
53
|
+
this.options = { endpoints: mix }
|
|
54
|
+
} else if (mix != null) {
|
|
55
|
+
this.options = mix;
|
|
56
|
+
}
|
|
29
57
|
|
|
58
|
+
if (this.options.endpoints == null && this.options.web3 == null) {
|
|
59
|
+
console.dir(this.options, { depth: null });
|
|
60
|
+
throw new Error(`Neither Node endpoints nor web3 instance provided`);
|
|
61
|
+
}
|
|
62
|
+
this.pool = new ClientPool(this.options);
|
|
63
|
+
this.debug = new ClientDebugMethods(this, this.options.debug)
|
|
30
64
|
}
|
|
31
65
|
|
|
32
|
-
getEventStream (address: TAddress, abi:
|
|
33
|
-
|
|
66
|
+
getEventStream (address: TAddress, abi: AbiItem[], event: string) {
|
|
67
|
+
let eventAbi = abi.find(x => x.type === 'event' && x.name === event);
|
|
68
|
+
if (eventAbi == null) {
|
|
69
|
+
let events = abi.filter(x => x.type === 'event').map(x => x.name).join(', ');
|
|
70
|
+
throw new Error(`Event "${event}" not present in ABI. Events: ${ events }`);
|
|
71
|
+
}
|
|
72
|
+
let stream = new ClientEventsStream(address, eventAbi);
|
|
73
|
+
this
|
|
74
|
+
.subscribe('logs', {
|
|
75
|
+
address: address,
|
|
76
|
+
fromBlock: 'latest',
|
|
77
|
+
topics: [
|
|
78
|
+
$abiUtils.getMethodHash(eventAbi)
|
|
79
|
+
]
|
|
80
|
+
})
|
|
81
|
+
.then(subscription => {
|
|
82
|
+
stream.fromSubscription(subscription);
|
|
83
|
+
}, error => {
|
|
84
|
+
stream.error(error);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return stream;
|
|
34
88
|
}
|
|
35
89
|
|
|
36
90
|
with <TResult> (fn: (web3: Web3) => Promise<TResult>) {
|
|
@@ -57,25 +111,28 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
57
111
|
): Promise<Subscription<Syncing>>;
|
|
58
112
|
subscribe(
|
|
59
113
|
type: 'newBlockHeaders',
|
|
60
|
-
callback?: (error: Error, blockHeader:
|
|
61
|
-
): Promise<Subscription<
|
|
114
|
+
callback?: (error: Error, blockHeader: BlockTransactionString) => void
|
|
115
|
+
): Promise<Subscription<BlockTransactionString>>;
|
|
62
116
|
subscribe(
|
|
63
117
|
type: 'pendingTransactions',
|
|
64
118
|
callback?: (error: Error, transactionHash: string) => void
|
|
65
119
|
): Promise<Subscription<string>>;
|
|
66
120
|
async subscribe (...args): Promise<Subscription<any>>{
|
|
67
121
|
let web3 = await this.getWeb3({ ws: true });
|
|
122
|
+
|
|
123
|
+
let provider = web3.eth.currentProvider as WebsocketProvider & { url };
|
|
124
|
+
if (provider.connected === false) {
|
|
125
|
+
provider.connect();
|
|
126
|
+
await $promise.waitForTrue(() => provider.connected, {
|
|
127
|
+
intervalMs: 200,
|
|
128
|
+
timeoutMessage: `Can not connect to ${provider.url}`,
|
|
129
|
+
timeoutMs: 20_000
|
|
130
|
+
});
|
|
131
|
+
}
|
|
68
132
|
return web3.eth.subscribe(...args as Parameters<Web3['eth']['subscribe']>);
|
|
69
133
|
}
|
|
70
134
|
|
|
71
|
-
readContract (data: {
|
|
72
|
-
address: TAddress,
|
|
73
|
-
abi: any
|
|
74
|
-
method: string,
|
|
75
|
-
arguments?: any[]
|
|
76
|
-
options?: { from?: string, },
|
|
77
|
-
blockNumber?: number
|
|
78
|
-
}) {
|
|
135
|
+
readContract (data: Web3BatchRequests.IContractRequest) {
|
|
79
136
|
let { address, method, abi, options, blockNumber, arguments: params } = data;
|
|
80
137
|
return this.pool.call(async web3 => {
|
|
81
138
|
let contract = new web3.eth.Contract(abi, address);
|
|
@@ -94,6 +151,17 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
94
151
|
});
|
|
95
152
|
}
|
|
96
153
|
|
|
154
|
+
readContractBatch (requests: Web3BatchRequests.IContractRequest[]) {
|
|
155
|
+
let trace = new ClientPoolTrace();
|
|
156
|
+
trace.action = `Batch requests: ${ requests.map(x => x.address) }`;
|
|
157
|
+
return this.pool.call(async web3 => {
|
|
158
|
+
let batch = new Web3BatchRequests.BatchRequest(web3, requests);
|
|
159
|
+
return batch.execute();
|
|
160
|
+
}, {
|
|
161
|
+
trace
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
97
165
|
encodeParameters (types: any[], paramaters: any[]) {
|
|
98
166
|
return this.pool.callSync(web3 => {
|
|
99
167
|
return web3.eth.abi.encodeParameters(types, paramaters);
|
|
@@ -106,6 +174,14 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
106
174
|
return BigInt(weiStr);
|
|
107
175
|
});
|
|
108
176
|
}
|
|
177
|
+
getBalances (addresses: TAddress[], blockNumber?: number): Promise<bigint[]> {
|
|
178
|
+
return this.pool.call(async web3 => {
|
|
179
|
+
let reqs = addresses.map(address => cb => (web3.eth.getBalance as any).request(address, blockNumber, cb));
|
|
180
|
+
let batch = new Web3BatchRequests.BatchRequest<string>(web3, reqs);
|
|
181
|
+
let weiStrings = await batch.execute();
|
|
182
|
+
return weiStrings.map(weiStr => BigInt(weiStr));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
109
185
|
getTransactionCount(address: TAddress, type?: 'pending' | string) {
|
|
110
186
|
return this.pool.call(web3 => {
|
|
111
187
|
return web3.eth.getTransactionCount(address, type);
|
|
@@ -121,16 +197,67 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
121
197
|
return web3.eth.getTransaction(txHash);
|
|
122
198
|
}, opts);
|
|
123
199
|
}
|
|
200
|
+
getTransactions (hashes: TAddress[], opts?: IPoolWeb3Request): Promise<Transaction[]> {
|
|
201
|
+
return this.pool.call(web3 => {
|
|
202
|
+
let reqs = hashes.map(hash => cb => (web3.eth.getTransaction as any).request(hash, cb));
|
|
203
|
+
let batch = new Web3BatchRequests.BatchRequest(web3, reqs);
|
|
204
|
+
return batch.execute();
|
|
205
|
+
}, opts);
|
|
206
|
+
}
|
|
124
207
|
getTransactionReceipt (txHash: TAddress) {
|
|
125
208
|
return this.pool.call(web3 => {
|
|
126
209
|
return web3.eth.getTransactionReceipt(txHash);
|
|
127
210
|
});
|
|
128
211
|
}
|
|
212
|
+
getTransactionReceipts (hashes: TAddress[]): Promise<TransactionReceipt[]> {
|
|
213
|
+
return this.pool.call(web3 => {
|
|
214
|
+
let reqs = hashes.map(hash => cb => (web3.eth.getTransactionReceipt as any).request(hash, cb));
|
|
215
|
+
let batch = new Web3BatchRequests.BatchRequest(web3, reqs);
|
|
216
|
+
return batch.execute();
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
getTransactionTrace (hash: string) {
|
|
220
|
+
return this.pool.call(async web3 => {
|
|
221
|
+
let eth = web3.eth as (typeof web3.eth & { traceTransaction });
|
|
222
|
+
|
|
223
|
+
if (typeof eth.traceTransaction !== 'function') {
|
|
224
|
+
web3.eth.extend({
|
|
225
|
+
methods: [
|
|
226
|
+
{
|
|
227
|
+
name: 'traceTransaction',
|
|
228
|
+
call: 'debug_traceTransaction',
|
|
229
|
+
params: 1,
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
let result = await eth.traceTransaction(hash);
|
|
236
|
+
return result;
|
|
237
|
+
|
|
238
|
+
}, {
|
|
239
|
+
node: {
|
|
240
|
+
traceable: true
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
129
244
|
getBlock (nr: number): Promise<BlockTransactionString> {
|
|
130
245
|
return this.pool.call(web3 => {
|
|
131
246
|
return web3.eth.getBlock(nr);
|
|
132
247
|
});
|
|
133
248
|
}
|
|
249
|
+
getBlocks (nrs: number[]): Promise<BlockTransactionString[]> {
|
|
250
|
+
return this.pool.call(web3 => {
|
|
251
|
+
let reqs = nrs.map(nr => cb => (web3.eth.getBlock as any).request(nr, cb));
|
|
252
|
+
let batch = new Web3BatchRequests.BatchRequest(web3, reqs);
|
|
253
|
+
return batch.execute();
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
getCode (address: TAddress) {
|
|
257
|
+
return this.pool.call(web3 => {
|
|
258
|
+
return web3.eth.getCode(address);
|
|
259
|
+
})
|
|
260
|
+
}
|
|
134
261
|
getPendingTransactions () {
|
|
135
262
|
return this.pool.call(web3 => {
|
|
136
263
|
return web3.eth.getPendingTransactions();
|
|
@@ -162,7 +289,6 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
162
289
|
}
|
|
163
290
|
});
|
|
164
291
|
}
|
|
165
|
-
|
|
166
292
|
getStorageAt (address: TAddress, position: string | number | bigint, blockNumber?: number) {
|
|
167
293
|
return this.pool.call(web3 => {
|
|
168
294
|
return web3.eth.getStorageAt(address, <any> position, blockNumber);
|
|
@@ -177,7 +303,7 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
177
303
|
});
|
|
178
304
|
});
|
|
179
305
|
}
|
|
180
|
-
getGasEstimation (from: TAddress, tx:
|
|
306
|
+
getGasEstimation (from: TAddress, tx: TransactionRequest) {
|
|
181
307
|
return this.pool.call(async web3 => {
|
|
182
308
|
let txData = {
|
|
183
309
|
from: from,
|
|
@@ -190,12 +316,36 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
190
316
|
return gasAmount;
|
|
191
317
|
})
|
|
192
318
|
}
|
|
319
|
+
async getAccounts (options?: IPoolWeb3Request): Promise<TAddress[]> {
|
|
320
|
+
let web3 = await this.getWeb3(options);
|
|
321
|
+
return web3.eth.getAccounts();
|
|
322
|
+
}
|
|
323
|
+
async getChainId (options?: IPoolWeb3Request): Promise<number> {
|
|
324
|
+
let web3 = await this.getWeb3(options);
|
|
325
|
+
return web3.eth.getChainId()
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
async switchChain (params: { chainId: number | string }, options: IPoolWeb3Request): Promise<any> {
|
|
329
|
+
let web3 = await this.getWeb3(options);
|
|
330
|
+
if (typeof (web3.eth.currentProvider as any).request !== 'function') {
|
|
331
|
+
throw new Error(`Current provider doesn't have request method`);
|
|
332
|
+
}
|
|
333
|
+
return (web3.eth.currentProvider as any).request({
|
|
334
|
+
method: 'wallet_switchEthereumChain',
|
|
335
|
+
params: [{ chainId: $number.toHex(params.chainId) }],
|
|
336
|
+
});
|
|
337
|
+
}
|
|
193
338
|
|
|
194
339
|
sendSignedTransaction(signedTxBuffer: string) {
|
|
195
340
|
return this.pool.callPromiEvent(web3 => {
|
|
196
341
|
return web3.eth.sendSignedTransaction(signedTxBuffer);
|
|
197
342
|
}, { preferSafe: true, distinct: true });
|
|
198
343
|
}
|
|
344
|
+
sendTransaction(data: TransactionConfig) {
|
|
345
|
+
return this.pool.callPromiEvent(web3 => {
|
|
346
|
+
return web3.eth.sendTransaction(data);
|
|
347
|
+
}, { preferSafe: true, distinct: true });
|
|
348
|
+
}
|
|
199
349
|
|
|
200
350
|
getBlockNumber () {
|
|
201
351
|
return this.pool.call(web3 => {
|
|
@@ -210,6 +360,53 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
210
360
|
});
|
|
211
361
|
}
|
|
212
362
|
|
|
363
|
+
async getPastLogs (options: PastLogsOptions) {
|
|
364
|
+
const getBlock = async (block: BlockNumber | Date, $default: string | number) => {
|
|
365
|
+
if (block == null) {
|
|
366
|
+
return $default;
|
|
367
|
+
}
|
|
368
|
+
if (block instanceof Date) {
|
|
369
|
+
let resolver = di.resolve(BlockDateResolver, this);
|
|
370
|
+
return resolver.getBlockNumberFor(block);
|
|
371
|
+
}
|
|
372
|
+
return block;
|
|
373
|
+
};
|
|
374
|
+
const getBlockNumber = async (block: number | string) => {
|
|
375
|
+
if (typeof block === 'number') {
|
|
376
|
+
return block;
|
|
377
|
+
}
|
|
378
|
+
if (block == null || block === 'latest') {
|
|
379
|
+
return this.getBlockNumber();
|
|
380
|
+
}
|
|
381
|
+
if (block.startsWith('0x')) {
|
|
382
|
+
return Number(block);
|
|
383
|
+
}
|
|
384
|
+
throw new Error(`Invalid block number`);
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
options.fromBlock = await getBlock(options.fromBlock, 0);
|
|
388
|
+
options.toBlock = await getBlock(options.toBlock, 'latest');
|
|
389
|
+
options.topics = options.topics?.map(topic => {
|
|
390
|
+
if (typeof topic === 'string' && topic.startsWith('0x')) {
|
|
391
|
+
return '0x' + topic.substring(2).padStart(64, '0');
|
|
392
|
+
}
|
|
393
|
+
return topic;
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
let MAX = this.pool.getOptionForFetchableRange();
|
|
397
|
+
let [ fromBlock, toBlock ] = await Promise.all([
|
|
398
|
+
getBlockNumber(options.fromBlock as any),
|
|
399
|
+
getBlockNumber(options.toBlock as any),
|
|
400
|
+
]);
|
|
401
|
+
return await RangeWorker.fetchWithLimits(this, options, {
|
|
402
|
+
maxBlockRange: MAX,
|
|
403
|
+
maxResultCount: null,
|
|
404
|
+
}, {
|
|
405
|
+
fromBlock,
|
|
406
|
+
toBlock
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
213
410
|
getNodeInfos () {
|
|
214
411
|
return this.pool.getNodeInfos();
|
|
215
412
|
}
|
|
@@ -217,12 +414,213 @@ export abstract class Web3Client implements IWeb3Client {
|
|
|
217
414
|
return this.pool.getNodeStats();
|
|
218
415
|
}
|
|
219
416
|
|
|
220
|
-
static url<T extends Web3Client> (
|
|
417
|
+
static url<T extends Web3Client> (options: IWeb3ClientOptions)
|
|
418
|
+
static url<T extends Web3Client> (endpoints: IPoolClientConfig[], opts?: Partial<IWeb3ClientOptions>)
|
|
419
|
+
static url<T extends Web3Client> (url: string, opts?: Partial<IWeb3ClientOptions>): T
|
|
420
|
+
static url<T extends Web3Client> (mix: IWeb3ClientOptions | IPoolClientConfig[] | string, opts?: Partial<IWeb3ClientOptions>): T {
|
|
221
421
|
const Ctor: any = this;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
422
|
+
let options: IWeb3ClientOptions;
|
|
423
|
+
if (typeof mix === 'string') {
|
|
424
|
+
options = { endpoints: [ { url: mix }] }
|
|
425
|
+
} else if (Array.isArray(mix)) {
|
|
426
|
+
options = { endpoints: mix }
|
|
427
|
+
} else {
|
|
428
|
+
options = mix;
|
|
429
|
+
}
|
|
430
|
+
const param = {
|
|
431
|
+
...options,
|
|
432
|
+
...(opts ?? {})
|
|
433
|
+
};
|
|
434
|
+
return new Ctor(param);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
namespace Web3BatchRequests {
|
|
440
|
+
|
|
441
|
+
export interface IContractRequest {
|
|
442
|
+
address: TAddress,
|
|
443
|
+
abi: any
|
|
444
|
+
method: string,
|
|
445
|
+
arguments?: any[]
|
|
446
|
+
options?: {
|
|
447
|
+
from?: TAddress
|
|
448
|
+
}
|
|
449
|
+
blockNumber?: number
|
|
450
|
+
}
|
|
451
|
+
export type IRequestBuilder = (cb: Function) => IRPCRequest
|
|
452
|
+
|
|
453
|
+
export interface IRPCRequest {
|
|
454
|
+
method: string
|
|
455
|
+
params: any
|
|
456
|
+
callback: Function
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export function contractRequest (web3: Web3, request: IContractRequest, onComplete: Function) {
|
|
460
|
+
let { contract, method, params, callArgs } = prepair(web3, request);
|
|
461
|
+
return contract.methods[method](...params).call.request(...callArgs, onComplete);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
export function call (web3: Web3, request: IContractRequest) {
|
|
466
|
+
let { contract, method, params, callArgs } = prepair(web3, request);
|
|
467
|
+
return contract.methods[method](...params).call(...callArgs);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export class BatchRequest<TReturnItem = any> {
|
|
471
|
+
private promise = new class_Dfr();
|
|
472
|
+
private results = new Array(this.requests.length);
|
|
473
|
+
private awaitables = this.requests.length;
|
|
474
|
+
//-private wasCompleted = false;
|
|
475
|
+
|
|
476
|
+
constructor (private web3: Web3, private requests: (IContractRequest | IRequestBuilder)[]) {
|
|
477
|
+
|
|
478
|
+
}
|
|
479
|
+
async execute (): Promise<TReturnItem[]> {
|
|
480
|
+
if (this.requests.length === 0) {
|
|
481
|
+
return this.promise.resolve(this.results);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
let web3 = this.web3;
|
|
485
|
+
let batch = new web3.BatchRequest();
|
|
486
|
+
let arr = this.requests.map((req, i) => {
|
|
487
|
+
const cb = (err, result) => {
|
|
488
|
+
this.onCompleted(i, err, result);
|
|
489
|
+
};
|
|
490
|
+
if (typeof req === 'function') {
|
|
491
|
+
return req(cb);
|
|
492
|
+
}
|
|
493
|
+
return contractRequest(web3, req, cb);
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
arr.forEach(req => {
|
|
497
|
+
batch.add(req);
|
|
498
|
+
});
|
|
499
|
+
batch.execute();
|
|
500
|
+
return this.promise;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
private onCompleted (i: number, error: Error, result?) {
|
|
504
|
+
this.results[i] = result ?? error;
|
|
505
|
+
|
|
506
|
+
if (--this.awaitables === 0) {
|
|
507
|
+
this.promise.resolve(this.results);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function prepair (web3: Web3, request: IContractRequest) {
|
|
513
|
+
let { address, method, abi, options, blockNumber, arguments: params } = request;
|
|
514
|
+
let contract = new web3.eth.Contract(abi, address);
|
|
515
|
+
let callArgs = [];
|
|
516
|
+
if (options != null) {
|
|
517
|
+
callArgs[0] = options;
|
|
518
|
+
}
|
|
519
|
+
if (blockNumber != null) {
|
|
520
|
+
callArgs[0] = null;
|
|
521
|
+
callArgs[1] = blockNumber;
|
|
522
|
+
}
|
|
523
|
+
return { contract, method, params, callArgs };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
namespace RangeWorker {
|
|
530
|
+
|
|
531
|
+
export async function fetchWithLimits (
|
|
532
|
+
client: Web3Client,
|
|
533
|
+
options: PastLogsOptions,
|
|
534
|
+
limits: { maxBlockRange?: number, maxResultCount?: number },
|
|
535
|
+
ranges: { fromBlock: number, toBlock: number }
|
|
536
|
+
) {
|
|
537
|
+
let { fromBlock, toBlock } = ranges;
|
|
538
|
+
let { maxBlockRange } = limits;
|
|
539
|
+
let range = toBlock - fromBlock;
|
|
540
|
+
if (maxBlockRange == null || range <= maxBlockRange) {
|
|
541
|
+
return fetch (client, options, ranges, limits);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
let logs = [];
|
|
545
|
+
let cursor = fromBlock;
|
|
546
|
+
let pages = Math.ceil(range / maxBlockRange);
|
|
547
|
+
let page = 0;
|
|
548
|
+
let complete = false;
|
|
549
|
+
while (complete === false) {
|
|
550
|
+
++page;
|
|
551
|
+
let end = cursor + maxBlockRange;
|
|
552
|
+
if (end > toBlock) {
|
|
553
|
+
end = options.toBlock as number;
|
|
554
|
+
complete = true;
|
|
555
|
+
}
|
|
556
|
+
$logger.log(`Get past logs paged: ${page}/${pages} (Block start: ${cursor}). Loaded ${logs.length}`);
|
|
557
|
+
let paged = await fetch(client, options, {
|
|
558
|
+
fromBlock: cursor,
|
|
559
|
+
toBlock: end ?? undefined,
|
|
560
|
+
}, limits);
|
|
561
|
+
logs.push(...paged);
|
|
562
|
+
cursor += maxBlockRange + 1;
|
|
563
|
+
}
|
|
564
|
+
return logs;
|
|
565
|
+
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
async function fetch (
|
|
570
|
+
client: Web3Client,
|
|
571
|
+
options: PastLogsOptions,
|
|
572
|
+
range: { fromBlock: number, toBlock: number },
|
|
573
|
+
knownLimits: { maxBlockRange?: number, maxResultCount?: number },
|
|
574
|
+
) {
|
|
575
|
+
try {
|
|
576
|
+
let paged = await client.pool.call(web3 => web3.eth.getPastLogs({
|
|
577
|
+
...options,
|
|
578
|
+
fromBlock: range.fromBlock,
|
|
579
|
+
toBlock: range.toBlock ?? undefined,
|
|
580
|
+
}));
|
|
581
|
+
return paged;
|
|
582
|
+
} catch (error) {
|
|
583
|
+
/**
|
|
584
|
+
* query returned more than 10000 results
|
|
585
|
+
*/
|
|
586
|
+
$logger.log(`Range worker request: ${range.fromBlock}-${range.toBlock}. ${error.message.trim()}. Splitting range.`)
|
|
587
|
+
let matchCountLimit = /(?<count>\d+) results/.exec(error.message);
|
|
588
|
+
if (matchCountLimit) {
|
|
589
|
+
let count = Number(matchCountLimit.groups.count);
|
|
590
|
+
|
|
591
|
+
let half = Math.floor((range.toBlock - range.fromBlock) / 2);
|
|
592
|
+
let rangeA = {
|
|
593
|
+
fromBlock: range.fromBlock,
|
|
594
|
+
toBlock: range.fromBlock + half
|
|
595
|
+
};
|
|
596
|
+
let arr1 = await fetchWithLimits(client, options, {
|
|
597
|
+
...knownLimits,
|
|
598
|
+
maxResultCount: count
|
|
599
|
+
}, rangeA);
|
|
600
|
+
|
|
601
|
+
let rangeB = {
|
|
602
|
+
fromBlock: range.fromBlock + half,
|
|
603
|
+
toBlock: range.toBlock
|
|
604
|
+
};
|
|
605
|
+
let arr2 = await fetchWithLimits(client, options, {
|
|
606
|
+
...knownLimits,
|
|
607
|
+
maxResultCount: count
|
|
608
|
+
}, rangeB);
|
|
609
|
+
|
|
610
|
+
return [ ...(arr1 ?? []), ...(arr2 ?? []) ]
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
let maxRangeMatch = /\b(?<maxRange>\d+)\b/.exec(error.message);
|
|
614
|
+
if (maxRangeMatch && knownLimits.maxBlockRange == null) {
|
|
615
|
+
// handle unknown range, otherwise throw
|
|
616
|
+
let rangeLimit = Number(maxRangeMatch.groups.maxRange);
|
|
617
|
+
return await fetchWithLimits(client, options, {
|
|
618
|
+
...knownLimits,
|
|
619
|
+
maxBlockRange: rangeLimit
|
|
620
|
+
}, range);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
throw error;
|
|
624
|
+
}
|
|
227
625
|
}
|
|
228
626
|
}
|
|
@@ -6,22 +6,38 @@ import { IWeb3EndpointOptions } from './interfaces/IWeb3EndpointOptions';
|
|
|
6
6
|
import { PolyWeb3Client } from './PolyWeb3Client';
|
|
7
7
|
import { ArbWeb3Client } from '@dequanto/chains/arbitrum/ArbWeb3Client';
|
|
8
8
|
import { XDaiWeb3Client } from '@dequanto/chains/xdai/XDaiWeb3Client';
|
|
9
|
+
import { HardhatProvider } from '@dequanto/hardhat/HardhatProvider';
|
|
10
|
+
import { config } from '@dequanto/Config';
|
|
11
|
+
import { $require } from '@dequanto/utils/$require';
|
|
12
|
+
import { EvmWeb3Client } from './EvmWeb3Client';
|
|
9
13
|
|
|
10
14
|
export namespace Web3ClientFactory {
|
|
11
15
|
|
|
12
|
-
export function get (platform: TPlatform, opts?: IWeb3EndpointOptions) {
|
|
16
|
+
export function get (platform: TPlatform | string, opts?: IWeb3EndpointOptions) {
|
|
13
17
|
switch (platform) {
|
|
14
18
|
case 'bsc':
|
|
15
19
|
return di.resolve(BscWeb3Client, opts);
|
|
16
20
|
case 'eth':
|
|
17
21
|
return di.resolve(EthWeb3Client, opts);
|
|
22
|
+
case 'eth:goerli':
|
|
23
|
+
return di.resolve(EthWeb3Client, {
|
|
24
|
+
platform: platform,
|
|
25
|
+
chainId: 5,
|
|
26
|
+
...(opts ?? {})
|
|
27
|
+
});
|
|
18
28
|
case 'polygon':
|
|
19
29
|
return di.resolve(PolyWeb3Client, opts);
|
|
20
30
|
case 'arbitrum':
|
|
21
31
|
return di.resolve(ArbWeb3Client, opts);
|
|
22
32
|
case 'xdai':
|
|
23
33
|
return di.resolve(XDaiWeb3Client, opts);
|
|
34
|
+
case 'hardhat':
|
|
35
|
+
return di.resolve(HardhatProvider).client('localhost');
|
|
24
36
|
default:
|
|
37
|
+
let cfg = config.web3[platform];
|
|
38
|
+
if (cfg != null) {
|
|
39
|
+
return new EvmWeb3Client({ platform, ...cfg });
|
|
40
|
+
}
|
|
25
41
|
throw new Error(`Unsupported platform ${platform} for web3 client`);
|
|
26
42
|
}
|
|
27
43
|
}
|