dequanto 0.2.37 → 0.2.40

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 (484) hide show
  1. package/hardhat.config.js +10 -1
  2. package/lib/cjs/abi/$abiCoder.js +1 -1
  3. package/lib/cjs/abi/$abiCoder.js.map +1 -1
  4. package/lib/cjs/abi/Logger.js +1 -1
  5. package/lib/cjs/abi/abi-coder-packed.js +3 -3
  6. package/lib/cjs/abi/abi-coder.js +16 -16
  7. package/lib/cjs/abi/coders/abstract-coder.js +31 -31
  8. package/lib/cjs/abi/coders/abstract-coder.js.map +1 -1
  9. package/lib/cjs/abi/fragments.js +90 -90
  10. package/lib/cjs/abi/fragments.js.map +1 -1
  11. package/lib/cjs/blocks/BlockDateResolver.js +9 -9
  12. package/lib/cjs/blocks/BlockDateResolver.js.map +1 -1
  13. package/lib/cjs/class/PackedRanges.js +46 -46
  14. package/lib/cjs/class/PackedRanges.js.map +1 -1
  15. package/lib/cjs/clients/ClientEventsStream.js +1 -1
  16. package/lib/cjs/clients/ClientEventsStream.js.map +1 -1
  17. package/lib/cjs/clients/ClientPool.js +23 -23
  18. package/lib/cjs/clients/ClientPool.js.map +1 -1
  19. package/lib/cjs/clients/WalletClient.js +3 -3
  20. package/lib/cjs/clients/WalletClient.js.map +1 -1
  21. package/lib/cjs/clients/Web3Client.js +14 -14
  22. package/lib/cjs/clients/Web3Client.js.map +1 -1
  23. package/lib/cjs/clients/Web3ClientFactory.js +1 -1
  24. package/lib/cjs/clients/Web3ClientFactory.js.map +1 -1
  25. package/lib/cjs/clients/compatibility/Web3.js +2 -2
  26. package/lib/cjs/clients/compatibility/Web3.js.map +1 -1
  27. package/lib/cjs/clients/handlers/RateLimitGuard.js +16 -16
  28. package/lib/cjs/clients/handlers/RateLimitGuard.js.map +1 -1
  29. package/lib/cjs/clients/model/PromiEventWrap.js +1 -1
  30. package/lib/cjs/clients/model/PromiEventWrap.js.map +1 -1
  31. package/lib/cjs/clients/utils/$web3Abi.js +2 -2
  32. package/lib/cjs/clients/utils/$web3Abi.js.map +1 -1
  33. package/lib/cjs/clients/utils/ClientErrorUtil.js +4 -0
  34. package/lib/cjs/clients/utils/ClientErrorUtil.js.map +1 -1
  35. package/lib/cjs/config/Config.js.map +1 -1
  36. package/lib/cjs/contracts/Contract.js +1 -1
  37. package/lib/cjs/contracts/Contract.js.map +1 -1
  38. package/lib/cjs/contracts/ContractAbiProvider.js +6 -6
  39. package/lib/cjs/contracts/ContractAbiProvider.js.map +1 -1
  40. package/lib/cjs/contracts/ContractBase.js +10 -10
  41. package/lib/cjs/contracts/ContractBase.js.map +1 -1
  42. package/lib/cjs/contracts/ContractProvider.js +1 -1
  43. package/lib/cjs/contracts/ContractProvider.js.map +1 -1
  44. package/lib/cjs/contracts/ContractReader.js +5 -5
  45. package/lib/cjs/contracts/ContractReader.js.map +1 -1
  46. package/lib/cjs/contracts/ContractWriter.js +4 -4
  47. package/lib/cjs/contracts/ContractWriter.js.map +1 -1
  48. package/lib/cjs/contracts/deploy/ContractDeployer.js +4 -4
  49. package/lib/cjs/contracts/deploy/ContractDeployer.js.map +1 -1
  50. package/lib/cjs/contracts/deploy/Deployments.js +68 -26
  51. package/lib/cjs/contracts/deploy/Deployments.js.map +1 -1
  52. package/lib/cjs/contracts/deploy/proxy/$proxyDeploy.js +13 -13
  53. package/lib/cjs/contracts/deploy/proxy/$proxyDeploy.js.map +1 -1
  54. package/lib/cjs/contracts/deploy/proxy/ProxyDeployment.js +58 -25
  55. package/lib/cjs/contracts/deploy/proxy/ProxyDeployment.js.map +1 -1
  56. package/lib/cjs/contracts/deploy/storage/DeploymentsStorage.js +15 -14
  57. package/lib/cjs/contracts/deploy/storage/DeploymentsStorage.js.map +1 -1
  58. package/lib/cjs/contracts/utils/AbiDeserializer.js +4 -4
  59. package/lib/cjs/contracts/utils/AbiDeserializer.js.map +1 -1
  60. package/lib/cjs/contracts/utils/ContractBaseUtils.js +3 -3
  61. package/lib/cjs/contracts/utils/ContractBaseUtils.js.map +1 -1
  62. package/lib/cjs/evm/OpcodesWalker.js +1 -1
  63. package/lib/cjs/evm/OpcodesWalker.js.map +1 -1
  64. package/lib/cjs/explorer/BlockchainExplorer.js +1 -1
  65. package/lib/cjs/explorer/BlockchainExplorer.js.map +1 -1
  66. package/lib/cjs/explorer/BlockchainExplorerFactory.js +1 -1
  67. package/lib/cjs/explorer/BlockchainExplorerStorage.js +12 -12
  68. package/lib/cjs/explorer/BlockchainExplorerStorage.js.map +1 -1
  69. package/lib/cjs/explorer/Evmscan.js +1 -1
  70. package/lib/cjs/explorer/verifiers/FsHtmlVerifier.js +7 -7
  71. package/lib/cjs/explorer/verifiers/FsHtmlVerifier.js.map +1 -1
  72. package/lib/cjs/flashbots/FlashbotWeb3Client.js +1 -1
  73. package/lib/cjs/flashbots/FlashbotWeb3Client.js.map +1 -1
  74. package/lib/cjs/gen/Generator.js +15 -0
  75. package/lib/cjs/gen/Generator.js.map +1 -1
  76. package/lib/cjs/hardhat/HardhatProvider.js +7 -7
  77. package/lib/cjs/hardhat/HardhatProvider.js.map +1 -1
  78. package/lib/cjs/indexer/BlocksTxIndexer.js +2 -2
  79. package/lib/cjs/indexer/BlocksTxIndexer.js.map +1 -1
  80. package/lib/cjs/indexer/EventsIndexer.js +11 -11
  81. package/lib/cjs/indexer/EventsIndexer.js.map +1 -1
  82. package/lib/cjs/indexer/PendingTxIndexer.js +2 -2
  83. package/lib/cjs/indexer/PendingTxIndexer.js.map +1 -1
  84. package/lib/cjs/indexer/handlers/BlocksWalker.js +9 -9
  85. package/lib/cjs/indexer/handlers/BlocksWalker.js.map +1 -1
  86. package/lib/cjs/indexer/handlers/TxQueueLoader.js +1 -1
  87. package/lib/cjs/indexer/storage/FsEventsIndexerStore.js +3 -3
  88. package/lib/cjs/indexer/storage/FsEventsIndexerStore.js.map +1 -1
  89. package/lib/cjs/indexer/storage/FsEventsStoreUtils.js +1 -1
  90. package/lib/cjs/indexer/storage/FsEventsStoreUtils.js.map +1 -1
  91. package/lib/cjs/json/JsonArrayMultiStore.js +1 -1
  92. package/lib/cjs/json/JsonArrayMultiStore.js.map +1 -1
  93. package/lib/cjs/json/JsonStoreFs.js +1 -1
  94. package/lib/cjs/json/JsonStoreFs.js.map +1 -1
  95. package/lib/cjs/rpc/$rpc.js +2 -2
  96. package/lib/cjs/rpc/$rpc.js.map +1 -1
  97. package/lib/cjs/rpc/Rpc.js +2 -2
  98. package/lib/cjs/rpc/RpcBase.js +2 -2
  99. package/lib/cjs/rpc/RpcBase.js.map +1 -1
  100. package/lib/cjs/rpc/RpcContract.js +4 -3
  101. package/lib/cjs/rpc/RpcContract.js.map +1 -1
  102. package/lib/cjs/rpc/RpcSubscription.js +1 -1
  103. package/lib/cjs/rpc/RpcSubscription.js.map +1 -1
  104. package/lib/cjs/rpc/transports/compatibility/EIP1193Transport.js +4 -4
  105. package/lib/cjs/rpc/transports/compatibility/EIP1193Transport.js.map +1 -1
  106. package/lib/cjs/rpc/transports/compatibility/Web3Transport.js +1 -1
  107. package/lib/cjs/rpc/transports/compatibility/Web3Transport.js.map +1 -1
  108. package/lib/cjs/services/TimelockService/TimelockService.js +2 -2
  109. package/lib/cjs/services/TimelockService/TimelockServiceFallbackSafe.js +2 -2
  110. package/lib/cjs/solidity/SlotsDump.js +1 -1
  111. package/lib/cjs/solidity/SlotsDump.js.map +1 -1
  112. package/lib/cjs/solidity/SlotsParser/MappingSettersResolver.js +3 -3
  113. package/lib/cjs/solidity/SlotsParser/MappingSettersResolver.js.map +1 -1
  114. package/lib/cjs/solidity/SlotsParser/SourceFile.js +3 -3
  115. package/lib/cjs/solidity/SlotsParser/SourceFile.js.map +1 -1
  116. package/lib/cjs/solidity/SolidityParser.js +1 -1
  117. package/lib/cjs/solidity/SolidityParser.js.map +1 -1
  118. package/lib/cjs/solidity/SourceCodeProvider.js +1 -1
  119. package/lib/cjs/solidity/SourceCodeProvider.js.map +1 -1
  120. package/lib/cjs/solidity/storage/Accessor.js +1 -1
  121. package/lib/cjs/solidity/storage/Accessor.js.map +1 -1
  122. package/lib/cjs/solidity/storage/SlotFixedArray.js +1 -1
  123. package/lib/cjs/solidity/storage/SlotFixedArray.js.map +1 -1
  124. package/lib/cjs/solidity/storage/SlotsStorageTransport.js +3 -3
  125. package/lib/cjs/solidity/storage/SlotsStorageTransport.js.map +1 -1
  126. package/lib/cjs/solidity/storage/handlers/SlotBytesHandler.js +1 -1
  127. package/lib/cjs/solidity/storage/handlers/SlotBytesHandler.js.map +1 -1
  128. package/lib/cjs/solidity/storage/handlers/SlotDynamicArrayHandler.js +1 -1
  129. package/lib/cjs/solidity/storage/handlers/SlotDynamicArrayHandler.js.map +1 -1
  130. package/lib/cjs/solidity/storage/handlers/SlotFixedArrayHandler.js +1 -1
  131. package/lib/cjs/solidity/storage/handlers/SlotFixedArrayHandler.js.map +1 -1
  132. package/lib/cjs/solidity/storage/handlers/SlotValueConstantHandler.js +1 -1
  133. package/lib/cjs/solidity/storage/handlers/SlotValueConstantHandler.js.map +1 -1
  134. package/lib/cjs/solidity/storage/handlers/SlotValueHandler.js +1 -1
  135. package/lib/cjs/solidity/storage/handlers/SlotValueHandler.js.map +1 -1
  136. package/lib/cjs/solidity/storage/handlers/SlotValueImmutableHandler.js +4 -4
  137. package/lib/cjs/solidity/storage/handlers/SlotValueImmutableHandler.js.map +1 -1
  138. package/lib/cjs/tokens/TokenDataProvider.js +2 -2
  139. package/lib/cjs/tokens/TokenDataProvider.js.map +1 -1
  140. package/lib/cjs/tokens/TokenExchangeService.js +1 -1
  141. package/lib/cjs/tokens/TokenExchangeService.js.map +1 -1
  142. package/lib/cjs/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js +2 -2
  143. package/lib/cjs/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js.map +1 -1
  144. package/lib/cjs/tokens/TokenExchanges/AmmV2PriceQuote.js +2 -2
  145. package/lib/cjs/tokens/TokenExchanges/AmmV2PriceQuote.js.map +1 -1
  146. package/lib/cjs/tokens/TokenOracles/amm/AmmV1Oracle.js +2 -2
  147. package/lib/cjs/tokens/TokenOracles/amm/AmmV1Oracle.js.map +1 -1
  148. package/lib/cjs/tokens/TokenTransferService.js +2 -2
  149. package/lib/cjs/tokens/TokenTransferService.js.map +1 -1
  150. package/lib/cjs/tokens/TokensService.js +1 -1
  151. package/lib/cjs/tokens/TokensService.js.map +1 -1
  152. package/lib/cjs/txs/TxNonceManager.js +1 -1
  153. package/lib/cjs/txs/TxWriter.js +9 -0
  154. package/lib/cjs/txs/TxWriter.js.map +1 -1
  155. package/lib/cjs/txs/conditional/GasWatcherTx.js +1 -1
  156. package/lib/cjs/txs/conditional/GasWatcherTx.js.map +1 -1
  157. package/lib/cjs/txs/receipt/TxLogParser.js +1 -1
  158. package/lib/cjs/utils/$crypto.js +1 -1
  159. package/lib/cjs/utils/$crypto.js.map +1 -1
  160. package/lib/cjs/utils/$date.js +1 -1
  161. package/lib/cjs/utils/$date.js.map +1 -1
  162. package/lib/cjs/utils/$hex.js +1 -1
  163. package/lib/cjs/utils/$logger.js +1 -1
  164. package/lib/cjs/utils/$logger.js.map +1 -1
  165. package/lib/cjs/utils/$machine.js +2 -2
  166. package/lib/cjs/utils/$machine.js.map +1 -1
  167. package/lib/cjs/utils/$traces.js +1 -1
  168. package/lib/cjs/utils/$traces.js.map +1 -1
  169. package/lib/esm/abi/$abiCoder.js.map +1 -1
  170. package/lib/esm/abi/$abiCoder.mjs +1 -1
  171. package/lib/esm/abi/Logger.mjs +1 -1
  172. package/lib/esm/abi/abi-coder-packed.mjs +3 -3
  173. package/lib/esm/abi/abi-coder.mjs +16 -16
  174. package/lib/esm/abi/coders/abstract-coder.js.map +1 -1
  175. package/lib/esm/abi/coders/abstract-coder.mjs +31 -31
  176. package/lib/esm/abi/fragments.js.map +1 -1
  177. package/lib/esm/abi/fragments.mjs +90 -90
  178. package/lib/esm/blocks/BlockDateResolver.js.map +1 -1
  179. package/lib/esm/blocks/BlockDateResolver.mjs +9 -9
  180. package/lib/esm/class/PackedRanges.js.map +1 -1
  181. package/lib/esm/class/PackedRanges.mjs +46 -46
  182. package/lib/esm/clients/ClientEventsStream.js.map +1 -1
  183. package/lib/esm/clients/ClientEventsStream.mjs +1 -1
  184. package/lib/esm/clients/ClientPool.js.map +1 -1
  185. package/lib/esm/clients/ClientPool.mjs +23 -23
  186. package/lib/esm/clients/WalletClient.js.map +1 -1
  187. package/lib/esm/clients/WalletClient.mjs +3 -3
  188. package/lib/esm/clients/Web3Client.js.map +1 -1
  189. package/lib/esm/clients/Web3Client.mjs +14 -14
  190. package/lib/esm/clients/Web3ClientFactory.js.map +1 -1
  191. package/lib/esm/clients/Web3ClientFactory.mjs +1 -1
  192. package/lib/esm/clients/compatibility/Web3.js.map +1 -1
  193. package/lib/esm/clients/compatibility/Web3.mjs +2 -2
  194. package/lib/esm/clients/handlers/RateLimitGuard.js.map +1 -1
  195. package/lib/esm/clients/handlers/RateLimitGuard.mjs +16 -16
  196. package/lib/esm/clients/model/PromiEventWrap.js.map +1 -1
  197. package/lib/esm/clients/model/PromiEventWrap.mjs +1 -1
  198. package/lib/esm/clients/utils/$web3Abi.js.map +1 -1
  199. package/lib/esm/clients/utils/$web3Abi.mjs +2 -2
  200. package/lib/esm/clients/utils/ClientErrorUtil.js.map +1 -1
  201. package/lib/esm/clients/utils/ClientErrorUtil.mjs +4 -0
  202. package/lib/esm/config/Config.js.map +1 -1
  203. package/lib/esm/contracts/Contract.js.map +1 -1
  204. package/lib/esm/contracts/Contract.mjs +1 -1
  205. package/lib/esm/contracts/ContractAbiProvider.js.map +1 -1
  206. package/lib/esm/contracts/ContractAbiProvider.mjs +6 -6
  207. package/lib/esm/contracts/ContractBase.js.map +1 -1
  208. package/lib/esm/contracts/ContractBase.mjs +10 -10
  209. package/lib/esm/contracts/ContractProvider.js.map +1 -1
  210. package/lib/esm/contracts/ContractProvider.mjs +1 -1
  211. package/lib/esm/contracts/ContractReader.js.map +1 -1
  212. package/lib/esm/contracts/ContractReader.mjs +5 -5
  213. package/lib/esm/contracts/ContractWriter.js.map +1 -1
  214. package/lib/esm/contracts/ContractWriter.mjs +4 -4
  215. package/lib/esm/contracts/deploy/ContractDeployer.js.map +1 -1
  216. package/lib/esm/contracts/deploy/ContractDeployer.mjs +4 -4
  217. package/lib/esm/contracts/deploy/Deployments.js.map +1 -1
  218. package/lib/esm/contracts/deploy/Deployments.mjs +68 -26
  219. package/lib/esm/contracts/deploy/proxy/$proxyDeploy.js.map +1 -1
  220. package/lib/esm/contracts/deploy/proxy/$proxyDeploy.mjs +13 -13
  221. package/lib/esm/contracts/deploy/proxy/ProxyDeployment.js.map +1 -1
  222. package/lib/esm/contracts/deploy/proxy/ProxyDeployment.mjs +58 -25
  223. package/lib/esm/contracts/deploy/storage/DeploymentsStorage.js.map +1 -1
  224. package/lib/esm/contracts/deploy/storage/DeploymentsStorage.mjs +15 -14
  225. package/lib/esm/contracts/utils/AbiDeserializer.js.map +1 -1
  226. package/lib/esm/contracts/utils/AbiDeserializer.mjs +4 -4
  227. package/lib/esm/contracts/utils/ContractBaseUtils.js.map +1 -1
  228. package/lib/esm/contracts/utils/ContractBaseUtils.mjs +3 -3
  229. package/lib/esm/evm/OpcodesWalker.js.map +1 -1
  230. package/lib/esm/evm/OpcodesWalker.mjs +1 -1
  231. package/lib/esm/explorer/BlockchainExplorer.js.map +1 -1
  232. package/lib/esm/explorer/BlockchainExplorer.mjs +1 -1
  233. package/lib/esm/explorer/BlockchainExplorerFactory.mjs +1 -1
  234. package/lib/esm/explorer/BlockchainExplorerStorage.js.map +1 -1
  235. package/lib/esm/explorer/BlockchainExplorerStorage.mjs +12 -12
  236. package/lib/esm/explorer/Evmscan.mjs +1 -1
  237. package/lib/esm/explorer/verifiers/FsHtmlVerifier.js.map +1 -1
  238. package/lib/esm/explorer/verifiers/FsHtmlVerifier.mjs +7 -7
  239. package/lib/esm/flashbots/FlashbotWeb3Client.js.map +1 -1
  240. package/lib/esm/flashbots/FlashbotWeb3Client.mjs +1 -1
  241. package/lib/esm/gen/Generator.js.map +1 -1
  242. package/lib/esm/gen/Generator.mjs +15 -0
  243. package/lib/esm/hardhat/HardhatProvider.js.map +1 -1
  244. package/lib/esm/hardhat/HardhatProvider.mjs +7 -7
  245. package/lib/esm/indexer/BlocksTxIndexer.js.map +1 -1
  246. package/lib/esm/indexer/BlocksTxIndexer.mjs +2 -2
  247. package/lib/esm/indexer/EventsIndexer.js.map +1 -1
  248. package/lib/esm/indexer/EventsIndexer.mjs +11 -11
  249. package/lib/esm/indexer/PendingTxIndexer.js.map +1 -1
  250. package/lib/esm/indexer/PendingTxIndexer.mjs +2 -2
  251. package/lib/esm/indexer/handlers/BlocksWalker.js.map +1 -1
  252. package/lib/esm/indexer/handlers/BlocksWalker.mjs +9 -9
  253. package/lib/esm/indexer/handlers/TxQueueLoader.mjs +1 -1
  254. package/lib/esm/indexer/storage/FsEventsIndexerStore.js.map +1 -1
  255. package/lib/esm/indexer/storage/FsEventsIndexerStore.mjs +3 -3
  256. package/lib/esm/indexer/storage/FsEventsStoreUtils.js.map +1 -1
  257. package/lib/esm/indexer/storage/FsEventsStoreUtils.mjs +1 -1
  258. package/lib/esm/json/JsonArrayMultiStore.js.map +1 -1
  259. package/lib/esm/json/JsonArrayMultiStore.mjs +1 -1
  260. package/lib/esm/json/JsonStoreFs.js.map +1 -1
  261. package/lib/esm/json/JsonStoreFs.mjs +1 -1
  262. package/lib/esm/rpc/$rpc.js.map +1 -1
  263. package/lib/esm/rpc/$rpc.mjs +2 -2
  264. package/lib/esm/rpc/Rpc.mjs +2 -2
  265. package/lib/esm/rpc/RpcBase.js.map +1 -1
  266. package/lib/esm/rpc/RpcBase.mjs +2 -2
  267. package/lib/esm/rpc/RpcContract.js.map +1 -1
  268. package/lib/esm/rpc/RpcContract.mjs +4 -3
  269. package/lib/esm/rpc/RpcSubscription.js.map +1 -1
  270. package/lib/esm/rpc/RpcSubscription.mjs +1 -1
  271. package/lib/esm/rpc/transports/compatibility/EIP1193Transport.js.map +1 -1
  272. package/lib/esm/rpc/transports/compatibility/EIP1193Transport.mjs +4 -4
  273. package/lib/esm/rpc/transports/compatibility/Web3Transport.js.map +1 -1
  274. package/lib/esm/rpc/transports/compatibility/Web3Transport.mjs +1 -1
  275. package/lib/esm/services/TimelockService/TimelockService.mjs +2 -2
  276. package/lib/esm/services/TimelockService/TimelockServiceFallbackSafe.mjs +2 -2
  277. package/lib/esm/solidity/SlotsDump.js.map +1 -1
  278. package/lib/esm/solidity/SlotsDump.mjs +1 -1
  279. package/lib/esm/solidity/SlotsParser/MappingSettersResolver.js.map +1 -1
  280. package/lib/esm/solidity/SlotsParser/MappingSettersResolver.mjs +3 -3
  281. package/lib/esm/solidity/SlotsParser/SourceFile.js.map +1 -1
  282. package/lib/esm/solidity/SlotsParser/SourceFile.mjs +3 -3
  283. package/lib/esm/solidity/SolidityParser.js.map +1 -1
  284. package/lib/esm/solidity/SolidityParser.mjs +1 -1
  285. package/lib/esm/solidity/SourceCodeProvider.js.map +1 -1
  286. package/lib/esm/solidity/SourceCodeProvider.mjs +1 -1
  287. package/lib/esm/solidity/storage/Accessor.js.map +1 -1
  288. package/lib/esm/solidity/storage/Accessor.mjs +1 -1
  289. package/lib/esm/solidity/storage/SlotFixedArray.js.map +1 -1
  290. package/lib/esm/solidity/storage/SlotFixedArray.mjs +1 -1
  291. package/lib/esm/solidity/storage/SlotsStorageTransport.js.map +1 -1
  292. package/lib/esm/solidity/storage/SlotsStorageTransport.mjs +3 -3
  293. package/lib/esm/solidity/storage/handlers/SlotBytesHandler.js.map +1 -1
  294. package/lib/esm/solidity/storage/handlers/SlotBytesHandler.mjs +1 -1
  295. package/lib/esm/solidity/storage/handlers/SlotDynamicArrayHandler.js.map +1 -1
  296. package/lib/esm/solidity/storage/handlers/SlotDynamicArrayHandler.mjs +1 -1
  297. package/lib/esm/solidity/storage/handlers/SlotFixedArrayHandler.js.map +1 -1
  298. package/lib/esm/solidity/storage/handlers/SlotFixedArrayHandler.mjs +1 -1
  299. package/lib/esm/solidity/storage/handlers/SlotValueConstantHandler.js.map +1 -1
  300. package/lib/esm/solidity/storage/handlers/SlotValueConstantHandler.mjs +1 -1
  301. package/lib/esm/solidity/storage/handlers/SlotValueHandler.js.map +1 -1
  302. package/lib/esm/solidity/storage/handlers/SlotValueHandler.mjs +1 -1
  303. package/lib/esm/solidity/storage/handlers/SlotValueImmutableHandler.js.map +1 -1
  304. package/lib/esm/solidity/storage/handlers/SlotValueImmutableHandler.mjs +4 -4
  305. package/lib/esm/tokens/TokenDataProvider.js.map +1 -1
  306. package/lib/esm/tokens/TokenDataProvider.mjs +2 -2
  307. package/lib/esm/tokens/TokenExchangeService.js.map +1 -1
  308. package/lib/esm/tokens/TokenExchangeService.mjs +1 -1
  309. package/lib/esm/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.js.map +1 -1
  310. package/lib/esm/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.mjs +2 -2
  311. package/lib/esm/tokens/TokenExchanges/AmmV2PriceQuote.js.map +1 -1
  312. package/lib/esm/tokens/TokenExchanges/AmmV2PriceQuote.mjs +2 -2
  313. package/lib/esm/tokens/TokenOracles/amm/AmmV1Oracle.js.map +1 -1
  314. package/lib/esm/tokens/TokenOracles/amm/AmmV1Oracle.mjs +2 -2
  315. package/lib/esm/tokens/TokenTransferService.js.map +1 -1
  316. package/lib/esm/tokens/TokenTransferService.mjs +2 -2
  317. package/lib/esm/tokens/TokensService.js.map +1 -1
  318. package/lib/esm/tokens/TokensService.mjs +1 -1
  319. package/lib/esm/txs/TxNonceManager.mjs +1 -1
  320. package/lib/esm/txs/TxWriter.js.map +1 -1
  321. package/lib/esm/txs/TxWriter.mjs +9 -0
  322. package/lib/esm/txs/conditional/GasWatcherTx.js.map +1 -1
  323. package/lib/esm/txs/conditional/GasWatcherTx.mjs +1 -1
  324. package/lib/esm/txs/receipt/TxLogParser.mjs +1 -1
  325. package/lib/esm/utils/$crypto.js.map +1 -1
  326. package/lib/esm/utils/$crypto.mjs +1 -1
  327. package/lib/esm/utils/$date.js.map +1 -1
  328. package/lib/esm/utils/$date.mjs +1 -1
  329. package/lib/esm/utils/$hex.mjs +1 -1
  330. package/lib/esm/utils/$logger.js.map +1 -1
  331. package/lib/esm/utils/$logger.mjs +1 -1
  332. package/lib/esm/utils/$machine.js.map +1 -1
  333. package/lib/esm/utils/$machine.mjs +2 -2
  334. package/lib/esm/utils/$traces.js.map +1 -1
  335. package/lib/esm/utils/$traces.mjs +1 -1
  336. package/lib/types/abi/abi-coder-packed.d.ts +1 -1
  337. package/lib/types/abi/abi-coder.d.ts +13 -13
  338. package/lib/types/abi/coders/abstract-coder.d.ts +14 -14
  339. package/lib/types/abi/fragments.d.ts +95 -95
  340. package/lib/types/blocks/BlockDateResolver.d.ts +7 -7
  341. package/lib/types/class/PackedRanges.d.ts +44 -44
  342. package/lib/types/clients/ClientPool.d.ts +10 -10
  343. package/lib/types/clients/WalletClient.d.ts +2 -2
  344. package/lib/types/clients/Web3Client.d.ts +6 -6
  345. package/lib/types/clients/Web3ClientFactory.d.ts +1 -1
  346. package/lib/types/clients/handlers/RateLimitGuard.d.ts +5 -5
  347. package/lib/types/clients/model/PromiEventWrap.d.ts +1 -1
  348. package/lib/types/clients/utils/$web3Abi.d.ts +1 -1
  349. package/lib/types/clients/utils/ClientErrorUtil.d.ts +1 -0
  350. package/lib/types/config/Config.d.ts +3 -2
  351. package/lib/types/contracts/ContractBase.d.ts +4 -4
  352. package/lib/types/contracts/ContractReader.d.ts +2 -2
  353. package/lib/types/contracts/ContractWriter.d.ts +3 -3
  354. package/lib/types/contracts/deploy/Deployments.d.ts +20 -15
  355. package/lib/types/contracts/deploy/proxy/ProxyDeployment.d.ts +2 -0
  356. package/lib/types/contracts/deploy/storage/DeploymentsStorage.d.ts +2 -0
  357. package/lib/types/explorer/BlockchainExplorerFactory.d.ts +1 -1
  358. package/lib/types/explorer/Evmscan.d.ts +1 -1
  359. package/lib/types/gen/Generator.d.ts +8 -0
  360. package/lib/types/indexer/BlocksTxIndexer.d.ts +4 -4
  361. package/lib/types/indexer/EventsIndexer.d.ts +4 -4
  362. package/lib/types/indexer/PendingTxIndexer.d.ts +1 -1
  363. package/lib/types/indexer/handlers/BlocksWalker.d.ts +2 -2
  364. package/lib/types/indexer/storage/FsEventsIndexerStore.d.ts +4 -4
  365. package/lib/types/ns/providers/INsProvider.d.ts +1 -1
  366. package/lib/types/rpc/Rpc.d.ts +2 -2
  367. package/lib/types/services/TimelockService/ITimelockService.d.ts +2 -2
  368. package/lib/types/services/TimelockService/TimelockService.d.ts +2 -2
  369. package/lib/types/services/TimelockService/TimelockServiceFallbackSafe.d.ts +2 -2
  370. package/lib/types/solidity/SlotsParser/SourceFile.d.ts +1 -1
  371. package/lib/types/solidity/storage/SlotFixedArray.d.ts +1 -1
  372. package/lib/types/tokens/TokenDataProvider.d.ts +2 -2
  373. package/lib/types/tokens/TokensService.d.ts +1 -1
  374. package/lib/types/txs/ITxBuilderOptions.d.ts +1 -1
  375. package/lib/types/txs/TxNonceManager.d.ts +1 -1
  376. package/lib/types/txs/TxWriter.d.ts +4 -4
  377. package/lib/types/txs/receipt/TxLogParser.d.ts +1 -1
  378. package/lib/types/utils/$date.d.ts +1 -1
  379. package/lib/types/utils/$hex.d.ts +1 -1
  380. package/package.json +1 -1
  381. package/readme.md +105 -83
  382. package/src/abi/$abiCoder.ts +1 -1
  383. package/src/abi/Logger.ts +1 -1
  384. package/src/abi/abi-coder-packed.ts +3 -3
  385. package/src/abi/abi-coder.ts +16 -16
  386. package/src/abi/coders/abstract-coder.ts +36 -36
  387. package/src/abi/fragments.ts +137 -137
  388. package/src/blocks/BlockDateResolver.ts +9 -9
  389. package/src/bridges/hop/HopBridge.ts +1 -1
  390. package/src/class/PackedRanges.ts +46 -46
  391. package/src/clients/ClientEventsStream.ts +1 -1
  392. package/src/clients/ClientPool.ts +38 -38
  393. package/src/clients/WalletClient.ts +3 -3
  394. package/src/clients/Web3BatchRequests.ts +3 -3
  395. package/src/clients/Web3Client.ts +21 -21
  396. package/src/clients/Web3ClientFactory.ts +1 -1
  397. package/src/clients/compatibility/Web3.ts +2 -2
  398. package/src/clients/handlers/RateLimitGuard.ts +16 -16
  399. package/src/clients/interfaces/IWeb3Client.ts +2 -2
  400. package/src/clients/model/PromiEventWrap.ts +1 -1
  401. package/src/clients/utils/$web3Abi.ts +2 -2
  402. package/src/clients/utils/ClientErrorUtil.ts +4 -0
  403. package/src/config/Config.ts +4 -3
  404. package/src/contracts/Contract.ts +1 -1
  405. package/src/contracts/ContractAbiProvider.ts +6 -6
  406. package/src/contracts/ContractBase.ts +14 -14
  407. package/src/contracts/ContractProvider.ts +1 -1
  408. package/src/contracts/ContractReader.ts +7 -7
  409. package/src/contracts/ContractWriter.ts +4 -4
  410. package/src/contracts/deploy/ContractDeployer.ts +4 -4
  411. package/src/contracts/deploy/ContractDeployment.ts +1 -1
  412. package/src/contracts/deploy/Deployments.ts +110 -53
  413. package/src/contracts/deploy/proxy/$proxyDeploy.ts +14 -14
  414. package/src/contracts/deploy/proxy/ProxyDeployment.ts +82 -37
  415. package/src/contracts/deploy/storage/DeploymentsStorage.ts +21 -18
  416. package/src/contracts/utils/AbiDeserializer.ts +4 -4
  417. package/src/contracts/utils/ContractBaseUtils.ts +3 -3
  418. package/src/erc4337/models/UserOperation.ts +2 -2
  419. package/src/evm/OpcodesWalker.ts +1 -1
  420. package/src/explorer/BlockchainExplorer.ts +1 -1
  421. package/src/explorer/BlockchainExplorerFactory.ts +1 -1
  422. package/src/explorer/BlockchainExplorerStorage.ts +12 -12
  423. package/src/explorer/Evmscan.ts +1 -1
  424. package/src/explorer/verifiers/FsHtmlVerifier.ts +7 -7
  425. package/src/flashbots/FlashbotWeb3Client.ts +1 -1
  426. package/src/gen/Generator.ts +17 -0
  427. package/src/hardhat/HardhatProvider.ts +7 -7
  428. package/src/indexer/BlocksTxIndexer.ts +6 -6
  429. package/src/indexer/EventsIndexer.ts +20 -20
  430. package/src/indexer/PendingTxIndexer.ts +3 -3
  431. package/src/indexer/handlers/BlocksWalker.ts +9 -9
  432. package/src/indexer/handlers/TxQueueLoader.ts +1 -1
  433. package/src/indexer/storage/FsEventsIndexerStore.ts +9 -9
  434. package/src/indexer/storage/FsEventsMetaStore.ts +1 -1
  435. package/src/indexer/storage/FsEventsStoreUtils.ts +1 -1
  436. package/src/json/JsonArrayMultiStore.ts +1 -1
  437. package/src/json/JsonStoreFs.ts +1 -1
  438. package/src/ns/providers/INsProvider.ts +1 -1
  439. package/src/rpc/$rpc.ts +2 -2
  440. package/src/rpc/Rpc.ts +2 -2
  441. package/src/rpc/RpcBase.ts +2 -2
  442. package/src/rpc/RpcContract.ts +6 -6
  443. package/src/rpc/RpcSubscription.ts +1 -1
  444. package/src/rpc/transports/compatibility/EIP1193Transport.ts +4 -4
  445. package/src/rpc/transports/compatibility/Web3Transport.ts +1 -1
  446. package/src/services/TimelockService/ITimelockService.ts +2 -2
  447. package/src/services/TimelockService/TimelockService.ts +2 -2
  448. package/src/services/TimelockService/TimelockServiceFallbackSafe.ts +2 -2
  449. package/src/solidity/SlotsDump.ts +1 -1
  450. package/src/solidity/SlotsParser/MappingSettersResolver.ts +3 -3
  451. package/src/solidity/SlotsParser/SourceFile.ts +3 -3
  452. package/src/solidity/SolidityParser.ts +1 -1
  453. package/src/solidity/SourceCodeProvider.ts +1 -1
  454. package/src/solidity/storage/Accessor.spec.ts +1 -1
  455. package/src/solidity/storage/Accessor.ts +1 -1
  456. package/src/solidity/storage/SlotDynamicArray.ts +1 -1
  457. package/src/solidity/storage/SlotFixedArray.ts +1 -1
  458. package/src/solidity/storage/SlotsStorageTransport.ts +3 -3
  459. package/src/solidity/storage/handlers/SlotBytesHandler.ts +1 -1
  460. package/src/solidity/storage/handlers/SlotDynamicArrayHandler.ts +1 -1
  461. package/src/solidity/storage/handlers/SlotFixedArrayHandler.ts +1 -1
  462. package/src/solidity/storage/handlers/SlotValueConstantHandler.ts +1 -1
  463. package/src/solidity/storage/handlers/SlotValueHandler.ts +1 -1
  464. package/src/solidity/storage/handlers/SlotValueImmutableHandler.ts +4 -4
  465. package/src/tokens/TokenDataProvider.ts +2 -2
  466. package/src/tokens/TokenExchangeService.ts +1 -1
  467. package/src/tokens/TokenExchanges/AmmBase/V2/AmmPairV2Service.ts +2 -2
  468. package/src/tokens/TokenExchanges/AmmV2PriceQuote.ts +2 -2
  469. package/src/tokens/TokenOracles/amm/AmmV1Oracle.ts +2 -2
  470. package/src/tokens/TokenTransferService.ts +2 -2
  471. package/src/tokens/TokensService.ts +1 -1
  472. package/src/txs/ITxBuilderOptions.ts +1 -1
  473. package/src/txs/TxNonceManager.ts +1 -1
  474. package/src/txs/TxWriter.ts +15 -4
  475. package/src/txs/agents/BatchAgent.ts +1 -1
  476. package/src/txs/conditional/GasWatcherTx.ts +1 -1
  477. package/src/txs/receipt/TxLogParser.ts +1 -1
  478. package/src/utils/$crypto.ts +1 -1
  479. package/src/utils/$date.ts +1 -1
  480. package/src/utils/$hex.ts +1 -1
  481. package/src/utils/$logger.ts +1 -1
  482. package/src/utils/$machine.ts +2 -2
  483. package/src/utils/$traces.ts +1 -1
  484. package/src/wallets/EIP6963ProviderFactory.ts +4 -4
