dequanto 0.0.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1265) hide show
  1. package/.circleci/config.yml +51 -0
  2. package/.github/workflows/npm-publish.yml +32 -0
  3. package/.vscode/settings.json +42 -11
  4. package/actions/chains.act.ts +136 -0
  5. package/actions/contracts.act.ts +178 -0
  6. package/actions/gen.act.ts +38 -38
  7. package/actions/logs.act.ts +7 -0
  8. package/actions/rpc.act.ts +918 -0
  9. package/actions/safe.act.ts +7 -0
  10. package/actions/tokens.act.ts +41 -12
  11. package/configs/defi.yml +28 -0
  12. package/configs/dequanto.yml +377 -51
  13. package/data/cex/eth.csv +356 -356
  14. package/data/chainlink/feeds.json +3674 -0
  15. package/data/chains/chains.json +972 -0
  16. package/data/evm/eventHashes.json +19314 -0
  17. package/data/evm/events.json +19314 -0
  18. package/data/evm/functionHashes.json +121138 -0
  19. package/data/evm/functions.json +121140 -0
  20. package/data/rpc/coregeth.json +1786 -0
  21. package/data/rpc/eth.json +5873 -0
  22. package/data/rpc/flashbots.json +662 -0
  23. package/data/rpc/metamask.json +3673 -0
  24. package/data/rpc/overrides.json +104 -0
  25. package/data/tokens/1inch.json +11107 -4733
  26. package/data/tokens/arbitrum.json +1 -1
  27. package/data/tokens/coingecko.json +118642 -0
  28. package/data/tokens/sushi.json +6067 -48632
  29. package/exports/core.lib.ts +103 -0
  30. package/hardhat.config.js +41 -1
  31. package/importmap.json +27 -0
  32. package/package-bundler.json +181 -0
  33. package/package.json +121 -49
  34. package/readme.md +22 -4
  35. package/src/ChainAccountService.ts +216 -0
  36. package/src/abi/$abiCoder.ts +62 -0
  37. package/src/abi/$rlp.ts +126 -0
  38. package/src/abi/Logger.ts +24 -0
  39. package/src/abi/_version.ts +1 -0
  40. package/src/abi/abi-coder-packed.ts +90 -0
  41. package/src/abi/abi-coder.ts +163 -0
  42. package/src/abi/coders/abstract-coder.ts +455 -0
  43. package/src/abi/coders/address.ts +39 -0
  44. package/src/abi/coders/anonymous.ts +29 -0
  45. package/src/abi/coders/array.ts +190 -0
  46. package/src/abi/coders/boolean.ts +25 -0
  47. package/src/abi/coders/bytes.ts +41 -0
  48. package/src/abi/coders/fixed-bytes.ts +36 -0
  49. package/src/abi/coders/null.ts +28 -0
  50. package/src/abi/coders/number.ts +59 -0
  51. package/src/abi/coders/string.ts +23 -0
  52. package/src/abi/coders/tuple.ts +61 -0
  53. package/src/abi/fragments.ts +1632 -0
  54. package/src/blocks/BlockDateResolver.ts +159 -149
  55. package/src/bridges/BridgeFactory.ts +16 -16
  56. package/src/bridges/hop/HopAddresses.ts +1 -1
  57. package/src/bridges/hop/HopBridge.ts +437 -430
  58. package/src/bridges/hop/contracts/gen.act.ts +51 -50
  59. package/src/bridges/models/IBridge.ts +44 -43
  60. package/src/chains/PlatformFactory.ts +46 -45
  61. package/src/chains/arbitrum/ArbTokenProvider.ts +39 -39
  62. package/src/chains/arbitrum/ArbWeb3Client.ts +21 -39
  63. package/src/chains/arbitrum/Arbiscan.ts +21 -24
  64. package/src/chains/arbitrum/TokensServiceArbitrum.ts +19 -0
  65. package/src/chains/boba/BobaWeb3Client.ts +21 -49
  66. package/src/chains/boba/Bobascan.ts +22 -25
  67. package/src/chains/xdai/XDaiWeb3Client.ts +56 -82
  68. package/src/chains/xdai/XDaiscan.ts +21 -24
  69. package/src/class/PackedRanges.ts +213 -0
  70. package/src/class/PromiseEvent.ts +21 -0
  71. package/src/class/SubjectKind.ts +5 -0
  72. package/src/class/SubjectStream.ts +137 -0
  73. package/src/class/Subscription.ts +7 -0
  74. package/src/clients/BscWeb3Client.ts +21 -38
  75. package/src/clients/ClientEventsStream.ts +95 -33
  76. package/src/clients/ClientPool.ts +616 -207
  77. package/src/clients/ClientPoolStats.ts +70 -64
  78. package/src/clients/EthWeb3Client.ts +23 -36
  79. package/src/clients/EvmWeb3Client.ts +26 -0
  80. package/src/clients/PolyWeb3Client.ts +42 -91
  81. package/src/clients/Web3BatchRequests.ts +119 -0
  82. package/src/clients/Web3Client.ts +700 -134
  83. package/src/clients/Web3ClientFactory.ts +31 -1
  84. package/src/clients/compatibility/Web3.ts +186 -0
  85. package/src/clients/debug/ClientDebugMethods.ts +100 -0
  86. package/src/clients/handlers/RateLimitGuard.ts +353 -0
  87. package/src/clients/interfaces/IWeb3Client.ts +63 -14
  88. package/src/clients/interfaces/IWeb3ClientStatus.ts +21 -23
  89. package/src/clients/interfaces/IWeb3EndpointOptions.ts +16 -9
  90. package/src/clients/model/ClientStatus.ts +6 -5
  91. package/src/clients/model/PromiEventWrap.ts +62 -61
  92. package/src/clients/model/SubscriptionWrap.ts +53 -53
  93. package/src/clients/utils/$web3Abi.ts +29 -0
  94. package/src/clients/utils/ClientEndpoints.ts +32 -26
  95. package/src/clients/utils/ClientErrorUtil.ts +29 -26
  96. package/src/clients/utils/TxFactory.ts +5 -17
  97. package/src/config/AConfigBase.ts +35 -0
  98. package/src/config/Config.ts +45 -0
  99. package/src/config/ConfigProvider.ts +4 -0
  100. package/src/config/ConfigProviderBrowser.ts +21 -0
  101. package/src/config/ConfigProviderIsoPlatform.ts +90 -0
  102. package/src/config/dequanto.d.ts +5 -0
  103. package/src/config/interface/IConfigData.ts +63 -0
  104. package/src/contracts/BscContract.ts +28 -28
  105. package/src/contracts/Contract.ts +120 -126
  106. package/src/contracts/ContractAbiProvider.ts +69 -0
  107. package/src/contracts/ContractBase.ts +496 -60
  108. package/src/contracts/ContractClassFactory.ts +114 -0
  109. package/src/contracts/ContractCreationResolver.ts +85 -0
  110. package/src/contracts/ContractProvider.ts +55 -55
  111. package/src/contracts/ContractReader.ts +339 -87
  112. package/src/contracts/ContractStorageReaderBase.ts +29 -0
  113. package/src/contracts/ContractStream.ts +34 -18
  114. package/src/contracts/ContractWriter.ts +139 -97
  115. package/src/contracts/EthContract.ts +29 -29
  116. package/src/contracts/TxContract.ts +39 -43
  117. package/src/contracts/deploy/ContractDeployer.ts +155 -0
  118. package/src/contracts/deploy/ContractDeployment.ts +53 -0
  119. package/src/contracts/deploy/ContractSource.ts +3 -0
  120. package/src/contracts/deploy/Deployments.ts +672 -0
  121. package/src/contracts/deploy/proxy/$proxyDeploy.ts +302 -0
  122. package/src/contracts/deploy/proxy/ProxyDeployment.ts +401 -0
  123. package/src/contracts/deploy/storage/DeploymentsStorage.ts +368 -0
  124. package/src/contracts/utils/AbiDeserializer.ts +111 -98
  125. package/src/contracts/utils/ContractBaseUtils.ts +105 -0
  126. package/src/contracts/utils/ConvertUtils.ts +16 -16
  127. package/src/contracts/utils/InputDataUtils.ts +32 -93
  128. package/src/contracts/utils/TypeUtils.ts +21 -21
  129. package/src/contracts/wrappers/FnRequestWrapper.ts +15 -0
  130. package/src/contracts/wrappers/FnSignedWrapper.ts +42 -0
  131. package/src/env/BigIntSerializer.ts +19 -18
  132. package/src/erc4337/Erc4337Factory.ts +54 -0
  133. package/src/erc4337/Erc4337Service.ts +219 -0
  134. package/src/erc4337/Erc4337TxWriter.ts +169 -0
  135. package/src/erc4337/models/Erc4337Abi.ts +7 -0
  136. package/src/erc4337/models/IErc4337Info.ts +8 -0
  137. package/src/erc4337/models/UserOperation.ts +18 -0
  138. package/src/erc4337/utils/$erc4337.ts +31 -0
  139. package/src/evm/EvmBytecode.ts +298 -0
  140. package/src/evm/OpcodesInfo.ts +211 -0
  141. package/src/evm/OpcodesWalker.ts +156 -0
  142. package/src/evm/Stack.ts +58 -0
  143. package/src/evm/functions/$opcodes.ts +122 -0
  144. package/src/evm/functions/opcodes.spec.ts +47 -0
  145. package/src/evm/interfaces/IJumps.ts +3 -0
  146. package/src/evm/interfaces/IMemory.ts +3 -0
  147. package/src/evm/interfaces/IOpcode.ts +11 -0
  148. package/src/evm/interfaces/IStorage.ts +3 -0
  149. package/src/evm/opcodes/add.ts +49 -0
  150. package/src/evm/opcodes/addmod.ts +19 -0
  151. package/src/evm/opcodes/address.ts +22 -0
  152. package/src/evm/opcodes/and.ts +58 -0
  153. package/src/evm/opcodes/balance.ts +25 -0
  154. package/src/evm/opcodes/blockhash.ts +25 -0
  155. package/src/evm/opcodes/byte.ts +34 -0
  156. package/src/evm/opcodes/call.ts +69 -0
  157. package/src/evm/opcodes/callcode.ts +69 -0
  158. package/src/evm/opcodes/calldatacopy.ts +36 -0
  159. package/src/evm/opcodes/calldataload.ts +40 -0
  160. package/src/evm/opcodes/calldatasize.ts +21 -0
  161. package/src/evm/opcodes/caller.ts +22 -0
  162. package/src/evm/opcodes/callvalue.ts +21 -0
  163. package/src/evm/opcodes/codecopy.ts +37 -0
  164. package/src/evm/opcodes/codesize.ts +21 -0
  165. package/src/evm/opcodes/coinbase.ts +21 -0
  166. package/src/evm/opcodes/create.ts +42 -0
  167. package/src/evm/opcodes/create2.ts +41 -0
  168. package/src/evm/opcodes/delegatecall.ts +63 -0
  169. package/src/evm/opcodes/difficulty.ts +21 -0
  170. package/src/evm/opcodes/div.ts +35 -0
  171. package/src/evm/opcodes/dup.ts +7 -0
  172. package/src/evm/opcodes/eq.ts +92 -0
  173. package/src/evm/opcodes/exp.ts +34 -0
  174. package/src/evm/opcodes/extcodecopy.ts +42 -0
  175. package/src/evm/opcodes/extcodehash.ts +25 -0
  176. package/src/evm/opcodes/extcodesize.ts +25 -0
  177. package/src/evm/opcodes/gas.ts +21 -0
  178. package/src/evm/opcodes/gaslimit.ts +21 -0
  179. package/src/evm/opcodes/gasprice.ts +21 -0
  180. package/src/evm/opcodes/gt.ts +39 -0
  181. package/src/evm/opcodes/invalid.ts +24 -0
  182. package/src/evm/opcodes/iszero.ts +48 -0
  183. package/src/evm/opcodes/jump.ts +66 -0
  184. package/src/evm/opcodes/jumpdest.ts +6 -0
  185. package/src/evm/opcodes/jumpi.ts +367 -0
  186. package/src/evm/opcodes/log.ts +89 -0
  187. package/src/evm/opcodes/lt.ts +39 -0
  188. package/src/evm/opcodes/mload.ts +30 -0
  189. package/src/evm/opcodes/mod.ts +33 -0
  190. package/src/evm/opcodes/msize.ts +21 -0
  191. package/src/evm/opcodes/mstore.ts +33 -0
  192. package/src/evm/opcodes/mul.ts +38 -0
  193. package/src/evm/opcodes/mulmod.ts +19 -0
  194. package/src/evm/opcodes/not.ts +30 -0
  195. package/src/evm/opcodes/number.ts +21 -0
  196. package/src/evm/opcodes/or.ts +33 -0
  197. package/src/evm/opcodes/origin.ts +21 -0
  198. package/src/evm/opcodes/pc.ts +7 -0
  199. package/src/evm/opcodes/pop.ts +6 -0
  200. package/src/evm/opcodes/push.ts +8 -0
  201. package/src/evm/opcodes/return.ts +78 -0
  202. package/src/evm/opcodes/returndatacopy.ts +37 -0
  203. package/src/evm/opcodes/returndatasize.ts +21 -0
  204. package/src/evm/opcodes/revert.ts +64 -0
  205. package/src/evm/opcodes/sar.ts +33 -0
  206. package/src/evm/opcodes/selfdestruct.ts +26 -0
  207. package/src/evm/opcodes/sha3.ts +63 -0
  208. package/src/evm/opcodes/shl.ts +42 -0
  209. package/src/evm/opcodes/shr.ts +33 -0
  210. package/src/evm/opcodes/signextend.ts +25 -0
  211. package/src/evm/opcodes/sload.ts +190 -0
  212. package/src/evm/opcodes/sstore.ts +259 -0
  213. package/src/evm/opcodes/staticcall.ts +63 -0
  214. package/src/evm/opcodes/stop.ts +22 -0
  215. package/src/evm/opcodes/sub.ts +33 -0
  216. package/src/evm/opcodes/swap.ts +7 -0
  217. package/src/evm/opcodes/timestamp.ts +21 -0
  218. package/src/evm/opcodes/xor.ts +33 -0
  219. package/src/evm/utils/$bytecode.ts +76 -0
  220. package/src/evm/utils/BigNumber.ts +9 -0
  221. package/src/evm/utils/hex.ts +37 -0
  222. package/src/evm/utils/opcodes.ts +213 -0
  223. package/src/evm/utils/stringify.ts +12 -0
  224. package/src/evm/utils/stringifyEvents.ts +37 -0
  225. package/src/evm/utils/stringifyFunctions.ts +41 -0
  226. package/src/evm/utils/stringifyInstructions.ts +38 -0
  227. package/src/evm/utils/stringifyMappings.ts +65 -0
  228. package/src/evm/utils/stringifyStructs.ts +16 -0
  229. package/src/evm/utils/stringifyVariables.ts +32 -0
  230. package/src/explorer/BlockChainExplorerFactory.ts +644 -0
  231. package/src/explorer/BlockChainExplorerProvider.ts +57 -0
  232. package/src/explorer/BlockChainExplorerStorage.ts +124 -0
  233. package/src/explorer/BlockNumberCache.ts +47 -0
  234. package/src/explorer/Bscscan.ts +24 -0
  235. package/src/explorer/ContractVerifier.ts +289 -0
  236. package/src/explorer/ContractVerifierHtml.ts +207 -0
  237. package/src/explorer/Etherscan.ts +37 -0
  238. package/src/explorer/Evmscan.ts +8 -0
  239. package/src/explorer/IAbiProvider.ts +5 -0
  240. package/src/explorer/IBlockChainExplorer.ts +69 -0
  241. package/src/explorer/Polyscan.ts +24 -0
  242. package/src/explorer/verifiers/FsHtmlVerifier.ts +195 -0
  243. package/src/explorer/verifiers/IVerifier.ts +14 -0
  244. package/src/flashbots/FlashbotWeb3Client.ts +24 -0
  245. package/src/flashbots/FlashbotsProvider.ts +163 -0
  246. package/src/gen/Ast.ts +12 -12
  247. package/src/gen/ContractStorageReaderTemplate.ts +18 -0
  248. package/src/gen/ContractTemplate.ts +134 -36
  249. package/src/gen/Generator.ts +414 -227
  250. package/src/gen/GeneratorFromAbi.ts +451 -128
  251. package/src/gen/GeneratorStorageReader.ts +114 -0
  252. package/src/gen/utils/$gen.ts +11 -0
  253. package/src/gen/utils/Str.ts +40 -0
  254. package/src/handlers/TokenHandler.ts +77 -78
  255. package/src/hardhat/HardhatProvider.ts +469 -0
  256. package/src/hardhat/HardhatWeb3Client.ts +66 -0
  257. package/src/indexer/BlocksTxIndexer.ts +116 -69
  258. package/src/indexer/EventsIndexer.ts +379 -0
  259. package/src/indexer/PendingTxIndexer.ts +123 -124
  260. package/src/indexer/handlers/BlocksWalker.ts +420 -390
  261. package/src/indexer/handlers/TxQueueLoader.ts +144 -143
  262. package/src/indexer/storage/FsEventsIndexerStore.ts +182 -0
  263. package/src/indexer/storage/FsEventsMetaStore.ts +65 -0
  264. package/src/indexer/storage/FsEventsStoreUtils.ts +43 -0
  265. package/src/indexer/storage/interfaces.ts +25 -0
  266. package/src/json/JsonArrayMultiStore.ts +219 -0
  267. package/src/json/JsonArrayStore.ts +193 -310
  268. package/src/json/JsonObjectStore.ts +78 -239
  269. package/src/json/JsonStoreFs.ts +187 -0
  270. package/src/loggers/ILogger.ts +6 -3
  271. package/src/loggers/LoggerService.ts +83 -39
  272. package/src/loggers/TxLoggerService.ts +144 -146
  273. package/src/models/IContractDetails.ts +10 -8
  274. package/src/models/IToken.ts +35 -11
  275. package/src/models/ITokenGlob.ts +14 -14
  276. package/src/models/ITransactionDetails.ts +10 -11
  277. package/src/models/TAccount.ts +53 -0
  278. package/src/models/TAddress.ts +2 -1
  279. package/src/models/TBufferLike.ts +2 -2
  280. package/src/models/TError.ts +4 -0
  281. package/src/models/TEth.ts +223 -0
  282. package/src/models/THex.ts +1 -1
  283. package/src/models/TPlatform.ts +16 -1
  284. package/src/models/TResult.ts +6 -6
  285. package/src/models/TTx.ts +42 -0
  286. package/src/ns/NameService.ts +54 -21
  287. package/src/ns/providers/ANsProvider.ts +110 -0
  288. package/src/ns/providers/EnsProvider.ts +109 -45
  289. package/src/ns/providers/INsProvider.ts +31 -6
  290. package/src/ns/providers/SpaceIdProvider.ts +17 -0
  291. package/src/ns/providers/UDProvider.ts +77 -49
  292. package/src/ns/utils/$ns.ts +27 -15
  293. package/src/prebuilt/1inch/OneInchRouterContract/OneInchRouterContract.ts +313 -0
  294. package/src/prebuilt/amm/AmmFactoryV2Contract/AmmFactoryV2Contract.ts +298 -0
  295. package/src/prebuilt/amm/AmmMasterChefV2Contract/AmmMasterChefV2Contract.ts +642 -0
  296. package/src/prebuilt/amm/AmmPairV2Contract/AmmPairV2Contract.ts +700 -0
  297. package/src/prebuilt/amm/AmmPairV3Contract/AmmPairV3Contract.ts +686 -0
  298. package/src/prebuilt/amm/AmmRouterV2Contract/AmmRouterV2Contract.ts +404 -0
  299. package/src/prebuilt/amm/AmmVaultV2Contract/AmmVaultV2Contract.ts +818 -0
  300. package/src/prebuilt/ens/EnsBaseRegistrar/EnsBaseRegistrar.ts +711 -0
  301. package/src/prebuilt/ens/EnsDnsRegistrar/EnsDnsRegistrar.ts +333 -0
  302. package/src/prebuilt/ens/EnsEthRegistrarController/EnsEthRegistrarController.ts +477 -0
  303. package/src/prebuilt/ens/EnsNameWrapper/EnsNameWrapper.ts +1003 -0
  304. package/src/prebuilt/ens/EnsPublicResolver/EnsPublicResolver.ts +873 -0
  305. package/src/prebuilt/ens/EnsRegistry/EnsRegistry.ts +415 -0
  306. package/src/prebuilt/ens/EnsReverseRegistrar/EnsReverseRegistrar.ts +407 -0
  307. package/src/prebuilt/erc4337/EntryPoint/EntryPoint.ts +640 -0
  308. package/src/prebuilt/erc4337/SimpleAccount/SimpleAccount.ts +501 -0
  309. package/src/prebuilt/erc4337/SimpleAccountFactory/SimpleAccountFactory.ts +184 -0
  310. package/src/prebuilt/openzeppelin/AccessControl.json +206 -0
  311. package/src/prebuilt/openzeppelin/AccessControl.ts +257 -0
  312. package/src/prebuilt/openzeppelin/AccessControlCrossChain.json +219 -0
  313. package/src/prebuilt/openzeppelin/AccessControlCrossChain.ts +266 -0
  314. package/src/prebuilt/openzeppelin/AccessControlDefaultAdminRules.json +391 -0
  315. package/src/prebuilt/openzeppelin/AccessControlDefaultAdminRules.ts +450 -0
  316. package/src/prebuilt/openzeppelin/AccessControlEnumerable.json +249 -0
  317. package/src/prebuilt/openzeppelin/AccessControlEnumerable.ts +275 -0
  318. package/src/prebuilt/openzeppelin/ConditionalEscrow.json +156 -0
  319. package/src/prebuilt/openzeppelin/ConditionalEscrow.ts +259 -0
  320. package/src/prebuilt/openzeppelin/CrossChainEnabledPolygonChild.json +30 -0
  321. package/src/prebuilt/openzeppelin/CrossChainEnabledPolygonChild.ts +150 -0
  322. package/src/prebuilt/openzeppelin/EIP712.json +67 -0
  323. package/src/prebuilt/openzeppelin/EIP712.ts +170 -0
  324. package/src/prebuilt/openzeppelin/ERC1155.json +325 -0
  325. package/src/prebuilt/openzeppelin/ERC1155.ts +291 -0
  326. package/src/prebuilt/openzeppelin/ERC1155Burnable.json +360 -0
  327. package/src/prebuilt/openzeppelin/ERC1155Burnable.ts +309 -0
  328. package/src/prebuilt/openzeppelin/ERC1155Holder.json +99 -0
  329. package/src/prebuilt/openzeppelin/ERC1155Holder.ts +163 -0
  330. package/src/prebuilt/openzeppelin/ERC1155Pausable.json +353 -0
  331. package/src/prebuilt/openzeppelin/ERC1155Pausable.ts +338 -0
  332. package/src/prebuilt/openzeppelin/ERC1155PresetMinterPauser.json +734 -0
  333. package/src/prebuilt/openzeppelin/ERC1155PresetMinterPauser.ts +567 -0
  334. package/src/prebuilt/openzeppelin/ERC1155Receiver.json +99 -0
  335. package/src/prebuilt/openzeppelin/ERC1155Receiver.ts +163 -0
  336. package/src/prebuilt/openzeppelin/ERC1155Supply.json +352 -0
  337. package/src/prebuilt/openzeppelin/ERC1155Supply.ts +305 -0
  338. package/src/prebuilt/openzeppelin/ERC1155URIStorage.json +314 -0
  339. package/src/prebuilt/openzeppelin/ERC1155URIStorage.ts +287 -0
  340. package/src/prebuilt/openzeppelin/ERC165.json +21 -0
  341. package/src/prebuilt/openzeppelin/ERC165.ts +143 -0
  342. package/src/prebuilt/openzeppelin/ERC165Storage.json +21 -0
  343. package/src/prebuilt/openzeppelin/ERC165Storage.ts +143 -0
  344. package/src/prebuilt/openzeppelin/ERC1820Implementer.json +26 -0
  345. package/src/prebuilt/openzeppelin/ERC1820Implementer.ts +143 -0
  346. package/src/prebuilt/openzeppelin/ERC20.json +288 -0
  347. package/src/prebuilt/openzeppelin/ERC20.ts +280 -0
  348. package/src/prebuilt/openzeppelin/ERC20Burnable.json +303 -0
  349. package/src/prebuilt/openzeppelin/ERC20Burnable.ts +298 -0
  350. package/src/prebuilt/openzeppelin/ERC20Capped.json +285 -0
  351. package/src/prebuilt/openzeppelin/ERC20Capped.ts +285 -0
  352. package/src/prebuilt/openzeppelin/ERC20FlashMint.json +349 -0
  353. package/src/prebuilt/openzeppelin/ERC20FlashMint.ts +305 -0
  354. package/src/prebuilt/openzeppelin/ERC20Pausable.json +311 -0
  355. package/src/prebuilt/openzeppelin/ERC20Pausable.ts +327 -0
  356. package/src/prebuilt/openzeppelin/ERC20Permit.json +412 -0
  357. package/src/prebuilt/openzeppelin/ERC20Permit.ts +348 -0
  358. package/src/prebuilt/openzeppelin/ERC20PresetFixedSupply.json +329 -0
  359. package/src/prebuilt/openzeppelin/ERC20PresetFixedSupply.ts +302 -0
  360. package/src/prebuilt/openzeppelin/ERC20PresetMinterPauser.json +663 -0
  361. package/src/prebuilt/openzeppelin/ERC20PresetMinterPauser.ts +554 -0
  362. package/src/prebuilt/openzeppelin/ERC20Snapshot.json +328 -0
  363. package/src/prebuilt/openzeppelin/ERC20Snapshot.ts +315 -0
  364. package/src/prebuilt/openzeppelin/ERC20Votes.json +675 -0
  365. package/src/prebuilt/openzeppelin/ERC20Votes.ts +484 -0
  366. package/src/prebuilt/openzeppelin/ERC20VotesComp.json +718 -0
  367. package/src/prebuilt/openzeppelin/ERC20VotesComp.ts +502 -0
  368. package/src/prebuilt/openzeppelin/ERC20Wrapper.json +333 -0
  369. package/src/prebuilt/openzeppelin/ERC20Wrapper.ts +307 -0
  370. package/src/prebuilt/openzeppelin/ERC2771Context.json +21 -0
  371. package/src/prebuilt/openzeppelin/ERC2771Context.ts +143 -0
  372. package/src/prebuilt/openzeppelin/ERC2981.json +50 -0
  373. package/src/prebuilt/openzeppelin/ERC2981.ts +152 -0
  374. package/src/prebuilt/openzeppelin/ERC4626.json +662 -0
  375. package/src/prebuilt/openzeppelin/ERC4626.ts +470 -0
  376. package/src/prebuilt/openzeppelin/ERC721.json +348 -0
  377. package/src/prebuilt/openzeppelin/ERC721.ts +314 -0
  378. package/src/prebuilt/openzeppelin/ERC721Burnable.json +345 -0
  379. package/src/prebuilt/openzeppelin/ERC721Burnable.ts +321 -0
  380. package/src/prebuilt/openzeppelin/ERC721Consecutive.json +363 -0
  381. package/src/prebuilt/openzeppelin/ERC721Consecutive.ts +331 -0
  382. package/src/prebuilt/openzeppelin/ERC721Enumerable.json +388 -0
  383. package/src/prebuilt/openzeppelin/ERC721Enumerable.ts +337 -0
  384. package/src/prebuilt/openzeppelin/ERC721Holder.json +36 -0
  385. package/src/prebuilt/openzeppelin/ERC721Holder.ts +143 -0
  386. package/src/prebuilt/openzeppelin/ERC721Pausable.json +371 -0
  387. package/src/prebuilt/openzeppelin/ERC721Pausable.ts +361 -0
  388. package/src/prebuilt/openzeppelin/ERC721PresetMinterPauserAutoId.json +742 -0
  389. package/src/prebuilt/openzeppelin/ERC721PresetMinterPauserAutoId.ts +595 -0
  390. package/src/prebuilt/openzeppelin/ERC721Royalty.json +361 -0
  391. package/src/prebuilt/openzeppelin/ERC721Royalty.ts +319 -0
  392. package/src/prebuilt/openzeppelin/ERC721URIStorage.json +364 -0
  393. package/src/prebuilt/openzeppelin/ERC721URIStorage.ts +352 -0
  394. package/src/prebuilt/openzeppelin/ERC721Votes.json +637 -0
  395. package/src/prebuilt/openzeppelin/ERC721Votes.ts +489 -0
  396. package/src/prebuilt/openzeppelin/ERC721Wrapper.json +427 -0
  397. package/src/prebuilt/openzeppelin/ERC721Wrapper.ts +352 -0
  398. package/src/prebuilt/openzeppelin/ERC777.json +578 -0
  399. package/src/prebuilt/openzeppelin/ERC777.ts +456 -0
  400. package/src/prebuilt/openzeppelin/ERC777PresetFixedSupply.json +588 -0
  401. package/src/prebuilt/openzeppelin/ERC777PresetFixedSupply.ts +456 -0
  402. package/src/prebuilt/openzeppelin/Escrow.json +137 -0
  403. package/src/prebuilt/openzeppelin/Escrow.ts +250 -0
  404. package/src/prebuilt/openzeppelin/Governor.json +1010 -0
  405. package/src/prebuilt/openzeppelin/Governor.ts +590 -0
  406. package/src/prebuilt/openzeppelin/GovernorCompatibilityBravo.json +1325 -0
  407. package/src/prebuilt/openzeppelin/GovernorCompatibilityBravo.ts +700 -0
  408. package/src/prebuilt/openzeppelin/GovernorCountingSimple.json +1039 -0
  409. package/src/prebuilt/openzeppelin/GovernorCountingSimple.ts +599 -0
  410. package/src/prebuilt/openzeppelin/GovernorPreventLateQuorum.json +1074 -0
  411. package/src/prebuilt/openzeppelin/GovernorPreventLateQuorum.ts +652 -0
  412. package/src/prebuilt/openzeppelin/GovernorProposalThreshold.json +1010 -0
  413. package/src/prebuilt/openzeppelin/GovernorProposalThreshold.ts +590 -0
  414. package/src/prebuilt/openzeppelin/GovernorSettings.json +1106 -0
  415. package/src/prebuilt/openzeppelin/GovernorSettings.ts +686 -0
  416. package/src/prebuilt/openzeppelin/GovernorTimelockCompound.json +1134 -0
  417. package/src/prebuilt/openzeppelin/GovernorTimelockCompound.ts +683 -0
  418. package/src/prebuilt/openzeppelin/GovernorTimelockControl.json +1127 -0
  419. package/src/prebuilt/openzeppelin/GovernorTimelockControl.ts +672 -0
  420. package/src/prebuilt/openzeppelin/GovernorVotes.json +1023 -0
  421. package/src/prebuilt/openzeppelin/GovernorVotes.ts +599 -0
  422. package/src/prebuilt/openzeppelin/GovernorVotesComp.json +1023 -0
  423. package/src/prebuilt/openzeppelin/GovernorVotesComp.ts +599 -0
  424. package/src/prebuilt/openzeppelin/GovernorVotesQuorumFraction.json +1100 -0
  425. package/src/prebuilt/openzeppelin/GovernorVotesQuorumFraction.ts +653 -0
  426. package/src/prebuilt/openzeppelin/IAMB.json +327 -0
  427. package/src/prebuilt/openzeppelin/IAMB.ts +330 -0
  428. package/src/prebuilt/openzeppelin/IAccessControl.json +174 -0
  429. package/src/prebuilt/openzeppelin/IAccessControl.ts +239 -0
  430. package/src/prebuilt/openzeppelin/IAccessControlDefaultAdminRules.json +346 -0
  431. package/src/prebuilt/openzeppelin/IAccessControlDefaultAdminRules.ts +423 -0
  432. package/src/prebuilt/openzeppelin/IAccessControlEnumerable.json +217 -0
  433. package/src/prebuilt/openzeppelin/IAccessControlEnumerable.ts +257 -0
  434. package/src/prebuilt/openzeppelin/IArbSys.json +355 -0
  435. package/src/prebuilt/openzeppelin/IArbSys.ts +300 -0
  436. package/src/prebuilt/openzeppelin/IBeacon.json +15 -0
  437. package/src/prebuilt/openzeppelin/IBeacon.ts +143 -0
  438. package/src/prebuilt/openzeppelin/IBridge.json +529 -0
  439. package/src/prebuilt/openzeppelin/IBridge.ts +430 -0
  440. package/src/prebuilt/openzeppelin/ICompoundTimelock.json +415 -0
  441. package/src/prebuilt/openzeppelin/ICompoundTimelock.ts +380 -0
  442. package/src/prebuilt/openzeppelin/ICrossDomainMessenger.json +101 -0
  443. package/src/prebuilt/openzeppelin/ICrossDomainMessenger.ts +208 -0
  444. package/src/prebuilt/openzeppelin/IERC1155.json +295 -0
  445. package/src/prebuilt/openzeppelin/IERC1155.ts +278 -0
  446. package/src/prebuilt/openzeppelin/IERC1155MetadataURI.json +314 -0
  447. package/src/prebuilt/openzeppelin/IERC1155MetadataURI.ts +287 -0
  448. package/src/prebuilt/openzeppelin/IERC1155Receiver.json +99 -0
  449. package/src/prebuilt/openzeppelin/IERC1155Receiver.ts +163 -0
  450. package/src/prebuilt/openzeppelin/IERC1271.json +26 -0
  451. package/src/prebuilt/openzeppelin/IERC1271.ts +143 -0
  452. package/src/prebuilt/openzeppelin/IERC1363.json +373 -0
  453. package/src/prebuilt/openzeppelin/IERC1363.ts +287 -0
  454. package/src/prebuilt/openzeppelin/IERC1363Receiver.json +36 -0
  455. package/src/prebuilt/openzeppelin/IERC1363Receiver.ts +143 -0
  456. package/src/prebuilt/openzeppelin/IERC1363Spender.json +31 -0
  457. package/src/prebuilt/openzeppelin/IERC1363Spender.ts +143 -0
  458. package/src/prebuilt/openzeppelin/IERC165.json +21 -0
  459. package/src/prebuilt/openzeppelin/IERC165.ts +143 -0
  460. package/src/prebuilt/openzeppelin/IERC1820Implementer.json +26 -0
  461. package/src/prebuilt/openzeppelin/IERC1820Implementer.ts +143 -0
  462. package/src/prebuilt/openzeppelin/IERC1820Registry.json +215 -0
  463. package/src/prebuilt/openzeppelin/IERC1820Registry.ts +245 -0
  464. package/src/prebuilt/openzeppelin/IERC1822Proxiable.json +15 -0
  465. package/src/prebuilt/openzeppelin/IERC1822Proxiable.ts +143 -0
  466. package/src/prebuilt/openzeppelin/IERC20.json +185 -0
  467. package/src/prebuilt/openzeppelin/IERC20.ts +227 -0
  468. package/src/prebuilt/openzeppelin/IERC20Metadata.json +224 -0
  469. package/src/prebuilt/openzeppelin/IERC20Metadata.ts +254 -0
  470. package/src/prebuilt/openzeppelin/IERC20Permit.json +77 -0
  471. package/src/prebuilt/openzeppelin/IERC20Permit.ts +161 -0
  472. package/src/prebuilt/openzeppelin/IERC2612.json +77 -0
  473. package/src/prebuilt/openzeppelin/IERC2612.ts +161 -0
  474. package/src/prebuilt/openzeppelin/IERC2981.json +50 -0
  475. package/src/prebuilt/openzeppelin/IERC2981.ts +152 -0
  476. package/src/prebuilt/openzeppelin/IERC3156FlashBorrower.json +41 -0
  477. package/src/prebuilt/openzeppelin/IERC3156FlashBorrower.ts +143 -0
  478. package/src/prebuilt/openzeppelin/IERC3156FlashLender.json +79 -0
  479. package/src/prebuilt/openzeppelin/IERC3156FlashLender.ts +161 -0
  480. package/src/prebuilt/openzeppelin/IERC4626.json +614 -0
  481. package/src/prebuilt/openzeppelin/IERC4626.ts +448 -0
  482. package/src/prebuilt/openzeppelin/IERC4906.json +319 -0
  483. package/src/prebuilt/openzeppelin/IERC4906.ts +325 -0
  484. package/src/prebuilt/openzeppelin/IERC5267.json +51 -0
  485. package/src/prebuilt/openzeppelin/IERC5267.ts +157 -0
  486. package/src/prebuilt/openzeppelin/IERC5313.json +15 -0
  487. package/src/prebuilt/openzeppelin/IERC5313.ts +143 -0
  488. package/src/prebuilt/openzeppelin/IERC5805.json +210 -0
  489. package/src/prebuilt/openzeppelin/IERC5805.ts +243 -0
  490. package/src/prebuilt/openzeppelin/IERC6372.json +28 -0
  491. package/src/prebuilt/openzeppelin/IERC6372.ts +152 -0
  492. package/src/prebuilt/openzeppelin/IERC721.json +287 -0
  493. package/src/prebuilt/openzeppelin/IERC721.ts +283 -0
  494. package/src/prebuilt/openzeppelin/IERC721Enumerable.json +343 -0
  495. package/src/prebuilt/openzeppelin/IERC721Enumerable.ts +310 -0
  496. package/src/prebuilt/openzeppelin/IERC721Metadata.json +332 -0
  497. package/src/prebuilt/openzeppelin/IERC721Metadata.ts +310 -0
  498. package/src/prebuilt/openzeppelin/IERC721Receiver.json +36 -0
  499. package/src/prebuilt/openzeppelin/IERC721Receiver.ts +143 -0
  500. package/src/prebuilt/openzeppelin/IERC777.json +393 -0
  501. package/src/prebuilt/openzeppelin/IERC777.ts +359 -0
  502. package/src/prebuilt/openzeppelin/IERC777Recipient.json +40 -0
  503. package/src/prebuilt/openzeppelin/IERC777Recipient.ts +143 -0
  504. package/src/prebuilt/openzeppelin/IERC777Sender.json +40 -0
  505. package/src/prebuilt/openzeppelin/IERC777Sender.ts +143 -0
  506. package/src/prebuilt/openzeppelin/IFxMessageProcessor.json +25 -0
  507. package/src/prebuilt/openzeppelin/IFxMessageProcessor.ts +143 -0
  508. package/src/prebuilt/openzeppelin/IGovernor.json +762 -0
  509. package/src/prebuilt/openzeppelin/IGovernor.ts +471 -0
  510. package/src/prebuilt/openzeppelin/IGovernorCompatibilityBravo.json +992 -0
  511. package/src/prebuilt/openzeppelin/IGovernorCompatibilityBravo.ts +536 -0
  512. package/src/prebuilt/openzeppelin/IGovernorTimelock.json +847 -0
  513. package/src/prebuilt/openzeppelin/IGovernorTimelock.ts +521 -0
  514. package/src/prebuilt/openzeppelin/IInbox.json +444 -0
  515. package/src/prebuilt/openzeppelin/IInbox.ts +337 -0
  516. package/src/prebuilt/openzeppelin/IOutbox.json +410 -0
  517. package/src/prebuilt/openzeppelin/IOutbox.ts +317 -0
  518. package/src/prebuilt/openzeppelin/ITransparentUpgradeableProxy.json +117 -0
  519. package/src/prebuilt/openzeppelin/ITransparentUpgradeableProxy.ts +239 -0
  520. package/src/prebuilt/openzeppelin/IVotes.json +184 -0
  521. package/src/prebuilt/openzeppelin/IVotes.ts +225 -0
  522. package/src/prebuilt/openzeppelin/LibArbitrumL2.json +15 -0
  523. package/src/prebuilt/openzeppelin/LibArbitrumL2.ts +143 -0
  524. package/src/prebuilt/openzeppelin/MinimalForwarder.json +208 -0
  525. package/src/prebuilt/openzeppelin/MinimalForwarder.ts +201 -0
  526. package/src/prebuilt/openzeppelin/Multicall.json +21 -0
  527. package/src/prebuilt/openzeppelin/Multicall.ts +143 -0
  528. package/src/prebuilt/openzeppelin/Ownable.json +54 -0
  529. package/src/prebuilt/openzeppelin/Ownable.ts +177 -0
  530. package/src/prebuilt/openzeppelin/Ownable2Step.json +93 -0
  531. package/src/prebuilt/openzeppelin/Ownable2Step.ts +218 -0
  532. package/src/prebuilt/openzeppelin/Pausable.json +41 -0
  533. package/src/prebuilt/openzeppelin/Pausable.ts +178 -0
  534. package/src/prebuilt/openzeppelin/PaymentSplitter.json +304 -0
  535. package/src/prebuilt/openzeppelin/PaymentSplitter.ts +296 -0
  536. package/src/prebuilt/openzeppelin/ProxyAdmin.json +151 -0
  537. package/src/prebuilt/openzeppelin/ProxyAdmin.ts +228 -0
  538. package/src/prebuilt/openzeppelin/PullPayment.json +34 -0
  539. package/src/prebuilt/openzeppelin/PullPayment.ts +152 -0
  540. package/src/prebuilt/openzeppelin/RefundEscrow.json +226 -0
  541. package/src/prebuilt/openzeppelin/RefundEscrow.ts +356 -0
  542. package/src/prebuilt/openzeppelin/TimelockController.json +891 -0
  543. package/src/prebuilt/openzeppelin/TimelockController.ts +573 -0
  544. package/src/prebuilt/openzeppelin/TokenTimelock.json +69 -0
  545. package/src/prebuilt/openzeppelin/TokenTimelock.ts +174 -0
  546. package/src/prebuilt/openzeppelin/UUPSUpgradeable.json +91 -0
  547. package/src/prebuilt/openzeppelin/UUPSUpgradeable.ts +219 -0
  548. package/src/prebuilt/openzeppelin/UpgradeableBeacon.json +104 -0
  549. package/src/prebuilt/openzeppelin/UpgradeableBeacon.ts +222 -0
  550. package/src/prebuilt/openzeppelin/VestingWallet.json +225 -0
  551. package/src/prebuilt/openzeppelin/VestingWallet.ts +254 -0
  552. package/src/prebuilt/openzeppelin/Votes.json +307 -0
  553. package/src/prebuilt/openzeppelin/Votes.ts +304 -0
  554. package/src/prebuilt/openzeppelin/compiled/TransparentUpgradeableProxy/TransparentUpgradeableProxy.ts +214 -0
  555. package/src/prebuilt/safe/CreateCall.ts +168 -0
  556. package/src/prebuilt/safe/GnosisSafe.ts +683 -0
  557. package/src/prebuilt/safe/MultiSend.ts +147 -0
  558. package/src/prebuilt/safe/Safe.ts +742 -0
  559. package/src/prebuilt/safe/SafeL2.ts +780 -0
  560. package/src/prebuilt/safe/SafeProxyFactory.ts +197 -0
  561. package/src/prebuilt/weth/WETH/WETH.ts +390 -0
  562. package/src/rpc/$rpc.ts +124 -0
  563. package/src/rpc/Rpc.ts +3010 -0
  564. package/src/rpc/RpcBase.ts +154 -0
  565. package/src/rpc/RpcContract.ts +179 -0
  566. package/src/rpc/RpcError.ts +41 -0
  567. package/src/rpc/RpcFunction.ts +42 -0
  568. package/src/rpc/RpcHandler.ts +3 -0
  569. package/src/rpc/RpcModelMiddleware.ts +110 -0
  570. package/src/rpc/RpcSubscription.ts +46 -0
  571. package/src/rpc/transports/HttpTransport.ts +54 -0
  572. package/src/rpc/transports/ITransport.ts +87 -0
  573. package/src/rpc/transports/MessageBasedTransport.ts +133 -0
  574. package/src/rpc/transports/RpcTransport.ts +66 -0
  575. package/src/rpc/transports/WsTransport.ts +87 -0
  576. package/src/rpc/transports/WsTransportIsomorphic.ts +26 -0
  577. package/src/rpc/transports/compatibility/EIP1193Transport.ts +38 -0
  578. package/src/rpc/transports/compatibility/Web3Transport.ts +35 -0
  579. package/src/safe/$gnosis.ts +7 -0
  580. package/src/safe/GnosisSafeFactory.ts +104 -0
  581. package/src/safe/GnosisSafeHandler.ts +472 -0
  582. package/src/safe/GnosisSafeService.ts +86 -0
  583. package/src/safe/SafeTx.ts +93 -0
  584. package/src/safe/abi/GnosisSafe.json +979 -0
  585. package/src/safe/abi/v1_4_1/CreateCall.json +68 -0
  586. package/src/safe/abi/v1_4_1/MultiSend.json +20 -0
  587. package/src/safe/abi/v1_4_1/Safe.json +999 -0
  588. package/src/safe/abi/v1_4_1/SafeL2.json +1104 -0
  589. package/src/safe/abi/v1_4_1/SafeProxyFactory.json +139 -0
  590. package/src/safe/transport/FileServiceTransport.ts +109 -0
  591. package/src/safe/transport/ISafeServiceTransport.ts +20 -0
  592. package/src/safe/transport/InMemoryServiceTransport.ts +84 -0
  593. package/src/safe/transport/SafeServiceTransport.ts +148 -0
  594. package/src/safe/types/SafeServiceTypes.ts +326 -0
  595. package/src/services/TimelockService.ts +666 -0
  596. package/src/solidity/SlotsDump.ts +245 -0
  597. package/src/solidity/SlotsParser/Ast.ts +601 -0
  598. package/src/solidity/SlotsParser/MappingSettersResolver.ts +681 -0
  599. package/src/solidity/SlotsParser/SourceFile.ts +240 -0
  600. package/src/solidity/SlotsParser/models.ts +32 -0
  601. package/src/solidity/SlotsParser.ts +497 -0
  602. package/src/solidity/SlotsStorage.ts +209 -0
  603. package/src/solidity/SolidityParser.ts +108 -0
  604. package/src/solidity/SourceCodeProvider.ts +83 -0
  605. package/src/solidity/storage/Accessor.spec.ts +45 -0
  606. package/src/solidity/storage/Accessor.ts +136 -0
  607. package/src/solidity/storage/MappingKeysLoader.ts +112 -0
  608. package/src/solidity/storage/SlotDynamicArray.ts +46 -0
  609. package/src/solidity/storage/SlotFixedArray.ts +31 -0
  610. package/src/solidity/storage/SlotsStorageHandler.ts +18 -0
  611. package/src/solidity/storage/SlotsStorageTransport.ts +215 -0
  612. package/src/solidity/storage/handlers/SlotBytesHandler.ts +135 -0
  613. package/src/solidity/storage/handlers/SlotDynamicArrayHandler.ts +58 -0
  614. package/src/solidity/storage/handlers/SlotFixedArrayHandler.ts +58 -0
  615. package/src/solidity/storage/handlers/SlotMappingHandler.ts +75 -0
  616. package/src/solidity/storage/handlers/SlotStringHandler.ts +27 -0
  617. package/src/solidity/storage/handlers/SlotStructHandler.ts +47 -0
  618. package/src/solidity/storage/handlers/SlotValueConstantHandler.ts +30 -0
  619. package/src/solidity/storage/handlers/SlotValueHandler.ts +36 -0
  620. package/src/solidity/storage/handlers/SlotValueImmutableHandler.ts +49 -0
  621. package/src/solidity/utils/$str.ts +73 -0
  622. package/src/solidity/utils/$types.ts +61 -0
  623. package/src/tokens/TokenDataProvider.ts +284 -0
  624. package/src/tokens/TokenExchangeService.ts +129 -126
  625. package/src/tokens/TokenExchanges/AmmBase/AmmUtilts.ts +16 -16
  626. package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.ts +228 -208
  627. package/src/tokens/TokenExchanges/AmmV2ExchangeBase.ts +242 -242
  628. package/src/tokens/TokenExchanges/AmmV2PriceQuote.ts +433 -0
  629. package/src/tokens/TokenExchanges/OneInchExchange.ts +114 -111
  630. package/src/tokens/TokenExchanges/PancakeswapExchange.ts +25 -30
  631. package/src/tokens/TokenExchanges/SushiswapPolygonExchange.ts +33 -30
  632. package/src/tokens/TokenExchanges/UniswapV2Exchange.ts +28 -0
  633. package/src/tokens/TokenOracles/IOracle.ts +36 -0
  634. package/src/tokens/TokenOracles/TokenPriceStore.ts +130 -129
  635. package/src/tokens/TokenOracles/amm/AmmV1Oracle.ts +219 -0
  636. package/src/tokens/TokenOracles/amm/AmmV2Oracle.ts +57 -0
  637. package/src/tokens/TokenOracles/chainlink/ChainlinkFeedProvider.ts +133 -0
  638. package/src/tokens/TokenOracles/chainlink/ChainlinkOracle.ts +135 -0
  639. package/src/tokens/TokenOracles/coingecko/CoingeckoOracle.ts +121 -0
  640. package/src/tokens/TokenOracles/coingecko/CoingeckoTokenProvider.ts +51 -0
  641. package/src/tokens/TokenPriceService.ts +273 -276
  642. package/src/tokens/TokenPriceServiceProvider.ts +36 -36
  643. package/src/tokens/TokenProviders/ITokenProvider.ts +9 -9
  644. package/src/tokens/TokenProviders/TPChain.ts +53 -41
  645. package/src/tokens/TokenProviders/TPCoingecko.ts +177 -0
  646. package/src/tokens/TokenProviders/TPCoinmarketcap.ts +82 -82
  647. package/src/tokens/TokenProviders/TPConfig.ts +53 -0
  648. package/src/tokens/TokenProviders/TPExplorer.ts +41 -0
  649. package/src/tokens/TokenProviders/TPOneInch.ts +71 -71
  650. package/src/tokens/TokenProviders/TPSushiswap.ts +88 -96
  651. package/src/tokens/TokenProviders/TPUniswap.ts +87 -85
  652. package/src/tokens/TokenService.ts +142 -128
  653. package/src/tokens/TokenSwapService.ts +44 -47
  654. package/src/tokens/TokenTransferService.ts +233 -216
  655. package/src/tokens/TokensService.ts +42 -186
  656. package/src/tokens/TokensServiceBsc.ts +17 -17
  657. package/src/tokens/TokensServiceEth.ts +9 -9
  658. package/src/tokens/TokensServiceFactory.ts +15 -1
  659. package/src/tokens/TokensServicePolygon.ts +17 -17
  660. package/src/tokens/TokensServiceXDai.ts +26 -26
  661. package/src/tokens/defi/ISwapService.ts +12 -12
  662. package/src/tokens/defi/paraswap/Paraswap.ts +242 -244
  663. package/src/tokens/utils/TokenUtils.ts +63 -63
  664. package/src/txs/ITxBuilderOptions.ts +41 -0
  665. package/src/txs/TxDataBuilder.ts +308 -207
  666. package/src/txs/TxLogger.ts +120 -121
  667. package/src/txs/TxNonceManager.ts +86 -0
  668. package/src/txs/TxProvider.ts +70 -68
  669. package/src/txs/TxService.ts +20 -19
  670. package/src/txs/TxWriter.ts +342 -78
  671. package/src/txs/agents/Erc4337Agent.ts +32 -0
  672. package/src/txs/agents/SafeAgent.ts +20 -0
  673. package/src/txs/agents/TxWriterAccountAgents.ts +27 -0
  674. package/src/txs/conditional/GasWatcherLogger.ts +57 -57
  675. package/src/txs/conditional/GasWatcherService.ts +116 -117
  676. package/src/txs/conditional/GasWatcherStore.ts +41 -40
  677. package/src/txs/conditional/GasWatcherTx.ts +142 -143
  678. package/src/txs/receipt/ITxLogItem.ts +31 -25
  679. package/src/txs/receipt/TxLogParser.ts +56 -29
  680. package/src/txs/receipt/TxLogsTransfer.ts +61 -61
  681. package/src/txs/receipt/TxTopicInMemoryProvider.ts +45 -45
  682. package/src/txs/receipt/TxTopicProvider.ts +29 -29
  683. package/src/txs/sig-transports/SigFileTransport.ts +49 -0
  684. package/src/types/TAbi.ts +32 -0
  685. package/src/utils/$abiParser.ts +245 -179
  686. package/src/utils/$abiType.ts +277 -85
  687. package/src/utils/$abiUtils.ts +332 -38
  688. package/src/utils/$account.ts +48 -0
  689. package/src/utils/$address.ts +71 -37
  690. package/src/utils/$array.ts +113 -57
  691. package/src/utils/$base.ts +67 -0
  692. package/src/utils/$bigfloat.ts +562 -0
  693. package/src/utils/$bigint.ts +238 -127
  694. package/src/utils/$block.ts +20 -7
  695. package/src/utils/$bloom.ts +43 -0
  696. package/src/utils/$buffer.ts +196 -0
  697. package/src/utils/$cache.ts +7 -0
  698. package/src/utils/$class.ts +8 -8
  699. package/src/utils/$cli.ts +42 -0
  700. package/src/utils/$color.ts +213 -0
  701. package/src/utils/$config.ts +80 -17
  702. package/src/utils/$const.ts +1 -0
  703. package/src/utils/$contract.ts +309 -67
  704. package/src/utils/$crypto.ts +223 -0
  705. package/src/utils/$csv.ts +70 -54
  706. package/src/utils/$date.ts +697 -473
  707. package/src/utils/$error.ts +16 -0
  708. package/src/utils/$fn.ts +134 -134
  709. package/src/utils/$gas.ts +26 -0
  710. package/src/utils/$hex.ts +133 -0
  711. package/src/utils/$http.ts +219 -0
  712. package/src/utils/$is.ts +73 -37
  713. package/src/utils/$logger.ts +216 -10
  714. package/src/utils/$machine.ts +85 -0
  715. package/src/utils/$number.ts +135 -89
  716. package/src/utils/$object.ts +95 -95
  717. package/src/utils/$path.ts +76 -32
  718. package/src/utils/$perf.ts +20 -0
  719. package/src/utils/$platform.ts +5 -0
  720. package/src/utils/$promise.ts +154 -7
  721. package/src/utils/$regexp.ts +16 -0
  722. package/src/utils/$require.ts +212 -118
  723. package/src/utils/$secret.ts +27 -0
  724. package/src/utils/$semver.ts +27 -0
  725. package/src/utils/$sig.ts +722 -0
  726. package/src/utils/$sign.ts +136 -36
  727. package/src/utils/$signRaw.ts +50 -0
  728. package/src/utils/$signRawNative.ts +105 -0
  729. package/src/utils/$signSerializer.ts +27 -21
  730. package/src/utils/$txData.ts +23 -0
  731. package/src/utils/$wallet.ts +3 -10
  732. package/src/utils/types.ts +58 -29
  733. package/src/wallets/Wallet.ts +33 -33
  734. package/src/wallets/WalletBsc.ts +13 -13
  735. package/src/wallets/WalletService.ts +43 -43
  736. package/test/Batch.spec.ts +89 -0
  737. package/test/BlockChainExplorer.spec.ts +24 -0
  738. package/test/ChainAccount.spec.ts +52 -9
  739. package/test/Fixtures.ts +36 -0
  740. package/test/Web3Client.spec.ts +81 -0
  741. package/test/browser/block.spec.ts +9 -0
  742. package/test/client/block.spec.ts +19 -0
  743. package/test/config.js +68 -0
  744. package/test/config.spec.ts +31 -0
  745. package/test/config.yml +4 -0
  746. package/test/contracts/ContractCreationResolver.spec.ts +26 -0
  747. package/test/ecrecover.spec.ts +63 -0
  748. package/test/erc2612/PermitToken.sol +10 -0
  749. package/test/erc4337/erc4337.spec.ts +407 -0
  750. package/test/fixtures/DaiTokenContract.ts +13 -13
  751. package/test/fixtures/abi/deployments.json +105 -0
  752. package/test/fixtures/abi/encode.json +23798 -0
  753. package/test/fixtures/abi/encodePacked.json +34586 -0
  754. package/test/fixtures/artifacts/AnyERC20/AnyERC20.json +340 -0
  755. package/test/fixtures/artifacts/AnyERC20/AnyERC20.sol +15 -0
  756. package/test/fixtures/contracts/AlphaKlimaSimple.sol +36 -0
  757. package/test/fixtures/contracts/Counter.sol +25 -0
  758. package/test/fixtures/contracts/Ecrecover.sol +33 -0
  759. package/test/fixtures/contracts/Foo.sol +49 -0
  760. package/test/fixtures/contracts/FooErc20.sol +7 -0
  761. package/test/fixtures/contracts/FooNestedModel.sol +6 -0
  762. package/test/fixtures/contracts/FreeToken.sol +263 -0
  763. package/test/fixtures/deployments/DeploymentsFoo.sol +14 -0
  764. package/test/fixtures/deployments/DeploymentsFooV2.sol +11 -0
  765. package/test/fixtures/deployments/DeploymentsFooV3.sol +12 -0
  766. package/test/fixtures/erc4337/core/BaseAccount.sol +107 -0
  767. package/test/fixtures/erc4337/core/BasePaymaster.sol +112 -0
  768. package/test/fixtures/erc4337/core/EntryPoint.sol +631 -0
  769. package/test/fixtures/erc4337/core/Helpers.sol +81 -0
  770. package/test/fixtures/erc4337/core/NonceManager.sol +40 -0
  771. package/test/fixtures/erc4337/core/SenderCreator.sol +28 -0
  772. package/test/fixtures/erc4337/core/StakeManager.sol +124 -0
  773. package/test/fixtures/erc4337/interfaces/IAccount.sol +34 -0
  774. package/test/fixtures/erc4337/interfaces/IAggregator.sol +36 -0
  775. package/test/fixtures/erc4337/interfaces/IEntryPoint.sol +205 -0
  776. package/test/fixtures/erc4337/interfaces/INonceManager.sol +27 -0
  777. package/test/fixtures/erc4337/interfaces/IPaymaster.sol +51 -0
  778. package/test/fixtures/erc4337/interfaces/IStakeManager.sol +104 -0
  779. package/test/fixtures/erc4337/interfaces/UserOperation.sol +91 -0
  780. package/test/fixtures/erc4337/samples/DepositPaymaster.sol +167 -0
  781. package/test/fixtures/erc4337/samples/IOracle.sol +11 -0
  782. package/test/fixtures/erc4337/samples/SimpleAccount.sol +138 -0
  783. package/test/fixtures/erc4337/samples/SimpleAccountFactory.sol +52 -0
  784. package/test/fixtures/erc4337/samples/TokenPaymaster.sol +113 -0
  785. package/test/fixtures/erc4337/samples/VerifyingPaymaster.sol +104 -0
  786. package/test/fixtures/erc4337/samples/bls/BLSAccount.sol +64 -0
  787. package/test/fixtures/erc4337/samples/bls/BLSAccountFactory.sol +61 -0
  788. package/test/fixtures/erc4337/samples/bls/BLSHelper.sol +232 -0
  789. package/test/fixtures/erc4337/samples/bls/BLSSignatureAggregator.sol +164 -0
  790. package/test/fixtures/erc4337/samples/bls/IBLSAccount.sol +16 -0
  791. package/test/fixtures/erc4337/samples/bls/lib/BLSOpen.sol +64 -0
  792. package/test/fixtures/erc4337/samples/bls/lib/hubble-contracts/contracts/libs/BLS.sol +440 -0
  793. package/test/fixtures/erc4337/samples/bls/lib/hubble-contracts/contracts/libs/BNPairingPrecompileCostEstimator.sol +108 -0
  794. package/test/fixtures/erc4337/samples/bls/lib/hubble-contracts/contracts/libs/ModExp.sol +652 -0
  795. package/test/fixtures/erc4337/samples/callback/TokenCallbackHandler.sol +61 -0
  796. package/test/fixtures/erc4337/utils/Exec.sol +70 -0
  797. package/test/fixtures/explorer/0xfbD2aa7efA2B46Ce3c58D7ab0D92C176c71499C0.html +2788 -0
  798. package/test/fixtures/gnosis/GnosisSafe.sol +422 -0
  799. package/test/fixtures/gnosis/GnosisSafeL2.sol +86 -0
  800. package/test/fixtures/gnosis/accessors/SimulateTxAccessor.sol +52 -0
  801. package/test/fixtures/gnosis/base/Executor.sol +27 -0
  802. package/test/fixtures/gnosis/base/FallbackManager.sol +53 -0
  803. package/test/fixtures/gnosis/base/GuardManager.sol +62 -0
  804. package/test/fixtures/gnosis/base/ModuleManager.sol +133 -0
  805. package/test/fixtures/gnosis/base/OwnerManager.sol +149 -0
  806. package/test/fixtures/gnosis/common/Enum.sol +8 -0
  807. package/test/fixtures/gnosis/common/EtherPaymentFallback.sol +13 -0
  808. package/test/fixtures/gnosis/common/SecuredTokenTransfer.sol +35 -0
  809. package/test/fixtures/gnosis/common/SelfAuthorized.sol +16 -0
  810. package/test/fixtures/gnosis/common/SignatureDecoder.sol +36 -0
  811. package/test/fixtures/gnosis/common/Singleton.sol +11 -0
  812. package/test/fixtures/gnosis/common/StorageAccessible.sol +47 -0
  813. package/test/fixtures/gnosis/external/GnosisSafeMath.sol +54 -0
  814. package/test/fixtures/gnosis/interfaces/ERC1155TokenReceiver.sol +49 -0
  815. package/test/fixtures/gnosis/interfaces/ERC721TokenReceiver.sol +24 -0
  816. package/test/fixtures/gnosis/interfaces/ERC777TokensRecipient.sol +13 -0
  817. package/test/fixtures/gnosis/interfaces/IERC165.sol +15 -0
  818. package/test/fixtures/gnosis/interfaces/ISignatureValidator.sol +20 -0
  819. package/test/fixtures/gnosis/interfaces/ViewStorageAccessible.sol +11 -0
  820. package/test/fixtures/gnosis/libraries/CreateCall.sol +30 -0
  821. package/test/fixtures/gnosis/libraries/GnosisSafeStorage.sol +21 -0
  822. package/test/fixtures/gnosis/libraries/MultiSend.sol +66 -0
  823. package/test/fixtures/gnosis/libraries/MultiSendCallOnly.sol +61 -0
  824. package/test/fixtures/gnosis/libraries/SignMessageLib.sol +34 -0
  825. package/test/fixtures/gnosis/proxies/GnosisSafeProxy.sol +44 -0
  826. package/test/fixtures/gnosis/proxies/GnosisSafeProxyFactory.sol +107 -0
  827. package/test/fixtures/gnosis/proxies/IProxyCreationCallback.sol +12 -0
  828. package/test/fixtures/mapping-setters/GTC.sol +611 -0
  829. package/test/fixtures/mapping-setters/UniswapV3Staker/Address.sol +189 -0
  830. package/test/fixtures/mapping-setters/UniswapV3Staker/FullMath.sol +124 -0
  831. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC165.sol +24 -0
  832. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC20.sol +77 -0
  833. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC20Minimal.sol +52 -0
  834. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721.sol +129 -0
  835. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Enumerable.sol +29 -0
  836. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Metadata.sol +27 -0
  837. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Permit.sol +32 -0
  838. package/test/fixtures/mapping-setters/UniswapV3Staker/IERC721Receiver.sol +21 -0
  839. package/test/fixtures/mapping-setters/UniswapV3Staker/IMulticall.sol +13 -0
  840. package/test/fixtures/mapping-setters/UniswapV3Staker/INonfungiblePositionManager.sol +180 -0
  841. package/test/fixtures/mapping-setters/UniswapV3Staker/IPeripheryImmutableState.sol +12 -0
  842. package/test/fixtures/mapping-setters/UniswapV3Staker/IPeripheryPayments.sol +28 -0
  843. package/test/fixtures/mapping-setters/UniswapV3Staker/IPoolInitializer.sol +22 -0
  844. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3Factory.sol +78 -0
  845. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3Pool.sol +24 -0
  846. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolActions.sol +103 -0
  847. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolDerivedState.sol +40 -0
  848. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolEvents.sol +121 -0
  849. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolImmutables.sol +35 -0
  850. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolOwnerActions.sol +23 -0
  851. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3PoolState.sol +116 -0
  852. package/test/fixtures/mapping-setters/UniswapV3Staker/IUniswapV3Staker.sol +183 -0
  853. package/test/fixtures/mapping-setters/UniswapV3Staker/IncentiveId.sol +14 -0
  854. package/test/fixtures/mapping-setters/UniswapV3Staker/Math.sol +31 -0
  855. package/test/fixtures/mapping-setters/UniswapV3Staker/Multicall.sol +28 -0
  856. package/test/fixtures/mapping-setters/UniswapV3Staker/NFTPositionInfo.sol +47 -0
  857. package/test/fixtures/mapping-setters/UniswapV3Staker/PoolAddress.sol +48 -0
  858. package/test/fixtures/mapping-setters/UniswapV3Staker/RewardMath.sol +42 -0
  859. package/test/fixtures/mapping-setters/UniswapV3Staker/TransferHelper.sol +60 -0
  860. package/test/fixtures/mapping-setters/UniswapV3Staker/TransferHelperExtended.sol +39 -0
  861. package/test/fixtures/mapping-setters/UniswapV3Staker/UniswapV3Staker.sol +350 -0
  862. package/test/fixtures/openzeppelin/Proxy.sol +11 -0
  863. package/test/fixtures/openzeppelin/ProxyAdmin.sol +11 -0
  864. package/test/fixtures/openzeppelin/beacon/BeaconProxy.sol +11 -0
  865. package/test/fixtures/openzeppelin/beacon/UpgradeableBeacon.sol +11 -0
  866. package/test/fixtures/parser/AlphaKlima.sol +36 -0
  867. package/test/fixtures/parser/CToken/CErc20.sol +228 -0
  868. package/test/fixtures/parser/CToken/CErc20Delegate.sol +44 -0
  869. package/test/fixtures/parser/CToken/CErc20Delegator.sol +476 -0
  870. package/test/fixtures/parser/CToken/CToken.sol +1156 -0
  871. package/test/fixtures/parser/CToken/CTokenInterfaces.sol +293 -0
  872. package/test/fixtures/parser/CToken/ComptrollerInterface.sol +72 -0
  873. package/test/fixtures/parser/CToken/EIP20Interface.sol +63 -0
  874. package/test/fixtures/parser/CToken/EIP20NonStandardInterface.sol +71 -0
  875. package/test/fixtures/parser/CToken/ErrorReporter.sol +127 -0
  876. package/test/fixtures/parser/CToken/ExponentialNoError.sol +171 -0
  877. package/test/fixtures/parser/CToken/InterestRateModel.sol +30 -0
  878. package/test/fixtures/parser/DAI.sol +194 -0
  879. package/test/fixtures/parser/PriceOracle.sol +1964 -0
  880. package/test/fixtures/parser/SAFE/Context.sol +24 -0
  881. package/test/fixtures/parser/SAFE/ERC20.sol +383 -0
  882. package/test/fixtures/parser/SAFE/IERC20.sol +82 -0
  883. package/test/fixtures/parser/SAFE/IERC20Metadata.sol +28 -0
  884. package/test/fixtures/parser/SAFE/Ownable.sol +76 -0
  885. package/test/fixtures/parser/SAFE/Pausable.sol +91 -0
  886. package/test/fixtures/parser/SAFE/SafeToken.sol +48 -0
  887. package/test/fixtures/parser/SAFE/TokenRescuer.sol +29 -0
  888. package/test/fixtures/parser/SomeERC20/Context.sol +24 -0
  889. package/test/fixtures/parser/SomeERC20/ERC20.sol +389 -0
  890. package/test/fixtures/parser/SomeERC20/IERC20.sol +82 -0
  891. package/test/fixtures/parser/SomeERC20/IERC20Metadata.sol +28 -0
  892. package/test/fixtures/parser/SomeERC20/Ownable.sol +83 -0
  893. package/test/fixtures/parser/SomeERC20/SomeToken.sol +210 -0
  894. package/test/fixtures/parser/TetherToken.sol +447 -0
  895. package/test/fixtures/parser/USDC.sol +2231 -0
  896. package/test/fixtures/parser/v04/ENJToken.sol +493 -0
  897. package/test/fixtures/parser/v04/MultiSigWallet.sol +371 -0
  898. package/test/fixtures/receipts/swap.json +93 -93
  899. package/test/fixtures/scan/WETH.sol +1533 -0
  900. package/test/fixtures/slots/FooStorage.sol +8 -0
  901. package/test/fixtures/slots/FooStorageBase.sol +6 -0
  902. package/test/fixtures/slots/Vault.sol +85 -0
  903. package/test/flashbots/flashbots.spec.ts +79 -0
  904. package/test/generate/class.spec.ts +293 -5
  905. package/test/generate/evm.spec.ts +71 -0
  906. package/test/generate/gen.spec.ts +69 -0
  907. package/test/generate/openzeppelin.spec.ts +22 -0
  908. package/test/generate/slotreader.spec.ts +34 -0
  909. package/test/hardhat/TestNode.ts +76 -61
  910. package/test/hardhat/compile.spec.ts +22 -0
  911. package/test/hardhat/deploy.spec.ts +579 -0
  912. package/test/hardhat/deployments/deployments.spec.ts +233 -0
  913. package/test/hardhat/deployments/proxy-layout.spec.ts +296 -0
  914. package/test/hardhat/forked.spec.ts +56 -0
  915. package/test/hardhat/gas.spec.ts +40 -0
  916. package/test/hardhat/permit.ts +33 -0
  917. package/test/hardhat/revert.spec.ts +30 -0
  918. package/test/indexer/BlocksWalker.spec.ts +51 -0
  919. package/test/indexer/EventsIndexer.spec.ts +170 -0
  920. package/test/json/JsonStore.spec.ts +170 -0
  921. package/test/node/block.spec.ts +11 -0
  922. package/test/ns.spec.ts +67 -30
  923. package/test/perf/calldata.spec.ts +93 -0
  924. package/test/receipt.spec.ts +52 -27
  925. package/test/rpc/rpc.spec.ts +353 -0
  926. package/test/rpc/rpcUtil.spec.ts +31 -0
  927. package/test/safe/safe.spec.ts +352 -0
  928. package/test/services/timelock.spec.ts +97 -0
  929. package/test/solidity/AbiExtractor.spec.ts +468 -0
  930. package/test/solidity/MappingSettersResolver.spec.ts +516 -0
  931. package/test/solidity/SlotsDump.spec.ts +154 -0
  932. package/test/solidity/SlotsParser.spec.ts +536 -0
  933. package/test/solidity/SlotsReader.spec.ts +388 -0
  934. package/test/solidity/Storage.spec.ts +404 -0
  935. package/test/structs/PackedRanges.spec.ts +56 -0
  936. package/test/subscriptions.spec.ts +127 -0
  937. package/test/token.spec.ts +17 -0
  938. package/test/tokens/oracles.spec.ts +51 -0
  939. package/test/utils/abi-parser-args.spec.ts +143 -0
  940. package/test/utils/abi-parser.spec.ts +141 -117
  941. package/test/utils/abi-types.spec.ts +31 -0
  942. package/test/utils/abi-utils.spec.ts +23 -0
  943. package/test/utils/abi.spec.ts +178 -0
  944. package/test/utils/address.spec.ts +66 -0
  945. package/test/utils/bigfloat/div.spec.ts +1919 -0
  946. package/test/utils/bigfloat/mod.spec.ts +1745 -0
  947. package/test/utils/bigfloat/mul.spec.ts +2085 -0
  948. package/test/utils/bigfloat/round.spec.ts +174 -0
  949. package/test/utils/bigfloat/sqrt.spec.ts +420 -0
  950. package/test/utils/bigint.spec.ts +39 -40
  951. package/test/utils/bytecode.spec.ts +107 -0
  952. package/test/utils/crypto.spec.ts +37 -0
  953. package/test/utils/date.spec.ts +9 -8
  954. package/test/utils/fn.spec.ts +39 -39
  955. package/test/utils/logbloom.spec.ts +17 -0
  956. package/test/utils/number.spec.ts +52 -41
  957. package/test/utils/rlp.spec.ts +142 -0
  958. package/test/utils/sign.spec.ts +327 -22
  959. package/tools/build-dts.ts +111 -0
  960. package/tools/copy-dts.ts +48 -0
  961. package/tsconfig-build.json +24 -24
  962. package/tsconfig-src.json +44 -36
  963. package/tsconfig.esm.json +12 -0
  964. package/tsconfig.json +34 -27
  965. package/tsconfig.umd.json +28 -0
  966. package/typings/globals/axios/index.d.ts +6 -6
  967. package/typings.json +6 -6
  968. package/contracts/abi/erc20.abi.json +0 -222
  969. package/contracts/gen/amm/AmmFactoryV2ContractBase.ts +0 -66
  970. package/contracts/gen/amm/AmmMasterChefV2ContractBase.ts +0 -158
  971. package/contracts/gen/amm/AmmPairContractV2Base.ts +0 -158
  972. package/contracts/gen/amm/AmmPairContractV3Base.ts +0 -125
  973. package/contracts/gen/amm/AmmRouterV2ContractBase.ts +0 -124
  974. package/contracts/gen/amm/AmmVaultV2ContractBase.ts +0 -214
  975. package/contracts/gen/base/ERC20Base.ts +0 -90
  976. package/contracts/gen/bsc/OneInchRouterV3Base.ts +0 -57
  977. package/contracts/gen/eth/WETHBase/WETHBase.sol +0 -756
  978. package/contracts/gen/eth/WETHBase.ts +0 -136
  979. package/contracts/gen/polygon/ERC20PolygonBase.ts +0 -305
  980. package/contracts/gen/polygon/WormholeBridgeContractBase/Address.sol +0 -216
  981. package/contracts/gen/polygon/WormholeBridgeContractBase/BeaconProxy.sol +0 -61
  982. package/contracts/gen/polygon/WormholeBridgeContractBase/Bridge.sol +0 -437
  983. package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeGetters.sol +0 -70
  984. package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeGovernance.sol +0 -142
  985. package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeImplementation.sol +0 -34
  986. package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeSetters.sol +0 -57
  987. package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeState.sol +0 -52
  988. package/contracts/gen/polygon/WormholeBridgeContractBase/BridgeStructs.sol +0 -66
  989. package/contracts/gen/polygon/WormholeBridgeContractBase/BytesLib.sol +0 -510
  990. package/contracts/gen/polygon/WormholeBridgeContractBase/Context.sol +0 -23
  991. package/contracts/gen/polygon/WormholeBridgeContractBase/ERC1967Proxy.sol +0 -32
  992. package/contracts/gen/polygon/WormholeBridgeContractBase/ERC1967Upgrade.sol +0 -193
  993. package/contracts/gen/polygon/WormholeBridgeContractBase/IBeacon.sol +0 -15
  994. package/contracts/gen/polygon/WormholeBridgeContractBase/IERC20.sol +0 -81
  995. package/contracts/gen/polygon/WormholeBridgeContractBase/IWormhole.sol +0 -42
  996. package/contracts/gen/polygon/WormholeBridgeContractBase/Ownable.sol +0 -71
  997. package/contracts/gen/polygon/WormholeBridgeContractBase/Proxy.sol +0 -85
  998. package/contracts/gen/polygon/WormholeBridgeContractBase/SafeERC20.sol +0 -98
  999. package/contracts/gen/polygon/WormholeBridgeContractBase/StorageSlot.sol +0 -83
  1000. package/contracts/gen/polygon/WormholeBridgeContractBase/Structs.sol +0 -40
  1001. package/contracts/gen/polygon/WormholeBridgeContractBase/Token.sol +0 -12
  1002. package/contracts/gen/polygon/WormholeBridgeContractBase/TokenBridge.sol +0 -15
  1003. package/contracts/gen/polygon/WormholeBridgeContractBase/TokenImplementation.sol +0 -177
  1004. package/contracts/gen/polygon/WormholeBridgeContractBase/TokenState.sol +0 -31
  1005. package/contracts/gen/polygon/WormholeBridgeContractBase.ts +0 -231
  1006. package/contracts/gen/xdai/WXDaiTokenContractBase.ts +0 -136
  1007. package/dist/contracts/gen/amm/AmmFactoryV2ContractBase.js +0 -53
  1008. package/dist/contracts/gen/amm/AmmMasterChefV2ContractBase.js +0 -122
  1009. package/dist/contracts/gen/amm/AmmPairContractV2Base.js +0 -122
  1010. package/dist/contracts/gen/amm/AmmPairContractV3Base.js +0 -98
  1011. package/dist/contracts/gen/amm/AmmRouterV2ContractBase.js +0 -95
  1012. package/dist/contracts/gen/amm/AmmVaultV2ContractBase.js +0 -164
  1013. package/dist/contracts/gen/base/ERC20Base.js +0 -64
  1014. package/dist/contracts/gen/bsc/OneInchRouterV3Base.js +0 -47
  1015. package/dist/contracts/gen/eth/WETHBase.js +0 -96
  1016. package/dist/contracts/gen/polygon/ERC20PolygonBase.js +0 -233
  1017. package/dist/contracts/gen/polygon/WormholeBridgeContractBase.js +0 -172
  1018. package/dist/contracts/gen/xdai/WXDaiTokenContractBase.js +0 -96
  1019. package/dist/src/BlockchainExplorer/BlockChainExplorerFactory.js +0 -227
  1020. package/dist/src/BlockchainExplorer/BlockChainExplorerProvider.js +0 -32
  1021. package/dist/src/BlockchainExplorer/BlockNumberCache.js +0 -33
  1022. package/dist/src/BlockchainExplorer/Bscscan.js +0 -27
  1023. package/dist/src/BlockchainExplorer/Etherscan.js +0 -27
  1024. package/dist/src/BlockchainExplorer/IAbiProvider.js +0 -2
  1025. package/dist/src/BlockchainExplorer/IBlockChainExplorer.js +0 -2
  1026. package/dist/src/BlockchainExplorer/Polyscan.js +0 -27
  1027. package/dist/src/ChainAccounts.js +0 -69
  1028. package/dist/src/ChainAccountsService.js +0 -75
  1029. package/dist/src/Config.js +0 -7
  1030. package/dist/src/blocks/BlockDateResolver.js +0 -125
  1031. package/dist/src/bridges/BridgeFactory.js +0 -19
  1032. package/dist/src/bridges/hop/HopAddresses.js +0 -520
  1033. package/dist/src/bridges/hop/HopBridge.js +0 -327
  1034. package/dist/src/bridges/hop/contracts/gen.act.js +0 -43
  1035. package/dist/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.js +0 -52
  1036. package/dist/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.js +0 -319
  1037. package/dist/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.js +0 -178
  1038. package/dist/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.js +0 -52
  1039. package/dist/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.js +0 -319
  1040. package/dist/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.js +0 -178
  1041. package/dist/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.js +0 -52
  1042. package/dist/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.js +0 -319
  1043. package/dist/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.js +0 -178
  1044. package/dist/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.js +0 -52
  1045. package/dist/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.js +0 -319
  1046. package/dist/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.js +0 -178
  1047. package/dist/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.js +0 -52
  1048. package/dist/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.js +0 -319
  1049. package/dist/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.js +0 -178
  1050. package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.js +0 -52
  1051. package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.js +0 -319
  1052. package/dist/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.js +0 -178
  1053. package/dist/src/bridges/models/IBridge.js +0 -2
  1054. package/dist/src/bridges/wormhole/contracts/WormholeBridgeContract.js +0 -15
  1055. package/dist/src/chains/PlatformFactory.js +0 -42
  1056. package/dist/src/chains/arbitrum/ArbTokenProvider.js +0 -40
  1057. package/dist/src/chains/arbitrum/ArbWeb3Client.js +0 -39
  1058. package/dist/src/chains/arbitrum/Arbiscan.js +0 -27
  1059. package/dist/src/chains/boba/BobaWeb3Client.js +0 -47
  1060. package/dist/src/chains/boba/Bobascan.js +0 -28
  1061. package/dist/src/chains/xdai/XDaiWeb3Client.js +0 -87
  1062. package/dist/src/chains/xdai/XDaiscan.js +0 -27
  1063. package/dist/src/chains/xdai/tokens/WXDaiTokenContract.js +0 -15
  1064. package/dist/src/clients/BscWeb3Client.js +0 -38
  1065. package/dist/src/clients/ClientEventsStream.js +0 -34
  1066. package/dist/src/clients/ClientPool.js +0 -560
  1067. package/dist/src/clients/ClientPoolStats.js +0 -52
  1068. package/dist/src/clients/EthWeb3Client.js +0 -35
  1069. package/dist/src/clients/HardhatWeb3Client.js +0 -56
  1070. package/dist/src/clients/PolyWeb3Client.js +0 -77
  1071. package/dist/src/clients/Web3Client.js +0 -186
  1072. package/dist/src/clients/Web3ClientFactory.js +0 -32
  1073. package/dist/src/clients/interfaces/IWeb3Client.js +0 -2
  1074. package/dist/src/clients/interfaces/IWeb3ClientStatus.js +0 -2
  1075. package/dist/src/clients/interfaces/IWeb3EndpointOptions.js +0 -2
  1076. package/dist/src/clients/model/ClientStatus.js +0 -9
  1077. package/dist/src/clients/model/PromiEventWrap.js +0 -52
  1078. package/dist/src/clients/model/SubscriptionWrap.js +0 -42
  1079. package/dist/src/clients/utils/ClientEndpoints.js +0 -27
  1080. package/dist/src/clients/utils/ClientErrorUtil.js +0 -30
  1081. package/dist/src/clients/utils/TxFactory.js +0 -14
  1082. package/dist/src/contracts/BscContract.js +0 -30
  1083. package/dist/src/contracts/Contract.js +0 -90
  1084. package/dist/src/contracts/ContractBase.js +0 -139
  1085. package/dist/src/contracts/ContractFactory.js +0 -17
  1086. package/dist/src/contracts/ContractProvider.js +0 -40
  1087. package/dist/src/contracts/ContractReader.js +0 -76
  1088. package/dist/src/contracts/ContractStream.js +0 -20
  1089. package/dist/src/contracts/ContractWriter.js +0 -62
  1090. package/dist/src/contracts/EthContract.js +0 -31
  1091. package/dist/src/contracts/TxContract.js +0 -37
  1092. package/dist/src/contracts/common/ERC20.js +0 -14
  1093. package/dist/src/contracts/common/ERC20Polygon.js +0 -14
  1094. package/dist/src/contracts/common/PoolPair.js +0 -23
  1095. package/dist/src/contracts/utils/AbiDeserializer.js +0 -89
  1096. package/dist/src/contracts/utils/ConvertUtils.js +0 -21
  1097. package/dist/src/contracts/utils/InputDataUtils.js +0 -87
  1098. package/dist/src/contracts/utils/TypeUtils.js +0 -24
  1099. package/dist/src/defi/OneInch/OneInchRouter.js +0 -14
  1100. package/dist/src/env/BigIntSerializer.js +0 -19
  1101. package/dist/src/gen/Ast.js +0 -12
  1102. package/dist/src/gen/ContractTemplate.js +0 -27
  1103. package/dist/src/gen/Generator.js +0 -180
  1104. package/dist/src/gen/GeneratorFromAbi.js +0 -361
  1105. package/dist/src/handlers/TokenHandler.js +0 -69
  1106. package/dist/src/indexer/BlocksTxIndexer.js +0 -52
  1107. package/dist/src/indexer/PendingTxIndexer.js +0 -96
  1108. package/dist/src/indexer/handlers/BlocksWalker.js +0 -306
  1109. package/dist/src/indexer/handlers/TxQueueLoader.js +0 -117
  1110. package/dist/src/json/JsonArrayStore.js +0 -296
  1111. package/dist/src/json/JsonObjectStore.js +0 -214
  1112. package/dist/src/json/JsonStore.spec.js +0 -83
  1113. package/dist/src/loggers/ILogger.js +0 -2
  1114. package/dist/src/loggers/LoggerService.js +0 -34
  1115. package/dist/src/loggers/TxLoggerService.js +0 -122
  1116. package/dist/src/models/IContractDetails.js +0 -2
  1117. package/dist/src/models/IToken.js +0 -2
  1118. package/dist/src/models/ITokenGlob.js +0 -6
  1119. package/dist/src/models/ITransactionDetails.js +0 -2
  1120. package/dist/src/models/TAddress.js +0 -2
  1121. package/dist/src/models/TBufferLike.js +0 -2
  1122. package/dist/src/models/THex.js +0 -2
  1123. package/dist/src/models/TPlatform.js +0 -2
  1124. package/dist/src/models/TResult.js +0 -2
  1125. package/dist/src/ns/NameService.js +0 -19
  1126. package/dist/src/ns/providers/EnsProvider.js +0 -41
  1127. package/dist/src/ns/providers/INsProvider.js +0 -2
  1128. package/dist/src/ns/providers/UDProvider.js +0 -39
  1129. package/dist/src/ns/utils/$ns.js +0 -17
  1130. package/dist/src/structs/PackedRanges.js +0 -186
  1131. package/dist/src/structs/PackedRanges.spec.js +0 -30
  1132. package/dist/src/tokens/TokenExchangeService.js +0 -110
  1133. package/dist/src/tokens/TokenExchanges/AmmBase/AmmUtilts.js +0 -17
  1134. package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmFactoryV2Contract.js +0 -15
  1135. package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmMasterChefV2Contract.js +0 -15
  1136. package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Contract.js +0 -16
  1137. package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js +0 -144
  1138. package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmRouterV2Contract.js +0 -15
  1139. package/dist/src/tokens/TokenExchanges/AmmBase/V2/AmmVaultV2Contract.js +0 -15
  1140. package/dist/src/tokens/TokenExchanges/AmmBase/V3/AmmPairV3Contract.js +0 -22
  1141. package/dist/src/tokens/TokenExchanges/AmmV2ExchangeBase.js +0 -194
  1142. package/dist/src/tokens/TokenExchanges/OneInchExchange.js +0 -92
  1143. package/dist/src/tokens/TokenExchanges/PancakeswapExchange.js +0 -28
  1144. package/dist/src/tokens/TokenExchanges/SushiswapPolygonExchange.js +0 -28
  1145. package/dist/src/tokens/TokenExchanges/UniswapExchange.js +0 -28
  1146. package/dist/src/tokens/TokenOracles/AmmPriceV2Oracle.js +0 -319
  1147. package/dist/src/tokens/TokenOracles/TokenPriceStore.js +0 -108
  1148. package/dist/src/tokens/TokenPriceService.js +0 -196
  1149. package/dist/src/tokens/TokenPriceServiceProvider.js +0 -31
  1150. package/dist/src/tokens/TokenProviders/ATokenProvider.js +0 -38
  1151. package/dist/src/tokens/TokenProviders/ITokenProvider.js +0 -2
  1152. package/dist/src/tokens/TokenProviders/TPChain.js +0 -35
  1153. package/dist/src/tokens/TokenProviders/TPCoinmarketcap.js +0 -63
  1154. package/dist/src/tokens/TokenProviders/TPOneInch.js +0 -65
  1155. package/dist/src/tokens/TokenProviders/TPSushiswap.js +0 -89
  1156. package/dist/src/tokens/TokenProviders/TPUniswap.js +0 -84
  1157. package/dist/src/tokens/TokenService.js +0 -115
  1158. package/dist/src/tokens/TokenSwapService.js +0 -37
  1159. package/dist/src/tokens/TokenTransferService.js +0 -189
  1160. package/dist/src/tokens/TokensService.js +0 -236
  1161. package/dist/src/tokens/TokensServiceBsc.js +0 -18
  1162. package/dist/src/tokens/TokensServiceEth.js +0 -15
  1163. package/dist/src/tokens/TokensServiceFactory.js +0 -29
  1164. package/dist/src/tokens/TokensServicePolygon.js +0 -18
  1165. package/dist/src/tokens/TokensServiceXDai.js +0 -24
  1166. package/dist/src/tokens/defi/ISwapService.js +0 -2
  1167. package/dist/src/tokens/defi/paraswap/Paraswap.js +0 -135
  1168. package/dist/src/tokens/erc20/eth/WETH.js +0 -14
  1169. package/dist/src/tokens/utils/TokenUtils.js +0 -66
  1170. package/dist/src/txs/ITxConfig.js +0 -2
  1171. package/dist/src/txs/TxDataBuilder.js +0 -159
  1172. package/dist/src/txs/TxLogger.js +0 -119
  1173. package/dist/src/txs/TxProvider.js +0 -73
  1174. package/dist/src/txs/TxService.js +0 -19
  1175. package/dist/src/txs/TxWriter.js +0 -287
  1176. package/dist/src/txs/conditional/GasWatcherLogger.js +0 -61
  1177. package/dist/src/txs/conditional/GasWatcherService.js +0 -103
  1178. package/dist/src/txs/conditional/GasWatcherStore.js +0 -25
  1179. package/dist/src/txs/conditional/GasWatcherTx.js +0 -126
  1180. package/dist/src/txs/receipt/ITxLogItem.js +0 -2
  1181. package/dist/src/txs/receipt/TxLogParser.js +0 -27
  1182. package/dist/src/txs/receipt/TxLogsTransfer.js +0 -50
  1183. package/dist/src/txs/receipt/TxTopicInMemoryProvider.js +0 -41
  1184. package/dist/src/txs/receipt/TxTopicProvider.js +0 -25
  1185. package/dist/src/utils/$abiParser.js +0 -159
  1186. package/dist/src/utils/$abiType.js +0 -77
  1187. package/dist/src/utils/$abiUtils.js +0 -43
  1188. package/dist/src/utils/$address.js +0 -41
  1189. package/dist/src/utils/$array.js +0 -60
  1190. package/dist/src/utils/$bigint.js +0 -130
  1191. package/dist/src/utils/$block.js +0 -10
  1192. package/dist/src/utils/$class.js +0 -13
  1193. package/dist/src/utils/$config.js +0 -18
  1194. package/dist/src/utils/$contract.js +0 -67
  1195. package/dist/src/utils/$csv.js +0 -79
  1196. package/dist/src/utils/$date.js +0 -496
  1197. package/dist/src/utils/$fn.js +0 -117
  1198. package/dist/src/utils/$is.js +0 -40
  1199. package/dist/src/utils/$logger.js +0 -15
  1200. package/dist/src/utils/$number.js +0 -95
  1201. package/dist/src/utils/$object.js +0 -82
  1202. package/dist/src/utils/$path.js +0 -33
  1203. package/dist/src/utils/$promise.js +0 -13
  1204. package/dist/src/utils/$require.js +0 -127
  1205. package/dist/src/utils/$sign.js +0 -35
  1206. package/dist/src/utils/$signSerializer.js +0 -264
  1207. package/dist/src/utils/$wallet.js +0 -13
  1208. package/dist/src/utils/types.js +0 -2
  1209. package/dist/src/wallets/Wallet.js +0 -26
  1210. package/dist/src/wallets/WalletBsc.js +0 -17
  1211. package/dist/src/wallets/WalletService.js +0 -35
  1212. package/dist/src/www/utils/BlockChainExplorerFormatter.js +0 -15
  1213. package/src/BlockchainExplorer/BlockChainExplorerFactory.ts +0 -273
  1214. package/src/BlockchainExplorer/BlockChainExplorerProvider.ts +0 -26
  1215. package/src/BlockchainExplorer/BlockNumberCache.ts +0 -46
  1216. package/src/BlockchainExplorer/Bscscan.ts +0 -23
  1217. package/src/BlockchainExplorer/Etherscan.ts +0 -25
  1218. package/src/BlockchainExplorer/IAbiProvider.ts +0 -5
  1219. package/src/BlockchainExplorer/IBlockChainExplorer.ts +0 -37
  1220. package/src/BlockchainExplorer/Polyscan.ts +0 -23
  1221. package/src/ChainAccounts.ts +0 -72
  1222. package/src/ChainAccountsService.ts +0 -74
  1223. package/src/Config.ts +0 -34
  1224. package/src/bridges/hop/contracts/polygon/Dai_l2AmmWrapperContract.ts +0 -69
  1225. package/src/bridges/hop/contracts/polygon/Dai_l2BridgeContract.ts +0 -453
  1226. package/src/bridges/hop/contracts/polygon/Dai_l2SaddleSwapContract.ts +0 -264
  1227. package/src/bridges/hop/contracts/polygon/Eth_l2AmmWrapperContract.ts +0 -69
  1228. package/src/bridges/hop/contracts/polygon/Eth_l2BridgeContract.ts +0 -453
  1229. package/src/bridges/hop/contracts/polygon/Eth_l2SaddleSwapContract.ts +0 -264
  1230. package/src/bridges/hop/contracts/polygon/Matic_l2AmmWrapperContract.ts +0 -69
  1231. package/src/bridges/hop/contracts/polygon/Matic_l2BridgeContract.ts +0 -453
  1232. package/src/bridges/hop/contracts/polygon/Matic_l2SaddleSwapContract.ts +0 -264
  1233. package/src/bridges/hop/contracts/polygon/Usdc_l2AmmWrapperContract.ts +0 -69
  1234. package/src/bridges/hop/contracts/polygon/Usdc_l2BridgeContract.ts +0 -453
  1235. package/src/bridges/hop/contracts/polygon/Usdc_l2SaddleSwapContract.ts +0 -264
  1236. package/src/bridges/hop/contracts/polygon/Usdt_l2AmmWrapperContract.ts +0 -69
  1237. package/src/bridges/hop/contracts/polygon/Usdt_l2BridgeContract.ts +0 -453
  1238. package/src/bridges/hop/contracts/polygon/Usdt_l2SaddleSwapContract.ts +0 -264
  1239. package/src/bridges/hop/contracts/polygon/Wbtc_l2AmmWrapperContract.ts +0 -69
  1240. package/src/bridges/hop/contracts/polygon/Wbtc_l2BridgeContract.ts +0 -453
  1241. package/src/bridges/hop/contracts/polygon/Wbtc_l2SaddleSwapContract.ts +0 -264
  1242. package/src/bridges/wormhole/contracts/WormholeBridgeContract.ts +0 -14
  1243. package/src/chains/xdai/tokens/WXDaiTokenContract.json +0 -279
  1244. package/src/chains/xdai/tokens/WXDaiTokenContract.ts +0 -14
  1245. package/src/clients/HardhatWeb3Client.ts +0 -60
  1246. package/src/contracts/ContractFactory.ts +0 -19
  1247. package/src/contracts/common/ERC20.ts +0 -13
  1248. package/src/contracts/common/ERC20Polygon.ts +0 -13
  1249. package/src/contracts/common/PoolPair.ts +0 -22
  1250. package/src/defi/OneInch/OneInchRouter.ts +0 -13
  1251. package/src/json/JsonStore.spec.ts +0 -98
  1252. package/src/structs/PackedRanges.spec.ts +0 -38
  1253. package/src/structs/PackedRanges.ts +0 -207
  1254. package/src/tokens/TokenExchanges/AmmBase/V2/AmmFactoryV2Contract.ts +0 -15
  1255. package/src/tokens/TokenExchanges/AmmBase/V2/AmmMasterChefV2Contract.ts +0 -15
  1256. package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Contract.ts +0 -17
  1257. package/src/tokens/TokenExchanges/AmmBase/V2/AmmRouterV2Contract.ts +0 -15
  1258. package/src/tokens/TokenExchanges/AmmBase/V2/AmmVaultV2Contract.ts +0 -15
  1259. package/src/tokens/TokenExchanges/AmmBase/V3/AmmPairV3Contract.ts +0 -24
  1260. package/src/tokens/TokenExchanges/UniswapExchange.ts +0 -31
  1261. package/src/tokens/TokenOracles/AmmPriceV2Oracle.ts +0 -440
  1262. package/src/tokens/erc20/eth/WETH.ts +0 -13
  1263. package/src/txs/ITxConfig.ts +0 -27
  1264. package/src/www/utils/BlockChainExplorerFormatter.ts +0 -13
  1265. package/test/client.spec.ts +0 -59
