@across-protocol/sdk 4.1.63-alpha.1 → 4.1.63-beta.0
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/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/cjs/arch/evm/SpokeUtils.js +6 -5
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +20 -0
- package/dist/cjs/arch/svm/SpokeUtils.js +428 -0
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -0
- package/dist/cjs/arch/svm/constants.d.ts +1 -0
- package/dist/cjs/arch/svm/constants.js +5 -0
- package/dist/cjs/arch/svm/constants.js.map +1 -0
- package/dist/cjs/arch/svm/eventsClient.d.ts +21 -0
- package/dist/cjs/{svm → arch/svm}/eventsClient.js +60 -28
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -0
- package/dist/cjs/arch/svm/index.d.ts +5 -1
- package/dist/cjs/arch/svm/index.js +6 -2
- package/dist/cjs/arch/svm/index.js.map +1 -1
- package/dist/cjs/{svm → arch/svm}/types.d.ts +9 -4
- package/dist/cjs/arch/svm/types.js.map +1 -0
- package/dist/cjs/arch/svm/utils.d.ts +17 -0
- package/dist/cjs/arch/svm/utils.js +204 -0
- package/dist/cjs/arch/svm/utils.js.map +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +7 -7
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BaseAbstractClient.d.ts +6 -5
- package/dist/cjs/clients/BaseAbstractClient.js +30 -19
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +15 -11
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +90 -90
- package/dist/cjs/clients/HubPoolClient.d.ts +1 -1
- package/dist/cjs/clients/HubPoolClient.js +16 -16
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +23 -20
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +23 -0
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +145 -0
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -5
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +50 -54
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +3 -0
- package/dist/cjs/clients/SpokePoolClient/index.js +8 -1
- package/dist/cjs/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +2 -1
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +2 -2
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +7 -4
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +4 -4
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js +3 -2
- package/dist/cjs/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +3 -3
- package/dist/cjs/gasPriceOracle/adapters/solana.d.ts +4 -0
- package/dist/cjs/gasPriceOracle/adapters/solana.js +43 -0
- package/dist/cjs/gasPriceOracle/adapters/solana.js.map +1 -0
- package/dist/cjs/gasPriceOracle/index.d.ts +1 -1
- package/dist/cjs/gasPriceOracle/oracle.d.ts +4 -3
- package/dist/cjs/gasPriceOracle/oracle.js +16 -9
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.d.ts +6 -1
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +7 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +5 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +7 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +31 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +136 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +9 -3
- package/dist/cjs/utils/AddressUtils.js +36 -6
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ArrayUtils.d.ts +1 -0
- package/dist/cjs/utils/ArrayUtils.js +6 -1
- package/dist/cjs/utils/ArrayUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.d.ts +4 -4
- package/dist/cjs/utils/EventUtils.js +7 -4
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +3 -0
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +5 -0
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +6 -5
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +94 -0
- package/dist/esm/arch/svm/SpokeUtils.js +513 -0
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -0
- package/dist/esm/arch/svm/constants.d.ts +1 -0
- package/dist/esm/arch/svm/constants.js +2 -0
- package/dist/esm/arch/svm/constants.js.map +1 -0
- package/dist/esm/arch/svm/eventsClient.d.ts +67 -0
- package/dist/esm/{svm → arch/svm}/eventsClient.js +69 -27
- package/dist/esm/arch/svm/eventsClient.js.map +1 -0
- package/dist/esm/arch/svm/index.d.ts +5 -1
- package/dist/esm/arch/svm/index.js +5 -1
- package/dist/esm/arch/svm/index.js.map +1 -1
- package/dist/{types → esm/arch}/svm/types.d.ts +9 -5
- package/dist/esm/arch/svm/types.js.map +1 -0
- package/dist/esm/arch/svm/utils.d.ts +59 -0
- package/dist/esm/arch/svm/utils.js +248 -0
- package/dist/esm/arch/svm/utils.js.map +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +7 -7
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BaseAbstractClient.d.ts +6 -5
- package/dist/esm/clients/BaseAbstractClient.js +30 -19
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +17 -14
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +90 -90
- package/dist/esm/clients/HubPoolClient.d.ts +1 -1
- package/dist/esm/clients/HubPoolClient.js +16 -16
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +23 -20
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +67 -0
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +196 -0
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -0
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +51 -55
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +8 -0
- package/dist/esm/clients/SpokePoolClient/index.js +10 -0
- package/dist/esm/clients/SpokePoolClient/index.js.map +1 -1
- package/dist/esm/clients/index.d.ts +1 -1
- package/dist/esm/clients/index.js +1 -1
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +2 -2
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js +2 -2
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +8 -5
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +4 -4
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js +3 -2
- package/dist/esm/gasPriceOracle/adapters/linea-viem.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +4 -4
- package/dist/esm/gasPriceOracle/adapters/polygon.js +1 -1
- package/dist/esm/gasPriceOracle/adapters/solana.d.ts +8 -0
- package/dist/esm/gasPriceOracle/adapters/solana.js +43 -0
- package/dist/esm/gasPriceOracle/adapters/solana.js.map +1 -0
- package/dist/esm/gasPriceOracle/index.d.ts +1 -1
- package/dist/esm/gasPriceOracle/oracle.d.ts +4 -3
- package/dist/esm/gasPriceOracle/oracle.js +18 -9
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.d.ts +6 -1
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +7 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +4 -3
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +8 -2
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +66 -0
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +169 -0
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +9 -3
- package/dist/esm/utils/AddressUtils.js +41 -6
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ArrayUtils.d.ts +6 -0
- package/dist/esm/utils/ArrayUtils.js +9 -0
- package/dist/esm/utils/ArrayUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.d.ts +4 -4
- package/dist/esm/utils/EventUtils.js +7 -4
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +3 -0
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +5 -0
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +95 -0
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -0
- package/dist/types/arch/svm/constants.d.ts +2 -0
- package/dist/types/arch/svm/constants.d.ts.map +1 -0
- package/dist/types/arch/svm/eventsClient.d.ts +68 -0
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -0
- package/dist/types/arch/svm/index.d.ts +5 -1
- package/dist/types/arch/svm/index.d.ts.map +1 -1
- package/dist/{esm → types/arch}/svm/types.d.ts +10 -4
- package/dist/types/arch/svm/types.d.ts.map +1 -0
- package/dist/types/arch/svm/utils.d.ts +60 -0
- package/dist/types/arch/svm/utils.d.ts.map +1 -0
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BaseAbstractClient.d.ts +6 -5
- package/dist/types/clients/BaseAbstractClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +90 -90
- package/dist/types/clients/HubPoolClient.d.ts +1 -1
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -3
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +68 -0
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/index.d.ts +8 -0
- package/dist/types/clients/SpokePoolClient/index.d.ts.map +1 -1
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +2 -2
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +4 -4
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/linea-viem.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts +4 -4
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/solana.d.ts +9 -0
- package/dist/types/gasPriceOracle/adapters/solana.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/index.d.ts +1 -1
- package/dist/types/gasPriceOracle/index.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts +4 -3
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/types.d.ts +6 -1
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +7 -0
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +4 -2
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +67 -0
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -0
- package/dist/types/utils/AddressUtils.d.ts +9 -3
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/ArrayUtils.d.ts +6 -0
- package/dist/types/utils/ArrayUtils.d.ts.map +1 -1
- package/dist/types/utils/EventUtils.d.ts +4 -4
- package/dist/types/utils/EventUtils.d.ts.map +1 -1
- package/dist/types/utils/JSONUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/arch/evm/SpokeUtils.ts +5 -5
- package/src/arch/svm/SpokeUtils.ts +526 -0
- package/src/arch/svm/constants.ts +1 -0
- package/src/{svm → arch/svm}/eventsClient.ts +67 -45
- package/src/arch/svm/index.ts +5 -1
- package/src/{svm → arch/svm}/types.ts +21 -4
- package/src/arch/svm/utils.ts +222 -0
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -7
- package/src/clients/BaseAbstractClient.ts +20 -13
- package/src/clients/BundleDataClient/BundleDataClient.ts +28 -19
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +1 -1
- package/src/clients/HubPoolClient.ts +16 -16
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +23 -21
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +244 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +44 -56
- package/src/clients/SpokePoolClient/index.ts +11 -0
- package/src/clients/index.ts +1 -1
- package/src/clients/mocks/MockConfigStoreClient.ts +2 -2
- package/src/clients/mocks/MockHubPoolClient.ts +2 -2
- package/src/clients/mocks/MockSpokePoolClient.ts +9 -4
- package/src/gasPriceOracle/adapters/arbitrum.ts +5 -2
- package/src/gasPriceOracle/adapters/ethereum.ts +7 -4
- package/src/gasPriceOracle/adapters/linea-viem.ts +3 -1
- package/src/gasPriceOracle/adapters/polygon.ts +6 -6
- package/src/gasPriceOracle/adapters/solana.ts +45 -0
- package/src/gasPriceOracle/index.ts +1 -1
- package/src/gasPriceOracle/oracle.ts +20 -4
- package/src/gasPriceOracle/types.ts +7 -1
- package/src/index.ts +0 -1
- package/src/interfaces/SpokePool.ts +7 -0
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +5 -3
- package/src/relayFeeCalculator/chain-queries/factory.ts +21 -5
- package/src/relayFeeCalculator/chain-queries/index.ts +1 -0
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +193 -0
- package/src/utils/AddressUtils.ts +49 -6
- package/src/utils/ArrayUtils.ts +12 -0
- package/src/utils/EventUtils.ts +11 -11
- package/src/utils/JSONUtils.ts +2 -0
- package/src/utils/SpokeUtils.ts +5 -1
- package/dist/cjs/svm/eventsClient.d.ts +0 -15
- package/dist/cjs/svm/eventsClient.js.map +0 -1
- package/dist/cjs/svm/index.d.ts +0 -3
- package/dist/cjs/svm/index.js +0 -8
- package/dist/cjs/svm/index.js.map +0 -1
- package/dist/cjs/svm/types.js.map +0 -1
- package/dist/cjs/svm/utils/events.d.ts +0 -8
- package/dist/cjs/svm/utils/events.js +0 -47
- package/dist/cjs/svm/utils/events.js.map +0 -1
- package/dist/cjs/svm/utils/helpers.d.ts +0 -2
- package/dist/cjs/svm/utils/helpers.js +0 -19
- package/dist/cjs/svm/utils/helpers.js.map +0 -1
- package/dist/cjs/svm/utils/index.d.ts +0 -1
- package/dist/cjs/svm/utils/index.js +0 -5
- package/dist/cjs/svm/utils/index.js.map +0 -1
- package/dist/esm/svm/eventsClient.d.ts +0 -51
- package/dist/esm/svm/eventsClient.js.map +0 -1
- package/dist/esm/svm/index.d.ts +0 -3
- package/dist/esm/svm/index.js +0 -5
- package/dist/esm/svm/index.js.map +0 -1
- package/dist/esm/svm/types.js.map +0 -1
- package/dist/esm/svm/utils/events.d.ts +0 -17
- package/dist/esm/svm/utils/events.js +0 -55
- package/dist/esm/svm/utils/events.js.map +0 -1
- package/dist/esm/svm/utils/helpers.d.ts +0 -5
- package/dist/esm/svm/utils/helpers.js +0 -18
- package/dist/esm/svm/utils/helpers.js.map +0 -1
- package/dist/esm/svm/utils/index.d.ts +0 -1
- package/dist/esm/svm/utils/index.js +0 -2
- package/dist/esm/svm/utils/index.js.map +0 -1
- package/dist/types/svm/eventsClient.d.ts +0 -52
- package/dist/types/svm/eventsClient.d.ts.map +0 -1
- package/dist/types/svm/index.d.ts +0 -4
- package/dist/types/svm/index.d.ts.map +0 -1
- package/dist/types/svm/types.d.ts.map +0 -1
- package/dist/types/svm/utils/events.d.ts +0 -18
- package/dist/types/svm/utils/events.d.ts.map +0 -1
- package/dist/types/svm/utils/helpers.d.ts +0 -6
- package/dist/types/svm/utils/helpers.d.ts.map +0 -1
- package/dist/types/svm/utils/index.d.ts +0 -2
- package/dist/types/svm/utils/index.d.ts.map +0 -1
- package/src/svm/index.ts +0 -3
- package/src/svm/utils/events.ts +0 -58
- package/src/svm/utils/helpers.ts +0 -9
- package/src/svm/utils/index.ts +0 -1
- /package/dist/cjs/{svm → arch/svm}/types.js +0 -0
- /package/dist/esm/{svm → arch/svm}/types.js +0 -0
|
@@ -32,7 +32,7 @@ export function getWidestPossibleExpectedBlockRange(
|
|
|
32
32
|
// filled during the challenge period.
|
|
33
33
|
const latestPossibleBundleEndBlockNumbers = chainIdListForBundleEvaluationBlockNumbers.map(
|
|
34
34
|
(chainId: number, index) =>
|
|
35
|
-
spokeClients[chainId] && Math.max(spokeClients[chainId].
|
|
35
|
+
spokeClients[chainId] && Math.max(spokeClients[chainId].latestHeightSearched - endBlockBuffers[index], 0)
|
|
36
36
|
);
|
|
37
37
|
return chainIdListForBundleEvaluationBlockNumbers.map((chainId: number, index) => {
|
|
38
38
|
const lastEndBlockForChain = clients.hubPoolClient.getLatestBundleEndBlockForChain(
|
|
@@ -105,7 +105,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
105
105
|
public configStoreClient: ConfigStoreClient,
|
|
106
106
|
public deploymentBlock = 0,
|
|
107
107
|
readonly chainId: number = 1,
|
|
108
|
-
eventSearchConfig: MakeOptional<EventSearchConfig, "
|
|
108
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 },
|
|
109
109
|
protected readonly configOverride: {
|
|
110
110
|
ignoredHubExecutedBundles: number[];
|
|
111
111
|
ignoredHubProposedBundles: number[];
|
|
@@ -117,8 +117,8 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
117
117
|
cachingMechanism?: CachingMechanismInterface
|
|
118
118
|
) {
|
|
119
119
|
super(eventSearchConfig, cachingMechanism);
|
|
120
|
-
this.
|
|
121
|
-
this.
|
|
120
|
+
this.latestHeightSearched = Math.min(deploymentBlock - 1, 0);
|
|
121
|
+
this.firstHeightToSearch = eventSearchConfig.from;
|
|
122
122
|
|
|
123
123
|
const provider = this.hubPool.provider;
|
|
124
124
|
this.blockFinder = new BlockFinder(provider);
|
|
@@ -254,7 +254,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
254
254
|
return l2Token !== undefined;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
-
l2TokenHasPoolRebalanceRoute(l2Token: string, l2ChainId: number, hubPoolBlock = this.
|
|
257
|
+
l2TokenHasPoolRebalanceRoute(l2Token: string, l2ChainId: number, hubPoolBlock = this.latestHeightSearched): boolean {
|
|
258
258
|
return Object.values(this.l1TokensToDestinationTokensWithBlock).some((destinationTokenMapping) => {
|
|
259
259
|
return Object.entries(destinationTokenMapping).some(([_l2ChainId, setPoolRebalanceRouteEvents]) => {
|
|
260
260
|
return setPoolRebalanceRouteEvents.some((e) => {
|
|
@@ -312,7 +312,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
async getCurrentPoolUtilization(l1Token: string): Promise<BigNumber> {
|
|
315
|
-
const blockNumber = this.
|
|
315
|
+
const blockNumber = this.latestHeightSearched ?? (await this.hubPool.provider.getBlockNumber());
|
|
316
316
|
return await this.getUtilization(l1Token, blockNumber, bnZero, getCurrentTime(), 0);
|
|
317
317
|
}
|
|
318
318
|
|
|
@@ -523,7 +523,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
523
523
|
chainIdA: number,
|
|
524
524
|
tokenB: string,
|
|
525
525
|
chainIdB: number,
|
|
526
|
-
hubPoolBlock = this.
|
|
526
|
+
hubPoolBlock = this.latestHeightSearched
|
|
527
527
|
): boolean {
|
|
528
528
|
if (
|
|
529
529
|
!this.l2TokenHasPoolRebalanceRoute(tokenA, chainIdA, hubPoolBlock) ||
|
|
@@ -719,7 +719,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
719
719
|
if (n === 0) {
|
|
720
720
|
throw new Error("n cannot be 0");
|
|
721
721
|
}
|
|
722
|
-
if (!this.
|
|
722
|
+
if (!this.latestHeightSearched) {
|
|
723
723
|
throw new Error("HubPoolClient::getNthFullyExecutedRootBundle client not updated");
|
|
724
724
|
}
|
|
725
725
|
|
|
@@ -728,7 +728,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
728
728
|
// If n is negative, then return the Nth latest executed bundle, otherwise return the Nth earliest
|
|
729
729
|
// executed bundle.
|
|
730
730
|
if (n < 0) {
|
|
731
|
-
let nextLatestMainnetBlock = startBlock ?? this.
|
|
731
|
+
let nextLatestMainnetBlock = startBlock ?? this.latestHeightSearched;
|
|
732
732
|
for (let i = 0; i < Math.abs(n); i++) {
|
|
733
733
|
bundleToReturn = this.getLatestFullyExecutedRootBundle(nextLatestMainnetBlock);
|
|
734
734
|
const bundleBlockNumber = bundleToReturn ? bundleToReturn.blockNumber : 0;
|
|
@@ -740,12 +740,12 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
740
740
|
} else {
|
|
741
741
|
let nextStartBlock = startBlock ?? 0;
|
|
742
742
|
for (let i = 0; i < n; i++) {
|
|
743
|
-
bundleToReturn = this.getEarliestFullyExecutedRootBundle(this.
|
|
743
|
+
bundleToReturn = this.getEarliestFullyExecutedRootBundle(this.latestHeightSearched, nextStartBlock);
|
|
744
744
|
const bundleBlockNumber = bundleToReturn ? bundleToReturn.blockNumber : 0;
|
|
745
745
|
|
|
746
746
|
// Add 1 so that next `getEarliestFullyExecutedRootBundle` call filters out the root bundle we just found
|
|
747
747
|
// because its block number is < nextStartBlock.
|
|
748
|
-
nextStartBlock = Math.min(bundleBlockNumber + 1, this.
|
|
748
|
+
nextStartBlock = Math.min(bundleBlockNumber + 1, this.latestHeightSearched);
|
|
749
749
|
}
|
|
750
750
|
}
|
|
751
751
|
|
|
@@ -831,7 +831,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
831
831
|
// instantiation. However, certain events generally must be queried back to HubPool genesis.
|
|
832
832
|
const overrideEvents = ["CrossChainContractsSet", "L1TokenEnabledForLiquidityProvision", "SetPoolRebalanceRoute"];
|
|
833
833
|
if (overrideEvents.includes(eventName) && !this.isUpdated) {
|
|
834
|
-
_searchConfig.
|
|
834
|
+
_searchConfig.from = this.deploymentBlock;
|
|
835
835
|
}
|
|
836
836
|
|
|
837
837
|
return {
|
|
@@ -853,7 +853,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
853
853
|
const [multicallOutput, ...events] = await Promise.all([
|
|
854
854
|
hubPool.callStatic.multicall(
|
|
855
855
|
multicallFunctions.map((f) => hubPool.interface.encodeFunctionData(f)),
|
|
856
|
-
{ blockTag: searchConfig.
|
|
856
|
+
{ blockTag: searchConfig.to }
|
|
857
857
|
),
|
|
858
858
|
...eventSearchConfigs.map((config) => paginatedEventQuery(hubPool, config.filter, config.searchConfig)),
|
|
859
859
|
]);
|
|
@@ -874,7 +874,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
874
874
|
success: true,
|
|
875
875
|
currentTime,
|
|
876
876
|
pendingRootBundleProposal,
|
|
877
|
-
searchEndBlock: searchConfig.
|
|
877
|
+
searchEndBlock: searchConfig.to,
|
|
878
878
|
events: _events,
|
|
879
879
|
};
|
|
880
880
|
}
|
|
@@ -1087,9 +1087,9 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1087
1087
|
}
|
|
1088
1088
|
|
|
1089
1089
|
this.currentTime = currentTime;
|
|
1090
|
-
this.
|
|
1091
|
-
this.
|
|
1092
|
-
this.eventSearchConfig.
|
|
1090
|
+
this.latestHeightSearched = searchEndBlock;
|
|
1091
|
+
this.firstHeightToSearch = update.searchEndBlock + 1; // Next iteration should start off from where this one ended.
|
|
1092
|
+
this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary.
|
|
1093
1093
|
|
|
1094
1094
|
this.isUpdated = true;
|
|
1095
1095
|
this.logger.debug({ at: "HubPoolClient::update", message: "HubPool client updated!", searchEndBlock });
|
|
@@ -39,20 +39,17 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
39
39
|
hubPoolClient: HubPoolClient | null,
|
|
40
40
|
chainId: number,
|
|
41
41
|
deploymentBlock: number,
|
|
42
|
-
eventSearchConfig: MakeOptional<EventSearchConfig, "
|
|
42
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 }
|
|
43
43
|
) {
|
|
44
44
|
super(logger, hubPoolClient, chainId, deploymentBlock, eventSearchConfig);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
public override relayFillStatus(relayData: RelayData,
|
|
48
|
-
return relayFillStatus(this.spokePool, relayData,
|
|
47
|
+
public override relayFillStatus(relayData: RelayData, atHeight?: number): Promise<FillStatus> {
|
|
48
|
+
return relayFillStatus(this.spokePool, relayData, atHeight, this.chainId);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
public override fillStatusArray(
|
|
52
|
-
relayData
|
|
53
|
-
blockTag?: number | "latest"
|
|
54
|
-
): Promise<(FillStatus | undefined)[]> {
|
|
55
|
-
return fillStatusArray(this.spokePool, relayData, blockTag);
|
|
51
|
+
public override fillStatusArray(relayData: RelayData[], atHeight?: number): Promise<(FillStatus | undefined)[]> {
|
|
52
|
+
return fillStatusArray(this.spokePool, relayData, atHeight);
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
public override getMaxFillDeadlineInRange(startBlock: number, endBlock: number): Promise<number> {
|
|
@@ -89,7 +86,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
89
86
|
// However, certain events have special overriding requirements to their search ranges:
|
|
90
87
|
// - EnabledDepositRoute: The full history is always required, so override the requested fromBlock.
|
|
91
88
|
if (eventName === "EnabledDepositRoute" && !this.isUpdated) {
|
|
92
|
-
_searchConfig.
|
|
89
|
+
_searchConfig.from = this.deploymentBlock;
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
return {
|
|
@@ -110,7 +107,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
110
107
|
const [multicallOutput, ...events] = await Promise.all([
|
|
111
108
|
spokePool.callStatic.multicall(
|
|
112
109
|
multicallFunctions.map((f) => spokePool.interface.encodeFunctionData(f)),
|
|
113
|
-
{ blockTag: searchConfig.
|
|
110
|
+
{ blockTag: searchConfig.to }
|
|
114
111
|
),
|
|
115
112
|
...eventSearchConfigs.map((config) => paginatedEventQuery(this.spokePool, config.filter, config.searchConfig)),
|
|
116
113
|
]);
|
|
@@ -124,17 +121,22 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
124
121
|
const errMsg = BigNumber.isBigNumber(currentTime)
|
|
125
122
|
? `currentTime: ${currentTime} < ${toBN(this.currentTime)}`
|
|
126
123
|
: `currentTime is not a BigNumber: ${JSON.stringify(currentTime)}`;
|
|
127
|
-
throw new Error(`
|
|
124
|
+
throw new Error(`EVMSpokePoolClient::update: ${errMsg}`);
|
|
128
125
|
}
|
|
129
126
|
|
|
130
127
|
// Sort all events to ensure they are stored in a consistent order.
|
|
131
128
|
events.forEach((events) => sortEventsAscendingInPlace(events.map(logToSortableEvent)));
|
|
132
129
|
|
|
130
|
+
// Map events to SortableEvent
|
|
131
|
+
const eventsWithBlockNumber = events.map((eventList) =>
|
|
132
|
+
eventList.map((event) => spreadEventWithBlockNumber(event))
|
|
133
|
+
);
|
|
134
|
+
|
|
133
135
|
return {
|
|
134
136
|
success: true,
|
|
135
137
|
currentTime: currentTime.toNumber(), // uint32
|
|
136
|
-
searchEndBlock: searchConfig.
|
|
137
|
-
events,
|
|
138
|
+
searchEndBlock: searchConfig.to,
|
|
139
|
+
events: eventsWithBlockNumber,
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -149,31 +151,31 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
// No deposit found; revert to searching for it.
|
|
152
|
-
const upperBound = this.
|
|
153
|
-
const
|
|
154
|
+
const upperBound = this.latestHeightSearched || undefined; // Don't permit block 0 as the high block.
|
|
155
|
+
const from = await findDepositBlock(this.spokePool, depositId, this.deploymentBlock, upperBound);
|
|
154
156
|
const chain = getNetworkName(this.chainId);
|
|
155
|
-
if (!
|
|
157
|
+
if (!from) {
|
|
156
158
|
const reason =
|
|
157
159
|
`Unable to find ${chain} depositId ${depositId}` +
|
|
158
160
|
` within blocks [${this.deploymentBlock}, ${upperBound ?? "latest"}].`;
|
|
159
161
|
return { found: false, code: InvalidFill.DepositIdNotFound, reason };
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
const
|
|
164
|
+
const to = from;
|
|
163
165
|
const tStart = Date.now();
|
|
164
166
|
// Check both V3FundsDeposited and FundsDeposited events to look for a specified depositId.
|
|
165
|
-
const {
|
|
167
|
+
const { maxLookBack } = this.eventSearchConfig;
|
|
166
168
|
const query = (
|
|
167
169
|
await Promise.all([
|
|
168
170
|
paginatedEventQuery(
|
|
169
171
|
this.spokePool,
|
|
170
172
|
this.spokePool.filters.V3FundsDeposited(null, null, null, null, null, depositId),
|
|
171
|
-
{
|
|
173
|
+
{ from, to, maxLookBack }
|
|
172
174
|
),
|
|
173
175
|
paginatedEventQuery(
|
|
174
176
|
this.spokePool,
|
|
175
177
|
this.spokePool.filters.FundsDeposited(null, null, null, null, null, depositId),
|
|
176
|
-
{
|
|
178
|
+
{ from, to, maxLookBack }
|
|
177
179
|
),
|
|
178
180
|
])
|
|
179
181
|
).flat();
|
|
@@ -184,7 +186,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
184
186
|
return {
|
|
185
187
|
found: false,
|
|
186
188
|
code: InvalidFill.DepositIdNotFound,
|
|
187
|
-
reason: `${chain} depositId ${depositId} not found at block ${
|
|
189
|
+
reason: `${chain} depositId ${depositId} not found at block ${from}.`,
|
|
188
190
|
};
|
|
189
191
|
}
|
|
190
192
|
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Address, Rpc, RpcTransport, SolanaRpcApiFromTransport } from "@solana/kit";
|
|
2
|
+
import winston from "winston";
|
|
3
|
+
import {
|
|
4
|
+
SVMEventNames,
|
|
5
|
+
unwrapEventData,
|
|
6
|
+
getFillDeadline,
|
|
7
|
+
getTimestampForSlot,
|
|
8
|
+
getStatePda,
|
|
9
|
+
SvmCpiEventsClient,
|
|
10
|
+
relayFillStatus,
|
|
11
|
+
fillStatusArray,
|
|
12
|
+
} from "../../arch/svm";
|
|
13
|
+
import { FillStatus, RelayData, SortableEvent } from "../../interfaces";
|
|
14
|
+
import {
|
|
15
|
+
BigNumber,
|
|
16
|
+
DepositSearchResult,
|
|
17
|
+
EventSearchConfig,
|
|
18
|
+
MakeOptional,
|
|
19
|
+
sortEventsAscendingInPlace,
|
|
20
|
+
} from "../../utils";
|
|
21
|
+
import { isUpdateFailureReason } from "../BaseAbstractClient";
|
|
22
|
+
import { HubPoolClient } from "../HubPoolClient";
|
|
23
|
+
import { knownEventNames, SpokePoolClient, SpokePoolUpdate } from "./SpokePoolClient";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* SvmSpokePoolClient is a client for the SVM SpokePool program. It extends the base SpokePoolClient
|
|
27
|
+
* and implements the abstract methods required for interacting with an SVM Spoke Pool.
|
|
28
|
+
*/
|
|
29
|
+
export class SvmSpokePoolClient extends SpokePoolClient {
|
|
30
|
+
/**
|
|
31
|
+
* Protected constructor. Use the async create() method to instantiate.
|
|
32
|
+
*/
|
|
33
|
+
protected constructor(
|
|
34
|
+
logger: winston.Logger,
|
|
35
|
+
hubPoolClient: HubPoolClient | null,
|
|
36
|
+
chainId: number,
|
|
37
|
+
deploymentSlot: bigint, // Using slot instead of block number for SVM
|
|
38
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to">,
|
|
39
|
+
public svmEventsClient: SvmCpiEventsClient,
|
|
40
|
+
protected programId: Address,
|
|
41
|
+
protected statePda: Address
|
|
42
|
+
) {
|
|
43
|
+
// Convert deploymentSlot to number for base class, might need refinement
|
|
44
|
+
super(logger, hubPoolClient, chainId, Number(deploymentSlot), eventSearchConfig);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Factory method to asynchronously create an instance of SvmSpokePoolClient.
|
|
49
|
+
*/
|
|
50
|
+
public static async create(
|
|
51
|
+
logger: winston.Logger,
|
|
52
|
+
hubPoolClient: HubPoolClient | null,
|
|
53
|
+
chainId: number,
|
|
54
|
+
deploymentSlot: bigint,
|
|
55
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 }, // Provide default
|
|
56
|
+
rpc: Rpc<SolanaRpcApiFromTransport<RpcTransport>>
|
|
57
|
+
): Promise<SvmSpokePoolClient> {
|
|
58
|
+
const svmEventsClient = await SvmCpiEventsClient.create(rpc);
|
|
59
|
+
const programId = svmEventsClient.getProgramAddress();
|
|
60
|
+
const statePda = await getStatePda(programId);
|
|
61
|
+
return new SvmSpokePoolClient(
|
|
62
|
+
logger,
|
|
63
|
+
hubPoolClient,
|
|
64
|
+
chainId,
|
|
65
|
+
deploymentSlot,
|
|
66
|
+
eventSearchConfig,
|
|
67
|
+
svmEventsClient,
|
|
68
|
+
programId,
|
|
69
|
+
statePda
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Factory method to asynchronously create an instance of SvmSpokePoolClient with an existing event client.
|
|
75
|
+
*/
|
|
76
|
+
public static async createWithExistingEventClient(
|
|
77
|
+
logger: winston.Logger,
|
|
78
|
+
hubPoolClient: HubPoolClient | null,
|
|
79
|
+
chainId: number,
|
|
80
|
+
deploymentSlot: bigint,
|
|
81
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 }, // Provide default
|
|
82
|
+
eventClient: SvmCpiEventsClient
|
|
83
|
+
) {
|
|
84
|
+
const programId = eventClient.getProgramAddress();
|
|
85
|
+
const statePda = await getStatePda(programId);
|
|
86
|
+
return new SvmSpokePoolClient(
|
|
87
|
+
logger,
|
|
88
|
+
hubPoolClient,
|
|
89
|
+
chainId,
|
|
90
|
+
deploymentSlot,
|
|
91
|
+
eventSearchConfig,
|
|
92
|
+
eventClient,
|
|
93
|
+
programId,
|
|
94
|
+
statePda
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
public _queryableEventNames(): string[] {
|
|
99
|
+
// We want to take the internal event names relevant to
|
|
100
|
+
// the SVM SpokePoolClient and filter them against the
|
|
101
|
+
// knownEventNames list that we reference in practice
|
|
102
|
+
const internalEventNames = Object.values(SVMEventNames);
|
|
103
|
+
return internalEventNames.filter((e) => knownEventNames.includes(e));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Performs an update to refresh the state of this client by querying SVM events.
|
|
108
|
+
*/
|
|
109
|
+
protected async _update(eventsToQuery: string[]): Promise<SpokePoolUpdate> {
|
|
110
|
+
const searchConfig = await this.updateSearchConfig(this.svmEventsClient.getRpc());
|
|
111
|
+
if (isUpdateFailureReason(searchConfig)) {
|
|
112
|
+
const reason = searchConfig;
|
|
113
|
+
return { success: false, reason };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const deploymentSlot = BigInt(this.deploymentBlock);
|
|
117
|
+
|
|
118
|
+
const eventSearchConfigs = eventsToQuery.map((eventName) => {
|
|
119
|
+
if (!this._queryableEventNames().includes(eventName)) {
|
|
120
|
+
throw new Error(`SpokePoolClient: Cannot query unrecognised SpokePool event name: ${eventName}`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const _searchConfig = { ...searchConfig }; // shallow copy
|
|
124
|
+
|
|
125
|
+
// By default, an event's query range is controlled by the `eventSearchConfig` passed in during instantiation.
|
|
126
|
+
// However, certain events have special overriding requirements to their search ranges:
|
|
127
|
+
// - EnabledDepositRoute: The full history is always required, so override the requested fromBlock.
|
|
128
|
+
if (eventName === "EnabledDepositRoute" && !this.isUpdated) {
|
|
129
|
+
_searchConfig.from = Number(deploymentSlot);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return _searchConfig as EventSearchConfig;
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const spokePoolAddress = this.svmEventsClient.getProgramAddress();
|
|
136
|
+
|
|
137
|
+
this.log("debug", `Updating SpokePool client for chain ${this.chainId}`, {
|
|
138
|
+
eventsToQuery,
|
|
139
|
+
searchConfig,
|
|
140
|
+
spokePool: spokePoolAddress,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
const timerStart = Date.now();
|
|
144
|
+
|
|
145
|
+
const [currentTime, ...eventsQueried] = await Promise.all([
|
|
146
|
+
this.svmEventsClient.getRpc().getBlockTime(BigInt(searchConfig.to)).send(),
|
|
147
|
+
...eventsToQuery.map(async (eventName, idx) => {
|
|
148
|
+
const config = eventSearchConfigs[idx];
|
|
149
|
+
const events = await this.svmEventsClient.queryEvents(
|
|
150
|
+
eventName as SVMEventNames,
|
|
151
|
+
BigInt(config.from),
|
|
152
|
+
BigInt(config.to),
|
|
153
|
+
{
|
|
154
|
+
limit: config.maxLookBack,
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
return events.map(
|
|
158
|
+
(event): SortableEvent => ({
|
|
159
|
+
txnRef: event.signature,
|
|
160
|
+
blockNumber: Number(event.slot),
|
|
161
|
+
txnIndex: 0,
|
|
162
|
+
logIndex: 0,
|
|
163
|
+
...(unwrapEventData(event.data) as Record<string, unknown>),
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
}),
|
|
167
|
+
]);
|
|
168
|
+
this.log("debug", `Time to query new events from RPC for ${this.chainId}: ${Date.now() - timerStart} ms`);
|
|
169
|
+
if (currentTime < this.currentTime) {
|
|
170
|
+
const errMsg = `currentTime: ${currentTime} < ${this.currentTime}`;
|
|
171
|
+
throw new Error(`SvmSpokePoolClient::update: ${errMsg}`);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Sort all events to ensure they are stored in a consistent order.
|
|
175
|
+
eventsQueried.forEach((events) => sortEventsAscendingInPlace(events));
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
success: true,
|
|
179
|
+
currentTime: Number(currentTime), // uint32
|
|
180
|
+
searchEndBlock: searchConfig.to,
|
|
181
|
+
events: eventsQueried,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Retrieves the fill deadline buffer fetched from the State PDA.
|
|
187
|
+
* @note This function assumes that fill deadline buffer is a constant value in svm environments.
|
|
188
|
+
*/
|
|
189
|
+
public override getMaxFillDeadlineInRange(_startSlot: number, _endSlot: number): Promise<number> {
|
|
190
|
+
return getFillDeadline(this.svmEventsClient.getRpc(), this.statePda);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Retrieves the timestamp for a given SVM slot number.
|
|
195
|
+
*/
|
|
196
|
+
public override getTimestampForBlock(slot: number): Promise<number> {
|
|
197
|
+
return getTimestampForSlot(this.svmEventsClient.getRpc(), slot);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Retrieves the timestamp for a given SVM slot number.
|
|
202
|
+
* @note This function uses the same underlying function as getTimestampForBlock.
|
|
203
|
+
* It is kept for consistency with the EVM SpokePoolClient.
|
|
204
|
+
*/
|
|
205
|
+
public getTimeAt(slot: number): Promise<number> {
|
|
206
|
+
return getTimestampForSlot(this.svmEventsClient.getRpc(), slot);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Finds a deposit based on its deposit ID on the SVM chain.
|
|
211
|
+
* TODO: Implement SVM state query for deposit details.
|
|
212
|
+
*/
|
|
213
|
+
public findDeposit(_depositId: BigNumber): Promise<DepositSearchResult> {
|
|
214
|
+
throw new Error("findDeposit not implemented for SVM");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Retrieves the fill status for a given relay data from the SVM chain.
|
|
219
|
+
*/
|
|
220
|
+
public override relayFillStatus(
|
|
221
|
+
relayData: RelayData,
|
|
222
|
+
atHeight?: number,
|
|
223
|
+
destinationChainId?: number
|
|
224
|
+
): Promise<FillStatus> {
|
|
225
|
+
destinationChainId ??= this.chainId;
|
|
226
|
+
return relayFillStatus(this.programId, relayData, destinationChainId, this.svmEventsClient, atHeight);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Retrieves the fill status for an array of given relay data.
|
|
231
|
+
* @param relayData The array relay data to retrieve the fill status for.
|
|
232
|
+
* @param atHeight The slot at which to query the fill status.
|
|
233
|
+
* @returns The fill status for each of the given relay data.
|
|
234
|
+
*/
|
|
235
|
+
public fillStatusArray(
|
|
236
|
+
relayData: RelayData[],
|
|
237
|
+
atHeight?: number,
|
|
238
|
+
destinationChainId?: number
|
|
239
|
+
): Promise<(FillStatus | undefined)[]> {
|
|
240
|
+
// @note: deploymentBlock actually refers to the deployment slot. Also, blockTag should be a slot number.
|
|
241
|
+
destinationChainId ??= this.chainId;
|
|
242
|
+
return fillStatusArray(this.programId, relayData, destinationChainId, this.svmEventsClient, atHeight, this.logger);
|
|
243
|
+
}
|
|
244
|
+
}
|