@across-protocol/sdk 4.1.63-beta.3 → 4.1.64-alpha.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 +5 -6
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/evm/index.d.ts +0 -1
- package/dist/cjs/arch/evm/index.js +0 -1
- package/dist/cjs/arch/evm/index.js.map +1 -1
- package/dist/cjs/arch/svm/index.d.ts +1 -5
- package/dist/cjs/arch/svm/index.js +2 -6
- package/dist/cjs/arch/svm/index.js.map +1 -1
- 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 +5 -6
- package/dist/cjs/clients/BaseAbstractClient.js +19 -30
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +11 -15
- 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 +3 -4
- package/dist/cjs/clients/HubPoolClient.js +17 -18
- 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 +20 -23
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -5
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +57 -54
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +0 -3
- package/dist/cjs/clients/SpokePoolClient/index.js +1 -8
- 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 +1 -2
- 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 +4 -7
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/index.d.ts +0 -2
- package/dist/cjs/clients/mocks/index.js +0 -2
- package/dist/cjs/clients/mocks/index.js.map +1 -1
- package/dist/cjs/constants.d.ts +0 -1
- package/dist/cjs/constants.js +1 -2
- package/dist/cjs/constants.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 +2 -3
- 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/index.d.ts +1 -1
- package/dist/cjs/gasPriceOracle/oracle.d.ts +3 -4
- package/dist/cjs/gasPriceOracle/oracle.js +9 -16
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.d.ts +1 -6
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +0 -13
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/providers/index.d.ts +1 -1
- package/dist/cjs/providers/index.js +2 -1
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/providers/{mocks/mockEthersProvider.js → mockProvider.js} +2 -2
- package/dist/cjs/providers/mockProvider.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +8 -10
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +2 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +2 -8
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.d.ts +0 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +0 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +0 -2
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +4 -10
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/svm/eventsClient.d.ts +15 -0
- package/dist/cjs/svm/eventsClient.js +157 -0
- package/dist/cjs/svm/eventsClient.js.map +1 -0
- package/dist/cjs/svm/index.d.ts +3 -0
- package/dist/cjs/svm/index.js +8 -0
- package/dist/cjs/svm/index.js.map +1 -0
- package/dist/cjs/{arch/svm → svm}/types.d.ts +4 -9
- package/dist/cjs/svm/types.js.map +1 -0
- package/dist/cjs/svm/utils/events.d.ts +8 -0
- package/dist/cjs/svm/utils/events.js +47 -0
- package/dist/cjs/svm/utils/events.js.map +1 -0
- package/dist/cjs/svm/utils/helpers.d.ts +2 -0
- package/dist/cjs/svm/utils/helpers.js +19 -0
- package/dist/cjs/svm/utils/helpers.js.map +1 -0
- package/dist/cjs/svm/utils/index.d.ts +1 -0
- package/dist/cjs/svm/utils/index.js +5 -0
- package/dist/cjs/svm/utils/index.js.map +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +3 -9
- package/dist/cjs/utils/AddressUtils.js +6 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/ArrayUtils.d.ts +0 -1
- package/dist/cjs/utils/ArrayUtils.js +1 -6
- package/dist/cjs/utils/ArrayUtils.js.map +1 -1
- package/dist/cjs/utils/BlockUtils.d.ts +27 -2
- package/dist/cjs/utils/BlockUtils.js +208 -2
- package/dist/cjs/utils/BlockUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.d.ts +4 -4
- package/dist/cjs/utils/EventUtils.js +4 -7
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +0 -3
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +0 -5
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +0 -1
- package/dist/cjs/utils/index.js +0 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +1 -1
- package/dist/esm/arch/evm/SpokeUtils.js +5 -6
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/evm/index.d.ts +0 -1
- package/dist/esm/arch/evm/index.js +0 -1
- package/dist/esm/arch/evm/index.js.map +1 -1
- package/dist/esm/arch/svm/index.d.ts +1 -5
- package/dist/esm/arch/svm/index.js +1 -5
- package/dist/esm/arch/svm/index.js.map +1 -1
- 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 +5 -6
- package/dist/esm/clients/BaseAbstractClient.js +19 -30
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +14 -17
- 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 +3 -4
- package/dist/esm/clients/HubPoolClient.js +18 -19
- 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 +20 -23
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +7 -7
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +59 -57
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +0 -8
- package/dist/esm/clients/SpokePoolClient/index.js +0 -10
- 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 +5 -8
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/index.d.ts +0 -2
- package/dist/esm/clients/mocks/index.js +0 -2
- package/dist/esm/clients/mocks/index.js.map +1 -1
- package/dist/esm/constants.d.ts +0 -1
- package/dist/esm/constants.js +0 -1
- package/dist/esm/constants.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 +2 -3
- 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/index.d.ts +1 -1
- package/dist/esm/gasPriceOracle/oracle.d.ts +3 -4
- package/dist/esm/gasPriceOracle/oracle.js +9 -18
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.d.ts +1 -6
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +0 -13
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/providers/index.d.ts +1 -1
- package/dist/esm/providers/index.js +2 -1
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/providers/{mocks/mockEthersProvider.js → mockProvider.js} +2 -2
- package/dist/esm/providers/mockProvider.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -10
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +2 -4
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +5 -11
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/index.d.ts +0 -1
- package/dist/esm/relayFeeCalculator/chain-queries/index.js +0 -1
- package/dist/esm/relayFeeCalculator/chain-queries/index.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -12
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +5 -10
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/svm/eventsClient.d.ts +51 -0
- package/dist/esm/svm/eventsClient.js +195 -0
- package/dist/esm/svm/eventsClient.js.map +1 -0
- package/dist/esm/svm/index.d.ts +3 -0
- package/dist/esm/svm/index.js +5 -0
- package/dist/esm/svm/index.js.map +1 -0
- package/dist/esm/{arch/svm → svm}/types.d.ts +4 -9
- package/dist/esm/svm/types.js.map +1 -0
- package/dist/esm/svm/utils/events.d.ts +17 -0
- package/dist/esm/svm/utils/events.js +55 -0
- package/dist/esm/svm/utils/events.js.map +1 -0
- package/dist/esm/svm/utils/helpers.d.ts +5 -0
- package/dist/esm/svm/utils/helpers.js +18 -0
- package/dist/esm/svm/utils/helpers.js.map +1 -0
- package/dist/esm/svm/utils/index.d.ts +1 -0
- package/dist/esm/svm/utils/index.js +2 -0
- package/dist/esm/svm/utils/index.js.map +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +3 -9
- package/dist/esm/utils/AddressUtils.js +6 -41
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/ArrayUtils.d.ts +0 -6
- package/dist/esm/utils/ArrayUtils.js +0 -9
- package/dist/esm/utils/ArrayUtils.js.map +1 -1
- package/dist/esm/utils/BlockUtils.d.ts +36 -2
- package/dist/esm/utils/BlockUtils.js +243 -2
- package/dist/esm/utils/BlockUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.d.ts +4 -4
- package/dist/esm/utils/EventUtils.js +4 -7
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +0 -3
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +0 -5
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/index.d.ts +0 -1
- package/dist/esm/utils/index.js +0 -1
- package/dist/esm/utils/index.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/evm/index.d.ts +0 -1
- package/dist/types/arch/evm/index.d.ts.map +1 -1
- package/dist/types/arch/svm/index.d.ts +1 -5
- package/dist/types/arch/svm/index.d.ts.map +1 -1
- 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 +5 -6
- 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 +3 -4
- 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/SpokePoolClient.d.ts +7 -7
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/index.d.ts +0 -8
- 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/clients/mocks/index.d.ts +0 -2
- package/dist/types/clients/mocks/index.d.ts.map +1 -1
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.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/index.d.ts +1 -1
- package/dist/types/gasPriceOracle/index.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts +3 -4
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/types.d.ts +1 -6
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +0 -13
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -1
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/providers/{mocks/mockEthersProvider.d.ts → mockProvider.d.ts} +1 -1
- package/dist/types/providers/mockProvider.d.ts.map +1 -0
- 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 +2 -4
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts +0 -1
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -12
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/svm/eventsClient.d.ts +52 -0
- package/dist/types/svm/eventsClient.d.ts.map +1 -0
- package/dist/types/svm/index.d.ts +4 -0
- package/dist/types/svm/index.d.ts.map +1 -0
- package/dist/types/{arch/svm → svm}/types.d.ts +4 -9
- package/dist/types/svm/types.d.ts.map +1 -0
- package/dist/types/svm/utils/events.d.ts +18 -0
- package/dist/types/svm/utils/events.d.ts.map +1 -0
- package/dist/types/svm/utils/helpers.d.ts +6 -0
- package/dist/types/svm/utils/helpers.d.ts.map +1 -0
- package/dist/types/svm/utils/index.d.ts +2 -0
- package/dist/types/svm/utils/index.d.ts.map +1 -0
- package/dist/types/utils/AddressUtils.d.ts +3 -9
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/ArrayUtils.d.ts +0 -6
- package/dist/types/utils/ArrayUtils.d.ts.map +1 -1
- package/dist/types/utils/BlockUtils.d.ts +36 -2
- package/dist/types/utils/BlockUtils.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/dist/types/utils/index.d.ts +0 -1
- package/dist/types/utils/index.d.ts.map +1 -1
- package/package.json +1 -3
- package/src/arch/evm/SpokeUtils.ts +5 -5
- package/src/arch/evm/index.ts +0 -1
- package/src/arch/svm/index.ts +1 -5
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -7
- package/src/clients/BaseAbstractClient.ts +13 -20
- package/src/clients/BundleDataClient/BundleDataClient.ts +19 -28
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +1 -1
- package/src/clients/HubPoolClient.ts +19 -19
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +21 -23
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +59 -50
- package/src/clients/SpokePoolClient/index.ts +0 -11
- 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 +4 -9
- package/src/clients/mocks/index.ts +0 -2
- package/src/constants.ts +0 -1
- package/src/gasPriceOracle/adapters/arbitrum.ts +2 -5
- package/src/gasPriceOracle/adapters/ethereum.ts +4 -7
- package/src/gasPriceOracle/adapters/linea-viem.ts +1 -3
- package/src/gasPriceOracle/adapters/polygon.ts +6 -6
- package/src/gasPriceOracle/index.ts +1 -1
- package/src/gasPriceOracle/oracle.ts +4 -20
- package/src/gasPriceOracle/types.ts +1 -7
- package/src/index.ts +1 -0
- package/src/interfaces/SpokePool.ts +0 -14
- package/src/providers/index.ts +1 -1
- package/src/providers/{mocks/mockEthersProvider.ts → mockProvider.ts} +1 -1
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +9 -11
- package/src/relayFeeCalculator/chain-queries/factory.ts +8 -24
- package/src/relayFeeCalculator/chain-queries/index.ts +0 -1
- package/src/relayFeeCalculator/relayFeeCalculator.ts +4 -16
- package/src/svm/eventsClient.ts +199 -0
- package/src/svm/index.ts +3 -0
- package/src/{arch/svm → svm}/types.ts +4 -21
- package/src/svm/utils/events.ts +58 -0
- package/src/svm/utils/helpers.ts +9 -0
- package/src/svm/utils/index.ts +1 -0
- package/src/utils/AddressUtils.ts +6 -49
- package/src/utils/ArrayUtils.ts +0 -12
- package/src/utils/BlockUtils.ts +215 -5
- package/src/utils/EventUtils.ts +11 -11
- package/src/utils/JSONUtils.ts +0 -2
- package/src/utils/SpokeUtils.ts +3 -7
- package/src/utils/index.ts +0 -1
- package/dist/cjs/arch/evm/BlockUtils.d.ts +0 -15
- package/dist/cjs/arch/evm/BlockUtils.js +0 -218
- package/dist/cjs/arch/evm/BlockUtils.js.map +0 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +0 -21
- package/dist/cjs/arch/svm/SpokeUtils.js +0 -454
- package/dist/cjs/arch/svm/SpokeUtils.js.map +0 -1
- package/dist/cjs/arch/svm/constants.d.ts +0 -2
- package/dist/cjs/arch/svm/constants.js +0 -7
- package/dist/cjs/arch/svm/constants.js.map +0 -1
- package/dist/cjs/arch/svm/eventsClient.d.ts +0 -26
- package/dist/cjs/arch/svm/eventsClient.js +0 -253
- package/dist/cjs/arch/svm/eventsClient.js.map +0 -1
- package/dist/cjs/arch/svm/types.js.map +0 -1
- package/dist/cjs/arch/svm/utils.d.ts +0 -18
- package/dist/cjs/arch/svm/utils.js +0 -212
- package/dist/cjs/arch/svm/utils.js.map +0 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +0 -23
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +0 -172
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +0 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +0 -33
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +0 -184
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +0 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +0 -30
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +0 -90
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +0 -1
- package/dist/cjs/gasPriceOracle/adapters/solana.d.ts +0 -4
- package/dist/cjs/gasPriceOracle/adapters/solana.js +0 -43
- package/dist/cjs/gasPriceOracle/adapters/solana.js.map +0 -1
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.d.ts +0 -5
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js +0 -21
- package/dist/cjs/providers/mocks/MockCachedSolanaRpcFactory.js.map +0 -1
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +0 -5
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js +0 -20
- package/dist/cjs/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +0 -1
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.d.ts +0 -13
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js +0 -76
- package/dist/cjs/providers/mocks/MockSolanaRpcFactory.js.map +0 -1
- package/dist/cjs/providers/mocks/index.d.ts +0 -4
- package/dist/cjs/providers/mocks/index.js +0 -8
- package/dist/cjs/providers/mocks/index.js.map +0 -1
- package/dist/cjs/providers/mocks/mockEthersProvider.js.map +0 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +0 -37
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +0 -171
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +0 -1
- package/dist/cjs/utils/BlockFinder.d.ts +0 -22
- package/dist/cjs/utils/BlockFinder.js +0 -10
- package/dist/cjs/utils/BlockFinder.js.map +0 -1
- package/dist/esm/arch/evm/BlockUtils.d.ts +0 -24
- package/dist/esm/arch/evm/BlockUtils.js +0 -250
- package/dist/esm/arch/evm/BlockUtils.js.map +0 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +0 -129
- package/dist/esm/arch/svm/SpokeUtils.js +0 -576
- package/dist/esm/arch/svm/SpokeUtils.js.map +0 -1
- package/dist/esm/arch/svm/constants.d.ts +0 -2
- package/dist/esm/arch/svm/constants.js +0 -3
- package/dist/esm/arch/svm/constants.js.map +0 -1
- package/dist/esm/arch/svm/eventsClient.d.ts +0 -87
- package/dist/esm/arch/svm/eventsClient.js +0 -316
- package/dist/esm/arch/svm/eventsClient.js.map +0 -1
- package/dist/esm/arch/svm/types.js.map +0 -1
- package/dist/esm/arch/svm/utils.d.ts +0 -63
- package/dist/esm/arch/svm/utils.js +0 -258
- package/dist/esm/arch/svm/utils.js.map +0 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +0 -66
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +0 -225
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +0 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +0 -33
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +0 -183
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +0 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +0 -30
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +0 -89
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +0 -1
- package/dist/esm/gasPriceOracle/adapters/solana.d.ts +0 -8
- package/dist/esm/gasPriceOracle/adapters/solana.js +0 -43
- package/dist/esm/gasPriceOracle/adapters/solana.js.map +0 -1
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.d.ts +0 -5
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js +0 -19
- package/dist/esm/providers/mocks/MockCachedSolanaRpcFactory.js.map +0 -1
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +0 -5
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js +0 -18
- package/dist/esm/providers/mocks/MockRateLimitedSolanaRpcFactory.js.map +0 -1
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.d.ts +0 -13
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js +0 -74
- package/dist/esm/providers/mocks/MockSolanaRpcFactory.js.map +0 -1
- package/dist/esm/providers/mocks/index.d.ts +0 -4
- package/dist/esm/providers/mocks/index.js +0 -5
- package/dist/esm/providers/mocks/index.js.map +0 -1
- package/dist/esm/providers/mocks/mockEthersProvider.js.map +0 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +0 -84
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +0 -216
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +0 -1
- package/dist/esm/utils/BlockFinder.d.ts +0 -22
- package/dist/esm/utils/BlockFinder.js +0 -7
- package/dist/esm/utils/BlockFinder.js.map +0 -1
- package/dist/types/arch/evm/BlockUtils.d.ts +0 -25
- package/dist/types/arch/evm/BlockUtils.d.ts.map +0 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +0 -130
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +0 -1
- package/dist/types/arch/svm/constants.d.ts +0 -3
- package/dist/types/arch/svm/constants.d.ts.map +0 -1
- package/dist/types/arch/svm/eventsClient.d.ts +0 -88
- package/dist/types/arch/svm/eventsClient.d.ts.map +0 -1
- package/dist/types/arch/svm/types.d.ts.map +0 -1
- package/dist/types/arch/svm/utils.d.ts +0 -64
- package/dist/types/arch/svm/utils.d.ts.map +0 -1
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +0 -67
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +0 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +0 -34
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +0 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +0 -31
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +0 -1
- package/dist/types/gasPriceOracle/adapters/solana.d.ts +0 -9
- package/dist/types/gasPriceOracle/adapters/solana.d.ts.map +0 -1
- package/dist/types/providers/mocks/MockCachedSolanaRpcFactory.d.ts +0 -6
- package/dist/types/providers/mocks/MockCachedSolanaRpcFactory.d.ts.map +0 -1
- package/dist/types/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts +0 -6
- package/dist/types/providers/mocks/MockRateLimitedSolanaRpcFactory.d.ts.map +0 -1
- package/dist/types/providers/mocks/MockSolanaRpcFactory.d.ts +0 -14
- package/dist/types/providers/mocks/MockSolanaRpcFactory.d.ts.map +0 -1
- package/dist/types/providers/mocks/index.d.ts +0 -5
- package/dist/types/providers/mocks/index.d.ts.map +0 -1
- package/dist/types/providers/mocks/mockEthersProvider.d.ts.map +0 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +0 -85
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +0 -1
- package/dist/types/utils/BlockFinder.d.ts +0 -23
- package/dist/types/utils/BlockFinder.d.ts.map +0 -1
- package/src/arch/evm/BlockUtils.ts +0 -209
- package/src/arch/svm/SpokeUtils.ts +0 -596
- package/src/arch/svm/constants.ts +0 -2
- package/src/arch/svm/eventsClient.ts +0 -342
- package/src/arch/svm/utils.ts +0 -233
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +0 -268
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +0 -226
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +0 -119
- package/src/gasPriceOracle/adapters/solana.ts +0 -45
- package/src/providers/mocks/MockCachedSolanaRpcFactory.ts +0 -15
- package/src/providers/mocks/MockRateLimitedSolanaRpcFactory.ts +0 -14
- package/src/providers/mocks/MockSolanaRpcFactory.ts +0 -55
- package/src/providers/mocks/index.ts +0 -4
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +0 -225
- package/src/utils/BlockFinder.ts +0 -26
- /package/dist/cjs/providers/{mocks/mockEthersProvider.d.ts → mockProvider.d.ts} +0 -0
- /package/dist/cjs/{arch/svm → svm}/types.js +0 -0
- /package/dist/esm/providers/{mocks/mockEthersProvider.d.ts → mockProvider.d.ts} +0 -0
- /package/dist/esm/{arch/svm → svm}/types.js +0 -0
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { Transport } from "viem";
|
|
3
|
-
import { providers } from "ethers";
|
|
3
|
+
import { PopulatedTransaction, providers } from "ethers";
|
|
4
4
|
import { CHAIN_IDs } from "../constants";
|
|
5
5
|
import { BigNumber, chainIsOPStack, fixedPointAdjustment, toBNWei } from "../utils";
|
|
6
|
-
import { SVMProvider as SolanaProvider } from "../arch/svm";
|
|
7
6
|
import { GasPriceEstimate } from "./types";
|
|
8
7
|
import { getPublicClient } from "./util";
|
|
9
8
|
import * as arbitrum from "./adapters/arbitrum";
|
|
10
9
|
import * as ethereum from "./adapters/ethereum";
|
|
11
10
|
import * as polygon from "./adapters/polygon";
|
|
12
11
|
import * as lineaViem from "./adapters/linea-viem";
|
|
13
|
-
import * as solana from "./adapters/solana";
|
|
14
12
|
|
|
15
13
|
export interface GasPriceEstimateOptions {
|
|
16
14
|
// baseFeeMultiplier Multiplier applied to base fee for EIP1559 gas prices (or total fee for legacy).
|
|
@@ -21,8 +19,8 @@ export interface GasPriceEstimateOptions {
|
|
|
21
19
|
legacyFallback: boolean;
|
|
22
20
|
// chainId The chain ID to query for gas prices. If omitted can be inferred by provider.
|
|
23
21
|
chainId: number;
|
|
24
|
-
// unsignedTx The unsigned transaction used for simulation by Linea's Viem provider to produce the priority gas fee
|
|
25
|
-
unsignedTx?:
|
|
22
|
+
// unsignedTx The unsigned transaction used for simulation by Linea's Viem provider to produce the priority gas fee.
|
|
23
|
+
unsignedTx?: PopulatedTransaction;
|
|
26
24
|
// transport Viem Transport object to use for querying gas fees used for testing.
|
|
27
25
|
transport?: Transport;
|
|
28
26
|
}
|
|
@@ -41,7 +39,7 @@ const VIEM_CHAINS = [CHAIN_IDs.LINEA];
|
|
|
41
39
|
* @returns An object of type GasPriceEstimate.
|
|
42
40
|
*/
|
|
43
41
|
export async function getGasPriceEstimate(
|
|
44
|
-
provider: providers.Provider
|
|
42
|
+
provider: providers.Provider,
|
|
45
43
|
opts: Partial<GasPriceEstimateOptions> = {}
|
|
46
44
|
): Promise<GasPriceEstimate> {
|
|
47
45
|
const baseFeeMultiplier = opts.baseFeeMultiplier ?? toBNWei("1");
|
|
@@ -55,20 +53,6 @@ export async function getGasPriceEstimate(
|
|
|
55
53
|
`Require 1.0 < priority fee multiplier (${priorityFeeMultiplier}) <= 5.0 for a total gas multiplier within [+1.0, +5.0]`
|
|
56
54
|
);
|
|
57
55
|
|
|
58
|
-
// Exit here if we need to estimate on Solana.
|
|
59
|
-
if (!(provider instanceof providers.Provider)) {
|
|
60
|
-
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
61
|
-
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
62
|
-
baseFeeMultiplier,
|
|
63
|
-
priorityFeeMultiplier,
|
|
64
|
-
...opts,
|
|
65
|
-
chainId: opts.chainId ?? CHAIN_IDs.SOLANA,
|
|
66
|
-
};
|
|
67
|
-
return solana.messageFee(provider, optsWithDefaults);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Cast the provider to an ethers provider, which should be given to the oracle when querying an EVM network.
|
|
71
|
-
provider = provider as providers.Provider;
|
|
72
56
|
const chainId = opts.chainId ?? (await provider.getNetwork()).chainId;
|
|
73
57
|
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
74
58
|
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
@@ -2,18 +2,12 @@ import { type Chain, type Transport, PublicClient, FeeValuesEIP1559 } from "viem
|
|
|
2
2
|
import { BigNumber } from "../utils";
|
|
3
3
|
|
|
4
4
|
export type InternalGasPriceEstimate = FeeValuesEIP1559;
|
|
5
|
-
export type GasPriceEstimate = EvmGasPriceEstimate | SvmGasPriceEstimate;
|
|
6
5
|
|
|
7
|
-
export type
|
|
6
|
+
export type GasPriceEstimate = {
|
|
8
7
|
maxFeePerGas: BigNumber;
|
|
9
8
|
maxPriorityFeePerGas: BigNumber;
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
export type SvmGasPriceEstimate = {
|
|
13
|
-
baseFee: BigNumber;
|
|
14
|
-
microLamportsPerComputeUnit: BigNumber;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
11
|
export interface GasPriceFeed {
|
|
18
12
|
(provider: PublicClient<Transport, Chain>, chainId: number): Promise<InternalGasPriceEstimate>;
|
|
19
13
|
}
|
package/src/index.ts
CHANGED
|
@@ -37,10 +37,6 @@ export interface DepositWithBlock extends Deposit, SortableEvent {
|
|
|
37
37
|
quoteBlockNumber: number;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export interface DepositWithTime extends Deposit, SortableEvent {
|
|
41
|
-
depositTimestamp: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
40
|
export enum FillStatus {
|
|
45
41
|
Unfilled = 0,
|
|
46
42
|
RequestedSlowFill,
|
|
@@ -70,17 +66,7 @@ export interface Fill extends Omit<RelayData, "message"> {
|
|
|
70
66
|
}
|
|
71
67
|
|
|
72
68
|
export interface FillWithBlock extends Fill, SortableEvent {}
|
|
73
|
-
export interface FillWithTime extends Fill, SortableEvent {
|
|
74
|
-
fillTimestamp: number;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface EnabledDepositRoute {
|
|
78
|
-
originToken: string;
|
|
79
|
-
destinationChainId: number;
|
|
80
|
-
enabled: boolean;
|
|
81
|
-
}
|
|
82
69
|
|
|
83
|
-
export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
|
|
84
70
|
export interface SpeedUp {
|
|
85
71
|
depositor: string;
|
|
86
72
|
depositorSignature: string;
|
package/src/providers/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BigNumber, providers } from "ethers";
|
|
2
2
|
import { Block, BlockTag, FeeData, TransactionResponse } from "@ethersproject/abstract-provider";
|
|
3
|
-
import { bnZero } from "
|
|
3
|
+
import { bnZero } from "../utils/BigNumberUtils";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
|
|
@@ -3,7 +3,7 @@ import { isL2Provider as isOptimismL2Provider } from "@eth-optimism/sdk/dist/l2-
|
|
|
3
3
|
|
|
4
4
|
import { PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
5
5
|
import { Coingecko } from "../../coingecko";
|
|
6
|
-
import { CHAIN_IDs } from "../../constants";
|
|
6
|
+
import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
|
|
7
7
|
import { Deposit } from "../../interfaces";
|
|
8
8
|
import { SpokePool, SpokePool__factory } from "../../typechain";
|
|
9
9
|
import { populateV3Relay } from "../../arch/evm";
|
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
fixedPointAdjustment,
|
|
18
18
|
} from "../../utils";
|
|
19
19
|
import assert from "assert";
|
|
20
|
-
import { Logger, QueryInterface
|
|
20
|
+
import { Logger, QueryInterface } from "../relayFeeCalculator";
|
|
21
21
|
import { Transport } from "viem";
|
|
22
|
-
import { getGasPriceEstimate
|
|
22
|
+
import { getGasPriceEstimate } from "../../gasPriceOracle/oracle";
|
|
23
23
|
type Provider = providers.Provider;
|
|
24
24
|
type OptimismProvider = L2Provider<Provider>;
|
|
25
|
-
|
|
25
|
+
type SymbolMappingType = Record<
|
|
26
26
|
string,
|
|
27
27
|
{
|
|
28
28
|
addresses: Record<number, string>;
|
|
@@ -72,7 +72,7 @@ export class QueryBase implements QueryInterface {
|
|
|
72
72
|
*/
|
|
73
73
|
async getGasCosts(
|
|
74
74
|
deposit: Omit<Deposit, "messageHash">,
|
|
75
|
-
relayer =
|
|
75
|
+
relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
76
76
|
options: Partial<{
|
|
77
77
|
gasPrice: BigNumberish;
|
|
78
78
|
gasUnits: BigNumberish;
|
|
@@ -122,7 +122,7 @@ export class QueryBase implements QueryInterface {
|
|
|
122
122
|
*/
|
|
123
123
|
getUnsignedTxFromDeposit(
|
|
124
124
|
deposit: Omit<Deposit, "messageHash">,
|
|
125
|
-
relayer =
|
|
125
|
+
relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS
|
|
126
126
|
): Promise<PopulatedTransaction> {
|
|
127
127
|
return populateV3Relay(this.spokePool, deposit, relayer);
|
|
128
128
|
}
|
|
@@ -135,7 +135,7 @@ export class QueryBase implements QueryInterface {
|
|
|
135
135
|
*/
|
|
136
136
|
async getNativeGasCost(
|
|
137
137
|
deposit: Omit<Deposit, "messageHash">,
|
|
138
|
-
relayer =
|
|
138
|
+
relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS
|
|
139
139
|
): Promise<BigNumber> {
|
|
140
140
|
const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
|
|
141
141
|
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
@@ -152,7 +152,7 @@ export class QueryBase implements QueryInterface {
|
|
|
152
152
|
*/
|
|
153
153
|
async getOpStackL1DataFee(
|
|
154
154
|
unsignedTx: PopulatedTransaction,
|
|
155
|
-
relayer =
|
|
155
|
+
relayer = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
156
156
|
options: Partial<{
|
|
157
157
|
opStackL2GasUnits: BigNumberish;
|
|
158
158
|
opStackL1DataFeeMultiplier: BigNumber;
|
|
@@ -213,9 +213,7 @@ 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,
|
|
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;
|
|
216
|
+
const [nativeGasCost, { maxFeePerGas: gasPrice }] = await Promise.all(queries);
|
|
219
217
|
assert(nativeGasCost.gt(bnZero), "Gas cost should not be 0");
|
|
220
218
|
let tokenGasCost: BigNumber;
|
|
221
219
|
|
|
@@ -3,13 +3,11 @@ import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
|
|
|
3
3
|
import { getDeployedAddress } from "@across-protocol/contracts";
|
|
4
4
|
import { asL2Provider } from "@eth-optimism/sdk";
|
|
5
5
|
import { providers } from "ethers";
|
|
6
|
-
import { CUSTOM_GAS_TOKENS } from "../../constants";
|
|
7
|
-
import { chainIsOPStack, isDefined
|
|
6
|
+
import { DEFAULT_SIMULATED_RELAYER_ADDRESS, CUSTOM_GAS_TOKENS } from "../../constants";
|
|
7
|
+
import { chainIsOPStack, isDefined } from "../../utils";
|
|
8
8
|
import { QueryBase } from "./baseQuery";
|
|
9
|
-
import {
|
|
10
|
-
import { DEFAULT_LOGGER, getDefaultSimulatedRelayerAddress, Logger } from "../relayFeeCalculator";
|
|
9
|
+
import { DEFAULT_LOGGER, Logger } from "../relayFeeCalculator";
|
|
11
10
|
import { CustomGasTokenQueries } from "./customGasToken";
|
|
12
|
-
import { SvmQuery } from "./svmQuery";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Some chains have a fixed gas price that is applied to the gas estimates. We should override
|
|
@@ -22,21 +20,21 @@ const fixedGasPrice = {
|
|
|
22
20
|
export class QueryBase__factory {
|
|
23
21
|
static create(
|
|
24
22
|
chainId: number,
|
|
25
|
-
provider: providers.Provider
|
|
23
|
+
provider: providers.Provider,
|
|
26
24
|
symbolMapping = TOKEN_SYMBOLS_MAP,
|
|
27
25
|
spokePoolAddress = getDeployedAddress("SpokePool", chainId),
|
|
28
|
-
simulatedRelayerAddress =
|
|
26
|
+
simulatedRelayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
29
27
|
coingeckoProApiKey?: string,
|
|
30
28
|
logger: Logger = DEFAULT_LOGGER,
|
|
31
29
|
coingeckoBaseCurrency = "eth"
|
|
32
|
-
): QueryBase
|
|
30
|
+
): QueryBase {
|
|
33
31
|
assert(isDefined(spokePoolAddress));
|
|
34
32
|
|
|
35
33
|
const customGasTokenSymbol = CUSTOM_GAS_TOKENS[chainId];
|
|
36
34
|
if (customGasTokenSymbol) {
|
|
37
35
|
return new CustomGasTokenQueries({
|
|
38
36
|
queryBaseArgs: [
|
|
39
|
-
provider
|
|
37
|
+
provider,
|
|
40
38
|
symbolMapping,
|
|
41
39
|
spokePoolAddress,
|
|
42
40
|
simulatedRelayerAddress,
|
|
@@ -48,23 +46,9 @@ export class QueryBase__factory {
|
|
|
48
46
|
customGasTokenSymbol,
|
|
49
47
|
});
|
|
50
48
|
}
|
|
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
|
-
}
|
|
63
49
|
|
|
64
50
|
// For OPStack chains, we need to wrap the provider in an L2Provider
|
|
65
|
-
provider = chainIsOPStack(chainId)
|
|
66
|
-
? asL2Provider(provider as providers.Provider)
|
|
67
|
-
: (provider as providers.Provider);
|
|
51
|
+
provider = chainIsOPStack(chainId) ? asL2Provider(provider) : provider;
|
|
68
52
|
|
|
69
53
|
return new QueryBase(
|
|
70
54
|
provider,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
4
|
-
DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM,
|
|
5
|
-
TOKEN_SYMBOLS_MAP,
|
|
6
|
-
} from "../constants";
|
|
2
|
+
import { DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../constants";
|
|
7
3
|
import { Deposit } from "../interfaces";
|
|
8
4
|
import {
|
|
9
5
|
BigNumber,
|
|
@@ -22,7 +18,6 @@ import {
|
|
|
22
18
|
toBNWei,
|
|
23
19
|
isZeroAddress,
|
|
24
20
|
compareAddressesSimple,
|
|
25
|
-
chainIsSvm,
|
|
26
21
|
} from "../utils";
|
|
27
22
|
import { Transport } from "viem";
|
|
28
23
|
|
|
@@ -41,7 +36,6 @@ export interface QueryInterface {
|
|
|
41
36
|
}>
|
|
42
37
|
) => Promise<TransactionCostEstimate>;
|
|
43
38
|
getTokenPrice: (tokenSymbol: string) => Promise<number>;
|
|
44
|
-
getNativeGasCost: (deposit: Omit<Deposit, "messageHash">, relayer: string) => Promise<BigNumber>;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export const expectedCapitalCostsKeys = ["lowerBound", "upperBound", "cutoff", "decimals"];
|
|
@@ -111,12 +105,6 @@ export const DEFAULT_LOGGER: Logger = {
|
|
|
111
105
|
error: (...args) => console.error(args),
|
|
112
106
|
};
|
|
113
107
|
|
|
114
|
-
export function getDefaultSimulatedRelayerAddress(chainId?: number) {
|
|
115
|
-
return isDefined(chainId) && chainIsSvm(chainId)
|
|
116
|
-
? DEFAULT_SIMULATED_RELAYER_ADDRESS_SVM
|
|
117
|
-
: DEFAULT_SIMULATED_RELAYER_ADDRESS;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
108
|
// Small amount to simulate filling with. Should be low enough to guarantee a successful fill.
|
|
121
109
|
const safeOutputAmount = toBN(100);
|
|
122
110
|
|
|
@@ -253,7 +241,7 @@ export class RelayFeeCalculator {
|
|
|
253
241
|
deposit: Deposit,
|
|
254
242
|
amountToRelay: BigNumberish,
|
|
255
243
|
simulateZeroFill = false,
|
|
256
|
-
relayerAddress =
|
|
244
|
+
relayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
257
245
|
_tokenPrice?: number,
|
|
258
246
|
tokenMapping = TOKEN_SYMBOLS_MAP,
|
|
259
247
|
gasPrice?: BigNumberish,
|
|
@@ -314,7 +302,7 @@ export class RelayFeeCalculator {
|
|
|
314
302
|
throw error;
|
|
315
303
|
}),
|
|
316
304
|
]);
|
|
317
|
-
const gasFeesInToken = nativeToToken(tokenGasCost, tokenPrice,
|
|
305
|
+
const gasFeesInToken = nativeToToken(tokenGasCost, tokenPrice, outputTokenInfo.decimals, this.nativeTokenDecimals);
|
|
318
306
|
return percent(gasFeesInToken, amountToRelay.toString());
|
|
319
307
|
}
|
|
320
308
|
|
|
@@ -492,7 +480,7 @@ export class RelayFeeCalculator {
|
|
|
492
480
|
deposit: Deposit,
|
|
493
481
|
amountToRelay?: BigNumberish,
|
|
494
482
|
simulateZeroFill = false,
|
|
495
|
-
relayerAddress =
|
|
483
|
+
relayerAddress = DEFAULT_SIMULATED_RELAYER_ADDRESS,
|
|
496
484
|
_tokenPrice?: number,
|
|
497
485
|
gasPrice?: BigNumberish,
|
|
498
486
|
gasUnits?: BigNumberish,
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { getDeployedAddress, SvmSpokeIdl } from "@across-protocol/contracts";
|
|
2
|
+
import { getSolanaChainId } from "@across-protocol/contracts/dist/src/svm/web3-v1";
|
|
3
|
+
import web3, {
|
|
4
|
+
Address,
|
|
5
|
+
Commitment,
|
|
6
|
+
GetSignaturesForAddressApi,
|
|
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";
|
|
15
|
+
|
|
16
|
+
// Utility type to extract the return type for the JSON encoding overload. We only care about the overload where the
|
|
17
|
+
// configuration parameter (C) has the optional property 'encoding' set to 'json'.
|
|
18
|
+
type ExtractJsonOverload<T> = T extends (signature: infer _S, config: infer C) => infer R
|
|
19
|
+
? C extends { encoding?: "json" }
|
|
20
|
+
? R
|
|
21
|
+
: never
|
|
22
|
+
: never;
|
|
23
|
+
|
|
24
|
+
type GetTransactionReturnType = ExtractJsonOverload<GetTransactionApi["getTransaction"]>;
|
|
25
|
+
type GetSignaturesForAddressConfig = Parameters<GetSignaturesForAddressApi["getSignaturesForAddress"]>[1];
|
|
26
|
+
type GetSignaturesForAddressTransaction = ReturnType<GetSignaturesForAddressApi["getSignaturesForAddress"]>[number];
|
|
27
|
+
type GetSignaturesForAddressApiResponse = readonly GetSignaturesForAddressTransaction[];
|
|
28
|
+
|
|
29
|
+
export class SvmSpokeEventsClient {
|
|
30
|
+
private rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>;
|
|
31
|
+
private svmSpokeAddress: Address;
|
|
32
|
+
private svmSpokeEventAuthority: Address;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Private constructor. Use the async create() method to instantiate.
|
|
36
|
+
*/
|
|
37
|
+
private constructor(
|
|
38
|
+
rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>,
|
|
39
|
+
svmSpokeAddress: Address,
|
|
40
|
+
eventAuthority: Address
|
|
41
|
+
) {
|
|
42
|
+
this.rpc = rpc;
|
|
43
|
+
this.svmSpokeAddress = svmSpokeAddress;
|
|
44
|
+
this.svmSpokeEventAuthority = eventAuthority;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Factory method to asynchronously create an instance of SvmSpokeEventsClient.
|
|
49
|
+
*/
|
|
50
|
+
public static async create(
|
|
51
|
+
rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>
|
|
52
|
+
): Promise<SvmSpokeEventsClient> {
|
|
53
|
+
const isTestnet = await isDevnet(rpc);
|
|
54
|
+
const programId = getDeployedAddress("SvmSpoke", getSolanaChainId(isTestnet ? "devnet" : "mainnet").toString());
|
|
55
|
+
if (!programId) throw new Error("Program not found");
|
|
56
|
+
const svmSpokeAddress = web3.address(programId);
|
|
57
|
+
const [svmSpokeEventAuthority] = await web3.getProgramDerivedAddress({
|
|
58
|
+
programAddress: svmSpokeAddress,
|
|
59
|
+
seeds: ["__event_authority"],
|
|
60
|
+
});
|
|
61
|
+
return new SvmSpokeEventsClient(rpc, svmSpokeAddress, svmSpokeEventAuthority);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Queries events for the SvmSpoke program filtered by event name.
|
|
66
|
+
*
|
|
67
|
+
* @param eventName - The name of the event to filter by.
|
|
68
|
+
* @param fromSlot - Optional starting slot.
|
|
69
|
+
* @param toSlot - Optional ending slot.
|
|
70
|
+
* @param options - Options for fetching signatures.
|
|
71
|
+
* @returns A promise that resolves to an array of events matching the eventName.
|
|
72
|
+
*/
|
|
73
|
+
public async queryEvents<T extends EventData>(
|
|
74
|
+
eventName: EventName,
|
|
75
|
+
fromSlot?: bigint,
|
|
76
|
+
toSlot?: bigint,
|
|
77
|
+
options: GetSignaturesForAddressConfig = { limit: 1000, commitment: "confirmed" }
|
|
78
|
+
): Promise<EventWithData<T>[]> {
|
|
79
|
+
const events = await this.queryAllEvents(fromSlot, toSlot, options);
|
|
80
|
+
return events.filter((event) => event.name === eventName) as EventWithData<T>[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Queries all events for a specific program.
|
|
85
|
+
*
|
|
86
|
+
* @param fromSlot - Optional starting slot.
|
|
87
|
+
* @param toSlot - Optional ending slot.
|
|
88
|
+
* @param options - Options for fetching signatures.
|
|
89
|
+
* @returns A promise that resolves to an array of all events with additional metadata.
|
|
90
|
+
*/
|
|
91
|
+
private async queryAllEvents(
|
|
92
|
+
fromSlot?: bigint,
|
|
93
|
+
toSlot?: bigint,
|
|
94
|
+
options: GetSignaturesForAddressConfig = { limit: 1000, commitment: "confirmed" }
|
|
95
|
+
): Promise<EventWithData<EventData>[]> {
|
|
96
|
+
const allSignatures: GetSignaturesForAddressTransaction[] = [];
|
|
97
|
+
let hasMoreSignatures = true;
|
|
98
|
+
let currentOptions = options;
|
|
99
|
+
|
|
100
|
+
while (hasMoreSignatures) {
|
|
101
|
+
const signatures: GetSignaturesForAddressApiResponse = await this.rpc
|
|
102
|
+
.getSignaturesForAddress(this.svmSpokeAddress, currentOptions)
|
|
103
|
+
.send();
|
|
104
|
+
// Signatures are sorted by slot in descending order.
|
|
105
|
+
allSignatures.push(...signatures);
|
|
106
|
+
|
|
107
|
+
// Update options for the next batch. Set "before" to the last fetched signature.
|
|
108
|
+
if (signatures.length > 0) {
|
|
109
|
+
currentOptions = { ...currentOptions, before: signatures[signatures.length - 1].signature };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (fromSlot && allSignatures.length > 0 && allSignatures[allSignatures.length - 1].slot < fromSlot) {
|
|
113
|
+
hasMoreSignatures = false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
hasMoreSignatures = Boolean(
|
|
117
|
+
hasMoreSignatures && currentOptions.limit && signatures.length === currentOptions.limit
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const filteredSignatures = allSignatures.filter((signatureTransaction) => {
|
|
122
|
+
if (fromSlot && signatureTransaction.slot < fromSlot) return false;
|
|
123
|
+
if (toSlot && signatureTransaction.slot > toSlot) return false;
|
|
124
|
+
return true;
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Fetch events for all signatures in parallel.
|
|
128
|
+
const eventsWithSlots = await Promise.all(
|
|
129
|
+
filteredSignatures.map(async (signatureTransaction) => {
|
|
130
|
+
const events = await this.readEventsFromSignature(signatureTransaction.signature, options.commitment);
|
|
131
|
+
return events.map((event) => ({
|
|
132
|
+
...event,
|
|
133
|
+
confirmationStatus: signatureTransaction.confirmationStatus,
|
|
134
|
+
blockTime: signatureTransaction.blockTime,
|
|
135
|
+
signature: signatureTransaction.signature,
|
|
136
|
+
slot: signatureTransaction.slot,
|
|
137
|
+
}));
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
return eventsWithSlots.flat();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Reads events from a transaction signature.
|
|
145
|
+
*
|
|
146
|
+
* @param txSignature - The transaction signature.
|
|
147
|
+
* @param commitment - Commitment level.
|
|
148
|
+
* @returns A promise that resolves to an array of events.
|
|
149
|
+
*/
|
|
150
|
+
private async readEventsFromSignature(txSignature: Signature, commitment: Commitment = "confirmed") {
|
|
151
|
+
const txResult = await this.rpc
|
|
152
|
+
.getTransaction(txSignature, { commitment, maxSupportedTransactionVersion: 0 })
|
|
153
|
+
.send();
|
|
154
|
+
|
|
155
|
+
if (txResult === null) return [];
|
|
156
|
+
return this.processEventFromTx(txResult);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Processes events from a transaction.
|
|
161
|
+
*
|
|
162
|
+
* @param txResult - The transaction result.
|
|
163
|
+
* @returns A promise that resolves to an array of events with their data and name.
|
|
164
|
+
*/
|
|
165
|
+
private processEventFromTx(
|
|
166
|
+
txResult: GetTransactionReturnType
|
|
167
|
+
): { program: Address; data: EventData; name: EventName }[] {
|
|
168
|
+
if (!txResult) return [];
|
|
169
|
+
const events: { program: Address; data: EventData; name: EventName }[] = [];
|
|
170
|
+
|
|
171
|
+
const accountKeys = txResult.transaction.message.accountKeys;
|
|
172
|
+
const messageAccountKeys = [...accountKeys];
|
|
173
|
+
// Writable accounts come first, then readonly.
|
|
174
|
+
// See https://docs.anza.xyz/proposals/versioned-transactions#new-transaction-format
|
|
175
|
+
messageAccountKeys.push(...(txResult?.meta?.loadedAddresses?.writable ?? []));
|
|
176
|
+
messageAccountKeys.push(...(txResult?.meta?.loadedAddresses?.readonly ?? []));
|
|
177
|
+
|
|
178
|
+
for (const ixBlock of txResult.meta?.innerInstructions ?? []) {
|
|
179
|
+
for (const ix of ixBlock.instructions) {
|
|
180
|
+
const ixProgramId = messageAccountKeys[ix.programIdIndex];
|
|
181
|
+
const singleIxAccount = ix.accounts.length === 1 ? messageAccountKeys[ix.accounts[0]] : undefined;
|
|
182
|
+
if (
|
|
183
|
+
ixProgramId !== undefined &&
|
|
184
|
+
singleIxAccount !== undefined &&
|
|
185
|
+
this.svmSpokeAddress === ixProgramId &&
|
|
186
|
+
this.svmSpokeEventAuthority === singleIxAccount
|
|
187
|
+
) {
|
|
188
|
+
const ixData = bs58.decode(ix.data);
|
|
189
|
+
// Skip the first 8 bytes (assumed header) and encode the rest.
|
|
190
|
+
const eventData = Buffer.from(ixData.slice(8)).toString("base64");
|
|
191
|
+
const { name, data } = decodeEvent(SvmSpokeIdl, eventData);
|
|
192
|
+
events.push({ program: this.svmSpokeAddress, name, data });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return events;
|
|
198
|
+
}
|
|
199
|
+
}
|
package/src/svm/index.ts
ADDED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
+
import { Signature, Address, UnixTimestamp } from "@solana/kit";
|
|
1
2
|
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";
|
|
13
3
|
|
|
14
4
|
export type EventData =
|
|
15
5
|
| SvmSpokeClient.BridgedToHubPool
|
|
@@ -46,19 +36,12 @@ export enum SVMEventNames {
|
|
|
46
36
|
|
|
47
37
|
export type EventName = keyof typeof SVMEventNames;
|
|
48
38
|
|
|
49
|
-
export type EventWithData = {
|
|
39
|
+
export type EventWithData<T extends EventData> = {
|
|
50
40
|
confirmationStatus: string | null;
|
|
51
41
|
blockTime: UnixTimestamp | null;
|
|
52
42
|
signature: Signature;
|
|
53
43
|
slot: bigint;
|
|
54
|
-
name:
|
|
55
|
-
data:
|
|
44
|
+
name: EventName;
|
|
45
|
+
data: T;
|
|
56
46
|
program: Address;
|
|
57
47
|
};
|
|
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,58 @@
|
|
|
1
|
+
import { BN, BorshEventCoder, Idl } from "@coral-xyz/anchor";
|
|
2
|
+
import { address } from "@solana/kit";
|
|
3
|
+
import { EventName, EventData, SVMEventNames } from "../types";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parses event data from a transaction.
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
export function parseEventData(eventData: any): any {
|
|
10
|
+
if (!eventData) return eventData;
|
|
11
|
+
|
|
12
|
+
if (Array.isArray(eventData)) {
|
|
13
|
+
return eventData.map(parseEventData);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (typeof eventData === "object") {
|
|
17
|
+
if (eventData.constructor.name === "PublicKey") {
|
|
18
|
+
return address(eventData.toString());
|
|
19
|
+
}
|
|
20
|
+
if (BN.isBN(eventData)) {
|
|
21
|
+
return BigInt(eventData.toString());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Convert each key from snake_case to camelCase and process the value recursively.
|
|
25
|
+
return Object.fromEntries(
|
|
26
|
+
Object.entries(eventData).map(([key, value]) => [snakeToCamel(key), parseEventData(value)])
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return eventData;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Decodes a raw event according to a supplied IDL.
|
|
35
|
+
*/
|
|
36
|
+
export function decodeEvent(idl: Idl, rawEvent: string): { data: EventData; name: EventName } {
|
|
37
|
+
const event = new BorshEventCoder(idl).decode(rawEvent);
|
|
38
|
+
if (!event) throw new Error(`Malformed rawEvent for IDL ${idl.address}: ${rawEvent}`);
|
|
39
|
+
return {
|
|
40
|
+
name: getEventName(event.name),
|
|
41
|
+
data: parseEventData(event.data),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Converts a snake_case string to camelCase.
|
|
47
|
+
*/
|
|
48
|
+
function snakeToCamel(s: string): string {
|
|
49
|
+
return s.replace(/(_\w)/g, (match) => match[1].toUpperCase());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Gets the event name from a raw name.
|
|
54
|
+
*/
|
|
55
|
+
export function getEventName(rawName: string): EventName {
|
|
56
|
+
if (Object.values(SVMEventNames).some((name) => rawName.includes(name))) return rawName as EventName;
|
|
57
|
+
throw new Error(`Unknown event name: ${rawName}`);
|
|
58
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import web3, { RpcTransport } from "@solana/kit";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helper to determine if the current RPC network is devnet.
|
|
5
|
+
*/
|
|
6
|
+
export async function isDevnet(rpc: web3.Rpc<web3.SolanaRpcApiFromTransport<RpcTransport>>): Promise<boolean> {
|
|
7
|
+
const genesisHash = await rpc.getGenesisHash().send();
|
|
8
|
+
return genesisHash === "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./events";
|