@opendatalabs/vana-sdk 0.1.0-alpha.276ea01 → 0.1.0-alpha.2b6935d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/waitForTransactionEvents.test.d.ts +1 -0
- package/dist/browser.d.ts +4 -2
- package/dist/chains/definitions.cjs +9 -6
- package/dist/chains/definitions.cjs.map +1 -1
- package/dist/chains/definitions.d.ts +9 -11
- package/dist/chains/definitions.js +9 -6
- package/dist/chains/definitions.js.map +1 -1
- package/dist/chains/index.d.ts +5 -2
- package/dist/chains.browser.d.ts +8 -2
- package/dist/chains.d.ts +8 -2
- package/dist/chains.node.d.ts +8 -2
- package/dist/config/addresses.d.ts +8 -24
- package/dist/config/chains.d.ts +9 -13
- package/dist/config/default-services.cjs +60 -0
- package/dist/config/default-services.cjs.map +1 -0
- package/dist/config/default-services.d.ts +46 -0
- package/dist/config/default-services.js +33 -0
- package/dist/config/default-services.js.map +1 -0
- package/dist/config/default-services.test.d.ts +1 -0
- package/dist/config/features.d.ts +1 -3
- package/dist/config/tests/addresses.test.d.ts +1 -0
- package/dist/contracts/contractController.cjs +3 -3
- package/dist/contracts/contractController.cjs.map +1 -1
- package/dist/contracts/contractController.d.ts +11 -28
- package/dist/contracts/contractController.js +4 -7
- package/dist/contracts/contractController.js.map +1 -1
- package/dist/contracts/tests/contractController.test.d.ts +1 -0
- package/dist/controllers/__tests__/schemas-edge-cases.test.d.ts +1 -0
- package/dist/controllers/base.cjs +83 -0
- package/dist/controllers/base.cjs.map +1 -0
- package/dist/controllers/base.d.ts +84 -0
- package/dist/controllers/base.js +59 -0
- package/dist/controllers/base.js.map +1 -0
- package/dist/controllers/data-error-handling.test.d.ts +1 -0
- package/dist/controllers/data.cjs +444 -191
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +149 -76
- package/dist/controllers/data.js +444 -191
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/permissions.cjs +551 -395
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +1283 -25
- package/dist/controllers/permissions.js +551 -395
- package/dist/controllers/permissions.js.map +1 -1
- package/dist/controllers/protocol.cjs +15 -11
- package/dist/controllers/protocol.cjs.map +1 -1
- package/dist/controllers/protocol.d.ts +7 -35
- package/dist/controllers/protocol.js +15 -14
- package/dist/controllers/protocol.js.map +1 -1
- package/dist/controllers/schemas.cjs +69 -54
- package/dist/controllers/schemas.cjs.map +1 -1
- package/dist/controllers/schemas.d.ts +9 -36
- package/dist/controllers/schemas.js +69 -54
- package/dist/controllers/schemas.js.map +1 -1
- package/dist/controllers/server-additional.test.d.ts +1 -0
- package/dist/controllers/server.cjs +15 -10
- package/dist/controllers/server.cjs.map +1 -1
- package/dist/controllers/server.d.ts +7 -33
- package/dist/controllers/server.js +15 -10
- package/dist/controllers/server.js.map +1 -1
- package/dist/core/apiClient.cjs +15 -12
- package/dist/core/apiClient.cjs.map +1 -1
- package/dist/core/apiClient.d.ts +5 -9
- package/dist/core/apiClient.js +19 -19
- package/dist/core/apiClient.js.map +1 -1
- package/dist/core/client.cjs +7 -7
- package/dist/core/client.cjs.map +1 -1
- package/dist/core/client.d.ts +6 -9
- package/dist/core/client.js +7 -7
- package/dist/core/client.js.map +1 -1
- package/dist/core/core.test.d.ts +1 -0
- package/dist/core/generics.cjs +11 -9
- package/dist/core/generics.cjs.map +1 -1
- package/dist/core/generics.d.ts +9 -13
- package/dist/core/generics.js +22 -29
- package/dist/core/generics.js.map +1 -1
- package/dist/core/tests/apiClient.test.d.ts +1 -0
- package/dist/core/tests/client.test.d.ts +1 -0
- package/dist/core/tests/generics.test.d.ts +1 -0
- package/dist/core.cjs +143 -60
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +42 -66
- package/dist/core.js +155 -85
- package/dist/core.js.map +1 -1
- package/dist/crypto/ecies/__tests__/base.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/compatibility.test.d.ts +8 -0
- package/dist/crypto/ecies/__tests__/constants.test.d.ts +4 -0
- package/dist/crypto/ecies/__tests__/native-parity.test.d.ts +7 -0
- package/dist/crypto/ecies/__tests__/normalization.test.d.ts +1 -0
- package/dist/crypto/ecies/__tests__/test-vectors.d.ts +2 -4
- package/dist/crypto/ecies/base.cjs +4 -3
- package/dist/crypto/ecies/base.cjs.map +1 -1
- package/dist/crypto/ecies/base.d.ts +2 -5
- package/dist/crypto/ecies/base.js +12 -15
- package/dist/crypto/ecies/base.js.map +1 -1
- package/dist/crypto/ecies/browser.cjs +2 -1
- package/dist/crypto/ecies/browser.cjs.map +1 -1
- package/dist/crypto/ecies/browser.d.ts +2 -7
- package/dist/crypto/ecies/browser.js +2 -1
- package/dist/crypto/ecies/browser.js.map +1 -1
- package/dist/crypto/ecies/constants.d.ts +7 -9
- package/dist/crypto/ecies/index.d.ts +8 -1
- package/dist/crypto/ecies/interface.cjs +4 -5
- package/dist/crypto/ecies/interface.cjs.map +1 -1
- package/dist/crypto/ecies/interface.d.ts +9 -11
- package/dist/crypto/ecies/interface.js +4 -5
- package/dist/crypto/ecies/interface.js.map +1 -1
- package/dist/crypto/ecies/node.cjs +3 -2
- package/dist/crypto/ecies/node.cjs.map +1 -1
- package/dist/crypto/ecies/node.d.ts +2 -7
- package/dist/crypto/ecies/node.js +11 -16
- package/dist/crypto/ecies/node.js.map +1 -1
- package/dist/crypto/ecies/utils.cjs +2 -41
- package/dist/crypto/ecies/utils.cjs.map +1 -1
- package/dist/crypto/ecies/utils.d.ts +3 -40
- package/dist/crypto/ecies/utils.js +1 -35
- package/dist/crypto/ecies/utils.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
- package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
- package/dist/diagnostics.d.ts +1 -3
- package/dist/diagnostics.test.d.ts +1 -0
- package/dist/errors.cjs +16 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +53 -15
- package/dist/errors.js +18 -6
- package/dist/errors.js.map +1 -1
- package/dist/generated/abi/ComputeEngineImplementation.d.ts +2 -3
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.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.d.ts +329 -332
- package/dist/index.browser.d.ts +48 -73
- package/dist/index.browser.js +12 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.node.cjs +12 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +183 -64
- package/dist/index.node.js +12 -0
- package/dist/index.node.js.map +1 -1
- package/dist/node.d.ts +4 -2
- package/dist/platform/browser-only.d.ts +5 -8
- package/dist/platform/browser-only.test.d.ts +1 -0
- package/dist/platform/browser-safe.d.ts +6 -9
- package/dist/platform/browser-safe.test.d.ts +1 -0
- package/dist/platform/browser.cjs +7 -6
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +3 -6
- package/dist/platform/browser.js +19 -27
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/browser.test.d.ts +1 -0
- package/dist/platform/index.d.ts +11 -5
- package/dist/platform/interface.d.ts +6 -8
- package/dist/platform/node.d.ts +3 -7
- package/dist/platform/node.js +12 -19
- package/dist/platform/node.js.map +1 -1
- package/dist/platform/ports/openpgp-port.cjs +74 -0
- package/dist/platform/ports/openpgp-port.cjs.map +1 -0
- package/dist/platform/ports/openpgp-port.d.ts +13 -0
- package/dist/platform/ports/openpgp-port.js +59 -0
- package/dist/platform/ports/openpgp-port.js.map +1 -0
- package/dist/platform/ports/pgp-port.cjs +17 -0
- package/dist/platform/ports/pgp-port.cjs.map +1 -0
- package/dist/platform/ports/pgp-port.d.ts +35 -0
- package/dist/platform/ports/pgp-port.js +1 -0
- package/dist/platform/ports/pgp-port.js.map +1 -0
- package/dist/platform/shared/error-utils.d.ts +2 -4
- package/dist/platform/shared/pgp-utils.cjs +2 -2
- package/dist/platform/shared/pgp-utils.cjs.map +1 -1
- package/dist/platform/shared/pgp-utils.d.ts +3 -5
- package/dist/platform/shared/pgp-utils.js +2 -2
- package/dist/platform/shared/pgp-utils.js.map +1 -1
- package/dist/platform/shared/stream-utils.d.ts +1 -3
- package/dist/platform/utils.d.ts +6 -10
- package/dist/platform/utils.test.d.ts +1 -0
- package/dist/platform.browser.d.ts +9 -4
- package/dist/platform.d.ts +11 -5
- package/dist/platform.node.d.ts +10 -5
- package/dist/server/handler.cjs +7 -5
- package/dist/server/handler.cjs.map +1 -1
- package/dist/server/handler.d.ts +17 -204
- package/dist/server/handler.js +7 -5
- package/dist/server/handler.js.map +1 -1
- package/dist/server/relayerHandler.cjs +220 -0
- package/dist/server/relayerHandler.cjs.map +1 -0
- package/dist/server/relayerHandler.d.ts +37 -0
- package/dist/server/relayerHandler.js +195 -0
- package/dist/server/relayerHandler.js.map +1 -0
- package/dist/storage/index.d.ts +56 -10
- package/dist/storage/manager.cjs +2 -2
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +2 -5
- package/dist/storage/manager.js +5 -12
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +3 -3
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +3 -9
- package/dist/storage/providers/callback-storage.js +3 -3
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/google-drive.cjs +2 -2
- package/dist/storage/providers/google-drive.cjs.map +1 -1
- package/dist/storage/providers/google-drive.d.ts +3 -7
- package/dist/storage/providers/google-drive.js +4 -7
- package/dist/storage/providers/google-drive.js.map +1 -1
- package/dist/storage/providers/google-drive.test.d.ts +1 -0
- package/dist/storage/providers/ipfs.cjs +5 -5
- package/dist/storage/providers/ipfs.cjs.map +1 -1
- package/dist/storage/providers/ipfs.d.ts +3 -6
- package/dist/storage/providers/ipfs.js +7 -10
- package/dist/storage/providers/ipfs.js.map +1 -1
- package/dist/storage/providers/pinata.cjs +6 -6
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +5 -8
- package/dist/storage/providers/pinata.js +8 -11
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
- package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
- package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
- package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
- package/dist/storage/tests/storageManager.test.d.ts +1 -0
- package/dist/tests/abi.test.d.ts +1 -0
- package/dist/tests/chains-definitions.test.d.ts +1 -0
- package/dist/tests/core-encryption.test.d.ts +1 -0
- package/dist/tests/core-extended.test.d.ts +1 -0
- package/dist/tests/core-generics-coverage.test.d.ts +1 -0
- package/dist/tests/coverage-boost.test.d.ts +1 -0
- package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
- package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
- package/dist/tests/data-additional-methods.test.d.ts +1 -0
- package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
- package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
- package/dist/tests/data-relayer.test.d.ts +1 -0
- package/dist/tests/data-schema-validation.test.d.ts +1 -0
- package/dist/tests/data-simple-methods.test.d.ts +1 -0
- package/dist/tests/data.test.d.ts +1 -0
- package/dist/tests/demo-integration.test.d.ts +1 -0
- package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
- package/dist/tests/download-relayer.test.d.ts +1 -0
- package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
- package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
- package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
- package/dist/tests/encryption-coverage.test.d.ts +1 -0
- package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
- package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
- package/dist/tests/errors-coverage.test.d.ts +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/factories/mockFactory.d.ts +316 -0
- package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
- package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
- package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
- package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
- package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
- package/dist/tests/helper-methods.test.d.ts +1 -0
- package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
- package/dist/tests/helpers/typedMocks.d.ts +64 -0
- package/dist/tests/index-browser.test.d.ts +1 -0
- package/dist/tests/index-node.test.d.ts +1 -0
- package/dist/tests/index.test.d.ts +1 -0
- package/dist/tests/mocks/platformAdapter.d.ts +12 -0
- package/dist/tests/new-permissions-methods.test.d.ts +1 -0
- package/dist/tests/no-buffer-browser.test.d.ts +1 -0
- package/dist/tests/permissions-grantee.test.d.ts +1 -0
- package/dist/tests/permissions-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-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-handler.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/types/blockchain.cjs +17 -0
- package/dist/types/blockchain.cjs.map +1 -0
- package/dist/types/blockchain.d.ts +57 -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.d.ts +6 -9
- package/dist/types/config.cjs +10 -0
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.ts +198 -238
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +8 -11
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.ts +65 -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 +107 -39
- package/dist/types/external-apis.d.ts +10 -12
- package/dist/types/generics.d.ts +35 -38
- package/dist/types/index.cjs +5 -4
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.ts +20 -34
- package/dist/types/index.js +9 -2
- package/dist/types/index.js.map +1 -1
- package/dist/types/operations.cjs +2 -2
- package/dist/types/operations.cjs.map +1 -1
- package/dist/types/operations.d.ts +32 -28
- package/dist/types/operations.js +2 -2
- package/dist/types/operations.js.map +1 -1
- package/dist/types/permissions.d.ts +55 -58
- package/dist/types/personal.cjs.map +1 -1
- package/dist/types/personal.d.ts +6 -8
- package/dist/types/relayer.cjs.map +1 -1
- package/dist/types/relayer.d.ts +186 -39
- package/dist/types/storage.d.ts +6 -8
- package/dist/types/storage.js +2 -5
- package/dist/types/storage.js.map +1 -1
- package/dist/types/transactionResults.cjs.map +1 -1
- package/dist/types/transactionResults.d.ts +193 -25
- package/dist/types/utils.d.ts +21 -24
- 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__/transaction-edge-cases.test.d.ts +1 -0
- package/dist/utils/__tests__/transactionHelpers.test.d.ts +1 -0
- package/dist/utils/__tests__/urlResolver.test.d.ts +4 -0
- package/dist/utils/blockchain/registry.cjs +2 -2
- package/dist/utils/blockchain/registry.cjs.map +1 -1
- package/dist/utils/blockchain/registry.d.ts +6 -8
- package/dist/utils/blockchain/registry.js +2 -2
- package/dist/utils/blockchain/registry.js.map +1 -1
- package/dist/utils/blockchain/registry.test.d.ts +1 -0
- package/dist/utils/crypto-utils.cjs +0 -12
- package/dist/utils/crypto-utils.cjs.map +1 -1
- package/dist/utils/crypto-utils.d.ts +9 -27
- package/dist/utils/crypto-utils.js +0 -11
- package/dist/utils/crypto-utils.js.map +1 -1
- package/dist/utils/crypto-utils.test.d.ts +1 -0
- package/dist/utils/download.cjs +3 -3
- package/dist/utils/download.cjs.map +1 -1
- package/dist/utils/download.d.ts +13 -14
- package/dist/utils/download.js +2 -2
- package/dist/utils/download.js.map +1 -1
- package/dist/utils/encoding.cjs +1 -1
- package/dist/utils/encoding.cjs.map +1 -1
- package/dist/utils/encoding.d.ts +4 -6
- package/dist/utils/encoding.js +1 -1
- package/dist/utils/encoding.js.map +1 -1
- package/dist/utils/encoding.test.d.ts +1 -0
- package/dist/utils/encryption.cjs +16 -10
- package/dist/utils/encryption.cjs.map +1 -1
- package/dist/utils/encryption.d.ts +13 -17
- package/dist/utils/encryption.js +16 -10
- package/dist/utils/encryption.js.map +1 -1
- package/dist/utils/formatters.cjs +4 -2
- package/dist/utils/formatters.cjs.map +1 -1
- package/dist/utils/formatters.d.ts +4 -6
- package/dist/utils/formatters.js +4 -2
- package/dist/utils/formatters.js.map +1 -1
- package/dist/utils/grantFiles.cjs +7 -4
- package/dist/utils/grantFiles.cjs.map +1 -1
- package/dist/utils/grantFiles.d.ts +6 -10
- package/dist/utils/grantFiles.js +7 -4
- package/dist/utils/grantFiles.js.map +1 -1
- package/dist/utils/grantValidation.cjs +1 -1
- package/dist/utils/grantValidation.cjs.map +1 -1
- package/dist/utils/grantValidation.d.ts +14 -17
- package/dist/utils/grantValidation.js +1 -1
- package/dist/utils/grantValidation.js.map +1 -1
- package/dist/utils/grants.cjs +1 -1
- package/dist/utils/grants.cjs.map +1 -1
- package/dist/utils/grants.d.ts +10 -13
- package/dist/utils/grants.js +1 -1
- package/dist/utils/grants.js.map +1 -1
- package/dist/utils/ipfs.d.ts +8 -10
- package/dist/utils/lazy-import.cjs +4 -6
- package/dist/utils/lazy-import.cjs.map +1 -1
- package/dist/utils/lazy-import.d.ts +1 -3
- package/dist/utils/lazy-import.js +4 -6
- package/dist/utils/lazy-import.js.map +1 -1
- package/dist/utils/multicall.cjs +4 -2
- package/dist/utils/multicall.cjs.map +1 -1
- package/dist/utils/multicall.d.ts +5 -8
- package/dist/utils/multicall.js +4 -2
- package/dist/utils/multicall.js.map +1 -1
- package/dist/utils/parseTransactionPojo.cjs +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 +1 -2
- package/dist/utils/signatureCache.cjs.map +1 -1
- package/dist/utils/signatureCache.d.ts +4 -7
- package/dist/utils/signatureCache.js +4 -8
- package/dist/utils/signatureCache.js.map +1 -1
- package/dist/utils/signatureFormatter.cjs +6 -9
- package/dist/utils/signatureFormatter.cjs.map +1 -1
- package/dist/utils/signatureFormatter.d.ts +2 -5
- package/dist/utils/signatureFormatter.js +6 -9
- package/dist/utils/signatureFormatter.js.map +1 -1
- package/dist/utils/tests/multicall.test.d.ts +1 -0
- package/dist/utils/transactionHelpers.cjs +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.d.ts +3 -6
- package/dist/utils/urlResolver.cjs +1 -1
- package/dist/utils/urlResolver.cjs.map +1 -1
- package/dist/utils/urlResolver.d.ts +2 -4
- package/dist/utils/urlResolver.js +2 -2
- package/dist/utils/urlResolver.js.map +1 -1
- package/dist/utils/wallet.cjs +63 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +32 -0
- package/dist/utils/wallet.js +37 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/{chains.browser.cjs → utils/withEvents.cjs} +22 -15
- 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 +23 -14
- 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/test-vectors/eccrypto-vectors.d.cts +0 -76
- package/dist/crypto/ecies/test-vectors/eccrypto-vectors.d.ts +0 -76
- package/dist/crypto/ecies/utils.d.cts +0 -67
- package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
- package/dist/diagnostics.d.cts +0 -26
- package/dist/errors.d.cts +0 -350
- package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
- package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
- package/dist/generated/abi/DATImplementation.d.cts +0 -693
- package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
- package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
- package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
- package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
- package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
- package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
- package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
- package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -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/schemas/dataSchema.schema.d.cts +0 -88
- package/dist/schemas/dataSchema.schema.d.ts +0 -88
- package/dist/schemas/grantFile.schema.d.cts +0 -57
- package/dist/schemas/grantFile.schema.d.ts +0 -57
- package/dist/server/handler.d.cts +0 -282
- 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
|
@@ -18,9 +18,10 @@ import { validateGrant } from "../utils/grantValidation";
|
|
|
18
18
|
import { withSignatureCache } from "../utils/signatureCache";
|
|
19
19
|
import { formatSignatureForContract } from "../utils/signatureFormatter";
|
|
20
20
|
import { toViemTypedDataDefinition } from "../utils/typedDataConverter";
|
|
21
|
-
|
|
21
|
+
import { BaseController } from "./base";
|
|
22
|
+
class PermissionsController extends BaseController {
|
|
22
23
|
constructor(context) {
|
|
23
|
-
|
|
24
|
+
super(context);
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Grants permission for an application to access user data with gasless transactions.
|
|
@@ -57,7 +58,10 @@ class PermissionsController {
|
|
|
57
58
|
* ```
|
|
58
59
|
*/
|
|
59
60
|
async grant(params) {
|
|
60
|
-
|
|
61
|
+
this.assertWallet();
|
|
62
|
+
const { typedData, signature } = await this.createAndSign(params);
|
|
63
|
+
const result = await this.submitSignedGrantWithEvents(typedData, signature);
|
|
64
|
+
return result;
|
|
61
65
|
}
|
|
62
66
|
/**
|
|
63
67
|
* Submits a permission grant transaction and returns a handle for flexible result access.
|
|
@@ -85,6 +89,7 @@ class PermissionsController {
|
|
|
85
89
|
* ```
|
|
86
90
|
*/
|
|
87
91
|
async submitPermissionGrant(params) {
|
|
92
|
+
this.assertWallet();
|
|
88
93
|
const { typedData, signature } = await this.createAndSign(params);
|
|
89
94
|
return await this.submitSignedGrant(typedData, signature);
|
|
90
95
|
}
|
|
@@ -114,13 +119,14 @@ class PermissionsController {
|
|
|
114
119
|
* ```
|
|
115
120
|
*/
|
|
116
121
|
async prepareGrant(params) {
|
|
122
|
+
this.assertWallet();
|
|
117
123
|
try {
|
|
118
124
|
const grantFile = createGrantFile(params);
|
|
119
125
|
validateGrant(grantFile);
|
|
120
126
|
return {
|
|
121
127
|
preview: grantFile,
|
|
122
128
|
confirm: async () => {
|
|
123
|
-
return await this.
|
|
129
|
+
return await this.confirmGrantInternalWithEvents(params, grantFile);
|
|
124
130
|
}
|
|
125
131
|
};
|
|
126
132
|
} catch (error) {
|
|
@@ -154,20 +160,34 @@ class PermissionsController {
|
|
|
154
160
|
*/
|
|
155
161
|
async confirmGrantInternal(params, grantFile) {
|
|
156
162
|
try {
|
|
157
|
-
let grantUrl = params
|
|
163
|
+
let { grantUrl } = params;
|
|
158
164
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
159
165
|
if (!grantUrl) {
|
|
160
|
-
|
|
166
|
+
const canStoreViaRelayer = this.context.relayer !== void 0;
|
|
167
|
+
if (!canStoreViaRelayer && !this.context.storageManager) {
|
|
161
168
|
if (this.context.validateStorageRequired) {
|
|
162
169
|
this.context.validateStorageRequired();
|
|
163
170
|
} else {
|
|
164
171
|
throw new Error(
|
|
165
|
-
"No storage available. Provide a grantUrl, configure
|
|
172
|
+
"No storage available. Provide a grantUrl, configure relayer, or storageManager."
|
|
166
173
|
);
|
|
167
174
|
}
|
|
168
175
|
}
|
|
169
|
-
if (this.context.
|
|
170
|
-
|
|
176
|
+
if (canStoreViaRelayer && this.context.relayer) {
|
|
177
|
+
const request = {
|
|
178
|
+
type: "direct",
|
|
179
|
+
operation: "storeGrantFile",
|
|
180
|
+
params: grantFile
|
|
181
|
+
};
|
|
182
|
+
const response = await this.context.relayer(request);
|
|
183
|
+
if (response.type === "error") {
|
|
184
|
+
throw new Error(response.error);
|
|
185
|
+
}
|
|
186
|
+
if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
|
|
187
|
+
grantUrl = response.result.url;
|
|
188
|
+
} else {
|
|
189
|
+
throw new Error("Invalid response from relayer for grant storage");
|
|
190
|
+
}
|
|
171
191
|
} else if (this.context.storageManager) {
|
|
172
192
|
const blob = new Blob([JSON.stringify(grantFile)], {
|
|
173
193
|
type: "application/json"
|
|
@@ -244,23 +264,38 @@ class PermissionsController {
|
|
|
244
264
|
* ```
|
|
245
265
|
*/
|
|
246
266
|
async createAndSign(params) {
|
|
267
|
+
this.assertWallet();
|
|
247
268
|
try {
|
|
248
269
|
const grantFile = createGrantFile(params);
|
|
249
270
|
validateGrant(grantFile);
|
|
250
|
-
let grantUrl = params
|
|
271
|
+
let { grantUrl } = params;
|
|
251
272
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
252
273
|
if (!grantUrl) {
|
|
253
|
-
|
|
274
|
+
const canStoreViaRelayer = this.context.relayer !== void 0;
|
|
275
|
+
if (!canStoreViaRelayer && !this.context.storageManager) {
|
|
254
276
|
if (this.context.validateStorageRequired) {
|
|
255
277
|
this.context.validateStorageRequired();
|
|
256
278
|
} else {
|
|
257
279
|
throw new Error(
|
|
258
|
-
"No storage available. Provide a grantUrl, configure
|
|
280
|
+
"No storage available. Provide a grantUrl, configure relayer, or storageManager."
|
|
259
281
|
);
|
|
260
282
|
}
|
|
261
283
|
}
|
|
262
|
-
if (this.context.
|
|
263
|
-
|
|
284
|
+
if (canStoreViaRelayer && this.context.relayer) {
|
|
285
|
+
const request = {
|
|
286
|
+
type: "direct",
|
|
287
|
+
operation: "storeGrantFile",
|
|
288
|
+
params: grantFile
|
|
289
|
+
};
|
|
290
|
+
const response = await this.context.relayer(request);
|
|
291
|
+
if (response.type === "error") {
|
|
292
|
+
throw new Error(response.error);
|
|
293
|
+
}
|
|
294
|
+
if (response.type === "direct" && typeof response.result === "object" && "url" in response.result) {
|
|
295
|
+
grantUrl = response.result.url;
|
|
296
|
+
} else {
|
|
297
|
+
throw new Error("Invalid response from relayer for grant storage");
|
|
298
|
+
}
|
|
264
299
|
} else if (this.context.storageManager) {
|
|
265
300
|
const blob = new Blob([JSON.stringify(grantFile)], {
|
|
266
301
|
type: "application/json"
|
|
@@ -335,23 +370,39 @@ class PermissionsController {
|
|
|
335
370
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
336
371
|
JSON.stringify(
|
|
337
372
|
typedData,
|
|
338
|
-
(
|
|
373
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
339
374
|
2
|
|
340
375
|
)
|
|
341
376
|
);
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
377
|
+
if (this.context.relayer) {
|
|
378
|
+
const response = await this.context.relayer({
|
|
379
|
+
type: "signed",
|
|
380
|
+
operation: "submitAddPermission",
|
|
345
381
|
typedData,
|
|
346
|
-
signature
|
|
347
|
-
|
|
382
|
+
signature,
|
|
383
|
+
expectedUserAddress: this.context.userAddress
|
|
384
|
+
});
|
|
385
|
+
let hash;
|
|
386
|
+
if (response.type === "signed") {
|
|
387
|
+
hash = response.hash;
|
|
388
|
+
} else if (response.type === "error") {
|
|
389
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
390
|
+
} else {
|
|
391
|
+
throw new Error(
|
|
392
|
+
"Invalid response from relayer: expected signed transaction"
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
396
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
397
|
+
return tx({
|
|
398
|
+
hash,
|
|
399
|
+
from: typeof account === "string" ? account : account.address,
|
|
400
|
+
contract: "DataPortabilityPermissions",
|
|
401
|
+
fn: "addPermission"
|
|
402
|
+
});
|
|
348
403
|
} else {
|
|
349
|
-
|
|
404
|
+
return await this.submitDirectTransaction(typedData, signature);
|
|
350
405
|
}
|
|
351
|
-
return {
|
|
352
|
-
hash,
|
|
353
|
-
from: this.context.walletClient.account?.address
|
|
354
|
-
};
|
|
355
406
|
} catch (error) {
|
|
356
407
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
357
408
|
throw error;
|
|
@@ -393,10 +444,14 @@ class PermissionsController {
|
|
|
393
444
|
trustServerInput,
|
|
394
445
|
signature
|
|
395
446
|
);
|
|
396
|
-
|
|
447
|
+
const account = this.context.userAddress;
|
|
448
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
449
|
+
return tx({
|
|
397
450
|
hash,
|
|
398
|
-
from:
|
|
399
|
-
|
|
451
|
+
from: account,
|
|
452
|
+
contract: "DataPortabilityServers",
|
|
453
|
+
fn: "trustServerWithSignature"
|
|
454
|
+
});
|
|
400
455
|
} catch (error) {
|
|
401
456
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
402
457
|
throw error;
|
|
@@ -454,10 +509,14 @@ class PermissionsController {
|
|
|
454
509
|
addAndTrustServerInput,
|
|
455
510
|
signature
|
|
456
511
|
);
|
|
457
|
-
|
|
512
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
513
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
514
|
+
return tx({
|
|
458
515
|
hash,
|
|
459
|
-
from:
|
|
460
|
-
|
|
516
|
+
from: typeof account === "string" ? account : account.address,
|
|
517
|
+
contract: "DataPortabilityServers",
|
|
518
|
+
fn: "addAndTrustServerWithSignature"
|
|
519
|
+
});
|
|
461
520
|
} catch (error) {
|
|
462
521
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
463
522
|
throw error;
|
|
@@ -468,6 +527,72 @@ class PermissionsController {
|
|
|
468
527
|
);
|
|
469
528
|
}
|
|
470
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Internal method to submit a signed grant and wait for events.
|
|
532
|
+
*
|
|
533
|
+
* @internal
|
|
534
|
+
* @param typedData - The EIP-712 typed data for the permission grant
|
|
535
|
+
* @param signature - The user's signature authorizing the transaction
|
|
536
|
+
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
537
|
+
*/
|
|
538
|
+
async submitSignedGrantWithEvents(typedData, signature) {
|
|
539
|
+
const txResult = await this.submitSignedGrant(typedData, signature);
|
|
540
|
+
if (!this.context.waitForTransactionEvents) {
|
|
541
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
542
|
+
}
|
|
543
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
544
|
+
const event = result.expectedEvents.PermissionAdded;
|
|
545
|
+
if (!event) {
|
|
546
|
+
throw new BlockchainError(
|
|
547
|
+
"PermissionAdded event not found in transaction"
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
551
|
+
hash: result.hash
|
|
552
|
+
});
|
|
553
|
+
return {
|
|
554
|
+
transactionHash: result.hash,
|
|
555
|
+
blockNumber: receipt.blockNumber,
|
|
556
|
+
gasUsed: receipt.gasUsed,
|
|
557
|
+
permissionId: event.permissionId,
|
|
558
|
+
user: event.user,
|
|
559
|
+
grant: event.grant,
|
|
560
|
+
fileIds: event.fileIds
|
|
561
|
+
};
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Internal method for confirm grant with events.
|
|
565
|
+
*
|
|
566
|
+
* @internal
|
|
567
|
+
* @param params - The permission grant parameters
|
|
568
|
+
* @param grantFile - The pre-created grant file object
|
|
569
|
+
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
570
|
+
*/
|
|
571
|
+
async confirmGrantInternalWithEvents(params, grantFile) {
|
|
572
|
+
const txResult = await this.confirmGrantInternal(params, grantFile);
|
|
573
|
+
if (!this.context.waitForTransactionEvents) {
|
|
574
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
575
|
+
}
|
|
576
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
577
|
+
const event = result.expectedEvents.PermissionAdded;
|
|
578
|
+
if (!event) {
|
|
579
|
+
throw new BlockchainError(
|
|
580
|
+
"PermissionAdded event not found in transaction"
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
584
|
+
hash: result.hash
|
|
585
|
+
});
|
|
586
|
+
return {
|
|
587
|
+
transactionHash: result.hash,
|
|
588
|
+
blockNumber: receipt.blockNumber,
|
|
589
|
+
gasUsed: receipt.gasUsed,
|
|
590
|
+
permissionId: event.permissionId,
|
|
591
|
+
user: event.user,
|
|
592
|
+
grant: event.grant,
|
|
593
|
+
fileIds: event.fileIds
|
|
594
|
+
};
|
|
595
|
+
}
|
|
471
596
|
/**
|
|
472
597
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
473
598
|
*
|
|
@@ -492,18 +617,37 @@ class PermissionsController {
|
|
|
492
617
|
async submitSignedRevoke(typedData, signature) {
|
|
493
618
|
try {
|
|
494
619
|
let hash;
|
|
495
|
-
if (this.context.
|
|
496
|
-
|
|
620
|
+
if (this.context.relayer) {
|
|
621
|
+
const response = await this.context.relayer({
|
|
622
|
+
type: "signed",
|
|
623
|
+
operation: "submitPermissionRevoke",
|
|
624
|
+
typedData,
|
|
625
|
+
signature,
|
|
626
|
+
expectedUserAddress: this.context.userAddress
|
|
627
|
+
});
|
|
628
|
+
if (response.type === "signed") {
|
|
629
|
+
hash = response.hash;
|
|
630
|
+
} else if (response.type === "error") {
|
|
631
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
632
|
+
} else {
|
|
633
|
+
throw new Error(
|
|
634
|
+
"Invalid response from relayer: expected signed transaction"
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
} else {
|
|
638
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
497
639
|
typedData,
|
|
498
640
|
signature
|
|
499
641
|
);
|
|
500
|
-
} else {
|
|
501
|
-
hash = await this.submitDirectRevokeTransaction(typedData, signature);
|
|
502
642
|
}
|
|
503
|
-
|
|
643
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
644
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
645
|
+
return tx({
|
|
504
646
|
hash,
|
|
505
|
-
from:
|
|
506
|
-
|
|
647
|
+
from: typeof account === "string" ? account : account.address,
|
|
648
|
+
contract: "DataPortabilityPermissions",
|
|
649
|
+
fn: "revokePermissionWithSignature"
|
|
650
|
+
});
|
|
507
651
|
} catch (error) {
|
|
508
652
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
509
653
|
throw error;
|
|
@@ -538,18 +682,37 @@ class PermissionsController {
|
|
|
538
682
|
async submitSignedUntrustServer(typedData, signature) {
|
|
539
683
|
try {
|
|
540
684
|
let hash;
|
|
541
|
-
if (this.context.
|
|
542
|
-
|
|
685
|
+
if (this.context.relayer) {
|
|
686
|
+
const response = await this.context.relayer({
|
|
687
|
+
type: "signed",
|
|
688
|
+
operation: "submitUntrustServer",
|
|
689
|
+
typedData,
|
|
690
|
+
signature,
|
|
691
|
+
expectedUserAddress: this.context.userAddress
|
|
692
|
+
});
|
|
693
|
+
if (response.type === "signed") {
|
|
694
|
+
hash = response.hash;
|
|
695
|
+
} else if (response.type === "error") {
|
|
696
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
697
|
+
} else {
|
|
698
|
+
throw new Error(
|
|
699
|
+
"Invalid response from relayer: expected signed transaction"
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
} else {
|
|
703
|
+
hash = await this.submitSignedUntrustTransaction(
|
|
543
704
|
typedData,
|
|
544
705
|
signature
|
|
545
706
|
);
|
|
546
|
-
} else {
|
|
547
|
-
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
548
707
|
}
|
|
549
|
-
|
|
708
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
709
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
710
|
+
return tx({
|
|
550
711
|
hash,
|
|
551
|
-
from:
|
|
552
|
-
|
|
712
|
+
from: typeof account === "string" ? account : account.address,
|
|
713
|
+
contract: "DataPortabilityServers",
|
|
714
|
+
fn: "untrustServerWithSignature"
|
|
715
|
+
});
|
|
553
716
|
} catch (error) {
|
|
554
717
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
555
718
|
throw error;
|
|
@@ -573,7 +736,8 @@ class PermissionsController {
|
|
|
573
736
|
* @throws {BlockchainError} When contract submission fails
|
|
574
737
|
*/
|
|
575
738
|
async submitDirectTransaction(typedData, signature) {
|
|
576
|
-
|
|
739
|
+
this.assertWallet();
|
|
740
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
577
741
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
578
742
|
chainId,
|
|
579
743
|
"DataPortabilityPermissions"
|
|
@@ -593,18 +757,25 @@ class PermissionsController {
|
|
|
593
757
|
console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
|
|
594
758
|
console.debug(
|
|
595
759
|
"\u{1F50D} Debug - Grant field length:",
|
|
596
|
-
typedData.message.grant?.length
|
|
760
|
+
typedData.message.grant?.length ?? 0
|
|
597
761
|
);
|
|
598
762
|
const formattedSignature = formatSignatureForContract(signature);
|
|
763
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
599
764
|
const txHash = await this.context.walletClient.writeContract({
|
|
600
765
|
address: DataPortabilityPermissionsAddress,
|
|
601
766
|
abi: DataPortabilityPermissionsAbi,
|
|
602
767
|
functionName: "addPermission",
|
|
603
768
|
args: [permissionInput, formattedSignature],
|
|
604
|
-
account
|
|
605
|
-
chain: this.context.walletClient
|
|
769
|
+
account,
|
|
770
|
+
chain: this.context.walletClient?.chain ?? null
|
|
771
|
+
});
|
|
772
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
773
|
+
return tx({
|
|
774
|
+
hash: txHash,
|
|
775
|
+
from: typeof account === "string" ? account : account.address,
|
|
776
|
+
contract: "DataPortabilityPermissions",
|
|
777
|
+
fn: "addPermission"
|
|
606
778
|
});
|
|
607
|
-
return txHash;
|
|
608
779
|
}
|
|
609
780
|
/**
|
|
610
781
|
* Revokes a previously granted permission.
|
|
@@ -631,7 +802,27 @@ class PermissionsController {
|
|
|
631
802
|
* ```
|
|
632
803
|
*/
|
|
633
804
|
async revoke(params) {
|
|
634
|
-
|
|
805
|
+
this.assertWallet();
|
|
806
|
+
const txResult = await this.submitPermissionRevoke(params);
|
|
807
|
+
if (!this.context.waitForTransactionEvents) {
|
|
808
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
809
|
+
}
|
|
810
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
811
|
+
const event = result.expectedEvents.PermissionRevoked;
|
|
812
|
+
if (!event) {
|
|
813
|
+
throw new BlockchainError(
|
|
814
|
+
"PermissionRevoked event not found in transaction"
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
818
|
+
hash: result.hash
|
|
819
|
+
});
|
|
820
|
+
return {
|
|
821
|
+
transactionHash: result.hash,
|
|
822
|
+
blockNumber: receipt.blockNumber,
|
|
823
|
+
gasUsed: receipt.gasUsed,
|
|
824
|
+
permissionId: event.permissionId
|
|
825
|
+
};
|
|
635
826
|
}
|
|
636
827
|
/**
|
|
637
828
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
@@ -653,11 +844,12 @@ class PermissionsController {
|
|
|
653
844
|
* ```
|
|
654
845
|
*/
|
|
655
846
|
async submitPermissionRevoke(params) {
|
|
847
|
+
this.assertWallet();
|
|
656
848
|
try {
|
|
657
|
-
if (!this.context.walletClient
|
|
849
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
658
850
|
throw new BlockchainError("Chain ID not available");
|
|
659
851
|
}
|
|
660
|
-
const chainId = await this.context.
|
|
852
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
661
853
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
662
854
|
chainId,
|
|
663
855
|
"DataPortabilityPermissions"
|
|
@@ -665,18 +857,22 @@ class PermissionsController {
|
|
|
665
857
|
const DataPortabilityPermissionsAbi = getAbi(
|
|
666
858
|
"DataPortabilityPermissions"
|
|
667
859
|
);
|
|
860
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
668
861
|
const txHash = await this.context.walletClient.writeContract({
|
|
669
862
|
address: DataPortabilityPermissionsAddress,
|
|
670
863
|
abi: DataPortabilityPermissionsAbi,
|
|
671
864
|
functionName: "revokePermission",
|
|
672
865
|
args: [params.permissionId],
|
|
673
|
-
account
|
|
674
|
-
chain: this.context.walletClient
|
|
866
|
+
account,
|
|
867
|
+
chain: this.context.walletClient?.chain ?? null
|
|
675
868
|
});
|
|
676
|
-
|
|
869
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
870
|
+
return tx({
|
|
677
871
|
hash: txHash,
|
|
678
|
-
from:
|
|
679
|
-
|
|
872
|
+
from: typeof account === "string" ? account : account.address,
|
|
873
|
+
contract: "DataPortabilityPermissions",
|
|
874
|
+
fn: "revokePermission"
|
|
875
|
+
});
|
|
680
876
|
} catch (error) {
|
|
681
877
|
if (error instanceof Error) {
|
|
682
878
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -716,8 +912,9 @@ class PermissionsController {
|
|
|
716
912
|
* ```
|
|
717
913
|
*/
|
|
718
914
|
async submitRevokeWithSignature(params) {
|
|
915
|
+
this.assertWallet();
|
|
719
916
|
try {
|
|
720
|
-
if (!this.context.walletClient
|
|
917
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
721
918
|
throw new BlockchainError("Chain ID not available");
|
|
722
919
|
}
|
|
723
920
|
const nonce = await this.getPermissionsUserNonce();
|
|
@@ -738,18 +935,37 @@ class PermissionsController {
|
|
|
738
935
|
};
|
|
739
936
|
const signature = await this.signTypedData(typedData);
|
|
740
937
|
let hash;
|
|
741
|
-
if (this.context.
|
|
742
|
-
|
|
938
|
+
if (this.context.relayer) {
|
|
939
|
+
const response = await this.context.relayer({
|
|
940
|
+
type: "signed",
|
|
941
|
+
operation: "submitPermissionRevoke",
|
|
942
|
+
typedData,
|
|
943
|
+
signature,
|
|
944
|
+
expectedUserAddress: this.context.userAddress
|
|
945
|
+
});
|
|
946
|
+
if (response.type === "signed") {
|
|
947
|
+
hash = response.hash;
|
|
948
|
+
} else if (response.type === "error") {
|
|
949
|
+
throw new Error(`Relayer error: ${response.error}`);
|
|
950
|
+
} else {
|
|
951
|
+
throw new Error(
|
|
952
|
+
"Invalid response from relayer: expected signed transaction"
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
} else {
|
|
956
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
743
957
|
typedData,
|
|
744
958
|
signature
|
|
745
959
|
);
|
|
746
|
-
} else {
|
|
747
|
-
hash = await this.submitDirectRevokeTransaction(typedData, signature);
|
|
748
960
|
}
|
|
749
|
-
|
|
961
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
962
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
963
|
+
return tx({
|
|
750
964
|
hash,
|
|
751
|
-
from:
|
|
752
|
-
|
|
965
|
+
from: typeof account === "string" ? account : account.address,
|
|
966
|
+
contract: "DataPortabilityPermissions",
|
|
967
|
+
fn: "revokePermissionWithSignature"
|
|
968
|
+
});
|
|
753
969
|
} catch (error) {
|
|
754
970
|
throw new PermissionError(
|
|
755
971
|
`Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -757,64 +973,6 @@ class PermissionsController {
|
|
|
757
973
|
);
|
|
758
974
|
}
|
|
759
975
|
}
|
|
760
|
-
/**
|
|
761
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
762
|
-
*
|
|
763
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
764
|
-
* This method is deprecated in favor of more specific nonce methods.
|
|
765
|
-
*
|
|
766
|
-
* The nonce is used to prevent replay attacks in signed transactions and must
|
|
767
|
-
* be incremented with each transaction to maintain security.
|
|
768
|
-
*
|
|
769
|
-
* @returns Promise resolving to the user's current nonce value as a bigint
|
|
770
|
-
* @throws {Error} When wallet account is not available
|
|
771
|
-
* @throws {Error} When chain ID is not available
|
|
772
|
-
* @throws {NonceError} When reading nonce from contract fails
|
|
773
|
-
* @private
|
|
774
|
-
* @example
|
|
775
|
-
* ```typescript
|
|
776
|
-
* // Deprecated - use specific methods instead
|
|
777
|
-
* const nonce = await this.getUserNonce();
|
|
778
|
-
*
|
|
779
|
-
* // Use these instead:
|
|
780
|
-
* const permissionsNonce = await this.getPermissionsUserNonce();
|
|
781
|
-
* const serversNonce = await this.getServersUserNonce();
|
|
782
|
-
* ```
|
|
783
|
-
*/
|
|
784
|
-
/**
|
|
785
|
-
* @deprecated Use getPermissionsUserNonce() for permission operations or getServersUserNonce() for server operations
|
|
786
|
-
*
|
|
787
|
-
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
788
|
-
*
|
|
789
|
-
* @remarks
|
|
790
|
-
* This method is deprecated in favor of more specific nonce methods that target
|
|
791
|
-
* the appropriate contract for the operation being performed.
|
|
792
|
-
*
|
|
793
|
-
* @returns Promise resolving to the user's current nonce as a bigint
|
|
794
|
-
* @throws {NonceError} When retrieving the nonce fails
|
|
795
|
-
*/
|
|
796
|
-
async getUserNonce() {
|
|
797
|
-
try {
|
|
798
|
-
const userAddress = await this.getUserAddress();
|
|
799
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
800
|
-
const DataPortabilityServersAddress = getContractAddress(
|
|
801
|
-
chainId,
|
|
802
|
-
"DataPortabilityServers"
|
|
803
|
-
);
|
|
804
|
-
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
805
|
-
const nonce = await this.context.publicClient.readContract({
|
|
806
|
-
address: DataPortabilityServersAddress,
|
|
807
|
-
abi: DataPortabilityServersAbi,
|
|
808
|
-
functionName: "userNonce",
|
|
809
|
-
args: [userAddress]
|
|
810
|
-
});
|
|
811
|
-
return nonce;
|
|
812
|
-
} catch (error) {
|
|
813
|
-
throw new NonceError(
|
|
814
|
-
`Failed to retrieve user nonce: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
815
|
-
);
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
976
|
/**
|
|
819
977
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
820
978
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
@@ -841,8 +999,8 @@ class PermissionsController {
|
|
|
841
999
|
*/
|
|
842
1000
|
async getServersUserNonce() {
|
|
843
1001
|
try {
|
|
844
|
-
const userAddress =
|
|
845
|
-
const chainId = await this.context.
|
|
1002
|
+
const userAddress = this.context.userAddress;
|
|
1003
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
846
1004
|
const DataPortabilityServersAddress = getContractAddress(
|
|
847
1005
|
chainId,
|
|
848
1006
|
"DataPortabilityServers"
|
|
@@ -887,8 +1045,8 @@ class PermissionsController {
|
|
|
887
1045
|
*/
|
|
888
1046
|
async getPermissionsUserNonce() {
|
|
889
1047
|
try {
|
|
890
|
-
const userAddress =
|
|
891
|
-
const chainId = await this.context.
|
|
1048
|
+
const userAddress = this.context.userAddress;
|
|
1049
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
892
1050
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
893
1051
|
chainId,
|
|
894
1052
|
"DataPortabilityPermissions"
|
|
@@ -927,7 +1085,7 @@ class PermissionsController {
|
|
|
927
1085
|
"\u{1F50D} Debug - Composing permission message with grantUrl:",
|
|
928
1086
|
params.grantUrl
|
|
929
1087
|
);
|
|
930
|
-
const chainId = await this.context.
|
|
1088
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
931
1089
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
932
1090
|
chainId,
|
|
933
1091
|
"DataPortabilityGrantees"
|
|
@@ -1036,7 +1194,7 @@ class PermissionsController {
|
|
|
1036
1194
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1037
1195
|
*/
|
|
1038
1196
|
async getPermissionDomain() {
|
|
1039
|
-
const chainId = await this.context.
|
|
1197
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1040
1198
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
1041
1199
|
chainId,
|
|
1042
1200
|
"DataPortabilityPermissions"
|
|
@@ -1055,8 +1213,9 @@ class PermissionsController {
|
|
|
1055
1213
|
* @returns Promise resolving to the cryptographic signature
|
|
1056
1214
|
*/
|
|
1057
1215
|
async signTypedData(typedData) {
|
|
1216
|
+
this.assertWallet();
|
|
1058
1217
|
try {
|
|
1059
|
-
const walletAddress = this.context.walletClient.account?.address
|
|
1218
|
+
const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
|
|
1060
1219
|
return await withSignatureCache(
|
|
1061
1220
|
this.context.platform.cache,
|
|
1062
1221
|
walletAddress,
|
|
@@ -1065,9 +1224,9 @@ class PermissionsController {
|
|
|
1065
1224
|
const viemCompatibleTypedData = toViemTypedDataDefinition(typedData);
|
|
1066
1225
|
return await this.context.walletClient.signTypedData({
|
|
1067
1226
|
...viemCompatibleTypedData,
|
|
1068
|
-
//
|
|
1069
|
-
//
|
|
1070
|
-
account: this.context.walletClient.account
|
|
1227
|
+
// Use the account if available, otherwise use the wallet address
|
|
1228
|
+
// This follows the same pattern used throughout this file
|
|
1229
|
+
account: this.context.walletClient.account ?? walletAddress
|
|
1071
1230
|
});
|
|
1072
1231
|
}
|
|
1073
1232
|
);
|
|
@@ -1082,17 +1241,10 @@ class PermissionsController {
|
|
|
1082
1241
|
}
|
|
1083
1242
|
}
|
|
1084
1243
|
/**
|
|
1085
|
-
* Gets the user's address from the
|
|
1244
|
+
* Gets the user's address from the context.
|
|
1086
1245
|
*
|
|
1087
|
-
* @returns
|
|
1246
|
+
* @returns The user's address
|
|
1088
1247
|
*/
|
|
1089
|
-
async getUserAddress() {
|
|
1090
|
-
const addresses = await this.context.walletClient.getAddresses();
|
|
1091
|
-
if (addresses.length === 0) {
|
|
1092
|
-
throw new BlockchainError("No addresses available in wallet client");
|
|
1093
|
-
}
|
|
1094
|
-
return addresses[0];
|
|
1095
|
-
}
|
|
1096
1248
|
/**
|
|
1097
1249
|
* Gets on-chain permission grant data without expensive off-chain resolution.
|
|
1098
1250
|
*
|
|
@@ -1131,8 +1283,8 @@ class PermissionsController {
|
|
|
1131
1283
|
async getUserPermissionGrantsOnChain(options = {}) {
|
|
1132
1284
|
const { limit = 50, subgraphUrl } = options;
|
|
1133
1285
|
try {
|
|
1134
|
-
const userAddress =
|
|
1135
|
-
const graphqlEndpoint = subgraphUrl
|
|
1286
|
+
const userAddress = this.context.userAddress;
|
|
1287
|
+
const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
1136
1288
|
if (!graphqlEndpoint) {
|
|
1137
1289
|
throw new BlockchainError(
|
|
1138
1290
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
@@ -1184,7 +1336,7 @@ class PermissionsController {
|
|
|
1184
1336
|
);
|
|
1185
1337
|
}
|
|
1186
1338
|
const userData = result.data?.user;
|
|
1187
|
-
if (!userData
|
|
1339
|
+
if (!userData?.permissions?.length) {
|
|
1188
1340
|
return [];
|
|
1189
1341
|
}
|
|
1190
1342
|
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
@@ -1195,8 +1347,8 @@ class PermissionsController {
|
|
|
1195
1347
|
nonce: BigInt(permission.nonce),
|
|
1196
1348
|
startBlock: BigInt(permission.startBlock),
|
|
1197
1349
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
1198
|
-
addedAtTimestamp: BigInt(permission.addedAtTimestamp
|
|
1199
|
-
transactionHash: permission.transactionHash
|
|
1350
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
|
|
1351
|
+
transactionHash: permission.transactionHash ?? "",
|
|
1200
1352
|
grantor: userAddress,
|
|
1201
1353
|
grantee: permission.grantee,
|
|
1202
1354
|
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
@@ -1217,26 +1369,6 @@ class PermissionsController {
|
|
|
1217
1369
|
);
|
|
1218
1370
|
}
|
|
1219
1371
|
}
|
|
1220
|
-
/**
|
|
1221
|
-
* Normalizes grant ID to hex format.
|
|
1222
|
-
* Handles conversion from permission ID (bigint/number/string) to proper hex hash format.
|
|
1223
|
-
*
|
|
1224
|
-
* @param grantId - Permission ID or grant hash in various formats
|
|
1225
|
-
* @returns Normalized hex hash
|
|
1226
|
-
*/
|
|
1227
|
-
normalizeGrantId(grantId) {
|
|
1228
|
-
if (typeof grantId === "string" && grantId.startsWith("0x") && grantId.length === 66) {
|
|
1229
|
-
return grantId;
|
|
1230
|
-
}
|
|
1231
|
-
try {
|
|
1232
|
-
const bigIntId = BigInt(grantId);
|
|
1233
|
-
return `0x${bigIntId.toString(16).padStart(64, "0")}`;
|
|
1234
|
-
} catch {
|
|
1235
|
-
throw new Error(
|
|
1236
|
-
`Invalid grant ID format: ${grantId}. Must be a permission ID (number/bigint/string) or a 32-byte hex hash.`
|
|
1237
|
-
);
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
1372
|
/**
|
|
1241
1373
|
* Registers a new server and immediately trusts it in the DataPortabilityServers contract.
|
|
1242
1374
|
*
|
|
@@ -1245,7 +1377,6 @@ class PermissionsController {
|
|
|
1245
1377
|
* Trusted servers can handle data export and portability requests from the user.
|
|
1246
1378
|
*
|
|
1247
1379
|
* @param params - Parameters for adding and trusting the server
|
|
1248
|
-
* @param params.owner - Ethereum address that will own this server registration
|
|
1249
1380
|
* @param params.serverAddress - Ethereum address of the server
|
|
1250
1381
|
* @param params.serverUrl - HTTPS URL where the server can be reached
|
|
1251
1382
|
* @param params.publicKey - Server's public key for encryption (hex string)
|
|
@@ -1272,6 +1403,7 @@ class PermissionsController {
|
|
|
1272
1403
|
* ```
|
|
1273
1404
|
*/
|
|
1274
1405
|
async addAndTrustServer(params) {
|
|
1406
|
+
this.assertWallet();
|
|
1275
1407
|
try {
|
|
1276
1408
|
const chainId = await this.context.walletClient.getChainId();
|
|
1277
1409
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1279,7 +1411,8 @@ class PermissionsController {
|
|
|
1279
1411
|
"DataPortabilityServers"
|
|
1280
1412
|
);
|
|
1281
1413
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1282
|
-
const
|
|
1414
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1415
|
+
const userAddress = typeof account === "string" ? account : account.address;
|
|
1283
1416
|
const normalizedUserAddress = getAddress(userAddress);
|
|
1284
1417
|
const normalizedServerAddress = getAddress(params.serverAddress);
|
|
1285
1418
|
const txHash = await this.context.walletClient.writeContract({
|
|
@@ -1294,12 +1427,40 @@ class PermissionsController {
|
|
|
1294
1427
|
publicKey: params.publicKey
|
|
1295
1428
|
}
|
|
1296
1429
|
],
|
|
1297
|
-
account
|
|
1298
|
-
chain: this.context.walletClient
|
|
1430
|
+
account,
|
|
1431
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1299
1432
|
});
|
|
1300
|
-
|
|
1433
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1434
|
+
const txResult = tx({
|
|
1301
1435
|
hash: txHash,
|
|
1302
|
-
from:
|
|
1436
|
+
from: userAddress,
|
|
1437
|
+
contract: "DataPortabilityServers",
|
|
1438
|
+
fn: "addAndTrustServerByManager"
|
|
1439
|
+
});
|
|
1440
|
+
if (!this.context.waitForTransactionEvents) {
|
|
1441
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
1442
|
+
}
|
|
1443
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
1444
|
+
const event = result.expectedEvents.ServerTrusted;
|
|
1445
|
+
if (!event) {
|
|
1446
|
+
throw new BlockchainError(
|
|
1447
|
+
"ServerTrusted event not found in transaction"
|
|
1448
|
+
);
|
|
1449
|
+
}
|
|
1450
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1451
|
+
hash: txHash
|
|
1452
|
+
});
|
|
1453
|
+
return {
|
|
1454
|
+
transactionHash: txHash,
|
|
1455
|
+
blockNumber: receipt.blockNumber,
|
|
1456
|
+
gasUsed: receipt.gasUsed,
|
|
1457
|
+
user: event.user,
|
|
1458
|
+
serverId: event.serverId,
|
|
1459
|
+
// bigint from event
|
|
1460
|
+
serverAddress: normalizedServerAddress,
|
|
1461
|
+
// derived from params
|
|
1462
|
+
serverUrl: params.serverUrl
|
|
1463
|
+
// provided in params
|
|
1303
1464
|
};
|
|
1304
1465
|
} catch (error) {
|
|
1305
1466
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
@@ -1319,6 +1480,7 @@ class PermissionsController {
|
|
|
1319
1480
|
* @deprecated Use addAndTrustServer instead
|
|
1320
1481
|
*/
|
|
1321
1482
|
async submitTrustServer(params) {
|
|
1483
|
+
this.assertWallet();
|
|
1322
1484
|
try {
|
|
1323
1485
|
const chainId = await this.context.walletClient.getChainId();
|
|
1324
1486
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1326,18 +1488,22 @@ class PermissionsController {
|
|
|
1326
1488
|
"DataPortabilityServers"
|
|
1327
1489
|
);
|
|
1328
1490
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1491
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1329
1492
|
const txHash = await this.context.walletClient.writeContract({
|
|
1330
1493
|
address: DataPortabilityServersAddress,
|
|
1331
1494
|
abi: DataPortabilityServersAbi,
|
|
1332
1495
|
functionName: "trustServer",
|
|
1333
1496
|
args: [BigInt(params.serverId)],
|
|
1334
|
-
account
|
|
1335
|
-
chain: this.context.walletClient
|
|
1497
|
+
account,
|
|
1498
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1336
1499
|
});
|
|
1337
|
-
|
|
1500
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1501
|
+
return tx({
|
|
1338
1502
|
hash: txHash,
|
|
1339
|
-
from:
|
|
1340
|
-
|
|
1503
|
+
from: typeof account === "string" ? account : account.address,
|
|
1504
|
+
contract: "DataPortabilityServers",
|
|
1505
|
+
fn: "trustServer"
|
|
1506
|
+
});
|
|
1341
1507
|
} catch (error) {
|
|
1342
1508
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
1343
1509
|
throw new UserRejectedRequestError();
|
|
@@ -1355,6 +1521,7 @@ class PermissionsController {
|
|
|
1355
1521
|
* @returns Promise resolving to TransactionResult with ServerTrustResult event data
|
|
1356
1522
|
*/
|
|
1357
1523
|
async submitAddAndTrustServerWithSignature(params) {
|
|
1524
|
+
this.assertWallet();
|
|
1358
1525
|
try {
|
|
1359
1526
|
const nonce = await this.getServersUserNonce();
|
|
1360
1527
|
const serverAddress = getAddress(params.serverAddress);
|
|
@@ -1378,21 +1545,36 @@ class PermissionsController {
|
|
|
1378
1545
|
const signature = await this.signTypedData(typedData);
|
|
1379
1546
|
console.debug("\u{1F50D} Generated signature:", signature);
|
|
1380
1547
|
let hash;
|
|
1381
|
-
if (this.context.
|
|
1382
|
-
|
|
1548
|
+
if (this.context.relayer) {
|
|
1549
|
+
const request = {
|
|
1550
|
+
type: "signed",
|
|
1551
|
+
operation: "submitAddAndTrustServer",
|
|
1383
1552
|
typedData,
|
|
1384
1553
|
signature
|
|
1385
|
-
|
|
1554
|
+
};
|
|
1555
|
+
const response = await this.context.relayer(request);
|
|
1556
|
+
if (response.type === "error") {
|
|
1557
|
+
throw new RelayerError(response.error);
|
|
1558
|
+
}
|
|
1559
|
+
if (response.type === "signed") {
|
|
1560
|
+
hash = response.hash;
|
|
1561
|
+
} else {
|
|
1562
|
+
throw new Error("Unexpected response type from relayer");
|
|
1563
|
+
}
|
|
1386
1564
|
} else {
|
|
1387
1565
|
hash = await this.submitAddAndTrustServerTransaction(
|
|
1388
1566
|
addAndTrustServerInput,
|
|
1389
1567
|
signature
|
|
1390
1568
|
);
|
|
1391
1569
|
}
|
|
1392
|
-
|
|
1570
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1571
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1572
|
+
return tx({
|
|
1393
1573
|
hash,
|
|
1394
|
-
from:
|
|
1395
|
-
|
|
1574
|
+
from: typeof account === "string" ? account : account.address,
|
|
1575
|
+
contract: "DataPortabilityServers",
|
|
1576
|
+
fn: "addAndTrustServerWithSignature"
|
|
1577
|
+
});
|
|
1396
1578
|
} catch (error) {
|
|
1397
1579
|
if (error instanceof Error) {
|
|
1398
1580
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -1422,6 +1604,7 @@ class PermissionsController {
|
|
|
1422
1604
|
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
1423
1605
|
*/
|
|
1424
1606
|
async submitTrustServerWithSignature(params) {
|
|
1607
|
+
this.assertWallet();
|
|
1425
1608
|
try {
|
|
1426
1609
|
const nonce = await this.getServersUserNonce();
|
|
1427
1610
|
const trustServerInput = {
|
|
@@ -1431,21 +1614,36 @@ class PermissionsController {
|
|
|
1431
1614
|
const typedData = await this.composeTrustServerMessage(trustServerInput);
|
|
1432
1615
|
const signature = await this.signTypedData(typedData);
|
|
1433
1616
|
let hash;
|
|
1434
|
-
if (this.context.
|
|
1435
|
-
|
|
1617
|
+
if (this.context.relayer) {
|
|
1618
|
+
const request = {
|
|
1619
|
+
type: "signed",
|
|
1620
|
+
operation: "submitTrustServer",
|
|
1436
1621
|
typedData,
|
|
1437
1622
|
signature
|
|
1438
|
-
|
|
1623
|
+
};
|
|
1624
|
+
const response = await this.context.relayer(request);
|
|
1625
|
+
if (response.type === "error") {
|
|
1626
|
+
throw new RelayerError(response.error);
|
|
1627
|
+
}
|
|
1628
|
+
if (response.type === "signed") {
|
|
1629
|
+
hash = response.hash;
|
|
1630
|
+
} else {
|
|
1631
|
+
throw new Error("Unexpected response type from relayer");
|
|
1632
|
+
}
|
|
1439
1633
|
} else {
|
|
1440
1634
|
hash = await this.submitTrustServerTransaction(
|
|
1441
1635
|
trustServerInput,
|
|
1442
1636
|
signature
|
|
1443
1637
|
);
|
|
1444
1638
|
}
|
|
1445
|
-
|
|
1639
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1640
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1641
|
+
return tx({
|
|
1446
1642
|
hash,
|
|
1447
|
-
from:
|
|
1448
|
-
|
|
1643
|
+
from: typeof account === "string" ? account : account.address,
|
|
1644
|
+
contract: "DataPortabilityServers",
|
|
1645
|
+
fn: "trustServerWithSignature"
|
|
1646
|
+
});
|
|
1449
1647
|
} catch (error) {
|
|
1450
1648
|
if (error instanceof Error) {
|
|
1451
1649
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -1477,6 +1675,7 @@ class PermissionsController {
|
|
|
1477
1675
|
* @throws {BlockchainError} When contract submission fails
|
|
1478
1676
|
*/
|
|
1479
1677
|
async submitDirectUntrustTransaction(params) {
|
|
1678
|
+
this.assertWallet();
|
|
1480
1679
|
try {
|
|
1481
1680
|
const chainId = await this.context.walletClient.getChainId();
|
|
1482
1681
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1484,18 +1683,22 @@ class PermissionsController {
|
|
|
1484
1683
|
"DataPortabilityServers"
|
|
1485
1684
|
);
|
|
1486
1685
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1686
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1487
1687
|
const txHash = await this.context.walletClient.writeContract({
|
|
1488
1688
|
address: DataPortabilityServersAddress,
|
|
1489
1689
|
abi: DataPortabilityServersAbi,
|
|
1490
1690
|
functionName: "untrustServer",
|
|
1491
1691
|
args: [BigInt(params.serverId)],
|
|
1492
|
-
account
|
|
1493
|
-
chain: this.context.walletClient
|
|
1692
|
+
account,
|
|
1693
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1494
1694
|
});
|
|
1495
|
-
|
|
1695
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1696
|
+
return tx({
|
|
1496
1697
|
hash: txHash,
|
|
1497
|
-
from:
|
|
1498
|
-
|
|
1698
|
+
from: typeof account === "string" ? account : account.address,
|
|
1699
|
+
contract: "DataPortabilityServers",
|
|
1700
|
+
fn: "untrustServer"
|
|
1701
|
+
});
|
|
1499
1702
|
} catch (error) {
|
|
1500
1703
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
1501
1704
|
throw new UserRejectedRequestError();
|
|
@@ -1535,6 +1738,7 @@ class PermissionsController {
|
|
|
1535
1738
|
* ```
|
|
1536
1739
|
*/
|
|
1537
1740
|
async submitUntrustServer(params) {
|
|
1741
|
+
this.assertWallet();
|
|
1538
1742
|
const nonce = await this.getServersUserNonce();
|
|
1539
1743
|
const untrustServerInput = {
|
|
1540
1744
|
nonce,
|
|
@@ -1555,6 +1759,7 @@ class PermissionsController {
|
|
|
1555
1759
|
* @throws {BlockchainError} When untrust transaction fails
|
|
1556
1760
|
*/
|
|
1557
1761
|
async submitUntrustServerWithSignature(params) {
|
|
1762
|
+
this.assertWallet();
|
|
1558
1763
|
try {
|
|
1559
1764
|
const nonce = await this.getServersUserNonce();
|
|
1560
1765
|
const untrustServerInput = {
|
|
@@ -1564,18 +1769,33 @@ class PermissionsController {
|
|
|
1564
1769
|
const typedData = await this.composeUntrustServerMessage(untrustServerInput);
|
|
1565
1770
|
const signature = await this.signTypedData(typedData);
|
|
1566
1771
|
let hash;
|
|
1567
|
-
if (this.context.
|
|
1568
|
-
|
|
1772
|
+
if (this.context.relayer) {
|
|
1773
|
+
const request = {
|
|
1774
|
+
type: "signed",
|
|
1775
|
+
operation: "submitUntrustServer",
|
|
1569
1776
|
typedData,
|
|
1570
1777
|
signature
|
|
1571
|
-
|
|
1778
|
+
};
|
|
1779
|
+
const response = await this.context.relayer(request);
|
|
1780
|
+
if (response.type === "error") {
|
|
1781
|
+
throw new RelayerError(response.error);
|
|
1782
|
+
}
|
|
1783
|
+
if (response.type === "signed") {
|
|
1784
|
+
hash = response.hash;
|
|
1785
|
+
} else {
|
|
1786
|
+
throw new Error("Unexpected response type from relayer");
|
|
1787
|
+
}
|
|
1572
1788
|
} else {
|
|
1573
1789
|
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
1574
1790
|
}
|
|
1575
|
-
|
|
1791
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1792
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1793
|
+
return tx({
|
|
1576
1794
|
hash,
|
|
1577
|
-
from:
|
|
1578
|
-
|
|
1795
|
+
from: typeof account === "string" ? account : account.address,
|
|
1796
|
+
contract: "DataPortabilityServers",
|
|
1797
|
+
fn: "untrustServerWithSignature"
|
|
1798
|
+
});
|
|
1579
1799
|
} catch (error) {
|
|
1580
1800
|
if (error instanceof Error) {
|
|
1581
1801
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -1613,8 +1833,8 @@ class PermissionsController {
|
|
|
1613
1833
|
*/
|
|
1614
1834
|
async getTrustedServers(userAddress) {
|
|
1615
1835
|
try {
|
|
1616
|
-
const user = userAddress
|
|
1617
|
-
const chainId = await this.context.
|
|
1836
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1837
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1618
1838
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1619
1839
|
chainId,
|
|
1620
1840
|
"DataPortabilityServers"
|
|
@@ -1643,8 +1863,8 @@ class PermissionsController {
|
|
|
1643
1863
|
*/
|
|
1644
1864
|
async getTrustedServersCount(userAddress) {
|
|
1645
1865
|
try {
|
|
1646
|
-
const user = userAddress
|
|
1647
|
-
const chainId = await this.context.
|
|
1866
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1867
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1648
1868
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1649
1869
|
chainId,
|
|
1650
1870
|
"DataPortabilityServers"
|
|
@@ -1673,10 +1893,10 @@ class PermissionsController {
|
|
|
1673
1893
|
*/
|
|
1674
1894
|
async getTrustedServersPaginated(options = {}) {
|
|
1675
1895
|
try {
|
|
1676
|
-
const user = options.userAddress
|
|
1677
|
-
const limit = options.limit
|
|
1678
|
-
const offset = options.offset
|
|
1679
|
-
const chainId = await this.context.
|
|
1896
|
+
const user = options.userAddress ?? this.context.userAddress;
|
|
1897
|
+
const limit = options.limit ?? 50;
|
|
1898
|
+
const offset = options.offset ?? 0;
|
|
1899
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1680
1900
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1681
1901
|
chainId,
|
|
1682
1902
|
"DataPortabilityServers"
|
|
@@ -1822,7 +2042,7 @@ class PermissionsController {
|
|
|
1822
2042
|
};
|
|
1823
2043
|
}
|
|
1824
2044
|
try {
|
|
1825
|
-
const chainId = await this.context.
|
|
2045
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1826
2046
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1827
2047
|
chainId,
|
|
1828
2048
|
"DataPortabilityServers"
|
|
@@ -1897,7 +2117,7 @@ class PermissionsController {
|
|
|
1897
2117
|
*/
|
|
1898
2118
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
1899
2119
|
try {
|
|
1900
|
-
const user = userAddress
|
|
2120
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1901
2121
|
const trustedServers = await this.getTrustedServers(user);
|
|
1902
2122
|
const trustIndex = trustedServers.findIndex(
|
|
1903
2123
|
(server) => server === serverId
|
|
@@ -1987,7 +2207,7 @@ class PermissionsController {
|
|
|
1987
2207
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1988
2208
|
*/
|
|
1989
2209
|
async getServersDomain() {
|
|
1990
|
-
const chainId = await this.context.
|
|
2210
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1991
2211
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1992
2212
|
chainId,
|
|
1993
2213
|
"DataPortabilityServers"
|
|
@@ -2007,6 +2227,7 @@ class PermissionsController {
|
|
|
2007
2227
|
* @returns Promise resolving to the transaction hash
|
|
2008
2228
|
*/
|
|
2009
2229
|
async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
|
|
2230
|
+
this.assertWallet();
|
|
2010
2231
|
const chainId = await this.context.walletClient.getChainId();
|
|
2011
2232
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2012
2233
|
chainId,
|
|
@@ -2038,8 +2259,8 @@ class PermissionsController {
|
|
|
2038
2259
|
},
|
|
2039
2260
|
formattedSignature
|
|
2040
2261
|
],
|
|
2041
|
-
account: this.context.walletClient
|
|
2042
|
-
chain: this.context.walletClient
|
|
2262
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2263
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2043
2264
|
});
|
|
2044
2265
|
return txHash;
|
|
2045
2266
|
}
|
|
@@ -2051,6 +2272,7 @@ class PermissionsController {
|
|
|
2051
2272
|
* @returns Promise resolving to the transaction hash
|
|
2052
2273
|
*/
|
|
2053
2274
|
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2275
|
+
this.assertWallet();
|
|
2054
2276
|
const chainId = await this.context.walletClient.getChainId();
|
|
2055
2277
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2056
2278
|
chainId,
|
|
@@ -2069,8 +2291,8 @@ class PermissionsController {
|
|
|
2069
2291
|
},
|
|
2070
2292
|
formattedSignature
|
|
2071
2293
|
],
|
|
2072
|
-
account: this.context.walletClient
|
|
2073
|
-
chain: this.context.walletClient
|
|
2294
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2295
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2074
2296
|
});
|
|
2075
2297
|
return txHash;
|
|
2076
2298
|
}
|
|
@@ -2082,6 +2304,7 @@ class PermissionsController {
|
|
|
2082
2304
|
* @returns Promise resolving to the transaction hash
|
|
2083
2305
|
*/
|
|
2084
2306
|
async submitDirectRevokeTransaction(typedData, signature) {
|
|
2307
|
+
this.assertWallet();
|
|
2085
2308
|
const chainId = await this.context.walletClient.getChainId();
|
|
2086
2309
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2087
2310
|
chainId,
|
|
@@ -2093,10 +2316,9 @@ class PermissionsController {
|
|
|
2093
2316
|
address: DataPortabilityPermissionsAddress,
|
|
2094
2317
|
abi: DataPortabilityPermissionsAbi,
|
|
2095
2318
|
functionName: "revokePermissionWithSignature",
|
|
2096
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2097
2319
|
args: [typedData.message, formattedSignature],
|
|
2098
|
-
account: this.context.walletClient
|
|
2099
|
-
chain: this.context.walletClient
|
|
2320
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2321
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2100
2322
|
});
|
|
2101
2323
|
return txHash;
|
|
2102
2324
|
}
|
|
@@ -2108,6 +2330,7 @@ class PermissionsController {
|
|
|
2108
2330
|
* @returns Promise resolving to the transaction hash
|
|
2109
2331
|
*/
|
|
2110
2332
|
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2333
|
+
this.assertWallet();
|
|
2111
2334
|
const chainId = await this.context.walletClient.getChainId();
|
|
2112
2335
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2113
2336
|
chainId,
|
|
@@ -2115,14 +2338,17 @@ class PermissionsController {
|
|
|
2115
2338
|
);
|
|
2116
2339
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
2117
2340
|
const formattedSignature = formatSignatureForContract(signature);
|
|
2341
|
+
const contractMessage = {
|
|
2342
|
+
nonce: typedData.message.nonce,
|
|
2343
|
+
serverId: BigInt(typedData.message.serverId)
|
|
2344
|
+
};
|
|
2118
2345
|
const txHash = await this.context.walletClient.writeContract({
|
|
2119
2346
|
address: DataPortabilityServersAddress,
|
|
2120
2347
|
abi: DataPortabilityServersAbi,
|
|
2121
2348
|
functionName: "untrustServerWithSignature",
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
chain: this.context.walletClient.chain || null
|
|
2349
|
+
args: [contractMessage, formattedSignature],
|
|
2350
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2351
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2126
2352
|
});
|
|
2127
2353
|
return txHash;
|
|
2128
2354
|
}
|
|
@@ -2155,6 +2381,7 @@ class PermissionsController {
|
|
|
2155
2381
|
* ```
|
|
2156
2382
|
*/
|
|
2157
2383
|
async submitRegisterGrantee(params) {
|
|
2384
|
+
this.assertWallet();
|
|
2158
2385
|
const chainId = await this.context.walletClient.getChainId();
|
|
2159
2386
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
2160
2387
|
chainId,
|
|
@@ -2163,77 +2390,26 @@ class PermissionsController {
|
|
|
2163
2390
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
2164
2391
|
const ownerAddress = getAddress(params.owner);
|
|
2165
2392
|
const granteeAddress = getAddress(params.granteeAddress);
|
|
2393
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2166
2394
|
const txHash = await this.context.walletClient.writeContract({
|
|
2167
2395
|
address: DataPortabilityGranteesAddress,
|
|
2168
2396
|
abi: DataPortabilityGranteesAbi,
|
|
2169
2397
|
functionName: "registerGrantee",
|
|
2170
2398
|
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2171
|
-
account
|
|
2172
|
-
chain: this.context.walletClient
|
|
2399
|
+
account,
|
|
2400
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2173
2401
|
});
|
|
2174
|
-
|
|
2402
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
2403
|
+
return tx({
|
|
2175
2404
|
hash: txHash,
|
|
2176
|
-
from:
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
* Registers a grantee with a signature (gasless transaction)
|
|
2181
|
-
*
|
|
2182
|
-
* @param params - Parameters for registering the grantee
|
|
2183
|
-
* @returns Promise resolving to the transaction hash
|
|
2184
|
-
*
|
|
2185
|
-
* @example
|
|
2186
|
-
* ```typescript
|
|
2187
|
-
* const txHash = await vana.permissions.registerGranteeWithSignature({
|
|
2188
|
-
* owner: "0x742d35Cc6558Fd4D9e9E0E888F0462ef6919Bd36",
|
|
2189
|
-
* granteeAddress: "0xApp1234567890123456789012345678901234567890",
|
|
2190
|
-
* publicKey: "0x1234567890abcdef..."
|
|
2191
|
-
* });
|
|
2192
|
-
* ```
|
|
2193
|
-
*/
|
|
2194
|
-
async submitRegisterGranteeWithSignature(params) {
|
|
2195
|
-
const nonce = await this.getServersUserNonce();
|
|
2196
|
-
const owner = getAddress(params.owner);
|
|
2197
|
-
const granteeAddress = getAddress(params.granteeAddress);
|
|
2198
|
-
const registerGranteeInput = {
|
|
2199
|
-
nonce,
|
|
2200
|
-
owner,
|
|
2201
|
-
granteeAddress,
|
|
2202
|
-
publicKey: params.publicKey
|
|
2203
|
-
};
|
|
2204
|
-
const typedData = await this.buildRegisterGranteeTypedData(registerGranteeInput);
|
|
2205
|
-
const signature = await this.signTypedData(typedData);
|
|
2206
|
-
const hash = await this.submitSignedRegisterGranteeTransaction(
|
|
2207
|
-
typedData,
|
|
2208
|
-
signature
|
|
2209
|
-
);
|
|
2210
|
-
return {
|
|
2211
|
-
hash,
|
|
2212
|
-
from: this.context.walletClient.account?.address
|
|
2213
|
-
};
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Submits a signed register grantee transaction via relayer
|
|
2217
|
-
*
|
|
2218
|
-
* @param typedData - The EIP-712 typed data for register grantee
|
|
2219
|
-
* @param signature - The cryptographic signature
|
|
2220
|
-
* @returns Promise resolving to the transaction hash
|
|
2221
|
-
*
|
|
2222
|
-
* @example
|
|
2223
|
-
* ```typescript
|
|
2224
|
-
* const result = await vana.permissions.submitSignedRegisterGrantee(typedData, signature);
|
|
2225
|
-
* ```
|
|
2226
|
-
*/
|
|
2227
|
-
async submitSignedRegisterGrantee(typedData, signature) {
|
|
2228
|
-
const hash = await this.submitSignedRegisterGranteeTransaction(
|
|
2229
|
-
typedData,
|
|
2230
|
-
signature
|
|
2231
|
-
);
|
|
2232
|
-
return {
|
|
2233
|
-
hash,
|
|
2234
|
-
from: this.context.walletClient.account?.address
|
|
2235
|
-
};
|
|
2405
|
+
from: typeof account === "string" ? account : account.address,
|
|
2406
|
+
contract: "DataPortabilityGrantees",
|
|
2407
|
+
fn: "registerGrantee"
|
|
2408
|
+
});
|
|
2236
2409
|
}
|
|
2410
|
+
// TODO: When DataPortabilityGrantees contract adds registerGranteeWithSignature function,
|
|
2411
|
+
// implement submitRegisterGranteeWithSignature and submitSignedRegisterGrantee methods
|
|
2412
|
+
// to support gasless transactions via relayer
|
|
2237
2413
|
/**
|
|
2238
2414
|
* Retrieves all registered grantees from the DataPortabilityGrantees contract.
|
|
2239
2415
|
*
|
|
@@ -2279,8 +2455,8 @@ class PermissionsController {
|
|
|
2279
2455
|
functionName: "granteesCount"
|
|
2280
2456
|
});
|
|
2281
2457
|
const total = Number(totalCount);
|
|
2282
|
-
const limit = options.limit
|
|
2283
|
-
const offset = options.offset
|
|
2458
|
+
const limit = options.limit ?? 50;
|
|
2459
|
+
const offset = options.offset ?? 0;
|
|
2284
2460
|
const grantees = [];
|
|
2285
2461
|
const endIndex = Math.min(offset + limit, total);
|
|
2286
2462
|
for (let i = offset; i < endIndex; i++) {
|
|
@@ -2420,67 +2596,6 @@ class PermissionsController {
|
|
|
2420
2596
|
return null;
|
|
2421
2597
|
}
|
|
2422
2598
|
}
|
|
2423
|
-
/**
|
|
2424
|
-
* Builds EIP-712 typed data for grantee registration
|
|
2425
|
-
*
|
|
2426
|
-
* @param input - The register grantee input
|
|
2427
|
-
* @returns Promise resolving to the typed data structure
|
|
2428
|
-
* @private
|
|
2429
|
-
*/
|
|
2430
|
-
async buildRegisterGranteeTypedData(input) {
|
|
2431
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
2432
|
-
const verifyingContract = getContractAddress(
|
|
2433
|
-
chainId,
|
|
2434
|
-
"DataPortabilityGrantees"
|
|
2435
|
-
);
|
|
2436
|
-
return {
|
|
2437
|
-
domain: {
|
|
2438
|
-
name: "DataPortabilityGrantees",
|
|
2439
|
-
version: "1",
|
|
2440
|
-
chainId,
|
|
2441
|
-
verifyingContract
|
|
2442
|
-
},
|
|
2443
|
-
types: {
|
|
2444
|
-
RegisterGrantee: [
|
|
2445
|
-
{ name: "nonce", type: "uint256" },
|
|
2446
|
-
{ name: "owner", type: "address" },
|
|
2447
|
-
{ name: "granteeAddress", type: "address" },
|
|
2448
|
-
{ name: "publicKey", type: "string" }
|
|
2449
|
-
]
|
|
2450
|
-
},
|
|
2451
|
-
primaryType: "RegisterGrantee",
|
|
2452
|
-
message: input
|
|
2453
|
-
};
|
|
2454
|
-
}
|
|
2455
|
-
/**
|
|
2456
|
-
* Submits a register grantee transaction with signature.
|
|
2457
|
-
*
|
|
2458
|
-
* @param typedData - The EIP-712 typed data structure for the registration
|
|
2459
|
-
* @param _signature - The cryptographic signature authorizing the registration (currently unused)
|
|
2460
|
-
* @returns Promise resolving to the transaction hash
|
|
2461
|
-
* @private
|
|
2462
|
-
*/
|
|
2463
|
-
async submitSignedRegisterGranteeTransaction(typedData, _signature) {
|
|
2464
|
-
const chainId = await this.context.walletClient.getChainId();
|
|
2465
|
-
const DataPortabilityGranteesAddress = getContractAddress(
|
|
2466
|
-
chainId,
|
|
2467
|
-
"DataPortabilityGrantees"
|
|
2468
|
-
);
|
|
2469
|
-
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
2470
|
-
const txHash = await this.context.walletClient.writeContract({
|
|
2471
|
-
address: DataPortabilityGranteesAddress,
|
|
2472
|
-
abi: DataPortabilityGranteesAbi,
|
|
2473
|
-
functionName: "registerGrantee",
|
|
2474
|
-
args: [
|
|
2475
|
-
typedData.message.owner,
|
|
2476
|
-
typedData.message.granteeAddress,
|
|
2477
|
-
typedData.message.publicKey
|
|
2478
|
-
],
|
|
2479
|
-
account: this.context.walletClient.account || await this.getUserAddress(),
|
|
2480
|
-
chain: this.context.walletClient.chain || null
|
|
2481
|
-
});
|
|
2482
|
-
return txHash;
|
|
2483
|
-
}
|
|
2484
2599
|
// ===========================
|
|
2485
2600
|
// DATA PORTABILITY SERVERS HELPER METHODS
|
|
2486
2601
|
// ===========================
|
|
@@ -2492,7 +2607,7 @@ class PermissionsController {
|
|
|
2492
2607
|
*/
|
|
2493
2608
|
async getUserServerIds(userAddress) {
|
|
2494
2609
|
try {
|
|
2495
|
-
const targetAddress = userAddress
|
|
2610
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2496
2611
|
const chainId = await this.context.publicClient.getChainId();
|
|
2497
2612
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2498
2613
|
chainId,
|
|
@@ -2550,7 +2665,7 @@ class PermissionsController {
|
|
|
2550
2665
|
*/
|
|
2551
2666
|
async getUserServerCount(userAddress) {
|
|
2552
2667
|
try {
|
|
2553
|
-
const targetAddress = userAddress
|
|
2668
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2554
2669
|
const chainId = await this.context.publicClient.getChainId();
|
|
2555
2670
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2556
2671
|
chainId,
|
|
@@ -2579,7 +2694,7 @@ class PermissionsController {
|
|
|
2579
2694
|
*/
|
|
2580
2695
|
async getUserTrustedServers(userAddress) {
|
|
2581
2696
|
try {
|
|
2582
|
-
const targetAddress = userAddress
|
|
2697
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2583
2698
|
const chainId = await this.context.publicClient.getChainId();
|
|
2584
2699
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2585
2700
|
chainId,
|
|
@@ -2696,7 +2811,7 @@ class PermissionsController {
|
|
|
2696
2811
|
*/
|
|
2697
2812
|
async getUserPermissionIds(userAddress) {
|
|
2698
2813
|
try {
|
|
2699
|
-
const targetAddress = userAddress
|
|
2814
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2700
2815
|
const chainId = await this.context.publicClient.getChainId();
|
|
2701
2816
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2702
2817
|
chainId,
|
|
@@ -2758,7 +2873,7 @@ class PermissionsController {
|
|
|
2758
2873
|
*/
|
|
2759
2874
|
async getUserPermissionCount(userAddress) {
|
|
2760
2875
|
try {
|
|
2761
|
-
const targetAddress = userAddress
|
|
2876
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2762
2877
|
const chainId = await this.context.publicClient.getChainId();
|
|
2763
2878
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2764
2879
|
chainId,
|
|
@@ -3203,6 +3318,7 @@ class PermissionsController {
|
|
|
3203
3318
|
* @returns Promise resolving to transaction hash
|
|
3204
3319
|
*/
|
|
3205
3320
|
async submitUpdateServer(serverId, url) {
|
|
3321
|
+
this.assertWallet();
|
|
3206
3322
|
try {
|
|
3207
3323
|
const chainId = await this.context.walletClient.getChainId();
|
|
3208
3324
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -3210,18 +3326,22 @@ class PermissionsController {
|
|
|
3210
3326
|
"DataPortabilityServers"
|
|
3211
3327
|
);
|
|
3212
3328
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
3329
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3213
3330
|
const hash = await this.context.walletClient.writeContract({
|
|
3214
3331
|
address: DataPortabilityServersAddress,
|
|
3215
3332
|
abi: DataPortabilityServersAbi,
|
|
3216
3333
|
functionName: "updateServer",
|
|
3217
3334
|
args: [serverId, url],
|
|
3218
|
-
chain: this.context.walletClient
|
|
3219
|
-
account
|
|
3335
|
+
chain: this.context.walletClient?.chain,
|
|
3336
|
+
account
|
|
3220
3337
|
});
|
|
3221
|
-
|
|
3338
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3339
|
+
return tx({
|
|
3222
3340
|
hash,
|
|
3223
|
-
from:
|
|
3224
|
-
|
|
3341
|
+
from: typeof account === "string" ? account : account.address,
|
|
3342
|
+
contract: "DataPortabilityServers",
|
|
3343
|
+
fn: "updateServer"
|
|
3344
|
+
});
|
|
3225
3345
|
} catch (error) {
|
|
3226
3346
|
throw new BlockchainError(
|
|
3227
3347
|
`Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3371,6 +3491,7 @@ class PermissionsController {
|
|
|
3371
3491
|
* @throws {NetworkError} When network communication fails
|
|
3372
3492
|
*/
|
|
3373
3493
|
async submitAddPermission(params) {
|
|
3494
|
+
this.assertWallet();
|
|
3374
3495
|
try {
|
|
3375
3496
|
const nonce = await this.getPermissionsUserNonce();
|
|
3376
3497
|
const addPermissionInput = {
|
|
@@ -3409,23 +3530,39 @@ class PermissionsController {
|
|
|
3409
3530
|
* @throws {NetworkError} When network communication fails
|
|
3410
3531
|
*/
|
|
3411
3532
|
async submitSignedAddPermission(typedData, signature) {
|
|
3533
|
+
this.assertWallet();
|
|
3412
3534
|
try {
|
|
3413
3535
|
let hash;
|
|
3414
|
-
if (this.context.
|
|
3415
|
-
|
|
3536
|
+
if (this.context.relayer) {
|
|
3537
|
+
const request = {
|
|
3538
|
+
type: "signed",
|
|
3539
|
+
operation: "submitAddPermission",
|
|
3416
3540
|
typedData,
|
|
3417
3541
|
signature
|
|
3418
|
-
|
|
3542
|
+
};
|
|
3543
|
+
const response = await this.context.relayer(request);
|
|
3544
|
+
if (response.type === "error") {
|
|
3545
|
+
throw new RelayerError(response.error);
|
|
3546
|
+
}
|
|
3547
|
+
if (response.type === "signed") {
|
|
3548
|
+
hash = response.hash;
|
|
3549
|
+
} else {
|
|
3550
|
+
throw new Error("Unexpected response type from relayer");
|
|
3551
|
+
}
|
|
3419
3552
|
} else {
|
|
3420
3553
|
hash = await this.submitDirectAddPermissionTransaction(
|
|
3421
3554
|
typedData,
|
|
3422
3555
|
signature
|
|
3423
3556
|
);
|
|
3424
3557
|
}
|
|
3425
|
-
|
|
3558
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3559
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3560
|
+
return tx({
|
|
3426
3561
|
hash,
|
|
3427
|
-
from:
|
|
3428
|
-
|
|
3562
|
+
from: typeof account === "string" ? account : account.address,
|
|
3563
|
+
contract: "DataPortabilityPermissions",
|
|
3564
|
+
fn: "addPermission"
|
|
3565
|
+
});
|
|
3429
3566
|
} catch (error) {
|
|
3430
3567
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
3431
3568
|
throw error;
|
|
@@ -3454,7 +3591,7 @@ class PermissionsController {
|
|
|
3454
3591
|
* @param params.serverAddress - Server wallet address for decryption permissions
|
|
3455
3592
|
* @param params.serverUrl - Server endpoint URL
|
|
3456
3593
|
* @param params.serverPublicKey - Server's public key for encryption.
|
|
3457
|
-
* Obtain via `vana.server.getIdentity(userAddress).
|
|
3594
|
+
* Obtain via `vana.server.getIdentity(userAddress).publicKey`.
|
|
3458
3595
|
* @param params.filePermissions - Nested array of permissions for each file
|
|
3459
3596
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3460
3597
|
* @throws {Error} When schemaIds array length doesn't match fileUrls array length
|
|
@@ -3476,7 +3613,7 @@ class PermissionsController {
|
|
|
3476
3613
|
* schemaIds: [123], // LinkedIn profile schema ID
|
|
3477
3614
|
* serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3478
3615
|
* serverUrl: "https://server.example.com",
|
|
3479
|
-
* serverPublicKey: serverInfo.
|
|
3616
|
+
* serverPublicKey: serverInfo.publicKey,
|
|
3480
3617
|
* filePermissions: [[{
|
|
3481
3618
|
* account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3482
3619
|
* key: encryptedKey
|
|
@@ -3487,6 +3624,7 @@ class PermissionsController {
|
|
|
3487
3624
|
* ```
|
|
3488
3625
|
*/
|
|
3489
3626
|
async submitAddServerFilesAndPermissions(params) {
|
|
3627
|
+
this.assertWallet();
|
|
3490
3628
|
try {
|
|
3491
3629
|
if (params.schemaIds.length !== params.fileUrls.length) {
|
|
3492
3630
|
throw new Error(
|
|
@@ -3551,37 +3689,45 @@ class PermissionsController {
|
|
|
3551
3689
|
* ```
|
|
3552
3690
|
*/
|
|
3553
3691
|
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
3692
|
+
this.assertWallet();
|
|
3554
3693
|
try {
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
hasSubmitMethod: !!this.context.relayerCallbacks?.submitAddServerFilesAndPermissions,
|
|
3558
|
-
availableRelayerMethods: this.context.relayerCallbacks ? Object.keys(this.context.relayerCallbacks) : []
|
|
3559
|
-
});
|
|
3560
|
-
if (this.context.relayerCallbacks?.submitAddServerFilesAndPermissions) {
|
|
3694
|
+
let hash;
|
|
3695
|
+
if (this.context.relayer) {
|
|
3561
3696
|
console.debug(
|
|
3562
3697
|
"\u{1F680} Using relayer for submitAddServerFilesAndPermissions"
|
|
3563
3698
|
);
|
|
3564
|
-
const
|
|
3699
|
+
const request = {
|
|
3700
|
+
type: "signed",
|
|
3701
|
+
operation: "submitAddServerFilesAndPermissions",
|
|
3565
3702
|
typedData,
|
|
3566
3703
|
signature
|
|
3567
|
-
);
|
|
3568
|
-
return {
|
|
3569
|
-
hash,
|
|
3570
|
-
from: this.context.walletClient.account?.address
|
|
3571
3704
|
};
|
|
3705
|
+
const response = await this.context.relayer(request);
|
|
3706
|
+
if (response.type === "error") {
|
|
3707
|
+
throw new RelayerError(response.error);
|
|
3708
|
+
}
|
|
3709
|
+
if (response.type === "signed") {
|
|
3710
|
+
hash = response.hash;
|
|
3711
|
+
} else {
|
|
3712
|
+
throw new Error("Unexpected response type from relayer");
|
|
3713
|
+
}
|
|
3572
3714
|
} else {
|
|
3573
3715
|
console.debug(
|
|
3574
3716
|
"\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
|
|
3575
3717
|
);
|
|
3576
|
-
|
|
3718
|
+
hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
|
|
3577
3719
|
typedData,
|
|
3578
3720
|
signature
|
|
3579
3721
|
);
|
|
3580
|
-
return {
|
|
3581
|
-
hash,
|
|
3582
|
-
from: this.context.walletClient.account?.address
|
|
3583
|
-
};
|
|
3584
3722
|
}
|
|
3723
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3724
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3725
|
+
return tx({
|
|
3726
|
+
hash,
|
|
3727
|
+
from: typeof account === "string" ? account : account.address,
|
|
3728
|
+
contract: "DataPortabilityPermissions",
|
|
3729
|
+
fn: "addServerFilesAndPermissions"
|
|
3730
|
+
});
|
|
3585
3731
|
} catch (error) {
|
|
3586
3732
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
3587
3733
|
throw error;
|
|
@@ -3599,6 +3745,7 @@ class PermissionsController {
|
|
|
3599
3745
|
* @returns Promise resolving to transaction hash
|
|
3600
3746
|
*/
|
|
3601
3747
|
async submitRevokePermission(permissionId) {
|
|
3748
|
+
this.assertWallet();
|
|
3602
3749
|
try {
|
|
3603
3750
|
const chainId = await this.context.walletClient.getChainId();
|
|
3604
3751
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
@@ -3608,18 +3755,25 @@ class PermissionsController {
|
|
|
3608
3755
|
const DataPortabilityPermissionsAbi = getAbi(
|
|
3609
3756
|
"DataPortabilityPermissions"
|
|
3610
3757
|
);
|
|
3758
|
+
const { account } = this.context.walletClient;
|
|
3759
|
+
if (!account) {
|
|
3760
|
+
throw new Error("No wallet account connected");
|
|
3761
|
+
}
|
|
3611
3762
|
const hash = await this.context.walletClient.writeContract({
|
|
3612
3763
|
address: DataPortabilityPermissionsAddress,
|
|
3613
3764
|
abi: DataPortabilityPermissionsAbi,
|
|
3614
3765
|
functionName: "revokePermission",
|
|
3615
3766
|
args: [permissionId],
|
|
3616
|
-
chain: this.context.walletClient
|
|
3617
|
-
account
|
|
3767
|
+
chain: this.context.walletClient?.chain,
|
|
3768
|
+
account
|
|
3618
3769
|
});
|
|
3619
|
-
|
|
3770
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3771
|
+
return tx({
|
|
3620
3772
|
hash,
|
|
3621
|
-
from:
|
|
3622
|
-
|
|
3773
|
+
from: typeof account === "string" ? account : account.address,
|
|
3774
|
+
contract: "DataPortabilityPermissions",
|
|
3775
|
+
fn: "revokePermission"
|
|
3776
|
+
});
|
|
3623
3777
|
} catch (error) {
|
|
3624
3778
|
throw new BlockchainError(
|
|
3625
3779
|
`Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3635,6 +3789,7 @@ class PermissionsController {
|
|
|
3635
3789
|
* @returns Promise resolving to the transaction hash
|
|
3636
3790
|
*/
|
|
3637
3791
|
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
3792
|
+
this.assertWallet();
|
|
3638
3793
|
const chainId = await this.context.walletClient.getChainId();
|
|
3639
3794
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
3640
3795
|
chainId,
|
|
@@ -3645,7 +3800,7 @@ class PermissionsController {
|
|
|
3645
3800
|
nonce: typedData.message.nonce,
|
|
3646
3801
|
granteeId: typedData.message.granteeId,
|
|
3647
3802
|
grant: typedData.message.grant,
|
|
3648
|
-
fileIds: typedData.message.fileIds
|
|
3803
|
+
fileIds: typedData.message.fileIds ?? []
|
|
3649
3804
|
};
|
|
3650
3805
|
const formattedSignature = formatSignatureForContract(signature);
|
|
3651
3806
|
const hash = await this.context.walletClient.writeContract({
|
|
@@ -3653,8 +3808,8 @@ class PermissionsController {
|
|
|
3653
3808
|
abi: DataPortabilityPermissionsAbi,
|
|
3654
3809
|
functionName: "addPermission",
|
|
3655
3810
|
args: [permissionInput, formattedSignature],
|
|
3656
|
-
account: this.context.walletClient
|
|
3657
|
-
chain: this.context.walletClient
|
|
3811
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3812
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3658
3813
|
});
|
|
3659
3814
|
return hash;
|
|
3660
3815
|
}
|
|
@@ -3666,7 +3821,8 @@ class PermissionsController {
|
|
|
3666
3821
|
* @returns Promise resolving to the transaction hash
|
|
3667
3822
|
*/
|
|
3668
3823
|
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
|
|
3669
|
-
|
|
3824
|
+
this.assertWallet();
|
|
3825
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
3670
3826
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
3671
3827
|
chainId,
|
|
3672
3828
|
"DataPortabilityPermissions"
|
|
@@ -3690,8 +3846,8 @@ class PermissionsController {
|
|
|
3690
3846
|
functionName: "addServerFilesAndPermissions",
|
|
3691
3847
|
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
3692
3848
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
3693
|
-
account: this.context.
|
|
3694
|
-
chain: this.context.walletClient
|
|
3849
|
+
account: this.context.userAddress,
|
|
3850
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3695
3851
|
});
|
|
3696
3852
|
return hash;
|
|
3697
3853
|
}
|