@across-protocol/sdk 3.0.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/LICENSE +661 -0
- package/README.md +116 -0
- package/dist/cjs/apiClient/abstractClient.d.ts +13 -0
- package/dist/cjs/apiClient/abstractClient.js +17 -0
- package/dist/cjs/apiClient/abstractClient.js.map +1 -0
- package/dist/cjs/apiClient/index.d.ts +2 -0
- package/dist/cjs/apiClient/index.js +11 -0
- package/dist/cjs/apiClient/index.js.map +1 -0
- package/dist/cjs/apiClient/mockedClient.d.ts +11 -0
- package/dist/cjs/apiClient/mockedClient.js +60 -0
- package/dist/cjs/apiClient/mockedClient.js.map +1 -0
- package/dist/cjs/apiClient/productionClient.d.ts +10 -0
- package/dist/cjs/apiClient/productionClient.js +110 -0
- package/dist/cjs/apiClient/productionClient.js.map +1 -0
- package/dist/cjs/apiClient/types.d.ts +44 -0
- package/dist/cjs/apiClient/types.js +3 -0
- package/dist/cjs/apiClient/types.js.map +1 -0
- package/dist/cjs/caching/Arweave/ArweaveClient.d.ts +20 -0
- package/dist/cjs/caching/Arweave/ArweaveClient.js +218 -0
- package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -0
- package/dist/cjs/caching/Arweave/index.d.ts +1 -0
- package/dist/cjs/caching/Arweave/index.js +5 -0
- package/dist/cjs/caching/Arweave/index.js.map +1 -0
- package/dist/cjs/caching/IPFS/PinataIPFSClient.d.ts +11 -0
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js +67 -0
- package/dist/cjs/caching/IPFS/PinataIPFSClient.js.map +1 -0
- package/dist/cjs/caching/IPFS/index.d.ts +1 -0
- package/dist/cjs/caching/IPFS/index.js +5 -0
- package/dist/cjs/caching/IPFS/index.js.map +1 -0
- package/dist/cjs/caching/index.d.ts +2 -0
- package/dist/cjs/caching/index.js +6 -0
- package/dist/cjs/caching/index.js.map +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +66 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +377 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/index.d.ts +1 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js +5 -0
- package/dist/cjs/clients/AcrossConfigStoreClient/index.js.map +1 -0
- package/dist/cjs/clients/BaseAbstractClient.d.ts +22 -0
- package/dist/cjs/clients/BaseAbstractClient.js +76 -0
- package/dist/cjs/clients/BaseAbstractClient.js.map +1 -0
- package/dist/cjs/clients/HubPoolClient.d.ts +111 -0
- package/dist/cjs/clients/HubPoolClient.js +758 -0
- package/dist/cjs/clients/HubPoolClient.js.map +1 -0
- package/dist/cjs/clients/SpokePoolClient.d.ts +117 -0
- package/dist/cjs/clients/SpokePoolClient.js +553 -0
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +4 -0
- package/dist/cjs/clients/index.js +14 -0
- package/dist/cjs/clients/index.js.map +1 -0
- package/dist/cjs/clients/mocks/MockConfigStoreClient.d.ts +20 -0
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +121 -0
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -0
- package/dist/cjs/clients/mocks/MockEvents.d.ts +27 -0
- package/dist/cjs/clients/mocks/MockEvents.js +117 -0
- package/dist/cjs/clients/mocks/MockEvents.js.map +1 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +35 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +222 -0
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +38 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +319 -0
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -0
- package/dist/cjs/clients/mocks/index.d.ts +3 -0
- package/dist/cjs/clients/mocks/index.js +7 -0
- package/dist/cjs/clients/mocks/index.js.map +1 -0
- package/dist/cjs/coingecko/Coingecko.d.ts +40 -0
- package/dist/cjs/coingecko/Coingecko.js +277 -0
- package/dist/cjs/coingecko/Coingecko.js.map +1 -0
- package/dist/cjs/coingecko/index.d.ts +1 -0
- package/dist/cjs/coingecko/index.js +5 -0
- package/dist/cjs/coingecko/index.js.map +1 -0
- package/dist/cjs/constants.d.ts +18 -0
- package/dist/cjs/constants.js +27 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/contracts/acrossConfigStore.d.ts +57 -0
- package/dist/cjs/contracts/acrossConfigStore.js +65 -0
- package/dist/cjs/contracts/acrossConfigStore.js.map +1 -0
- package/dist/cjs/contracts/hubPool.d.ts +17 -0
- package/dist/cjs/contracts/hubPool.js +61 -0
- package/dist/cjs/contracts/hubPool.js.map +1 -0
- package/dist/cjs/contracts/index.d.ts +2 -0
- package/dist/cjs/contracts/index.js +7 -0
- package/dist/cjs/contracts/index.js.map +1 -0
- package/dist/cjs/contracts/utils.d.ts +15 -0
- package/dist/cjs/contracts/utils.js +40 -0
- package/dist/cjs/contracts/utils.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +25 -0
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.d.ts +4 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +46 -0
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/index.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/index.js +7 -0
- package/dist/cjs/gasPriceOracle/adapters/index.js.map +1 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +77 -0
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -0
- package/dist/cjs/gasPriceOracle/index.d.ts +2 -0
- package/dist/cjs/gasPriceOracle/index.js +6 -0
- package/dist/cjs/gasPriceOracle/index.js.map +1 -0
- package/dist/cjs/gasPriceOracle/oracle.d.ts +3 -0
- package/dist/cjs/gasPriceOracle/oracle.js +45 -0
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -0
- package/dist/cjs/gasPriceOracle/types.d.ts +8 -0
- package/dist/cjs/gasPriceOracle/types.js +3 -0
- package/dist/cjs/gasPriceOracle/types.js.map +1 -0
- package/dist/cjs/gasPriceOracle/util.d.ts +2 -0
- package/dist/cjs/gasPriceOracle/util.js +8 -0
- package/dist/cjs/gasPriceOracle/util.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/Bridge.d.ts +9 -0
- package/dist/cjs/interfaces/Bridge.js +3 -0
- package/dist/cjs/interfaces/Bridge.js.map +1 -0
- package/dist/cjs/interfaces/CachingMechanism.d.ts +5 -0
- package/dist/cjs/interfaces/CachingMechanism.js +3 -0
- package/dist/cjs/interfaces/CachingMechanism.js.map +1 -0
- package/dist/cjs/interfaces/Common.d.ts +10 -0
- package/dist/cjs/interfaces/Common.js +3 -0
- package/dist/cjs/interfaces/Common.js.map +1 -0
- package/dist/cjs/interfaces/ConfigStore.d.ts +81 -0
- package/dist/cjs/interfaces/ConfigStore.js +3 -0
- package/dist/cjs/interfaces/ConfigStore.js.map +1 -0
- package/dist/cjs/interfaces/Error.d.ts +5 -0
- package/dist/cjs/interfaces/Error.js +3 -0
- package/dist/cjs/interfaces/Error.js.map +1 -0
- package/dist/cjs/interfaces/HubPool.d.ts +98 -0
- package/dist/cjs/interfaces/HubPool.js +3 -0
- package/dist/cjs/interfaces/HubPool.js.map +1 -0
- package/dist/cjs/interfaces/SpokePool.d.ts +103 -0
- package/dist/cjs/interfaces/SpokePool.js +16 -0
- package/dist/cjs/interfaces/SpokePool.js.map +1 -0
- package/dist/cjs/interfaces/TypedData.d.ts +19 -0
- package/dist/cjs/interfaces/TypedData.js +3 -0
- package/dist/cjs/interfaces/TypedData.js.map +1 -0
- package/dist/cjs/interfaces/index.d.ts +8 -0
- package/dist/cjs/interfaces/index.js +12 -0
- package/dist/cjs/interfaces/index.js.map +1 -0
- package/dist/cjs/lpFeeCalculator/index.d.ts +1 -0
- package/dist/cjs/lpFeeCalculator/index.js +5 -0
- package/dist/cjs/lpFeeCalculator/index.js.map +1 -0
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.d.ts +19 -0
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js +79 -0
- package/dist/cjs/lpFeeCalculator/lpFeeCalculator.js.map +1 -0
- package/dist/cjs/lpFeeCalculator/rateModel.d.ts +28 -0
- package/dist/cjs/lpFeeCalculator/rateModel.js +103 -0
- package/dist/cjs/lpFeeCalculator/rateModel.js.map +1 -0
- package/dist/cjs/merkleDistributor/MerkleDistributor.d.ts +8 -0
- package/dist/cjs/merkleDistributor/MerkleDistributor.js +25 -0
- package/dist/cjs/merkleDistributor/MerkleDistributor.js.map +1 -0
- package/dist/cjs/merkleDistributor/index.d.ts +2 -0
- package/dist/cjs/merkleDistributor/index.js +6 -0
- package/dist/cjs/merkleDistributor/index.js.map +1 -0
- package/dist/cjs/merkleDistributor/model/Distribution.d.ts +17 -0
- package/dist/cjs/merkleDistributor/model/Distribution.js +3 -0
- package/dist/cjs/merkleDistributor/model/Distribution.js.map +1 -0
- package/dist/cjs/merkleDistributor/model/index.d.ts +1 -0
- package/dist/cjs/merkleDistributor/model/index.js +5 -0
- package/dist/cjs/merkleDistributor/model/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/pool/TransactionManager.d.ts +12 -0
- package/dist/cjs/pool/TransactionManager.js +121 -0
- package/dist/cjs/pool/TransactionManager.js.map +1 -0
- package/dist/cjs/pool/index.d.ts +1 -0
- package/dist/cjs/pool/index.js +5 -0
- package/dist/cjs/pool/index.js.map +1 -0
- package/dist/cjs/pool/poolClient.d.ts +232 -0
- package/dist/cjs/pool/poolClient.js +869 -0
- package/dist/cjs/pool/poolClient.js.map +1 -0
- package/dist/cjs/priceClient/adapters/acrossApi.d.ts +13 -0
- package/dist/cjs/priceClient/adapters/acrossApi.js +48 -0
- package/dist/cjs/priceClient/adapters/acrossApi.js.map +1 -0
- package/dist/cjs/priceClient/adapters/baseAdapter.d.ts +17 -0
- package/dist/cjs/priceClient/adapters/baseAdapter.js +81 -0
- package/dist/cjs/priceClient/adapters/baseAdapter.js.map +1 -0
- package/dist/cjs/priceClient/adapters/coingecko.d.ts +14 -0
- package/dist/cjs/priceClient/adapters/coingecko.js +75 -0
- package/dist/cjs/priceClient/adapters/coingecko.js.map +1 -0
- package/dist/cjs/priceClient/adapters/defiLlama.d.ts +17 -0
- package/dist/cjs/priceClient/adapters/defiLlama.js +95 -0
- package/dist/cjs/priceClient/adapters/defiLlama.js.map +1 -0
- package/dist/cjs/priceClient/adapters/index.d.ts +3 -0
- package/dist/cjs/priceClient/adapters/index.js +8 -0
- package/dist/cjs/priceClient/adapters/index.js.map +1 -0
- package/dist/cjs/priceClient/index.d.ts +2 -0
- package/dist/cjs/priceClient/index.js +7 -0
- package/dist/cjs/priceClient/index.js.map +1 -0
- package/dist/cjs/priceClient/priceClient.d.ts +32 -0
- package/dist/cjs/priceClient/priceClient.js +197 -0
- package/dist/cjs/priceClient/priceClient.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +29 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +62 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.d.ts +151 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +35 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.d.ts +3 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js +7 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/index.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.d.ts +152 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js +43 -0
- package/dist/cjs/relayFeeCalculator/chain-queries/polygon.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/index.d.ts +2 -0
- package/dist/cjs/relayFeeCalculator/index.js +6 -0
- package/dist/cjs/relayFeeCalculator/index.js.map +1 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +231 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +224 -0
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -0
- package/dist/cjs/typechain.d.ts +17 -0
- package/dist/cjs/typechain.js +20 -0
- package/dist/cjs/typechain.js.map +1 -0
- package/dist/cjs/typeguards/error.d.ts +3 -0
- package/dist/cjs/typeguards/error.js +11 -0
- package/dist/cjs/typeguards/error.js.map +1 -0
- package/dist/cjs/typeguards/index.d.ts +1 -0
- package/dist/cjs/typeguards/index.js +5 -0
- package/dist/cjs/typeguards/index.js.map +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +2 -0
- package/dist/cjs/utils/AddressUtils.js +24 -0
- package/dist/cjs/utils/AddressUtils.js.map +1 -0
- package/dist/cjs/utils/ArrayUtils.d.ts +12 -0
- package/dist/cjs/utils/ArrayUtils.js +125 -0
- package/dist/cjs/utils/ArrayUtils.js.map +1 -0
- package/dist/cjs/utils/BigNumberUtils.d.ts +8 -0
- package/dist/cjs/utils/BigNumberUtils.js +26 -0
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -0
- package/dist/cjs/utils/BlockExplorerUtils.d.ts +3 -0
- package/dist/cjs/utils/BlockExplorerUtils.js +52 -0
- package/dist/cjs/utils/BlockExplorerUtils.js.map +1 -0
- package/dist/cjs/utils/BlockUtils.d.ts +28 -0
- package/dist/cjs/utils/BlockUtils.js +251 -0
- package/dist/cjs/utils/BlockUtils.js.map +1 -0
- package/dist/cjs/utils/BundleUtils.d.ts +5 -0
- package/dist/cjs/utils/BundleUtils.js +62 -0
- package/dist/cjs/utils/BundleUtils.js.map +1 -0
- package/dist/cjs/utils/CachingUtils.d.ts +5 -0
- package/dist/cjs/utils/CachingUtils.js +59 -0
- package/dist/cjs/utils/CachingUtils.js.map +1 -0
- package/dist/cjs/utils/DeploymentUtils.d.ts +1 -0
- package/dist/cjs/utils/DeploymentUtils.js +8 -0
- package/dist/cjs/utils/DeploymentUtils.js.map +1 -0
- package/dist/cjs/utils/DepositUtils.d.ts +19 -0
- package/dist/cjs/utils/DepositUtils.js +107 -0
- package/dist/cjs/utils/DepositUtils.js.map +1 -0
- package/dist/cjs/utils/EventUtils.d.ts +18 -0
- package/dist/cjs/utils/EventUtils.js +169 -0
- package/dist/cjs/utils/EventUtils.js.map +1 -0
- package/dist/cjs/utils/FlowUtils.d.ts +7 -0
- package/dist/cjs/utils/FlowUtils.js +42 -0
- package/dist/cjs/utils/FlowUtils.js.map +1 -0
- package/dist/cjs/utils/FormattingUtils.d.ts +15 -0
- package/dist/cjs/utils/FormattingUtils.js +107 -0
- package/dist/cjs/utils/FormattingUtils.js.map +1 -0
- package/dist/cjs/utils/IPFSUtils.d.ts +4 -0
- package/dist/cjs/utils/IPFSUtils.js +48 -0
- package/dist/cjs/utils/IPFSUtils.js.map +1 -0
- package/dist/cjs/utils/JSONUtils.d.ts +4 -0
- package/dist/cjs/utils/JSONUtils.js +53 -0
- package/dist/cjs/utils/JSONUtils.js.map +1 -0
- package/dist/cjs/utils/LogUtils.d.ts +14 -0
- package/dist/cjs/utils/LogUtils.js +18 -0
- package/dist/cjs/utils/LogUtils.js.map +1 -0
- package/dist/cjs/utils/Multicall.d.ts +13 -0
- package/dist/cjs/utils/Multicall.js +73 -0
- package/dist/cjs/utils/Multicall.js.map +1 -0
- package/dist/cjs/utils/NetworkUtils.d.ts +10 -0
- package/dist/cjs/utils/NetworkUtils.js +70 -0
- package/dist/cjs/utils/NetworkUtils.js.map +1 -0
- package/dist/cjs/utils/NumberUtils.d.ts +2 -0
- package/dist/cjs/utils/NumberUtils.js +12 -0
- package/dist/cjs/utils/NumberUtils.js.map +1 -0
- package/dist/cjs/utils/ObjectUtils.d.ts +5 -0
- package/dist/cjs/utils/ObjectUtils.js +65 -0
- package/dist/cjs/utils/ObjectUtils.js.map +1 -0
- package/dist/cjs/utils/ReviverUtils.d.ts +3 -0
- package/dist/cjs/utils/ReviverUtils.js +23 -0
- package/dist/cjs/utils/ReviverUtils.js.map +1 -0
- package/dist/cjs/utils/SpokeUtils.d.ts +16 -0
- package/dist/cjs/utils/SpokeUtils.js +299 -0
- package/dist/cjs/utils/SpokeUtils.js.map +1 -0
- package/dist/cjs/utils/TimeUtils.d.ts +1 -0
- package/dist/cjs/utils/TimeUtils.js +8 -0
- package/dist/cjs/utils/TimeUtils.js.map +1 -0
- package/dist/cjs/utils/TokenUtils.d.ts +303 -0
- package/dist/cjs/utils/TokenUtils.js +74 -0
- package/dist/cjs/utils/TokenUtils.js.map +1 -0
- package/dist/cjs/utils/TypeGuards.d.ts +3 -0
- package/dist/cjs/utils/TypeGuards.js +16 -0
- package/dist/cjs/utils/TypeGuards.js.map +1 -0
- package/dist/cjs/utils/TypeUtils.d.ts +5 -0
- package/dist/cjs/utils/TypeUtils.js +3 -0
- package/dist/cjs/utils/TypeUtils.js.map +1 -0
- package/dist/cjs/utils/V3Utils.d.ts +4 -0
- package/dist/cjs/utils/V3Utils.js +15 -0
- package/dist/cjs/utils/V3Utils.js.map +1 -0
- package/dist/cjs/utils/ValidatorUtils.d.ts +2 -0
- package/dist/cjs/utils/ValidatorUtils.js +39 -0
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -0
- package/dist/cjs/utils/abi/contracts/Multicall3.json +440 -0
- package/dist/cjs/utils/abi/index.d.ts +3 -0
- package/dist/cjs/utils/abi/index.js +31 -0
- package/dist/cjs/utils/abi/index.js.map +1 -0
- package/dist/cjs/utils/common.d.ts +79 -0
- package/dist/cjs/utils/common.js +220 -0
- package/dist/cjs/utils/common.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +29 -0
- package/dist/cjs/utils/index.js +33 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/apiClient/abstractClient.d.ts +66 -0
- package/dist/esm/apiClient/abstractClient.js +31 -0
- package/dist/esm/apiClient/abstractClient.js.map +1 -0
- package/dist/esm/apiClient/index.d.ts +2 -0
- package/dist/esm/apiClient/index.js +3 -0
- package/dist/esm/apiClient/index.js.map +1 -0
- package/dist/esm/apiClient/mockedClient.d.ts +24 -0
- package/dist/esm/apiClient/mockedClient.js +69 -0
- package/dist/esm/apiClient/mockedClient.js.map +1 -0
- package/dist/esm/apiClient/productionClient.d.ts +16 -0
- package/dist/esm/apiClient/productionClient.js +114 -0
- package/dist/esm/apiClient/productionClient.js.map +1 -0
- package/dist/esm/apiClient/types.d.ts +44 -0
- package/dist/esm/apiClient/types.js +2 -0
- package/dist/esm/apiClient/types.js.map +1 -0
- package/dist/esm/caching/Arweave/ArweaveClient.d.ts +61 -0
- package/dist/esm/caching/Arweave/ArweaveClient.js +265 -0
- package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -0
- package/dist/esm/caching/Arweave/index.d.ts +1 -0
- package/dist/esm/caching/Arweave/index.js +2 -0
- package/dist/esm/caching/Arweave/index.js.map +1 -0
- package/dist/esm/caching/IPFS/PinataIPFSClient.d.ts +37 -0
- package/dist/esm/caching/IPFS/PinataIPFSClient.js +81 -0
- package/dist/esm/caching/IPFS/PinataIPFSClient.js.map +1 -0
- package/dist/esm/caching/IPFS/index.d.ts +1 -0
- package/dist/esm/caching/IPFS/index.js +2 -0
- package/dist/esm/caching/IPFS/index.js.map +1 -0
- package/dist/esm/caching/index.d.ts +2 -0
- package/dist/esm/caching/index.js +3 -0
- package/dist/esm/caching/index.js.map +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +108 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +467 -0
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/index.d.ts +1 -0
- package/dist/esm/clients/AcrossConfigStoreClient/index.js +2 -0
- package/dist/esm/clients/AcrossConfigStoreClient/index.js.map +1 -0
- package/dist/esm/clients/BaseAbstractClient.d.ts +51 -0
- package/dist/esm/clients/BaseAbstractClient.js +101 -0
- package/dist/esm/clients/BaseAbstractClient.js.map +1 -0
- package/dist/esm/clients/HubPoolClient.d.ts +134 -0
- package/dist/esm/clients/HubPoolClient.js +862 -0
- package/dist/esm/clients/HubPoolClient.js.map +1 -0
- package/dist/esm/clients/SpokePoolClient.d.ts +318 -0
- package/dist/esm/clients/SpokePoolClient.js +780 -0
- package/dist/esm/clients/SpokePoolClient.js.map +1 -0
- package/dist/esm/clients/index.d.ts +4 -0
- package/dist/esm/clients/index.js +6 -0
- package/dist/esm/clients/index.js.map +1 -0
- package/dist/esm/clients/mocks/MockConfigStoreClient.d.ts +20 -0
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +122 -0
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -0
- package/dist/esm/clients/mocks/MockEvents.d.ts +34 -0
- package/dist/esm/clients/mocks/MockEvents.js +126 -0
- package/dist/esm/clients/mocks/MockEvents.js.map +1 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +35 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js +223 -0
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +38 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +322 -0
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -0
- package/dist/esm/clients/mocks/index.d.ts +3 -0
- package/dist/esm/clients/mocks/index.js +4 -0
- package/dist/esm/clients/mocks/index.js.map +1 -0
- package/dist/esm/coingecko/Coingecko.d.ts +40 -0
- package/dist/esm/coingecko/Coingecko.js +283 -0
- package/dist/esm/coingecko/Coingecko.js.map +1 -0
- package/dist/esm/coingecko/index.d.ts +1 -0
- package/dist/esm/coingecko/index.js +2 -0
- package/dist/esm/coingecko/index.js.map +1 -0
- package/dist/esm/constants.d.ts +29 -0
- package/dist/esm/constants.js +34 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/contracts/acrossConfigStore.d.ts +57 -0
- package/dist/esm/contracts/acrossConfigStore.js +62 -0
- package/dist/esm/contracts/acrossConfigStore.js.map +1 -0
- package/dist/esm/contracts/hubPool.d.ts +17 -0
- package/dist/esm/contracts/hubPool.js +55 -0
- package/dist/esm/contracts/hubPool.js.map +1 -0
- package/dist/esm/contracts/index.d.ts +2 -0
- package/dist/esm/contracts/index.js +5 -0
- package/dist/esm/contracts/index.js.map +1 -0
- package/dist/esm/contracts/utils.d.ts +23 -0
- package/dist/esm/contracts/utils.js +38 -0
- package/dist/esm/contracts/utils.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +25 -0
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.d.ts +4 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +41 -0
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/index.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/index.js +4 -0
- package/dist/esm/gasPriceOracle/adapters/index.js.map +1 -0
- package/dist/esm/gasPriceOracle/adapters/polygon.d.ts +3 -0
- package/dist/esm/gasPriceOracle/adapters/polygon.js +78 -0
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -0
- package/dist/esm/gasPriceOracle/index.d.ts +2 -0
- package/dist/esm/gasPriceOracle/index.js +2 -0
- package/dist/esm/gasPriceOracle/index.js.map +1 -0
- package/dist/esm/gasPriceOracle/oracle.d.ts +10 -0
- package/dist/esm/gasPriceOracle/oracle.js +48 -0
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -0
- package/dist/esm/gasPriceOracle/types.d.ts +8 -0
- package/dist/esm/gasPriceOracle/types.js +2 -0
- package/dist/esm/gasPriceOracle/types.js.map +1 -0
- package/dist/esm/gasPriceOracle/util.d.ts +2 -0
- package/dist/esm/gasPriceOracle/util.js +4 -0
- package/dist/esm/gasPriceOracle/util.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +31 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/Bridge.d.ts +9 -0
- package/dist/esm/interfaces/Bridge.js +2 -0
- package/dist/esm/interfaces/Bridge.js.map +1 -0
- package/dist/esm/interfaces/CachingMechanism.d.ts +26 -0
- package/dist/esm/interfaces/CachingMechanism.js +2 -0
- package/dist/esm/interfaces/CachingMechanism.js.map +1 -0
- package/dist/esm/interfaces/Common.d.ts +10 -0
- package/dist/esm/interfaces/Common.js +2 -0
- package/dist/esm/interfaces/Common.js.map +1 -0
- package/dist/esm/interfaces/ConfigStore.d.ts +157 -0
- package/dist/esm/interfaces/ConfigStore.js +2 -0
- package/dist/esm/interfaces/ConfigStore.js.map +1 -0
- package/dist/esm/interfaces/Error.d.ts +5 -0
- package/dist/esm/interfaces/Error.js +2 -0
- package/dist/esm/interfaces/Error.js.map +1 -0
- package/dist/esm/interfaces/HubPool.d.ts +98 -0
- package/dist/esm/interfaces/HubPool.js +2 -0
- package/dist/esm/interfaces/HubPool.js.map +1 -0
- package/dist/esm/interfaces/SpokePool.d.ts +103 -0
- package/dist/esm/interfaces/SpokePool.js +13 -0
- package/dist/esm/interfaces/SpokePool.js.map +1 -0
- package/dist/esm/interfaces/TypedData.d.ts +19 -0
- package/dist/esm/interfaces/TypedData.js +2 -0
- package/dist/esm/interfaces/TypedData.js.map +1 -0
- package/dist/esm/interfaces/index.d.ts +8 -0
- package/dist/esm/interfaces/index.js +9 -0
- package/dist/esm/interfaces/index.js.map +1 -0
- package/dist/esm/lpFeeCalculator/index.d.ts +1 -0
- package/dist/esm/lpFeeCalculator/index.js +2 -0
- package/dist/esm/lpFeeCalculator/index.js.map +1 -0
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.d.ts +66 -0
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js +129 -0
- package/dist/esm/lpFeeCalculator/lpFeeCalculator.js.map +1 -0
- package/dist/esm/lpFeeCalculator/rateModel.d.ts +45 -0
- package/dist/esm/lpFeeCalculator/rateModel.js +138 -0
- package/dist/esm/lpFeeCalculator/rateModel.js.map +1 -0
- package/dist/esm/merkleDistributor/MerkleDistributor.d.ts +20 -0
- package/dist/esm/merkleDistributor/MerkleDistributor.js +34 -0
- package/dist/esm/merkleDistributor/MerkleDistributor.js.map +1 -0
- package/dist/esm/merkleDistributor/index.d.ts +2 -0
- package/dist/esm/merkleDistributor/index.js +3 -0
- package/dist/esm/merkleDistributor/index.js.map +1 -0
- package/dist/esm/merkleDistributor/model/Distribution.d.ts +17 -0
- package/dist/esm/merkleDistributor/model/Distribution.js +2 -0
- package/dist/esm/merkleDistributor/model/Distribution.js.map +1 -0
- package/dist/esm/merkleDistributor/model/index.d.ts +1 -0
- package/dist/esm/merkleDistributor/model/index.js +2 -0
- package/dist/esm/merkleDistributor/model/index.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/pool/TransactionManager.d.ts +12 -0
- package/dist/esm/pool/TransactionManager.js +122 -0
- package/dist/esm/pool/TransactionManager.js.map +1 -0
- package/dist/esm/pool/index.d.ts +1 -0
- package/dist/esm/pool/index.js +2 -0
- package/dist/esm/pool/index.js.map +1 -0
- package/dist/esm/pool/poolClient.d.ts +242 -0
- package/dist/esm/pool/poolClient.js +899 -0
- package/dist/esm/pool/poolClient.js.map +1 -0
- package/dist/esm/priceClient/adapters/acrossApi.d.ts +14 -0
- package/dist/esm/priceClient/adapters/acrossApi.js +49 -0
- package/dist/esm/priceClient/adapters/acrossApi.js.map +1 -0
- package/dist/esm/priceClient/adapters/baseAdapter.d.ts +17 -0
- package/dist/esm/priceClient/adapters/baseAdapter.js +78 -0
- package/dist/esm/priceClient/adapters/baseAdapter.js.map +1 -0
- package/dist/esm/priceClient/adapters/coingecko.d.ts +14 -0
- package/dist/esm/priceClient/adapters/coingecko.js +73 -0
- package/dist/esm/priceClient/adapters/coingecko.js.map +1 -0
- package/dist/esm/priceClient/adapters/defiLlama.d.ts +17 -0
- package/dist/esm/priceClient/adapters/defiLlama.js +93 -0
- package/dist/esm/priceClient/adapters/defiLlama.js.map +1 -0
- package/dist/esm/priceClient/adapters/index.d.ts +3 -0
- package/dist/esm/priceClient/adapters/index.js +7 -0
- package/dist/esm/priceClient/adapters/index.js.map +1 -0
- package/dist/esm/priceClient/index.d.ts +2 -0
- package/dist/esm/priceClient/index.js +4 -0
- package/dist/esm/priceClient/index.js.map +1 -0
- package/dist/esm/priceClient/priceClient.d.ts +32 -0
- package/dist/esm/priceClient/priceClient.js +206 -0
- package/dist/esm/priceClient/priceClient.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +61 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +91 -0
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/factory.d.ts +151 -0
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +38 -0
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.d.ts +3 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js +4 -0
- package/dist/esm/relayFeeCalculator/chain-queries/index.js.map +1 -0
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.d.ts +152 -0
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.js +40 -0
- package/dist/esm/relayFeeCalculator/chain-queries/polygon.js.map +1 -0
- package/dist/esm/relayFeeCalculator/index.d.ts +2 -0
- package/dist/esm/relayFeeCalculator/index.js +3 -0
- package/dist/esm/relayFeeCalculator/index.js.map +1 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +282 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +298 -0
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -0
- package/dist/esm/typechain.d.ts +22 -0
- package/dist/esm/typechain.js +9 -0
- package/dist/esm/typechain.js.map +1 -0
- package/dist/esm/typeguards/error.d.ts +3 -0
- package/dist/esm/typeguards/error.js +6 -0
- package/dist/esm/typeguards/error.js.map +1 -0
- package/dist/esm/typeguards/index.d.ts +1 -0
- package/dist/esm/typeguards/index.js +2 -0
- package/dist/esm/typeguards/index.js.map +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +8 -0
- package/dist/esm/utils/AddressUtils.js +28 -0
- package/dist/esm/utils/AddressUtils.js.map +1 -0
- package/dist/esm/utils/ArrayUtils.d.ts +98 -0
- package/dist/esm/utils/ArrayUtils.js +196 -0
- package/dist/esm/utils/ArrayUtils.js.map +1 -0
- package/dist/esm/utils/BigNumberUtils.d.ts +31 -0
- package/dist/esm/utils/BigNumberUtils.js +52 -0
- package/dist/esm/utils/BigNumberUtils.js.map +1 -0
- package/dist/esm/utils/BlockExplorerUtils.d.ts +21 -0
- package/dist/esm/utils/BlockExplorerUtils.js +91 -0
- package/dist/esm/utils/BlockExplorerUtils.js.map +1 -0
- package/dist/esm/utils/BlockUtils.d.ts +46 -0
- package/dist/esm/utils/BlockUtils.js +294 -0
- package/dist/esm/utils/BlockUtils.js.map +1 -0
- package/dist/esm/utils/BundleUtils.d.ts +29 -0
- package/dist/esm/utils/BundleUtils.js +89 -0
- package/dist/esm/utils/BundleUtils.js.map +1 -0
- package/dist/esm/utils/CachingUtils.d.ts +17 -0
- package/dist/esm/utils/CachingUtils.js +66 -0
- package/dist/esm/utils/CachingUtils.js.map +1 -0
- package/dist/esm/utils/DeploymentUtils.d.ts +1 -0
- package/dist/esm/utils/DeploymentUtils.js +2 -0
- package/dist/esm/utils/DeploymentUtils.js.map +1 -0
- package/dist/esm/utils/DepositUtils.d.ts +46 -0
- package/dist/esm/utils/DepositUtils.js +138 -0
- package/dist/esm/utils/DepositUtils.js.map +1 -0
- package/dist/esm/utils/EventUtils.d.ts +32 -0
- package/dist/esm/utils/EventUtils.js +194 -0
- package/dist/esm/utils/EventUtils.js.map +1 -0
- package/dist/esm/utils/FlowUtils.d.ts +8 -0
- package/dist/esm/utils/FlowUtils.js +39 -0
- package/dist/esm/utils/FlowUtils.js.map +1 -0
- package/dist/esm/utils/FormattingUtils.d.ts +61 -0
- package/dist/esm/utils/FormattingUtils.js +167 -0
- package/dist/esm/utils/FormattingUtils.js.map +1 -0
- package/dist/esm/utils/IPFSUtils.d.ts +24 -0
- package/dist/esm/utils/IPFSUtils.js +65 -0
- package/dist/esm/utils/IPFSUtils.js.map +1 -0
- package/dist/esm/utils/JSONUtils.d.ts +31 -0
- package/dist/esm/utils/JSONUtils.js +82 -0
- package/dist/esm/utils/JSONUtils.js.map +1 -0
- package/dist/esm/utils/LogUtils.d.ts +20 -0
- package/dist/esm/utils/LogUtils.js +19 -0
- package/dist/esm/utils/LogUtils.js.map +1 -0
- package/dist/esm/utils/Multicall.d.ts +13 -0
- package/dist/esm/utils/Multicall.js +70 -0
- package/dist/esm/utils/Multicall.js.map +1 -0
- package/dist/esm/utils/NetworkUtils.d.ts +60 -0
- package/dist/esm/utils/NetworkUtils.js +109 -0
- package/dist/esm/utils/NetworkUtils.js.map +1 -0
- package/dist/esm/utils/NumberUtils.d.ts +12 -0
- package/dist/esm/utils/NumberUtils.js +17 -0
- package/dist/esm/utils/NumberUtils.js.map +1 -0
- package/dist/esm/utils/ObjectUtils.d.ts +10 -0
- package/dist/esm/utils/ObjectUtils.js +72 -0
- package/dist/esm/utils/ObjectUtils.js.map +1 -0
- package/dist/esm/utils/ReviverUtils.d.ts +15 -0
- package/dist/esm/utils/ReviverUtils.js +33 -0
- package/dist/esm/utils/ReviverUtils.js.map +1 -0
- package/dist/esm/utils/SpokeUtils.d.ts +64 -0
- package/dist/esm/utils/SpokeUtils.js +370 -0
- package/dist/esm/utils/SpokeUtils.js.map +1 -0
- package/dist/esm/utils/TimeUtils.d.ts +5 -0
- package/dist/esm/utils/TimeUtils.js +8 -0
- package/dist/esm/utils/TimeUtils.js.map +1 -0
- package/dist/esm/utils/TokenUtils.d.ts +325 -0
- package/dist/esm/utils/TokenUtils.js +88 -0
- package/dist/esm/utils/TokenUtils.js.map +1 -0
- package/dist/esm/utils/TypeGuards.d.ts +3 -0
- package/dist/esm/utils/TypeGuards.js +10 -0
- package/dist/esm/utils/TypeGuards.js.map +1 -0
- package/dist/esm/utils/TypeUtils.d.ts +5 -0
- package/dist/esm/utils/TypeUtils.js +2 -0
- package/dist/esm/utils/TypeUtils.js.map +1 -0
- package/dist/esm/utils/V3Utils.d.ts +4 -0
- package/dist/esm/utils/V3Utils.js +10 -0
- package/dist/esm/utils/V3Utils.js.map +1 -0
- package/dist/esm/utils/ValidatorUtils.d.ts +2 -0
- package/dist/esm/utils/ValidatorUtils.js +35 -0
- package/dist/esm/utils/ValidatorUtils.js.map +1 -0
- package/dist/esm/utils/abi/contracts/Multicall3.json +440 -0
- package/dist/esm/utils/abi/index.d.ts +18 -0
- package/dist/esm/utils/abi/index.js +41 -0
- package/dist/esm/utils/abi/index.js.map +1 -0
- package/dist/esm/utils/common.d.ts +204 -0
- package/dist/esm/utils/common.js +325 -0
- package/dist/esm/utils/common.js.map +1 -0
- package/dist/esm/utils/index.d.ts +29 -0
- package/dist/esm/utils/index.js +30 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/apiClient/abstractClient.d.ts +67 -0
- package/dist/types/apiClient/abstractClient.d.ts.map +1 -0
- package/dist/types/apiClient/index.d.ts +3 -0
- package/dist/types/apiClient/index.d.ts.map +1 -0
- package/dist/types/apiClient/mockedClient.d.ts +25 -0
- package/dist/types/apiClient/mockedClient.d.ts.map +1 -0
- package/dist/types/apiClient/productionClient.d.ts +17 -0
- package/dist/types/apiClient/productionClient.d.ts.map +1 -0
- package/dist/types/apiClient/types.d.ts +45 -0
- package/dist/types/apiClient/types.d.ts.map +1 -0
- package/dist/types/caching/Arweave/ArweaveClient.d.ts +62 -0
- package/dist/types/caching/Arweave/ArweaveClient.d.ts.map +1 -0
- package/dist/types/caching/Arweave/index.d.ts +2 -0
- package/dist/types/caching/Arweave/index.d.ts.map +1 -0
- package/dist/types/caching/IPFS/PinataIPFSClient.d.ts +38 -0
- package/dist/types/caching/IPFS/PinataIPFSClient.d.ts.map +1 -0
- package/dist/types/caching/IPFS/index.d.ts +2 -0
- package/dist/types/caching/IPFS/index.d.ts.map +1 -0
- package/dist/types/caching/index.d.ts +3 -0
- package/dist/types/caching/index.d.ts.map +1 -0
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +109 -0
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -0
- package/dist/types/clients/AcrossConfigStoreClient/index.d.ts +2 -0
- package/dist/types/clients/AcrossConfigStoreClient/index.d.ts.map +1 -0
- package/dist/types/clients/BaseAbstractClient.d.ts +52 -0
- package/dist/types/clients/BaseAbstractClient.d.ts.map +1 -0
- package/dist/types/clients/HubPoolClient.d.ts +135 -0
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -0
- package/dist/types/clients/SpokePoolClient.d.ts +319 -0
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/index.d.ts +5 -0
- package/dist/types/clients/index.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts +21 -0
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockEvents.d.ts +35 -0
- package/dist/types/clients/mocks/MockEvents.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +36 -0
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +39 -0
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -0
- package/dist/types/clients/mocks/index.d.ts +4 -0
- package/dist/types/clients/mocks/index.d.ts.map +1 -0
- package/dist/types/coingecko/Coingecko.d.ts +41 -0
- package/dist/types/coingecko/Coingecko.d.ts.map +1 -0
- package/dist/types/coingecko/index.d.ts +2 -0
- package/dist/types/coingecko/index.d.ts.map +1 -0
- package/dist/types/constants.d.ts +30 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/contracts/acrossConfigStore.d.ts +58 -0
- package/dist/types/contracts/acrossConfigStore.d.ts.map +1 -0
- package/dist/types/contracts/hubPool.d.ts +18 -0
- package/dist/types/contracts/hubPool.d.ts.map +1 -0
- package/dist/types/contracts/index.d.ts +3 -0
- package/dist/types/contracts/index.d.ts.map +1 -0
- package/dist/types/contracts/utils.d.ts +24 -0
- package/dist/types/contracts/utils.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts +5 -0
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/index.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/index.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts +4 -0
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/index.d.ts +3 -0
- package/dist/types/gasPriceOracle/index.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/oracle.d.ts +11 -0
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/types.d.ts +9 -0
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -0
- package/dist/types/gasPriceOracle/util.d.ts +3 -0
- package/dist/types/gasPriceOracle/util.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/interfaces/Bridge.d.ts +10 -0
- package/dist/types/interfaces/Bridge.d.ts.map +1 -0
- package/dist/types/interfaces/CachingMechanism.d.ts +27 -0
- package/dist/types/interfaces/CachingMechanism.d.ts.map +1 -0
- package/dist/types/interfaces/Common.d.ts +11 -0
- package/dist/types/interfaces/Common.d.ts.map +1 -0
- package/dist/types/interfaces/ConfigStore.d.ts +158 -0
- package/dist/types/interfaces/ConfigStore.d.ts.map +1 -0
- package/dist/types/interfaces/Error.d.ts +6 -0
- package/dist/types/interfaces/Error.d.ts.map +1 -0
- package/dist/types/interfaces/HubPool.d.ts +99 -0
- package/dist/types/interfaces/HubPool.d.ts.map +1 -0
- package/dist/types/interfaces/SpokePool.d.ts +104 -0
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -0
- package/dist/types/interfaces/TypedData.d.ts +20 -0
- package/dist/types/interfaces/TypedData.d.ts.map +1 -0
- package/dist/types/interfaces/index.d.ts +9 -0
- package/dist/types/interfaces/index.d.ts.map +1 -0
- package/dist/types/lpFeeCalculator/index.d.ts +2 -0
- package/dist/types/lpFeeCalculator/index.d.ts.map +1 -0
- package/dist/types/lpFeeCalculator/lpFeeCalculator.d.ts +67 -0
- package/dist/types/lpFeeCalculator/lpFeeCalculator.d.ts.map +1 -0
- package/dist/types/lpFeeCalculator/rateModel.d.ts +46 -0
- package/dist/types/lpFeeCalculator/rateModel.d.ts.map +1 -0
- package/dist/types/merkleDistributor/MerkleDistributor.d.ts +21 -0
- package/dist/types/merkleDistributor/MerkleDistributor.d.ts.map +1 -0
- package/dist/types/merkleDistributor/index.d.ts +3 -0
- package/dist/types/merkleDistributor/index.d.ts.map +1 -0
- package/dist/types/merkleDistributor/model/Distribution.d.ts +18 -0
- package/dist/types/merkleDistributor/model/Distribution.d.ts.map +1 -0
- package/dist/types/merkleDistributor/model/index.d.ts +2 -0
- package/dist/types/merkleDistributor/model/index.d.ts.map +1 -0
- package/dist/types/pool/TransactionManager.d.ts +13 -0
- package/dist/types/pool/TransactionManager.d.ts.map +1 -0
- package/dist/types/pool/index.d.ts +2 -0
- package/dist/types/pool/index.d.ts.map +1 -0
- package/dist/types/pool/poolClient.d.ts +243 -0
- package/dist/types/pool/poolClient.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/acrossApi.d.ts +15 -0
- package/dist/types/priceClient/adapters/acrossApi.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/baseAdapter.d.ts +18 -0
- package/dist/types/priceClient/adapters/baseAdapter.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/coingecko.d.ts +15 -0
- package/dist/types/priceClient/adapters/coingecko.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/defiLlama.d.ts +18 -0
- package/dist/types/priceClient/adapters/defiLlama.d.ts.map +1 -0
- package/dist/types/priceClient/adapters/index.d.ts +4 -0
- package/dist/types/priceClient/adapters/index.d.ts.map +1 -0
- package/dist/types/priceClient/index.d.ts +3 -0
- package/dist/types/priceClient/index.d.ts.map +1 -0
- package/dist/types/priceClient/priceClient.d.ts +33 -0
- package/dist/types/priceClient/priceClient.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +62 -0
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts +152 -0
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts +4 -0
- package/dist/types/relayFeeCalculator/chain-queries/index.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts +153 -0
- package/dist/types/relayFeeCalculator/chain-queries/polygon.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/index.d.ts +3 -0
- package/dist/types/relayFeeCalculator/index.d.ts.map +1 -0
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +283 -0
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -0
- package/dist/types/typechain.d.ts +23 -0
- package/dist/types/typechain.d.ts.map +1 -0
- package/dist/types/typeguards/error.d.ts +4 -0
- package/dist/types/typeguards/error.d.ts.map +1 -0
- package/dist/types/typeguards/index.d.ts +2 -0
- package/dist/types/typeguards/index.d.ts.map +1 -0
- package/dist/types/utils/AddressUtils.d.ts +9 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -0
- package/dist/types/utils/ArrayUtils.d.ts +99 -0
- package/dist/types/utils/ArrayUtils.d.ts.map +1 -0
- package/dist/types/utils/BigNumberUtils.d.ts +32 -0
- package/dist/types/utils/BigNumberUtils.d.ts.map +1 -0
- package/dist/types/utils/BlockExplorerUtils.d.ts +22 -0
- package/dist/types/utils/BlockExplorerUtils.d.ts.map +1 -0
- package/dist/types/utils/BlockUtils.d.ts +47 -0
- package/dist/types/utils/BlockUtils.d.ts.map +1 -0
- package/dist/types/utils/BundleUtils.d.ts +30 -0
- package/dist/types/utils/BundleUtils.d.ts.map +1 -0
- package/dist/types/utils/CachingUtils.d.ts +18 -0
- package/dist/types/utils/CachingUtils.d.ts.map +1 -0
- package/dist/types/utils/DeploymentUtils.d.ts +2 -0
- package/dist/types/utils/DeploymentUtils.d.ts.map +1 -0
- package/dist/types/utils/DepositUtils.d.ts +47 -0
- package/dist/types/utils/DepositUtils.d.ts.map +1 -0
- package/dist/types/utils/EventUtils.d.ts +33 -0
- package/dist/types/utils/EventUtils.d.ts.map +1 -0
- package/dist/types/utils/FlowUtils.d.ts +9 -0
- package/dist/types/utils/FlowUtils.d.ts.map +1 -0
- package/dist/types/utils/FormattingUtils.d.ts +62 -0
- package/dist/types/utils/FormattingUtils.d.ts.map +1 -0
- package/dist/types/utils/IPFSUtils.d.ts +25 -0
- package/dist/types/utils/IPFSUtils.d.ts.map +1 -0
- package/dist/types/utils/JSONUtils.d.ts +32 -0
- package/dist/types/utils/JSONUtils.d.ts.map +1 -0
- package/dist/types/utils/LogUtils.d.ts +21 -0
- package/dist/types/utils/LogUtils.d.ts.map +1 -0
- package/dist/types/utils/Multicall.d.ts +14 -0
- package/dist/types/utils/Multicall.d.ts.map +1 -0
- package/dist/types/utils/NetworkUtils.d.ts +61 -0
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -0
- package/dist/types/utils/NumberUtils.d.ts +13 -0
- package/dist/types/utils/NumberUtils.d.ts.map +1 -0
- package/dist/types/utils/ObjectUtils.d.ts +11 -0
- package/dist/types/utils/ObjectUtils.d.ts.map +1 -0
- package/dist/types/utils/ReviverUtils.d.ts +16 -0
- package/dist/types/utils/ReviverUtils.d.ts.map +1 -0
- package/dist/types/utils/SpokeUtils.d.ts +65 -0
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -0
- package/dist/types/utils/TimeUtils.d.ts +6 -0
- package/dist/types/utils/TimeUtils.d.ts.map +1 -0
- package/dist/types/utils/TokenUtils.d.ts +326 -0
- package/dist/types/utils/TokenUtils.d.ts.map +1 -0
- package/dist/types/utils/TypeGuards.d.ts +4 -0
- package/dist/types/utils/TypeGuards.d.ts.map +1 -0
- package/dist/types/utils/TypeUtils.d.ts +6 -0
- package/dist/types/utils/TypeUtils.d.ts.map +1 -0
- package/dist/types/utils/V3Utils.d.ts +5 -0
- package/dist/types/utils/V3Utils.d.ts.map +1 -0
- package/dist/types/utils/ValidatorUtils.d.ts +3 -0
- package/dist/types/utils/ValidatorUtils.d.ts.map +1 -0
- package/dist/types/utils/abi/index.d.ts +19 -0
- package/dist/types/utils/abi/index.d.ts.map +1 -0
- package/dist/types/utils/common.d.ts +205 -0
- package/dist/types/utils/common.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +30 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +144 -0
- package/src/apiClient/abstractClient.ts +95 -0
- package/src/apiClient/index.ts +2 -0
- package/src/apiClient/mockedClient.ts +90 -0
- package/src/apiClient/productionClient.ts +98 -0
- package/src/apiClient/types.ts +49 -0
- package/src/caching/Arweave/ArweaveClient.ts +238 -0
- package/src/caching/Arweave/index.ts +1 -0
- package/src/caching/IPFS/PinataIPFSClient.ts +92 -0
- package/src/caching/IPFS/index.ts +1 -0
- package/src/caching/index.ts +2 -0
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +526 -0
- package/src/clients/AcrossConfigStoreClient/index.ts +1 -0
- package/src/clients/BaseAbstractClient.ts +94 -0
- package/src/clients/HubPoolClient.ts +1010 -0
- package/src/clients/SpokePoolClient.ts +894 -0
- package/src/clients/index.ts +9 -0
- package/src/clients/mocks/MockConfigStoreClient.ts +129 -0
- package/src/clients/mocks/MockEvents.ts +156 -0
- package/src/clients/mocks/MockHubPoolClient.ts +257 -0
- package/src/clients/mocks/MockSpokePoolClient.ts +341 -0
- package/src/clients/mocks/index.ts +3 -0
- package/src/coingecko/Coingecko.ts +277 -0
- package/src/coingecko/index.ts +1 -0
- package/src/constants.ts +53 -0
- package/src/contracts/acrossConfigStore.ts +49 -0
- package/src/contracts/hubPool.ts +90 -0
- package/src/contracts/index.ts +2 -0
- package/src/contracts/utils.ts +56 -0
- package/src/gasPriceOracle/adapters/arbitrum.ts +21 -0
- package/src/gasPriceOracle/adapters/ethereum.ts +27 -0
- package/src/gasPriceOracle/adapters/index.ts +3 -0
- package/src/gasPriceOracle/adapters/polygon.ts +77 -0
- package/src/gasPriceOracle/index.ts +2 -0
- package/src/gasPriceOracle/oracle.ts +42 -0
- package/src/gasPriceOracle/types.ts +10 -0
- package/src/gasPriceOracle/util.ts +5 -0
- package/src/index.ts +15 -0
- package/src/interfaces/Bridge.ts +10 -0
- package/src/interfaces/CachingMechanism.ts +37 -0
- package/src/interfaces/Common.ts +12 -0
- package/src/interfaces/ConfigStore.ts +173 -0
- package/src/interfaces/Error.ts +5 -0
- package/src/interfaces/HubPool.ts +118 -0
- package/src/interfaces/SpokePool.ts +119 -0
- package/src/interfaces/TypedData.ts +21 -0
- package/src/interfaces/index.ts +8 -0
- package/src/lpFeeCalculator/README.md +27 -0
- package/src/lpFeeCalculator/index.ts +1 -0
- package/src/lpFeeCalculator/lpFeeCalculator.ts +169 -0
- package/src/lpFeeCalculator/rateModel.ts +183 -0
- package/src/merkleDistributor/MerkleDistributor.ts +37 -0
- package/src/merkleDistributor/README.md +30 -0
- package/src/merkleDistributor/index.ts +2 -0
- package/src/merkleDistributor/model/Distribution.ts +17 -0
- package/src/merkleDistributor/model/index.ts +1 -0
- package/src/pool/TransactionManager.ts +73 -0
- package/src/pool/index.ts +1 -0
- package/src/pool/poolClient.ts +840 -0
- package/src/priceClient/README.md +36 -0
- package/src/priceClient/adapters/acrossApi.ts +44 -0
- package/src/priceClient/adapters/baseAdapter.ts +65 -0
- package/src/priceClient/adapters/coingecko.ts +67 -0
- package/src/priceClient/adapters/defiLlama.ts +96 -0
- package/src/priceClient/adapters/index.ts +3 -0
- package/src/priceClient/index.ts +2 -0
- package/src/priceClient/priceClient.ts +192 -0
- package/src/relayFeeCalculator/README.md +34 -0
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +98 -0
- package/src/relayFeeCalculator/chain-queries/factory.ts +58 -0
- package/src/relayFeeCalculator/chain-queries/index.ts +3 -0
- package/src/relayFeeCalculator/chain-queries/polygon.ts +45 -0
- package/src/relayFeeCalculator/index.ts +2 -0
- package/src/relayFeeCalculator/relayFeeCalculator.ts +410 -0
- package/src/typechain.ts +46 -0
- package/src/typeguards/error.ts +7 -0
- package/src/typeguards/index.ts +1 -0
- package/src/utils/AddressUtils.ts +18 -0
- package/src/utils/ArrayUtils.ts +170 -0
- package/src/utils/BigNumberUtils.ts +58 -0
- package/src/utils/BlockExplorerUtils.ts +91 -0
- package/src/utils/BlockUtils.ts +265 -0
- package/src/utils/BundleUtils.ts +109 -0
- package/src/utils/CachingUtils.ts +56 -0
- package/src/utils/DeploymentUtils.ts +5 -0
- package/src/utils/DepositUtils.ts +144 -0
- package/src/utils/EventUtils.ts +227 -0
- package/src/utils/FlowUtils.ts +48 -0
- package/src/utils/FormattingUtils.ts +186 -0
- package/src/utils/IPFSUtils.ts +48 -0
- package/src/utils/JSONUtils.ts +85 -0
- package/src/utils/LogUtils.ts +38 -0
- package/src/utils/Multicall.ts +64 -0
- package/src/utils/NetworkUtils.ts +117 -0
- package/src/utils/NumberUtils.ts +17 -0
- package/src/utils/ObjectUtils.ts +77 -0
- package/src/utils/ReviverUtils.ts +31 -0
- package/src/utils/SpokeUtils.ts +372 -0
- package/src/utils/TimeUtils.ts +7 -0
- package/src/utils/TokenUtils.ts +94 -0
- package/src/utils/TypeGuards.ts +15 -0
- package/src/utils/TypeUtils.ts +9 -0
- package/src/utils/V3Utils.ts +12 -0
- package/src/utils/ValidatorUtils.ts +38 -0
- package/src/utils/abi/contracts/Multicall3.json +440 -0
- package/src/utils/abi/index.ts +33 -0
- package/src/utils/common.ts +392 -0
- package/src/utils/index.ts +29 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import { BN, toBN } from "./BigNumberUtils";
|
|
3
|
+
import { fromWei } from "./common";
|
|
4
|
+
import assert from "assert";
|
|
5
|
+
import { BigNumber } from "bignumber.js";
|
|
6
|
+
|
|
7
|
+
// Formats the input to round to decimalPlaces number of decimals if the number has a magnitude larger than 1 and fixes
|
|
8
|
+
// precision to minPrecision if the number has a magnitude less than 1.
|
|
9
|
+
export const formatWithMaxDecimals = (
|
|
10
|
+
num: number | string,
|
|
11
|
+
decimalPlaces: number,
|
|
12
|
+
minPrecision: number,
|
|
13
|
+
roundUp: boolean,
|
|
14
|
+
showSign: boolean
|
|
15
|
+
): string => {
|
|
16
|
+
if (roundUp) {
|
|
17
|
+
BigNumber.set({ ROUNDING_MODE: BigNumber.ROUND_UP });
|
|
18
|
+
} else {
|
|
19
|
+
BigNumber.set({ ROUNDING_MODE: BigNumber.ROUND_DOWN });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const fullPrecisionFloat = new BigNumber(num);
|
|
23
|
+
const positiveSign = showSign && fullPrecisionFloat.gt(0) ? "+" : "";
|
|
24
|
+
let fixedPrecisionFloat;
|
|
25
|
+
// Convert back to BN to truncate any trailing 0s that the toFixed() output would print. If the number is equal to or larger than
|
|
26
|
+
// 1 then truncate to `decimalPlaces` number of decimal places. EG 999.999 -> 999.99 with decimalPlaces=2 If the number
|
|
27
|
+
// is less than 1 then truncate to minPrecision precision. EG: 0.0022183471 -> 0.002218 with minPrecision=4
|
|
28
|
+
if (fullPrecisionFloat.abs().gte(new BigNumber(1))) {
|
|
29
|
+
fixedPrecisionFloat = new BigNumber(fullPrecisionFloat).toFixed(decimalPlaces).toString();
|
|
30
|
+
} else {
|
|
31
|
+
fixedPrecisionFloat = new BigNumber(fullPrecisionFloat).toPrecision(minPrecision).toString();
|
|
32
|
+
}
|
|
33
|
+
// This puts commas in the thousands places, but only before the decimal point.
|
|
34
|
+
const fixedPrecisionFloatParts = fixedPrecisionFloat.split(".");
|
|
35
|
+
fixedPrecisionFloatParts[0] = fixedPrecisionFloatParts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
36
|
+
return positiveSign + fixedPrecisionFloatParts.join(".");
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const createFormatFunction = (
|
|
40
|
+
numDisplayedDecimals: number,
|
|
41
|
+
minDisplayedPrecision: number,
|
|
42
|
+
showSign = false,
|
|
43
|
+
decimals = 18
|
|
44
|
+
) => {
|
|
45
|
+
return (valInWei: string | BN): string =>
|
|
46
|
+
formatWithMaxDecimals(
|
|
47
|
+
formatWei(ConvertDecimals(decimals, 18)(valInWei)),
|
|
48
|
+
numDisplayedDecimals,
|
|
49
|
+
minDisplayedPrecision,
|
|
50
|
+
false,
|
|
51
|
+
showSign
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
export const formatFeePct = (relayerFeePct: BN): string => {
|
|
55
|
+
// 1e18 = 100% so 1e16 = 1%.
|
|
56
|
+
return createFormatFunction(2, 4, false, 16)(toBN(relayerFeePct).toString());
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Shortens a lengthy hexadecimal string to a shorter version with an ellipsis in the middle.
|
|
61
|
+
* @param hex A hexadecimal string to be shortened.
|
|
62
|
+
* @param maxLength The maximum length of the shortened string. Defaults to 8.
|
|
63
|
+
* @param delimiter The delimiter to use in the middle of the shortened string. Defaults to "...".
|
|
64
|
+
* @returns The shortened hexadecimal string.
|
|
65
|
+
* @example createShortHexString("0x772871a444c6e4e9903d8533a5a13101b74037158123e6709470f0afbf6e7d94") -> "0x7787...7d94"
|
|
66
|
+
*/
|
|
67
|
+
export function createShortHexString(hex: string, maxLength = 8, delimiter = ".."): string {
|
|
68
|
+
// If we have more maxLength then the hex size, we can simply
|
|
69
|
+
// return the hex directly.
|
|
70
|
+
if (hex.length <= maxLength) {
|
|
71
|
+
return hex;
|
|
72
|
+
}
|
|
73
|
+
// Resolve the maximum available after we account for the delimiter.
|
|
74
|
+
const maxAvailable = maxLength - delimiter.length;
|
|
75
|
+
// Sanity check to make sure we have enough characters to
|
|
76
|
+
// create a shortened version.
|
|
77
|
+
if (maxAvailable <= 0) {
|
|
78
|
+
throw new Error("Invalid max length");
|
|
79
|
+
}
|
|
80
|
+
// We can simulate rounding by adding 0.5 to the integer. If
|
|
81
|
+
// we had an odd division, the floor will add one additional
|
|
82
|
+
// character to the left side.
|
|
83
|
+
const leftCharacters = Math.floor(maxAvailable / 2 + 0.5);
|
|
84
|
+
// A simple floor division between the max character length
|
|
85
|
+
const rightCharacters = Math.floor(maxAvailable / 2);
|
|
86
|
+
// Combine the two sides with the delimiter in the middle.
|
|
87
|
+
return `${hex.substring(0, leftCharacters)}${delimiter}${hex.substring(hex.length - rightCharacters)}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Converts a utf8 string to a hex string.
|
|
92
|
+
* @param input The utf8 string to convert.
|
|
93
|
+
* @returns The hex string.
|
|
94
|
+
*/
|
|
95
|
+
export function utf8ToHex(input: string): string {
|
|
96
|
+
return ethers.utils.formatBytes32String(input);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Converts a hexadecimal string to a utf8 string.
|
|
101
|
+
* @param input The hexadecimal string to convert.
|
|
102
|
+
* @returns The utf8 string.
|
|
103
|
+
*/
|
|
104
|
+
export function hexToUtf8(input: string): string {
|
|
105
|
+
return ethers.utils.toUtf8String(input);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Converts a BigNumber to a 32-byte hexadecimal string.
|
|
110
|
+
*
|
|
111
|
+
* @param input - The BigNumber to convert.
|
|
112
|
+
* @returns The 32-byte hexadecimal string representation of the input.
|
|
113
|
+
*/
|
|
114
|
+
export function bnToHex(input: BN): string {
|
|
115
|
+
return ethers.utils.hexZeroPad(ethers.utils.hexlify(toBN(input)), 32);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Converts a value from wei to a decimal value with the specified number of decimal places.
|
|
120
|
+
* @param weiVal - The value in wei to convert.
|
|
121
|
+
* @param decimals - The number of decimal places to include in the converted value.
|
|
122
|
+
* @returns The converted value as a string.
|
|
123
|
+
*/
|
|
124
|
+
export function convertFromWei(weiVal: string, decimals: number): string {
|
|
125
|
+
const formatFunction = createFormatFunction(2, 4, false, decimals);
|
|
126
|
+
return formatFunction(weiVal);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Shortens a list of addresses to a shorter version with only the first 10 characters.
|
|
131
|
+
* @param addresses A list of addresses to shorten.
|
|
132
|
+
* @returns A list of shortened addresses.
|
|
133
|
+
* @see createShortHexString
|
|
134
|
+
*/
|
|
135
|
+
export function shortenHexStrings(addresses: string[]): string[] {
|
|
136
|
+
return addresses.map((h) => createShortHexString(h));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// formatWei converts a string or BN instance from Wei to Ether, e.g., 1e19 -> 10.
|
|
140
|
+
export const formatWei = (num: string | BN): string => {
|
|
141
|
+
// Web3's `fromWei` function doesn't work on BN objects in minified mode (e.g.,
|
|
142
|
+
// `web3.utils.isBN(web3.utils.fromBN("5"))` is false), so we use a workaround where we always pass in strings.
|
|
143
|
+
// See https://github.com/ethereum/web3.js/issues/1777.
|
|
144
|
+
return fromWei(num.toString());
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
// Take an amount based on fromDecimals and convert it to an amount based on toDecimals. For example 100 usdt = 100e6,
|
|
148
|
+
// with 6 decimals. If you wanted to convert this to a base 18 decimals you would get:
|
|
149
|
+
// convertDecimals(6,18)(100000000) => 100000000000000000000 = 100e18.
|
|
150
|
+
// Returns a BigNumber you will need to call toString on
|
|
151
|
+
// fromDecimals: number - decimal value of amount
|
|
152
|
+
// toDecimals: number - decimal value to convert to
|
|
153
|
+
// web3: web3 object to get a big number function.
|
|
154
|
+
// return => (amount:string)=>BN
|
|
155
|
+
export const ConvertDecimals = (fromDecimals: number, toDecimals: number): ((amountIn: string | number | BN) => BN) => {
|
|
156
|
+
assert(fromDecimals >= 0, "requires fromDecimals as an integer >= 0");
|
|
157
|
+
assert(toDecimals >= 0, "requires toDecimals as an integer >= 0");
|
|
158
|
+
// amount: string, BN, number - integer amount in fromDecimals smallest unit that want to convert toDecimals
|
|
159
|
+
// returns: BN with toDecimals in smallest unit
|
|
160
|
+
return (amountIn: string | number | BN) => {
|
|
161
|
+
const amount = toBN(amountIn.toString());
|
|
162
|
+
if (amount.isZero()) return amount;
|
|
163
|
+
const diff = fromDecimals - toDecimals;
|
|
164
|
+
if (diff == 0) return amount;
|
|
165
|
+
if (diff > 0) return amount.div(toBN("10").pow(toBN(diff.toString())));
|
|
166
|
+
return amount.mul(toBN("10").pow(toBN((-1 * diff).toString())));
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Converts a numeric decimal-inclusive string to winston, the base unit of Arweave
|
|
172
|
+
* @param numericString The numeric string to convert
|
|
173
|
+
* @returns The winston representation of the numeric string as a BigNumber
|
|
174
|
+
*/
|
|
175
|
+
export function parseWinston(numericString: string): ethers.BigNumber {
|
|
176
|
+
return ethers.utils.parseUnits(numericString, 12);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Converts a winston value to a numeric string
|
|
181
|
+
* @param winstonValue The winston value to convert
|
|
182
|
+
* @returns The numeric string representation of the winston value
|
|
183
|
+
*/
|
|
184
|
+
export function formatWinston(winstonValue: ethers.BigNumber): string {
|
|
185
|
+
return ethers.utils.formatUnits(winstonValue, 12);
|
|
186
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import PinataClient from "@pinata/sdk";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Build an IPFS client for interacting with the IPFS API
|
|
6
|
+
* @param APIKey The project ID
|
|
7
|
+
* @param secretAPIKey The project secret
|
|
8
|
+
* @returns An IPFS client for interacting with Pinata
|
|
9
|
+
*/
|
|
10
|
+
export function buildIPFSClient(APIKey: string, secretAPIKey: string): PinataClient {
|
|
11
|
+
return new PinataClient(APIKey, secretAPIKey);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Retrieves a value from an IPFS gateway
|
|
16
|
+
* @param contentHash The content hash of the value to retrieve
|
|
17
|
+
* @param publicGatewayURL The URL of the public IPFS gateway to use
|
|
18
|
+
* @returns The value retrieved from the IPFS gateway
|
|
19
|
+
* @throws Error if the value could not be retrieved
|
|
20
|
+
*/
|
|
21
|
+
export async function retrieveValueFromIPFS(contentHash: string, publicGatewayURL: string): Promise<string> {
|
|
22
|
+
const result = await axios.get(`${publicGatewayURL}/ipfs/${contentHash}`, {
|
|
23
|
+
// We need to set the Accept header to text/plain to avoid
|
|
24
|
+
// any anomalies with the response
|
|
25
|
+
headers: {
|
|
26
|
+
Accept: "text/plain",
|
|
27
|
+
},
|
|
28
|
+
// We want just the raw response, not the parsed response
|
|
29
|
+
transformResponse: (r) => r,
|
|
30
|
+
});
|
|
31
|
+
return result.data;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Pins a value to the IPFS network
|
|
36
|
+
* @param key A key to use for pinning the value. This is a metadata field.
|
|
37
|
+
* @param content The value to pin
|
|
38
|
+
* @param client The IPFS client to use
|
|
39
|
+
* @returns The content hash of the pinned value
|
|
40
|
+
*/
|
|
41
|
+
export async function storeValueInIPFS(key: string, content: string, client: PinataClient): Promise<string> {
|
|
42
|
+
const result = await client.pinJSONToIPFS(JSON.parse(content), {
|
|
43
|
+
pinataMetadata: {
|
|
44
|
+
name: key,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return result.IpfsHash;
|
|
48
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { BigNumber } from "ethers";
|
|
2
|
+
import { isDefined } from "./TypeGuards";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This function converts a JSON string into a JSON object. The caveat is that if
|
|
6
|
+
* the parser detects a number, it will convert it to a string and floor it to
|
|
7
|
+
* an integer. This function will not throw but instead return an undefined value
|
|
8
|
+
* if the JSON string is invalid.
|
|
9
|
+
* @param jsonString The JSON string to parse
|
|
10
|
+
* @returns The parsed JSON object or undefined if the JSON string is invalid
|
|
11
|
+
*/
|
|
12
|
+
export function parseJSONWithNumericString(jsonString: string): unknown | undefined {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(jsonString, (_key, value) => {
|
|
15
|
+
if (typeof value === "number") {
|
|
16
|
+
return String(Math.floor(value));
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
});
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This function converts an object into a JSON string. The caveat is that if
|
|
27
|
+
* the parser detects a BigNumber or BN, it will convert it to a string.
|
|
28
|
+
* @param obj The object to stringify
|
|
29
|
+
* @returns The stringified JSON object
|
|
30
|
+
* @throws Error if the object cannot be stringified
|
|
31
|
+
*/
|
|
32
|
+
export function stringifyJSONWithNumericString(obj: unknown): string {
|
|
33
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
34
|
+
if (typeof value === "object" && value !== null && value.type === "BigNumber") {
|
|
35
|
+
return BigNumber.from(value).toString();
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A replacer for use in `JSON.stringify` that converts big numbers to numeric strings.
|
|
43
|
+
* @param _key Unused
|
|
44
|
+
* @param value The value to convert
|
|
45
|
+
* @returns The converted value
|
|
46
|
+
*/
|
|
47
|
+
export function jsonReplacerWithBigNumbers(_key: string, value: unknown): unknown {
|
|
48
|
+
// If the value is not defined (null or undefined), return it as is
|
|
49
|
+
if (!isDefined(value)) {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// We need to check if this is a big number, because the JSON parser
|
|
54
|
+
// is not aware of BigNumbers and will convert them to the string representation
|
|
55
|
+
// of the object itself which is not what we want.
|
|
56
|
+
if (BigNumber.isBigNumber(value)) {
|
|
57
|
+
return value.toString();
|
|
58
|
+
}
|
|
59
|
+
// There's a legacy issues that returns BigNumbers as { type: "BigNumber", hex: "0x..." }
|
|
60
|
+
// so we need to check for that as well.
|
|
61
|
+
const recordValue = value as { type: string; hex: string };
|
|
62
|
+
if (recordValue.type === "BigNumber" && isDefined(recordValue.hex)) {
|
|
63
|
+
return BigNumber.from(recordValue.hex).toString();
|
|
64
|
+
}
|
|
65
|
+
// Return the value as is
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A reviver for use in `JSON.parse` that converts numeric strings to big numbers.
|
|
71
|
+
* @param _key Unused
|
|
72
|
+
* @param value The value to convert
|
|
73
|
+
* @returns The converted value
|
|
74
|
+
*/
|
|
75
|
+
export function jsonReviverWithBigNumbers(_key: string, value: unknown): unknown {
|
|
76
|
+
// We need to check for both strings and big numbers, because the JSON parser
|
|
77
|
+
// is not aware of BigNumbers.
|
|
78
|
+
if (typeof value === "string" && /^-?\d+$/.test(value)) {
|
|
79
|
+
const bigNumber = BigNumber.from(value);
|
|
80
|
+
if (bigNumber.toString() === value) {
|
|
81
|
+
return bigNumber;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
|
|
3
|
+
export type DefaultLogLevels = "debug" | "info" | "warn" | "error";
|
|
4
|
+
|
|
5
|
+
type LogParamType = {
|
|
6
|
+
level: DefaultLogLevels;
|
|
7
|
+
message: string;
|
|
8
|
+
at: {
|
|
9
|
+
location: string;
|
|
10
|
+
function: string;
|
|
11
|
+
};
|
|
12
|
+
data?: Record<string | number, unknown>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function formattedLog(
|
|
16
|
+
logger: Logger | undefined,
|
|
17
|
+
{ level, message, at: { location, function: fnName }, data }: LogParamType
|
|
18
|
+
): void {
|
|
19
|
+
if (logger) {
|
|
20
|
+
logger[level]({
|
|
21
|
+
at: `${location}#${fnName}`,
|
|
22
|
+
message,
|
|
23
|
+
...data,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Asserts the truth of a condition. If the condition is false, an error is thrown with the provided message.
|
|
30
|
+
* @param condition The condition to assert.
|
|
31
|
+
* @param message The message to throw if the condition is false.
|
|
32
|
+
* @throws Error if the condition is false.
|
|
33
|
+
*/
|
|
34
|
+
export function assert(condition: boolean, message: string): void {
|
|
35
|
+
if (!condition) {
|
|
36
|
+
throw new Error(message);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { BigNumber, Contract, providers, Signer, utils as ethersUtils } from "ethers";
|
|
2
|
+
import { getABI } from "./abi";
|
|
3
|
+
|
|
4
|
+
type Provider = providers.Provider;
|
|
5
|
+
type BlockTag = providers.BlockTag;
|
|
6
|
+
type Result = ethersUtils.Result;
|
|
7
|
+
|
|
8
|
+
export type Call3 = {
|
|
9
|
+
contract: Contract;
|
|
10
|
+
method: string;
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
args?: any[];
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Multicall3 Constants:
|
|
16
|
+
export const multicall3Addresses: Record<number, string> = {
|
|
17
|
+
1: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
18
|
+
10: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
19
|
+
137: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
20
|
+
324: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
|
|
21
|
+
8453: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
22
|
+
34443: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
23
|
+
42161: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
24
|
+
59144: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
25
|
+
534352: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
26
|
+
// Testnets
|
|
27
|
+
5: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
28
|
+
300: "0xF9cda624FBC7e059355ce98a31693d299FACd963",
|
|
29
|
+
59140: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
30
|
+
59141: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
31
|
+
80002: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
32
|
+
84531: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
33
|
+
84532: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
34
|
+
421613: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
35
|
+
534351: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
36
|
+
11155111: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
37
|
+
11155420: "0xcA11bde05977b3631167028862bE2a173976CA11",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export async function getMulticall3(
|
|
41
|
+
chainId: number,
|
|
42
|
+
signerOrProvider?: Signer | Provider
|
|
43
|
+
): Promise<Contract | undefined> {
|
|
44
|
+
const address = multicall3Addresses[chainId];
|
|
45
|
+
if (!address) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return new Contract(address, await getABI("Multicall3"), signerOrProvider);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function aggregate(multicall3: Contract, calls: Call3[], blockTag?: BlockTag): Promise<Result[]> {
|
|
53
|
+
const inputs = calls.map(({ contract, method, args }) => ({
|
|
54
|
+
target: contract.address,
|
|
55
|
+
callData: contract.interface.encodeFunctionData(method, args),
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
const [, results] = await (multicall3.callStatic.aggregate(inputs, { blockTag }) as Promise<[BigNumber, string[]]>);
|
|
59
|
+
|
|
60
|
+
return results.map((result, idx) => {
|
|
61
|
+
const { contract, method } = calls[idx];
|
|
62
|
+
return contract.interface.decodeFunctionResult(method, result);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { CHAIN_IDs, MAINNET_CHAIN_IDs, PUBLIC_NETWORKS, TESTNET_CHAIN_IDs } from "../constants";
|
|
2
|
+
|
|
3
|
+
const hreNetworks: Record<number, string> = {
|
|
4
|
+
666: "Hardhat1",
|
|
5
|
+
1337: "Hardhat2",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a network name from a network id.
|
|
10
|
+
* @param networkId The network id to resolve the name for
|
|
11
|
+
* @returns The network name for the network id. If the network id is not found, returns "unknown"
|
|
12
|
+
*/
|
|
13
|
+
export function getNetworkName(networkId: number | string): string {
|
|
14
|
+
networkId = Number(networkId);
|
|
15
|
+
return PUBLIC_NETWORKS[networkId]?.name ?? hreNetworks[networkId] ?? "unknown";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a native token symbol from a chain id.
|
|
20
|
+
* @param chainId The chain id to resolve the native token symbol for
|
|
21
|
+
* @returns The native token symbol for the chain id. If the chain id is not found, returns "ETH"
|
|
22
|
+
*/
|
|
23
|
+
export function getNativeTokenSymbol(chainId: number | string): string {
|
|
24
|
+
return PUBLIC_NETWORKS[Number(chainId)]?.nativeToken ?? "ETH";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Determines whether a chain ID is part of the production network.
|
|
29
|
+
* @param chainId Chain ID to query.
|
|
30
|
+
* @returns true if the chain ID is part of the production network, otherwise false.
|
|
31
|
+
*/
|
|
32
|
+
export function chainIsProd(chainId: number): boolean {
|
|
33
|
+
return Object.values(MAINNET_CHAIN_IDs).includes(chainId);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Determines whether a chain ID is part of the production network.
|
|
38
|
+
* @param chainId Chain ID to query.
|
|
39
|
+
* @returns true if the chain ID is part of the production network, otherwise false.
|
|
40
|
+
*/
|
|
41
|
+
export function chainIsTestnet(chainId: number): boolean {
|
|
42
|
+
return Object.values(TESTNET_CHAIN_IDs).includes(chainId);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Determines whether a chain ID is a Polygon implementation.
|
|
47
|
+
* @param chainId Chain ID to evaluate.
|
|
48
|
+
* @returns True if chainId is a Polygon chain (mainnet or testnet), otherwise false.
|
|
49
|
+
*/
|
|
50
|
+
export function chainIsMatic(chainId: number): boolean {
|
|
51
|
+
return [CHAIN_IDs.POLYGON, CHAIN_IDs.POLYGON_AMOY].includes(chainId);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Determines whether a chain ID is an Optimism OP Stack implementation.
|
|
56
|
+
* @param chainId Chain ID to evaluate.
|
|
57
|
+
* @returns True if chainId is an OP stack, otherwise false.
|
|
58
|
+
*/
|
|
59
|
+
export function chainIsOPStack(chainId: number): boolean {
|
|
60
|
+
return [
|
|
61
|
+
CHAIN_IDs.OPTIMISM,
|
|
62
|
+
CHAIN_IDs.BASE,
|
|
63
|
+
CHAIN_IDs.MODE,
|
|
64
|
+
CHAIN_IDs.OPTIMISM_GOERLI,
|
|
65
|
+
CHAIN_IDs.BASE_GOERLI,
|
|
66
|
+
CHAIN_IDs.OPTIMISM_SEPOLIA,
|
|
67
|
+
CHAIN_IDs.BASE_SEPOLIA,
|
|
68
|
+
CHAIN_IDs.MODE_SEPOLIA,
|
|
69
|
+
].includes(chainId);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Determines whether a chain ID is an Arbitrum implementation.
|
|
74
|
+
* @param chainId Chain ID to evaluate.
|
|
75
|
+
* @returns True if chainId is an Arbitrum chain, otherwise false.
|
|
76
|
+
*/
|
|
77
|
+
export function chainIsArbitrum(chainId: number): boolean {
|
|
78
|
+
return [CHAIN_IDs.ARBITRUM, CHAIN_IDs.ARBITRUM_GOERLI, CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Determines whether a chain ID is a Linea implementation.
|
|
83
|
+
* @param chainId Chain ID to evaluate.
|
|
84
|
+
* @returns True if chainId is a Linea chain, otherwise false.
|
|
85
|
+
*/
|
|
86
|
+
export function chainIsLinea(chainId: number): boolean {
|
|
87
|
+
return [CHAIN_IDs.LINEA, CHAIN_IDs.LINEA_GOERLI].includes(chainId);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Determines whether a chain ID has the capacity for having its USDC bridged via CCTP.
|
|
92
|
+
* @param chainId Chain ID to evaluate.
|
|
93
|
+
* @returns True if chainId is a CCTP-bridging enabled chain, otherwise false.
|
|
94
|
+
*/
|
|
95
|
+
export function chainIsCCTPEnabled(chainId: number): boolean {
|
|
96
|
+
return [
|
|
97
|
+
// Mainnets
|
|
98
|
+
CHAIN_IDs.BASE,
|
|
99
|
+
CHAIN_IDs.OPTIMISM,
|
|
100
|
+
CHAIN_IDs.ARBITRUM,
|
|
101
|
+
CHAIN_IDs.POLYGON,
|
|
102
|
+
// Testnets
|
|
103
|
+
CHAIN_IDs.BASE_SEPOLIA,
|
|
104
|
+
CHAIN_IDs.OPTIMISM_SEPOLIA,
|
|
105
|
+
CHAIN_IDs.ARBITRUM_SEPOLIA,
|
|
106
|
+
CHAIN_IDs.POLYGON_AMOY,
|
|
107
|
+
].includes(chainId);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Determines if a chain ID requires a manual L1 -> L2 finalization step.
|
|
112
|
+
* @param chainId Chain ID to evaluate.
|
|
113
|
+
* @returns True if chainId requires manual L1 -> L2 finalization, otherwise false.
|
|
114
|
+
*/
|
|
115
|
+
export function chainRequiresL1ToL2Finalization(chainId: number): boolean {
|
|
116
|
+
return chainIsCCTPEnabled(chainId) || chainIsLinea(chainId);
|
|
117
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A typeguard for a number with the added check that the number is an integer.
|
|
3
|
+
* @param value The value to check.
|
|
4
|
+
* @returns True if the value is a number and an integer, false otherwise.
|
|
5
|
+
*/
|
|
6
|
+
export function isInteger(value: unknown): value is number {
|
|
7
|
+
return !Number.isNaN(Number(value)) && Number.isInteger(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A typeguard for a number with added checks that the number is an integer and is greater to zero.
|
|
12
|
+
* @param value The value to check.
|
|
13
|
+
* @returns True if the value is a number, an integer, and greater than zero, false otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export function isPositiveInteger(value: unknown): value is number {
|
|
16
|
+
return isInteger(value) && value > 0;
|
|
17
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
// Append value along the keyPath to object. For example assign(deposits, ['1337', '31337'], [{depositId:1}]) will create
|
|
4
|
+
// deposits = {1337:{31337:[{depositId:1}]}}. Note that if the path into the object exists then this will append. This
|
|
5
|
+
// function respects the destination type; if it is an object then deep merge and if an array effectively will push.
|
|
6
|
+
export function assign(obj: any, keyPath: any[], value: any): void {
|
|
7
|
+
const lastKeyIndex = keyPath.length - 1;
|
|
8
|
+
for (let i = 0; i < lastKeyIndex; ++i) {
|
|
9
|
+
const key = keyPath[i];
|
|
10
|
+
if (!(key in obj)) {
|
|
11
|
+
obj[key] = {};
|
|
12
|
+
}
|
|
13
|
+
obj = obj[key];
|
|
14
|
+
}
|
|
15
|
+
// If the object at the deep path does not exist then set to the value.
|
|
16
|
+
if (!obj[keyPath[lastKeyIndex]] || typeof obj[keyPath[lastKeyIndex]] == "string") {
|
|
17
|
+
obj[keyPath[lastKeyIndex]] = value;
|
|
18
|
+
}
|
|
19
|
+
// If the object at the deep path is an array then append array wise.
|
|
20
|
+
else if (Array.isArray(value)) {
|
|
21
|
+
obj[keyPath[lastKeyIndex]] = [...obj[keyPath[lastKeyIndex]], ...value];
|
|
22
|
+
}
|
|
23
|
+
// If the value is false bool then set to false. This special case is needed as {...false} = {} which causes issues.
|
|
24
|
+
else if (value === false) {
|
|
25
|
+
obj[keyPath[lastKeyIndex]] = false;
|
|
26
|
+
}
|
|
27
|
+
// If the object at the deep path is an object then append object wise.
|
|
28
|
+
else {
|
|
29
|
+
obj[keyPath[lastKeyIndex]] = { ...obj[keyPath[lastKeyIndex]], ...value };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Refactor to be more generalized with N props
|
|
34
|
+
export function groupObjectCountsByThreeProps(
|
|
35
|
+
objects: any[],
|
|
36
|
+
primaryProp: string,
|
|
37
|
+
secondaryProp: string,
|
|
38
|
+
tertiaryProp: string
|
|
39
|
+
): any {
|
|
40
|
+
return objects.reduce((result, obj) => {
|
|
41
|
+
result[obj[primaryProp]] = result[obj[primaryProp]] ?? {};
|
|
42
|
+
result[obj[primaryProp]][obj[secondaryProp]] = result[obj[primaryProp]][obj[secondaryProp]] ?? {};
|
|
43
|
+
const existingCount = result[obj[primaryProp]][obj[secondaryProp]][obj[tertiaryProp]];
|
|
44
|
+
result[obj[primaryProp]][obj[secondaryProp]][obj[tertiaryProp]] =
|
|
45
|
+
existingCount === undefined ? 1 : existingCount + 1;
|
|
46
|
+
return result;
|
|
47
|
+
}, {});
|
|
48
|
+
}
|
|
49
|
+
export function groupObjectCountsByTwoProps(
|
|
50
|
+
objects: any[],
|
|
51
|
+
primaryProp: string,
|
|
52
|
+
getSecondaryProp: (obj: any) => string
|
|
53
|
+
): any {
|
|
54
|
+
return objects.reduce((result, obj) => {
|
|
55
|
+
result[obj[primaryProp]] = result[obj[primaryProp]] ?? {};
|
|
56
|
+
const existingCount = result[obj[primaryProp]][getSecondaryProp(obj)];
|
|
57
|
+
result[obj[primaryProp]][getSecondaryProp(obj)] = existingCount === undefined ? 1 : existingCount + 1;
|
|
58
|
+
return result;
|
|
59
|
+
}, {});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function groupObjectCountsByProp(objects: any[], getProp: (obj: any) => string): any {
|
|
63
|
+
return objects.reduce((result, obj) => {
|
|
64
|
+
const existingCount = result[getProp(obj)];
|
|
65
|
+
result[getProp(obj)] = existingCount === undefined ? 1 : existingCount + 1;
|
|
66
|
+
return result;
|
|
67
|
+
}, {});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Filter out falsy keys from an object. Falsy keys are keys with values of false, null, undefined, 0, or empty string.
|
|
72
|
+
* @param obj The object to filter
|
|
73
|
+
* @returns A new object with falsy keys removed
|
|
74
|
+
*/
|
|
75
|
+
export function filterFalsyKeys(obj: Record<string | number, unknown>): Record<string | number, unknown> {
|
|
76
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v));
|
|
77
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { toBN } from "./BigNumberUtils";
|
|
2
|
+
import { isDefined } from "./TypeGuards";
|
|
3
|
+
import { Reviver } from "./TypeUtils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A reviver composer that takes a list of revivers and returns a single reviver that applies all of them.
|
|
7
|
+
* @param revivers The revivers to compose.
|
|
8
|
+
* @returns A single reviver that applies all of the revivers passed in. If no revivers are passed in, the identity
|
|
9
|
+
* function is returned.
|
|
10
|
+
*/
|
|
11
|
+
export function composeRevivers(...revivers: Reviver[]): Reviver {
|
|
12
|
+
// Filter out undefined revivers.
|
|
13
|
+
revivers = revivers.filter(isDefined);
|
|
14
|
+
// Return a single reviver that applies all of the revivers passed in. If no revivers are passed in, the identity
|
|
15
|
+
// function is implicitly returned.
|
|
16
|
+
return (key: string, value: unknown) => revivers.reduce((acc, reviver) => reviver(key, acc), value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reviver function that converts a stringified BigNumber object to a BigNumber object.
|
|
21
|
+
* @param _ The key to the value being revived. Unused.
|
|
22
|
+
* @param value The value being revived.
|
|
23
|
+
* @returns The revived value. If the value is not a stringified BigNumber object, it is returned as-is.
|
|
24
|
+
*/
|
|
25
|
+
export function objectWithBigNumberReviver(_: unknown, value: unknown): unknown {
|
|
26
|
+
if (value === null || typeof value !== "object") {
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
const resolvedValue = value as { type: string; hex: string };
|
|
30
|
+
return resolvedValue.type === "BigNumber" ? toBN(resolvedValue.hex) : resolvedValue;
|
|
31
|
+
}
|