@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
|
@@ -18,9 +18,10 @@ import { validateGrant } from "../utils/grantValidation";
|
|
|
18
18
|
import { withSignatureCache } from "../utils/signatureCache";
|
|
19
19
|
import { formatSignatureForContract } from "../utils/signatureFormatter";
|
|
20
20
|
import { toViemTypedDataDefinition } from "../utils/typedDataConverter";
|
|
21
|
-
|
|
21
|
+
import { BaseController } from "./base";
|
|
22
|
+
class PermissionsController extends BaseController {
|
|
22
23
|
constructor(context) {
|
|
23
|
-
|
|
24
|
+
super(context);
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Grants permission for an application to access user data with gasless transactions.
|
|
@@ -57,6 +58,7 @@ class PermissionsController {
|
|
|
57
58
|
* ```
|
|
58
59
|
*/
|
|
59
60
|
async grant(params) {
|
|
61
|
+
this.assertWallet();
|
|
60
62
|
const { typedData, signature } = await this.createAndSign(params);
|
|
61
63
|
const result = await this.submitSignedGrantWithEvents(typedData, signature);
|
|
62
64
|
return result;
|
|
@@ -87,6 +89,7 @@ class PermissionsController {
|
|
|
87
89
|
* ```
|
|
88
90
|
*/
|
|
89
91
|
async submitPermissionGrant(params) {
|
|
92
|
+
this.assertWallet();
|
|
90
93
|
const { typedData, signature } = await this.createAndSign(params);
|
|
91
94
|
return await this.submitSignedGrant(typedData, signature);
|
|
92
95
|
}
|
|
@@ -116,6 +119,7 @@ class PermissionsController {
|
|
|
116
119
|
* ```
|
|
117
120
|
*/
|
|
118
121
|
async prepareGrant(params) {
|
|
122
|
+
this.assertWallet();
|
|
119
123
|
try {
|
|
120
124
|
const grantFile = createGrantFile(params);
|
|
121
125
|
validateGrant(grantFile);
|
|
@@ -156,7 +160,7 @@ class PermissionsController {
|
|
|
156
160
|
*/
|
|
157
161
|
async confirmGrantInternal(params, grantFile) {
|
|
158
162
|
try {
|
|
159
|
-
let grantUrl = params
|
|
163
|
+
let { grantUrl } = params;
|
|
160
164
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
161
165
|
if (!grantUrl) {
|
|
162
166
|
if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
|
|
@@ -246,10 +250,11 @@ class PermissionsController {
|
|
|
246
250
|
* ```
|
|
247
251
|
*/
|
|
248
252
|
async createAndSign(params) {
|
|
253
|
+
this.assertWallet();
|
|
249
254
|
try {
|
|
250
255
|
const grantFile = createGrantFile(params);
|
|
251
256
|
validateGrant(grantFile);
|
|
252
|
-
let grantUrl = params
|
|
257
|
+
let { grantUrl } = params;
|
|
253
258
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
254
259
|
if (!grantUrl) {
|
|
255
260
|
if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
|
|
@@ -337,7 +342,7 @@ class PermissionsController {
|
|
|
337
342
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
338
343
|
JSON.stringify(
|
|
339
344
|
typedData,
|
|
340
|
-
(
|
|
345
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
341
346
|
2
|
|
342
347
|
)
|
|
343
348
|
);
|
|
@@ -346,7 +351,7 @@ class PermissionsController {
|
|
|
346
351
|
typedData,
|
|
347
352
|
signature
|
|
348
353
|
);
|
|
349
|
-
const account = this.context.walletClient
|
|
354
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
350
355
|
const { tx } = await import("../utils/transactionHelpers");
|
|
351
356
|
return tx({
|
|
352
357
|
hash,
|
|
@@ -398,11 +403,11 @@ class PermissionsController {
|
|
|
398
403
|
trustServerInput,
|
|
399
404
|
signature
|
|
400
405
|
);
|
|
401
|
-
const account = this.context.
|
|
406
|
+
const account = this.context.userAddress;
|
|
402
407
|
const { tx } = await import("../utils/transactionHelpers");
|
|
403
408
|
return tx({
|
|
404
409
|
hash,
|
|
405
|
-
from:
|
|
410
|
+
from: account,
|
|
406
411
|
contract: "DataPortabilityServers",
|
|
407
412
|
fn: "trustServerWithSignature"
|
|
408
413
|
});
|
|
@@ -463,7 +468,7 @@ class PermissionsController {
|
|
|
463
468
|
addAndTrustServerInput,
|
|
464
469
|
signature
|
|
465
470
|
);
|
|
466
|
-
const account = this.context.walletClient
|
|
471
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
467
472
|
const { tx } = await import("../utils/transactionHelpers");
|
|
468
473
|
return tx({
|
|
469
474
|
hash,
|
|
@@ -483,7 +488,7 @@ class PermissionsController {
|
|
|
483
488
|
}
|
|
484
489
|
/**
|
|
485
490
|
* Internal method to submit a signed grant and wait for events.
|
|
486
|
-
*
|
|
491
|
+
*
|
|
487
492
|
* @internal
|
|
488
493
|
* @param typedData - The EIP-712 typed data for the permission grant
|
|
489
494
|
* @param signature - The user's signature authorizing the transaction
|
|
@@ -497,7 +502,9 @@ class PermissionsController {
|
|
|
497
502
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
498
503
|
const event = result.expectedEvents.PermissionAdded;
|
|
499
504
|
if (!event) {
|
|
500
|
-
throw new BlockchainError(
|
|
505
|
+
throw new BlockchainError(
|
|
506
|
+
"PermissionAdded event not found in transaction"
|
|
507
|
+
);
|
|
501
508
|
}
|
|
502
509
|
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
503
510
|
hash: result.hash
|
|
@@ -514,7 +521,7 @@ class PermissionsController {
|
|
|
514
521
|
}
|
|
515
522
|
/**
|
|
516
523
|
* Internal method for confirm grant with events.
|
|
517
|
-
*
|
|
524
|
+
*
|
|
518
525
|
* @internal
|
|
519
526
|
* @param params - The permission grant parameters
|
|
520
527
|
* @param grantFile - The pre-created grant file object
|
|
@@ -528,7 +535,9 @@ class PermissionsController {
|
|
|
528
535
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
529
536
|
const event = result.expectedEvents.PermissionAdded;
|
|
530
537
|
if (!event) {
|
|
531
|
-
throw new BlockchainError(
|
|
538
|
+
throw new BlockchainError(
|
|
539
|
+
"PermissionAdded event not found in transaction"
|
|
540
|
+
);
|
|
532
541
|
}
|
|
533
542
|
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
534
543
|
hash: result.hash
|
|
@@ -543,34 +552,6 @@ class PermissionsController {
|
|
|
543
552
|
fileIds: event.fileIds
|
|
544
553
|
};
|
|
545
554
|
}
|
|
546
|
-
/**
|
|
547
|
-
* Internal method to submit a signed revoke and wait for events.
|
|
548
|
-
*
|
|
549
|
-
* @internal
|
|
550
|
-
* @param typedData - The EIP-712 typed data for the permission revoke
|
|
551
|
-
* @param signature - The user's signature authorizing the transaction
|
|
552
|
-
* @returns Promise resolving to PermissionRevokeResult with parsed events
|
|
553
|
-
*/
|
|
554
|
-
async submitSignedRevokeWithEvents(typedData, signature) {
|
|
555
|
-
const txResult = await this.submitSignedRevoke(typedData, signature);
|
|
556
|
-
if (!this.context.waitForTransactionEvents) {
|
|
557
|
-
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
558
|
-
}
|
|
559
|
-
const result = await this.context.waitForTransactionEvents(txResult);
|
|
560
|
-
const event = result.expectedEvents.PermissionRevoked;
|
|
561
|
-
if (!event) {
|
|
562
|
-
throw new BlockchainError("PermissionRevoked event not found in transaction");
|
|
563
|
-
}
|
|
564
|
-
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
565
|
-
hash: result.hash
|
|
566
|
-
});
|
|
567
|
-
return {
|
|
568
|
-
transactionHash: result.hash,
|
|
569
|
-
blockNumber: receipt.blockNumber,
|
|
570
|
-
gasUsed: receipt.gasUsed,
|
|
571
|
-
permissionId: event.permissionId
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
555
|
/**
|
|
575
556
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
576
557
|
*
|
|
@@ -601,9 +582,12 @@ class PermissionsController {
|
|
|
601
582
|
signature
|
|
602
583
|
);
|
|
603
584
|
} else {
|
|
604
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
585
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
586
|
+
typedData,
|
|
587
|
+
signature
|
|
588
|
+
);
|
|
605
589
|
}
|
|
606
|
-
const account = this.context.walletClient
|
|
590
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
607
591
|
const { tx } = await import("../utils/transactionHelpers");
|
|
608
592
|
return tx({
|
|
609
593
|
hash,
|
|
@@ -651,9 +635,12 @@ class PermissionsController {
|
|
|
651
635
|
signature
|
|
652
636
|
);
|
|
653
637
|
} else {
|
|
654
|
-
hash = await this.submitSignedUntrustTransaction(
|
|
638
|
+
hash = await this.submitSignedUntrustTransaction(
|
|
639
|
+
typedData,
|
|
640
|
+
signature
|
|
641
|
+
);
|
|
655
642
|
}
|
|
656
|
-
const account = this.context.walletClient
|
|
643
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
657
644
|
const { tx } = await import("../utils/transactionHelpers");
|
|
658
645
|
return tx({
|
|
659
646
|
hash,
|
|
@@ -684,7 +671,8 @@ class PermissionsController {
|
|
|
684
671
|
* @throws {BlockchainError} When contract submission fails
|
|
685
672
|
*/
|
|
686
673
|
async submitDirectTransaction(typedData, signature) {
|
|
687
|
-
|
|
674
|
+
this.assertWallet();
|
|
675
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
688
676
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
689
677
|
chainId,
|
|
690
678
|
"DataPortabilityPermissions"
|
|
@@ -704,17 +692,17 @@ class PermissionsController {
|
|
|
704
692
|
console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
|
|
705
693
|
console.debug(
|
|
706
694
|
"\u{1F50D} Debug - Grant field length:",
|
|
707
|
-
typedData.message.grant?.length
|
|
695
|
+
typedData.message.grant?.length ?? 0
|
|
708
696
|
);
|
|
709
697
|
const formattedSignature = formatSignatureForContract(signature);
|
|
710
|
-
const account = this.context.walletClient
|
|
698
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
711
699
|
const txHash = await this.context.walletClient.writeContract({
|
|
712
700
|
address: DataPortabilityPermissionsAddress,
|
|
713
701
|
abi: DataPortabilityPermissionsAbi,
|
|
714
702
|
functionName: "addPermission",
|
|
715
703
|
args: [permissionInput, formattedSignature],
|
|
716
704
|
account,
|
|
717
|
-
chain: this.context.walletClient
|
|
705
|
+
chain: this.context.walletClient?.chain ?? null
|
|
718
706
|
});
|
|
719
707
|
const { tx } = await import("../utils/transactionHelpers");
|
|
720
708
|
return tx({
|
|
@@ -749,6 +737,7 @@ class PermissionsController {
|
|
|
749
737
|
* ```
|
|
750
738
|
*/
|
|
751
739
|
async revoke(params) {
|
|
740
|
+
this.assertWallet();
|
|
752
741
|
const txResult = await this.submitPermissionRevoke(params);
|
|
753
742
|
if (!this.context.waitForTransactionEvents) {
|
|
754
743
|
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
@@ -756,7 +745,9 @@ class PermissionsController {
|
|
|
756
745
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
757
746
|
const event = result.expectedEvents.PermissionRevoked;
|
|
758
747
|
if (!event) {
|
|
759
|
-
throw new BlockchainError(
|
|
748
|
+
throw new BlockchainError(
|
|
749
|
+
"PermissionRevoked event not found in transaction"
|
|
750
|
+
);
|
|
760
751
|
}
|
|
761
752
|
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
762
753
|
hash: result.hash
|
|
@@ -788,11 +779,12 @@ class PermissionsController {
|
|
|
788
779
|
* ```
|
|
789
780
|
*/
|
|
790
781
|
async submitPermissionRevoke(params) {
|
|
782
|
+
this.assertWallet();
|
|
791
783
|
try {
|
|
792
|
-
if (!this.context.walletClient
|
|
784
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
793
785
|
throw new BlockchainError("Chain ID not available");
|
|
794
786
|
}
|
|
795
|
-
const chainId = await this.context.
|
|
787
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
796
788
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
797
789
|
chainId,
|
|
798
790
|
"DataPortabilityPermissions"
|
|
@@ -800,14 +792,14 @@ class PermissionsController {
|
|
|
800
792
|
const DataPortabilityPermissionsAbi = getAbi(
|
|
801
793
|
"DataPortabilityPermissions"
|
|
802
794
|
);
|
|
803
|
-
const account = this.context.walletClient
|
|
795
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
804
796
|
const txHash = await this.context.walletClient.writeContract({
|
|
805
797
|
address: DataPortabilityPermissionsAddress,
|
|
806
798
|
abi: DataPortabilityPermissionsAbi,
|
|
807
799
|
functionName: "revokePermission",
|
|
808
800
|
args: [params.permissionId],
|
|
809
801
|
account,
|
|
810
|
-
chain: this.context.walletClient
|
|
802
|
+
chain: this.context.walletClient?.chain ?? null
|
|
811
803
|
});
|
|
812
804
|
const { tx } = await import("../utils/transactionHelpers");
|
|
813
805
|
return tx({
|
|
@@ -855,8 +847,9 @@ class PermissionsController {
|
|
|
855
847
|
* ```
|
|
856
848
|
*/
|
|
857
849
|
async submitRevokeWithSignature(params) {
|
|
850
|
+
this.assertWallet();
|
|
858
851
|
try {
|
|
859
|
-
if (!this.context.walletClient
|
|
852
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
860
853
|
throw new BlockchainError("Chain ID not available");
|
|
861
854
|
}
|
|
862
855
|
const nonce = await this.getPermissionsUserNonce();
|
|
@@ -883,9 +876,12 @@ class PermissionsController {
|
|
|
883
876
|
signature
|
|
884
877
|
);
|
|
885
878
|
} else {
|
|
886
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
879
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
880
|
+
typedData,
|
|
881
|
+
signature
|
|
882
|
+
);
|
|
887
883
|
}
|
|
888
|
-
const account = this.context.walletClient
|
|
884
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
889
885
|
const { tx } = await import("../utils/transactionHelpers");
|
|
890
886
|
return tx({
|
|
891
887
|
hash,
|
|
@@ -900,64 +896,6 @@ class PermissionsController {
|
|
|
900
896
|
);
|
|
901
897
|
}
|
|
902
898
|
}
|
|
903
|
-
/**
|
|
904
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
905
|
-
*
|
|
906
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
907
|
-
* This method is deprecated in favor of more specific nonce methods.
|
|
908
|
-
*
|
|
909
|
-
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
910
|
-
* be incremented with each transaction to maintain security.
|
|
911
|
-
*
|
|
912
|
-
* @returns Promise resolving to the user's current nonce value as a bigint
|
|
913
|
-
* @throws {Error} When wallet account is not available
|
|
914
|
-
* @throws {Error} When chain ID is not available
|
|
915
|
-
* @throws {NonceError} When reading nonce from contract fails
|
|
916
|
-
* @private
|
|
917
|
-
* @example
|
|
918
|
-
* ```typescript
|
|
919
|
-
* // Deprecated - use specific methods instead
|
|
920
|
-
* const nonce = await this.getUserNonce();
|
|
921
|
-
*
|
|
922
|
-
* // Use these instead:
|
|
923
|
-
* const permissionsNonce = await this.getPermissionsUserNonce();
|
|
924
|
-
* const serversNonce = await this.getServersUserNonce();
|
|
925
|
-
* ```
|
|
926
|
-
*/
|
|
927
|
-
/**
|
|
928
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
929
|
-
*
|
|
930
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
931
|
-
*
|
|
932
|
-
* @remarks
|
|
933
|
-
* This method is deprecated in favor of more specific nonce methods that target
|
|
934
|
-
* the appropriate contract for the operation being performed.
|
|
935
|
-
*
|
|
936
|
-
* @returns Promise resolving to the user's current nonce as a bigint
|
|
937
|
-
* @throws {NonceError} When retrieving the nonce fails
|
|
938
|
-
*/
|
|
939
|
-
async getUserNonce() {
|
|
940
|
-
try {
|
|
941
|
-
const userAddress = await this.getUserAddress();
|
|
942
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
943
|
-
const DataPortabilityServersAddress = getContractAddress(
|
|
944
|
-
chainId,
|
|
945
|
-
"DataPortabilityServers"
|
|
946
|
-
);
|
|
947
|
-
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
948
|
-
const nonce = await this.context.publicClient.readContract({
|
|
949
|
-
address: DataPortabilityServersAddress,
|
|
950
|
-
abi: DataPortabilityServersAbi,
|
|
951
|
-
functionName: "userNonce",
|
|
952
|
-
args: [userAddress]
|
|
953
|
-
});
|
|
954
|
-
return nonce;
|
|
955
|
-
} catch (error) {
|
|
956
|
-
throw new NonceError(
|
|
957
|
-
`Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
958
|
-
);
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
899
|
/**
|
|
962
900
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
963
901
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
@@ -984,8 +922,8 @@ class PermissionsController {
|
|
|
984
922
|
*/
|
|
985
923
|
async getServersUserNonce() {
|
|
986
924
|
try {
|
|
987
|
-
const userAddress =
|
|
988
|
-
const chainId = await this.context.
|
|
925
|
+
const userAddress = this.context.userAddress;
|
|
926
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
989
927
|
const DataPortabilityServersAddress = getContractAddress(
|
|
990
928
|
chainId,
|
|
991
929
|
"DataPortabilityServers"
|
|
@@ -1030,8 +968,8 @@ class PermissionsController {
|
|
|
1030
968
|
*/
|
|
1031
969
|
async getPermissionsUserNonce() {
|
|
1032
970
|
try {
|
|
1033
|
-
const userAddress =
|
|
1034
|
-
const chainId = await this.context.
|
|
971
|
+
const userAddress = this.context.userAddress;
|
|
972
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1035
973
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
1036
974
|
chainId,
|
|
1037
975
|
"DataPortabilityPermissions"
|
|
@@ -1070,7 +1008,7 @@ class PermissionsController {
|
|
|
1070
1008
|
"\u{1F50D} Debug - Composing permission message with grantUrl:",
|
|
1071
1009
|
params.grantUrl
|
|
1072
1010
|
);
|
|
1073
|
-
const chainId = await this.context.
|
|
1011
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1074
1012
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
1075
1013
|
chainId,
|
|
1076
1014
|
"DataPortabilityGrantees"
|
|
@@ -1179,7 +1117,7 @@ class PermissionsController {
|
|
|
1179
1117
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1180
1118
|
*/
|
|
1181
1119
|
async getPermissionDomain() {
|
|
1182
|
-
const chainId = await this.context.
|
|
1120
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1183
1121
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
1184
1122
|
chainId,
|
|
1185
1123
|
"DataPortabilityPermissions"
|
|
@@ -1198,8 +1136,9 @@ class PermissionsController {
|
|
|
1198
1136
|
* @returns Promise resolving to the cryptographic signature
|
|
1199
1137
|
*/
|
|
1200
1138
|
async signTypedData(typedData) {
|
|
1139
|
+
this.assertWallet();
|
|
1201
1140
|
try {
|
|
1202
|
-
const walletAddress = this.context.walletClient.account?.address
|
|
1141
|
+
const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
|
|
1203
1142
|
return await withSignatureCache(
|
|
1204
1143
|
this.context.platform.cache,
|
|
1205
1144
|
walletAddress,
|
|
@@ -1208,9 +1147,9 @@ class PermissionsController {
|
|
|
1208
1147
|
const viemCompatibleTypedData = toViemTypedDataDefinition(typedData);
|
|
1209
1148
|
return await this.context.walletClient.signTypedData({
|
|
1210
1149
|
...viemCompatibleTypedData,
|
|
1211
|
-
//
|
|
1212
|
-
//
|
|
1213
|
-
account: this.context.walletClient.account
|
|
1150
|
+
// Use the account if available, otherwise use the wallet address
|
|
1151
|
+
// This follows the same pattern used throughout this file
|
|
1152
|
+
account: this.context.walletClient.account ?? walletAddress
|
|
1214
1153
|
});
|
|
1215
1154
|
}
|
|
1216
1155
|
);
|
|
@@ -1225,17 +1164,10 @@ class PermissionsController {
|
|
|
1225
1164
|
}
|
|
1226
1165
|
}
|
|
1227
1166
|
/**
|
|
1228
|
-
* Gets the user's address from the
|
|
1167
|
+
* Gets the user's address from the context.
|
|
1229
1168
|
*
|
|
1230
|
-
* @returns
|
|
1169
|
+
* @returns The user's address
|
|
1231
1170
|
*/
|
|
1232
|
-
async getUserAddress() {
|
|
1233
|
-
const addresses = await this.context.walletClient.getAddresses();
|
|
1234
|
-
if (addresses.length === 0) {
|
|
1235
|
-
throw new BlockchainError("No addresses available in wallet client");
|
|
1236
|
-
}
|
|
1237
|
-
return addresses[0];
|
|
1238
|
-
}
|
|
1239
1171
|
/**
|
|
1240
1172
|
* Gets on-chain permission grant data without expensive off-chain resolution.
|
|
1241
1173
|
*
|
|
@@ -1274,8 +1206,8 @@ class PermissionsController {
|
|
|
1274
1206
|
async getUserPermissionGrantsOnChain(options = {}) {
|
|
1275
1207
|
const { limit = 50, subgraphUrl } = options;
|
|
1276
1208
|
try {
|
|
1277
|
-
const userAddress =
|
|
1278
|
-
const graphqlEndpoint = subgraphUrl
|
|
1209
|
+
const userAddress = this.context.userAddress;
|
|
1210
|
+
const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
1279
1211
|
if (!graphqlEndpoint) {
|
|
1280
1212
|
throw new BlockchainError(
|
|
1281
1213
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
@@ -1327,7 +1259,7 @@ class PermissionsController {
|
|
|
1327
1259
|
);
|
|
1328
1260
|
}
|
|
1329
1261
|
const userData = result.data?.user;
|
|
1330
|
-
if (!userData
|
|
1262
|
+
if (!userData?.permissions?.length) {
|
|
1331
1263
|
return [];
|
|
1332
1264
|
}
|
|
1333
1265
|
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
@@ -1338,8 +1270,8 @@ class PermissionsController {
|
|
|
1338
1270
|
nonce: BigInt(permission.nonce),
|
|
1339
1271
|
startBlock: BigInt(permission.startBlock),
|
|
1340
1272
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
1341
|
-
addedAtTimestamp: BigInt(permission.addedAtTimestamp
|
|
1342
|
-
transactionHash: permission.transactionHash
|
|
1273
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
|
|
1274
|
+
transactionHash: permission.transactionHash ?? "",
|
|
1343
1275
|
grantor: userAddress,
|
|
1344
1276
|
grantee: permission.grantee,
|
|
1345
1277
|
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
@@ -1360,26 +1292,6 @@ class PermissionsController {
|
|
|
1360
1292
|
);
|
|
1361
1293
|
}
|
|
1362
1294
|
}
|
|
1363
|
-
/**
|
|
1364
|
-
* Normalizes grant ID to hex format.
|
|
1365
|
-
* Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
|
|
1366
|
-
*
|
|
1367
|
-
* @param grantId - Permission ID or grant hash in various formats
|
|
1368
|
-
* @returns Normalized hex hash
|
|
1369
|
-
*/
|
|
1370
|
-
normalizeGrantId(grantId) {
|
|
1371
|
-
if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
|
|
1372
|
-
return grantId;
|
|
1373
|
-
}
|
|
1374
|
-
try {
|
|
1375
|
-
const bigIntId = BigInt(grantId);
|
|
1376
|
-
return `0x${bigIntId.toString(16).padStart(64, "0")}`;
|
|
1377
|
-
} catch {
|
|
1378
|
-
throw new Error(
|
|
1379
|
-
`Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
}
|
|
1383
1295
|
/**
|
|
1384
1296
|
* Registers a new server and immediately trusts it in the DataPortabilityServers contract.
|
|
1385
1297
|
*
|
|
@@ -1388,7 +1300,6 @@ class PermissionsController {
|
|
|
1388
1300
|
* Trusted servers can handle data export and portability requests from the user.
|
|
1389
1301
|
*
|
|
1390
1302
|
* @param params - Parameters for adding and trusting the server
|
|
1391
|
-
* @param params.owner - Ethereum address that will own this server registration
|
|
1392
1303
|
* @param params.serverAddress - Ethereum address of the server
|
|
1393
1304
|
* @param params.serverUrl - HTTPS URL where the server can be reached
|
|
1394
1305
|
* @param params.publicKey - Server's public key for encryption (hex string)
|
|
@@ -1415,6 +1326,7 @@ class PermissionsController {
|
|
|
1415
1326
|
* ```
|
|
1416
1327
|
*/
|
|
1417
1328
|
async addAndTrustServer(params) {
|
|
1329
|
+
this.assertWallet();
|
|
1418
1330
|
try {
|
|
1419
1331
|
const chainId = await this.context.walletClient.getChainId();
|
|
1420
1332
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1422,7 +1334,7 @@ class PermissionsController {
|
|
|
1422
1334
|
"DataPortabilityServers"
|
|
1423
1335
|
);
|
|
1424
1336
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1425
|
-
const account = this.context.walletClient
|
|
1337
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1426
1338
|
const userAddress = typeof account === "string" ? account : account.address;
|
|
1427
1339
|
const normalizedUserAddress = getAddress(userAddress);
|
|
1428
1340
|
const normalizedServerAddress = getAddress(params.serverAddress);
|
|
@@ -1439,7 +1351,7 @@ class PermissionsController {
|
|
|
1439
1351
|
}
|
|
1440
1352
|
],
|
|
1441
1353
|
account,
|
|
1442
|
-
chain: this.context.walletClient
|
|
1354
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1443
1355
|
});
|
|
1444
1356
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1445
1357
|
const txResult = tx({
|
|
@@ -1454,9 +1366,13 @@ class PermissionsController {
|
|
|
1454
1366
|
const result = await this.context.waitForTransactionEvents(txResult);
|
|
1455
1367
|
const event = result.expectedEvents.ServerTrusted;
|
|
1456
1368
|
if (!event) {
|
|
1457
|
-
throw new BlockchainError(
|
|
1369
|
+
throw new BlockchainError(
|
|
1370
|
+
"ServerTrusted event not found in transaction"
|
|
1371
|
+
);
|
|
1458
1372
|
}
|
|
1459
|
-
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1373
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1374
|
+
hash: txHash
|
|
1375
|
+
});
|
|
1460
1376
|
return {
|
|
1461
1377
|
transactionHash: txHash,
|
|
1462
1378
|
blockNumber: receipt.blockNumber,
|
|
@@ -1487,6 +1403,7 @@ class PermissionsController {
|
|
|
1487
1403
|
* @deprecated Use addAndTrustServer instead
|
|
1488
1404
|
*/
|
|
1489
1405
|
async submitTrustServer(params) {
|
|
1406
|
+
this.assertWallet();
|
|
1490
1407
|
try {
|
|
1491
1408
|
const chainId = await this.context.walletClient.getChainId();
|
|
1492
1409
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1494,14 +1411,14 @@ class PermissionsController {
|
|
|
1494
1411
|
"DataPortabilityServers"
|
|
1495
1412
|
);
|
|
1496
1413
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1497
|
-
const account = this.context.walletClient
|
|
1414
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1498
1415
|
const txHash = await this.context.walletClient.writeContract({
|
|
1499
1416
|
address: DataPortabilityServersAddress,
|
|
1500
1417
|
abi: DataPortabilityServersAbi,
|
|
1501
1418
|
functionName: "trustServer",
|
|
1502
1419
|
args: [BigInt(params.serverId)],
|
|
1503
1420
|
account,
|
|
1504
|
-
chain: this.context.walletClient
|
|
1421
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1505
1422
|
});
|
|
1506
1423
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1507
1424
|
return tx({
|
|
@@ -1527,6 +1444,7 @@ class PermissionsController {
|
|
|
1527
1444
|
* @returns Promise resolving to TransactionResult with ServerTrustResult event data
|
|
1528
1445
|
*/
|
|
1529
1446
|
async submitAddAndTrustServerWithSignature(params) {
|
|
1447
|
+
this.assertWallet();
|
|
1530
1448
|
try {
|
|
1531
1449
|
const nonce = await this.getServersUserNonce();
|
|
1532
1450
|
const serverAddress = getAddress(params.serverAddress);
|
|
@@ -1561,7 +1479,7 @@ class PermissionsController {
|
|
|
1561
1479
|
signature
|
|
1562
1480
|
);
|
|
1563
1481
|
}
|
|
1564
|
-
const account = this.context.walletClient
|
|
1482
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1565
1483
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1566
1484
|
return tx({
|
|
1567
1485
|
hash,
|
|
@@ -1598,6 +1516,7 @@ class PermissionsController {
|
|
|
1598
1516
|
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
1599
1517
|
*/
|
|
1600
1518
|
async submitTrustServerWithSignature(params) {
|
|
1519
|
+
this.assertWallet();
|
|
1601
1520
|
try {
|
|
1602
1521
|
const nonce = await this.getServersUserNonce();
|
|
1603
1522
|
const trustServerInput = {
|
|
@@ -1618,7 +1537,7 @@ class PermissionsController {
|
|
|
1618
1537
|
signature
|
|
1619
1538
|
);
|
|
1620
1539
|
}
|
|
1621
|
-
const account = this.context.walletClient
|
|
1540
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1622
1541
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1623
1542
|
return tx({
|
|
1624
1543
|
hash,
|
|
@@ -1657,6 +1576,7 @@ class PermissionsController {
|
|
|
1657
1576
|
* @throws {BlockchainError} When contract submission fails
|
|
1658
1577
|
*/
|
|
1659
1578
|
async submitDirectUntrustTransaction(params) {
|
|
1579
|
+
this.assertWallet();
|
|
1660
1580
|
try {
|
|
1661
1581
|
const chainId = await this.context.walletClient.getChainId();
|
|
1662
1582
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1664,14 +1584,14 @@ class PermissionsController {
|
|
|
1664
1584
|
"DataPortabilityServers"
|
|
1665
1585
|
);
|
|
1666
1586
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1667
|
-
const account = this.context.walletClient
|
|
1587
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1668
1588
|
const txHash = await this.context.walletClient.writeContract({
|
|
1669
1589
|
address: DataPortabilityServersAddress,
|
|
1670
1590
|
abi: DataPortabilityServersAbi,
|
|
1671
1591
|
functionName: "untrustServer",
|
|
1672
1592
|
args: [BigInt(params.serverId)],
|
|
1673
1593
|
account,
|
|
1674
|
-
chain: this.context.walletClient
|
|
1594
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1675
1595
|
});
|
|
1676
1596
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1677
1597
|
return tx({
|
|
@@ -1719,6 +1639,7 @@ class PermissionsController {
|
|
|
1719
1639
|
* ```
|
|
1720
1640
|
*/
|
|
1721
1641
|
async submitUntrustServer(params) {
|
|
1642
|
+
this.assertWallet();
|
|
1722
1643
|
const nonce = await this.getServersUserNonce();
|
|
1723
1644
|
const untrustServerInput = {
|
|
1724
1645
|
nonce,
|
|
@@ -1739,6 +1660,7 @@ class PermissionsController {
|
|
|
1739
1660
|
* @throws {BlockchainError} When untrust transaction fails
|
|
1740
1661
|
*/
|
|
1741
1662
|
async submitUntrustServerWithSignature(params) {
|
|
1663
|
+
this.assertWallet();
|
|
1742
1664
|
try {
|
|
1743
1665
|
const nonce = await this.getServersUserNonce();
|
|
1744
1666
|
const untrustServerInput = {
|
|
@@ -1756,7 +1678,7 @@ class PermissionsController {
|
|
|
1756
1678
|
} else {
|
|
1757
1679
|
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
1758
1680
|
}
|
|
1759
|
-
const account = this.context.walletClient
|
|
1681
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1760
1682
|
const { tx } = await import("../utils/transactionHelpers");
|
|
1761
1683
|
return tx({
|
|
1762
1684
|
hash,
|
|
@@ -1801,8 +1723,8 @@ class PermissionsController {
|
|
|
1801
1723
|
*/
|
|
1802
1724
|
async getTrustedServers(userAddress) {
|
|
1803
1725
|
try {
|
|
1804
|
-
const user = userAddress
|
|
1805
|
-
const chainId = await this.context.
|
|
1726
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1727
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1806
1728
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1807
1729
|
chainId,
|
|
1808
1730
|
"DataPortabilityServers"
|
|
@@ -1831,8 +1753,8 @@ class PermissionsController {
|
|
|
1831
1753
|
*/
|
|
1832
1754
|
async getTrustedServersCount(userAddress) {
|
|
1833
1755
|
try {
|
|
1834
|
-
const user = userAddress
|
|
1835
|
-
const chainId = await this.context.
|
|
1756
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1757
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1836
1758
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1837
1759
|
chainId,
|
|
1838
1760
|
"DataPortabilityServers"
|
|
@@ -1861,10 +1783,10 @@ class PermissionsController {
|
|
|
1861
1783
|
*/
|
|
1862
1784
|
async getTrustedServersPaginated(options = {}) {
|
|
1863
1785
|
try {
|
|
1864
|
-
const user = options.userAddress
|
|
1865
|
-
const limit = options.limit
|
|
1866
|
-
const offset = options.offset
|
|
1867
|
-
const chainId = await this.context.
|
|
1786
|
+
const user = options.userAddress ?? this.context.userAddress;
|
|
1787
|
+
const limit = options.limit ?? 50;
|
|
1788
|
+
const offset = options.offset ?? 0;
|
|
1789
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1868
1790
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1869
1791
|
chainId,
|
|
1870
1792
|
"DataPortabilityServers"
|
|
@@ -2010,7 +1932,7 @@ class PermissionsController {
|
|
|
2010
1932
|
};
|
|
2011
1933
|
}
|
|
2012
1934
|
try {
|
|
2013
|
-
const chainId = await this.context.
|
|
1935
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2014
1936
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2015
1937
|
chainId,
|
|
2016
1938
|
"DataPortabilityServers"
|
|
@@ -2085,7 +2007,7 @@ class PermissionsController {
|
|
|
2085
2007
|
*/
|
|
2086
2008
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
2087
2009
|
try {
|
|
2088
|
-
const user = userAddress
|
|
2010
|
+
const user = userAddress ?? this.context.userAddress;
|
|
2089
2011
|
const trustedServers = await this.getTrustedServers(user);
|
|
2090
2012
|
const trustIndex = trustedServers.findIndex(
|
|
2091
2013
|
(server) => server === serverId
|
|
@@ -2175,7 +2097,7 @@ class PermissionsController {
|
|
|
2175
2097
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
2176
2098
|
*/
|
|
2177
2099
|
async getServersDomain() {
|
|
2178
|
-
const chainId = await this.context.
|
|
2100
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2179
2101
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2180
2102
|
chainId,
|
|
2181
2103
|
"DataPortabilityServers"
|
|
@@ -2195,6 +2117,7 @@ class PermissionsController {
|
|
|
2195
2117
|
* @returns Promise resolving to the transaction hash
|
|
2196
2118
|
*/
|
|
2197
2119
|
async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
|
|
2120
|
+
this.assertWallet();
|
|
2198
2121
|
const chainId = await this.context.walletClient.getChainId();
|
|
2199
2122
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2200
2123
|
chainId,
|
|
@@ -2226,8 +2149,8 @@ class PermissionsController {
|
|
|
2226
2149
|
},
|
|
2227
2150
|
formattedSignature
|
|
2228
2151
|
],
|
|
2229
|
-
account: this.context.walletClient
|
|
2230
|
-
chain: this.context.walletClient
|
|
2152
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2153
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2231
2154
|
});
|
|
2232
2155
|
return txHash;
|
|
2233
2156
|
}
|
|
@@ -2239,6 +2162,7 @@ class PermissionsController {
|
|
|
2239
2162
|
* @returns Promise resolving to the transaction hash
|
|
2240
2163
|
*/
|
|
2241
2164
|
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2165
|
+
this.assertWallet();
|
|
2242
2166
|
const chainId = await this.context.walletClient.getChainId();
|
|
2243
2167
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2244
2168
|
chainId,
|
|
@@ -2257,8 +2181,8 @@ class PermissionsController {
|
|
|
2257
2181
|
},
|
|
2258
2182
|
formattedSignature
|
|
2259
2183
|
],
|
|
2260
|
-
account: this.context.walletClient
|
|
2261
|
-
chain: this.context.walletClient
|
|
2184
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2185
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2262
2186
|
});
|
|
2263
2187
|
return txHash;
|
|
2264
2188
|
}
|
|
@@ -2270,6 +2194,7 @@ class PermissionsController {
|
|
|
2270
2194
|
* @returns Promise resolving to the transaction hash
|
|
2271
2195
|
*/
|
|
2272
2196
|
async submitDirectRevokeTransaction(typedData, signature) {
|
|
2197
|
+
this.assertWallet();
|
|
2273
2198
|
const chainId = await this.context.walletClient.getChainId();
|
|
2274
2199
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2275
2200
|
chainId,
|
|
@@ -2281,10 +2206,9 @@ class PermissionsController {
|
|
|
2281
2206
|
address: DataPortabilityPermissionsAddress,
|
|
2282
2207
|
abi: DataPortabilityPermissionsAbi,
|
|
2283
2208
|
functionName: "revokePermissionWithSignature",
|
|
2284
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2285
2209
|
args: [typedData.message, formattedSignature],
|
|
2286
|
-
account: this.context.walletClient
|
|
2287
|
-
chain: this.context.walletClient
|
|
2210
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2211
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2288
2212
|
});
|
|
2289
2213
|
return txHash;
|
|
2290
2214
|
}
|
|
@@ -2296,6 +2220,7 @@ class PermissionsController {
|
|
|
2296
2220
|
* @returns Promise resolving to the transaction hash
|
|
2297
2221
|
*/
|
|
2298
2222
|
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2223
|
+
this.assertWallet();
|
|
2299
2224
|
const chainId = await this.context.walletClient.getChainId();
|
|
2300
2225
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2301
2226
|
chainId,
|
|
@@ -2303,14 +2228,17 @@ class PermissionsController {
|
|
|
2303
2228
|
);
|
|
2304
2229
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
2305
2230
|
const formattedSignature = formatSignatureForContract(signature);
|
|
2231
|
+
const contractMessage = {
|
|
2232
|
+
nonce: typedData.message.nonce,
|
|
2233
|
+
serverId: BigInt(typedData.message.serverId)
|
|
2234
|
+
};
|
|
2306
2235
|
const txHash = await this.context.walletClient.writeContract({
|
|
2307
2236
|
address: DataPortabilityServersAddress,
|
|
2308
2237
|
abi: DataPortabilityServersAbi,
|
|
2309
2238
|
functionName: "untrustServerWithSignature",
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
chain: this.context.walletClient.chain || null
|
|
2239
|
+
args: [contractMessage, formattedSignature],
|
|
2240
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2241
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2314
2242
|
});
|
|
2315
2243
|
return txHash;
|
|
2316
2244
|
}
|
|
@@ -2343,6 +2271,7 @@ class PermissionsController {
|
|
|
2343
2271
|
* ```
|
|
2344
2272
|
*/
|
|
2345
2273
|
async submitRegisterGrantee(params) {
|
|
2274
|
+
this.assertWallet();
|
|
2346
2275
|
const chainId = await this.context.walletClient.getChainId();
|
|
2347
2276
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
2348
2277
|
chainId,
|
|
@@ -2351,14 +2280,14 @@ class PermissionsController {
|
|
|
2351
2280
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
2352
2281
|
const ownerAddress = getAddress(params.owner);
|
|
2353
2282
|
const granteeAddress = getAddress(params.granteeAddress);
|
|
2354
|
-
const account = this.context.walletClient
|
|
2283
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2355
2284
|
const txHash = await this.context.walletClient.writeContract({
|
|
2356
2285
|
address: DataPortabilityGranteesAddress,
|
|
2357
2286
|
abi: DataPortabilityGranteesAbi,
|
|
2358
2287
|
functionName: "registerGrantee",
|
|
2359
2288
|
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2360
2289
|
account,
|
|
2361
|
-
chain: this.context.walletClient
|
|
2290
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2362
2291
|
});
|
|
2363
2292
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2364
2293
|
return tx({
|
|
@@ -2384,6 +2313,7 @@ class PermissionsController {
|
|
|
2384
2313
|
* ```
|
|
2385
2314
|
*/
|
|
2386
2315
|
async submitRegisterGranteeWithSignature(params) {
|
|
2316
|
+
this.assertWallet();
|
|
2387
2317
|
const nonce = await this.getServersUserNonce();
|
|
2388
2318
|
const owner = getAddress(params.owner);
|
|
2389
2319
|
const granteeAddress = getAddress(params.granteeAddress);
|
|
@@ -2399,7 +2329,7 @@ class PermissionsController {
|
|
|
2399
2329
|
typedData,
|
|
2400
2330
|
signature
|
|
2401
2331
|
);
|
|
2402
|
-
const account = this.context.walletClient
|
|
2332
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2403
2333
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2404
2334
|
return tx({
|
|
2405
2335
|
hash,
|
|
@@ -2425,7 +2355,7 @@ class PermissionsController {
|
|
|
2425
2355
|
typedData,
|
|
2426
2356
|
signature
|
|
2427
2357
|
);
|
|
2428
|
-
const account = this.context.walletClient
|
|
2358
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2429
2359
|
const { tx } = await import("../utils/transactionHelpers");
|
|
2430
2360
|
return tx({
|
|
2431
2361
|
hash,
|
|
@@ -2479,8 +2409,8 @@ class PermissionsController {
|
|
|
2479
2409
|
functionName: "granteesCount"
|
|
2480
2410
|
});
|
|
2481
2411
|
const total = Number(totalCount);
|
|
2482
|
-
const limit = options.limit
|
|
2483
|
-
const offset = options.offset
|
|
2412
|
+
const limit = options.limit ?? 50;
|
|
2413
|
+
const offset = options.offset ?? 0;
|
|
2484
2414
|
const grantees = [];
|
|
2485
2415
|
const endIndex = Math.min(offset + limit, total);
|
|
2486
2416
|
for (let i = offset; i < endIndex; i++) {
|
|
@@ -2628,7 +2558,7 @@ class PermissionsController {
|
|
|
2628
2558
|
* @private
|
|
2629
2559
|
*/
|
|
2630
2560
|
async buildRegisterGranteeTypedData(input) {
|
|
2631
|
-
const chainId = await this.context.
|
|
2561
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2632
2562
|
const verifyingContract = getContractAddress(
|
|
2633
2563
|
chainId,
|
|
2634
2564
|
"DataPortabilityGrantees"
|
|
@@ -2661,6 +2591,7 @@ class PermissionsController {
|
|
|
2661
2591
|
* @private
|
|
2662
2592
|
*/
|
|
2663
2593
|
async submitSignedRegisterGranteeTransaction(typedData, _signature) {
|
|
2594
|
+
this.assertWallet();
|
|
2664
2595
|
const chainId = await this.context.walletClient.getChainId();
|
|
2665
2596
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
2666
2597
|
chainId,
|
|
@@ -2676,8 +2607,8 @@ class PermissionsController {
|
|
|
2676
2607
|
typedData.message.granteeAddress,
|
|
2677
2608
|
typedData.message.publicKey
|
|
2678
2609
|
],
|
|
2679
|
-
account: this.context.walletClient
|
|
2680
|
-
chain: this.context.walletClient
|
|
2610
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2611
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2681
2612
|
});
|
|
2682
2613
|
return txHash;
|
|
2683
2614
|
}
|
|
@@ -2692,7 +2623,7 @@ class PermissionsController {
|
|
|
2692
2623
|
*/
|
|
2693
2624
|
async getUserServerIds(userAddress) {
|
|
2694
2625
|
try {
|
|
2695
|
-
const targetAddress = userAddress
|
|
2626
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2696
2627
|
const chainId = await this.context.publicClient.getChainId();
|
|
2697
2628
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2698
2629
|
chainId,
|
|
@@ -2750,7 +2681,7 @@ class PermissionsController {
|
|
|
2750
2681
|
*/
|
|
2751
2682
|
async getUserServerCount(userAddress) {
|
|
2752
2683
|
try {
|
|
2753
|
-
const targetAddress = userAddress
|
|
2684
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2754
2685
|
const chainId = await this.context.publicClient.getChainId();
|
|
2755
2686
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2756
2687
|
chainId,
|
|
@@ -2779,7 +2710,7 @@ class PermissionsController {
|
|
|
2779
2710
|
*/
|
|
2780
2711
|
async getUserTrustedServers(userAddress) {
|
|
2781
2712
|
try {
|
|
2782
|
-
const targetAddress = userAddress
|
|
2713
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2783
2714
|
const chainId = await this.context.publicClient.getChainId();
|
|
2784
2715
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2785
2716
|
chainId,
|
|
@@ -2896,7 +2827,7 @@ class PermissionsController {
|
|
|
2896
2827
|
*/
|
|
2897
2828
|
async getUserPermissionIds(userAddress) {
|
|
2898
2829
|
try {
|
|
2899
|
-
const targetAddress = userAddress
|
|
2830
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2900
2831
|
const chainId = await this.context.publicClient.getChainId();
|
|
2901
2832
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2902
2833
|
chainId,
|
|
@@ -2958,7 +2889,7 @@ class PermissionsController {
|
|
|
2958
2889
|
*/
|
|
2959
2890
|
async getUserPermissionCount(userAddress) {
|
|
2960
2891
|
try {
|
|
2961
|
-
const targetAddress = userAddress
|
|
2892
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2962
2893
|
const chainId = await this.context.publicClient.getChainId();
|
|
2963
2894
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2964
2895
|
chainId,
|
|
@@ -3403,6 +3334,7 @@ class PermissionsController {
|
|
|
3403
3334
|
* @returns Promise resolving to transaction hash
|
|
3404
3335
|
*/
|
|
3405
3336
|
async submitUpdateServer(serverId, url) {
|
|
3337
|
+
this.assertWallet();
|
|
3406
3338
|
try {
|
|
3407
3339
|
const chainId = await this.context.walletClient.getChainId();
|
|
3408
3340
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -3410,13 +3342,13 @@ class PermissionsController {
|
|
|
3410
3342
|
"DataPortabilityServers"
|
|
3411
3343
|
);
|
|
3412
3344
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
3413
|
-
const account = this.context.walletClient
|
|
3345
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3414
3346
|
const hash = await this.context.walletClient.writeContract({
|
|
3415
3347
|
address: DataPortabilityServersAddress,
|
|
3416
3348
|
abi: DataPortabilityServersAbi,
|
|
3417
3349
|
functionName: "updateServer",
|
|
3418
3350
|
args: [serverId, url],
|
|
3419
|
-
chain: this.context.walletClient
|
|
3351
|
+
chain: this.context.walletClient?.chain,
|
|
3420
3352
|
account
|
|
3421
3353
|
});
|
|
3422
3354
|
const { tx } = await import("../utils/transactionHelpers");
|
|
@@ -3575,6 +3507,7 @@ class PermissionsController {
|
|
|
3575
3507
|
* @throws {NetworkError} When network communication fails
|
|
3576
3508
|
*/
|
|
3577
3509
|
async submitAddPermission(params) {
|
|
3510
|
+
this.assertWallet();
|
|
3578
3511
|
try {
|
|
3579
3512
|
const nonce = await this.getPermissionsUserNonce();
|
|
3580
3513
|
const addPermissionInput = {
|
|
@@ -3613,6 +3546,7 @@ class PermissionsController {
|
|
|
3613
3546
|
* @throws {NetworkError} When network communication fails
|
|
3614
3547
|
*/
|
|
3615
3548
|
async submitSignedAddPermission(typedData, signature) {
|
|
3549
|
+
this.assertWallet();
|
|
3616
3550
|
try {
|
|
3617
3551
|
let hash;
|
|
3618
3552
|
if (this.context.relayerCallbacks?.submitAddPermission) {
|
|
@@ -3626,7 +3560,7 @@ class PermissionsController {
|
|
|
3626
3560
|
signature
|
|
3627
3561
|
);
|
|
3628
3562
|
}
|
|
3629
|
-
const account = this.context.walletClient
|
|
3563
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3630
3564
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3631
3565
|
return tx({
|
|
3632
3566
|
hash,
|
|
@@ -3662,7 +3596,7 @@ class PermissionsController {
|
|
|
3662
3596
|
* @param params.serverAddress - Server wallet address for decryption permissions
|
|
3663
3597
|
* @param params.serverUrl - Server endpoint URL
|
|
3664
3598
|
* @param params.serverPublicKey - Server's public key for encryption.
|
|
3665
|
-
* Obtain via `vana.server.getIdentity(userAddress).
|
|
3599
|
+
* Obtain via `vana.server.getIdentity(userAddress).publicKey`.
|
|
3666
3600
|
* @param params.filePermissions - Nested array of permissions for each file
|
|
3667
3601
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3668
3602
|
* @throws {Error} When schemaIds array length doesn't match fileUrls array length
|
|
@@ -3684,7 +3618,7 @@ class PermissionsController {
|
|
|
3684
3618
|
* schemaIds: [123], // LinkedIn profile schema ID
|
|
3685
3619
|
* serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3686
3620
|
* serverUrl: "https://server.example.com",
|
|
3687
|
-
* serverPublicKey: serverInfo.
|
|
3621
|
+
* serverPublicKey: serverInfo.publicKey,
|
|
3688
3622
|
* filePermissions: [[{
|
|
3689
3623
|
* account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3690
3624
|
* key: encryptedKey
|
|
@@ -3695,6 +3629,7 @@ class PermissionsController {
|
|
|
3695
3629
|
* ```
|
|
3696
3630
|
*/
|
|
3697
3631
|
async submitAddServerFilesAndPermissions(params) {
|
|
3632
|
+
this.assertWallet();
|
|
3698
3633
|
try {
|
|
3699
3634
|
if (params.schemaIds.length !== params.fileUrls.length) {
|
|
3700
3635
|
throw new Error(
|
|
@@ -3759,6 +3694,7 @@ class PermissionsController {
|
|
|
3759
3694
|
* ```
|
|
3760
3695
|
*/
|
|
3761
3696
|
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
3697
|
+
this.assertWallet();
|
|
3762
3698
|
try {
|
|
3763
3699
|
console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
|
|
3764
3700
|
hasRelayerCallbacks: !!this.context.relayerCallbacks,
|
|
@@ -3773,7 +3709,7 @@ class PermissionsController {
|
|
|
3773
3709
|
typedData,
|
|
3774
3710
|
signature
|
|
3775
3711
|
);
|
|
3776
|
-
const account = this.context.walletClient
|
|
3712
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3777
3713
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3778
3714
|
return tx({
|
|
3779
3715
|
hash,
|
|
@@ -3789,11 +3725,11 @@ class PermissionsController {
|
|
|
3789
3725
|
typedData,
|
|
3790
3726
|
signature
|
|
3791
3727
|
);
|
|
3792
|
-
const account = this.context.
|
|
3728
|
+
const account = this.context.userAddress;
|
|
3793
3729
|
const { tx } = await import("../utils/transactionHelpers");
|
|
3794
3730
|
return tx({
|
|
3795
3731
|
hash,
|
|
3796
|
-
from:
|
|
3732
|
+
from: account,
|
|
3797
3733
|
contract: "DataPortabilityPermissions",
|
|
3798
3734
|
fn: "addServerFilesAndPermissions"
|
|
3799
3735
|
});
|
|
@@ -3815,6 +3751,7 @@ class PermissionsController {
|
|
|
3815
3751
|
* @returns Promise resolving to transaction hash
|
|
3816
3752
|
*/
|
|
3817
3753
|
async submitRevokePermission(permissionId) {
|
|
3754
|
+
this.assertWallet();
|
|
3818
3755
|
try {
|
|
3819
3756
|
const chainId = await this.context.walletClient.getChainId();
|
|
3820
3757
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
@@ -3824,7 +3761,7 @@ class PermissionsController {
|
|
|
3824
3761
|
const DataPortabilityPermissionsAbi = getAbi(
|
|
3825
3762
|
"DataPortabilityPermissions"
|
|
3826
3763
|
);
|
|
3827
|
-
const account = this.context.walletClient
|
|
3764
|
+
const { account } = this.context.walletClient;
|
|
3828
3765
|
if (!account) {
|
|
3829
3766
|
throw new Error("No wallet account connected");
|
|
3830
3767
|
}
|
|
@@ -3833,7 +3770,7 @@ class PermissionsController {
|
|
|
3833
3770
|
abi: DataPortabilityPermissionsAbi,
|
|
3834
3771
|
functionName: "revokePermission",
|
|
3835
3772
|
args: [permissionId],
|
|
3836
|
-
chain: this.context.walletClient
|
|
3773
|
+
chain: this.context.walletClient?.chain,
|
|
3837
3774
|
account
|
|
3838
3775
|
});
|
|
3839
3776
|
const { tx } = await import("../utils/transactionHelpers");
|
|
@@ -3858,6 +3795,7 @@ class PermissionsController {
|
|
|
3858
3795
|
* @returns Promise resolving to the transaction hash
|
|
3859
3796
|
*/
|
|
3860
3797
|
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
3798
|
+
this.assertWallet();
|
|
3861
3799
|
const chainId = await this.context.walletClient.getChainId();
|
|
3862
3800
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
3863
3801
|
chainId,
|
|
@@ -3868,7 +3806,7 @@ class PermissionsController {
|
|
|
3868
3806
|
nonce: typedData.message.nonce,
|
|
3869
3807
|
granteeId: typedData.message.granteeId,
|
|
3870
3808
|
grant: typedData.message.grant,
|
|
3871
|
-
fileIds: typedData.message.fileIds
|
|
3809
|
+
fileIds: typedData.message.fileIds ?? []
|
|
3872
3810
|
};
|
|
3873
3811
|
const formattedSignature = formatSignatureForContract(signature);
|
|
3874
3812
|
const hash = await this.context.walletClient.writeContract({
|
|
@@ -3876,8 +3814,8 @@ class PermissionsController {
|
|
|
3876
3814
|
abi: DataPortabilityPermissionsAbi,
|
|
3877
3815
|
functionName: "addPermission",
|
|
3878
3816
|
args: [permissionInput, formattedSignature],
|
|
3879
|
-
account: this.context.walletClient
|
|
3880
|
-
chain: this.context.walletClient
|
|
3817
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3818
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3881
3819
|
});
|
|
3882
3820
|
return hash;
|
|
3883
3821
|
}
|
|
@@ -3889,7 +3827,8 @@ class PermissionsController {
|
|
|
3889
3827
|
* @returns Promise resolving to the transaction hash
|
|
3890
3828
|
*/
|
|
3891
3829
|
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
|
|
3892
|
-
|
|
3830
|
+
this.assertWallet();
|
|
3831
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
3893
3832
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
3894
3833
|
chainId,
|
|
3895
3834
|
"DataPortabilityPermissions"
|
|
@@ -3913,8 +3852,8 @@ class PermissionsController {
|
|
|
3913
3852
|
functionName: "addServerFilesAndPermissions",
|
|
3914
3853
|
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
3915
3854
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
3916
|
-
account: this.context.
|
|
3917
|
-
chain: this.context.walletClient
|
|
3855
|
+
account: this.context.userAddress,
|
|
3856
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3918
3857
|
});
|
|
3919
3858
|
return hash;
|
|
3920
3859
|
}
|