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
package/src/txs/TxWriter.ts
CHANGED
|
@@ -1,21 +1,33 @@
|
|
|
1
|
+
import '../env/BigIntSerializer'
|
|
1
2
|
import di from 'a-di';
|
|
2
|
-
import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
3
3
|
import { class_Dfr, class_EventEmitter } from 'atma-utils';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import type { ProposeTransactionProps } from '@gnosis.pm/safe-service-client';
|
|
6
|
+
import type { TransactionRequest } from '@ethersproject/abstract-provider';
|
|
7
|
+
import { TransactionReceipt, type PromiEvent } from 'web3-core';
|
|
8
|
+
|
|
9
|
+
import { $bigint } from '@dequanto/utils/$bigint';
|
|
10
|
+
import { $txData } from '@dequanto/utils/$txData';
|
|
11
|
+
import { $sign } from '@dequanto/utils/$sign';
|
|
12
|
+
import { $logger } from '@dequanto/utils/$logger';
|
|
13
|
+
import { $promise } from '@dequanto/utils/$promise';
|
|
14
|
+
import { $account } from '@dequanto/utils/$account';
|
|
15
|
+
import { $gas } from '@dequanto/utils/$gas';
|
|
16
|
+
import { Web3Client } from '@dequanto/clients/Web3Client';
|
|
5
17
|
import { TxDataBuilder } from './TxDataBuilder';
|
|
6
18
|
import { TxLogger } from './TxLogger';
|
|
7
|
-
import
|
|
8
|
-
import { ChainAccount } from '@dequanto/ChainAccounts';
|
|
9
|
-
import { $bigint } from '@dequanto/utils/$bigint';
|
|
19
|
+
import { ChainAccount, IAccount, SafeAccount, TAccount } from "@dequanto/models/TAccount";
|
|
10
20
|
import { TAddress } from '@dequanto/models/TAddress';
|
|
11
21
|
import { ChainAccountsService } from '@dequanto/ChainAccountsService';
|
|
12
22
|
import { Web3ClientFactory } from '@dequanto/clients/Web3ClientFactory';
|
|
13
23
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
14
|
-
import { $promise } from '@dequanto/utils/$promise';
|
|
15
24
|
import { ClientErrorUtil } from '@dequanto/clients/utils/ClientErrorUtil';
|
|
16
|
-
import { $logger } from '@dequanto/utils/$logger';
|
|
17
25
|
import { ITxLogItem } from './receipt/ITxLogItem';
|
|
18
26
|
import { TxLogParser } from './receipt/TxLogParser';
|
|
27
|
+
import { GnosisSafeHandler } from '@dequanto/safe/GnosisSafeHandler';
|
|
28
|
+
import { ISafeServiceTransport } from '@dequanto/safe/transport/ISafeServiceTransport';
|
|
29
|
+
import { SigFileTransport } from './sig-transports/SigFileTransport';
|
|
30
|
+
import { $require } from '@dequanto/utils/$require';
|
|
19
31
|
|
|
20
32
|
interface ITxWriterEvents {
|
|
21
33
|
transactionHash (hash: string)
|
|
@@ -23,12 +35,26 @@ interface ITxWriterEvents {
|
|
|
23
35
|
confirmation (confNumber: number, receipt: TransactionReceipt)
|
|
24
36
|
error (error: Error)
|
|
25
37
|
sent ()
|
|
26
|
-
log (message: string)
|
|
38
|
+
log (message: string)
|
|
39
|
+
safeTxProposed (safeTx: ProposeTransactionProps)
|
|
27
40
|
}
|
|
28
41
|
export interface ITxWriterOptions {
|
|
29
42
|
timeout?: number | boolean
|
|
30
43
|
retries?: number
|
|
31
44
|
retryDelay?: number
|
|
45
|
+
safeTransport?: ISafeServiceTransport
|
|
46
|
+
|
|
47
|
+
/** Tx Data will be saved to the store(e.g. a File), and will wait until the signature appears in the store. */
|
|
48
|
+
sigTransport?: string
|
|
49
|
+
|
|
50
|
+
/** Optionally disable waiting for the transport response */
|
|
51
|
+
sigTransportWait?: boolean
|
|
52
|
+
|
|
53
|
+
/** Write the Tx Data to a JSON file, without submit to the blockchain */
|
|
54
|
+
txOutput?: string
|
|
55
|
+
|
|
56
|
+
/** Provide a pre-signed signature for this transaction data. */
|
|
57
|
+
signature?: string
|
|
32
58
|
|
|
33
59
|
/**
|
|
34
60
|
* The callback is executed on error, to give the opportunity to build a new Tx to resubmit the tx.
|
|
@@ -41,8 +67,11 @@ export interface ITxWriterOptions {
|
|
|
41
67
|
|
|
42
68
|
export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
43
69
|
|
|
70
|
+
private isSafe = $account.isSafe(this.account);
|
|
71
|
+
|
|
44
72
|
onSent = new class_Dfr<string>();
|
|
45
73
|
onCompleted = new class_Dfr<TransactionReceipt>();
|
|
74
|
+
onSaved = new class_Dfr<string>();
|
|
46
75
|
receipt: TransactionReceipt
|
|
47
76
|
|
|
48
77
|
onConfirmed (waitForCount: number): Promise<string> {
|
|
@@ -58,6 +87,10 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
58
87
|
return promise as any;
|
|
59
88
|
}
|
|
60
89
|
|
|
90
|
+
wait (): Promise<TransactionReceipt> {
|
|
91
|
+
return this.onCompleted as any as Promise<TransactionReceipt>;
|
|
92
|
+
}
|
|
93
|
+
|
|
61
94
|
id = Math.round(Math.random() * 10**10) + '';
|
|
62
95
|
tx: {
|
|
63
96
|
timestamp: number
|
|
@@ -75,16 +108,16 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
75
108
|
|
|
76
109
|
private logger = new TxLogger(
|
|
77
110
|
this.id,
|
|
78
|
-
this.
|
|
111
|
+
this.getSenderName(),
|
|
112
|
+
|
|
79
113
|
this.builder
|
|
80
114
|
);
|
|
81
115
|
private confirmationAwaiters = [] as { count: number, promise }[]
|
|
82
116
|
|
|
83
|
-
|
|
84
117
|
protected constructor (
|
|
85
118
|
public client: Web3Client,
|
|
86
119
|
public builder: TxDataBuilder,
|
|
87
|
-
public account:
|
|
120
|
+
public account: TAccount
|
|
88
121
|
) {
|
|
89
122
|
super();
|
|
90
123
|
}
|
|
@@ -109,9 +142,60 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
109
142
|
}
|
|
110
143
|
}
|
|
111
144
|
|
|
112
|
-
private sendTxInner () {
|
|
145
|
+
private async sendTxInner () {
|
|
146
|
+
|
|
147
|
+
if (this.options?.txOutput != null) {
|
|
148
|
+
// handle none blockchain
|
|
149
|
+
await this.saveTxAndExit()
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (this.isSafe) {
|
|
154
|
+
let safeAccount = this.account as SafeAccount;
|
|
155
|
+
let sender = await this.getSender();
|
|
156
|
+
let safe = new GnosisSafeHandler({
|
|
157
|
+
safeAddress: safeAccount.address ?? safeAccount.safeAddress,
|
|
158
|
+
owner: sender,
|
|
159
|
+
client: this.client,
|
|
160
|
+
transport: this.options?.safeTransport
|
|
161
|
+
});
|
|
162
|
+
let innerWriter = await safe.execute(this);
|
|
163
|
+
|
|
164
|
+
this.pipeInnerWriter(innerWriter);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
113
168
|
let time = Date.now();
|
|
114
|
-
let
|
|
169
|
+
let sender: ChainAccount = await this.getSender();
|
|
170
|
+
|
|
171
|
+
if (this.builder.data.nonce == null) {
|
|
172
|
+
await this.builder.setNonce();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let key = sender?.key;
|
|
176
|
+
let signedTxBuffer = key == null
|
|
177
|
+
? null
|
|
178
|
+
: await this.builder.signToString(sender.key);
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
if (signedTxBuffer == null) {
|
|
182
|
+
if (this.options?.sigTransport != null) {
|
|
183
|
+
let transport = di.resolve(SigFileTransport);
|
|
184
|
+
let shouldWait = this.options?.sigTransportWait !== false;
|
|
185
|
+
let { signed, path } = await transport.create(this.options.sigTransport, this.builder, { wait: shouldWait });
|
|
186
|
+
if (path) {
|
|
187
|
+
this.onSaved.resolve(path);
|
|
188
|
+
}
|
|
189
|
+
if (shouldWait === false) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (this.options?.signature) {
|
|
194
|
+
let tx = $txData.getJson(this.builder.data, this.client);
|
|
195
|
+
signedTxBuffer = await $sign.serializeTx(tx, this.options.signature);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
115
199
|
|
|
116
200
|
let tx = <TxWriter['tx']> {
|
|
117
201
|
timestamp: Date.now(),
|
|
@@ -124,10 +208,22 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
124
208
|
this.tx = tx;
|
|
125
209
|
this.txs.push(tx);
|
|
126
210
|
|
|
127
|
-
let promiEvent
|
|
128
|
-
|
|
129
|
-
|
|
211
|
+
let promiEvent: PromiEvent<TransactionReceipt>;
|
|
212
|
+
if (signedTxBuffer != null) {
|
|
213
|
+
promiEvent = this
|
|
214
|
+
.client
|
|
215
|
+
.sendSignedTransaction(signedTxBuffer);
|
|
216
|
+
} else {
|
|
217
|
+
promiEvent = this
|
|
218
|
+
.client
|
|
219
|
+
.sendTransaction(this.builder.getTxData(this.client));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
promiEvent
|
|
130
223
|
.once('transactionHash', hash => {
|
|
224
|
+
if (tx.hash === hash) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
131
227
|
if (tx.hash && tx.timeout) {
|
|
132
228
|
// network has reaccepted the tx, restart previous timeout
|
|
133
229
|
this.clearTimer(tx);
|
|
@@ -137,18 +233,7 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
137
233
|
tx.hash = hash;
|
|
138
234
|
this.onSent.resolve(hash);
|
|
139
235
|
this.emit('transactionHash', hash);
|
|
140
|
-
this.emit('log', `Tx hash
|
|
141
|
-
})
|
|
142
|
-
.once('receipt', receipt => {
|
|
143
|
-
tx.receipt = receipt;
|
|
144
|
-
tx.hash = receipt.transactionHash ?? tx.hash;
|
|
145
|
-
|
|
146
|
-
this.receipt = receipt;
|
|
147
|
-
this.clearTimer(tx);
|
|
148
|
-
this.logger.logReceipt(receipt, Date.now() - time);
|
|
149
|
-
this.onSent.resolve();
|
|
150
|
-
this.emit('receipt', receipt);
|
|
151
|
-
this.emit('log', `Tx receipt received for ${receipt.transactionHash}. Status: ${receipt.status}`);
|
|
236
|
+
this.emit('log', `Tx hash: ${hash}`);
|
|
152
237
|
})
|
|
153
238
|
// .on('confirmation', (confNumber, receipt) => {
|
|
154
239
|
// tx.hash = receipt.transactionHash ?? tx.hash;
|
|
@@ -166,6 +251,9 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
166
251
|
// }
|
|
167
252
|
// })
|
|
168
253
|
.on('error', error => {
|
|
254
|
+
this.onSent.reject(error);
|
|
255
|
+
this.onCompleted.reject(error);
|
|
256
|
+
|
|
169
257
|
this.clearTimer(tx);
|
|
170
258
|
this.logger.logError(error);
|
|
171
259
|
this.emit('error', error);
|
|
@@ -176,10 +264,33 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
176
264
|
|
|
177
265
|
try {
|
|
178
266
|
await this.extractLogs(receipt, tx);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
|
|
267
|
+
} catch (error) {
|
|
268
|
+
console.error('Logs error', error);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
tx.receipt = receipt;
|
|
273
|
+
tx.hash = receipt.transactionHash ?? tx.hash;
|
|
274
|
+
|
|
275
|
+
this.receipt = receipt;
|
|
276
|
+
this.logger.logReceipt(receipt, Date.now() - time);
|
|
277
|
+
this.onSent.resolve();
|
|
278
|
+
this.emit('receipt', receipt);
|
|
279
|
+
|
|
280
|
+
let hash = tx.hash;
|
|
281
|
+
let status = receipt.status;
|
|
282
|
+
let gasFormatted = $gas.formatUsed(this.builder.data, <any>receipt);
|
|
283
|
+
this.emit('log', `Tx receipt: ${hash}.\n\tStatus: ${status}.\n\tGas used: ${gasFormatted}`);
|
|
284
|
+
|
|
285
|
+
this.onCompleted.resolve(receipt);
|
|
286
|
+
} catch (error) {
|
|
287
|
+
console.error('FATAL ERROR', error);
|
|
288
|
+
throw error;
|
|
289
|
+
}
|
|
181
290
|
|
|
182
291
|
}, async (err: Error & { receipt?: TransactionReceipt }) => {
|
|
292
|
+
this.logger.log(`Tx errored ${err.message}`);
|
|
293
|
+
|
|
183
294
|
this.clearTimer(tx);
|
|
184
295
|
tx.error = err;
|
|
185
296
|
|
|
@@ -190,12 +301,12 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
190
301
|
// let client = await this.client.getWeb3();
|
|
191
302
|
// let tx = await this.client.getTransaction(err.receipt.transactionHash);
|
|
192
303
|
|
|
193
|
-
//
|
|
304
|
+
// $logger.log('RECEIPT', err.receipt, tx);
|
|
194
305
|
// try {
|
|
195
306
|
// let result = await client.eth.call(tx, tx.blockNumber);
|
|
196
|
-
//
|
|
307
|
+
// $logger.log('RESULT', result);
|
|
197
308
|
// } catch (err) {
|
|
198
|
-
//
|
|
309
|
+
// $logger.log('CALL ERROR', err);
|
|
199
310
|
// }
|
|
200
311
|
// throw new Error('asd');
|
|
201
312
|
}
|
|
@@ -244,6 +355,27 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
244
355
|
this.onCompleted.reject(err);
|
|
245
356
|
});
|
|
246
357
|
}
|
|
358
|
+
|
|
359
|
+
private async getSender (): Promise<ChainAccount> {
|
|
360
|
+
let account = this.account;
|
|
361
|
+
|
|
362
|
+
let sender = $account.getSender(account);
|
|
363
|
+
if (sender.key == null) {
|
|
364
|
+
/** check the encrypted storage. In case no key is found, assume the target node contains unlocked or locked account */
|
|
365
|
+
let addressOrName = sender.address ?? sender.name;
|
|
366
|
+
let service = di.resolve(ChainAccountsService);
|
|
367
|
+
let fromStorage = await service.get(addressOrName, this.client.platform);
|
|
368
|
+
if (fromStorage) {
|
|
369
|
+
sender = fromStorage as ChainAccount;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return sender;
|
|
373
|
+
}
|
|
374
|
+
private getSenderName () {
|
|
375
|
+
let sender = $account.getSender(this.account);
|
|
376
|
+
return sender.name ?? sender.address;
|
|
377
|
+
}
|
|
378
|
+
|
|
247
379
|
private async extractLogs(receipt: TransactionReceipt, tx: TxWriter['tx']) {
|
|
248
380
|
let parser = di.resolve(TxLogParser);
|
|
249
381
|
let logs = await parser.parse(receipt);
|
|
@@ -251,16 +383,21 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
251
383
|
}
|
|
252
384
|
|
|
253
385
|
private async fundAccountAndResend () {
|
|
254
|
-
let
|
|
386
|
+
let gasFunding = this.builder.config.gasFunding;
|
|
387
|
+
let sender = $account.getSender(this.account);
|
|
255
388
|
await this.builder.setGas({
|
|
256
389
|
gasEstimation: true,
|
|
257
|
-
from:
|
|
390
|
+
from: sender.address
|
|
258
391
|
});
|
|
259
|
-
|
|
392
|
+
|
|
393
|
+
let { gasLimit } = this.builder.data;
|
|
394
|
+
let gasPrice = TxDataBuilder.getGasPrice(this.builder);
|
|
395
|
+
|
|
396
|
+
|
|
260
397
|
let LITTLE_BIT_MORE = 1.3;
|
|
261
|
-
let wei = $bigint.multWithFloat(
|
|
398
|
+
let wei = $bigint.multWithFloat(gasPrice * BigInt(gasLimit as any), LITTLE_BIT_MORE);
|
|
262
399
|
|
|
263
|
-
let fundTx = await this.transferNative(
|
|
400
|
+
let fundTx = await this.transferNative(gasFunding, sender.address, wei);
|
|
264
401
|
await fundTx.onCompleted;
|
|
265
402
|
// account was funded resubmit the tx
|
|
266
403
|
this.resubmit();
|
|
@@ -300,9 +437,21 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
300
437
|
}
|
|
301
438
|
this.sendTxInner();
|
|
302
439
|
}
|
|
440
|
+
private pipeInnerWriter (innerWriter: TxWriter) {
|
|
441
|
+
innerWriter.onCompleted.then(
|
|
442
|
+
(receipt) => this.onCompleted.resolve(receipt),
|
|
443
|
+
(error) => this.onCompleted.reject(error)
|
|
444
|
+
);
|
|
445
|
+
innerWriter.onSent.then(
|
|
446
|
+
(hash) => this.onSent.resolve(hash),
|
|
447
|
+
(error) => this.onSent.reject(error)
|
|
448
|
+
);
|
|
449
|
+
innerWriter.on('error', error => this.emit('error', error));
|
|
450
|
+
innerWriter.on('log', message => this.emit('log', message));
|
|
451
|
+
}
|
|
303
452
|
|
|
304
|
-
/** Use this transfer in case of additional account funding */
|
|
305
|
-
|
|
453
|
+
/** Use this transfer also in case of additional account funding */
|
|
454
|
+
public async transferNative (from: ChainAccount, to: TAddress, amount: bigint): Promise<TxWriter> {
|
|
306
455
|
let txBuilder = new TxDataBuilder(this.client, from, {
|
|
307
456
|
to: to,
|
|
308
457
|
value: $bigint.toHex(amount)
|
|
@@ -317,25 +466,44 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
317
466
|
}
|
|
318
467
|
|
|
319
468
|
toJSON (): TTxWriterJson {
|
|
469
|
+
let account = this.account;
|
|
470
|
+
if (typeof account !== 'string') {
|
|
471
|
+
account = <ChainAccount | SafeAccount> JSON.parse(JSON.stringify(account));
|
|
472
|
+
// Clean any KEY to prevent leaking. When resubmitted if one is required should be taken from the storage
|
|
473
|
+
if ($account.isSafe(account)) {
|
|
474
|
+
delete account.operator?.key;
|
|
475
|
+
} else {
|
|
476
|
+
delete account.key;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
320
479
|
return {
|
|
321
480
|
id: this.id,
|
|
322
481
|
platform: this.client.platform,
|
|
323
482
|
options: this.options,
|
|
324
|
-
account:
|
|
483
|
+
account: account,
|
|
325
484
|
txs: this.txs,
|
|
326
485
|
builder: this.builder.toJSON(),
|
|
327
486
|
};
|
|
328
487
|
}
|
|
329
488
|
|
|
330
|
-
|
|
489
|
+
//** We can save the Tx Data for later reuse/blockchain send */
|
|
490
|
+
async saveTxAndExit (additionalProperties?) {
|
|
491
|
+
let path = this.options?.txOutput;
|
|
492
|
+
$require.notNull(path, 'Save tx data to the file, but the path is undefined');
|
|
493
|
+
await this.builder.save(path, additionalProperties);
|
|
494
|
+
this.onSent.resolve(path);
|
|
495
|
+
this.onSaved.resolve(path);
|
|
496
|
+
this.onCompleted.reject(new Error(`Transaction is not submited to the blockchain. It has been saved to "${path}". Subscribe to the "onSaved" promise instead`))
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
static async fromJSON (json: TTxWriterJson, client?: Web3Client, account?: TAccount): Promise<TxWriter> {
|
|
331
500
|
client = client ?? Web3ClientFactory.get(json.platform);
|
|
332
501
|
|
|
333
|
-
|
|
334
|
-
let account = await service.get(json.account, json.platform);
|
|
502
|
+
account = account ?? json.account;
|
|
335
503
|
|
|
336
504
|
let builder = TxDataBuilder.fromJSON(client, account, {
|
|
337
505
|
config: json.builder.config,
|
|
338
|
-
|
|
506
|
+
tx: json.builder.tx,
|
|
339
507
|
});
|
|
340
508
|
let writer = TxWriter.create(client, builder, account, json.options);
|
|
341
509
|
let txs = json.txs;
|
|
@@ -349,22 +517,51 @@ export class TxWriter extends class_EventEmitter<ITxWriterEvents> {
|
|
|
349
517
|
}
|
|
350
518
|
|
|
351
519
|
|
|
352
|
-
static write (
|
|
520
|
+
static write (
|
|
521
|
+
client: Web3Client,
|
|
522
|
+
builder: TxDataBuilder,
|
|
523
|
+
account: TAccount,
|
|
524
|
+
options?: ITxWriterOptions
|
|
525
|
+
): TxWriter {
|
|
353
526
|
let writer = new TxWriter(client, builder, account);
|
|
354
527
|
writer.write(options);
|
|
355
528
|
return writer;
|
|
356
529
|
}
|
|
357
530
|
|
|
358
|
-
static create (
|
|
531
|
+
static create (
|
|
532
|
+
client: Web3Client,
|
|
533
|
+
builder: TxDataBuilder,
|
|
534
|
+
account: TAccount,
|
|
535
|
+
options?: ITxWriterOptions
|
|
536
|
+
): TxWriter {
|
|
359
537
|
return new TxWriter(client, builder, account);
|
|
360
538
|
}
|
|
539
|
+
|
|
540
|
+
static async writeTxData (
|
|
541
|
+
client: Web3Client,
|
|
542
|
+
data: Partial<TransactionRequest>,
|
|
543
|
+
account: TAccount,
|
|
544
|
+
options?: ITxWriterOptions
|
|
545
|
+
): Promise<TxWriter> {
|
|
546
|
+
let txBuilder = new TxDataBuilder(client, account as IAccount, data);
|
|
547
|
+
|
|
548
|
+
await Promise.all([
|
|
549
|
+
txBuilder.setGas(),
|
|
550
|
+
txBuilder.setNonce(),
|
|
551
|
+
]);
|
|
552
|
+
|
|
553
|
+
let w = new TxWriter(client, txBuilder, account);
|
|
554
|
+
w.send(options);
|
|
555
|
+
return w;
|
|
556
|
+
}
|
|
361
557
|
}
|
|
362
558
|
|
|
363
559
|
export type TTxWriterJson = {
|
|
364
560
|
id: string
|
|
365
561
|
platform: TPlatform
|
|
366
562
|
options: ITxWriterOptions
|
|
367
|
-
account:
|
|
563
|
+
account: TAccount
|
|
368
564
|
txs: TxWriter['txs']
|
|
369
565
|
builder: ReturnType<TxDataBuilder['toJSON']>
|
|
370
566
|
};
|
|
567
|
+
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { TAddress } from '@dequanto/models/TAddress';
|
|
2
2
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
3
|
-
import { AbiItem } from 'web3-utils';
|
|
3
|
+
import { type AbiItem } from 'web3-utils';
|
|
4
4
|
|
|
5
|
-
export interface ITxLogItem {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export interface ITxLogItem<TParams = { [name: string]: any }> {
|
|
6
|
+
blockNumber: number
|
|
7
|
+
transactionHash: string
|
|
8
|
+
address: TAddress
|
|
9
|
+
event: string
|
|
8
10
|
arguments: {
|
|
9
11
|
name?: string
|
|
10
12
|
value: any
|
|
11
|
-
}[]
|
|
13
|
+
}[]
|
|
14
|
+
params: TParams
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
export interface ITxLogItemDescriptor {
|
|
@@ -2,7 +2,7 @@ import alot from 'alot';
|
|
|
2
2
|
import { $contract } from '@dequanto/utils/$contract';
|
|
3
3
|
import { TransactionReceipt } from 'web3-core';
|
|
4
4
|
import { TxTopicProvider } from './TxTopicProvider';
|
|
5
|
-
|
|
5
|
+
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
6
6
|
|
|
7
7
|
export class TxLogParser {
|
|
8
8
|
|
|
@@ -13,7 +13,11 @@ export class TxLogParser {
|
|
|
13
13
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Sparse arrays will contain NULLs for unparsed log items.
|
|
18
|
+
* Per default dense arrays - only with known logs - are returned
|
|
19
|
+
*/
|
|
20
|
+
async parse (receipt: TransactionReceipt, opts?: { sparse?: boolean, platform?: TPlatform }) {
|
|
17
21
|
let logs = await alot(receipt.logs).mapAsync(async log => {
|
|
18
22
|
let topic = await this.topics.get(log.topics[0]);
|
|
19
23
|
if (topic == null) {
|
|
@@ -21,9 +25,16 @@ export class TxLogParser {
|
|
|
21
25
|
}
|
|
22
26
|
let { abi, formatter } = topic;
|
|
23
27
|
let parsed = $contract.parseLogWithAbi(log, abi);
|
|
28
|
+
if (formatter) {
|
|
29
|
+
return await formatter.extract(parsed, opts?.platform ?? 'eth');
|
|
30
|
+
}
|
|
24
31
|
return parsed;
|
|
25
32
|
}).toArrayAsync();
|
|
26
33
|
|
|
34
|
+
if (opts?.sparse !== true) {
|
|
35
|
+
logs = logs.filter(x => x != null);
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
return logs;
|
|
28
39
|
}
|
|
29
40
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import alot from 'alot';
|
|
2
2
|
import { TPlatform } from '@dequanto/models/TPlatform';
|
|
3
|
-
import { TokensServiceFactory } from '@dequanto/tokens/TokensServiceFactory';
|
|
4
|
-
import { TransactionReceipt } from 'web3-core';
|
|
5
3
|
import { TxWriter } from '../TxWriter';
|
|
6
4
|
import { IKnownLogFormatter, ITxLogItem } from './ITxLogItem';
|
|
7
|
-
import { TxLogParser } from './TxLogParser';
|
|
8
|
-
|
|
9
5
|
import { IToken } from '@dequanto/models/IToken';
|
|
10
6
|
import { TAddress } from '@dequanto/models/TAddress';
|
|
7
|
+
import { TokenDataProvider } from '@dequanto/tokens/TokenDataProvider';
|
|
11
8
|
|
|
12
9
|
export interface ITxLogsTransferData {
|
|
10
|
+
event: string
|
|
13
11
|
token: IToken
|
|
14
12
|
from: TAddress
|
|
15
13
|
to: TAddress
|
|
@@ -24,13 +22,14 @@ export class TxLogsTransfer implements IKnownLogFormatter {
|
|
|
24
22
|
|
|
25
23
|
async extractFromParsed(knownLogs: ITxLogItem[], platform: TPlatform): Promise<ITxLogsTransferData[]> {
|
|
26
24
|
|
|
27
|
-
let transfers = knownLogs.filter(x => x.
|
|
28
|
-
let tokenService =
|
|
25
|
+
let transfers = knownLogs.filter(x => x.event === 'Transfer');
|
|
26
|
+
let tokenService = new TokenDataProvider(platform);
|
|
29
27
|
return alot(transfers).mapAsync(async transfer => {
|
|
30
|
-
let erc20Address = transfer.
|
|
28
|
+
let erc20Address = transfer.address;
|
|
31
29
|
let token = await tokenService.getTokenOrDefault(erc20Address);
|
|
32
30
|
let [ from, to, amount ] = transfer.arguments;
|
|
33
31
|
return {
|
|
32
|
+
event: transfer.event,
|
|
34
33
|
token,
|
|
35
34
|
from: from.value,
|
|
36
35
|
to: to.value,
|
|
@@ -39,19 +38,20 @@ export class TxLogsTransfer implements IKnownLogFormatter {
|
|
|
39
38
|
}).toArrayAsync();
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
async extractFromReceipt (receipt: TransactionReceipt, platform: TPlatform): Promise<ITxLogsTransferData[]> {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
41
|
+
// async extractFromReceipt (receipt: TransactionReceipt, platform: TPlatform): Promise<ITxLogsTransferData[]> {
|
|
42
|
+
// let parser = new TxLogParser();
|
|
43
|
+
// let logs = await parser.parse(receipt);
|
|
44
|
+
// logs = logs.filter(x => x != null);
|
|
45
|
+
// return this.extractFromParsed(logs, platform);
|
|
46
|
+
// }
|
|
48
47
|
|
|
49
48
|
async extract (transfer: ITxLogItem, platform: TPlatform): Promise<ITxLogsTransferData> {
|
|
50
|
-
let tokenService =
|
|
51
|
-
let erc20Address = transfer.
|
|
49
|
+
let tokenService = new TokenDataProvider(platform);
|
|
50
|
+
let erc20Address = transfer.address;
|
|
52
51
|
let token = await tokenService.getTokenOrDefault(erc20Address);
|
|
53
52
|
let [ from, to, amount ] = transfer.arguments;
|
|
54
53
|
return {
|
|
54
|
+
event: transfer.event,
|
|
55
55
|
token,
|
|
56
56
|
from: from.value,
|
|
57
57
|
to: to.value,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $abiParser } from '@dequanto/utils/$abiParser';
|
|
2
2
|
import { $abiUtils } from '@dequanto/utils/$abiUtils';
|
|
3
|
-
import { AbiItem } from 'web3-utils';
|
|
3
|
+
import { type AbiItem } from 'web3-utils';
|
|
4
4
|
import { IAbiItemFormattable, IKnownLogFormatter, ITxLogItemDescriptor } from './ITxLogItem';
|
|
5
5
|
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import di from 'a-di';
|
|
2
|
-
import { AbiItem } from 'web3-utils';
|
|
2
|
+
import { type AbiItem } from 'web3-utils';
|
|
3
3
|
import { IAbiItemFormattable, ITxLogItemDescriptor } from './ITxLogItem';
|
|
4
|
-
|
|
4
|
+
import { TxLogsTransfer } from './TxLogsTransfer';
|
|
5
5
|
import { TxTopicInMemoryProvider } from './TxTopicInMemoryProvider';
|
|
6
6
|
|
|
7
7
|
export class TxTopicProvider {
|
|
@@ -10,11 +10,11 @@ export class TxTopicProvider {
|
|
|
10
10
|
|
|
11
11
|
constructor () {
|
|
12
12
|
this.register([
|
|
13
|
-
'event Transfer(address from, address to, uint256 amount)'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
//'event Transfer(address from, address to, uint256 amount)'
|
|
14
|
+
{
|
|
15
|
+
abi: 'event Transfer(address from, address to, uint256 amount)',
|
|
16
|
+
formatter: di.resolve(TxLogsTransfer)
|
|
17
|
+
}
|
|
18
18
|
]);
|
|
19
19
|
}
|
|
20
20
|
|