@opendatalabs/vana-sdk 0.1.0-alpha.7ee7635 → 0.1.0-alpha.80df35f
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.d.ts +4 -2
- 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.d.ts +5 -2
- 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 -45
- package/dist/config/chains.d.ts +9 -13
- 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 +11 -49
- 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__/schemas-edge-cases.test.d.ts +1 -0
- package/dist/controllers/base.cjs +83 -0
- package/dist/controllers/base.cjs.map +1 -0
- package/dist/controllers/base.d.ts +84 -0
- package/dist/controllers/base.js +59 -0
- package/dist/controllers/base.js.map +1 -0
- package/dist/controllers/data-error-handling.test.d.ts +1 -0
- package/dist/controllers/data.cjs +338 -107
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +145 -46
- package/dist/controllers/data.js +338 -107
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/permissions.cjs +162 -223
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +24 -78
- package/dist/controllers/permissions.js +162 -223
- 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 +7 -56
- package/dist/controllers/protocol.js +15 -14
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +29 -36
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +8 -23
- package/dist/controllers/schemas.js +29 -36
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server-additional.test.d.ts +1 -0
- package/dist/controllers/server.cjs +15 -10
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +7 -20
- package/dist/controllers/server.js +15 -10
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/apiClient.cjs +15 -12
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +5 -9
- package/dist/core/apiClient.js +19 -19
- 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 +11 -9
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +9 -13
- package/dist/core/generics.js +22 -29
- package/dist/core/generics.js.map +1 -1
- 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 +82 -34
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +21 -73
- package/dist/core.js +105 -60
- 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 +4 -3
- package/dist/crypto/ecies/base.cjs.map +1 -1
- package/dist/crypto/ecies/base.d.ts +2 -5
- package/dist/crypto/ecies/base.js +12 -15
- 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/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 +16 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +53 -15
- package/dist/errors.js +18 -6
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.js.map +1 -1
- 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.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.js.map +1 -1
- package/dist/generated/abi/DataPortabilityServersImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
- package/dist/generated/abi/DataPortabilityServersImplementation.js.map +1 -1
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DataRegistryImplementation.d.ts +2 -3
- 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.d.ts +37 -39
- package/dist/generated/event-types.d.ts +9 -10
- package/dist/generated/eventRegistry.d.ts +3 -7
- 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.d.ts +329 -332
- package/dist/index.browser.d.ts +47 -96
- package/dist/index.browser.js +12 -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 +9 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +181 -87
- package/dist/index.node.js +10 -0
- package/dist/index.node.js.map +1 -1
- package/dist/node.d.ts +4 -2
- 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 +7 -6
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +3 -6
- package/dist/platform/browser.js +19 -27
- 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.d.ts +6 -8
- package/dist/platform/node.d.ts +3 -7
- package/dist/platform/node.js +12 -19
- 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/server/handler.cjs.map +1 -1
- package/dist/server/handler.d.ts +8 -227
- package/dist/server/handler.js.map +1 -1
- package/dist/storage/index.d.ts +56 -10
- package/dist/storage/manager.cjs +2 -2
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +2 -5
- package/dist/storage/manager.js +5 -12
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +3 -3
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +3 -9
- package/dist/storage/providers/callback-storage.js +3 -3
- 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 +5 -8
- 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-schema-validation.test.d.ts +1 -0
- package/dist/tests/permissions-server-files.test.d.ts +1 -0
- package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
- package/dist/tests/permissions.test.d.ts +1 -0
- package/dist/tests/personal.test.d.ts +1 -0
- package/dist/tests/platform-browser.test.d.ts +1 -0
- package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
- package/dist/tests/platform-crypto.test.d.ts +1 -0
- package/dist/tests/platform-index.test.d.ts +1 -0
- package/dist/tests/platform-node.test.d.ts +1 -0
- package/dist/tests/platform-shared-utils.test.d.ts +1 -0
- package/dist/tests/platform-updated.test.d.ts +1 -0
- package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
- package/dist/tests/protocol.test.d.ts +1 -0
- package/dist/tests/read-only-mode.test.d.ts +1 -0
- package/dist/tests/schemas.test.d.ts +1 -0
- package/dist/tests/server-handler.test.d.ts +1 -0
- package/dist/tests/setup.d.ts +7 -0
- package/dist/tests/signatureFormatter.test.d.ts +1 -0
- package/dist/tests/trusted-server-queries.test.d.ts +1 -0
- package/dist/tests/typedDataConverter.test.d.ts +1 -0
- package/dist/tests/types-contracts.test.d.ts +1 -0
- package/dist/tests/types-data.test.d.ts +1 -0
- package/dist/tests/types-external-apis.test.d.ts +1 -0
- package/dist/tests/types-generics.test.d.ts +1 -0
- package/dist/tests/types-permissions.test.d.ts +1 -0
- package/dist/tests/types-upload-params.test.d.ts +1 -0
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/tests/utils-formatters.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles.test.d.ts +1 -0
- package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
- package/dist/tests/utils-grants.test.d.ts +1 -0
- package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
- package/dist/tests/utils-ipfs.test.d.ts +4 -0
- package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
- package/dist/tests/vana.test.d.ts +1 -0
- package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
- package/dist/types/blockchain.cjs.map +1 -1
- package/dist/types/blockchain.d.ts +13 -8
- package/dist/types/chains-additional.test.d.ts +1 -0
- package/dist/types/chains.d.ts +6 -9
- package/dist/types/config.cjs +10 -0
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +161 -54
- 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 +8 -11
- package/dist/types/controller-context.cjs.map +1 -1
- package/dist/types/controller-context.d.ts +13 -20
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +107 -39
- package/dist/types/external-apis.d.ts +10 -12
- package/dist/types/generics.d.ts +35 -38
- package/dist/types/index.cjs +5 -4
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +20 -22
- package/dist/types/index.js +9 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/operations.cjs +2 -2
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +13 -17
- package/dist/types/operations.js +2 -2
- package/dist/types/operations.js.map +1 -1
- package/dist/types/permissions.d.ts +55 -58
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +6 -8
- package/dist/types/relayer.d.ts +15 -18
- package/dist/types/storage.d.ts +6 -8
- package/dist/types/storage.js +2 -5
- package/dist/types/storage.js.map +1 -1
- package/dist/types/transactionResults.d.ts +16 -18
- package/dist/types/utils.d.ts +21 -24
- package/dist/types.d.ts +4 -28
- package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
- package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
- package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
- package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
- package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
- package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
- package/dist/utils/blockchain/registry.cjs +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/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 +6 -10
- 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 +14 -17
- 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 +10 -13
- package/dist/utils/grants.js +1 -1
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/ipfs.d.ts +8 -10
- package/dist/utils/lazy-import.cjs +4 -6
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +1 -3
- 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.map +1 -1
- package/dist/utils/parseTransactionPojo.d.ts +4 -10
- package/dist/utils/parseTransactionPojo.js.map +1 -1
- 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 +1 -2
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +4 -7
- package/dist/utils/signatureCache.js +4 -8
- 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/tests/multicall.test.d.ts +1 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -1
- package/dist/utils/transactionHelpers.d.ts +5 -11
- package/dist/utils/transactionHelpers.js.map +1 -1
- 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.d.ts +3 -6
- package/dist/utils/urlResolver.cjs +1 -1
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +2 -4
- package/dist/utils/urlResolver.js +2 -2
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs +62 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +32 -0
- package/dist/utils/wallet.js +36 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/utils/withEvents.cjs.map +1 -1
- package/dist/utils/withEvents.d.ts +5 -12
- package/dist/utils/withEvents.js.map +1 -1
- package/package.json +22 -16
- 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 +0 -37
- 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 -401
- package/dist/config/chains.d.cts +0 -85
- package/dist/config/features.d.cts +0 -64
- package/dist/contracts/contractController.d.cts +0 -117
- package/dist/controllers/data.d.cts +0 -915
- package/dist/controllers/permissions.d.cts +0 -1383
- package/dist/controllers/protocol.d.cts +0 -188
- package/dist/controllers/schemas.d.cts +0 -260
- package/dist/controllers/server.d.cts +0 -230
- 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 -493
- 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/test-vectors/eccrypto-vectors.d.cts +0 -76
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +0 -76
- 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 -1014
- 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 -26547
- package/dist/generated/event-types.d.cts +0 -855
- package/dist/generated/eventRegistry.d.cts +0 -18
- 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 -201
- package/dist/index.d.cts +0 -2
- package/dist/index.node.d.cts +0 -87
- package/dist/node.d.cts +0 -2
- 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/schemas/dataSchema.schema.d.cts +0 -88
- package/dist/schemas/dataSchema.schema.d.ts +0 -88
- package/dist/schemas/grantFile.schema.d.cts +0 -57
- package/dist/schemas/grantFile.schema.d.ts +0 -57
- package/dist/server/handler.d.cts +0 -306
- 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/blockchain.d.cts +0 -52
- 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/controller-context.d.cts +0 -71
- 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 -22
- package/dist/types/operations.d.cts +0 -116
- 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 -195
- package/dist/types/utils.d.cts +0 -819
- package/dist/types.d.cts +0 -54
- 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/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/parseTransactionPojo.d.cts +0 -37
- 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/transactionHelpers.d.cts +0 -86
- package/dist/utils/typedDataConverter.d.cts +0 -13
- package/dist/utils/urlResolver.d.cts +0 -40
- package/dist/utils/withEvents.d.cts +0 -63
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/config.ts"],"sourcesContent":["import type { WalletClient, Account, Hash, Address } from \"viem\";\nimport type { VanaChainId, VanaChain } from \"./chains\";\nimport type {\n StorageProvider,\n StorageUploadResult,\n StorageListOptions,\n} from \"./storage\";\nimport type {\n PermissionGrantTypedData,\n TrustServerTypedData,\n UntrustServerTypedData,\n AddAndTrustServerTypedData,\n GenericTypedData,\n GrantFile,\n ServerFilesAndPermissionTypedData,\n} from \"./permissions\";\n\n/**\n * Marker interface to indicate that a Vana instance has storage configured.\n * Used for compile-time type safety to ensure storage-dependent methods\n * are only called on properly configured instances.\n *\n * @category Configuration\n */\nexport interface StorageRequiredMarker {\n readonly __storageRequired: true;\n}\n\n/**\n * Configuration for storage providers used by the SDK.\n *\n * Allows you to configure multiple storage backends (IPFS, Pinata, Google Drive, etc.)\n * and specify which one to use by default for file operations.\n *\n * **Provider Selection:**\n * - IPFS: Decentralized, permanent storage ideal for production\n * - Pinata: Managed IPFS with guaranteed availability\n * - Google Drive: Centralized, suitable for development/testing\n * - Custom providers: Implement StorageProvider interface\n *\n * @category Configuration\n * @example\n * ```typescript\n * const storage: StorageConfig = {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: 'your-key', secretKey: 'your-secret' })\n * },\n * defaultProvider: 'ipfs'\n * };\n * ```\n */\nexport interface StorageConfig {\n /**\n * Map of provider name to storage provider instance.\n * Common provider names: \"ipfs\", \"pinata\", \"googledrive\", \"s3\".\n * Custom names allowed for custom provider implementations.\n */\n providers: Record<string, StorageProvider>;\n /**\n * Default provider name to use when none specified.\n * Must match a key in the providers map. Falls back to first provider if not specified.\n */\n defaultProvider?: string;\n}\n\n/**\n * Download relayer callbacks for proxying CORS-restricted downloads.\n *\n * Provides a callback to proxy download requests through your application server\n * when direct browser access fails due to CORS restrictions (e.g., Google Drive).\n *\n * IMPORTANT SECURITY REQUIREMENTS for your proxy endpoint:\n * 1. MUST block requests to private/internal IPs (SSRF protection)\n * 2. SHOULD NOT restrict domains (files can be hosted anywhere)\n *\n * @category Configuration\n * @example Client-side implementation:\n * ```typescript\n * const downloadRelayer: DownloadRelayerCallbacks = {\n * async proxyDownload(url) {\n * const response = await fetch('/api/proxy', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ url })\n * });\n * return response.blob();\n * }\n * };\n * ```\n *\n * @example Server-side proxy endpoint (Next.js):\n * ```typescript\n * // /api/proxy/route.ts\n * import { promises as dns } from 'dns';\n * import { isIPv4 } from 'net';\n *\n * async function handleProxy(url: string) {\n * const { hostname } = new URL(url);\n *\n * // Resolve hostname to IP (handle localhost specially)\n * const ip = hostname === 'localhost' ? '127.0.0.1' :\n * isIPv4(hostname) ? hostname :\n * await dns.lookup(hostname).then(r => r.address);\n *\n * // SSRF Protection: Block private/internal IPs\n * if (isIPv4(ip)) {\n * const [a, b] = ip.split('.').map(Number);\n * if (a === 10 || a === 127 || a === 0 ||\n * (a === 172 && b >= 16 && b <= 31) ||\n * (a === 192 && b === 168) ||\n * (a === 169 && b === 254) ||\n * a >= 224) { // Also block multicast/reserved\n * return new Response('Private/internal addresses not allowed', { status: 403 });\n * }\n * }\n *\n * // Proxy the request\n * const response = await fetch(url, { redirect: 'manual' });\n *\n * // Handle redirects (with recursion limit)\n * if (response.status >= 301 && response.status <= 308) {\n * const location = response.headers.get('location');\n * if (location) return handleProxy(new URL(location, url).href);\n * }\n *\n * const data = await response.arrayBuffer();\n * return new Response(data, {\n * headers: {\n * 'Content-Type': response.headers.get('content-type') || 'application/octet-stream',\n * 'Access-Control-Allow-Origin': '*'\n * }\n * });\n * }\n * ```\n */\nexport interface DownloadRelayerCallbacks {\n /**\n * Proxy a download request through your application server\n *\n * @param url - The URL to download from\n * @returns Promise resolving to the downloaded content as a Blob\n */\n proxyDownload: (url: string) => Promise<Blob>;\n}\n\n/**\n * Relayer callback functions for handling gasless transactions.\n *\n * Instead of hardcoding HTTP/REST API calls, users can provide custom callback\n * functions to handle transaction relay in any way they choose (HTTP, WebSocket,\n * direct blockchain submission, etc.).\n *\n * @category Configuration\n * @example\n * ```typescript\n * const relayerCallbacks: RelayerCallbacks = {\n * async submitPermissionGrant(typedData, signature) {\n * // Custom implementation - could be HTTP, WebSocket, etc.\n * const response = await fetch('https://my-relayer.com/api/grant', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ typedData, signature })\n * });\n * const result = await response.json();\n * return result.transactionHash;\n * },\n *\n * async submitFileAddition(url, userAddress) {\n * // Custom relay implementation\n * return await myCustomRelayer.addFile(url, userAddress);\n * }\n * };\n * ```\n */\nexport interface RelayerCallbacks {\n /**\n * Submit a signed permission grant transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitPermissionGrant?: (\n typedData: PermissionGrantTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed permission revocation transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitPermissionRevoke?: (\n typedData: GenericTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed trust server transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitTrustServer?: (\n typedData: TrustServerTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed untrust server transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitUntrustServer?: (\n typedData: UntrustServerTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed add and trust server transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitAddAndTrustServer?: (\n typedData: AddAndTrustServerTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed permission addition transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitAddPermission?: (\n typedData: GenericTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed server files and permissions transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitAddServerFilesAndPermissions?: (\n typedData: ServerFilesAndPermissionTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a file addition for relay\n *\n * @deprecated Since v2.0.0 - Use submitFileAdditionComplete() instead for full support.\n * Will be removed in v3.0.0.\n *\n * Migration guide:\n * ```typescript\n * // Old:\n * await submitFileAddition(url, userAddress);\n *\n * // New:\n * await submitFileAdditionComplete({\n * url,\n * userAddress,\n * permissions: [] // Optional\n * });\n * ```\n * @param url - The file URL to register\n * @param userAddress - The user's address\n * @returns Promise resolving to object with fileId and transactionHash\n */\n submitFileAddition?: (\n url: string,\n userAddress: string,\n ) => Promise<{ fileId: number; transactionHash: Hash }>;\n\n /**\n * Submit a file addition with permissions for relay\n *\n * @deprecated Since v2.0.0 - Use submitFileAdditionComplete() instead for full support.\n * Will be removed in v3.0.0.\n *\n * Migration guide:\n * ```typescript\n * // Old:\n * await submitFileAdditionWithPermissions(url, userAddress, permissions);\n *\n * // New:\n * await submitFileAdditionComplete({\n * url,\n * userAddress,\n * permissions\n * });\n * ```\n * @param url - The file URL to register\n * @param userAddress - The user's address\n * @param permissions - Array of encrypted permissions\n * @returns Promise resolving to object with fileId and transactionHash\n */\n submitFileAdditionWithPermissions?: (\n url: string,\n userAddress: string,\n permissions: Array<{ account: string; key: string }>,\n ) => Promise<{ fileId: number; transactionHash: Hash }>;\n\n /**\n * Submit a comprehensive file addition with optional schema and permissions for relay\n *\n * This is the preferred callback that supports all file addition scenarios.\n * It can handle files with schemas, permissions, or both.\n *\n * @param params - Complete parameters for file addition\n * @param params.url - The file URL to register\n * @param params.userAddress - The user's address (defaults to connected wallet if not specified)\n * @param params.permissions - Array of encrypted permissions (empty array if none)\n * @param params.schemaId - Schema ID for validation (0 if none)\n * @param params.ownerAddress - Optional owner address (defaults to userAddress if not specified)\n * @returns Promise resolving to object with fileId and transactionHash\n */\n submitFileAdditionComplete?: (params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n schemaId: number;\n ownerAddress?: Address;\n }) => Promise<{ fileId: number; transactionHash: Hash }>;\n\n /**\n * Store a grant file for relay (e.g., upload to IPFS)\n *\n * @param grantData - The grant file data\n * @returns Promise resolving to the storage URL\n */\n storeGrantFile?: (grantData: GrantFile) => Promise<string>;\n}\n\n/**\n * Storage callback functions for flexible storage operations.\n *\n * Instead of hardcoding storage behavior (HTTP endpoints, etc.), users can provide\n * custom callback functions to handle storage operations in any way they choose.\n * This pattern matches the relayer callbacks approach, providing maximum flexibility.\n *\n * @category Configuration\n * @example\n * ```typescript\n * const storageCallbacks: StorageCallbacks = {\n * async upload(blob, filename, metadata) {\n * // Custom implementation - could be HTTP, S3, local filesystem, etc.\n * const formData = new FormData();\n * formData.append('file', blob, filename);\n * const response = await fetch('/api/storage/upload', {\n * method: 'POST',\n * body: formData\n * });\n * const data = await response.json();\n * return {\n * url: data.url,\n * size: blob.size,\n * contentType: blob.type,\n * metadata: data.metadata\n * };\n * },\n *\n * async download(identifier) {\n * const response = await fetch(`/api/storage/download/${identifier}`);\n * return response.blob();\n * }\n * };\n * ```\n */\nexport interface StorageCallbacks {\n /**\n * Upload a blob to storage\n *\n * @param blob - The data to upload\n * @param filename - Optional filename hint\n * @param metadata - Optional metadata for the upload\n * @returns Upload result with identifier and metadata\n */\n upload: (\n blob: Blob,\n filename?: string,\n metadata?: Record<string, unknown>,\n ) => Promise<StorageUploadResult>;\n\n /**\n * Download data from storage\n *\n * @param identifier - The storage identifier (could be URL, hash, path, or any unique ID)\n * @param options - Optional download options\n * @returns The downloaded data as a Blob\n */\n download: (\n identifier: string,\n options?: StorageDownloadOptions,\n ) => Promise<Blob>;\n\n /**\n * List stored items (optional)\n *\n * @param prefix - Optional prefix to filter results\n * @param options - Optional listing options\n * @returns Array of storage items with metadata\n */\n list?: (\n prefix?: string,\n options?: StorageListOptions,\n ) => Promise<StorageListResult>;\n\n /**\n * Delete a stored item (optional)\n *\n * @param identifier - The storage identifier to delete\n * @returns Promise that resolves to true if deletion succeeded\n */\n delete?: (identifier: string) => Promise<boolean>;\n\n /**\n * Extract identifier from a URL or return as-is (optional)\n * Used for backward compatibility with URL-based systems\n *\n * @param url - The URL to extract from\n * @returns The extracted identifier\n */\n extractIdentifier?: (url: string) => string;\n}\n\n/**\n * Options for storage download operations\n *\n * @category Configuration\n */\nexport interface StorageDownloadOptions {\n /** Optional HTTP headers */\n headers?: Record<string, string>;\n /** Optional abort signal for cancellation */\n signal?: AbortSignal;\n /** Optional byte range for partial downloads */\n range?: { start?: number; end?: number };\n}\n\n/**\n * Result from storage list operations\n *\n * @category Configuration\n */\nexport interface StorageListResult {\n /** Array of storage items */\n items: Array<{\n /** Item identifier */\n identifier: string;\n /** Item size in bytes */\n size?: number;\n /** Last modified timestamp */\n lastModified?: Date;\n /** Item metadata */\n metadata?: Record<string, unknown>;\n }>;\n /** Continuation token for pagination */\n continuationToken?: string;\n /** Whether more results are available */\n hasMore?: boolean;\n}\n\n/**\n * Base configuration interface without storage requirements\n *\n * @category Configuration\n */\nexport interface BaseConfig {\n /**\n * Optional relayer callback functions for handling gasless transactions.\n * Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.\n */\n relayerCallbacks?: RelayerCallbacks;\n\n /**\n * Optional download relayer for proxying CORS-restricted downloads.\n * Provides a proxy mechanism for files stored on servers with CORS restrictions.\n */\n downloadRelayer?: DownloadRelayerCallbacks;\n\n /**\n * Optional storage providers configuration for file upload/download.\n * Required for: upload(), grant() without pre-stored URLs, schema operations.\n * See StorageConfig for provider selection guidance.\n */\n storage?: StorageConfig;\n /**\n * Optional subgraph URL for querying user files and permissions.\n * If not provided, defaults to the built-in subgraph URL for the current chain.\n * Can be overridden per method call if needed.\n * Obtain chain-specific URLs from Vana documentation or deployment info.\n */\n subgraphUrl?: string;\n /**\n * Optional default IPFS gateways to use for fetching files.\n * These gateways will be used by default in fetchFromIPFS unless overridden per-call.\n * If not provided, the SDK will use public gateways.\n * Order matters: first successful gateway is used.\n *\n * @example ['https://gateway.pinata.cloud', 'https://ipfs.io']\n */\n ipfsGateways?: string[];\n /**\n * Default personal server base URL for server operations.\n * Required for ServerController methods like getIdentity(), createOperation(), etc.\n *\n * @example 'https://my-personal-server.example.com'\n */\n defaultPersonalServerUrl?: string;\n}\n\n/**\n * Base configuration interface that requires storage for storage-dependent operations\n *\n * @category Configuration\n */\nexport interface BaseConfigWithStorage {\n /**\n * Optional relayer callback functions for handling gasless transactions.\n * Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.\n */\n relayerCallbacks?: RelayerCallbacks;\n\n /**\n * Optional download relayer for proxying CORS-restricted downloads.\n * Provides a proxy mechanism for files stored on servers with CORS restrictions.\n */\n downloadRelayer?: DownloadRelayerCallbacks;\n\n /** Required storage providers configuration for file upload/download */\n storage: StorageConfig;\n /**\n * Optional subgraph URL for querying user files and permissions.\n * If not provided, defaults to the built-in subgraph URL for the current chain.\n * Can be overridden per method call if needed.\n */\n subgraphUrl?: string;\n /**\n * Optional default IPFS gateways to use for fetching files.\n * These gateways will be used by default in fetchFromIPFS unless overridden per-call.\n * If not provided, the SDK will use public gateways.\n *\n * @example ['https://gateway.pinata.cloud', 'https://ipfs.io']\n */\n ipfsGateways?: string[];\n /**\n * Default personal server base URL for server operations.\n * Required for ServerController methods like getIdentity(), createOperation(), etc.\n *\n * @example 'https://my-personal-server.example.com'\n */\n defaultPersonalServerUrl?: string;\n}\n\n/**\n * Configuration with wallet client\n *\n * @category Configuration\n */\nexport interface WalletConfig extends BaseConfig {\n /** The viem WalletClient instance used for signing transactions */\n walletClient: WalletClient & {\n chain: VanaChain;\n };\n}\n\n/**\n * Configuration with wallet client that requires storage\n *\n * @category Configuration\n */\nexport interface WalletConfigWithStorage extends BaseConfigWithStorage {\n /** The viem WalletClient instance used for signing transactions */\n walletClient: WalletClient & {\n chain: VanaChain;\n };\n}\n\n/**\n * Configuration with chain and account details\n *\n * @category Configuration\n */\nexport interface ChainConfig extends BaseConfig {\n /**\n * The chain ID for Vana network.\n * Supported: 14800 (Vana Mainnet), 14801 (Moksha Testnet), 31337 (Local Development).\n * Use chain constants from '@vana/sdk' for type safety.\n */\n chainId: VanaChainId;\n /**\n * RPC URL for the chain (optional, will use default for the chain if not provided).\n * Default URLs: mainnet (https://rpc.vana.org), testnet (https://rpc.moksha.vana.org).\n * Override for custom nodes or local development.\n */\n rpcUrl?: string;\n /**\n * Optional account for signing transactions.\n * Can be: privateKeyToAccount(), mnemonicToAccount(), or custom Account implementation.\n * Required for write operations; read-only operations work without account.\n */\n account?: Account;\n}\n\n/**\n * Configuration with chain and account details that requires storage\n *\n * @category Configuration\n */\nexport interface ChainConfigWithStorage extends BaseConfigWithStorage {\n /** The chain ID for Vana network */\n chainId: VanaChainId;\n /** RPC URL for the chain (optional, will use default for the chain if not provided) */\n rpcUrl?: string;\n /** Optional account for signing transactions */\n account?: Account;\n}\n\n/**\n * Main configuration interface for initializing the Vana SDK.\n *\n * You can configure the SDK using either a pre-configured wallet client\n * (WalletConfig) or by providing chain and account details (ChainConfig).\n * Both approaches support optional storage providers and relayer configuration.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Using WalletConfig with pre-configured client\n * const config: VanaConfig = {\n * walletClient: createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: moksha,\n * transport: http()\n * }),\n * relayerCallbacks: {\n * submitPermissionGrant: async (typedData, signature) => {\n * // Custom relay implementation\n * return await myRelayer.submit(typedData, signature);\n * }\n * }\n * };\n *\n * // Using ChainConfig with chain ID and account\n * const config: VanaConfig = {\n * chainId: 14800,\n * account: privateKeyToAccount('0x...'),\n * relayerCallbacks: {\n * submitPermissionGrant: async (typedData, signature) => {\n * // Custom relay implementation\n * return await myRelayer.submit(typedData, signature);\n * }\n * }\n * };\n * ```\n */\nexport type VanaConfig = WalletConfig | ChainConfig;\n\n/**\n * Configuration interface for Vana SDK that requires storage providers.\n *\n * Use this type when you need to ensure storage is configured for operations\n * like file uploads, permission grants without pre-stored URLs, or schema creation.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Configuration that guarantees storage availability\n * const config: VanaConfigWithStorage = {\n * walletClient: createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: moksha,\n * transport: http()\n * }),\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' })\n * },\n * defaultProvider: 'ipfs'\n * }\n * };\n * ```\n */\nexport type VanaConfigWithStorage =\n | WalletConfigWithStorage\n | ChainConfigWithStorage;\n\n/**\n * Runtime configuration information\n *\n * @category Configuration\n */\nexport interface RuntimeConfig {\n /** Current chain ID */\n chainId: VanaChainId;\n /** Current chain name */\n chainName: string;\n /** Available storage providers */\n storageProviders: string[];\n /** Default storage provider */\n defaultStorageProvider?: string;\n /** Current relayer callbacks configuration */\n relayerCallbacks?: RelayerCallbacks;\n}\n\n/**\n * Validates whether a configuration object is a WalletConfig.\n *\n * @param config - The configuration object to check\n * @returns True if the config is a WalletConfig (contains walletClient)\n * @example\n * ```typescript\n * if (isWalletConfig(config)) {\n * console.log('Using wallet client:', config.walletClient.account?.address);\n * } else {\n * console.log('Using chain config with chain ID:', config.chainId);\n * }\n * ```\n */\nexport function isWalletConfig(config: VanaConfig): config is WalletConfig {\n return \"walletClient\" in config;\n}\n\n/**\n * Validates whether a configuration object is a ChainConfig.\n *\n * @param config - The configuration object to check\n * @returns True if the config is a ChainConfig (contains chainId but not walletClient)\n * @example\n * ```typescript\n * if (isChainConfig(config)) {\n * console.log('Chain ID:', config.chainId);\n * console.log('RPC URL:', config.rpcUrl);\n * } else {\n * console.log('Using pre-configured wallet client');\n * }\n * ```\n */\nexport function isChainConfig(config: VanaConfig): config is ChainConfig {\n return \"chainId\" in config && !(\"walletClient\" in config);\n}\n\n/**\n * Validates whether a configuration has required storage providers.\n *\n * @param config - The configuration object to check\n * @returns True if the config has storage providers configured\n * @example\n * ```typescript\n * if (hasStorageConfig(config)) {\n * // Safe to use storage-dependent operations\n * await vana.data.uploadFile(file);\n * } else {\n * console.log('Storage not configured - some operations may fail');\n * }\n * ```\n */\nexport function hasStorageConfig(\n config: VanaConfig,\n): config is VanaConfigWithStorage {\n return (\n config.storage?.providers !== undefined &&\n Object.keys(config.storage.providers).length > 0\n );\n}\n\n/**\n * Configuration validation options\n *\n * @category Configuration\n */\nexport interface ConfigValidationOptions {\n /** Whether to validate storage providers */\n validateStorage?: boolean;\n /** Whether to validate relayer URL */\n validateRelayer?: boolean;\n /** Whether to validate chain configuration */\n validateChain?: boolean;\n}\n\n/**\n * Configuration validation result\n *\n * @category Configuration\n */\nexport interface ConfigValidationResult {\n /** Whether the configuration is valid */\n valid: boolean;\n /** List of validation errors */\n errors: string[];\n /** List of validation warnings */\n warnings: string[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6tBO,SAAS,eAAe,QAA4C;AACzE,SAAO,kBAAkB;AAC3B;AAiBO,SAAS,cAAc,QAA2C;AACvE,SAAO,aAAa,UAAU,EAAE,kBAAkB;AACpD;AAiBO,SAAS,iBACd,QACiC;AACjC,SACE,OAAO,SAAS,cAAc,UAC9B,OAAO,KAAK,OAAO,QAAQ,SAAS,EAAE,SAAS;AAEnD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/config.ts"],"sourcesContent":["import type {\n WalletClient,\n PublicClient,\n Account,\n Hash,\n Address,\n Chain,\n} from \"viem\";\nimport type { VanaChainId, VanaChain } from \"./chains\";\nimport type {\n StorageProvider,\n StorageUploadResult,\n StorageListOptions,\n} from \"./storage\";\nimport type {\n PermissionGrantTypedData,\n TrustServerTypedData,\n UntrustServerTypedData,\n AddAndTrustServerTypedData,\n GenericTypedData,\n GrantFile,\n ServerFilesAndPermissionTypedData,\n} from \"./permissions\";\n\n/**\n * Marker interface to indicate that a Vana instance has storage configured.\n * Used for compile-time type safety to ensure storage-dependent methods\n * are only called on properly configured instances.\n *\n * @category Configuration\n */\nexport interface StorageRequiredMarker {\n readonly __storageRequired: true;\n}\n\n/**\n * Configuration for storage providers used by the SDK.\n *\n * Allows you to configure multiple storage backends (IPFS, Pinata, Google Drive, etc.)\n * and specify which one to use by default for file operations.\n *\n * **Provider Selection:**\n * - IPFS: Decentralized, permanent storage ideal for production\n * - Pinata: Managed IPFS with guaranteed availability\n * - Google Drive: Centralized, suitable for development/testing\n * - Custom providers: Implement StorageProvider interface\n *\n * @category Configuration\n * @example\n * ```typescript\n * const storage: StorageConfig = {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' }),\n * pinata: new PinataStorage({ apiKey: 'your-key', secretKey: 'your-secret' })\n * },\n * defaultProvider: 'ipfs'\n * };\n * ```\n */\nexport interface StorageConfig {\n /**\n * Map of provider name to storage provider instance.\n * Common provider names: \"ipfs\", \"pinata\", \"googledrive\", \"s3\".\n * Custom names allowed for custom provider implementations.\n */\n providers: Record<string, StorageProvider>;\n /**\n * Default provider name to use when none specified.\n * Must match a key in the providers map. Falls back to first provider if not specified.\n */\n defaultProvider?: string;\n}\n\n/**\n * Download relayer callbacks for proxying CORS-restricted downloads.\n *\n * Provides a callback to proxy download requests through your application server\n * when direct browser access fails due to CORS restrictions (e.g., Google Drive).\n *\n * IMPORTANT SECURITY REQUIREMENTS for your proxy endpoint:\n * 1. MUST block requests to private/internal IPs (SSRF protection)\n * 2. SHOULD NOT restrict domains (files can be hosted anywhere)\n *\n * @category Configuration\n * @example Client-side implementation:\n * ```typescript\n * const downloadRelayer: DownloadRelayerCallbacks = {\n * async proxyDownload(url) {\n * const response = await fetch('/api/proxy', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ url })\n * });\n * return response.blob();\n * }\n * };\n * ```\n *\n * @example Server-side proxy endpoint (Next.js):\n * ```typescript\n * // /api/proxy/route.ts\n * import { promises as dns } from 'dns';\n * import { isIPv4 } from 'net';\n *\n * async function handleProxy(url: string) {\n * const { hostname } = new URL(url);\n *\n * // Resolve hostname to IP (handle localhost specially)\n * const ip = hostname === 'localhost' ? '127.0.0.1' :\n * isIPv4(hostname) ? hostname :\n * await dns.lookup(hostname).then(r => r.address);\n *\n * // SSRF Protection: Block private/internal IPs\n * if (isIPv4(ip)) {\n * const [a, b] = ip.split('.').map(Number);\n * if (a === 10 || a === 127 || a === 0 ||\n * (a === 172 && b >= 16 && b <= 31) ||\n * (a === 192 && b === 168) ||\n * (a === 169 && b === 254) ||\n * a >= 224) { // Also block multicast/reserved\n * return new Response('Private/internal addresses not allowed', { status: 403 });\n * }\n * }\n *\n * // Proxy the request\n * const response = await fetch(url, { redirect: 'manual' });\n *\n * // Handle redirects (with recursion limit)\n * if (response.status >= 301 && response.status <= 308) {\n * const location = response.headers.get('location');\n * if (location) return handleProxy(new URL(location, url).href);\n * }\n *\n * const data = await response.arrayBuffer();\n * return new Response(data, {\n * headers: {\n * 'Content-Type': response.headers.get('content-type') || 'application/octet-stream',\n * 'Access-Control-Allow-Origin': '*'\n * }\n * });\n * }\n * ```\n */\nexport interface DownloadRelayerCallbacks {\n /**\n * Proxy a download request through your application server\n *\n * @param url - The URL to download from\n * @returns Promise resolving to the downloaded content as a Blob\n */\n proxyDownload: (url: string) => Promise<Blob>;\n}\n\n/**\n * Relayer callback functions for handling gasless transactions.\n *\n * Instead of hardcoding HTTP/REST API calls, users can provide custom callback\n * functions to handle transaction relay in any way they choose (HTTP, WebSocket,\n * direct blockchain submission, etc.).\n *\n * @category Configuration\n * @example\n * ```typescript\n * const relayerCallbacks: RelayerCallbacks = {\n * async submitPermissionGrant(typedData, signature) {\n * // Custom implementation - could be HTTP, WebSocket, etc.\n * const response = await fetch('https://my-relayer.com/api/grant', {\n * method: 'POST',\n * headers: { 'Content-Type': 'application/json' },\n * body: JSON.stringify({ typedData, signature })\n * });\n * const result = await response.json();\n * return result.transactionHash;\n * },\n *\n * async submitFileAddition(url, userAddress) {\n * // Custom relay implementation\n * return await myCustomRelayer.addFile(url, userAddress);\n * }\n * };\n * ```\n */\nexport interface RelayerCallbacks {\n /**\n * Submit a signed permission grant transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitPermissionGrant?: (\n typedData: PermissionGrantTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed permission revocation transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitPermissionRevoke?: (\n typedData: GenericTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed trust server transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitTrustServer?: (\n typedData: TrustServerTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed untrust server transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitUntrustServer?: (\n typedData: UntrustServerTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed add and trust server transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitAddAndTrustServer?: (\n typedData: AddAndTrustServerTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed permission addition transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitAddPermission?: (\n typedData: GenericTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a signed server files and permissions transaction for relay\n *\n * @param typedData - The EIP-712 typed data that was signed\n * @param signature - The user's signature\n * @returns Promise resolving to the transaction hash\n */\n submitAddServerFilesAndPermissions?: (\n typedData: ServerFilesAndPermissionTypedData,\n signature: Hash,\n ) => Promise<Hash>;\n\n /**\n * Submit a file addition for relay\n *\n * @deprecated Since v2.0.0 - Use submitFileAdditionComplete() instead for full support.\n * Will be removed in v3.0.0.\n *\n * Migration guide:\n * ```typescript\n * // Old:\n * await submitFileAddition(url, userAddress);\n *\n * // New:\n * await submitFileAdditionComplete({\n * url,\n * userAddress,\n * permissions: [] // Optional\n * });\n * ```\n * @param url - The file URL to register\n * @param userAddress - The user's address\n * @returns Promise resolving to object with fileId and transactionHash\n */\n submitFileAddition?: (\n url: string,\n userAddress: string,\n ) => Promise<{ fileId: number; transactionHash: Hash }>;\n\n /**\n * Submit a file addition with permissions for relay\n *\n * @deprecated Since v2.0.0 - Use submitFileAdditionComplete() instead for full support.\n * Will be removed in v3.0.0.\n *\n * Migration guide:\n * ```typescript\n * // Old:\n * await submitFileAdditionWithPermissions(url, userAddress, permissions);\n *\n * // New:\n * await submitFileAdditionComplete({\n * url,\n * userAddress,\n * permissions\n * });\n * ```\n * @param url - The file URL to register\n * @param userAddress - The user's address\n * @param permissions - Array of encrypted permissions\n * @returns Promise resolving to object with fileId and transactionHash\n */\n submitFileAdditionWithPermissions?: (\n url: string,\n userAddress: string,\n permissions: Array<{ account: string; key: string }>,\n ) => Promise<{ fileId: number; transactionHash: Hash }>;\n\n /**\n * Submit a comprehensive file addition with optional schema and permissions for relay\n *\n * This is the preferred callback that supports all file addition scenarios.\n * It can handle files with schemas, permissions, or both.\n *\n * @param params - Complete parameters for file addition\n * @param params.url - The file URL to register\n * @param params.userAddress - The user's address (defaults to connected wallet if not specified)\n * @param params.permissions - Array of encrypted permissions (empty array if none)\n * @param params.schemaId - Schema ID for validation (0 if none)\n * @param params.ownerAddress - Optional owner address (defaults to userAddress if not specified)\n * @returns Promise resolving to object with fileId and transactionHash\n */\n submitFileAdditionComplete?: (params: {\n url: string;\n userAddress: Address;\n permissions: Array<{ account: Address; key: string }>;\n schemaId: number;\n ownerAddress?: Address;\n }) => Promise<{ fileId: number; transactionHash: Hash }>;\n\n /**\n * Store a grant file for relay (e.g., upload to IPFS)\n *\n * @param grantData - The grant file data\n * @returns Promise resolving to the storage URL\n */\n storeGrantFile?: (grantData: GrantFile) => Promise<string>;\n}\n\n/**\n * Storage callback functions for flexible storage operations.\n *\n * Instead of hardcoding storage behavior (HTTP endpoints, etc.), users can provide\n * custom callback functions to handle storage operations in any way they choose.\n * This pattern matches the relayer callbacks approach, providing maximum flexibility.\n *\n * @category Configuration\n * @example\n * ```typescript\n * const storageCallbacks: StorageCallbacks = {\n * async upload(blob, filename, metadata) {\n * // Custom implementation - could be HTTP, S3, local filesystem, etc.\n * const formData = new FormData();\n * formData.append('file', blob, filename);\n * const response = await fetch('/api/storage/upload', {\n * method: 'POST',\n * body: formData\n * });\n * const data = await response.json();\n * return {\n * url: data.url,\n * size: blob.size,\n * contentType: blob.type,\n * metadata: data.metadata\n * };\n * },\n *\n * async download(identifier) {\n * const response = await fetch(`/api/storage/download/${identifier}`);\n * return response.blob();\n * }\n * };\n * ```\n */\nexport interface StorageCallbacks {\n /**\n * Upload a blob to storage\n *\n * @param blob - The data to upload\n * @param filename - Optional filename hint\n * @param metadata - Optional metadata for the upload\n * @returns Upload result with identifier and metadata\n */\n upload: (\n blob: Blob,\n filename?: string,\n metadata?: Record<string, unknown>,\n ) => Promise<StorageUploadResult>;\n\n /**\n * Download data from storage\n *\n * @param identifier - The storage identifier (could be URL, hash, path, or any unique ID)\n * @param options - Optional download options\n * @returns The downloaded data as a Blob\n */\n download: (\n identifier: string,\n options?: StorageDownloadOptions,\n ) => Promise<Blob>;\n\n /**\n * List stored items (optional)\n *\n * @param prefix - Optional prefix to filter results\n * @param options - Optional listing options\n * @returns Array of storage items with metadata\n */\n list?: (\n prefix?: string,\n options?: StorageListOptions,\n ) => Promise<StorageListResult>;\n\n /**\n * Delete a stored item (optional)\n *\n * @param identifier - The storage identifier to delete\n * @returns Promise that resolves to true if deletion succeeded\n */\n delete?: (identifier: string) => Promise<boolean>;\n\n /**\n * Extract identifier from a URL or return as-is (optional)\n * Used for backward compatibility with URL-based systems\n *\n * @param url - The URL to extract from\n * @returns The extracted identifier\n */\n extractIdentifier?: (url: string) => string;\n}\n\n/**\n * Options for storage download operations\n *\n * @category Configuration\n */\nexport interface StorageDownloadOptions {\n /** Optional HTTP headers */\n headers?: Record<string, string>;\n /** Optional abort signal for cancellation */\n signal?: AbortSignal;\n /** Optional byte range for partial downloads */\n range?: { start?: number; end?: number };\n}\n\n/**\n * Result from storage list operations\n *\n * @category Configuration\n */\nexport interface StorageListResult {\n /** Array of storage items */\n items: Array<{\n /** Item identifier */\n identifier: string;\n /** Item size in bytes */\n size?: number;\n /** Last modified timestamp */\n lastModified?: Date;\n /** Item metadata */\n metadata?: Record<string, unknown>;\n }>;\n /** Continuation token for pagination */\n continuationToken?: string;\n /** Whether more results are available */\n hasMore?: boolean;\n}\n\n/**\n * Base configuration interface without storage requirements\n *\n * @category Configuration\n */\nexport interface BaseConfig {\n /**\n * Optional relayer callback functions for handling gasless transactions.\n * Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.\n */\n relayerCallbacks?: RelayerCallbacks;\n\n /**\n * Optional download relayer for proxying CORS-restricted downloads.\n * Provides a proxy mechanism for files stored on servers with CORS restrictions.\n */\n downloadRelayer?: DownloadRelayerCallbacks;\n\n /**\n * Optional storage providers configuration for file upload/download.\n * Required for: upload(), grant() without pre-stored URLs, schema operations.\n * See StorageConfig for provider selection guidance.\n */\n storage?: StorageConfig;\n /**\n * Optional subgraph URL for querying user files and permissions.\n * If not provided, defaults to the built-in subgraph URL for the current chain.\n * Can be overridden per method call if needed.\n * Obtain chain-specific URLs from Vana documentation or deployment info.\n */\n subgraphUrl?: string;\n /**\n * Optional default IPFS gateways to use for fetching files.\n * These gateways will be used by default in fetchFromIPFS unless overridden per-call.\n * If not provided, the SDK will use public gateways.\n * Order matters: first successful gateway is used.\n *\n * @example ['https://gateway.pinata.cloud', 'https://ipfs.io']\n */\n ipfsGateways?: string[];\n /**\n * Default personal server base URL for server operations.\n * Required for ServerController methods like getIdentity(), createOperation(), etc.\n *\n * @example 'https://my-personal-server.example.com'\n */\n defaultPersonalServerUrl?: string;\n}\n\n/**\n * Base configuration interface that requires storage for storage-dependent operations\n *\n * @category Configuration\n */\nexport interface BaseConfigWithStorage {\n /**\n * Optional relayer callback functions for handling gasless transactions.\n * Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.\n */\n relayerCallbacks?: RelayerCallbacks;\n\n /**\n * Optional download relayer for proxying CORS-restricted downloads.\n * Provides a proxy mechanism for files stored on servers with CORS restrictions.\n */\n downloadRelayer?: DownloadRelayerCallbacks;\n\n /** Required storage providers configuration for file upload/download */\n storage: StorageConfig;\n /**\n * Optional subgraph URL for querying user files and permissions.\n * If not provided, defaults to the built-in subgraph URL for the current chain.\n * Can be overridden per method call if needed.\n */\n subgraphUrl?: string;\n /**\n * Optional default IPFS gateways to use for fetching files.\n * These gateways will be used by default in fetchFromIPFS unless overridden per-call.\n * If not provided, the SDK will use public gateways.\n *\n * @example ['https://gateway.pinata.cloud', 'https://ipfs.io']\n */\n ipfsGateways?: string[];\n /**\n * Default personal server base URL for server operations.\n * Required for ServerController methods like getIdentity(), createOperation(), etc.\n *\n * @example 'https://my-personal-server.example.com'\n */\n defaultPersonalServerUrl?: string;\n}\n\n/**\n * Configuration with wallet client\n *\n * @category Configuration\n */\nexport interface WalletConfig extends BaseConfig {\n /** The viem WalletClient instance used for signing transactions */\n walletClient: WalletClient & {\n chain: VanaChain;\n };\n}\n\n/**\n * Configuration with wallet client that requires storage\n *\n * @category Configuration\n */\nexport interface WalletConfigWithStorage extends BaseConfigWithStorage {\n /** The viem WalletClient instance used for signing transactions */\n walletClient: WalletClient & {\n chain: VanaChain;\n };\n}\n\n/**\n * Configuration with chain and account details\n *\n * @category Configuration\n */\nexport interface ChainConfig extends BaseConfig {\n /**\n * The chain ID for Vana network.\n * Supported: 14800 (Vana Mainnet), 14801 (Moksha Testnet), 31337 (Local Development).\n * Use chain constants from '@vana/sdk' for type safety.\n */\n chainId: VanaChainId;\n /**\n * RPC URL for the chain (optional, will use default for the chain if not provided).\n * Default URLs: mainnet (https://rpc.vana.org), testnet (https://rpc.moksha.vana.org).\n * Override for custom nodes or local development.\n */\n rpcUrl?: string;\n /**\n * Optional account for signing transactions.\n * Can be: privateKeyToAccount(), mnemonicToAccount(), or custom Account implementation.\n * Required for write operations; read-only operations work without account.\n */\n account?: Account;\n}\n\n/**\n * Configuration with chain and account details that requires storage\n *\n * @category Configuration\n */\nexport interface ChainConfigWithStorage extends BaseConfigWithStorage {\n /** The chain ID for Vana network */\n chainId: VanaChainId;\n /** RPC URL for the chain (optional, will use default for the chain if not provided) */\n rpcUrl?: string;\n /** Optional account for signing transactions */\n account?: Account;\n}\n\n/**\n * Configuration with wallet client and optional public client\n *\n * @category Configuration\n */\nexport interface VanaConfigWithWallet extends BaseConfig {\n /** The viem WalletClient instance used for signing transactions */\n walletClient: WalletClient;\n /** Optional PublicClient for read operations (derived from wallet if not provided) */\n publicClient?: PublicClient;\n}\n\n/**\n * Configuration for read-only operations with public client and address\n *\n * @category Configuration\n */\nexport interface VanaConfigReadOnly extends BaseConfig {\n /** The viem PublicClient instance for read operations */\n publicClient: PublicClient;\n /** The user's address for read operations */\n address: Address;\n}\n\n/**\n * Configuration for minimal read-only operations with just an address\n *\n * @category Configuration\n */\nexport interface VanaConfigAddressOnly extends BaseConfig {\n /** The user's address for read operations */\n address: Address;\n /** Optional chain configuration (will use default if not provided) */\n chain?: Chain;\n}\n\n/**\n * Configuration with wallet client and optional public client that requires storage\n *\n * @category Configuration\n */\nexport interface VanaConfigWithWalletWithStorage extends BaseConfigWithStorage {\n /** The viem WalletClient instance used for signing transactions */\n walletClient: WalletClient;\n /** Optional PublicClient for read operations (derived from wallet if not provided) */\n publicClient?: PublicClient;\n}\n\n/**\n * Configuration for read-only operations with public client and address that requires storage\n *\n * @category Configuration\n */\nexport interface VanaConfigReadOnlyWithStorage extends BaseConfigWithStorage {\n /** The viem PublicClient instance for read operations */\n publicClient: PublicClient;\n /** The user's address for read operations */\n address: Address;\n}\n\n/**\n * Configuration for minimal read-only operations with just an address that requires storage\n *\n * @category Configuration\n */\nexport interface VanaConfigAddressOnlyWithStorage\n extends BaseConfigWithStorage {\n /** The user's address for read operations */\n address: Address;\n /** Optional chain configuration (will use default if not provided) */\n chain?: Chain;\n}\n\n/**\n * Main configuration interface for initializing the Vana SDK.\n *\n * The SDK supports three initialization modes:\n * 1. Full mode with wallet client for signing transactions\n * 2. Read-only mode with public client and address for read operations\n * 3. Minimal mode with just an address and optional chain\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Mode 1: Full configuration with wallet client\n * const configWithWallet: VanaConfig = {\n * walletClient: createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: moksha,\n * transport: http()\n * }),\n * publicClient: createPublicClient({\n * chain: moksha,\n * transport: http()\n * })\n * };\n *\n * // Mode 2: Read-only with public client and address\n * const configReadOnly: VanaConfig = {\n * publicClient: createPublicClient({\n * chain: moksha,\n * transport: http()\n * }),\n * address: '0x1234...'\n * };\n *\n * // Mode 3: Minimal with just address\n * const configMinimal: VanaConfig = {\n * address: '0x1234...',\n * chain: moksha // optional\n * };\n * ```\n */\nexport type VanaConfig =\n | VanaConfigWithWallet\n | VanaConfigReadOnly\n | VanaConfigAddressOnly\n | WalletConfig\n | ChainConfig;\n\n/**\n * Configuration interface for Vana SDK that requires storage providers.\n *\n * Use this type when you need to ensure storage is configured for operations\n * like file uploads, permission grants without pre-stored URLs, or schema creation.\n * Supports all three initialization modes with required storage.\n *\n * @category Configuration\n * @example\n * ```typescript\n * // Full configuration with wallet client and storage\n * const configWithWallet: VanaConfigWithStorage = {\n * walletClient: createWalletClient({\n * account: privateKeyToAccount('0x...'),\n * chain: moksha,\n * transport: http()\n * }),\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' })\n * },\n * defaultProvider: 'ipfs'\n * }\n * };\n *\n * // Read-only configuration with storage\n * const configReadOnly: VanaConfigWithStorage = {\n * publicClient: createPublicClient({\n * chain: moksha,\n * transport: http()\n * }),\n * address: '0x1234...',\n * storage: {\n * providers: {\n * ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' })\n * },\n * defaultProvider: 'ipfs'\n * }\n * };\n * ```\n */\nexport type VanaConfigWithStorage =\n | VanaConfigWithWalletWithStorage\n | VanaConfigReadOnlyWithStorage\n | VanaConfigAddressOnlyWithStorage\n | WalletConfigWithStorage\n | ChainConfigWithStorage;\n\n/**\n * Runtime configuration information\n *\n * @category Configuration\n */\nexport interface RuntimeConfig {\n /** Current chain ID */\n chainId: VanaChainId;\n /** Current chain name */\n chainName: string;\n /** Available storage providers */\n storageProviders: string[];\n /** Default storage provider */\n defaultStorageProvider?: string;\n /** Current relayer callbacks configuration */\n relayerCallbacks?: RelayerCallbacks;\n}\n\n/**\n * Validates whether a configuration object has a wallet client (any wallet-based config).\n *\n * @param config - The configuration object to check\n * @returns True if the config contains a walletClient\n * @example\n * ```typescript\n * if (isWalletConfig(config)) {\n * console.log('Using wallet client:', config.walletClient.account?.address);\n * } else {\n * console.log('Read-only or chain config');\n * }\n * ```\n */\nexport function isWalletConfig(\n config: VanaConfig,\n): config is VanaConfigWithWallet | WalletConfig {\n return \"walletClient\" in config;\n}\n\n/**\n * Validates whether a configuration object is a read-only config with public client.\n *\n * @param config - The configuration object to check\n * @returns True if the config has publicClient and address but no walletClient\n * @example\n * ```typescript\n * if (isReadOnlyConfig(config)) {\n * console.log('Read-only mode with address:', config.address);\n * }\n * ```\n */\nexport function isReadOnlyConfig(\n config: VanaConfig,\n): config is VanaConfigReadOnly {\n return (\n \"publicClient\" in config &&\n \"address\" in config &&\n !(\"walletClient\" in config)\n );\n}\n\n/**\n * Validates whether a configuration object is an address-only config.\n *\n * @param config - The configuration object to check\n * @returns True if the config has only address (and optionally chain) but no clients\n * @example\n * ```typescript\n * if (isAddressOnlyConfig(config)) {\n * console.log('Address-only mode:', config.address);\n * }\n * ```\n */\nexport function isAddressOnlyConfig(\n config: VanaConfig,\n): config is VanaConfigAddressOnly {\n return (\n \"address\" in config &&\n !(\"publicClient\" in config) &&\n !(\"walletClient\" in config) &&\n !(\"chainId\" in config)\n );\n}\n\n/**\n * Validates whether a configuration object is a ChainConfig.\n *\n * @param config - The configuration object to check\n * @returns True if the config is a ChainConfig (contains chainId but not walletClient)\n * @example\n * ```typescript\n * if (isChainConfig(config)) {\n * console.log('Chain ID:', config.chainId);\n * console.log('RPC URL:', config.rpcUrl);\n * } else {\n * console.log('Using pre-configured wallet client');\n * }\n * ```\n */\nexport function isChainConfig(config: VanaConfig): config is ChainConfig {\n return \"chainId\" in config && !(\"walletClient\" in config);\n}\n\n/**\n * Validates whether a configuration has required storage providers.\n *\n * @param config - The configuration object to check\n * @returns True if the config has storage providers configured\n * @example\n * ```typescript\n * if (hasStorageConfig(config)) {\n * // Safe to use storage-dependent operations\n * await vana.data.uploadFile(file);\n * } else {\n * console.log('Storage not configured - some operations may fail');\n * }\n * ```\n */\nexport function hasStorageConfig(\n config: VanaConfig,\n): config is VanaConfigWithStorage {\n return (\n config.storage?.providers !== undefined &&\n Object.keys(config.storage.providers).length > 0\n );\n}\n\n/**\n * Configuration validation options\n *\n * @category Configuration\n */\nexport interface ConfigValidationOptions {\n /** Whether to validate storage providers */\n validateStorage?: boolean;\n /** Whether to validate relayer URL */\n validateRelayer?: boolean;\n /** Whether to validate chain configuration */\n validateChain?: boolean;\n}\n\n/**\n * Configuration validation result\n *\n * @category Configuration\n */\nexport interface ConfigValidationResult {\n /** Whether the configuration is valid */\n valid: boolean;\n /** List of validation errors */\n errors: string[];\n /** List of validation warnings */\n warnings: string[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAu0BO,SAAS,eACd,QAC+C;AAC/C,SAAO,kBAAkB;AAC3B;AAcO,SAAS,iBACd,QAC8B;AAC9B,SACE,kBAAkB,UAClB,aAAa,UACb,EAAE,kBAAkB;AAExB;AAcO,SAAS,oBACd,QACiC;AACjC,SACE,aAAa,UACb,EAAE,kBAAkB,WACpB,EAAE,kBAAkB,WACpB,EAAE,aAAa;AAEnB;AAiBO,SAAS,cAAc,QAA2C;AACvE,SAAO,aAAa,UAAU,EAAE,kBAAkB;AACpD;AAiBO,SAAS,iBACd,QACiC;AACjC,SACE,OAAO,SAAS,cAAc,UAC9B,OAAO,KAAK,OAAO,QAAQ,SAAS,EAAE,SAAS;AAEnD;","names":[]}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Hash, Address,
|
|
2
|
-
import {
|
|
3
|
-
import { StorageProvider, StorageUploadResult, StorageListOptions } from
|
|
4
|
-
import { PermissionGrantTypedData,
|
|
5
|
-
|
|
1
|
+
import type { WalletClient, PublicClient, Account, Hash, Address, Chain } from "viem";
|
|
2
|
+
import type { VanaChainId, VanaChain } from "./chains";
|
|
3
|
+
import type { StorageProvider, StorageUploadResult, StorageListOptions } from "./storage";
|
|
4
|
+
import type { PermissionGrantTypedData, TrustServerTypedData, UntrustServerTypedData, AddAndTrustServerTypedData, GenericTypedData, GrantFile, ServerFilesAndPermissionTypedData } from "./permissions";
|
|
6
5
|
/**
|
|
7
6
|
* Marker interface to indicate that a Vana instance has storage configured.
|
|
8
7
|
* Used for compile-time type safety to ensure storage-dependent methods
|
|
@@ -10,7 +9,7 @@ import { PermissionGrantTypedData, GenericTypedData, TrustServerTypedData, Untru
|
|
|
10
9
|
*
|
|
11
10
|
* @category Configuration
|
|
12
11
|
*/
|
|
13
|
-
interface StorageRequiredMarker {
|
|
12
|
+
export interface StorageRequiredMarker {
|
|
14
13
|
readonly __storageRequired: true;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
@@ -37,7 +36,7 @@ interface StorageRequiredMarker {
|
|
|
37
36
|
* };
|
|
38
37
|
* ```
|
|
39
38
|
*/
|
|
40
|
-
interface StorageConfig {
|
|
39
|
+
export interface StorageConfig {
|
|
41
40
|
/**
|
|
42
41
|
* Map of provider name to storage provider instance.
|
|
43
42
|
* Common provider names: "ipfs", "pinata", "googledrive", "s3".
|
|
@@ -120,7 +119,7 @@ interface StorageConfig {
|
|
|
120
119
|
* }
|
|
121
120
|
* ```
|
|
122
121
|
*/
|
|
123
|
-
interface DownloadRelayerCallbacks {
|
|
122
|
+
export interface DownloadRelayerCallbacks {
|
|
124
123
|
/**
|
|
125
124
|
* Proxy a download request through your application server
|
|
126
125
|
*
|
|
@@ -158,7 +157,7 @@ interface DownloadRelayerCallbacks {
|
|
|
158
157
|
* };
|
|
159
158
|
* ```
|
|
160
159
|
*/
|
|
161
|
-
interface RelayerCallbacks {
|
|
160
|
+
export interface RelayerCallbacks {
|
|
162
161
|
/**
|
|
163
162
|
* Submit a signed permission grant transaction for relay
|
|
164
163
|
*
|
|
@@ -341,7 +340,7 @@ interface RelayerCallbacks {
|
|
|
341
340
|
* };
|
|
342
341
|
* ```
|
|
343
342
|
*/
|
|
344
|
-
interface StorageCallbacks {
|
|
343
|
+
export interface StorageCallbacks {
|
|
345
344
|
/**
|
|
346
345
|
* Upload a blob to storage
|
|
347
346
|
*
|
|
@@ -388,7 +387,7 @@ interface StorageCallbacks {
|
|
|
388
387
|
*
|
|
389
388
|
* @category Configuration
|
|
390
389
|
*/
|
|
391
|
-
interface StorageDownloadOptions {
|
|
390
|
+
export interface StorageDownloadOptions {
|
|
392
391
|
/** Optional HTTP headers */
|
|
393
392
|
headers?: Record<string, string>;
|
|
394
393
|
/** Optional abort signal for cancellation */
|
|
@@ -404,7 +403,7 @@ interface StorageDownloadOptions {
|
|
|
404
403
|
*
|
|
405
404
|
* @category Configuration
|
|
406
405
|
*/
|
|
407
|
-
interface StorageListResult {
|
|
406
|
+
export interface StorageListResult {
|
|
408
407
|
/** Array of storage items */
|
|
409
408
|
items: Array<{
|
|
410
409
|
/** Item identifier */
|
|
@@ -426,7 +425,7 @@ interface StorageListResult {
|
|
|
426
425
|
*
|
|
427
426
|
* @category Configuration
|
|
428
427
|
*/
|
|
429
|
-
interface BaseConfig {
|
|
428
|
+
export interface BaseConfig {
|
|
430
429
|
/**
|
|
431
430
|
* Optional relayer callback functions for handling gasless transactions.
|
|
432
431
|
* Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.
|
|
@@ -472,7 +471,7 @@ interface BaseConfig {
|
|
|
472
471
|
*
|
|
473
472
|
* @category Configuration
|
|
474
473
|
*/
|
|
475
|
-
interface BaseConfigWithStorage {
|
|
474
|
+
export interface BaseConfigWithStorage {
|
|
476
475
|
/**
|
|
477
476
|
* Optional relayer callback functions for handling gasless transactions.
|
|
478
477
|
* Provides flexible relay mechanism - can use HTTP, WebSocket, or any custom implementation.
|
|
@@ -512,7 +511,7 @@ interface BaseConfigWithStorage {
|
|
|
512
511
|
*
|
|
513
512
|
* @category Configuration
|
|
514
513
|
*/
|
|
515
|
-
interface WalletConfig extends BaseConfig {
|
|
514
|
+
export interface WalletConfig extends BaseConfig {
|
|
516
515
|
/** The viem WalletClient instance used for signing transactions */
|
|
517
516
|
walletClient: WalletClient & {
|
|
518
517
|
chain: VanaChain;
|
|
@@ -523,7 +522,7 @@ interface WalletConfig extends BaseConfig {
|
|
|
523
522
|
*
|
|
524
523
|
* @category Configuration
|
|
525
524
|
*/
|
|
526
|
-
interface WalletConfigWithStorage extends BaseConfigWithStorage {
|
|
525
|
+
export interface WalletConfigWithStorage extends BaseConfigWithStorage {
|
|
527
526
|
/** The viem WalletClient instance used for signing transactions */
|
|
528
527
|
walletClient: WalletClient & {
|
|
529
528
|
chain: VanaChain;
|
|
@@ -534,7 +533,7 @@ interface WalletConfigWithStorage extends BaseConfigWithStorage {
|
|
|
534
533
|
*
|
|
535
534
|
* @category Configuration
|
|
536
535
|
*/
|
|
537
|
-
interface ChainConfig extends BaseConfig {
|
|
536
|
+
export interface ChainConfig extends BaseConfig {
|
|
538
537
|
/**
|
|
539
538
|
* The chain ID for Vana network.
|
|
540
539
|
* Supported: 14800 (Vana Mainnet), 14801 (Moksha Testnet), 31337 (Local Development).
|
|
@@ -559,7 +558,7 @@ interface ChainConfig extends BaseConfig {
|
|
|
559
558
|
*
|
|
560
559
|
* @category Configuration
|
|
561
560
|
*/
|
|
562
|
-
interface ChainConfigWithStorage extends BaseConfigWithStorage {
|
|
561
|
+
export interface ChainConfigWithStorage extends BaseConfigWithStorage {
|
|
563
562
|
/** The chain ID for Vana network */
|
|
564
563
|
chainId: VanaChainId;
|
|
565
564
|
/** RPC URL for the chain (optional, will use default for the chain if not provided) */
|
|
@@ -567,56 +566,125 @@ interface ChainConfigWithStorage extends BaseConfigWithStorage {
|
|
|
567
566
|
/** Optional account for signing transactions */
|
|
568
567
|
account?: Account;
|
|
569
568
|
}
|
|
569
|
+
/**
|
|
570
|
+
* Configuration with wallet client and optional public client
|
|
571
|
+
*
|
|
572
|
+
* @category Configuration
|
|
573
|
+
*/
|
|
574
|
+
export interface VanaConfigWithWallet extends BaseConfig {
|
|
575
|
+
/** The viem WalletClient instance used for signing transactions */
|
|
576
|
+
walletClient: WalletClient;
|
|
577
|
+
/** Optional PublicClient for read operations (derived from wallet if not provided) */
|
|
578
|
+
publicClient?: PublicClient;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Configuration for read-only operations with public client and address
|
|
582
|
+
*
|
|
583
|
+
* @category Configuration
|
|
584
|
+
*/
|
|
585
|
+
export interface VanaConfigReadOnly extends BaseConfig {
|
|
586
|
+
/** The viem PublicClient instance for read operations */
|
|
587
|
+
publicClient: PublicClient;
|
|
588
|
+
/** The user's address for read operations */
|
|
589
|
+
address: Address;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Configuration for minimal read-only operations with just an address
|
|
593
|
+
*
|
|
594
|
+
* @category Configuration
|
|
595
|
+
*/
|
|
596
|
+
export interface VanaConfigAddressOnly extends BaseConfig {
|
|
597
|
+
/** The user's address for read operations */
|
|
598
|
+
address: Address;
|
|
599
|
+
/** Optional chain configuration (will use default if not provided) */
|
|
600
|
+
chain?: Chain;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Configuration with wallet client and optional public client that requires storage
|
|
604
|
+
*
|
|
605
|
+
* @category Configuration
|
|
606
|
+
*/
|
|
607
|
+
export interface VanaConfigWithWalletWithStorage extends BaseConfigWithStorage {
|
|
608
|
+
/** The viem WalletClient instance used for signing transactions */
|
|
609
|
+
walletClient: WalletClient;
|
|
610
|
+
/** Optional PublicClient for read operations (derived from wallet if not provided) */
|
|
611
|
+
publicClient?: PublicClient;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Configuration for read-only operations with public client and address that requires storage
|
|
615
|
+
*
|
|
616
|
+
* @category Configuration
|
|
617
|
+
*/
|
|
618
|
+
export interface VanaConfigReadOnlyWithStorage extends BaseConfigWithStorage {
|
|
619
|
+
/** The viem PublicClient instance for read operations */
|
|
620
|
+
publicClient: PublicClient;
|
|
621
|
+
/** The user's address for read operations */
|
|
622
|
+
address: Address;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Configuration for minimal read-only operations with just an address that requires storage
|
|
626
|
+
*
|
|
627
|
+
* @category Configuration
|
|
628
|
+
*/
|
|
629
|
+
export interface VanaConfigAddressOnlyWithStorage extends BaseConfigWithStorage {
|
|
630
|
+
/** The user's address for read operations */
|
|
631
|
+
address: Address;
|
|
632
|
+
/** Optional chain configuration (will use default if not provided) */
|
|
633
|
+
chain?: Chain;
|
|
634
|
+
}
|
|
570
635
|
/**
|
|
571
636
|
* Main configuration interface for initializing the Vana SDK.
|
|
572
637
|
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
*
|
|
638
|
+
* The SDK supports three initialization modes:
|
|
639
|
+
* 1. Full mode with wallet client for signing transactions
|
|
640
|
+
* 2. Read-only mode with public client and address for read operations
|
|
641
|
+
* 3. Minimal mode with just an address and optional chain
|
|
576
642
|
*
|
|
577
643
|
* @category Configuration
|
|
578
644
|
* @example
|
|
579
645
|
* ```typescript
|
|
580
|
-
* //
|
|
581
|
-
* const
|
|
646
|
+
* // Mode 1: Full configuration with wallet client
|
|
647
|
+
* const configWithWallet: VanaConfig = {
|
|
582
648
|
* walletClient: createWalletClient({
|
|
583
649
|
* account: privateKeyToAccount('0x...'),
|
|
584
650
|
* chain: moksha,
|
|
585
651
|
* transport: http()
|
|
586
652
|
* }),
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
* }
|
|
592
|
-
* }
|
|
653
|
+
* publicClient: createPublicClient({
|
|
654
|
+
* chain: moksha,
|
|
655
|
+
* transport: http()
|
|
656
|
+
* })
|
|
593
657
|
* };
|
|
594
658
|
*
|
|
595
|
-
* //
|
|
596
|
-
* const
|
|
597
|
-
*
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
659
|
+
* // Mode 2: Read-only with public client and address
|
|
660
|
+
* const configReadOnly: VanaConfig = {
|
|
661
|
+
* publicClient: createPublicClient({
|
|
662
|
+
* chain: moksha,
|
|
663
|
+
* transport: http()
|
|
664
|
+
* }),
|
|
665
|
+
* address: '0x1234...'
|
|
666
|
+
* };
|
|
667
|
+
*
|
|
668
|
+
* // Mode 3: Minimal with just address
|
|
669
|
+
* const configMinimal: VanaConfig = {
|
|
670
|
+
* address: '0x1234...',
|
|
671
|
+
* chain: moksha // optional
|
|
605
672
|
* };
|
|
606
673
|
* ```
|
|
607
674
|
*/
|
|
608
|
-
type VanaConfig = WalletConfig | ChainConfig;
|
|
675
|
+
export type VanaConfig = VanaConfigWithWallet | VanaConfigReadOnly | VanaConfigAddressOnly | WalletConfig | ChainConfig;
|
|
609
676
|
/**
|
|
610
677
|
* Configuration interface for Vana SDK that requires storage providers.
|
|
611
678
|
*
|
|
612
679
|
* Use this type when you need to ensure storage is configured for operations
|
|
613
680
|
* like file uploads, permission grants without pre-stored URLs, or schema creation.
|
|
681
|
+
* Supports all three initialization modes with required storage.
|
|
614
682
|
*
|
|
615
683
|
* @category Configuration
|
|
616
684
|
* @example
|
|
617
685
|
* ```typescript
|
|
618
|
-
* //
|
|
619
|
-
* const
|
|
686
|
+
* // Full configuration with wallet client and storage
|
|
687
|
+
* const configWithWallet: VanaConfigWithStorage = {
|
|
620
688
|
* walletClient: createWalletClient({
|
|
621
689
|
* account: privateKeyToAccount('0x...'),
|
|
622
690
|
* chain: moksha,
|
|
@@ -629,15 +697,30 @@ type VanaConfig = WalletConfig | ChainConfig;
|
|
|
629
697
|
* defaultProvider: 'ipfs'
|
|
630
698
|
* }
|
|
631
699
|
* };
|
|
700
|
+
*
|
|
701
|
+
* // Read-only configuration with storage
|
|
702
|
+
* const configReadOnly: VanaConfigWithStorage = {
|
|
703
|
+
* publicClient: createPublicClient({
|
|
704
|
+
* chain: moksha,
|
|
705
|
+
* transport: http()
|
|
706
|
+
* }),
|
|
707
|
+
* address: '0x1234...',
|
|
708
|
+
* storage: {
|
|
709
|
+
* providers: {
|
|
710
|
+
* ipfs: new IPFSStorage({ gateway: 'https://gateway.pinata.cloud' })
|
|
711
|
+
* },
|
|
712
|
+
* defaultProvider: 'ipfs'
|
|
713
|
+
* }
|
|
714
|
+
* };
|
|
632
715
|
* ```
|
|
633
716
|
*/
|
|
634
|
-
type VanaConfigWithStorage = WalletConfigWithStorage | ChainConfigWithStorage;
|
|
717
|
+
export type VanaConfigWithStorage = VanaConfigWithWalletWithStorage | VanaConfigReadOnlyWithStorage | VanaConfigAddressOnlyWithStorage | WalletConfigWithStorage | ChainConfigWithStorage;
|
|
635
718
|
/**
|
|
636
719
|
* Runtime configuration information
|
|
637
720
|
*
|
|
638
721
|
* @category Configuration
|
|
639
722
|
*/
|
|
640
|
-
interface RuntimeConfig {
|
|
723
|
+
export interface RuntimeConfig {
|
|
641
724
|
/** Current chain ID */
|
|
642
725
|
chainId: VanaChainId;
|
|
643
726
|
/** Current chain name */
|
|
@@ -650,20 +733,46 @@ interface RuntimeConfig {
|
|
|
650
733
|
relayerCallbacks?: RelayerCallbacks;
|
|
651
734
|
}
|
|
652
735
|
/**
|
|
653
|
-
* Validates whether a configuration object
|
|
736
|
+
* Validates whether a configuration object has a wallet client (any wallet-based config).
|
|
654
737
|
*
|
|
655
738
|
* @param config - The configuration object to check
|
|
656
|
-
* @returns True if the config
|
|
739
|
+
* @returns True if the config contains a walletClient
|
|
657
740
|
* @example
|
|
658
741
|
* ```typescript
|
|
659
742
|
* if (isWalletConfig(config)) {
|
|
660
743
|
* console.log('Using wallet client:', config.walletClient.account?.address);
|
|
661
744
|
* } else {
|
|
662
|
-
* console.log('
|
|
745
|
+
* console.log('Read-only or chain config');
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
export declare function isWalletConfig(config: VanaConfig): config is VanaConfigWithWallet | WalletConfig;
|
|
750
|
+
/**
|
|
751
|
+
* Validates whether a configuration object is a read-only config with public client.
|
|
752
|
+
*
|
|
753
|
+
* @param config - The configuration object to check
|
|
754
|
+
* @returns True if the config has publicClient and address but no walletClient
|
|
755
|
+
* @example
|
|
756
|
+
* ```typescript
|
|
757
|
+
* if (isReadOnlyConfig(config)) {
|
|
758
|
+
* console.log('Read-only mode with address:', config.address);
|
|
759
|
+
* }
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
export declare function isReadOnlyConfig(config: VanaConfig): config is VanaConfigReadOnly;
|
|
763
|
+
/**
|
|
764
|
+
* Validates whether a configuration object is an address-only config.
|
|
765
|
+
*
|
|
766
|
+
* @param config - The configuration object to check
|
|
767
|
+
* @returns True if the config has only address (and optionally chain) but no clients
|
|
768
|
+
* @example
|
|
769
|
+
* ```typescript
|
|
770
|
+
* if (isAddressOnlyConfig(config)) {
|
|
771
|
+
* console.log('Address-only mode:', config.address);
|
|
663
772
|
* }
|
|
664
773
|
* ```
|
|
665
774
|
*/
|
|
666
|
-
declare function
|
|
775
|
+
export declare function isAddressOnlyConfig(config: VanaConfig): config is VanaConfigAddressOnly;
|
|
667
776
|
/**
|
|
668
777
|
* Validates whether a configuration object is a ChainConfig.
|
|
669
778
|
*
|
|
@@ -679,7 +788,7 @@ declare function isWalletConfig(config: VanaConfig): config is WalletConfig;
|
|
|
679
788
|
* }
|
|
680
789
|
* ```
|
|
681
790
|
*/
|
|
682
|
-
declare function isChainConfig(config: VanaConfig): config is ChainConfig;
|
|
791
|
+
export declare function isChainConfig(config: VanaConfig): config is ChainConfig;
|
|
683
792
|
/**
|
|
684
793
|
* Validates whether a configuration has required storage providers.
|
|
685
794
|
*
|
|
@@ -695,13 +804,13 @@ declare function isChainConfig(config: VanaConfig): config is ChainConfig;
|
|
|
695
804
|
* }
|
|
696
805
|
* ```
|
|
697
806
|
*/
|
|
698
|
-
declare function hasStorageConfig(config: VanaConfig): config is VanaConfigWithStorage;
|
|
807
|
+
export declare function hasStorageConfig(config: VanaConfig): config is VanaConfigWithStorage;
|
|
699
808
|
/**
|
|
700
809
|
* Configuration validation options
|
|
701
810
|
*
|
|
702
811
|
* @category Configuration
|
|
703
812
|
*/
|
|
704
|
-
interface ConfigValidationOptions {
|
|
813
|
+
export interface ConfigValidationOptions {
|
|
705
814
|
/** Whether to validate storage providers */
|
|
706
815
|
validateStorage?: boolean;
|
|
707
816
|
/** Whether to validate relayer URL */
|
|
@@ -714,7 +823,7 @@ interface ConfigValidationOptions {
|
|
|
714
823
|
*
|
|
715
824
|
* @category Configuration
|
|
716
825
|
*/
|
|
717
|
-
interface ConfigValidationResult {
|
|
826
|
+
export interface ConfigValidationResult {
|
|
718
827
|
/** Whether the configuration is valid */
|
|
719
828
|
valid: boolean;
|
|
720
829
|
/** List of validation errors */
|
|
@@ -722,5 +831,3 @@ interface ConfigValidationResult {
|
|
|
722
831
|
/** List of validation warnings */
|
|
723
832
|
warnings: string[];
|
|
724
833
|
}
|
|
725
|
-
|
|
726
|
-
export { type BaseConfig, type BaseConfigWithStorage, type ChainConfig, type ChainConfigWithStorage, type ConfigValidationOptions, type ConfigValidationResult, type DownloadRelayerCallbacks, type RelayerCallbacks, type RuntimeConfig, type StorageCallbacks, type StorageConfig, type StorageDownloadOptions, type StorageListResult, type StorageRequiredMarker, type VanaConfig, type VanaConfigWithStorage, type WalletConfig, type WalletConfigWithStorage, hasStorageConfig, isChainConfig, isWalletConfig };
|
package/dist/types/config.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
function isWalletConfig(config) {
|
|
2
2
|
return "walletClient" in config;
|
|
3
3
|
}
|
|
4
|
+
function isReadOnlyConfig(config) {
|
|
5
|
+
return "publicClient" in config && "address" in config && !("walletClient" in config);
|
|
6
|
+
}
|
|
7
|
+
function isAddressOnlyConfig(config) {
|
|
8
|
+
return "address" in config && !("publicClient" in config) && !("walletClient" in config) && !("chainId" in config);
|
|
9
|
+
}
|
|
4
10
|
function isChainConfig(config) {
|
|
5
11
|
return "chainId" in config && !("walletClient" in config);
|
|
6
12
|
}
|
|
@@ -9,7 +15,9 @@ function hasStorageConfig(config) {
|
|
|
9
15
|
}
|
|
10
16
|
export {
|
|
11
17
|
hasStorageConfig,
|
|
18
|
+
isAddressOnlyConfig,
|
|
12
19
|
isChainConfig,
|
|
20
|
+
isReadOnlyConfig,
|
|
13
21
|
isWalletConfig
|
|
14
22
|
};
|
|
15
23
|
//# sourceMappingURL=config.js.map
|