@@ -53,9 +53,9 @@ export class ContractWriter implements IContractWriter {
53
53
  }
54
54
 
55
55
  /**
56
- * We split Tx sending in two awaitable steps
57
- * 1. This method prepares(gas, nonce, etc) - and sends the Tx
58
- * 2. With returned writer you can subscribe to events and/or wait for Tx to be mined
56
+ * We split transaction sending into two awaitable steps:
57
+ * 1. This method prepares gas, nonce, etc., and sends the transaction.
58
+ * 2. With the returned writer, you can subscribe to events and/or wait for the transaction to be mined.
59
59
  * @param account
60
60
  * @param interfaceAbi
61
61
  * @param params
@@ -74,7 +74,7 @@ export class ContractWriter implements IContractWriter {
74
74
  ): Promise<TxWriter> {
75
75
 
76
76
  $require.notNull(account, 'Account parameter is undefined.');
77
- $require.True(typeof account === 'object' || typeof account === 'string', `ContractWriter expect Account as the first parameter, got: ${ typeof account }`)
77
+ $require.True(typeof account === 'object' || typeof account === 'string', `ContractWriter expects Account as the first parameter, got: ${ typeof account }`)
78
78
 
79
79
  let value = typeof account !== 'string'
80
80
  ? account.value
@@ -87,10 +87,10 @@ export class ContractDeployer {
87
87
  let artifacts = ctx.artifacts ?? './artifacts/';
88
88
  let files = await $require.resolved(
89
89
  Directory.readFilesAsync(artifacts, '**.json'),
90
- `Artifact files not found for ${ctx.name}`
90
+ `Artifact files were not found for ${ctx.name}`
91
91
  );
92
92
  let file = files.find(x => x.uri.file === `${ctx.name}.json`);
93
- $require.notNull(file, `File for the contract ${ctx.name} not found within: \n ${ files.map(x => x.uri.toString()).join('\n') }`);
93
+ $require.notNull(file, `File for contract ${ctx.name} was not found in: \n ${ files.map(x => x.uri.toString()).join('\n') }`);
94
94
 
95
95
  return this.fromMetaFile ({
96
96
  ...ctx,
@@ -129,7 +129,7 @@ export class ContractDeployer {
129
129
  }
130
130
 
131
131
  private async fromMetaJson (ctx: TDeploymentByMetaJson) {
132
- $require.notNull(ctx.json?.bytecode, 'Contract bytecode is expected in json');
132
+ $require.notNull(ctx.json?.bytecode, 'Contract bytecode is expected in JSON');
133
133
  return this.fromBytecode({
134
134
  ...ctx,
135
135
  bytecode: ctx.json.bytecode,
@@ -139,7 +139,7 @@ export class ContractDeployer {
139
139
  }
140
140
 
141
141
  private async fromBytecode (ctx: TDeploymentWithBytecode) {
142
- $require.True($is.Hex(ctx.bytecode), `bytecode must be a hex string: ${ctx.bytecode}`);
142
+ $require.True($is.Hex(ctx.bytecode), `Bytecode must be a hex string: ${ctx.bytecode}`);
143
143
 
144
144
  let deployment = new ContractDeployment({
145
145
  client: this.client,
@@ -19,7 +19,7 @@ export class ContractDeployment {
19
19
  abi?: TAbiItem[]
20
20
  params?: any[]
21
21
  source?: {
22
- // JSON meta file
22
+ // JSON metadata file.
23
23
  path: string
24
24
  }
25
25
  }) {
@@ -7,8 +7,7 @@ import { TEth } from '@dequanto/models/TEth';
7
7
  import { $abiUtils } from '@dequanto/utils/$abiUtils';
8
8
  import { $contract } from '@dequanto/utils/$contract';
9
9
  import { $require } from '@dequanto/utils/$require';
10
- import { ParametersFromSecond } from '@dequanto/utils/types';
11
- import { Constructor } from '@dequanto/utils/types';
10
+ import { Constructor, ParametersFromSecond } from '@dequanto/utils/types';
12
11
 
13
12
  import { BlockchainExplorerFactory } from '@dequanto/explorer/BlockchainExplorerFactory';
14
13
  import { ContractVerifier } from '@dequanto/explorer/ContractVerifier';
@@ -16,40 +15,45 @@ import { HardhatWeb3Client } from '@dequanto/hardhat/HardhatWeb3Client';
16
15
  import { LoggerService } from '@dequanto/loggers/LoggerService';
17
16
  import { $is } from '@dequanto/utils/$is';
18
17
 
19
- import { IBeacon, IBeaconProxy, IProxy, IProxyAdmin, ProxyDeployment } from './proxy/ProxyDeployment';
20
- import { DeploymentsStorage, IDeployment } from './storage/DeploymentsStorage';
18
+ import { $bytecode } from '@dequanto/evm/utils/$bytecode';
21
19
  import { TAddress } from '@dequanto/models/TAddress';
22
- import { $promise } from '@dequanto/utils/$promise';
23
20
  import { l } from '@dequanto/utils/$logger';
24
- import { $bytecode } from '@dequanto/evm/utils/$bytecode';
25
- import { THex } from '@dequanto/models/THex';
21
+ import { $promise } from '@dequanto/utils/$promise';
22
+ import { IBeacon, IBeaconProxy, IProxy, IProxyAdmin, ProxyDeployment } from './proxy/ProxyDeployment';
23
+ import { DeploymentsStorage, IDeployment } from './storage/DeploymentsStorage';
26
24
 
27
25
 
28
26
 
29
27
  type TDeploymentOptions = {
30
28
  id?: string
31
29
 
32
- /** Will deploy the contract */
30
+ // For proxy deployments: redeploys the implementation if the bytecode has not changed but the immutable arguments have changed.
31
+ immutablesKey?: string
32
+
33
+ // Older deployments did not have immutablesKey, so any proxy implementation with immutable variables would trigger redeployment.
34
+ checkImmutables?: boolean
35
+
36
+ /** Deploys the contract. */
33
37
  force?: boolean
