@opendatalabs/vana-sdk 0.1.0-alpha.d7fc764 → 0.1.0-alpha.dba79a3
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.map +1 -1
- package/dist/browser.d.ts +36 -2
- 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 +9 -11
- 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 +34 -2
- package/dist/chains/index.js.map +1 -1
- package/dist/chains.browser.d.ts +8 -2
- package/dist/chains.d.ts +8 -2
- package/dist/chains.node.d.ts +8 -2
- package/dist/config/addresses.d.ts +8 -24
- package/dist/config/chains.cjs.map +1 -1
- package/dist/config/chains.d.ts +108 -13
- package/dist/config/chains.js.map +1 -1
- 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.d.ts +1 -3
- package/dist/config/tests/addresses.test.d.ts +1 -0
- package/dist/contracts/contractController.cjs +3 -3
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +77 -38
- package/dist/contracts/contractController.js +4 -7
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/contracts/tests/contractController.test.d.ts +1 -0
- 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/__tests__/schemas-edge-cases.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-error-handling.test.d.ts +1 -0
- package/dist/controllers/data.cjs +827 -439
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +373 -254
- package/dist/controllers/data.js +840 -442
- 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 +929 -483
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +1318 -25
- package/dist/controllers/permissions.js +929 -483
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs +15 -11
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +34 -63
- package/dist/controllers/protocol.js +15 -14
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +100 -75
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +56 -74
- package/dist/controllers/schemas.js +100 -75
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server-additional.test.d.ts +1 -0
- package/dist/controllers/server.cjs +32 -25
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +53 -71
- package/dist/controllers/server.js +32 -25
- 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 +68 -15
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +137 -16
- package/dist/core/apiClient.js +72 -22
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/client.cjs +7 -7
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +6 -9
- package/dist/core/client.js +7 -7
- package/dist/core/client.js.map +1 -1
- package/dist/core/core.test.d.ts +1 -0
- package/dist/core/generics.cjs +41 -12
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +104 -19
- package/dist/core/generics.js +52 -32
- 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/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 +152 -61
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +50 -67
- package/dist/core.js +164 -86
- package/dist/core.js.map +1 -1
- 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.d.ts +2 -4
- package/dist/crypto/ecies/base.cjs +20 -6
- package/dist/crypto/ecies/base.cjs.map +1 -1
- package/dist/crypto/ecies/base.d.ts +2 -5
- package/dist/crypto/ecies/base.js +28 -18
- package/dist/crypto/ecies/base.js.map +1 -1
- package/dist/crypto/ecies/browser.cjs +2 -1
- package/dist/crypto/ecies/browser.cjs.map +1 -1
- package/dist/crypto/ecies/browser.d.ts +2 -7
- package/dist/crypto/ecies/browser.js +2 -1
- package/dist/crypto/ecies/browser.js.map +1 -1
- package/dist/crypto/ecies/constants.d.ts +7 -9
- package/dist/crypto/ecies/index.d.ts +8 -1
- package/dist/crypto/ecies/interface.cjs +4 -5
- package/dist/crypto/ecies/interface.cjs.map +1 -1
- package/dist/crypto/ecies/interface.d.ts +9 -11
- package/dist/crypto/ecies/interface.js +4 -5
- package/dist/crypto/ecies/interface.js.map +1 -1
- package/dist/crypto/ecies/node.cjs +3 -2
- package/dist/crypto/ecies/node.cjs.map +1 -1
- package/dist/crypto/ecies/node.d.ts +2 -7
- package/dist/crypto/ecies/node.js +11 -16
- package/dist/crypto/ecies/node.js.map +1 -1
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +2 -41
- package/dist/crypto/ecies/utils.cjs.map +1 -1
- package/dist/crypto/ecies/utils.d.ts +3 -40
- package/dist/crypto/ecies/utils.js +1 -35
- package/dist/crypto/ecies/utils.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
- package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
- package/dist/diagnostics.d.ts +1 -3
- package/dist/diagnostics.test.d.ts +1 -0
- package/dist/errors.cjs +45 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +117 -15
- package/dist/errors.js +46 -6
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DATFactoryImplementation.d.ts +2 -3
- package/dist/generated/abi/DATImplementation.d.ts +2 -3
- package/dist/generated/abi/DATPausableImplementation.d.ts +2 -3
- package/dist/generated/abi/DATVotesImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRootImplementation.d.ts +1 -3
- package/dist/generated/abi/DLPTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +1 -3
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +2 -3
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DataRegistryImplementation.cjs +13 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataRegistryImplementation.d.ts +12 -3
- package/dist/generated/abi/DataRegistryImplementation.js +13 -0
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/QueryEngineImplementation.d.ts +2 -3
- package/dist/generated/abi/SwapHelperImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaEpochImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/index.cjs +42 -0
- package/dist/generated/abi/index.cjs.map +1 -1
- package/dist/generated/abi/index.d.ts +47 -18
- package/dist/generated/abi/index.js +21 -0
- package/dist/generated/abi/index.js.map +1 -1
- 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.d.ts +19 -21
- package/dist/generated/server/server.cjs.map +1 -1
- package/dist/generated/server/server.d.ts +113 -87
- package/dist/generated/subgraph.cjs +797 -32
- package/dist/generated/subgraph.cjs.map +1 -1
- package/dist/generated/subgraph.d.ts +464 -332
- package/dist/generated/subgraph.js +792 -32
- package/dist/generated/subgraph.js.map +1 -1
- package/dist/index.browser.d.ts +49 -73
- package/dist/index.browser.js +14 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +31 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +223 -64
- package/dist/index.node.js +28 -2
- 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 +42 -2
- package/dist/node.js.map +1 -1
- package/dist/platform/browser-only.d.ts +5 -8
- package/dist/platform/browser-only.test.d.ts +1 -0
- package/dist/platform/browser-safe.d.ts +6 -9
- package/dist/platform/browser-safe.test.d.ts +1 -0
- package/dist/platform/browser.cjs +167 -8
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +235 -18
- package/dist/platform/browser.js +179 -29
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/browser.test.d.ts +1 -0
- package/dist/platform/index.d.ts +11 -5
- package/dist/platform/interface.cjs.map +1 -1
- package/dist/platform/interface.d.ts +289 -98
- package/dist/platform/node.cjs +163 -2
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +72 -13
- package/dist/platform/node.js +175 -21
- package/dist/platform/node.js.map +1 -1
- 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.d.ts +2 -4
- package/dist/platform/shared/pgp-utils.cjs +2 -2
- package/dist/platform/shared/pgp-utils.cjs.map +1 -1
- package/dist/platform/shared/pgp-utils.d.ts +3 -5
- package/dist/platform/shared/pgp-utils.js +2 -2
- package/dist/platform/shared/pgp-utils.js.map +1 -1
- package/dist/platform/shared/stream-utils.d.ts +1 -3
- package/dist/platform/utils.d.ts +6 -10
- package/dist/platform/utils.test.d.ts +1 -0
- package/dist/platform.browser.d.ts +9 -4
- package/dist/platform.d.ts +11 -5
- package/dist/platform.node.d.ts +10 -5
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/relayerHandler.cjs +420 -0
- package/dist/server/relayerHandler.cjs.map +1 -0
- package/dist/server/relayerHandler.d.ts +69 -0
- package/dist/server/relayerHandler.js +396 -0
- package/dist/server/relayerHandler.js.map +1 -0
- package/dist/storage/index.d.ts +56 -10
- package/dist/storage/manager.cjs +114 -31
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +121 -30
- package/dist/storage/manager.js +113 -37
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +89 -18
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +111 -28
- package/dist/storage/providers/callback-storage.js +89 -18
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/google-drive.cjs +2 -2
- package/dist/storage/providers/google-drive.cjs.map +1 -1
- package/dist/storage/providers/google-drive.d.ts +3 -7
- package/dist/storage/providers/google-drive.js +4 -7
- package/dist/storage/providers/google-drive.js.map +1 -1
- package/dist/storage/providers/google-drive.test.d.ts +1 -0
- package/dist/storage/providers/ipfs.cjs +5 -5
- package/dist/storage/providers/ipfs.cjs.map +1 -1
- package/dist/storage/providers/ipfs.d.ts +3 -6
- package/dist/storage/providers/ipfs.js +7 -10
- package/dist/storage/providers/ipfs.js.map +1 -1
- package/dist/storage/providers/pinata.cjs +6 -6
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +17 -22
- package/dist/storage/providers/pinata.js +8 -11
- package/dist/storage/providers/pinata.js.map +1 -1
- 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-revoke-relayer.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/relayer-integration.test.d.ts +1 -0
- package/dist/tests/relayer-unified.test.d.ts +1 -0
- package/dist/tests/schemas.test.d.ts +1 -0
- package/dist/tests/server-relayer-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/{chains.browser.cjs → types/atomicStore.cjs} +9 -15
- 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 +17 -0
- package/dist/types/blockchain.cjs.map +1 -0
- package/dist/types/blockchain.d.ts +85 -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.map +1 -1
- package/dist/types/chains.d.ts +80 -16
- 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 +236 -242
- 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 +79 -18
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.ts +68 -0
- package/dist/types/controller-context.js +1 -0
- package/dist/types/controller-context.js.map +1 -0
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +118 -49
- package/dist/types/external-apis.d.ts +10 -12
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +116 -48
- package/dist/types/index.cjs +5 -4
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +48 -34
- package/dist/types/index.js +9 -2
- 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 +2 -2
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +164 -42
- package/dist/types/operations.js +2 -2
- 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 +72 -78
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +137 -22
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +293 -50
- package/dist/types/storage.cjs.map +1 -1
- package/dist/types/storage.d.ts +15 -29
- package/dist/types/storage.js +2 -5
- package/dist/types/storage.js.map +1 -1
- package/dist/types/transactionResults.cjs.map +1 -1
- package/dist/types/transactionResults.d.ts +193 -25
- package/dist/types/utils.cjs.map +1 -1
- package/dist/types/utils.d.ts +20 -68
- package/dist/types.d.ts +4 -40
- 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__/subgraphConsistency.test.d.ts +4 -0
- package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -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 +2 -2
- package/dist/utils/blockchain/registry.cjs.map +1 -1
- package/dist/utils/blockchain/registry.d.ts +6 -8
- package/dist/utils/blockchain/registry.js +2 -2
- package/dist/utils/blockchain/registry.js.map +1 -1
- package/dist/utils/blockchain/registry.test.d.ts +1 -0
- 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/crypto-utils.cjs +0 -12
- package/dist/utils/crypto-utils.cjs.map +1 -1
- package/dist/utils/crypto-utils.d.ts +9 -27
- package/dist/utils/crypto-utils.js +0 -11
- package/dist/utils/crypto-utils.js.map +1 -1
- package/dist/utils/crypto-utils.test.d.ts +1 -0
- package/dist/utils/download.cjs +3 -3
- package/dist/utils/download.cjs.map +1 -1
- package/dist/utils/download.d.ts +13 -14
- package/dist/utils/download.js +2 -2
- package/dist/utils/download.js.map +1 -1
- package/dist/utils/encoding.cjs +1 -1
- package/dist/utils/encoding.cjs.map +1 -1
- package/dist/utils/encoding.d.ts +4 -6
- package/dist/utils/encoding.js +1 -1
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/encoding.test.d.ts +1 -0
- package/dist/utils/encryption.cjs +16 -10
- package/dist/utils/encryption.cjs.map +1 -1
- package/dist/utils/encryption.d.ts +13 -17
- package/dist/utils/encryption.js +16 -10
- package/dist/utils/encryption.js.map +1 -1
- package/dist/utils/formatters.cjs +4 -2
- package/dist/utils/formatters.cjs.map +1 -1
- package/dist/utils/formatters.d.ts +4 -6
- package/dist/utils/formatters.js +4 -2
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/grantFiles.cjs +7 -4
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +16 -30
- package/dist/utils/grantFiles.js +7 -4
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +109 -33
- package/dist/utils/grantValidation.js +1 -1
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +101 -23
- package/dist/utils/grants.js +1 -1
- 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 +8 -10
- package/dist/utils/ipfs.js +2 -4
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/lazy-import.cjs +4 -6
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +33 -10
- package/dist/utils/lazy-import.js +4 -6
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/multicall.cjs +4 -2
- package/dist/utils/multicall.cjs.map +1 -1
- package/dist/utils/multicall.d.ts +5 -8
- package/dist/utils/multicall.js +4 -2
- package/dist/utils/multicall.js.map +1 -1
- 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 +5 -5
- package/dist/utils/schemaValidation.cjs.map +1 -1
- package/dist/utils/schemaValidation.d.ts +8 -12
- package/dist/utils/schemaValidation.js +7 -10
- package/dist/utils/schemaValidation.js.map +1 -1
- package/dist/utils/signatureCache.cjs +9 -4
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +53 -15
- package/dist/utils/signatureCache.js +12 -10
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/signatureFormatter.cjs +6 -9
- package/dist/utils/signatureFormatter.cjs.map +1 -1
- package/dist/utils/signatureFormatter.d.ts +2 -5
- package/dist/utils/signatureFormatter.js +6 -9
- package/dist/utils/signatureFormatter.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/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.map +1 -1
- package/dist/utils/typedDataConverter.d.ts +42 -9
- package/dist/utils/typedDataConverter.js.map +1 -1
- package/dist/utils/urlResolver.cjs +8 -1
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +24 -8
- package/dist/utils/urlResolver.js +9 -2
- 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/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 +25 -13
- package/dist/browser.d.cts +0 -2
- package/dist/chains/definitions.d.cts +0 -53
- package/dist/chains/index.d.cts +0 -2
- package/dist/chains.browser.cjs.map +0 -1
- package/dist/chains.browser.d.cts +0 -2
- package/dist/chains.d.cts +0 -2
- package/dist/chains.node.d.cts +0 -2
- package/dist/config/addresses.d.cts +0 -380
- package/dist/config/chains.d.cts +0 -85
- package/dist/config/eventMappings.cjs +0 -114
- package/dist/config/eventMappings.cjs.map +0 -1
- package/dist/config/eventMappings.d.cts +0 -108
- package/dist/config/eventMappings.d.ts +0 -108
- package/dist/config/eventMappings.js +0 -90
- package/dist/config/eventMappings.js.map +0 -1
- package/dist/config/features.d.cts +0 -64
- package/dist/contracts/contractController.d.cts +0 -96
- package/dist/controllers/data.d.cts +0 -941
- package/dist/controllers/permissions.d.cts +0 -25
- package/dist/controllers/protocol.d.cts +0 -167
- package/dist/controllers/schemas.d.cts +0 -272
- package/dist/controllers/server.d.cts +0 -243
- package/dist/core/apiClient.d.cts +0 -165
- package/dist/core/client.d.cts +0 -92
- package/dist/core/generics.d.cts +0 -120
- package/dist/core.d.cts +0 -466
- package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
- package/dist/crypto/ecies/base.d.cts +0 -143
- package/dist/crypto/ecies/browser.d.cts +0 -48
- package/dist/crypto/ecies/constants.d.cts +0 -122
- package/dist/crypto/ecies/index.d.cts +0 -1
- package/dist/crypto/ecies/interface.d.cts +0 -176
- package/dist/crypto/ecies/node.d.cts +0 -50
- package/dist/crypto/ecies/utils.d.cts +0 -67
- package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
- package/dist/diagnostics.d.cts +0 -26
- package/dist/errors.d.cts +0 -350
- package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
- package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
- package/dist/generated/abi/DATImplementation.d.cts +0 -693
- package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
- package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
- package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
- package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
- package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
- package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
- package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
- package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1004
- package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
- package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
- package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
- package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
- package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
- package/dist/generated/abi/index.d.cts +0 -26516
- package/dist/generated/server/server-exports.d.cts +0 -21
- package/dist/generated/server/server.d.cts +0 -512
- package/dist/generated/subgraph.d.cts +0 -5981
- package/dist/index.browser.cjs +0 -151
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.cts +0 -177
- package/dist/index.d.cts +0 -2
- package/dist/index.node.d.cts +0 -64
- package/dist/node.d.cts +0 -2
- package/dist/permissions-DNKPu_G0.d.cts +0 -1666
- package/dist/permissions-eo8YeLGf.d.ts +0 -1666
- package/dist/platform/browser-only.d.cts +0 -25
- package/dist/platform/browser-safe.d.cts +0 -32
- package/dist/platform/browser.d.cts +0 -74
- package/dist/platform/index.d.cts +0 -5
- package/dist/platform/interface.d.cts +0 -218
- package/dist/platform/node.d.cts +0 -27
- package/dist/platform/shared/error-utils.d.cts +0 -25
- package/dist/platform/shared/pgp-utils.d.cts +0 -61
- package/dist/platform/shared/stream-utils.d.cts +0 -16
- package/dist/platform/utils.d.cts +0 -53
- package/dist/platform.browser.cjs +0 -41
- package/dist/platform.browser.cjs.map +0 -1
- package/dist/platform.browser.d.cts +0 -4
- package/dist/platform.d.cts +0 -5
- package/dist/platform.node.d.cts +0 -5
- package/dist/server/handler.cjs +0 -101
- package/dist/server/handler.cjs.map +0 -1
- package/dist/server/handler.d.cts +0 -282
- package/dist/server/handler.d.ts +0 -282
- package/dist/server/handler.js +0 -77
- package/dist/server/handler.js.map +0 -1
- package/dist/storage/index.d.cts +0 -10
- package/dist/storage/manager.d.cts +0 -150
- package/dist/storage/providers/callback-storage.d.cts +0 -100
- package/dist/storage/providers/google-drive.d.cts +0 -156
- package/dist/storage/providers/ipfs.d.cts +0 -163
- package/dist/storage/providers/pinata.d.cts +0 -173
- package/dist/types/chains.d.cts +0 -34
- package/dist/types/config.d.cts +0 -726
- package/dist/types/contracts.d.cts +0 -68
- package/dist/types/data.d.cts +0 -694
- package/dist/types/eccrypto-js.d.d.cts +0 -13
- package/dist/types/eccrypto-js.d.d.ts +0 -13
- package/dist/types/external-apis.d.cts +0 -186
- package/dist/types/generics.d.cts +0 -450
- package/dist/types/index.d.cts +0 -34
- package/dist/types/operations.d.cts +0 -108
- package/dist/types/permissions.d.cts +0 -957
- package/dist/types/personal.d.cts +0 -40
- package/dist/types/relayer.d.cts +0 -284
- package/dist/types/storage.d.cts +0 -131
- package/dist/types/transactionResults.d.cts +0 -25
- package/dist/types/utils.d.cts +0 -819
- package/dist/types.d.cts +0 -66
- package/dist/utils/blockchain/registry.d.cts +0 -34
- package/dist/utils/crypto-utils.d.cts +0 -118
- package/dist/utils/download.d.cts +0 -41
- package/dist/utils/encoding.d.cts +0 -54
- package/dist/utils/encryption.d.cts +0 -275
- package/dist/utils/eventParsing.cjs +0 -111
- package/dist/utils/eventParsing.cjs.map +0 -1
- package/dist/utils/eventParsing.d.cts +0 -60
- package/dist/utils/eventParsing.d.ts +0 -60
- package/dist/utils/eventParsing.js +0 -86
- package/dist/utils/eventParsing.js.map +0 -1
- package/dist/utils/formatters.d.cts +0 -120
- package/dist/utils/grantFiles.d.cts +0 -186
- package/dist/utils/grantValidation.d.cts +0 -150
- package/dist/utils/grants.d.cts +0 -70
- package/dist/utils/ipfs.d.cts +0 -90
- package/dist/utils/lazy-import.d.cts +0 -20
- package/dist/utils/multicall.d.cts +0 -129
- package/dist/utils/schemaValidation.d.cts +0 -172
- package/dist/utils/signatureCache.d.cts +0 -134
- package/dist/utils/signatureFormatter.d.cts +0 -39
- package/dist/utils/transactionParsing.cjs +0 -84
- package/dist/utils/transactionParsing.cjs.map +0 -1
- package/dist/utils/transactionParsing.d.cts +0 -25
- package/dist/utils/transactionParsing.d.ts +0 -25
- package/dist/utils/transactionParsing.js +0 -62
- package/dist/utils/transactionParsing.js.map +0 -1
- package/dist/utils/typedDataConverter.d.cts +0 -13
- package/dist/utils/urlResolver.d.cts +0 -40
|
@@ -32,18 +32,24 @@ __export(data_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(data_exports);
|
|
34
34
|
var import_viem = require("viem");
|
|
35
|
+
var import_pollingManager = require("../core/pollingManager");
|
|
36
|
+
var import_base = require("./base");
|
|
35
37
|
var import_addresses = require("../config/addresses");
|
|
36
38
|
var import_abi = require("../generated/abi");
|
|
37
39
|
var import_subgraph = require("../generated/subgraph");
|
|
38
40
|
var import_graphql = require("graphql");
|
|
41
|
+
var import_subgraphConsistency = require("../utils/subgraphConsistency");
|
|
42
|
+
var import_subgraphPagination = require("../utils/subgraphPagination");
|
|
43
|
+
var import_chainQuery = require("../utils/chainQuery");
|
|
39
44
|
var import_encryption = require("../utils/encryption");
|
|
40
45
|
var import_schemaValidation = require("../utils/schemaValidation");
|
|
41
46
|
var import_multicall = require("../utils/multicall");
|
|
42
|
-
class DataController {
|
|
47
|
+
class DataController extends import_base.BaseController {
|
|
43
48
|
constructor(context) {
|
|
44
|
-
|
|
49
|
+
super(context);
|
|
45
50
|
}
|
|
46
51
|
async upload(params) {
|
|
52
|
+
this.assertWallet();
|
|
47
53
|
const {
|
|
48
54
|
content,
|
|
49
55
|
filename,
|
|
@@ -51,12 +57,13 @@ class DataController {
|
|
|
51
57
|
permissions = [],
|
|
52
58
|
encrypt = true,
|
|
53
59
|
providerName,
|
|
54
|
-
owner
|
|
60
|
+
owner,
|
|
61
|
+
schemaValidation = "strict"
|
|
55
62
|
} = params;
|
|
56
63
|
try {
|
|
57
64
|
let isValid = true;
|
|
58
65
|
let validationErrors = [];
|
|
59
|
-
if (schemaId !== void 0) {
|
|
66
|
+
if (schemaId !== void 0 && schemaValidation !== "skip") {
|
|
60
67
|
try {
|
|
61
68
|
const { SchemaController } = await import("./schemas");
|
|
62
69
|
const schemaController = new SchemaController(this.context);
|
|
@@ -68,15 +75,33 @@ class DataController {
|
|
|
68
75
|
} catch {
|
|
69
76
|
parsedContent = content;
|
|
70
77
|
}
|
|
78
|
+
} else if (content instanceof Blob) {
|
|
79
|
+
const text = await content.text();
|
|
80
|
+
try {
|
|
81
|
+
parsedContent = JSON.parse(text);
|
|
82
|
+
} catch {
|
|
83
|
+
parsedContent = text;
|
|
84
|
+
}
|
|
71
85
|
} else {
|
|
72
86
|
parsedContent = content;
|
|
73
87
|
}
|
|
74
88
|
(0, import_schemaValidation.validateDataAgainstSchema)(parsedContent, schema);
|
|
75
89
|
} catch (error) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
if (schemaValidation === "strict") {
|
|
91
|
+
throw error;
|
|
92
|
+
} else if (schemaValidation === "warn") {
|
|
93
|
+
console.warn(
|
|
94
|
+
'[Vana SDK] Schema validation failed, but continuing due to validation mode "warn"'
|
|
95
|
+
);
|
|
96
|
+
if (error instanceof Error) {
|
|
97
|
+
console.warn(" Validation error:", error.message);
|
|
98
|
+
if (typeof error === "object" && "errors" in error && Array.isArray(error.errors)) {
|
|
99
|
+
console.warn(" Detailed errors:", error.errors);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
isValid = false;
|
|
103
|
+
validationErrors = error instanceof Error ? [error.message] : ["Schema validation failed"];
|
|
104
|
+
}
|
|
80
105
|
}
|
|
81
106
|
}
|
|
82
107
|
const uploadResult = await this.uploadToStorage(
|
|
@@ -85,9 +110,10 @@ class DataController {
|
|
|
85
110
|
encrypt,
|
|
86
111
|
providerName
|
|
87
112
|
);
|
|
88
|
-
const userAddress = owner
|
|
113
|
+
const userAddress = owner ?? this.context.userAddress;
|
|
89
114
|
let encryptedPermissions = [];
|
|
90
115
|
if (permissions.length > 0 && encrypt) {
|
|
116
|
+
this.assertWallet();
|
|
91
117
|
const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
92
118
|
this.context.walletClient,
|
|
93
119
|
this.context.platform,
|
|
@@ -108,34 +134,54 @@ class DataController {
|
|
|
108
134
|
);
|
|
109
135
|
}
|
|
110
136
|
let result;
|
|
111
|
-
if (this.context.
|
|
112
|
-
|
|
113
|
-
|
|
137
|
+
if (this.context.relayer) {
|
|
138
|
+
const request = {
|
|
139
|
+
type: "direct",
|
|
140
|
+
operation: "submitFileAdditionComplete",
|
|
141
|
+
params: {
|
|
114
142
|
url: uploadResult.url,
|
|
115
143
|
userAddress,
|
|
116
144
|
permissions: encryptedPermissions,
|
|
117
|
-
schemaId: schemaId
|
|
145
|
+
schemaId: schemaId ?? 0,
|
|
118
146
|
ownerAddress: owner
|
|
119
147
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
148
|
+
};
|
|
149
|
+
const response = await this.context.relayer(request);
|
|
150
|
+
if (response.type === "error") {
|
|
151
|
+
throw new Error(response.error);
|
|
152
|
+
}
|
|
153
|
+
if (response.type === "pending") {
|
|
154
|
+
result = await this.pollRelayerForConfirmation(
|
|
155
|
+
response.operationId,
|
|
156
|
+
void 0
|
|
157
|
+
// TODO: Add TransactionOptions to upload method signature
|
|
126
158
|
);
|
|
159
|
+
} else if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "fileId" in response.result) {
|
|
160
|
+
result = response.result;
|
|
161
|
+
} else {
|
|
162
|
+
throw new Error("Invalid response from relayer");
|
|
127
163
|
}
|
|
128
|
-
result = await this.context.relayerCallbacks.submitFileAddition(
|
|
129
|
-
uploadResult.url,
|
|
130
|
-
userAddress
|
|
131
|
-
);
|
|
132
164
|
} else {
|
|
133
|
-
|
|
165
|
+
const txResult = await this.addFileWithEncryptedPermissionsAndSchema(
|
|
134
166
|
uploadResult.url,
|
|
135
167
|
userAddress,
|
|
136
168
|
encryptedPermissions,
|
|
137
|
-
schemaId
|
|
169
|
+
schemaId ?? 0
|
|
138
170
|
);
|
|
171
|
+
if (!this.context.waitForTransactionEvents) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
"Cannot upload without relay: waitForTransactionEvents not configured"
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
const eventResult = await this.context.waitForTransactionEvents(txResult);
|
|
177
|
+
const fileAddedEvent = eventResult.expectedEvents.FileAdded;
|
|
178
|
+
if (!fileAddedEvent) {
|
|
179
|
+
throw new Error("FileAdded event not found in transaction");
|
|
180
|
+
}
|
|
181
|
+
result = {
|
|
182
|
+
fileId: Number(fileAddedEvent.fileId),
|
|
183
|
+
transactionHash: txResult.hash
|
|
184
|
+
};
|
|
139
185
|
}
|
|
140
186
|
return {
|
|
141
187
|
fileId: result.fileId,
|
|
@@ -152,35 +198,110 @@ class DataController {
|
|
|
152
198
|
}
|
|
153
199
|
}
|
|
154
200
|
/**
|
|
155
|
-
*
|
|
201
|
+
* Encrypts data using wallet-derived encryption.
|
|
156
202
|
*
|
|
157
203
|
* @remarks
|
|
158
|
-
* This
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
* decryption.
|
|
204
|
+
* This method provides secure, wallet-based encryption for data before uploading
|
|
205
|
+
* to the Vana network. It's the counterpart to decryptFile for preparing data
|
|
206
|
+
* for secure storage.
|
|
162
207
|
*
|
|
163
208
|
* The method automatically:
|
|
164
|
-
* - Generates
|
|
165
|
-
* -
|
|
166
|
-
* -
|
|
167
|
-
* -
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* @param
|
|
174
|
-
* @
|
|
175
|
-
* @
|
|
176
|
-
* @
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
209
|
+
* - Generates an encryption key from the user's wallet signature
|
|
210
|
+
* - Converts the input data to a Blob if necessary
|
|
211
|
+
* - Encrypts the data using the generated key
|
|
212
|
+
* - Returns both the encrypted data and the encryption key
|
|
213
|
+
*
|
|
214
|
+
* The encryption key returned can be stored and later used for decryption,
|
|
215
|
+
* or shared with others to grant them decryption access.
|
|
216
|
+
*
|
|
217
|
+
* @param data - The data to encrypt (Blob, string, or object)
|
|
218
|
+
* @param options - Optional encryption configuration
|
|
219
|
+
* @returns Promise resolving to encrypted data and the encryption key used
|
|
220
|
+
* @throws {Error} When wallet is not connected or encryption fails
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* // Encrypt a string
|
|
224
|
+
* const { encryptedData, encryptionKey } = await vana.data.encryptFile(
|
|
225
|
+
* "My secret data"
|
|
226
|
+
* );
|
|
227
|
+
*
|
|
228
|
+
* // Encrypt JSON with custom MIME type
|
|
229
|
+
* const { encryptedData, encryptionKey } = await vana.data.encryptFile(
|
|
230
|
+
* { name: "Alice", age: 30 },
|
|
231
|
+
* { mimeType: "application/json" }
|
|
232
|
+
* );
|
|
233
|
+
*
|
|
234
|
+
* // With custom encryption seed
|
|
235
|
+
* const { encryptedData, encryptionKey } = await vana.data.encryptFile(
|
|
236
|
+
* "Secret message",
|
|
237
|
+
* { seed: "My custom encryption seed" }
|
|
238
|
+
* );
|
|
239
|
+
*
|
|
240
|
+
* // Upload the encrypted data
|
|
241
|
+
* const result = await vana.data.uploadToStorage(encryptedData);
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
async encryptFile(data, options) {
|
|
245
|
+
this.assertWallet();
|
|
246
|
+
try {
|
|
247
|
+
const encryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
248
|
+
this.context.walletClient,
|
|
249
|
+
this.context.platform,
|
|
250
|
+
options?.seed ?? import_encryption.DEFAULT_ENCRYPTION_SEED
|
|
251
|
+
);
|
|
252
|
+
let blob;
|
|
253
|
+
if (data instanceof Blob) {
|
|
254
|
+
blob = data;
|
|
255
|
+
} else if (typeof data === "string") {
|
|
256
|
+
blob = new Blob([data], { type: options?.mimeType ?? "text/plain" });
|
|
257
|
+
} else {
|
|
258
|
+
blob = new Blob([JSON.stringify(data)], {
|
|
259
|
+
type: options?.mimeType ?? "application/json"
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
const encryptedData = await (0, import_encryption.encryptBlobWithSignedKey)(
|
|
263
|
+
blob,
|
|
264
|
+
encryptionKey,
|
|
265
|
+
this.context.platform
|
|
266
|
+
);
|
|
267
|
+
return {
|
|
268
|
+
encryptedData,
|
|
269
|
+
encryptionKey
|
|
270
|
+
};
|
|
271
|
+
} catch (error) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
`Failed to encrypt file: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Decrypts a file using wallet-derived decryption key.
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* Counterpart to `upload()` for decrypting user files. Automatically
|
|
282
|
+
* generates decryption key from wallet, fetches encrypted content,
|
|
283
|
+
* and decrypts. Supports IPFS (with gateway fallback) and HTTP URLs.
|
|
284
|
+
*
|
|
285
|
+
* @param file - UserFile object from `getUserFiles()`
|
|
286
|
+
* @param options - Decryption options
|
|
287
|
+
* @param options.seed - Custom encryption seed.
|
|
288
|
+
* Defaults to standard Vana seed.
|
|
289
|
+
*
|
|
290
|
+
* @returns Decrypted content as Blob
|
|
291
|
+
*
|
|
292
|
+
* @throws {Error} No wallet connected.
|
|
293
|
+
* Connect wallet before decrypting.
|
|
294
|
+
* @throws {Error} Network error accessing file.
|
|
295
|
+
* Check CORS settings or server availability.
|
|
296
|
+
* @throws {Error} File not found (404).
|
|
297
|
+
* File no longer available at stored URL.
|
|
298
|
+
* @throws {Error} Access denied (403).
|
|
299
|
+
* No permission to access file.
|
|
300
|
+
* @throws {Error} Invalid file format.
|
|
301
|
+
* File not encrypted with Vana protocol.
|
|
302
|
+
* @throws {Error} Wrong encryption key.
|
|
303
|
+
* Verify seed matches upload or use default.
|
|
304
|
+
*
|
|
184
305
|
* @example
|
|
185
306
|
* ```typescript
|
|
186
307
|
* // Basic file decryption
|
|
@@ -206,12 +327,14 @@ class DataController {
|
|
|
206
327
|
* fs.writeFileSync('decrypted-file.txt', Buffer.from(buffer));
|
|
207
328
|
* ```
|
|
208
329
|
*/
|
|
209
|
-
async decryptFile(file,
|
|
330
|
+
async decryptFile(file, options) {
|
|
331
|
+
this.assertWallet();
|
|
210
332
|
try {
|
|
333
|
+
this.assertWallet();
|
|
211
334
|
const encryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
212
335
|
this.context.walletClient,
|
|
213
336
|
this.context.platform,
|
|
214
|
-
|
|
337
|
+
options?.seed ?? import_encryption.DEFAULT_ENCRYPTION_SEED
|
|
215
338
|
);
|
|
216
339
|
let encryptedBlob;
|
|
217
340
|
try {
|
|
@@ -294,99 +417,126 @@ class DataController {
|
|
|
294
417
|
}
|
|
295
418
|
}
|
|
296
419
|
/**
|
|
297
|
-
* Retrieves all
|
|
420
|
+
* Retrieves all files owned by a specific user address.
|
|
298
421
|
*
|
|
299
422
|
* @remarks
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
* @
|
|
311
|
-
*
|
|
312
|
-
* @
|
|
313
|
-
*
|
|
314
|
-
* @throws {Error}
|
|
315
|
-
*
|
|
316
|
-
* @throws {Error}
|
|
423
|
+
* Queries the Vana subgraph for files owned by the specified address.
|
|
424
|
+
* Automatically deduplicates by file ID, keeping the latest version
|
|
425
|
+
* when duplicates exist from re-indexing or chain reorganizations.
|
|
426
|
+
* Enriches results with DLP proof data when available.
|
|
427
|
+
*
|
|
428
|
+
* @param params - Query configuration
|
|
429
|
+
* @param params.owner - Wallet address of the file owner
|
|
430
|
+
* @param params.subgraphUrl - Subgraph endpoint override.
|
|
431
|
+
* Defaults to context configuration.
|
|
432
|
+
*
|
|
433
|
+
* @returns Array of UserFile objects sorted by timestamp (newest first)
|
|
434
|
+
*
|
|
435
|
+
* @throws {Error} Subgraph URL not configured.
|
|
436
|
+
* Provide `subgraphUrl` parameter or configure in Vana constructor.
|
|
437
|
+
* @throws {Error} Subgraph request failed.
|
|
438
|
+
* Check network connectivity and subgraph availability.
|
|
439
|
+
* @throws {Error} Subgraph returned errors.
|
|
440
|
+
* Review query parameters and subgraph logs.
|
|
441
|
+
*
|
|
317
442
|
* @example
|
|
318
443
|
* ```typescript
|
|
319
|
-
* // Query files for a specific user
|
|
320
444
|
* const files = await vana.data.getUserFiles({
|
|
321
|
-
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
445
|
+
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36"
|
|
322
446
|
* });
|
|
323
447
|
*
|
|
324
448
|
* files.forEach(file => {
|
|
325
|
-
* console.log(`File ${file.id}: ${file.url}
|
|
449
|
+
* console.log(`File ${file.id}: ${file.url}`);
|
|
450
|
+
* console.log(` Schema: ${file.schemaId}`);
|
|
451
|
+
* console.log(` DLPs: ${file.dlpIds?.join(", ") || "none"}`);
|
|
326
452
|
* });
|
|
327
453
|
* ```
|
|
328
454
|
*/
|
|
329
|
-
async getUserFiles(params) {
|
|
455
|
+
async getUserFiles(params, options) {
|
|
330
456
|
const { owner, subgraphUrl } = params;
|
|
331
|
-
|
|
457
|
+
let dataSource = options?.source === "chain" ? "chain" : "subgraph";
|
|
458
|
+
if (options?.source === "auto" || !options?.source && options?.minBlock) {
|
|
459
|
+
const endpoint2 = subgraphUrl ?? this.context.subgraphUrl;
|
|
460
|
+
const currentBlock = await this.context.publicClient.getBlockNumber();
|
|
461
|
+
let subgraphBlock;
|
|
462
|
+
if (endpoint2) {
|
|
463
|
+
try {
|
|
464
|
+
const meta = await (0, import_subgraphConsistency.fetchSubgraphMeta)(endpoint2);
|
|
465
|
+
subgraphBlock = meta.blockNumber;
|
|
466
|
+
} catch {
|
|
467
|
+
subgraphBlock = void 0;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
dataSource = (0, import_chainQuery.determineDataSource)(
|
|
471
|
+
options?.source,
|
|
472
|
+
options?.minBlock,
|
|
473
|
+
currentBlock,
|
|
474
|
+
subgraphBlock
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
if (dataSource === "chain") {
|
|
478
|
+
const publicClient = this.context.publicClient;
|
|
479
|
+
const chainId = await publicClient.getChainId();
|
|
480
|
+
const contractAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
|
|
481
|
+
const files = await (0, import_chainQuery.getUserFilesFromChain)(
|
|
482
|
+
publicClient,
|
|
483
|
+
contractAddress,
|
|
484
|
+
owner,
|
|
485
|
+
options?.minBlock ? BigInt(options.minBlock) : void 0
|
|
486
|
+
);
|
|
487
|
+
const limit = options?.fetchAll ? files.length : options?.limit ?? 100;
|
|
488
|
+
const offset = options?.offset ?? 0;
|
|
489
|
+
return files.slice(offset, offset + limit);
|
|
490
|
+
}
|
|
491
|
+
const endpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
332
492
|
if (!endpoint) {
|
|
333
493
|
throw new Error(
|
|
334
494
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
335
495
|
);
|
|
336
496
|
}
|
|
497
|
+
if (options?.minBlock || options?.waitForSync) {
|
|
498
|
+
await (0, import_subgraphConsistency.checkSubgraphConsistency)(endpoint, options);
|
|
499
|
+
}
|
|
337
500
|
try {
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
501
|
+
const orderByMap = {
|
|
502
|
+
id: "id",
|
|
503
|
+
addedAtBlock: "addedAtBlock",
|
|
504
|
+
addedAtTimestamp: "addedAtTimestamp",
|
|
505
|
+
url: "url",
|
|
506
|
+
schemaId: "schemaId"
|
|
507
|
+
};
|
|
508
|
+
const allFiles = await (0, import_subgraphPagination.executePaginatedQuery)({
|
|
509
|
+
endpoint,
|
|
510
|
+
document: import_subgraph.GetUserFilesPaginatedDocument,
|
|
511
|
+
baseVariables: {
|
|
512
|
+
userId: owner.toLowerCase(),
|
|
513
|
+
// Subgraph requires lowercase addresses
|
|
514
|
+
orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
|
|
515
|
+
options?.orderBy,
|
|
516
|
+
orderByMap,
|
|
517
|
+
"addedAtBlock"
|
|
518
|
+
),
|
|
519
|
+
orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
|
|
520
|
+
options?.orderDirection,
|
|
521
|
+
"asc",
|
|
522
|
+
"desc"
|
|
523
|
+
)
|
|
342
524
|
},
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
// Subgraph requires lowercase addresses
|
|
348
|
-
}
|
|
349
|
-
})
|
|
350
|
-
});
|
|
351
|
-
if (!response.ok) {
|
|
352
|
-
throw new Error(
|
|
353
|
-
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
const result = await response.json();
|
|
357
|
-
if (result.errors) {
|
|
358
|
-
throw new Error(
|
|
359
|
-
`Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
const user = result.data?.user;
|
|
363
|
-
if (!user || !user.files?.length) {
|
|
364
|
-
console.warn("No files found for user:", owner);
|
|
365
|
-
return [];
|
|
366
|
-
}
|
|
367
|
-
const fileMap = /* @__PURE__ */ new Map();
|
|
368
|
-
user.files.forEach((file) => {
|
|
369
|
-
const fileId = parseInt(file.id);
|
|
370
|
-
const userFile = {
|
|
371
|
-
id: fileId,
|
|
525
|
+
options,
|
|
526
|
+
extractItems: (data) => data?.user?.files,
|
|
527
|
+
transformItem: (file) => ({
|
|
528
|
+
id: parseInt(file.id),
|
|
372
529
|
url: file.url,
|
|
373
530
|
ownerAddress: file.owner.id,
|
|
374
531
|
addedAtBlock: BigInt(file.addedAtBlock),
|
|
375
532
|
schemaId: parseInt(file.schemaId),
|
|
376
533
|
addedAtTimestamp: BigInt(file.addedAtTimestamp),
|
|
377
534
|
transactionHash: file.transactionHash
|
|
378
|
-
}
|
|
379
|
-
const existing = fileMap.get(fileId);
|
|
380
|
-
if (!existing || userFile.addedAtTimestamp && existing.addedAtTimestamp && userFile.addedAtTimestamp > existing.addedAtTimestamp) {
|
|
381
|
-
fileMap.set(fileId, userFile);
|
|
382
|
-
}
|
|
535
|
+
})
|
|
383
536
|
});
|
|
384
|
-
|
|
385
|
-
(a, b) => Number((b.addedAtTimestamp || 0n) - (a.addedAtTimestamp || 0n))
|
|
386
|
-
);
|
|
387
|
-
if (userFiles.length > 0) {
|
|
537
|
+
if (allFiles.length > 0) {
|
|
388
538
|
try {
|
|
389
|
-
const fileIds =
|
|
539
|
+
const fileIds = allFiles.map((f) => f.id);
|
|
390
540
|
let proofMap;
|
|
391
541
|
try {
|
|
392
542
|
proofMap = await this._fetchProofsFromSubgraph(fileIds, endpoint);
|
|
@@ -397,7 +547,7 @@ class DataController {
|
|
|
397
547
|
);
|
|
398
548
|
proofMap = await this._fetchProofsFromChain(fileIds);
|
|
399
549
|
}
|
|
400
|
-
for (const file of
|
|
550
|
+
for (const file of allFiles) {
|
|
401
551
|
const dlpIds = proofMap.get(file.id);
|
|
402
552
|
if (dlpIds && dlpIds.length > 0) {
|
|
403
553
|
file.dlpIds = dlpIds;
|
|
@@ -407,7 +557,7 @@ class DataController {
|
|
|
407
557
|
console.warn("Failed to fetch proof data for files:", error);
|
|
408
558
|
}
|
|
409
559
|
}
|
|
410
|
-
return
|
|
560
|
+
return allFiles;
|
|
411
561
|
} catch (error) {
|
|
412
562
|
console.error("Failed to fetch user files from subgraph:", error);
|
|
413
563
|
throw new Error(
|
|
@@ -453,10 +603,11 @@ class DataController {
|
|
|
453
603
|
if (proof.dlp?.id) {
|
|
454
604
|
const fileId = parseInt(proof.fileId);
|
|
455
605
|
const dlpId = parseInt(proof.dlp.id);
|
|
456
|
-
|
|
457
|
-
|
|
606
|
+
let dlpIds = proofMap.get(fileId);
|
|
607
|
+
if (!dlpIds) {
|
|
608
|
+
dlpIds = [];
|
|
609
|
+
proofMap.set(fileId, dlpIds);
|
|
458
610
|
}
|
|
459
|
-
const dlpIds = proofMap.get(fileId);
|
|
460
611
|
if (!dlpIds.includes(dlpId)) {
|
|
461
612
|
dlpIds.push(dlpId);
|
|
462
613
|
}
|
|
@@ -474,7 +625,7 @@ class DataController {
|
|
|
474
625
|
* @returns Map of file IDs to their associated DLP IDs
|
|
475
626
|
*/
|
|
476
627
|
async _fetchProofsFromChain(fileIds) {
|
|
477
|
-
const chainId = this.context.
|
|
628
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
478
629
|
if (!chainId) {
|
|
479
630
|
throw new Error("Chain ID not available");
|
|
480
631
|
}
|
|
@@ -531,7 +682,10 @@ class DataController {
|
|
|
531
682
|
* ```
|
|
532
683
|
*/
|
|
533
684
|
async getDLP(dlpId, options = {}) {
|
|
534
|
-
const subgraphUrl = options.subgraphUrl
|
|
685
|
+
const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
|
|
686
|
+
if (subgraphUrl && (options.minBlock || options.waitForSync)) {
|
|
687
|
+
await (0, import_subgraphConsistency.checkSubgraphConsistency)(subgraphUrl, options);
|
|
688
|
+
}
|
|
535
689
|
if (subgraphUrl) {
|
|
536
690
|
try {
|
|
537
691
|
const response = await fetch(subgraphUrl, {
|
|
@@ -562,18 +716,18 @@ class DataController {
|
|
|
562
716
|
}
|
|
563
717
|
return {
|
|
564
718
|
id: parseInt(result.data.dlp.id),
|
|
565
|
-
name: result.data.dlp.name
|
|
566
|
-
metadata: result.data.dlp.metadata
|
|
719
|
+
name: result.data.dlp.name ?? "",
|
|
720
|
+
metadata: result.data.dlp.metadata ?? void 0,
|
|
567
721
|
status: result.data.dlp.status ? parseInt(result.data.dlp.status) : void 0,
|
|
568
|
-
address: result.data.dlp.address,
|
|
569
|
-
owner: result.data.dlp.owner
|
|
722
|
+
address: result.data.dlp.address ? result.data.dlp.address : void 0,
|
|
723
|
+
owner: result.data.dlp.owner ? result.data.dlp.owner : void 0
|
|
570
724
|
};
|
|
571
725
|
} catch (error) {
|
|
572
726
|
console.debug("Subgraph query failed, falling back to chain:", error);
|
|
573
727
|
}
|
|
574
728
|
}
|
|
575
729
|
try {
|
|
576
|
-
const chainId = this.context.
|
|
730
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
577
731
|
if (!chainId) {
|
|
578
732
|
throw new Error("Chain ID not available");
|
|
579
733
|
}
|
|
@@ -585,7 +739,7 @@ class DataController {
|
|
|
585
739
|
functionName: "dlps",
|
|
586
740
|
args: [BigInt(dlpId)]
|
|
587
741
|
});
|
|
588
|
-
if (!dlpData
|
|
742
|
+
if (!dlpData?.name) {
|
|
589
743
|
throw new Error(`DLP not found: ${dlpId}`);
|
|
590
744
|
}
|
|
591
745
|
return {
|
|
@@ -627,7 +781,7 @@ class DataController {
|
|
|
627
781
|
*/
|
|
628
782
|
async listDLPs(options = {}) {
|
|
629
783
|
const { limit = 100, offset = 0 } = options;
|
|
630
|
-
const subgraphUrl = options.subgraphUrl
|
|
784
|
+
const subgraphUrl = options.subgraphUrl ?? this.context.subgraphUrl;
|
|
631
785
|
if (subgraphUrl) {
|
|
632
786
|
try {
|
|
633
787
|
const query = `
|
|
@@ -666,21 +820,21 @@ class DataController {
|
|
|
666
820
|
`Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
667
821
|
);
|
|
668
822
|
}
|
|
669
|
-
const dlps = result.data?.dlps
|
|
823
|
+
const dlps = result.data?.dlps ?? [];
|
|
670
824
|
return dlps.map((dlp) => ({
|
|
671
825
|
id: parseInt(dlp.id),
|
|
672
|
-
name: dlp.name
|
|
826
|
+
name: dlp.name ?? "",
|
|
673
827
|
metadata: dlp.metadata,
|
|
674
828
|
status: dlp.status ? parseInt(dlp.status) : void 0,
|
|
675
|
-
address: dlp.address,
|
|
676
|
-
owner: dlp.owner
|
|
829
|
+
address: dlp.address ? dlp.address : void 0,
|
|
830
|
+
owner: dlp.owner ? dlp.owner : void 0
|
|
677
831
|
}));
|
|
678
832
|
} catch (error) {
|
|
679
833
|
console.debug("Subgraph query failed, falling back to chain:", error);
|
|
680
834
|
}
|
|
681
835
|
}
|
|
682
836
|
try {
|
|
683
|
-
const chainId = this.context.
|
|
837
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
684
838
|
if (!chainId) {
|
|
685
839
|
throw new Error("Chain ID not available");
|
|
686
840
|
}
|
|
@@ -750,21 +904,33 @@ class DataController {
|
|
|
750
904
|
* @returns Promise resolving to an array of permission objects
|
|
751
905
|
* @throws Error if both subgraph and RPC queries fail
|
|
752
906
|
*/
|
|
753
|
-
async getUserPermissions(params) {
|
|
907
|
+
async getUserPermissions(params, options) {
|
|
754
908
|
const { user, subgraphUrl } = params;
|
|
755
|
-
const endpoint = subgraphUrl
|
|
909
|
+
const endpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
910
|
+
if (endpoint && (options?.minBlock || options?.waitForSync)) {
|
|
911
|
+
await (0, import_subgraphConsistency.checkSubgraphConsistency)(endpoint, options);
|
|
912
|
+
}
|
|
756
913
|
if (endpoint) {
|
|
757
914
|
try {
|
|
758
|
-
const permissions = await this._getUserPermissionsViaSubgraph(
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
915
|
+
const permissions = await this._getUserPermissionsViaSubgraph(
|
|
916
|
+
{
|
|
917
|
+
user,
|
|
918
|
+
subgraphUrl: endpoint
|
|
919
|
+
},
|
|
920
|
+
options
|
|
921
|
+
);
|
|
762
922
|
return permissions;
|
|
763
923
|
} catch (error) {
|
|
764
924
|
console.warn("Subgraph query failed, falling back to RPC:", error);
|
|
765
925
|
}
|
|
766
926
|
}
|
|
767
|
-
|
|
927
|
+
const allPermissions = await this._getUserPermissionsViaRpc({ user });
|
|
928
|
+
if (options && !options.fetchAll) {
|
|
929
|
+
const limit = options.limit ?? 100;
|
|
930
|
+
const offset = options.offset ?? 0;
|
|
931
|
+
return allPermissions.slice(offset, offset + limit);
|
|
932
|
+
}
|
|
933
|
+
return allPermissions;
|
|
768
934
|
}
|
|
769
935
|
/**
|
|
770
936
|
* Internal method: Query user permissions via subgraph
|
|
@@ -774,46 +940,48 @@ class DataController {
|
|
|
774
940
|
* @param params.subgraphUrl - The subgraph URL endpoint to query
|
|
775
941
|
* @returns Promise resolving to an array of permission objects
|
|
776
942
|
*/
|
|
777
|
-
async _getUserPermissionsViaSubgraph(params) {
|
|
943
|
+
async _getUserPermissionsViaSubgraph(params, options) {
|
|
778
944
|
const { user, subgraphUrl } = params;
|
|
779
945
|
try {
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
946
|
+
const orderByMap = {
|
|
947
|
+
id: "id",
|
|
948
|
+
addedAtBlock: "addedAtBlock",
|
|
949
|
+
addedAtTimestamp: "addedAtTimestamp",
|
|
950
|
+
grant: "grant",
|
|
951
|
+
nonce: "nonce",
|
|
952
|
+
startBlock: "startBlock",
|
|
953
|
+
endBlock: "endBlock"
|
|
954
|
+
};
|
|
955
|
+
const permissions = await (0, import_subgraphPagination.executePaginatedQuery)({
|
|
956
|
+
endpoint: subgraphUrl,
|
|
957
|
+
document: import_subgraph.GetUserPermissionsPaginatedDocument,
|
|
958
|
+
baseVariables: {
|
|
959
|
+
userId: user.toLowerCase(),
|
|
960
|
+
orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
|
|
961
|
+
options?.orderBy,
|
|
962
|
+
orderByMap,
|
|
963
|
+
"addedAtTimestamp"
|
|
964
|
+
),
|
|
965
|
+
orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
|
|
966
|
+
options?.orderDirection,
|
|
967
|
+
"desc",
|
|
968
|
+
"asc"
|
|
969
|
+
)
|
|
784
970
|
},
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
971
|
+
options,
|
|
972
|
+
extractItems: (data) => data?.user?.permissions,
|
|
973
|
+
transformItem: (permission) => ({
|
|
974
|
+
id: permission.id,
|
|
975
|
+
grant: permission.grant,
|
|
976
|
+
nonce: BigInt(permission.nonce),
|
|
977
|
+
signature: permission.signature,
|
|
978
|
+
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
979
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp),
|
|
980
|
+
transactionHash: permission.transactionHash,
|
|
981
|
+
user
|
|
790
982
|
})
|
|
791
983
|
});
|
|
792
|
-
|
|
793
|
-
throw new Error(
|
|
794
|
-
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
795
|
-
);
|
|
796
|
-
}
|
|
797
|
-
const result = await response.json();
|
|
798
|
-
if (result.errors) {
|
|
799
|
-
throw new Error(
|
|
800
|
-
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
801
|
-
);
|
|
802
|
-
}
|
|
803
|
-
const userData = result.data?.user;
|
|
804
|
-
if (!userData || !userData.permissions?.length) {
|
|
805
|
-
return [];
|
|
806
|
-
}
|
|
807
|
-
return userData.permissions.map((permission) => ({
|
|
808
|
-
id: permission.id,
|
|
809
|
-
grant: permission.grant,
|
|
810
|
-
nonce: BigInt(permission.nonce),
|
|
811
|
-
signature: permission.signature,
|
|
812
|
-
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
813
|
-
addedAtTimestamp: BigInt(permission.addedAtTimestamp),
|
|
814
|
-
transactionHash: permission.transactionHash,
|
|
815
|
-
user
|
|
816
|
-
})).sort((a, b) => Number(b.addedAtTimestamp - a.addedAtTimestamp));
|
|
984
|
+
return permissions;
|
|
817
985
|
} catch (error) {
|
|
818
986
|
console.error("Failed to query user permissions from subgraph:", error);
|
|
819
987
|
throw error;
|
|
@@ -829,7 +997,7 @@ class DataController {
|
|
|
829
997
|
async _getUserPermissionsViaRpc(params) {
|
|
830
998
|
const { user } = params;
|
|
831
999
|
try {
|
|
832
|
-
const chainId = this.context.
|
|
1000
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
833
1001
|
if (!chainId) {
|
|
834
1002
|
throw new Error("Chain ID not available");
|
|
835
1003
|
}
|
|
@@ -946,20 +1114,28 @@ class DataController {
|
|
|
946
1114
|
* });
|
|
947
1115
|
* ```
|
|
948
1116
|
*/
|
|
949
|
-
async getUserTrustedServers(params) {
|
|
950
|
-
const { user
|
|
951
|
-
const subgraphUrl = params.subgraphUrl
|
|
1117
|
+
async getUserTrustedServers(params, options) {
|
|
1118
|
+
const { user } = params;
|
|
1119
|
+
const subgraphUrl = params.subgraphUrl ?? this.context.subgraphUrl;
|
|
1120
|
+
if (subgraphUrl && (options?.minBlock || options?.waitForSync)) {
|
|
1121
|
+
await (0, import_subgraphConsistency.checkSubgraphConsistency)(subgraphUrl, options);
|
|
1122
|
+
}
|
|
952
1123
|
if (subgraphUrl) {
|
|
953
1124
|
try {
|
|
954
|
-
const servers = await this._getUserTrustedServersViaSubgraph(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1125
|
+
const servers = await this._getUserTrustedServersViaSubgraph(
|
|
1126
|
+
{
|
|
1127
|
+
user,
|
|
1128
|
+
subgraphUrl
|
|
1129
|
+
},
|
|
1130
|
+
options
|
|
1131
|
+
);
|
|
1132
|
+
return servers;
|
|
959
1133
|
} catch (error) {
|
|
960
1134
|
console.warn("Subgraph query failed, falling back to RPC:", error);
|
|
961
1135
|
}
|
|
962
1136
|
}
|
|
1137
|
+
const limit = options?.fetchAll ? Number.MAX_SAFE_INTEGER : options?.limit ?? 100;
|
|
1138
|
+
const offset = options?.offset ?? 0;
|
|
963
1139
|
const rpcResult = await this._getUserTrustedServersViaRpc({
|
|
964
1140
|
user,
|
|
965
1141
|
limit,
|
|
@@ -975,7 +1151,7 @@ class DataController {
|
|
|
975
1151
|
* @param params.subgraphUrl - The subgraph URL endpoint to query
|
|
976
1152
|
* @returns Promise resolving to an array of trusted server objects
|
|
977
1153
|
*/
|
|
978
|
-
async _getUserTrustedServersViaSubgraph(params) {
|
|
1154
|
+
async _getUserTrustedServersViaSubgraph(params, options) {
|
|
979
1155
|
const { user, subgraphUrl } = params;
|
|
980
1156
|
const graphqlEndpoint = subgraphUrl;
|
|
981
1157
|
if (!graphqlEndpoint) {
|
|
@@ -984,42 +1160,46 @@ class DataController {
|
|
|
984
1160
|
);
|
|
985
1161
|
}
|
|
986
1162
|
try {
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1163
|
+
const orderByMap = {
|
|
1164
|
+
id: "id",
|
|
1165
|
+
trustedAt: "trustedAt",
|
|
1166
|
+
trustedAtBlock: "trustedAtBlock",
|
|
1167
|
+
server: "server",
|
|
1168
|
+
user: "user"
|
|
1169
|
+
};
|
|
1170
|
+
const serverTrusts = await (0, import_subgraphPagination.executePaginatedQuery)({
|
|
1171
|
+
endpoint: graphqlEndpoint,
|
|
1172
|
+
document: import_subgraph.GetUserTrustedServersPaginatedDocument,
|
|
1173
|
+
baseVariables: {
|
|
1174
|
+
userId: user.toLowerCase(),
|
|
1175
|
+
// Subgraph requires lowercase addresses
|
|
1176
|
+
orderBy: (0, import_subgraphPagination.mapOrderByToEnum)(
|
|
1177
|
+
options?.orderBy,
|
|
1178
|
+
orderByMap,
|
|
1179
|
+
"trustedAtBlock"
|
|
1180
|
+
),
|
|
1181
|
+
orderDirection: (0, import_subgraphPagination.mapOrderDirection)(
|
|
1182
|
+
options?.orderDirection,
|
|
1183
|
+
"desc",
|
|
1184
|
+
"asc"
|
|
1185
|
+
)
|
|
991
1186
|
},
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
1187
|
+
options,
|
|
1188
|
+
extractItems: (data) => {
|
|
1189
|
+
const trusts = data?.user?.serverTrusts ?? [];
|
|
1190
|
+
return trusts.filter((trust) => !trust.untrustedAtBlock);
|
|
1191
|
+
},
|
|
1192
|
+
transformItem: (trust) => ({
|
|
1193
|
+
id: trust.server.id,
|
|
1194
|
+
serverAddress: trust.server.serverAddress,
|
|
1195
|
+
serverUrl: trust.server.url,
|
|
1196
|
+
trustedAt: BigInt(trust.trustedAt),
|
|
1197
|
+
user,
|
|
1198
|
+
name: ""
|
|
1199
|
+
// Not available in new schema, will be empty
|
|
998
1200
|
})
|
|
999
1201
|
});
|
|
1000
|
-
|
|
1001
|
-
throw new Error(
|
|
1002
|
-
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
1003
|
-
);
|
|
1004
|
-
}
|
|
1005
|
-
const result = await response.json();
|
|
1006
|
-
if (result.errors) {
|
|
1007
|
-
throw new Error(
|
|
1008
|
-
`Subgraph query errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
1009
|
-
);
|
|
1010
|
-
}
|
|
1011
|
-
if (!result.data?.user) {
|
|
1012
|
-
return [];
|
|
1013
|
-
}
|
|
1014
|
-
return (result.data.user.serverTrusts || []).filter((trust) => !trust.untrustedAtBlock).map((trust) => ({
|
|
1015
|
-
id: trust.server.id,
|
|
1016
|
-
serverAddress: trust.server.serverAddress,
|
|
1017
|
-
serverUrl: trust.server.url,
|
|
1018
|
-
trustedAt: BigInt(trust.trustedAt),
|
|
1019
|
-
user,
|
|
1020
|
-
name: ""
|
|
1021
|
-
// Not available in new schema, will be empty
|
|
1022
|
-
}));
|
|
1202
|
+
return serverTrusts;
|
|
1023
1203
|
} catch (error) {
|
|
1024
1204
|
console.error("Failed to query trusted servers from subgraph:", error);
|
|
1025
1205
|
throw error;
|
|
@@ -1037,7 +1217,7 @@ class DataController {
|
|
|
1037
1217
|
async _getUserTrustedServersViaRpc(params) {
|
|
1038
1218
|
const { user, limit, offset } = params;
|
|
1039
1219
|
try {
|
|
1040
|
-
const chainId = this.context.
|
|
1220
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1041
1221
|
if (!chainId) {
|
|
1042
1222
|
throw new Error("Chain ID not available");
|
|
1043
1223
|
}
|
|
@@ -1121,23 +1301,31 @@ class DataController {
|
|
|
1121
1301
|
}
|
|
1122
1302
|
}
|
|
1123
1303
|
/**
|
|
1124
|
-
*
|
|
1304
|
+
* Retrieves total file count from Data Registry.
|
|
1305
|
+
*
|
|
1306
|
+
* @remarks
|
|
1307
|
+
* Queries blockchain for complete file count across all users.
|
|
1308
|
+
* Useful for pagination and network statistics.
|
|
1309
|
+
*
|
|
1310
|
+
* @returns Total number of registered files
|
|
1311
|
+
*
|
|
1312
|
+
* @throws {Error} Chain ID not available.
|
|
1313
|
+
* Ensure network connection.
|
|
1314
|
+
* @throws {Error} Contract read failed.
|
|
1315
|
+
* Check RPC availability.
|
|
1125
1316
|
*
|
|
1126
|
-
* @returns Promise resolving to the total file count
|
|
1127
1317
|
* @example
|
|
1128
1318
|
* ```typescript
|
|
1129
|
-
* const
|
|
1130
|
-
* console.log(`Total files
|
|
1319
|
+
* const total = await vana.data.getTotalFilesCount();
|
|
1320
|
+
* console.log(`Total files: ${total}`);
|
|
1131
1321
|
*
|
|
1132
|
-
* //
|
|
1133
|
-
* const
|
|
1134
|
-
* const totalPages = Math.ceil(totalFiles / filesPerPage);
|
|
1135
|
-
* console.log(`Total pages: ${totalPages}`);
|
|
1322
|
+
* // Calculate pagination
|
|
1323
|
+
* const pages = Math.ceil(total / 20);
|
|
1136
1324
|
* ```
|
|
1137
1325
|
*/
|
|
1138
1326
|
async getTotalFilesCount() {
|
|
1139
1327
|
try {
|
|
1140
|
-
const chainId = this.context.
|
|
1328
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1141
1329
|
if (!chainId) {
|
|
1142
1330
|
throw new Error("Chain ID not available");
|
|
1143
1331
|
}
|
|
@@ -1146,7 +1334,7 @@ class DataController {
|
|
|
1146
1334
|
const dataRegistry = (0, import_viem.getContract)({
|
|
1147
1335
|
address: dataRegistryAddress,
|
|
1148
1336
|
abi: dataRegistryAbi,
|
|
1149
|
-
client: this.context.
|
|
1337
|
+
client: this.context.publicClient
|
|
1150
1338
|
});
|
|
1151
1339
|
const count = await dataRegistry.read.filesCount();
|
|
1152
1340
|
return Number(count);
|
|
@@ -1159,36 +1347,36 @@ class DataController {
|
|
|
1159
1347
|
}
|
|
1160
1348
|
}
|
|
1161
1349
|
/**
|
|
1162
|
-
* Retrieves
|
|
1350
|
+
* Retrieves file metadata by ID from the blockchain.
|
|
1351
|
+
*
|
|
1352
|
+
* @remarks
|
|
1353
|
+
* Queries DataRegistry contract directly for file details.
|
|
1354
|
+
* Works for any file ID regardless of ownership, enabling
|
|
1355
|
+
* cross-user file discovery and verification.
|
|
1356
|
+
*
|
|
1357
|
+
* @param fileId - Numeric file ID to retrieve
|
|
1358
|
+
*
|
|
1359
|
+
* @returns UserFile object with metadata
|
|
1360
|
+
*
|
|
1361
|
+
* @throws {Error} Chain ID not available.
|
|
1362
|
+
* Ensure proper network connection.
|
|
1363
|
+
* @throws {Error} File not found.
|
|
1364
|
+
* Verify file ID exists on-chain.
|
|
1365
|
+
* @throws {Error} Contract call failed.
|
|
1366
|
+
* Check network and RPC availability.
|
|
1163
1367
|
*
|
|
1164
|
-
* @param fileId - The file ID to look up
|
|
1165
|
-
* @returns Promise resolving to UserFile object
|
|
1166
|
-
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
1167
|
-
* @throws {Error} "File not found" - When file ID doesn't exist or returns empty data
|
|
1168
|
-
* @throws {Error} "Failed to fetch file {fileId}: {error}" - General contract read failures
|
|
1169
1368
|
* @example
|
|
1170
1369
|
* ```typescript
|
|
1171
|
-
*
|
|
1172
|
-
*
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1176
|
-
* owner: file.ownerAddress,
|
|
1177
|
-
* addedAt: file.addedAtBlock
|
|
1178
|
-
* });
|
|
1179
|
-
* } catch (error) {
|
|
1180
|
-
* console.error('File not found or error retrieving file:', error);
|
|
1181
|
-
* }
|
|
1370
|
+
* const file = await vana.data.getFileById(123);
|
|
1371
|
+
* console.log(`File ${file.id}:`);
|
|
1372
|
+
* console.log(` URL: ${file.url}`);
|
|
1373
|
+
* console.log(` Owner: ${file.ownerAddress}`);
|
|
1374
|
+
* console.log(` Block: ${file.addedAtBlock}`);
|
|
1182
1375
|
* ```
|
|
1183
|
-
*
|
|
1184
|
-
* This method queries the DataRegistry contract directly
|
|
1185
|
-
* to get file details for any file ID, regardless of user ownership.
|
|
1186
|
-
* This is useful for file lookup functionality where users can search
|
|
1187
|
-
* for specific files by ID.
|
|
1188
1376
|
*/
|
|
1189
1377
|
async getFileById(fileId) {
|
|
1190
1378
|
try {
|
|
1191
|
-
const chainId = this.context.
|
|
1379
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1192
1380
|
if (!chainId) {
|
|
1193
1381
|
throw new Error("Chain ID not available");
|
|
1194
1382
|
}
|
|
@@ -1197,7 +1385,7 @@ class DataController {
|
|
|
1197
1385
|
const dataRegistry = (0, import_viem.getContract)({
|
|
1198
1386
|
address: dataRegistryAddress,
|
|
1199
1387
|
abi: dataRegistryAbi,
|
|
1200
|
-
client: this.context.
|
|
1388
|
+
client: this.context.publicClient
|
|
1201
1389
|
});
|
|
1202
1390
|
const fileDetails = await dataRegistry.read.files([BigInt(fileId)]);
|
|
1203
1391
|
if (!fileDetails) {
|
|
@@ -1255,35 +1443,34 @@ class DataController {
|
|
|
1255
1443
|
* console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
|
|
1256
1444
|
* ```
|
|
1257
1445
|
*/
|
|
1258
|
-
async registerFileWithSchema(url, schemaId) {
|
|
1446
|
+
async registerFileWithSchema(url, schemaId, options) {
|
|
1447
|
+
this.assertWallet();
|
|
1259
1448
|
try {
|
|
1260
|
-
const chainId = this.context.
|
|
1449
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1261
1450
|
if (!chainId) {
|
|
1262
1451
|
throw new Error("Chain ID not available");
|
|
1263
1452
|
}
|
|
1453
|
+
this.assertWallet();
|
|
1264
1454
|
const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
|
|
1265
1455
|
const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
|
|
1266
|
-
const
|
|
1267
|
-
const
|
|
1456
|
+
const account = this.context.walletClient.account ?? this.context.userAddress;
|
|
1457
|
+
const from = typeof account === "string" ? account : account.address;
|
|
1458
|
+
const hash = await this.context.walletClient.writeContract({
|
|
1268
1459
|
address: dataRegistryAddress,
|
|
1269
1460
|
abi: dataRegistryAbi,
|
|
1270
1461
|
functionName: "addFileWithSchema",
|
|
1271
1462
|
args: [url, BigInt(schemaId)],
|
|
1272
|
-
account
|
|
1273
|
-
chain: this.context.walletClient.chain
|
|
1463
|
+
account,
|
|
1464
|
+
chain: this.context.walletClient.chain ?? null,
|
|
1465
|
+
...this.spreadTransactionOptions(options)
|
|
1466
|
+
});
|
|
1467
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1468
|
+
return tx({
|
|
1469
|
+
hash,
|
|
1470
|
+
from,
|
|
1471
|
+
contract: "DataRegistry",
|
|
1472
|
+
fn: "addFileWithSchema"
|
|
1274
1473
|
});
|
|
1275
|
-
const receipt = await this.context.publicClient.waitForTransactionReceipt(
|
|
1276
|
-
{
|
|
1277
|
-
hash: txHash,
|
|
1278
|
-
confirmations: 1
|
|
1279
|
-
}
|
|
1280
|
-
);
|
|
1281
|
-
const { parseFileAddedEvent } = await import("../utils/eventParsing");
|
|
1282
|
-
const eventData = parseFileAddedEvent(receipt);
|
|
1283
|
-
return {
|
|
1284
|
-
fileId: Number(eventData.fileId),
|
|
1285
|
-
transactionHash: txHash
|
|
1286
|
-
};
|
|
1287
1474
|
} catch (error) {
|
|
1288
1475
|
console.error("Failed to register file with schema:", error);
|
|
1289
1476
|
throw new Error(
|
|
@@ -1297,13 +1484,6 @@ class DataController {
|
|
|
1297
1484
|
* @returns Promise resolving to the user's wallet address
|
|
1298
1485
|
* @throws {Error} When no addresses are available in wallet client
|
|
1299
1486
|
*/
|
|
1300
|
-
async getUserAddress() {
|
|
1301
|
-
const addresses = await this.context.walletClient.getAddresses();
|
|
1302
|
-
if (addresses.length === 0) {
|
|
1303
|
-
throw new Error("No addresses available in wallet client");
|
|
1304
|
-
}
|
|
1305
|
-
return addresses[0];
|
|
1306
|
-
}
|
|
1307
1487
|
/**
|
|
1308
1488
|
* Adds a file with permissions to the DataRegistry contract.
|
|
1309
1489
|
*
|
|
@@ -1320,34 +1500,34 @@ class DataController {
|
|
|
1320
1500
|
* with specific permissions on the DataRegistry contract. It can be used
|
|
1321
1501
|
* by both direct transactions and relayer services.
|
|
1322
1502
|
*/
|
|
1323
|
-
async addFileWithPermissions(url, ownerAddress, permissions = []) {
|
|
1503
|
+
async addFileWithPermissions(url, ownerAddress, permissions = [], options) {
|
|
1504
|
+
this.assertWallet();
|
|
1324
1505
|
try {
|
|
1325
|
-
const chainId = this.context.
|
|
1506
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1326
1507
|
if (!chainId) {
|
|
1327
1508
|
throw new Error("Chain ID not available");
|
|
1328
1509
|
}
|
|
1510
|
+
this.assertWallet();
|
|
1329
1511
|
const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
|
|
1330
1512
|
const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
|
|
1331
|
-
const
|
|
1513
|
+
const account = this.context.walletClient.account ?? ownerAddress;
|
|
1514
|
+
const from = typeof account === "string" ? account : account.address;
|
|
1515
|
+
const hash = await this.context.walletClient.writeContract({
|
|
1332
1516
|
address: dataRegistryAddress,
|
|
1333
1517
|
abi: dataRegistryAbi,
|
|
1334
1518
|
functionName: "addFileWithPermissions",
|
|
1335
1519
|
args: [url, ownerAddress, permissions],
|
|
1336
|
-
account
|
|
1337
|
-
chain: this.context.walletClient.chain
|
|
1520
|
+
account,
|
|
1521
|
+
chain: this.context.walletClient.chain ?? null,
|
|
1522
|
+
...this.spreadTransactionOptions(options)
|
|
1523
|
+
});
|
|
1524
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1525
|
+
return tx({
|
|
1526
|
+
hash,
|
|
1527
|
+
from,
|
|
1528
|
+
contract: "DataRegistry",
|
|
1529
|
+
fn: "addFileWithPermissions"
|
|
1338
1530
|
});
|
|
1339
|
-
const receipt = await this.context.publicClient.waitForTransactionReceipt(
|
|
1340
|
-
{
|
|
1341
|
-
hash: txHash,
|
|
1342
|
-
confirmations: 1
|
|
1343
|
-
}
|
|
1344
|
-
);
|
|
1345
|
-
const { parseFileAddedEvent } = await import("../utils/eventParsing");
|
|
1346
|
-
const eventData = parseFileAddedEvent(receipt);
|
|
1347
|
-
return {
|
|
1348
|
-
fileId: Number(eventData.fileId),
|
|
1349
|
-
transactionHash: txHash
|
|
1350
|
-
};
|
|
1351
1531
|
} catch (error) {
|
|
1352
1532
|
console.error("Failed to add file with permissions:", error);
|
|
1353
1533
|
throw new Error(
|
|
@@ -1359,44 +1539,150 @@ class DataController {
|
|
|
1359
1539
|
* Adds a file to the registry with permissions and schema.
|
|
1360
1540
|
* This combines the functionality of addFileWithPermissions and schema validation.
|
|
1361
1541
|
*
|
|
1542
|
+
* @remarks
|
|
1543
|
+
* This method automatically encrypts permissions when a publicKey is provided.
|
|
1544
|
+
* It generates the user's encryption key and encrypts it with each recipient's
|
|
1545
|
+
* public key before registering on the blockchain.
|
|
1546
|
+
*
|
|
1362
1547
|
* @param url - The URL of the file to register
|
|
1363
1548
|
* @param ownerAddress - The address of the file owner
|
|
1364
|
-
* @param permissions - Array of permissions to grant
|
|
1549
|
+
* @param permissions - Array of permissions to grant, each with account and publicKey properties
|
|
1365
1550
|
* @param schemaId - The schema ID to associate with the file (0 for no schema)
|
|
1366
|
-
* @returns Promise resolving to
|
|
1551
|
+
* @returns Promise resolving to TransactionResult with fileId and transactionHash
|
|
1552
|
+
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
1553
|
+
* @throws {Error} "Failed to generate encryption key" - When encryption key generation fails
|
|
1554
|
+
* @throws {Error} "Permission for {account} must include 'publicKey'" - When publicKey is missing
|
|
1555
|
+
* @throws {Error} "Failed to add file with permissions and schema: {error}" - When transaction fails
|
|
1556
|
+
* @example
|
|
1557
|
+
* ```typescript
|
|
1558
|
+
* // Get server's public key
|
|
1559
|
+
* const serverIdentity = await vana.server.getIdentity({
|
|
1560
|
+
* userAddress: "0x..."
|
|
1561
|
+
* });
|
|
1562
|
+
*
|
|
1563
|
+
* // Add file with permissions and schema
|
|
1564
|
+
* const result = await vana.data.addFileWithPermissionsAndSchema(
|
|
1565
|
+
* "ipfs://QmXxx...",
|
|
1566
|
+
* ownerAddress,
|
|
1567
|
+
* [{
|
|
1568
|
+
* account: serverIdentity.address,
|
|
1569
|
+
* publicKey: serverIdentity.publicKey
|
|
1570
|
+
* }],
|
|
1571
|
+
* schemaId
|
|
1572
|
+
* );
|
|
1573
|
+
*
|
|
1574
|
+
* console.log(`File ${result.fileId} registered in tx ${result.hash}`);
|
|
1575
|
+
* ```
|
|
1576
|
+
*/
|
|
1577
|
+
async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
|
|
1578
|
+
this.assertWallet();
|
|
1579
|
+
try {
|
|
1580
|
+
let encryptedPermissions = [];
|
|
1581
|
+
if (permissions.length > 0) {
|
|
1582
|
+
this.assertWallet();
|
|
1583
|
+
const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
1584
|
+
this.context.walletClient,
|
|
1585
|
+
this.context.platform,
|
|
1586
|
+
import_encryption.DEFAULT_ENCRYPTION_SEED
|
|
1587
|
+
);
|
|
1588
|
+
encryptedPermissions = await Promise.all(
|
|
1589
|
+
permissions.map(async (permission) => {
|
|
1590
|
+
if (!permission.publicKey) {
|
|
1591
|
+
throw new Error(
|
|
1592
|
+
`Permission for ${permission.account} must include 'publicKey'`
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
const encryptedKey = await (0, import_encryption.encryptWithWalletPublicKey)(
|
|
1596
|
+
userEncryptionKey,
|
|
1597
|
+
permission.publicKey,
|
|
1598
|
+
this.context.platform
|
|
1599
|
+
);
|
|
1600
|
+
return {
|
|
1601
|
+
account: permission.account,
|
|
1602
|
+
key: encryptedKey
|
|
1603
|
+
};
|
|
1604
|
+
})
|
|
1605
|
+
);
|
|
1606
|
+
}
|
|
1607
|
+
return await this.addFileWithEncryptedPermissionsAndSchema(
|
|
1608
|
+
url,
|
|
1609
|
+
ownerAddress,
|
|
1610
|
+
encryptedPermissions,
|
|
1611
|
+
schemaId,
|
|
1612
|
+
options
|
|
1613
|
+
);
|
|
1614
|
+
} catch (error) {
|
|
1615
|
+
console.error("Failed to add file with permissions and schema:", error);
|
|
1616
|
+
throw new Error(
|
|
1617
|
+
`Failed to add file with permissions and schema: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Adds a file with pre-encrypted permissions and schema to the DataRegistry.
|
|
1623
|
+
*
|
|
1624
|
+
* @remarks
|
|
1625
|
+
* This method is designed for relay services and advanced use cases where permissions
|
|
1626
|
+
* have already been encrypted client-side. Unlike `addFileWithPermissionsAndSchema()`,
|
|
1627
|
+
* this method expects permissions in the encrypted format with a 'key' field instead
|
|
1628
|
+
* of 'publicKey'.
|
|
1629
|
+
*
|
|
1630
|
+
* This is typically used by relay endpoints that receive pre-encrypted data from
|
|
1631
|
+
* the client SDK's `upload()` method, avoiding double encryption.
|
|
1632
|
+
*
|
|
1633
|
+
* @param url - The storage URL of the file (e.g., IPFS URL)
|
|
1634
|
+
* @param ownerAddress - The address that will own this file
|
|
1635
|
+
* @param permissions - Array of pre-encrypted permissions with 'account' and 'key' fields
|
|
1636
|
+
* @param schemaId - Optional schema ID for data validation (defaults to 0)
|
|
1637
|
+
* @returns Promise resolving to transaction result with hash and contract details
|
|
1367
1638
|
* @throws {Error} When chain ID is not available
|
|
1368
|
-
* @throws {
|
|
1369
|
-
* @throws {Error} When transaction
|
|
1370
|
-
* @
|
|
1639
|
+
* @throws {Error} When wallet is not connected
|
|
1640
|
+
* @throws {Error} When transaction fails
|
|
1641
|
+
* @example
|
|
1642
|
+
* ```typescript
|
|
1643
|
+
* // In a relay endpoint that receives pre-encrypted permissions
|
|
1644
|
+
* const result = await vana.data.addFileWithEncryptedPermissionsAndSchema(
|
|
1645
|
+
* "ipfs://QmXxx...",
|
|
1646
|
+
* ownerAddress,
|
|
1647
|
+
* [
|
|
1648
|
+
* {
|
|
1649
|
+
* account: "0xServerAddress...",
|
|
1650
|
+
* key: "encrypted_key_string" // Already encrypted by client
|
|
1651
|
+
* }
|
|
1652
|
+
* ],
|
|
1653
|
+
* schemaId
|
|
1654
|
+
* );
|
|
1655
|
+
*
|
|
1656
|
+
* console.log(`File registered in tx ${result.hash}`);
|
|
1657
|
+
* ```
|
|
1371
1658
|
*/
|
|
1372
|
-
async
|
|
1659
|
+
async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
|
|
1373
1660
|
try {
|
|
1374
|
-
const chainId = this.context.
|
|
1661
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1375
1662
|
if (!chainId) {
|
|
1376
1663
|
throw new Error("Chain ID not available");
|
|
1377
1664
|
}
|
|
1665
|
+
this.assertWallet();
|
|
1378
1666
|
const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
|
|
1379
1667
|
const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
|
|
1380
|
-
const
|
|
1668
|
+
const account = this.context.walletClient.account ?? ownerAddress;
|
|
1669
|
+
const from = typeof account === "string" ? account : account.address;
|
|
1670
|
+
const hash = await this.context.walletClient.writeContract({
|
|
1381
1671
|
address: dataRegistryAddress,
|
|
1382
1672
|
abi: dataRegistryAbi,
|
|
1383
1673
|
functionName: "addFileWithPermissionsAndSchema",
|
|
1384
1674
|
args: [url, ownerAddress, permissions, BigInt(schemaId)],
|
|
1385
|
-
account
|
|
1386
|
-
chain: this.context.walletClient.chain
|
|
1675
|
+
account,
|
|
1676
|
+
chain: this.context.walletClient.chain ?? null,
|
|
1677
|
+
...this.spreadTransactionOptions(options)
|
|
1678
|
+
});
|
|
1679
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1680
|
+
return tx({
|
|
1681
|
+
hash,
|
|
1682
|
+
from,
|
|
1683
|
+
contract: "DataRegistry",
|
|
1684
|
+
fn: "addFileWithPermissionsAndSchema"
|
|
1387
1685
|
});
|
|
1388
|
-
const receipt = await this.context.publicClient.waitForTransactionReceipt(
|
|
1389
|
-
{
|
|
1390
|
-
hash: txHash,
|
|
1391
|
-
confirmations: 1
|
|
1392
|
-
}
|
|
1393
|
-
);
|
|
1394
|
-
const { parseFileAddedEvent } = await import("../utils/eventParsing");
|
|
1395
|
-
const eventData = parseFileAddedEvent(receipt);
|
|
1396
|
-
return {
|
|
1397
|
-
fileId: Number(eventData.fileId),
|
|
1398
|
-
transactionHash: txHash
|
|
1399
|
-
};
|
|
1400
1686
|
} catch (error) {
|
|
1401
1687
|
console.error("Failed to add file with permissions and schema:", error);
|
|
1402
1688
|
throw new Error(
|
|
@@ -1405,36 +1691,41 @@ class DataController {
|
|
|
1405
1691
|
}
|
|
1406
1692
|
}
|
|
1407
1693
|
/**
|
|
1408
|
-
*
|
|
1694
|
+
* Registers a data refiner for processing templates.
|
|
1409
1695
|
*
|
|
1410
1696
|
* @remarks
|
|
1411
|
-
* Refiners
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
* @param params - Refiner
|
|
1417
|
-
* @param params.
|
|
1418
|
-
*
|
|
1419
|
-
* @param params.
|
|
1420
|
-
*
|
|
1421
|
-
* @returns
|
|
1422
|
-
*
|
|
1423
|
-
* @throws {Error}
|
|
1697
|
+
* Refiners define data transformation rules for DLPs.
|
|
1698
|
+
* Associates schema, instructions, and processing logic.
|
|
1699
|
+
*
|
|
1700
|
+
* @param params - Refiner configuration
|
|
1701
|
+
* @param params.dlpId - Data Liquidity Pool ID
|
|
1702
|
+
* @param params.name - Refiner display name
|
|
1703
|
+
* @param params.schemaId - Output schema ID.
|
|
1704
|
+
* Obtain via `vana.schemas.list()`.
|
|
1705
|
+
* @param params.refinementInstructionUrl - Processing instructions URL
|
|
1706
|
+
*
|
|
1707
|
+
* @returns Refiner ID and transaction hash
|
|
1708
|
+
*
|
|
1709
|
+
* @throws {Error} Chain ID not available.
|
|
1710
|
+
* Ensure network connection.
|
|
1711
|
+
* @throws {Error} Transaction failed.
|
|
1712
|
+
* Check wallet balance and network status.
|
|
1713
|
+
*
|
|
1424
1714
|
* @example
|
|
1425
1715
|
* ```typescript
|
|
1426
1716
|
* const result = await vana.data.addRefiner({
|
|
1427
1717
|
* dlpId: 1,
|
|
1428
|
-
* name: "
|
|
1718
|
+
* name: "Sentiment Analyzer",
|
|
1429
1719
|
* schemaId: 42,
|
|
1430
1720
|
* refinementInstructionUrl: "ipfs://QmXxx..."
|
|
1431
1721
|
* });
|
|
1432
|
-
* console.log(`
|
|
1722
|
+
* console.log(`Refiner ${result.refinerId} created`);
|
|
1433
1723
|
* ```
|
|
1434
1724
|
*/
|
|
1435
|
-
async addRefiner(params) {
|
|
1725
|
+
async addRefiner(params, options) {
|
|
1726
|
+
this.assertWallet();
|
|
1436
1727
|
try {
|
|
1437
|
-
const chainId = this.context.
|
|
1728
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1438
1729
|
if (!chainId) {
|
|
1439
1730
|
throw new Error("Chain ID not available");
|
|
1440
1731
|
}
|
|
@@ -1443,7 +1734,10 @@ class DataController {
|
|
|
1443
1734
|
"DataRefinerRegistry"
|
|
1444
1735
|
);
|
|
1445
1736
|
const dataRefinerRegistryAbi = (0, import_abi.getAbi)("DataRefinerRegistry");
|
|
1446
|
-
|
|
1737
|
+
this.assertWallet();
|
|
1738
|
+
const account = this.context.walletClient.account ?? this.context.userAddress;
|
|
1739
|
+
const from = typeof account === "string" ? account : account.address;
|
|
1740
|
+
const hash = await this.context.walletClient.writeContract({
|
|
1447
1741
|
address: dataRefinerRegistryAddress,
|
|
1448
1742
|
abi: dataRefinerRegistryAbi,
|
|
1449
1743
|
functionName: "addRefinerWithSchemaId",
|
|
@@ -1453,20 +1747,28 @@ class DataController {
|
|
|
1453
1747
|
BigInt(params.schemaId),
|
|
1454
1748
|
params.refinementInstructionUrl
|
|
1455
1749
|
],
|
|
1456
|
-
account
|
|
1457
|
-
chain: this.context.walletClient.chain
|
|
1750
|
+
account,
|
|
1751
|
+
chain: this.context.walletClient.chain ?? null,
|
|
1752
|
+
...this.spreadTransactionOptions(options)
|
|
1458
1753
|
});
|
|
1459
|
-
const
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1754
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1755
|
+
const txResult = tx({
|
|
1756
|
+
hash,
|
|
1757
|
+
from,
|
|
1758
|
+
contract: "DataRefinerRegistry",
|
|
1759
|
+
fn: "addRefinerWithSchemaId"
|
|
1760
|
+
});
|
|
1761
|
+
if (!this.context.waitForTransactionEvents) {
|
|
1762
|
+
throw new Error("waitForTransactionEvents not configured");
|
|
1763
|
+
}
|
|
1764
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
1765
|
+
const event = result.expectedEvents.RefinerAdded;
|
|
1766
|
+
if (!event) {
|
|
1767
|
+
throw new Error("RefinerAdded event not found in transaction");
|
|
1768
|
+
}
|
|
1467
1769
|
return {
|
|
1468
|
-
refinerId: Number(
|
|
1469
|
-
transactionHash:
|
|
1770
|
+
refinerId: Number(event.refinerId),
|
|
1771
|
+
transactionHash: hash
|
|
1470
1772
|
};
|
|
1471
1773
|
} catch (error) {
|
|
1472
1774
|
console.error("Failed to add refiner:", error);
|
|
@@ -1476,31 +1778,34 @@ class DataController {
|
|
|
1476
1778
|
}
|
|
1477
1779
|
}
|
|
1478
1780
|
/**
|
|
1479
|
-
* Retrieves
|
|
1781
|
+
* Retrieves refiner configuration by ID.
|
|
1480
1782
|
*
|
|
1481
1783
|
* @remarks
|
|
1482
|
-
* Queries
|
|
1483
|
-
*
|
|
1784
|
+
* Queries DataRefinerRegistry for refiner details.
|
|
1785
|
+
* Returns DLP association, schema, and processing instructions.
|
|
1786
|
+
*
|
|
1787
|
+
* @param refinerId - Numeric refiner ID
|
|
1788
|
+
*
|
|
1789
|
+
* @returns Refiner configuration object
|
|
1790
|
+
*
|
|
1791
|
+
* @throws {Error} Chain ID not available.
|
|
1792
|
+
* Ensure network connection.
|
|
1793
|
+
* @throws {Error} Refiner not found.
|
|
1794
|
+
* Verify refiner ID exists.
|
|
1795
|
+
* @throws {Error} Contract read failed.
|
|
1796
|
+
* Check network and RPC status.
|
|
1484
1797
|
*
|
|
1485
|
-
* @param refinerId - The numeric refiner ID to retrieve
|
|
1486
|
-
* @returns Promise resolving to the refiner information object
|
|
1487
|
-
* @throws {Error} When chain ID is not available - "Chain ID not available"
|
|
1488
|
-
* @throws {Error} When refiner doesn't exist - "Refiner with ID {refinerId} does not exist"
|
|
1489
|
-
* @throws {Error} When contract read fails - "Failed to fetch refiner: {error}"
|
|
1490
1798
|
* @example
|
|
1491
1799
|
* ```typescript
|
|
1492
1800
|
* const refiner = await vana.data.getRefiner(1);
|
|
1493
|
-
* console.log({
|
|
1494
|
-
*
|
|
1495
|
-
*
|
|
1496
|
-
* schema: refiner.schemaId,
|
|
1497
|
-
* instructions: refiner.refinementInstructionUrl
|
|
1498
|
-
* });
|
|
1801
|
+
* console.log(`Refiner: ${refiner.name}`);
|
|
1802
|
+
* console.log(`DLP: ${refiner.dlpId}`);
|
|
1803
|
+
* console.log(`Schema: ${refiner.schemaId}`);
|
|
1499
1804
|
* ```
|
|
1500
1805
|
*/
|
|
1501
1806
|
async getRefiner(refinerId) {
|
|
1502
1807
|
try {
|
|
1503
|
-
const chainId = this.context.
|
|
1808
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1504
1809
|
if (!chainId) {
|
|
1505
1810
|
throw new Error("Chain ID not available");
|
|
1506
1811
|
}
|
|
@@ -1512,7 +1817,7 @@ class DataController {
|
|
|
1512
1817
|
const dataRefinerRegistry = (0, import_viem.getContract)({
|
|
1513
1818
|
address: dataRefinerRegistryAddress,
|
|
1514
1819
|
abi: dataRefinerRegistryAbi,
|
|
1515
|
-
client: this.context.
|
|
1820
|
+
client: this.context.publicClient
|
|
1516
1821
|
});
|
|
1517
1822
|
const refinerData = await dataRefinerRegistry.read.refiners([
|
|
1518
1823
|
BigInt(refinerId)
|
|
@@ -1536,27 +1841,33 @@ class DataController {
|
|
|
1536
1841
|
}
|
|
1537
1842
|
}
|
|
1538
1843
|
/**
|
|
1539
|
-
* Validates
|
|
1844
|
+
* Validates schema ID existence.
|
|
1540
1845
|
*
|
|
1541
1846
|
* @remarks
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1847
|
+
* Verifies schema registration in DataRegistry.
|
|
1848
|
+
* Check before using schemas for uploads.
|
|
1849
|
+
*
|
|
1850
|
+
* @param schemaId - Numeric schema ID to validate
|
|
1851
|
+
*
|
|
1852
|
+
* @returns True if schema exists, false otherwise
|
|
1853
|
+
*
|
|
1854
|
+
* @throws {Error} Chain ID not available.
|
|
1855
|
+
* Ensure network connection.
|
|
1856
|
+
* @throws {Error} Contract read failed.
|
|
1857
|
+
* Check RPC availability.
|
|
1544
1858
|
*
|
|
1545
|
-
* @param schemaId - The numeric schema ID to validate
|
|
1546
|
-
* @returns Promise resolving to true if schema exists, false otherwise
|
|
1547
1859
|
* @example
|
|
1548
1860
|
* ```typescript
|
|
1549
|
-
* const
|
|
1550
|
-
* if (
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
* console.log('Schema 42 does not exist');
|
|
1861
|
+
* const valid = await vana.data.isValidSchemaId(42);
|
|
1862
|
+
* if (valid) {
|
|
1863
|
+
* // Safe to use schema 42
|
|
1864
|
+
* await vana.data.upload({ schemaId: 42, ... });
|
|
1554
1865
|
* }
|
|
1555
1866
|
* ```
|
|
1556
1867
|
*/
|
|
1557
1868
|
async isValidSchemaId(schemaId) {
|
|
1558
1869
|
try {
|
|
1559
|
-
const chainId = this.context.
|
|
1870
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1560
1871
|
if (!chainId) {
|
|
1561
1872
|
throw new Error("Chain ID not available");
|
|
1562
1873
|
}
|
|
@@ -1568,7 +1879,7 @@ class DataController {
|
|
|
1568
1879
|
const dataRefinerRegistry = (0, import_viem.getContract)({
|
|
1569
1880
|
address: dataRefinerRegistryAddress,
|
|
1570
1881
|
abi: dataRefinerRegistryAbi,
|
|
1571
|
-
client: this.context.
|
|
1882
|
+
client: this.context.publicClient
|
|
1572
1883
|
});
|
|
1573
1884
|
const isValid = await dataRefinerRegistry.read.isValidSchemaId([
|
|
1574
1885
|
BigInt(schemaId)
|
|
@@ -1595,7 +1906,7 @@ class DataController {
|
|
|
1595
1906
|
*/
|
|
1596
1907
|
async getRefinersCount() {
|
|
1597
1908
|
try {
|
|
1598
|
-
const chainId = this.context.
|
|
1909
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1599
1910
|
if (!chainId) {
|
|
1600
1911
|
throw new Error("Chain ID not available");
|
|
1601
1912
|
}
|
|
@@ -1607,7 +1918,7 @@ class DataController {
|
|
|
1607
1918
|
const dataRefinerRegistry = (0, import_viem.getContract)({
|
|
1608
1919
|
address: dataRefinerRegistryAddress,
|
|
1609
1920
|
abi: dataRefinerRegistryAbi,
|
|
1610
|
-
client: this.context.
|
|
1921
|
+
client: this.context.publicClient
|
|
1611
1922
|
});
|
|
1612
1923
|
const count = await dataRefinerRegistry.read.refinersCount();
|
|
1613
1924
|
return Number(count);
|
|
@@ -1638,9 +1949,10 @@ class DataController {
|
|
|
1638
1949
|
* console.log(`Schema updated in tx ${result.transactionHash}`);
|
|
1639
1950
|
* ```
|
|
1640
1951
|
*/
|
|
1641
|
-
async updateSchemaId(params) {
|
|
1952
|
+
async updateSchemaId(params, options) {
|
|
1953
|
+
this.assertWallet();
|
|
1642
1954
|
try {
|
|
1643
|
-
const chainId = this.context.
|
|
1955
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1644
1956
|
if (!chainId) {
|
|
1645
1957
|
throw new Error("Chain ID not available");
|
|
1646
1958
|
}
|
|
@@ -1649,20 +1961,20 @@ class DataController {
|
|
|
1649
1961
|
"DataRefinerRegistry"
|
|
1650
1962
|
);
|
|
1651
1963
|
const dataRefinerRegistryAbi = (0, import_abi.getAbi)("DataRefinerRegistry");
|
|
1652
|
-
|
|
1964
|
+
this.assertWallet();
|
|
1965
|
+
const account = this.context.walletClient.account ?? this.context.userAddress;
|
|
1966
|
+
const hash = await this.context.walletClient.writeContract({
|
|
1653
1967
|
address: dataRefinerRegistryAddress,
|
|
1654
1968
|
abi: dataRefinerRegistryAbi,
|
|
1655
1969
|
functionName: "updateSchemaId",
|
|
1656
1970
|
args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
|
|
1657
|
-
account
|
|
1658
|
-
chain: this.context.walletClient.chain
|
|
1659
|
-
|
|
1660
|
-
await this.context.publicClient.waitForTransactionReceipt({
|
|
1661
|
-
hash: txHash,
|
|
1662
|
-
timeout: 3e4
|
|
1971
|
+
account,
|
|
1972
|
+
chain: this.context.walletClient.chain ?? null,
|
|
1973
|
+
...this.spreadTransactionOptions(options)
|
|
1663
1974
|
});
|
|
1975
|
+
await this.context.publicClient.waitForTransactionReceipt({ hash });
|
|
1664
1976
|
return {
|
|
1665
|
-
transactionHash:
|
|
1977
|
+
transactionHash: hash
|
|
1666
1978
|
};
|
|
1667
1979
|
} catch (error) {
|
|
1668
1980
|
console.error("Failed to update schema ID:", error);
|
|
@@ -1680,13 +1992,12 @@ class DataController {
|
|
|
1680
1992
|
* 3. Encrypts the user's encryption key with the provided public key
|
|
1681
1993
|
* 4. Registers the file with permissions
|
|
1682
1994
|
*
|
|
1683
|
-
* @param
|
|
1684
|
-
* @param permissions - Array of permissions to grant, each with account address and public key
|
|
1685
|
-
* @param filename - Optional filename for the upload
|
|
1686
|
-
* @param providerName - Optional storage provider to use
|
|
1995
|
+
* @param params - Upload parameters including data, permissions, and options
|
|
1687
1996
|
* @returns Promise resolving to upload result with file ID and storage URL
|
|
1688
1997
|
*/
|
|
1689
|
-
async uploadFileWithPermissions(
|
|
1998
|
+
async uploadFileWithPermissions(params) {
|
|
1999
|
+
this.assertWallet();
|
|
2000
|
+
const { data, permissions, filename, providerName } = params;
|
|
1690
2001
|
try {
|
|
1691
2002
|
const uploadResult = await this.uploadToStorage(
|
|
1692
2003
|
data,
|
|
@@ -1695,7 +2006,7 @@ class DataController {
|
|
|
1695
2006
|
// Always encrypt for uploadFileWithPermissions
|
|
1696
2007
|
providerName
|
|
1697
2008
|
);
|
|
1698
|
-
const userAddress =
|
|
2009
|
+
const userAddress = this.context.userAddress;
|
|
1699
2010
|
const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
1700
2011
|
this.context.walletClient,
|
|
1701
2012
|
this.context.platform,
|
|
@@ -1714,26 +2025,61 @@ class DataController {
|
|
|
1714
2025
|
};
|
|
1715
2026
|
})
|
|
1716
2027
|
);
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
2028
|
+
if (this.context.relayer) {
|
|
2029
|
+
const request = {
|
|
2030
|
+
type: "direct",
|
|
2031
|
+
operation: "submitFileAdditionWithPermissions",
|
|
2032
|
+
params: {
|
|
2033
|
+
url: uploadResult.url,
|
|
2034
|
+
userAddress,
|
|
2035
|
+
permissions: encryptedPermissions
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
const response = await this.context.relayer(request);
|
|
2039
|
+
if (response.type === "error") {
|
|
2040
|
+
throw new Error(response.error);
|
|
2041
|
+
}
|
|
2042
|
+
let result;
|
|
2043
|
+
if (response.type === "pending") {
|
|
2044
|
+
result = await this.pollRelayerForConfirmation(
|
|
2045
|
+
response.operationId,
|
|
2046
|
+
void 0
|
|
2047
|
+
// TODO: Add TransactionOptions to upload method signature
|
|
2048
|
+
);
|
|
2049
|
+
} else if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "fileId" in response.result) {
|
|
2050
|
+
result = response.result;
|
|
2051
|
+
} else {
|
|
2052
|
+
throw new Error("Invalid response from relayer");
|
|
2053
|
+
}
|
|
2054
|
+
return {
|
|
2055
|
+
fileId: result.fileId,
|
|
2056
|
+
url: uploadResult.url,
|
|
2057
|
+
size: uploadResult.size,
|
|
2058
|
+
transactionHash: result.transactionHash
|
|
2059
|
+
};
|
|
1724
2060
|
} else {
|
|
1725
|
-
|
|
2061
|
+
const txResult = await this.addFileWithPermissions(
|
|
1726
2062
|
uploadResult.url,
|
|
1727
2063
|
userAddress,
|
|
1728
2064
|
encryptedPermissions
|
|
1729
2065
|
);
|
|
2066
|
+
if (!this.context.waitForTransactionEvents) {
|
|
2067
|
+
throw new Error(
|
|
2068
|
+
"Cannot upload without relay: waitForTransactionEvents not configured"
|
|
2069
|
+
);
|
|
2070
|
+
}
|
|
2071
|
+
const eventResult = await this.context.waitForTransactionEvents(txResult);
|
|
2072
|
+
const fileAddedEvent = eventResult.expectedEvents.FileAdded;
|
|
2073
|
+
if (!fileAddedEvent) {
|
|
2074
|
+
throw new Error("FileAdded event not found in transaction");
|
|
2075
|
+
}
|
|
2076
|
+
return {
|
|
2077
|
+
fileId: Number(fileAddedEvent.fileId),
|
|
2078
|
+
url: uploadResult.url,
|
|
2079
|
+
size: uploadResult.size,
|
|
2080
|
+
transactionHash: txResult.hash
|
|
2081
|
+
};
|
|
1730
2082
|
}
|
|
1731
|
-
return {
|
|
1732
|
-
fileId: result.fileId,
|
|
1733
|
-
url: uploadResult.url,
|
|
1734
|
-
size: uploadResult.size,
|
|
1735
|
-
transactionHash: result.transactionHash
|
|
1736
|
-
};
|
|
1737
2083
|
} catch (error) {
|
|
1738
2084
|
console.error("Failed to upload file with permissions:", error);
|
|
1739
2085
|
throw new Error(
|
|
@@ -1771,6 +2117,7 @@ class DataController {
|
|
|
1771
2117
|
}
|
|
1772
2118
|
let finalBlob = blob;
|
|
1773
2119
|
if (encrypt) {
|
|
2120
|
+
this.assertWallet();
|
|
1774
2121
|
const encryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
1775
2122
|
this.context.walletClient,
|
|
1776
2123
|
this.context.platform,
|
|
@@ -1792,7 +2139,15 @@ class DataController {
|
|
|
1792
2139
|
);
|
|
1793
2140
|
}
|
|
1794
2141
|
}
|
|
1795
|
-
const finalFilename =
|
|
2142
|
+
const finalFilename = (() => {
|
|
2143
|
+
if (filename) {
|
|
2144
|
+
if (encrypt && !filename.endsWith(".enc")) {
|
|
2145
|
+
return `${filename}.enc`;
|
|
2146
|
+
}
|
|
2147
|
+
return filename;
|
|
2148
|
+
}
|
|
2149
|
+
return encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`;
|
|
2150
|
+
})();
|
|
1796
2151
|
const uploadResult = await this.context.storageManager.upload(
|
|
1797
2152
|
finalBlob,
|
|
1798
2153
|
finalFilename,
|
|
@@ -1817,22 +2172,30 @@ class DataController {
|
|
|
1817
2172
|
* For advanced users who need more control over transaction timing,
|
|
1818
2173
|
* use `submitFilePermission()` instead.
|
|
1819
2174
|
*
|
|
1820
|
-
* @param
|
|
1821
|
-
* @param
|
|
1822
|
-
* @param
|
|
2175
|
+
* @param params - Parameters for adding file permission
|
|
2176
|
+
* @param params.fileId - The ID of the file to grant permission for
|
|
2177
|
+
* @param params.account - The recipient's wallet address that will access the file
|
|
2178
|
+
* @param params.publicKey - The recipient's public key for encryption.
|
|
2179
|
+
* Obtain via `vana.server.getIdentity(account).publicKey`
|
|
1823
2180
|
* @returns Promise resolving to permission data from PermissionGranted event
|
|
1824
2181
|
* @throws {Error} "No addresses available in wallet client" - When wallet is not connected
|
|
1825
2182
|
* @throws {Error} "Chain ID not available" - When wallet chain is not configured
|
|
1826
2183
|
* @throws {Error} "Failed to add permission to file: {error}" - When transaction fails or user doesn't own file
|
|
1827
2184
|
* @example
|
|
1828
2185
|
* ```typescript
|
|
1829
|
-
* const result = await vana.data.addPermissionToFile(
|
|
2186
|
+
* const result = await vana.data.addPermissionToFile({
|
|
2187
|
+
* fileId: 123,
|
|
2188
|
+
* account: "0xRecipientAddress...",
|
|
2189
|
+
* publicKey: "0xRecipientPublicKey..."
|
|
2190
|
+
* });
|
|
1830
2191
|
* console.log(`Permission granted to ${result.account} for file ${result.fileId}`);
|
|
1831
2192
|
* console.log(`Transaction: ${result.transactionHash}`);
|
|
1832
2193
|
* ```
|
|
1833
2194
|
*/
|
|
1834
|
-
async addPermissionToFile(
|
|
1835
|
-
|
|
2195
|
+
async addPermissionToFile(params, options) {
|
|
2196
|
+
this.assertWallet();
|
|
2197
|
+
const { fileId, account, publicKey } = params;
|
|
2198
|
+
return await this.submitFilePermission(fileId, account, publicKey, options);
|
|
1836
2199
|
}
|
|
1837
2200
|
/**
|
|
1838
2201
|
* Submits a file permission transaction to the blockchain.
|
|
@@ -1845,7 +2208,7 @@ class DataController {
|
|
|
1845
2208
|
* @param fileId - The ID of the file to grant permission for
|
|
1846
2209
|
* @param account - The recipient's wallet address that will access the file
|
|
1847
2210
|
* @param publicKey - The recipient's public key for encryption.
|
|
1848
|
-
* Obtain via `vana.server.getIdentity(account).
|
|
2211
|
+
* Obtain via `vana.server.getIdentity(account).publicKey`
|
|
1849
2212
|
* @returns Promise resolving to TransactionResult for tracking the transaction
|
|
1850
2213
|
* @throws {Error} When chain ID is not available
|
|
1851
2214
|
* @throws {Error} When encryption key generation fails
|
|
@@ -1862,7 +2225,8 @@ class DataController {
|
|
|
1862
2225
|
* console.log(`Permission granted with ID: ${result.permissionId}`);
|
|
1863
2226
|
* ```
|
|
1864
2227
|
*/
|
|
1865
|
-
async submitFilePermission(fileId, account, publicKey) {
|
|
2228
|
+
async submitFilePermission(fileId, account, publicKey, options) {
|
|
2229
|
+
this.assertWallet();
|
|
1866
2230
|
try {
|
|
1867
2231
|
const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
|
|
1868
2232
|
this.context.walletClient,
|
|
@@ -1874,24 +2238,30 @@ class DataController {
|
|
|
1874
2238
|
publicKey,
|
|
1875
2239
|
this.context.platform
|
|
1876
2240
|
);
|
|
1877
|
-
const chainId = this.context.
|
|
2241
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1878
2242
|
if (!chainId) {
|
|
1879
2243
|
throw new Error("Chain ID not available");
|
|
1880
2244
|
}
|
|
1881
2245
|
const dataRegistryAddress = (0, import_addresses.getContractAddress)(chainId, "DataRegistry");
|
|
1882
2246
|
const dataRegistryAbi = (0, import_abi.getAbi)("DataRegistry");
|
|
2247
|
+
this.assertWallet();
|
|
2248
|
+
const walletAccount = this.context.walletClient.account ?? this.context.userAddress;
|
|
1883
2249
|
const txHash = await this.context.walletClient.writeContract({
|
|
1884
2250
|
address: dataRegistryAddress,
|
|
1885
2251
|
abi: dataRegistryAbi,
|
|
1886
2252
|
functionName: "addFilePermission",
|
|
1887
2253
|
args: [BigInt(fileId), account, encryptedKey],
|
|
1888
|
-
account:
|
|
1889
|
-
chain: this.context.walletClient.chain
|
|
2254
|
+
account: walletAccount,
|
|
2255
|
+
chain: this.context.walletClient.chain ?? null,
|
|
2256
|
+
...this.spreadTransactionOptions(options)
|
|
1890
2257
|
});
|
|
1891
|
-
|
|
2258
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
2259
|
+
return tx({
|
|
1892
2260
|
hash: txHash,
|
|
1893
|
-
from:
|
|
1894
|
-
|
|
2261
|
+
from: typeof walletAccount === "string" ? walletAccount : walletAccount.address,
|
|
2262
|
+
contract: "DataRegistry",
|
|
2263
|
+
fn: "addFilePermission"
|
|
2264
|
+
});
|
|
1895
2265
|
} catch (error) {
|
|
1896
2266
|
console.error("Failed to add permission to file:", error);
|
|
1897
2267
|
throw new Error(
|
|
@@ -1908,7 +2278,7 @@ class DataController {
|
|
|
1908
2278
|
*/
|
|
1909
2279
|
async getFilePermission(fileId, account) {
|
|
1910
2280
|
try {
|
|
1911
|
-
const chainId = this.context.
|
|
2281
|
+
const chainId = this.context.publicClient.chain?.id;
|
|
1912
2282
|
if (!chainId) {
|
|
1913
2283
|
throw new Error("Chain ID not available");
|
|
1914
2284
|
}
|
|
@@ -1917,7 +2287,7 @@ class DataController {
|
|
|
1917
2287
|
const dataRegistry = (0, import_viem.getContract)({
|
|
1918
2288
|
address: dataRegistryAddress,
|
|
1919
2289
|
abi: dataRegistryAbi,
|
|
1920
|
-
client: this.context.
|
|
2290
|
+
client: this.context.publicClient
|
|
1921
2291
|
});
|
|
1922
2292
|
const encryptedKey = await dataRegistry.read.filePermissions([
|
|
1923
2293
|
BigInt(fileId),
|
|
@@ -1941,12 +2311,13 @@ class DataController {
|
|
|
1941
2311
|
*
|
|
1942
2312
|
* @param file - The file to decrypt
|
|
1943
2313
|
* @param privateKey - The private key to decrypt the user's encryption key
|
|
1944
|
-
* @param
|
|
2314
|
+
* @param options - Optional decryption configuration
|
|
2315
|
+
* @param options.account - The account address that has permission (defaults to current wallet account)
|
|
1945
2316
|
* @returns Promise resolving to the decrypted file data
|
|
1946
2317
|
*/
|
|
1947
|
-
async decryptFileWithPermission(file, privateKey,
|
|
2318
|
+
async decryptFileWithPermission(file, privateKey, options) {
|
|
1948
2319
|
try {
|
|
1949
|
-
const permissionAccount = account
|
|
2320
|
+
const permissionAccount = options?.account ?? this.context.userAddress;
|
|
1950
2321
|
const encryptedKey = await this.getFilePermission(
|
|
1951
2322
|
file.id,
|
|
1952
2323
|
permissionAccount
|
|
@@ -2010,11 +2381,8 @@ class DataController {
|
|
|
2010
2381
|
*/
|
|
2011
2382
|
async fetch(url) {
|
|
2012
2383
|
try {
|
|
2013
|
-
const {
|
|
2014
|
-
const response = await
|
|
2015
|
-
url,
|
|
2016
|
-
this.context.downloadRelayer
|
|
2017
|
-
);
|
|
2384
|
+
const { universalFetch } = await import("../utils/download");
|
|
2385
|
+
const response = await universalFetch(url, this.context.downloadRelayer);
|
|
2018
2386
|
if (!response.ok) {
|
|
2019
2387
|
throw new Error(
|
|
2020
2388
|
`HTTP error! status: ${response.status} ${response.statusText}`
|
|
@@ -2079,7 +2447,7 @@ class DataController {
|
|
|
2079
2447
|
"https://dweb.link/ipfs/",
|
|
2080
2448
|
"https://ipfs.io/ipfs/"
|
|
2081
2449
|
];
|
|
2082
|
-
const gateways = options?.gateways
|
|
2450
|
+
const gateways = options?.gateways ?? this.context.ipfsGateways ?? defaultGateways;
|
|
2083
2451
|
const { extractIpfsHash } = await import("../utils/ipfs");
|
|
2084
2452
|
const cid = extractIpfsHash(url);
|
|
2085
2453
|
if (!cid) {
|
|
@@ -2208,7 +2576,7 @@ class DataController {
|
|
|
2208
2576
|
* ```
|
|
2209
2577
|
*/
|
|
2210
2578
|
validateDataAgainstSchema(data, schema) {
|
|
2211
|
-
|
|
2579
|
+
(0, import_schemaValidation.validateDataAgainstSchema)(data, schema);
|
|
2212
2580
|
}
|
|
2213
2581
|
/**
|
|
2214
2582
|
* Fetches and validates a data schema from a URL, then returns the parsed data schema.
|
|
@@ -2231,6 +2599,26 @@ class DataController {
|
|
|
2231
2599
|
async fetchAndValidateSchema(url) {
|
|
2232
2600
|
return (0, import_schemaValidation.fetchAndValidateSchema)(url);
|
|
2233
2601
|
}
|
|
2602
|
+
/**
|
|
2603
|
+
* Polls for confirmation of a relayer operation.
|
|
2604
|
+
* @internal
|
|
2605
|
+
*/
|
|
2606
|
+
async pollRelayerForConfirmation(operationId, options) {
|
|
2607
|
+
if (!this.context.relayer) {
|
|
2608
|
+
throw new Error("Relayer not configured for polling");
|
|
2609
|
+
}
|
|
2610
|
+
const pollingManager = new import_pollingManager.PollingManager(this.context.relayer);
|
|
2611
|
+
const result = await pollingManager.startPolling(operationId, {
|
|
2612
|
+
signal: options?.signal,
|
|
2613
|
+
onStatusUpdate: options?.onStatusUpdate,
|
|
2614
|
+
...options?.pollingOptions
|
|
2615
|
+
});
|
|
2616
|
+
return {
|
|
2617
|
+
fileId: 0,
|
|
2618
|
+
// This would need to be extracted from transaction events
|
|
2619
|
+
transactionHash: result.hash
|
|
2620
|
+
};
|
|
2621
|
+
}
|
|
2234
2622
|
}
|
|
2235
2623
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2236
2624
|
0 && (module.exports = {
|