@@ -0,0 +1,1632 @@
1
+ /**
2
+ * A fragment is a single item from an ABI, which may represent any of:
3
+ *
4
+ * - [Functions](FunctionFragment)
5
+ * - [Events](EventFragment)
6
+ * - [Constructors](ConstructorFragment)
7
+ * - Custom [Errors](ErrorFragment)
8
+ * - [Fallback or Receive](FallbackFragment) functions
9
+ *
10
+ * @_subsection api/abi/abi-coder:Fragments [about-fragments]
11
+ */
12
+
13
+ import { $contract } from '@dequanto/utils/$contract';
14
+ import { $bigint } from '@dequanto/utils/$bigint';
15
+
16
+
17
+ import { $require } from '@dequanto/utils/$require';
18
+
19
+
20
+ /**
21
+ * A Type description in a [JSON ABI format](link-solc-jsonabi).
22
+ */
23
+ export interface JsonFragmentType {
24
+ /**
25
+ * The parameter name.
26
+ */
27
+ readonly name?: string;
28
+
29
+ /**
30
+ * If the parameter is indexed.
31
+ */
32
+ readonly indexed?: boolean;
33
+
34
+ /**
35
+ * The type of the parameter.
36
+ */
37
+ readonly type?: string;
38
+
39
+ /**
40
+ * The internal Solidity type.
41
+ */
42
+ readonly internalType?: string;
43
+
44
+ /**
45
+ * The components for a tuple.
46
+ */
47
+ readonly components?: ReadonlyArray<JsonFragmentType>;
48
+ }
49
+
50
+ /**
51
+ * A fragment for a method, event or error in a [JSON ABI format](link-solc-jsonabi).
52
+ */
53
+ export interface JsonFragment {
54
+ /**
55
+ * The name of the error, event, function, etc.
56
+ */
57
+ readonly name?: string;
58
+
59
+ /**
60
+ * The type of the fragment (e.g. ``event``, ``"function"``, etc.)
61
+ */
62
+ readonly type?: string;
63
+
64
+ /**
65
+ * If the event is anonymous.
66
+ */
67
+ readonly anonymous?: boolean;
68
+
69
+ /**
70
+ * If the function is payable.
71
+ */
72
+ readonly payable?: boolean;
73
+
74
+ /**
75
+ * If the function is constant.
76
+ */
77
+ readonly constant?: boolean;
78
+
79
+ /**
80
+ * The mutability state of the function.
81
+ */
82
+ readonly stateMutability?: string;
83
+
84
+ /**
85
+ * The input parameters.
86
+ */
87
+ readonly inputs?: ReadonlyArray<JsonFragmentType>;
88
+
89
+ /**
90
+ * The output parameters.
91
+ */
92
+ readonly outputs?: ReadonlyArray<JsonFragmentType>;
93
+
94
+ /**
95
+ * The gas limit to use when sending a transaction for this function.
96
+ */
97
+ readonly gas?: string;
98
+ };
99
+
100
+ /**
101
+ * The format to serialize the output as.
102
+ *
103
+ * **``"sighash"``** - the bare formatting, used to compute the selector
104
+ * or topic hash; this format cannot be reversed (as it discards ``indexed``)
105
+ * so cannot by used to export an [[Interface]].
106
+ *
107
+ * **``"minimal"``** - Human-Readable ABI with minimal spacing and without
108
+ * names, so it is compact, but will result in Result objects that cannot
109
+ * be accessed by name.
110
+ *
111
+ * **``"full"``** - Full Human-Readable ABI, with readable spacing and names
112
+ * intact; this is generally the recommended format.
113
+ *
114
+ * **``"json"``** - The [JSON ABI format](link-solc-jsonabi).
115
+ */
116
+ export type FormatType = "sighash" | "minimal" | "full" | "json";
117
+
118
+ // [ "a", "b" ] => { "a": 1, "b": 1 }
119
+ function setify(items: Array<string>): ReadonlySet<string> {
120
+ const result: Set<string> = new Set();
121
+ items.forEach((k) => result.add(k));
122
+ return Object.freeze(result);
123
+ }
124
+
125
+ const _kwVisibDeploy = "external public payable";
126
+ const KwVisibDeploy = setify(_kwVisibDeploy.split(" "));
127
+
128
+ // Visibility Keywords
129
+ const _kwVisib = "constant external internal payable private public pure view";
130
+ const KwVisib = setify(_kwVisib.split(" "));
131
+
132
+ const _kwTypes = "constructor error event fallback function receive struct";
133
+ const KwTypes = setify(_kwTypes.split(" "));
134
+
135
+ const _kwModifiers = "calldata memory storage payable indexed";
136
+ const KwModifiers = setify(_kwModifiers.split(" "));
137
+
138
+ const _kwOther = "tuple returns";
139
+
140
+ // All Keywords
141
+ const _keywords = [ _kwTypes, _kwModifiers, _kwOther, _kwVisib ].join(" ");
142
+ const Keywords = setify(_keywords.split(" "));
143
+
144
+ // Single character tokens
145
+ const SimpleTokens: Record<string, string> = {
146
+ "(": "OPEN_PAREN", ")": "CLOSE_PAREN",
147
+ "[": "OPEN_BRACKET", "]": "CLOSE_BRACKET",
148
+ ",": "COMMA", "@": "AT"
149
+ };
150
+
151
+ // Parser regexes to consume the next token
152
+ const regexWhitespacePrefix = new RegExp("^(\\s*)");
153
+ const regexNumberPrefix = new RegExp("^([0-9]+)");
154
+ const regexIdPrefix = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)");
155
+
156
+ // Parser regexs to check validity
157
+ const regexId = new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$");
158
+ const regexType = new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");
159
+
160
+ /**
161
+ * @ignore:
162
+ */
163
+ type Token = Readonly<{
164
+ // Type of token (e.g. TYPE, KEYWORD, NUMBER, etc)
165
+ type: string;
166
+
167
+ // Offset into the original source code
168
+ offset: number;
169
+
170
+ // Actual text content of the token
171
+ text: string;
172
+
173
+ // The parenthesis depth
174
+ depth: number;
175
+
176
+ // If a parenthesis, the offset (in tokens) that balances it
177
+ match: number;
178
+
179
+ // For parenthesis and commas, the offset (in tokens) to the
180
+ // previous/next parenthesis or comma in the list
181
+ linkBack: number;
182
+ linkNext: number;
183
+
184
+ // If a BRACKET, the value inside
185
+ value: number;
186
+ }>;
187
+
188
+ class TokenString {
189
+ #offset: number;
190
+ #tokens: ReadonlyArray<Token>;
191
+
192
+ get offset(): number { return this.#offset; }
193
+ get length(): number { return this.#tokens.length - this.#offset; }
194
+
195
+ constructor(tokens: ReadonlyArray<Token>) {
196
+ this.#offset = 0;
197
+ this.#tokens = tokens.slice();
198
+ }
199
+
200
+ clone(): TokenString { return new TokenString(this.#tokens); }
201
+ reset(): void { this.#offset = 0; }
202
+
203
+ #subTokenString(from: number = 0, to: number = 0): TokenString {
204
+ return new TokenString(this.#tokens.slice(from, to).map((t) => {
205
+ return Object.freeze(Object.assign({ }, t, {
206
+ match: (t.match - from),
207
+ linkBack: (t.linkBack - from),
208
+ linkNext: (t.linkNext - from),
209
+ }));
210
+ }));
211
+ }
212
+
213
+ // Pops and returns the value of the next token, if it is a keyword in allowed; throws if out of tokens
214
+ popKeyword(allowed: ReadonlySet<string>): string {
215
+ const top = this.peek();
216
+ if (top.type !== "KEYWORD" || !allowed.has(top.text)) { throw new Error(`expected keyword ${ top.text }`); }
217
+ return this.pop().text;
218
+ }
219
+
220
+ // Pops and returns the value of the next token if it is `type`; throws if out of tokens
221
+ popType(type: string): string {
222
+ if (this.peek().type !== type) { throw new Error(`expected ${ type }; got ${ JSON.stringify(this.peek()) }`); }
223
+ return this.pop().text;
224
+ }
225
+
226
+ // Pops and returns a "(" TOKENS ")"
227
+ popParen(): TokenString {
228
+ const top = this.peek();
229
+ if (top.type !== "OPEN_PAREN") { throw new Error("bad start"); }
230
+ const result = this.#subTokenString(this.#offset + 1, top.match + 1);
231
+ this.#offset = top.match + 1;
232
+ return result;
233
+ }
234
+
235
+ // Pops and returns the items within "(" ITEM1 "," ITEM2 "," ... ")"
236
+ popParams(): Array<TokenString> {
237
+ const top = this.peek();
238
+
239
+ if (top.type !== "OPEN_PAREN") { throw new Error("bad start"); }
240
+
241
+ const result: Array<TokenString> = [ ];
242
+
243
+ while(this.#offset < top.match - 1) {
244
+ const link = this.peek().linkNext;
245
+ result.push(this.#subTokenString(this.#offset + 1, link));
246
+ this.#offset = link;
247
+ }
248
+
249
+ this.#offset = top.match + 1;
250
+
251
+ return result;
252
+ }
253
+
254
+ // Returns the top Token, throwing if out of tokens
255
+ peek(): Token {
256
+ if (this.#offset >= this.#tokens.length) {
257
+ throw new Error("out-of-bounds");
258
+ }
259
+ return this.#tokens[this.#offset];
260
+ }
261
+
262
+ // Returns the next value, if it is a keyword in `allowed`
263
+ peekKeyword(allowed: ReadonlySet<string>): null | string {
264
+ const top = this.peekType("KEYWORD");
265
+ return (top != null && allowed.has(top)) ? top: null;
266
+ }
267
+
268
+ // Returns the value of the next token if it is `type`
269
+ peekType(type: string): null | string {
270
+ if (this.length === 0) { return null; }
271
+ const top = this.peek();
272
+ return (top.type === type) ? top.text: null;
273
+ }
274
+
275
+ // Returns the next token; throws if out of tokens
276
+ pop(): Token {
277
+ const result = this.peek();
278
+ this.#offset++;
279
+ return result;
280
+ }
281
+
282
+ toString(): string {
283
+ const tokens: Array<string> = [ ];
284
+ for (let i = this.#offset; i < this.#tokens.length; i++) {
285
+ const token = this.#tokens[i];
286
+ tokens.push(`${ token.type }:${ token.text }`);
287
+ }
288
+ return `<TokenString ${ tokens.join(" ") }>`
289
+ }
290
+ }
291
+
292
+ type Writeable<T> = { -readonly [P in keyof T]: T[P] };
293
+
294
+ function lex(text: string): TokenString {
295
+ const tokens: Array<Token> = [ ];
296
+
297
+ const throwError = (message: string) => {
298
+ const token = (offset < text.length) ? JSON.stringify(text[offset]): "$EOI";
299
+ throw new Error(`invalid token ${ token } at ${ offset }: ${ message }`);
300
+ };
301
+
302
+ let brackets: Array<number> = [ ];
303
+ let commas: Array<number> = [ ];
304
+
305
+ let offset = 0;
306
+ while (offset < text.length) {
307
+
308
+ // Strip off any leading whitespace
309
+ let cur = text.substring(offset);
310
+ let match = cur.match(regexWhitespacePrefix);
311
+ if (match) {
312
+ offset += match[1].length;
313
+ cur = text.substring(offset);
314
+ }
315
+
316
+ const token = { depth: brackets.length, linkBack: -1, linkNext: -1, match: -1, type: "", text: "", offset, value: -1 };
317
+ tokens.push(token);
318
+
319
+ let type = (SimpleTokens[cur[0]] || "");
320
+ if (type) {
321
+ token.type = type;
322
+ token.text = cur[0];
323
+ offset++;
324
+
325
+ if (type === "OPEN_PAREN") {
326
+ brackets.push(tokens.length - 1);
327
+ commas.push(tokens.length - 1);
328
+
329
+ } else if (type == "CLOSE_PAREN") {
330
+ if (brackets.length === 0) { throwError("no matching open bracket"); }
331
+
332
+ token.match = brackets.pop() as number;
333
+ (<Writeable<Token>>(tokens[token.match])).match = tokens.length - 1;
334
+ token.depth--;
335
+
336
+ token.linkBack = commas.pop() as number;
337
+ (<Writeable<Token>>(tokens[token.linkBack])).linkNext = tokens.length - 1;
338
+
339
+ } else if (type === "COMMA") {
340
+ token.linkBack = commas.pop() as number;
341
+ (<Writeable<Token>>(tokens[token.linkBack])).linkNext = tokens.length - 1;
342
+ commas.push(tokens.length - 1);
343
+
344
+ } else if (type === "OPEN_BRACKET") {
345
+ token.type = "BRACKET";
346
+
347
+ } else if (type === "CLOSE_BRACKET") {
348
+ // Remove the CLOSE_BRACKET
349
+ let suffix = (tokens.pop() as Token).text;
350
+ if (tokens.length > 0 && tokens[tokens.length - 1].type === "NUMBER") {
351
+ const value = (tokens.pop() as Token).text;
352
+ suffix = value + suffix;
353
+ (<Writeable<Token>>(tokens[tokens.length - 1])).value = Number(value);
354
+ }
355
+ if (tokens.length === 0 || tokens[tokens.length - 1].type !== "BRACKET") {
356
+ throw new Error("missing opening bracket");
357
+ }
358
+ (<Writeable<Token>>(tokens[tokens.length - 1])).text += suffix;
359
+ }
360
+
361
+ continue;
362
+ }
363
+
364
+ match = cur.match(regexIdPrefix);
365
+ if (match) {
366
+ token.text = match[1];
367
+ offset += token.text.length;
368
+
369
+ if (Keywords.has(token.text)) {
370
+ token.type = "KEYWORD";
371
+ continue;
372
+ }
373
+
374
+ if (token.text.match(regexType)) {
375
+ token.type = "TYPE";
376
+ continue;
377
+ }
378
+
379
+ token.type = "ID";
380
+ continue;
381
+ }
382
+
383
+ match = cur.match(regexNumberPrefix);
384
+ if (match) {
385
+ token.text = match[1];
386
+ token.type = "NUMBER";
387
+ offset += token.text.length;
388
+ continue;
389
+ }
390
+
391
+ throw new Error(`unexpected token ${ JSON.stringify(cur[0]) } at position ${ offset }`);
392
+ }
393
+
394
+ return new TokenString(tokens.map((t) => Object.freeze(t)));
395
+ }
396
+
397
+ // Check only one of `allowed` is in `set`
398
+ function allowSingle(set: ReadonlySet<string>, allowed: ReadonlySet<string>): void {
399
+ let included: Array<string> = [ ];
400
+ for (const key in allowed.keys()) {
401
+ if (set.has(key)) { included.push(key); }
402
+ }
403
+ if (included.length > 1) { throw new Error(`conflicting types: ${ included.join(", ") }`); }
404
+ }
405
+
406
+ // Functions to process a Solidity Signature TokenString from left-to-right for...
407
+
408
+ // ...the name with an optional type, returning the name
409
+ function consumeName(type: string, tokens: TokenString): string {
410
+ if (tokens.peekKeyword(KwTypes)) {
411
+ const keyword = tokens.pop().text;
412
+ if (keyword !== type) {
413
+ throw new Error(`expected ${ type }, got ${ keyword }`);
414
+ }
415
+ }
416
+
417
+ return tokens.popType("ID");
418
+ }
419
+
420
+ // ...all keywords matching allowed, returning the keywords
421
+ function consumeKeywords(tokens: TokenString, allowed?: ReadonlySet<string>): ReadonlySet<string> {
422
+ const keywords: Set<string> = new Set();
423
+ while (true) {
424
+ const keyword = tokens.peekType("KEYWORD");
425
+
426
+ if (keyword == null || (allowed && !allowed.has(keyword))) { break; }
427
+ tokens.pop();
428
+
429
+ if (keywords.has(keyword)) { throw new Error(`duplicate keywords: ${ JSON.stringify(keyword) }`); }
430
+ keywords.add(keyword);
431
+ }
432
+
433
+ return Object.freeze(keywords);
434
+ }
435
+
436
+ // ...all visibility keywords, returning the coalesced mutability
437
+ function consumeMutability(tokens: TokenString): "payable" | "nonpayable" | "view" | "pure" {
438
+ let modifiers = consumeKeywords(tokens, KwVisib);
439
+
440
+ // Detect conflicting modifiers
441
+ allowSingle(modifiers, setify("constant payable nonpayable".split(" ")));
442
+ allowSingle(modifiers, setify("pure view payable nonpayable".split(" ")));
443
+
444
+ // Process mutability states
445
+ if (modifiers.has("view")) { return "view"; }
446
+ if (modifiers.has("pure")) { return "pure"; }
447
+ if (modifiers.has("payable")) { return "payable"; }
448
+ if (modifiers.has("nonpayable")) { return "nonpayable"; }
449
+
450
+ // Process legacy `constant` last
451
+ if (modifiers.has("constant")) { return "view"; }
452
+
453
+ return "nonpayable";
454
+ }
455
+
456
+ // ...a parameter list, returning the ParamType list
457
+ function consumeParams(tokens: TokenString, allowIndexed?: boolean): Array<ParamType> {
458
+ return tokens.popParams().map((t) => ParamType.from(t, allowIndexed));
459
+ }
460
+
461
+ // ...a gas limit, returning a BigNumber or null if none
462
+ function consumeGas(tokens: TokenString): null | bigint {
463
+ if (tokens.peekType("AT")) {
464
+ tokens.pop();
465
+ if (tokens.peekType("NUMBER")) {
466
+ return $bigint.toBigInt(tokens.pop().text);
467
+ }
468
+ throw new Error("invalid gas");
469
+ }
470
+ return null;
471
+ }
472
+
473
+ function consumeEoi(tokens: TokenString): void {
474
+ if (tokens.length) {
475
+ throw new Error(`unexpected tokens: ${ tokens.toString() }`);
476
+ }
477
+ }
478
+
479
+ const regexArrayType = new RegExp(/^(.*)\[([0-9]*)\]$/);
480
+
481
+ function verifyBasicType(type: string): string {
482
+ const match = type.match(regexType);
483
+ $require.notNull(match, `invalid type ${type}`);
484
+ if (type === "uint") { return "uint256"; }
485
+ if (type === "int") { return "int256"; }
486
+
487
+ if (match[2]) {
488
+ // bytesXX
489
+ const length = parseInt(match[2]);
490
+ $require.True(length !== 0 && length <= 32, "invalid bytes length" + type);
491
+
492
+ } else if (match[3]) {
493
+ // intXX or uintXX
494
+ const size = parseInt(match[3] as string);
495
+ $require.True(size !== 0 && size <= 256 && (size % 8) === 0, "invalid numeric width" + type);
496
+ }
497
+
498
+ return type;
499
+ }
500
+
501
+ // Make the Fragment constructors effectively private
502
+ const _guard = { };
503
+
504
+
505
+ /**
506
+ * When [walking](ParamType-walk) a [[ParamType]], this is called
507
+ * on each component.
508
+ */
509
+ export type ParamTypeWalkFunc = (type: string, value: any) => any;
510
+
511
+ /**
512
+ * When [walking asynchronously](ParamType-walkAsync) a [[ParamType]],
513
+ * this is called on each component.
514
+ */
515
+ export type ParamTypeWalkAsyncFunc = (type: string, value: any) => any | Promise<any>;
516
+
517
+ // const internal = Symbol.for("_ethers_internal");
518
+ // const ParamTypeInternal = "_ParamTypeInternal";
519
+ // const ErrorFragmentInternal = "_ErrorInternal";
520
+ // const EventFragmentInternal = "_EventInternal";
521
+ // const ConstructorFragmentInternal = "_ConstructorInternal";
522
+ // const FallbackFragmentInternal = "_FallbackInternal";
523
+ // const FunctionFragmentInternal = "_FunctionInternal";
524
+ // const StructFragmentInternal = "_StructInternal";
525
+
526
+ /**
527
+ * Each input and output of a [[Fragment]] is an Array of **ParamType**.
528
+ */
529
+ export class ParamType {
530
+
531
+ /**
532
+ * The local name of the parameter (or ``""`` if unbound)
533
+ */
534
+ readonly name!: string;
535
+
536
+ /**
537
+ * The fully qualified type (e.g. ``"address"``, ``"tuple(address)"``,
538
+ * ``"uint256[3][]"``)
539
+ */
540
+ readonly type!: string;
541
+
542
+ /**
543
+ * The base type (e.g. ``"address"``, ``"tuple"``, ``"array"``)
544
+ */
545
+ readonly baseType!: string;
546
+
547
+ /**
548
+ * True if the parameters is indexed.
549
+ *
550
+ * For non-indexable types this is ``null``.
551
+ */
552
+ readonly indexed!: null | boolean;
553
+
554
+ /**
555
+ * The components for the tuple.
556
+ *
557
+ * For non-tuple types this is ``null``.
558
+ */
559
+ readonly components?: ReadonlyArray<ParamType>;
560
+
561
+ /**
562
+ * The array length, or ``-1`` for dynamic-lengthed arrays.
563
+ *
564
+ * For non-array types this is ``null``.
565
+ */
566
+ readonly arrayLength?: number;
567
+
568
+ /**
569
+ * The type of each child in the array.
570
+ *
571
+ * For non-array types this is ``null``.
572
+ */
573
+ readonly arrayChildren?: ParamType;
574
+
575
+
576
+ /**
577
+ * @private
578
+ */
579
+ constructor(
580
+ guard: any
581
+ , name: string
582
+ , type: string
583
+ , baseType: string
584
+ , indexed: null | boolean
585
+ , components: null | ReadonlyArray<ParamType>
586
+ , arrayLength: null | number
587
+ , arrayChildren: null | ParamType
588
+ ) {
589
+
590
+ //Object.defineProperty(this, internal, { value: ParamTypeInternal });
591
+
592
+
593
+ components = components?.slice();
594
+
595
+ if (baseType === "array") {
596
+ if (arrayLength == null || arrayChildren == null) {
597
+ throw new Error("");
598
+ }
599
+ } else if (arrayLength != null || arrayChildren != null) {
600
+ throw new Error("");
601
+ }
602
+
603
+ if (baseType === "tuple") {
604
+ if (components == null) { throw new Error(""); }
605
+ } else if (components != null) {
606
+ throw new Error("");
607
+ }
608
+
609
+ this.name = name;
610
+ this.type = type;
611
+ this.baseType = baseType;
612
+ this.indexed = indexed;
613
+ this.components = components;
614
+ this.arrayLength = arrayLength;
615
+ this.arrayChildren = arrayChildren;
616
+ }
617
+
618
+ /**
619
+ * Return a string representation of this type.
620
+ *
621
+ * For example,
622
+ *
623
+ * ``sighash" => "(uint256,address)"``
624
+ *
625
+ * ``"minimal" => "tuple(uint256,address) indexed"``
626
+ *
627
+ * ``"full" => "tuple(uint256 foo, address bar) indexed baz"``
628
+ */
629
+ format(format?: FormatType): string {
630
+ format ??= "sighash";
631
+
632
+ if (format === "json") {
633
+ const name = this.name ?? "";
634
+
635
+ if (this.isArray()) {
636
+ const result = JSON.parse(this.arrayChildren.format("json"));
637
+ result.name = name;
638
+ result.type += `[${ (this.arrayLength < 0 ? "": String(this.arrayLength)) }]`;
639
+ return JSON.stringify(result);
640
+ }
641
+
642
+ const result: any = {
643
+ type: ((this.baseType === "tuple") ? "tuple": this.type),
644
+ name
645
+ };
646
+
647
+
648
+ if (typeof(this.indexed) === "boolean") { result.indexed = this.indexed; }
649
+ if (this.isTuple()) {
650
+ result.components = this.components.map((c) => JSON.parse(c.format(format)));
651
+ }
652
+ return JSON.stringify(result);
653
+ }
654
+
655
+ let result = "";
656
+
657
+ // Array
658
+ if (this.isArray()) {
659
+ result += this.arrayChildren.format(format);
660
+ result += `[${ (this.arrayLength < 0 ? "": String(this.arrayLength)) }]`;
661
+ } else {
662
+ if (this.isTuple()) {
663
+ if (format !== "sighash") { result += this.type; }
664
+ result += "(" + this.components.map(
665
+ (comp) => comp.format(format)
666
+ ).join((format === "full") ? ", ": ",") + ")";
667
+ } else {
668
+ result += this.type;
669
+ }
670
+ }
671
+
672
+ if (format !== "sighash") {
673
+ if (this.indexed === true) { result += " indexed"; }
674
+ if (format === "full" && this.name) {
675
+ result += " " + this.name;
676
+ }
677
+ }
678
+
679
+ return result;
680
+ }
681
+
682
+ /**
683
+ * Returns true if %%this%% is an Array type.
684
+ *
685
+ * This provides a type gaurd ensuring that [[arrayChildren]]
686
+ * and [[arrayLength]] are non-null.
687
+ */
688
+ isArray(): this is (ParamType & { arrayChildren: ParamType, arrayLength: number }) {
689
+ return (this.baseType === "array")
690
+ }
691
+
692
+ /**
693
+ * Returns true if %%this%% is a Tuple type.
694
+ *
695
+ * This provides a type gaurd ensuring that [[components]]
696
+ * is non-null.
697
+ */
698
+ isTuple(): this is (ParamType & { components: ReadonlyArray<ParamType> }) {
699
+ return (this.baseType === "tuple");
700
+ }
701
+
702
+ /**
703
+ * Returns true if %%this%% is an Indexable type.
704
+ *
705
+ * This provides a type gaurd ensuring that [[indexed]]
706
+ * is non-null.
707
+ */
708
+ isIndexable(): this is (ParamType & { indexed: boolean }) {
709
+ return (this.indexed != null);
710
+ }
711
+
712
+ /**
713
+ * Walks the **ParamType** with %%value%%, calling %%process%%
714
+ * on each type, destructing the %%value%% recursively.
715
+ */
716
+ walk(value: any, process: ParamTypeWalkFunc): any {
717
+ if (this.isArray()) {
718
+ if (!Array.isArray(value)) { throw new Error("invalid array value"); }
719
+ if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
720
+ throw new Error("array is wrong length");
721
+ }
722
+ const _this = this;
723
+ return value.map((v) => (_this.arrayChildren.walk(v, process)));
724
+ }
725
+
726
+ if (this.isTuple()) {
727
+ if (!Array.isArray(value)) { throw new Error("invalid tuple value"); }
728
+ if (value.length !== this.components.length) {
729
+ throw new Error("array is wrong length");
730
+ }
731
+ const _this = this;
732
+ return value.map((v, i) => (_this.components[i].walk(v, process)));
733
+ }
734
+
735
+ return process(this.type, value);
736
+ }
737
+
738
+ #walkAsync(promises: Array<Promise<void>>, value: any, process: ParamTypeWalkAsyncFunc, setValue: (value: any) => void): void {
739
+
740
+ if (this.isArray()) {
741
+ if (!Array.isArray(value)) { throw new Error("invalid array value"); }
742
+ if (this.arrayLength !== -1 && value.length !== this.arrayLength) {
743
+ throw new Error("array is wrong length");
744
+ }
745
+ const childType = this.arrayChildren;
746
+
747
+ const result = value.slice();
748
+ result.forEach((value, index) => {
749
+ childType.#walkAsync(promises, value, process, (value: any) => {
750
+ result[index] = value;
751
+ });
752
+ });
753
+ setValue(result);
754
+ return;
755
+ }
756
+
757
+ if (this.isTuple()) {
758
+ const components = this.components;
759
+
760
+ // Convert the object into an array
761
+ let result: Array<any>;
762
+ if (Array.isArray(value)) {
763
+ result = value.slice();
764
+
765
+ } else {
766
+ if (value == null || typeof(value) !== "object") {
767
+ throw new Error("invalid tuple value");
768
+ }
769
+
770
+ result = components.map((param) => {
771
+ if (!param.name) { throw new Error("cannot use object value with unnamed components"); }
772
+ if (!(param.name in value)) {
773
+ throw new Error(`missing value for component ${ param.name }`);
774
+ }
775
+ return value[param.name];
776
+ });
777
+ }
778
+
779
+ if (result.length !== this.components.length) {
780
+ throw new Error("array is wrong length");
781
+ }
782
+
783
+ result.forEach((value, index) => {
784
+ components[index].#walkAsync(promises, value, process, (value: any) => {
785
+ result[index] = value;
786
+ });
787
+ });
788
+ setValue(result);
789
+ return;
790
+ }
791
+
792
+ const result = process(this.type, value);
793
+ if (result.then) {
794
+ promises.push((async function() { setValue(await result); })());
795
+ } else {
796
+ setValue(result);
797
+ }
798
+ }
799
+
800
+ /**
801
+ * Walks the **ParamType** with %%value%%, asynchronously calling
802
+ * %%process%% on each type, destructing the %%value%% recursively.
803
+ *
804
+ * This can be used to resolve ENS naes by walking and resolving each
805
+ * ``"address"`` type.
806
+ */
807
+ async walkAsync(value: any, process: ParamTypeWalkAsyncFunc): Promise<any> {
808
+ const promises: Array<Promise<void>> = [ ];
809
+ const result: [ any ] = [ value ];
810
+ this.#walkAsync(promises, value, process, (value: any) => {
811
+ result[0] = value;
812
+ });
813
+ if (promises.length) { await Promise.all(promises); }
814
+ return result[0];
815
+ }
816
+
817
+ /**
818
+ * Creates a new **ParamType** for %%obj%%.
819
+ *
820
+ * If %%allowIndexed%% then the ``indexed`` keyword is permitted,
821
+ * otherwise the ``indexed`` keyword will throw an error.
822
+ */
823
+ static from(obj: any, allowIndexed?: boolean): ParamType {
824
+ if (ParamType.isParamType(obj)) { return obj; }
825
+
826
+ if (typeof(obj) === "string") {
827
+ try {
828
+ return ParamType.from(lex(obj), allowIndexed);
829
+ } catch (error) {
830
+ throw new Error(`invalid param type: ${ error.message }`);
831
+ }
832
+
833
+ } else if (obj instanceof TokenString) {
834
+ let type = "", baseType = "";
835
+ let comps: null | Array<ParamType> = null;
836
+
837
+ if (consumeKeywords(obj, setify([ "tuple" ])).has("tuple") || obj.peekType("OPEN_PAREN")) {
838
+ // Tuple
839
+ baseType = "tuple";
840
+ comps = obj.popParams().map((t) => ParamType.from(t));
841
+ type = `tuple(${ comps.map((c) => c.format()).join(",") })`;
842
+ } else {
843
+ // Normal
844
+ type = verifyBasicType(obj.popType("TYPE"));
845
+ baseType = type;
846
+ }
847
+
848
+ // Check for Array
849
+ let arrayChildren: null | ParamType = null;
850
+ let arrayLength: null | number = null;
851
+
852
+ while (obj.length && obj.peekType("BRACKET")) {
853
+ const bracket = obj.pop(); //arrays[i];
854
+ arrayChildren = new ParamType(_guard, "", type, baseType, null, comps, arrayLength, arrayChildren);
855
+ arrayLength = bracket.value;
856
+ type += bracket.text;
857
+ baseType = "array";
858
+ comps = null;
859
+ }
860
+
861
+ let indexed: null | boolean = null;
862
+ const keywords = consumeKeywords(obj, KwModifiers);
863
+ if (keywords.has("indexed")) {
864
+ if (!allowIndexed) { throw new Error(""); }
865
+ indexed = true;
866
+ }
867
+
868
+ const name = (obj.peekType("ID") ? obj.pop().text: "");
869
+
870
+ if (obj.length) { throw new Error("leftover tokens"); }
871
+
872
+ return new ParamType(_guard, name, type, baseType, indexed, comps, arrayLength, arrayChildren);
873
+ }
874
+
875
+ const name = obj.name;
876
+ $require.True(!name || (typeof(name) === "string" && regexId.test(name)), "invalid name" + name);
877
+
878
+ let indexed = obj.indexed;
879
+ if (indexed != null) {
880
+ $require.True(allowIndexed ?? true, `parameter cannot be indexed: ${obj.indexed}`);
881
+ indexed = !!indexed;
882
+ }
883
+
884
+ let type = obj.type;
885
+
886
+ let arrayMatch = type.match(regexArrayType);
887
+ if (arrayMatch) {
888
+ const arrayLength = parseInt(arrayMatch[2] || "-1");
889
+ const arrayChildren = ParamType.from({
890
+ type: arrayMatch[1],
891
+ components: obj.components
892
+ });
893
+
894
+ return new ParamType(_guard, name || "", type, "array", indexed, null, arrayLength, arrayChildren);
895
+ }
896
+
897
+ if (type === "tuple" || type.startsWith("tuple("/* fix: ) */) || type.startsWith("(" /* fix: ) */)) {
898
+ const comps = (obj.components != null) ? obj.components.map((c: any) => ParamType.from(c)): null;
899
+ const tuple = new ParamType(_guard, name || "", type, "tuple", indexed, comps, null, null);
900
+ // @TODO: use lexer to validate and normalize type
901
+ return tuple;
902
+ }
903
+
904
+ type = verifyBasicType(obj.type);
905
+
906
+ return new ParamType(_guard, name || "", type, type, indexed, null, null, null);
907
+ }
908
+
909
+ /**
910
+ * Returns true if %%value%% is a **ParamType**.
911
+ */
912
+ static isParamType(value: any): value is ParamType {
913
+ return (value instanceof ParamType)//value[internal] === ParamTypeInternal);
914
+ }
915
+ }
916
+
917
+ /**
918
+ * The type of a [[Fragment]].
919
+ */
920
+ export type FragmentType = "constructor" | "error" | "event" | "fallback" | "function" | "struct";
921
+
922
+ /**
923
+ * An abstract class to represent An individual fragment from a parse ABI.
924
+ */
925
+ export abstract class Fragment {
926
+ /**
927
+ * The type of the fragment.
928
+ */
929
+ readonly type!: FragmentType;
930
+
931
+ /**
932
+ * The inputs for the fragment.
933
+ */
934
+ readonly inputs!: ReadonlyArray<ParamType>;
935
+
936
+ /**
937
+ * @private
938
+ */
939
+ constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>) {
940
+ //assertPrivate(guard, _guard, "Fragment");
941
+ inputs = Object.freeze(inputs.slice());
942
+
943
+ this.type = type;
944
+ this.inputs = inputs;
945
+ }
946
+
947
+ /**
948
+ * Returns a string representation of this fragment as %%format%%.
949
+ */
950
+ abstract format(format?: FormatType): string;
951
+
952
+ /**
953
+ * Creates a new **Fragment** for %%obj%%, wich can be any supported
954
+ * ABI frgament type.
955
+ */
956
+ static from(obj: any): Fragment {
957
+ if (typeof(obj) === "string") {
958
+
959
+ // Try parsing JSON...
960
+ try {
961
+ Fragment.from(JSON.parse(obj));
962
+ } catch (e) { }
963
+
964
+ // ...otherwise, use the human-readable lexer
965
+ return Fragment.from(lex(obj));
966
+ }
967
+
968
+ if (obj instanceof TokenString) {
969
+ // Human-readable ABI (already lexed)
970
+
971
+ const type = obj.peekKeyword(KwTypes);
972
+
973
+ switch (type) {
974
+ case "constructor": return ConstructorFragment.from(obj);
975
+ case "error": return ErrorFragment.from(obj);
976
+ case "event": return EventFragment.from(obj);
977
+ case "fallback": case "receive":
978
+ return FallbackFragment.from(obj);
979
+ case "function": return FunctionFragment.from(obj);
980
+ case "struct": return StructFragment.from(obj);
981
+ }
982
+
983
+ } else if (typeof(obj) === "object") {
984
+ // JSON ABI
985
+
986
+ switch (obj.type) {
987
+ case "constructor": return ConstructorFragment.from(obj);
988
+ case "error": return ErrorFragment.from(obj);
989
+ case "event": return EventFragment.from(obj);
990
+ case "fallback": case "receive":
991
+ return FallbackFragment.from(obj);
992
+ case "function": return FunctionFragment.from(obj);
993
+ case "struct": return StructFragment.from(obj);
994
+ }
995
+
996
+ throw new Error(`UNSUPPORTED_OPERATION: unsupported type: ${ obj.type }`);
997
+ }
998
+ throw new Error("unsupported frgament object: " + JSON.stringify(obj));
999
+ }
1000
+
1001
+ /**
1002
+ * Returns true if %%value%% is a [[ConstructorFragment]].
1003
+ */
1004
+ static isConstructor(value: any): value is ConstructorFragment {
1005
+ return ConstructorFragment.isFragment(value);
1006
+ }
1007
+
1008
+ /**
1009
+ * Returns true if %%value%% is an [[ErrorFragment]].
1010
+ */
1011
+ static isError(value: any): value is ErrorFragment {
1012
+ return ErrorFragment.isFragment(value);
1013
+ }
1014
+
1015
+ /**
1016
+ * Returns true if %%value%% is an [[EventFragment]].
1017
+ */
1018
+ static isEvent(value: any): value is EventFragment {
1019
+ return EventFragment.isFragment(value);
1020
+ }
1021
+
1022
+ /**
1023
+ * Returns true if %%value%% is a [[FunctionFragment]].
1024
+ */
1025
+ static isFunction(value: any): value is FunctionFragment {
1026
+ return FunctionFragment.isFragment(value);
1027
+ }
1028
+
1029
+ /**
1030
+ * Returns true if %%value%% is a [[StructFragment]].
1031
+ */
1032
+ static isStruct(value: any): value is StructFragment {
1033
+ return StructFragment.isFragment(value);
1034
+ }
1035
+ }
1036
+
1037
+ /**
1038
+ * An abstract class to represent An individual fragment
1039
+ * which has a name from a parse ABI.
1040
+ */
1041
+ export abstract class NamedFragment extends Fragment {
1042
+ /**
1043
+ * The name of the fragment.
1044
+ */
1045
+ readonly name!: string;
1046
+
1047
+ /**
1048
+ * @private
1049
+ */
1050
+ constructor(guard: any, type: FragmentType, name: string, inputs: ReadonlyArray<ParamType>) {
1051
+ super(guard, type, inputs);
1052
+ $require.True(typeof(name) === "string" && regexId.test(name), "invalid identifier " + name);
1053
+ //-inputs = Object.freeze(inputs.slice());
1054
+ this.name = name;
1055
+ }
1056
+ }
1057
+
1058
+ function joinParams(format: FormatType, params: ReadonlyArray<ParamType>): string {
1059
+ return "(" + params.map((p) => p.format(format)).join((format === "full") ? ", ": ",") + ")";
1060
+ }
1061
+
1062
+ /**
1063
+ * A Fragment which represents a //Custom Error//.
1064
+ */
1065
+ export class ErrorFragment extends NamedFragment {
1066
+ /**
1067
+ * @private
1068
+ */
1069
+ constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>) {
1070
+ super(guard, "error", name, inputs);
1071
+ //Object.defineProperty(this, internal, { value: ErrorFragmentInternal });
1072
+ }
1073
+
1074
+ /**
1075
+ * The Custom Error selector.
1076
+ */
1077
+ get selector(): string {
1078
+ return $contract.keccak256(this.format("sighash")).substring(0, 10);
1079
+ }
1080
+
1081
+ /**
1082
+ * Returns a string representation of this fragment as %%format%%.
1083
+ */
1084
+ format(format?: FormatType): string {
1085
+ if (format == null) { format = "sighash"; }
1086
+ if (format === "json") {
1087
+ return JSON.stringify({
1088
+ type: "error",
1089
+ name: this.name,
1090
+ inputs: this.inputs.map((input) => JSON.parse(input.format(format))),
1091
+ });
1092
+ }
1093
+
1094
+ const result: Array<string> = [ ];
1095
+ if (format !== "sighash") { result.push("error"); }
1096
+ result.push(this.name + joinParams(format, this.inputs));
1097
+ return result.join(" ");
1098
+ }
1099
+
1100
+ /**
1101
+ * Returns a new **ErrorFragment** for %%obj%%.
1102
+ */
1103
+ static from(obj: any): ErrorFragment {
1104
+ if (ErrorFragment.isFragment(obj)) { return obj; }
1105
+
1106
+ if (typeof(obj) === "string") {
1107
+ return ErrorFragment.from(lex(obj));
1108
+
1109
+ } else if (obj instanceof TokenString) {
1110
+ const name = consumeName("error", obj);
1111
+ const inputs = consumeParams(obj);
1112
+ consumeEoi(obj);
1113
+
1114
+ return new ErrorFragment(_guard, name, inputs);
1115
+ }
1116
+
1117
+ return new ErrorFragment(_guard, obj.name,
1118
+ obj.inputs ? obj.inputs.map(ParamType.from): [ ]);
1119
+ }
1120
+
1121
+ /**
1122
+ * Returns ``true`` and provides a type guard if %%value%% is an
1123
+ * **ErrorFragment**.
1124
+ */
1125
+ static isFragment(value: any): value is ErrorFragment {
1126
+ return (value instanceof ErrorFragment); //[internal] === ErrorFragmentInternal);
1127
+ }
1128
+ }
1129
+
1130
+ /**
1131
+ * A Fragment which represents an Event.
1132
+ */
1133
+ export class EventFragment extends NamedFragment {
1134
+ /**
1135
+ * Whether this event is anonymous.
1136
+ */
1137
+ readonly anonymous!: boolean;
1138
+
1139
+ /**
1140
+ * @private
1141
+ */
1142
+ constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>, anonymous: boolean) {
1143
+ super(guard, "event", name, inputs);
1144
+ //Object.defineProperty(this, internal, { value: EventFragmentInternal });
1145
+ this.anonymous = anonymous;
1146
+ }
1147
+
1148
+ /**
1149
+ * The Event topic hash.
1150
+ */
1151
+ get topicHash(): string {
1152
+ return $contract.keccak256(this.format("sighash"));
1153
+ }
1154
+
1155
+ /**
1156
+ * Returns a string representation of this event as %%format%%.
1157
+ */
1158
+ format(format?: FormatType): string {
1159
+ if (format == null) { format = "sighash"; }
1160
+ if (format === "json") {
1161
+ return JSON.stringify({
1162
+ type: "event",
1163
+ anonymous: this.anonymous,
1164
+ name: this.name,
1165
+ inputs: this.inputs.map((i) => JSON.parse(i.format(format)))
1166
+ });
1167
+ }
1168
+
1169
+ const result: Array<string> = [ ];
1170
+ if (format !== "sighash") { result.push("event"); }
1171
+ result.push(this.name + joinParams(format, this.inputs));
1172
+ if (format !== "sighash" && this.anonymous) { result.push("anonymous"); }
1173
+ return result.join(" ");
1174
+ }
1175
+
1176
+ /**
1177
+ * Return the topic hash for an event with %%name%% and %%params%%.
1178
+ */
1179
+ static getTopicHash(name: string, params?: Array<any>): string {
1180
+ params = (params || []).map((p) => ParamType.from(p));
1181
+ const fragment = new EventFragment(_guard, name, params, false);
1182
+ return fragment.topicHash;
1183
+ }
1184
+
1185
+ /**
1186
+ * Returns a new **EventFragment** for %%obj%%.
1187
+ */
1188
+ static from(obj: any): EventFragment {
1189
+ if (EventFragment.isFragment(obj)) { return obj; }
1190
+
1191
+ if (typeof(obj) === "string") {
1192
+ try {
1193
+ return EventFragment.from(lex(obj));
1194
+ } catch (error) {
1195
+ throw new Error("invalid event fragment: " + JSON.stringify(obj));
1196
+ }
1197
+
1198
+ } else if (obj instanceof TokenString) {
1199
+ const name = consumeName("event", obj);
1200
+ const inputs = consumeParams(obj, true);
1201
+ const anonymous = !!consumeKeywords(obj, setify([ "anonymous" ])).has("anonymous");
1202
+ consumeEoi(obj);
1203
+
1204
+ return new EventFragment(_guard, name, inputs, anonymous);
1205
+ }
1206
+
1207
+ return new EventFragment(_guard, obj.name,
1208
+ obj.inputs ? obj.inputs.map((p: any) => ParamType.from(p, true)): [ ], !!obj.anonymous);
1209
+ }
1210
+
1211
+ /**
1212
+ * Returns ``true`` and provides a type guard if %%value%% is an
1213
+ * **EventFragment**.
1214
+ */
1215
+ static isFragment(value: any): value is EventFragment {
1216
+ return (value instanceof EventFragment); //[internal] === EventFragmentInternal);
1217
+ }
1218
+ }
1219
+
1220
+ /**
1221
+ * A Fragment which represents a constructor.
1222
+ */
1223
+ export class ConstructorFragment extends Fragment {
1224
+
1225
+ /**
1226
+ * Whether the constructor can receive an endowment.
1227
+ */
1228
+ readonly payable!: boolean;
1229
+
1230
+ /**
1231
+ * The recommended gas limit for deployment or ``null``.
1232
+ */
1233
+ readonly gas!: null | bigint;
1234
+
1235
+ /**
1236
+ * @private
1237
+ */
1238
+ constructor(guard: any, type: FragmentType, inputs: ReadonlyArray<ParamType>, payable: boolean, gas: null | bigint) {
1239
+ super(guard, type, inputs);
1240
+ //Object.defineProperty(this, internal, { value: ConstructorFragmentInternal });
1241
+ this.payable = payable;
1242
+ this.gas = gas;
1243
+ }
1244
+
1245
+ /**
1246
+ * Returns a string representation of this constructor as %%format%%.
1247
+ */
1248
+ format(format?: FormatType): string {
1249
+ $require.True(format != null && format !== "sighash", "UNSUPPORTED_OPERATION: cannot format a constructor for sighash");
1250
+
1251
+ if (format === "json") {
1252
+ return JSON.stringify({
1253
+ type: "constructor",
1254
+ stateMutability: (this.payable ? "payable": "undefined"),
1255
+ payable: this.payable,
1256
+ gas: ((this.gas != null) ? this.gas: undefined),
1257
+ inputs: this.inputs.map((i) => JSON.parse(i.format(format)))
1258
+ });
1259
+ }
1260
+
1261
+ const result = [ `constructor${ joinParams(format, this.inputs) }` ];
1262
+ result.push((this.payable) ? "payable": "nonpayable");
1263
+ if (this.gas != null) { result.push(`@${ this.gas.toString() }`); }
1264
+ return result.join(" ");
1265
+ }
1266
+
1267
+ /**
1268
+ * Returns a new **ConstructorFragment** for %%obj%%.
1269
+ */
1270
+ static from(obj: any): ConstructorFragment {
1271
+ if (ConstructorFragment.isFragment(obj)) { return obj; }
1272
+
1273
+ if (typeof(obj) === "string") {
1274
+ try {
1275
+ return ConstructorFragment.from(lex(obj));
1276
+ } catch (error) {
1277
+ throw new Error("invalid constructor fragment: " + JSON.stringify(obj));
1278
+ }
1279
+
1280
+ } else if (obj instanceof TokenString) {
1281
+ consumeKeywords(obj, setify([ "constructor" ]));
1282
+ const inputs = consumeParams(obj);
1283
+ const payable = !!consumeKeywords(obj, KwVisibDeploy).has("payable");
1284
+ const gas = consumeGas(obj);
1285
+ consumeEoi(obj);
1286
+
1287
+ return new ConstructorFragment(_guard, "constructor", inputs, payable, gas);
1288
+ }
1289
+
1290
+ return new ConstructorFragment(_guard, "constructor",
1291
+ obj.inputs ? obj.inputs.map(ParamType.from): [ ],
1292
+ !!obj.payable, (obj.gas != null) ? obj.gas: null);
1293
+ }
1294
+
1295
+ /**
1296
+ * Returns ``true`` and provides a type guard if %%value%% is a
1297
+ * **ConstructorFragment**.
1298
+ */
1299
+ static isFragment(value: any): value is ConstructorFragment {
1300
+ return (value instanceof ConstructorFragment); //[internal] === ConstructorFragmentInternal);
1301
+ }
1302
+ }
1303
+
1304
+ /**
1305
+ * A Fragment which represents a method.
1306
+ */
1307
+ export class FallbackFragment extends Fragment {
1308
+
1309
+ /**
1310
+ * If the function can be sent value during invocation.
1311
+ */
1312
+ readonly payable!: boolean;
1313
+
1314
+ constructor(guard: any, inputs: ReadonlyArray<ParamType>, payable: boolean) {
1315
+ super(guard, "fallback", inputs);
1316
+ //Object.defineProperty(this, internal, { value: FallbackFragmentInternal });
1317
+ this.payable = payable;
1318
+ }
1319
+
1320
+ /**
1321
+ * Returns a string representation of this fallback as %%format%%.
1322
+ */
1323
+ format(format?: FormatType): string {
1324
+ const type = ((this.inputs.length === 0) ? "receive": "fallback");
1325
+
1326
+ if (format === "json") {
1327
+ const stateMutability = (this.payable ? "payable": "nonpayable");
1328
+ return JSON.stringify({ type, stateMutability });
1329
+ }
1330
+
1331
+ return `${ type }()${ this.payable ? " payable": "" }`;
1332
+ }
1333
+
1334
+ /**
1335
+ * Returns a new **FallbackFragment** for %%obj%%.
1336
+ */
1337
+ static from(obj: any): FallbackFragment {
1338
+ if (FallbackFragment.isFragment(obj)) { return obj; }
1339
+
1340
+ if (typeof(obj) === "string") {
1341
+ try {
1342
+ return FallbackFragment.from(lex(obj));
1343
+ } catch (error) {
1344
+ throw new Error("invalid fallback fragment: " + JSON.stringify(obj));
1345
+ }
1346
+
1347
+ } else if (obj instanceof TokenString) {
1348
+ const errorObj = obj.toString();
1349
+
1350
+ const topIsValid = obj.peekKeyword(setify([ "fallback", "receive" ]));
1351
+ $require.notNull(topIsValid, "type must be fallback or receive " + errorObj);
1352
+
1353
+ const type = obj.popKeyword(setify([ "fallback", "receive" ]));
1354
+
1355
+ // receive()
1356
+ if (type === "receive") {
1357
+ const inputs = consumeParams(obj);
1358
+ $require.True(inputs.length === 0, `receive cannot have arguments ` + inputs);
1359
+ consumeKeywords(obj, setify([ "payable" ]));
1360
+ consumeEoi(obj);
1361
+ return new FallbackFragment(_guard, [ ], true);
1362
+ }
1363
+
1364
+ // fallback() [payable]
1365
+ // fallback(bytes) [payable] returns (bytes)
1366
+ let inputs = consumeParams(obj);
1367
+ if (inputs.length) {
1368
+ $require.True(inputs.length === 1 && inputs[0].type === "bytes",
1369
+ "invalid fallback inputs " +
1370
+ inputs.map((i) => i.format("minimal")).join(", "));
1371
+ } else {
1372
+ inputs = [ ParamType.from("bytes") ];
1373
+ }
1374
+
1375
+ const mutability = consumeMutability(obj);
1376
+ $require.True(mutability === "nonpayable" || mutability === "payable", "fallback cannot be constants " + mutability);
1377
+
1378
+ if (consumeKeywords(obj, setify([ "returns" ])).has("returns")) {
1379
+ const outputs = consumeParams(obj);
1380
+ $require.True(outputs.length === 1 && outputs[0].type === "bytes",
1381
+ "invalid fallback outputs " +
1382
+ outputs.map((i) => i.format("minimal")).join(", "));
1383
+ }
1384
+
1385
+ consumeEoi(obj);
1386
+
1387
+ return new FallbackFragment(_guard, inputs, mutability === "payable");
1388
+ }
1389
+
1390
+ if (obj.type === "receive") {
1391
+ return new FallbackFragment(_guard, [ ], true);
1392
+ }
1393
+
1394
+ if (obj.type === "fallback") {
1395
+ const inputs = [ ParamType.from("bytes") ];
1396
+ const payable = (obj.stateMutability === "payable");
1397
+ return new FallbackFragment(_guard, inputs, payable);
1398
+ }
1399
+
1400
+ throw new Error("invalid fallback fragment: " + JSON.stringify(obj));
1401
+ }
1402
+
1403
+ /**
1404
+ * Returns ``true`` and provides a type guard if %%value%% is a
1405
+ * **FallbackFragment**.
1406
+ */
1407
+ static isFragment(value: any): value is FallbackFragment {
1408
+ return (value instanceof FallbackFragment); //[internal] === FallbackFragmentInternal);
1409
+ }
1410
+ }
1411
+
1412
+
1413
+ /**
1414
+ * A Fragment which represents a method.
1415
+ */
1416
+ export class FunctionFragment extends NamedFragment {
1417
+ /**
1418
+ * If the function is constant (e.g. ``pure`` or ``view`` functions).
1419
+ */
1420
+ readonly constant!: boolean;
1421
+
1422
+ /**
1423
+ * The returned types for the result of calling this function.
1424
+ */
1425
+ readonly outputs!: ReadonlyArray<ParamType>;
1426
+
1427
+ /**
1428
+ * The state mutability (e.g. ``payable``, ``nonpayable``, ``view``
1429
+ * or ``pure``)
1430
+ */
1431
+ readonly stateMutability!: "payable" | "nonpayable" | "view" | "pure";
1432
+
1433
+ /**
1434
+ * If the function can be sent value during invocation.
1435
+ */
1436
+ readonly payable!: boolean;
1437
+
1438
+ /**
1439
+ * The recommended gas limit to send when calling this function.
1440
+ */
1441
+ readonly gas!: null | bigint;
1442
+
1443
+ /**
1444
+ * @private
1445
+ */
1446
+ constructor(guard: any, name: string, stateMutability: "payable" | "nonpayable" | "view" | "pure", inputs: ReadonlyArray<ParamType>, outputs: ReadonlyArray<ParamType>, gas: null | bigint) {
1447
+ super(guard, "function", name, inputs);
1448
+ //Object.defineProperty(this, internal, { value: FunctionFragmentInternal });
1449
+ outputs = Object.freeze(outputs.slice());
1450
+ const constant = (stateMutability === "view" || stateMutability === "pure");
1451
+ const payable = (stateMutability === "payable");
1452
+
1453
+ this.constant = constant;
1454
+ this.gas = gas;
1455
+ this.outputs = outputs;
1456
+ this.payable = payable;
1457
+ this.stateMutability = stateMutability;
1458
+ }
1459
+
1460
+ /**
1461
+ * The Function selector.
1462
+ */
1463
+ get selector(): string {
1464
+ return $contract.keccak256(this.format("sighash")).substring(0, 10);
1465
+ }
1466
+
1467
+ /**
1468
+ * Returns a string representation of this function as %%format%%.
1469
+ */
1470
+ format(format?: FormatType): string {
1471
+ if (format == null) { format = "sighash"; }
1472
+ if (format === "json") {
1473
+ return JSON.stringify({
1474
+ type: "function",
1475
+ name: this.name,
1476
+ constant: this.constant,
1477
+ stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability: undefined),
1478
+ payable: this.payable,
1479
+ gas: ((this.gas != null) ? this.gas: undefined),
1480
+ inputs: this.inputs.map((i) => JSON.parse(i.format(format))),
1481
+ outputs: this.outputs.map((o) => JSON.parse(o.format(format))),
1482
+ });
1483
+ }
1484
+
1485
+ const result: Array<string> = [];
1486
+
1487
+ if (format !== "sighash") { result.push("function"); }
1488
+
1489
+ result.push(this.name + joinParams(format, this.inputs));
1490
+
1491
+ if (format !== "sighash") {
1492
+ if (this.stateMutability !== "nonpayable") {
1493
+ result.push(this.stateMutability);
1494
+ }
1495
+
1496
+ if (this.outputs && this.outputs.length) {
1497
+ result.push("returns");
1498
+ result.push(joinParams(format, this.outputs));
1499
+ }
1500
+
1501
+ if (this.gas != null) { result.push(`@${ this.gas.toString() }`); }
1502
+ }
1503
+ return result.join(" ");
1504
+ }
1505
+
1506
+ /**
1507
+ * Return the selector for a function with %%name%% and %%params%%.
1508
+ */
1509
+ static getSelector(name: string, params?: Array<any>): string {
1510
+ params = (params || []).map((p) => ParamType.from(p));
1511
+ const fragment = new FunctionFragment(_guard, name, "view", params, [ ], null);
1512
+ return fragment.selector;
1513
+ }
1514
+
1515
+ /**
1516
+ * Returns a new **FunctionFragment** for %%obj%%.
1517
+ */
1518
+ static from(obj: any): FunctionFragment {
1519
+ if (FunctionFragment.isFragment(obj)) { return obj; }
1520
+
1521
+ if (typeof(obj) === "string") {
1522
+ try {
1523
+ return FunctionFragment.from(lex(obj));
1524
+ } catch (error) {
1525
+ throw new Error("invalid function fragment: " + JSON.stringify(obj));
1526
+ }
1527
+
1528
+ } else if (obj instanceof TokenString) {
1529
+ const name = consumeName("function", obj);
1530
+ const inputs = consumeParams(obj);
1531
+ const mutability = consumeMutability(obj);
1532
+
1533
+ let outputs: Array<ParamType> = [ ];
1534
+ if (consumeKeywords(obj, setify([ "returns" ])).has("returns")) {
1535
+ outputs = consumeParams(obj);
1536
+ }
1537
+
1538
+ const gas = consumeGas(obj);
1539
+
1540
+ consumeEoi(obj);
1541
+
1542
+ return new FunctionFragment(_guard, name, mutability, inputs, outputs, gas);
1543
+ }
1544
+
1545
+ let stateMutability = obj.stateMutability;
1546
+
1547
+ // Use legacy Solidity ABI logic if stateMutability is missing
1548
+ if (stateMutability == null) {
1549
+ stateMutability = "payable";
1550
+
1551
+ if (typeof(obj.constant) === "boolean") {
1552
+ stateMutability = "view";
1553
+ if (!obj.constant) {
1554
+ stateMutability = "payable"
1555
+ if (typeof(obj.payable) === "boolean" && !obj.payable) {
1556
+ stateMutability = "nonpayable";
1557
+ }
1558
+ }
1559
+ } else if (typeof(obj.payable) === "boolean" && !obj.payable) {
1560
+ stateMutability = "nonpayable";
1561
+ }
1562
+ }
1563
+
1564
+ // @TODO: verifyState for stateMutability (e.g. throw if
1565
+ // payable: false but stateMutability is "nonpayable")
1566
+
1567
+ return new FunctionFragment(_guard, obj.name, stateMutability,
1568
+ obj.inputs ? obj.inputs.map(ParamType.from): [ ],
1569
+ obj.outputs ? obj.outputs.map(ParamType.from): [ ],
1570
+ (obj.gas != null) ? obj.gas: null);
1571
+ }
1572
+
1573
+ /**
1574
+ * Returns ``true`` and provides a type guard if %%value%% is a
1575
+ * **FunctionFragment**.
1576
+ */
1577
+ static isFragment(value: any): value is FunctionFragment {
1578
+ return (value instanceof FunctionFragment); //[internal] === FunctionFragmentInternal);
1579
+ }
1580
+ }
1581
+
1582
+ /**
1583
+ * A Fragment which represents a structure.
1584
+ */
1585
+ export class StructFragment extends NamedFragment {
1586
+
1587
+ /**
1588
+ * @private
1589
+ */
1590
+ constructor(guard: any, name: string, inputs: ReadonlyArray<ParamType>) {
1591
+ super(guard, "struct", name, inputs);
1592
+ //Object.defineProperty(this, internal, { value: StructFragmentInternal });
1593
+ }
1594
+
1595
+ /**
1596
+ * Returns a string representation of this struct as %%format%%.
1597
+ */
1598
+ format(): string {
1599
+ throw new Error("@TODO");
1600
+ }
1601
+
1602
+ /**
1603
+ * Returns a new **StructFragment** for %%obj%%.
1604
+ */
1605
+ static from(obj: any): StructFragment {
1606
+ if (typeof(obj) === "string") {
1607
+ try {
1608
+ return StructFragment.from(lex(obj));
1609
+ } catch (error) {
1610
+ throw new Error("invalid struct fragment: " + JSON.stringify(obj));
1611
+ }
1612
+
1613
+ } else if (obj instanceof TokenString) {
1614
+ const name = consumeName("struct", obj);
1615
+ const inputs = consumeParams(obj);
1616
+ consumeEoi(obj);
1617
+ return new StructFragment(_guard, name, inputs);
1618
+ }
1619
+
1620
+ return new StructFragment(_guard, obj.name, obj.inputs ? obj.inputs.map(ParamType.from): [ ]);
1621
+ }
1622
+
1623
+ // @TODO: fix this return type
1624
+ /**
1625
+ * Returns ``true`` and provides a type guard if %%value%% is a
1626
+ * **StructFragment**.
1627
+ */
1628
+ static isFragment(value: any): value is FunctionFragment {
1629
+ return (value instanceof StructFragment) //[internal] === StructFragmentInternal);
1630
+ }
1631
+ }
1632
+