34
- /** Will check if local bytecode has changed and will deploy */
38
+ /** Checks whether the local bytecode has changed and deploys if needed. */
35
39
  latest?: boolean
36
40
 
37
41
  verification?: boolean | 'silent'
38
42
 
39
- // Will be used for verification process
43
+ // Used for the verification process.
40
44
  proxyFor?: TAddress
41
45
 
42
46
  deployment?: {
43
- // Pending deployment transaction will be re-checked
47
+ // Pending deployment transaction will be rechecked.
44
48
  tx?: TEth.Hex
45
- // When false, the implementation won't be updated in proxy
49
+ // When false, the implementation will not be updated in the proxy.
46
50
  upgradeProxy?: boolean
47
- // Owner, if differes from deployer
51
+ // Owner, if different from the deployer.
48
52
  owner?: TEth.IAccount
49
53
  }
50
54
  }
51
55
  type TVerificationOptions = TDeploymentOptions & {
52
- // otherwise will be fetched from the deployment TX
56
+ // Otherwise, this will be fetched from the deployment transaction.
53
57
  constructorParams?: any[]
54
58
  }
55
59
 
@@ -81,7 +85,7 @@ export class Deployments {
81
85
  Proxy?: Constructor<ContractBase>,
82
86
  ProxyAdmin?: Constructor<IProxyAdmin>
83
87
  directory?: string
84
- // Will be part of the deployments filename
88
+ // Part of the deployments filename.
85
89
  name?: string
86
90
  // TPlatform of a forked network
87
91
  fork?: string
@@ -136,7 +140,7 @@ export class Deployments {
136
140
  }): Promise<T> {
137
141
  let contract = await this.getOrNull(Ctor, opts);
138
142
  if (contract == null) {
139
- throw new Error(`Deployment ${Ctor.name} ${opts?.id ?? ''} not found in ${this.client.platform} [${this.store.opts?.name ?? this.store.opts?.directory ?? ''}]`);
143
+ throw new Error(`Deployment ${Ctor.name} ${opts?.id ?? ''} was not found in ${this.client.platform} [${this.store.opts?.name ?? this.store.opts?.directory ?? ''}]`);
140
144
  }
141
145
  return contract;
142
146
  }
