@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
package/dist/index.node.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { NodePlatformAdapter } from "./platform/node";
|
|
2
2
|
import { VanaCore } from "./core";
|
|
3
3
|
class VanaNodeImpl extends VanaCore {
|
|
4
|
+
operationStore;
|
|
5
|
+
atomicStore;
|
|
4
6
|
constructor(config) {
|
|
5
7
|
super(new NodePlatformAdapter(), config);
|
|
8
|
+
this.operationStore = config.operationStore;
|
|
9
|
+
this.atomicStore = config.atomicStore;
|
|
6
10
|
}
|
|
7
11
|
}
|
|
8
12
|
function Vana(config) {
|
|
@@ -10,18 +14,30 @@ function Vana(config) {
|
|
|
10
14
|
}
|
|
11
15
|
var index_node_default = Vana;
|
|
12
16
|
import { VanaCore as VanaCore2, VanaCoreFactory } from "./core";
|
|
17
|
+
import { DistributedNonceManager } from "./core/nonceManager";
|
|
18
|
+
import { InMemoryNonceManager } from "./core/inMemoryNonceManager";
|
|
19
|
+
import { SystemHealthChecker } from "./core/health";
|
|
20
|
+
import { RedisAtomicStore } from "./lib/redisAtomicStore";
|
|
13
21
|
import {
|
|
14
22
|
isReplicateAPIResponse,
|
|
15
23
|
isAPIResponse,
|
|
16
24
|
safeParseJSON,
|
|
17
25
|
parseReplicateOutput
|
|
18
26
|
} from "./types/external-apis";
|
|
27
|
+
import {
|
|
28
|
+
EnhancedTransactionResponse,
|
|
29
|
+
canEnhanceResponse,
|
|
30
|
+
enhanceResponse
|
|
31
|
+
} from "./client/enhancedResponse";
|
|
19
32
|
export * from "./errors";
|
|
20
33
|
import { PermissionsController } from "./controllers/permissions";
|
|
34
|
+
import { RuntimePermissionsController } from "./controllers/runtimePermissions";
|
|
35
|
+
import { AccessSettlementController } from "./controllers/accessSettlement";
|
|
21
36
|
import { DataController } from "./controllers/data";
|
|
22
37
|
import { ServerController } from "./controllers/server";
|
|
23
38
|
import { ProtocolController } from "./controllers/protocol";
|
|
24
39
|
import { SchemaController } from "./controllers/schemas";
|
|
40
|
+
import { OperationsController } from "./controllers/operations";
|
|
25
41
|
export * from "./contracts/contractController";
|
|
26
42
|
export * from "./utils/encryption";
|
|
27
43
|
export * from "./utils/formatters";
|
|
@@ -32,8 +48,14 @@ export * from "./utils/ipfs";
|
|
|
32
48
|
export * from "./utils/schemaValidation";
|
|
33
49
|
export * from "./utils/signatureCache";
|
|
34
50
|
export * from "./storage";
|
|
35
|
-
import { getContractAddress } from "./
|
|
51
|
+
import { getContractAddress, CONTRACTS } from "./generated/addresses";
|
|
36
52
|
import { chains } from "./config/chains";
|
|
53
|
+
import {
|
|
54
|
+
mainnetServices,
|
|
55
|
+
mokshaServices,
|
|
56
|
+
getServiceEndpoints,
|
|
57
|
+
getDefaultPersonalServerUrl
|
|
58
|
+
} from "./config/default-services";
|
|
37
59
|
import {
|
|
38
60
|
vanaMainnet,
|
|
39
61
|
mokshaTestnet,
|
|
@@ -53,7 +75,9 @@ import {
|
|
|
53
75
|
AsyncQueue,
|
|
54
76
|
CircuitBreaker
|
|
55
77
|
} from "./core/generics";
|
|
56
|
-
import {
|
|
78
|
+
import {
|
|
79
|
+
handleRelayerOperation
|
|
80
|
+
} from "./server/relayerHandler";
|
|
57
81
|
import { NodePlatformAdapter as NodePlatformAdapter2 } from "./platform/node";
|
|
58
82
|
import { BrowserPlatformAdapter } from "./platform/browser";
|
|
59
83
|
import {
|
|
@@ -70,26 +94,36 @@ import {
|
|
|
70
94
|
} from "./platform/browser-safe";
|
|
71
95
|
import { ApiClient } from "./core/apiClient";
|
|
72
96
|
export {
|
|
97
|
+
AccessSettlementController,
|
|
73
98
|
ApiClient,
|
|
74
99
|
AsyncQueue,
|
|
75
100
|
BaseController,
|
|
76
101
|
BrowserPlatformAdapter,
|
|
102
|
+
CONTRACTS,
|
|
77
103
|
CircuitBreaker,
|
|
78
104
|
DataController,
|
|
105
|
+
DistributedNonceManager,
|
|
106
|
+
EnhancedTransactionResponse,
|
|
79
107
|
EventEmitter,
|
|
108
|
+
InMemoryNonceManager,
|
|
80
109
|
MemoryCache,
|
|
81
110
|
MiddlewarePipeline,
|
|
82
111
|
NodePlatformAdapter2 as NodePlatformAdapter,
|
|
112
|
+
OperationsController,
|
|
83
113
|
PermissionsController,
|
|
84
114
|
ProtocolController,
|
|
85
115
|
RateLimiter,
|
|
116
|
+
RedisAtomicStore,
|
|
86
117
|
RetryUtility,
|
|
118
|
+
RuntimePermissionsController,
|
|
87
119
|
SchemaController,
|
|
88
120
|
ServerController,
|
|
121
|
+
SystemHealthChecker,
|
|
89
122
|
Vana,
|
|
90
123
|
VanaCore2 as VanaCore,
|
|
91
124
|
VanaCoreFactory,
|
|
92
125
|
VanaNodeImpl,
|
|
126
|
+
canEnhanceResponse,
|
|
93
127
|
chains,
|
|
94
128
|
createBrowserPlatformAdapter,
|
|
95
129
|
createNodePlatformAdapter,
|
|
@@ -98,16 +132,21 @@ export {
|
|
|
98
132
|
createPlatformAdapterSafe,
|
|
99
133
|
index_node_default as default,
|
|
100
134
|
detectPlatform,
|
|
135
|
+
enhanceResponse,
|
|
101
136
|
getAbi,
|
|
102
137
|
getAllChains,
|
|
103
138
|
getChainConfig,
|
|
104
139
|
getContractAddress,
|
|
140
|
+
getDefaultPersonalServerUrl,
|
|
105
141
|
getPlatformCapabilities,
|
|
106
|
-
|
|
142
|
+
getServiceEndpoints,
|
|
143
|
+
handleRelayerOperation,
|
|
107
144
|
isAPIResponse,
|
|
108
145
|
isPlatformSupported,
|
|
109
146
|
isReplicateAPIResponse,
|
|
147
|
+
mainnetServices,
|
|
110
148
|
moksha,
|
|
149
|
+
mokshaServices,
|
|
111
150
|
mokshaTestnet,
|
|
112
151
|
parseReplicateOutput,
|
|
113
152
|
safeParseJSON,
|
package/dist/index.node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n} from \"./types\";\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n constructor(config: VanaConfig) {\n super(new NodePlatformAdapter(), config);\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerRequest } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay/:operation', async (req, res) => {\n * try {\n * const result = await handleRelayerRequest(\n * req.params.operation,\n * req.body,\n * vana\n * );\n * res.json({ success: true, result });\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\nexport function Vana(\n config: VanaConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\nexport function Vana(config: VanaConfig): VanaNodeImpl;\n/**\n * Creates a new Vana SDK instance.\n *\n * @param config - The configuration for the Vana SDK\n * @returns A new Vana SDK instance\n */\nexport function Vana(config: VanaConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\n\n// Types - modular exports\nexport type * from \"./types\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress } from \"./config/addresses\";\nexport { chains } from \"./config/chains\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport { handleRelayerRequest } from \"./server/handler\";\nexport type { RelayerRequestPayload } from \"./server/handler\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAWzB,MAAM,qBAAqB,SAAS;AAAA,EAClC,YAAY,QAAoB;AAC9B,UAAM,IAAI,oBAAoB,GAAG,MAAM;AAAA,EACzC;AACF;AAmIO,SAAS,KAAK,QAAoB;AACvC,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAM1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAGjC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,0BAA0B;AACnC,SAAS,cAAc;AAGvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,4BAA4B;AAYrC,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AAIvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.node.ts"],"sourcesContent":["/**\n * @module Node\n * Node.js-specific implementation of the Vana SDK\n */\n\nimport { NodePlatformAdapter } from \"./platform/node\";\nimport { VanaCore } from \"./core\";\nimport type {\n VanaConfig,\n VanaConfigWithStorage,\n StorageRequiredMarker,\n RelayerRequiredMarker,\n} from \"./types\";\nimport type {\n IOperationStore,\n IRelayerStateStore,\n} from \"./types/operationStore\";\nimport type { IAtomicStore } from \"./types/atomicStore\";\nimport type { PublicClient } from \"viem\";\n\n/**\n * Node.js-specific configuration interface with operation store support\n *\n * @category Configuration\n */\nexport type VanaNodeConfig = VanaConfig & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Node.js configuration with storage requirements\n *\n * @category Configuration\n */\nexport type VanaNodeConfigWithStorage = VanaConfigWithStorage & {\n operationStore?: IOperationStore | IRelayerStateStore; // Can be either type\n atomicStore?: IAtomicStore;\n};\n\n/**\n * Internal implementation class for Node.js environments.\n * This class is not exported directly - use the Vana factory function instead.\n */\nclass VanaNodeImpl extends VanaCore {\n override readonly operationStore?: IOperationStore | IRelayerStateStore;\n override readonly atomicStore?: IAtomicStore;\n\n constructor(config: VanaNodeConfig) {\n super(new NodePlatformAdapter(), config);\n this.operationStore = config.operationStore;\n this.atomicStore = config.atomicStore;\n }\n}\n\n/**\n * Creates a new Vana SDK instance configured for Node.js environments.\n *\n * @remarks\n * This is the primary entry point for Node.js applications using the Vana SDK. The function\n * automatically detects your configuration type and provides compile-time type safety:\n * - **With storage configured**: All methods including file upload/download are available\n * - **Without storage**: Storage-dependent methods throw runtime errors and are excluded from TypeScript\n *\n * The Node.js version provides enhanced capabilities including native file system access,\n * server-side cryptographic operations, and support for personal server deployment.\n * It includes all browser capabilities plus Node.js-specific optimizations and utilities.\n *\n * @param config - Configuration object containing wallet, storage, and relayer settings\n * @returns A fully configured Vana SDK instance for Node.js use\n * @throws {InvalidConfigurationError} When configuration parameters are invalid or missing\n * @example\n * ```typescript\n * import { Vana } from '@opendatalabs/vana-sdk/node';\n * import { createWalletClient, http } from 'viem';\n * import { privateKeyToAccount } from 'viem/accounts';\n * import { IPFSStorage, PinataStorage } from '@opendatalabs/vana-sdk/node';\n * import { mokshaTestnet } from '@opendatalabs/vana-sdk/node';\n *\n * // Server setup with private key\n * const account = privateKeyToAccount('0x...');\n * const walletClient = createWalletClient({\n * account,\n * chain: mokshaTestnet,\n * transport: http('https://rpc.moksha.vana.org')\n * });\n *\n * const vana = Vana({\n * walletClient,\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({\n * gateway: 'https://gateway.pinata.cloud',\n * timeout: 30000\n * }),\n * pinata: new PinataStorage({\n * apiKey: process.env.PINATA_KEY,\n * secretKey: process.env.PINATA_SECRET\n * })\n * },\n * defaultProvider: 'pinata'\n * },\n * relayerCallbacks: {\n * async submitPermissionGrant(typedData, signature) {\n * // Server-side relayer implementation\n * return await submitToCustomRelayer(typedData, signature);\n * }\n * }\n * });\n *\n * // Server operations\n * const uploadResult = await vana.data.upload({\n * content: await fs.readFile('./user-data.json'),\n * filename: 'user-data.json',\n * schemaId: 1\n * });\n *\n * // Personal server setup\n * await vana.server.setupPersonalServer({\n * serverUrl: 'https://my-server.example.com',\n * capabilities: ['data_processing', 'ml_inference']\n * });\n * ```\n *\n * @example\n * ```typescript\n * // CLI tool or script usage\n * const vana = Vana({\n * chainId: 14800, // Moksha testnet\n * account: privateKeyToAccount(process.env.PRIVATE_KEY),\n * rpcUrl: process.env.RPC_URL,\n * storage: {\n * providers: { ipfs: new IPFSStorage() },\n * defaultProvider: 'ipfs'\n * }\n * });\n *\n * // Batch operations for data processing\n * const userFiles = await vana.data.getUserFiles({\n * owner: process.env.USER_ADDRESS\n * });\n *\n * for (const file of userFiles) {\n * const decrypted = await vana.data.decryptFile(file);\n * // Process file data...\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Express.js server integration\n * import express from 'express';\n * import { handleRelayerOperation } from '@opendatalabs/vana-sdk/node';\n *\n * const app = express();\n *\n * app.post('/api/relay', async (req, res) => {\n * try {\n * const result = await handleRelayerOperation(\n * vana,\n * req.body\n * );\n * res.json(result);\n * } catch (error) {\n * res.status(500).json({ error: error.message });\n * }\n * });\n * ```\n *\n * @see {@link https://docs.vana.org/docs/sdk/server-setup | Server Setup Guide} for Node.js-specific features\n * @see {@link VanaCore} for the underlying implementation details\n * @category Core SDK\n */\n// Overload 1: For configurations that include both storage and operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage & { operationStore: IOperationStore },\n): VanaNodeImpl & StorageRequiredMarker & RelayerRequiredMarker;\n\n// Overload 2: For configurations that include only the operation store\nexport function Vana(\n config: VanaNodeConfig & { operationStore: IOperationStore },\n): VanaNodeImpl & RelayerRequiredMarker;\n\n// Overload 3: For configurations with storage but no operation store\nexport function Vana(\n config: VanaNodeConfigWithStorage,\n): VanaNodeImpl & StorageRequiredMarker;\n\n// Overload 4: Base configuration without special requirements\nexport function Vana(config: VanaNodeConfig): VanaNodeImpl;\n\n// Implementation\nexport function Vana(config: VanaNodeConfig) {\n return new VanaNodeImpl(config);\n}\n\n/**\n * The type of a Vana SDK instance in Node.js environments.\n * Uses InstanceType to properly expose all public methods from the class hierarchy.\n *\n * @see {@link Vana}\n */\nexport type VanaInstance = InstanceType<typeof VanaNodeImpl>;\n\n// Export as default export\nexport default Vana;\n\n// Re-export everything that was in index.ts (avoiding circular dependency)\n// Core class and factory\nexport { VanaCore, VanaCoreFactory } from \"./core\";\nexport { DistributedNonceManager } from \"./core/nonceManager\";\nexport { InMemoryNonceManager } from \"./core/inMemoryNonceManager\";\nexport { SystemHealthChecker } from \"./core/health\";\nexport type {\n SystemHealthCheckerConfig,\n HealthStatus,\n ComponentHealth,\n NonceHealth,\n QueueHealth,\n} from \"./core/health\";\n\n// Storage implementations\nexport { RedisAtomicStore } from \"./lib/redisAtomicStore\";\nexport type { RedisAtomicStoreConfig } from \"./lib/redisAtomicStore\";\n\n// Types - modular exports\nexport type * from \"./types\";\nexport type { IAtomicStore } from \"./types/atomicStore\";\nexport type {\n IOperationStore,\n StoredOperation,\n IRelayerStateStore,\n OperationState,\n} from \"./types/operationStore\";\n\n// Type guards and utilities\nexport {\n isReplicateAPIResponse,\n isAPIResponse,\n safeParseJSON,\n parseReplicateOutput,\n} from \"./types/external-apis\";\n\n// VanaContract is exported from abi to avoid circular dependencies\nexport type { VanaContract } from \"./generated/abi\";\n\n// Enhanced response pattern for improved developer experience\nexport {\n EnhancedTransactionResponse,\n canEnhanceResponse,\n enhanceResponse,\n} from \"./client/enhancedResponse\";\n\n// Error classes\nexport * from \"./errors\";\n\n// Controllers\nexport { PermissionsController } from \"./controllers/permissions\";\nexport { RuntimePermissionsController } from \"./controllers/runtimePermissions\";\nexport { AccessSettlementController } from \"./controllers/accessSettlement\";\nexport { DataController } from \"./controllers/data\";\nexport { ServerController } from \"./controllers/server\";\nexport { ProtocolController } from \"./controllers/protocol\";\nexport { SchemaController } from \"./controllers/schemas\";\nexport { OperationsController } from \"./controllers/operations\";\n\n// Contract controller\nexport * from \"./contracts/contractController\";\n\n// Utilities\nexport * from \"./utils/encryption\";\nexport * from \"./utils/formatters\";\nexport * from \"./utils/grantFiles\";\nexport * from \"./utils/grantValidation\";\nexport * from \"./utils/grants\";\nexport * from \"./utils/ipfs\";\nexport * from \"./utils/schemaValidation\";\nexport * from \"./utils/signatureCache\";\n\n// Storage API\nexport * from \"./storage\";\n\n// Configuration\nexport { getContractAddress, CONTRACTS } from \"./generated/addresses\";\nexport { chains } from \"./config/chains\";\nexport {\n type ServiceEndpoints,\n mainnetServices,\n mokshaServices,\n getServiceEndpoints,\n getDefaultPersonalServerUrl,\n} from \"./config/default-services\";\n\n// Chain configurations with subgraph URLs - explicit exports for better DX\nexport {\n vanaMainnet,\n mokshaTestnet,\n moksha,\n type VanaChainConfig,\n getChainConfig,\n getAllChains,\n} from \"./chains\";\nexport * from \"./chains\";\n\n// ABIs\nexport { getAbi } from \"./generated/abi\";\nexport type { VanaContract as VanaContractAbi } from \"./generated/abi\";\n\n// Generic utilities for extensibility\nexport {\n BaseController,\n RetryUtility,\n RateLimiter,\n MemoryCache,\n EventEmitter,\n MiddlewarePipeline,\n AsyncQueue,\n CircuitBreaker,\n} from \"./core/generics\";\n\n// Server-side utilities\nexport {\n handleRelayerOperation,\n type RelayerOperationOptions,\n} from \"./server/relayerHandler\";\nexport type {\n UnifiedRelayerRequest,\n UnifiedRelayerResponse,\n} from \"./types/relayer\";\n// TransactionHandle removed - using POJOs instead\nexport type {\n Operation,\n TransactionResult,\n TransactionReceipt,\n PollingOptions,\n TransactionWaitOptions,\n} from \"./types/operations\";\n\n// Platform adapters\nexport { NodePlatformAdapter } from \"./platform/node\";\nexport { BrowserPlatformAdapter } from \"./platform/browser\";\nexport type { VanaPlatformAdapter } from \"./platform/interface\";\n\n// Platform utilities\nexport {\n detectPlatform,\n createPlatformAdapter,\n createPlatformAdapterFor,\n isPlatformSupported,\n getPlatformCapabilities,\n} from \"./platform/utils\";\n\n// Browser-safe platform utilities\nexport {\n createNodePlatformAdapter,\n createBrowserPlatformAdapter,\n createPlatformAdapterSafe,\n} from \"./platform/browser-safe\";\n\nexport { ApiClient } from \"./core/apiClient\";\n\nexport type {\n ApiClientConfig,\n HttpMethod,\n RequestOptions,\n} from \"./core/apiClient\";\n\n// Note: Default export is already handled above with the Vana factory function\n// For testing purposes, we also export the implementation class\nexport { VanaNodeImpl };\n\n// Server-specific interface for accessing stores\nexport interface VanaWithStores {\n readonly operationStore?: IOperationStore | IRelayerStateStore;\n readonly atomicStore?: IAtomicStore;\n readonly publicClient: PublicClient;\n}\n"],"mappings":"AAKA,SAAS,2BAA2B;AACpC,SAAS,gBAAgB;AAsCzB,MAAM,qBAAqB,SAAS;AAAA,EAChB;AAAA,EACA;AAAA,EAElB,YAAY,QAAwB;AAClC,UAAM,IAAI,oBAAoB,GAAG,MAAM;AACvC,SAAK,iBAAiB,OAAO;AAC7B,SAAK,cAAc,OAAO;AAAA,EAC5B;AACF;AA2IO,SAAS,KAAK,QAAwB;AAC3C,SAAO,IAAI,aAAa,MAAM;AAChC;AAWA,IAAO,qBAAQ;AAIf,SAAS,YAAAA,WAAU,uBAAuB;AAC1C,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AAUpC,SAAS,wBAAwB;AAcjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,cAAc;AAGd,SAAS,6BAA6B;AACtC,SAAS,oCAAoC;AAC7C,SAAS,kCAAkC;AAC3C,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AAGrC,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,cAAc;AAGd,SAAS,oBAAoB,iBAAiB;AAC9C,SAAS,cAAc;AACvB;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AAGd,SAAS,cAAc;AAIvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,OAEK;AAeP,SAAS,uBAAAC,4BAA2B;AACpC,SAAS,8BAA8B;AAIvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,iBAAiB;","names":["VanaCore","NodePlatformAdapter"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,201 @@
|
|
|
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 redisAtomicStore_exports = {};
|
|
20
|
+
__export(redisAtomicStore_exports, {
|
|
21
|
+
RedisAtomicStore: () => RedisAtomicStore
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(redisAtomicStore_exports);
|
|
24
|
+
class RedisAtomicStore {
|
|
25
|
+
redis;
|
|
26
|
+
// ioredis instance
|
|
27
|
+
keyPrefix;
|
|
28
|
+
/**
|
|
29
|
+
* Lua script for safe lock release.
|
|
30
|
+
* This ensures we only delete a lock if the value matches our lock ID.
|
|
31
|
+
*/
|
|
32
|
+
UNLOCK_SCRIPT = `
|
|
33
|
+
if redis.call("GET", KEYS[1]) == ARGV[1] then
|
|
34
|
+
return redis.call("DEL", KEYS[1])
|
|
35
|
+
else
|
|
36
|
+
return 0
|
|
37
|
+
end
|
|
38
|
+
`;
|
|
39
|
+
constructor(config) {
|
|
40
|
+
if (typeof config.redis === "string") {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"RedisAtomicStore requires an initialized Redis client instance. Please create the Redis client in your application and pass it to the constructor."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
this.redis = config.redis;
|
|
46
|
+
this.keyPrefix = config.keyPrefix ?? "vana-sdk:atomic";
|
|
47
|
+
if (!this.redis || typeof this.redis.incr !== "function" || typeof this.redis.set !== "function" || typeof this.redis.get !== "function" || typeof this.redis.eval !== "function") {
|
|
48
|
+
throw new Error(
|
|
49
|
+
"Invalid Redis client instance provided to RedisAtomicStore"
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Atomically increments a counter.
|
|
55
|
+
*/
|
|
56
|
+
async incr(key) {
|
|
57
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
58
|
+
return await this.redis.incr(fullKey);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Acquires a distributed lock using SET NX EX.
|
|
62
|
+
*/
|
|
63
|
+
async acquireLock(key, ttlSeconds) {
|
|
64
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
65
|
+
const lockId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;
|
|
66
|
+
const result = await this.redis.set(
|
|
67
|
+
fullKey,
|
|
68
|
+
lockId,
|
|
69
|
+
"EX",
|
|
70
|
+
ttlSeconds,
|
|
71
|
+
"NX"
|
|
72
|
+
);
|
|
73
|
+
if (result === "OK") {
|
|
74
|
+
console.log(`[RedisAtomicStore] Lock acquired: ${key} with ID ${lockId}`);
|
|
75
|
+
return lockId;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Releases a lock using a Lua script for atomicity.
|
|
81
|
+
*/
|
|
82
|
+
async releaseLock(key, lockId) {
|
|
83
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
84
|
+
const result = await this.redis.eval(
|
|
85
|
+
this.UNLOCK_SCRIPT,
|
|
86
|
+
1,
|
|
87
|
+
// Number of keys
|
|
88
|
+
fullKey,
|
|
89
|
+
// KEYS[1]
|
|
90
|
+
lockId
|
|
91
|
+
// ARGV[1]
|
|
92
|
+
);
|
|
93
|
+
if (result === 1) {
|
|
94
|
+
console.log(`[RedisAtomicStore] Lock released: ${key}`);
|
|
95
|
+
} else {
|
|
96
|
+
console.warn(
|
|
97
|
+
`[RedisAtomicStore] Lock release failed: ${key} (lock not held or expired)`
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Gets a value from Redis.
|
|
103
|
+
*/
|
|
104
|
+
async get(key) {
|
|
105
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
106
|
+
return await this.redis.get(fullKey);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Sets a value in Redis.
|
|
110
|
+
*/
|
|
111
|
+
async set(key, value) {
|
|
112
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
113
|
+
await this.redis.set(fullKey, value);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sets a value with TTL for automatic expiration.
|
|
117
|
+
*/
|
|
118
|
+
async setWithTTL(key, value, ttlSeconds) {
|
|
119
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
120
|
+
await this.redis.setex(fullKey, ttlSeconds, value);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Deletes a key from Redis.
|
|
124
|
+
*/
|
|
125
|
+
async delete(key) {
|
|
126
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
127
|
+
await this.redis.del(fullKey);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Executes a Lua script atomically.
|
|
131
|
+
*
|
|
132
|
+
* @remarks
|
|
133
|
+
* This provides generic script execution for complex atomic operations.
|
|
134
|
+
* Keys passed to the script will be automatically prefixed.
|
|
135
|
+
*
|
|
136
|
+
* @param script - The Lua script to execute
|
|
137
|
+
* @param keys - Array of keys (will be prefixed)
|
|
138
|
+
* @param args - Array of arguments
|
|
139
|
+
* @returns The script's return value
|
|
140
|
+
*/
|
|
141
|
+
async eval(script, keys, args) {
|
|
142
|
+
const prefixedKeys = keys.map((key) => `${this.keyPrefix}:${key}`);
|
|
143
|
+
const result = await this.redis.eval(
|
|
144
|
+
script,
|
|
145
|
+
keys.length,
|
|
146
|
+
...prefixedKeys,
|
|
147
|
+
...args
|
|
148
|
+
);
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Atomically assigns a nonce using Vana App's battle-tested logic.
|
|
153
|
+
*
|
|
154
|
+
* @remarks
|
|
155
|
+
* This is a Redis-specific optimization that uses a Lua script for
|
|
156
|
+
* atomic nonce assignment with gap prevention. This method is called
|
|
157
|
+
* by DistributedNonceManager when it detects a Redis store.
|
|
158
|
+
*
|
|
159
|
+
* Ported from apps/web/app/api/relay/route.ts (Vana App production code)
|
|
160
|
+
* DO NOT MODIFY without thorough testing in production environment.
|
|
161
|
+
*
|
|
162
|
+
* @param key - The key for storing the last used nonce
|
|
163
|
+
* @param pendingCount - The current pending transaction count from blockchain
|
|
164
|
+
* @returns The assigned nonce
|
|
165
|
+
*/
|
|
166
|
+
async atomicAssignNonce(key, pendingCount) {
|
|
167
|
+
const LUA_ASSIGN_NONCE = `
|
|
168
|
+
-- KEYS[1] = lastUsedKey
|
|
169
|
+
-- ARGV[1] = pendingCount (integer)
|
|
170
|
+
|
|
171
|
+
local last = tonumber(redis.call("GET", KEYS[1]) or "-1")
|
|
172
|
+
local pending = tonumber(ARGV[1])
|
|
173
|
+
local candidate = last + 1
|
|
174
|
+
if pending > candidate or (candidate - pending > 500) then
|
|
175
|
+
-- If pending is ahead OR if candidate is too far ahead (>500 nonces), reset to pending
|
|
176
|
+
candidate = pending
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
-- IMPORTANT: Atomically update the last used nonce
|
|
180
|
+
redis.call("SET", KEYS[1], candidate)
|
|
181
|
+
|
|
182
|
+
return candidate
|
|
183
|
+
`;
|
|
184
|
+
const fullKey = `${this.keyPrefix}:${key}`;
|
|
185
|
+
const nonce = await this.redis.eval(
|
|
186
|
+
LUA_ASSIGN_NONCE,
|
|
187
|
+
1,
|
|
188
|
+
// Number of keys
|
|
189
|
+
fullKey,
|
|
190
|
+
// KEYS[1]
|
|
191
|
+
pendingCount.toString()
|
|
192
|
+
// ARGV[1]
|
|
193
|
+
);
|
|
194
|
+
return nonce;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
198
|
+
0 && (module.exports = {
|
|
199
|
+
RedisAtomicStore
|
|
200
|
+
});
|
|
201
|
+
//# sourceMappingURL=redisAtomicStore.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/redisAtomicStore.ts"],"sourcesContent":["/**\n * Redis implementation of IAtomicStore for production use.\n *\n * @remarks\n * This is a Node.js-only implementation that requires the ioredis package.\n * It will not be included in browser bundles.\n *\n * @module\n */\n\nimport type { IAtomicStoreWithNonceSupport } from \"../types/atomicStore\";\n\n/**\n * Configuration for RedisAtomicStore\n */\nexport interface RedisAtomicStoreConfig {\n /** Redis connection URL or ioredis options */\n redis: string | any;\n /** Key prefix for all operations (default: 'vana-sdk:atomic') */\n keyPrefix?: string;\n}\n\n/**\n * Redis-backed implementation of IAtomicStore.\n *\n * @remarks\n * This implementation uses Redis's native atomic operations:\n * - INCR for atomic counter increments\n * - SET NX EX for distributed locking\n * - Lua script for safe lock release\n *\n * Redis is ideal for this use case because:\n * - All operations are atomic by design\n * - Built-in TTL support for automatic cleanup\n * - High performance (sub-millisecond operations)\n * - Battle-tested in production environments\n *\n * @example\n * ```typescript\n * import Redis from 'ioredis';\n * import { RedisAtomicStore } from '@opendatalabs/vana-sdk/node';\n *\n * const redis = new Redis(process.env.REDIS_URL);\n * const atomicStore = new RedisAtomicStore({\n * redis: redis\n * });\n *\n * const vana = Vana({\n * walletClient,\n * atomicStore,\n * operationStore\n * });\n * ```\n *\n * @category Storage\n */\nexport class RedisAtomicStore implements IAtomicStoreWithNonceSupport {\n private redis: any; // ioredis instance\n private keyPrefix: string;\n\n /**\n * Lua script for safe lock release.\n * This ensures we only delete a lock if the value matches our lock ID.\n */\n private readonly UNLOCK_SCRIPT = `\n if redis.call(\"GET\", KEYS[1]) == ARGV[1] then\n return redis.call(\"DEL\", KEYS[1])\n else\n return 0\n end\n `;\n\n constructor(config: RedisAtomicStoreConfig) {\n // Dynamic import to avoid bundling ioredis in browser builds\n // The actual Redis instance should be passed in already created\n if (typeof config.redis === \"string\") {\n throw new Error(\n \"RedisAtomicStore requires an initialized Redis client instance. \" +\n \"Please create the Redis client in your application and pass it to the constructor.\",\n );\n }\n\n this.redis = config.redis;\n this.keyPrefix = config.keyPrefix ?? \"vana-sdk:atomic\";\n\n // Validate that the redis instance has the methods we need\n if (\n !this.redis ||\n typeof this.redis.incr !== \"function\" ||\n typeof this.redis.set !== \"function\" ||\n typeof this.redis.get !== \"function\" ||\n typeof this.redis.eval !== \"function\"\n ) {\n throw new Error(\n \"Invalid Redis client instance provided to RedisAtomicStore\",\n );\n }\n }\n\n /**\n * Atomically increments a counter.\n */\n async incr(key: string): Promise<number> {\n const fullKey = `${this.keyPrefix}:${key}`;\n return await this.redis.incr(fullKey);\n }\n\n /**\n * Acquires a distributed lock using SET NX EX.\n */\n async acquireLock(key: string, ttlSeconds: number): Promise<string | null> {\n const fullKey = `${this.keyPrefix}:${key}`;\n const lockId = `${Date.now()}-${Math.random().toString(36).substring(2, 15)}`;\n\n // SET key value NX EX ttl\n const result = await this.redis.set(\n fullKey,\n lockId,\n \"EX\",\n ttlSeconds,\n \"NX\",\n );\n\n if (result === \"OK\") {\n console.log(`[RedisAtomicStore] Lock acquired: ${key} with ID ${lockId}`);\n return lockId;\n }\n\n return null;\n }\n\n /**\n * Releases a lock using a Lua script for atomicity.\n */\n async releaseLock(key: string, lockId: string): Promise<void> {\n const fullKey = `${this.keyPrefix}:${key}`;\n\n // Use Lua script for atomic compare-and-delete\n const result = (await this.redis.eval(\n this.UNLOCK_SCRIPT,\n 1, // Number of keys\n fullKey, // KEYS[1]\n lockId, // ARGV[1]\n )) as number;\n\n if (result === 1) {\n console.log(`[RedisAtomicStore] Lock released: ${key}`);\n } else {\n console.warn(\n `[RedisAtomicStore] Lock release failed: ${key} (lock not held or expired)`,\n );\n }\n }\n\n /**\n * Gets a value from Redis.\n */\n async get(key: string): Promise<string | null> {\n const fullKey = `${this.keyPrefix}:${key}`;\n return await this.redis.get(fullKey);\n }\n\n /**\n * Sets a value in Redis.\n */\n async set(key: string, value: string): Promise<void> {\n const fullKey = `${this.keyPrefix}:${key}`;\n await this.redis.set(fullKey, value);\n }\n\n /**\n * Sets a value with TTL for automatic expiration.\n */\n async setWithTTL?(\n key: string,\n value: string,\n ttlSeconds: number,\n ): Promise<void> {\n const fullKey = `${this.keyPrefix}:${key}`;\n await this.redis.setex(fullKey, ttlSeconds, value);\n }\n\n /**\n * Deletes a key from Redis.\n */\n async delete?(key: string): Promise<void> {\n const fullKey = `${this.keyPrefix}:${key}`;\n await this.redis.del(fullKey);\n }\n\n /**\n * Executes a Lua script atomically.\n *\n * @remarks\n * This provides generic script execution for complex atomic operations.\n * Keys passed to the script will be automatically prefixed.\n *\n * @param script - The Lua script to execute\n * @param keys - Array of keys (will be prefixed)\n * @param args - Array of arguments\n * @returns The script's return value\n */\n async eval(script: string, keys: string[], args: string[]): Promise<any> {\n // Apply key prefix to all keys\n const prefixedKeys = keys.map((key) => `${this.keyPrefix}:${key}`);\n\n // Execute the Lua script\n const result = await this.redis.eval(\n script,\n keys.length,\n ...prefixedKeys,\n ...args,\n );\n\n return result;\n }\n\n /**\n * Atomically assigns a nonce using Vana App's battle-tested logic.\n *\n * @remarks\n * This is a Redis-specific optimization that uses a Lua script for\n * atomic nonce assignment with gap prevention. This method is called\n * by DistributedNonceManager when it detects a Redis store.\n *\n * Ported from apps/web/app/api/relay/route.ts (Vana App production code)\n * DO NOT MODIFY without thorough testing in production environment.\n *\n * @param key - The key for storing the last used nonce\n * @param pendingCount - The current pending transaction count from blockchain\n * @returns The assigned nonce\n */\n async atomicAssignNonce(key: string, pendingCount: number): Promise<number> {\n const LUA_ASSIGN_NONCE = `\n -- KEYS[1] = lastUsedKey\n -- ARGV[1] = pendingCount (integer)\n\n local last = tonumber(redis.call(\"GET\", KEYS[1]) or \"-1\")\n local pending = tonumber(ARGV[1])\n local candidate = last + 1\n if pending > candidate or (candidate - pending > 500) then\n -- If pending is ahead OR if candidate is too far ahead (>500 nonces), reset to pending\n candidate = pending\n end\n\n -- IMPORTANT: Atomically update the last used nonce\n redis.call(\"SET\", KEYS[1], candidate)\n\n return candidate\n `;\n\n const fullKey = `${this.keyPrefix}:${key}`;\n const nonce = (await this.redis.eval(\n LUA_ASSIGN_NONCE,\n 1, // Number of keys\n fullKey, // KEYS[1]\n pendingCount.toString(), // ARGV[1]\n )) as number;\n\n return nonce;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAwDO,MAAM,iBAAyD;AAAA,EAC5D;AAAA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMS,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjC,YAAY,QAAgC;AAG1C,QAAI,OAAO,OAAO,UAAU,UAAU;AACpC,YAAM,IAAI;AAAA,QACR;AAAA,MAEF;AAAA,IACF;AAEA,SAAK,QAAQ,OAAO;AACpB,SAAK,YAAY,OAAO,aAAa;AAGrC,QACE,CAAC,KAAK,SACN,OAAO,KAAK,MAAM,SAAS,cAC3B,OAAO,KAAK,MAAM,QAAQ,cAC1B,OAAO,KAAK,MAAM,QAAQ,cAC1B,OAAO,KAAK,MAAM,SAAS,YAC3B;AACA,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAK,KAA8B;AACvC,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,WAAO,MAAM,KAAK,MAAM,KAAK,OAAO;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAY,KAAa,YAA4C;AACzE,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,UAAM,SAAS,GAAG,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,EAAE,CAAC;AAG3E,UAAM,SAAS,MAAM,KAAK,MAAM;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAEA,QAAI,WAAW,MAAM;AACnB,cAAQ,IAAI,qCAAqC,GAAG,YAAY,MAAM,EAAE;AACxE,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAY,KAAa,QAA+B;AAC5D,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AAGxC,UAAM,SAAU,MAAM,KAAK,MAAM;AAAA,MAC/B,KAAK;AAAA,MACL;AAAA;AAAA,MACA;AAAA;AAAA,MACA;AAAA;AAAA,IACF;AAEA,QAAI,WAAW,GAAG;AAChB,cAAQ,IAAI,qCAAqC,GAAG,EAAE;AAAA,IACxD,OAAO;AACL,cAAQ;AAAA,QACN,2CAA2C,GAAG;AAAA,MAChD;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,KAAqC;AAC7C,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,WAAO,MAAM,KAAK,MAAM,IAAI,OAAO;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,IAAI,KAAa,OAA8B;AACnD,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,UAAM,KAAK,MAAM,IAAI,SAAS,KAAK;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WACJ,KACA,OACA,YACe;AACf,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,UAAM,KAAK,MAAM,MAAM,SAAS,YAAY,KAAK;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAQ,KAA4B;AACxC,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,UAAM,KAAK,MAAM,IAAI,OAAO;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAcA,MAAM,KAAK,QAAgB,MAAgB,MAA8B;AAEvE,UAAM,eAAe,KAAK,IAAI,CAAC,QAAQ,GAAG,KAAK,SAAS,IAAI,GAAG,EAAE;AAGjE,UAAM,SAAS,MAAM,KAAK,MAAM;AAAA,MAC9B;AAAA,MACA,KAAK;AAAA,MACL,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,MAAM,kBAAkB,KAAa,cAAuC;AAC1E,UAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBzB,UAAM,UAAU,GAAG,KAAK,SAAS,IAAI,GAAG;AACxC,UAAM,QAAS,MAAM,KAAK,MAAM;AAAA,MAC9B;AAAA,MACA;AAAA;AAAA,MACA;AAAA;AAAA,MACA,aAAa,SAAS;AAAA;AAAA,IACxB;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis implementation of IAtomicStore for production use.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This is a Node.js-only implementation that requires the ioredis package.
|
|
6
|
+
* It will not be included in browser bundles.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { IAtomicStoreWithNonceSupport } from "../types/atomicStore";
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for RedisAtomicStore
|
|
13
|
+
*/
|
|
14
|
+
export interface RedisAtomicStoreConfig {
|
|
15
|
+
/** Redis connection URL or ioredis options */
|
|
16
|
+
redis: string | any;
|
|
17
|
+
/** Key prefix for all operations (default: 'vana-sdk:atomic') */
|
|
18
|
+
keyPrefix?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Redis-backed implementation of IAtomicStore.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* This implementation uses Redis's native atomic operations:
|
|
25
|
+
* - INCR for atomic counter increments
|
|
26
|
+
* - SET NX EX for distributed locking
|
|
27
|
+
* - Lua script for safe lock release
|
|
28
|
+
*
|
|
29
|
+
* Redis is ideal for this use case because:
|
|
30
|
+
* - All operations are atomic by design
|
|
31
|
+
* - Built-in TTL support for automatic cleanup
|
|
32
|
+
* - High performance (sub-millisecond operations)
|
|
33
|
+
* - Battle-tested in production environments
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import Redis from 'ioredis';
|
|
38
|
+
* import { RedisAtomicStore } from '@opendatalabs/vana-sdk/node';
|
|
39
|
+
*
|
|
40
|
+
* const redis = new Redis(process.env.REDIS_URL);
|
|
41
|
+
* const atomicStore = new RedisAtomicStore({
|
|
42
|
+
* redis: redis
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const vana = Vana({
|
|
46
|
+
* walletClient,
|
|
47
|
+
* atomicStore,
|
|
48
|
+
* operationStore
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @category Storage
|
|
53
|
+
*/
|
|
54
|
+
export declare class RedisAtomicStore implements IAtomicStoreWithNonceSupport {
|
|
55
|
+
private redis;
|
|
56
|
+
private keyPrefix;
|
|
57
|
+
/**
|
|
58
|
+
* Lua script for safe lock release.
|
|
59
|
+
* This ensures we only delete a lock if the value matches our lock ID.
|
|
60
|
+
*/
|
|
61
|
+
private readonly UNLOCK_SCRIPT;
|
|
62
|
+
constructor(config: RedisAtomicStoreConfig);
|
|
63
|
+
/**
|
|
64
|
+
* Atomically increments a counter.
|
|
65
|
+
*/
|
|
66
|
+
incr(key: string): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Acquires a distributed lock using SET NX EX.
|
|
69
|
+
*/
|
|
70
|
+
acquireLock(key: string, ttlSeconds: number): Promise<string | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Releases a lock using a Lua script for atomicity.
|
|
73
|
+
*/
|
|
74
|
+
releaseLock(key: string, lockId: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Gets a value from Redis.
|
|
77
|
+
*/
|
|
78
|
+
get(key: string): Promise<string | null>;
|
|
79
|
+
/**
|
|
80
|
+
* Sets a value in Redis.
|
|
81
|
+
*/
|
|
82
|
+
set(key: string, value: string): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Sets a value with TTL for automatic expiration.
|
|
85
|
+
*/
|
|
86
|
+
setWithTTL?(key: string, value: string, ttlSeconds: number): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Deletes a key from Redis.
|
|
89
|
+
*/
|
|
90
|
+
delete?(key: string): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Executes a Lua script atomically.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* This provides generic script execution for complex atomic operations.
|
|
96
|
+
* Keys passed to the script will be automatically prefixed.
|
|
97
|
+
*
|
|
98
|
+
* @param script - The Lua script to execute
|
|
99
|
+
* @param keys - Array of keys (will be prefixed)
|
|
100
|
+
* @param args - Array of arguments
|
|
101
|
+
* @returns The script's return value
|
|
102
|
+
*/
|
|
103
|
+
eval(script: string, keys: string[], args: string[]): Promise<any>;
|
|
104
|
+
/**
|
|
105
|
+
* Atomically assigns a nonce using Vana App's battle-tested logic.
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* This is a Redis-specific optimization that uses a Lua script for
|
|
109
|
+
* atomic nonce assignment with gap prevention. This method is called
|
|
110
|
+
* by DistributedNonceManager when it detects a Redis store.
|
|
111
|
+
*
|
|
112
|
+
* Ported from apps/web/app/api/relay/route.ts (Vana App production code)
|
|
113
|
+
* DO NOT MODIFY without thorough testing in production environment.
|
|
114
|
+
*
|
|
115
|
+
* @param key - The key for storing the last used nonce
|
|
116
|
+
* @param pendingCount - The current pending transaction count from blockchain
|
|
117
|
+
* @returns The assigned nonce
|
|
118
|
+
*/
|
|
119
|
+
atomicAssignNonce(key: string, pendingCount: number): Promise<number>;
|
|
120
|
+
}
|