@across-protocol/sdk 4.1.63-alpha.1 → 4.1.63-beta.1
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 +424 -0
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -0
- package/dist/cjs/arch/svm/constants.d.ts +2 -0
- package/dist/cjs/arch/svm/constants.js +7 -0
- package/dist/cjs/arch/svm/constants.js.map +1 -0
- package/dist/cjs/arch/svm/eventsClient.d.ts +26 -0
- package/dist/cjs/arch/svm/eventsClient.js +253 -0
- 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 +114 -114
- 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 +13 -0
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- 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 +509 -0
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -0
- package/dist/esm/arch/svm/constants.d.ts +2 -0
- package/dist/esm/arch/svm/constants.js +3 -0
- package/dist/esm/arch/svm/constants.js.map +1 -0
- package/dist/esm/arch/svm/eventsClient.d.ts +87 -0
- package/dist/esm/arch/svm/eventsClient.js +316 -0
- 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 +114 -114
- 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 +13 -0
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- 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 +3 -0
- package/dist/types/arch/svm/constants.d.ts.map +1 -0
- package/dist/types/arch/svm/eventsClient.d.ts +88 -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 +114 -114
- 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 +13 -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 +2 -0
- package/src/arch/svm/eventsClient.ts +334 -0
- 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 +14 -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 +7 -3
- package/dist/cjs/svm/eventsClient.d.ts +0 -15
- package/dist/cjs/svm/eventsClient.js +0 -157
- 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 +0 -195
- 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/eventsClient.ts +0 -199
- 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
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
import assert from "assert";
|
|
20
20
|
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
21
21
|
import { Transport } from "viem";
|
|
22
|
-
import { getGasPriceEstimate } from "../../gasPriceOracle
|
|
22
|
+
import { getGasPriceEstimate, EvmGasPriceEstimate } from "../../gasPriceOracle";
|
|
23
23
|
type Provider = providers.Provider;
|
|
24
24
|
type OptimismProvider = L2Provider<Provider>;
|
|
25
|
-
type SymbolMappingType = Record<
|
|
25
|
+
export type SymbolMappingType = Record<
|
|
26
26
|
string,
|
|
27
27
|
{
|
|
28
28
|
addresses: Record<number, string>;
|
|
@@ -213,7 +213,9 @@ export class QueryBase implements QueryInterface {
|
|
|
213
213
|
? Promise.resolve({ maxFeePerGas: _gasPrice })
|
|
214
214
|
: getGasPriceEstimate(provider, { chainId, baseFeeMultiplier, priorityFeeMultiplier, transport, unsignedTx }),
|
|
215
215
|
] as const;
|
|
216
|
-
const [nativeGasCost,
|
|
216
|
+
const [nativeGasCost, _gasPriceEstimate] = await Promise.all(queries);
|
|
217
|
+
// It should be safe to cast to an EvmGasPriceEstimate here since QueryBase is only used for EVM chains.
|
|
218
|
+
const gasPrice = (_gasPriceEstimate as EvmGasPriceEstimate).maxFeePerGas;
|
|
217
219
|
assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
|
|
218
220
|
let tokenGasCost: BigNumber;
|
|
219
221
|
|
|
@@ -4,10 +4,12 @@ import { getDeployedAddress } from "@across-protocol/contracts";
|
|
|
4
4
|
import { asL2Provider } from "@eth-optimism/sdk";
|
|
5
5
|
import { providers } from "ethers";
|
|
6
6
|
import { DEFAULT_SIMULATED_RELAYER_ADDRESS, CUSTOM_GAS_TOKENS } from "../../constants";
|
|
7
|
-
import { chainIsOPStack, isDefined } from "../../utils";
|
|
7
|
+
import { chainIsOPStack, isDefined, chainIsSvm, SvmAddress } from "../../utils";
|
|
8
8
|
import { QueryBase } from "./baseQuery";
|
|
9
|
+
import { SVMProvider as svmProvider } from "../../arch/svm";
|
|
9
10
|
import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator";
|
|
10
11
|
import { CustomGasTokenQueries } from "./customGasToken";
|
|
12
|
+
import { SvmQuery } from "./svmQuery";
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Some chains have a fixed gas price that is applied to the gas estimates. We should override
|
|
@@ -20,21 +22,21 @@ const fixedGasPrice = {
|
|
|
20
22
|
export class QueryBase__factory {
|
|
21
23
|
static create(
|
|
22
24
|
chainId: number,
|
|
23
|
-
provider: providers.Provider,
|
|
25
|
+
provider: providers.Provider | svmProvider,
|
|
24
26
|
symbolMapping = TOKEN_SYMBOLS_MAP,
|
|
25
27
|
spokePoolAddress = getDeployedAddress("SpokePool", chainId),
|
|
26
28
|
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
27
29
|
coingeckoProApiKey?: string,
|
|
28
30
|
logger: Logger = DEFAULT_LOGGER,
|
|
29
31
|
coingeckoBaseCurrency = "eth"
|
|
30
|
-
): QueryBase {
|
|
32
|
+
): QueryBase | SvmQuery {
|
|
31
33
|
assert(isDefined(spokePoolAddress));
|
|
32
34
|
|
|
33
35
|
const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
|
|
34
36
|
if (customGasTokenSymbol) {
|
|
35
37
|
return new CustomGasTokenQueries({
|
|
36
38
|
queryBaseArgs: [
|
|
37
|
-
provider,
|
|
39
|
+
provider as providers.Provider,
|
|
38
40
|
symbolMapping,
|
|
39
41
|
spokePoolAddress,
|
|
40
42
|
simulatedRelayerAddress,
|
|
@@ -46,9 +48,23 @@ export class QueryBase__factory {
|
|
|
46
48
|
customGasTokenSymbol,
|
|
47
49
|
});
|
|
48
50
|
}
|
|
51
|
+
if (chainIsSvm(chainId)) {
|
|
52
|
+
return new SvmQuery(
|
|
53
|
+
provider as svmProvider,
|
|
54
|
+
symbolMapping,
|
|
55
|
+
SvmAddress.from(spokePoolAddress),
|
|
56
|
+
SvmAddress.from(simulatedRelayerAddress),
|
|
57
|
+
logger,
|
|
58
|
+
coingeckoProApiKey,
|
|
59
|
+
fixedGasPrice[chainId],
|
|
60
|
+
coingeckoBaseCurrency
|
|
61
|
+
);
|
|
62
|
+
}
|
|
49
63
|
|
|
50
64
|
// For OPStack chains, we need to wrap the provider in an L2Provider
|
|
51
|
-
provider = chainIsOPStack(chainId)
|
|
65
|
+
provider = chainIsOPStack(chainId)
|
|
66
|
+
? asL2Provider(provider as providers.Provider)
|
|
67
|
+
: (provider as providers.Provider);
|
|
52
68
|
|
|
53
69
|
return new QueryBase(
|
|
54
70
|
provider,
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { pipe } from "@solana/functional";
|
|
2
|
+
import { Coingecko } from "../../coingecko";
|
|
3
|
+
import { SymbolMappingType } from "./";
|
|
4
|
+
import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
|
|
5
|
+
import { Deposit } from "../../interfaces";
|
|
6
|
+
import { getGasPriceEstimate, SvmGasPriceEstimate } from "../../gasPriceOracle";
|
|
7
|
+
import {
|
|
8
|
+
BigNumberish,
|
|
9
|
+
TransactionCostEstimate,
|
|
10
|
+
BigNumber,
|
|
11
|
+
SvmAddress,
|
|
12
|
+
toBN,
|
|
13
|
+
isDefined,
|
|
14
|
+
toAddressType,
|
|
15
|
+
} from "../../utils";
|
|
16
|
+
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
17
|
+
import {
|
|
18
|
+
fillRelayInstruction,
|
|
19
|
+
createApproveInstruction,
|
|
20
|
+
createTokenAccountsInstruction,
|
|
21
|
+
SVMProvider,
|
|
22
|
+
SolanaVoidSigner,
|
|
23
|
+
getAssociatedTokenAddress,
|
|
24
|
+
} from "../../arch/svm";
|
|
25
|
+
import {
|
|
26
|
+
createTransactionMessage,
|
|
27
|
+
setTransactionMessageFeePayer,
|
|
28
|
+
setTransactionMessageLifetimeUsingBlockhash,
|
|
29
|
+
appendTransactionMessageInstructions,
|
|
30
|
+
getComputeUnitEstimateForTransactionMessageFactory,
|
|
31
|
+
fetchEncodedAccount,
|
|
32
|
+
IInstruction,
|
|
33
|
+
} from "@solana/kit";
|
|
34
|
+
import { TOKEN_PROGRAM_ADDRESS, getMintSize, getInitializeMintInstruction, fetchMint } from "@solana-program/token";
|
|
35
|
+
import { getCreateAccountInstruction } from "@solana-program/system";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A special QueryBase implementation for SVM used for querying gas costs, token prices, and decimals of various tokens
|
|
39
|
+
* on Solana.
|
|
40
|
+
*/
|
|
41
|
+
export class SvmQuery implements QueryInterface {
|
|
42
|
+
protected computeUnitEstimator;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Instantiates a SvmQuery instance
|
|
46
|
+
* @param provider A valid solana/kit rpc client.
|
|
47
|
+
* @param symbolMapping A mapping to valid ERC20 tokens and their respective characteristics
|
|
48
|
+
* @param spokePoolAddress The valid address of the Spoke Pool deployment
|
|
49
|
+
* @param simulatedRelayerAddress The address that these queries will reference as the sender. Note: This address must be approved for USDC
|
|
50
|
+
* @param logger A logging utility to report logs
|
|
51
|
+
* @param coingeckoProApiKey An optional CoinGecko API key that links to a PRO account
|
|
52
|
+
* @param fixedGasPrice Overrides the gas price with a fixed value. Note: primarily used for the Boba blockchain
|
|
53
|
+
* @param coingeckoBaseCurrency The basis currency that CoinGecko will use to resolve pricing
|
|
54
|
+
*/
|
|
55
|
+
constructor(
|
|
56
|
+
readonly provider: SVMProvider,
|
|
57
|
+
readonly symbolMapping: SymbolMappingType,
|
|
58
|
+
readonly spokePoolAddress: SvmAddress,
|
|
59
|
+
readonly simulatedRelayerAddress: SvmAddress,
|
|
60
|
+
readonly logger: Logger,
|
|
61
|
+
readonly coingeckoProApiKey?: string,
|
|
62
|
+
readonly fixedGasPrice?: BigNumberish,
|
|
63
|
+
readonly coingeckoBaseCurrency: string = "eth"
|
|
64
|
+
) {
|
|
65
|
+
this.computeUnitEstimator = getComputeUnitEstimateForTransactionMessageFactory({
|
|
66
|
+
rpc: provider,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Retrieves the current gas costs of performing a fillRelay contract at the referenced SpokePool.
|
|
72
|
+
* @param deposit V3 deposit instance.
|
|
73
|
+
* @param relayerAddress Relayer address to simulate with.
|
|
74
|
+
* @param options
|
|
75
|
+
* @param options.gasPrice Optional gas price to use for the simulation.
|
|
76
|
+
* @param options.gasUnits Optional gas units to use for the simulation.
|
|
77
|
+
* @param options.transport Optional transport object for custom gas price retrieval.
|
|
78
|
+
* @returns The gas estimate for this function call (multiplied with the optional buffer).
|
|
79
|
+
*/
|
|
80
|
+
async getGasCosts(
|
|
81
|
+
deposit: Omit<Deposit, "messageHash">,
|
|
82
|
+
_relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
83
|
+
options: Partial<{
|
|
84
|
+
gasPrice: BigNumberish;
|
|
85
|
+
gasUnits: BigNumberish;
|
|
86
|
+
baseFeeMultiplier: BigNumber;
|
|
87
|
+
priorityFeeMultiplier: BigNumber;
|
|
88
|
+
}> = {}
|
|
89
|
+
): Promise<TransactionCostEstimate> {
|
|
90
|
+
// If the user did not have a token account created on destination, then we need to include this as a gas cost.
|
|
91
|
+
const mint = toAddressType(deposit.outputToken).forceSvmAddress();
|
|
92
|
+
const owner = toAddressType(deposit.recipient).forceSvmAddress();
|
|
93
|
+
const associatedToken = await getAssociatedTokenAddress(owner, mint);
|
|
94
|
+
const simulatedSigner = SolanaVoidSigner(this.simulatedRelayerAddress.toBase58());
|
|
95
|
+
|
|
96
|
+
// If the recipient has an associated token account on destination, then skip generating the instruction for creating a new token account.
|
|
97
|
+
let recipientCreateTokenAccountInstructions: IInstruction[] | undefined = undefined;
|
|
98
|
+
const [associatedTokenAccountExists, mintInfo] = await Promise.all([
|
|
99
|
+
(await fetchEncodedAccount(this.provider, associatedToken)).exists,
|
|
100
|
+
fetchMint(this.provider, mint.toV2Address()),
|
|
101
|
+
]);
|
|
102
|
+
if (!associatedTokenAccountExists) {
|
|
103
|
+
const space = BigInt(getMintSize());
|
|
104
|
+
const rent = await this.provider.getMinimumBalanceForRentExemption(space).send();
|
|
105
|
+
const createAccountIx = getCreateAccountInstruction({
|
|
106
|
+
payer: simulatedSigner,
|
|
107
|
+
newAccount: SolanaVoidSigner(mint.toBase58()),
|
|
108
|
+
lamports: rent,
|
|
109
|
+
space,
|
|
110
|
+
programAddress: TOKEN_PROGRAM_ADDRESS,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const initializeMintIx = getInitializeMintInstruction({
|
|
114
|
+
mint: mint.toV2Address(),
|
|
115
|
+
decimals: mintInfo.data.decimals,
|
|
116
|
+
mintAuthority: owner.toV2Address(),
|
|
117
|
+
});
|
|
118
|
+
recipientCreateTokenAccountInstructions = [createAccountIx, initializeMintIx];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const [createTokenAccountsIx, approveIx, fillIx] = await Promise.all([
|
|
122
|
+
createTokenAccountsInstruction(mint, simulatedSigner),
|
|
123
|
+
createApproveInstruction(
|
|
124
|
+
mint,
|
|
125
|
+
deposit.outputAmount,
|
|
126
|
+
this.simulatedRelayerAddress,
|
|
127
|
+
this.spokePoolAddress,
|
|
128
|
+
mintInfo.data.decimals
|
|
129
|
+
),
|
|
130
|
+
fillRelayInstruction(this.spokePoolAddress, deposit, simulatedSigner, associatedToken),
|
|
131
|
+
]);
|
|
132
|
+
|
|
133
|
+
// Get the most recent confirmed blockhash.
|
|
134
|
+
const recentBlockhash = await this.provider.getLatestBlockhash().send();
|
|
135
|
+
const fillRelayTx = pipe(
|
|
136
|
+
createTransactionMessage({ version: 0 }),
|
|
137
|
+
(tx) => setTransactionMessageFeePayer(this.simulatedRelayerAddress.toV2Address(), tx),
|
|
138
|
+
(tx) => setTransactionMessageLifetimeUsingBlockhash(recentBlockhash.value, tx),
|
|
139
|
+
(tx) =>
|
|
140
|
+
isDefined(recipientCreateTokenAccountInstructions)
|
|
141
|
+
? appendTransactionMessageInstructions(recipientCreateTokenAccountInstructions, tx)
|
|
142
|
+
: tx,
|
|
143
|
+
(tx) => appendTransactionMessageInstructions([createTokenAccountsIx, approveIx, fillIx], tx)
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
|
|
147
|
+
toBN(await this.computeUnitEstimator(fillRelayTx)),
|
|
148
|
+
getGasPriceEstimate(this.provider, {
|
|
149
|
+
unsignedTx: fillRelayTx,
|
|
150
|
+
baseFeeMultiplier: options.baseFeeMultiplier,
|
|
151
|
+
priorityFeeMultiplier: options.priorityFeeMultiplier,
|
|
152
|
+
}),
|
|
153
|
+
]);
|
|
154
|
+
|
|
155
|
+
// We can cast the gas price estimate to an SvmGasPriceEstimate here since the oracle should always
|
|
156
|
+
// query the Solana adapter.
|
|
157
|
+
const gasPriceEstimate = _gasPriceEstimate as SvmGasPriceEstimate;
|
|
158
|
+
const gasPrice = gasPriceEstimate.baseFee.add(
|
|
159
|
+
gasPriceEstimate.microLamportsPerComputeUnit.mul(computeUnitsConsumed).div(toBN(1_000_000)) // 1_000_000 microLamports/lamport.
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
nativeGasCost: computeUnitsConsumed,
|
|
164
|
+
tokenGasCost: gasPrice,
|
|
165
|
+
gasPrice,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves the current price of a token
|
|
171
|
+
* @param tokenSymbol A valid [CoinGecko-ID](https://api.coingecko.com/api/v3/coins/list)
|
|
172
|
+
* @returns The resolved token price within the specified coingeckoBaseCurrency
|
|
173
|
+
*/
|
|
174
|
+
async getTokenPrice(tokenSymbol: string): Promise<number> {
|
|
175
|
+
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
176
|
+
const coingeckoInstance = Coingecko.get(this.logger, this.coingeckoProApiKey);
|
|
177
|
+
const [, price] = await coingeckoInstance.getCurrentPriceByContract(
|
|
178
|
+
this.symbolMapping[tokenSymbol].addresses[CHAIN_IDs.MAINNET],
|
|
179
|
+
this.coingeckoBaseCurrency
|
|
180
|
+
);
|
|
181
|
+
return price;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Resolves the number of decimal places a token can have
|
|
186
|
+
* @param tokenSymbol A valid Across-Enabled Token ID
|
|
187
|
+
* @returns The number of decimals of precision for the corresponding tokenSymbol
|
|
188
|
+
*/
|
|
189
|
+
getTokenDecimals(tokenSymbol: string): number {
|
|
190
|
+
if (!this.symbolMapping[tokenSymbol]) throw new Error(`${tokenSymbol} does not exist in mapping`);
|
|
191
|
+
return this.symbolMapping[tokenSymbol].decimals;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { providers, utils } from "ethers";
|
|
2
2
|
import bs58 from "bs58";
|
|
3
|
+
import { Address as V2Address } from "@solana/kit";
|
|
3
4
|
import { BigNumber, chainIsEvm } from "./";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -77,9 +78,9 @@ export function isValidEvmAddress(address: string): boolean {
|
|
|
77
78
|
* @returns a child `Address` type most fitting for the chain ID.
|
|
78
79
|
* @todo: Change this to `toAddress` once we remove the other `toAddress` function.
|
|
79
80
|
*/
|
|
80
|
-
export function toAddressType(address: string
|
|
81
|
+
export function toAddressType(address: string): Address | EvmAddress | SvmAddress {
|
|
81
82
|
try {
|
|
82
|
-
if (
|
|
83
|
+
if (utils.isHexString(address)) {
|
|
83
84
|
return EvmAddress.from(address);
|
|
84
85
|
}
|
|
85
86
|
return SvmAddress.from(address);
|
|
@@ -146,6 +147,11 @@ export class Address {
|
|
|
146
147
|
return this.toBytes32();
|
|
147
148
|
}
|
|
148
149
|
|
|
150
|
+
// Converts the address to a Buffer type.
|
|
151
|
+
toBuffer(): Buffer {
|
|
152
|
+
return Buffer.from(this.rawAddress);
|
|
153
|
+
}
|
|
154
|
+
|
|
149
155
|
// Implements `Hexable` for `Address`. Needed for encoding purposes. This class is treated by default as a bytes32 primitive type, but can change for subclasses.
|
|
150
156
|
toHexString(): string {
|
|
151
157
|
return this.toBytes32();
|
|
@@ -185,6 +191,16 @@ export class Address {
|
|
|
185
191
|
return utils.stripZeros(this.rawAddress).length === 0;
|
|
186
192
|
}
|
|
187
193
|
|
|
194
|
+
// Forces `rawAddress` to become an SvmAddress type. This will only throw if `rawAddress.length > 32`.
|
|
195
|
+
forceSvmAddress(): SvmAddress {
|
|
196
|
+
return SvmAddress.from(this.toBase58());
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Forces `rawAddress` to become an EvmAddress type. This will throw if `rawAddress.length > 20`.
|
|
200
|
+
forceEvmAddress(): EvmAddress {
|
|
201
|
+
return EvmAddress.from(this.toEvmAddress());
|
|
202
|
+
}
|
|
203
|
+
|
|
188
204
|
// Checks if the other address is equivalent to this address.
|
|
189
205
|
eq(other: Address): boolean {
|
|
190
206
|
return this.toString() === other.toString();
|
|
@@ -223,8 +239,20 @@ export class EvmAddress extends Address {
|
|
|
223
239
|
}
|
|
224
240
|
|
|
225
241
|
// Constructs a new EvmAddress type.
|
|
226
|
-
static from(
|
|
227
|
-
|
|
242
|
+
static from(address: string, encoding: "base16" | "base58" = "base16"): EvmAddress {
|
|
243
|
+
if (encoding === "base16") {
|
|
244
|
+
return new this(utils.arrayify(address));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const decodedAddress = bs58.decode(address);
|
|
248
|
+
const padding = decodedAddress.subarray(0, 12);
|
|
249
|
+
const evmAddress = decodedAddress.subarray(12);
|
|
250
|
+
|
|
251
|
+
if (padding.length !== 12 || utils.stripZeros(padding).length !== 0 || evmAddress.length !== 20) {
|
|
252
|
+
throw new Error(`Not a valid base58-encoded EVM address: ${address}`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return new this(evmAddress);
|
|
228
256
|
}
|
|
229
257
|
}
|
|
230
258
|
|
|
@@ -241,12 +269,27 @@ export class SvmAddress extends Address {
|
|
|
241
269
|
return this.toBase58();
|
|
242
270
|
}
|
|
243
271
|
|
|
272
|
+
// Small utility to convert an SvmAddress to a Solana Kit branded type.
|
|
273
|
+
toV2Address(): V2Address<string> {
|
|
274
|
+
return this.toBase58() as V2Address<string>;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Forces an SvmAddress to an EVM address string by truncating the leading 12 bytes.
|
|
244
278
|
override toEvmAddress(): string {
|
|
245
279
|
return toAddress(`0x${this.toBytes32().slice(-40)}`);
|
|
246
280
|
}
|
|
247
281
|
|
|
248
282
|
// Constructs a new SvmAddress type.
|
|
249
|
-
static from(
|
|
250
|
-
|
|
283
|
+
static from(address: string, encoding: "base58" | "base16" = "base58"): SvmAddress {
|
|
284
|
+
if (encoding === "base58") {
|
|
285
|
+
return new this(bs58.decode(address));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const decodedAddress = utils.arrayify(address);
|
|
289
|
+
if (decodedAddress.length !== 32) {
|
|
290
|
+
throw new Error(`Not a valid base16-encoded SVM address: ${address}`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return new this(decodedAddress);
|
|
251
294
|
}
|
|
252
295
|
}
|
package/src/utils/ArrayUtils.ts
CHANGED
|
@@ -168,3 +168,15 @@ export function includesAsync<T>(
|
|
|
168
168
|
export function isArrayOf<T>(array: unknown, predicate: (value: unknown) => value is T): array is T[] {
|
|
169
169
|
return Array.isArray(array) && array.every(predicate);
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Checks if a value is a Uint8Array.
|
|
174
|
+
* @param value The value to check.
|
|
175
|
+
* @returns True if the value is a Uint8Array, false otherwise.
|
|
176
|
+
*/
|
|
177
|
+
export function isUint8Array(value: unknown): value is Uint8Array {
|
|
178
|
+
return (
|
|
179
|
+
Array.isArray(value) &&
|
|
180
|
+
value.every((item) => typeof item === "number" && Number.isInteger(item) && item >= 0 && item < 256)
|
|
181
|
+
);
|
|
182
|
+
}
|
package/src/utils/EventUtils.ts
CHANGED
|
@@ -99,9 +99,9 @@ export function spreadEvent(args: Result | Record<string, unknown>): { [key: str
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
export interface EventSearchConfig {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
from: number;
|
|
103
|
+
to: number;
|
|
104
|
+
maxLookBack?: number;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
export const eventToLog = (event: Event): Log => ({ ...event, event: event.event!, args: spreadEvent(event.args!) });
|
|
@@ -113,8 +113,8 @@ export async function paginatedEventQuery(
|
|
|
113
113
|
retryCount = 0
|
|
114
114
|
): Promise<Log[]> {
|
|
115
115
|
// If the max block look back is set to 0 then we dont need to do any pagination and can query over the whole range.
|
|
116
|
-
if (searchConfig.
|
|
117
|
-
const events = await contract.queryFilter(filter, searchConfig.
|
|
116
|
+
if (searchConfig.maxLookBack === 0) {
|
|
117
|
+
const events = await contract.queryFilter(filter, searchConfig.from, searchConfig.to);
|
|
118
118
|
return events.map(eventToLog);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -132,7 +132,7 @@ export async function paginatedEventQuery(
|
|
|
132
132
|
)
|
|
133
133
|
.flat()
|
|
134
134
|
// Filter events by block number because ranges can include blocks that are outside the range specified for caching reasons.
|
|
135
|
-
.filter((event) => event.blockNumber >= searchConfig.
|
|
135
|
+
.filter((event) => event.blockNumber >= searchConfig.from && event.blockNumber <= searchConfig.to)
|
|
136
136
|
.map(eventToLog)
|
|
137
137
|
);
|
|
138
138
|
} catch (error) {
|
|
@@ -159,11 +159,11 @@ export async function paginatedEventQuery(
|
|
|
159
159
|
* input range, but can include blocks outside of the desired range, so results should be filtered. Results
|
|
160
160
|
* are ordered from smallest to largest.
|
|
161
161
|
*/
|
|
162
|
-
export function getPaginatedBlockRanges({
|
|
163
|
-
fromBlock
|
|
164
|
-
toBlock
|
|
165
|
-
maxBlockLookBack
|
|
166
|
-
|
|
162
|
+
export function getPaginatedBlockRanges({ from, to, maxLookBack }: EventSearchConfig): [number, number][] {
|
|
163
|
+
const fromBlock = from;
|
|
164
|
+
const toBlock = to;
|
|
165
|
+
const maxBlockLookBack = maxLookBack;
|
|
166
|
+
|
|
167
167
|
// If the maxBlockLookBack is undefined, we can look back as far as we like. Just return the entire range.
|
|
168
168
|
if (maxBlockLookBack === undefined) {
|
|
169
169
|
return [[fromBlock, toBlock]];
|
package/src/utils/JSONUtils.ts
CHANGED
|
@@ -33,6 +33,8 @@ export function stringifyJSONWithNumericString(obj: unknown): string {
|
|
|
33
33
|
return JSON.stringify(obj, (_key, value) => {
|
|
34
34
|
if (typeof value === "object" && value !== null && value.type === "BigNumber") {
|
|
35
35
|
return BigNumber.from(value).toString();
|
|
36
|
+
} else if (typeof value === "bigint" && value !== null) {
|
|
37
|
+
return value.toString();
|
|
36
38
|
}
|
|
37
39
|
return value;
|
|
38
40
|
});
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { encodeAbiParameters, keccak256 } from "viem";
|
|
1
|
+
import { encodeAbiParameters, Hex, keccak256 } from "viem";
|
|
2
2
|
import { MAX_SAFE_DEPOSIT_ID, ZERO_ADDRESS, ZERO_BYTES } from "../constants";
|
|
3
3
|
import { Deposit, RelayData } from "../interfaces";
|
|
4
4
|
import { toBytes32 } from "./AddressUtils";
|
|
5
5
|
import { BigNumber } from "./BigNumberUtils";
|
|
6
6
|
import { isMessageEmpty } from "./DepositUtils";
|
|
7
|
+
import { chainIsSvm } from "./NetworkUtils";
|
|
8
|
+
import { svm } from "../arch";
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Produce the RelayData for a Deposit.
|
|
@@ -63,7 +65,9 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
63
65
|
outputToken: toBytes32(relayData.outputToken),
|
|
64
66
|
exclusiveRelayer: toBytes32(relayData.exclusiveRelayer),
|
|
65
67
|
};
|
|
66
|
-
|
|
68
|
+
if (chainIsSvm(destinationChainId)) {
|
|
69
|
+
return svm.getRelayDataHash(_relayData, destinationChainId);
|
|
70
|
+
}
|
|
67
71
|
return keccak256(encodeAbiParameters(abi, [_relayData, destinationChainId]));
|
|
68
72
|
}
|
|
69
73
|
|
|
@@ -87,5 +91,5 @@ export function isZeroAddress(address: string): boolean {
|
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
export function getMessageHash(message: string): string {
|
|
90
|
-
return isMessageEmpty(message) ? ZERO_BYTES : keccak256(message as
|
|
94
|
+
return isMessageEmpty(message) ? ZERO_BYTES : keccak256(message as Hex);
|
|
91
95
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import web3, { GetSignaturesForAddressApi, RpcTransport } from "@solana/kit";
|
|
2
|
-
import { EventData, EventName, EventWithData } from "./types";
|
|
3
|
-
type GetSignaturesForAddressConfig = Parameters<GetSignaturesForAddressApi["getSignaturesForAddress"]>[1];
|
|
4
|
-
export declare class SvmSpokeEventsClient {
|
|
5
|
-
private rpc;
|
|
6
|
-
private svmSpokeAddress;
|
|
7
|
-
private svmSpokeEventAuthority;
|
|
8
|
-
private constructor();
|
|
9
|
-
static create(rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>): Promise<SvmSpokeEventsClient>;
|
|
10
|
-
queryEvents<T extends EventData>(eventName: EventName, fromSlot?: bigint, toSlot?: bigint, options?: GetSignaturesForAddressConfig): Promise<EventWithData<T>[]>;
|
|
11
|
-
private queryAllEvents;
|
|
12
|
-
private readEventsFromSignature;
|
|
13
|
-
private processEventFromTx;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SvmSpokeEventsClient = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var contracts_1 = require("@across-protocol/contracts");
|
|
6
|
-
var web3_v1_1 = require("@across-protocol/contracts/dist/src/svm/web3-v1");
|
|
7
|
-
var kit_1 = tslib_1.__importDefault(require("@solana/kit"));
|
|
8
|
-
var utils_1 = require("../utils");
|
|
9
|
-
var events_1 = require("./utils/events");
|
|
10
|
-
var helpers_1 = require("./utils/helpers");
|
|
11
|
-
var SvmSpokeEventsClient = (function () {
|
|
12
|
-
function SvmSpokeEventsClient(rpc, svmSpokeAddress, eventAuthority) {
|
|
13
|
-
this.rpc = rpc;
|
|
14
|
-
this.svmSpokeAddress = svmSpokeAddress;
|
|
15
|
-
this.svmSpokeEventAuthority = eventAuthority;
|
|
16
|
-
}
|
|
17
|
-
SvmSpokeEventsClient.create = function (rpc) {
|
|
18
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
19
|
-
var isTestnet, programId, svmSpokeAddress, svmSpokeEventAuthority;
|
|
20
|
-
return tslib_1.__generator(this, function (_a) {
|
|
21
|
-
switch (_a.label) {
|
|
22
|
-
case 0: return [4, (0, helpers_1.isDevnet)(rpc)];
|
|
23
|
-
case 1:
|
|
24
|
-
isTestnet = _a.sent();
|
|
25
|
-
programId = (0, contracts_1.getDeployedAddress)("SvmSpoke", (0, web3_v1_1.getSolanaChainId)(isTestnet ? "devnet" : "mainnet").toString());
|
|
26
|
-
if (!programId)
|
|
27
|
-
throw new Error("Program not found");
|
|
28
|
-
svmSpokeAddress = kit_1.default.address(programId);
|
|
29
|
-
return [4, kit_1.default.getProgramDerivedAddress({
|
|
30
|
-
programAddress: svmSpokeAddress,
|
|
31
|
-
seeds: ["__event_authority"],
|
|
32
|
-
})];
|
|
33
|
-
case 2:
|
|
34
|
-
svmSpokeEventAuthority = (_a.sent())[0];
|
|
35
|
-
return [2, new SvmSpokeEventsClient(rpc, svmSpokeAddress, svmSpokeEventAuthority)];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
SvmSpokeEventsClient.prototype.queryEvents = function (eventName, fromSlot, toSlot, options) {
|
|
41
|
-
if (options === void 0) { options = { limit: 1000, commitment: "confirmed" }; }
|
|
42
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var events;
|
|
44
|
-
return tslib_1.__generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0: return [4, this.queryAllEvents(fromSlot, toSlot, options)];
|
|
47
|
-
case 1:
|
|
48
|
-
events = _a.sent();
|
|
49
|
-
return [2, events.filter(function (event) { return event.name === eventName; })];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
SvmSpokeEventsClient.prototype.queryAllEvents = function (fromSlot, toSlot, options) {
|
|
55
|
-
if (options === void 0) { options = { limit: 1000, commitment: "confirmed" }; }
|
|
56
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var allSignatures, hasMoreSignatures, currentOptions, signatures, filteredSignatures, eventsWithSlots;
|
|
58
|
-
var _this = this;
|
|
59
|
-
return tslib_1.__generator(this, function (_a) {
|
|
60
|
-
switch (_a.label) {
|
|
61
|
-
case 0:
|
|
62
|
-
allSignatures = [];
|
|
63
|
-
hasMoreSignatures = true;
|
|
64
|
-
currentOptions = options;
|
|
65
|
-
_a.label = 1;
|
|
66
|
-
case 1:
|
|
67
|
-
if (!hasMoreSignatures) return [3, 3];
|
|
68
|
-
return [4, this.rpc
|
|
69
|
-
.getSignaturesForAddress(this.svmSpokeAddress, currentOptions)
|
|
70
|
-
.send()];
|
|
71
|
-
case 2:
|
|
72
|
-
signatures = _a.sent();
|
|
73
|
-
allSignatures.push.apply(allSignatures, signatures);
|
|
74
|
-
if (signatures.length > 0) {
|
|
75
|
-
currentOptions = tslib_1.__assign(tslib_1.__assign({}, currentOptions), { before: signatures[signatures.length - 1].signature });
|
|
76
|
-
}
|
|
77
|
-
if (fromSlot && allSignatures.length > 0 && allSignatures[allSignatures.length - 1].slot < fromSlot) {
|
|
78
|
-
hasMoreSignatures = false;
|
|
79
|
-
}
|
|
80
|
-
hasMoreSignatures = Boolean(hasMoreSignatures && currentOptions.limit && signatures.length === currentOptions.limit);
|
|
81
|
-
return [3, 1];
|
|
82
|
-
case 3:
|
|
83
|
-
filteredSignatures = allSignatures.filter(function (signatureTransaction) {
|
|
84
|
-
if (fromSlot && signatureTransaction.slot < fromSlot)
|
|
85
|
-
return false;
|
|
86
|
-
if (toSlot && signatureTransaction.slot > toSlot)
|
|
87
|
-
return false;
|
|
88
|
-
return true;
|
|
89
|
-
});
|
|
90
|
-
return [4, Promise.all(filteredSignatures.map(function (signatureTransaction) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
91
|
-
var events;
|
|
92
|
-
return tslib_1.__generator(this, function (_a) {
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0: return [4, this.readEventsFromSignature(signatureTransaction.signature, options.commitment)];
|
|
95
|
-
case 1:
|
|
96
|
-
events = _a.sent();
|
|
97
|
-
return [2, events.map(function (event) { return (tslib_1.__assign(tslib_1.__assign({}, event), { confirmationStatus: signatureTransaction.confirmationStatus, blockTime: signatureTransaction.blockTime, signature: signatureTransaction.signature, slot: signatureTransaction.slot })); })];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}); }))];
|
|
101
|
-
case 4:
|
|
102
|
-
eventsWithSlots = _a.sent();
|
|
103
|
-
return [2, eventsWithSlots.flat()];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
SvmSpokeEventsClient.prototype.readEventsFromSignature = function (txSignature, commitment) {
|
|
109
|
-
if (commitment === void 0) { commitment = "confirmed"; }
|
|
110
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
111
|
-
var txResult;
|
|
112
|
-
return tslib_1.__generator(this, function (_a) {
|
|
113
|
-
switch (_a.label) {
|
|
114
|
-
case 0: return [4, this.rpc
|
|
115
|
-
.getTransaction(txSignature, { commitment: commitment, maxSupportedTransactionVersion: 0 })
|
|
116
|
-
.send()];
|
|
117
|
-
case 1:
|
|
118
|
-
txResult = _a.sent();
|
|
119
|
-
if (txResult === null)
|
|
120
|
-
return [2, []];
|
|
121
|
-
return [2, this.processEventFromTx(txResult)];
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
SvmSpokeEventsClient.prototype.processEventFromTx = function (txResult) {
|
|
127
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
128
|
-
if (!txResult)
|
|
129
|
-
return [];
|
|
130
|
-
var events = [];
|
|
131
|
-
var accountKeys = txResult.transaction.message.accountKeys;
|
|
132
|
-
var messageAccountKeys = tslib_1.__spreadArray([], accountKeys, true);
|
|
133
|
-
messageAccountKeys.push.apply(messageAccountKeys, ((_c = (_b = (_a = txResult === null || txResult === void 0 ? void 0 : txResult.meta) === null || _a === void 0 ? void 0 : _a.loadedAddresses) === null || _b === void 0 ? void 0 : _b.writable) !== null && _c !== void 0 ? _c : []));
|
|
134
|
-
messageAccountKeys.push.apply(messageAccountKeys, ((_f = (_e = (_d = txResult === null || txResult === void 0 ? void 0 : txResult.meta) === null || _d === void 0 ? void 0 : _d.loadedAddresses) === null || _e === void 0 ? void 0 : _e.readonly) !== null && _f !== void 0 ? _f : []));
|
|
135
|
-
for (var _i = 0, _j = (_h = (_g = txResult.meta) === null || _g === void 0 ? void 0 : _g.innerInstructions) !== null && _h !== void 0 ? _h : []; _i < _j.length; _i++) {
|
|
136
|
-
var ixBlock = _j[_i];
|
|
137
|
-
for (var _k = 0, _l = ixBlock.instructions; _k < _l.length; _k++) {
|
|
138
|
-
var ix = _l[_k];
|
|
139
|
-
var ixProgramId = messageAccountKeys[ix.programIdIndex];
|
|
140
|
-
var singleIxAccount = ix.accounts.length === 1 ? messageAccountKeys[ix.accounts[0]] : undefined;
|
|
141
|
-
if (ixProgramId !== undefined &&
|
|
142
|
-
singleIxAccount !== undefined &&
|
|
143
|
-
this.svmSpokeAddress === ixProgramId &&
|
|
144
|
-
this.svmSpokeEventAuthority === singleIxAccount) {
|
|
145
|
-
var ixData = utils_1.bs58.decode(ix.data);
|
|
146
|
-
var eventData = Buffer.from(ixData.slice(8)).toString("base64");
|
|
147
|
-
var _m = (0, events_1.decodeEvent)(contracts_1.SvmSpokeIdl, eventData), name_1 = _m.name, data = _m.data;
|
|
148
|
-
events.push({ program: this.svmSpokeAddress, name: name_1, data: data });
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return events;
|
|
153
|
-
};
|
|
154
|
-
return SvmSpokeEventsClient;
|
|
155
|
-
}());
|
|
156
|
-
exports.SvmSpokeEventsClient = SvmSpokeEventsClient;
|
|
157
|
-
//# sourceMappingURL=eventsClient.js.map
|