@across-protocol/sdk 4.1.62 → 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 +4 -1
- 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
|
@@ -1,17 +1,10 @@
|
|
|
1
|
+
import { Idl } from "@coral-xyz/anchor";
|
|
1
2
|
import { getDeployedAddress, SvmSpokeIdl } from "@across-protocol/contracts";
|
|
2
3
|
import { getSolanaChainId } from "@across-protocol/contracts/dist/src/svm/web3-v1";
|
|
3
|
-
import web3, {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
GetTransactionApi,
|
|
8
|
-
RpcTransport,
|
|
9
|
-
Signature,
|
|
10
|
-
} from "@solana/kit";
|
|
11
|
-
import { bs58 } from "../utils";
|
|
12
|
-
import { EventData, EventName, EventWithData } from "./types";
|
|
13
|
-
import { decodeEvent } from "./utils/events";
|
|
14
|
-
import { isDevnet } from "./utils/helpers";
|
|
4
|
+
import web3, { Address, Commitment, GetSignaturesForAddressApi, GetTransactionApi, Signature } from "@solana/kit";
|
|
5
|
+
import { bs58 } from "../../utils";
|
|
6
|
+
import { EventName, EventWithData, SVMProvider } from "./types";
|
|
7
|
+
import { decodeEvent, isDevnet } from "./utils";
|
|
15
8
|
|
|
16
9
|
// Utility type to extract the return type for the JSON encoding overload. We only care about the overload where the
|
|
17
10
|
// configuration parameter (C) has the optional property 'encoding' set to 'json'.
|
|
@@ -26,39 +19,39 @@ type GetSignaturesForAddressConfig = Parameters<GetSignaturesForAddressApi["getS
|
|
|
26
19
|
type GetSignaturesForAddressTransaction = ReturnType<GetSignaturesForAddressApi["getSignaturesForAddress"]>[number];
|
|
27
20
|
type GetSignaturesForAddressApiResponse = readonly GetSignaturesForAddressTransaction[];
|
|
28
21
|
|
|
29
|
-
export class
|
|
30
|
-
private rpc:
|
|
31
|
-
private
|
|
32
|
-
private
|
|
22
|
+
export class SvmCpiEventsClient {
|
|
23
|
+
private rpc: SVMProvider;
|
|
24
|
+
private programAddress: Address;
|
|
25
|
+
private programEventAuthority: Address;
|
|
26
|
+
private idl: Idl;
|
|
33
27
|
|
|
34
28
|
/**
|
|
35
|
-
*
|
|
29
|
+
* Protected constructor. Use the async create() method to instantiate.
|
|
36
30
|
*/
|
|
37
|
-
|
|
38
|
-
rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>,
|
|
39
|
-
svmSpokeAddress: Address,
|
|
40
|
-
eventAuthority: Address
|
|
41
|
-
) {
|
|
31
|
+
protected constructor(rpc: SVMProvider, address: Address, eventAuthority: Address, idl: Idl) {
|
|
42
32
|
this.rpc = rpc;
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
33
|
+
this.programAddress = address;
|
|
34
|
+
this.programEventAuthority = eventAuthority;
|
|
35
|
+
this.idl = idl;
|
|
45
36
|
}
|
|
46
37
|
|
|
47
38
|
/**
|
|
48
39
|
* Factory method to asynchronously create an instance of SvmSpokeEventsClient.
|
|
49
40
|
*/
|
|
50
|
-
public static async create(
|
|
51
|
-
rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>
|
|
52
|
-
): Promise<SvmSpokeEventsClient> {
|
|
41
|
+
public static async create(rpc: SVMProvider): Promise<SvmCpiEventsClient> {
|
|
53
42
|
const isTestnet = await isDevnet(rpc);
|
|
54
43
|
const programId = getDeployedAddress("SvmSpoke", getSolanaChainId(isTestnet ? "devnet" : "mainnet").toString());
|
|
55
44
|
if (!programId) throw new Error("Program not found");
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
45
|
+
return this.createFor(rpc, programId, SvmSpokeIdl);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public static async createFor(rpc: SVMProvider, programId: string, idl: Idl): Promise<SvmCpiEventsClient> {
|
|
49
|
+
const address = web3.address(programId);
|
|
50
|
+
const [eventAuthority] = await web3.getProgramDerivedAddress({
|
|
51
|
+
programAddress: address,
|
|
59
52
|
seeds: ["__event_authority"],
|
|
60
53
|
});
|
|
61
|
-
return new
|
|
54
|
+
return new SvmCpiEventsClient(rpc, address, eventAuthority, idl);
|
|
62
55
|
}
|
|
63
56
|
|
|
64
57
|
/**
|
|
@@ -70,14 +63,34 @@ export class SvmSpokeEventsClient {
|
|
|
70
63
|
* @param options - Options for fetching signatures.
|
|
71
64
|
* @returns A promise that resolves to an array of events matching the eventName.
|
|
72
65
|
*/
|
|
73
|
-
public async queryEvents
|
|
66
|
+
public async queryEvents(
|
|
74
67
|
eventName: EventName,
|
|
75
68
|
fromSlot?: bigint,
|
|
76
69
|
toSlot?: bigint,
|
|
77
70
|
options: GetSignaturesForAddressConfig = { limit: 1000, commitment: "confirmed" }
|
|
78
|
-
): Promise<EventWithData
|
|
71
|
+
): Promise<EventWithData[]> {
|
|
79
72
|
const events = await this.queryAllEvents(fromSlot, toSlot, options);
|
|
80
|
-
return events.filter((event) => event.name === eventName) as EventWithData
|
|
73
|
+
return events.filter((event) => event.name === eventName) as EventWithData[];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Queries events for the provided derived address at instantiation filtered by event name.
|
|
78
|
+
*
|
|
79
|
+
* @param eventName - The name of the event to filter by.
|
|
80
|
+
* @param fromSlot - Optional starting slot.
|
|
81
|
+
* @param toSlot - Optional ending slot.
|
|
82
|
+
* @param options - Options for fetching signatures.
|
|
83
|
+
* @returns A promise that resolves to an array of events matching the eventName.
|
|
84
|
+
*/
|
|
85
|
+
public async queryDerivedAddressEvents(
|
|
86
|
+
eventName: string,
|
|
87
|
+
derivedAddress: Address,
|
|
88
|
+
fromSlot?: bigint,
|
|
89
|
+
toSlot?: bigint,
|
|
90
|
+
options: GetSignaturesForAddressConfig = { limit: 1000, commitment: "confirmed" }
|
|
91
|
+
): Promise<EventWithData[]> {
|
|
92
|
+
const events = await this.queryAllEvents(fromSlot, toSlot, options, derivedAddress);
|
|
93
|
+
return events.filter((event) => event.name === eventName) as EventWithData[];
|
|
81
94
|
}
|
|
82
95
|
|
|
83
96
|
/**
|
|
@@ -86,20 +99,23 @@ export class SvmSpokeEventsClient {
|
|
|
86
99
|
* @param fromSlot - Optional starting slot.
|
|
87
100
|
* @param toSlot - Optional ending slot.
|
|
88
101
|
* @param options - Options for fetching signatures.
|
|
102
|
+
* @param forDerivedAddress - Whether to query events for the program or the derived address.
|
|
89
103
|
* @returns A promise that resolves to an array of all events with additional metadata.
|
|
90
104
|
*/
|
|
91
105
|
private async queryAllEvents(
|
|
92
106
|
fromSlot?: bigint,
|
|
93
107
|
toSlot?: bigint,
|
|
94
|
-
options: GetSignaturesForAddressConfig = { limit: 1000, commitment: "confirmed" }
|
|
95
|
-
|
|
108
|
+
options: GetSignaturesForAddressConfig = { limit: 1000, commitment: "confirmed" },
|
|
109
|
+
derivedAddress?: Address
|
|
110
|
+
): Promise<EventWithData[]> {
|
|
111
|
+
const addressToQuery = derivedAddress || this.programAddress;
|
|
96
112
|
const allSignatures: GetSignaturesForAddressTransaction[] = [];
|
|
97
113
|
let hasMoreSignatures = true;
|
|
98
114
|
let currentOptions = options;
|
|
99
115
|
|
|
100
116
|
while (hasMoreSignatures) {
|
|
101
117
|
const signatures: GetSignaturesForAddressApiResponse = await this.rpc
|
|
102
|
-
.getSignaturesForAddress(
|
|
118
|
+
.getSignaturesForAddress(addressToQuery!, currentOptions)
|
|
103
119
|
.send();
|
|
104
120
|
// Signatures are sorted by slot in descending order.
|
|
105
121
|
allSignatures.push(...signatures);
|
|
@@ -162,11 +178,9 @@ export class SvmSpokeEventsClient {
|
|
|
162
178
|
* @param txResult - The transaction result.
|
|
163
179
|
* @returns A promise that resolves to an array of events with their data and name.
|
|
164
180
|
*/
|
|
165
|
-
private processEventFromTx(
|
|
166
|
-
txResult: GetTransactionReturnType
|
|
167
|
-
): { program: Address; data: EventData; name: EventName }[] {
|
|
181
|
+
private processEventFromTx(txResult: GetTransactionReturnType): { program: Address; data: unknown; name: string }[] {
|
|
168
182
|
if (!txResult) return [];
|
|
169
|
-
const events: { program: Address; data:
|
|
183
|
+
const events: { program: Address; data: unknown; name: string }[] = [];
|
|
170
184
|
|
|
171
185
|
const accountKeys = txResult.transaction.message.accountKeys;
|
|
172
186
|
const messageAccountKeys = [...accountKeys];
|
|
@@ -182,18 +196,26 @@ export class SvmSpokeEventsClient {
|
|
|
182
196
|
if (
|
|
183
197
|
ixProgramId !== undefined &&
|
|
184
198
|
singleIxAccount !== undefined &&
|
|
185
|
-
this.
|
|
186
|
-
this.
|
|
199
|
+
this.programAddress === ixProgramId &&
|
|
200
|
+
this.programEventAuthority === singleIxAccount
|
|
187
201
|
) {
|
|
188
202
|
const ixData = bs58.decode(ix.data);
|
|
189
203
|
// Skip the first 8 bytes (assumed header) and encode the rest.
|
|
190
204
|
const eventData = Buffer.from(ixData.slice(8)).toString("base64");
|
|
191
|
-
const { name, data } = decodeEvent(
|
|
192
|
-
events.push({ program: this.
|
|
205
|
+
const { name, data } = decodeEvent(this.idl, eventData);
|
|
206
|
+
events.push({ program: this.programAddress, name, data });
|
|
193
207
|
}
|
|
194
208
|
}
|
|
195
209
|
}
|
|
196
210
|
|
|
197
211
|
return events;
|
|
198
212
|
}
|
|
213
|
+
|
|
214
|
+
public getProgramAddress(): Address {
|
|
215
|
+
return this.programAddress;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public getRpc(): SVMProvider {
|
|
219
|
+
return this.rpc;
|
|
220
|
+
}
|
|
199
221
|
}
|
package/src/arch/svm/index.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import { Signature, Address, UnixTimestamp } from "@solana/kit";
|
|
2
1
|
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
2
|
+
import {
|
|
3
|
+
Address,
|
|
4
|
+
Rpc,
|
|
5
|
+
RpcSubscriptions,
|
|
6
|
+
RpcTransport,
|
|
7
|
+
Signature,
|
|
8
|
+
SignatureNotificationsApi,
|
|
9
|
+
SlotNotificationsApi,
|
|
10
|
+
SolanaRpcApiFromTransport,
|
|
11
|
+
UnixTimestamp,
|
|
12
|
+
} from "@solana/kit";
|
|
3
13
|
|
|
4
14
|
export type EventData =
|
|
5
15
|
| SvmSpokeClient.BridgedToHubPool
|
|
@@ -36,12 +46,19 @@ export enum SVMEventNames {
|
|
|
36
46
|
|
|
37
47
|
export type EventName = keyof typeof SVMEventNames;
|
|
38
48
|
|
|
39
|
-
export type EventWithData
|
|
49
|
+
export type EventWithData = {
|
|
40
50
|
confirmationStatus: string | null;
|
|
41
51
|
blockTime: UnixTimestamp | null;
|
|
42
52
|
signature: Signature;
|
|
43
53
|
slot: bigint;
|
|
44
|
-
name:
|
|
45
|
-
data:
|
|
54
|
+
name: string;
|
|
55
|
+
data: unknown;
|
|
46
56
|
program: Address;
|
|
47
57
|
};
|
|
58
|
+
|
|
59
|
+
// Typed aggregate of JSON‑RPC and subscription clients.
|
|
60
|
+
export type RpcClient = {
|
|
61
|
+
rpc: Rpc<SolanaRpcApiFromTransport<RpcTransport>>;
|
|
62
|
+
rpcSubscriptions: RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi>;
|
|
63
|
+
};
|
|
64
|
+
export type SVMProvider = Rpc<SolanaRpcApiFromTransport<RpcTransport>>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { BN, BorshEventCoder, Idl } from "@coral-xyz/anchor";
|
|
2
|
+
import {
|
|
3
|
+
address,
|
|
4
|
+
getProgramDerivedAddress,
|
|
5
|
+
getU64Encoder,
|
|
6
|
+
getAddressEncoder,
|
|
7
|
+
Address,
|
|
8
|
+
isAddress,
|
|
9
|
+
type TransactionSigner,
|
|
10
|
+
} from "@solana/kit";
|
|
11
|
+
import { BigNumber, getRelayDataHash, isUint8Array, SvmAddress } from "../../utils";
|
|
12
|
+
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
13
|
+
import { FillType, RelayData } from "../../interfaces";
|
|
14
|
+
import { EventName, SVMEventNames, SVMProvider } from "./types";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Basic void TransactionSigner type
|
|
18
|
+
*/
|
|
19
|
+
export const SolanaVoidSigner: (simulationAddress: string) => TransactionSigner<string> = (
|
|
20
|
+
simulationAddress: string
|
|
21
|
+
) => {
|
|
22
|
+
return {
|
|
23
|
+
address: address(simulationAddress),
|
|
24
|
+
signAndSendTransactions: async () => {
|
|
25
|
+
return await Promise.resolve([]);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Helper to determine if the current RPC network is devnet.
|
|
32
|
+
*/
|
|
33
|
+
export async function isDevnet(rpc: SVMProvider): Promise<boolean> {
|
|
34
|
+
const genesisHash = await rpc.getGenesisHash().send();
|
|
35
|
+
return genesisHash === "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Parses event data from a transaction.
|
|
40
|
+
*/
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
export function parseEventData(eventData: any): any {
|
|
43
|
+
if (!eventData) return eventData;
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(eventData)) {
|
|
46
|
+
return eventData.map(parseEventData);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (typeof eventData === "object") {
|
|
50
|
+
if (eventData.constructor.name === "PublicKey") {
|
|
51
|
+
return address(eventData.toString());
|
|
52
|
+
}
|
|
53
|
+
if (BN.isBN(eventData)) {
|
|
54
|
+
return BigInt(eventData.toString());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Convert each key from snake_case to camelCase and process the value recursively.
|
|
58
|
+
return Object.fromEntries(
|
|
59
|
+
Object.entries(eventData).map(([key, value]) => [snakeToCamel(key), parseEventData(value)])
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return eventData;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Decodes a raw event according to a supplied IDL.
|
|
68
|
+
*/
|
|
69
|
+
export function decodeEvent(idl: Idl, rawEvent: string): { data: unknown; name: string } {
|
|
70
|
+
const event = new BorshEventCoder(idl).decode(rawEvent);
|
|
71
|
+
if (!event) throw new Error(`Malformed rawEvent for IDL ${idl.address}: ${rawEvent}`);
|
|
72
|
+
return {
|
|
73
|
+
name: event.name,
|
|
74
|
+
data: parseEventData(event.data),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Converts a snake_case string to camelCase.
|
|
80
|
+
*/
|
|
81
|
+
function snakeToCamel(s: string): string {
|
|
82
|
+
return s.replace(/(_\w)/g, (match) => match[1].toUpperCase());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Gets the event name from a raw name.
|
|
87
|
+
*/
|
|
88
|
+
export function getEventName(rawName: string): EventName {
|
|
89
|
+
if (Object.values(SVMEventNames).some((name) => rawName.includes(name))) return rawName as EventName;
|
|
90
|
+
throw new Error(`Unknown event name: ${rawName}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Unwraps any data structure and converts Address types to strings and Uint8Array to hex or BigInt.
|
|
95
|
+
* Recursively processes nested objects and arrays.
|
|
96
|
+
*/
|
|
97
|
+
export function unwrapEventData(
|
|
98
|
+
data: unknown,
|
|
99
|
+
uint8ArrayKeysAsBigInt: string[] = ["depositId"],
|
|
100
|
+
currentKey?: string
|
|
101
|
+
): unknown {
|
|
102
|
+
// Handle null/undefined
|
|
103
|
+
if (data == null) {
|
|
104
|
+
return data;
|
|
105
|
+
}
|
|
106
|
+
// Handle BigInt
|
|
107
|
+
if (typeof data === "bigint") {
|
|
108
|
+
return BigNumber.from(data);
|
|
109
|
+
}
|
|
110
|
+
// Handle Uint8Array and byte arrays
|
|
111
|
+
if (data instanceof Uint8Array || isUint8Array(data)) {
|
|
112
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data as number[]);
|
|
113
|
+
const hex = "0x" + Buffer.from(bytes).toString("hex");
|
|
114
|
+
if (currentKey && uint8ArrayKeysAsBigInt.includes(currentKey)) {
|
|
115
|
+
return BigNumber.from(hex);
|
|
116
|
+
}
|
|
117
|
+
return hex;
|
|
118
|
+
}
|
|
119
|
+
// Handle regular arrays (non-byte arrays)
|
|
120
|
+
if (Array.isArray(data)) {
|
|
121
|
+
return data.map((item) => unwrapEventData(item, uint8ArrayKeysAsBigInt));
|
|
122
|
+
}
|
|
123
|
+
// Handle strings (potential addresses)
|
|
124
|
+
if (typeof data === "string" && isAddress(data)) {
|
|
125
|
+
return SvmAddress.from(data).toBytes32();
|
|
126
|
+
}
|
|
127
|
+
// Handle objects
|
|
128
|
+
if (typeof data === "object") {
|
|
129
|
+
// Special case: if an object is in the context of the fillType key, then
|
|
130
|
+
// parse out the fillType from the object
|
|
131
|
+
if (currentKey === "fillType") {
|
|
132
|
+
const fillType = Object.keys(data)[0];
|
|
133
|
+
switch (fillType) {
|
|
134
|
+
case "FastFill":
|
|
135
|
+
return FillType.FastFill;
|
|
136
|
+
case "ReplacedSlowFill":
|
|
137
|
+
return FillType.ReplacedSlowFill;
|
|
138
|
+
case "SlowFill":
|
|
139
|
+
return FillType.SlowFill;
|
|
140
|
+
default:
|
|
141
|
+
throw new Error(`Unknown fill type: ${fillType}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Special case: if an object is empty, return 0x
|
|
145
|
+
if (Object.keys(data).length === 0) {
|
|
146
|
+
return "0x";
|
|
147
|
+
}
|
|
148
|
+
return Object.fromEntries(
|
|
149
|
+
Object.entries(data as Record<string, unknown>).map(([key, value]) => [
|
|
150
|
+
key,
|
|
151
|
+
unwrapEventData(value, uint8ArrayKeysAsBigInt, key),
|
|
152
|
+
])
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
// Return primitives as is
|
|
156
|
+
return data;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Returns the PDA for the State account.
|
|
161
|
+
* @param programId The SpokePool program ID.
|
|
162
|
+
* @returns The PDA for the State account.
|
|
163
|
+
*/
|
|
164
|
+
export async function getStatePda(programId: Address): Promise<Address> {
|
|
165
|
+
const intEncoder = getU64Encoder();
|
|
166
|
+
const seed = intEncoder.encode(0);
|
|
167
|
+
const [statePda] = await getProgramDerivedAddress({
|
|
168
|
+
programAddress: programId,
|
|
169
|
+
seeds: ["state", seed],
|
|
170
|
+
});
|
|
171
|
+
return statePda;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Returns the fill status PDA for the given relay data.
|
|
176
|
+
* @param programId The SpokePool program ID.
|
|
177
|
+
* @param relayData The relay data to get the fill status PDA for.
|
|
178
|
+
* @param destinationChainId The destination chain ID.
|
|
179
|
+
* @returns The PDA for the fill status.
|
|
180
|
+
*/
|
|
181
|
+
export async function getFillStatusPda(
|
|
182
|
+
programId: Address,
|
|
183
|
+
relayData: RelayData,
|
|
184
|
+
destinationChainId: number
|
|
185
|
+
): Promise<Address> {
|
|
186
|
+
const relayDataHash = getRelayDataHash(relayData, destinationChainId);
|
|
187
|
+
const uint8RelayDataHash = new Uint8Array(Buffer.from(relayDataHash.slice(2), "hex"));
|
|
188
|
+
const [fillStatusPda] = await getProgramDerivedAddress({
|
|
189
|
+
programAddress: programId,
|
|
190
|
+
seeds: ["fills", uint8RelayDataHash],
|
|
191
|
+
});
|
|
192
|
+
return fillStatusPda;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Returns the PDA for a route account on SVM Spoke.
|
|
197
|
+
* @param originToken The origin token address.
|
|
198
|
+
* @param seed The seed for the route account.
|
|
199
|
+
* @param routeChainId The route chain ID.
|
|
200
|
+
* @returns The PDA for the route account.
|
|
201
|
+
*/
|
|
202
|
+
export async function getRoutePda(originToken: Address, seed: bigint, routeChainId: bigint): Promise<Address> {
|
|
203
|
+
const intEncoder = getU64Encoder();
|
|
204
|
+
const addressEncoder = getAddressEncoder();
|
|
205
|
+
const [pda] = await getProgramDerivedAddress({
|
|
206
|
+
programAddress: address(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
|
|
207
|
+
seeds: ["route", addressEncoder.encode(originToken), intEncoder.encode(seed), intEncoder.encode(routeChainId)],
|
|
208
|
+
});
|
|
209
|
+
return pda;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Returns the PDA for the Event Authority.
|
|
214
|
+
* @returns The PDA for the Event Authority.
|
|
215
|
+
*/
|
|
216
|
+
export const getEventAuthority = async () => {
|
|
217
|
+
const [eventAuthority] = await getProgramDerivedAddress({
|
|
218
|
+
programAddress: address(SvmSpokeClient.SVM_SPOKE_PROGRAM_ADDRESS),
|
|
219
|
+
seeds: ["__event_authority"],
|
|
220
|
+
});
|
|
221
|
+
return eventAuthority;
|
|
222
|
+
};
|
|
@@ -98,12 +98,12 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
98
98
|
constructor(
|
|
99
99
|
readonly logger: winston.Logger,
|
|
100
100
|
readonly configStore: Contract,
|
|
101
|
-
eventSearchConfig: MakeOptional<EventSearchConfig, "
|
|
101
|
+
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 },
|
|
102
102
|
readonly configStoreVersion: number
|
|
103
103
|
) {
|
|
104
104
|
super(eventSearchConfig);
|
|
105
|
-
this.
|
|
106
|
-
this.
|
|
105
|
+
this.firstHeightToSearch = eventSearchConfig.from;
|
|
106
|
+
this.latestHeightSearched = 0;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
getRateModelForBlockNumber(
|
|
@@ -355,7 +355,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
355
355
|
return {
|
|
356
356
|
success: true,
|
|
357
357
|
chainId,
|
|
358
|
-
searchEndBlock: searchConfig.
|
|
358
|
+
searchEndBlock: searchConfig.to,
|
|
359
359
|
events: {
|
|
360
360
|
updatedTokenConfigEvents: updatedTokenConfigSortableEvents,
|
|
361
361
|
updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
|
|
@@ -550,9 +550,9 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
this.hasLatestConfigStoreVersion = this.hasValidConfigStoreVersionForTimestamp();
|
|
553
|
-
this.
|
|
554
|
-
this.
|
|
555
|
-
this.eventSearchConfig.
|
|
553
|
+
this.latestHeightSearched = result.searchEndBlock;
|
|
554
|
+
this.firstHeightToSearch = result.searchEndBlock + 1; // Next iteration should start off from where this one ended.
|
|
555
|
+
this.eventSearchConfig.to = undefined; // Caller can re-set on subsequent updates if necessary
|
|
556
556
|
this.chainId = this.chainId ?? chainId; // Update on the first run only.
|
|
557
557
|
this.isUpdated = true;
|
|
558
558
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { providers } from "ethers";
|
|
2
2
|
import { CachingMechanismInterface } from "../interfaces";
|
|
3
3
|
import { EventSearchConfig, isDefined, MakeOptional } from "../utils";
|
|
4
|
+
import { SVMProvider } from "../arch/svm";
|
|
4
5
|
|
|
5
6
|
export enum UpdateFailureReason {
|
|
6
7
|
NotReady,
|
|
@@ -18,15 +19,15 @@ export function isUpdateFailureReason(x: EventSearchConfig | UpdateFailureReason
|
|
|
18
19
|
*/
|
|
19
20
|
export abstract class BaseAbstractClient {
|
|
20
21
|
protected _isUpdated: boolean;
|
|
21
|
-
public
|
|
22
|
-
public
|
|
22
|
+
public firstHeightToSearch = 0;
|
|
23
|
+
public latestHeightSearched = 0;
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Creates a new client.
|
|
26
27
|
* @param cachingMechanism The caching mechanism to use for this client. If not provided, the client will not rely on an external cache.
|
|
27
28
|
*/
|
|
28
29
|
constructor(
|
|
29
|
-
readonly eventSearchConfig: MakeOptional<EventSearchConfig, "
|
|
30
|
+
readonly eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 },
|
|
30
31
|
protected cachingMechanism?: CachingMechanismInterface
|
|
31
32
|
) {
|
|
32
33
|
this._isUpdated = false;
|
|
@@ -58,22 +59,28 @@ export abstract class BaseAbstractClient {
|
|
|
58
59
|
* @provider Ethers RPC provider instance.
|
|
59
60
|
* @returns An EventSearchConfig instance if valid, otherwise an UpdateFailureReason.
|
|
60
61
|
*/
|
|
61
|
-
public async updateSearchConfig(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
public async updateSearchConfig(
|
|
63
|
+
provider: providers.Provider | SVMProvider
|
|
64
|
+
): Promise<EventSearchConfig | UpdateFailureReason> {
|
|
65
|
+
const from = this.firstHeightToSearch;
|
|
66
|
+
let { to } = this.eventSearchConfig;
|
|
67
|
+
if (isDefined(to)) {
|
|
68
|
+
if (from > to) {
|
|
69
|
+
throw new Error(`Invalid event search config from (${from}) > to (${to})`);
|
|
67
70
|
}
|
|
68
71
|
} else {
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
if (provider instanceof providers.Provider) {
|
|
73
|
+
to = await provider.getBlockNumber();
|
|
74
|
+
} else {
|
|
75
|
+
to = Number(await provider.getSlot({ commitment: "confirmed" }).send());
|
|
76
|
+
}
|
|
77
|
+
if (to < from) {
|
|
71
78
|
return UpdateFailureReason.AlreadyUpdated;
|
|
72
79
|
}
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
const {
|
|
76
|
-
return {
|
|
82
|
+
const { maxLookBack } = this.eventSearchConfig;
|
|
83
|
+
return { from, to, maxLookBack };
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
/**
|
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
DepositWithBlock,
|
|
21
21
|
} from "../../interfaces";
|
|
22
22
|
import { SpokePoolClient } from "..";
|
|
23
|
-
import { findFillEvent } from "../../arch/evm";
|
|
23
|
+
import { findFillEvent as findEvmFillEvent } from "../../arch/evm";
|
|
24
|
+
import { findFillEvent as findSvmFillEvent } from "../../arch/svm";
|
|
24
25
|
import {
|
|
25
26
|
BigNumber,
|
|
26
27
|
bnZero,
|
|
@@ -56,7 +57,7 @@ import {
|
|
|
56
57
|
V3FillWithBlock,
|
|
57
58
|
verifyFillRepayment,
|
|
58
59
|
} from "./utils";
|
|
59
|
-
import { isEVMSpokePoolClient } from "../SpokePoolClient";
|
|
60
|
+
import { isEVMSpokePoolClient, isSvmSpokePoolClient } from "../SpokePoolClient";
|
|
60
61
|
|
|
61
62
|
// max(uint256) - 1
|
|
62
63
|
export const INFINITE_FILL_DEADLINE = bnUint32Max;
|
|
@@ -370,7 +371,7 @@ export class BundleDataClient {
|
|
|
370
371
|
}
|
|
371
372
|
|
|
372
373
|
const bundle = this.clients.hubPoolClient.getLatestFullyExecutedRootBundle(
|
|
373
|
-
this.clients.hubPoolClient.
|
|
374
|
+
this.clients.hubPoolClient.latestHeightSearched
|
|
374
375
|
);
|
|
375
376
|
if (bundle !== undefined) {
|
|
376
377
|
refunds.push(await this.getPendingRefundsFromBundle(bundle));
|
|
@@ -383,7 +384,7 @@ export class BundleDataClient {
|
|
|
383
384
|
async getPendingRefundsFromBundle(bundle: ProposedRootBundle): Promise<CombinedRefunds> {
|
|
384
385
|
const nextBundleMainnetStartBlock = this.clients.hubPoolClient.getNextBundleStartBlockNumber(
|
|
385
386
|
this.chainIdListForBundleEvaluationBlockNumbers,
|
|
386
|
-
this.clients.hubPoolClient.
|
|
387
|
+
this.clients.hubPoolClient.latestHeightSearched,
|
|
387
388
|
this.clients.hubPoolClient.chainId
|
|
388
389
|
);
|
|
389
390
|
const chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(nextBundleMainnetStartBlock);
|
|
@@ -517,7 +518,7 @@ export class BundleDataClient {
|
|
|
517
518
|
const hubPoolClient = this.clients.hubPoolClient;
|
|
518
519
|
const nextBundleMainnetStartBlock = hubPoolClient.getNextBundleStartBlockNumber(
|
|
519
520
|
this.chainIdListForBundleEvaluationBlockNumbers,
|
|
520
|
-
hubPoolClient.
|
|
521
|
+
hubPoolClient.latestHeightSearched,
|
|
521
522
|
hubPoolClient.chainId
|
|
522
523
|
);
|
|
523
524
|
const chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(nextBundleMainnetStartBlock);
|
|
@@ -530,8 +531,8 @@ export class BundleDataClient {
|
|
|
530
531
|
this.spokePoolClients,
|
|
531
532
|
getEndBlockBuffers(chainIds, this.blockRangeEndBlockBuffer),
|
|
532
533
|
this.clients,
|
|
533
|
-
this.clients.hubPoolClient.
|
|
534
|
-
this.clients.configStoreClient.getEnabledChains(this.clients.hubPoolClient.
|
|
534
|
+
this.clients.hubPoolClient.latestHeightSearched,
|
|
535
|
+
this.clients.configStoreClient.getEnabledChains(this.clients.hubPoolClient.latestHeightSearched)
|
|
535
536
|
);
|
|
536
537
|
// Return block ranges for blocks after _pendingBlockRanges and up to widestBlockRanges.
|
|
537
538
|
// If a chain is disabled or doesn't have a spoke pool client, return a range of 0
|
|
@@ -799,7 +800,7 @@ export class BundleDataClient {
|
|
|
799
800
|
// hasn't queried. This is because this function will usually be called
|
|
800
801
|
// in production with block ranges that were validated by
|
|
801
802
|
// DataworkerUtils.blockRangesAreInvalidForSpokeClients.
|
|
802
|
-
Math.min(queryBlock, spokePoolClients[deposit.destinationChainId].
|
|
803
|
+
Math.min(queryBlock, spokePoolClients[deposit.destinationChainId].latestHeightSearched)
|
|
803
804
|
);
|
|
804
805
|
};
|
|
805
806
|
|
|
@@ -1616,16 +1617,24 @@ export class BundleDataClient {
|
|
|
1616
1617
|
deposit: DepositWithBlock,
|
|
1617
1618
|
spokePoolClient: SpokePoolClient
|
|
1618
1619
|
): Promise<FillWithBlock | undefined> {
|
|
1619
|
-
if (
|
|
1620
|
-
|
|
1621
|
-
|
|
1620
|
+
if (isSvmSpokePoolClient(spokePoolClient)) {
|
|
1621
|
+
return await findSvmFillEvent(
|
|
1622
|
+
deposit,
|
|
1623
|
+
spokePoolClient.chainId,
|
|
1624
|
+
spokePoolClient.svmEventsClient,
|
|
1625
|
+
spokePoolClient.deploymentBlock,
|
|
1626
|
+
spokePoolClient.latestHeightSearched
|
|
1627
|
+
);
|
|
1628
|
+
} else if (isEVMSpokePoolClient(spokePoolClient)) {
|
|
1629
|
+
return await findEvmFillEvent(
|
|
1630
|
+
spokePoolClient.spokePool,
|
|
1631
|
+
deposit,
|
|
1632
|
+
spokePoolClient.deploymentBlock,
|
|
1633
|
+
spokePoolClient.latestHeightSearched
|
|
1634
|
+
);
|
|
1635
|
+
} else {
|
|
1636
|
+
throw new Error("Unsupported spoke pool client type");
|
|
1622
1637
|
}
|
|
1623
|
-
return await findFillEvent(
|
|
1624
|
-
spokePoolClient.spokePool,
|
|
1625
|
-
deposit,
|
|
1626
|
-
spokePoolClient.deploymentBlock,
|
|
1627
|
-
spokePoolClient.latestBlockSearched
|
|
1628
|
-
);
|
|
1629
1638
|
}
|
|
1630
1639
|
|
|
1631
1640
|
async getBundleBlockTimestamps(
|
|
@@ -1652,13 +1661,13 @@ export class BundleDataClient {
|
|
|
1652
1661
|
// contain blocks where the spoke pool client hasn't queried. This is because this function
|
|
1653
1662
|
// will usually be called in production with block ranges that were validated by
|
|
1654
1663
|
// DataworkerUtils.blockRangesAreInvalidForSpokeClients.
|
|
1655
|
-
const startBlockForChain = Math.min(_startBlockForChain, spokePoolClient.
|
|
1664
|
+
const startBlockForChain = Math.min(_startBlockForChain, spokePoolClient.latestHeightSearched);
|
|
1656
1665
|
// @dev Add 1 to the bundle end block. The thinking here is that there can be a gap between
|
|
1657
1666
|
// block timestamps in subsequent blocks. The bundle data client assumes that fill deadlines expire
|
|
1658
1667
|
// in exactly one bundle, therefore we must make sure that the bundle block timestamp for one bundle's
|
|
1659
1668
|
// end block is exactly equal to the bundle block timestamp for the next bundle's start block. This way
|
|
1660
1669
|
// there are no gaps in block timestamps between bundles.
|
|
1661
|
-
const endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.
|
|
1670
|
+
const endBlockForChain = Math.min(_endBlockForChain + 1, spokePoolClient.latestHeightSearched);
|
|
1662
1671
|
const [startTime, _endTime] = [
|
|
1663
1672
|
await spokePoolClient.getTimestampForBlock(startBlockForChain),
|
|
1664
1673
|
await spokePoolClient.getTimestampForBlock(endBlockForChain),
|