@across-protocol/sdk 4.3.111-alpha.4 → 4.3.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/addressAggregator/adapters/abstract.js +64 -50
- package/dist/cjs/addressAggregator/adapters/abstract.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/bybit.js +29 -16
- package/dist/cjs/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/env.js +15 -11
- package/dist/cjs/addressAggregator/adapters/env.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/file.js +45 -32
- package/dist/cjs/addressAggregator/adapters/file.js.map +1 -1
- package/dist/cjs/addressAggregator/adapters/index.js +1 -1
- package/dist/cjs/addressAggregator/adapters/risklabs.js +36 -22
- package/dist/cjs/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/cjs/addressAggregator/index.js +87 -57
- package/dist/cjs/addressAggregator/index.js.map +1 -1
- package/dist/cjs/apiClient/abstractClient.js +8 -9
- package/dist/cjs/apiClient/abstractClient.js.map +1 -1
- package/dist/cjs/apiClient/index.js +1 -1
- package/dist/cjs/apiClient/mockedClient.js +29 -23
- package/dist/cjs/apiClient/mockedClient.js.map +1 -1
- package/dist/cjs/apiClient/productionClient.js +103 -65
- package/dist/cjs/apiClient/productionClient.js.map +1 -1
- package/dist/cjs/arch/evm/BlockUtils.js +208 -122
- package/dist/cjs/arch/evm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/evm/MessageUtils.js +1 -1
- package/dist/cjs/arch/evm/MessageUtils.js.map +1 -1
- package/dist/cjs/arch/evm/SpokeUtils.js +288 -134
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/evm/index.js +1 -1
- package/dist/cjs/arch/evm/utils/index.js +1 -1
- package/dist/cjs/arch/evm/utils/wait.js +49 -38
- package/dist/cjs/arch/evm/utils/wait.js.map +1 -1
- package/dist/cjs/arch/index.js +1 -1
- package/dist/cjs/arch/svm/BlockUtils.js +158 -102
- package/dist/cjs/arch/svm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/svm/MessageUtils.js +2 -2
- package/dist/cjs/arch/svm/MessageUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +1147 -708
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/encoders.js +1 -1
- package/dist/cjs/arch/svm/encoders.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +236 -174
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/index.js +1 -1
- package/dist/cjs/arch/svm/provider.js +3 -3
- package/dist/cjs/arch/svm/provider.js.map +1 -1
- package/dist/cjs/arch/svm/utils.js +355 -166
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/caching/Arweave/ArweaveClient.js +246 -168
- package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/cjs/caching/Arweave/index.js +1 -1
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js +49 -40
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js.map +1 -1
- package/dist/cjs/caching/IPFS/index.js +1 -1
- package/dist/cjs/caching/Memory/MemoryCacheClient.js +18 -13
- package/dist/cjs/caching/Memory/MemoryCacheClient.js.map +1 -1
- package/dist/cjs/caching/Memory/index.js +1 -1
- package/dist/cjs/caching/index.js +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +381 -302
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js +1 -1
- package/dist/cjs/clients/BaseAbstractClient.js +83 -58
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +900 -709
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/index.js +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +128 -95
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +53 -48
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +8 -10
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +90 -67
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +24 -46
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/index.js +1 -1
- package/dist/cjs/clients/HubPoolClient.js +708 -526
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +179 -133
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -124
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +389 -357
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js +8 -9
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.js +3 -3
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.js +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +67 -58
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockEvents.js +52 -47
- package/dist/cjs/clients/mocks/MockEvents.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +185 -142
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +192 -208
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +143 -140
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +73 -57
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/index.js +1 -1
- package/dist/cjs/coingecko/Coingecko.js +437 -285
- package/dist/cjs/coingecko/Coingecko.js.map +1 -1
- package/dist/cjs/coingecko/index.js +1 -1
- package/dist/cjs/constants.js +30 -23
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/contracts/acrossConfigStore.js +48 -27
- package/dist/cjs/contracts/acrossConfigStore.js.map +1 -1
- package/dist/cjs/contracts/hubPool.js +20 -36
- package/dist/cjs/contracts/hubPool.js.map +1 -1
- package/dist/cjs/contracts/index.js +1 -1
- package/dist/cjs/contracts/utils.js +8 -6
- package/dist/cjs/contracts/utils.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +16 -7
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +45 -26
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +28 -16
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +112 -73
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/solana.js +33 -20
- package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.js +104 -77
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.js +3 -3
- package/dist/cjs/gasPriceOracle/types.js.map +1 -1
- package/dist/cjs/gasPriceOracle/util.js +8 -8
- package/dist/cjs/gasPriceOracle/util.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/interfaces/index.js +1 -1
- package/dist/cjs/lpFeeCalculator/index.js +1 -1
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js +35 -33
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
- package/dist/cjs/lpFeeCalculator/rateModel.js +9 -7
- package/dist/cjs/lpFeeCalculator/rateModel.js.map +1 -1
- package/dist/cjs/merkleDistributor/MerkleDistributor.js +18 -20
- package/dist/cjs/merkleDistributor/MerkleDistributor.js.map +1 -1
- package/dist/cjs/merkleDistributor/index.js +1 -1
- package/dist/cjs/merkleDistributor/model/index.js +1 -1
- package/dist/cjs/pool/TransactionManager.js +100 -45
- package/dist/cjs/pool/TransactionManager.js.map +1 -1
- package/dist/cjs/pool/index.js +1 -1
- package/dist/cjs/pool/poolClient.js +731 -464
- package/dist/cjs/pool/poolClient.js.map +1 -1
- package/dist/cjs/pool/uma/across/index.js +1 -1
- package/dist/cjs/pool/uma/across/transactionManager.js +100 -45
- package/dist/cjs/pool/uma/across/transactionManager.js.map +1 -1
- package/dist/cjs/pool/uma/clients/erc20/client.js +16 -18
- package/dist/cjs/pool/uma/clients/erc20/client.js.map +1 -1
- package/dist/cjs/pool/uma/clients/erc20/index.js +1 -1
- package/dist/cjs/pool/uma/clients/index.js +1 -1
- package/dist/cjs/pool/uma/index.js +1 -1
- package/dist/cjs/pool/uma/oracle/index.js +1 -1
- package/dist/cjs/pool/uma/oracle/utils.js +5 -4
- package/dist/cjs/pool/uma/oracle/utils.js.map +1 -1
- package/dist/cjs/pool/uma/utils.js +30 -11
- package/dist/cjs/pool/uma/utils.js.map +1 -1
- package/dist/cjs/priceClient/adapters/acrossApi.js +39 -22
- package/dist/cjs/priceClient/adapters/acrossApi.js.map +1 -1
- package/dist/cjs/priceClient/adapters/baseAdapter.js +73 -49
- package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -1
- package/dist/cjs/priceClient/adapters/coingecko.js +61 -34
- package/dist/cjs/priceClient/adapters/coingecko.js.map +1 -1
- package/dist/cjs/priceClient/adapters/default.js +31 -16
- package/dist/cjs/priceClient/adapters/default.js.map +1 -1
- package/dist/cjs/priceClient/adapters/defiLlama.js +74 -40
- package/dist/cjs/priceClient/adapters/defiLlama.js.map +1 -1
- package/dist/cjs/priceClient/adapters/index.js +1 -1
- package/dist/cjs/priceClient/index.js +1 -1
- package/dist/cjs/priceClient/priceClient.js +159 -110
- package/dist/cjs/priceClient/priceClient.js.map +1 -1
- package/dist/cjs/providers/alchemy.js +19 -17
- package/dist/cjs/providers/alchemy.js.map +1 -1
- package/dist/cjs/providers/cachedProvider.js +129 -88
- package/dist/cjs/providers/cachedProvider.js.map +1 -1
- package/dist/cjs/providers/drpc.js +11 -9
- package/dist/cjs/providers/drpc.js.map +1 -1
- package/dist/cjs/providers/index.js +1 -1
- package/dist/cjs/providers/infura.js +12 -10
- package/dist/cjs/providers/infura.js.map +1 -1
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +15 -7
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -6
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js +15 -7
- package/dist/cjs/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +66 -42
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
- package/dist/cjs/providers/mocks/index.js +1 -1
- package/dist/cjs/providers/mocks/mockEthersProvider.js +31 -29
- package/dist/cjs/providers/mocks/mockEthersProvider.js.map +1 -1
- package/dist/cjs/providers/quicknode.js +21 -19
- package/dist/cjs/providers/quicknode.js.map +1 -1
- package/dist/cjs/providers/rateLimitedProvider.js +79 -64
- package/dist/cjs/providers/rateLimitedProvider.js.map +1 -1
- package/dist/cjs/providers/retryProvider.js +246 -163
- package/dist/cjs/providers/retryProvider.js.map +1 -1
- package/dist/cjs/providers/solana/baseRpcFactories.js +18 -14
- package/dist/cjs/providers/solana/baseRpcFactories.js.map +1 -1
- package/dist/cjs/providers/solana/cachedRpcFactory.js +112 -70
- package/dist/cjs/providers/solana/cachedRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/defaultRpcFactory.js +15 -8
- package/dist/cjs/providers/solana/defaultRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/index.js +1 -1
- package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js +191 -135
- package/dist/cjs/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/rateLimitedRpcFactory.js +90 -67
- package/dist/cjs/providers/solana/rateLimitedRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/retryRpcFactory.js +79 -52
- package/dist/cjs/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/cjs/providers/solana/utils.js +2 -2
- package/dist/cjs/providers/solana/utils.js.map +1 -1
- package/dist/cjs/providers/speedProvider.js +53 -31
- package/dist/cjs/providers/speedProvider.js.map +1 -1
- package/dist/cjs/providers/types.js +1 -1
- package/dist/cjs/providers/types.js.map +1 -1
- package/dist/cjs/providers/utils.js +28 -26
- package/dist/cjs/providers/utils.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +162 -108
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js +26 -14
- package/dist/cjs/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +29 -20
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +137 -88
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/index.js +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +297 -199
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/typeguards/error.js +7 -5
- package/dist/cjs/typeguards/error.js.map +1 -1
- package/dist/cjs/typeguards/index.js +1 -1
- package/dist/cjs/utils/AddressUtils.js +144 -117
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ArrayUtils.js +78 -21
- package/dist/cjs/utils/ArrayUtils.js.map +1 -1
- package/dist/cjs/utils/BigNumberUtils.js +10 -9
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
- package/dist/cjs/utils/BlockExplorerUtils.js +30 -26
- package/dist/cjs/utils/BlockExplorerUtils.js.map +1 -1
- package/dist/cjs/utils/BlockFinder.js +5 -2
- package/dist/cjs/utils/BlockFinder.js.map +1 -1
- package/dist/cjs/utils/BlockUtils.js +41 -24
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/BundleUtils.js +24 -21
- package/dist/cjs/utils/BundleUtils.js.map +1 -1
- package/dist/cjs/utils/CCTPUtils.js +126 -62
- package/dist/cjs/utils/CCTPUtils.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +42 -20
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/ContractUtils.js +5 -5
- package/dist/cjs/utils/ContractUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.js +99 -122
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +70 -49
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/FormattingUtils.js +32 -26
- package/dist/cjs/utils/FormattingUtils.js.map +1 -1
- package/dist/cjs/utils/HyperLiquidUtils.js +23 -10
- package/dist/cjs/utils/HyperLiquidUtils.js.map +1 -1
- package/dist/cjs/utils/IPFSUtils.js +34 -16
- package/dist/cjs/utils/IPFSUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +6 -6
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/LogUtils.js +12 -10
- package/dist/cjs/utils/LogUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +115 -56
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.js +28 -12
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/NumberUtils.js +3 -1
- package/dist/cjs/utils/NumberUtils.js.map +1 -1
- package/dist/cjs/utils/ObjectUtils.js +41 -27
- package/dist/cjs/utils/ObjectUtils.js.map +1 -1
- package/dist/cjs/utils/Profiler.js +83 -80
- package/dist/cjs/utils/Profiler.js.map +1 -1
- package/dist/cjs/utils/ReviverUtils.js +9 -5
- package/dist/cjs/utils/ReviverUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +84 -84
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.js +64 -41
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/cjs/utils/TypeGuards.js +1 -1
- package/dist/cjs/utils/TypeGuards.js.map +1 -1
- package/dist/cjs/utils/ValidatorUtils.js +7 -7
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
- package/dist/cjs/utils/abi/contracts/index.js +1 -1
- package/dist/cjs/utils/abi/index.js +22 -12
- package/dist/cjs/utils/abi/index.js.map +1 -1
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js +12 -9
- package/dist/cjs/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/cjs/utils/abi/typechain/index.js +1 -1
- package/dist/cjs/utils/common.js +53 -40
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/cjs/utils/index.js +1 -1
- package/dist/esm/addressAggregator/adapters/abstract.js +64 -48
- package/dist/esm/addressAggregator/adapters/abstract.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/bybit.js +29 -15
- package/dist/esm/addressAggregator/adapters/bybit.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/env.js +14 -9
- package/dist/esm/addressAggregator/adapters/env.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/file.js +43 -29
- package/dist/esm/addressAggregator/adapters/file.js.map +1 -1
- package/dist/esm/addressAggregator/adapters/risklabs.js +35 -20
- package/dist/esm/addressAggregator/adapters/risklabs.js.map +1 -1
- package/dist/esm/addressAggregator/index.js +83 -52
- package/dist/esm/addressAggregator/index.js.map +1 -1
- package/dist/esm/addressAggregator/types.js +1 -1
- package/dist/esm/addressAggregator/types.js.map +1 -1
- package/dist/esm/apiClient/abstractClient.js +9 -15
- package/dist/esm/apiClient/abstractClient.js.map +1 -1
- package/dist/esm/apiClient/mockedClient.js +26 -21
- package/dist/esm/apiClient/mockedClient.js.map +1 -1
- package/dist/esm/apiClient/productionClient.js +101 -61
- package/dist/esm/apiClient/productionClient.js.map +1 -1
- package/dist/esm/arch/evm/BlockUtils.js +217 -139
- package/dist/esm/arch/evm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +289 -146
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/evm/utils/wait.js +46 -34
- package/dist/esm/arch/evm/utils/wait.js.map +1 -1
- package/dist/esm/arch/svm/BlockUtils.js +166 -118
- package/dist/esm/arch/svm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +1150 -738
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/constants.js +1 -1
- package/dist/esm/arch/svm/constants.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +232 -172
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/provider.js +1 -1
- package/dist/esm/arch/svm/provider.js.map +1 -1
- package/dist/esm/arch/svm/utils.js +345 -155
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/caching/Arweave/ArweaveClient.js +256 -182
- package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/esm/caching/IPFS/PinataIPFSClient.js +48 -47
- package/dist/esm/caching/IPFS/PinataIPFSClient.js.map +1 -1
- package/dist/esm/caching/Memory/MemoryCacheClient.js +19 -13
- package/dist/esm/caching/Memory/MemoryCacheClient.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +408 -333
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BaseAbstractClient.js +92 -66
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1054 -927
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +131 -102
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +59 -57
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -7
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +94 -75
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +23 -45
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.js +740 -581
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +178 -133
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +183 -126
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +399 -372
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js +9 -9
- package/dist/esm/clients/SpokePoolClient/SpokePoolClientManager.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.js +2 -2
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/types.js +2 -2
- package/dist/esm/clients/SpokePoolClient/types.js.map +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +64 -53
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockEvents.js +49 -42
- package/dist/esm/clients/mocks/MockEvents.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js +182 -138
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +188 -202
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +132 -127
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +69 -53
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/coingecko/Coingecko.js +443 -298
- package/dist/esm/coingecko/Coingecko.js.map +1 -1
- package/dist/esm/constants.js +47 -40
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/contracts/acrossConfigStore.js +46 -24
- package/dist/esm/contracts/acrossConfigStore.js.map +1 -1
- package/dist/esm/contracts/hubPool.js +18 -34
- package/dist/esm/contracts/hubPool.js.map +1 -1
- package/dist/esm/contracts/utils.js +5 -3
- package/dist/esm/contracts/utils.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +14 -6
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +42 -22
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js +25 -13
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.js +108 -72
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/solana.js +31 -22
- package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.js +96 -70
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.js +2 -2
- package/dist/esm/gasPriceOracle/types.js.map +1 -1
- package/dist/esm/gasPriceOracle/util.js +4 -4
- package/dist/esm/gasPriceOracle/util.js.map +1 -1
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js +33 -30
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js.map +1 -1
- package/dist/esm/lpFeeCalculator/rateModel.js +9 -7
- package/dist/esm/lpFeeCalculator/rateModel.js.map +1 -1
- package/dist/esm/merkleDistributor/MerkleDistributor.js +17 -18
- package/dist/esm/merkleDistributor/MerkleDistributor.js.map +1 -1
- package/dist/esm/pool/TransactionManager.js +100 -45
- package/dist/esm/pool/TransactionManager.js.map +1 -1
- package/dist/esm/pool/poolClient.js +740 -479
- package/dist/esm/pool/poolClient.js.map +1 -1
- package/dist/esm/pool/uma/across/constants.js +2 -2
- package/dist/esm/pool/uma/across/constants.js.map +1 -1
- package/dist/esm/pool/uma/across/transactionManager.js +100 -45
- package/dist/esm/pool/uma/across/transactionManager.js.map +1 -1
- package/dist/esm/pool/uma/clients/erc20/client.js +13 -15
- package/dist/esm/pool/uma/clients/erc20/client.js.map +1 -1
- package/dist/esm/pool/uma/oracle/utils.js +3 -2
- package/dist/esm/pool/uma/oracle/utils.js.map +1 -1
- package/dist/esm/pool/uma/utils.js +28 -9
- package/dist/esm/pool/uma/utils.js.map +1 -1
- package/dist/esm/priceClient/adapters/acrossApi.js +40 -21
- package/dist/esm/priceClient/adapters/acrossApi.js.map +1 -1
- package/dist/esm/priceClient/adapters/baseAdapter.js +72 -46
- package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -1
- package/dist/esm/priceClient/adapters/coingecko.js +61 -33
- package/dist/esm/priceClient/adapters/coingecko.js.map +1 -1
- package/dist/esm/priceClient/adapters/default.js +31 -15
- package/dist/esm/priceClient/adapters/default.js.map +1 -1
- package/dist/esm/priceClient/adapters/defiLlama.js +73 -38
- package/dist/esm/priceClient/adapters/defiLlama.js.map +1 -1
- package/dist/esm/priceClient/priceClient.js +158 -109
- package/dist/esm/priceClient/priceClient.js.map +1 -1
- package/dist/esm/providers/alchemy.js +18 -16
- package/dist/esm/providers/alchemy.js.map +1 -1
- package/dist/esm/providers/cachedProvider.js +134 -99
- package/dist/esm/providers/cachedProvider.js.map +1 -1
- package/dist/esm/providers/constants.js +3 -3
- package/dist/esm/providers/constants.js.map +1 -1
- package/dist/esm/providers/drpc.js +10 -8
- package/dist/esm/providers/drpc.js.map +1 -1
- package/dist/esm/providers/infura.js +11 -9
- package/dist/esm/providers/infura.js.map +1 -1
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +15 -6
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +14 -5
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js +15 -6
- package/dist/esm/providers/mocks/MockRetrySolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +66 -41
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +1 -1
- package/dist/esm/providers/mocks/mockEthersProvider.js +30 -27
- package/dist/esm/providers/mocks/mockEthersProvider.js.map +1 -1
- package/dist/esm/providers/quicknode.js +20 -18
- package/dist/esm/providers/quicknode.js.map +1 -1
- package/dist/esm/providers/rateLimitedProvider.js +80 -68
- package/dist/esm/providers/rateLimitedProvider.js.map +1 -1
- package/dist/esm/providers/retryProvider.js +259 -186
- package/dist/esm/providers/retryProvider.js.map +1 -1
- package/dist/esm/providers/solana/baseRpcFactories.js +19 -13
- package/dist/esm/providers/solana/baseRpcFactories.js.map +1 -1
- package/dist/esm/providers/solana/cachedRpcFactory.js +112 -75
- package/dist/esm/providers/solana/cachedRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/defaultRpcFactory.js +14 -6
- package/dist/esm/providers/solana/defaultRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/quorumFallbackRpcFactory.js +202 -149
- package/dist/esm/providers/solana/quorumFallbackRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/rateLimitedRpcFactory.js +90 -70
- package/dist/esm/providers/solana/rateLimitedRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/retryRpcFactory.js +74 -50
- package/dist/esm/providers/solana/retryRpcFactory.js.map +1 -1
- package/dist/esm/providers/solana/utils.js +1 -1
- package/dist/esm/providers/solana/utils.js.map +1 -1
- package/dist/esm/providers/speedProvider.js +51 -28
- package/dist/esm/providers/speedProvider.js.map +1 -1
- package/dist/esm/providers/types.js +2 -2
- package/dist/esm/providers/types.js.map +1 -1
- package/dist/esm/providers/utils.js +20 -17
- package/dist/esm/providers/utils.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +152 -98
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js +26 -13
- package/dist/esm/relayFeeCalculator/chain-queries/customGasToken.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +19 -9
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +128 -83
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +299 -211
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/typeguards/error.js +5 -3
- package/dist/esm/typeguards/error.js.map +1 -1
- package/dist/esm/utils/AddressUtils.js +147 -115
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ArrayUtils.js +78 -21
- package/dist/esm/utils/ArrayUtils.js.map +1 -1
- package/dist/esm/utils/BigNumberUtils.js +12 -11
- package/dist/esm/utils/BigNumberUtils.js.map +1 -1
- package/dist/esm/utils/BlockExplorerUtils.js +23 -19
- package/dist/esm/utils/BlockExplorerUtils.js.map +1 -1
- package/dist/esm/utils/BlockFinder.js +6 -2
- package/dist/esm/utils/BlockFinder.js.map +1 -1
- package/dist/esm/utils/BlockUtils.js +40 -31
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/BundleUtils.js +24 -21
- package/dist/esm/utils/BundleUtils.js.map +1 -1
- package/dist/esm/utils/CCTPUtils.js +123 -62
- package/dist/esm/utils/CCTPUtils.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +38 -17
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/ContractUtils.js +3 -3
- package/dist/esm/utils/ContractUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.js +98 -121
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +69 -52
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/FormattingUtils.js +26 -20
- package/dist/esm/utils/FormattingUtils.js.map +1 -1
- package/dist/esm/utils/HyperLiquidUtils.js +22 -8
- package/dist/esm/utils/HyperLiquidUtils.js.map +1 -1
- package/dist/esm/utils/IPFSUtils.js +35 -16
- package/dist/esm/utils/IPFSUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +4 -4
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/LogUtils.js +12 -8
- package/dist/esm/utils/LogUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js +110 -50
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.js +28 -12
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/NumberUtils.js +3 -1
- package/dist/esm/utils/NumberUtils.js.map +1 -1
- package/dist/esm/utils/ObjectUtils.js +41 -27
- package/dist/esm/utils/ObjectUtils.js.map +1 -1
- package/dist/esm/utils/Profiler.js +82 -77
- package/dist/esm/utils/Profiler.js.map +1 -1
- package/dist/esm/utils/ReviverUtils.js +7 -3
- package/dist/esm/utils/ReviverUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +78 -83
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.js +57 -33
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/esm/utils/ValidatorUtils.js +4 -4
- package/dist/esm/utils/ValidatorUtils.js.map +1 -1
- package/dist/esm/utils/abi/index.js +20 -10
- package/dist/esm/utils/abi/index.js.map +1 -1
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js +12 -8
- package/dist/esm/utils/abi/typechain/factories/Multicall3__factory.js.map +1 -1
- package/dist/esm/utils/common.js +52 -38
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +1 -0
- package/src/gasPriceOracle/oracle.ts +1 -0
- package/src/utils/Multicall.ts +1 -0
- package/src/utils/NetworkUtils.ts +8 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
1
2
|
import { MessageTransmitterClient, SpokePool__factory, SvmSpokeClient } from "@across-protocol/contracts";
|
|
2
3
|
import { BN, BorshEventCoder } from "@coral-xyz/anchor";
|
|
3
4
|
import { address, appendTransactionMessageInstruction, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, getU32Encoder, getU64Encoder, isAddress, pipe, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, signTransactionMessageWithSigners, } from "@solana/kit";
|
|
@@ -11,20 +12,34 @@ import { SVMEventNames } from "./types";
|
|
|
11
12
|
/**
|
|
12
13
|
* Basic void TransactionSigner type
|
|
13
14
|
*/
|
|
14
|
-
export
|
|
15
|
+
export var SolanaVoidSigner = function (simulationAddress) {
|
|
15
16
|
return {
|
|
16
17
|
address: address(simulationAddress),
|
|
17
|
-
signAndSendTransactions:
|
|
18
|
-
return
|
|
19
|
-
|
|
18
|
+
signAndSendTransactions: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
19
|
+
return __generator(this, function (_a) {
|
|
20
|
+
switch (_a.label) {
|
|
21
|
+
case 0: return [4 /*yield*/, Promise.resolve([])];
|
|
22
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}); },
|
|
20
26
|
};
|
|
21
27
|
};
|
|
22
28
|
/**
|
|
23
29
|
* Helper to determine if the current RPC network is devnet.
|
|
24
30
|
*/
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
export function isDevnet(rpc) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
33
|
+
var genesisHash;
|
|
34
|
+
return __generator(this, function (_a) {
|
|
35
|
+
switch (_a.label) {
|
|
36
|
+
case 0: return [4 /*yield*/, rpc.getGenesisHash().send()];
|
|
37
|
+
case 1:
|
|
38
|
+
genesisHash = _a.sent();
|
|
39
|
+
return [2 /*return*/, genesisHash === "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
28
43
|
}
|
|
29
44
|
/**
|
|
30
45
|
* Small utility to convert an Address to a Solana Kit branded type.
|
|
@@ -38,36 +53,75 @@ export function toAddress(address) {
|
|
|
38
53
|
* @param opts An object containing a specific slot number, or a Solana commitment, defaulting to "confirmed".
|
|
39
54
|
* @returns An object containing the slot number and the relevant timestamp for the block.
|
|
40
55
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
56
|
+
export function getNearestSlotTime(provider_1) {
|
|
57
|
+
return __awaiter(this, arguments, void 0, function (provider, opts, logger) {
|
|
58
|
+
var timestamp, slot, _a, maxRetries;
|
|
59
|
+
if (opts === void 0) { opts = { commitment: "confirmed" }; }
|
|
60
|
+
return __generator(this, function (_b) {
|
|
61
|
+
switch (_b.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (!("slot" in opts)) return [3 /*break*/, 1];
|
|
64
|
+
_a = opts.slot;
|
|
65
|
+
return [3 /*break*/, 3];
|
|
66
|
+
case 1: return [4 /*yield*/, getSlot(provider, opts.commitment, logger)];
|
|
67
|
+
case 2:
|
|
68
|
+
_a = _b.sent();
|
|
69
|
+
_b.label = 3;
|
|
70
|
+
case 3:
|
|
71
|
+
slot = _a;
|
|
72
|
+
maxRetries = undefined;
|
|
73
|
+
_b.label = 4;
|
|
74
|
+
case 4: return [4 /*yield*/, getTimestampForSlot(provider, slot, maxRetries, logger)];
|
|
75
|
+
case 5:
|
|
76
|
+
timestamp = _b.sent();
|
|
77
|
+
_b.label = 6;
|
|
78
|
+
case 6:
|
|
79
|
+
if (!isDefined(timestamp) && --slot) return [3 /*break*/, 4];
|
|
80
|
+
_b.label = 7;
|
|
81
|
+
case 7:
|
|
82
|
+
assert(isDefined(timestamp), "Unable to resolve block time for SVM slot ".concat(slot));
|
|
83
|
+
return [2 /*return*/, { slot: slot, timestamp: timestamp }];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
50
87
|
}
|
|
51
88
|
/**
|
|
52
89
|
* Resolve the latest finalized slot, and then work backwards to find the nearest slot containing a block.
|
|
53
90
|
* In most cases the first-resolved slot should also have a block. Avoid making arbitrary decisions about
|
|
54
91
|
* how many slots to rotate through.
|
|
55
92
|
*/
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
export function getLatestFinalizedSlotWithBlock(provider_1, logger_1, maxSlot_1) {
|
|
94
|
+
return __awaiter(this, arguments, void 0, function (provider, logger, maxSlot, maxLookback) {
|
|
95
|
+
var opts, finalizedSlot, endSlot, slot, block;
|
|
96
|
+
if (maxLookback === void 0) { maxLookback = 1000; }
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
opts = { maxSupportedTransactionVersion: 0, transactionDetails: "none", rewards: false };
|
|
101
|
+
return [4 /*yield*/, getNearestSlotTime(provider, { commitment: "finalized" }, logger)];
|
|
102
|
+
case 1:
|
|
103
|
+
finalizedSlot = (_a.sent()).slot;
|
|
104
|
+
endSlot = biMin(maxSlot, finalizedSlot);
|
|
105
|
+
slot = endSlot;
|
|
106
|
+
_a.label = 2;
|
|
107
|
+
case 2: return [4 /*yield*/, provider.getBlock(slot, opts).send()];
|
|
108
|
+
case 3:
|
|
109
|
+
block = _a.sent();
|
|
110
|
+
if (isDefined(block) && [block.blockHeight, block.blockTime].every(isDefined)) {
|
|
111
|
+
return [3 /*break*/, 5];
|
|
112
|
+
}
|
|
113
|
+
_a.label = 4;
|
|
114
|
+
case 4:
|
|
115
|
+
if (--maxLookback > 0 && --slot > 0) return [3 /*break*/, 2];
|
|
116
|
+
_a.label = 5;
|
|
117
|
+
case 5:
|
|
118
|
+
if (maxLookback === 0) {
|
|
119
|
+
throw new Error("Unable to find Solana block between slots [".concat(slot, ", ").concat(endSlot, "]"));
|
|
120
|
+
}
|
|
121
|
+
return [2 /*return*/, Number(slot)];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
71
125
|
}
|
|
72
126
|
/**
|
|
73
127
|
* Parses event data from a transaction.
|
|
@@ -83,7 +137,7 @@ export function parseEventData(eventData) {
|
|
|
83
137
|
return new Uint8Array(eventData);
|
|
84
138
|
}
|
|
85
139
|
if (typeof eventData === "object") {
|
|
86
|
-
|
|
140
|
+
var stringTag = Object.prototype.toString.call(eventData);
|
|
87
141
|
if (stringTag.includes("PublicKey")) {
|
|
88
142
|
return address(eventData.toString());
|
|
89
143
|
}
|
|
@@ -91,7 +145,10 @@ export function parseEventData(eventData) {
|
|
|
91
145
|
return BigInt(eventData.toString());
|
|
92
146
|
}
|
|
93
147
|
// Convert each key from snake_case to camelCase and process the value recursively.
|
|
94
|
-
return Object.fromEntries(Object.entries(eventData).map(
|
|
148
|
+
return Object.fromEntries(Object.entries(eventData).map(function (_a) {
|
|
149
|
+
var key = _a[0], value = _a[1];
|
|
150
|
+
return [snakeToCamel(key), parseEventData(value)];
|
|
151
|
+
}));
|
|
95
152
|
}
|
|
96
153
|
return eventData;
|
|
97
154
|
}
|
|
@@ -99,9 +156,9 @@ export function parseEventData(eventData) {
|
|
|
99
156
|
* Decodes a raw event according to a supplied IDL.
|
|
100
157
|
*/
|
|
101
158
|
export function decodeEvent(idl, rawEvent) {
|
|
102
|
-
|
|
159
|
+
var event = new BorshEventCoder(idl).decode(rawEvent);
|
|
103
160
|
if (!event)
|
|
104
|
-
throw new Error(
|
|
161
|
+
throw new Error("Malformed rawEvent for IDL ".concat(idl.address, ": ").concat(rawEvent));
|
|
105
162
|
return {
|
|
106
163
|
name: event.name,
|
|
107
164
|
data: parseEventData(event.data),
|
|
@@ -111,28 +168,29 @@ export function decodeEvent(idl, rawEvent) {
|
|
|
111
168
|
* Converts a snake_case string to camelCase.
|
|
112
169
|
*/
|
|
113
170
|
function snakeToCamel(s) {
|
|
114
|
-
return s.replace(/(_\w)/g, (match)
|
|
171
|
+
return s.replace(/(_\w)/g, function (match) { return match[1].toUpperCase(); });
|
|
115
172
|
}
|
|
116
173
|
/**
|
|
117
174
|
* Gets the event name from a raw name.
|
|
118
175
|
*/
|
|
119
176
|
export function getEventName(rawName) {
|
|
120
|
-
if (Object.values(SVMEventNames).some((name)
|
|
177
|
+
if (Object.values(SVMEventNames).some(function (name) { return rawName.includes(name); }))
|
|
121
178
|
return rawName;
|
|
122
|
-
throw new Error(
|
|
179
|
+
throw new Error("Unknown event name: ".concat(rawName));
|
|
123
180
|
}
|
|
124
181
|
/**
|
|
125
182
|
* Unwraps any data structure and converts Address types to strings and Uint8Array to hex or BigInt.
|
|
126
183
|
* Recursively processes nested objects and arrays.
|
|
127
184
|
*/
|
|
128
|
-
export function unwrapEventData(data, uint8ArrayKeysAsBigInt
|
|
185
|
+
export function unwrapEventData(data, uint8ArrayKeysAsBigInt, currentKey) {
|
|
186
|
+
if (uint8ArrayKeysAsBigInt === void 0) { uint8ArrayKeysAsBigInt = ["depositId", "outputAmount", "inputAmount"]; }
|
|
129
187
|
// Handle null/undefined
|
|
130
188
|
if (data == null) {
|
|
131
189
|
return data;
|
|
132
190
|
}
|
|
133
191
|
// Handle BigInt
|
|
134
192
|
if (typeof data === "bigint") {
|
|
135
|
-
|
|
193
|
+
var bigIntKeysAsNumber = ["originChainId", "destinationChainId", "repaymentChainId", "chainId"];
|
|
136
194
|
if (currentKey && bigIntKeysAsNumber.includes(currentKey)) {
|
|
137
195
|
return Number(data);
|
|
138
196
|
}
|
|
@@ -140,8 +198,8 @@ export function unwrapEventData(data, uint8ArrayKeysAsBigInt = ["depositId", "ou
|
|
|
140
198
|
}
|
|
141
199
|
// Handle Uint8Array and byte arrays
|
|
142
200
|
if (data instanceof Uint8Array || isUint8Array(data)) {
|
|
143
|
-
|
|
144
|
-
|
|
201
|
+
var bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
202
|
+
var hex = ethers.utils.hexlify(bytes);
|
|
145
203
|
if (currentKey && uint8ArrayKeysAsBigInt.includes(currentKey)) {
|
|
146
204
|
return BigNumber.from(hex);
|
|
147
205
|
}
|
|
@@ -149,7 +207,7 @@ export function unwrapEventData(data, uint8ArrayKeysAsBigInt = ["depositId", "ou
|
|
|
149
207
|
}
|
|
150
208
|
// Handle regular arrays (non-byte arrays)
|
|
151
209
|
if (Array.isArray(data)) {
|
|
152
|
-
return data.map((item)
|
|
210
|
+
return data.map(function (item) { return unwrapEventData(item, uint8ArrayKeysAsBigInt); });
|
|
153
211
|
}
|
|
154
212
|
// Handle strings (potential addresses)
|
|
155
213
|
if (typeof data === "string" && isAddress(data)) {
|
|
@@ -160,7 +218,7 @@ export function unwrapEventData(data, uint8ArrayKeysAsBigInt = ["depositId", "ou
|
|
|
160
218
|
// Special case: if an object is in the context of the fillType key, then
|
|
161
219
|
// parse out the fillType from the object
|
|
162
220
|
if (currentKey === "fillType") {
|
|
163
|
-
|
|
221
|
+
var fillType = Object.keys(data)[0];
|
|
164
222
|
switch (fillType) {
|
|
165
223
|
case "FastFill":
|
|
166
224
|
return FillType.FastFill;
|
|
@@ -169,17 +227,20 @@ export function unwrapEventData(data, uint8ArrayKeysAsBigInt = ["depositId", "ou
|
|
|
169
227
|
case "SlowFill":
|
|
170
228
|
return FillType.SlowFill;
|
|
171
229
|
default:
|
|
172
|
-
throw new Error(
|
|
230
|
+
throw new Error("Unknown fill type: ".concat(fillType));
|
|
173
231
|
}
|
|
174
232
|
}
|
|
175
233
|
// Special case: if an object is empty, return 0x
|
|
176
234
|
if (Object.keys(data).length === 0) {
|
|
177
235
|
return "0x";
|
|
178
236
|
}
|
|
179
|
-
return Object.fromEntries(Object.entries(data).map((
|
|
180
|
-
key,
|
|
181
|
-
|
|
182
|
-
|
|
237
|
+
return Object.fromEntries(Object.entries(data).map(function (_a) {
|
|
238
|
+
var key = _a[0], value = _a[1];
|
|
239
|
+
return [
|
|
240
|
+
key,
|
|
241
|
+
unwrapEventData(value, uint8ArrayKeysAsBigInt, key),
|
|
242
|
+
];
|
|
243
|
+
}));
|
|
183
244
|
}
|
|
184
245
|
// Return primitives as is
|
|
185
246
|
return data;
|
|
@@ -189,14 +250,24 @@ export function unwrapEventData(data, uint8ArrayKeysAsBigInt = ["depositId", "ou
|
|
|
189
250
|
* @param programId The SpokePool program ID.
|
|
190
251
|
* @returns The PDA for the State account.
|
|
191
252
|
*/
|
|
192
|
-
export
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
253
|
+
export function getStatePda(programId) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
var intEncoder, seed, statePda;
|
|
256
|
+
return __generator(this, function (_a) {
|
|
257
|
+
switch (_a.label) {
|
|
258
|
+
case 0:
|
|
259
|
+
intEncoder = getU64Encoder();
|
|
260
|
+
seed = intEncoder.encode(0);
|
|
261
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
262
|
+
programAddress: programId,
|
|
263
|
+
seeds: ["state", seed],
|
|
264
|
+
})];
|
|
265
|
+
case 1:
|
|
266
|
+
statePda = (_a.sent())[0];
|
|
267
|
+
return [2 /*return*/, statePda];
|
|
268
|
+
}
|
|
269
|
+
});
|
|
198
270
|
});
|
|
199
|
-
return statePda;
|
|
200
271
|
}
|
|
201
272
|
/**
|
|
202
273
|
* Returns the fill status PDA for the given relay data.
|
|
@@ -205,15 +276,26 @@ export async function getStatePda(programId) {
|
|
|
205
276
|
* @param destinationChainId The destination chain ID.
|
|
206
277
|
* @returns The PDA for the fill status.
|
|
207
278
|
*/
|
|
208
|
-
export
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
279
|
+
export function getFillStatusPda(programId, relayData, destinationChainId) {
|
|
280
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
+
var messageHash, relayDataHash, uint8RelayDataHash, fillStatusPda;
|
|
282
|
+
var _a;
|
|
283
|
+
return __generator(this, function (_b) {
|
|
284
|
+
switch (_b.label) {
|
|
285
|
+
case 0:
|
|
286
|
+
messageHash = (_a = relayData.messageHash) !== null && _a !== void 0 ? _a : getMessageHash(relayData.message);
|
|
287
|
+
relayDataHash = getRelayDataHash(__assign(__assign({}, relayData), { messageHash: messageHash }), destinationChainId);
|
|
288
|
+
uint8RelayDataHash = new Uint8Array(Buffer.from(relayDataHash.slice(2), "hex"));
|
|
289
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
290
|
+
programAddress: programId,
|
|
291
|
+
seeds: ["fills", uint8RelayDataHash],
|
|
292
|
+
})];
|
|
293
|
+
case 1:
|
|
294
|
+
fillStatusPda = (_b.sent())[0];
|
|
295
|
+
return [2 /*return*/, fillStatusPda];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
215
298
|
});
|
|
216
|
-
return fillStatusPda;
|
|
217
299
|
}
|
|
218
300
|
/**
|
|
219
301
|
* Returns the PDA for a route account on SVM Spoke.
|
|
@@ -222,55 +304,95 @@ export async function getFillStatusPda(programId, relayData, destinationChainId)
|
|
|
222
304
|
* @param routeChainId The route chain ID.
|
|
223
305
|
* @returns The PDA for the route account.
|
|
224
306
|
*/
|
|
225
|
-
export
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
307
|
+
export function getRoutePda(originToken, seed, routeChainId) {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
309
|
+
var intEncoder, addressEncoder, pda;
|
|
310
|
+
return __generator(this, function (_a) {
|
|
311
|
+
switch (_a.label) {
|
|
312
|
+
case 0:
|
|
313
|
+
intEncoder = getU64Encoder();
|
|
314
|
+
addressEncoder = getAddressEncoder();
|
|
315
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
316
|
+
programAddress: address(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
|
|
317
|
+
seeds: ["route", addressEncoder.encode(originToken), intEncoder.encode(seed), intEncoder.encode(routeChainId)],
|
|
318
|
+
})];
|
|
319
|
+
case 1:
|
|
320
|
+
pda = (_a.sent())[0];
|
|
321
|
+
return [2 /*return*/, pda];
|
|
322
|
+
}
|
|
323
|
+
});
|
|
231
324
|
});
|
|
232
|
-
return pda;
|
|
233
325
|
}
|
|
234
326
|
/**
|
|
235
327
|
* Returns the PDA for the SVM Spoke's transfer liability account.
|
|
236
328
|
* @param programId the address of the spoke pool.
|
|
237
329
|
* @param originToken the address of the corresponding token.
|
|
238
330
|
*/
|
|
239
|
-
export
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
331
|
+
export function getTransferLiabilityPda(programId, originToken) {
|
|
332
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
333
|
+
var addressEncoder, pda;
|
|
334
|
+
return __generator(this, function (_a) {
|
|
335
|
+
switch (_a.label) {
|
|
336
|
+
case 0:
|
|
337
|
+
addressEncoder = getAddressEncoder();
|
|
338
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
339
|
+
programAddress: programId,
|
|
340
|
+
seeds: ["transfer_liability", addressEncoder.encode(originToken)],
|
|
341
|
+
})];
|
|
342
|
+
case 1:
|
|
343
|
+
pda = (_a.sent())[0];
|
|
344
|
+
return [2 /*return*/, pda];
|
|
345
|
+
}
|
|
346
|
+
});
|
|
244
347
|
});
|
|
245
|
-
return pda;
|
|
246
348
|
}
|
|
247
349
|
/**
|
|
248
350
|
* Returns the PDA for the SVM Spoke's root bundle account.
|
|
249
351
|
* @param programId the address of the spoke pool.
|
|
250
352
|
* @param rootBundleId the associated root bundle ID.
|
|
251
353
|
*/
|
|
252
|
-
export
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
354
|
+
export function getRootBundlePda(programId, rootBundleId) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
+
var seedEncoder, seed, intEncoder, pda;
|
|
357
|
+
return __generator(this, function (_a) {
|
|
358
|
+
switch (_a.label) {
|
|
359
|
+
case 0:
|
|
360
|
+
seedEncoder = getU64Encoder();
|
|
361
|
+
seed = seedEncoder.encode(0);
|
|
362
|
+
intEncoder = getU32Encoder();
|
|
363
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
364
|
+
programAddress: programId,
|
|
365
|
+
seeds: ["root_bundle", seed, intEncoder.encode(rootBundleId)],
|
|
366
|
+
})];
|
|
367
|
+
case 1:
|
|
368
|
+
pda = (_a.sent())[0];
|
|
369
|
+
return [2 /*return*/, pda];
|
|
370
|
+
}
|
|
371
|
+
});
|
|
259
372
|
});
|
|
260
|
-
return pda;
|
|
261
373
|
}
|
|
262
374
|
/**
|
|
263
375
|
* Returns the PDA for the SVM Spoke's instruction params account.
|
|
264
376
|
* @param programId the address of the spoke pool.
|
|
265
377
|
* @param signer the signer of the authenticated call.
|
|
266
378
|
*/
|
|
267
|
-
export
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
379
|
+
export function getInstructionParamsPda(programId, signer) {
|
|
380
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
381
|
+
var addressEncoder, pda;
|
|
382
|
+
return __generator(this, function (_a) {
|
|
383
|
+
switch (_a.label) {
|
|
384
|
+
case 0:
|
|
385
|
+
addressEncoder = getAddressEncoder();
|
|
386
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
387
|
+
programAddress: programId,
|
|
388
|
+
seeds: ["instruction_params", addressEncoder.encode(signer)],
|
|
389
|
+
})];
|
|
390
|
+
case 1:
|
|
391
|
+
pda = (_a.sent())[0];
|
|
392
|
+
return [2 /*return*/, pda];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
272
395
|
});
|
|
273
|
-
return pda;
|
|
274
396
|
}
|
|
275
397
|
/**
|
|
276
398
|
* Returns the PDA for an individual's claim account.
|
|
@@ -278,42 +400,68 @@ export async function getInstructionParamsPda(programId, signer) {
|
|
|
278
400
|
* @param mint the address of the token.
|
|
279
401
|
* @param tokenOwner the address of the signer which owns the claim account.
|
|
280
402
|
*/
|
|
281
|
-
export
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
403
|
+
export function getClaimAccountPda(programId, mint, tokenOwner) {
|
|
404
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
405
|
+
var addressEncoder, pda;
|
|
406
|
+
return __generator(this, function (_a) {
|
|
407
|
+
switch (_a.label) {
|
|
408
|
+
case 0:
|
|
409
|
+
addressEncoder = getAddressEncoder();
|
|
410
|
+
return [4 /*yield*/, getProgramDerivedAddress({
|
|
411
|
+
programAddress: programId,
|
|
412
|
+
seeds: ["claim_account", addressEncoder.encode(mint), addressEncoder.encode(tokenOwner)],
|
|
413
|
+
})];
|
|
414
|
+
case 1:
|
|
415
|
+
pda = (_a.sent())[0];
|
|
416
|
+
return [2 /*return*/, pda];
|
|
417
|
+
}
|
|
418
|
+
});
|
|
286
419
|
});
|
|
287
|
-
return pda;
|
|
288
420
|
}
|
|
289
421
|
/**
|
|
290
422
|
* Returns the PDA for the Event Authority.
|
|
291
423
|
* @returns The PDA for the Event Authority.
|
|
292
424
|
*/
|
|
293
|
-
export
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
425
|
+
export function getEventAuthority(programId) {
|
|
426
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
427
|
+
var eventAuthority;
|
|
428
|
+
return __generator(this, function (_a) {
|
|
429
|
+
switch (_a.label) {
|
|
430
|
+
case 0: return [4 /*yield*/, getProgramDerivedAddress({
|
|
431
|
+
programAddress: programId,
|
|
432
|
+
seeds: ["__event_authority"],
|
|
433
|
+
})];
|
|
434
|
+
case 1:
|
|
435
|
+
eventAuthority = (_a.sent())[0];
|
|
436
|
+
return [2 /*return*/, eventAuthority];
|
|
437
|
+
}
|
|
438
|
+
});
|
|
297
439
|
});
|
|
298
|
-
return eventAuthority;
|
|
299
440
|
}
|
|
300
441
|
/**
|
|
301
442
|
* Returns the PDA for the Self Authority.
|
|
302
443
|
* @returns The PDA for the Self Authority.
|
|
303
444
|
*/
|
|
304
|
-
export
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
445
|
+
export var getSelfAuthority = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
446
|
+
var selfAuthority;
|
|
447
|
+
return __generator(this, function (_a) {
|
|
448
|
+
switch (_a.label) {
|
|
449
|
+
case 0: return [4 /*yield*/, getProgramDerivedAddress({
|
|
450
|
+
programAddress: address(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
|
|
451
|
+
seeds: ["self_authority"],
|
|
452
|
+
})];
|
|
453
|
+
case 1:
|
|
454
|
+
selfAuthority = (_a.sent())[0];
|
|
455
|
+
return [2 /*return*/, selfAuthority];
|
|
456
|
+
}
|
|
308
457
|
});
|
|
309
|
-
|
|
310
|
-
};
|
|
458
|
+
}); };
|
|
311
459
|
/**
|
|
312
460
|
* Returns a random SVM address.
|
|
313
461
|
*/
|
|
314
462
|
export function getRandomSvmAddress() {
|
|
315
|
-
|
|
316
|
-
|
|
463
|
+
var bytes = ethers.utils.randomBytes(32);
|
|
464
|
+
var base58Address = bs58.encode(bytes);
|
|
317
465
|
return address(base58Address);
|
|
318
466
|
}
|
|
319
467
|
/**
|
|
@@ -322,10 +470,24 @@ export function getRandomSvmAddress() {
|
|
|
322
470
|
* @param signer - The signer of the transaction.
|
|
323
471
|
* @returns The default transaction.
|
|
324
472
|
*/
|
|
325
|
-
export
|
|
326
|
-
|
|
327
|
-
return
|
|
328
|
-
|
|
473
|
+
export var createDefaultTransaction = function (rpcClient, signer, latestBlockhash) { return __awaiter(void 0, void 0, void 0, function () {
|
|
474
|
+
var _a;
|
|
475
|
+
return __generator(this, function (_b) {
|
|
476
|
+
switch (_b.label) {
|
|
477
|
+
case 0:
|
|
478
|
+
if (!isDefined(latestBlockhash)) return [3 /*break*/, 1];
|
|
479
|
+
_a = latestBlockhash;
|
|
480
|
+
return [3 /*break*/, 3];
|
|
481
|
+
case 1: return [4 /*yield*/, rpcClient.getLatestBlockhash().send()];
|
|
482
|
+
case 2:
|
|
483
|
+
_a = (_b.sent()).value;
|
|
484
|
+
_b.label = 3;
|
|
485
|
+
case 3:
|
|
486
|
+
latestBlockhash = _a;
|
|
487
|
+
return [2 /*return*/, pipe(createTransactionMessage({ version: 0 }), function (tx) { return setTransactionMessageFeePayerSigner(signer, tx); }, function (tx) { return setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx); })];
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}); };
|
|
329
491
|
/**
|
|
330
492
|
* Simulates a transaction and decodes the result using a parser function.
|
|
331
493
|
* @param solanaClient - The Solana client.
|
|
@@ -334,18 +496,34 @@ export const createDefaultTransaction = async (rpcClient, signer, latestBlockhas
|
|
|
334
496
|
* @param parser - The parser function to decode the result.
|
|
335
497
|
* @returns The decoded result.
|
|
336
498
|
*/
|
|
337
|
-
export
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
499
|
+
export var simulateAndDecode = function (solanaClient, ix, signer, parser, latestBlockhash) { return __awaiter(void 0, void 0, void 0, function () {
|
|
500
|
+
var simulationTx, _a, _b, simulationResult, _c, _d, _e;
|
|
501
|
+
var _f;
|
|
502
|
+
return __generator(this, function (_g) {
|
|
503
|
+
switch (_g.label) {
|
|
504
|
+
case 0:
|
|
505
|
+
_a = appendTransactionMessageInstruction;
|
|
506
|
+
_b = [ix];
|
|
507
|
+
return [4 /*yield*/, createDefaultTransaction(solanaClient, signer, latestBlockhash)];
|
|
508
|
+
case 1:
|
|
509
|
+
simulationTx = _a.apply(void 0, _b.concat([_g.sent()]));
|
|
510
|
+
_d = (_c = solanaClient)
|
|
511
|
+
.simulateTransaction;
|
|
512
|
+
_e = getBase64EncodedWireTransaction;
|
|
513
|
+
return [4 /*yield*/, signTransactionMessageWithSigners(simulationTx)];
|
|
514
|
+
case 2: return [4 /*yield*/, _d.apply(_c, [_e.apply(void 0, [_g.sent()]), {
|
|
515
|
+
encoding: "base64",
|
|
516
|
+
}])
|
|
517
|
+
.send()];
|
|
518
|
+
case 3:
|
|
519
|
+
simulationResult = _g.sent();
|
|
520
|
+
if (!((_f = simulationResult.value.returnData) === null || _f === void 0 ? void 0 : _f.data[0])) {
|
|
521
|
+
throw new Error("svm::simulateAndDecode: simulateTransaction failed. No return data.");
|
|
522
|
+
}
|
|
523
|
+
return [2 /*return*/, parser(Buffer.from(simulationResult.value.returnData.data[0], "base64"))];
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}); };
|
|
349
527
|
/**
|
|
350
528
|
* Converts a common `RelayData` type to an SvmSpokeClient.RelayData` type. This is useful for when we need
|
|
351
529
|
* to interface directly with the SvmSpoke.
|
|
@@ -376,24 +554,34 @@ export function toSvmRelayData(relayData) {
|
|
|
376
554
|
* @param sourceDomain The source domain.
|
|
377
555
|
* @returns The PDA for the CCTP nonce.
|
|
378
556
|
*/
|
|
379
|
-
export
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
557
|
+
export var getCCTPNoncePda = function (solanaClient, signer, nonce, sourceDomain, latestBlockhash) { return __awaiter(void 0, void 0, void 0, function () {
|
|
558
|
+
var messageTransmitterPda, getNonceIx, parserFunction;
|
|
559
|
+
return __generator(this, function (_a) {
|
|
560
|
+
switch (_a.label) {
|
|
561
|
+
case 0: return [4 /*yield*/, getProgramDerivedAddress({
|
|
562
|
+
programAddress: MessageTransmitterClient.MESSAGE_TRANSMITTER_PROGRAM_ADDRESS,
|
|
563
|
+
seeds: ["message_transmitter"],
|
|
564
|
+
})];
|
|
565
|
+
case 1:
|
|
566
|
+
messageTransmitterPda = (_a.sent())[0];
|
|
567
|
+
return [4 /*yield*/, MessageTransmitterClient.getGetNoncePdaInstruction({
|
|
568
|
+
messageTransmitter: messageTransmitterPda,
|
|
569
|
+
nonce: nonce,
|
|
570
|
+
sourceDomain: sourceDomain,
|
|
571
|
+
})];
|
|
572
|
+
case 2:
|
|
573
|
+
getNonceIx = _a.sent();
|
|
574
|
+
parserFunction = function (buf) {
|
|
575
|
+
if (buf.length === 32) {
|
|
576
|
+
return address(bs58.encode(buf));
|
|
577
|
+
}
|
|
578
|
+
throw new Error("Invalid buffer");
|
|
579
|
+
};
|
|
580
|
+
return [4 /*yield*/, simulateAndDecode(solanaClient, getNonceIx, signer, parserFunction, latestBlockhash)];
|
|
581
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
392
582
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return await simulateAndDecode(solanaClient, getNonceIx, signer, parserFunction, latestBlockhash);
|
|
396
|
-
};
|
|
583
|
+
});
|
|
584
|
+
}); };
|
|
397
585
|
/**
|
|
398
586
|
* Checks if a CCTP message is a deposit for burn event.
|
|
399
587
|
* @param event The CCTP message event.
|
|
@@ -405,21 +593,21 @@ export function isDepositForBurnEvent(event) {
|
|
|
405
593
|
/**
|
|
406
594
|
* True if `body` encodes a `relayRootBundle(bytes32,bytes32)` call.
|
|
407
595
|
*/
|
|
408
|
-
export
|
|
596
|
+
export var isRelayRootBundleMessageBody = function (body) {
|
|
409
597
|
if (body.length < 4)
|
|
410
598
|
return false;
|
|
411
|
-
|
|
412
|
-
|
|
599
|
+
var spokePoolInterface = new ethers.utils.Interface(SpokePool__factory.abi);
|
|
600
|
+
var relayRootBundleSelector = spokePoolInterface.getSighash("relayRootBundle");
|
|
413
601
|
return body.slice(0, 4).equals(Buffer.from(relayRootBundleSelector.slice(2), "hex"));
|
|
414
602
|
};
|
|
415
603
|
/**
|
|
416
604
|
* True if `body` encodes a `emergencyDeleteRootBundle(uint32)` call.
|
|
417
605
|
*/
|
|
418
|
-
export
|
|
606
|
+
export var isEmergencyDeleteRootBundleMessageBody = function (body) {
|
|
419
607
|
if (body.length < 4)
|
|
420
608
|
return false;
|
|
421
|
-
|
|
422
|
-
|
|
609
|
+
var spokePoolInterface = new ethers.utils.Interface(SpokePool__factory.abi);
|
|
610
|
+
var emergencyDeleteRootBundleSelector = spokePoolInterface.getSighash("emergencyDeleteRootBundle");
|
|
423
611
|
return body.slice(0, 4).equals(Buffer.from(emergencyDeleteRootBundleSelector.slice(2), "hex"));
|
|
424
612
|
};
|
|
425
613
|
/**
|
|
@@ -427,9 +615,9 @@ export const isEmergencyDeleteRootBundleMessageBody = (body) => {
|
|
|
427
615
|
* @param body The message body.
|
|
428
616
|
* @returns The root bundle ID.
|
|
429
617
|
*/
|
|
430
|
-
export
|
|
431
|
-
|
|
432
|
-
|
|
618
|
+
export var getEmergencyDeleteRootBundleRootBundleId = function (body) {
|
|
619
|
+
var spokePoolInterface = new ethers.utils.Interface(SpokePool__factory.abi);
|
|
620
|
+
var result = spokePoolInterface.decodeFunctionData("emergencyDeleteRootBundle", body);
|
|
433
621
|
return result.rootBundleId.toNumber();
|
|
434
622
|
};
|
|
435
623
|
/**
|
|
@@ -441,9 +629,11 @@ export function bigintToU8a32(n) {
|
|
|
441
629
|
if (n < BigInt(0) || n > ethers.constants.MaxUint256.toBigInt()) {
|
|
442
630
|
throw new RangeError("Value must fit in 256 bits");
|
|
443
631
|
}
|
|
444
|
-
|
|
632
|
+
var hexPadded = ethers.utils.hexZeroPad("0x" + n.toString(16), 32);
|
|
445
633
|
return ethers.utils.arrayify(hexPadded);
|
|
446
634
|
}
|
|
447
|
-
export
|
|
448
|
-
|
|
635
|
+
export var bigToU8a32 = function (bn) {
|
|
636
|
+
return bigintToU8a32(typeof bn === "bigint" ? bn : BigInt(bn.toString()));
|
|
637
|
+
};
|
|
638
|
+
export var numberToU8a32 = function (n) { return bigintToU8a32(BigInt(n)); };
|
|
449
639
|
//# sourceMappingURL=utils.js.map
|