@centrifuge/sdk 0.0.0-alpha.5 → 0.0.0-alpha.50
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/README.md +19 -8
- package/dist/Centrifuge.d.ts +279 -426
- package/dist/Centrifuge.d.ts.map +1 -1
- package/dist/Centrifuge.js +642 -144
- package/dist/Centrifuge.js.map +1 -1
- package/dist/Centrifuge.test.d.ts +2 -0
- package/dist/Centrifuge.test.d.ts.map +1 -0
- package/dist/Centrifuge.test.js +529 -0
- package/dist/Centrifuge.test.js.map +1 -0
- package/dist/abi/Accounting.abi.d.ts +3 -0
- package/dist/abi/Accounting.abi.d.ts.map +1 -0
- package/dist/abi/Accounting.abi.js +33 -0
- package/dist/abi/Accounting.abi.js.map +1 -0
- package/dist/abi/AsyncRequestManager.abi.d.ts +3 -0
- package/dist/abi/AsyncRequestManager.abi.d.ts.map +1 -0
- package/dist/abi/AsyncRequestManager.abi.js +78 -0
- package/dist/abi/AsyncRequestManager.abi.js.map +1 -0
- package/dist/abi/AsyncVault.abi.d.ts +3 -0
- package/dist/abi/AsyncVault.abi.d.ts.map +1 -0
- package/dist/abi/AsyncVault.abi.js +101 -0
- package/dist/abi/AsyncVault.abi.js.map +1 -0
- package/dist/abi/BalanceSheet.abi.d.ts +3 -0
- package/dist/abi/BalanceSheet.abi.d.ts.map +1 -0
- package/dist/abi/BalanceSheet.abi.js +55 -0
- package/dist/abi/BalanceSheet.abi.js.map +1 -0
- package/dist/abi/Currency.abi.d.ts +3 -0
- package/dist/abi/Currency.abi.d.ts.map +1 -0
- package/dist/abi/Currency.abi.js +16 -0
- package/dist/abi/Currency.abi.js.map +1 -0
- package/dist/abi/ERC6909.abi.d.ts +3 -0
- package/dist/abi/ERC6909.abi.d.ts.map +1 -0
- package/dist/abi/ERC6909.abi.js +22 -0
- package/dist/abi/ERC6909.abi.js.map +1 -0
- package/dist/abi/GasService.abi.d.ts +3 -0
- package/dist/abi/GasService.abi.d.ts.map +1 -0
- package/dist/abi/GasService.abi.js +32 -0
- package/dist/abi/GasService.abi.js.map +1 -0
- package/dist/abi/Holdings.abi.d.ts +3 -0
- package/dist/abi/Holdings.abi.d.ts.map +1 -0
- package/dist/abi/Holdings.abi.js +43 -0
- package/dist/abi/Holdings.abi.js.map +1 -0
- package/dist/abi/Hub.abi.d.ts +3 -0
- package/dist/abi/Hub.abi.d.ts.map +1 -0
- package/dist/abi/Hub.abi.js +89 -0
- package/dist/abi/Hub.abi.js.map +1 -0
- package/dist/abi/HubRegistry.abi.d.ts +3 -0
- package/dist/abi/HubRegistry.abi.d.ts.map +1 -0
- package/dist/abi/HubRegistry.abi.js +39 -0
- package/dist/abi/HubRegistry.abi.js.map +1 -0
- package/dist/abi/MessageDispatcher.abi.d.ts +3 -0
- package/dist/abi/MessageDispatcher.abi.d.ts.map +1 -0
- package/dist/abi/MessageDispatcher.abi.js +49 -0
- package/dist/abi/MessageDispatcher.abi.js.map +1 -0
- package/dist/abi/MultiAdapter.abi.d.ts +3 -0
- package/dist/abi/MultiAdapter.abi.d.ts.map +1 -0
- package/dist/abi/MultiAdapter.abi.js +53 -0
- package/dist/abi/MultiAdapter.abi.js.map +1 -0
- package/dist/abi/PoolEscrow.abi.d.ts +3 -0
- package/dist/abi/PoolEscrow.abi.d.ts.map +1 -0
- package/dist/abi/PoolEscrow.abi.js +32 -0
- package/dist/abi/PoolEscrow.abi.js.map +1 -0
- package/dist/abi/PoolEscrowFactory.abi.d.ts +3 -0
- package/dist/abi/PoolEscrowFactory.abi.d.ts.map +1 -0
- package/dist/abi/PoolEscrowFactory.abi.js +19 -0
- package/dist/abi/PoolEscrowFactory.abi.js.map +1 -0
- package/dist/abi/RestrictionManager.abi.d.ts +3 -0
- package/dist/abi/RestrictionManager.abi.d.ts.map +1 -0
- package/dist/abi/RestrictionManager.abi.js +23 -0
- package/dist/abi/RestrictionManager.abi.js.map +1 -0
- package/dist/abi/ShareClassManager.abi.d.ts +3 -0
- package/dist/abi/ShareClassManager.abi.d.ts.map +1 -0
- package/dist/abi/ShareClassManager.abi.js +89 -0
- package/dist/abi/ShareClassManager.abi.js.map +1 -0
- package/dist/abi/Spoke.abi.d.ts +3 -0
- package/dist/abi/Spoke.abi.d.ts.map +1 -0
- package/dist/abi/Spoke.abi.js +90 -0
- package/dist/abi/Spoke.abi.js.map +1 -0
- package/dist/abi/SyncRequestManager.abi.d.ts +3 -0
- package/dist/abi/SyncRequestManager.abi.d.ts.map +1 -0
- package/dist/abi/SyncRequestManager.abi.js +61 -0
- package/dist/abi/SyncRequestManager.abi.js.map +1 -0
- package/dist/abi/Valuation.abi.d.ts +3 -0
- package/dist/abi/Valuation.abi.d.ts.map +1 -0
- package/dist/abi/Valuation.abi.js +2 -0
- package/dist/abi/Valuation.abi.js.map +1 -0
- package/dist/abi/VaultRouter.abi.d.ts +3 -0
- package/dist/abi/VaultRouter.abi.d.ts.map +1 -0
- package/dist/abi/VaultRouter.abi.js +50 -0
- package/dist/abi/VaultRouter.abi.js.map +1 -0
- package/dist/abi/index.d.ts +8696 -8
- package/dist/abi/index.d.ts.map +1 -1
- package/dist/abi/index.js +40 -16
- package/dist/abi/index.js.map +1 -1
- package/dist/config/chains.d.ts +184 -925
- package/dist/config/chains.d.ts.map +1 -1
- package/dist/config/chains.js +2 -2
- package/dist/config/chains.js.map +1 -1
- package/dist/config/protocol.d.ts +3 -0
- package/dist/config/protocol.d.ts.map +1 -0
- package/dist/config/protocol.js +7 -0
- package/dist/config/protocol.js.map +1 -0
- package/dist/entities/BalanceSheet.d.ts +48 -0
- package/dist/entities/BalanceSheet.d.ts.map +1 -0
- package/dist/entities/BalanceSheet.js +94 -0
- package/dist/entities/BalanceSheet.js.map +1 -0
- package/dist/entities/BalanceSheet.test.d.ts +2 -0
- package/dist/entities/BalanceSheet.test.d.ts.map +1 -0
- package/dist/entities/BalanceSheet.test.js +64 -0
- package/dist/entities/BalanceSheet.test.js.map +1 -0
- package/dist/entities/Entity.d.ts +8 -0
- package/dist/entities/Entity.d.ts.map +1 -0
- package/dist/{Entity.js → entities/Entity.js} +5 -3
- package/dist/entities/Entity.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/assetSnapshots.d.ts +14 -14
- package/dist/entities/IndexerQueries/assetSnapshots.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/assetSnapshots.js +16 -16
- package/dist/entities/IndexerQueries/assetSnapshots.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/assetTransactions.d.ts +9 -6
- package/dist/entities/IndexerQueries/assetTransactions.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/assetTransactions.js +8 -7
- package/dist/entities/IndexerQueries/assetTransactions.js.map +1 -0
- package/dist/entities/IndexerQueries/epochs.d.ts +45 -0
- package/dist/entities/IndexerQueries/epochs.d.ts.map +1 -0
- package/dist/entities/IndexerQueries/epochs.js +51 -0
- package/dist/entities/IndexerQueries/epochs.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/index.d.ts +24 -22
- package/dist/entities/IndexerQueries/index.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/index.js +10 -6
- package/dist/entities/IndexerQueries/index.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/investorTransactions.d.ts +4 -4
- package/dist/entities/IndexerQueries/investorTransactions.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/investorTransactions.js +4 -4
- package/dist/entities/IndexerQueries/investorTransactions.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeSnapshots.d.ts +8 -8
- package/dist/entities/IndexerQueries/poolFeeSnapshots.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeSnapshots.js +8 -8
- package/dist/entities/IndexerQueries/poolFeeSnapshots.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeTransactions.d.ts +3 -3
- package/dist/entities/IndexerQueries/poolFeeTransactions.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeTransactions.js +3 -3
- package/dist/entities/IndexerQueries/poolFeeTransactions.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/poolSnapshots.d.ts +30 -24
- package/dist/entities/IndexerQueries/poolSnapshots.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/poolSnapshots.js +29 -23
- package/dist/entities/IndexerQueries/poolSnapshots.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/trancheCurrencyBalance.d.ts +15 -17
- package/dist/entities/IndexerQueries/trancheCurrencyBalance.d.ts.map +1 -0
- package/dist/entities/IndexerQueries/trancheCurrencyBalance.js +63 -0
- package/dist/entities/IndexerQueries/trancheCurrencyBalance.js.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/trancheSnapshots.d.ts +6 -6
- package/dist/entities/IndexerQueries/trancheSnapshots.d.ts.map +1 -0
- package/dist/{IndexerQueries → entities/IndexerQueries}/trancheSnapshots.js +6 -6
- package/dist/entities/IndexerQueries/trancheSnapshots.js.map +1 -0
- package/dist/entities/Investor.d.ts +33 -0
- package/dist/entities/Investor.d.ts.map +1 -0
- package/dist/entities/Investor.js +59 -0
- package/dist/entities/Investor.js.map +1 -0
- package/dist/entities/Investor.test.d.ts +2 -0
- package/dist/entities/Investor.test.d.ts.map +1 -0
- package/dist/entities/Investor.test.js +74 -0
- package/dist/entities/Investor.test.js.map +1 -0
- package/dist/entities/Pool.d.ts +155 -0
- package/dist/entities/Pool.d.ts.map +1 -0
- package/dist/entities/Pool.js +590 -0
- package/dist/entities/Pool.js.map +1 -0
- package/dist/entities/Pool.test.d.ts +2 -0
- package/dist/entities/Pool.test.d.ts.map +1 -0
- package/dist/entities/Pool.test.js +270 -0
- package/dist/entities/Pool.test.js.map +1 -0
- package/dist/entities/PoolNetwork.d.ts +73 -0
- package/dist/entities/PoolNetwork.d.ts.map +1 -0
- package/dist/entities/PoolNetwork.js +318 -0
- package/dist/entities/PoolNetwork.js.map +1 -0
- package/dist/entities/PoolNetwork.test.d.ts +2 -0
- package/dist/entities/PoolNetwork.test.d.ts.map +1 -0
- package/dist/entities/PoolNetwork.test.js +112 -0
- package/dist/entities/PoolNetwork.test.js.map +1 -0
- package/dist/{Reports → entities/Reports}/Processor.d.ts +3 -1
- package/dist/entities/Reports/Processor.d.ts.map +1 -0
- package/dist/{Reports → entities/Reports}/Processor.js +100 -22
- package/dist/entities/Reports/Processor.js.map +1 -0
- package/dist/entities/Reports/Processor.test.d.ts +2 -0
- package/dist/entities/Reports/Processor.test.d.ts.map +1 -0
- package/dist/entities/Reports/Processor.test.js +767 -0
- package/dist/entities/Reports/Processor.test.js.map +1 -0
- package/dist/entities/Reports/Reports.test.d.ts +2 -0
- package/dist/entities/Reports/Reports.test.d.ts.map +1 -0
- package/dist/entities/Reports/Reports.test.js +559 -0
- package/dist/entities/Reports/Reports.test.js.map +1 -0
- package/dist/entities/Reports/index.d.ts +21 -0
- package/dist/entities/Reports/index.d.ts.map +1 -0
- package/dist/{Reports → entities/Reports}/index.js +25 -7
- package/dist/entities/Reports/index.js.map +1 -0
- package/dist/entities/ShareClass.d.ts +196 -0
- package/dist/entities/ShareClass.d.ts.map +1 -0
- package/dist/entities/ShareClass.js +1189 -0
- package/dist/entities/ShareClass.js.map +1 -0
- package/dist/entities/ShareClass.test.d.ts +2 -0
- package/dist/entities/ShareClass.test.d.ts.map +1 -0
- package/dist/entities/ShareClass.test.js +500 -0
- package/dist/entities/ShareClass.test.js.map +1 -0
- package/dist/entities/Vault.d.ts +92 -0
- package/dist/entities/Vault.d.ts.map +1 -0
- package/dist/entities/Vault.js +434 -0
- package/dist/entities/Vault.js.map +1 -0
- package/dist/entities/Vault.test.d.ts +2 -0
- package/dist/entities/Vault.test.d.ts.map +1 -0
- package/dist/entities/Vault.test.js +306 -0
- package/dist/entities/Vault.test.js.map +1 -0
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/tests/forkServer.d.mts +2 -0
- package/dist/tests/forkServer.d.mts.map +1 -0
- package/dist/tests/forkServer.mjs +104 -0
- package/dist/tests/forkServer.mjs.map +1 -0
- package/dist/tests/mocks/mockAssetSnapshots.d.ts +1 -1
- package/dist/tests/mocks/mockAssetSnapshots.d.ts.map +1 -1
- package/dist/tests/mocks/mockAssetSnapshots.js +27 -27
- package/dist/tests/mocks/mockAssetSnapshots.js.map +1 -1
- package/dist/tests/mocks/mockAssetTransactions.d.ts +1 -1
- package/dist/tests/mocks/mockAssetTransactions.d.ts.map +1 -1
- package/dist/tests/mocks/mockAssetTransactions.js +24 -19
- package/dist/tests/mocks/mockAssetTransactions.js.map +1 -1
- package/dist/tests/mocks/mockEpochs.d.ts +3 -0
- package/dist/tests/mocks/mockEpochs.d.ts.map +1 -0
- package/dist/tests/mocks/mockEpochs.js +26 -0
- package/dist/tests/mocks/mockEpochs.js.map +1 -0
- package/dist/tests/mocks/mockInvestorCurrencyBalance.d.ts +1 -1
- package/dist/tests/mocks/mockInvestorCurrencyBalance.d.ts.map +1 -1
- package/dist/tests/mocks/mockInvestorCurrencyBalance.js +15 -15
- package/dist/tests/mocks/mockInvestorCurrencyBalance.js.map +1 -1
- package/dist/tests/mocks/mockInvestorTransactions.d.ts +1 -1
- package/dist/tests/mocks/mockInvestorTransactions.d.ts.map +1 -1
- package/dist/tests/mocks/mockInvestorTransactions.js +5 -5
- package/dist/tests/mocks/mockInvestorTransactions.js.map +1 -1
- package/dist/tests/mocks/mockPoolFeeSnapshot.d.ts +1 -1
- package/dist/tests/mocks/mockPoolFeeSnapshot.d.ts.map +1 -1
- package/dist/tests/mocks/mockPoolFeeSnapshot.js +29 -29
- package/dist/tests/mocks/mockPoolFeeSnapshot.js.map +1 -1
- package/dist/tests/mocks/mockPoolFeeTransactions.d.ts +3 -3
- package/dist/tests/mocks/mockPoolFeeTransactions.d.ts.map +1 -1
- package/dist/tests/mocks/mockPoolFeeTransactions.js +3 -3
- package/dist/tests/mocks/mockPoolFeeTransactions.js.map +1 -1
- package/dist/tests/mocks/mockPoolMetadata.d.ts.map +1 -1
- package/dist/tests/mocks/mockPoolMetadata.js +7 -17
- package/dist/tests/mocks/mockPoolMetadata.js.map +1 -1
- package/dist/tests/mocks/mockPoolSnapshots.d.ts +1 -1
- package/dist/tests/mocks/mockPoolSnapshots.d.ts.map +1 -1
- package/dist/tests/mocks/mockPoolSnapshots.js +47 -45
- package/dist/tests/mocks/mockPoolSnapshots.js.map +1 -1
- package/dist/tests/mocks/mockTrancheSnapshots.d.ts +1 -1
- package/dist/tests/mocks/mockTrancheSnapshots.d.ts.map +1 -1
- package/dist/tests/mocks/mockTrancheSnapshots.js +21 -21
- package/dist/tests/mocks/mockTrancheSnapshots.js.map +1 -1
- package/dist/tests/setup.d.ts.map +1 -1
- package/dist/tests/setup.js +4 -3
- package/dist/tests/setup.js.map +1 -1
- package/dist/tests/tenderly.d.ts +15 -2
- package/dist/tests/tenderly.d.ts.map +1 -1
- package/dist/tests/tenderly.js +74 -67
- package/dist/tests/tenderly.js.map +1 -1
- package/dist/tests/utils.d.ts +3 -0
- package/dist/tests/utils.d.ts.map +1 -0
- package/dist/tests/utils.js +4 -0
- package/dist/tests/utils.js.map +1 -0
- package/dist/types/holdings.d.ts +9 -0
- package/dist/types/holdings.d.ts.map +1 -0
- package/dist/types/holdings.js +10 -0
- package/dist/types/holdings.js.map +1 -0
- package/dist/types/index.d.ts +64 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/poolInput.d.ts +71 -0
- package/dist/types/poolInput.d.ts.map +1 -0
- package/dist/types/poolInput.js +2 -0
- package/dist/types/poolInput.js.map +1 -0
- package/dist/types/poolMetadata.d.ts +14 -13
- package/dist/types/poolMetadata.d.ts.map +1 -1
- package/dist/types/reports.d.ts +130 -69
- package/dist/types/reports.d.ts.map +1 -1
- package/dist/types/transaction.d.ts +60 -3
- package/dist/types/transaction.d.ts.map +1 -1
- package/dist/types/transaction.js +55 -1
- package/dist/types/transaction.js.map +1 -1
- package/dist/utils/BigInt.d.ts +16 -35
- package/dist/utils/BigInt.d.ts.map +1 -1
- package/dist/utils/BigInt.js +18 -25
- package/dist/utils/BigInt.js.map +1 -1
- package/dist/utils/BigInt.test.d.ts +2 -0
- package/dist/utils/BigInt.test.d.ts.map +1 -0
- package/dist/utils/BigInt.test.js +298 -0
- package/dist/utils/BigInt.test.js.map +1 -0
- package/dist/utils/currencies.d.ts +5 -0
- package/dist/utils/currencies.d.ts.map +1 -0
- package/dist/utils/currencies.js +7 -0
- package/dist/utils/currencies.js.map +1 -0
- package/dist/utils/decimal.d.ts +2 -2
- package/dist/utils/decimal.d.ts.map +1 -1
- package/dist/utils/decimal.js.map +1 -1
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +24 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/ipfs.d.ts +7 -0
- package/dist/utils/ipfs.d.ts.map +1 -0
- package/dist/utils/ipfs.js +64 -0
- package/dist/utils/ipfs.js.map +1 -0
- package/dist/utils/ipfs.test.d.ts +2 -0
- package/dist/utils/ipfs.test.d.ts.map +1 -0
- package/dist/utils/ipfs.test.js +54 -0
- package/dist/utils/ipfs.test.js.map +1 -0
- package/dist/utils/permit.d.ts +13 -0
- package/dist/utils/permit.d.ts.map +1 -0
- package/dist/utils/permit.js +82 -0
- package/dist/utils/permit.js.map +1 -0
- package/dist/utils/permit.test.d.ts +2 -0
- package/dist/utils/permit.test.d.ts.map +1 -0
- package/dist/utils/permit.test.js +22 -0
- package/dist/utils/permit.test.js.map +1 -0
- package/dist/utils/rx.d.ts +1 -1
- package/dist/utils/rx.d.ts.map +1 -1
- package/dist/utils/rx.js +4 -0
- package/dist/utils/rx.js.map +1 -1
- package/dist/utils/transaction.d.ts +15 -10
- package/dist/utils/transaction.d.ts.map +1 -1
- package/dist/utils/transaction.js +57 -21
- package/dist/utils/transaction.js.map +1 -1
- package/dist/utils/types.d.ts +39 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +89 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/types.test.d.ts +2 -0
- package/dist/utils/types.test.d.ts.map +1 -0
- package/dist/utils/types.test.js +89 -0
- package/dist/utils/types.test.js.map +1 -0
- package/package.json +14 -9
- package/dist/Account.d.ts +0 -11
- package/dist/Account.d.ts.map +0 -1
- package/dist/Account.js +0 -46
- package/dist/Account.js.map +0 -1
- package/dist/Entity.d.ts +0 -12
- package/dist/Entity.d.ts.map +0 -1
- package/dist/Entity.js.map +0 -1
- package/dist/IndexerQueries/assetSnapshots.d.ts.map +0 -1
- package/dist/IndexerQueries/assetSnapshots.js.map +0 -1
- package/dist/IndexerQueries/assetTransactions.d.ts.map +0 -1
- package/dist/IndexerQueries/assetTransactions.js.map +0 -1
- package/dist/IndexerQueries/index.d.ts.map +0 -1
- package/dist/IndexerQueries/index.js.map +0 -1
- package/dist/IndexerQueries/investorTransactions.d.ts.map +0 -1
- package/dist/IndexerQueries/investorTransactions.js.map +0 -1
- package/dist/IndexerQueries/poolFeeSnapshots.d.ts.map +0 -1
- package/dist/IndexerQueries/poolFeeSnapshots.js.map +0 -1
- package/dist/IndexerQueries/poolFeeTransactions.d.ts.map +0 -1
- package/dist/IndexerQueries/poolFeeTransactions.js.map +0 -1
- package/dist/IndexerQueries/poolSnapshots.d.ts.map +0 -1
- package/dist/IndexerQueries/poolSnapshots.js.map +0 -1
- package/dist/IndexerQueries/trancheCurrencyBalance.d.ts.map +0 -1
- package/dist/IndexerQueries/trancheCurrencyBalance.js +0 -103
- package/dist/IndexerQueries/trancheCurrencyBalance.js.map +0 -1
- package/dist/IndexerQueries/trancheSnapshots.d.ts.map +0 -1
- package/dist/IndexerQueries/trancheSnapshots.js.map +0 -1
- package/dist/Pool.d.ts +0 -27
- package/dist/Pool.d.ts.map +0 -1
- package/dist/Pool.js +0 -76
- package/dist/Pool.js.map +0 -1
- package/dist/PoolNetwork.d.ts +0 -82
- package/dist/PoolNetwork.d.ts.map +0 -1
- package/dist/PoolNetwork.js +0 -236
- package/dist/PoolNetwork.js.map +0 -1
- package/dist/Reports/Processor.d.ts.map +0 -1
- package/dist/Reports/Processor.js.map +0 -1
- package/dist/Reports/index.d.ts +0 -27
- package/dist/Reports/index.d.ts.map +0 -1
- package/dist/Reports/index.js.map +0 -1
- package/dist/Vault.d.ts +0 -96
- package/dist/Vault.d.ts.map +0 -1
- package/dist/Vault.js +0 -330
- package/dist/Vault.js.map +0 -1
- package/dist/abi/CentrifugeRouter.abi.json +0 -43
- package/dist/abi/Currency.abi.json +0 -14
- package/dist/abi/Gateway.abi.json +0 -1
- package/dist/abi/InvestmentManager.abi.json +0 -4
- package/dist/abi/LiquidityPool.abi.json +0 -79
- package/dist/abi/PoolManager.abi.json +0 -55
- package/dist/abi/RestrictionManager.abi.json +0 -22
- package/dist/abi/Router.abi.json +0 -1
- package/dist/config/lp.d.ts +0 -17
- package/dist/config/lp.d.ts.map +0 -1
- package/dist/config/lp.js +0 -35
- package/dist/config/lp.js.map +0 -1
- package/dist/utils/pinToApi.d.ts +0 -2
- package/dist/utils/pinToApi.d.ts.map +0 -1
- package/dist/utils/pinToApi.js +0 -10
- package/dist/utils/pinToApi.js.map +0 -1
package/dist/Centrifuge.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
import { concatWith, defaultIfEmpty, defer, filter, identity, isObservable, map, mergeMap, of, Subject, switchMap, using, } from 'rxjs';
|
|
1
|
+
import { combineLatest, concatWith, defaultIfEmpty, defer, filter, first, identity, isObservable, map, mergeMap, of, Subject, switchMap, timer, using, } from 'rxjs';
|
|
2
2
|
import { fromFetch } from 'rxjs/fetch';
|
|
3
|
-
import { createPublicClient, createWalletClient, custom, getContract, http, parseEventLogs, } from 'viem';
|
|
3
|
+
import { createPublicClient, createWalletClient, custom, encodeFunctionData, fallback, getContract, http, parseAbi, parseEventLogs, toHex, } from 'viem';
|
|
4
4
|
import { ABI } from './abi/index.js';
|
|
5
|
-
import { Account } from './Account.js';
|
|
6
5
|
import { chains } from './config/chains.js';
|
|
7
6
|
import { PERMIT_TYPEHASH } from './constants.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { Investor } from './entities/Investor.js';
|
|
8
|
+
import { Pool } from './entities/Pool.js';
|
|
9
|
+
import { emptyMessage, MessageType, } from './types/transaction.js';
|
|
10
|
+
import { Balance } from './utils/BigInt.js';
|
|
11
|
+
import { randomUint } from './utils/index.js';
|
|
12
|
+
import { createPinning, getUrlFromHash } from './utils/ipfs.js';
|
|
10
13
|
import { hashKey } from './utils/query.js';
|
|
11
14
|
import { makeThenable, repeatOnEvents, shareReplayWithDelayedReset } from './utils/rx.js';
|
|
12
|
-
import { doTransaction, isLocalAccount } from './utils/transaction.js';
|
|
15
|
+
import { doTransaction, isLocalAccount, wrapTransaction } from './utils/transaction.js';
|
|
16
|
+
import { AssetId, PoolId, ShareClassId } from './utils/types.js';
|
|
17
|
+
const PINNING_API_DEMO = 'https://europe-central2-peak-vista-185616.cloudfunctions.net/pinning-api-demo';
|
|
13
18
|
const envConfig = {
|
|
14
19
|
mainnet: {
|
|
15
|
-
indexerUrl: 'https://
|
|
16
|
-
alchemyKey: 'KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ',
|
|
17
|
-
infuraKey: '8ed99a9a115349bbbc01dcf3a24edc96',
|
|
18
|
-
defaultChain: 1,
|
|
20
|
+
indexerUrl: 'https://api.centrifuge.io',
|
|
19
21
|
ipfsUrl: 'https://centrifuge.mypinata.cloud',
|
|
22
|
+
...createPinning(PINNING_API_DEMO),
|
|
20
23
|
},
|
|
21
|
-
|
|
22
|
-
indexerUrl: 'https://api.
|
|
23
|
-
alchemyKey: 'KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ',
|
|
24
|
-
infuraKey: '8cd8e043ee8d4001b97a1c37e08fd9dd',
|
|
25
|
-
defaultChain: 11155111,
|
|
26
|
-
ipfsUrl: 'https://centrifuge.mypinata.cloud',
|
|
27
|
-
},
|
|
28
|
-
dev: {
|
|
29
|
-
indexerUrl: 'https://api.subquery.network/sq/centrifuge/pools-demo-multichain',
|
|
30
|
-
alchemyKey: 'KNR-1LZhNqWOxZS2AN8AFeaiESBV10qZ',
|
|
31
|
-
infuraKey: '8cd8e043ee8d4001b97a1c37e08fd9dd',
|
|
32
|
-
defaultChain: 11155111,
|
|
24
|
+
testnet: {
|
|
25
|
+
indexerUrl: 'https://api-v3-hitz.marble.live/graphql',
|
|
33
26
|
ipfsUrl: 'https://centrifuge.mypinata.cloud',
|
|
27
|
+
...createPinning(PINNING_API_DEMO),
|
|
34
28
|
},
|
|
35
29
|
};
|
|
36
30
|
const defaultConfig = {
|
|
37
31
|
environment: 'mainnet',
|
|
32
|
+
cache: true,
|
|
38
33
|
};
|
|
39
34
|
export class Centrifuge {
|
|
40
35
|
#config;
|
|
@@ -43,13 +38,16 @@ export class Centrifuge {
|
|
|
43
38
|
}
|
|
44
39
|
#clients = new Map();
|
|
45
40
|
getClient(chainId) {
|
|
46
|
-
|
|
41
|
+
const client = this.#clients.get(chainId);
|
|
42
|
+
if (!client)
|
|
43
|
+
throw new Error(`No client found for chain ID "${chainId}"`);
|
|
44
|
+
return client;
|
|
47
45
|
}
|
|
48
46
|
get chains() {
|
|
49
47
|
return [...this.#clients.keys()];
|
|
50
48
|
}
|
|
51
49
|
getChainConfig(chainId) {
|
|
52
|
-
return this.getClient(chainId
|
|
50
|
+
return this.getClient(chainId).chain;
|
|
53
51
|
}
|
|
54
52
|
#signer = null;
|
|
55
53
|
setSigner(signer) {
|
|
@@ -58,8 +56,9 @@ export class Centrifuge {
|
|
|
58
56
|
get signer() {
|
|
59
57
|
return this.#signer;
|
|
60
58
|
}
|
|
59
|
+
#isBatching = new WeakSet();
|
|
61
60
|
constructor(config = {}) {
|
|
62
|
-
const defaultConfigForEnv = envConfig[config?.environment
|
|
61
|
+
const defaultConfigForEnv = envConfig[config?.environment || 'mainnet'];
|
|
63
62
|
this.#config = {
|
|
64
63
|
...defaultConfig,
|
|
65
64
|
...defaultConfigForEnv,
|
|
@@ -73,47 +72,253 @@ export class Centrifuge {
|
|
|
73
72
|
if (!rpcUrl) {
|
|
74
73
|
console.warn(`No rpcUrl defined for chain ${chain.id}. Using public RPC endpoint.`);
|
|
75
74
|
}
|
|
76
|
-
this.#clients.set(chain.id, createPublicClient({
|
|
75
|
+
this.#clients.set(chain.id, createPublicClient({
|
|
76
|
+
chain,
|
|
77
|
+
transport: Array.isArray(rpcUrl)
|
|
78
|
+
? fallback(rpcUrl.map((url) => http(url)), {
|
|
79
|
+
rank: {
|
|
80
|
+
interval: 30_000,
|
|
81
|
+
sampleCount: 5,
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
|
+
: http(rpcUrl),
|
|
85
|
+
batch: { multicall: true },
|
|
86
|
+
pollingInterval: this.#config.pollingInterval,
|
|
87
|
+
cacheTime: 100,
|
|
88
|
+
}));
|
|
77
89
|
});
|
|
78
90
|
}
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Create a new pool on the given chain.
|
|
93
|
+
* @param metadataInput - The metadata for the pool
|
|
94
|
+
* @param currencyCode - The currency code for the pool
|
|
95
|
+
* @param chainId - The chain ID to create the pool on
|
|
96
|
+
* @param counter - The pool counter, used to create a unique pool ID (uint48)
|
|
97
|
+
*/
|
|
98
|
+
createPool(metadataInput, currencyCode = 840, chainId, counter) {
|
|
99
|
+
const self = this;
|
|
100
|
+
return this._transact(async function* ({ walletClient, signingAddress, publicClient }) {
|
|
101
|
+
const [addresses, id] = await Promise.all([self._protocolAddresses(chainId), self.id(chainId)]);
|
|
102
|
+
const poolId = PoolId.from(id, counter ?? randomUint(48));
|
|
103
|
+
const createPoolData = encodeFunctionData({
|
|
104
|
+
abi: ABI.Hub,
|
|
105
|
+
functionName: 'createPool',
|
|
106
|
+
args: [poolId.raw, signingAddress, BigInt(currencyCode)],
|
|
107
|
+
});
|
|
108
|
+
const scIds = Array.from({ length: metadataInput.shareClasses.length }, (_, i) => ShareClassId.from(poolId, i + 1));
|
|
109
|
+
const shareClassesById = {};
|
|
110
|
+
metadataInput.shareClasses.forEach((sc, index) => {
|
|
111
|
+
shareClassesById[scIds[index].raw] = {
|
|
112
|
+
minInitialInvestment: sc.minInvestment,
|
|
113
|
+
apyPercentage: sc.apyPercentage,
|
|
114
|
+
apy: sc.apy,
|
|
115
|
+
defaultAccounts: sc.defaultAccounts,
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
const formattedMetadata = {
|
|
119
|
+
version: 1,
|
|
120
|
+
pool: {
|
|
121
|
+
name: metadataInput.poolName,
|
|
122
|
+
icon: metadataInput.poolIcon,
|
|
123
|
+
asset: {
|
|
124
|
+
class: metadataInput.assetClass,
|
|
125
|
+
subClass: metadataInput.subAssetClass,
|
|
126
|
+
},
|
|
127
|
+
issuer: {
|
|
128
|
+
name: metadataInput.issuerName,
|
|
129
|
+
repName: metadataInput.issuerRepName,
|
|
130
|
+
description: metadataInput.issuerDescription,
|
|
131
|
+
email: metadataInput.email,
|
|
132
|
+
logo: metadataInput.issuerLogo,
|
|
133
|
+
shortDescription: metadataInput.issuerShortDescription,
|
|
134
|
+
categories: metadataInput.issuerCategories,
|
|
135
|
+
},
|
|
136
|
+
poolStructure: metadataInput.poolStructure,
|
|
137
|
+
investorType: metadataInput.investorType,
|
|
138
|
+
links: {
|
|
139
|
+
executiveSummary: metadataInput.executiveSummary,
|
|
140
|
+
forum: metadataInput.forum,
|
|
141
|
+
website: metadataInput.website,
|
|
142
|
+
},
|
|
143
|
+
details: metadataInput.details,
|
|
144
|
+
status: 'open',
|
|
145
|
+
listed: metadataInput.listed ?? true,
|
|
146
|
+
poolRatings: metadataInput.poolRatings.length > 0 ? metadataInput.poolRatings : [],
|
|
147
|
+
reports: metadataInput.report
|
|
148
|
+
? [
|
|
149
|
+
{
|
|
150
|
+
author: {
|
|
151
|
+
name: metadataInput.report.author.name,
|
|
152
|
+
title: metadataInput.report.author.title,
|
|
153
|
+
avatar: metadataInput.report.author.avatar,
|
|
154
|
+
},
|
|
155
|
+
uri: metadataInput.report.uri,
|
|
156
|
+
},
|
|
157
|
+
]
|
|
158
|
+
: [],
|
|
159
|
+
},
|
|
160
|
+
shareClasses: shareClassesById,
|
|
161
|
+
onboarding: {
|
|
162
|
+
shareClasses: metadataInput.onboarding?.shareClasses || {},
|
|
163
|
+
taxInfoRequired: metadataInput.onboarding?.taxInfoRequired,
|
|
164
|
+
externalOnboardingUrl: metadataInput.onboarding?.externalOnboardingUrl,
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
const cid = await self.config.pinJson(formattedMetadata);
|
|
168
|
+
const setMetadataData = encodeFunctionData({
|
|
169
|
+
abi: ABI.Hub,
|
|
170
|
+
functionName: 'setPoolMetadata',
|
|
171
|
+
args: [poolId.raw, toHex(cid)],
|
|
172
|
+
});
|
|
173
|
+
const addScData = metadataInput.shareClasses.map((sc) => encodeFunctionData({
|
|
174
|
+
abi: ABI.Hub,
|
|
175
|
+
functionName: 'addShareClass',
|
|
176
|
+
args: [
|
|
177
|
+
poolId.raw,
|
|
178
|
+
sc.tokenName,
|
|
179
|
+
sc.symbolName,
|
|
180
|
+
sc.salt?.startsWith('0x') ? sc.salt : toHex(sc.salt ?? randomUint(256), { size: 32 }),
|
|
181
|
+
],
|
|
182
|
+
}));
|
|
183
|
+
const accountIsDebitNormal = new Map();
|
|
184
|
+
const accountNumbers = [
|
|
185
|
+
...new Set(metadataInput.shareClasses.flatMap((sc) => Object.entries(sc.defaultAccounts ?? {})
|
|
186
|
+
.filter(([k, v]) => {
|
|
187
|
+
if (!v)
|
|
188
|
+
return false;
|
|
189
|
+
if (['asset', 'expense'].includes(k)) {
|
|
190
|
+
if (accountIsDebitNormal.get(v) === false)
|
|
191
|
+
throw new Error(`Account "${v}" is set as both credit normal and debit normal.`);
|
|
192
|
+
accountIsDebitNormal.set(v, true);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
if (accountIsDebitNormal.get(v) === true)
|
|
196
|
+
throw new Error(`Account "${v}" is set as both credit normal and debit normal.`);
|
|
197
|
+
accountIsDebitNormal.set(v, false);
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
})
|
|
201
|
+
.map(([, v]) => v))),
|
|
202
|
+
];
|
|
203
|
+
const createAccountsData = accountNumbers.map((account) => encodeFunctionData({
|
|
204
|
+
abi: ABI.Hub,
|
|
205
|
+
functionName: 'createAccount',
|
|
206
|
+
args: [poolId.raw, account, accountIsDebitNormal.get(account)],
|
|
207
|
+
}));
|
|
208
|
+
yield* doTransaction('Create pool', publicClient, () => {
|
|
209
|
+
return walletClient.writeContract({
|
|
210
|
+
address: addresses.hub,
|
|
211
|
+
abi: ABI.Hub,
|
|
212
|
+
functionName: 'multicall',
|
|
213
|
+
args: [[createPoolData, setMetadataData, ...addScData, ...createAccountsData]],
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}, chainId);
|
|
81
217
|
}
|
|
82
|
-
|
|
83
|
-
return this._query(
|
|
218
|
+
id(chainId) {
|
|
219
|
+
return this._query(['centrifugeId', chainId], () => this._protocolAddresses(chainId).pipe(switchMap(({ messageDispatcher }) => {
|
|
220
|
+
return this.getClient(chainId).readContract({
|
|
221
|
+
address: messageDispatcher,
|
|
222
|
+
abi: ABI.MessageDispatcher,
|
|
223
|
+
functionName: 'localCentrifugeId',
|
|
224
|
+
});
|
|
225
|
+
})));
|
|
84
226
|
}
|
|
85
227
|
/**
|
|
86
|
-
* Get the
|
|
228
|
+
* Get the existing pools on the different chains.
|
|
229
|
+
*/
|
|
230
|
+
pools() {
|
|
231
|
+
return this._queryIndexer(`{
|
|
232
|
+
pools {
|
|
233
|
+
items {
|
|
234
|
+
id
|
|
235
|
+
blockchain {
|
|
236
|
+
id
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}`, {}, (data) => {
|
|
241
|
+
return data.pools.items.map((pool) => {
|
|
242
|
+
const poolId = new PoolId(pool.id);
|
|
243
|
+
return new Pool(this, poolId.toString(), Number(pool.blockchain.id));
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
pool(id) {
|
|
248
|
+
return this._query(null, () => this.pools().pipe(map((pools) => {
|
|
249
|
+
const pool = pools.find((pool) => pool.id.equals(id));
|
|
250
|
+
if (!pool)
|
|
251
|
+
throw new Error(`Pool with id ${id} not found`);
|
|
252
|
+
return pool;
|
|
253
|
+
})));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get the metadata for an ERC20 or ERC6909 token
|
|
87
257
|
* @param address - The token address
|
|
88
258
|
* @param chainId - The chain ID
|
|
89
259
|
*/
|
|
90
|
-
currency(address, chainId) {
|
|
260
|
+
currency(address, chainId, tokenId = 0n) {
|
|
91
261
|
const curAddress = address.toLowerCase();
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
262
|
+
return this._query(['currency', curAddress, chainId, tokenId], () => defer(async () => {
|
|
263
|
+
let decimals, name, symbol, supportsPermit;
|
|
264
|
+
if (tokenId) {
|
|
265
|
+
const contract = getContract({
|
|
266
|
+
address: curAddress,
|
|
267
|
+
abi: ABI.ERC6909,
|
|
268
|
+
client: this.getClient(chainId),
|
|
269
|
+
});
|
|
270
|
+
[decimals, name, symbol] = await Promise.all([
|
|
271
|
+
contract.read.decimals([tokenId]),
|
|
272
|
+
contract.read.name([tokenId]),
|
|
273
|
+
contract.read.symbol([tokenId]),
|
|
274
|
+
]);
|
|
275
|
+
supportsPermit = false;
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
const contract = getContract({
|
|
279
|
+
address: curAddress,
|
|
280
|
+
abi: ABI.Currency,
|
|
281
|
+
client: this.getClient(chainId),
|
|
282
|
+
});
|
|
283
|
+
[decimals, name, symbol, supportsPermit] = await Promise.all([
|
|
284
|
+
contract.read.decimals(),
|
|
285
|
+
contract.read.name(),
|
|
286
|
+
contract.read.symbol(),
|
|
287
|
+
contract.read
|
|
288
|
+
.PERMIT_TYPEHASH()
|
|
289
|
+
.then((hash) => hash === PERMIT_TYPEHASH)
|
|
290
|
+
.catch(() => false),
|
|
291
|
+
]);
|
|
292
|
+
}
|
|
107
293
|
return {
|
|
108
294
|
address: curAddress,
|
|
295
|
+
tokenId,
|
|
109
296
|
decimals,
|
|
110
297
|
name,
|
|
111
298
|
symbol,
|
|
112
|
-
chainId
|
|
299
|
+
chainId,
|
|
113
300
|
supportsPermit,
|
|
114
301
|
};
|
|
115
302
|
}));
|
|
116
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Get the asset currency details for a given asset ID
|
|
306
|
+
* @param assetId - The asset ID to query
|
|
307
|
+
*/
|
|
308
|
+
assetCurrency(assetId) {
|
|
309
|
+
return this._query(['asset', assetId.toString()], () => this._idToChain(assetId.centrifugeId).pipe(switchMap((chainId) => this._protocolAddresses(chainId).pipe(map(({ spoke }) => ({ chainId, spoke })))), switchMap(async ({ spoke, chainId }) => {
|
|
310
|
+
const [assetAddress, tokenId] = await this.getClient(chainId).readContract({
|
|
311
|
+
address: spoke,
|
|
312
|
+
abi: ABI.Spoke,
|
|
313
|
+
functionName: 'idToAsset',
|
|
314
|
+
args: [assetId.raw],
|
|
315
|
+
});
|
|
316
|
+
return this.currency(assetAddress, chainId, tokenId);
|
|
317
|
+
})));
|
|
318
|
+
}
|
|
319
|
+
investor(address) {
|
|
320
|
+
return this._query(null, () => of(new Investor(this, address)));
|
|
321
|
+
}
|
|
117
322
|
/**
|
|
118
323
|
* Get the balance of an ERC20 token for a given owner.
|
|
119
324
|
* @param currency - The token address
|
|
@@ -122,16 +327,19 @@ export class Centrifuge {
|
|
|
122
327
|
*/
|
|
123
328
|
balance(currency, owner, chainId) {
|
|
124
329
|
const address = owner.toLowerCase();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
330
|
+
return this._query(['balance', currency, owner, chainId], () => {
|
|
331
|
+
return this.currency(currency, chainId).pipe(switchMap((currencyMeta) => defer(async () => {
|
|
332
|
+
const val = await this.getClient(chainId).readContract({
|
|
333
|
+
address: currency,
|
|
334
|
+
abi: ABI.Currency,
|
|
335
|
+
functionName: 'balanceOf',
|
|
336
|
+
args: [address],
|
|
337
|
+
});
|
|
338
|
+
return {
|
|
339
|
+
balance: new Balance(val, currencyMeta.decimals),
|
|
340
|
+
currency: currencyMeta,
|
|
341
|
+
};
|
|
342
|
+
}).pipe(repeatOnEvents(this, {
|
|
135
343
|
address: currency,
|
|
136
344
|
abi: ABI.Currency,
|
|
137
345
|
eventName: 'Transfer',
|
|
@@ -140,18 +348,149 @@ export class Centrifuge {
|
|
|
140
348
|
return event.args.from?.toLowerCase() === address || event.args.to?.toLowerCase() === address;
|
|
141
349
|
});
|
|
142
350
|
},
|
|
143
|
-
},
|
|
351
|
+
}, chainId))));
|
|
144
352
|
});
|
|
145
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Get the assets that exist on a given spoke chain that have been registered on a given hub chain.
|
|
356
|
+
* @param spokeChainId - The chain ID where the assets exist
|
|
357
|
+
* @param hubChainId - The chain ID where the assets should optionally be registered
|
|
358
|
+
*/
|
|
359
|
+
assets(spokeChainId, hubChainId = spokeChainId) {
|
|
360
|
+
return this._query(null, () => combineLatest([this.id(spokeChainId), this.id(hubChainId)]).pipe(switchMap(([spokeCentId, hubCentId]) => this._queryIndexer(`query ($hubCentId: String!) {
|
|
361
|
+
assetRegistrations(where: { centrifugeId: $hubCentId, decimals_gt: 0 }) {
|
|
362
|
+
items {
|
|
363
|
+
assetId
|
|
364
|
+
name
|
|
365
|
+
symbol
|
|
366
|
+
decimals
|
|
367
|
+
asset {
|
|
368
|
+
centrifugeId
|
|
369
|
+
address
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}`, { hubCentId: String(hubCentId) }, (data) => {
|
|
374
|
+
return data.assetRegistrations.items
|
|
375
|
+
.filter((assetReg) => assetReg.asset && Number(assetReg.asset.centrifugeId) === spokeCentId)
|
|
376
|
+
.map((assetReg) => {
|
|
377
|
+
return {
|
|
378
|
+
id: new AssetId(assetReg.assetId),
|
|
379
|
+
address: assetReg.asset.address,
|
|
380
|
+
name: assetReg.name,
|
|
381
|
+
symbol: assetReg.symbol,
|
|
382
|
+
decimals: assetReg.decimals,
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
}))));
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Get the valuation addresses that can be used for holdings.
|
|
389
|
+
*/
|
|
390
|
+
valuations(chainId) {
|
|
391
|
+
return this._query(null, () => this._protocolAddresses(chainId).pipe(map(({ identityValuation }) => {
|
|
392
|
+
return {
|
|
393
|
+
identityValuation,
|
|
394
|
+
};
|
|
395
|
+
})));
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Get the restriction hook addresses that can be used for share tokens.
|
|
399
|
+
*/
|
|
400
|
+
restrictionHooks(chainId) {
|
|
401
|
+
return this._query(null, () => this._protocolAddresses(chainId).pipe(map(({ freezeOnlyHook, redemptionRestrictionsHook, fullRestrictionsHook /* freelyTransferableHook */ }) => {
|
|
402
|
+
return {
|
|
403
|
+
freezeOnlyHook,
|
|
404
|
+
redemptionRestrictionsHook,
|
|
405
|
+
fullRestrictionsHook,
|
|
406
|
+
};
|
|
407
|
+
})));
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Register an asset
|
|
411
|
+
* @param originChainId - The chain ID where the asset exists
|
|
412
|
+
* @param registerOnChainId - The chain ID where the asset should be registered
|
|
413
|
+
* @param assetAddress - The address of the asset to register
|
|
414
|
+
* @param tokenId - Optional token ID for ERC6909 assets
|
|
415
|
+
*/
|
|
416
|
+
registerAsset(originChainId, registerOnChainId, assetAddress, tokenId = 0) {
|
|
417
|
+
const self = this;
|
|
418
|
+
return this._transact(async function* ({ walletClient, publicClient }) {
|
|
419
|
+
const [addresses, id, estimate] = await Promise.all([
|
|
420
|
+
self._protocolAddresses(originChainId),
|
|
421
|
+
self.id(registerOnChainId),
|
|
422
|
+
self._estimate(originChainId, { chainId: registerOnChainId }, MessageType.RegisterAsset),
|
|
423
|
+
]);
|
|
424
|
+
yield* doTransaction('Register asset', publicClient, () => walletClient.writeContract({
|
|
425
|
+
address: addresses.spoke,
|
|
426
|
+
abi: ABI.Spoke,
|
|
427
|
+
functionName: 'registerAsset',
|
|
428
|
+
args: [id, assetAddress, BigInt(tokenId)],
|
|
429
|
+
value: estimate,
|
|
430
|
+
}));
|
|
431
|
+
}, originChainId);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Get the decimals of asset on the Hub side
|
|
435
|
+
* @internal
|
|
436
|
+
*/
|
|
437
|
+
_assetDecimals(assetId, chainId) {
|
|
438
|
+
return this._query(['assetDecimals', assetId.toString()], () => this._protocolAddresses(chainId).pipe(switchMap(({ hubRegistry }) => this.getClient(chainId).readContract({
|
|
439
|
+
address: hubRegistry,
|
|
440
|
+
// Use inline ABI because of function overload
|
|
441
|
+
abi: parseAbi(['function decimals(uint128) view returns (uint8)']),
|
|
442
|
+
functionName: 'decimals',
|
|
443
|
+
args: [assetId.raw],
|
|
444
|
+
}))));
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Get the allowance of an ERC20 or ERC6909 token.
|
|
448
|
+
* which is the contract that moves funds into the vault on behalf of the investor.
|
|
449
|
+
* @param owner - The address of the owner
|
|
450
|
+
* @param spender - The address of the spender
|
|
451
|
+
* @param chainId - The chain ID where the asset is located
|
|
452
|
+
* @param asset - The address of the asset
|
|
453
|
+
* @param tokenId - Optional token ID for ERC6909 assets
|
|
454
|
+
* @internal
|
|
455
|
+
*/
|
|
456
|
+
_allowance(owner, spender, chainId, asset, tokenId) {
|
|
457
|
+
return this._query(['allowance', owner.toLowerCase(), spender.toLowerCase(), asset.toLowerCase(), chainId, tokenId], () => defer(async () => {
|
|
458
|
+
const client = this.getClient(chainId);
|
|
459
|
+
if (tokenId) {
|
|
460
|
+
return client.readContract({
|
|
461
|
+
address: asset,
|
|
462
|
+
abi: ABI.ERC6909,
|
|
463
|
+
functionName: 'allowance',
|
|
464
|
+
args: [owner, spender, tokenId],
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
return client.readContract({
|
|
468
|
+
address: asset,
|
|
469
|
+
abi: ABI.Currency,
|
|
470
|
+
functionName: 'allowance',
|
|
471
|
+
args: [owner, spender],
|
|
472
|
+
});
|
|
473
|
+
}).pipe(repeatOnEvents(this, {
|
|
474
|
+
address: asset,
|
|
475
|
+
abi: [ABI.Currency, ABI.ERC6909],
|
|
476
|
+
eventName: ['Approval', 'Transfer'],
|
|
477
|
+
filter: (events) => {
|
|
478
|
+
return events.some((event) => {
|
|
479
|
+
return (event.args.owner?.toLowerCase() === owner.toLowerCase() ||
|
|
480
|
+
event.args.spender?.toLowerCase() === owner.toLowerCase() ||
|
|
481
|
+
event.args.from?.toLowerCase() === owner.toLowerCase());
|
|
482
|
+
});
|
|
483
|
+
},
|
|
484
|
+
}, chainId)));
|
|
485
|
+
}
|
|
146
486
|
/**
|
|
147
487
|
* Returns an observable of all events on a given chain.
|
|
148
488
|
* @internal
|
|
149
489
|
*/
|
|
150
490
|
_events(chainId) {
|
|
151
|
-
|
|
152
|
-
return this._query(['events', cid], () => using(() => {
|
|
491
|
+
return this._query(['events', chainId], () => using(() => {
|
|
153
492
|
const subject = new Subject();
|
|
154
|
-
const unwatch = this.getClient(
|
|
493
|
+
const unwatch = this.getClient(chainId).watchEvent({
|
|
155
494
|
onLogs: (logs) => subject.next(logs),
|
|
156
495
|
});
|
|
157
496
|
return {
|
|
@@ -199,30 +538,26 @@ export class Centrifuge {
|
|
|
199
538
|
});
|
|
200
539
|
}
|
|
201
540
|
_queryIndexer(query, variables, postProcess) {
|
|
202
|
-
return this._query([query, variables], () =>
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @internal
|
|
208
|
-
*/
|
|
209
|
-
_getIPFSObservable(hash) {
|
|
210
|
-
return fromFetch(`${this.config.ipfsUrl}/ipfs/${hash}`, {
|
|
211
|
-
method: 'GET',
|
|
212
|
-
selector: async (res) => {
|
|
213
|
-
if (!res.ok) {
|
|
214
|
-
console.warn(`Failed to fetch IPFS data: ${res.statusText}`);
|
|
215
|
-
}
|
|
216
|
-
const data = await res.json();
|
|
217
|
-
return data;
|
|
218
|
-
},
|
|
219
|
-
});
|
|
541
|
+
return this._query([query, variables], () =>
|
|
542
|
+
// If subscribed, refetch every 2 minutes
|
|
543
|
+
timer(0, 120_000).pipe(switchMap(() => this._getIndexerObservable(query, variables).pipe(map(postProcess ?? identity)))));
|
|
220
544
|
}
|
|
221
545
|
/**
|
|
222
546
|
* @internal
|
|
223
547
|
*/
|
|
224
548
|
_queryIPFS(hash) {
|
|
225
|
-
return this._query([hash], () =>
|
|
549
|
+
return this._query([hash], () => defer(async () => {
|
|
550
|
+
const url = getUrlFromHash(hash, this.#config.ipfsUrl);
|
|
551
|
+
if (!url) {
|
|
552
|
+
throw new Error(`Invalid IPFS hash: ${hash}`);
|
|
553
|
+
}
|
|
554
|
+
const res = await fetch(url);
|
|
555
|
+
if (!res.ok) {
|
|
556
|
+
throw new Error(`Error fetching IPFS hash ${hash}: ${res.statusText}`);
|
|
557
|
+
}
|
|
558
|
+
const data = (await res.json());
|
|
559
|
+
return data;
|
|
560
|
+
}));
|
|
226
561
|
}
|
|
227
562
|
#memoized = new Map();
|
|
228
563
|
#memoizeWith(keys, callback) {
|
|
@@ -289,10 +624,9 @@ export class Centrifuge {
|
|
|
289
624
|
* const chainId = 1
|
|
290
625
|
*
|
|
291
626
|
* // Wrap an observable that only emits one value and then completes
|
|
292
|
-
* //
|
|
293
627
|
* const query = this._query(['balance', address, tUSD, chainId], () => {
|
|
294
628
|
* return defer(() => fetchBalance(address, tUSD, chainId))
|
|
295
|
-
* }, { valueCacheTime:
|
|
629
|
+
* }, { valueCacheTime: 60_000 })
|
|
296
630
|
*
|
|
297
631
|
* // Logs the current balance and updated balances whenever a new
|
|
298
632
|
* const obs1 = query.subscribe(balance => console.log(balance))
|
|
@@ -316,14 +650,17 @@ export class Centrifuge {
|
|
|
316
650
|
* @internal
|
|
317
651
|
*/
|
|
318
652
|
_query(keys, observableCallback, options) {
|
|
653
|
+
const cache = options?.cache !== false && this.#config.cache !== false;
|
|
654
|
+
const obsCacheTime = options?.observableCacheTime ?? this.#config.pollingInterval ?? 4000;
|
|
319
655
|
function get() {
|
|
320
656
|
const sharedSubject = new Subject();
|
|
321
657
|
function createShared() {
|
|
322
658
|
const $shared = observableCallback().pipe(keys
|
|
323
659
|
? shareReplayWithDelayedReset({
|
|
324
|
-
bufferSize:
|
|
325
|
-
resetDelay:
|
|
326
|
-
|
|
660
|
+
bufferSize: cache ? 1 : 0,
|
|
661
|
+
resetDelay: cache ? obsCacheTime : 0,
|
|
662
|
+
// TODO: Fix valueCacheTime to not cause an infinite loop when the value is expired.
|
|
663
|
+
// windowTime: options?.valueCacheTime ?? Infinity,
|
|
327
664
|
})
|
|
328
665
|
: map((val) => val));
|
|
329
666
|
sharedSubject.next($shared);
|
|
@@ -343,50 +680,9 @@ export class Centrifuge {
|
|
|
343
680
|
return keys ? this.#memoizeWith(keys, get) : get();
|
|
344
681
|
}
|
|
345
682
|
/**
|
|
346
|
-
* Executes
|
|
347
|
-
* When subscribed to, it emits status updates as it progresses.
|
|
348
|
-
* When awaited, it returns the final confirmed if successful.
|
|
349
|
-
* Will additionally prompt the user to switch chains if they're not on the correct chain.
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```ts
|
|
353
|
-
* const tx = this._transact(
|
|
354
|
-
* 'Transfer',
|
|
355
|
-
* ({ walletClient }) =>
|
|
356
|
-
* walletClient.writeContract({
|
|
357
|
-
* address: '0xabc...123',
|
|
358
|
-
* abi: ABI.Currency,
|
|
359
|
-
* functionName: 'transfer',
|
|
360
|
-
* args: ['0xdef...456', 1000000n],
|
|
361
|
-
* }),
|
|
362
|
-
* 1
|
|
363
|
-
* )
|
|
364
|
-
* tx.subscribe(status => console.log(status))
|
|
365
|
-
*
|
|
366
|
-
* // Results in something like the following values being emitted (assuming the user wasn't connected to mainnet):
|
|
367
|
-
* // { type: 'SwitchingChain', chainId: 1 }
|
|
368
|
-
* // { type: 'SigningTransaction', title: 'Transfer' }
|
|
369
|
-
* // { type: 'TransactionPending', title: 'Transfer', hash: '0x123...abc' }
|
|
370
|
-
* // { type: 'TransactionConfirmed', title: 'Transfer', hash: '0x123...abc', receipt: { ... } }
|
|
371
|
-
* ```
|
|
372
|
-
*
|
|
373
|
-
* ```ts
|
|
374
|
-
* const finalResult = await this._transact(...)
|
|
375
|
-
* console.log(finalResult) // { type: 'TransactionConfirmed', title: 'Transfer', hash: '0x123...abc', receipt: { ... } }
|
|
376
|
-
* ```
|
|
377
|
-
*
|
|
378
|
-
* @internal
|
|
379
|
-
*/
|
|
380
|
-
_transact(title, transactionCallback, chainId) {
|
|
381
|
-
return this._transactSequence(async function* (params) {
|
|
382
|
-
const transaction = transactionCallback(params);
|
|
383
|
-
yield* doTransaction(title, params.publicClient, () => transaction);
|
|
384
|
-
}, chainId);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Executes a sequence of transactions on a given chain.
|
|
683
|
+
* Executes one or more transactions on a given chain.
|
|
388
684
|
* When subscribed to, it emits status updates as it progresses.
|
|
389
|
-
* When awaited, it returns the final confirmed if successful.
|
|
685
|
+
* When awaited, it returns the final confirmed result if successful.
|
|
390
686
|
* Will additionally prompt the user to switch chains if they're not on the correct chain.
|
|
391
687
|
*
|
|
392
688
|
* @example
|
|
@@ -413,41 +709,53 @@ export class Centrifuge {
|
|
|
413
709
|
* // { type: 'SigningTransaction', title: 'Invest' }
|
|
414
710
|
* // { type: 'TransactionPending', title: 'Invest', hash: '0x123...abc' }
|
|
415
711
|
* // { type: 'TransactionConfirmed', title: 'Invest', hash: '0x123...abc', receipt: { ... } }
|
|
712
|
+
* ```
|
|
416
713
|
*
|
|
417
714
|
* @internal
|
|
418
715
|
*/
|
|
419
|
-
|
|
420
|
-
const targetChainId = chainId ?? this.config.defaultChain;
|
|
716
|
+
_transact(transactionCallback, chainId) {
|
|
421
717
|
const self = this;
|
|
422
718
|
async function* transact() {
|
|
719
|
+
let isBatching = false;
|
|
720
|
+
if (self.#isBatching.has($tx)) {
|
|
721
|
+
isBatching = true;
|
|
722
|
+
}
|
|
423
723
|
const { signer } = self;
|
|
424
724
|
if (!signer)
|
|
425
725
|
throw new Error('Signer not set');
|
|
426
|
-
const publicClient = self.getClient(
|
|
427
|
-
const chain = self.getChainConfig(
|
|
428
|
-
|
|
429
|
-
? createWalletClient({
|
|
726
|
+
const publicClient = self.getClient(chainId);
|
|
727
|
+
const chain = self.getChainConfig(chainId);
|
|
728
|
+
let walletClient = isLocalAccount(signer)
|
|
729
|
+
? createWalletClient({
|
|
730
|
+
account: signer,
|
|
731
|
+
chain,
|
|
732
|
+
transport: http(),
|
|
733
|
+
})
|
|
430
734
|
: createWalletClient({ transport: custom(signer) });
|
|
431
|
-
const [address] = await
|
|
735
|
+
const [address] = await walletClient.getAddresses();
|
|
432
736
|
if (!address)
|
|
433
737
|
throw new Error('No account selected');
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
738
|
+
if (!isBatching) {
|
|
739
|
+
const selectedChain = await walletClient.getChainId();
|
|
740
|
+
if (selectedChain !== chainId) {
|
|
741
|
+
yield { type: 'SwitchingChain', chainId };
|
|
742
|
+
await walletClient.switchChain({ id: chainId });
|
|
743
|
+
}
|
|
438
744
|
}
|
|
439
745
|
// Re-create the wallet client with the correct chain and account
|
|
440
746
|
// Saves having to pass `account` and `chain` to every `writeContract` call
|
|
441
|
-
|
|
442
|
-
?
|
|
747
|
+
walletClient = isLocalAccount(signer)
|
|
748
|
+
? walletClient
|
|
443
749
|
: createWalletClient({ account: address, chain, transport: custom(signer) });
|
|
444
750
|
const transaction = transactionCallback({
|
|
751
|
+
isBatching,
|
|
445
752
|
signingAddress: address,
|
|
446
753
|
chain,
|
|
447
|
-
chainId
|
|
754
|
+
chainId,
|
|
448
755
|
publicClient,
|
|
449
756
|
walletClient,
|
|
450
757
|
signer,
|
|
758
|
+
root: self,
|
|
451
759
|
});
|
|
452
760
|
if (Symbol.asyncIterator in transaction) {
|
|
453
761
|
yield* transaction;
|
|
@@ -460,7 +768,197 @@ export class Centrifuge {
|
|
|
460
768
|
}
|
|
461
769
|
}
|
|
462
770
|
const $tx = defer(transact).pipe(mergeMap((d) => (isObservable(d) ? d : of(d))));
|
|
463
|
-
|
|
771
|
+
makeThenable($tx, true);
|
|
772
|
+
Object.assign($tx, {
|
|
773
|
+
chainId,
|
|
774
|
+
});
|
|
775
|
+
return $tx;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Batch multiple transactions together into a single transaction.
|
|
779
|
+
* It's not exposed, because it is somewhat limited and requires knowledge of internals.
|
|
780
|
+
* It only works when there's only a single transaction being done in the method.
|
|
781
|
+
* It only works for methods that wrap the transaction in `wrapTransaction`.
|
|
782
|
+
* It only works when the transactions are executed on the same contract on the same chain,
|
|
783
|
+
* and that contract supports multicall
|
|
784
|
+
* @internal
|
|
785
|
+
*/
|
|
786
|
+
_experimental_batch(title, transactions) {
|
|
787
|
+
const chainIds = [...new Set(transactions.map((tx) => tx.chainId))];
|
|
788
|
+
if (chainIds.length !== 1) {
|
|
789
|
+
throw new Error(`Cannot batch transactions on different chains: ${chainIds.join(', ')}`);
|
|
790
|
+
}
|
|
791
|
+
for (const tx of transactions) {
|
|
792
|
+
this.#isBatching.add(tx);
|
|
793
|
+
}
|
|
794
|
+
return this._transact((ctx) => combineLatest(transactions.map((tx) => tx.pipe(first()))).pipe(switchMap(async function* (batches_) {
|
|
795
|
+
const batches = batches_;
|
|
796
|
+
if (!batches.every((b) => b.data && b.contract)) {
|
|
797
|
+
throw new Error('Not all transactions can be batched');
|
|
798
|
+
}
|
|
799
|
+
const value = batches.reduce((acc, b) => acc + (b.value ?? 0n), 0n);
|
|
800
|
+
const data = batches.map((b) => b.data).flat();
|
|
801
|
+
const messages = batches.reduce((acc, b) => {
|
|
802
|
+
if (b.messages) {
|
|
803
|
+
Object.entries(b.messages).forEach(([cid, types]) => {
|
|
804
|
+
const chainId = Number(cid);
|
|
805
|
+
if (!acc[chainId])
|
|
806
|
+
acc[chainId] = [];
|
|
807
|
+
acc[chainId].push(...types);
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
return acc;
|
|
811
|
+
}, {});
|
|
812
|
+
const contracts = [...new Set(batches.map((b) => b.contract))];
|
|
813
|
+
if (contracts.length !== 1) {
|
|
814
|
+
throw new Error(`Cannot batch transactions to different contracts: ${contracts.join(', ')}`);
|
|
815
|
+
}
|
|
816
|
+
yield* wrapTransaction(title, ctx, { data, value, contract: contracts[0], messages });
|
|
817
|
+
})), chainIds[0]);
|
|
818
|
+
}
|
|
819
|
+
/** @internal */
|
|
820
|
+
_protocolAddresses(chainId) {
|
|
821
|
+
return this._query(null, () => this._deployments().pipe(map((data) => {
|
|
822
|
+
if (!this.chains.includes(chainId)) {
|
|
823
|
+
throw new Error(`Chain ID "${chainId}" not supported`);
|
|
824
|
+
}
|
|
825
|
+
const deployment = data.deployments.items.find((d) => Number(d.chainId) === chainId);
|
|
826
|
+
if (!deployment) {
|
|
827
|
+
throw new Error(`No protocol contracts found for chain ID "${chainId}"`);
|
|
828
|
+
}
|
|
829
|
+
return deployment;
|
|
830
|
+
})));
|
|
831
|
+
}
|
|
832
|
+
/** @internal */
|
|
833
|
+
_getQuote(valuationAddress, baseAmount, baseAssetId, quoteAssetId, chainId) {
|
|
834
|
+
return this._query(['getQuote', baseAmount, baseAssetId.toString(), quoteAssetId.toString()], () => timer(0, 60_000).pipe(switchMap(() => this._protocolAddresses(chainId)), switchMap(({ hubRegistry }) => defer(async () => {
|
|
835
|
+
const [quote, quoteDecimals] = await Promise.all([
|
|
836
|
+
this.getClient(chainId).readContract({
|
|
837
|
+
address: valuationAddress,
|
|
838
|
+
abi: ABI.Valuation,
|
|
839
|
+
functionName: 'getQuote',
|
|
840
|
+
args: [baseAmount.toBigInt(), baseAssetId.raw, quoteAssetId.raw],
|
|
841
|
+
}),
|
|
842
|
+
this.getClient(chainId).readContract({
|
|
843
|
+
address: hubRegistry,
|
|
844
|
+
// Use inline ABI because of function overload
|
|
845
|
+
abi: parseAbi(['function decimals(uint256) view returns (uint8)']),
|
|
846
|
+
functionName: 'decimals',
|
|
847
|
+
args: [quoteAssetId.raw],
|
|
848
|
+
}),
|
|
849
|
+
]);
|
|
850
|
+
return new Balance(quote, quoteDecimals);
|
|
851
|
+
}))));
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Estimates the gas cost needed to bridge the message from one chain to another,
|
|
855
|
+
* that results from a transaction
|
|
856
|
+
* @internal
|
|
857
|
+
*/
|
|
858
|
+
_estimate(fromChain, to, messageType) {
|
|
859
|
+
return this._query(['estimate', fromChain, to, messageType], () => this._protocolAddresses(fromChain).pipe(switchMap(({ multiAdapter, gasService }) => {
|
|
860
|
+
const types = Array.isArray(messageType) ? messageType : [messageType];
|
|
861
|
+
return combineLatest([
|
|
862
|
+
'chainId' in to ? this.id(to.chainId) : of(to.centId),
|
|
863
|
+
...types.map((typeAndMaybeSubtype) => {
|
|
864
|
+
const type = typeof typeAndMaybeSubtype === 'number' ? typeAndMaybeSubtype : typeAndMaybeSubtype.type;
|
|
865
|
+
const subtype = typeof typeAndMaybeSubtype === 'number' ? undefined : typeAndMaybeSubtype.subtype;
|
|
866
|
+
const data = emptyMessage(type, subtype);
|
|
867
|
+
return this.getClient(fromChain).readContract({
|
|
868
|
+
address: gasService,
|
|
869
|
+
abi: ABI.GasService,
|
|
870
|
+
functionName: 'messageGasLimit',
|
|
871
|
+
args: [0, data],
|
|
872
|
+
});
|
|
873
|
+
}),
|
|
874
|
+
]).pipe(switchMap(async ([toCentId, ...gasLimits]) => {
|
|
875
|
+
const estimate = await this.getClient(fromChain).readContract({
|
|
876
|
+
address: multiAdapter,
|
|
877
|
+
abi: ABI.MultiAdapter,
|
|
878
|
+
functionName: 'estimate',
|
|
879
|
+
args: [toCentId, '0x0', gasLimits.reduce((acc, val) => acc + val, 0n)],
|
|
880
|
+
});
|
|
881
|
+
return (estimate * 3n) / 2n; // Add 50% buffer to the estimate
|
|
882
|
+
}));
|
|
883
|
+
})));
|
|
884
|
+
}
|
|
885
|
+
/** @internal */
|
|
886
|
+
_maxBatchGasLimit(chainId) {
|
|
887
|
+
return this._query(['maxBatchGasLimit', chainId], () => this._protocolAddresses(chainId).pipe(switchMap(async ({ gasService }) => {
|
|
888
|
+
try {
|
|
889
|
+
// `batchGasLimit` was renamed to `maxBatchGasLimit`, support both for backwards compatibility,
|
|
890
|
+
// until all chains are updated
|
|
891
|
+
return await this.getClient(chainId).readContract({
|
|
892
|
+
address: gasService,
|
|
893
|
+
abi: ABI.GasService,
|
|
894
|
+
functionName: 'maxBatchGasLimit',
|
|
895
|
+
args: [0],
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
catch {
|
|
899
|
+
return await this.getClient(chainId).readContract({
|
|
900
|
+
address: gasService,
|
|
901
|
+
abi: ABI.GasService,
|
|
902
|
+
functionName: 'batchGasLimit',
|
|
903
|
+
args: [0],
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
})));
|
|
907
|
+
}
|
|
908
|
+
/** @internal */
|
|
909
|
+
_idToChain(centrifugeId) {
|
|
910
|
+
return this._query(null, () => this._deployments().pipe(map((data) => {
|
|
911
|
+
const item = data.blockchains.items.find((b) => Number(b.centrifugeId) === centrifugeId);
|
|
912
|
+
if (!item)
|
|
913
|
+
throw new Error(`Chain with Centrifuge ID "${centrifugeId}" not found`);
|
|
914
|
+
return Number(item.id);
|
|
915
|
+
})));
|
|
916
|
+
}
|
|
917
|
+
/** @internal */
|
|
918
|
+
_deployments() {
|
|
919
|
+
return this._query(['deployments'], () => this._getIndexerObservable(`{
|
|
920
|
+
blockchains {
|
|
921
|
+
items {
|
|
922
|
+
centrifugeId
|
|
923
|
+
id
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
deployments {
|
|
927
|
+
items {
|
|
928
|
+
accounting
|
|
929
|
+
asyncRequestManager
|
|
930
|
+
asyncVaultFactory
|
|
931
|
+
axelarAdapter
|
|
932
|
+
balanceSheet
|
|
933
|
+
centrifugeId
|
|
934
|
+
chainId
|
|
935
|
+
freezeOnlyHook
|
|
936
|
+
fullRestrictionsHook
|
|
937
|
+
gasService
|
|
938
|
+
gateway
|
|
939
|
+
globalEscrow
|
|
940
|
+
guardian
|
|
941
|
+
holdings
|
|
942
|
+
hub
|
|
943
|
+
hubRegistry
|
|
944
|
+
identityValuation
|
|
945
|
+
messageDispatcher
|
|
946
|
+
messageProcessor
|
|
947
|
+
multiAdapter
|
|
948
|
+
poolEscrowFactory
|
|
949
|
+
redemptionRestrictionsHook
|
|
950
|
+
root
|
|
951
|
+
routerEscrow
|
|
952
|
+
shareClassManager
|
|
953
|
+
spoke
|
|
954
|
+
syncDepositVaultFactory
|
|
955
|
+
syncManager
|
|
956
|
+
wormholeAdapter
|
|
957
|
+
vaultRouter
|
|
958
|
+
tokenFactory
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
}`));
|
|
464
962
|
}
|
|
465
963
|
}
|
|
466
964
|
//# sourceMappingURL=Centrifuge.js.map
|