@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
|
@@ -41,9 +41,10 @@ var import_grantValidation = require("../utils/grantValidation");
|
|
|
41
41
|
var import_signatureCache = require("../utils/signatureCache");
|
|
42
42
|
var import_signatureFormatter = require("../utils/signatureFormatter");
|
|
43
43
|
var import_typedDataConverter = require("../utils/typedDataConverter");
|
|
44
|
-
|
|
44
|
+
var import_base = require("./base");
|
|
45
|
+
class PermissionsController extends import_base.BaseController {
|
|
45
46
|
constructor(context) {
|
|
46
|
-
|
|
47
|
+
super(context);
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Grants permission for an application to access user data with gasless transactions.
|
|
@@ -80,6 +81,7 @@ class PermissionsController {
|
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
82
83
|
async grant(params) {
|
|
84
|
+
this.assertWallet();
|
|
83
85
|
const { typedData, signature } = await this.createAndSign(params);
|
|
84
86
|
const result = await this.submitSignedGrantWithEvents(typedData, signature);
|
|
85
87
|
return result;
|
|
@@ -110,6 +112,7 @@ class PermissionsController {
|
|
|
110
112
|
* ```
|
|
111
113
|
*/
|
|
112
114
|
async submitPermissionGrant(params) {
|
|
115
|
+
this.assertWallet();
|
|
113
116
|
const { typedData, signature } = await this.createAndSign(params);
|
|
114
117
|
return await this.submitSignedGrant(typedData, signature);
|
|
115
118
|
}
|
|
@@ -139,6 +142,7 @@ class PermissionsController {
|
|
|
139
142
|
* ```
|
|
140
143
|
*/
|
|
141
144
|
async prepareGrant(params) {
|
|
145
|
+
this.assertWallet();
|
|
142
146
|
try {
|
|
143
147
|
const grantFile = (0, import_grantFiles.createGrantFile)(params);
|
|
144
148
|
(0, import_grantValidation.validateGrant)(grantFile);
|
|
@@ -179,7 +183,7 @@ class PermissionsController {
|
|
|
179
183
|
*/
|
|
180
184
|
async confirmGrantInternal(params, grantFile) {
|
|
181
185
|
try {
|
|
182
|
-
let grantUrl = params
|
|
186
|
+
let { grantUrl } = params;
|
|
183
187
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
184
188
|
if (!grantUrl) {
|
|
185
189
|
if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
|
|
@@ -269,10 +273,11 @@ class PermissionsController {
|
|
|
269
273
|
* ```
|
|
270
274
|
*/
|
|
271
275
|
async createAndSign(params) {
|
|
276
|
+
this.assertWallet();
|
|
272
277
|
try {
|
|
273
278
|
const grantFile = (0, import_grantFiles.createGrantFile)(params);
|
|
274
279
|
(0, import_grantValidation.validateGrant)(grantFile);
|
|
275
|
-
let grantUrl = params
|
|
280
|
+
let { grantUrl } = params;
|
|
276
281
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
277
282
|
if (!grantUrl) {
|
|
278
283
|
if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
|
|
@@ -360,7 +365,7 @@ class PermissionsController {
|
|
|
360
365
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
361
366
|
JSON.stringify(
|
|
362
367
|
typedData,
|
|
363
|
-
(
|
|
368
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
364
369
|
2
|
|
365
370
|
)
|
|
366
371
|
);
|
|
@@ -369,7 +374,7 @@ class PermissionsController {
|
|
|
369
374
|
typedData,
|
|
370
375
|
signature
|
|
371
376
|
);
|
|
372
|
-
const account = this.context.walletClient
|
|
377
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
373
378
|
const { tx } = await import("../utils/transactionHelpers");
|
|
374
379
|
return tx({
|
|
375
380
|
hash,
|
|
@@ -421,11 +426,11 @@ class PermissionsController {
|
|
|
421
426
|
trustServerInput,
|
|
422
427
|
signature
|
|
423
428
|
);
|
|
424
|
-
const account = this.context.
|
|
429
|
+
const account = this.context.userAddress;
|
|
425
430
|
const { tx } = await import("../utils/transactionHelpers");
|
|
426
431
|
return tx({
|
|
427
432
|
hash,
|
|
428
|
-
from:
|
|
433
|
+
from: account,
|
|
429
434
|
contract: "DataPortabilityServers",
|
|
430
435
|
fn: "trustServerWithSignature"
|
|
431
436
|
});
|
|
@@ -486,7 +491,7 @@ class PermissionsController {
|
|
|
486
491
|
addAndTrustServerInput,
|
|
487
492
|
signature
|
|
488
493
|
);
|
|
489
|
-
const account = this.context.walletClient
|
|
494
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
490
495
|
const { tx } = await import("../utils/transactionHelpers");
|
|
491
496
|
return tx({
|
|
492
497
|
hash,
|
|
@@ -506,7 +511,7 @@ class PermissionsController {
|
|
|
506
511
|
}
|
|
507
512
|
/**
|
|
508
513
|
* Internal method to submit a signed grant and wait for events.
|
|
509
|
-
*
|
|
514
|
+
*
|
|
510
515
|
* @internal
|
|
511
516
|
* @param typedData - The EIP-712 typed data for the permission grant
|
|
512
517
|
* @param signature - The user's signature authorizing the transaction
|
|
@@ -520,7 +525,9 @@ class PermissionsController {
|
|
|
520
525
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
521
526
|
const event = result.expectedEvents.PermissionAdded;
|
|
522
527
|
if (!event) {
|
|
523
|
-
throw new import_errors.BlockchainError(
|
|
528
|
+
throw new import_errors.BlockchainError(
|
|
529
|
+
"PermissionAdded event not found in transaction"
|
|
530
|
+
);
|
|
524
531
|
}
|
|
525
532
|
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
526
533
|
hash: result.hash
|
|
@@ -537,7 +544,7 @@ class PermissionsController {
|
|
|
537
544
|
}
|
|
538
545
|
/**
|
|
539
546
|
* Internal method for confirm grant with events.
|
|
540
|
-
*
|
|
547
|
+
*
|
|
541
548
|
* @internal
|
|
542
549
|
* @param params - The permission grant parameters
|
|
543
550
|
* @param grantFile - The pre-created grant file object
|
|
@@ -551,7 +558,9 @@ class PermissionsController {
|
|
|
551
558
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
552
559
|
const event = result.expectedEvents.PermissionAdded;
|
|
553
560
|
if (!event) {
|
|
554
|
-
throw new import_errors.BlockchainError(
|
|
561
|
+
throw new import_errors.BlockchainError(
|
|
562
|
+
"PermissionAdded event not found in transaction"
|
|
563
|
+
);
|
|
555
564
|
}
|
|
556
565
|
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
557
566
|
hash: result.hash
|
|
@@ -566,34 +575,6 @@ class PermissionsController {
|
|
|
566
575
|
fileIds: event.fileIds
|
|
567
576
|
};
|
|
568
577
|
}
|
|
569
|
-
/**
|
|
570
|
-
* Internal method to submit a signed revoke and wait for events.
|
|
571
|
-
*
|
|
572
|
-
* @internal
|
|
573
|
-
* @param typedData - The EIP-712 typed data for the permission revoke
|
|
574
|
-
* @param signature - The user's signature authorizing the transaction
|
|
575
|
-
* @returns Promise resolving to PermissionRevokeResult with parsed events
|
|
576
|
-
*/
|
|
577
|
-
async submitSignedRevokeWithEvents(typedData, signature) {
|
|
578
|
-
const txResult = await this.submitSignedRevoke(typedData, signature);
|
|
579
|
-
if (!this.context.waitForTransactionEvents) {
|
|
580
|
-
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
581
|
-
}
|
|
582
|
-
const result = await this.context.waitForTransactionEvents(txResult);
|
|
583
|
-
const event = result.expectedEvents.PermissionRevoked;
|
|
584
|
-
if (!event) {
|
|
585
|
-
throw new import_errors.BlockchainError("PermissionRevoked event not found in transaction");
|
|
586
|
-
}
|
|
587
|
-
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
588
|
-
hash: result.hash
|
|
589
|
-
});
|
|
590
|
-
return {
|
|
591
|
-
transactionHash: result.hash,
|
|
592
|
-
blockNumber: receipt.blockNumber,
|
|
593
|
-
gasUsed: receipt.gasUsed,
|
|
594
|
-
permissionId: event.permissionId
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
578
|
/**
|
|
598
579
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
599
580
|
*
|
|
@@ -624,9 +605,12 @@ class PermissionsController {
|
|
|
624
605
|
signature
|
|
625
606
|
);
|
|
626
607
|
} else {
|
|
627
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
608
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
609
|
+
typedData,
|
|
610
|
+
signature
|
|
611
|
+
);
|
|
628
612
|
}
|
|
629
|
-
const account = this.context.walletClient
|
|
613
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
630
614
|
const { tx } = await import("../utils/transactionHelpers");
|
|
631
615
|
return tx({
|
|
632
616
|
hash,
|
|
@@ -674,9 +658,12 @@ class PermissionsController {
|
|
|
674
658
|
signature
|
|
675
659
|
);
|
|
676
660
|
} else {
|
|
677
|
-
hash = await this.submitSignedUntrustTransaction(
|
|
661
|
+
hash = await this.submitSignedUntrustTransaction(
|
|
662
|
+
typedData,
|
|
663
|
+
signature
|
|
664
|
+
);
|
|
678
665
|
}
|
|
679
|
-
const account = this.context.walletClient
|
|
666
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
680
667
|
const { tx } = await import("../utils/transactionHelpers");
|
|
681
668
|
return tx({
|
|
682
669
|
hash,
|
|
@@ -707,7 +694,8 @@ class PermissionsController {
|
|
|
707
694
|
* @throws {BlockchainError} When contract submission fails
|
|
708
695
|
*/
|
|
709
696
|
async submitDirectTransaction(typedData, signature) {
|
|
710
|
-
|
|
697
|
+
this.assertWallet();
|
|
698
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
711
699
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
712
700
|
chainId,
|
|
713
701
|
"DataPortabilityPermissions"
|
|
@@ -727,17 +715,17 @@ class PermissionsController {
|
|
|
727
715
|
console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
|
|
728
716
|
console.debug(
|
|
729
717
|
"\u{1F50D} Debug - Grant field length:",
|
|
730
|
-
typedData.message.grant?.length
|
|
718
|
+
typedData.message.grant?.length ?? 0
|
|
731
719
|
);
|
|
732
720
|
const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
|
|
733
|
-
const account = this.context.walletClient
|
|
721
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
734
722
|
const txHash = await this.context.walletClient.writeContract({
|
|
735
723
|
address: DataPortabilityPermissionsAddress,
|
|
736
724
|
abi: DataPortabilityPermissionsAbi,
|
|
737
725
|
functionName: "addPermission",
|
|
738
726
|
args: [permissionInput, formattedSignature],
|
|
739
727
|
account,
|
|
740
|
-
chain: this.context.walletClient
|
|
728
|
+
chain: this.context.walletClient?.chain ?? null
|
|
741
729
|
});
|
|
742
730
|
const { tx } = await import("../utils/transactionHelpers");
|
|
743
731
|
return tx({
|
|
@@ -772,6 +760,7 @@ class PermissionsController {
|
|
|
772
760
|
* ```
|
|
773
761
|
*/
|
|
774
762
|
async revoke(params) {
|
|
763
|
+
this.assertWallet();
|
|
775
764
|
const txResult = await this.submitPermissionRevoke(params);
|
|
776
765
|
if (!this.context.waitForTransactionEvents) {
|
|
777
766
|
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
@@ -779,7 +768,9 @@ class PermissionsController {
|
|
|
779
768
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
780
769
|
const event = result.expectedEvents.PermissionRevoked;
|
|
781
770
|
if (!event) {
|
|
782
|
-
throw new import_errors.BlockchainError(
|
|
771
|
+
throw new import_errors.BlockchainError(
|
|
772
|
+
"PermissionRevoked event not found in transaction"
|
|
773
|
+
);
|
|
783
774
|
}
|
|
784
775
|
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
785
776
|
hash: result.hash
|
|
@@ -811,11 +802,12 @@ class PermissionsController {
|
|
|
811
802
|
* ```
|
|
812
803
|
*/
|
|
813
804
|
async submitPermissionRevoke(params) {
|
|
805
|
+
this.assertWallet();
|
|
814
806
|
try {
|
|
815
|
-
if (!this.context.walletClient
|
|
807
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
816
808
|
throw new import_errors.BlockchainError("Chain ID not available");
|
|
817
809
|
}
|
|
818
|
-
const chainId = await this.context.
|
|
810
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
819
811
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
820
812
|
chainId,
|
|
821
813
|
"DataPortabilityPermissions"
|
|
@@ -823,14 +815,14 @@ class PermissionsController {
|
|
|
823
815
|
const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
|
|
824
816
|
"DataPortabilityPermissions"
|
|
825
817
|
);
|
|
826
|
-
const account = this.context.walletClient
|
|
818
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
827
819
|
const txHash = await this.context.walletClient.writeContract({
|
|
828
820
|
address: DataPortabilityPermissionsAddress,
|
|
829
821
|
abi: DataPortabilityPermissionsAbi,
|
|
830
822
|
functionName: "revokePermission",
|
|
831
823
|
args: [params.permissionId],
|
|
832
824
|
account,
|
|
833
|
-
chain: this.context.walletClient
|
|
825
|
+
chain: this.context.walletClient?.chain ?? null
|
|
834
826
|
});
|
|
835
827
|
const { tx } = await import("../utils/transactionHelpers");
|
|
836
828
|
return tx({
|
|
@@ -878,8 +870,9 @@ class PermissionsController {
|
|
|
878
870
|
* ```
|
|
879
871
|
*/
|
|
880
872
|
async submitRevokeWithSignature(params) {
|
|
873
|
+
this.assertWallet();
|
|
881
874
|
try {
|
|
882
|
-
if (!this.context.walletClient
|
|
875
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
883
876
|
throw new import_errors.BlockchainError("Chain ID not available");
|
|
884
877
|
}
|
|
885
878
|
const nonce = await this.getPermissionsUserNonce();
|
|
@@ -906,9 +899,12 @@ class PermissionsController {
|
|
|
906
899
|
signature
|
|
907
900
|
);
|
|
908
901
|
} else {
|
|
909
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
902
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
903
|
+
typedData,
|
|
904
|
+
signature
|
|
905
|
+
);
|
|
910
906
|
}
|
|
911
|
-
const account = this.context.walletClient
|
|
907
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
912
908
|
const { tx } = await import("../utils/transactionHelpers");
|
|
913
909
|
return tx({
|
|
914
910
|
hash,
|
|
@@ -923,64 +919,6 @@ class PermissionsController {
|
|
|
923
919
|
);
|
|
924
920
|
}
|
|
925
921
|
}
|
|
926
|
-
/**
|
|
927
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
928
|
-
*
|
|
929
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
930
|
-
* This method is deprecated in favor of more specific nonce methods.
|
|
931
|
-
*
|
|
932
|
-
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
933
|
-
* be incremented with each transaction to maintain security.
|
|
934
|
-
*
|
|
935
|
-
* @returns Promise resolving to the user's current nonce value as a bigint
|
|
936
|
-
* @throws {Error} When wallet account is not available
|
|
937
|
-
* @throws {Error} When chain ID is not available
|
|
938
|
-
* @throws {NonceError} When reading nonce from contract fails
|
|
939
|
-
* @private
|
|
940
|
-
* @example
|
|
941
|
-
* ```typescript
|
|
942
|
-
* // Deprecated - use specific methods instead
|
|
943
|
-
* const nonce = await this.getUserNonce();
|
|
944
|
-
*
|
|
945
|
-
* // Use these instead:
|
|
946
|
-
* const permissionsNonce = await this.getPermissionsUserNonce();
|
|
947
|
-
* const serversNonce = await this.getServersUserNonce();
|
|
948
|
-
* ```
|
|
949
|
-
*/
|
|
950
|
-
/**
|
|
951
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
952
|
-
*
|
|
953
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
954
|
-
*
|
|
955
|
-
* @remarks
|
|
956
|
-
* This method is deprecated in favor of more specific nonce methods that target
|
|
957
|
-
* the appropriate contract for the operation being performed.
|
|
958
|
-
*
|
|
959
|
-
* @returns Promise resolving to the user's current nonce as a bigint
|
|
960
|
-
* @throws {NonceError} When retrieving the nonce fails
|
|
961
|
-
*/
|
|
962
|
-
async getUserNonce() {
|
|
963
|
-
try {
|
|
964
|
-
const userAddress = await this.getUserAddress();
|
|
965
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
966
|
-
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
967
|
-
chainId,
|
|
968
|
-
"DataPortabilityServers"
|
|
969
|
-
);
|
|
970
|
-
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
971
|
-
const nonce = await this.context.publicClient.readContract({
|
|
972
|
-
address: DataPortabilityServersAddress,
|
|
973
|
-
abi: DataPortabilityServersAbi,
|
|
974
|
-
functionName: "userNonce",
|
|
975
|
-
args: [userAddress]
|
|
976
|
-
});
|
|
977
|
-
return nonce;
|
|
978
|
-
} catch (error) {
|
|
979
|
-
throw new import_errors.NonceError(
|
|
980
|
-
`Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
981
|
-
);
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
922
|
/**
|
|
985
923
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
986
924
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
@@ -1007,8 +945,8 @@ class PermissionsController {
|
|
|
1007
945
|
*/
|
|
1008
946
|
async getServersUserNonce() {
|
|
1009
947
|
try {
|
|
1010
|
-
const userAddress =
|
|
1011
|
-
const chainId = await this.context.
|
|
948
|
+
const userAddress = this.context.userAddress;
|
|
949
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1012
950
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1013
951
|
chainId,
|
|
1014
952
|
"DataPortabilityServers"
|
|
@@ -1053,8 +991,8 @@ class PermissionsController {
|
|
|
1053
991
|
*/
|
|
1054
992
|
async getPermissionsUserNonce() {
|
|
1055
993
|
try {
|
|
1056
|
-
const userAddress =
|
|
1057
|
-
const chainId = await this.context.
|
|
994
|
+
const userAddress = this.context.userAddress;
|
|
995
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1058
996
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
1059
997
|
chainId,
|
|
1060
998
|
"DataPortabilityPermissions"
|
|
@@ -1093,7 +1031,7 @@ class PermissionsController {
|
|
|
1093
1031
|
"\u{1F50D} Debug - Composing permission message with grantUrl:",
|
|
1094
1032
|
params.grantUrl
|
|
1095
1033
|
);
|
|
1096
|
-
const chainId = await this.context.
|
|
1034
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1097
1035
|
const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
|
|
1098
1036
|
chainId,
|
|
1099
1037
|
"DataPortabilityGrantees"
|
|
@@ -1202,7 +1140,7 @@ class PermissionsController {
|
|
|
1202
1140
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1203
1141
|
*/
|
|
1204
1142
|
async getPermissionDomain() {
|
|
1205
|
-
const chainId = await this.context.
|
|
1143
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1206
1144
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
1207
1145
|
chainId,
|
|
1208
1146
|
"DataPortabilityPermissions"
|
|
@@ -1221,8 +1159,9 @@ class PermissionsController {
|
|
|
1221
1159
|
* @returns Promise resolving to the cryptographic signature
|
|
1222
1160
|
*/
|
|
1223
1161
|
async signTypedData(typedData) {
|
|
1162
|
+
this.assertWallet();
|
|
1224
1163
|
try {
|
|
1225
|
-
const walletAddress = this.context.walletClient.account?.address
|
|
1164
|
+
const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
|
|
1226
1165
|
return await (0, import_signatureCache.withSignatureCache)(
|
|
1227
1166
|
this.context.platform.cache,
|
|
1228
1167
|
walletAddress,
|
|
@@ -1231,9 +1170,9 @@ class PermissionsController {
|
|
|
1231
1170
|
const viemCompatibleTypedData = (0, import_typedDataConverter.toViemTypedDataDefinition)(typedData);
|
|
1232
1171
|
return await this.context.walletClient.signTypedData({
|
|
1233
1172
|
...viemCompatibleTypedData,
|
|
1234
|
-
//
|
|
1235
|
-
//
|
|
1236
|
-
account: this.context.walletClient.account
|
|
1173
|
+
// Use the account if available, otherwise use the wallet address
|
|
1174
|
+
// This follows the same pattern used throughout this file
|
|
1175
|
+
account: this.context.walletClient.account ?? walletAddress
|
|
1237
1176
|
});
|
|
1238
1177
|
}
|
|
1239
1178
|
);
|
|
@@ -1248,17 +1187,10 @@ class PermissionsController {
|
|
|
1248
1187
|
}
|
|
1249
1188
|
}
|
|
1250
1189
|
/**
|
|
1251
|
-
* Gets the user's address from the
|
|
1190
|
+
* Gets the user's address from the context.
|
|
1252
1191
|
*
|
|
1253
|
-
* @returns
|
|
1192
|
+
* @returns The user's address
|
|
1254
1193
|
*/
|
|
1255
|
-
async getUserAddress() {
|
|
1256
|
-
const addresses = await this.context.walletClient.getAddresses();
|
|
1257
|
-
if (addresses.length === 0) {
|
|
1258
|
-
throw new import_errors.BlockchainError("No addresses available in wallet client");
|
|
1259
|
-
}
|
|
1260
|
-
return addresses[0];
|
|
1261
|
-
}
|
|
1262
1194
|
/**
|
|
1263
1195
|
* Gets on-chain permission grant data without expensive off-chain resolution.
|
|
1264
1196
|
*
|
|
@@ -1297,8 +1229,8 @@ class PermissionsController {
|
|
|
1297
1229
|
async getUserPermissionGrantsOnChain(options = {}) {
|
|
1298
1230
|
const { limit = 50, subgraphUrl } = options;
|
|
1299
1231
|
try {
|
|
1300
|
-
const userAddress =
|
|
1301
|
-
const graphqlEndpoint = subgraphUrl
|
|
1232
|
+
const userAddress = this.context.userAddress;
|
|
1233
|
+
const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
1302
1234
|
if (!graphqlEndpoint) {
|
|
1303
1235
|
throw new import_errors.BlockchainError(
|
|
1304
1236
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
@@ -1350,7 +1282,7 @@ class PermissionsController {
|
|
|
1350
1282
|
);
|
|
1351
1283
|
}
|
|
1352
1284
|
const userData = result.data?.user;
|
|
1353
|
-
if (!userData
|
|
1285
|
+
if (!userData?.permissions?.length) {
|
|
1354
1286
|
return [];
|
|
1355
1287
|
}
|
|
1356
1288
|
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
@@ -1361,8 +1293,8 @@ class PermissionsController {
|
|
|
1361
1293
|
nonce: BigInt(permission.nonce),
|
|
1362
1294
|
startBlock: BigInt(permission.startBlock),
|
|
1363
1295
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
1364
|
-
addedAtTimestamp: BigInt(permission.addedAtTimestamp
|
|
1365
|
-
transactionHash: permission.transactionHash
|
|
1296
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
|
|
1297
|
+
transactionHash: permission.transactionHash ?? "",
|
|
1366
1298
|
grantor: userAddress,
|
|
1367
1299
|
grantee: permission.grantee,
|
|
1368
1300
|
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
@@ -1383,26 +1315,6 @@ class PermissionsController {
|
|
|
1383
1315
|
);
|
|
1384
1316
|
}
|
|
1385
1317
|
}
|
|
1386
|
-
/**
|
|
1387
|
-
* Normalizes grant ID to hex format.
|
|
1388
|
-
* Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
|
|
1389
|
-
*
|
|
1390
|
-
* @param grantId - Permission ID or grant hash in various formats
|
|
1391
|
-
* @returns Normalized hex hash
|
|
1392
|
-
*/
|
|
1393
|
-
normalizeGrantId(grantId) {
|
|
1394
|
-
if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
|
|
1395
|
-
return grantId;
|
|
1396
|
-
}
|
|
1397
|
-
try {
|
|
1398
|
-
const bigIntId = BigInt(grantId);
|
|
1399
|
-
return `0x${bigIntId.toString(16).padStart(64, "0")}`;
|
|
1400
|
-
} catch {
|
|
1401
|
-
throw new Error(
|
|
1402
|
-
`Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
|
|
1403
|
-
);
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
1318
|
/**
|
|
1407
1319
|
* Registers a new server and immediately trusts it in the DataPortabilityServers contract.
|
|
1408
1320
|
*
|
|
@@ -1411,7 +1323,6 @@ class PermissionsController {
|
|
|
1411
1323
|
* Trusted servers can handle data export and portability requests from the user.
|
|
1412
1324
|
*
|
|
1413
1325
|
* @param params - Parameters for adding and trusting the server
|
|
1414
|
-
* @param params.owner - Ethereum address that will own this server registration
|
|
1415
1326
|
* @param params.serverAddress - Ethereum address of the server
|
|
1416
1327
|
* @param params.serverUrl - HTTPS URL where the server can be reached
|
|
1417
1328
|
* @param params.publicKey - Server's public key for encryption (hex string)
|
|
@@ -1438,6 +1349,7 @@ class PermissionsController {
|
|
|
1438
1349
|
* ```
|
|
1439
1350
|
*/
|
|
1440
1351
|
async addAndTrustServer(params) {
|
|
1352
|
+
this.assertWallet();
|
|
1441
1353
|
try {
|
|
1442
1354
|
const chainId = await this.context.walletClient.getChainId();
|
|
1443
1355
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -1445,7 +1357,7 @@ class PermissionsController {
|
|
|
1445
1357
|
"DataPortabilityServers"
|
|
1446
1358
|
);
|
|
1447
1359
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
1448
|
-
const account = this.context.walletClient
|
|
1360
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1449
1361
|
const userAddress = typeof account === "string" ? account : account.address;
|
|
1450
1362
|
const normalizedUserAddress = (0, import_viem.getAddress)(userAddress);
|
|
1451
1363
|
const normalizedServerAddress = (0, import_viem.getAddress)(params.serverAddress);
|
|
@@ -1462,7 +1374,7 @@ class PermissionsController {
|
|
|
1462
1374
|
}
|
|
1463
1375
|
],
|
|
1464
1376
|
account,
|
|
1465
|
-
chain: this.context.walletClient
|
|
1377
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1466
1378
|
});
|
|
1467
1379
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1468
1380
|
const txResult = tx({
|
|
@@ -1477,9 +1389,13 @@ class PermissionsController {
|
|
|
1477
1389
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
1478
1390
|
const event = result.expectedEvents.ServerTrusted;
|
|
1479
1391
|
if (!event) {
|
|
1480
|
-
throw new import_errors.BlockchainError(
|
|
1392
|
+
throw new import_errors.BlockchainError(
|
|
1393
|
+
"ServerTrusted event not found in transaction"
|
|
1394
|
+
);
|
|
1481
1395
|
}
|
|
1482
|
-
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1396
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1397
|
+
hash: txHash
|
|
1398
|
+
});
|
|
1483
1399
|
return {
|
|
1484
1400
|
transactionHash: txHash,
|
|
1485
1401
|
blockNumber: receipt.blockNumber,
|
|
@@ -1510,6 +1426,7 @@ class PermissionsController {
|
|
|
1510
1426
|
* @deprecated Use addAndTrustServer instead
|
|
1511
1427
|
*/
|
|
1512
1428
|
async submitTrustServer(params) {
|
|
1429
|
+
this.assertWallet();
|
|
1513
1430
|
try {
|
|
1514
1431
|
const chainId = await this.context.walletClient.getChainId();
|
|
1515
1432
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -1517,14 +1434,14 @@ class PermissionsController {
|
|
|
1517
1434
|
"DataPortabilityServers"
|
|
1518
1435
|
);
|
|
1519
1436
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
1520
|
-
const account = this.context.walletClient
|
|
1437
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1521
1438
|
const txHash = await this.context.walletClient.writeContract({
|
|
1522
1439
|
address: DataPortabilityServersAddress,
|
|
1523
1440
|
abi: DataPortabilityServersAbi,
|
|
1524
1441
|
functionName: "trustServer",
|
|
1525
1442
|
args: [BigInt(params.serverId)],
|
|
1526
1443
|
account,
|
|
1527
|
-
chain: this.context.walletClient
|
|
1444
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1528
1445
|
});
|
|
1529
1446
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1530
1447
|
return tx({
|
|
@@ -1550,6 +1467,7 @@ class PermissionsController {
|
|
|
1550
1467
|
* @returns Promise resolving to TransactionResult with ServerTrustResult event data
|
|
1551
1468
|
*/
|
|
1552
1469
|
async submitAddAndTrustServerWithSignature(params) {
|
|
1470
|
+
this.assertWallet();
|
|
1553
1471
|
try {
|
|
1554
1472
|
const nonce = await this.getServersUserNonce();
|
|
1555
1473
|
const serverAddress = (0, import_viem.getAddress)(params.serverAddress);
|
|
@@ -1584,7 +1502,7 @@ class PermissionsController {
|
|
|
1584
1502
|
signature
|
|
1585
1503
|
);
|
|
1586
1504
|
}
|
|
1587
|
-
const account = this.context.walletClient
|
|
1505
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1588
1506
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1589
1507
|
return tx({
|
|
1590
1508
|
hash,
|
|
@@ -1621,6 +1539,7 @@ class PermissionsController {
|
|
|
1621
1539
|
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
1622
1540
|
*/
|
|
1623
1541
|
async submitTrustServerWithSignature(params) {
|
|
1542
|
+
this.assertWallet();
|
|
1624
1543
|
try {
|
|
1625
1544
|
const nonce = await this.getServersUserNonce();
|
|
1626
1545
|
const trustServerInput = {
|
|
@@ -1641,7 +1560,7 @@ class PermissionsController {
|
|
|
1641
1560
|
signature
|
|
1642
1561
|
);
|
|
1643
1562
|
}
|
|
1644
|
-
const account = this.context.walletClient
|
|
1563
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1645
1564
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1646
1565
|
return tx({
|
|
1647
1566
|
hash,
|
|
@@ -1680,6 +1599,7 @@ class PermissionsController {
|
|
|
1680
1599
|
* @throws {BlockchainError} When contract submission fails
|
|
1681
1600
|
*/
|
|
1682
1601
|
async submitDirectUntrustTransaction(params) {
|
|
1602
|
+
this.assertWallet();
|
|
1683
1603
|
try {
|
|
1684
1604
|
const chainId = await this.context.walletClient.getChainId();
|
|
1685
1605
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -1687,14 +1607,14 @@ class PermissionsController {
|
|
|
1687
1607
|
"DataPortabilityServers"
|
|
1688
1608
|
);
|
|
1689
1609
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
1690
|
-
const account = this.context.walletClient
|
|
1610
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1691
1611
|
const txHash = await this.context.walletClient.writeContract({
|
|
1692
1612
|
address: DataPortabilityServersAddress,
|
|
1693
1613
|
abi: DataPortabilityServersAbi,
|
|
1694
1614
|
functionName: "untrustServer",
|
|
1695
1615
|
args: [BigInt(params.serverId)],
|
|
1696
1616
|
account,
|
|
1697
|
-
chain: this.context.walletClient
|
|
1617
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1698
1618
|
});
|
|
1699
1619
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1700
1620
|
return tx({
|
|
@@ -1742,6 +1662,7 @@ class PermissionsController {
|
|
|
1742
1662
|
* ```
|
|
1743
1663
|
*/
|
|
1744
1664
|
async submitUntrustServer(params) {
|
|
1665
|
+
this.assertWallet();
|
|
1745
1666
|
const nonce = await this.getServersUserNonce();
|
|
1746
1667
|
const untrustServerInput = {
|
|
1747
1668
|
nonce,
|
|
@@ -1762,6 +1683,7 @@ class PermissionsController {
|
|
|
1762
1683
|
* @throws {BlockchainError} When untrust transaction fails
|
|
1763
1684
|
*/
|
|
1764
1685
|
async submitUntrustServerWithSignature(params) {
|
|
1686
|
+
this.assertWallet();
|
|
1765
1687
|
try {
|
|
1766
1688
|
const nonce = await this.getServersUserNonce();
|
|
1767
1689
|
const untrustServerInput = {
|
|
@@ -1779,7 +1701,7 @@ class PermissionsController {
|
|
|
1779
1701
|
} else {
|
|
1780
1702
|
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
1781
1703
|
}
|
|
1782
|
-
const account = this.context.walletClient
|
|
1704
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1783
1705
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1784
1706
|
return tx({
|
|
1785
1707
|
hash,
|
|
@@ -1824,8 +1746,8 @@ class PermissionsController {
|
|
|
1824
1746
|
*/
|
|
1825
1747
|
async getTrustedServers(userAddress) {
|
|
1826
1748
|
try {
|
|
1827
|
-
const user = userAddress
|
|
1828
|
-
const chainId = await this.context.
|
|
1749
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1750
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1829
1751
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1830
1752
|
chainId,
|
|
1831
1753
|
"DataPortabilityServers"
|
|
@@ -1854,8 +1776,8 @@ class PermissionsController {
|
|
|
1854
1776
|
*/
|
|
1855
1777
|
async getTrustedServersCount(userAddress) {
|
|
1856
1778
|
try {
|
|
1857
|
-
const user = userAddress
|
|
1858
|
-
const chainId = await this.context.
|
|
1779
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1780
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1859
1781
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1860
1782
|
chainId,
|
|
1861
1783
|
"DataPortabilityServers"
|
|
@@ -1884,10 +1806,10 @@ class PermissionsController {
|
|
|
1884
1806
|
*/
|
|
1885
1807
|
async getTrustedServersPaginated(options = {}) {
|
|
1886
1808
|
try {
|
|
1887
|
-
const user = options.userAddress
|
|
1888
|
-
const limit = options.limit
|
|
1889
|
-
const offset = options.offset
|
|
1890
|
-
const chainId = await this.context.
|
|
1809
|
+
const user = options.userAddress ?? this.context.userAddress;
|
|
1810
|
+
const limit = options.limit ?? 50;
|
|
1811
|
+
const offset = options.offset ?? 0;
|
|
1812
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1891
1813
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1892
1814
|
chainId,
|
|
1893
1815
|
"DataPortabilityServers"
|
|
@@ -2033,7 +1955,7 @@ class PermissionsController {
|
|
|
2033
1955
|
};
|
|
2034
1956
|
}
|
|
2035
1957
|
try {
|
|
2036
|
-
const chainId = await this.context.
|
|
1958
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2037
1959
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2038
1960
|
chainId,
|
|
2039
1961
|
"DataPortabilityServers"
|
|
@@ -2108,7 +2030,7 @@ class PermissionsController {
|
|
|
2108
2030
|
*/
|
|
2109
2031
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
2110
2032
|
try {
|
|
2111
|
-
const user = userAddress
|
|
2033
|
+
const user = userAddress ?? this.context.userAddress;
|
|
2112
2034
|
const trustedServers = await this.getTrustedServers(user);
|
|
2113
2035
|
const trustIndex = trustedServers.findIndex(
|
|
2114
2036
|
(server) => server === serverId
|
|
@@ -2198,7 +2120,7 @@ class PermissionsController {
|
|
|
2198
2120
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
2199
2121
|
*/
|
|
2200
2122
|
async getServersDomain() {
|
|
2201
|
-
const chainId = await this.context.
|
|
2123
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2202
2124
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2203
2125
|
chainId,
|
|
2204
2126
|
"DataPortabilityServers"
|
|
@@ -2218,6 +2140,7 @@ class PermissionsController {
|
|
|
2218
2140
|
* @returns Promise resolving to the transaction hash
|
|
2219
2141
|
*/
|
|
2220
2142
|
async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
|
|
2143
|
+
this.assertWallet();
|
|
2221
2144
|
const chainId = await this.context.walletClient.getChainId();
|
|
2222
2145
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2223
2146
|
chainId,
|
|
@@ -2249,8 +2172,8 @@ class PermissionsController {
|
|
|
2249
2172
|
},
|
|
2250
2173
|
formattedSignature
|
|
2251
2174
|
],
|
|
2252
|
-
account: this.context.walletClient
|
|
2253
|
-
chain: this.context.walletClient
|
|
2175
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2176
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2254
2177
|
});
|
|
2255
2178
|
return txHash;
|
|
2256
2179
|
}
|
|
@@ -2262,6 +2185,7 @@ class PermissionsController {
|
|
|
2262
2185
|
* @returns Promise resolving to the transaction hash
|
|
2263
2186
|
*/
|
|
2264
2187
|
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2188
|
+
this.assertWallet();
|
|
2265
2189
|
const chainId = await this.context.walletClient.getChainId();
|
|
2266
2190
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2267
2191
|
chainId,
|
|
@@ -2280,8 +2204,8 @@ class PermissionsController {
|
|
|
2280
2204
|
},
|
|
2281
2205
|
formattedSignature
|
|
2282
2206
|
],
|
|
2283
|
-
account: this.context.walletClient
|
|
2284
|
-
chain: this.context.walletClient
|
|
2207
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2208
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2285
2209
|
});
|
|
2286
2210
|
return txHash;
|
|
2287
2211
|
}
|
|
@@ -2293,6 +2217,7 @@ class PermissionsController {
|
|
|
2293
2217
|
* @returns Promise resolving to the transaction hash
|
|
2294
2218
|
*/
|
|
2295
2219
|
async submitDirectRevokeTransaction(typedData, signature) {
|
|
2220
|
+
this.assertWallet();
|
|
2296
2221
|
const chainId = await this.context.walletClient.getChainId();
|
|
2297
2222
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
2298
2223
|
chainId,
|
|
@@ -2304,10 +2229,9 @@ class PermissionsController {
|
|
|
2304
2229
|
address: DataPortabilityPermissionsAddress,
|
|
2305
2230
|
abi: DataPortabilityPermissionsAbi,
|
|
2306
2231
|
functionName: "revokePermissionWithSignature",
|
|
2307
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2308
2232
|
args: [typedData.message, formattedSignature],
|
|
2309
|
-
account: this.context.walletClient
|
|
2310
|
-
chain: this.context.walletClient
|
|
2233
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2234
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2311
2235
|
});
|
|
2312
2236
|
return txHash;
|
|
2313
2237
|
}
|
|
@@ -2319,6 +2243,7 @@ class PermissionsController {
|
|
|
2319
2243
|
* @returns Promise resolving to the transaction hash
|
|
2320
2244
|
*/
|
|
2321
2245
|
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2246
|
+
this.assertWallet();
|
|
2322
2247
|
const chainId = await this.context.walletClient.getChainId();
|
|
2323
2248
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2324
2249
|
chainId,
|
|
@@ -2326,14 +2251,17 @@ class PermissionsController {
|
|
|
2326
2251
|
);
|
|
2327
2252
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
2328
2253
|
const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
|
|
2254
|
+
const contractMessage = {
|
|
2255
|
+
nonce: typedData.message.nonce,
|
|
2256
|
+
serverId: BigInt(typedData.message.serverId)
|
|
2257
|
+
};
|
|
2329
2258
|
const txHash = await this.context.walletClient.writeContract({
|
|
2330
2259
|
address: DataPortabilityServersAddress,
|
|
2331
2260
|
abi: DataPortabilityServersAbi,
|
|
2332
2261
|
functionName: "untrustServerWithSignature",
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
chain: this.context.walletClient.chain || null
|
|
2262
|
+
args: [contractMessage, formattedSignature],
|
|
2263
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2264
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2337
2265
|
});
|
|
2338
2266
|
return txHash;
|
|
2339
2267
|
}
|
|
@@ -2366,6 +2294,7 @@ class PermissionsController {
|
|
|
2366
2294
|
* ```
|
|
2367
2295
|
*/
|
|
2368
2296
|
async submitRegisterGrantee(params) {
|
|
2297
|
+
this.assertWallet();
|
|
2369
2298
|
const chainId = await this.context.walletClient.getChainId();
|
|
2370
2299
|
const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
|
|
2371
2300
|
chainId,
|
|
@@ -2374,14 +2303,14 @@ class PermissionsController {
|
|
|
2374
2303
|
const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
|
|
2375
2304
|
const ownerAddress = (0, import_viem.getAddress)(params.owner);
|
|
2376
2305
|
const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
|
|
2377
|
-
const account = this.context.walletClient
|
|
2306
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2378
2307
|
const txHash = await this.context.walletClient.writeContract({
|
|
2379
2308
|
address: DataPortabilityGranteesAddress,
|
|
2380
2309
|
abi: DataPortabilityGranteesAbi,
|
|
2381
2310
|
functionName: "registerGrantee",
|
|
2382
2311
|
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2383
2312
|
account,
|
|
2384
|
-
chain: this.context.walletClient
|
|
2313
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2385
2314
|
});
|
|
2386
2315
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2387
2316
|
return tx({
|
|
@@ -2407,6 +2336,7 @@ class PermissionsController {
|
|
|
2407
2336
|
* ```
|
|
2408
2337
|
*/
|
|
2409
2338
|
async submitRegisterGranteeWithSignature(params) {
|
|
2339
|
+
this.assertWallet();
|
|
2410
2340
|
const nonce = await this.getServersUserNonce();
|
|
2411
2341
|
const owner = (0, import_viem.getAddress)(params.owner);
|
|
2412
2342
|
const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
|
|
@@ -2422,7 +2352,7 @@ class PermissionsController {
|
|
|
2422
2352
|
typedData,
|
|
2423
2353
|
signature
|
|
2424
2354
|
);
|
|
2425
|
-
const account = this.context.walletClient
|
|
2355
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2426
2356
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2427
2357
|
return tx({
|
|
2428
2358
|
hash,
|
|
@@ -2448,7 +2378,7 @@ class PermissionsController {
|
|
|
2448
2378
|
typedData,
|
|
2449
2379
|
signature
|
|
2450
2380
|
);
|
|
2451
|
-
const account = this.context.walletClient
|
|
2381
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2452
2382
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2453
2383
|
return tx({
|
|
2454
2384
|
hash,
|
|
@@ -2502,8 +2432,8 @@ class PermissionsController {
|
|
|
2502
2432
|
functionName: "granteesCount"
|
|
2503
2433
|
});
|
|
2504
2434
|
const total = Number(totalCount);
|
|
2505
|
-
const limit = options.limit
|
|
2506
|
-
const offset = options.offset
|
|
2435
|
+
const limit = options.limit ?? 50;
|
|
2436
|
+
const offset = options.offset ?? 0;
|
|
2507
2437
|
const grantees = [];
|
|
2508
2438
|
const endIndex = Math.min(offset + limit, total);
|
|
2509
2439
|
for (let i = offset; i < endIndex; i++) {
|
|
@@ -2651,7 +2581,7 @@ class PermissionsController {
|
|
|
2651
2581
|
* @private
|
|
2652
2582
|
*/
|
|
2653
2583
|
async buildRegisterGranteeTypedData(input) {
|
|
2654
|
-
const chainId = await this.context.
|
|
2584
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2655
2585
|
const verifyingContract = (0, import_addresses.getContractAddress)(
|
|
2656
2586
|
chainId,
|
|
2657
2587
|
"DataPortabilityGrantees"
|
|
@@ -2684,6 +2614,7 @@ class PermissionsController {
|
|
|
2684
2614
|
* @private
|
|
2685
2615
|
*/
|
|
2686
2616
|
async submitSignedRegisterGranteeTransaction(typedData, _signature) {
|
|
2617
|
+
this.assertWallet();
|
|
2687
2618
|
const chainId = await this.context.walletClient.getChainId();
|
|
2688
2619
|
const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
|
|
2689
2620
|
chainId,
|
|
@@ -2699,8 +2630,8 @@ class PermissionsController {
|
|
|
2699
2630
|
typedData.message.granteeAddress,
|
|
2700
2631
|
typedData.message.publicKey
|
|
2701
2632
|
],
|
|
2702
|
-
account: this.context.walletClient
|
|
2703
|
-
chain: this.context.walletClient
|
|
2633
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2634
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2704
2635
|
});
|
|
2705
2636
|
return txHash;
|
|
2706
2637
|
}
|
|
@@ -2715,7 +2646,7 @@ class PermissionsController {
|
|
|
2715
2646
|
*/
|
|
2716
2647
|
async getUserServerIds(userAddress) {
|
|
2717
2648
|
try {
|
|
2718
|
-
const targetAddress = userAddress
|
|
2649
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2719
2650
|
const chainId = await this.context.publicClient.getChainId();
|
|
2720
2651
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2721
2652
|
chainId,
|
|
@@ -2773,7 +2704,7 @@ class PermissionsController {
|
|
|
2773
2704
|
*/
|
|
2774
2705
|
async getUserServerCount(userAddress) {
|
|
2775
2706
|
try {
|
|
2776
|
-
const targetAddress = userAddress
|
|
2707
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2777
2708
|
const chainId = await this.context.publicClient.getChainId();
|
|
2778
2709
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2779
2710
|
chainId,
|
|
@@ -2802,7 +2733,7 @@ class PermissionsController {
|
|
|
2802
2733
|
*/
|
|
2803
2734
|
async getUserTrustedServers(userAddress) {
|
|
2804
2735
|
try {
|
|
2805
|
-
const targetAddress = userAddress
|
|
2736
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2806
2737
|
const chainId = await this.context.publicClient.getChainId();
|
|
2807
2738
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2808
2739
|
chainId,
|
|
@@ -2919,7 +2850,7 @@ class PermissionsController {
|
|
|
2919
2850
|
*/
|
|
2920
2851
|
async getUserPermissionIds(userAddress) {
|
|
2921
2852
|
try {
|
|
2922
|
-
const targetAddress = userAddress
|
|
2853
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2923
2854
|
const chainId = await this.context.publicClient.getChainId();
|
|
2924
2855
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
2925
2856
|
chainId,
|
|
@@ -2981,7 +2912,7 @@ class PermissionsController {
|
|
|
2981
2912
|
*/
|
|
2982
2913
|
async getUserPermissionCount(userAddress) {
|
|
2983
2914
|
try {
|
|
2984
|
-
const targetAddress = userAddress
|
|
2915
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2985
2916
|
const chainId = await this.context.publicClient.getChainId();
|
|
2986
2917
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
2987
2918
|
chainId,
|
|
@@ -3426,6 +3357,7 @@ class PermissionsController {
|
|
|
3426
3357
|
* @returns Promise resolving to transaction hash
|
|
3427
3358
|
*/
|
|
3428
3359
|
async submitUpdateServer(serverId, url) {
|
|
3360
|
+
this.assertWallet();
|
|
3429
3361
|
try {
|
|
3430
3362
|
const chainId = await this.context.walletClient.getChainId();
|
|
3431
3363
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -3433,13 +3365,13 @@ class PermissionsController {
|
|
|
3433
3365
|
"DataPortabilityServers"
|
|
3434
3366
|
);
|
|
3435
3367
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
3436
|
-
const account = this.context.walletClient
|
|
3368
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3437
3369
|
const hash = await this.context.walletClient.writeContract({
|
|
3438
3370
|
address: DataPortabilityServersAddress,
|
|
3439
3371
|
abi: DataPortabilityServersAbi,
|
|
3440
3372
|
functionName: "updateServer",
|
|
3441
3373
|
args: [serverId, url],
|
|
3442
|
-
chain: this.context.walletClient
|
|
3374
|
+
chain: this.context.walletClient?.chain,
|
|
3443
3375
|
account
|
|
3444
3376
|
});
|
|
3445
3377
|
const { tx } = await import("../utils/transactionHelpers");
|
|
@@ -3598,6 +3530,7 @@ class PermissionsController {
|
|
|
3598
3530
|
* @throws {NetworkError} When network communication fails
|
|
3599
3531
|
*/
|
|
3600
3532
|
async submitAddPermission(params) {
|
|
3533
|
+
this.assertWallet();
|
|
3601
3534
|
try {
|
|
3602
3535
|
const nonce = await this.getPermissionsUserNonce();
|
|
3603
3536
|
const addPermissionInput = {
|
|
@@ -3636,6 +3569,7 @@ class PermissionsController {
|
|
|
3636
3569
|
* @throws {NetworkError} When network communication fails
|
|
3637
3570
|
*/
|
|
3638
3571
|
async submitSignedAddPermission(typedData, signature) {
|
|
3572
|
+
this.assertWallet();
|
|
3639
3573
|
try {
|
|
3640
3574
|
let hash;
|
|
3641
3575
|
if (this.context.relayerCallbacks?.submitAddPermission) {
|
|
@@ -3649,7 +3583,7 @@ class PermissionsController {
|
|
|
3649
3583
|
signature
|
|
3650
3584
|
);
|
|
3651
3585
|
}
|
|
3652
|
-
const account = this.context.walletClient
|
|
3586
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3653
3587
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3654
3588
|
return tx({
|
|
3655
3589
|
hash,
|
|
@@ -3685,7 +3619,7 @@ class PermissionsController {
|
|
|
3685
3619
|
* @param params.serverAddress - Server wallet address for decryption permissions
|
|
3686
3620
|
* @param params.serverUrl - Server endpoint URL
|
|
3687
3621
|
* @param params.serverPublicKey - Server's public key for encryption.
|
|
3688
|
-
* Obtain via `vana.server.getIdentity(userAddress).
|
|
3622
|
+
* Obtain via `vana.server.getIdentity(userAddress).publicKey`.
|
|
3689
3623
|
* @param params.filePermissions - Nested array of permissions for each file
|
|
3690
3624
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3691
3625
|
* @throws {Error} When schemaIds array length doesn't match fileUrls array length
|
|
@@ -3707,7 +3641,7 @@ class PermissionsController {
|
|
|
3707
3641
|
* schemaIds: [123], // LinkedIn profile schema ID
|
|
3708
3642
|
* serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3709
3643
|
* serverUrl: "https://server.example.com",
|
|
3710
|
-
* serverPublicKey: serverInfo.
|
|
3644
|
+
* serverPublicKey: serverInfo.publicKey,
|
|
3711
3645
|
* filePermissions: [[{
|
|
3712
3646
|
* account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3713
3647
|
* key: encryptedKey
|
|
@@ -3718,6 +3652,7 @@ class PermissionsController {
|
|
|
3718
3652
|
* ```
|
|
3719
3653
|
*/
|
|
3720
3654
|
async submitAddServerFilesAndPermissions(params) {
|
|
3655
|
+
this.assertWallet();
|
|
3721
3656
|
try {
|
|
3722
3657
|
if (params.schemaIds.length !== params.fileUrls.length) {
|
|
3723
3658
|
throw new Error(
|
|
@@ -3782,6 +3717,7 @@ class PermissionsController {
|
|
|
3782
3717
|
* ```
|
|
3783
3718
|
*/
|
|
3784
3719
|
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
3720
|
+
this.assertWallet();
|
|
3785
3721
|
try {
|
|
3786
3722
|
console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
|
|
3787
3723
|
hasRelayerCallbacks: !!this.context.relayerCallbacks,
|
|
@@ -3796,7 +3732,7 @@ class PermissionsController {
|
|
|
3796
3732
|
typedData,
|
|
3797
3733
|
signature
|
|
3798
3734
|
);
|
|
3799
|
-
const account = this.context.walletClient
|
|
3735
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3800
3736
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3801
3737
|
return tx({
|
|
3802
3738
|
hash,
|
|
@@ -3812,11 +3748,11 @@ class PermissionsController {
|
|
|
3812
3748
|
typedData,
|
|
3813
3749
|
signature
|
|
3814
3750
|
);
|
|
3815
|
-
const account = this.context.
|
|
3751
|
+
const account = this.context.userAddress;
|
|
3816
3752
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3817
3753
|
return tx({
|
|
3818
3754
|
hash,
|
|
3819
|
-
from:
|
|
3755
|
+
from: account,
|
|
3820
3756
|
contract: "DataPortabilityPermissions",
|
|
3821
3757
|
fn: "addServerFilesAndPermissions"
|
|
3822
3758
|
});
|
|
@@ -3838,6 +3774,7 @@ class PermissionsController {
|
|
|
3838
3774
|
* @returns Promise resolving to transaction hash
|
|
3839
3775
|
*/
|
|
3840
3776
|
async submitRevokePermission(permissionId) {
|
|
3777
|
+
this.assertWallet();
|
|
3841
3778
|
try {
|
|
3842
3779
|
const chainId = await this.context.walletClient.getChainId();
|
|
3843
3780
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -3847,7 +3784,7 @@ class PermissionsController {
|
|
|
3847
3784
|
const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
|
|
3848
3785
|
"DataPortabilityPermissions"
|
|
3849
3786
|
);
|
|
3850
|
-
const account = this.context.walletClient
|
|
3787
|
+
const { account } = this.context.walletClient;
|
|
3851
3788
|
if (!account) {
|
|
3852
3789
|
throw new Error("No wallet account connected");
|
|
3853
3790
|
}
|
|
@@ -3856,7 +3793,7 @@ class PermissionsController {
|
|
|
3856
3793
|
abi: DataPortabilityPermissionsAbi,
|
|
3857
3794
|
functionName: "revokePermission",
|
|
3858
3795
|
args: [permissionId],
|
|
3859
|
-
chain: this.context.walletClient
|
|
3796
|
+
chain: this.context.walletClient?.chain,
|
|
3860
3797
|
account
|
|
3861
3798
|
});
|
|
3862
3799
|
const { tx } = await import("../utils/transactionHelpers");
|
|
@@ -3881,6 +3818,7 @@ class PermissionsController {
|
|
|
3881
3818
|
* @returns Promise resolving to the transaction hash
|
|
3882
3819
|
*/
|
|
3883
3820
|
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
3821
|
+
this.assertWallet();
|
|
3884
3822
|
const chainId = await this.context.walletClient.getChainId();
|
|
3885
3823
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
3886
3824
|
chainId,
|
|
@@ -3891,7 +3829,7 @@ class PermissionsController {
|
|
|
3891
3829
|
nonce: typedData.message.nonce,
|
|
3892
3830
|
granteeId: typedData.message.granteeId,
|
|
3893
3831
|
grant: typedData.message.grant,
|
|
3894
|
-
fileIds: typedData.message.fileIds
|
|
3832
|
+
fileIds: typedData.message.fileIds ?? []
|
|
3895
3833
|
};
|
|
3896
3834
|
const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
|
|
3897
3835
|
const hash = await this.context.walletClient.writeContract({
|
|
@@ -3899,8 +3837,8 @@ class PermissionsController {
|
|
|
3899
3837
|
abi: DataPortabilityPermissionsAbi,
|
|
3900
3838
|
functionName: "addPermission",
|
|
3901
3839
|
args: [permissionInput, formattedSignature],
|
|
3902
|
-
account: this.context.walletClient
|
|
3903
|
-
chain: this.context.walletClient
|
|
3840
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3841
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3904
3842
|
});
|
|
3905
3843
|
return hash;
|
|
3906
3844
|
}
|
|
@@ -3912,7 +3850,8 @@ class PermissionsController {
|
|
|
3912
3850
|
* @returns Promise resolving to the transaction hash
|
|
3913
3851
|
*/
|
|
3914
3852
|
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
|
|
3915
|
-
|
|
3853
|
+
this.assertWallet();
|
|
3854
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
3916
3855
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
3917
3856
|
chainId,
|
|
3918
3857
|
"DataPortabilityPermissions"
|
|
@@ -3936,8 +3875,8 @@ class PermissionsController {
|
|
|
3936
3875
|
functionName: "addServerFilesAndPermissions",
|
|
3937
3876
|
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
3938
3877
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
3939
|
-
account: this.context.
|
|
3940
|
-
chain: this.context.walletClient
|
|
3878
|
+
account: this.context.userAddress,
|
|
3879
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3941
3880
|
});
|
|
3942
3881
|
return hash;
|
|
3943
3882
|
}
|