@opendatalabs/vana-sdk 0.1.0-alpha.db07fe1 → 0.1.0-alpha.dc68f39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
- package/dist/browser.cjs +29 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +4 -0
- package/dist/browser.js +5 -0
- package/dist/browser.js.map +1 -0
- package/dist/chains/definitions.cjs +95 -0
- package/dist/chains/definitions.cjs.map +1 -0
- package/dist/chains/definitions.d.ts +51 -0
- package/dist/chains/definitions.js +67 -0
- package/dist/chains/definitions.js.map +1 -0
- package/dist/chains/index.cjs +37 -0
- package/dist/chains/index.cjs.map +1 -0
- package/dist/chains/index.d.ts +5 -0
- package/dist/chains/index.js +15 -0
- package/dist/chains/index.js.map +1 -0
- package/dist/chains.browser.d.ts +8 -0
- package/dist/chains.browser.js +15 -0
- package/dist/chains.browser.js.map +1 -0
- package/dist/chains.cjs +37 -0
- package/dist/chains.cjs.map +1 -0
- package/dist/chains.d.ts +8 -0
- package/dist/chains.js +15 -0
- package/dist/chains.js.map +1 -0
- package/dist/chains.node.cjs +37 -0
- package/dist/chains.node.cjs.map +1 -0
- package/dist/chains.node.d.ts +8 -0
- package/dist/chains.node.js +15 -0
- package/dist/chains.node.js.map +1 -0
- package/dist/config/addresses.cjs +325 -0
- package/dist/config/addresses.cjs.map +1 -0
- package/dist/config/addresses.d.ts +364 -0
- package/dist/config/addresses.js +295 -0
- package/dist/config/addresses.js.map +1 -0
- package/dist/config/chains.cjs +93 -0
- package/dist/config/chains.cjs.map +1 -0
- package/dist/config/chains.d.ts +81 -0
- package/dist/config/chains.js +67 -0
- package/dist/config/chains.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/config/features.cjs +52 -0
- package/dist/config/features.cjs.map +1 -0
- package/dist/config/features.d.ts +62 -0
- package/dist/config/features.js +28 -0
- package/dist/config/features.js.map +1 -0
- package/dist/config/tests/addresses.test.d.ts +1 -0
- package/dist/contracts/contractController.cjs +126 -0
- package/dist/contracts/contractController.cjs.map +1 -0
- package/dist/contracts/contractController.d.ts +79 -0
- package/dist/contracts/contractController.js +100 -0
- package/dist/contracts/contractController.js.map +1 -0
- package/dist/contracts/tests/contractController.test.d.ts +1 -0
- package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
- package/dist/controllers/base.cjs +83 -0
- package/dist/controllers/base.cjs.map +1 -0
- package/dist/controllers/base.d.ts +84 -0
- package/dist/controllers/base.js +59 -0
- package/dist/controllers/base.js.map +1 -0
- package/dist/controllers/data-error-handling.test.d.ts +1 -0
- package/dist/controllers/data.cjs +2482 -0
- package/dist/controllers/data.cjs.map +1 -0
- package/dist/controllers/data.d.ts +1014 -0
- package/dist/controllers/data.js +2465 -0
- package/dist/controllers/data.js.map +1 -0
- package/dist/controllers/permissions.cjs +3977 -0
- package/dist/controllers/permissions.cjs.map +1 -0
- package/dist/controllers/permissions.d.ts +1348 -0
- package/dist/controllers/permissions.js +3953 -0
- package/dist/controllers/permissions.js.map +1 -0
- package/dist/controllers/protocol.cjs +183 -0
- package/dist/controllers/protocol.cjs.map +1 -0
- package/dist/controllers/protocol.d.ts +139 -0
- package/dist/controllers/protocol.js +163 -0
- package/dist/controllers/protocol.js.map +1 -0
- package/dist/controllers/schemas.cjs +599 -0
- package/dist/controllers/schemas.cjs.map +1 -0
- package/dist/controllers/schemas.d.ts +245 -0
- package/dist/controllers/schemas.js +575 -0
- package/dist/controllers/schemas.js.map +1 -0
- package/dist/controllers/server-additional.test.d.ts +1 -0
- package/dist/controllers/server.cjs +432 -0
- package/dist/controllers/server.cjs.map +1 -0
- package/dist/controllers/server.d.ts +217 -0
- package/dist/controllers/server.js +413 -0
- package/dist/controllers/server.js.map +1 -0
- package/dist/core/apiClient.cjs +328 -0
- package/dist/core/apiClient.cjs.map +1 -0
- package/dist/core/apiClient.d.ts +161 -0
- package/dist/core/apiClient.js +309 -0
- package/dist/core/apiClient.js.map +1 -0
- package/dist/core/client.cjs +70 -0
- package/dist/core/client.cjs.map +1 -0
- package/dist/core/client.d.ts +89 -0
- package/dist/core/client.js +47 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/core.test.d.ts +1 -0
- package/dist/core/generics.cjs +390 -0
- package/dist/core/generics.cjs.map +1 -0
- package/dist/core/generics.d.ts +116 -0
- package/dist/core/generics.js +359 -0
- package/dist/core/generics.js.map +1 -0
- package/dist/core/tests/apiClient.test.d.ts +1 -0
- package/dist/core/tests/client.test.d.ts +1 -0
- package/dist/core/tests/generics.test.d.ts +1 -0
- package/dist/core.cjs +706 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.ts +441 -0
- package/dist/core.js +681 -0
- package/dist/core.js.map +1 -0
- package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
- package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
- package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs +102 -0
- package/dist/crypto/ecies/__tests__/test-vectors.cjs.map +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.ts +38 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js +77 -0
- package/dist/crypto/ecies/__tests__/test-vectors.js.map +1 -0
- package/dist/crypto/ecies/base.cjs +232 -0
- package/dist/crypto/ecies/base.cjs.map +1 -0
- package/dist/crypto/ecies/base.d.ts +140 -0
- package/dist/crypto/ecies/base.js +208 -0
- package/dist/crypto/ecies/base.js.map +1 -0
- package/dist/crypto/ecies/browser.cjs +165 -0
- package/dist/crypto/ecies/browser.cjs.map +1 -0
- package/dist/crypto/ecies/browser.d.ts +43 -0
- package/dist/crypto/ecies/browser.js +131 -0
- package/dist/crypto/ecies/browser.js.map +1 -0
- package/dist/crypto/ecies/constants.cjs +131 -0
- package/dist/crypto/ecies/constants.cjs.map +1 -0
- package/dist/crypto/ecies/constants.d.ts +120 -0
- package/dist/crypto/ecies/constants.js +101 -0
- package/dist/crypto/ecies/constants.js.map +1 -0
- package/dist/crypto/ecies/index.cjs +35 -0
- package/dist/crypto/ecies/index.cjs.map +1 -0
- package/dist/crypto/ecies/index.d.ts +8 -0
- package/dist/crypto/ecies/index.js +13 -0
- package/dist/crypto/ecies/index.js.map +1 -0
- package/dist/crypto/ecies/interface.cjs +87 -0
- package/dist/crypto/ecies/interface.cjs.map +1 -0
- package/dist/crypto/ecies/interface.d.ts +174 -0
- package/dist/crypto/ecies/interface.js +60 -0
- package/dist/crypto/ecies/interface.js.map +1 -0
- package/dist/crypto/ecies/node.cjs +167 -0
- package/dist/crypto/ecies/node.cjs.map +1 -0
- package/dist/crypto/ecies/node.d.ts +45 -0
- package/dist/crypto/ecies/node.js +139 -0
- package/dist/crypto/ecies/node.js.map +1 -0
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +52 -0
- package/dist/crypto/ecies/utils.cjs.map +1 -0
- package/dist/crypto/ecies/utils.d.ts +30 -0
- package/dist/crypto/ecies/utils.js +26 -0
- package/dist/crypto/ecies/utils.js.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +128 -0
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +88 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js +108 -0
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -0
- package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
- package/dist/diagnostics.cjs +37 -0
- package/dist/diagnostics.cjs.map +1 -0
- package/dist/diagnostics.d.ts +24 -0
- package/dist/diagnostics.js +13 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/diagnostics.test.d.ts +1 -0
- package/dist/errors.cjs +157 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +388 -0
- package/dist/errors.js +120 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs +1313 -0
- package/dist/generated/abi/ComputeEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +995 -0
- package/dist/generated/abi/ComputeEngineImplementation.js +1289 -0
- package/dist/generated/abi/ComputeEngineImplementation.js.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs +734 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +544 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js +710 -0
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs +882 -0
- package/dist/generated/abi/DATFactoryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATFactoryImplementation.d.ts +660 -0
- package/dist/generated/abi/DATFactoryImplementation.js +858 -0
- package/dist/generated/abi/DATFactoryImplementation.js.map +1 -0
- package/dist/generated/abi/DATImplementation.cjs +934 -0
- package/dist/generated/abi/DATImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATImplementation.d.ts +692 -0
- package/dist/generated/abi/DATImplementation.js +910 -0
- package/dist/generated/abi/DATImplementation.js.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.cjs +1523 -0
- package/dist/generated/abi/DATPausableImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATPausableImplementation.d.ts +1144 -0
- package/dist/generated/abi/DATPausableImplementation.js +1499 -0
- package/dist/generated/abi/DATPausableImplementation.js.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.cjs +1460 -0
- package/dist/generated/abi/DATVotesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DATVotesImplementation.d.ts +1094 -0
- package/dist/generated/abi/DATVotesImplementation.js +1436 -0
- package/dist/generated/abi/DATVotesImplementation.js.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs +1160 -0
- package/dist/generated/abi/DLPPerformanceImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +882 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js +1136 -0
- package/dist/generated/abi/DLPPerformanceImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs +1469 -0
- package/dist/generated/abi/DLPRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +1122 -0
- package/dist/generated/abi/DLPRegistryImplementation.js +1445 -0
- package/dist/generated/abi/DLPRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +451 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs +948 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +713 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js +924 -0
- package/dist/generated/abi/DLPRewardDeployerImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +451 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs +939 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +705 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js +915 -0
- package/dist/generated/abi/DLPRewardSwapImplementation.js.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.cjs +1644 -0
- package/dist/generated/abi/DLPRootImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPRootImplementation.d.ts +1246 -0
- package/dist/generated/abi/DLPRootImplementation.js +1620 -0
- package/dist/generated/abi/DLPRootImplementation.js.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs +612 -0
- package/dist/generated/abi/DLPTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DLPTreasuryImplementation.d.ts +451 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js +588 -0
- package/dist/generated/abi/DLPTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs +985 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +735 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js +961 -0
- package/dist/generated/abi/DataLiquidityPoolImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs +888 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +660 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js +864 -0
- package/dist/generated/abi/DataPortabilityGranteesImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs +1317 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +988 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js +1293 -0
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs +1438 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +1085 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js +1414 -0
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs +984 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +736 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js +960 -0
- package/dist/generated/abi/DataRefinerRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs +1341 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -0
- package/dist/generated/abi/DataRegistryImplementation.d.ts +1013 -0
- package/dist/generated/abi/DataRegistryImplementation.js +1317 -0
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs +1319 -0
- package/dist/generated/abi/QueryEngineImplementation.cjs.map +1 -0
- package/dist/generated/abi/QueryEngineImplementation.d.ts +1000 -0
- package/dist/generated/abi/QueryEngineImplementation.js +1295 -0
- package/dist/generated/abi/QueryEngineImplementation.js.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs +1019 -0
- package/dist/generated/abi/SwapHelperImplementation.cjs.map +1 -0
- package/dist/generated/abi/SwapHelperImplementation.d.ts +763 -0
- package/dist/generated/abi/SwapHelperImplementation.js +995 -0
- package/dist/generated/abi/SwapHelperImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolImplementation.d.ts +992 -0
- package/dist/generated/abi/TeePoolImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs +936 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +700 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js +912 -0
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.js.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs +1313 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.cjs.map +1 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +992 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js +1289 -0
- package/dist/generated/abi/TeePoolPhalaImplementation.js.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs +1188 -0
- package/dist/generated/abi/VanaEpochImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaEpochImplementation.d.ts +899 -0
- package/dist/generated/abi/VanaEpochImplementation.js +1164 -0
- package/dist/generated/abi/VanaEpochImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs +1234 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +933 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js +1210 -0
- package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs +921 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +692 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js +897 -0
- package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs +538 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.cjs.map +1 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +393 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js +514 -0
- package/dist/generated/abi/VanaPoolTreasuryImplementation.js.map +1 -0
- package/dist/generated/abi/index.cjs +177 -0
- package/dist/generated/abi/index.cjs.map +1 -0
- package/dist/generated/abi/index.d.ts +26545 -0
- package/dist/generated/abi/index.js +120 -0
- package/dist/generated/abi/index.js.map +1 -0
- package/dist/generated/event-types.cjs +17 -0
- package/dist/generated/event-types.cjs.map +1 -0
- package/dist/generated/event-types.d.ts +854 -0
- package/dist/generated/event-types.js +1 -0
- package/dist/generated/event-types.js.map +1 -0
- package/dist/generated/eventRegistry.cjs +3351 -0
- package/dist/generated/eventRegistry.cjs.map +1 -0
- package/dist/generated/eventRegistry.d.ts +14 -0
- package/dist/generated/eventRegistry.js +3326 -0
- package/dist/generated/eventRegistry.js.map +1 -0
- package/dist/generated/server/server-exports.cjs +23 -0
- package/dist/generated/server/server-exports.cjs.map +1 -0
- package/dist/generated/server/server-exports.d.ts +19 -0
- package/dist/generated/server/server-exports.js +2 -0
- package/dist/generated/server/server-exports.js.map +1 -0
- package/dist/generated/server/server.cjs +17 -0
- package/dist/generated/server/server.cjs.map +1 -0
- package/dist/generated/server/server.d.ts +538 -0
- package/dist/generated/server/server.js +1 -0
- package/dist/generated/server/server.js.map +1 -0
- package/dist/generated/subgraph.cjs +675 -0
- package/dist/generated/subgraph.cjs.map +1 -0
- package/dist/generated/subgraph.d.ts +5978 -0
- package/dist/generated/subgraph.js +644 -0
- package/dist/generated/subgraph.js.map +1 -0
- package/dist/index.browser.d.ts +152 -0
- package/dist/index.browser.js +118 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.cjs +5 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.cjs +172 -0
- package/dist/index.node.cjs.map +1 -0
- package/dist/index.node.d.ts +181 -0
- package/dist/index.node.js +126 -0
- package/dist/index.node.js.map +1 -0
- package/dist/node.cjs +29 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +4 -0
- package/dist/node.js +5 -0
- package/dist/node.js.map +1 -0
- package/dist/platform/browser-only.cjs +37 -0
- package/dist/platform/browser-only.cjs.map +1 -0
- package/dist/platform/browser-only.d.ts +22 -0
- package/dist/platform/browser-only.js +12 -0
- package/dist/platform/browser-only.js.map +1 -0
- package/dist/platform/browser-only.test.d.ts +1 -0
- package/dist/platform/browser-safe.cjs +57 -0
- package/dist/platform/browser-safe.cjs.map +1 -0
- package/dist/platform/browser-safe.d.ts +29 -0
- package/dist/platform/browser-safe.js +31 -0
- package/dist/platform/browser-safe.js.map +1 -0
- package/dist/platform/browser-safe.test.d.ts +1 -0
- package/dist/platform/browser.cjs +330 -0
- package/dist/platform/browser.cjs.map +1 -0
- package/dist/platform/browser.d.ts +71 -0
- package/dist/platform/browser.js +296 -0
- package/dist/platform/browser.js.map +1 -0
- package/dist/platform/browser.test.d.ts +1 -0
- package/dist/platform/index.cjs +50 -0
- package/dist/platform/index.cjs.map +1 -0
- package/dist/platform/index.d.ts +11 -0
- package/dist/platform/index.js +27 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/interface.cjs +17 -0
- package/dist/platform/interface.cjs.map +1 -0
- package/dist/platform/interface.d.ts +216 -0
- package/dist/platform/interface.js +1 -0
- package/dist/platform/interface.js.map +1 -0
- package/dist/platform/node.cjs +351 -0
- package/dist/platform/node.cjs.map +1 -0
- package/dist/platform/node.d.ts +23 -0
- package/dist/platform/node.js +320 -0
- package/dist/platform/node.js.map +1 -0
- package/dist/platform/ports/openpgp-port.cjs +74 -0
- package/dist/platform/ports/openpgp-port.cjs.map +1 -0
- package/dist/platform/ports/openpgp-port.d.ts +13 -0
- package/dist/platform/ports/openpgp-port.js +59 -0
- package/dist/platform/ports/openpgp-port.js.map +1 -0
- package/dist/platform/ports/pgp-port.cjs +17 -0
- package/dist/platform/ports/pgp-port.cjs.map +1 -0
- package/dist/platform/ports/pgp-port.d.ts +35 -0
- package/dist/platform/ports/pgp-port.js +1 -0
- package/dist/platform/ports/pgp-port.js.map +1 -0
- package/dist/platform/shared/error-utils.cjs +43 -0
- package/dist/platform/shared/error-utils.cjs.map +1 -0
- package/dist/platform/shared/error-utils.d.ts +23 -0
- package/dist/platform/shared/error-utils.js +18 -0
- package/dist/platform/shared/error-utils.js.map +1 -0
- package/dist/platform/shared/pgp-utils.cjs +55 -0
- package/dist/platform/shared/pgp-utils.cjs.map +1 -0
- package/dist/platform/shared/pgp-utils.d.ts +59 -0
- package/dist/platform/shared/pgp-utils.js +29 -0
- package/dist/platform/shared/pgp-utils.js.map +1 -0
- package/dist/platform/shared/stream-utils.cjs +49 -0
- package/dist/platform/shared/stream-utils.cjs.map +1 -0
- package/dist/platform/shared/stream-utils.d.ts +14 -0
- package/dist/platform/shared/stream-utils.js +25 -0
- package/dist/platform/shared/stream-utils.js.map +1 -0
- package/dist/platform/utils.cjs +114 -0
- package/dist/platform/utils.cjs.map +1 -0
- package/dist/platform/utils.d.ts +49 -0
- package/dist/platform/utils.js +76 -0
- package/dist/platform/utils.js.map +1 -0
- package/dist/platform/utils.test.d.ts +1 -0
- package/dist/platform.browser.d.ts +9 -0
- package/dist/platform.browser.js +19 -0
- package/dist/platform.browser.js.map +1 -0
- package/dist/platform.cjs +50 -0
- package/dist/platform.cjs.map +1 -0
- package/dist/platform.d.ts +11 -0
- package/dist/platform.js +27 -0
- package/dist/platform.js.map +1 -0
- package/dist/platform.node.cjs +50 -0
- package/dist/platform.node.cjs.map +1 -0
- package/dist/platform.node.d.ts +10 -0
- package/dist/platform.node.js +27 -0
- package/dist/platform.node.js.map +1 -0
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/handler.cjs +101 -0
- package/dist/server/handler.cjs.map +1 -0
- package/dist/server/handler.d.ts +87 -0
- package/dist/server/handler.js +77 -0
- package/dist/server/handler.js.map +1 -0
- package/dist/storage/index.cjs +44 -0
- package/dist/storage/index.cjs.map +1 -0
- package/dist/storage/index.d.ts +56 -0
- package/dist/storage/index.js +15 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/manager.cjs +189 -0
- package/dist/storage/manager.cjs.map +1 -0
- package/dist/storage/manager.d.ts +147 -0
- package/dist/storage/manager.js +165 -0
- package/dist/storage/manager.js.map +1 -0
- package/dist/storage/providers/callback-storage.cjs +177 -0
- package/dist/storage/providers/callback-storage.cjs.map +1 -0
- package/dist/storage/providers/callback-storage.d.ts +94 -0
- package/dist/storage/providers/callback-storage.js +155 -0
- package/dist/storage/providers/callback-storage.js.map +1 -0
- package/dist/storage/providers/google-drive.cjs +516 -0
- package/dist/storage/providers/google-drive.cjs.map +1 -0
- package/dist/storage/providers/google-drive.d.ts +152 -0
- package/dist/storage/providers/google-drive.js +494 -0
- package/dist/storage/providers/google-drive.js.map +1 -0
- package/dist/storage/providers/google-drive.test.d.ts +1 -0
- package/dist/storage/providers/ipfs.cjs +283 -0
- package/dist/storage/providers/ipfs.cjs.map +1 -0
- package/dist/storage/providers/ipfs.d.ts +160 -0
- package/dist/storage/providers/ipfs.js +261 -0
- package/dist/storage/providers/ipfs.js.map +1 -0
- package/dist/storage/providers/pinata.cjs +339 -0
- package/dist/storage/providers/pinata.cjs.map +1 -0
- package/dist/storage/providers/pinata.d.ts +170 -0
- package/dist/storage/providers/pinata.js +317 -0
- package/dist/storage/providers/pinata.js.map +1 -0
- package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
- package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
- package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
- package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
- package/dist/storage/tests/storageManager.test.d.ts +1 -0
- package/dist/tests/abi.test.d.ts +1 -0
- package/dist/tests/chains-definitions.test.d.ts +1 -0
- package/dist/tests/core-encryption.test.d.ts +1 -0
- package/dist/tests/core-extended.test.d.ts +1 -0
- package/dist/tests/core-generics-coverage.test.d.ts +1 -0
- package/dist/tests/coverage-boost.test.d.ts +1 -0
- package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
- package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
- package/dist/tests/data-additional-methods.test.d.ts +1 -0
- package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
- package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
- package/dist/tests/data-relayer.test.d.ts +1 -0
- package/dist/tests/data-schema-validation.test.d.ts +1 -0
- package/dist/tests/data-simple-methods.test.d.ts +1 -0
- package/dist/tests/data.test.d.ts +1 -0
- package/dist/tests/demo-integration.test.d.ts +1 -0
- package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
- package/dist/tests/download-relayer.test.d.ts +1 -0
- package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
- package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
- package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
- package/dist/tests/encryption-coverage.test.d.ts +1 -0
- package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
- package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
- package/dist/tests/errors-coverage.test.d.ts +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/factories/mockFactory.d.ts +316 -0
- package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
- package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
- package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
- package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
- package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
- package/dist/tests/helper-methods.test.d.ts +1 -0
- package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
- package/dist/tests/helpers/typedMocks.d.ts +64 -0
- package/dist/tests/index-browser.test.d.ts +1 -0
- package/dist/tests/index-node.test.d.ts +1 -0
- package/dist/tests/index.test.d.ts +1 -0
- package/dist/tests/mocks/platformAdapter.d.ts +12 -0
- package/dist/tests/new-permissions-methods.test.d.ts +1 -0
- package/dist/tests/no-buffer-browser.test.d.ts +1 -0
- package/dist/tests/permissions-grantee.test.d.ts +1 -0
- package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
- package/dist/tests/permissions-server-files.test.d.ts +1 -0
- package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
- package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
- package/dist/tests/permissions.test.d.ts +1 -0
- package/dist/tests/personal.test.d.ts +1 -0
- package/dist/tests/platform-browser.test.d.ts +1 -0
- package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
- package/dist/tests/platform-crypto.test.d.ts +1 -0
- package/dist/tests/platform-index.test.d.ts +1 -0
- package/dist/tests/platform-node.test.d.ts +1 -0
- package/dist/tests/platform-shared-utils.test.d.ts +1 -0
- package/dist/tests/platform-updated.test.d.ts +1 -0
- package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
- package/dist/tests/protocol.test.d.ts +1 -0
- package/dist/tests/read-only-mode.test.d.ts +1 -0
- package/dist/tests/schemas.test.d.ts +1 -0
- package/dist/tests/server-handler.test.d.ts +1 -0
- package/dist/tests/setup.d.ts +7 -0
- package/dist/tests/signatureFormatter.test.d.ts +1 -0
- package/dist/tests/trusted-server-queries.test.d.ts +1 -0
- package/dist/tests/typedDataConverter.test.d.ts +1 -0
- package/dist/tests/types-contracts.test.d.ts +1 -0
- package/dist/tests/types-data.test.d.ts +1 -0
- package/dist/tests/types-external-apis.test.d.ts +1 -0
- package/dist/tests/types-generics.test.d.ts +1 -0
- package/dist/tests/types-permissions.test.d.ts +1 -0
- package/dist/tests/types-upload-params.test.d.ts +1 -0
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/tests/utils-formatters.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles.test.d.ts +1 -0
- package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
- package/dist/tests/utils-grants.test.d.ts +1 -0
- package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
- package/dist/tests/utils-ipfs.test.d.ts +4 -0
- package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
- package/dist/tests/vana.test.d.ts +1 -0
- package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
- package/dist/types/blockchain.cjs +17 -0
- package/dist/types/blockchain.cjs.map +1 -0
- package/dist/types/blockchain.d.ts +57 -0
- package/dist/types/blockchain.js +1 -0
- package/dist/types/blockchain.js.map +1 -0
- package/dist/types/chains-additional.test.d.ts +1 -0
- package/dist/types/chains.cjs +36 -0
- package/dist/types/chains.cjs.map +1 -0
- package/dist/types/chains.d.ts +31 -0
- package/dist/types/chains.js +11 -0
- package/dist/types/chains.js.map +1 -0
- package/dist/types/config.cjs +51 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.ts +833 -0
- package/dist/types/config.js +23 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/contracts.cjs +17 -0
- package/dist/types/contracts.cjs.map +1 -0
- package/dist/types/contracts.d.ts +65 -0
- package/dist/types/contracts.js +1 -0
- package/dist/types/contracts.js.map +1 -0
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.ts +64 -0
- package/dist/types/controller-context.js +1 -0
- package/dist/types/controller-context.js.map +1 -0
- package/dist/types/data.cjs +17 -0
- package/dist/types/data.cjs.map +1 -0
- package/dist/types/data.d.ts +762 -0
- package/dist/types/data.js +1 -0
- package/dist/types/data.js.map +1 -0
- package/dist/types/eccrypto-js.d.cjs +2 -0
- package/dist/types/eccrypto-js.d.cjs.map +1 -0
- package/dist/types/eccrypto-js.d.js +1 -0
- package/dist/types/eccrypto-js.d.js.map +1 -0
- package/dist/types/external-apis.cjs +61 -0
- package/dist/types/external-apis.cjs.map +1 -0
- package/dist/types/external-apis.d.ts +184 -0
- package/dist/types/external-apis.js +34 -0
- package/dist/types/external-apis.js.map +1 -0
- package/dist/types/generics.cjs +17 -0
- package/dist/types/generics.cjs.map +1 -0
- package/dist/types/generics.d.ts +447 -0
- package/dist/types/generics.js +1 -0
- package/dist/types/generics.js.map +1 -0
- package/dist/types/index.cjs +65 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.js +42 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/operations.cjs +65 -0
- package/dist/types/operations.cjs.map +1 -0
- package/dist/types/operations.d.ts +112 -0
- package/dist/types/operations.js +37 -0
- package/dist/types/operations.js.map +1 -0
- package/dist/types/permissions.cjs +17 -0
- package/dist/types/permissions.cjs.map +1 -0
- package/dist/types/permissions.d.ts +954 -0
- package/dist/types/permissions.js +1 -0
- package/dist/types/permissions.js.map +1 -0
- package/dist/types/personal.cjs +17 -0
- package/dist/types/personal.cjs.map +1 -0
- package/dist/types/personal.d.ts +38 -0
- package/dist/types/personal.js +1 -0
- package/dist/types/personal.js.map +1 -0
- package/dist/types/relayer.cjs +17 -0
- package/dist/types/relayer.cjs.map +1 -0
- package/dist/types/relayer.d.ts +281 -0
- package/dist/types/relayer.js +1 -0
- package/dist/types/relayer.js.map +1 -0
- package/dist/types/storage.cjs +39 -0
- package/dist/types/storage.cjs.map +1 -0
- package/dist/types/storage.d.ts +129 -0
- package/dist/types/storage.js +15 -0
- package/dist/types/storage.js.map +1 -0
- package/dist/types/transactionResults.cjs +17 -0
- package/dist/types/transactionResults.cjs.map +1 -0
- package/dist/types/transactionResults.d.ts +193 -0
- package/dist/types/transactionResults.js +1 -0
- package/dist/types/transactionResults.js.map +1 -0
- package/dist/types/utils.cjs +17 -0
- package/dist/types/utils.cjs.map +1 -0
- package/dist/types/utils.d.ts +820 -0
- package/dist/types/utils.js +1 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types.cjs +23 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +30 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
- package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
- package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
- package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
- package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
- package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
- package/dist/utils/blockchain/registry.cjs +81 -0
- package/dist/utils/blockchain/registry.cjs.map +1 -0
- package/dist/utils/blockchain/registry.d.ts +32 -0
- package/dist/utils/blockchain/registry.js +56 -0
- package/dist/utils/blockchain/registry.js.map +1 -0
- package/dist/utils/blockchain/registry.test.d.ts +1 -0
- package/dist/utils/crypto-utils.cjs +108 -0
- package/dist/utils/crypto-utils.cjs.map +1 -0
- package/dist/utils/crypto-utils.d.ts +100 -0
- package/dist/utils/crypto-utils.js +76 -0
- package/dist/utils/crypto-utils.js.map +1 -0
- package/dist/utils/crypto-utils.test.d.ts +1 -0
- package/dist/utils/download.cjs +69 -0
- package/dist/utils/download.cjs.map +1 -0
- package/dist/utils/download.d.ts +40 -0
- package/dist/utils/download.js +45 -0
- package/dist/utils/download.js.map +1 -0
- package/dist/utils/encoding.cjs +66 -0
- package/dist/utils/encoding.cjs.map +1 -0
- package/dist/utils/encoding.d.ts +52 -0
- package/dist/utils/encoding.js +39 -0
- package/dist/utils/encoding.js.map +1 -0
- package/dist/utils/encoding.test.d.ts +1 -0
- package/dist/utils/encryption.cjs +176 -0
- package/dist/utils/encryption.cjs.map +1 -0
- package/dist/utils/encryption.d.ts +271 -0
- package/dist/utils/encryption.js +142 -0
- package/dist/utils/encryption.js.map +1 -0
- package/dist/utils/formatters.cjs +55 -0
- package/dist/utils/formatters.cjs.map +1 -0
- package/dist/utils/formatters.d.ts +118 -0
- package/dist/utils/formatters.js +28 -0
- package/dist/utils/formatters.js.map +1 -0
- package/dist/utils/grantFiles.cjs +178 -0
- package/dist/utils/grantFiles.cjs.map +1 -0
- package/dist/utils/grantFiles.d.ts +182 -0
- package/dist/utils/grantFiles.js +140 -0
- package/dist/utils/grantFiles.js.map +1 -0
- package/dist/utils/grantValidation.cjs +243 -0
- package/dist/utils/grantValidation.cjs.map +1 -0
- package/dist/utils/grantValidation.d.ts +147 -0
- package/dist/utils/grantValidation.js +201 -0
- package/dist/utils/grantValidation.js.map +1 -0
- package/dist/utils/grants.cjs +108 -0
- package/dist/utils/grants.cjs.map +1 -0
- package/dist/utils/grants.d.ts +67 -0
- package/dist/utils/grants.js +82 -0
- package/dist/utils/grants.js.map +1 -0
- package/dist/utils/ipfs.cjs +130 -0
- package/dist/utils/ipfs.cjs.map +1 -0
- package/dist/utils/ipfs.d.ts +88 -0
- package/dist/utils/ipfs.js +99 -0
- package/dist/utils/ipfs.js.map +1 -0
- package/dist/utils/lazy-import.cjs +38 -0
- package/dist/utils/lazy-import.cjs.map +1 -0
- package/dist/utils/lazy-import.d.ts +18 -0
- package/dist/utils/lazy-import.js +14 -0
- package/dist/utils/lazy-import.js.map +1 -0
- package/dist/utils/multicall.cjs +233 -0
- package/dist/utils/multicall.cjs.map +1 -0
- package/dist/utils/multicall.d.ts +126 -0
- package/dist/utils/multicall.js +208 -0
- package/dist/utils/multicall.js.map +1 -0
- package/dist/utils/parseTransactionPojo.cjs +87 -0
- package/dist/utils/parseTransactionPojo.cjs.map +1 -0
- package/dist/utils/parseTransactionPojo.d.ts +31 -0
- package/dist/utils/parseTransactionPojo.js +63 -0
- package/dist/utils/parseTransactionPojo.js.map +1 -0
- package/dist/utils/schemaValidation.cjs +258 -0
- package/dist/utils/schemaValidation.cjs.map +1 -0
- package/dist/utils/schemaValidation.d.ts +168 -0
- package/dist/utils/schemaValidation.js +219 -0
- package/dist/utils/schemaValidation.js.map +1 -0
- package/dist/utils/signatureCache.cjs +186 -0
- package/dist/utils/signatureCache.cjs.map +1 -0
- package/dist/utils/signatureCache.d.ts +131 -0
- package/dist/utils/signatureCache.js +161 -0
- package/dist/utils/signatureCache.js.map +1 -0
- package/dist/utils/signatureFormatter.cjs +42 -0
- package/dist/utils/signatureFormatter.cjs.map +1 -0
- package/dist/utils/signatureFormatter.d.ts +36 -0
- package/dist/utils/signatureFormatter.js +18 -0
- package/dist/utils/signatureFormatter.js.map +1 -0
- package/dist/utils/tests/multicall.test.d.ts +1 -0
- package/dist/utils/transactionHelpers.cjs +54 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -0
- package/dist/utils/transactionHelpers.d.ts +80 -0
- package/dist/utils/transactionHelpers.js +29 -0
- package/dist/utils/transactionHelpers.js.map +1 -0
- package/dist/utils/typeGuards.cjs +109 -0
- package/dist/utils/typeGuards.cjs.map +1 -0
- package/dist/utils/typeGuards.d.ts +138 -0
- package/dist/utils/typeGuards.js +74 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/dist/utils/typedDataConverter.cjs +43 -0
- package/dist/utils/typedDataConverter.cjs.map +1 -0
- package/dist/utils/typedDataConverter.d.ts +10 -0
- package/dist/utils/typedDataConverter.js +19 -0
- package/dist/utils/typedDataConverter.js.map +1 -0
- package/dist/utils/urlResolver.cjs +55 -0
- package/dist/utils/urlResolver.cjs.map +1 -0
- package/dist/utils/urlResolver.d.ts +38 -0
- package/dist/utils/urlResolver.js +30 -0
- package/dist/utils/urlResolver.js.map +1 -0
- package/dist/utils/wallet.cjs +62 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +32 -0
- package/dist/utils/wallet.js +36 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/utils/withEvents.cjs +44 -0
- package/dist/utils/withEvents.cjs.map +1 -0
- package/dist/utils/withEvents.d.ts +56 -0
- package/dist/utils/withEvents.js +18 -0
- package/dist/utils/withEvents.js.map +1 -0
- package/package.json +32 -16
|
@@ -0,0 +1,126 @@
|
|
|
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 contractController_exports = {};
|
|
20
|
+
__export(contractController_exports, {
|
|
21
|
+
ContractFactory: () => ContractFactory,
|
|
22
|
+
clearContractCache: () => clearContractCache,
|
|
23
|
+
contractCacheForTesting: () => contractCacheForTesting,
|
|
24
|
+
getContractController: () => getContractController,
|
|
25
|
+
getContractInfo: () => getContractInfo
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(contractController_exports);
|
|
28
|
+
var import_viem = require("viem");
|
|
29
|
+
var import_abi = require("../generated/abi");
|
|
30
|
+
var import_addresses = require("../config/addresses");
|
|
31
|
+
var import_client = require("../core/client");
|
|
32
|
+
var import_chains = require("../config/chains");
|
|
33
|
+
const contractCache = /* @__PURE__ */ new Map();
|
|
34
|
+
const contractCacheForTesting = contractCache;
|
|
35
|
+
function createCacheKey(contract, chainId) {
|
|
36
|
+
return `${contract}:${chainId}`;
|
|
37
|
+
}
|
|
38
|
+
function getContractController(contract, client = (0, import_client.createClient)()) {
|
|
39
|
+
const chainId = client.chain?.id ?? import_chains.vanaMainnet.id;
|
|
40
|
+
const cacheKey = createCacheKey(contract, chainId);
|
|
41
|
+
let controller = contractCache.get(cacheKey);
|
|
42
|
+
if (!controller) {
|
|
43
|
+
controller = (0, import_viem.getContract)({
|
|
44
|
+
address: (0, import_addresses.getContractAddress)(chainId, contract),
|
|
45
|
+
abi: (0, import_abi.getAbi)(contract),
|
|
46
|
+
client
|
|
47
|
+
});
|
|
48
|
+
contractCache.set(cacheKey, controller);
|
|
49
|
+
}
|
|
50
|
+
return controller;
|
|
51
|
+
}
|
|
52
|
+
function getContractInfo(contract, chainId = import_chains.vanaMainnet.id) {
|
|
53
|
+
return {
|
|
54
|
+
address: (0, import_addresses.getContractAddress)(chainId, contract),
|
|
55
|
+
abi: (0, import_abi.getAbi)(contract)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
class ContractFactory {
|
|
59
|
+
client;
|
|
60
|
+
chainId;
|
|
61
|
+
constructor(client) {
|
|
62
|
+
this.client = client;
|
|
63
|
+
try {
|
|
64
|
+
this.chainId = client.chain?.id ?? import_chains.vanaMainnet.id;
|
|
65
|
+
} catch {
|
|
66
|
+
this.chainId = import_chains.vanaMainnet.id;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a typed contract instance
|
|
71
|
+
*
|
|
72
|
+
* @param contract - Contract name (use const assertion for full typing)
|
|
73
|
+
* @returns Fully typed contract instance
|
|
74
|
+
*/
|
|
75
|
+
create(contract) {
|
|
76
|
+
return getContractController(contract, this.client);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Gets contract information without creating an instance
|
|
80
|
+
*
|
|
81
|
+
* @param contract - Contract name
|
|
82
|
+
* @returns Contract information with typed ABI
|
|
83
|
+
*/
|
|
84
|
+
getInfo(contract) {
|
|
85
|
+
return getContractInfo(contract, this.chainId);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Lists all available contracts for the current chain
|
|
89
|
+
*
|
|
90
|
+
* @returns Array of contract names available on this chain
|
|
91
|
+
*/
|
|
92
|
+
getAvailableContracts() {
|
|
93
|
+
const chainAddresses = import_addresses.CONTRACT_ADDRESSES[this.chainId];
|
|
94
|
+
if (!chainAddresses) return [];
|
|
95
|
+
return Object.keys(chainAddresses);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function clearContractCache(contract, chainId) {
|
|
99
|
+
if (contract && chainId) {
|
|
100
|
+
const cacheKey = createCacheKey(contract, chainId);
|
|
101
|
+
contractCache.delete(cacheKey);
|
|
102
|
+
} else if (contract) {
|
|
103
|
+
for (const key of contractCache.keys()) {
|
|
104
|
+
if (key.startsWith(`${contract}:`)) {
|
|
105
|
+
contractCache.delete(key);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} else if (chainId) {
|
|
109
|
+
for (const key of contractCache.keys()) {
|
|
110
|
+
if (key.endsWith(`:${chainId}`)) {
|
|
111
|
+
contractCache.delete(key);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
contractCache.clear();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
ContractFactory,
|
|
121
|
+
clearContractCache,
|
|
122
|
+
contractCacheForTesting,
|
|
123
|
+
getContractController,
|
|
124
|
+
getContractInfo
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=contractController.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/contractController.ts"],"sourcesContent":["import 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 \"../config/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 * @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 */\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 with full type inference.\n * This function provides complete type safety following viem's patterns.\n *\n * @param contract - Name of the contract to instantiate (must be a const assertion for full typing)\n * @param client - Optional viem client instance\n * @returns A fully typed contract instance with methods corresponding to the contract's ABI\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 */\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 (address and ABI) without creating a contract instance.\n * Useful for cases where you need contract details but don't want to create a client connection.\n *\n * @param contract - Name of the contract\n * @param chainId - Chain ID (defaults to Vana mainnet)\n * @returns Contract information with typed ABI\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 */\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 * Type-safe contract factory that creates contract instances with full type inference.\n * This provides an alternative API that's more explicit about typing.\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAKO;AACP,iBAA6D;AAE7D,uBAAuD;AACvD,oBAA6B;AAC7B,oBAA4B;AAG5B,MAAM,gBAAgB,oBAAI,IAAwC;AAG3D,MAAM,0BAA0B;AASvC,SAAS,eAAe,UAAwB,SAAyB;AACvE,SAAO,GAAG,QAAQ,IAAI,OAAO;AAC/B;AAmBO,SAAS,sBACd,UACA,aAGsC,4BAAa,GACX;AACxC,QAAM,UAAU,OAAO,OAAO,MAAM,0BAAY;AAChD,QAAM,WAAW,eAAe,UAAU,OAAO;AAEjD,MAAI,aAAa,cAAc,IAAI,QAAQ;AAE3C,MAAI,CAAC,YAAY;AACf,qBAAa,yBAAY;AAAA,MACvB,aAAS,qCAAmB,SAAS,QAAQ;AAAA,MAC7C,SAAK,mBAAO,QAAQ;AAAA,MACpB;AAAA,IACF,CAAC;AAED,kBAAc,IAAI,UAAU,UAAU;AAAA,EACxC;AAEA,SAAO;AACT;AAgBO,SAAS,gBACd,UACA,UAAuB,0BAAY,IACJ;AAC/B,SAAO;AAAA,IACL,aAAS,qCAAmB,SAAS,QAAQ;AAAA,IAC7C,SAAK,mBAAO,QAAQ;AAAA,EACtB;AACF;AAMO,MAAM,gBAAgB;AAAA,EACV;AAAA,EAIA;AAAA,EAEjB,YACE,QACA;AACA,SAAK,SAAS;AACd,QAAI;AACF,WAAK,UAAU,OAAO,OAAO,MAAM,0BAAY;AAAA,IACjD,QAAQ;AACN,WAAK,UAAU,0BAAY;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OACE,UACwC;AACxC,WAAO,sBAAsB,UAAU,KAAK,MAAM;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAgC,UAA4C;AAC1E,WAAO,gBAAgB,UAAU,KAAK,OAAsB;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,wBAAwC;AAEtC,UAAM,iBAAiB,oCAAmB,KAAK,OAAO;AACtD,QAAI,CAAC,eAAgB,QAAO,CAAC;AAE7B,WAAO,OAAO,KAAK,cAAc;AAAA,EACnC;AACF;AAQO,SAAS,mBACd,UACA,SACM;AACN,MAAI,YAAY,SAAS;AACvB,UAAM,WAAW,eAAe,UAAU,OAAO;AACjD,kBAAc,OAAO,QAAQ;AAAA,EAC/B,WAAW,UAAU;AAEnB,eAAW,OAAO,cAAc,KAAK,GAAG;AACtC,UAAI,IAAI,WAAW,GAAG,QAAQ,GAAG,GAAG;AAClC,sBAAc,OAAO,GAAG;AAAA,MAC1B;AAAA,IACF;AAAA,EACF,WAAW,SAAS;AAElB,eAAW,OAAO,cAAc,KAAK,GAAG;AACtC,UAAI,IAAI,SAAS,IAAI,OAAO,EAAE,GAAG;AAC/B,sBAAc,OAAO,GAAG;AAAA,MAC1B;AAAA,IACF;AAAA,EACF,OAAO;AAEL,kBAAc,MAAM;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Abi } from "abitype";
|
|
2
|
+
import { type GetContractReturnType, type PublicClient, type WalletClient } from "viem";
|
|
3
|
+
import { type ContractAbis, type VanaContract } from "../generated/abi";
|
|
4
|
+
import type { VanaChainId, ContractInfo } from "../types/index";
|
|
5
|
+
import { createClient } from "../core/client";
|
|
6
|
+
export declare const contractCacheForTesting: Map<string, {
|
|
7
|
+
address: `0x${string}`;
|
|
8
|
+
abi: Abi;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Gets a typed contract instance for the specified contract name with full type inference.
|
|
12
|
+
* This function provides complete type safety following viem's patterns.
|
|
13
|
+
*
|
|
14
|
+
* @param contract - Name of the contract to instantiate (must be a const assertion for full typing)
|
|
15
|
+
* @param client - Optional viem client instance
|
|
16
|
+
* @returns A fully typed contract instance with methods corresponding to the contract's ABI
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Full type inference with const assertion
|
|
20
|
+
* const dataRegistry = getContractController("DataRegistry" as const, client);
|
|
21
|
+
*
|
|
22
|
+
* // Now dataRegistry has full type inference for all methods
|
|
23
|
+
* const result = await dataRegistry.read.getFileCount(); // Type: bigint
|
|
24
|
+
* await dataRegistry.write.addFile([url, proof]); // Typed parameters
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function getContractController<T extends VanaContract>(contract: T, client?: PublicClient | WalletClient | ReturnType<typeof createClient>): GetContractReturnType<ContractAbis[T]>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets contract information (address and ABI) without creating a contract instance.
|
|
30
|
+
* Useful for cases where you need contract details but don't want to create a client connection.
|
|
31
|
+
*
|
|
32
|
+
* @param contract - Name of the contract
|
|
33
|
+
* @param chainId - Chain ID (defaults to Vana mainnet)
|
|
34
|
+
* @returns Contract information with typed ABI
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const info = getContractInfo("DataRegistry" as const, 14800);
|
|
38
|
+
* console.log(info.address); // Typed as Address
|
|
39
|
+
* console.log(info.abi); // Fully typed ABI
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function getContractInfo<T extends VanaContract>(contract: T, chainId?: VanaChainId): ContractInfo<ContractAbis[T]>;
|
|
43
|
+
/**
|
|
44
|
+
* Type-safe contract factory that creates contract instances with full type inference.
|
|
45
|
+
* This provides an alternative API that's more explicit about typing.
|
|
46
|
+
*/
|
|
47
|
+
export declare class ContractFactory {
|
|
48
|
+
private readonly client;
|
|
49
|
+
private readonly chainId;
|
|
50
|
+
constructor(client: PublicClient | WalletClient | ReturnType<typeof createClient>);
|
|
51
|
+
/**
|
|
52
|
+
* Creates a typed contract instance
|
|
53
|
+
*
|
|
54
|
+
* @param contract - Contract name (use const assertion for full typing)
|
|
55
|
+
* @returns Fully typed contract instance
|
|
56
|
+
*/
|
|
57
|
+
create<T extends VanaContract>(contract: T): GetContractReturnType<ContractAbis[T]>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets contract information without creating an instance
|
|
60
|
+
*
|
|
61
|
+
* @param contract - Contract name
|
|
62
|
+
* @returns Contract information with typed ABI
|
|
63
|
+
*/
|
|
64
|
+
getInfo<T extends VanaContract>(contract: T): ContractInfo<ContractAbis[T]>;
|
|
65
|
+
/**
|
|
66
|
+
* Lists all available contracts for the current chain
|
|
67
|
+
*
|
|
68
|
+
* @returns Array of contract names available on this chain
|
|
69
|
+
*/
|
|
70
|
+
getAvailableContracts(): VanaContract[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Clears the contract cache. Useful for testing or when chain configurations change.
|
|
74
|
+
*
|
|
75
|
+
* @param contract - Optional specific contract to clear, or clear all if not provided
|
|
76
|
+
* @param chainId - Optional specific chain to clear, or clear all if not provided
|
|
77
|
+
*/
|
|
78
|
+
export declare function clearContractCache(contract?: VanaContract, chainId?: number): void;
|
|
79
|
+
export type { GetContractReturnType } from "viem";
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getContract
|
|
3
|
+
} from "viem";
|
|
4
|
+
import { getAbi } from "../generated/abi";
|
|
5
|
+
import { getContractAddress, CONTRACT_ADDRESSES } from "../config/addresses";
|
|
6
|
+
import { createClient } from "../core/client";
|
|
7
|
+
import { vanaMainnet } from "../config/chains";
|
|
8
|
+
const contractCache = /* @__PURE__ */ new Map();
|
|
9
|
+
const contractCacheForTesting = contractCache;
|
|
10
|
+
function createCacheKey(contract, chainId) {
|
|
11
|
+
return `${contract}:${chainId}`;
|
|
12
|
+
}
|
|
13
|
+
function getContractController(contract, client = createClient()) {
|
|
14
|
+
const chainId = client.chain?.id ?? vanaMainnet.id;
|
|
15
|
+
const cacheKey = createCacheKey(contract, chainId);
|
|
16
|
+
let controller = contractCache.get(cacheKey);
|
|
17
|
+
if (!controller) {
|
|
18
|
+
controller = getContract({
|
|
19
|
+
address: getContractAddress(chainId, contract),
|
|
20
|
+
abi: getAbi(contract),
|
|
21
|
+
client
|
|
22
|
+
});
|
|
23
|
+
contractCache.set(cacheKey, controller);
|
|
24
|
+
}
|
|
25
|
+
return controller;
|
|
26
|
+
}
|
|
27
|
+
function getContractInfo(contract, chainId = vanaMainnet.id) {
|
|
28
|
+
return {
|
|
29
|
+
address: getContractAddress(chainId, contract),
|
|
30
|
+
abi: getAbi(contract)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
class ContractFactory {
|
|
34
|
+
client;
|
|
35
|
+
chainId;
|
|
36
|
+
constructor(client) {
|
|
37
|
+
this.client = client;
|
|
38
|
+
try {
|
|
39
|
+
this.chainId = client.chain?.id ?? vanaMainnet.id;
|
|
40
|
+
} catch {
|
|
41
|
+
this.chainId = vanaMainnet.id;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a typed contract instance
|
|
46
|
+
*
|
|
47
|
+
* @param contract - Contract name (use const assertion for full typing)
|
|
48
|
+
* @returns Fully typed contract instance
|
|
49
|
+
*/
|
|
50
|
+
create(contract) {
|
|
51
|
+
return getContractController(contract, this.client);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets contract information without creating an instance
|
|
55
|
+
*
|
|
56
|
+
* @param contract - Contract name
|
|
57
|
+
* @returns Contract information with typed ABI
|
|
58
|
+
*/
|
|
59
|
+
getInfo(contract) {
|
|
60
|
+
return getContractInfo(contract, this.chainId);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Lists all available contracts for the current chain
|
|
64
|
+
*
|
|
65
|
+
* @returns Array of contract names available on this chain
|
|
66
|
+
*/
|
|
67
|
+
getAvailableContracts() {
|
|
68
|
+
const chainAddresses = CONTRACT_ADDRESSES[this.chainId];
|
|
69
|
+
if (!chainAddresses) return [];
|
|
70
|
+
return Object.keys(chainAddresses);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function clearContractCache(contract, chainId) {
|
|
74
|
+
if (contract && chainId) {
|
|
75
|
+
const cacheKey = createCacheKey(contract, chainId);
|
|
76
|
+
contractCache.delete(cacheKey);
|
|
77
|
+
} else if (contract) {
|
|
78
|
+
for (const key of contractCache.keys()) {
|
|
79
|
+
if (key.startsWith(`${contract}:`)) {
|
|
80
|
+
contractCache.delete(key);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} else if (chainId) {
|
|
84
|
+
for (const key of contractCache.keys()) {
|
|
85
|
+
if (key.endsWith(`:${chainId}`)) {
|
|
86
|
+
contractCache.delete(key);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
contractCache.clear();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
ContractFactory,
|
|
95
|
+
clearContractCache,
|
|
96
|
+
contractCacheForTesting,
|
|
97
|
+
getContractController,
|
|
98
|
+
getContractInfo
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=contractController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/contracts/contractController.ts"],"sourcesContent":["import 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 \"../config/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 * @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 */\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 with full type inference.\n * This function provides complete type safety following viem's patterns.\n *\n * @param contract - Name of the contract to instantiate (must be a const assertion for full typing)\n * @param client - Optional viem client instance\n * @returns A fully typed contract instance with methods corresponding to the contract's ABI\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 */\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 (address and ABI) without creating a contract instance.\n * Useful for cases where you need contract details but don't want to create a client connection.\n *\n * @param contract - Name of the contract\n * @param chainId - Chain ID (defaults to Vana mainnet)\n * @returns Contract information with typed ABI\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 */\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 * Type-safe contract factory that creates contract instances with full type inference.\n * This provides an alternative API that's more explicit about typing.\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":"AACA;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;AASvC,SAAS,eAAe,UAAwB,SAAyB;AACvE,SAAO,GAAG,QAAQ,IAAI,OAAO;AAC/B;AAmBO,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;AAgBO,SAAS,gBACd,UACA,UAAuB,YAAY,IACJ;AAC/B,SAAO;AAAA,IACL,SAAS,mBAAmB,SAAS,QAAQ;AAAA,IAC7C,KAAK,OAAO,QAAQ;AAAA,EACtB;AACF;AAMO,MAAM,gBAAgB;AAAA,EACV;AAAA,EAIA;AAAA,EAEjB,YACE,QACA;AACA,SAAK,SAAS;AACd,QAAI;AACF,WAAK,UAAU,OAAO,OAAO,MAAM,YAAY;AAAA,IACjD,QAAQ;AACN,WAAK,UAAU,YAAY;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OACE,UACwC;AACxC,WAAO,sBAAsB,UAAU,KAAK,MAAM;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,QAAgC,UAA4C;AAC1E,WAAO,gBAAgB,UAAU,KAAK,OAAsB;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,wBAAwC;AAEtC,UAAM,iBAAiB,mBAAmB,KAAK,OAAO;AACtD,QAAI,CAAC,eAAgB,QAAO,CAAC;AAE7B,WAAO,OAAO,KAAK,cAAc;AAAA,EACnC;AACF;AAQO,SAAS,mBACd,UACA,SACM;AACN,MAAI,YAAY,SAAS;AACvB,UAAM,WAAW,eAAe,UAAU,OAAO;AACjD,kBAAc,OAAO,QAAQ;AAAA,EAC/B,WAAW,UAAU;AAEnB,eAAW,OAAO,cAAc,KAAK,GAAG;AACtC,UAAI,IAAI,WAAW,GAAG,QAAQ,GAAG,GAAG;AAClC,sBAAc,OAAO,GAAG;AAAA,MAC1B;AAAA,IACF;AAAA,EACF,WAAW,SAAS;AAElB,eAAW,OAAO,cAAc,KAAK,GAAG;AACtC,UAAI,IAAI,SAAS,IAAI,OAAO,EAAE,GAAG;AAC/B,sBAAc,OAAO,GAAG;AAAA,MAC1B;AAAA,IACF;AAAA,EACF,OAAO;AAEL,kBAAc,MAAM;AAAA,EACtB;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
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 base_exports = {};
|
|
20
|
+
__export(base_exports, {
|
|
21
|
+
BaseController: () => BaseController
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(base_exports);
|
|
24
|
+
var import_errors = require("../errors");
|
|
25
|
+
class BaseController {
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new controller instance with the provided context.
|
|
28
|
+
*
|
|
29
|
+
* @param context - The controller context containing clients and configuration
|
|
30
|
+
*/
|
|
31
|
+
constructor(context) {
|
|
32
|
+
this.context = context;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Asserts that a wallet client with an account is available for operations requiring signing.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* This method uses TypeScript assertion signatures to narrow the type of
|
|
39
|
+
* `this.context` to guarantee that `walletClient` with an account is available
|
|
40
|
+
* after the call succeeds. This provides compile-time safety for wallet operations
|
|
41
|
+
* while enabling clear error messages for read-only scenarios.
|
|
42
|
+
*
|
|
43
|
+
* The assertion signature ensures that after calling this method,
|
|
44
|
+
* TypeScript knows that `this.context.walletClient` is definitely available
|
|
45
|
+
* with a configured account.
|
|
46
|
+
*
|
|
47
|
+
* @throws {ReadOnlyError} When no wallet client is configured
|
|
48
|
+
* @throws {Error} When wallet client exists but no account is configured
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* async performWalletOperation() {
|
|
53
|
+
* this.assertWallet(); // Type assertion + runtime check
|
|
54
|
+
*
|
|
55
|
+
* // TypeScript now knows walletClient and account are available
|
|
56
|
+
* const account = this.context.walletClient.account;
|
|
57
|
+
* const address = typeof account === 'string' ? account : account.address;
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
assertWallet() {
|
|
62
|
+
if (!this.context.walletClient) {
|
|
63
|
+
const stack = new Error().stack;
|
|
64
|
+
const callingMethod = stack?.split("\n")[2]?.match(/at \w+\.(\w+)/)?.[1] ?? "this operation";
|
|
65
|
+
throw new import_errors.ReadOnlyError(
|
|
66
|
+
callingMethod,
|
|
67
|
+
"Initialize the SDK with a walletClient to perform this operation"
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
if (!this.context.walletClient.account) {
|
|
71
|
+
const stack = new Error().stack;
|
|
72
|
+
const callingMethod = stack?.split("\n")[2]?.match(/at \w+\.(\w+)/)?.[1] ?? "this operation";
|
|
73
|
+
throw new Error(
|
|
74
|
+
`No wallet account connected. Cannot perform ${callingMethod} without an account.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
BaseController
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=base.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,oBAA8B;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BlD,eAER;AACA,QAAI,CAAC,KAAK,QAAQ,cAAc;AAE9B,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,QAAQ,aAAa,SAAS;AAEtC,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR,+CAA+C,aAAa;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base controller class providing common functionality for all controllers.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This abstract class establishes the foundation for all Vana SDK controllers,
|
|
6
|
+
* providing shared utilities like wallet validation and context management.
|
|
7
|
+
* All controllers should extend this base class to ensure consistency and
|
|
8
|
+
* shared behavior across the SDK.
|
|
9
|
+
*
|
|
10
|
+
* The class follows the Single Responsibility Principle by handling only
|
|
11
|
+
* the core controller concerns while leaving specific functionality to
|
|
12
|
+
* implementing classes.
|
|
13
|
+
*
|
|
14
|
+
* @category Controllers
|
|
15
|
+
*/
|
|
16
|
+
import type { WalletClient } from "viem";
|
|
17
|
+
import type { ControllerContext } from "../types/controller-context";
|
|
18
|
+
/**
|
|
19
|
+
* Abstract base controller that all Vana SDK controllers extend.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* Provides common functionality and patterns used across all controllers,
|
|
23
|
+
* including wallet validation and context management. This ensures
|
|
24
|
+
* consistency and reduces code duplication throughout the SDK.
|
|
25
|
+
*
|
|
26
|
+
* Key features:
|
|
27
|
+
* - Wallet client validation with TypeScript assertion signatures
|
|
28
|
+
* - Consistent error handling for read-only scenarios
|
|
29
|
+
* - Shared context management patterns
|
|
30
|
+
* - Type-safe wallet operations
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* class MyController extends BaseController {
|
|
35
|
+
* async performWalletOperation() {
|
|
36
|
+
* this.assertWallet(); // Ensures wallet is available
|
|
37
|
+
* // Now this.context.walletClient is guaranteed to be available
|
|
38
|
+
* const address = await this.context.walletClient.getAddresses();
|
|
39
|
+
* return address[0];
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare abstract class BaseController {
|
|
45
|
+
protected readonly context: ControllerContext;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new controller instance with the provided context.
|
|
48
|
+
*
|
|
49
|
+
* @param context - The controller context containing clients and configuration
|
|
50
|
+
*/
|
|
51
|
+
constructor(context: ControllerContext);
|
|
52
|
+
/**
|
|
53
|
+
* Asserts that a wallet client with an account is available for operations requiring signing.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* This method uses TypeScript assertion signatures to narrow the type of
|
|
57
|
+
* `this.context` to guarantee that `walletClient` with an account is available
|
|
58
|
+
* after the call succeeds. This provides compile-time safety for wallet operations
|
|
59
|
+
* while enabling clear error messages for read-only scenarios.
|
|
60
|
+
*
|
|
61
|
+
* The assertion signature ensures that after calling this method,
|
|
62
|
+
* TypeScript knows that `this.context.walletClient` is definitely available
|
|
63
|
+
* with a configured account.
|
|
64
|
+
*
|
|
65
|
+
* @throws {ReadOnlyError} When no wallet client is configured
|
|
66
|
+
* @throws {Error} When wallet client exists but no account is configured
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* async performWalletOperation() {
|
|
71
|
+
* this.assertWallet(); // Type assertion + runtime check
|
|
72
|
+
*
|
|
73
|
+
* // TypeScript now knows walletClient and account are available
|
|
74
|
+
* const account = this.context.walletClient.account;
|
|
75
|
+
* const address = typeof account === 'string' ? account : account.address;
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
protected assertWallet(): asserts this is {
|
|
80
|
+
context: ControllerContext & {
|
|
81
|
+
walletClient: WalletClient;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ReadOnlyError } from "../errors";
|
|
2
|
+
class BaseController {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new controller instance with the provided context.
|
|
5
|
+
*
|
|
6
|
+
* @param context - The controller context containing clients and configuration
|
|
7
|
+
*/
|
|
8
|
+
constructor(context) {
|
|
9
|
+
this.context = context;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Asserts that a wallet client with an account is available for operations requiring signing.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This method uses TypeScript assertion signatures to narrow the type of
|
|
16
|
+
* `this.context` to guarantee that `walletClient` with an account is available
|
|
17
|
+
* after the call succeeds. This provides compile-time safety for wallet operations
|
|
18
|
+
* while enabling clear error messages for read-only scenarios.
|
|
19
|
+
*
|
|
20
|
+
* The assertion signature ensures that after calling this method,
|
|
21
|
+
* TypeScript knows that `this.context.walletClient` is definitely available
|
|
22
|
+
* with a configured account.
|
|
23
|
+
*
|
|
24
|
+
* @throws {ReadOnlyError} When no wallet client is configured
|
|
25
|
+
* @throws {Error} When wallet client exists but no account is configured
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* async performWalletOperation() {
|
|
30
|
+
* this.assertWallet(); // Type assertion + runtime check
|
|
31
|
+
*
|
|
32
|
+
* // TypeScript now knows walletClient and account are available
|
|
33
|
+
* const account = this.context.walletClient.account;
|
|
34
|
+
* const address = typeof account === 'string' ? account : account.address;
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
assertWallet() {
|
|
39
|
+
if (!this.context.walletClient) {
|
|
40
|
+
const stack = new Error().stack;
|
|
41
|
+
const callingMethod = stack?.split("\n")[2]?.match(/at \w+\.(\w+)/)?.[1] ?? "this operation";
|
|
42
|
+
throw new ReadOnlyError(
|
|
43
|
+
callingMethod,
|
|
44
|
+
"Initialize the SDK with a walletClient to perform this operation"
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (!this.context.walletClient.account) {
|
|
48
|
+
const stack = new Error().stack;
|
|
49
|
+
const callingMethod = stack?.split("\n")[2]?.match(/at \w+\.(\w+)/)?.[1] ?? "this operation";
|
|
50
|
+
throw new Error(
|
|
51
|
+
`No wallet account connected. Cannot perform ${callingMethod} without an account.`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
BaseController
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n}\n"],"mappings":"AAkBA,SAAS,qBAAqB;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BlD,eAER;AACA,QAAI,CAAC,KAAK,QAAQ,cAAc;AAE9B,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,QAAQ,aAAa,SAAS;AAEtC,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR,+CAA+C,aAAa;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|