@opendatalabs/vana-sdk 0.1.0-alpha.eebb656 → 0.1.0-alpha.ef15099
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 +67 -351
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +33 -1
- package/dist/browser.js.map +1 -1
- package/dist/chains/definitions.cjs +9 -6
- package/dist/chains/definitions.cjs.map +1 -1
- package/dist/chains/definitions.d.ts +2 -0
- package/dist/chains/definitions.js +9 -6
- package/dist/chains/definitions.js.map +1 -1
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.d.ts +30 -1
- package/dist/chains/index.js.map +1 -1
- package/dist/client/enhancedResponse.cjs +164 -0
- package/dist/client/enhancedResponse.cjs.map +1 -0
- package/dist/client/enhancedResponse.d.ts +120 -0
- package/dist/client/enhancedResponse.js +138 -0
- package/dist/client/enhancedResponse.js.map +1 -0
- package/dist/config/chains.cjs.map +1 -1
- package/dist/config/chains.d.ts +99 -0
- package/dist/config/chains.js.map +1 -1
- package/dist/config/contracts.config.cjs +400 -0
- package/dist/config/contracts.config.cjs.map +1 -0
- package/dist/config/contracts.config.d.ts +84 -0
- package/dist/config/contracts.config.js +375 -0
- package/dist/config/contracts.config.js.map +1 -0
- package/dist/config/default-services.cjs +60 -0
- package/dist/config/default-services.cjs.map +1 -0
- package/dist/config/default-services.d.ts +46 -0
- package/dist/config/default-services.js +33 -0
- package/dist/config/default-services.js.map +1 -0
- package/dist/config/default-services.test.d.ts +1 -0
- package/dist/contracts/contractController.cjs +1 -1
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +66 -10
- package/dist/contracts/contractController.js +1 -1
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
- package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
- package/dist/controllers/accessSettlement.cjs +289 -0
- package/dist/controllers/accessSettlement.cjs.map +1 -0
- package/dist/controllers/accessSettlement.d.ts +157 -0
- package/dist/controllers/accessSettlement.js +265 -0
- package/dist/controllers/accessSettlement.js.map +1 -0
- package/dist/controllers/accessSettlement.test.d.ts +1 -0
- package/dist/controllers/base.cjs +116 -0
- package/dist/controllers/base.cjs.map +1 -0
- package/dist/controllers/base.d.ts +94 -0
- package/dist/controllers/base.js +92 -0
- package/dist/controllers/base.js.map +1 -0
- package/dist/controllers/data.cjs +634 -352
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +348 -213
- package/dist/controllers/data.js +647 -355
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/operations.cjs +430 -0
- package/dist/controllers/operations.cjs.map +1 -0
- package/dist/controllers/operations.d.ts +229 -0
- package/dist/controllers/operations.js +406 -0
- package/dist/controllers/operations.js.map +1 -0
- package/dist/controllers/permissions.cjs +943 -443
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +201 -120
- package/dist/controllers/permissions.js +943 -443
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs +14 -10
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +30 -31
- package/dist/controllers/protocol.js +14 -10
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/runtimePermissions.cjs +272 -0
- package/dist/controllers/runtimePermissions.cjs.map +1 -0
- package/dist/controllers/runtimePermissions.d.ts +152 -0
- package/dist/controllers/runtimePermissions.js +251 -0
- package/dist/controllers/runtimePermissions.js.map +1 -0
- package/dist/controllers/runtimePermissions.test.d.ts +1 -0
- package/dist/controllers/schemas.cjs +113 -43
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +90 -43
- package/dist/controllers/schemas.js +113 -43
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server.cjs +276 -60
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +159 -54
- package/dist/controllers/server.js +276 -60
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/__tests__/health.test.d.ts +1 -0
- package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
- package/dist/core/apiClient.cjs +53 -3
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +132 -7
- package/dist/core/apiClient.js +53 -3
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/generics.cjs +30 -3
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +95 -6
- package/dist/core/generics.js +30 -3
- package/dist/core/generics.js.map +1 -1
- package/dist/core/health.cjs +289 -0
- package/dist/core/health.cjs.map +1 -0
- package/dist/core/health.d.ts +143 -0
- package/dist/core/health.js +265 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/inMemoryNonceManager.cjs +138 -0
- package/dist/core/inMemoryNonceManager.cjs.map +1 -0
- package/dist/core/inMemoryNonceManager.d.ts +69 -0
- package/dist/core/inMemoryNonceManager.js +114 -0
- package/dist/core/inMemoryNonceManager.js.map +1 -0
- package/dist/core/nonceManager.cjs +304 -0
- package/dist/core/nonceManager.cjs.map +1 -0
- package/dist/core/nonceManager.d.ts +116 -0
- package/dist/core/nonceManager.js +280 -0
- package/dist/core/nonceManager.js.map +1 -0
- package/dist/core/pollingManager.cjs +292 -0
- package/dist/core/pollingManager.cjs.map +1 -0
- package/dist/core/pollingManager.d.ts +120 -0
- package/dist/core/pollingManager.js +268 -0
- package/dist/core/pollingManager.js.map +1 -0
- package/dist/core.cjs +164 -36
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +69 -10
- package/dist/core.js +167 -37
- package/dist/core.js.map +1 -1
- package/dist/crypto/ecies/__tests__/constants.test.d.ts +1 -1
- package/dist/crypto/ecies/__tests__/interface.test.d.ts +1 -0
- package/dist/crypto/ecies/__tests__/serialization.test.d.ts +8 -0
- package/dist/crypto/ecies/__tests__/utils.test.d.ts +1 -0
- package/dist/crypto/ecies/base.cjs +59 -23
- package/dist/crypto/ecies/base.cjs.map +1 -1
- package/dist/crypto/ecies/base.js +59 -23
- package/dist/crypto/ecies/base.js.map +1 -1
- package/dist/crypto/ecies/constants.cjs +2 -10
- package/dist/crypto/ecies/constants.cjs.map +1 -1
- package/dist/crypto/ecies/constants.d.ts +0 -9
- package/dist/crypto/ecies/constants.js +1 -8
- package/dist/crypto/ecies/constants.js.map +1 -1
- package/dist/crypto/ecies/interface.cjs +19 -2
- package/dist/crypto/ecies/interface.cjs.map +1 -1
- package/dist/crypto/ecies/interface.js +19 -2
- package/dist/crypto/ecies/interface.js.map +1 -1
- package/dist/errors.cjs +45 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +104 -0
- package/dist/errors.js +43 -0
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/AccessSettlementImplementation.cjs +635 -0
- package/dist/generated/abi/AccessSettlementImplementation.cjs.map +1 -0
- package/dist/generated/abi/AccessSettlementImplementation.d.ts +468 -0
- package/dist/generated/abi/AccessSettlementImplementation.js +611 -0
- package/dist/generated/abi/AccessSettlementImplementation.js.map +1 -0
- package/dist/generated/abi/AttestationPolicyImplementation.cjs +614 -0
- package/dist/generated/abi/AttestationPolicyImplementation.cjs.map +1 -0
- package/dist/generated/abi/AttestationPolicyImplementation.d.ts +449 -0
- package/dist/generated/abi/AttestationPolicyImplementation.js +590 -0
- package/dist/generated/abi/AttestationPolicyImplementation.js.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -1
- package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -1
- package/dist/generated/abi/{DLPTreasuryImplementation.cjs → ComputeEngineTreasuryImplementation.cjs} +16 -92
- package/dist/generated/abi/ComputeEngineTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/{DLPTreasuryImplementation.d.ts → ComputeEngineTreasuryImplementation.d.ts} +9 -67
- package/dist/generated/abi/{DLPTreasuryImplementation.js → ComputeEngineTreasuryImplementation.js} +12 -88
- package/dist/generated/abi/ComputeEngineTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DATFactoryImplementation.js.map +1 -1
- package/dist/generated/abi/DATImplementation.cjs.map +1 -1
- package/dist/generated/abi/DATImplementation.js.map +1 -1
- package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -1
- package/dist/generated/abi/DATPausableImplementation.js.map +1 -1
- package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -1
- package/dist/generated/abi/DATVotesImplementation.js.map +1 -1
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +42 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +32 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js +42 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -1
- package/dist/generated/abi/DLPRegistryImplementation.cjs +5 -5
- package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +4 -4
- package/dist/generated/abi/DLPRegistryImplementation.js +5 -5
- package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -1
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +166 -2
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +129 -2
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +166 -2
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -1
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -1
- package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -1
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +282 -100
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +218 -79
- package/dist/generated/abi/DataLiquidityPoolImplementation.js +281 -99
- package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +167 -19
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +127 -14
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js +167 -19
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +0 -19
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +0 -14
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +0 -19
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs +0 -19
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +0 -14
- package/dist/generated/abi/DataPortabilityServersImplementation.js +0 -19
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/DataRegistryImplementation.cjs +0 -13
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataRegistryImplementation.d.ts +0 -10
- package/dist/generated/abi/DataRegistryImplementation.js +0 -13
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/DatasetRegistryImplementation.cjs +751 -0
- package/dist/generated/abi/DatasetRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DatasetRegistryImplementation.d.ts +557 -0
- package/dist/generated/abi/DatasetRegistryImplementation.js +727 -0
- package/dist/generated/abi/DatasetRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/ProtocolConfigImplementation.cjs +578 -0
- package/dist/generated/abi/ProtocolConfigImplementation.cjs.map +1 -0
- package/dist/generated/abi/ProtocolConfigImplementation.d.ts +423 -0
- package/dist/generated/abi/ProtocolConfigImplementation.js +554 -0
- package/dist/generated/abi/ProtocolConfigImplementation.js.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -1
- package/dist/generated/abi/QueryEngineImplementation.js.map +1 -1
- package/dist/generated/abi/SwapHelperImplementation.cjs +0 -43
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -1
- package/dist/generated/abi/SwapHelperImplementation.d.ts +0 -35
- package/dist/generated/abi/SwapHelperImplementation.js +0 -43
- package/dist/generated/abi/SwapHelperImplementation.js.map +1 -1
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -1
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -1
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -1
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -1
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -1
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -1
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -1
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -1
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -1
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -1
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -1
- package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -1
- package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.cjs +1251 -0
- package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.cjs.map +1 -0
- package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.d.ts +948 -0
- package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.js +1227 -0
- package/dist/generated/abi/UniswapV3NonfungiblePositionManagerImplementation.js.map +1 -0
- package/dist/generated/abi/UniswapV3QuoterV2Implementation.cjs +297 -0
- package/dist/generated/abi/UniswapV3QuoterV2Implementation.cjs.map +1 -0
- package/dist/generated/abi/UniswapV3QuoterV2Implementation.d.ts +206 -0
- package/dist/generated/abi/UniswapV3QuoterV2Implementation.js +273 -0
- package/dist/generated/abi/UniswapV3QuoterV2Implementation.js.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs +195 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaEpochImplementation.d.ts +151 -0
- package/dist/generated/abi/VanaEpochImplementation.js +195 -0
- package/dist/generated/abi/VanaEpochImplementation.js.map +1 -1
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +22 -65
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +17 -51
- package/dist/generated/abi/VanaPoolEntityImplementation.js +22 -65
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +113 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +85 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.js +113 -1
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -1
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -1
- package/dist/generated/abi/VanaRuntimePermissionsImplementation.cjs +759 -0
- package/dist/generated/abi/VanaRuntimePermissionsImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaRuntimePermissionsImplementation.d.ts +563 -0
- package/dist/generated/abi/VanaRuntimePermissionsImplementation.js +735 -0
- package/dist/generated/abi/VanaRuntimePermissionsImplementation.js.map +1 -0
- package/dist/generated/abi/VanaRuntimeServersImplementation.cjs +820 -0
- package/dist/generated/abi/VanaRuntimeServersImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaRuntimeServersImplementation.d.ts +609 -0
- package/dist/generated/abi/VanaRuntimeServersImplementation.js +796 -0
- package/dist/generated/abi/VanaRuntimeServersImplementation.js.map +1 -0
- package/dist/generated/abi/VanaTreasuryImplementation.cjs +536 -0
- package/dist/generated/abi/VanaTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaTreasuryImplementation.d.ts +393 -0
- package/dist/generated/abi/VanaTreasuryImplementation.js +512 -0
- package/dist/generated/abi/VanaTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/WVANAImplementation.cjs +339 -0
- package/dist/generated/abi/WVANAImplementation.cjs.map +1 -0
- package/dist/generated/abi/WVANAImplementation.d.ts +244 -0
- package/dist/generated/abi/WVANAImplementation.js +315 -0
- package/dist/generated/abi/WVANAImplementation.js.map +1 -0
- package/dist/generated/abi/index.cjs +79 -47
- package/dist/generated/abi/index.cjs.map +1 -1
- package/dist/generated/abi/index.d.ts +15783 -10449
- package/dist/generated/abi/index.js +65 -43
- package/dist/generated/abi/index.js.map +1 -1
- package/dist/{config → generated}/addresses.cjs +174 -75
- package/dist/generated/addresses.cjs.map +1 -0
- package/dist/{config → generated}/addresses.d.ts +174 -165
- package/dist/{config → generated}/addresses.js +174 -75
- package/dist/generated/addresses.js.map +1 -0
- package/dist/generated/event-types.cjs.map +1 -1
- package/dist/generated/event-types.d.ts +482 -399
- package/dist/generated/eventRegistry.cjs +2601 -724
- package/dist/generated/eventRegistry.cjs.map +1 -1
- package/dist/generated/eventRegistry.d.ts +2 -2
- package/dist/generated/eventRegistry.js +2601 -724
- package/dist/generated/eventRegistry.js.map +1 -1
- package/dist/generated/server/server-exports.cjs +22 -0
- package/dist/generated/server/server-exports.cjs.map +1 -1
- package/dist/generated/server/server-exports.d.ts +31 -11
- package/dist/generated/server/server-exports.js +17 -0
- package/dist/generated/server/server-exports.js.map +1 -1
- package/dist/generated/server/server.cjs.map +1 -1
- package/dist/generated/server/server.d.ts +771 -402
- package/dist/generated/subgraph.cjs +797 -32
- package/dist/generated/subgraph.cjs.map +1 -1
- package/dist/generated/subgraph.d.ts +135 -0
- package/dist/generated/subgraph.js +792 -32
- package/dist/generated/subgraph.js.map +1 -1
- package/dist/index.browser.d.ts +6 -1
- package/dist/index.browser.js +26 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +47 -4
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +60 -14
- package/dist/index.node.js +42 -3
- package/dist/index.node.js.map +1 -1
- package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
- package/dist/lib/redisAtomicStore.cjs +201 -0
- package/dist/lib/redisAtomicStore.cjs.map +1 -0
- package/dist/lib/redisAtomicStore.d.ts +120 -0
- package/dist/lib/redisAtomicStore.js +177 -0
- package/dist/lib/redisAtomicStore.js.map +1 -0
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +39 -1
- package/dist/node.js.map +1 -1
- package/dist/platform/browser.cjs +160 -2
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +232 -12
- package/dist/platform/browser.js +160 -2
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/interface.cjs.map +1 -1
- package/dist/platform/interface.d.ts +283 -90
- package/dist/platform/node.cjs +163 -2
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +69 -6
- package/dist/platform/node.js +163 -2
- package/dist/platform/node.js.map +1 -1
- package/dist/server/relayerHandler.cjs +452 -0
- package/dist/server/relayerHandler.cjs.map +1 -0
- package/dist/server/relayerHandler.d.ts +69 -0
- package/dist/server/relayerHandler.js +428 -0
- package/dist/server/relayerHandler.js.map +1 -0
- package/dist/storage/index.cjs +3 -0
- package/dist/storage/index.cjs.map +1 -1
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/manager.cjs +108 -25
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +119 -25
- package/dist/storage/manager.js +108 -25
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +86 -15
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +109 -20
- package/dist/storage/providers/callback-storage.js +86 -15
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/dropbox.cjs +237 -0
- package/dist/storage/providers/dropbox.cjs.map +1 -0
- package/dist/storage/providers/dropbox.d.ts +39 -0
- package/dist/storage/providers/dropbox.js +215 -0
- package/dist/storage/providers/dropbox.js.map +1 -0
- package/dist/storage/providers/dropbox.test.d.ts +1 -0
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +12 -14
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/tests/data-upload-owner-validation.test.d.ts +1 -0
- package/dist/tests/factories/mockFactory.d.ts +6 -6
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +2 -2
- package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
- package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
- package/dist/tests/read-only-mode.test.d.ts +1 -0
- package/dist/tests/relayer-integration.test.d.ts +1 -0
- package/dist/tests/relayer-unified.test.d.ts +1 -0
- package/dist/tests/server-relayer-handler.test.d.ts +1 -0
- package/dist/types/accessSettlement.cjs +17 -0
- package/dist/types/accessSettlement.cjs.map +1 -0
- package/dist/types/accessSettlement.d.ts +66 -0
- package/dist/types/accessSettlement.js +1 -0
- package/dist/types/accessSettlement.js.map +1 -0
- package/dist/types/atomicStore.cjs +31 -0
- package/dist/types/atomicStore.cjs.map +1 -0
- package/dist/types/atomicStore.d.ts +236 -0
- package/dist/types/atomicStore.js +7 -0
- package/dist/types/atomicStore.js.map +1 -0
- package/dist/types/blockchain.cjs.map +1 -1
- package/dist/types/blockchain.d.ts +39 -11
- package/dist/types/chains.cjs.map +1 -1
- package/dist/types/chains.d.ts +74 -7
- package/dist/types/chains.js.map +1 -1
- package/dist/types/config.cjs +10 -0
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +217 -220
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +71 -7
- package/dist/types/controller-context.cjs.map +1 -1
- package/dist/types/controller-context.d.ts +12 -6
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +82 -10
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +81 -10
- package/dist/types/index.cjs +4 -0
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +36 -6
- package/dist/types/index.js +9 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/operationStore.cjs +17 -0
- package/dist/types/operationStore.cjs.map +1 -0
- package/dist/types/operationStore.d.ts +171 -0
- package/dist/types/operationStore.js +1 -0
- package/dist/types/operationStore.js.map +1 -0
- package/dist/types/operations.cjs +3 -15
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +131 -39
- package/dist/types/operations.js +2 -13
- package/dist/types/operations.js.map +1 -1
- package/dist/types/options.cjs +17 -0
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.d.ts +308 -0
- package/dist/types/options.js +1 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/permissions.cjs.map +1 -1
- package/dist/types/permissions.d.ts +19 -20
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +150 -14
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +307 -35
- package/dist/types/runtimePermissions.cjs +17 -0
- package/dist/types/runtimePermissions.cjs.map +1 -0
- package/dist/types/runtimePermissions.d.ts +122 -0
- package/dist/types/runtimePermissions.js +1 -0
- package/dist/types/runtimePermissions.js.map +1 -0
- package/dist/types/storage.cjs.map +1 -1
- package/dist/types/storage.d.ts +9 -21
- package/dist/types/storage.js.map +1 -1
- package/dist/types/utils.cjs.map +1 -1
- package/dist/types/utils.d.ts +0 -45
- package/dist/utils/__tests__/chainQuery.test.d.ts +1 -0
- package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
- package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
- package/dist/utils/blockchain/registry.cjs +3 -3
- package/dist/utils/blockchain/registry.cjs.map +1 -1
- package/dist/utils/blockchain/registry.d.ts +1 -1
- package/dist/utils/blockchain/registry.js +3 -3
- package/dist/utils/blockchain/registry.js.map +1 -1
- package/dist/utils/chainQuery.cjs +107 -0
- package/dist/utils/chainQuery.cjs.map +1 -0
- package/dist/utils/chainQuery.d.ts +31 -0
- package/dist/utils/chainQuery.js +82 -0
- package/dist/utils/chainQuery.js.map +1 -0
- package/dist/utils/grantFiles.cjs +4 -1
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +10 -20
- package/dist/utils/grantFiles.js +4 -1
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +95 -16
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +93 -12
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/ipfs.cjs +2 -4
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.d.ts +1 -1
- package/dist/utils/ipfs.js +2 -4
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +32 -7
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/multicall.cjs +1 -1
- package/dist/utils/multicall.cjs.map +1 -1
- package/dist/utils/multicall.js +1 -1
- package/dist/utils/multicall.js.map +1 -1
- package/dist/utils/runtimeGrantFiles.cjs +84 -0
- package/dist/utils/runtimeGrantFiles.cjs.map +1 -0
- package/dist/utils/runtimeGrantFiles.d.ts +66 -0
- package/dist/utils/runtimeGrantFiles.js +58 -0
- package/dist/utils/runtimeGrantFiles.js.map +1 -0
- package/dist/utils/signatureCache.cjs +8 -2
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +49 -8
- package/dist/utils/signatureCache.js +8 -2
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/subgraphConsistency.cjs +184 -0
- package/dist/utils/subgraphConsistency.cjs.map +1 -0
- package/dist/utils/subgraphConsistency.d.ts +65 -0
- package/dist/utils/subgraphConsistency.js +155 -0
- package/dist/utils/subgraphConsistency.js.map +1 -0
- package/dist/utils/subgraphMetaCache.cjs +101 -0
- package/dist/utils/subgraphMetaCache.cjs.map +1 -0
- package/dist/utils/subgraphMetaCache.d.ts +56 -0
- package/dist/utils/subgraphMetaCache.js +76 -0
- package/dist/utils/subgraphMetaCache.js.map +1 -0
- package/dist/utils/subgraphPagination.cjs +104 -0
- package/dist/utils/subgraphPagination.cjs.map +1 -0
- package/dist/utils/subgraphPagination.d.ts +78 -0
- package/dist/utils/subgraphPagination.js +78 -0
- package/dist/utils/subgraphPagination.js.map +1 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -1
- package/dist/utils/transactionHelpers.d.ts +12 -12
- package/dist/utils/transactionHelpers.js.map +1 -1
- package/dist/utils/typedDataConverter.cjs.map +1 -1
- package/dist/utils/typedDataConverter.d.ts +39 -3
- package/dist/utils/typedDataConverter.js.map +1 -1
- package/dist/utils/urlResolver.cjs +7 -0
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +22 -4
- package/dist/utils/urlResolver.js +7 -0
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs +63 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +94 -0
- package/dist/utils/wallet.js +37 -0
- package/dist/utils/wallet.js.map +1 -0
- package/package.json +7 -2
- package/dist/config/addresses.cjs.map +0 -1
- package/dist/config/addresses.js.map +0 -1
- package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +0 -1
- package/dist/generated/abi/DLPTreasuryImplementation.js.map +0 -1
- package/dist/server/handler.cjs +0 -101
- package/dist/server/handler.cjs.map +0 -1
- package/dist/server/handler.d.ts +0 -87
- package/dist/server/handler.js +0 -77
- package/dist/server/handler.js.map +0 -1
- /package/dist/{tests/server-handler.test.d.ts → client/__tests__/enhancedResponse.test.d.ts} +0 -0
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides type-safe contract interaction utilities for the Vana protocol.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This module enables strongly-typed smart contract interactions with automatic
|
|
6
|
+
* ABI loading, address resolution, and instance caching. It follows viem's patterns
|
|
7
|
+
* for contract typing while providing Vana-specific conveniences.
|
|
8
|
+
*
|
|
9
|
+
* @category Contracts
|
|
10
|
+
* @module contractController
|
|
11
|
+
*/
|
|
1
12
|
import type { Abi } from "abitype";
|
|
2
13
|
import { type GetContractReturnType, type PublicClient, type WalletClient } from "viem";
|
|
3
14
|
import { type ContractAbis, type VanaContract } from "../generated/abi";
|
|
@@ -8,12 +19,19 @@ export declare const contractCacheForTesting: Map<string, {
|
|
|
8
19
|
abi: Abi;
|
|
9
20
|
}>;
|
|
10
21
|
/**
|
|
11
|
-
* Gets a typed contract instance for the specified contract name
|
|
12
|
-
*
|
|
22
|
+
* Gets a typed contract instance for the specified contract name.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Provides complete type safety following viem's patterns with automatic
|
|
26
|
+
* ABI loading and address resolution. Contract instances are cached per
|
|
27
|
+
* chain for performance. Use const assertion for full type inference.
|
|
13
28
|
*
|
|
14
|
-
* @param contract - Name of the contract to instantiate
|
|
15
|
-
*
|
|
29
|
+
* @param contract - Name of the contract to instantiate.
|
|
30
|
+
* Use const assertion for full typing: `"DataRegistry" as const`
|
|
31
|
+
* @param client - Optional viem client instance.
|
|
32
|
+
* Defaults to auto-configured client. Obtain via `createClient()` or viem.
|
|
16
33
|
* @returns A fully typed contract instance with methods corresponding to the contract's ABI
|
|
34
|
+
*
|
|
17
35
|
* @example
|
|
18
36
|
* ```typescript
|
|
19
37
|
* // Full type inference with const assertion
|
|
@@ -22,27 +40,65 @@ export declare const contractCacheForTesting: Map<string, {
|
|
|
22
40
|
* // Now dataRegistry has full type inference for all methods
|
|
23
41
|
* const result = await dataRegistry.read.getFileCount(); // Type: bigint
|
|
24
42
|
* await dataRegistry.write.addFile([url, proof]); // Typed parameters
|
|
43
|
+
*
|
|
44
|
+
* // Auto-configured client
|
|
45
|
+
* const permissions = getContractController("DataPortabilityPermissions" as const);
|
|
46
|
+
* const granted = await permissions.read.hasPermission([grantor, grantee]);
|
|
25
47
|
* ```
|
|
48
|
+
*
|
|
49
|
+
* @category Contracts
|
|
26
50
|
*/
|
|
27
51
|
export declare function getContractController<T extends VanaContract>(contract: T, client?: PublicClient | WalletClient | ReturnType<typeof createClient>): GetContractReturnType<ContractAbis[T]>;
|
|
28
52
|
/**
|
|
29
|
-
* Gets contract information
|
|
30
|
-
* Useful for cases where you need contract details but don't want to create a client connection.
|
|
53
|
+
* Gets contract information without creating a contract instance.
|
|
31
54
|
*
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Returns contract address and ABI for manual contract interaction or
|
|
57
|
+
* custom client configuration. Useful when you need contract details
|
|
58
|
+
* but don't want to create a client connection.
|
|
59
|
+
*
|
|
60
|
+
* @param contract - Name of the contract.
|
|
61
|
+
* Use const assertion for typed ABI.
|
|
62
|
+
* @param chainId - Chain ID to get contract info for.
|
|
63
|
+
* Defaults to Vana mainnet (1480).
|
|
34
64
|
* @returns Contract information with typed ABI
|
|
65
|
+
*
|
|
35
66
|
* @example
|
|
36
67
|
* ```typescript
|
|
37
68
|
* const info = getContractInfo("DataRegistry" as const, 14800);
|
|
38
69
|
* console.log(info.address); // Typed as Address
|
|
39
70
|
* console.log(info.abi); // Fully typed ABI
|
|
71
|
+
*
|
|
72
|
+
* // Use with custom viem client
|
|
73
|
+
* const contract = getContract({
|
|
74
|
+
* ...info,
|
|
75
|
+
* client: customClient
|
|
76
|
+
* });
|
|
40
77
|
* ```
|
|
78
|
+
*
|
|
79
|
+
* @category Contracts
|
|
41
80
|
*/
|
|
42
81
|
export declare function getContractInfo<T extends VanaContract>(contract: T, chainId?: VanaChainId): ContractInfo<ContractAbis[T]>;
|
|
43
82
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
83
|
+
* Provides type-safe contract factory for creating multiple contract instances.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* Alternative API for applications that need to create multiple contracts
|
|
87
|
+
* with the same client. The factory pattern reduces boilerplate and ensures
|
|
88
|
+
* consistent client configuration across contracts.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const factory = new ContractFactory(client);
|
|
93
|
+
*
|
|
94
|
+
* const dataRegistry = factory.create("DataRegistry" as const);
|
|
95
|
+
* const permissions = factory.create("DataPortabilityPermissions" as const);
|
|
96
|
+
*
|
|
97
|
+
* // List available contracts
|
|
98
|
+
* const contracts = factory.getAvailableContracts();
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* @category Contracts
|
|
46
102
|
*/
|
|
47
103
|
export declare class ContractFactory {
|
|
48
104
|
private readonly client;
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getContract
|
|
3
3
|
} from "viem";
|
|
4
4
|
import { getAbi } from "../generated/abi";
|
|
5
|
-
import { getContractAddress, CONTRACT_ADDRESSES } from "../
|
|
5
|
+
import { getContractAddress, CONTRACT_ADDRESSES } from "../generated/addresses";
|
|
6
6
|
import { createClient } from "../core/client";
|
|
7
7
|
import { vanaMainnet } from "../config/chains";
|
|
8
8
|
const contractCache = /* @__PURE__ */ new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/contracts/contractController.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/contractController.ts"],"sourcesContent":["/**\n * Provides type-safe contract interaction utilities for the Vana protocol.\n *\n * @remarks\n * This module enables strongly-typed smart contract interactions with automatic\n * ABI loading, address resolution, and instance caching. It follows viem's patterns\n * for contract typing while providing Vana-specific conveniences.\n *\n * @category Contracts\n * @module contractController\n */\n\nimport type { Abi } from \"abitype\";\nimport {\n getContract,\n type GetContractReturnType,\n type PublicClient,\n type WalletClient,\n} from \"viem\";\nimport { type ContractAbis, getAbi, type VanaContract } from \"../generated/abi\";\nimport type { VanaChainId, ContractInfo } from \"../types/index\";\nimport { getContractAddress, CONTRACT_ADDRESSES } from \"../generated/addresses\";\nimport { createClient } from \"../core/client\";\nimport { vanaMainnet } from \"../config/chains\";\n\n// Cache for contract instances - keyed by contract name and chain ID\nconst contractCache = new Map<string, GetContractReturnType<Abi>>();\n\n// Export cache for testing\nexport const contractCacheForTesting = contractCache;\n\n/**\n * Creates a cache key for contract instances.\n *\n * @remarks\n * Generates unique keys for caching contract instances per chain to prevent\n * cross-chain contamination and improve performance.\n *\n * @param contract - The contract name to create a cache key for\n * @param chainId - The chain ID to include in the cache key\n * @returns A string cache key combining contract name and chain ID\n *\n * @internal\n */\nfunction createCacheKey(contract: VanaContract, chainId: number): string {\n return `${contract}:${chainId}`;\n}\n\n/**\n * Gets a typed contract instance for the specified contract name.\n *\n * @remarks\n * Provides complete type safety following viem's patterns with automatic\n * ABI loading and address resolution. Contract instances are cached per\n * chain for performance. Use const assertion for full type inference.\n *\n * @param contract - Name of the contract to instantiate.\n * Use const assertion for full typing: `\"DataRegistry\" as const`\n * @param client - Optional viem client instance.\n * Defaults to auto-configured client. Obtain via `createClient()` or viem.\n * @returns A fully typed contract instance with methods corresponding to the contract's ABI\n *\n * @example\n * ```typescript\n * // Full type inference with const assertion\n * const dataRegistry = getContractController(\"DataRegistry\" as const, client);\n *\n * // Now dataRegistry has full type inference for all methods\n * const result = await dataRegistry.read.getFileCount(); // Type: bigint\n * await dataRegistry.write.addFile([url, proof]); // Typed parameters\n *\n * // Auto-configured client\n * const permissions = getContractController(\"DataPortabilityPermissions\" as const);\n * const granted = await permissions.read.hasPermission([grantor, grantee]);\n * ```\n *\n * @category Contracts\n */\nexport function getContractController<T extends VanaContract>(\n contract: T,\n client:\n | PublicClient\n | WalletClient\n | ReturnType<typeof createClient> = createClient(),\n): GetContractReturnType<ContractAbis[T]> {\n const chainId = client.chain?.id ?? vanaMainnet.id;\n const cacheKey = createCacheKey(contract, chainId);\n\n let controller = contractCache.get(cacheKey);\n\n if (!controller) {\n controller = getContract({\n address: getContractAddress(chainId, contract),\n abi: getAbi(contract),\n client,\n }) as GetContractReturnType<ContractAbis[T]>;\n\n contractCache.set(cacheKey, controller);\n }\n\n return controller as GetContractReturnType<ContractAbis[T]>;\n}\n\n/**\n * Gets contract information without creating a contract instance.\n *\n * @remarks\n * Returns contract address and ABI for manual contract interaction or\n * custom client configuration. Useful when you need contract details\n * but don't want to create a client connection.\n *\n * @param contract - Name of the contract.\n * Use const assertion for typed ABI.\n * @param chainId - Chain ID to get contract info for.\n * Defaults to Vana mainnet (1480).\n * @returns Contract information with typed ABI\n *\n * @example\n * ```typescript\n * const info = getContractInfo(\"DataRegistry\" as const, 14800);\n * console.log(info.address); // Typed as Address\n * console.log(info.abi); // Fully typed ABI\n *\n * // Use with custom viem client\n * const contract = getContract({\n * ...info,\n * client: customClient\n * });\n * ```\n *\n * @category Contracts\n */\nexport function getContractInfo<T extends VanaContract>(\n contract: T,\n chainId: VanaChainId = vanaMainnet.id as VanaChainId,\n): ContractInfo<ContractAbis[T]> {\n return {\n address: getContractAddress(chainId, contract),\n abi: getAbi(contract),\n };\n}\n\n/**\n * Provides type-safe contract factory for creating multiple contract instances.\n *\n * @remarks\n * Alternative API for applications that need to create multiple contracts\n * with the same client. The factory pattern reduces boilerplate and ensures\n * consistent client configuration across contracts.\n *\n * @example\n * ```typescript\n * const factory = new ContractFactory(client);\n *\n * const dataRegistry = factory.create(\"DataRegistry\" as const);\n * const permissions = factory.create(\"DataPortabilityPermissions\" as const);\n *\n * // List available contracts\n * const contracts = factory.getAvailableContracts();\n * ```\n *\n * @category Contracts\n */\nexport class ContractFactory {\n private readonly client:\n | PublicClient\n | WalletClient\n | ReturnType<typeof createClient>;\n private readonly chainId: number;\n\n constructor(\n client: PublicClient | WalletClient | ReturnType<typeof createClient>,\n ) {\n this.client = client;\n try {\n this.chainId = client.chain?.id ?? vanaMainnet.id;\n } catch {\n this.chainId = vanaMainnet.id;\n }\n }\n\n /**\n * Creates a typed contract instance\n *\n * @param contract - Contract name (use const assertion for full typing)\n * @returns Fully typed contract instance\n */\n create<T extends VanaContract>(\n contract: T,\n ): GetContractReturnType<ContractAbis[T]> {\n return getContractController(contract, this.client);\n }\n\n /**\n * Gets contract information without creating an instance\n *\n * @param contract - Contract name\n * @returns Contract information with typed ABI\n */\n getInfo<T extends VanaContract>(contract: T): ContractInfo<ContractAbis[T]> {\n return getContractInfo(contract, this.chainId as VanaChainId);\n }\n\n /**\n * Lists all available contracts for the current chain\n *\n * @returns Array of contract names available on this chain\n */\n getAvailableContracts(): VanaContract[] {\n // Return all contract names that have addresses on this chain\n const chainAddresses = CONTRACT_ADDRESSES[this.chainId];\n if (!chainAddresses) return [];\n\n return Object.keys(chainAddresses) as VanaContract[];\n }\n}\n\n/**\n * Clears the contract cache. Useful for testing or when chain configurations change.\n *\n * @param contract - Optional specific contract to clear, or clear all if not provided\n * @param chainId - Optional specific chain to clear, or clear all if not provided\n */\nexport function clearContractCache(\n contract?: VanaContract,\n chainId?: number,\n): void {\n if (contract && chainId) {\n const cacheKey = createCacheKey(contract, chainId);\n contractCache.delete(cacheKey);\n } else if (contract) {\n // Clear all instances of this contract across all chains\n for (const key of contractCache.keys()) {\n if (key.startsWith(`${contract}:`)) {\n contractCache.delete(key);\n }\n }\n } else if (chainId) {\n // Clear all contracts for this chain\n for (const key of contractCache.keys()) {\n if (key.endsWith(`:${chainId}`)) {\n contractCache.delete(key);\n }\n }\n } else {\n // Clear entire cache\n contractCache.clear();\n }\n}\n\n// Function is already exported above, no need for redundant export\n\n// Type-only exports for enhanced type safety\nexport type { GetContractReturnType } from \"viem\";\n"],"mappings":"AAaA;AAAA,EACE;AAAA,OAIK;AACP,SAA4B,cAAiC;AAE7D,SAAS,oBAAoB,0BAA0B;AACvD,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAG5B,MAAM,gBAAgB,oBAAI,IAAwC;AAG3D,MAAM,0BAA0B;AAevC,SAAS,eAAe,UAAwB,SAAyB;AACvE,SAAO,GAAG,QAAQ,IAAI,OAAO;AAC/B;AAgCO,SAAS,sBACd,UACA,SAGsC,aAAa,GACX;AACxC,QAAM,UAAU,OAAO,OAAO,MAAM,YAAY;AAChD,QAAM,WAAW,eAAe,UAAU,OAAO;AAEjD,MAAI,aAAa,cAAc,IAAI,QAAQ;AAE3C,MAAI,CAAC,YAAY;AACf,iBAAa,YAAY;AAAA,MACvB,SAAS,mBAAmB,SAAS,QAAQ;AAAA,MAC7C,KAAK,OAAO,QAAQ;AAAA,MACpB;AAAA,IACF,CAAC;AAED,kBAAc,IAAI,UAAU,UAAU;AAAA,EACxC;AAEA,SAAO;AACT;AA+BO,SAAS,gBACd,UACA,UAAuB,YAAY,IACJ;AAC/B,SAAO;AAAA,IACL,SAAS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 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var accessSettlement_exports = {};
|
|
20
|
+
__export(accessSettlement_exports, {
|
|
21
|
+
AccessSettlementController: () => AccessSettlementController
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(accessSettlement_exports);
|
|
24
|
+
var import_viem = require("viem");
|
|
25
|
+
var import_base = require("./base");
|
|
26
|
+
var import_errors = require("../errors");
|
|
27
|
+
var import_addresses = require("../generated/addresses");
|
|
28
|
+
var import_abi = require("../generated/abi");
|
|
29
|
+
class AccessSettlementController extends import_base.BaseController {
|
|
30
|
+
/**
|
|
31
|
+
* Get invoice details for an operation
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Retrieves the payment invoice created by the runtime after an operation completes.
|
|
35
|
+
* The invoice contains the final price, payment token, and settlement status.
|
|
36
|
+
*
|
|
37
|
+
* @param operationId - Operation identifier (from runtime API)
|
|
38
|
+
* @returns Invoice details including price and settlement status
|
|
39
|
+
* @throws {BlockchainError} When invoice retrieval fails
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_abc123");
|
|
44
|
+
* console.log(`Price: ${invoice.price} wei`);
|
|
45
|
+
* console.log(`Issuer: ${invoice.issuer}`);
|
|
46
|
+
* console.log(`Settled: ${invoice.isSettled}`);
|
|
47
|
+
*
|
|
48
|
+
* // Convert price to VANA for display
|
|
49
|
+
* const priceInVana = Number(invoice.price) / 10**18;
|
|
50
|
+
* console.log(`Price: ${priceInVana} VANA`);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
async getOperationInvoice(operationId) {
|
|
54
|
+
try {
|
|
55
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
56
|
+
const contractAddress = (0, import_addresses.getContractAddress)(chainId, "AccessSettlement");
|
|
57
|
+
const abi = (0, import_abi.getAbi)("AccessSettlement");
|
|
58
|
+
const contract = (0, import_viem.getContract)({
|
|
59
|
+
address: contractAddress,
|
|
60
|
+
abi,
|
|
61
|
+
client: this.context.publicClient
|
|
62
|
+
});
|
|
63
|
+
const operationIdBytes = this.stringToBytes(operationId);
|
|
64
|
+
const result = await contract.read.getOperationInvoice([
|
|
65
|
+
operationIdBytes
|
|
66
|
+
]);
|
|
67
|
+
const invoice = result;
|
|
68
|
+
return {
|
|
69
|
+
issuer: invoice.issuer ?? invoice[0],
|
|
70
|
+
grantee: invoice.grantee ?? invoice[1],
|
|
71
|
+
price: invoice.price ?? invoice[2],
|
|
72
|
+
tokenAddress: invoice.tokenAddress ?? invoice[3],
|
|
73
|
+
isSettled: invoice.isSettled !== void 0 ? invoice.isSettled : invoice[4]
|
|
74
|
+
};
|
|
75
|
+
} catch (error) {
|
|
76
|
+
if (error instanceof Error) {
|
|
77
|
+
throw new import_errors.BlockchainError(
|
|
78
|
+
`Failed to get operation invoice: ${error.message}`,
|
|
79
|
+
error
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
throw new import_errors.BlockchainError(
|
|
83
|
+
"Failed to get operation invoice with unknown error"
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Check if an operation's payment has been settled
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* Quick check to determine if payment has been completed for an operation.
|
|
92
|
+
* Returns true if settlePaymentWithNative() or settlePaymentWithToken() was called.
|
|
93
|
+
*
|
|
94
|
+
* @param operationId - Operation identifier
|
|
95
|
+
* @returns Whether the payment has been settled
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const isSettled = await sdk.accessSettlement.isOperationSettled("op_123");
|
|
100
|
+
* if (isSettled) {
|
|
101
|
+
* console.log("Payment already settled, artifacts should be available");
|
|
102
|
+
* } else {
|
|
103
|
+
* console.log("Payment pending");
|
|
104
|
+
* }
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
async isOperationSettled(operationId) {
|
|
108
|
+
try {
|
|
109
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
110
|
+
const contractAddress = (0, import_addresses.getContractAddress)(chainId, "AccessSettlement");
|
|
111
|
+
const abi = (0, import_abi.getAbi)("AccessSettlement");
|
|
112
|
+
const contract = (0, import_viem.getContract)({
|
|
113
|
+
address: contractAddress,
|
|
114
|
+
abi,
|
|
115
|
+
client: this.context.publicClient
|
|
116
|
+
});
|
|
117
|
+
const operationIdBytes = this.stringToBytes(operationId);
|
|
118
|
+
return await contract.read.isOperationSettled([
|
|
119
|
+
operationIdBytes
|
|
120
|
+
]);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
if (error instanceof Error) {
|
|
123
|
+
throw new import_errors.BlockchainError(
|
|
124
|
+
`Failed to check settlement status: ${error.message}`,
|
|
125
|
+
error
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
throw new import_errors.BlockchainError(
|
|
129
|
+
"Failed to check settlement status with unknown error"
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Settle payment for an operation using native VANA
|
|
135
|
+
*
|
|
136
|
+
* @remarks
|
|
137
|
+
* Pays for a completed operation using native VANA tokens. The amount must match
|
|
138
|
+
* the invoice price exactly. Upon successful payment:
|
|
139
|
+
* - Funds are transferred to the issuer (dataset owner)
|
|
140
|
+
* - PaymentSettled event is emitted
|
|
141
|
+
* - Runtime unlocks operation artifacts for download
|
|
142
|
+
*
|
|
143
|
+
* IMPORTANT: You must send the exact value specified in the invoice.
|
|
144
|
+
* Check the invoice first using getOperationInvoice().
|
|
145
|
+
*
|
|
146
|
+
* @param operationId - Operation identifier to settle payment for
|
|
147
|
+
* @param value - Amount to pay in wei (must match invoice.price)
|
|
148
|
+
* @returns Transaction hash and operation ID
|
|
149
|
+
* @throws {BlockchainError} When payment settlement fails
|
|
150
|
+
* @throws {Error} When wallet is not configured (read-only mode)
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* // Get invoice to find the exact price
|
|
155
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_123");
|
|
156
|
+
*
|
|
157
|
+
* // Settle with native VANA
|
|
158
|
+
* const result = await sdk.accessSettlement.settlePaymentWithNative(
|
|
159
|
+
* "op_123",
|
|
160
|
+
* invoice.price // Must match exactly
|
|
161
|
+
* );
|
|
162
|
+
*
|
|
163
|
+
* // Wait for confirmation
|
|
164
|
+
* await sdk.waitForTransactionReceipt(result.hash);
|
|
165
|
+
* console.log("Payment confirmed, artifacts now available");
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
async settlePaymentWithNative(operationId, value) {
|
|
169
|
+
this.assertWallet();
|
|
170
|
+
try {
|
|
171
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
172
|
+
const contractAddress = (0, import_addresses.getContractAddress)(chainId, "AccessSettlement");
|
|
173
|
+
const abi = (0, import_abi.getAbi)("AccessSettlement");
|
|
174
|
+
const operationIdBytes = this.stringToBytes(operationId);
|
|
175
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
176
|
+
const hash = await this.context.walletClient.writeContract({
|
|
177
|
+
address: contractAddress,
|
|
178
|
+
abi,
|
|
179
|
+
functionName: "settlePaymentWithNative",
|
|
180
|
+
args: [operationIdBytes],
|
|
181
|
+
value,
|
|
182
|
+
account,
|
|
183
|
+
chain: this.context.walletClient?.chain ?? null
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
hash,
|
|
187
|
+
operationId
|
|
188
|
+
};
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof Error) {
|
|
191
|
+
throw new import_errors.BlockchainError(
|
|
192
|
+
`Failed to settle payment with native VANA: ${error.message}`,
|
|
193
|
+
error
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
throw new import_errors.BlockchainError(
|
|
197
|
+
"Failed to settle payment with native VANA with unknown error"
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Settle payment for an operation using an ERC20 token
|
|
203
|
+
*
|
|
204
|
+
* @remarks
|
|
205
|
+
* Pays for a completed operation using an ERC20 token. Before calling this method:
|
|
206
|
+
* 1. Check the invoice to get tokenAddress and price
|
|
207
|
+
* 2. Approve the AccessSettlement contract to spend the token amount
|
|
208
|
+
* 3. Call this method to complete the payment
|
|
209
|
+
*
|
|
210
|
+
* The token address and amount must match the invoice exactly.
|
|
211
|
+
*
|
|
212
|
+
* @param operationId - Operation identifier to settle payment for
|
|
213
|
+
* @param tokenAddress - ERC20 token contract address (must match invoice)
|
|
214
|
+
* @returns Transaction hash and operation ID
|
|
215
|
+
* @throws {BlockchainError} When payment settlement fails
|
|
216
|
+
* @throws {Error} When wallet is not configured (read-only mode)
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* // Get invoice
|
|
221
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_123");
|
|
222
|
+
*
|
|
223
|
+
* // Approve token spending (if not already approved)
|
|
224
|
+
* const tokenContract = sdk.protocol.createContract("ERC20" as const);
|
|
225
|
+
* await tokenContract.write.approve([
|
|
226
|
+
* accessSettlementAddress,
|
|
227
|
+
* invoice.price
|
|
228
|
+
* ]);
|
|
229
|
+
*
|
|
230
|
+
* // Settle with token
|
|
231
|
+
* const result = await sdk.accessSettlement.settlePaymentWithToken(
|
|
232
|
+
* "op_123",
|
|
233
|
+
* invoice.tokenAddress
|
|
234
|
+
* );
|
|
235
|
+
*
|
|
236
|
+
* await sdk.waitForTransactionReceipt(result.hash);
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
async settlePaymentWithToken(operationId, tokenAddress) {
|
|
240
|
+
this.assertWallet();
|
|
241
|
+
try {
|
|
242
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
243
|
+
const contractAddress = (0, import_addresses.getContractAddress)(chainId, "AccessSettlement");
|
|
244
|
+
const abi = (0, import_abi.getAbi)("AccessSettlement");
|
|
245
|
+
const operationIdBytes = this.stringToBytes(operationId);
|
|
246
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
247
|
+
const hash = await this.context.walletClient.writeContract({
|
|
248
|
+
address: contractAddress,
|
|
249
|
+
abi,
|
|
250
|
+
functionName: "settlePaymentWithToken",
|
|
251
|
+
args: [operationIdBytes, tokenAddress],
|
|
252
|
+
account,
|
|
253
|
+
chain: this.context.walletClient?.chain ?? null
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
hash,
|
|
257
|
+
operationId
|
|
258
|
+
};
|
|
259
|
+
} catch (error) {
|
|
260
|
+
if (error instanceof Error) {
|
|
261
|
+
throw new import_errors.BlockchainError(
|
|
262
|
+
`Failed to settle payment with token: ${error.message}`,
|
|
263
|
+
error
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
throw new import_errors.BlockchainError(
|
|
267
|
+
"Failed to settle payment with token with unknown error"
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Helper method to convert operation ID string to bytes
|
|
273
|
+
* @internal
|
|
274
|
+
*/
|
|
275
|
+
stringToBytes(str) {
|
|
276
|
+
if (str.startsWith("0x")) {
|
|
277
|
+
return str;
|
|
278
|
+
}
|
|
279
|
+
const encoder = new TextEncoder();
|
|
280
|
+
const bytes = encoder.encode(str);
|
|
281
|
+
const hexString = Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
282
|
+
return `0x${hexString}`;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
286
|
+
0 && (module.exports = {
|
|
287
|
+
AccessSettlementController
|
|
288
|
+
});
|
|
289
|
+
//# sourceMappingURL=accessSettlement.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/controllers/accessSettlement.ts"],"sourcesContent":["import { getContract } from \"viem\";\nimport { BaseController } from \"./base\";\nimport type {\n OperationInvoice,\n PaymentSettlementResult,\n} from \"../types/accessSettlement\";\nimport { BlockchainError } from \"../errors\";\nimport { getContractAddress } from \"../generated/addresses\";\nimport { getAbi } from \"../generated/abi\";\n\n/**\n * Controller for AccessSettlement contract\n *\n * @remarks\n * Manages payment settlement for runtime operations. Allows data consumers\n * to pay for completed operations using native VANA or ERC20 tokens.\n *\n * The AccessSettlement contract acts as an escrow system:\n * 1. Runtime completes an operation and logs the final price\n * 2. Consumer calls settlePaymentWithNative() or settlePaymentWithToken()\n * 3. Funds are transferred to the issuer (dataset owner)\n * 4. Runtime unlocks the operation artifacts for download\n *\n * @category Controllers\n * @example\n * ```typescript\n * // Consumer pays for a completed operation\n * const invoice = await sdk.accessSettlement.getOperationInvoice(\"op_123\");\n *\n * if (!invoice.isSettled) {\n * const result = await sdk.accessSettlement.settlePaymentWithNative(\n * \"op_123\",\n * invoice.price\n * );\n * console.log(`Payment settled: ${result.hash}`);\n * }\n * ```\n */\nexport class AccessSettlementController extends BaseController {\n /**\n * Get invoice details for an operation\n *\n * @remarks\n * Retrieves the payment invoice created by the runtime after an operation completes.\n * The invoice contains the final price, payment token, and settlement status.\n *\n * @param operationId - Operation identifier (from runtime API)\n * @returns Invoice details including price and settlement status\n * @throws {BlockchainError} When invoice retrieval fails\n *\n * @example\n * ```typescript\n * const invoice = await sdk.accessSettlement.getOperationInvoice(\"op_abc123\");\n * console.log(`Price: ${invoice.price} wei`);\n * console.log(`Issuer: ${invoice.issuer}`);\n * console.log(`Settled: ${invoice.isSettled}`);\n *\n * // Convert price to VANA for display\n * const priceInVana = Number(invoice.price) / 10**18;\n * console.log(`Price: ${priceInVana} VANA`);\n * ```\n */\n async getOperationInvoice(operationId: string): Promise<OperationInvoice> {\n try {\n const chainId = await this.context.publicClient.getChainId();\n const contractAddress = getContractAddress(chainId, \"AccessSettlement\");\n const abi = getAbi(\"AccessSettlement\");\n\n const contract = getContract({\n address: contractAddress,\n abi,\n client: this.context.publicClient,\n });\n\n // Convert operationId string to bytes\n const operationIdBytes = this.stringToBytes(operationId);\n\n const result = await contract.read.getOperationInvoice([\n operationIdBytes,\n ]);\n\n // Parse tuple result into OperationInvoice object\n // The contract returns a struct which viem converts to an array-like object\n const invoice = result as any;\n return {\n issuer: invoice.issuer ?? invoice[0],\n grantee: invoice.grantee ?? invoice[1],\n price: invoice.price ?? invoice[2],\n tokenAddress: invoice.tokenAddress ?? invoice[3],\n isSettled:\n invoice.isSettled !== undefined ? invoice.isSettled : invoice[4],\n } as OperationInvoice;\n } catch (error) {\n if (error instanceof Error) {\n throw new BlockchainError(\n `Failed to get operation invoice: ${error.message}`,\n error,\n );\n }\n throw new BlockchainError(\n \"Failed to get operation invoice with unknown error\",\n );\n }\n }\n\n /**\n * Check if an operation's payment has been settled\n *\n * @remarks\n * Quick check to determine if payment has been completed for an operation.\n * Returns true if settlePaymentWithNative() or settlePaymentWithToken() was called.\n *\n * @param operationId - Operation identifier\n * @returns Whether the payment has been settled\n *\n * @example\n * ```typescript\n * const isSettled = await sdk.accessSettlement.isOperationSettled(\"op_123\");\n * if (isSettled) {\n * console.log(\"Payment already settled, artifacts should be available\");\n * } else {\n * console.log(\"Payment pending\");\n * }\n * ```\n */\n async isOperationSettled(operationId: string): Promise<boolean> {\n try {\n const chainId = await this.context.publicClient.getChainId();\n const contractAddress = getContractAddress(chainId, \"AccessSettlement\");\n const abi = getAbi(\"AccessSettlement\");\n\n const contract = getContract({\n address: contractAddress,\n abi,\n client: this.context.publicClient,\n });\n\n const operationIdBytes = this.stringToBytes(operationId);\n\n return (await contract.read.isOperationSettled([\n operationIdBytes,\n ])) as boolean;\n } catch (error) {\n if (error instanceof Error) {\n throw new BlockchainError(\n `Failed to check settlement status: ${error.message}`,\n error,\n );\n }\n throw new BlockchainError(\n \"Failed to check settlement status with unknown error\",\n );\n }\n }\n\n /**\n * Settle payment for an operation using native VANA\n *\n * @remarks\n * Pays for a completed operation using native VANA tokens. The amount must match\n * the invoice price exactly. Upon successful payment:\n * - Funds are transferred to the issuer (dataset owner)\n * - PaymentSettled event is emitted\n * - Runtime unlocks operation artifacts for download\n *\n * IMPORTANT: You must send the exact value specified in the invoice.\n * Check the invoice first using getOperationInvoice().\n *\n * @param operationId - Operation identifier to settle payment for\n * @param value - Amount to pay in wei (must match invoice.price)\n * @returns Transaction hash and operation ID\n * @throws {BlockchainError} When payment settlement fails\n * @throws {Error} When wallet is not configured (read-only mode)\n *\n * @example\n * ```typescript\n * // Get invoice to find the exact price\n * const invoice = await sdk.accessSettlement.getOperationInvoice(\"op_123\");\n *\n * // Settle with native VANA\n * const result = await sdk.accessSettlement.settlePaymentWithNative(\n * \"op_123\",\n * invoice.price // Must match exactly\n * );\n *\n * // Wait for confirmation\n * await sdk.waitForTransactionReceipt(result.hash);\n * console.log(\"Payment confirmed, artifacts now available\");\n * ```\n */\n async settlePaymentWithNative(\n operationId: string,\n value: bigint,\n ): Promise<PaymentSettlementResult> {\n this.assertWallet();\n\n try {\n const chainId = await this.context.publicClient.getChainId();\n const contractAddress = getContractAddress(chainId, \"AccessSettlement\");\n const abi = getAbi(\"AccessSettlement\");\n\n const operationIdBytes = this.stringToBytes(operationId);\n\n const account =\n this.context.walletClient?.account ?? this.context.userAddress;\n\n const hash = await this.context.walletClient.writeContract({\n address: contractAddress,\n abi,\n functionName: \"settlePaymentWithNative\",\n args: [operationIdBytes],\n value,\n account,\n chain: this.context.walletClient?.chain ?? null,\n });\n\n return {\n hash,\n operationId,\n };\n } catch (error) {\n if (error instanceof Error) {\n throw new BlockchainError(\n `Failed to settle payment with native VANA: ${error.message}`,\n error,\n );\n }\n throw new BlockchainError(\n \"Failed to settle payment with native VANA with unknown error\",\n );\n }\n }\n\n /**\n * Settle payment for an operation using an ERC20 token\n *\n * @remarks\n * Pays for a completed operation using an ERC20 token. Before calling this method:\n * 1. Check the invoice to get tokenAddress and price\n * 2. Approve the AccessSettlement contract to spend the token amount\n * 3. Call this method to complete the payment\n *\n * The token address and amount must match the invoice exactly.\n *\n * @param operationId - Operation identifier to settle payment for\n * @param tokenAddress - ERC20 token contract address (must match invoice)\n * @returns Transaction hash and operation ID\n * @throws {BlockchainError} When payment settlement fails\n * @throws {Error} When wallet is not configured (read-only mode)\n *\n * @example\n * ```typescript\n * // Get invoice\n * const invoice = await sdk.accessSettlement.getOperationInvoice(\"op_123\");\n *\n * // Approve token spending (if not already approved)\n * const tokenContract = sdk.protocol.createContract(\"ERC20\" as const);\n * await tokenContract.write.approve([\n * accessSettlementAddress,\n * invoice.price\n * ]);\n *\n * // Settle with token\n * const result = await sdk.accessSettlement.settlePaymentWithToken(\n * \"op_123\",\n * invoice.tokenAddress\n * );\n *\n * await sdk.waitForTransactionReceipt(result.hash);\n * ```\n */\n async settlePaymentWithToken(\n operationId: string,\n tokenAddress: `0x${string}`,\n ): Promise<PaymentSettlementResult> {\n this.assertWallet();\n\n try {\n const chainId = await this.context.publicClient.getChainId();\n const contractAddress = getContractAddress(chainId, \"AccessSettlement\");\n const abi = getAbi(\"AccessSettlement\");\n\n const operationIdBytes = this.stringToBytes(operationId);\n\n const account =\n this.context.walletClient?.account ?? this.context.userAddress;\n\n const hash = await this.context.walletClient.writeContract({\n address: contractAddress,\n abi,\n functionName: \"settlePaymentWithToken\",\n args: [operationIdBytes, tokenAddress],\n account,\n chain: this.context.walletClient?.chain ?? null,\n });\n\n return {\n hash,\n operationId,\n };\n } catch (error) {\n if (error instanceof Error) {\n throw new BlockchainError(\n `Failed to settle payment with token: ${error.message}`,\n error,\n );\n }\n throw new BlockchainError(\n \"Failed to settle payment with token with unknown error\",\n );\n }\n }\n\n /**\n * Helper method to convert operation ID string to bytes\n * @internal\n */\n private stringToBytes(str: string): `0x${string}` {\n // If already hex string, return as-is\n if (str.startsWith(\"0x\")) {\n return str as `0x${string}`;\n }\n\n // Convert string to hex bytes\n const encoder = new TextEncoder();\n const bytes = encoder.encode(str);\n const hexString = Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n\n return `0x${hexString}` as `0x${string}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAC5B,kBAA+B;AAK/B,oBAAgC;AAChC,uBAAmC;AACnC,iBAAuB;AA8BhB,MAAM,mCAAmC,2BAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwB7D,MAAM,oBAAoB,aAAgD;AACxE,QAAI;AACF,YAAM,UAAU,MAAM,KAAK,QAAQ,aAAa,WAAW;AAC3D,YAAM,sBAAkB,qCAAmB,SAAS,kBAAkB;AACtE,YAAM,UAAM,mBAAO,kBAAkB;AAErC,YAAM,eAAW,yBAAY;AAAA,QAC3B,SAAS;AAAA,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ettlementResult } from "../types/accessSettlement";
|
|
3
|
+
/**
|
|
4
|
+
* Controller for AccessSettlement contract
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Manages payment settlement for runtime operations. Allows data consumers
|
|
8
|
+
* to pay for completed operations using native VANA or ERC20 tokens.
|
|
9
|
+
*
|
|
10
|
+
* The AccessSettlement contract acts as an escrow system:
|
|
11
|
+
* 1. Runtime completes an operation and logs the final price
|
|
12
|
+
* 2. Consumer calls settlePaymentWithNative() or settlePaymentWithToken()
|
|
13
|
+
* 3. Funds are transferred to the issuer (dataset owner)
|
|
14
|
+
* 4. Runtime unlocks the operation artifacts for download
|
|
15
|
+
*
|
|
16
|
+
* @category Controllers
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Consumer pays for a completed operation
|
|
20
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_123");
|
|
21
|
+
*
|
|
22
|
+
* if (!invoice.isSettled) {
|
|
23
|
+
* const result = await sdk.accessSettlement.settlePaymentWithNative(
|
|
24
|
+
* "op_123",
|
|
25
|
+
* invoice.price
|
|
26
|
+
* );
|
|
27
|
+
* console.log(`Payment settled: ${result.hash}`);
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class AccessSettlementController extends BaseController {
|
|
32
|
+
/**
|
|
33
|
+
* Get invoice details for an operation
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* Retrieves the payment invoice created by the runtime after an operation completes.
|
|
37
|
+
* The invoice contains the final price, payment token, and settlement status.
|
|
38
|
+
*
|
|
39
|
+
* @param operationId - Operation identifier (from runtime API)
|
|
40
|
+
* @returns Invoice details including price and settlement status
|
|
41
|
+
* @throws {BlockchainError} When invoice retrieval fails
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_abc123");
|
|
46
|
+
* console.log(`Price: ${invoice.price} wei`);
|
|
47
|
+
* console.log(`Issuer: ${invoice.issuer}`);
|
|
48
|
+
* console.log(`Settled: ${invoice.isSettled}`);
|
|
49
|
+
*
|
|
50
|
+
* // Convert price to VANA for display
|
|
51
|
+
* const priceInVana = Number(invoice.price) / 10**18;
|
|
52
|
+
* console.log(`Price: ${priceInVana} VANA`);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
getOperationInvoice(operationId: string): Promise<OperationInvoice>;
|
|
56
|
+
/**
|
|
57
|
+
* Check if an operation's payment has been settled
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* Quick check to determine if payment has been completed for an operation.
|
|
61
|
+
* Returns true if settlePaymentWithNative() or settlePaymentWithToken() was called.
|
|
62
|
+
*
|
|
63
|
+
* @param operationId - Operation identifier
|
|
64
|
+
* @returns Whether the payment has been settled
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const isSettled = await sdk.accessSettlement.isOperationSettled("op_123");
|
|
69
|
+
* if (isSettled) {
|
|
70
|
+
* console.log("Payment already settled, artifacts should be available");
|
|
71
|
+
* } else {
|
|
72
|
+
* console.log("Payment pending");
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
isOperationSettled(operationId: string): Promise<boolean>;
|
|
77
|
+
/**
|
|
78
|
+
* Settle payment for an operation using native VANA
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* Pays for a completed operation using native VANA tokens. The amount must match
|
|
82
|
+
* the invoice price exactly. Upon successful payment:
|
|
83
|
+
* - Funds are transferred to the issuer (dataset owner)
|
|
84
|
+
* - PaymentSettled event is emitted
|
|
85
|
+
* - Runtime unlocks operation artifacts for download
|
|
86
|
+
*
|
|
87
|
+
* IMPORTANT: You must send the exact value specified in the invoice.
|
|
88
|
+
* Check the invoice first using getOperationInvoice().
|
|
89
|
+
*
|
|
90
|
+
* @param operationId - Operation identifier to settle payment for
|
|
91
|
+
* @param value - Amount to pay in wei (must match invoice.price)
|
|
92
|
+
* @returns Transaction hash and operation ID
|
|
93
|
+
* @throws {BlockchainError} When payment settlement fails
|
|
94
|
+
* @throws {Error} When wallet is not configured (read-only mode)
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* // Get invoice to find the exact price
|
|
99
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_123");
|
|
100
|
+
*
|
|
101
|
+
* // Settle with native VANA
|
|
102
|
+
* const result = await sdk.accessSettlement.settlePaymentWithNative(
|
|
103
|
+
* "op_123",
|
|
104
|
+
* invoice.price // Must match exactly
|
|
105
|
+
* );
|
|
106
|
+
*
|
|
107
|
+
* // Wait for confirmation
|
|
108
|
+
* await sdk.waitForTransactionReceipt(result.hash);
|
|
109
|
+
* console.log("Payment confirmed, artifacts now available");
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
settlePaymentWithNative(operationId: string, value: bigint): Promise<PaymentSettlementResult>;
|
|
113
|
+
/**
|
|
114
|
+
* Settle payment for an operation using an ERC20 token
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* Pays for a completed operation using an ERC20 token. Before calling this method:
|
|
118
|
+
* 1. Check the invoice to get tokenAddress and price
|
|
119
|
+
* 2. Approve the AccessSettlement contract to spend the token amount
|
|
120
|
+
* 3. Call this method to complete the payment
|
|
121
|
+
*
|
|
122
|
+
* The token address and amount must match the invoice exactly.
|
|
123
|
+
*
|
|
124
|
+
* @param operationId - Operation identifier to settle payment for
|
|
125
|
+
* @param tokenAddress - ERC20 token contract address (must match invoice)
|
|
126
|
+
* @returns Transaction hash and operation ID
|
|
127
|
+
* @throws {BlockchainError} When payment settlement fails
|
|
128
|
+
* @throws {Error} When wallet is not configured (read-only mode)
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* // Get invoice
|
|
133
|
+
* const invoice = await sdk.accessSettlement.getOperationInvoice("op_123");
|
|
134
|
+
*
|
|
135
|
+
* // Approve token spending (if not already approved)
|
|
136
|
+
* const tokenContract = sdk.protocol.createContract("ERC20" as const);
|
|
137
|
+
* await tokenContract.write.approve([
|
|
138
|
+
* accessSettlementAddress,
|
|
139
|
+
* invoice.price
|
|
140
|
+
* ]);
|
|
141
|
+
*
|
|
142
|
+
* // Settle with token
|
|
143
|
+
* const result = await sdk.accessSettlement.settlePaymentWithToken(
|
|
144
|
+
* "op_123",
|
|
145
|
+
* invoice.tokenAddress
|
|
146
|
+
* );
|
|
147
|
+
*
|
|
148
|
+
* await sdk.waitForTransactionReceipt(result.hash);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
settlePaymentWithToken(operationId: string, tokenAddress: `0x${string}`): Promise<PaymentSettlementResult>;
|
|
152
|
+
/**
|
|
153
|
+
* Helper method to convert operation ID string to bytes
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
private stringToBytes;
|
|
157
|
+
}
|