@@ -162,7 +166,7 @@ export class Deployments {
162
166
  }
163
167
 
164
168
  /**
165
- * Get the deployment for Ctor, but returns the CtorWrapped instance. Useful for proxies, etc.
169
+ * Gets the deployment for Ctor, but returns the CtorWrapped instance. Useful for proxies, etc.
166
170
  * e.g. deployments.getAs(SomeProxy, SomeImplementation);
167
171
  */
168
172
  async getAs<TDeployed extends ContractBase, TWrapped extends ContractBase>(Ctor: Constructor<TDeployed>, CtorWrapped: Constructor<TWrapped>, opts?: {
@@ -183,7 +187,7 @@ export class Deployments {
183
187
  let deployment = await this.store.getDeploymentInfo('', {
184
188
  id: params.id
185
189
  });
186
- $require.notNull(deployment, `Deployment for ${params.id} not found`);
190
+ $require.notNull(deployment, `Deployment for ${params.id} was not found`);
187
191
  await this.ensureVerification(params.Ctor, deployment, {
188
192
  id: params.id,
189
193
  constructorParams: params.constructorParams,
@@ -217,8 +221,14 @@ export class Deployments {
217
221
  ? (this.client.platform === 'hardhat' || this.opts?.checkBytecode !== false)
218
222
  : (opts.latest);
219
223
 
220
- if (opts.force !== true && requireLatest !== true) {
221
- // return already deployed contract
224
+ /** For backward compatibility:
225
+ * For older deployments, the deployer should set this if immutablesKey is not present in the deployed state. */
226
+ let hasNewImmutables = opts.checkImmutables === true
227
+ ? Boolean(currentDeployment.immutablesKey != opts.immutablesKey)
228
+ : Boolean(currentDeployment.immutablesKey && currentDeployment.immutablesKey != opts.immutablesKey);
229
+
230
+ if (opts.force !== true && requireLatest !== true && hasNewImmutables !== true) {
231
+ // Return the already deployed contract.
222
232
  $contract.store.register(contract as any);
223
233
  return {
224
234
  contract,
@@ -226,9 +236,9 @@ export class Deployments {
226
236
  };
227
237
  }
228
238
  if (requireLatest === true && opts.force !== true) {
229
- // was already deployed. Check new bytecode hash
239
+ // The contract was already deployed. Check the new bytecode hash.
230
240
  let isSame = await this.isSameBytecode(Ctor, currentDeployment);
231
- if (isSame) {
241
+ if (isSame && hasNewImmutables !== true) {
232
242
  $contract.store.register(contract as any);
233
243
  return {
234
244
  contract,
@@ -252,7 +262,7 @@ export class Deployments {
252
262
 
253
263
 
254
264
 
255
- // Lets deploy the contract, new, forced, or latest
265
+ // Deploy the contract: new, forced, or latest.
256
266
 
257
267
  let constructorArgs = opts.arguments ?? [];
258
268
  let id = opts.id ?? Ctor.name;
@@ -272,6 +282,7 @@ export class Deployments {
272
282
  let deployment = await this.store.saveDeployment(deployedContract, {
273
283
  id,
274
284
  name: Ctor.name,
285
+ immutablesKey: opts.immutablesKey,
275
286
  bytecodeHash: this.getBytecodeHash(deployedBytecode)
276
287
  }, receipt);
277
288
 
@@ -287,16 +298,11 @@ export class Deployments {
287
298
  };
288
299
  }
289
300
 
290
- async ensureWithProxy<
291
- T extends (TContract & { initialize?: TInit }),
292
- TInit extends TInitializer
293
- >(
301
+ async ensureWithProxy<T extends TContract>(
294
302
  CtorImpl: Constructor<T>,
295
- opts?: TConstructorArgs<T> & TDeploymentOptions & {
296
- initialize?: ParametersFromSecond<T['initialize']>
297
- }
303
+ opts?: TConstructorArgs<T> & TDeploymentOptions & TInitializerParams<T>
298
304
  ): Promise<{
299
- // the Implementation Contract with the address set to Proxy
305
+ // The implementation contract with the address set to the proxy.
300
306
  contract: T
301
307
  contractReceipt?: TEth.TxReceipt
302
308
  contractProxy: IProxy,
@@ -308,6 +314,7 @@ export class Deployments {
308
314
 
309
315
  let id = opts?.id ?? getImplementationId(CtorImpl);
310
316
  let proxyId = `${id}Proxy`;
317
+ let immutablesKey = getImmutablesKey(opts?.arguments);
311
318
 
312
319
  let {
313
320
  contract: contractImpl,
@@ -316,13 +323,15 @@ export class Deployments {
316
323
  } = await this.ensure(CtorImpl, {
317
324
  arguments: opts?.arguments as any,
318
325
  id: id,
326
+ immutablesKey,
319
327
  force: opts?.force,
320
328
  latest: this.opts?.checkBytecode !== false,
321
329
  verification: opts?.verification,
322
330
  deployment: opts?.deployment
323
331
  });
324
332
 
325
- let data = serializeInitData(id, contractImpl, opts.initialize);
333
+ let initData = serializeInitData(id, contractImpl, opts.initialize);
334
+ let { migrationData, migrationV } = serializeMigrationData(id, contractImpl, opts);
326
335
  let implementationAddress = contractImplDeployment.implementation ?? contractImplDeployment.address;
327
336
 
328
337
  let {
@@ -337,13 +346,15 @@ export class Deployments {
337
346
  deployments: this,
338
347
  implementation: {
339
348
  address: implementationAddress,
340
- initData: data
349
+ initData,
350
+ migrationData,
351
+ migrationV,
341
352
  },
342
353
  upgradeImplementation: opts.deployment?.upgradeProxy ?? this.opts?.whenUpgradeRequired !== 'ignore'
343
354
  })
344
355
 
345
356
  if (contractImplDeployment.implementation == null) {
346
- // Set the Proxy contract as the main Address
357
+ // Set the proxy contract as the main address.
347
358
  contractImplDeployment.implementation = contractImplDeployment.address;
348
359
  contractImplDeployment.address = contractProxy.address;
349
360
 
@@ -365,12 +376,12 @@ export class Deployments {
365
376
  }
366
377
 
367
378
  /**
368
- * Deploys the Beacon contract. Implementation is the target contract (can be a proxy or normal contract)
379
+ * Deploys the Beacon contract. The implementation is the target contract (can be a proxy or normal contract).
369
380
  * https://docs.openzeppelin.com/contracts/5.x/api/proxy#beacon
370
381
  **/
371
382
  async ensureWithBeacon<
372
383
  T extends (TContract & { initialize?: TInit }),
373
- TInit extends TInitializer
384
+ TInit extends TFunction
374
385
  >(
375
386
  CtorImpl: Constructor<T>,
376
387
  opts: TConstructorArgs<T> & TDeploymentOptions & {
@@ -379,7 +390,7 @@ export class Deployments {
379
390
  initialize?: ParametersFromSecond<T['initialize']>
380
391
  }
381
392
  ): Promise<{
382
- // the Implementation Contract with the address set to Beacon Proxy
393
+ // The implementation contract with the address set to the Beacon proxy.
383
394
  contract: T
384
395
  contractReceipt?: TEth.TxReceipt
385
396
  contractDeployment: IDeployment
@@ -390,7 +401,7 @@ export class Deployments {
390
401
  contractBeaconProxyDeployment: IDeployment
391
402
  }> {
392
403
 
393
- $require.notEmpty(opts?.id, `ID is required for Beacon deployment, as Implementation apparently will get multiple Beacons`);
404
+ $require.notEmpty(opts?.id, `ID is required for Beacon deployment, as the implementation can have multiple Beacons`);
394
405
 
395
406
  let beaconProxyId = opts.id;
396
407
  let implId = beaconProxyId.includes('/')
@@ -426,7 +437,9 @@ export class Deployments {
426
437
  deployments: this,
427
438
  implementation: {
428
439
  address: implementationAddress,
429
- initData: data
440
+ initData: data,
441
+ // @TODO Implement migrations for Beacons.
442
+ migrationData: null
430
443
  }
431
444
  });
432
445
 
@@ -461,7 +474,7 @@ export class Deployments {
461
474
  return true;
462
475
  }
463
476
 
464
- // recheck v1
477
+ // Recheck v1.
465
478
  if (deployment.bytecodeHash != null) {
466
479
  let address = deployment.implementation ?? deployment.address;
467
480
  let bytecode = await this.client.getCode(address);
@@ -479,8 +492,8 @@ export class Deployments {
479
492
  let [ localDiff, onchainDiff ] = Str.getDifference(bytecodeLocal, bytecodeOnchain);
480
493
  if (localDiff === '' || /^0+$/.test(localDiff)) {
481
494
  this._logger.log(`${deployment.id} bytecode has only immutable data diff, assume unchanged`);
482
- // Local deployedBytecode doesn't contain the immutable data
483
- // instead the solc generates the bytecode with 0 as the placeholder
495
+ // Local deployedBytecode does not contain immutable data.
496
+ // Instead, solc generates bytecode with 0 as the placeholder.
484
497
  return true;
485
498
  }
486
499
  }
@@ -557,19 +570,19 @@ export class Deployments {
557
570
 
558
571
 
559
572
  /**
560
- * A simple method to configure the contracts state
573
+ * A simple method to configure contract state.
561
574
  */
562
575
  public async configure<T extends TContract, TValue>(Ctor: Constructor<T> | T, opts: {
563
576
  id?: string;
564
577
 
565
- // Latest value, if differs from current, the updater will be executed
578
+ // Latest value. If it differs from current, the updater will be executed.
566
579
  value?: TValue
567
580
  // Current value.
568
581
  current?: TValue | Promise<TValue> | ((x: T) => Promise<TValue>);
569
582
  shouldUpdate?: boolean | (() => boolean | Promise<boolean>)
570
583
  updater: (x: T, value: TValue) => Promise<any>
571
584
 
572
- // Will be logged with old and new value
585
+ // Logged with the old and new values.
573
586
  title?: string
574
587
  }) {
575
588
  let x: T;
@@ -611,9 +624,19 @@ export class Deployments {
611
624
  }
612
625
  }
613
626
 
614
-
615
- type TInitializer = (...args: any[]) => any
616
-
627
+ type TFunction = (...args: any[]) => any;
628
+ type TInitializerName = 'initialize' | `initializeV${number}`;
629
+ type TInitializerParams<T> = {
630
+ initialize?: T extends { initialize: infer TInit }
631
+ ? TInit extends TFunction
632
+ ? ParametersFromSecond<TInit>
633
+ : never
634
+ : any[];
635
+ } & {
636
+ [K in Extract<keyof T, TInitializerName>]?: T[K] extends TFunction
637
+ ? ParametersFromSecond<T[K]>
638
+ : never;
639
+ };
617
640
 
618
641
  type TContract = ContractBase & { $constructor?: (...args: any[]) => any }
619
642
  type TConstructorArgs<T extends TContract> = T['$constructor'] extends Function ? {
@@ -639,7 +662,7 @@ function isEqual(a, b) {
639
662
  // Not strictly equal
640
663
  return a == b;
641
664
  }
642
- // check arrays
665
+ // Check arrays.
643
666
  if (Array.isArray(a) || Array.isArray(b)) {
644
667
  if (a.length !== b.length) {
645
668
  return false;
@@ -648,7 +671,7 @@ function isEqual(a, b) {
648
671
  return isEqual(x, b[i]);
649
672
  });
650
673
  }
651
- // check objects
674
+ // Check objects.
652
675
  for (let key in a) {
653
676
  let aValue = a[key];
654
677
  let bValue = b[key];
@@ -658,7 +681,7 @@ function isEqual(a, b) {
658
681
  }
659
682
  for (let key in b) {
660
683
  if (key in a === false && b[key] != null) {
661
- // value present in b, but was not in a
684
+ // Value is present in b, but not in a.
662
685
  return false;
663
686
  }
664
687
  }
@@ -678,9 +701,34 @@ function serializeInitData(id: string, contract: ContractBase, initializeParams:
678
701
  }
679
702
 
680
703
 
704
+ function serializeMigrationData(id: string, contract: ContractBase, opts: any) {
705
+ let rgx = /^initializeV(?<version>[\d+])$/;
706
+ let migrations = contract
707
+ .abi
708
+ .map(x => rgx.exec(x.name))
709
+ .filter(x => x != null)
710
+ .map(match => Number(match.groups.version))
711
+ ;
712
+ if (migrations.length === 0) {
713
+ return { migrationData: null, migrationV: 1 };
714
+ }
715
+ let v = alot(migrations).max(x => x);
716
+ let key = `initializeV${v}`;
717
+ let migrationAbi = contract.abi.find(x => x.name === key);
718
+ let migrationParams = opts?.[key] ?? [];
719
+ if (migrationParams?.length !== migrationAbi.inputs.length) {
720
+ throw new Error(`Wrong number of arguments (${migrationParams?.length}) for initializer method (${migrationAbi.inputs.length}) in ${id}.`);
721
+ }
722
+ return {
723
+ migrationData: $abiUtils.serializeMethodCallData(migrationAbi, migrationParams ?? []),
724
+ migrationV: v
725
+ };
726
+ }
727
+
728
+
681
729
  /**
682
- * Normalize the contract name by removing any versions from name
683
- * "FooV1" is actually the "Foo" contract
730
+ * Normalizes the contract name by removing any version suffix from the name.
731
+ * "FooV1" is actually the "Foo" contract.
684
732
  */
685
733
  function getImplementationId (Ctor: Constructor<TContract>) {
686
734
  let id = Ctor.name;
@@ -691,6 +739,15 @@ function getImplementationId (Ctor: Constructor<TContract>) {
691
739
  return id;
692
740
  }
693
741
 
742
+
743
+ function getImmutablesKey (args: any[]) {
744
+ if (args == null || args.length === 0) {
745
+ return null;
746
+ }
747
+ let key = args.map(arg => `${arg?.toString()}`).join('-');
748
+ return key;
749
+ }
750
+
694
751
  namespace Str {
695
752
  export function getDifference (a: TEth.Hex, b: TEth.Hex) {
696
753
  if (a === b) {
@@ -20,7 +20,7 @@ export namespace $proxyDeploy {
20
20
  variable: result.newVar,
21
21
  path: serializePath(result.newPath, result.newVar),
22
22
  conflicts: result.conflicts,
23
- message: `${result.type}: Variable ${serializePath(result.newPath, result.newVar)}(${result.newVar.type}) at slot ${result.newVar.slot} conflicts ${conflicts}`
23
+ message: `${result.type}: Variable ${serializePath(result.newPath, result.newVar)}(${result.newVar.type}) at slot ${result.newVar.slot} conflicts with ${conflicts}`
24
24
  };
25
25
  }
26
26
  return null;
@@ -34,15 +34,15 @@ export namespace $proxyDeploy {
34
34
 
35
35
  ctx ??= {};
36
36
 
37
- // When resolving state variables
38
- // we append '$' char(s) to the overriden variables to avoid name conflicts, so here we check also for __gap with possible $ sfx.
37
+ // When resolving state variables, we append '$' characters to overridden variables to avoid name conflicts.
38
+ // Also check for __gap with a possible '$' suffix.
39
39
  let rgxGap = /^_+gap\$*$/;
40
40
  let oldMemory = oldVars.map(getMemoryPosition);
41
41
  let oldLastSlot = alot(oldVars).max(x => x.slot);
42
42
  for (let i = 0; i < newVars.length; i++) {
43
43
  let newVar = newVars[i];
44
44
  if (newVar.slot > oldLastSlot) {
45
- // New variable was added after the last slot in current deployment
45
+ // A new variable was added after the last slot in the current deployment.
46
46
  if (ctx.isExtendableMemory === false) {
47
47
  return new BaseError(
48
48
  ELayoutError.MEMORY_OVERFLOW,
@@ -52,8 +52,8 @@ export namespace $proxyDeploy {
52
52
  );
53
53
  }
54
54
 
55
- // Find the new variable name in old storage
56
- // Exclude those with the same position, as they might be pushed logically down by __gap pattern
55
+ // Find the new variable name in old storage.
56
+ // Exclude variables at the same position, as they might be pushed logically down by the __gap pattern.
57
57
  let oldVarWithName = oldVars.find(x => x.name === newVar.name);
58
58
  if (oldVarWithName != null && !Variables.eqLocation(oldVarWithName, newVar) && !rgxGap.test(newVar.name)) {
59
59
  return new BaseError(
@@ -69,7 +69,7 @@ export namespace $proxyDeploy {
69
69
  let oldVarAtSamePos = oldVars.find(x => x.slot === newVar.slot && x.position === newVar.position);
70
70
  if (oldVarAtSamePos != null) {
71
71
  if (oldVarAtSamePos.type === newVar.type) {
72
- // New variable is the same
72
+ // The new variable is the same.
73
73
  if (oldVarAtSamePos.name !== newVar.name) {
74
74
  let oldVarWithName = oldVars.find(x => x.name === newVar.name);
75
75
  if (oldVarWithName != null) {
@@ -229,7 +229,7 @@ export namespace $proxyDeploy {
229
229
  newPath?: string
230
230
  oldPath?: string
231
231
 
232
- // root storage is extendable, but if we compare base array types, or structs, the memory is limited due to outer next variable slots
232
+ // Root storage is extendable, but when comparing base array types or structs, memory is limited by outer next-variable slots.
233
233
  isExtendableMemory?: boolean
234
234
 
235
235
  isLastVariable?: boolean
@@ -239,13 +239,13 @@ export namespace $proxyDeploy {
239
239
  TYPE_MISMATCH = 'TYPE_MISMATCH',
240
240
  TYPE_COLLISION = 'TYPE_COLLISION',
241
241
 
242
- /** throws error if memory is not extendable */
242
+ /** Throws an error if memory is not extendable. */
243
243
  ARRAY_LENGTH_MISMATCH = 'ARRAY_LENGTH_MISMATCH',
244
244
 
245
- /** in arrays the memory for a single item is not extendable, but in contract's root storage or mapping values is */
245
+ /** In arrays, memory for a single item is not extendable, but it is extendable in contract root storage or mapping values. */
246
246
  MEMORY_OVERFLOW = 'MEMORY_OVERFLOW',
247
247
 
248
- /** Variables on same slot with different names (rename possible) but additionally the some variable exists in old layout on different slot */
248
+ /** Variables on the same slot with different names (rename possible), while the same variable also exists in the old layout on a different slot. */
249
249
  NAME_MISMATCH = 'NAME_MISMATCH'
250
250
  }
251
251
  class BaseError {
@@ -274,7 +274,7 @@ export namespace $proxyDeploy {
274
274
 
275
275
  function getMemoryPosition ($var: ISlotVarDefinition) {
276
276
  if (isDynamicVariable($var)) {
277
- // dynamic variables occupy the single slot
277
+ // Dynamic variables occupy a single slot.
278
278
  return {
279
279
  variable: $var,
280
280
  offset: $var.slot * 256,
@@ -300,12 +300,12 @@ export namespace $proxyDeploy {
300
300
  function requireBoth (a: ISlotVarDefinition, b: ISlotVarDefinition, aCheck: boolean, bCheck: boolean) {
301
301
  if (!aCheck) {
302
302
  return {
303
- error: `Current variable is not dynamic ${a.name}(${a.type}) but the new one is: ${b.name}(${b.type})`
303
+ error: `Current variable ${a.name}(${a.type}) is not dynamic, but the new one is: ${b.name}(${b.type})`
304
304
  };
305
305
  }
306
306
  if (!bCheck) {
307
307
  return {
308
- error: `Current variable is dynamic ${a.name}(${a.type}) but the new one is not: ${b.name}(${b.type})`
308
+ error: `Current variable ${a.name}(${a.type}) is dynamic, but the new one is not: ${b.name}(${b.type})`
309
309
  };
310
310
  }
311
311
  }