@opendatalabs/vana-sdk 0.1.0-alpha.d7fc764 → 0.1.0-alpha.dba79a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +36 -2
- package/dist/browser.js.map +1 -1
- package/dist/chains/definitions.cjs +9 -6
- package/dist/chains/definitions.cjs.map +1 -1
- package/dist/chains/definitions.d.ts +9 -11
- package/dist/chains/definitions.js +9 -6
- package/dist/chains/definitions.js.map +1 -1
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.d.ts +34 -2
- package/dist/chains/index.js.map +1 -1
- package/dist/chains.browser.d.ts +8 -2
- package/dist/chains.d.ts +8 -2
- package/dist/chains.node.d.ts +8 -2
- package/dist/config/addresses.d.ts +8 -24
- package/dist/config/chains.cjs.map +1 -1
- package/dist/config/chains.d.ts +108 -13
- package/dist/config/chains.js.map +1 -1
- package/dist/config/default-services.cjs +60 -0
- package/dist/config/default-services.cjs.map +1 -0
- package/dist/config/default-services.d.ts +46 -0
- package/dist/config/default-services.js +33 -0
- package/dist/config/default-services.js.map +1 -0
- package/dist/config/default-services.test.d.ts +1 -0
- package/dist/config/features.d.ts +1 -3
- package/dist/config/tests/addresses.test.d.ts +1 -0
- package/dist/contracts/contractController.cjs +3 -3
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +77 -38
- package/dist/contracts/contractController.js +4 -7
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/contracts/tests/contractController.test.d.ts +1 -0
- package/dist/controllers/__tests__/data-consistency-integration.test.d.ts +7 -0
- package/dist/controllers/__tests__/operations.processQueue.test.d.ts +1 -0
- package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
- package/dist/controllers/base.cjs +116 -0
- package/dist/controllers/base.cjs.map +1 -0
- package/dist/controllers/base.d.ts +94 -0
- package/dist/controllers/base.js +92 -0
- package/dist/controllers/base.js.map +1 -0
- package/dist/controllers/data-error-handling.test.d.ts +1 -0
- package/dist/controllers/data.cjs +827 -439
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +373 -254
- package/dist/controllers/data.js +840 -442
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/operations.cjs +430 -0
- package/dist/controllers/operations.cjs.map +1 -0
- package/dist/controllers/operations.d.ts +229 -0
- package/dist/controllers/operations.js +406 -0
- package/dist/controllers/operations.js.map +1 -0
- package/dist/controllers/permissions.cjs +929 -483
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +1318 -25
- package/dist/controllers/permissions.js +929 -483
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs +15 -11
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +34 -63
- package/dist/controllers/protocol.js +15 -14
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +100 -75
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +56 -74
- package/dist/controllers/schemas.js +100 -75
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server-additional.test.d.ts +1 -0
- package/dist/controllers/server.cjs +32 -25
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +53 -71
- package/dist/controllers/server.js +32 -25
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/__tests__/health.test.d.ts +1 -0
- package/dist/core/__tests__/inMemoryNonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/nonceManager.test.d.ts +1 -0
- package/dist/core/__tests__/pollingManager.test.d.ts +4 -0
- package/dist/core/apiClient.cjs +68 -15
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +137 -16
- package/dist/core/apiClient.js +72 -22
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/client.cjs +7 -7
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +6 -9
- package/dist/core/client.js +7 -7
- package/dist/core/client.js.map +1 -1
- package/dist/core/core.test.d.ts +1 -0
- package/dist/core/generics.cjs +41 -12
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +104 -19
- package/dist/core/generics.js +52 -32
- package/dist/core/generics.js.map +1 -1
- package/dist/core/health.cjs +289 -0
- package/dist/core/health.cjs.map +1 -0
- package/dist/core/health.d.ts +143 -0
- package/dist/core/health.js +265 -0
- package/dist/core/health.js.map +1 -0
- package/dist/core/inMemoryNonceManager.cjs +138 -0
- package/dist/core/inMemoryNonceManager.cjs.map +1 -0
- package/dist/core/inMemoryNonceManager.d.ts +69 -0
- package/dist/core/inMemoryNonceManager.js +114 -0
- package/dist/core/inMemoryNonceManager.js.map +1 -0
- package/dist/core/nonceManager.cjs +304 -0
- package/dist/core/nonceManager.cjs.map +1 -0
- package/dist/core/nonceManager.d.ts +116 -0
- package/dist/core/nonceManager.js +280 -0
- package/dist/core/nonceManager.js.map +1 -0
- package/dist/core/pollingManager.cjs +292 -0
- package/dist/core/pollingManager.cjs.map +1 -0
- package/dist/core/pollingManager.d.ts +120 -0
- package/dist/core/pollingManager.js +268 -0
- package/dist/core/pollingManager.js.map +1 -0
- package/dist/core/tests/apiClient.test.d.ts +1 -0
- package/dist/core/tests/client.test.d.ts +1 -0
- package/dist/core/tests/generics.test.d.ts +1 -0
- package/dist/core.cjs +152 -61
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +50 -67
- package/dist/core.js +164 -86
- package/dist/core.js.map +1 -1
- package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
- package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
- package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.ts +2 -4
- package/dist/crypto/ecies/base.cjs +20 -6
- package/dist/crypto/ecies/base.cjs.map +1 -1
- package/dist/crypto/ecies/base.d.ts +2 -5
- package/dist/crypto/ecies/base.js +28 -18
- package/dist/crypto/ecies/base.js.map +1 -1
- package/dist/crypto/ecies/browser.cjs +2 -1
- package/dist/crypto/ecies/browser.cjs.map +1 -1
- package/dist/crypto/ecies/browser.d.ts +2 -7
- package/dist/crypto/ecies/browser.js +2 -1
- package/dist/crypto/ecies/browser.js.map +1 -1
- package/dist/crypto/ecies/constants.d.ts +7 -9
- package/dist/crypto/ecies/index.d.ts +8 -1
- package/dist/crypto/ecies/interface.cjs +4 -5
- package/dist/crypto/ecies/interface.cjs.map +1 -1
- package/dist/crypto/ecies/interface.d.ts +9 -11
- package/dist/crypto/ecies/interface.js +4 -5
- package/dist/crypto/ecies/interface.js.map +1 -1
- package/dist/crypto/ecies/node.cjs +3 -2
- package/dist/crypto/ecies/node.cjs.map +1 -1
- package/dist/crypto/ecies/node.d.ts +2 -7
- package/dist/crypto/ecies/node.js +11 -16
- package/dist/crypto/ecies/node.js.map +1 -1
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +2 -41
- package/dist/crypto/ecies/utils.cjs.map +1 -1
- package/dist/crypto/ecies/utils.d.ts +3 -40
- package/dist/crypto/ecies/utils.js +1 -35
- package/dist/crypto/ecies/utils.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
- package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
- package/dist/diagnostics.d.ts +1 -3
- package/dist/diagnostics.test.d.ts +1 -0
- package/dist/errors.cjs +45 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +117 -15
- package/dist/errors.js +46 -6
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DATFactoryImplementation.d.ts +2 -3
- package/dist/generated/abi/DATImplementation.d.ts +2 -3
- package/dist/generated/abi/DATPausableImplementation.d.ts +2 -3
- package/dist/generated/abi/DATVotesImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPPerformanceImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRewardSwapImplementation.d.ts +2 -3
- package/dist/generated/abi/DLPRootImplementation.d.ts +1 -3
- package/dist/generated/abi/DLPTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.ts +1 -3
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.ts +2 -3
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.ts +2 -3
- package/dist/generated/abi/DataPortabilityServersImplementation.d.ts +2 -3
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.ts +2 -3
- package/dist/generated/abi/DataRegistryImplementation.cjs +13 -0
- package/dist/generated/abi/DataRegistryImplementation.cjs.map +1 -1
- package/dist/generated/abi/DataRegistryImplementation.d.ts +12 -3
- package/dist/generated/abi/DataRegistryImplementation.js +13 -0
- package/dist/generated/abi/DataRegistryImplementation.js.map +1 -1
- package/dist/generated/abi/QueryEngineImplementation.d.ts +2 -3
- package/dist/generated/abi/SwapHelperImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.ts +2 -3
- package/dist/generated/abi/TeePoolPhalaImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaEpochImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +2 -3
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.ts +2 -3
- package/dist/generated/abi/index.cjs +42 -0
- package/dist/generated/abi/index.cjs.map +1 -1
- package/dist/generated/abi/index.d.ts +47 -18
- package/dist/generated/abi/index.js +21 -0
- package/dist/generated/abi/index.js.map +1 -1
- package/dist/generated/event-types.cjs +17 -0
- package/dist/generated/event-types.cjs.map +1 -0
- package/dist/generated/event-types.d.ts +854 -0
- package/dist/generated/event-types.js +1 -0
- package/dist/generated/event-types.js.map +1 -0
- package/dist/generated/eventRegistry.cjs +3351 -0
- package/dist/generated/eventRegistry.cjs.map +1 -0
- package/dist/generated/eventRegistry.d.ts +14 -0
- package/dist/generated/eventRegistry.js +3326 -0
- package/dist/generated/eventRegistry.js.map +1 -0
- package/dist/generated/server/server-exports.d.ts +19 -21
- package/dist/generated/server/server.cjs.map +1 -1
- package/dist/generated/server/server.d.ts +113 -87
- package/dist/generated/subgraph.cjs +797 -32
- package/dist/generated/subgraph.cjs.map +1 -1
- package/dist/generated/subgraph.d.ts +464 -332
- package/dist/generated/subgraph.js +792 -32
- package/dist/generated/subgraph.js.map +1 -1
- package/dist/index.browser.d.ts +49 -73
- package/dist/index.browser.js +14 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +31 -3
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +223 -64
- package/dist/index.node.js +28 -2
- package/dist/index.node.js.map +1 -1
- package/dist/lib/__tests__/redisAtomicStore.test.d.ts +1 -0
- package/dist/lib/redisAtomicStore.cjs +201 -0
- package/dist/lib/redisAtomicStore.cjs.map +1 -0
- package/dist/lib/redisAtomicStore.d.ts +120 -0
- package/dist/lib/redisAtomicStore.js +177 -0
- package/dist/lib/redisAtomicStore.js.map +1 -0
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +42 -2
- package/dist/node.js.map +1 -1
- package/dist/platform/browser-only.d.ts +5 -8
- package/dist/platform/browser-only.test.d.ts +1 -0
- package/dist/platform/browser-safe.d.ts +6 -9
- package/dist/platform/browser-safe.test.d.ts +1 -0
- package/dist/platform/browser.cjs +167 -8
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +235 -18
- package/dist/platform/browser.js +179 -29
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/browser.test.d.ts +1 -0
- package/dist/platform/index.d.ts +11 -5
- package/dist/platform/interface.cjs.map +1 -1
- package/dist/platform/interface.d.ts +289 -98
- package/dist/platform/node.cjs +163 -2
- package/dist/platform/node.cjs.map +1 -1
- package/dist/platform/node.d.ts +72 -13
- package/dist/platform/node.js +175 -21
- package/dist/platform/node.js.map +1 -1
- package/dist/platform/ports/openpgp-port.cjs +74 -0
- package/dist/platform/ports/openpgp-port.cjs.map +1 -0
- package/dist/platform/ports/openpgp-port.d.ts +13 -0
- package/dist/platform/ports/openpgp-port.js +59 -0
- package/dist/platform/ports/openpgp-port.js.map +1 -0
- package/dist/platform/ports/pgp-port.cjs +17 -0
- package/dist/platform/ports/pgp-port.cjs.map +1 -0
- package/dist/platform/ports/pgp-port.d.ts +35 -0
- package/dist/platform/ports/pgp-port.js +1 -0
- package/dist/platform/ports/pgp-port.js.map +1 -0
- package/dist/platform/shared/error-utils.d.ts +2 -4
- package/dist/platform/shared/pgp-utils.cjs +2 -2
- package/dist/platform/shared/pgp-utils.cjs.map +1 -1
- package/dist/platform/shared/pgp-utils.d.ts +3 -5
- package/dist/platform/shared/pgp-utils.js +2 -2
- package/dist/platform/shared/pgp-utils.js.map +1 -1
- package/dist/platform/shared/stream-utils.d.ts +1 -3
- package/dist/platform/utils.d.ts +6 -10
- package/dist/platform/utils.test.d.ts +1 -0
- package/dist/platform.browser.d.ts +9 -4
- package/dist/platform.d.ts +11 -5
- package/dist/platform.node.d.ts +10 -5
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/relayerHandler.cjs +420 -0
- package/dist/server/relayerHandler.cjs.map +1 -0
- package/dist/server/relayerHandler.d.ts +69 -0
- package/dist/server/relayerHandler.js +396 -0
- package/dist/server/relayerHandler.js.map +1 -0
- package/dist/storage/index.d.ts +56 -10
- package/dist/storage/manager.cjs +114 -31
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +121 -30
- package/dist/storage/manager.js +113 -37
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +89 -18
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +111 -28
- package/dist/storage/providers/callback-storage.js +89 -18
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/google-drive.cjs +2 -2
- package/dist/storage/providers/google-drive.cjs.map +1 -1
- package/dist/storage/providers/google-drive.d.ts +3 -7
- package/dist/storage/providers/google-drive.js +4 -7
- package/dist/storage/providers/google-drive.js.map +1 -1
- package/dist/storage/providers/google-drive.test.d.ts +1 -0
- package/dist/storage/providers/ipfs.cjs +5 -5
- package/dist/storage/providers/ipfs.cjs.map +1 -1
- package/dist/storage/providers/ipfs.d.ts +3 -6
- package/dist/storage/providers/ipfs.js +7 -10
- package/dist/storage/providers/ipfs.js.map +1 -1
- package/dist/storage/providers/pinata.cjs +6 -6
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +17 -22
- package/dist/storage/providers/pinata.js +8 -11
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
- package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
- package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
- package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
- package/dist/storage/tests/storageManager.test.d.ts +1 -0
- package/dist/tests/abi.test.d.ts +1 -0
- package/dist/tests/chains-definitions.test.d.ts +1 -0
- package/dist/tests/core-encryption.test.d.ts +1 -0
- package/dist/tests/core-extended.test.d.ts +1 -0
- package/dist/tests/core-generics-coverage.test.d.ts +1 -0
- package/dist/tests/coverage-boost.test.d.ts +1 -0
- package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
- package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
- package/dist/tests/data-additional-methods.test.d.ts +1 -0
- package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
- package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
- package/dist/tests/data-relayer.test.d.ts +1 -0
- package/dist/tests/data-schema-validation.test.d.ts +1 -0
- package/dist/tests/data-simple-methods.test.d.ts +1 -0
- package/dist/tests/data.test.d.ts +1 -0
- package/dist/tests/demo-integration.test.d.ts +1 -0
- package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
- package/dist/tests/download-relayer.test.d.ts +1 -0
- package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
- package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
- package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
- package/dist/tests/encryption-coverage.test.d.ts +1 -0
- package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
- package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
- package/dist/tests/errors-coverage.test.d.ts +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/factories/mockFactory.d.ts +316 -0
- package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
- package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
- package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
- package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
- package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
- package/dist/tests/helper-methods.test.d.ts +1 -0
- package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
- package/dist/tests/helpers/typedMocks.d.ts +64 -0
- package/dist/tests/index-browser.test.d.ts +1 -0
- package/dist/tests/index-node.test.d.ts +1 -0
- package/dist/tests/index.test.d.ts +1 -0
- package/dist/tests/mocks/platformAdapter.d.ts +12 -0
- package/dist/tests/new-permissions-methods.test.d.ts +1 -0
- package/dist/tests/no-buffer-browser.test.d.ts +1 -0
- package/dist/tests/permissions-grantee.test.d.ts +1 -0
- package/dist/tests/permissions-revoke-relayer.test.d.ts +1 -0
- package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
- package/dist/tests/permissions-server-files.test.d.ts +1 -0
- package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
- package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
- package/dist/tests/permissions.test.d.ts +1 -0
- package/dist/tests/personal.test.d.ts +1 -0
- package/dist/tests/platform-browser.test.d.ts +1 -0
- package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
- package/dist/tests/platform-crypto.test.d.ts +1 -0
- package/dist/tests/platform-index.test.d.ts +1 -0
- package/dist/tests/platform-node.test.d.ts +1 -0
- package/dist/tests/platform-shared-utils.test.d.ts +1 -0
- package/dist/tests/platform-updated.test.d.ts +1 -0
- package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
- package/dist/tests/protocol.test.d.ts +1 -0
- package/dist/tests/read-only-mode.test.d.ts +1 -0
- package/dist/tests/relayer-integration.test.d.ts +1 -0
- package/dist/tests/relayer-unified.test.d.ts +1 -0
- package/dist/tests/schemas.test.d.ts +1 -0
- package/dist/tests/server-relayer-handler.test.d.ts +1 -0
- package/dist/tests/setup.d.ts +7 -0
- package/dist/tests/signatureFormatter.test.d.ts +1 -0
- package/dist/tests/trusted-server-queries.test.d.ts +1 -0
- package/dist/tests/typedDataConverter.test.d.ts +1 -0
- package/dist/tests/types-contracts.test.d.ts +1 -0
- package/dist/tests/types-data.test.d.ts +1 -0
- package/dist/tests/types-external-apis.test.d.ts +1 -0
- package/dist/tests/types-generics.test.d.ts +1 -0
- package/dist/tests/types-permissions.test.d.ts +1 -0
- package/dist/tests/types-upload-params.test.d.ts +1 -0
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/tests/utils-formatters.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles.test.d.ts +1 -0
- package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
- package/dist/tests/utils-grants.test.d.ts +1 -0
- package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
- package/dist/tests/utils-ipfs.test.d.ts +4 -0
- package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
- package/dist/tests/vana.test.d.ts +1 -0
- package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
- package/dist/{chains.browser.cjs → types/atomicStore.cjs} +9 -15
- package/dist/types/atomicStore.cjs.map +1 -0
- package/dist/types/atomicStore.d.ts +236 -0
- package/dist/types/atomicStore.js +7 -0
- package/dist/types/atomicStore.js.map +1 -0
- package/dist/types/blockchain.cjs +17 -0
- package/dist/types/blockchain.cjs.map +1 -0
- package/dist/types/blockchain.d.ts +85 -0
- package/dist/types/blockchain.js +1 -0
- package/dist/types/blockchain.js.map +1 -0
- package/dist/types/chains-additional.test.d.ts +1 -0
- package/dist/types/chains.cjs.map +1 -1
- package/dist/types/chains.d.ts +80 -16
- package/dist/types/chains.js.map +1 -1
- package/dist/types/config.cjs +10 -0
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +236 -242
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +79 -18
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.ts +68 -0
- package/dist/types/controller-context.js +1 -0
- package/dist/types/controller-context.js.map +1 -0
- package/dist/types/data.cjs.map +1 -1
- package/dist/types/data.d.ts +118 -49
- package/dist/types/external-apis.d.ts +10 -12
- package/dist/types/generics.cjs.map +1 -1
- package/dist/types/generics.d.ts +116 -48
- package/dist/types/index.cjs +5 -4
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +48 -34
- package/dist/types/index.js +9 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/operationStore.cjs +17 -0
- package/dist/types/operationStore.cjs.map +1 -0
- package/dist/types/operationStore.d.ts +171 -0
- package/dist/types/operationStore.js +1 -0
- package/dist/types/operationStore.js.map +1 -0
- package/dist/types/operations.cjs +2 -2
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +164 -42
- package/dist/types/operations.js +2 -2
- package/dist/types/operations.js.map +1 -1
- package/dist/types/options.cjs +17 -0
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.d.ts +308 -0
- package/dist/types/options.js +1 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/permissions.cjs.map +1 -1
- package/dist/types/permissions.d.ts +72 -78
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +137 -22
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +293 -50
- package/dist/types/storage.cjs.map +1 -1
- package/dist/types/storage.d.ts +15 -29
- package/dist/types/storage.js +2 -5
- package/dist/types/storage.js.map +1 -1
- package/dist/types/transactionResults.cjs.map +1 -1
- package/dist/types/transactionResults.d.ts +193 -25
- package/dist/types/utils.cjs.map +1 -1
- package/dist/types/utils.d.ts +20 -68
- package/dist/types.d.ts +4 -40
- package/dist/utils/__tests__/parseTransaction.test.d.ts +1 -0
- package/dist/utils/__tests__/pojo-serialization.test.d.ts +1 -0
- package/dist/utils/__tests__/signatureCache.test.d.ts +1 -0
- package/dist/utils/__tests__/subgraphConsistency.test.d.ts +4 -0
- package/dist/utils/__tests__/subgraphPagination.test.d.ts +4 -0
- package/dist/utils/__tests__/transaction-edge-cases.test.d.ts +1 -0
- package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
- package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
- package/dist/utils/blockchain/registry.cjs +2 -2
- package/dist/utils/blockchain/registry.cjs.map +1 -1
- package/dist/utils/blockchain/registry.d.ts +6 -8
- package/dist/utils/blockchain/registry.js +2 -2
- package/dist/utils/blockchain/registry.js.map +1 -1
- package/dist/utils/blockchain/registry.test.d.ts +1 -0
- package/dist/utils/chainQuery.cjs +107 -0
- package/dist/utils/chainQuery.cjs.map +1 -0
- package/dist/utils/chainQuery.d.ts +31 -0
- package/dist/utils/chainQuery.js +82 -0
- package/dist/utils/chainQuery.js.map +1 -0
- package/dist/utils/crypto-utils.cjs +0 -12
- package/dist/utils/crypto-utils.cjs.map +1 -1
- package/dist/utils/crypto-utils.d.ts +9 -27
- package/dist/utils/crypto-utils.js +0 -11
- package/dist/utils/crypto-utils.js.map +1 -1
- package/dist/utils/crypto-utils.test.d.ts +1 -0
- package/dist/utils/download.cjs +3 -3
- package/dist/utils/download.cjs.map +1 -1
- package/dist/utils/download.d.ts +13 -14
- package/dist/utils/download.js +2 -2
- package/dist/utils/download.js.map +1 -1
- package/dist/utils/encoding.cjs +1 -1
- package/dist/utils/encoding.cjs.map +1 -1
- package/dist/utils/encoding.d.ts +4 -6
- package/dist/utils/encoding.js +1 -1
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/encoding.test.d.ts +1 -0
- package/dist/utils/encryption.cjs +16 -10
- package/dist/utils/encryption.cjs.map +1 -1
- package/dist/utils/encryption.d.ts +13 -17
- package/dist/utils/encryption.js +16 -10
- package/dist/utils/encryption.js.map +1 -1
- package/dist/utils/formatters.cjs +4 -2
- package/dist/utils/formatters.cjs.map +1 -1
- package/dist/utils/formatters.d.ts +4 -6
- package/dist/utils/formatters.js +4 -2
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/grantFiles.cjs +7 -4
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +16 -30
- package/dist/utils/grantFiles.js +7 -4
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +109 -33
- package/dist/utils/grantValidation.js +1 -1
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +101 -23
- package/dist/utils/grants.js +1 -1
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/ipfs.cjs +2 -4
- package/dist/utils/ipfs.cjs.map +1 -1
- package/dist/utils/ipfs.d.ts +8 -10
- package/dist/utils/ipfs.js +2 -4
- package/dist/utils/ipfs.js.map +1 -1
- package/dist/utils/lazy-import.cjs +4 -6
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +33 -10
- package/dist/utils/lazy-import.js +4 -6
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/multicall.cjs +4 -2
- package/dist/utils/multicall.cjs.map +1 -1
- package/dist/utils/multicall.d.ts +5 -8
- package/dist/utils/multicall.js +4 -2
- package/dist/utils/multicall.js.map +1 -1
- package/dist/utils/parseTransactionPojo.cjs +87 -0
- package/dist/utils/parseTransactionPojo.cjs.map +1 -0
- package/dist/utils/parseTransactionPojo.d.ts +31 -0
- package/dist/utils/parseTransactionPojo.js +63 -0
- package/dist/utils/parseTransactionPojo.js.map +1 -0
- package/dist/utils/schemaValidation.cjs +5 -5
- package/dist/utils/schemaValidation.cjs.map +1 -1
- package/dist/utils/schemaValidation.d.ts +8 -12
- package/dist/utils/schemaValidation.js +7 -10
- package/dist/utils/schemaValidation.js.map +1 -1
- package/dist/utils/signatureCache.cjs +9 -4
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +53 -15
- package/dist/utils/signatureCache.js +12 -10
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/signatureFormatter.cjs +6 -9
- package/dist/utils/signatureFormatter.cjs.map +1 -1
- package/dist/utils/signatureFormatter.d.ts +2 -5
- package/dist/utils/signatureFormatter.js +6 -9
- package/dist/utils/signatureFormatter.js.map +1 -1
- package/dist/utils/subgraphConsistency.cjs +184 -0
- package/dist/utils/subgraphConsistency.cjs.map +1 -0
- package/dist/utils/subgraphConsistency.d.ts +65 -0
- package/dist/utils/subgraphConsistency.js +155 -0
- package/dist/utils/subgraphConsistency.js.map +1 -0
- package/dist/utils/subgraphMetaCache.cjs +101 -0
- package/dist/utils/subgraphMetaCache.cjs.map +1 -0
- package/dist/utils/subgraphMetaCache.d.ts +56 -0
- package/dist/utils/subgraphMetaCache.js +76 -0
- package/dist/utils/subgraphMetaCache.js.map +1 -0
- package/dist/utils/subgraphPagination.cjs +104 -0
- package/dist/utils/subgraphPagination.cjs.map +1 -0
- package/dist/utils/subgraphPagination.d.ts +78 -0
- package/dist/utils/subgraphPagination.js +78 -0
- package/dist/utils/subgraphPagination.js.map +1 -0
- package/dist/utils/tests/multicall.test.d.ts +1 -0
- package/dist/utils/transactionHelpers.cjs +54 -0
- package/dist/utils/transactionHelpers.cjs.map +1 -0
- package/dist/utils/transactionHelpers.d.ts +80 -0
- package/dist/utils/transactionHelpers.js +29 -0
- package/dist/utils/transactionHelpers.js.map +1 -0
- package/dist/utils/typeGuards.cjs +109 -0
- package/dist/utils/typeGuards.cjs.map +1 -0
- package/dist/utils/typeGuards.d.ts +138 -0
- package/dist/utils/typeGuards.js +74 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/dist/utils/typedDataConverter.cjs.map +1 -1
- package/dist/utils/typedDataConverter.d.ts +42 -9
- package/dist/utils/typedDataConverter.js.map +1 -1
- package/dist/utils/urlResolver.cjs +8 -1
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +24 -8
- package/dist/utils/urlResolver.js +9 -2
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs +63 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +94 -0
- package/dist/utils/wallet.js +37 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/utils/withEvents.cjs +44 -0
- package/dist/utils/withEvents.cjs.map +1 -0
- package/dist/utils/withEvents.d.ts +56 -0
- package/dist/utils/withEvents.js +18 -0
- package/dist/utils/withEvents.js.map +1 -0
- package/package.json +25 -13
- package/dist/browser.d.cts +0 -2
- package/dist/chains/definitions.d.cts +0 -53
- package/dist/chains/index.d.cts +0 -2
- package/dist/chains.browser.cjs.map +0 -1
- package/dist/chains.browser.d.cts +0 -2
- package/dist/chains.d.cts +0 -2
- package/dist/chains.node.d.cts +0 -2
- package/dist/config/addresses.d.cts +0 -380
- package/dist/config/chains.d.cts +0 -85
- package/dist/config/eventMappings.cjs +0 -114
- package/dist/config/eventMappings.cjs.map +0 -1
- package/dist/config/eventMappings.d.cts +0 -108
- package/dist/config/eventMappings.d.ts +0 -108
- package/dist/config/eventMappings.js +0 -90
- package/dist/config/eventMappings.js.map +0 -1
- package/dist/config/features.d.cts +0 -64
- package/dist/contracts/contractController.d.cts +0 -96
- package/dist/controllers/data.d.cts +0 -941
- package/dist/controllers/permissions.d.cts +0 -25
- package/dist/controllers/protocol.d.cts +0 -167
- package/dist/controllers/schemas.d.cts +0 -272
- package/dist/controllers/server.d.cts +0 -243
- package/dist/core/apiClient.d.cts +0 -165
- package/dist/core/client.d.cts +0 -92
- package/dist/core/generics.d.cts +0 -120
- package/dist/core.d.cts +0 -466
- package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
- package/dist/crypto/ecies/base.d.cts +0 -143
- package/dist/crypto/ecies/browser.d.cts +0 -48
- package/dist/crypto/ecies/constants.d.cts +0 -122
- package/dist/crypto/ecies/index.d.cts +0 -1
- package/dist/crypto/ecies/interface.d.cts +0 -176
- package/dist/crypto/ecies/node.d.cts +0 -50
- package/dist/crypto/ecies/utils.d.cts +0 -67
- package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
- package/dist/diagnostics.d.cts +0 -26
- package/dist/errors.d.cts +0 -350
- package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
- package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
- package/dist/generated/abi/DATImplementation.d.cts +0 -693
- package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
- package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
- package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
- package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
- package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
- package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
- package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
- package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1004
- package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
- package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
- package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
- package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
- package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
- package/dist/generated/abi/index.d.cts +0 -26516
- package/dist/generated/server/server-exports.d.cts +0 -21
- package/dist/generated/server/server.d.cts +0 -512
- package/dist/generated/subgraph.d.cts +0 -5981
- package/dist/index.browser.cjs +0 -151
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.cts +0 -177
- package/dist/index.d.cts +0 -2
- package/dist/index.node.d.cts +0 -64
- package/dist/node.d.cts +0 -2
- package/dist/permissions-DNKPu_G0.d.cts +0 -1666
- package/dist/permissions-eo8YeLGf.d.ts +0 -1666
- package/dist/platform/browser-only.d.cts +0 -25
- package/dist/platform/browser-safe.d.cts +0 -32
- package/dist/platform/browser.d.cts +0 -74
- package/dist/platform/index.d.cts +0 -5
- package/dist/platform/interface.d.cts +0 -218
- package/dist/platform/node.d.cts +0 -27
- package/dist/platform/shared/error-utils.d.cts +0 -25
- package/dist/platform/shared/pgp-utils.d.cts +0 -61
- package/dist/platform/shared/stream-utils.d.cts +0 -16
- package/dist/platform/utils.d.cts +0 -53
- package/dist/platform.browser.cjs +0 -41
- package/dist/platform.browser.cjs.map +0 -1
- package/dist/platform.browser.d.cts +0 -4
- package/dist/platform.d.cts +0 -5
- package/dist/platform.node.d.cts +0 -5
- package/dist/server/handler.cjs +0 -101
- package/dist/server/handler.cjs.map +0 -1
- package/dist/server/handler.d.cts +0 -282
- package/dist/server/handler.d.ts +0 -282
- package/dist/server/handler.js +0 -77
- package/dist/server/handler.js.map +0 -1
- package/dist/storage/index.d.cts +0 -10
- package/dist/storage/manager.d.cts +0 -150
- package/dist/storage/providers/callback-storage.d.cts +0 -100
- package/dist/storage/providers/google-drive.d.cts +0 -156
- package/dist/storage/providers/ipfs.d.cts +0 -163
- package/dist/storage/providers/pinata.d.cts +0 -173
- package/dist/types/chains.d.cts +0 -34
- package/dist/types/config.d.cts +0 -726
- package/dist/types/contracts.d.cts +0 -68
- package/dist/types/data.d.cts +0 -694
- package/dist/types/eccrypto-js.d.d.cts +0 -13
- package/dist/types/eccrypto-js.d.d.ts +0 -13
- package/dist/types/external-apis.d.cts +0 -186
- package/dist/types/generics.d.cts +0 -450
- package/dist/types/index.d.cts +0 -34
- package/dist/types/operations.d.cts +0 -108
- package/dist/types/permissions.d.cts +0 -957
- package/dist/types/personal.d.cts +0 -40
- package/dist/types/relayer.d.cts +0 -284
- package/dist/types/storage.d.cts +0 -131
- package/dist/types/transactionResults.d.cts +0 -25
- package/dist/types/utils.d.cts +0 -819
- package/dist/types.d.cts +0 -66
- package/dist/utils/blockchain/registry.d.cts +0 -34
- package/dist/utils/crypto-utils.d.cts +0 -118
- package/dist/utils/download.d.cts +0 -41
- package/dist/utils/encoding.d.cts +0 -54
- package/dist/utils/encryption.d.cts +0 -275
- package/dist/utils/eventParsing.cjs +0 -111
- package/dist/utils/eventParsing.cjs.map +0 -1
- package/dist/utils/eventParsing.d.cts +0 -60
- package/dist/utils/eventParsing.d.ts +0 -60
- package/dist/utils/eventParsing.js +0 -86
- package/dist/utils/eventParsing.js.map +0 -1
- package/dist/utils/formatters.d.cts +0 -120
- package/dist/utils/grantFiles.d.cts +0 -186
- package/dist/utils/grantValidation.d.cts +0 -150
- package/dist/utils/grants.d.cts +0 -70
- package/dist/utils/ipfs.d.cts +0 -90
- package/dist/utils/lazy-import.d.cts +0 -20
- package/dist/utils/multicall.d.cts +0 -129
- package/dist/utils/schemaValidation.d.cts +0 -172
- package/dist/utils/signatureCache.d.cts +0 -134
- package/dist/utils/signatureFormatter.d.cts +0 -39
- package/dist/utils/transactionParsing.cjs +0 -84
- package/dist/utils/transactionParsing.cjs.map +0 -1
- package/dist/utils/transactionParsing.d.cts +0 -25
- package/dist/utils/transactionParsing.d.ts +0 -25
- package/dist/utils/transactionParsing.js +0 -62
- package/dist/utils/transactionParsing.js.map +0 -1
- package/dist/utils/typedDataConverter.d.cts +0 -13
- package/dist/utils/urlResolver.d.cts +0 -40
|
@@ -33,6 +33,7 @@ __export(permissions_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(permissions_exports);
|
|
34
34
|
var import_viem = require("viem");
|
|
35
35
|
var import_multicall = require("../utils/multicall");
|
|
36
|
+
var import_pollingManager = require("../core/pollingManager");
|
|
36
37
|
var import_errors = require("../errors");
|
|
37
38
|
var import_addresses = require("../config/addresses");
|
|
38
39
|
var import_abi = require("../generated/abi");
|
|
@@ -41,9 +42,10 @@ var import_grantValidation = require("../utils/grantValidation");
|
|
|
41
42
|
var import_signatureCache = require("../utils/signatureCache");
|
|
42
43
|
var import_signatureFormatter = require("../utils/signatureFormatter");
|
|
43
44
|
var import_typedDataConverter = require("../utils/typedDataConverter");
|
|
44
|
-
|
|
45
|
+
var import_base = require("./base");
|
|
46
|
+
class PermissionsController extends import_base.BaseController {
|
|
45
47
|
constructor(context) {
|
|
46
|
-
|
|
48
|
+
super(context);
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* Grants permission for an application to access user data with gasless transactions.
|
|
@@ -79,8 +81,15 @@ class PermissionsController {
|
|
|
79
81
|
* await vana.permissions.revoke({ permissionId: result.permissionId });
|
|
80
82
|
* ```
|
|
81
83
|
*/
|
|
82
|
-
async grant(params) {
|
|
83
|
-
|
|
84
|
+
async grant(params, options) {
|
|
85
|
+
this.assertWallet();
|
|
86
|
+
const { typedData, signature } = await this.createAndSign(params);
|
|
87
|
+
const result = await this.submitSignedGrantWithEvents(
|
|
88
|
+
typedData,
|
|
89
|
+
signature,
|
|
90
|
+
options
|
|
91
|
+
);
|
|
92
|
+
return result;
|
|
84
93
|
}
|
|
85
94
|
/**
|
|
86
95
|
* Submits a permission grant transaction and returns a handle for flexible result access.
|
|
@@ -107,9 +116,10 @@ class PermissionsController {
|
|
|
107
116
|
* console.log(`Permission ID: ${eventData.permissionId}`);
|
|
108
117
|
* ```
|
|
109
118
|
*/
|
|
110
|
-
async submitPermissionGrant(params) {
|
|
119
|
+
async submitPermissionGrant(params, options) {
|
|
120
|
+
this.assertWallet();
|
|
111
121
|
const { typedData, signature } = await this.createAndSign(params);
|
|
112
|
-
return await this.submitSignedGrant(typedData, signature);
|
|
122
|
+
return await this.submitSignedGrant(typedData, signature, options);
|
|
113
123
|
}
|
|
114
124
|
/**
|
|
115
125
|
* Prepares a permission grant with preview before signing.
|
|
@@ -136,14 +146,19 @@ class PermissionsController {
|
|
|
136
146
|
* const transactionHash = await confirm();
|
|
137
147
|
* ```
|
|
138
148
|
*/
|
|
139
|
-
async prepareGrant(params) {
|
|
149
|
+
async prepareGrant(params, options) {
|
|
150
|
+
this.assertWallet();
|
|
140
151
|
try {
|
|
141
152
|
const grantFile = (0, import_grantFiles.createGrantFile)(params);
|
|
142
153
|
(0, import_grantValidation.validateGrant)(grantFile);
|
|
143
154
|
return {
|
|
144
155
|
preview: grantFile,
|
|
145
156
|
confirm: async () => {
|
|
146
|
-
return await this.
|
|
157
|
+
return await this.confirmGrantInternalWithEvents(
|
|
158
|
+
params,
|
|
159
|
+
grantFile,
|
|
160
|
+
options
|
|
161
|
+
);
|
|
147
162
|
}
|
|
148
163
|
};
|
|
149
164
|
} catch (error) {
|
|
@@ -175,22 +190,36 @@ class PermissionsController {
|
|
|
175
190
|
* @throws {NetworkError} When IPFS upload fails
|
|
176
191
|
* @throws {SignatureError} When user rejects the signature
|
|
177
192
|
*/
|
|
178
|
-
async confirmGrantInternal(params, grantFile) {
|
|
193
|
+
async confirmGrantInternal(params, grantFile, options) {
|
|
179
194
|
try {
|
|
180
|
-
let grantUrl = params
|
|
195
|
+
let { grantUrl } = params;
|
|
181
196
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
182
197
|
if (!grantUrl) {
|
|
183
|
-
|
|
198
|
+
const canStoreViaRelayer = this.context.relayer !== void 0;
|
|
199
|
+
if (!canStoreViaRelayer && !this.context.storageManager) {
|
|
184
200
|
if (this.context.validateStorageRequired) {
|
|
185
201
|
this.context.validateStorageRequired();
|
|
186
202
|
} else {
|
|
187
203
|
throw new Error(
|
|
188
|
-
"No storage available. Provide a grantUrl, configure
|
|
204
|
+
"No storage available. Provide a grantUrl, configure relayer, or storageManager."
|
|
189
205
|
);
|
|
190
206
|
}
|
|
191
207
|
}
|
|
192
|
-
if (this.context.
|
|
193
|
-
|
|
208
|
+
if (canStoreViaRelayer && this.context.relayer) {
|
|
209
|
+
const request = {
|
|
210
|
+
type: "direct",
|
|
211
|
+
operation: "storeGrantFile",
|
|
212
|
+
params: grantFile
|
|
213
|
+
};
|
|
214
|
+
const response = await this.context.relayer(request);
|
|
215
|
+
if (response.type === "error") {
|
|
216
|
+
throw new Error(response.error);
|
|
217
|
+
}
|
|
218
|
+
if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
|
|
219
|
+
grantUrl = response.result.url;
|
|
220
|
+
} else {
|
|
221
|
+
throw new Error("Invalid response from relayer for grant storage");
|
|
222
|
+
}
|
|
194
223
|
} else if (this.context.storageManager) {
|
|
195
224
|
const blob = new Blob([JSON.stringify(grantFile)], {
|
|
196
225
|
type: "application/json"
|
|
@@ -222,7 +251,7 @@ class PermissionsController {
|
|
|
222
251
|
nonce
|
|
223
252
|
});
|
|
224
253
|
const signature = await this.signTypedData(typedData);
|
|
225
|
-
return await this.submitSignedGrant(typedData, signature);
|
|
254
|
+
return await this.submitSignedGrant(typedData, signature, options);
|
|
226
255
|
} catch (error) {
|
|
227
256
|
if (error instanceof Error) {
|
|
228
257
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -267,23 +296,38 @@ class PermissionsController {
|
|
|
267
296
|
* ```
|
|
268
297
|
*/
|
|
269
298
|
async createAndSign(params) {
|
|
299
|
+
this.assertWallet();
|
|
270
300
|
try {
|
|
271
301
|
const grantFile = (0, import_grantFiles.createGrantFile)(params);
|
|
272
302
|
(0, import_grantValidation.validateGrant)(grantFile);
|
|
273
|
-
let grantUrl = params
|
|
303
|
+
let { grantUrl } = params;
|
|
274
304
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
275
305
|
if (!grantUrl) {
|
|
276
|
-
|
|
306
|
+
const canStoreViaRelayer = this.context.relayer !== void 0;
|
|
307
|
+
if (!canStoreViaRelayer && !this.context.storageManager) {
|
|
277
308
|
if (this.context.validateStorageRequired) {
|
|
278
309
|
this.context.validateStorageRequired();
|
|
279
310
|
} else {
|
|
280
311
|
throw new Error(
|
|
281
|
-
"No storage available. Provide a grantUrl, configure
|
|
312
|
+
"No storage available. Provide a grantUrl, configure relayer, or storageManager."
|
|
282
313
|
);
|
|
283
314
|
}
|
|
284
315
|
}
|
|
285
|
-
if (this.context.
|
|
286
|
-
|
|
316
|
+
if (canStoreViaRelayer && this.context.relayer) {
|
|
317
|
+
const request = {
|
|
318
|
+
type: "direct",
|
|
319
|
+
operation: "storeGrantFile",
|
|
320
|
+
params: grantFile
|
|
321
|
+
};
|
|
322
|
+
const response = await this.context.relayer(request);
|
|
323
|
+
if (response.type === "error") {
|
|
324
|
+
throw new Error(response.error);
|
|
325
|
+
}
|
|
326
|
+
if (response.type === "direct" && typeof response.result === "object" && response.result !== null && "url" in response.result) {
|
|
327
|
+
grantUrl = response.result.url;
|
|
328
|
+
} else {
|
|
329
|
+
throw new Error("Invalid response from relayer for grant storage");
|
|
330
|
+
}
|
|
287
331
|
} else if (this.context.storageManager) {
|
|
288
332
|
const blob = new Blob([JSON.stringify(grantFile)], {
|
|
289
333
|
type: "application/json"
|
|
@@ -352,29 +396,60 @@ class PermissionsController {
|
|
|
352
396
|
* );
|
|
353
397
|
* ```
|
|
354
398
|
*/
|
|
355
|
-
async submitSignedGrant(typedData, signature) {
|
|
399
|
+
async submitSignedGrant(typedData, signature, options) {
|
|
356
400
|
try {
|
|
357
401
|
console.debug(
|
|
358
402
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
359
403
|
JSON.stringify(
|
|
360
404
|
typedData,
|
|
361
|
-
(
|
|
405
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
362
406
|
2
|
|
363
407
|
)
|
|
364
408
|
);
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
409
|
+
if (this.context.relayer) {
|
|
410
|
+
const response = await this.context.relayer({
|
|
411
|
+
type: "signed",
|
|
412
|
+
operation: "submitAddPermission",
|
|
368
413
|
typedData,
|
|
369
|
-
signature
|
|
370
|
-
|
|
414
|
+
signature,
|
|
415
|
+
expectedUserAddress: this.context.userAddress
|
|
416
|
+
});
|
|
417
|
+
if (response.type === "error") {
|
|
418
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
419
|
+
}
|
|
420
|
+
let finalHash;
|
|
421
|
+
if (response.type === "submitted") {
|
|
422
|
+
finalHash = response.hash;
|
|
423
|
+
} else if (response.type === "pending") {
|
|
424
|
+
const pollResult = await this.pollRelayerForConfirmation(
|
|
425
|
+
response.operationId,
|
|
426
|
+
options
|
|
427
|
+
);
|
|
428
|
+
finalHash = pollResult.hash;
|
|
429
|
+
} else if (response.type === "confirmed") {
|
|
430
|
+
finalHash = response.hash;
|
|
431
|
+
} else if (response.type === "signed") {
|
|
432
|
+
finalHash = response.hash;
|
|
433
|
+
} else {
|
|
434
|
+
throw new Error(
|
|
435
|
+
"Invalid response from relayer: unexpected response type"
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
439
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
440
|
+
return tx({
|
|
441
|
+
hash: finalHash,
|
|
442
|
+
from: typeof account === "string" ? account : account.address,
|
|
443
|
+
contract: "DataPortabilityPermissions",
|
|
444
|
+
fn: "addPermission"
|
|
445
|
+
});
|
|
371
446
|
} else {
|
|
372
|
-
|
|
447
|
+
return await this.submitDirectTransaction(
|
|
448
|
+
typedData,
|
|
449
|
+
signature,
|
|
450
|
+
options
|
|
451
|
+
);
|
|
373
452
|
}
|
|
374
|
-
return {
|
|
375
|
-
hash,
|
|
376
|
-
from: this.context.walletClient.account?.address
|
|
377
|
-
};
|
|
378
453
|
} catch (error) {
|
|
379
454
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
380
455
|
throw error;
|
|
@@ -406,7 +481,7 @@ class PermissionsController {
|
|
|
406
481
|
* const result = await txHandle.waitForEvents();
|
|
407
482
|
* ```
|
|
408
483
|
*/
|
|
409
|
-
async submitSignedTrustServer(typedData, signature) {
|
|
484
|
+
async submitSignedTrustServer(typedData, signature, options) {
|
|
410
485
|
try {
|
|
411
486
|
const trustServerInput = {
|
|
412
487
|
nonce: BigInt(typedData.message.nonce),
|
|
@@ -414,12 +489,17 @@ class PermissionsController {
|
|
|
414
489
|
};
|
|
415
490
|
const hash = await this.submitTrustServerTransaction(
|
|
416
491
|
trustServerInput,
|
|
417
|
-
signature
|
|
492
|
+
signature,
|
|
493
|
+
options
|
|
418
494
|
);
|
|
419
|
-
|
|
495
|
+
const account = this.context.userAddress;
|
|
496
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
497
|
+
return tx({
|
|
420
498
|
hash,
|
|
421
|
-
from:
|
|
422
|
-
|
|
499
|
+
from: account,
|
|
500
|
+
contract: "DataPortabilityServers",
|
|
501
|
+
fn: "trustServerWithSignature"
|
|
502
|
+
});
|
|
423
503
|
} catch (error) {
|
|
424
504
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
425
505
|
throw error;
|
|
@@ -465,7 +545,7 @@ class PermissionsController {
|
|
|
465
545
|
* const result = await txHandle.waitForEvents();
|
|
466
546
|
* ```
|
|
467
547
|
*/
|
|
468
|
-
async submitSignedAddAndTrustServer(typedData, signature) {
|
|
548
|
+
async submitSignedAddAndTrustServer(typedData, signature, options) {
|
|
469
549
|
try {
|
|
470
550
|
const addAndTrustServerInput = {
|
|
471
551
|
nonce: BigInt(typedData.message.nonce),
|
|
@@ -475,12 +555,17 @@ class PermissionsController {
|
|
|
475
555
|
};
|
|
476
556
|
const hash = await this.submitAddAndTrustServerTransaction(
|
|
477
557
|
addAndTrustServerInput,
|
|
478
|
-
signature
|
|
558
|
+
signature,
|
|
559
|
+
options
|
|
479
560
|
);
|
|
480
|
-
|
|
561
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
562
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
563
|
+
return tx({
|
|
481
564
|
hash,
|
|
482
|
-
from:
|
|
483
|
-
|
|
565
|
+
from: typeof account === "string" ? account : account.address,
|
|
566
|
+
contract: "DataPortabilityServers",
|
|
567
|
+
fn: "addAndTrustServerWithSignature"
|
|
568
|
+
});
|
|
484
569
|
} catch (error) {
|
|
485
570
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
486
571
|
throw error;
|
|
@@ -491,6 +576,101 @@ class PermissionsController {
|
|
|
491
576
|
);
|
|
492
577
|
}
|
|
493
578
|
}
|
|
579
|
+
/**
|
|
580
|
+
* Internal method to submit a signed grant and wait for events.
|
|
581
|
+
*
|
|
582
|
+
* @internal
|
|
583
|
+
* @param typedData - The EIP-712 typed data for the permission grant
|
|
584
|
+
* @param signature - The user's signature authorizing the transaction
|
|
585
|
+
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
586
|
+
*/
|
|
587
|
+
async submitSignedGrantWithEvents(typedData, signature, options) {
|
|
588
|
+
const txResult = await this.submitSignedGrant(
|
|
589
|
+
typedData,
|
|
590
|
+
signature,
|
|
591
|
+
options
|
|
592
|
+
);
|
|
593
|
+
if (!this.context.waitForTransactionEvents) {
|
|
594
|
+
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
595
|
+
}
|
|
596
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
597
|
+
const event = result.expectedEvents.PermissionAdded;
|
|
598
|
+
if (!event) {
|
|
599
|
+
throw new import_errors.BlockchainError(
|
|
600
|
+
"PermissionAdded event not found in transaction"
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
604
|
+
hash: result.hash
|
|
605
|
+
});
|
|
606
|
+
return {
|
|
607
|
+
transactionHash: result.hash,
|
|
608
|
+
blockNumber: receipt.blockNumber,
|
|
609
|
+
gasUsed: receipt.gasUsed,
|
|
610
|
+
permissionId: event.permissionId,
|
|
611
|
+
user: event.user,
|
|
612
|
+
grant: event.grant,
|
|
613
|
+
fileIds: event.fileIds
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Internal method for confirm grant with events.
|
|
618
|
+
*
|
|
619
|
+
* @internal
|
|
620
|
+
* @param params - The permission grant parameters
|
|
621
|
+
* @param grantFile - The pre-created grant file object
|
|
622
|
+
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
623
|
+
*/
|
|
624
|
+
async confirmGrantInternalWithEvents(params, grantFile, options) {
|
|
625
|
+
const txResult = await this.confirmGrantInternal(
|
|
626
|
+
params,
|
|
627
|
+
grantFile,
|
|
628
|
+
options
|
|
629
|
+
);
|
|
630
|
+
if (!this.context.waitForTransactionEvents) {
|
|
631
|
+
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
632
|
+
}
|
|
633
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
634
|
+
const event = result.expectedEvents.PermissionAdded;
|
|
635
|
+
if (!event) {
|
|
636
|
+
throw new import_errors.BlockchainError(
|
|
637
|
+
"PermissionAdded event not found in transaction"
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
641
|
+
hash: result.hash
|
|
642
|
+
});
|
|
643
|
+
return {
|
|
644
|
+
transactionHash: result.hash,
|
|
645
|
+
blockNumber: receipt.blockNumber,
|
|
646
|
+
gasUsed: receipt.gasUsed,
|
|
647
|
+
permissionId: event.permissionId,
|
|
648
|
+
user: event.user,
|
|
649
|
+
grant: event.grant,
|
|
650
|
+
fileIds: event.fileIds
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Polls the relayer for confirmation of a pending operation.
|
|
655
|
+
*
|
|
656
|
+
* @param operationId - The operation ID to poll
|
|
657
|
+
* @param options - Polling configuration including status updates and cancellation
|
|
658
|
+
* @returns Promise resolving to the confirmed hash and receipt
|
|
659
|
+
* @throws {TransactionPendingError} When the operation times out
|
|
660
|
+
* @throws {Error} When the operation fails or is cancelled
|
|
661
|
+
* @internal
|
|
662
|
+
*/
|
|
663
|
+
async pollRelayerForConfirmation(operationId, options) {
|
|
664
|
+
if (!this.context.relayer) {
|
|
665
|
+
throw new Error("Relayer not configured for polling");
|
|
666
|
+
}
|
|
667
|
+
const pollingManager = new import_pollingManager.PollingManager(this.context.relayer);
|
|
668
|
+
return await pollingManager.startPolling(operationId, {
|
|
669
|
+
signal: options?.signal,
|
|
670
|
+
onStatusUpdate: options?.onStatusUpdate,
|
|
671
|
+
...options?.pollingOptions
|
|
672
|
+
});
|
|
673
|
+
}
|
|
494
674
|
/**
|
|
495
675
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
496
676
|
*
|
|
@@ -512,21 +692,52 @@ class PermissionsController {
|
|
|
512
692
|
* const result = await txHandle.waitForEvents();
|
|
513
693
|
* ```
|
|
514
694
|
*/
|
|
515
|
-
async submitSignedRevoke(typedData, signature) {
|
|
695
|
+
async submitSignedRevoke(typedData, signature, options) {
|
|
516
696
|
try {
|
|
517
697
|
let hash;
|
|
518
|
-
if (this.context.
|
|
519
|
-
|
|
698
|
+
if (this.context.relayer) {
|
|
699
|
+
const response = await this.context.relayer({
|
|
700
|
+
type: "signed",
|
|
701
|
+
operation: "submitPermissionRevoke",
|
|
520
702
|
typedData,
|
|
521
|
-
signature
|
|
522
|
-
|
|
703
|
+
signature,
|
|
704
|
+
expectedUserAddress: this.context.userAddress
|
|
705
|
+
});
|
|
706
|
+
if (response.type === "error") {
|
|
707
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
708
|
+
}
|
|
709
|
+
if (response.type === "submitted") {
|
|
710
|
+
hash = response.hash;
|
|
711
|
+
} else if (response.type === "pending") {
|
|
712
|
+
const pollResult = await this.pollRelayerForConfirmation(
|
|
713
|
+
response.operationId,
|
|
714
|
+
options
|
|
715
|
+
);
|
|
716
|
+
hash = pollResult.hash;
|
|
717
|
+
} else if (response.type === "confirmed") {
|
|
718
|
+
hash = response.hash;
|
|
719
|
+
} else if (response.type === "signed") {
|
|
720
|
+
hash = response.hash;
|
|
721
|
+
} else {
|
|
722
|
+
throw new Error(
|
|
723
|
+
"Invalid response from relayer: unexpected response type"
|
|
724
|
+
);
|
|
725
|
+
}
|
|
523
726
|
} else {
|
|
524
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
727
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
728
|
+
typedData,
|
|
729
|
+
signature,
|
|
730
|
+
options
|
|
731
|
+
);
|
|
525
732
|
}
|
|
526
|
-
|
|
733
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
734
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
735
|
+
return tx({
|
|
527
736
|
hash,
|
|
528
|
-
from:
|
|
529
|
-
|
|
737
|
+
from: typeof account === "string" ? account : account.address,
|
|
738
|
+
contract: "DataPortabilityPermissions",
|
|
739
|
+
fn: "revokePermissionWithSignature"
|
|
740
|
+
});
|
|
530
741
|
} catch (error) {
|
|
531
742
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
532
743
|
throw error;
|
|
@@ -558,21 +769,43 @@ class PermissionsController {
|
|
|
558
769
|
* const result = await txHandle.waitForEvents();
|
|
559
770
|
* ```
|
|
560
771
|
*/
|
|
561
|
-
async submitSignedUntrustServer(typedData, signature) {
|
|
772
|
+
async submitSignedUntrustServer(typedData, signature, options) {
|
|
562
773
|
try {
|
|
563
774
|
let hash;
|
|
564
|
-
if (this.context.
|
|
565
|
-
|
|
775
|
+
if (this.context.relayer) {
|
|
776
|
+
const response = await this.context.relayer({
|
|
777
|
+
type: "signed",
|
|
778
|
+
operation: "submitUntrustServer",
|
|
566
779
|
typedData,
|
|
567
|
-
signature
|
|
568
|
-
|
|
780
|
+
signature,
|
|
781
|
+
expectedUserAddress: this.context.userAddress
|
|
782
|
+
});
|
|
783
|
+
if (response.type === "submitted") {
|
|
784
|
+
hash = response.hash;
|
|
785
|
+
} else if (response.type === "signed") {
|
|
786
|
+
hash = response.hash;
|
|
787
|
+
} else if (response.type === "error") {
|
|
788
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
789
|
+
} else {
|
|
790
|
+
throw new Error(
|
|
791
|
+
"Invalid response from relayer: expected signed transaction"
|
|
792
|
+
);
|
|
793
|
+
}
|
|
569
794
|
} else {
|
|
570
|
-
hash = await this.submitSignedUntrustTransaction(
|
|
795
|
+
hash = await this.submitSignedUntrustTransaction(
|
|
796
|
+
typedData,
|
|
797
|
+
signature,
|
|
798
|
+
options
|
|
799
|
+
);
|
|
571
800
|
}
|
|
572
|
-
|
|
801
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
802
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
803
|
+
return tx({
|
|
573
804
|
hash,
|
|
574
|
-
from:
|
|
575
|
-
|
|
805
|
+
from: typeof account === "string" ? account : account.address,
|
|
806
|
+
contract: "DataPortabilityServers",
|
|
807
|
+
fn: "untrustServerWithSignature"
|
|
808
|
+
});
|
|
576
809
|
} catch (error) {
|
|
577
810
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
578
811
|
throw error;
|
|
@@ -595,8 +828,9 @@ class PermissionsController {
|
|
|
595
828
|
* @returns Promise resolving to the transaction hash
|
|
596
829
|
* @throws {BlockchainError} When contract submission fails
|
|
597
830
|
*/
|
|
598
|
-
async submitDirectTransaction(typedData, signature) {
|
|
599
|
-
|
|
831
|
+
async submitDirectTransaction(typedData, signature, options) {
|
|
832
|
+
this.assertWallet();
|
|
833
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
600
834
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
601
835
|
chainId,
|
|
602
836
|
"DataPortabilityPermissions"
|
|
@@ -616,18 +850,26 @@ class PermissionsController {
|
|
|
616
850
|
console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
|
|
617
851
|
console.debug(
|
|
618
852
|
"\u{1F50D} Debug - Grant field length:",
|
|
619
|
-
typedData.message.grant?.length
|
|
853
|
+
typedData.message.grant?.length ?? 0
|
|
620
854
|
);
|
|
621
855
|
const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
|
|
856
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
622
857
|
const txHash = await this.context.walletClient.writeContract({
|
|
623
858
|
address: DataPortabilityPermissionsAddress,
|
|
624
859
|
abi: DataPortabilityPermissionsAbi,
|
|
625
860
|
functionName: "addPermission",
|
|
626
861
|
args: [permissionInput, formattedSignature],
|
|
627
|
-
account
|
|
628
|
-
chain: this.context.walletClient
|
|
862
|
+
account,
|
|
863
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
864
|
+
...this.spreadTransactionOptions(options)
|
|
865
|
+
});
|
|
866
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
867
|
+
return tx({
|
|
868
|
+
hash: txHash,
|
|
869
|
+
from: typeof account === "string" ? account : account.address,
|
|
870
|
+
contract: "DataPortabilityPermissions",
|
|
871
|
+
fn: "addPermission"
|
|
629
872
|
});
|
|
630
|
-
return txHash;
|
|
631
873
|
}
|
|
632
874
|
/**
|
|
633
875
|
* Revokes a previously granted permission.
|
|
@@ -654,7 +896,27 @@ class PermissionsController {
|
|
|
654
896
|
* ```
|
|
655
897
|
*/
|
|
656
898
|
async revoke(params) {
|
|
657
|
-
|
|
899
|
+
this.assertWallet();
|
|
900
|
+
const txResult = await this.submitPermissionRevoke(params);
|
|
901
|
+
if (!this.context.waitForTransactionEvents) {
|
|
902
|
+
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
903
|
+
}
|
|
904
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
905
|
+
const event = result.expectedEvents.PermissionRevoked;
|
|
906
|
+
if (!event) {
|
|
907
|
+
throw new import_errors.BlockchainError(
|
|
908
|
+
"PermissionRevoked event not found in transaction"
|
|
909
|
+
);
|
|
910
|
+
}
|
|
911
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
912
|
+
hash: result.hash
|
|
913
|
+
});
|
|
914
|
+
return {
|
|
915
|
+
transactionHash: result.hash,
|
|
916
|
+
blockNumber: receipt.blockNumber,
|
|
917
|
+
gasUsed: receipt.gasUsed,
|
|
918
|
+
permissionId: event.permissionId
|
|
919
|
+
};
|
|
658
920
|
}
|
|
659
921
|
/**
|
|
660
922
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
@@ -663,6 +925,7 @@ class PermissionsController {
|
|
|
663
925
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
664
926
|
*
|
|
665
927
|
* @param params - Parameters for revoking the permission
|
|
928
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
666
929
|
* @returns Promise resolving to the transaction hash when successfully submitted
|
|
667
930
|
* @throws {BlockchainError} When revocation transaction fails
|
|
668
931
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
@@ -675,12 +938,13 @@ class PermissionsController {
|
|
|
675
938
|
* console.log(`Revocation submitted: ${txHash}`);
|
|
676
939
|
* ```
|
|
677
940
|
*/
|
|
678
|
-
async submitPermissionRevoke(params) {
|
|
941
|
+
async submitPermissionRevoke(params, options) {
|
|
942
|
+
this.assertWallet();
|
|
679
943
|
try {
|
|
680
|
-
if (!this.context.walletClient
|
|
944
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
681
945
|
throw new import_errors.BlockchainError("Chain ID not available");
|
|
682
946
|
}
|
|
683
|
-
const chainId = await this.context.
|
|
947
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
684
948
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
685
949
|
chainId,
|
|
686
950
|
"DataPortabilityPermissions"
|
|
@@ -688,18 +952,33 @@ class PermissionsController {
|
|
|
688
952
|
const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
|
|
689
953
|
"DataPortabilityPermissions"
|
|
690
954
|
);
|
|
955
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
691
956
|
const txHash = await this.context.walletClient.writeContract({
|
|
692
957
|
address: DataPortabilityPermissionsAddress,
|
|
693
958
|
abi: DataPortabilityPermissionsAbi,
|
|
694
959
|
functionName: "revokePermission",
|
|
695
960
|
args: [params.permissionId],
|
|
696
|
-
account
|
|
697
|
-
chain: this.context.walletClient
|
|
961
|
+
account,
|
|
962
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
963
|
+
...options?.gas && { gas: options.gas },
|
|
964
|
+
...options?.nonce && { nonce: options.nonce },
|
|
965
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
966
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
967
|
+
...options.maxFeePerGas && {
|
|
968
|
+
maxFeePerGas: options.maxFeePerGas
|
|
969
|
+
},
|
|
970
|
+
...options.maxPriorityFeePerGas && {
|
|
971
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
972
|
+
}
|
|
973
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
698
974
|
});
|
|
699
|
-
|
|
975
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
976
|
+
return tx({
|
|
700
977
|
hash: txHash,
|
|
701
|
-
from:
|
|
702
|
-
|
|
978
|
+
from: typeof account === "string" ? account : account.address,
|
|
979
|
+
contract: "DataPortabilityPermissions",
|
|
980
|
+
fn: "revokePermission"
|
|
981
|
+
});
|
|
703
982
|
} catch (error) {
|
|
704
983
|
if (error instanceof Error) {
|
|
705
984
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -738,9 +1017,10 @@ class PermissionsController {
|
|
|
738
1017
|
* console.log(`Permission ${result.permissionId} revoked`);
|
|
739
1018
|
* ```
|
|
740
1019
|
*/
|
|
741
|
-
async submitRevokeWithSignature(params) {
|
|
1020
|
+
async submitRevokeWithSignature(params, options) {
|
|
1021
|
+
this.assertWallet();
|
|
742
1022
|
try {
|
|
743
|
-
if (!this.context.walletClient
|
|
1023
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
744
1024
|
throw new import_errors.BlockchainError("Chain ID not available");
|
|
745
1025
|
}
|
|
746
1026
|
const nonce = await this.getPermissionsUserNonce();
|
|
@@ -761,18 +1041,40 @@ class PermissionsController {
|
|
|
761
1041
|
};
|
|
762
1042
|
const signature = await this.signTypedData(typedData);
|
|
763
1043
|
let hash;
|
|
764
|
-
if (this.context.
|
|
765
|
-
|
|
1044
|
+
if (this.context.relayer) {
|
|
1045
|
+
const response = await this.context.relayer({
|
|
1046
|
+
type: "signed",
|
|
1047
|
+
operation: "submitPermissionRevoke",
|
|
766
1048
|
typedData,
|
|
767
|
-
signature
|
|
768
|
-
|
|
1049
|
+
signature,
|
|
1050
|
+
expectedUserAddress: this.context.userAddress
|
|
1051
|
+
});
|
|
1052
|
+
if (response.type === "submitted") {
|
|
1053
|
+
hash = response.hash;
|
|
1054
|
+
} else if (response.type === "signed") {
|
|
1055
|
+
hash = response.hash;
|
|
1056
|
+
} else if (response.type === "error") {
|
|
1057
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
1058
|
+
} else {
|
|
1059
|
+
throw new Error(
|
|
1060
|
+
"Invalid response from relayer: expected signed transaction"
|
|
1061
|
+
);
|
|
1062
|
+
}
|
|
769
1063
|
} else {
|
|
770
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
1064
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
1065
|
+
typedData,
|
|
1066
|
+
signature,
|
|
1067
|
+
options
|
|
1068
|
+
);
|
|
771
1069
|
}
|
|
772
|
-
|
|
1070
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1071
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1072
|
+
return tx({
|
|
773
1073
|
hash,
|
|
774
|
-
from:
|
|
775
|
-
|
|
1074
|
+
from: typeof account === "string" ? account : account.address,
|
|
1075
|
+
contract: "DataPortabilityPermissions",
|
|
1076
|
+
fn: "revokePermissionWithSignature"
|
|
1077
|
+
});
|
|
776
1078
|
} catch (error) {
|
|
777
1079
|
throw new import_errors.PermissionError(
|
|
778
1080
|
`Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -780,64 +1082,6 @@ class PermissionsController {
|
|
|
780
1082
|
);
|
|
781
1083
|
}
|
|
782
1084
|
}
|
|
783
|
-
/**
|
|
784
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
785
|
-
*
|
|
786
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
787
|
-
* This method is deprecated in favor of more specific nonce methods.
|
|
788
|
-
*
|
|
789
|
-
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
790
|
-
* be incremented with each transaction to maintain security.
|
|
791
|
-
*
|
|
792
|
-
* @returns Promise resolving to the user's current nonce value as a bigint
|
|
793
|
-
* @throws {Error} When wallet account is not available
|
|
794
|
-
* @throws {Error} When chain ID is not available
|
|
795
|
-
* @throws {NonceError} When reading nonce from contract fails
|
|
796
|
-
* @private
|
|
797
|
-
* @example
|
|
798
|
-
* ```typescript
|
|
799
|
-
* // Deprecated - use specific methods instead
|
|
800
|
-
* const nonce = await this.getUserNonce();
|
|
801
|
-
*
|
|
802
|
-
* // Use these instead:
|
|
803
|
-
* const permissionsNonce = await this.getPermissionsUserNonce();
|
|
804
|
-
* const serversNonce = await this.getServersUserNonce();
|
|
805
|
-
* ```
|
|
806
|
-
*/
|
|
807
|
-
/**
|
|
808
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
809
|
-
*
|
|
810
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
811
|
-
*
|
|
812
|
-
* @remarks
|
|
813
|
-
* This method is deprecated in favor of more specific nonce methods that target
|
|
814
|
-
* the appropriate contract for the operation being performed.
|
|
815
|
-
*
|
|
816
|
-
* @returns Promise resolving to the user's current nonce as a bigint
|
|
817
|
-
* @throws {NonceError} When retrieving the nonce fails
|
|
818
|
-
*/
|
|
819
|
-
async getUserNonce() {
|
|
820
|
-
try {
|
|
821
|
-
const userAddress = await this.getUserAddress();
|
|
822
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
823
|
-
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
824
|
-
chainId,
|
|
825
|
-
"DataPortabilityServers"
|
|
826
|
-
);
|
|
827
|
-
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
828
|
-
const nonce = await this.context.publicClient.readContract({
|
|
829
|
-
address: DataPortabilityServersAddress,
|
|
830
|
-
abi: DataPortabilityServersAbi,
|
|
831
|
-
functionName: "userNonce",
|
|
832
|
-
args: [userAddress]
|
|
833
|
-
});
|
|
834
|
-
return nonce;
|
|
835
|
-
} catch (error) {
|
|
836
|
-
throw new import_errors.NonceError(
|
|
837
|
-
`Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
1085
|
/**
|
|
842
1086
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
843
1087
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
@@ -864,8 +1108,8 @@ class PermissionsController {
|
|
|
864
1108
|
*/
|
|
865
1109
|
async getServersUserNonce() {
|
|
866
1110
|
try {
|
|
867
|
-
const userAddress =
|
|
868
|
-
const chainId = await this.context.
|
|
1111
|
+
const userAddress = this.context.userAddress;
|
|
1112
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
869
1113
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
870
1114
|
chainId,
|
|
871
1115
|
"DataPortabilityServers"
|
|
@@ -910,8 +1154,8 @@ class PermissionsController {
|
|
|
910
1154
|
*/
|
|
911
1155
|
async getPermissionsUserNonce() {
|
|
912
1156
|
try {
|
|
913
|
-
const userAddress =
|
|
914
|
-
const chainId = await this.context.
|
|
1157
|
+
const userAddress = this.context.userAddress;
|
|
1158
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
915
1159
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
916
1160
|
chainId,
|
|
917
1161
|
"DataPortabilityPermissions"
|
|
@@ -950,7 +1194,7 @@ class PermissionsController {
|
|
|
950
1194
|
"\u{1F50D} Debug - Composing permission message with grantUrl:",
|
|
951
1195
|
params.grantUrl
|
|
952
1196
|
);
|
|
953
|
-
const chainId = await this.context.
|
|
1197
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
954
1198
|
const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
|
|
955
1199
|
chainId,
|
|
956
1200
|
"DataPortabilityGrantees"
|
|
@@ -1059,7 +1303,7 @@ class PermissionsController {
|
|
|
1059
1303
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1060
1304
|
*/
|
|
1061
1305
|
async getPermissionDomain() {
|
|
1062
|
-
const chainId = await this.context.
|
|
1306
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1063
1307
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
1064
1308
|
chainId,
|
|
1065
1309
|
"DataPortabilityPermissions"
|
|
@@ -1078,8 +1322,9 @@ class PermissionsController {
|
|
|
1078
1322
|
* @returns Promise resolving to the cryptographic signature
|
|
1079
1323
|
*/
|
|
1080
1324
|
async signTypedData(typedData) {
|
|
1325
|
+
this.assertWallet();
|
|
1081
1326
|
try {
|
|
1082
|
-
const walletAddress = this.context.walletClient.account?.address
|
|
1327
|
+
const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
|
|
1083
1328
|
return await (0, import_signatureCache.withSignatureCache)(
|
|
1084
1329
|
this.context.platform.cache,
|
|
1085
1330
|
walletAddress,
|
|
@@ -1088,9 +1333,9 @@ class PermissionsController {
|
|
|
1088
1333
|
const viemCompatibleTypedData = (0, import_typedDataConverter.toViemTypedDataDefinition)(typedData);
|
|
1089
1334
|
return await this.context.walletClient.signTypedData({
|
|
1090
1335
|
...viemCompatibleTypedData,
|
|
1091
|
-
//
|
|
1092
|
-
//
|
|
1093
|
-
account: this.context.walletClient.account
|
|
1336
|
+
// Use the account if available, otherwise use the wallet address
|
|
1337
|
+
// This follows the same pattern used throughout this file
|
|
1338
|
+
account: this.context.walletClient.account ?? walletAddress
|
|
1094
1339
|
});
|
|
1095
1340
|
}
|
|
1096
1341
|
);
|
|
@@ -1105,17 +1350,10 @@ class PermissionsController {
|
|
|
1105
1350
|
}
|
|
1106
1351
|
}
|
|
1107
1352
|
/**
|
|
1108
|
-
* Gets the user's address from the
|
|
1353
|
+
* Gets the user's address from the context.
|
|
1109
1354
|
*
|
|
1110
|
-
* @returns
|
|
1355
|
+
* @returns The user's address
|
|
1111
1356
|
*/
|
|
1112
|
-
async getUserAddress() {
|
|
1113
|
-
const addresses = await this.context.walletClient.getAddresses();
|
|
1114
|
-
if (addresses.length === 0) {
|
|
1115
|
-
throw new import_errors.BlockchainError("No addresses available in wallet client");
|
|
1116
|
-
}
|
|
1117
|
-
return addresses[0];
|
|
1118
|
-
}
|
|
1119
1357
|
/**
|
|
1120
1358
|
* Gets on-chain permission grant data without expensive off-chain resolution.
|
|
1121
1359
|
*
|
|
@@ -1152,20 +1390,22 @@ class PermissionsController {
|
|
|
1152
1390
|
* ```
|
|
1153
1391
|
*/
|
|
1154
1392
|
async getUserPermissionGrantsOnChain(options = {}) {
|
|
1155
|
-
const { limit = 50, subgraphUrl } = options;
|
|
1393
|
+
const { limit = 50, fetchAll = false, subgraphUrl } = options;
|
|
1394
|
+
const pageSize = fetchAll ? 100 : limit;
|
|
1395
|
+
const maxResults = fetchAll ? 1e4 : limit;
|
|
1156
1396
|
try {
|
|
1157
|
-
const userAddress =
|
|
1158
|
-
const graphqlEndpoint = subgraphUrl
|
|
1397
|
+
const userAddress = this.context.userAddress;
|
|
1398
|
+
const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
1159
1399
|
if (!graphqlEndpoint) {
|
|
1160
1400
|
throw new import_errors.BlockchainError(
|
|
1161
1401
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
1162
1402
|
);
|
|
1163
1403
|
}
|
|
1164
1404
|
const query = `
|
|
1165
|
-
query GetUserPermissions($userId: ID!) {
|
|
1405
|
+
query GetUserPermissions($userId: ID!, $first: Int!, $skip: Int!) {
|
|
1166
1406
|
user(id: $userId) {
|
|
1167
1407
|
id
|
|
1168
|
-
permissions {
|
|
1408
|
+
permissions(first: $first, skip: $skip, orderBy: addedAtBlock, orderDirection: desc) {
|
|
1169
1409
|
id
|
|
1170
1410
|
grant
|
|
1171
1411
|
nonce
|
|
@@ -1183,34 +1423,82 @@ class PermissionsController {
|
|
|
1183
1423
|
}
|
|
1184
1424
|
}
|
|
1185
1425
|
`;
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1426
|
+
const allPermissions = [];
|
|
1427
|
+
let currentOffset = 0;
|
|
1428
|
+
if (!fetchAll) {
|
|
1429
|
+
const response = await fetch(graphqlEndpoint, {
|
|
1430
|
+
method: "POST",
|
|
1431
|
+
headers: {
|
|
1432
|
+
"Content-Type": "application/json"
|
|
1433
|
+
},
|
|
1434
|
+
body: JSON.stringify({
|
|
1435
|
+
query,
|
|
1436
|
+
variables: {
|
|
1437
|
+
userId: userAddress.toLowerCase(),
|
|
1438
|
+
first: limit,
|
|
1439
|
+
skip: 0
|
|
1440
|
+
}
|
|
1441
|
+
})
|
|
1442
|
+
});
|
|
1443
|
+
if (!response.ok) {
|
|
1444
|
+
throw new import_errors.BlockchainError(
|
|
1445
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
const result = await response.json();
|
|
1449
|
+
if (result.errors) {
|
|
1450
|
+
throw new import_errors.BlockchainError(
|
|
1451
|
+
`Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
1452
|
+
);
|
|
1453
|
+
}
|
|
1454
|
+
const userData = result.data?.user;
|
|
1455
|
+
if (!userData?.permissions?.length) {
|
|
1456
|
+
return [];
|
|
1457
|
+
}
|
|
1458
|
+
allPermissions.push(...userData.permissions);
|
|
1459
|
+
} else {
|
|
1460
|
+
while (allPermissions.length < maxResults) {
|
|
1461
|
+
const currentLimit = Math.min(
|
|
1462
|
+
pageSize,
|
|
1463
|
+
maxResults - allPermissions.length
|
|
1464
|
+
);
|
|
1465
|
+
const response = await fetch(graphqlEndpoint, {
|
|
1466
|
+
method: "POST",
|
|
1467
|
+
headers: {
|
|
1468
|
+
"Content-Type": "application/json"
|
|
1469
|
+
},
|
|
1470
|
+
body: JSON.stringify({
|
|
1471
|
+
query,
|
|
1472
|
+
variables: {
|
|
1473
|
+
userId: userAddress.toLowerCase(),
|
|
1474
|
+
first: currentLimit,
|
|
1475
|
+
skip: currentOffset
|
|
1476
|
+
}
|
|
1477
|
+
})
|
|
1478
|
+
});
|
|
1479
|
+
if (!response.ok) {
|
|
1480
|
+
throw new import_errors.BlockchainError(
|
|
1481
|
+
`Subgraph request failed: ${response.status} ${response.statusText}`
|
|
1482
|
+
);
|
|
1195
1483
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1484
|
+
const result = await response.json();
|
|
1485
|
+
if (result.errors) {
|
|
1486
|
+
throw new import_errors.BlockchainError(
|
|
1487
|
+
`Subgraph errors: ${result.errors.map((e) => e.message).join(", ")}`
|
|
1488
|
+
);
|
|
1489
|
+
}
|
|
1490
|
+
const userData = result.data?.user;
|
|
1491
|
+
if (!userData?.permissions?.length) {
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
allPermissions.push(...userData.permissions);
|
|
1495
|
+
if (userData.permissions.length < currentLimit) {
|
|
1496
|
+
break;
|
|
1497
|
+
}
|
|
1498
|
+
currentOffset += userData.permissions.length;
|
|
1499
|
+
}
|
|
1212
1500
|
}
|
|
1213
|
-
const onChainGrants =
|
|
1501
|
+
const onChainGrants = allPermissions.map(
|
|
1214
1502
|
(permission) => ({
|
|
1215
1503
|
id: BigInt(permission.id),
|
|
1216
1504
|
grantUrl: permission.grant,
|
|
@@ -1218,8 +1506,8 @@ class PermissionsController {
|
|
|
1218
1506
|
nonce: BigInt(permission.nonce),
|
|
1219
1507
|
startBlock: BigInt(permission.startBlock),
|
|
1220
1508
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
1221
|
-
addedAtTimestamp: BigInt(permission.addedAtTimestamp
|
|
1222
|
-
transactionHash: permission.transactionHash
|
|
1509
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
|
|
1510
|
+
transactionHash: permission.transactionHash ?? "",
|
|
1223
1511
|
grantor: userAddress,
|
|
1224
1512
|
grantee: permission.grantee,
|
|
1225
1513
|
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
@@ -1240,26 +1528,6 @@ class PermissionsController {
|
|
|
1240
1528
|
);
|
|
1241
1529
|
}
|
|
1242
1530
|
}
|
|
1243
|
-
/**
|
|
1244
|
-
* Normalizes grant ID to hex format.
|
|
1245
|
-
* Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
|
|
1246
|
-
*
|
|
1247
|
-
* @param grantId - Permission ID or grant hash in various formats
|
|
1248
|
-
* @returns Normalized hex hash
|
|
1249
|
-
*/
|
|
1250
|
-
normalizeGrantId(grantId) {
|
|
1251
|
-
if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
|
|
1252
|
-
return grantId;
|
|
1253
|
-
}
|
|
1254
|
-
try {
|
|
1255
|
-
const bigIntId = BigInt(grantId);
|
|
1256
|
-
return `0x${bigIntId.toString(16).padStart(64, "0")}`;
|
|
1257
|
-
} catch {
|
|
1258
|
-
throw new Error(
|
|
1259
|
-
`Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
|
|
1260
|
-
);
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
1531
|
/**
|
|
1264
1532
|
* Registers a new server and immediately trusts it in the DataPortabilityServers contract.
|
|
1265
1533
|
*
|
|
@@ -1268,7 +1536,6 @@ class PermissionsController {
|
|
|
1268
1536
|
* Trusted servers can handle data export and portability requests from the user.
|
|
1269
1537
|
*
|
|
1270
1538
|
* @param params - Parameters for adding and trusting the server
|
|
1271
|
-
* @param params.owner - Ethereum address that will own this server registration
|
|
1272
1539
|
* @param params.serverAddress - Ethereum address of the server
|
|
1273
1540
|
* @param params.serverUrl - HTTPS URL where the server can be reached
|
|
1274
1541
|
* @param params.publicKey - Server's public key for encryption (hex string)
|
|
@@ -1295,6 +1562,7 @@ class PermissionsController {
|
|
|
1295
1562
|
* ```
|
|
1296
1563
|
*/
|
|
1297
1564
|
async addAndTrustServer(params) {
|
|
1565
|
+
this.assertWallet();
|
|
1298
1566
|
try {
|
|
1299
1567
|
const chainId = await this.context.walletClient.getChainId();
|
|
1300
1568
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -1302,7 +1570,8 @@ class PermissionsController {
|
|
|
1302
1570
|
"DataPortabilityServers"
|
|
1303
1571
|
);
|
|
1304
1572
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
1305
|
-
const
|
|
1573
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1574
|
+
const userAddress = typeof account === "string" ? account : account.address;
|
|
1306
1575
|
const normalizedUserAddress = (0, import_viem.getAddress)(userAddress);
|
|
1307
1576
|
const normalizedServerAddress = (0, import_viem.getAddress)(params.serverAddress);
|
|
1308
1577
|
const txHash = await this.context.walletClient.writeContract({
|
|
@@ -1317,12 +1586,40 @@ class PermissionsController {
|
|
|
1317
1586
|
publicKey: params.publicKey
|
|
1318
1587
|
}
|
|
1319
1588
|
],
|
|
1320
|
-
account
|
|
1321
|
-
chain: this.context.walletClient
|
|
1589
|
+
account,
|
|
1590
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1322
1591
|
});
|
|
1323
|
-
|
|
1592
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1593
|
+
const txResult = tx({
|
|
1324
1594
|
hash: txHash,
|
|
1325
|
-
from:
|
|
1595
|
+
from: userAddress,
|
|
1596
|
+
contract: "DataPortabilityServers",
|
|
1597
|
+
fn: "addAndTrustServerByManager"
|
|
1598
|
+
});
|
|
1599
|
+
if (!this.context.waitForTransactionEvents) {
|
|
1600
|
+
throw new import_errors.BlockchainError("waitForTransactionEvents not configured");
|
|
1601
|
+
}
|
|
1602
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
1603
|
+
const event = result.expectedEvents.ServerTrusted;
|
|
1604
|
+
if (!event) {
|
|
1605
|
+
throw new import_errors.BlockchainError(
|
|
1606
|
+
"ServerTrusted event not found in transaction"
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1610
|
+
hash: txHash
|
|
1611
|
+
});
|
|
1612
|
+
return {
|
|
1613
|
+
transactionHash: txHash,
|
|
1614
|
+
blockNumber: receipt.blockNumber,
|
|
1615
|
+
gasUsed: receipt.gasUsed,
|
|
1616
|
+
user: event.user,
|
|
1617
|
+
serverId: event.serverId,
|
|
1618
|
+
// bigint from event
|
|
1619
|
+
serverAddress: normalizedServerAddress,
|
|
1620
|
+
// derived from params
|
|
1621
|
+
serverUrl: params.serverUrl
|
|
1622
|
+
// provided in params
|
|
1326
1623
|
};
|
|
1327
1624
|
} catch (error) {
|
|
1328
1625
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
@@ -1342,6 +1639,7 @@ class PermissionsController {
|
|
|
1342
1639
|
* @deprecated Use addAndTrustServer instead
|
|
1343
1640
|
*/
|
|
1344
1641
|
async submitTrustServer(params) {
|
|
1642
|
+
this.assertWallet();
|
|
1345
1643
|
try {
|
|
1346
1644
|
const chainId = await this.context.walletClient.getChainId();
|
|
1347
1645
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -1349,18 +1647,22 @@ class PermissionsController {
|
|
|
1349
1647
|
"DataPortabilityServers"
|
|
1350
1648
|
);
|
|
1351
1649
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
1650
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1352
1651
|
const txHash = await this.context.walletClient.writeContract({
|
|
1353
1652
|
address: DataPortabilityServersAddress,
|
|
1354
1653
|
abi: DataPortabilityServersAbi,
|
|
1355
1654
|
functionName: "trustServer",
|
|
1356
1655
|
args: [BigInt(params.serverId)],
|
|
1357
|
-
account
|
|
1358
|
-
chain: this.context.walletClient
|
|
1656
|
+
account,
|
|
1657
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1359
1658
|
});
|
|
1360
|
-
|
|
1659
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1660
|
+
return tx({
|
|
1361
1661
|
hash: txHash,
|
|
1362
|
-
from:
|
|
1363
|
-
|
|
1662
|
+
from: typeof account === "string" ? account : account.address,
|
|
1663
|
+
contract: "DataPortabilityServers",
|
|
1664
|
+
fn: "trustServer"
|
|
1665
|
+
});
|
|
1364
1666
|
} catch (error) {
|
|
1365
1667
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
1366
1668
|
throw new import_errors.UserRejectedRequestError();
|
|
@@ -1377,7 +1679,8 @@ class PermissionsController {
|
|
|
1377
1679
|
* @param params - Parameters for adding and trusting the server
|
|
1378
1680
|
* @returns Promise resolving to TransactionResult with ServerTrustResult event data
|
|
1379
1681
|
*/
|
|
1380
|
-
async submitAddAndTrustServerWithSignature(params) {
|
|
1682
|
+
async submitAddAndTrustServerWithSignature(params, options) {
|
|
1683
|
+
this.assertWallet();
|
|
1381
1684
|
try {
|
|
1382
1685
|
const nonce = await this.getServersUserNonce();
|
|
1383
1686
|
const serverAddress = (0, import_viem.getAddress)(params.serverAddress);
|
|
@@ -1401,21 +1704,39 @@ class PermissionsController {
|
|
|
1401
1704
|
const signature = await this.signTypedData(typedData);
|
|
1402
1705
|
console.debug("\u{1F50D} Generated signature:", signature);
|
|
1403
1706
|
let hash;
|
|
1404
|
-
if (this.context.
|
|
1405
|
-
|
|
1707
|
+
if (this.context.relayer) {
|
|
1708
|
+
const request = {
|
|
1709
|
+
type: "signed",
|
|
1710
|
+
operation: "submitAddAndTrustServer",
|
|
1406
1711
|
typedData,
|
|
1407
1712
|
signature
|
|
1408
|
-
|
|
1713
|
+
};
|
|
1714
|
+
const response = await this.context.relayer(request);
|
|
1715
|
+
if (response.type === "error") {
|
|
1716
|
+
throw new import_errors.RelayerError(response.error);
|
|
1717
|
+
}
|
|
1718
|
+
if (response.type === "submitted") {
|
|
1719
|
+
hash = response.hash;
|
|
1720
|
+
} else if (response.type === "signed") {
|
|
1721
|
+
hash = response.hash;
|
|
1722
|
+
} else {
|
|
1723
|
+
throw new Error("Unexpected response type from relayer");
|
|
1724
|
+
}
|
|
1409
1725
|
} else {
|
|
1410
1726
|
hash = await this.submitAddAndTrustServerTransaction(
|
|
1411
1727
|
addAndTrustServerInput,
|
|
1412
|
-
signature
|
|
1728
|
+
signature,
|
|
1729
|
+
options
|
|
1413
1730
|
);
|
|
1414
1731
|
}
|
|
1415
|
-
|
|
1732
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1733
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1734
|
+
return tx({
|
|
1416
1735
|
hash,
|
|
1417
|
-
from:
|
|
1418
|
-
|
|
1736
|
+
from: typeof account === "string" ? account : account.address,
|
|
1737
|
+
contract: "DataPortabilityServers",
|
|
1738
|
+
fn: "addAndTrustServerWithSignature"
|
|
1739
|
+
});
|
|
1419
1740
|
} catch (error) {
|
|
1420
1741
|
if (error instanceof Error) {
|
|
1421
1742
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -1444,7 +1765,8 @@ class PermissionsController {
|
|
|
1444
1765
|
* @throws {ServerUrlMismatchError} When server URL doesn't match existing registration
|
|
1445
1766
|
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
1446
1767
|
*/
|
|
1447
|
-
async submitTrustServerWithSignature(params) {
|
|
1768
|
+
async submitTrustServerWithSignature(params, options) {
|
|
1769
|
+
this.assertWallet();
|
|
1448
1770
|
try {
|
|
1449
1771
|
const nonce = await this.getServersUserNonce();
|
|
1450
1772
|
const trustServerInput = {
|
|
@@ -1454,21 +1776,39 @@ class PermissionsController {
|
|
|
1454
1776
|
const typedData = await this.composeTrustServerMessage(trustServerInput);
|
|
1455
1777
|
const signature = await this.signTypedData(typedData);
|
|
1456
1778
|
let hash;
|
|
1457
|
-
if (this.context.
|
|
1458
|
-
|
|
1779
|
+
if (this.context.relayer) {
|
|
1780
|
+
const request = {
|
|
1781
|
+
type: "signed",
|
|
1782
|
+
operation: "submitTrustServer",
|
|
1459
1783
|
typedData,
|
|
1460
1784
|
signature
|
|
1461
|
-
|
|
1785
|
+
};
|
|
1786
|
+
const response = await this.context.relayer(request);
|
|
1787
|
+
if (response.type === "error") {
|
|
1788
|
+
throw new import_errors.RelayerError(response.error);
|
|
1789
|
+
}
|
|
1790
|
+
if (response.type === "submitted") {
|
|
1791
|
+
hash = response.hash;
|
|
1792
|
+
} else if (response.type === "signed") {
|
|
1793
|
+
hash = response.hash;
|
|
1794
|
+
} else {
|
|
1795
|
+
throw new Error("Unexpected response type from relayer");
|
|
1796
|
+
}
|
|
1462
1797
|
} else {
|
|
1463
1798
|
hash = await this.submitTrustServerTransaction(
|
|
1464
1799
|
trustServerInput,
|
|
1465
|
-
signature
|
|
1800
|
+
signature,
|
|
1801
|
+
options
|
|
1466
1802
|
);
|
|
1467
1803
|
}
|
|
1468
|
-
|
|
1804
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1805
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1806
|
+
return tx({
|
|
1469
1807
|
hash,
|
|
1470
|
-
from:
|
|
1471
|
-
|
|
1808
|
+
from: typeof account === "string" ? account : account.address,
|
|
1809
|
+
contract: "DataPortabilityServers",
|
|
1810
|
+
fn: "trustServerWithSignature"
|
|
1811
|
+
});
|
|
1472
1812
|
} catch (error) {
|
|
1473
1813
|
if (error instanceof Error) {
|
|
1474
1814
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -1499,7 +1839,8 @@ class PermissionsController {
|
|
|
1499
1839
|
* @returns Promise resolving to TransactionResult for transaction tracking
|
|
1500
1840
|
* @throws {BlockchainError} When contract submission fails
|
|
1501
1841
|
*/
|
|
1502
|
-
async submitDirectUntrustTransaction(params) {
|
|
1842
|
+
async submitDirectUntrustTransaction(params, options) {
|
|
1843
|
+
this.assertWallet();
|
|
1503
1844
|
try {
|
|
1504
1845
|
const chainId = await this.context.walletClient.getChainId();
|
|
1505
1846
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -1507,18 +1848,33 @@ class PermissionsController {
|
|
|
1507
1848
|
"DataPortabilityServers"
|
|
1508
1849
|
);
|
|
1509
1850
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
1851
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1510
1852
|
const txHash = await this.context.walletClient.writeContract({
|
|
1511
1853
|
address: DataPortabilityServersAddress,
|
|
1512
1854
|
abi: DataPortabilityServersAbi,
|
|
1513
1855
|
functionName: "untrustServer",
|
|
1514
1856
|
args: [BigInt(params.serverId)],
|
|
1515
|
-
account
|
|
1516
|
-
chain: this.context.walletClient
|
|
1857
|
+
account,
|
|
1858
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
1859
|
+
...options?.gas && { gas: options.gas },
|
|
1860
|
+
...options?.nonce && { nonce: options.nonce },
|
|
1861
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
1862
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
1863
|
+
...options.maxFeePerGas && {
|
|
1864
|
+
maxFeePerGas: options.maxFeePerGas
|
|
1865
|
+
},
|
|
1866
|
+
...options.maxPriorityFeePerGas && {
|
|
1867
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
1868
|
+
}
|
|
1869
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
1517
1870
|
});
|
|
1518
|
-
|
|
1871
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1872
|
+
return tx({
|
|
1519
1873
|
hash: txHash,
|
|
1520
|
-
from:
|
|
1521
|
-
|
|
1874
|
+
from: typeof account === "string" ? account : account.address,
|
|
1875
|
+
contract: "DataPortabilityServers",
|
|
1876
|
+
fn: "untrustServer"
|
|
1877
|
+
});
|
|
1522
1878
|
} catch (error) {
|
|
1523
1879
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
1524
1880
|
throw new import_errors.UserRejectedRequestError();
|
|
@@ -1537,6 +1893,7 @@ class PermissionsController {
|
|
|
1537
1893
|
*
|
|
1538
1894
|
* @param params - Parameters for untrusting the server
|
|
1539
1895
|
* @param params.serverId - The numeric ID of the server to untrust
|
|
1896
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
1540
1897
|
* @returns Promise resolving to transaction hash
|
|
1541
1898
|
* @throws {Error} When wallet account is not available
|
|
1542
1899
|
* @throws {NonceError} When retrieving user nonce fails
|
|
@@ -1557,13 +1914,17 @@ class PermissionsController {
|
|
|
1557
1914
|
* console.log('Still trusting servers:', trustedServers);
|
|
1558
1915
|
* ```
|
|
1559
1916
|
*/
|
|
1560
|
-
async submitUntrustServer(params) {
|
|
1917
|
+
async submitUntrustServer(params, options) {
|
|
1918
|
+
this.assertWallet();
|
|
1561
1919
|
const nonce = await this.getServersUserNonce();
|
|
1562
1920
|
const untrustServerInput = {
|
|
1563
1921
|
nonce,
|
|
1564
1922
|
serverId: params.serverId
|
|
1565
1923
|
};
|
|
1566
|
-
return await this.submitDirectUntrustTransaction(
|
|
1924
|
+
return await this.submitDirectUntrustTransaction(
|
|
1925
|
+
untrustServerInput,
|
|
1926
|
+
options
|
|
1927
|
+
);
|
|
1567
1928
|
}
|
|
1568
1929
|
/**
|
|
1569
1930
|
* Untrusts a server using a signature (gasless transaction).
|
|
@@ -1578,6 +1939,7 @@ class PermissionsController {
|
|
|
1578
1939
|
* @throws {BlockchainError} When untrust transaction fails
|
|
1579
1940
|
*/
|
|
1580
1941
|
async submitUntrustServerWithSignature(params) {
|
|
1942
|
+
this.assertWallet();
|
|
1581
1943
|
try {
|
|
1582
1944
|
const nonce = await this.getServersUserNonce();
|
|
1583
1945
|
const untrustServerInput = {
|
|
@@ -1587,18 +1949,35 @@ class PermissionsController {
|
|
|
1587
1949
|
const typedData = await this.composeUntrustServerMessage(untrustServerInput);
|
|
1588
1950
|
const signature = await this.signTypedData(typedData);
|
|
1589
1951
|
let hash;
|
|
1590
|
-
if (this.context.
|
|
1591
|
-
|
|
1952
|
+
if (this.context.relayer) {
|
|
1953
|
+
const request = {
|
|
1954
|
+
type: "signed",
|
|
1955
|
+
operation: "submitUntrustServer",
|
|
1592
1956
|
typedData,
|
|
1593
1957
|
signature
|
|
1594
|
-
|
|
1958
|
+
};
|
|
1959
|
+
const response = await this.context.relayer(request);
|
|
1960
|
+
if (response.type === "error") {
|
|
1961
|
+
throw new import_errors.RelayerError(response.error);
|
|
1962
|
+
}
|
|
1963
|
+
if (response.type === "submitted") {
|
|
1964
|
+
hash = response.hash;
|
|
1965
|
+
} else if (response.type === "signed") {
|
|
1966
|
+
hash = response.hash;
|
|
1967
|
+
} else {
|
|
1968
|
+
throw new Error("Unexpected response type from relayer");
|
|
1969
|
+
}
|
|
1595
1970
|
} else {
|
|
1596
1971
|
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
1597
1972
|
}
|
|
1598
|
-
|
|
1973
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1974
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1975
|
+
return tx({
|
|
1599
1976
|
hash,
|
|
1600
|
-
from:
|
|
1601
|
-
|
|
1977
|
+
from: typeof account === "string" ? account : account.address,
|
|
1978
|
+
contract: "DataPortabilityServers",
|
|
1979
|
+
fn: "untrustServerWithSignature"
|
|
1980
|
+
});
|
|
1602
1981
|
} catch (error) {
|
|
1603
1982
|
if (error instanceof Error) {
|
|
1604
1983
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -1636,8 +2015,8 @@ class PermissionsController {
|
|
|
1636
2015
|
*/
|
|
1637
2016
|
async getTrustedServers(userAddress) {
|
|
1638
2017
|
try {
|
|
1639
|
-
const user = userAddress
|
|
1640
|
-
const chainId = await this.context.
|
|
2018
|
+
const user = userAddress ?? this.context.userAddress;
|
|
2019
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1641
2020
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1642
2021
|
chainId,
|
|
1643
2022
|
"DataPortabilityServers"
|
|
@@ -1666,8 +2045,8 @@ class PermissionsController {
|
|
|
1666
2045
|
*/
|
|
1667
2046
|
async getTrustedServersCount(userAddress) {
|
|
1668
2047
|
try {
|
|
1669
|
-
const user = userAddress
|
|
1670
|
-
const chainId = await this.context.
|
|
2048
|
+
const user = userAddress ?? this.context.userAddress;
|
|
2049
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1671
2050
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1672
2051
|
chainId,
|
|
1673
2052
|
"DataPortabilityServers"
|
|
@@ -1696,10 +2075,10 @@ class PermissionsController {
|
|
|
1696
2075
|
*/
|
|
1697
2076
|
async getTrustedServersPaginated(options = {}) {
|
|
1698
2077
|
try {
|
|
1699
|
-
const user = options.userAddress
|
|
1700
|
-
const limit = options.limit
|
|
1701
|
-
const offset = options.offset
|
|
1702
|
-
const chainId = await this.context.
|
|
2078
|
+
const user = options.userAddress ?? this.context.userAddress;
|
|
2079
|
+
const limit = options.limit ?? 50;
|
|
2080
|
+
const offset = options.offset ?? 0;
|
|
2081
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1703
2082
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1704
2083
|
chainId,
|
|
1705
2084
|
"DataPortabilityServers"
|
|
@@ -1845,7 +2224,7 @@ class PermissionsController {
|
|
|
1845
2224
|
};
|
|
1846
2225
|
}
|
|
1847
2226
|
try {
|
|
1848
|
-
const chainId = await this.context.
|
|
2227
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1849
2228
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
1850
2229
|
chainId,
|
|
1851
2230
|
"DataPortabilityServers"
|
|
@@ -1920,7 +2299,7 @@ class PermissionsController {
|
|
|
1920
2299
|
*/
|
|
1921
2300
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
1922
2301
|
try {
|
|
1923
|
-
const user = userAddress
|
|
2302
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1924
2303
|
const trustedServers = await this.getTrustedServers(user);
|
|
1925
2304
|
const trustIndex = trustedServers.findIndex(
|
|
1926
2305
|
(server) => server === serverId
|
|
@@ -2010,7 +2389,7 @@ class PermissionsController {
|
|
|
2010
2389
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
2011
2390
|
*/
|
|
2012
2391
|
async getServersDomain() {
|
|
2013
|
-
const chainId = await this.context.
|
|
2392
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2014
2393
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2015
2394
|
chainId,
|
|
2016
2395
|
"DataPortabilityServers"
|
|
@@ -2029,7 +2408,8 @@ class PermissionsController {
|
|
|
2029
2408
|
* @param signature - The cryptographic signature for the transaction
|
|
2030
2409
|
* @returns Promise resolving to the transaction hash
|
|
2031
2410
|
*/
|
|
2032
|
-
async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
|
|
2411
|
+
async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature, options) {
|
|
2412
|
+
this.assertWallet();
|
|
2033
2413
|
const chainId = await this.context.walletClient.getChainId();
|
|
2034
2414
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2035
2415
|
chainId,
|
|
@@ -2061,8 +2441,17 @@ class PermissionsController {
|
|
|
2061
2441
|
},
|
|
2062
2442
|
formattedSignature
|
|
2063
2443
|
],
|
|
2064
|
-
account: this.context.walletClient
|
|
2065
|
-
chain: this.context.walletClient
|
|
2444
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2445
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2446
|
+
...options && {
|
|
2447
|
+
gas: options.gas,
|
|
2448
|
+
nonce: options.nonce,
|
|
2449
|
+
// Use EIP-1559 gas pricing if available, otherwise legacy
|
|
2450
|
+
...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
|
|
2451
|
+
maxFeePerGas: options.maxFeePerGas,
|
|
2452
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
2453
|
+
} : options.gasPrice ? { gasPrice: options.gasPrice } : {}
|
|
2454
|
+
}
|
|
2066
2455
|
});
|
|
2067
2456
|
return txHash;
|
|
2068
2457
|
}
|
|
@@ -2073,7 +2462,8 @@ class PermissionsController {
|
|
|
2073
2462
|
* @param signature - The cryptographic signature for the transaction
|
|
2074
2463
|
* @returns Promise resolving to the transaction hash
|
|
2075
2464
|
*/
|
|
2076
|
-
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2465
|
+
async submitTrustServerTransaction(trustServerInput, signature, options) {
|
|
2466
|
+
this.assertWallet();
|
|
2077
2467
|
const chainId = await this.context.walletClient.getChainId();
|
|
2078
2468
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2079
2469
|
chainId,
|
|
@@ -2092,8 +2482,9 @@ class PermissionsController {
|
|
|
2092
2482
|
},
|
|
2093
2483
|
formattedSignature
|
|
2094
2484
|
],
|
|
2095
|
-
account: this.context.walletClient
|
|
2096
|
-
chain: this.context.walletClient
|
|
2485
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2486
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2487
|
+
...this.spreadTransactionOptions(options)
|
|
2097
2488
|
});
|
|
2098
2489
|
return txHash;
|
|
2099
2490
|
}
|
|
@@ -2104,7 +2495,8 @@ class PermissionsController {
|
|
|
2104
2495
|
* @param signature - The cryptographic signature authorizing the revoke
|
|
2105
2496
|
* @returns Promise resolving to the transaction hash
|
|
2106
2497
|
*/
|
|
2107
|
-
async submitDirectRevokeTransaction(typedData, signature) {
|
|
2498
|
+
async submitDirectRevokeTransaction(typedData, signature, options) {
|
|
2499
|
+
this.assertWallet();
|
|
2108
2500
|
const chainId = await this.context.walletClient.getChainId();
|
|
2109
2501
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
2110
2502
|
chainId,
|
|
@@ -2116,10 +2508,18 @@ class PermissionsController {
|
|
|
2116
2508
|
address: DataPortabilityPermissionsAddress,
|
|
2117
2509
|
abi: DataPortabilityPermissionsAbi,
|
|
2118
2510
|
functionName: "revokePermissionWithSignature",
|
|
2119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2120
2511
|
args: [typedData.message, formattedSignature],
|
|
2121
|
-
account: this.context.walletClient
|
|
2122
|
-
chain: this.context.walletClient
|
|
2512
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2513
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2514
|
+
...options && {
|
|
2515
|
+
gas: options.gas,
|
|
2516
|
+
nonce: options.nonce,
|
|
2517
|
+
// Use EIP-1559 gas pricing if available, otherwise legacy
|
|
2518
|
+
...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
|
|
2519
|
+
maxFeePerGas: options.maxFeePerGas,
|
|
2520
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
2521
|
+
} : options.gasPrice ? { gasPrice: options.gasPrice } : {}
|
|
2522
|
+
}
|
|
2123
2523
|
});
|
|
2124
2524
|
return txHash;
|
|
2125
2525
|
}
|
|
@@ -2130,7 +2530,8 @@ class PermissionsController {
|
|
|
2130
2530
|
* @param signature - The cryptographic signature authorizing the untrust
|
|
2131
2531
|
* @returns Promise resolving to the transaction hash
|
|
2132
2532
|
*/
|
|
2133
|
-
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2533
|
+
async submitSignedUntrustTransaction(typedData, signature, options) {
|
|
2534
|
+
this.assertWallet();
|
|
2134
2535
|
const chainId = await this.context.walletClient.getChainId();
|
|
2135
2536
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2136
2537
|
chainId,
|
|
@@ -2138,14 +2539,26 @@ class PermissionsController {
|
|
|
2138
2539
|
);
|
|
2139
2540
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
2140
2541
|
const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
|
|
2542
|
+
const contractMessage = {
|
|
2543
|
+
nonce: typedData.message.nonce,
|
|
2544
|
+
serverId: BigInt(typedData.message.serverId)
|
|
2545
|
+
};
|
|
2141
2546
|
const txHash = await this.context.walletClient.writeContract({
|
|
2142
2547
|
address: DataPortabilityServersAddress,
|
|
2143
2548
|
abi: DataPortabilityServersAbi,
|
|
2144
2549
|
functionName: "untrustServerWithSignature",
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2550
|
+
args: [contractMessage, formattedSignature],
|
|
2551
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2552
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2553
|
+
...options && {
|
|
2554
|
+
gas: options.gas,
|
|
2555
|
+
nonce: options.nonce,
|
|
2556
|
+
// Use EIP-1559 gas pricing if available, otherwise legacy
|
|
2557
|
+
...options.maxFeePerGas || options.maxPriorityFeePerGas ? {
|
|
2558
|
+
maxFeePerGas: options.maxFeePerGas,
|
|
2559
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
2560
|
+
} : options.gasPrice ? { gasPrice: options.gasPrice } : {}
|
|
2561
|
+
}
|
|
2149
2562
|
});
|
|
2150
2563
|
return txHash;
|
|
2151
2564
|
}
|
|
@@ -2158,14 +2571,18 @@ class PermissionsController {
|
|
|
2158
2571
|
* A grantee is an entity (like an application) that can receive data permissions
|
|
2159
2572
|
* from users. Once registered, users can grant the grantee access to their data.
|
|
2160
2573
|
*
|
|
2574
|
+
* This method supports gasless transactions via relayer when configured.
|
|
2575
|
+
* If no relayer is available, it falls back to direct wallet transactions.
|
|
2576
|
+
*
|
|
2161
2577
|
* @param params - Parameters for registering the grantee
|
|
2162
2578
|
* @param params.owner - The Ethereum address that will own this grantee registration
|
|
2163
2579
|
* @param params.granteeAddress - The Ethereum address of the grantee (application)
|
|
2164
2580
|
* @param params.publicKey - The public key used for data encryption/decryption (hex string)
|
|
2581
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
2165
2582
|
* @returns Promise resolving to the transaction hash
|
|
2166
2583
|
* @throws {BlockchainError} When the grantee registration transaction fails
|
|
2167
2584
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
2168
|
-
* @throws {
|
|
2585
|
+
* @throws {RelayerError} When gasless transaction submission fails
|
|
2169
2586
|
*
|
|
2170
2587
|
* @example
|
|
2171
2588
|
* ```typescript
|
|
@@ -2177,86 +2594,88 @@ class PermissionsController {
|
|
|
2177
2594
|
* console.log(`Grantee registered in transaction: ${txHash}`);
|
|
2178
2595
|
* ```
|
|
2179
2596
|
*/
|
|
2180
|
-
async submitRegisterGrantee(params) {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
from: this.context.walletClient.account?.address
|
|
2258
|
-
};
|
|
2597
|
+
async submitRegisterGrantee(params, options) {
|
|
2598
|
+
try {
|
|
2599
|
+
let hash;
|
|
2600
|
+
if (this.context.relayer) {
|
|
2601
|
+
const request = {
|
|
2602
|
+
type: "direct",
|
|
2603
|
+
operation: "submitRegisterGrantee",
|
|
2604
|
+
params: {
|
|
2605
|
+
owner: params.owner,
|
|
2606
|
+
granteeAddress: params.granteeAddress,
|
|
2607
|
+
publicKey: params.publicKey
|
|
2608
|
+
}
|
|
2609
|
+
};
|
|
2610
|
+
const response = await this.context.relayer(request);
|
|
2611
|
+
if (response.type === "error") {
|
|
2612
|
+
throw new import_errors.RelayerError(response.error);
|
|
2613
|
+
}
|
|
2614
|
+
if (response.type === "submitted") {
|
|
2615
|
+
hash = response.hash;
|
|
2616
|
+
} else if (response.type === "direct") {
|
|
2617
|
+
const result = response.result;
|
|
2618
|
+
hash = result.transactionHash;
|
|
2619
|
+
} else {
|
|
2620
|
+
throw new Error("Unexpected response type from relayer");
|
|
2621
|
+
}
|
|
2622
|
+
} else {
|
|
2623
|
+
this.assertWallet();
|
|
2624
|
+
const chainId = await this.context.walletClient.getChainId();
|
|
2625
|
+
const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
|
|
2626
|
+
chainId,
|
|
2627
|
+
"DataPortabilityGrantees"
|
|
2628
|
+
);
|
|
2629
|
+
const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
|
|
2630
|
+
const ownerAddress = (0, import_viem.getAddress)(params.owner);
|
|
2631
|
+
const granteeAddress = (0, import_viem.getAddress)(params.granteeAddress);
|
|
2632
|
+
const account2 = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2633
|
+
hash = await this.context.walletClient.writeContract({
|
|
2634
|
+
address: DataPortabilityGranteesAddress,
|
|
2635
|
+
abi: DataPortabilityGranteesAbi,
|
|
2636
|
+
functionName: "registerGrantee",
|
|
2637
|
+
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2638
|
+
account: account2,
|
|
2639
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2640
|
+
...this.spreadTransactionOptions(options)
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2644
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
2645
|
+
return tx({
|
|
2646
|
+
hash,
|
|
2647
|
+
from: typeof account === "string" ? account : account.address,
|
|
2648
|
+
contract: "DataPortabilityGrantees",
|
|
2649
|
+
fn: "registerGrantee"
|
|
2650
|
+
});
|
|
2651
|
+
} catch (error) {
|
|
2652
|
+
if (error instanceof Error) {
|
|
2653
|
+
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.BlockchainError) {
|
|
2654
|
+
throw error;
|
|
2655
|
+
}
|
|
2656
|
+
if (error.name === "ContractFunctionExecutionError") {
|
|
2657
|
+
throw new import_errors.BlockchainError(
|
|
2658
|
+
`Grantee registration failed: ${error.message}`,
|
|
2659
|
+
error
|
|
2660
|
+
);
|
|
2661
|
+
}
|
|
2662
|
+
if (error.name === "UserRejectedRequestError") {
|
|
2663
|
+
throw new import_errors.UserRejectedRequestError(
|
|
2664
|
+
"User rejected the grantee registration transaction"
|
|
2665
|
+
);
|
|
2666
|
+
}
|
|
2667
|
+
throw new import_errors.BlockchainError(
|
|
2668
|
+
`Failed to register grantee: ${error.message}`,
|
|
2669
|
+
error
|
|
2670
|
+
);
|
|
2671
|
+
}
|
|
2672
|
+
throw new import_errors.BlockchainError(`Failed to register grantee: ${String(error)}`);
|
|
2673
|
+
}
|
|
2259
2674
|
}
|
|
2675
|
+
// TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
|
|
2676
|
+
// implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
|
|
2677
|
+
// to support EIP-712 signed gasless transactions via relayer.
|
|
2678
|
+
// Current implementation above supports direct gasless transactions (relayer pays gas directly).
|
|
2260
2679
|
/**
|
|
2261
2680
|
* Retrieves all registered grantees from the DataPortabilityGrantees contract.
|
|
2262
2681
|
*
|
|
@@ -2302,8 +2721,8 @@ class PermissionsController {
|
|
|
2302
2721
|
functionName: "granteesCount"
|
|
2303
2722
|
});
|
|
2304
2723
|
const total = Number(totalCount);
|
|
2305
|
-
const limit = options.limit
|
|
2306
|
-
const offset = options.offset
|
|
2724
|
+
const limit = options.limit ?? 50;
|
|
2725
|
+
const offset = options.offset ?? 0;
|
|
2307
2726
|
const grantees = [];
|
|
2308
2727
|
const endIndex = Math.min(offset + limit, total);
|
|
2309
2728
|
for (let i = offset; i < endIndex; i++) {
|
|
@@ -2443,67 +2862,6 @@ class PermissionsController {
|
|
|
2443
2862
|
return null;
|
|
2444
2863
|
}
|
|
2445
2864
|
}
|
|
2446
|
-
/**
|
|
2447
|
-
* Builds EIP-712 typed data for grantee registration
|
|
2448
|
-
*
|
|
2449
|
-
* @param input - The register grantee input
|
|
2450
|
-
* @returns Promise resolving to the typed data structure
|
|
2451
|
-
* @private
|
|
2452
|
-
*/
|
|
2453
|
-
async buildRegisterGranteeTypedData(input) {
|
|
2454
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
2455
|
-
const verifyingContract = (0, import_addresses.getContractAddress)(
|
|
2456
|
-
chainId,
|
|
2457
|
-
"DataPortabilityGrantees"
|
|
2458
|
-
);
|
|
2459
|
-
return {
|
|
2460
|
-
domain: {
|
|
2461
|
-
name: "DataPortabilityGrantees",
|
|
2462
|
-
version: "1",
|
|
2463
|
-
chainId,
|
|
2464
|
-
verifyingContract
|
|
2465
|
-
},
|
|
2466
|
-
types: {
|
|
2467
|
-
RegisterGrantee: [
|
|
2468
|
-
{ name: "nonce", type: "uint256" },
|
|
2469
|
-
{ name: "owner", type: "address" },
|
|
2470
|
-
{ name: "granteeAddress", type: "address" },
|
|
2471
|
-
{ name: "publicKey", type: "string" }
|
|
2472
|
-
]
|
|
2473
|
-
},
|
|
2474
|
-
primaryType: "RegisterGrantee",
|
|
2475
|
-
message: input
|
|
2476
|
-
};
|
|
2477
|
-
}
|
|
2478
|
-
/**
|
|
2479
|
-
* Submits a register grantee transaction with signature.
|
|
2480
|
-
*
|
|
2481
|
-
* @param typedData - The EIP-712 typed data structure for the registration
|
|
2482
|
-
* @param _signature - The cryptographic signature authorizing the registration (currently unused)
|
|
2483
|
-
* @returns Promise resolving to the transaction hash
|
|
2484
|
-
* @private
|
|
2485
|
-
*/
|
|
2486
|
-
async submitSignedRegisterGranteeTransaction(typedData, _signature) {
|
|
2487
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
2488
|
-
const DataPortabilityGranteesAddress = (0, import_addresses.getContractAddress)(
|
|
2489
|
-
chainId,
|
|
2490
|
-
"DataPortabilityGrantees"
|
|
2491
|
-
);
|
|
2492
|
-
const DataPortabilityGranteesAbi = (0, import_abi.getAbi)("DataPortabilityGrantees");
|
|
2493
|
-
const txHash = await this.context.walletClient.writeContract({
|
|
2494
|
-
address: DataPortabilityGranteesAddress,
|
|
2495
|
-
abi: DataPortabilityGranteesAbi,
|
|
2496
|
-
functionName: "registerGrantee",
|
|
2497
|
-
args: [
|
|
2498
|
-
typedData.message.owner,
|
|
2499
|
-
typedData.message.granteeAddress,
|
|
2500
|
-
typedData.message.publicKey
|
|
2501
|
-
],
|
|
2502
|
-
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
2503
|
-
chain: this.context.walletClient.chain || null
|
|
2504
|
-
});
|
|
2505
|
-
return txHash;
|
|
2506
|
-
}
|
|
2507
2865
|
// ===========================
|
|
2508
2866
|
// DATA PORTABILITY SERVERS HELPER METHODS
|
|
2509
2867
|
// ===========================
|
|
@@ -2515,7 +2873,7 @@ class PermissionsController {
|
|
|
2515
2873
|
*/
|
|
2516
2874
|
async getUserServerIds(userAddress) {
|
|
2517
2875
|
try {
|
|
2518
|
-
const targetAddress = userAddress
|
|
2876
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2519
2877
|
const chainId = await this.context.publicClient.getChainId();
|
|
2520
2878
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2521
2879
|
chainId,
|
|
@@ -2573,7 +2931,7 @@ class PermissionsController {
|
|
|
2573
2931
|
*/
|
|
2574
2932
|
async getUserServerCount(userAddress) {
|
|
2575
2933
|
try {
|
|
2576
|
-
const targetAddress = userAddress
|
|
2934
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2577
2935
|
const chainId = await this.context.publicClient.getChainId();
|
|
2578
2936
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2579
2937
|
chainId,
|
|
@@ -2602,7 +2960,7 @@ class PermissionsController {
|
|
|
2602
2960
|
*/
|
|
2603
2961
|
async getUserTrustedServers(userAddress) {
|
|
2604
2962
|
try {
|
|
2605
|
-
const targetAddress = userAddress
|
|
2963
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2606
2964
|
const chainId = await this.context.publicClient.getChainId();
|
|
2607
2965
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
2608
2966
|
chainId,
|
|
@@ -2719,7 +3077,7 @@ class PermissionsController {
|
|
|
2719
3077
|
*/
|
|
2720
3078
|
async getUserPermissionIds(userAddress) {
|
|
2721
3079
|
try {
|
|
2722
|
-
const targetAddress = userAddress
|
|
3080
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2723
3081
|
const chainId = await this.context.publicClient.getChainId();
|
|
2724
3082
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
2725
3083
|
chainId,
|
|
@@ -2781,7 +3139,7 @@ class PermissionsController {
|
|
|
2781
3139
|
*/
|
|
2782
3140
|
async getUserPermissionCount(userAddress) {
|
|
2783
3141
|
try {
|
|
2784
|
-
const targetAddress = userAddress
|
|
3142
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2785
3143
|
const chainId = await this.context.publicClient.getChainId();
|
|
2786
3144
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
2787
3145
|
chainId,
|
|
@@ -3223,9 +3581,11 @@ class PermissionsController {
|
|
|
3223
3581
|
*
|
|
3224
3582
|
* @param serverId - Server ID to update
|
|
3225
3583
|
* @param url - New URL for the server
|
|
3584
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
3226
3585
|
* @returns Promise resolving to transaction hash
|
|
3227
3586
|
*/
|
|
3228
|
-
async submitUpdateServer(serverId, url) {
|
|
3587
|
+
async submitUpdateServer(serverId, url, options) {
|
|
3588
|
+
this.assertWallet();
|
|
3229
3589
|
try {
|
|
3230
3590
|
const chainId = await this.context.walletClient.getChainId();
|
|
3231
3591
|
const DataPortabilityServersAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -3233,18 +3593,33 @@ class PermissionsController {
|
|
|
3233
3593
|
"DataPortabilityServers"
|
|
3234
3594
|
);
|
|
3235
3595
|
const DataPortabilityServersAbi = (0, import_abi.getAbi)("DataPortabilityServers");
|
|
3596
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3236
3597
|
const hash = await this.context.walletClient.writeContract({
|
|
3237
3598
|
address: DataPortabilityServersAddress,
|
|
3238
3599
|
abi: DataPortabilityServersAbi,
|
|
3239
3600
|
functionName: "updateServer",
|
|
3240
3601
|
args: [serverId, url],
|
|
3241
|
-
chain: this.context.walletClient
|
|
3242
|
-
account
|
|
3602
|
+
chain: this.context.walletClient?.chain,
|
|
3603
|
+
account,
|
|
3604
|
+
...options?.gas && { gas: options.gas },
|
|
3605
|
+
...options?.nonce && { nonce: options.nonce },
|
|
3606
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3607
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3608
|
+
...options.maxFeePerGas && {
|
|
3609
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3610
|
+
},
|
|
3611
|
+
...options.maxPriorityFeePerGas && {
|
|
3612
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3613
|
+
}
|
|
3614
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3243
3615
|
});
|
|
3244
|
-
|
|
3616
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3617
|
+
return tx({
|
|
3245
3618
|
hash,
|
|
3246
|
-
from:
|
|
3247
|
-
|
|
3619
|
+
from: typeof account === "string" ? account : account.address,
|
|
3620
|
+
contract: "DataPortabilityServers",
|
|
3621
|
+
fn: "updateServer"
|
|
3622
|
+
});
|
|
3248
3623
|
} catch (error) {
|
|
3249
3624
|
throw new import_errors.BlockchainError(
|
|
3250
3625
|
`Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3394,6 +3769,7 @@ class PermissionsController {
|
|
|
3394
3769
|
* @throws {NetworkError} When network communication fails
|
|
3395
3770
|
*/
|
|
3396
3771
|
async submitAddPermission(params) {
|
|
3772
|
+
this.assertWallet();
|
|
3397
3773
|
try {
|
|
3398
3774
|
const nonce = await this.getPermissionsUserNonce();
|
|
3399
3775
|
const addPermissionInput = {
|
|
@@ -3431,24 +3807,43 @@ class PermissionsController {
|
|
|
3431
3807
|
* @throws {BlockchainError} When permission addition fails
|
|
3432
3808
|
* @throws {NetworkError} When network communication fails
|
|
3433
3809
|
*/
|
|
3434
|
-
async submitSignedAddPermission(typedData, signature) {
|
|
3810
|
+
async submitSignedAddPermission(typedData, signature, options) {
|
|
3811
|
+
this.assertWallet();
|
|
3435
3812
|
try {
|
|
3436
3813
|
let hash;
|
|
3437
|
-
if (this.context.
|
|
3438
|
-
|
|
3814
|
+
if (this.context.relayer) {
|
|
3815
|
+
const request = {
|
|
3816
|
+
type: "signed",
|
|
3817
|
+
operation: "submitAddPermission",
|
|
3439
3818
|
typedData,
|
|
3440
3819
|
signature
|
|
3441
|
-
|
|
3820
|
+
};
|
|
3821
|
+
const response = await this.context.relayer(request);
|
|
3822
|
+
if (response.type === "error") {
|
|
3823
|
+
throw new import_errors.RelayerError(response.error);
|
|
3824
|
+
}
|
|
3825
|
+
if (response.type === "submitted") {
|
|
3826
|
+
hash = response.hash;
|
|
3827
|
+
} else if (response.type === "signed") {
|
|
3828
|
+
hash = response.hash;
|
|
3829
|
+
} else {
|
|
3830
|
+
throw new Error("Unexpected response type from relayer");
|
|
3831
|
+
}
|
|
3442
3832
|
} else {
|
|
3443
3833
|
hash = await this.submitDirectAddPermissionTransaction(
|
|
3444
3834
|
typedData,
|
|
3445
|
-
signature
|
|
3835
|
+
signature,
|
|
3836
|
+
options
|
|
3446
3837
|
);
|
|
3447
3838
|
}
|
|
3448
|
-
|
|
3839
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3840
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3841
|
+
return tx({
|
|
3449
3842
|
hash,
|
|
3450
|
-
from:
|
|
3451
|
-
|
|
3843
|
+
from: typeof account === "string" ? account : account.address,
|
|
3844
|
+
contract: "DataPortabilityPermissions",
|
|
3845
|
+
fn: "addPermission"
|
|
3846
|
+
});
|
|
3452
3847
|
} catch (error) {
|
|
3453
3848
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
3454
3849
|
throw error;
|
|
@@ -3477,8 +3872,11 @@ class PermissionsController {
|
|
|
3477
3872
|
* @param params.serverAddress - Server wallet address for decryption permissions
|
|
3478
3873
|
* @param params.serverUrl - Server endpoint URL
|
|
3479
3874
|
* @param params.serverPublicKey - Server's public key for encryption.
|
|
3480
|
-
* Obtain via `vana.server.getIdentity(userAddress).
|
|
3875
|
+
* Obtain via `vana.server.getIdentity(userAddress).publicKey`.
|
|
3481
3876
|
* @param params.filePermissions - Nested array of permissions for each file
|
|
3877
|
+
* @param options - Optional transaction options for gas parameters and timeout.
|
|
3878
|
+
* Note: These options are only applied for direct blockchain transactions.
|
|
3879
|
+
* When using relayer callbacks (gasless transactions), these options are ignored.
|
|
3482
3880
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3483
3881
|
* @throws {Error} When schemaIds array length doesn't match fileUrls array length
|
|
3484
3882
|
* @throws {SchemaValidationError} When file data doesn't match the specified schema.
|
|
@@ -3492,6 +3890,7 @@ class PermissionsController {
|
|
|
3492
3890
|
*
|
|
3493
3891
|
* @example
|
|
3494
3892
|
* ```typescript
|
|
3893
|
+
* // Submit with custom gas parameters and timeout
|
|
3495
3894
|
* const result = await vana.permissions.submitAddServerFilesAndPermissions({
|
|
3496
3895
|
* granteeId: BigInt(1),
|
|
3497
3896
|
* grant: "ipfs://QmXxx...",
|
|
@@ -3499,17 +3898,25 @@ class PermissionsController {
|
|
|
3499
3898
|
* schemaIds: [123], // LinkedIn profile schema ID
|
|
3500
3899
|
* serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3501
3900
|
* serverUrl: "https://server.example.com",
|
|
3502
|
-
* serverPublicKey: serverInfo.
|
|
3901
|
+
* serverPublicKey: serverInfo.publicKey,
|
|
3503
3902
|
* filePermissions: [[{
|
|
3504
3903
|
* account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3505
3904
|
* key: encryptedKey
|
|
3506
3905
|
* }]]
|
|
3906
|
+
* }, {
|
|
3907
|
+
* maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
|
|
3908
|
+
* maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
|
|
3507
3909
|
* });
|
|
3508
|
-
*
|
|
3509
|
-
*
|
|
3910
|
+
*
|
|
3911
|
+
* // Wait for confirmation with custom timeout
|
|
3912
|
+
* const receipt = await vana.waitForTransactionReceipt(result, {
|
|
3913
|
+
* timeout: 180000 // 3 minutes
|
|
3914
|
+
* });
|
|
3915
|
+
* console.log(`Transaction confirmed: ${receipt.transactionHash}`);
|
|
3510
3916
|
* ```
|
|
3511
3917
|
*/
|
|
3512
|
-
async submitAddServerFilesAndPermissions(params) {
|
|
3918
|
+
async submitAddServerFilesAndPermissions(params, options) {
|
|
3919
|
+
this.assertWallet();
|
|
3513
3920
|
try {
|
|
3514
3921
|
if (params.schemaIds.length !== params.fileUrls.length) {
|
|
3515
3922
|
throw new Error(
|
|
@@ -3534,7 +3941,8 @@ class PermissionsController {
|
|
|
3534
3941
|
const signature = await this.signTypedData(typedData);
|
|
3535
3942
|
return await this.submitSignedAddServerFilesAndPermissions(
|
|
3536
3943
|
typedData,
|
|
3537
|
-
signature
|
|
3944
|
+
signature,
|
|
3945
|
+
options
|
|
3538
3946
|
);
|
|
3539
3947
|
} catch (error) {
|
|
3540
3948
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SerializationError || error instanceof import_errors.SignatureError || error instanceof import_errors.NetworkError || error instanceof import_errors.NonceError) {
|
|
@@ -3555,6 +3963,9 @@ class PermissionsController {
|
|
|
3555
3963
|
*
|
|
3556
3964
|
* @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
|
|
3557
3965
|
* @param signature - The user's signature
|
|
3966
|
+
* @param options - Optional transaction options for gas parameters and timeout.
|
|
3967
|
+
* Note: These options are only applied for direct blockchain transactions.
|
|
3968
|
+
* When using relayer callbacks (gasless transactions), these options are ignored.
|
|
3558
3969
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3559
3970
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
3560
3971
|
* @throws {BlockchainError} When server files and permissions addition fails
|
|
@@ -3573,38 +3984,49 @@ class PermissionsController {
|
|
|
3573
3984
|
* console.log(`Permission created with ID: ${permissionId}`);
|
|
3574
3985
|
* ```
|
|
3575
3986
|
*/
|
|
3576
|
-
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
3987
|
+
async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
|
|
3988
|
+
this.assertWallet();
|
|
3577
3989
|
try {
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
|
|
3581
|
-
availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
|
|
3582
|
-
});
|
|
3583
|
-
if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
|
|
3990
|
+
let hash;
|
|
3991
|
+
if (this.context.relayer) {
|
|
3584
3992
|
console.debug(
|
|
3585
3993
|
"\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
|
|
3586
3994
|
);
|
|
3587
|
-
const
|
|
3995
|
+
const request = {
|
|
3996
|
+
type: "signed",
|
|
3997
|
+
operation: "submitAddServerFilesAndPermissions",
|
|
3588
3998
|
typedData,
|
|
3589
3999
|
signature
|
|
3590
|
-
);
|
|
3591
|
-
return {
|
|
3592
|
-
hash,
|
|
3593
|
-
from: this.context.walletClient.account?.address
|
|
3594
4000
|
};
|
|
4001
|
+
const response = await this.context.relayer(request);
|
|
4002
|
+
if (response.type === "error") {
|
|
4003
|
+
throw new import_errors.RelayerError(response.error);
|
|
4004
|
+
}
|
|
4005
|
+
if (response.type === "submitted") {
|
|
4006
|
+
hash = response.hash;
|
|
4007
|
+
} else if (response.type === "signed") {
|
|
4008
|
+
hash = response.hash;
|
|
4009
|
+
} else {
|
|
4010
|
+
throw new Error("Unexpected response type from relayer");
|
|
4011
|
+
}
|
|
3595
4012
|
} else {
|
|
3596
4013
|
console.debug(
|
|
3597
4014
|
"\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
|
|
3598
4015
|
);
|
|
3599
|
-
|
|
4016
|
+
hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
|
|
3600
4017
|
typedData,
|
|
3601
|
-
signature
|
|
4018
|
+
signature,
|
|
4019
|
+
options
|
|
3602
4020
|
);
|
|
3603
|
-
return {
|
|
3604
|
-
hash,
|
|
3605
|
-
from: this.context.walletClient.account?.address
|
|
3606
|
-
};
|
|
3607
4021
|
}
|
|
4022
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
4023
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
4024
|
+
return tx({
|
|
4025
|
+
hash,
|
|
4026
|
+
from: typeof account === "string" ? account : account.address,
|
|
4027
|
+
contract: "DataPortabilityPermissions",
|
|
4028
|
+
fn: "addServerFilesAndPermissions"
|
|
4029
|
+
});
|
|
3608
4030
|
} catch (error) {
|
|
3609
4031
|
if (error instanceof import_errors.RelayerError || error instanceof import_errors.NetworkError || error instanceof import_errors.UserRejectedRequestError || error instanceof import_errors.SignatureError || error instanceof import_errors.NonceError) {
|
|
3610
4032
|
throw error;
|
|
@@ -3619,9 +4041,11 @@ class PermissionsController {
|
|
|
3619
4041
|
* Submit permission revocation with signature to the blockchain
|
|
3620
4042
|
*
|
|
3621
4043
|
* @param permissionId - Permission ID to revoke
|
|
4044
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
3622
4045
|
* @returns Promise resolving to transaction hash
|
|
3623
4046
|
*/
|
|
3624
|
-
async submitRevokePermission(permissionId) {
|
|
4047
|
+
async submitRevokePermission(permissionId, options) {
|
|
4048
|
+
this.assertWallet();
|
|
3625
4049
|
try {
|
|
3626
4050
|
const chainId = await this.context.walletClient.getChainId();
|
|
3627
4051
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
@@ -3631,18 +4055,36 @@ class PermissionsController {
|
|
|
3631
4055
|
const DataPortabilityPermissionsAbi = (0, import_abi.getAbi)(
|
|
3632
4056
|
"DataPortabilityPermissions"
|
|
3633
4057
|
);
|
|
4058
|
+
const { account } = this.context.walletClient;
|
|
4059
|
+
if (!account) {
|
|
4060
|
+
throw new Error("No wallet account connected");
|
|
4061
|
+
}
|
|
3634
4062
|
const hash = await this.context.walletClient.writeContract({
|
|
3635
4063
|
address: DataPortabilityPermissionsAddress,
|
|
3636
4064
|
abi: DataPortabilityPermissionsAbi,
|
|
3637
4065
|
functionName: "revokePermission",
|
|
3638
4066
|
args: [permissionId],
|
|
3639
|
-
chain: this.context.walletClient
|
|
3640
|
-
account
|
|
4067
|
+
chain: this.context.walletClient?.chain,
|
|
4068
|
+
account,
|
|
4069
|
+
...options?.gas && { gas: options.gas },
|
|
4070
|
+
...options?.nonce && { nonce: options.nonce },
|
|
4071
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
4072
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
4073
|
+
...options.maxFeePerGas && {
|
|
4074
|
+
maxFeePerGas: options.maxFeePerGas
|
|
4075
|
+
},
|
|
4076
|
+
...options.maxPriorityFeePerGas && {
|
|
4077
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
4078
|
+
}
|
|
4079
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3641
4080
|
});
|
|
3642
|
-
|
|
4081
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
4082
|
+
return tx({
|
|
3643
4083
|
hash,
|
|
3644
|
-
from:
|
|
3645
|
-
|
|
4084
|
+
from: typeof account === "string" ? account : account.address,
|
|
4085
|
+
contract: "DataPortabilityPermissions",
|
|
4086
|
+
fn: "revokePermission"
|
|
4087
|
+
});
|
|
3646
4088
|
} catch (error) {
|
|
3647
4089
|
throw new import_errors.BlockchainError(
|
|
3648
4090
|
`Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3657,7 +4099,8 @@ class PermissionsController {
|
|
|
3657
4099
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
3658
4100
|
* @returns Promise resolving to the transaction hash
|
|
3659
4101
|
*/
|
|
3660
|
-
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
4102
|
+
async submitDirectAddPermissionTransaction(typedData, signature, options) {
|
|
4103
|
+
this.assertWallet();
|
|
3661
4104
|
const chainId = await this.context.walletClient.getChainId();
|
|
3662
4105
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
3663
4106
|
chainId,
|
|
@@ -3668,7 +4111,7 @@ class PermissionsController {
|
|
|
3668
4111
|
nonce: typedData.message.nonce,
|
|
3669
4112
|
granteeId: typedData.message.granteeId,
|
|
3670
4113
|
grant: typedData.message.grant,
|
|
3671
|
-
fileIds: typedData.message.fileIds
|
|
4114
|
+
fileIds: typedData.message.fileIds ?? []
|
|
3672
4115
|
};
|
|
3673
4116
|
const formattedSignature = (0, import_signatureFormatter.formatSignatureForContract)(signature);
|
|
3674
4117
|
const hash = await this.context.walletClient.writeContract({
|
|
@@ -3676,8 +4119,9 @@ class PermissionsController {
|
|
|
3676
4119
|
abi: DataPortabilityPermissionsAbi,
|
|
3677
4120
|
functionName: "addPermission",
|
|
3678
4121
|
args: [permissionInput, formattedSignature],
|
|
3679
|
-
account: this.context.walletClient
|
|
3680
|
-
chain: this.context.walletClient
|
|
4122
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
4123
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
4124
|
+
...this.spreadTransactionOptions(options)
|
|
3681
4125
|
});
|
|
3682
4126
|
return hash;
|
|
3683
4127
|
}
|
|
@@ -3688,8 +4132,9 @@ class PermissionsController {
|
|
|
3688
4132
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
3689
4133
|
* @returns Promise resolving to the transaction hash
|
|
3690
4134
|
*/
|
|
3691
|
-
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
|
|
3692
|
-
|
|
4135
|
+
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
|
|
4136
|
+
this.assertWallet();
|
|
4137
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
3693
4138
|
const DataPortabilityPermissionsAddress = (0, import_addresses.getContractAddress)(
|
|
3694
4139
|
chainId,
|
|
3695
4140
|
"DataPortabilityPermissions"
|
|
@@ -3711,10 +4156,11 @@ class PermissionsController {
|
|
|
3711
4156
|
address: DataPortabilityPermissionsAddress,
|
|
3712
4157
|
abi: DataPortabilityPermissionsAbi,
|
|
3713
4158
|
functionName: "addServerFilesAndPermissions",
|
|
3714
|
-
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
3715
4159
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
3716
|
-
account: this.context.walletClient
|
|
3717
|
-
chain: this.context.walletClient
|
|
4160
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
4161
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
4162
|
+
...options?.value && { value: options.value },
|
|
4163
|
+
...this.spreadTransactionOptions(options)
|
|
3718
4164
|
});
|
|
3719
4165
|
return hash;
|
|
3720
4166
|
}
|