@opendatalabs/vana-sdk 0.1.0-alpha.d7fc764 → 0.1.0-alpha.dc68f39
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 +415 -172
- package/dist/controllers/data.cjs.map +1 -1
- package/dist/controllers/data.d.ts +149 -76
- package/dist/controllers/data.js +415 -172
- package/dist/controllers/data.js.map +1 -1
- package/dist/controllers/permissions.cjs +508 -257
- package/dist/controllers/permissions.cjs.map +1 -1
- package/dist/controllers/permissions.d.ts +1348 -25
- package/dist/controllers/permissions.js +508 -257
- 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 +114 -48
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +40 -65
- package/dist/core.js +127 -74
- 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/test-vectors/eccrypto-vectors.json +72 -0
- package/dist/crypto/ecies/utils.cjs +2 -41
- package/dist/crypto/ecies/utils.cjs.map +1 -1
- package/dist/crypto/ecies/utils.d.ts +3 -40
- package/dist/crypto/ecies/utils.js +1 -35
- package/dist/crypto/ecies/utils.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.cjs +2 -2
- package/dist/crypto/services/WalletKeyEncryptionService.cjs.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.d.ts +3 -7
- package/dist/crypto/services/WalletKeyEncryptionService.js +5 -9
- package/dist/crypto/services/WalletKeyEncryptionService.js.map +1 -1
- package/dist/crypto/services/WalletKeyEncryptionService.test.d.ts +1 -0
- package/dist/diagnostics.d.ts +1 -3
- package/dist/diagnostics.test.d.ts +1 -0
- package/dist/errors.cjs +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 +9 -0
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.d.ts +181 -64
- package/dist/index.node.js +10 -0
- package/dist/index.node.js.map +1 -1
- package/dist/node.d.ts +4 -2
- package/dist/platform/browser-only.d.ts +5 -8
- package/dist/platform/browser-only.test.d.ts +1 -0
- package/dist/platform/browser-safe.d.ts +6 -9
- package/dist/platform/browser-safe.test.d.ts +1 -0
- package/dist/platform/browser.cjs +7 -6
- package/dist/platform/browser.cjs.map +1 -1
- package/dist/platform/browser.d.ts +3 -6
- package/dist/platform/browser.js +19 -27
- package/dist/platform/browser.js.map +1 -1
- package/dist/platform/browser.test.d.ts +1 -0
- package/dist/platform/index.d.ts +11 -5
- package/dist/platform/interface.d.ts +6 -8
- package/dist/platform/node.d.ts +3 -7
- package/dist/platform/node.js +12 -19
- package/dist/platform/node.js.map +1 -1
- package/dist/platform/ports/openpgp-port.cjs +74 -0
- package/dist/platform/ports/openpgp-port.cjs.map +1 -0
- package/dist/platform/ports/openpgp-port.d.ts +13 -0
- package/dist/platform/ports/openpgp-port.js +59 -0
- package/dist/platform/ports/openpgp-port.js.map +1 -0
- package/dist/platform/ports/pgp-port.cjs +17 -0
- package/dist/platform/ports/pgp-port.cjs.map +1 -0
- package/dist/platform/ports/pgp-port.d.ts +35 -0
- package/dist/platform/ports/pgp-port.js +1 -0
- package/dist/platform/ports/pgp-port.js.map +1 -0
- package/dist/platform/shared/error-utils.d.ts +2 -4
- package/dist/platform/shared/pgp-utils.cjs +2 -2
- package/dist/platform/shared/pgp-utils.cjs.map +1 -1
- package/dist/platform/shared/pgp-utils.d.ts +3 -5
- package/dist/platform/shared/pgp-utils.js +2 -2
- package/dist/platform/shared/pgp-utils.js.map +1 -1
- package/dist/platform/shared/stream-utils.d.ts +1 -3
- package/dist/platform/utils.d.ts +6 -10
- package/dist/platform/utils.test.d.ts +1 -0
- package/dist/platform.browser.d.ts +9 -4
- package/dist/platform.d.ts +11 -5
- package/dist/platform.node.d.ts +10 -5
- package/dist/schemas/dataSchema.schema.json +53 -0
- package/dist/schemas/grantFile.schema.json +43 -0
- package/dist/server/handler.cjs.map +1 -1
- package/dist/server/handler.d.ts +8 -203
- package/dist/server/handler.js.map +1 -1
- package/dist/storage/index.d.ts +56 -10
- package/dist/storage/manager.cjs +6 -6
- package/dist/storage/manager.cjs.map +1 -1
- package/dist/storage/manager.d.ts +2 -5
- package/dist/storage/manager.js +5 -12
- package/dist/storage/manager.js.map +1 -1
- package/dist/storage/providers/callback-storage.cjs +3 -3
- package/dist/storage/providers/callback-storage.cjs.map +1 -1
- package/dist/storage/providers/callback-storage.d.ts +3 -9
- package/dist/storage/providers/callback-storage.js +3 -3
- package/dist/storage/providers/callback-storage.js.map +1 -1
- package/dist/storage/providers/google-drive.cjs +2 -2
- package/dist/storage/providers/google-drive.cjs.map +1 -1
- package/dist/storage/providers/google-drive.d.ts +3 -7
- package/dist/storage/providers/google-drive.js +4 -7
- package/dist/storage/providers/google-drive.js.map +1 -1
- package/dist/storage/providers/google-drive.test.d.ts +1 -0
- package/dist/storage/providers/ipfs.cjs +5 -5
- package/dist/storage/providers/ipfs.cjs.map +1 -1
- package/dist/storage/providers/ipfs.d.ts +3 -6
- package/dist/storage/providers/ipfs.js +7 -10
- package/dist/storage/providers/ipfs.js.map +1 -1
- package/dist/storage/providers/pinata.cjs +6 -6
- package/dist/storage/providers/pinata.cjs.map +1 -1
- package/dist/storage/providers/pinata.d.ts +5 -8
- package/dist/storage/providers/pinata.js +8 -11
- package/dist/storage/providers/pinata.js.map +1 -1
- package/dist/storage/tests/callbackStorage.test.d.ts +1 -0
- package/dist/storage/tests/googleDriveStorage.test.d.ts +1 -0
- package/dist/storage/tests/ipfsStorage.test.d.ts +1 -0
- package/dist/storage/tests/pinataStorage.test.d.ts +1 -0
- package/dist/storage/tests/storageManager.test.d.ts +1 -0
- package/dist/tests/abi.test.d.ts +1 -0
- package/dist/tests/chains-definitions.test.d.ts +1 -0
- package/dist/tests/core-encryption.test.d.ts +1 -0
- package/dist/tests/core-extended.test.d.ts +1 -0
- package/dist/tests/core-generics-coverage.test.d.ts +1 -0
- package/dist/tests/coverage-boost.test.d.ts +1 -0
- package/dist/tests/crypto-cross-platform-compatibility.test.d.ts +1 -0
- package/dist/tests/data-addfile-permissions-schema.test.d.ts +1 -0
- package/dist/tests/data-additional-methods.test.d.ts +1 -0
- package/dist/tests/data-controller-edge-cases.test.d.ts +1 -0
- package/dist/tests/data-ipfs-gateways.test.d.ts +1 -0
- package/dist/tests/data-relayer.test.d.ts +1 -0
- package/dist/tests/data-schema-validation.test.d.ts +1 -0
- package/dist/tests/data-simple-methods.test.d.ts +1 -0
- package/dist/tests/data.test.d.ts +1 -0
- package/dist/tests/demo-integration.test.d.ts +1 -0
- package/dist/tests/demo-trusted-server-integration.test.d.ts +1 -0
- package/dist/tests/download-relayer.test.d.ts +1 -0
- package/dist/tests/dual-mode-permissions.test.d.ts +1 -0
- package/dist/tests/dual-mode-trusted-servers.test.d.ts +1 -0
- package/dist/tests/encryption-correct-implementation.test.d.ts +1 -0
- package/dist/tests/encryption-coverage.test.d.ts +1 -0
- package/dist/tests/encryption-edge-cases.test.d.ts +1 -0
- package/dist/tests/encryption-utils-updated.test.d.ts +1 -0
- package/dist/tests/errors-coverage.test.d.ts +1 -0
- package/dist/tests/errors.test.d.ts +1 -0
- package/dist/tests/factories/mockFactory.d.ts +316 -0
- package/dist/tests/fakes/FakeStorageManager.d.ts +200 -0
- package/dist/tests/fakes/FakeStorageManager.test.d.ts +1 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.d.ts +170 -0
- package/dist/tests/fakes/FakeWaitForTransactionEvents.test.d.ts +1 -0
- package/dist/tests/fakes/fake-pgp-port.d.ts +13 -0
- package/dist/tests/grantValidation-edge-cases.test.d.ts +1 -0
- package/dist/tests/grantValidation-unreachable-branch.test.d.ts +1 -0
- package/dist/tests/helper-methods.test.d.ts +1 -0
- package/dist/tests/helpers/platformTestHelpers.d.ts +106 -0
- package/dist/tests/helpers/typedMocks.d.ts +64 -0
- package/dist/tests/index-browser.test.d.ts +1 -0
- package/dist/tests/index-node.test.d.ts +1 -0
- package/dist/tests/index.test.d.ts +1 -0
- package/dist/tests/mocks/platformAdapter.d.ts +12 -0
- package/dist/tests/new-permissions-methods.test.d.ts +1 -0
- package/dist/tests/no-buffer-browser.test.d.ts +1 -0
- package/dist/tests/permissions-grantee.test.d.ts +1 -0
- package/dist/tests/permissions-schema-validation.test.d.ts +1 -0
- package/dist/tests/permissions-server-files.test.d.ts +1 -0
- package/dist/tests/permissions-transaction-options.test.d.ts +1 -0
- package/dist/tests/permissions-trust-servers.test.d.ts +1 -0
- package/dist/tests/permissions.test.d.ts +1 -0
- package/dist/tests/personal.test.d.ts +1 -0
- package/dist/tests/platform-browser.test.d.ts +1 -0
- package/dist/tests/platform-crypto-expanded.test.d.ts +1 -0
- package/dist/tests/platform-crypto.test.d.ts +1 -0
- package/dist/tests/platform-index.test.d.ts +1 -0
- package/dist/tests/platform-node.test.d.ts +1 -0
- package/dist/tests/platform-shared-utils.test.d.ts +1 -0
- package/dist/tests/platform-updated.test.d.ts +1 -0
- package/dist/tests/protocol-additional-methods.test.d.ts +1 -0
- package/dist/tests/protocol.test.d.ts +1 -0
- package/dist/tests/read-only-mode.test.d.ts +1 -0
- package/dist/tests/schemas.test.d.ts +1 -0
- package/dist/tests/server-handler.test.d.ts +1 -0
- package/dist/tests/setup.d.ts +7 -0
- package/dist/tests/signatureFormatter.test.d.ts +1 -0
- package/dist/tests/trusted-server-queries.test.d.ts +1 -0
- package/dist/tests/typedDataConverter.test.d.ts +1 -0
- package/dist/tests/types-contracts.test.d.ts +1 -0
- package/dist/tests/types-data.test.d.ts +1 -0
- package/dist/tests/types-external-apis.test.d.ts +1 -0
- package/dist/tests/types-generics.test.d.ts +1 -0
- package/dist/tests/types-permissions.test.d.ts +1 -0
- package/dist/tests/types-upload-params.test.d.ts +1 -0
- package/dist/tests/types.test.d.ts +1 -0
- package/dist/tests/utils-formatters.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-edge-cases.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles-validation.test.d.ts +1 -0
- package/dist/tests/utils-grantFiles.test.d.ts +1 -0
- package/dist/tests/utils-grantValidation-consolidated.test.d.ts +1 -0
- package/dist/tests/utils-grants.test.d.ts +1 -0
- package/dist/tests/utils-ipfs-additional.test.d.ts +1 -0
- package/dist/tests/utils-ipfs.test.d.ts +4 -0
- package/dist/tests/utils-schemaValidation.test.d.ts +1 -0
- package/dist/tests/vana.test.d.ts +1 -0
- package/dist/tests/wallet-crypto-compatibility.test.d.ts +1 -0
- package/dist/types/blockchain.cjs +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 +161 -54
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -1
- package/dist/types/contracts.cjs.map +1 -1
- package/dist/types/contracts.d.ts +8 -11
- package/dist/types/controller-context.cjs +17 -0
- package/dist/types/controller-context.cjs.map +1 -0
- package/dist/types/controller-context.d.ts +64 -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.d.ts +15 -18
- package/dist/types/storage.d.ts +6 -8
- package/dist/types/storage.js +2 -5
- package/dist/types/storage.js.map +1 -1
- package/dist/types/transactionResults.cjs.map +1 -1
- package/dist/types/transactionResults.d.ts +193 -25
- package/dist/types/utils.cjs.map +1 -1
- package/dist/types/utils.d.ts +26 -25
- 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 +62 -0
- package/dist/utils/wallet.cjs.map +1 -0
- package/dist/utils/wallet.d.ts +32 -0
- package/dist/utils/wallet.js +36 -0
- package/dist/utils/wallet.js.map +1 -0
- package/dist/{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 -13
- package/dist/browser.d.cts +0 -2
- package/dist/chains/definitions.d.cts +0 -53
- package/dist/chains/index.d.cts +0 -2
- package/dist/chains.browser.cjs.map +0 -1
- package/dist/chains.browser.d.cts +0 -2
- package/dist/chains.d.cts +0 -2
- package/dist/chains.node.d.cts +0 -2
- package/dist/config/addresses.d.cts +0 -380
- package/dist/config/chains.d.cts +0 -85
- package/dist/config/eventMappings.cjs +0 -114
- package/dist/config/eventMappings.cjs.map +0 -1
- package/dist/config/eventMappings.d.cts +0 -108
- package/dist/config/eventMappings.d.ts +0 -108
- package/dist/config/eventMappings.js +0 -90
- package/dist/config/eventMappings.js.map +0 -1
- package/dist/config/features.d.cts +0 -64
- package/dist/contracts/contractController.d.cts +0 -96
- package/dist/controllers/data.d.cts +0 -941
- package/dist/controllers/permissions.d.cts +0 -25
- package/dist/controllers/protocol.d.cts +0 -167
- package/dist/controllers/schemas.d.cts +0 -272
- package/dist/controllers/server.d.cts +0 -243
- package/dist/core/apiClient.d.cts +0 -165
- package/dist/core/client.d.cts +0 -92
- package/dist/core/generics.d.cts +0 -120
- package/dist/core.d.cts +0 -466
- package/dist/crypto/ecies/__tests__/test-vectors.d.cts +0 -40
- package/dist/crypto/ecies/base.d.cts +0 -143
- package/dist/crypto/ecies/browser.d.cts +0 -48
- package/dist/crypto/ecies/constants.d.cts +0 -122
- package/dist/crypto/ecies/index.d.cts +0 -1
- package/dist/crypto/ecies/interface.d.cts +0 -176
- package/dist/crypto/ecies/node.d.cts +0 -50
- package/dist/crypto/ecies/utils.d.cts +0 -67
- package/dist/crypto/services/WalletKeyEncryptionService.d.cts +0 -92
- package/dist/diagnostics.d.cts +0 -26
- package/dist/errors.d.cts +0 -350
- package/dist/generated/abi/ComputeEngineImplementation.d.cts +0 -996
- package/dist/generated/abi/ComputeInstructionRegistryImplementation.d.cts +0 -545
- package/dist/generated/abi/DATFactoryImplementation.d.cts +0 -661
- package/dist/generated/abi/DATImplementation.d.cts +0 -693
- package/dist/generated/abi/DATPausableImplementation.d.cts +0 -1145
- package/dist/generated/abi/DATVotesImplementation.d.cts +0 -1095
- package/dist/generated/abi/DLPPerformanceImplementation.d.cts +0 -883
- package/dist/generated/abi/DLPRegistryImplementation.d.cts +0 -1123
- package/dist/generated/abi/DLPRegistryTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardDeployerImplementation.d.cts +0 -714
- package/dist/generated/abi/DLPRewardDeployerTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DLPRewardSwapImplementation.d.cts +0 -706
- package/dist/generated/abi/DLPRootImplementation.d.cts +0 -1248
- package/dist/generated/abi/DLPTreasuryImplementation.d.cts +0 -452
- package/dist/generated/abi/DataLiquidityPoolImplementation.d.cts +0 -737
- package/dist/generated/abi/DataPortabilityGranteesImplementation.d.cts +0 -661
- package/dist/generated/abi/DataPortabilityPermissionsImplementation.d.cts +0 -989
- package/dist/generated/abi/DataPortabilityServersImplementation.d.cts +0 -1086
- package/dist/generated/abi/DataRefinerRegistryImplementation.d.cts +0 -737
- package/dist/generated/abi/DataRegistryImplementation.d.cts +0 -1004
- package/dist/generated/abi/QueryEngineImplementation.d.cts +0 -1001
- package/dist/generated/abi/SwapHelperImplementation.d.cts +0 -764
- package/dist/generated/abi/TeePoolDedicatedGpuImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolDedicatedStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolEphemeralStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolImplementation.d.cts +0 -993
- package/dist/generated/abi/TeePoolPersistentGpuImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolPersistentStandardImplementation.d.cts +0 -701
- package/dist/generated/abi/TeePoolPhalaImplementation.d.cts +0 -993
- package/dist/generated/abi/VanaEpochImplementation.d.cts +0 -900
- package/dist/generated/abi/VanaPoolEntityImplementation.d.cts +0 -934
- package/dist/generated/abi/VanaPoolStakingImplementation.d.cts +0 -693
- package/dist/generated/abi/VanaPoolTreasuryImplementation.d.cts +0 -394
- package/dist/generated/abi/index.d.cts +0 -26516
- package/dist/generated/server/server-exports.d.cts +0 -21
- package/dist/generated/server/server.d.cts +0 -512
- package/dist/generated/subgraph.d.cts +0 -5981
- package/dist/index.browser.cjs +0 -151
- package/dist/index.browser.cjs.map +0 -1
- package/dist/index.browser.d.cts +0 -177
- package/dist/index.d.cts +0 -2
- package/dist/index.node.d.cts +0 -64
- package/dist/node.d.cts +0 -2
- package/dist/permissions-DNKPu_G0.d.cts +0 -1666
- package/dist/permissions-eo8YeLGf.d.ts +0 -1666
- package/dist/platform/browser-only.d.cts +0 -25
- package/dist/platform/browser-safe.d.cts +0 -32
- package/dist/platform/browser.d.cts +0 -74
- package/dist/platform/index.d.cts +0 -5
- package/dist/platform/interface.d.cts +0 -218
- package/dist/platform/node.d.cts +0 -27
- package/dist/platform/shared/error-utils.d.cts +0 -25
- package/dist/platform/shared/pgp-utils.d.cts +0 -61
- package/dist/platform/shared/stream-utils.d.cts +0 -16
- package/dist/platform/utils.d.cts +0 -53
- package/dist/platform.browser.cjs +0 -41
- package/dist/platform.browser.cjs.map +0 -1
- package/dist/platform.browser.d.cts +0 -4
- package/dist/platform.d.cts +0 -5
- package/dist/platform.node.d.cts +0 -5
- package/dist/server/handler.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,7 +160,7 @@ 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
|
if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
|
|
@@ -244,10 +250,11 @@ class PermissionsController {
|
|
|
244
250
|
* ```
|
|
245
251
|
*/
|
|
246
252
|
async createAndSign(params) {
|
|
253
|
+
this.assertWallet();
|
|
247
254
|
try {
|
|
248
255
|
const grantFile = createGrantFile(params);
|
|
249
256
|
validateGrant(grantFile);
|
|
250
|
-
let grantUrl = params
|
|
257
|
+
let { grantUrl } = params;
|
|
251
258
|
console.debug("\u{1F50D} Debug - Grant URL from params:", grantUrl);
|
|
252
259
|
if (!grantUrl) {
|
|
253
260
|
if (!this.context.relayerCallbacks?.storeGrantFile && !this.context.storageManager) {
|
|
@@ -335,23 +342,26 @@ class PermissionsController {
|
|
|
335
342
|
"\u{1F50D} Debug - submitSignedGrant called with typed data:",
|
|
336
343
|
JSON.stringify(
|
|
337
344
|
typedData,
|
|
338
|
-
(
|
|
345
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
339
346
|
2
|
|
340
347
|
)
|
|
341
348
|
);
|
|
342
|
-
let hash;
|
|
343
349
|
if (this.context.relayerCallbacks?.submitPermissionGrant) {
|
|
344
|
-
hash = await this.context.relayerCallbacks.submitPermissionGrant(
|
|
350
|
+
const hash = await this.context.relayerCallbacks.submitPermissionGrant(
|
|
345
351
|
typedData,
|
|
346
352
|
signature
|
|
347
353
|
);
|
|
354
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
355
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
356
|
+
return tx({
|
|
357
|
+
hash,
|
|
358
|
+
from: typeof account === "string" ? account : account.address,
|
|
359
|
+
contract: "DataPortabilityPermissions",
|
|
360
|
+
fn: "addPermission"
|
|
361
|
+
});
|
|
348
362
|
} else {
|
|
349
|
-
|
|
363
|
+
return await this.submitDirectTransaction(typedData, signature);
|
|
350
364
|
}
|
|
351
|
-
return {
|
|
352
|
-
hash,
|
|
353
|
-
from: this.context.walletClient.account?.address
|
|
354
|
-
};
|
|
355
365
|
} catch (error) {
|
|
356
366
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
357
367
|
throw error;
|
|
@@ -393,10 +403,14 @@ class PermissionsController {
|
|
|
393
403
|
trustServerInput,
|
|
394
404
|
signature
|
|
395
405
|
);
|
|
396
|
-
|
|
406
|
+
const account = this.context.userAddress;
|
|
407
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
408
|
+
return tx({
|
|
397
409
|
hash,
|
|
398
|
-
from:
|
|
399
|
-
|
|
410
|
+
from: account,
|
|
411
|
+
contract: "DataPortabilityServers",
|
|
412
|
+
fn: "trustServerWithSignature"
|
|
413
|
+
});
|
|
400
414
|
} catch (error) {
|
|
401
415
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
402
416
|
throw error;
|
|
@@ -454,10 +468,14 @@ class PermissionsController {
|
|
|
454
468
|
addAndTrustServerInput,
|
|
455
469
|
signature
|
|
456
470
|
);
|
|
457
|
-
|
|
471
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
472
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
473
|
+
return tx({
|
|
458
474
|
hash,
|
|
459
|
-
from:
|
|
460
|
-
|
|
475
|
+
from: typeof account === "string" ? account : account.address,
|
|
476
|
+
contract: "DataPortabilityServers",
|
|
477
|
+
fn: "addAndTrustServerWithSignature"
|
|
478
|
+
});
|
|
461
479
|
} catch (error) {
|
|
462
480
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
463
481
|
throw error;
|
|
@@ -468,6 +486,72 @@ class PermissionsController {
|
|
|
468
486
|
);
|
|
469
487
|
}
|
|
470
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Internal method to submit a signed grant and wait for events.
|
|
491
|
+
*
|
|
492
|
+
* @internal
|
|
493
|
+
* @param typedData - The EIP-712 typed data for the permission grant
|
|
494
|
+
* @param signature - The user's signature authorizing the transaction
|
|
495
|
+
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
496
|
+
*/
|
|
497
|
+
async submitSignedGrantWithEvents(typedData, signature) {
|
|
498
|
+
const txResult = await this.submitSignedGrant(typedData, signature);
|
|
499
|
+
if (!this.context.waitForTransactionEvents) {
|
|
500
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
501
|
+
}
|
|
502
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
503
|
+
const event = result.expectedEvents.PermissionAdded;
|
|
504
|
+
if (!event) {
|
|
505
|
+
throw new BlockchainError(
|
|
506
|
+
"PermissionAdded event not found in transaction"
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
510
|
+
hash: result.hash
|
|
511
|
+
});
|
|
512
|
+
return {
|
|
513
|
+
transactionHash: result.hash,
|
|
514
|
+
blockNumber: receipt.blockNumber,
|
|
515
|
+
gasUsed: receipt.gasUsed,
|
|
516
|
+
permissionId: event.permissionId,
|
|
517
|
+
user: event.user,
|
|
518
|
+
grant: event.grant,
|
|
519
|
+
fileIds: event.fileIds
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Internal method for confirm grant with events.
|
|
524
|
+
*
|
|
525
|
+
* @internal
|
|
526
|
+
* @param params - The permission grant parameters
|
|
527
|
+
* @param grantFile - The pre-created grant file object
|
|
528
|
+
* @returns Promise resolving to PermissionGrantResult with parsed events
|
|
529
|
+
*/
|
|
530
|
+
async confirmGrantInternalWithEvents(params, grantFile) {
|
|
531
|
+
const txResult = await this.confirmGrantInternal(params, grantFile);
|
|
532
|
+
if (!this.context.waitForTransactionEvents) {
|
|
533
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
534
|
+
}
|
|
535
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
536
|
+
const event = result.expectedEvents.PermissionAdded;
|
|
537
|
+
if (!event) {
|
|
538
|
+
throw new BlockchainError(
|
|
539
|
+
"PermissionAdded event not found in transaction"
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
543
|
+
hash: result.hash
|
|
544
|
+
});
|
|
545
|
+
return {
|
|
546
|
+
transactionHash: result.hash,
|
|
547
|
+
blockNumber: receipt.blockNumber,
|
|
548
|
+
gasUsed: receipt.gasUsed,
|
|
549
|
+
permissionId: event.permissionId,
|
|
550
|
+
user: event.user,
|
|
551
|
+
grant: event.grant,
|
|
552
|
+
fileIds: event.fileIds
|
|
553
|
+
};
|
|
554
|
+
}
|
|
471
555
|
/**
|
|
472
556
|
* Submits an already-signed permission revoke transaction to the blockchain.
|
|
473
557
|
*
|
|
@@ -498,12 +582,19 @@ class PermissionsController {
|
|
|
498
582
|
signature
|
|
499
583
|
);
|
|
500
584
|
} else {
|
|
501
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
585
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
586
|
+
typedData,
|
|
587
|
+
signature
|
|
588
|
+
);
|
|
502
589
|
}
|
|
503
|
-
|
|
590
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
591
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
592
|
+
return tx({
|
|
504
593
|
hash,
|
|
505
|
-
from:
|
|
506
|
-
|
|
594
|
+
from: typeof account === "string" ? account : account.address,
|
|
595
|
+
contract: "DataPortabilityPermissions",
|
|
596
|
+
fn: "revokePermissionWithSignature"
|
|
597
|
+
});
|
|
507
598
|
} catch (error) {
|
|
508
599
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
509
600
|
throw error;
|
|
@@ -544,12 +635,19 @@ class PermissionsController {
|
|
|
544
635
|
signature
|
|
545
636
|
);
|
|
546
637
|
} else {
|
|
547
|
-
hash = await this.submitSignedUntrustTransaction(
|
|
638
|
+
hash = await this.submitSignedUntrustTransaction(
|
|
639
|
+
typedData,
|
|
640
|
+
signature
|
|
641
|
+
);
|
|
548
642
|
}
|
|
549
|
-
|
|
643
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
644
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
645
|
+
return tx({
|
|
550
646
|
hash,
|
|
551
|
-
from:
|
|
552
|
-
|
|
647
|
+
from: typeof account === "string" ? account : account.address,
|
|
648
|
+
contract: "DataPortabilityServers",
|
|
649
|
+
fn: "untrustServerWithSignature"
|
|
650
|
+
});
|
|
553
651
|
} catch (error) {
|
|
554
652
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
555
653
|
throw error;
|
|
@@ -573,7 +671,8 @@ class PermissionsController {
|
|
|
573
671
|
* @throws {BlockchainError} When contract submission fails
|
|
574
672
|
*/
|
|
575
673
|
async submitDirectTransaction(typedData, signature) {
|
|
576
|
-
|
|
674
|
+
this.assertWallet();
|
|
675
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
577
676
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
578
677
|
chainId,
|
|
579
678
|
"DataPortabilityPermissions"
|
|
@@ -593,18 +692,25 @@ class PermissionsController {
|
|
|
593
692
|
console.debug("\u{1F50D} Debug - Grant field value:", typedData.message.grant);
|
|
594
693
|
console.debug(
|
|
595
694
|
"\u{1F50D} Debug - Grant field length:",
|
|
596
|
-
typedData.message.grant?.length
|
|
695
|
+
typedData.message.grant?.length ?? 0
|
|
597
696
|
);
|
|
598
697
|
const formattedSignature = formatSignatureForContract(signature);
|
|
698
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
599
699
|
const txHash = await this.context.walletClient.writeContract({
|
|
600
700
|
address: DataPortabilityPermissionsAddress,
|
|
601
701
|
abi: DataPortabilityPermissionsAbi,
|
|
602
702
|
functionName: "addPermission",
|
|
603
703
|
args: [permissionInput, formattedSignature],
|
|
604
|
-
account
|
|
605
|
-
chain: this.context.walletClient
|
|
704
|
+
account,
|
|
705
|
+
chain: this.context.walletClient?.chain ?? null
|
|
706
|
+
});
|
|
707
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
708
|
+
return tx({
|
|
709
|
+
hash: txHash,
|
|
710
|
+
from: typeof account === "string" ? account : account.address,
|
|
711
|
+
contract: "DataPortabilityPermissions",
|
|
712
|
+
fn: "addPermission"
|
|
606
713
|
});
|
|
607
|
-
return txHash;
|
|
608
714
|
}
|
|
609
715
|
/**
|
|
610
716
|
* Revokes a previously granted permission.
|
|
@@ -631,7 +737,27 @@ class PermissionsController {
|
|
|
631
737
|
* ```
|
|
632
738
|
*/
|
|
633
739
|
async revoke(params) {
|
|
634
|
-
|
|
740
|
+
this.assertWallet();
|
|
741
|
+
const txResult = await this.submitPermissionRevoke(params);
|
|
742
|
+
if (!this.context.waitForTransactionEvents) {
|
|
743
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
744
|
+
}
|
|
745
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
746
|
+
const event = result.expectedEvents.PermissionRevoked;
|
|
747
|
+
if (!event) {
|
|
748
|
+
throw new BlockchainError(
|
|
749
|
+
"PermissionRevoked event not found in transaction"
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
753
|
+
hash: result.hash
|
|
754
|
+
});
|
|
755
|
+
return {
|
|
756
|
+
transactionHash: result.hash,
|
|
757
|
+
blockNumber: receipt.blockNumber,
|
|
758
|
+
gasUsed: receipt.gasUsed,
|
|
759
|
+
permissionId: event.permissionId
|
|
760
|
+
};
|
|
635
761
|
}
|
|
636
762
|
/**
|
|
637
763
|
* Submits a permission revocation transaction and returns the transaction hash immediately.
|
|
@@ -640,6 +766,7 @@ class PermissionsController {
|
|
|
640
766
|
* Use this when you want to handle transaction confirmation and event parsing separately.
|
|
641
767
|
*
|
|
642
768
|
* @param params - Parameters for revoking the permission
|
|
769
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
643
770
|
* @returns Promise resolving to the transaction hash when successfully submitted
|
|
644
771
|
* @throws {BlockchainError} When revocation transaction fails
|
|
645
772
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
@@ -652,12 +779,13 @@ class PermissionsController {
|
|
|
652
779
|
* console.log(`Revocation submitted: ${txHash}`);
|
|
653
780
|
* ```
|
|
654
781
|
*/
|
|
655
|
-
async submitPermissionRevoke(params) {
|
|
782
|
+
async submitPermissionRevoke(params, options) {
|
|
783
|
+
this.assertWallet();
|
|
656
784
|
try {
|
|
657
|
-
if (!this.context.walletClient
|
|
785
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
658
786
|
throw new BlockchainError("Chain ID not available");
|
|
659
787
|
}
|
|
660
|
-
const chainId = await this.context.
|
|
788
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
661
789
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
662
790
|
chainId,
|
|
663
791
|
"DataPortabilityPermissions"
|
|
@@ -665,18 +793,33 @@ class PermissionsController {
|
|
|
665
793
|
const DataPortabilityPermissionsAbi = getAbi(
|
|
666
794
|
"DataPortabilityPermissions"
|
|
667
795
|
);
|
|
796
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
668
797
|
const txHash = await this.context.walletClient.writeContract({
|
|
669
798
|
address: DataPortabilityPermissionsAddress,
|
|
670
799
|
abi: DataPortabilityPermissionsAbi,
|
|
671
800
|
functionName: "revokePermission",
|
|
672
801
|
args: [params.permissionId],
|
|
673
|
-
account
|
|
674
|
-
chain: this.context.walletClient
|
|
802
|
+
account,
|
|
803
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
804
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
805
|
+
...options?.nonce && { nonce: options.nonce },
|
|
806
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
807
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
808
|
+
...options.maxFeePerGas && {
|
|
809
|
+
maxFeePerGas: options.maxFeePerGas
|
|
810
|
+
},
|
|
811
|
+
...options.maxPriorityFeePerGas && {
|
|
812
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
813
|
+
}
|
|
814
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
675
815
|
});
|
|
676
|
-
|
|
816
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
817
|
+
return tx({
|
|
677
818
|
hash: txHash,
|
|
678
|
-
from:
|
|
679
|
-
|
|
819
|
+
from: typeof account === "string" ? account : account.address,
|
|
820
|
+
contract: "DataPortabilityPermissions",
|
|
821
|
+
fn: "revokePermission"
|
|
822
|
+
});
|
|
680
823
|
} catch (error) {
|
|
681
824
|
if (error instanceof Error) {
|
|
682
825
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -716,8 +859,9 @@ class PermissionsController {
|
|
|
716
859
|
* ```
|
|
717
860
|
*/
|
|
718
861
|
async submitRevokeWithSignature(params) {
|
|
862
|
+
this.assertWallet();
|
|
719
863
|
try {
|
|
720
|
-
if (!this.context.walletClient
|
|
864
|
+
if (!this.context.walletClient?.chain?.id) {
|
|
721
865
|
throw new BlockchainError("Chain ID not available");
|
|
722
866
|
}
|
|
723
867
|
const nonce = await this.getPermissionsUserNonce();
|
|
@@ -744,12 +888,19 @@ class PermissionsController {
|
|
|
744
888
|
signature
|
|
745
889
|
);
|
|
746
890
|
} else {
|
|
747
|
-
hash = await this.submitDirectRevokeTransaction(
|
|
891
|
+
hash = await this.submitDirectRevokeTransaction(
|
|
892
|
+
typedData,
|
|
893
|
+
signature
|
|
894
|
+
);
|
|
748
895
|
}
|
|
749
|
-
|
|
896
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
897
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
898
|
+
return tx({
|
|
750
899
|
hash,
|
|
751
|
-
from:
|
|
752
|
-
|
|
900
|
+
from: typeof account === "string" ? account : account.address,
|
|
901
|
+
contract: "DataPortabilityPermissions",
|
|
902
|
+
fn: "revokePermissionWithSignature"
|
|
903
|
+
});
|
|
753
904
|
} catch (error) {
|
|
754
905
|
throw new PermissionError(
|
|
755
906
|
`Failed to revoke permission with signature: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -757,64 +908,6 @@ class PermissionsController {
|
|
|
757
908
|
);
|
|
758
909
|
}
|
|
759
910
|
}
|
|
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
911
|
/**
|
|
819
912
|
* Retrieves the user's current nonce from the DataPortabilityServers contract.
|
|
820
913
|
* This nonce is used for server-related operations (AddAndTrustServer, TrustServer, UntrustServer).
|
|
@@ -841,8 +934,8 @@ class PermissionsController {
|
|
|
841
934
|
*/
|
|
842
935
|
async getServersUserNonce() {
|
|
843
936
|
try {
|
|
844
|
-
const userAddress =
|
|
845
|
-
const chainId = await this.context.
|
|
937
|
+
const userAddress = this.context.userAddress;
|
|
938
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
846
939
|
const DataPortabilityServersAddress = getContractAddress(
|
|
847
940
|
chainId,
|
|
848
941
|
"DataPortabilityServers"
|
|
@@ -887,8 +980,8 @@ class PermissionsController {
|
|
|
887
980
|
*/
|
|
888
981
|
async getPermissionsUserNonce() {
|
|
889
982
|
try {
|
|
890
|
-
const userAddress =
|
|
891
|
-
const chainId = await this.context.
|
|
983
|
+
const userAddress = this.context.userAddress;
|
|
984
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
892
985
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
893
986
|
chainId,
|
|
894
987
|
"DataPortabilityPermissions"
|
|
@@ -927,7 +1020,7 @@ class PermissionsController {
|
|
|
927
1020
|
"\u{1F50D} Debug - Composing permission message with grantUrl:",
|
|
928
1021
|
params.grantUrl
|
|
929
1022
|
);
|
|
930
|
-
const chainId = await this.context.
|
|
1023
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
931
1024
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
932
1025
|
chainId,
|
|
933
1026
|
"DataPortabilityGrantees"
|
|
@@ -1036,7 +1129,7 @@ class PermissionsController {
|
|
|
1036
1129
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1037
1130
|
*/
|
|
1038
1131
|
async getPermissionDomain() {
|
|
1039
|
-
const chainId = await this.context.
|
|
1132
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1040
1133
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
1041
1134
|
chainId,
|
|
1042
1135
|
"DataPortabilityPermissions"
|
|
@@ -1055,8 +1148,9 @@ class PermissionsController {
|
|
|
1055
1148
|
* @returns Promise resolving to the cryptographic signature
|
|
1056
1149
|
*/
|
|
1057
1150
|
async signTypedData(typedData) {
|
|
1151
|
+
this.assertWallet();
|
|
1058
1152
|
try {
|
|
1059
|
-
const walletAddress = this.context.walletClient.account?.address
|
|
1153
|
+
const walletAddress = this.context.walletClient.account?.address ?? this.context.userAddress;
|
|
1060
1154
|
return await withSignatureCache(
|
|
1061
1155
|
this.context.platform.cache,
|
|
1062
1156
|
walletAddress,
|
|
@@ -1065,9 +1159,9 @@ class PermissionsController {
|
|
|
1065
1159
|
const viemCompatibleTypedData = toViemTypedDataDefinition(typedData);
|
|
1066
1160
|
return await this.context.walletClient.signTypedData({
|
|
1067
1161
|
...viemCompatibleTypedData,
|
|
1068
|
-
//
|
|
1069
|
-
//
|
|
1070
|
-
account: this.context.walletClient.account
|
|
1162
|
+
// Use the account if available, otherwise use the wallet address
|
|
1163
|
+
// This follows the same pattern used throughout this file
|
|
1164
|
+
account: this.context.walletClient.account ?? walletAddress
|
|
1071
1165
|
});
|
|
1072
1166
|
}
|
|
1073
1167
|
);
|
|
@@ -1082,17 +1176,10 @@ class PermissionsController {
|
|
|
1082
1176
|
}
|
|
1083
1177
|
}
|
|
1084
1178
|
/**
|
|
1085
|
-
* Gets the user's address from the
|
|
1179
|
+
* Gets the user's address from the context.
|
|
1086
1180
|
*
|
|
1087
|
-
* @returns
|
|
1181
|
+
* @returns The user's address
|
|
1088
1182
|
*/
|
|
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
1183
|
/**
|
|
1097
1184
|
* Gets on-chain permission grant data without expensive off-chain resolution.
|
|
1098
1185
|
*
|
|
@@ -1131,8 +1218,8 @@ class PermissionsController {
|
|
|
1131
1218
|
async getUserPermissionGrantsOnChain(options = {}) {
|
|
1132
1219
|
const { limit = 50, subgraphUrl } = options;
|
|
1133
1220
|
try {
|
|
1134
|
-
const userAddress =
|
|
1135
|
-
const graphqlEndpoint = subgraphUrl
|
|
1221
|
+
const userAddress = this.context.userAddress;
|
|
1222
|
+
const graphqlEndpoint = subgraphUrl ?? this.context.subgraphUrl;
|
|
1136
1223
|
if (!graphqlEndpoint) {
|
|
1137
1224
|
throw new BlockchainError(
|
|
1138
1225
|
"subgraphUrl is required. Please provide a valid subgraph endpoint or configure it in Vana constructor."
|
|
@@ -1184,7 +1271,7 @@ class PermissionsController {
|
|
|
1184
1271
|
);
|
|
1185
1272
|
}
|
|
1186
1273
|
const userData = result.data?.user;
|
|
1187
|
-
if (!userData
|
|
1274
|
+
if (!userData?.permissions?.length) {
|
|
1188
1275
|
return [];
|
|
1189
1276
|
}
|
|
1190
1277
|
const onChainGrants = userData.permissions.slice(0, limit).map(
|
|
@@ -1195,8 +1282,8 @@ class PermissionsController {
|
|
|
1195
1282
|
nonce: BigInt(permission.nonce),
|
|
1196
1283
|
startBlock: BigInt(permission.startBlock),
|
|
1197
1284
|
addedAtBlock: BigInt(permission.addedAtBlock),
|
|
1198
|
-
addedAtTimestamp: BigInt(permission.addedAtTimestamp
|
|
1199
|
-
transactionHash: permission.transactionHash
|
|
1285
|
+
addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
|
|
1286
|
+
transactionHash: permission.transactionHash ?? "",
|
|
1200
1287
|
grantor: userAddress,
|
|
1201
1288
|
grantee: permission.grantee,
|
|
1202
1289
|
active: !permission.endBlock || BigInt(permission.endBlock) === 0n
|
|
@@ -1217,26 +1304,6 @@ class PermissionsController {
|
|
|
1217
1304
|
);
|
|
1218
1305
|
}
|
|
1219
1306
|
}
|
|
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
1307
|
/**
|
|
1241
1308
|
* Registers a new server and immediately trusts it in the DataPortabilityServers contract.
|
|
1242
1309
|
*
|
|
@@ -1245,7 +1312,6 @@ class PermissionsController {
|
|
|
1245
1312
|
* Trusted servers can handle data export and portability requests from the user.
|
|
1246
1313
|
*
|
|
1247
1314
|
* @param params - Parameters for adding and trusting the server
|
|
1248
|
-
* @param params.owner - Ethereum address that will own this server registration
|
|
1249
1315
|
* @param params.serverAddress - Ethereum address of the server
|
|
1250
1316
|
* @param params.serverUrl - HTTPS URL where the server can be reached
|
|
1251
1317
|
* @param params.publicKey - Server's public key for encryption (hex string)
|
|
@@ -1272,6 +1338,7 @@ class PermissionsController {
|
|
|
1272
1338
|
* ```
|
|
1273
1339
|
*/
|
|
1274
1340
|
async addAndTrustServer(params) {
|
|
1341
|
+
this.assertWallet();
|
|
1275
1342
|
try {
|
|
1276
1343
|
const chainId = await this.context.walletClient.getChainId();
|
|
1277
1344
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1279,7 +1346,8 @@ class PermissionsController {
|
|
|
1279
1346
|
"DataPortabilityServers"
|
|
1280
1347
|
);
|
|
1281
1348
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1282
|
-
const
|
|
1349
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1350
|
+
const userAddress = typeof account === "string" ? account : account.address;
|
|
1283
1351
|
const normalizedUserAddress = getAddress(userAddress);
|
|
1284
1352
|
const normalizedServerAddress = getAddress(params.serverAddress);
|
|
1285
1353
|
const txHash = await this.context.walletClient.writeContract({
|
|
@@ -1294,12 +1362,40 @@ class PermissionsController {
|
|
|
1294
1362
|
publicKey: params.publicKey
|
|
1295
1363
|
}
|
|
1296
1364
|
],
|
|
1297
|
-
account
|
|
1298
|
-
chain: this.context.walletClient
|
|
1365
|
+
account,
|
|
1366
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1299
1367
|
});
|
|
1300
|
-
|
|
1368
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1369
|
+
const txResult = tx({
|
|
1301
1370
|
hash: txHash,
|
|
1302
|
-
from:
|
|
1371
|
+
from: userAddress,
|
|
1372
|
+
contract: "DataPortabilityServers",
|
|
1373
|
+
fn: "addAndTrustServerByManager"
|
|
1374
|
+
});
|
|
1375
|
+
if (!this.context.waitForTransactionEvents) {
|
|
1376
|
+
throw new BlockchainError("waitForTransactionEvents not configured");
|
|
1377
|
+
}
|
|
1378
|
+
const result = await this.context.waitForTransactionEvents(txResult);
|
|
1379
|
+
const event = result.expectedEvents.ServerTrusted;
|
|
1380
|
+
if (!event) {
|
|
1381
|
+
throw new BlockchainError(
|
|
1382
|
+
"ServerTrusted event not found in transaction"
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
const receipt = await this.context.publicClient.getTransactionReceipt({
|
|
1386
|
+
hash: txHash
|
|
1387
|
+
});
|
|
1388
|
+
return {
|
|
1389
|
+
transactionHash: txHash,
|
|
1390
|
+
blockNumber: receipt.blockNumber,
|
|
1391
|
+
gasUsed: receipt.gasUsed,
|
|
1392
|
+
user: event.user,
|
|
1393
|
+
serverId: event.serverId,
|
|
1394
|
+
// bigint from event
|
|
1395
|
+
serverAddress: normalizedServerAddress,
|
|
1396
|
+
// derived from params
|
|
1397
|
+
serverUrl: params.serverUrl
|
|
1398
|
+
// provided in params
|
|
1303
1399
|
};
|
|
1304
1400
|
} catch (error) {
|
|
1305
1401
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
@@ -1319,6 +1415,7 @@ class PermissionsController {
|
|
|
1319
1415
|
* @deprecated Use addAndTrustServer instead
|
|
1320
1416
|
*/
|
|
1321
1417
|
async submitTrustServer(params) {
|
|
1418
|
+
this.assertWallet();
|
|
1322
1419
|
try {
|
|
1323
1420
|
const chainId = await this.context.walletClient.getChainId();
|
|
1324
1421
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1326,18 +1423,22 @@ class PermissionsController {
|
|
|
1326
1423
|
"DataPortabilityServers"
|
|
1327
1424
|
);
|
|
1328
1425
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1426
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1329
1427
|
const txHash = await this.context.walletClient.writeContract({
|
|
1330
1428
|
address: DataPortabilityServersAddress,
|
|
1331
1429
|
abi: DataPortabilityServersAbi,
|
|
1332
1430
|
functionName: "trustServer",
|
|
1333
1431
|
args: [BigInt(params.serverId)],
|
|
1334
|
-
account
|
|
1335
|
-
chain: this.context.walletClient
|
|
1432
|
+
account,
|
|
1433
|
+
chain: this.context.walletClient?.chain ?? null
|
|
1336
1434
|
});
|
|
1337
|
-
|
|
1435
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1436
|
+
return tx({
|
|
1338
1437
|
hash: txHash,
|
|
1339
|
-
from:
|
|
1340
|
-
|
|
1438
|
+
from: typeof account === "string" ? account : account.address,
|
|
1439
|
+
contract: "DataPortabilityServers",
|
|
1440
|
+
fn: "trustServer"
|
|
1441
|
+
});
|
|
1341
1442
|
} catch (error) {
|
|
1342
1443
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
1343
1444
|
throw new UserRejectedRequestError();
|
|
@@ -1355,6 +1456,7 @@ class PermissionsController {
|
|
|
1355
1456
|
* @returns Promise resolving to TransactionResult with ServerTrustResult event data
|
|
1356
1457
|
*/
|
|
1357
1458
|
async submitAddAndTrustServerWithSignature(params) {
|
|
1459
|
+
this.assertWallet();
|
|
1358
1460
|
try {
|
|
1359
1461
|
const nonce = await this.getServersUserNonce();
|
|
1360
1462
|
const serverAddress = getAddress(params.serverAddress);
|
|
@@ -1389,10 +1491,14 @@ class PermissionsController {
|
|
|
1389
1491
|
signature
|
|
1390
1492
|
);
|
|
1391
1493
|
}
|
|
1392
|
-
|
|
1494
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1495
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1496
|
+
return tx({
|
|
1393
1497
|
hash,
|
|
1394
|
-
from:
|
|
1395
|
-
|
|
1498
|
+
from: typeof account === "string" ? account : account.address,
|
|
1499
|
+
contract: "DataPortabilityServers",
|
|
1500
|
+
fn: "addAndTrustServerWithSignature"
|
|
1501
|
+
});
|
|
1396
1502
|
} catch (error) {
|
|
1397
1503
|
if (error instanceof Error) {
|
|
1398
1504
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -1422,6 +1528,7 @@ class PermissionsController {
|
|
|
1422
1528
|
* @throws {BlockchainError} When trust operation fails for any other reason
|
|
1423
1529
|
*/
|
|
1424
1530
|
async submitTrustServerWithSignature(params) {
|
|
1531
|
+
this.assertWallet();
|
|
1425
1532
|
try {
|
|
1426
1533
|
const nonce = await this.getServersUserNonce();
|
|
1427
1534
|
const trustServerInput = {
|
|
@@ -1442,10 +1549,14 @@ class PermissionsController {
|
|
|
1442
1549
|
signature
|
|
1443
1550
|
);
|
|
1444
1551
|
}
|
|
1445
|
-
|
|
1552
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1553
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1554
|
+
return tx({
|
|
1446
1555
|
hash,
|
|
1447
|
-
from:
|
|
1448
|
-
|
|
1556
|
+
from: typeof account === "string" ? account : account.address,
|
|
1557
|
+
contract: "DataPortabilityServers",
|
|
1558
|
+
fn: "trustServerWithSignature"
|
|
1559
|
+
});
|
|
1449
1560
|
} catch (error) {
|
|
1450
1561
|
if (error instanceof Error) {
|
|
1451
1562
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -1476,7 +1587,8 @@ class PermissionsController {
|
|
|
1476
1587
|
* @returns Promise resolving to TransactionResult for transaction tracking
|
|
1477
1588
|
* @throws {BlockchainError} When contract submission fails
|
|
1478
1589
|
*/
|
|
1479
|
-
async submitDirectUntrustTransaction(params) {
|
|
1590
|
+
async submitDirectUntrustTransaction(params, options) {
|
|
1591
|
+
this.assertWallet();
|
|
1480
1592
|
try {
|
|
1481
1593
|
const chainId = await this.context.walletClient.getChainId();
|
|
1482
1594
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -1484,18 +1596,33 @@ class PermissionsController {
|
|
|
1484
1596
|
"DataPortabilityServers"
|
|
1485
1597
|
);
|
|
1486
1598
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
1599
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1487
1600
|
const txHash = await this.context.walletClient.writeContract({
|
|
1488
1601
|
address: DataPortabilityServersAddress,
|
|
1489
1602
|
abi: DataPortabilityServersAbi,
|
|
1490
1603
|
functionName: "untrustServer",
|
|
1491
1604
|
args: [BigInt(params.serverId)],
|
|
1492
|
-
account
|
|
1493
|
-
chain: this.context.walletClient
|
|
1605
|
+
account,
|
|
1606
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
1607
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
1608
|
+
...options?.nonce && { nonce: options.nonce },
|
|
1609
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
1610
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
1611
|
+
...options.maxFeePerGas && {
|
|
1612
|
+
maxFeePerGas: options.maxFeePerGas
|
|
1613
|
+
},
|
|
1614
|
+
...options.maxPriorityFeePerGas && {
|
|
1615
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
1616
|
+
}
|
|
1617
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
1494
1618
|
});
|
|
1495
|
-
|
|
1619
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1620
|
+
return tx({
|
|
1496
1621
|
hash: txHash,
|
|
1497
|
-
from:
|
|
1498
|
-
|
|
1622
|
+
from: typeof account === "string" ? account : account.address,
|
|
1623
|
+
contract: "DataPortabilityServers",
|
|
1624
|
+
fn: "untrustServer"
|
|
1625
|
+
});
|
|
1499
1626
|
} catch (error) {
|
|
1500
1627
|
if (error instanceof Error && error.message.includes("rejected")) {
|
|
1501
1628
|
throw new UserRejectedRequestError();
|
|
@@ -1514,6 +1641,7 @@ class PermissionsController {
|
|
|
1514
1641
|
*
|
|
1515
1642
|
* @param params - Parameters for untrusting the server
|
|
1516
1643
|
* @param params.serverId - The numeric ID of the server to untrust
|
|
1644
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
1517
1645
|
* @returns Promise resolving to transaction hash
|
|
1518
1646
|
* @throws {Error} When wallet account is not available
|
|
1519
1647
|
* @throws {NonceError} When retrieving user nonce fails
|
|
@@ -1534,13 +1662,17 @@ class PermissionsController {
|
|
|
1534
1662
|
* console.log('Still trusting servers:', trustedServers);
|
|
1535
1663
|
* ```
|
|
1536
1664
|
*/
|
|
1537
|
-
async submitUntrustServer(params) {
|
|
1665
|
+
async submitUntrustServer(params, options) {
|
|
1666
|
+
this.assertWallet();
|
|
1538
1667
|
const nonce = await this.getServersUserNonce();
|
|
1539
1668
|
const untrustServerInput = {
|
|
1540
1669
|
nonce,
|
|
1541
1670
|
serverId: params.serverId
|
|
1542
1671
|
};
|
|
1543
|
-
return await this.submitDirectUntrustTransaction(
|
|
1672
|
+
return await this.submitDirectUntrustTransaction(
|
|
1673
|
+
untrustServerInput,
|
|
1674
|
+
options
|
|
1675
|
+
);
|
|
1544
1676
|
}
|
|
1545
1677
|
/**
|
|
1546
1678
|
* Untrusts a server using a signature (gasless transaction).
|
|
@@ -1555,6 +1687,7 @@ class PermissionsController {
|
|
|
1555
1687
|
* @throws {BlockchainError} When untrust transaction fails
|
|
1556
1688
|
*/
|
|
1557
1689
|
async submitUntrustServerWithSignature(params) {
|
|
1690
|
+
this.assertWallet();
|
|
1558
1691
|
try {
|
|
1559
1692
|
const nonce = await this.getServersUserNonce();
|
|
1560
1693
|
const untrustServerInput = {
|
|
@@ -1572,10 +1705,14 @@ class PermissionsController {
|
|
|
1572
1705
|
} else {
|
|
1573
1706
|
hash = await this.submitSignedUntrustTransaction(typedData, signature);
|
|
1574
1707
|
}
|
|
1575
|
-
|
|
1708
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
1709
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
1710
|
+
return tx({
|
|
1576
1711
|
hash,
|
|
1577
|
-
from:
|
|
1578
|
-
|
|
1712
|
+
from: typeof account === "string" ? account : account.address,
|
|
1713
|
+
contract: "DataPortabilityServers",
|
|
1714
|
+
fn: "untrustServerWithSignature"
|
|
1715
|
+
});
|
|
1579
1716
|
} catch (error) {
|
|
1580
1717
|
if (error instanceof Error) {
|
|
1581
1718
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -1613,8 +1750,8 @@ class PermissionsController {
|
|
|
1613
1750
|
*/
|
|
1614
1751
|
async getTrustedServers(userAddress) {
|
|
1615
1752
|
try {
|
|
1616
|
-
const user = userAddress
|
|
1617
|
-
const chainId = await this.context.
|
|
1753
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1754
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1618
1755
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1619
1756
|
chainId,
|
|
1620
1757
|
"DataPortabilityServers"
|
|
@@ -1643,8 +1780,8 @@ class PermissionsController {
|
|
|
1643
1780
|
*/
|
|
1644
1781
|
async getTrustedServersCount(userAddress) {
|
|
1645
1782
|
try {
|
|
1646
|
-
const user = userAddress
|
|
1647
|
-
const chainId = await this.context.
|
|
1783
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1784
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1648
1785
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1649
1786
|
chainId,
|
|
1650
1787
|
"DataPortabilityServers"
|
|
@@ -1673,10 +1810,10 @@ class PermissionsController {
|
|
|
1673
1810
|
*/
|
|
1674
1811
|
async getTrustedServersPaginated(options = {}) {
|
|
1675
1812
|
try {
|
|
1676
|
-
const user = options.userAddress
|
|
1677
|
-
const limit = options.limit
|
|
1678
|
-
const offset = options.offset
|
|
1679
|
-
const chainId = await this.context.
|
|
1813
|
+
const user = options.userAddress ?? this.context.userAddress;
|
|
1814
|
+
const limit = options.limit ?? 50;
|
|
1815
|
+
const offset = options.offset ?? 0;
|
|
1816
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1680
1817
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1681
1818
|
chainId,
|
|
1682
1819
|
"DataPortabilityServers"
|
|
@@ -1822,7 +1959,7 @@ class PermissionsController {
|
|
|
1822
1959
|
};
|
|
1823
1960
|
}
|
|
1824
1961
|
try {
|
|
1825
|
-
const chainId = await this.context.
|
|
1962
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1826
1963
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1827
1964
|
chainId,
|
|
1828
1965
|
"DataPortabilityServers"
|
|
@@ -1897,7 +2034,7 @@ class PermissionsController {
|
|
|
1897
2034
|
*/
|
|
1898
2035
|
async checkServerTrustStatus(serverId, userAddress) {
|
|
1899
2036
|
try {
|
|
1900
|
-
const user = userAddress
|
|
2037
|
+
const user = userAddress ?? this.context.userAddress;
|
|
1901
2038
|
const trustedServers = await this.getTrustedServers(user);
|
|
1902
2039
|
const trustIndex = trustedServers.findIndex(
|
|
1903
2040
|
(server) => server === serverId
|
|
@@ -1987,7 +2124,7 @@ class PermissionsController {
|
|
|
1987
2124
|
* @returns Promise resolving to the EIP-712 domain configuration
|
|
1988
2125
|
*/
|
|
1989
2126
|
async getServersDomain() {
|
|
1990
|
-
const chainId = await this.context.
|
|
2127
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
1991
2128
|
const DataPortabilityServersAddress = getContractAddress(
|
|
1992
2129
|
chainId,
|
|
1993
2130
|
"DataPortabilityServers"
|
|
@@ -2007,6 +2144,7 @@ class PermissionsController {
|
|
|
2007
2144
|
* @returns Promise resolving to the transaction hash
|
|
2008
2145
|
*/
|
|
2009
2146
|
async submitAddAndTrustServerTransaction(addAndTrustServerInput, signature) {
|
|
2147
|
+
this.assertWallet();
|
|
2010
2148
|
const chainId = await this.context.walletClient.getChainId();
|
|
2011
2149
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2012
2150
|
chainId,
|
|
@@ -2038,8 +2176,8 @@ class PermissionsController {
|
|
|
2038
2176
|
},
|
|
2039
2177
|
formattedSignature
|
|
2040
2178
|
],
|
|
2041
|
-
account: this.context.walletClient
|
|
2042
|
-
chain: this.context.walletClient
|
|
2179
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2180
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2043
2181
|
});
|
|
2044
2182
|
return txHash;
|
|
2045
2183
|
}
|
|
@@ -2051,6 +2189,7 @@ class PermissionsController {
|
|
|
2051
2189
|
* @returns Promise resolving to the transaction hash
|
|
2052
2190
|
*/
|
|
2053
2191
|
async submitTrustServerTransaction(trustServerInput, signature) {
|
|
2192
|
+
this.assertWallet();
|
|
2054
2193
|
const chainId = await this.context.walletClient.getChainId();
|
|
2055
2194
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2056
2195
|
chainId,
|
|
@@ -2069,8 +2208,8 @@ class PermissionsController {
|
|
|
2069
2208
|
},
|
|
2070
2209
|
formattedSignature
|
|
2071
2210
|
],
|
|
2072
|
-
account: this.context.walletClient
|
|
2073
|
-
chain: this.context.walletClient
|
|
2211
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2212
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2074
2213
|
});
|
|
2075
2214
|
return txHash;
|
|
2076
2215
|
}
|
|
@@ -2082,6 +2221,7 @@ class PermissionsController {
|
|
|
2082
2221
|
* @returns Promise resolving to the transaction hash
|
|
2083
2222
|
*/
|
|
2084
2223
|
async submitDirectRevokeTransaction(typedData, signature) {
|
|
2224
|
+
this.assertWallet();
|
|
2085
2225
|
const chainId = await this.context.walletClient.getChainId();
|
|
2086
2226
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2087
2227
|
chainId,
|
|
@@ -2093,10 +2233,9 @@ class PermissionsController {
|
|
|
2093
2233
|
address: DataPortabilityPermissionsAddress,
|
|
2094
2234
|
abi: DataPortabilityPermissionsAbi,
|
|
2095
2235
|
functionName: "revokePermissionWithSignature",
|
|
2096
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2097
2236
|
args: [typedData.message, formattedSignature],
|
|
2098
|
-
account: this.context.walletClient
|
|
2099
|
-
chain: this.context.walletClient
|
|
2237
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2238
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2100
2239
|
});
|
|
2101
2240
|
return txHash;
|
|
2102
2241
|
}
|
|
@@ -2108,6 +2247,7 @@ class PermissionsController {
|
|
|
2108
2247
|
* @returns Promise resolving to the transaction hash
|
|
2109
2248
|
*/
|
|
2110
2249
|
async submitSignedUntrustTransaction(typedData, signature) {
|
|
2250
|
+
this.assertWallet();
|
|
2111
2251
|
const chainId = await this.context.walletClient.getChainId();
|
|
2112
2252
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2113
2253
|
chainId,
|
|
@@ -2115,14 +2255,17 @@ class PermissionsController {
|
|
|
2115
2255
|
);
|
|
2116
2256
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
2117
2257
|
const formattedSignature = formatSignatureForContract(signature);
|
|
2258
|
+
const contractMessage = {
|
|
2259
|
+
nonce: typedData.message.nonce,
|
|
2260
|
+
serverId: BigInt(typedData.message.serverId)
|
|
2261
|
+
};
|
|
2118
2262
|
const txHash = await this.context.walletClient.writeContract({
|
|
2119
2263
|
address: DataPortabilityServersAddress,
|
|
2120
2264
|
abi: DataPortabilityServersAbi,
|
|
2121
2265
|
functionName: "untrustServerWithSignature",
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
chain: this.context.walletClient.chain || null
|
|
2266
|
+
args: [contractMessage, formattedSignature],
|
|
2267
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2268
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2126
2269
|
});
|
|
2127
2270
|
return txHash;
|
|
2128
2271
|
}
|
|
@@ -2139,6 +2282,7 @@ class PermissionsController {
|
|
|
2139
2282
|
* @param params.owner - The Ethereum address that will own this grantee registration
|
|
2140
2283
|
* @param params.granteeAddress - The Ethereum address of the grantee (application)
|
|
2141
2284
|
* @param params.publicKey - The public key used for data encryption/decryption (hex string)
|
|
2285
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
2142
2286
|
* @returns Promise resolving to the transaction hash
|
|
2143
2287
|
* @throws {BlockchainError} When the grantee registration transaction fails
|
|
2144
2288
|
* @throws {UserRejectedRequestError} When user rejects the transaction
|
|
@@ -2154,7 +2298,8 @@ class PermissionsController {
|
|
|
2154
2298
|
* console.log(`Grantee registered in transaction: ${txHash}`);
|
|
2155
2299
|
* ```
|
|
2156
2300
|
*/
|
|
2157
|
-
async submitRegisterGrantee(params) {
|
|
2301
|
+
async submitRegisterGrantee(params, options) {
|
|
2302
|
+
this.assertWallet();
|
|
2158
2303
|
const chainId = await this.context.walletClient.getChainId();
|
|
2159
2304
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
2160
2305
|
chainId,
|
|
@@ -2163,18 +2308,31 @@ class PermissionsController {
|
|
|
2163
2308
|
const DataPortabilityGranteesAbi = getAbi("DataPortabilityGrantees");
|
|
2164
2309
|
const ownerAddress = getAddress(params.owner);
|
|
2165
2310
|
const granteeAddress = getAddress(params.granteeAddress);
|
|
2311
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2166
2312
|
const txHash = await this.context.walletClient.writeContract({
|
|
2167
2313
|
address: DataPortabilityGranteesAddress,
|
|
2168
2314
|
abi: DataPortabilityGranteesAbi,
|
|
2169
2315
|
functionName: "registerGrantee",
|
|
2170
2316
|
args: [ownerAddress, granteeAddress, params.publicKey],
|
|
2171
|
-
account
|
|
2172
|
-
chain: this.context.walletClient
|
|
2317
|
+
account,
|
|
2318
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
2319
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
2320
|
+
...options?.nonce && { nonce: options.nonce },
|
|
2321
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
2322
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
2323
|
+
...options.maxFeePerGas && { maxFeePerGas: options.maxFeePerGas },
|
|
2324
|
+
...options.maxPriorityFeePerGas && {
|
|
2325
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
2326
|
+
}
|
|
2327
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
2173
2328
|
});
|
|
2174
|
-
|
|
2329
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
2330
|
+
return tx({
|
|
2175
2331
|
hash: txHash,
|
|
2176
|
-
from:
|
|
2177
|
-
|
|
2332
|
+
from: typeof account === "string" ? account : account.address,
|
|
2333
|
+
contract: "DataPortabilityGrantees",
|
|
2334
|
+
fn: "registerGrantee"
|
|
2335
|
+
});
|
|
2178
2336
|
}
|
|
2179
2337
|
/**
|
|
2180
2338
|
* Registers a grantee with a signature (gasless transaction)
|
|
@@ -2192,6 +2350,7 @@ class PermissionsController {
|
|
|
2192
2350
|
* ```
|
|
2193
2351
|
*/
|
|
2194
2352
|
async submitRegisterGranteeWithSignature(params) {
|
|
2353
|
+
this.assertWallet();
|
|
2195
2354
|
const nonce = await this.getServersUserNonce();
|
|
2196
2355
|
const owner = getAddress(params.owner);
|
|
2197
2356
|
const granteeAddress = getAddress(params.granteeAddress);
|
|
@@ -2207,10 +2366,14 @@ class PermissionsController {
|
|
|
2207
2366
|
typedData,
|
|
2208
2367
|
signature
|
|
2209
2368
|
);
|
|
2210
|
-
|
|
2369
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2370
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
2371
|
+
return tx({
|
|
2211
2372
|
hash,
|
|
2212
|
-
from:
|
|
2213
|
-
|
|
2373
|
+
from: typeof account === "string" ? account : account.address,
|
|
2374
|
+
contract: "DataPortabilityGrantees",
|
|
2375
|
+
fn: "registerGrantee"
|
|
2376
|
+
});
|
|
2214
2377
|
}
|
|
2215
2378
|
/**
|
|
2216
2379
|
* Submits a signed register grantee transaction via relayer
|
|
@@ -2229,10 +2392,14 @@ class PermissionsController {
|
|
|
2229
2392
|
typedData,
|
|
2230
2393
|
signature
|
|
2231
2394
|
);
|
|
2232
|
-
|
|
2395
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
2396
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
2397
|
+
return tx({
|
|
2233
2398
|
hash,
|
|
2234
|
-
from:
|
|
2235
|
-
|
|
2399
|
+
from: typeof account === "string" ? account : account.address,
|
|
2400
|
+
contract: "DataPortabilityGrantees",
|
|
2401
|
+
fn: "registerGrantee"
|
|
2402
|
+
});
|
|
2236
2403
|
}
|
|
2237
2404
|
/**
|
|
2238
2405
|
* Retrieves all registered grantees from the DataPortabilityGrantees contract.
|
|
@@ -2279,8 +2446,8 @@ class PermissionsController {
|
|
|
2279
2446
|
functionName: "granteesCount"
|
|
2280
2447
|
});
|
|
2281
2448
|
const total = Number(totalCount);
|
|
2282
|
-
const limit = options.limit
|
|
2283
|
-
const offset = options.offset
|
|
2449
|
+
const limit = options.limit ?? 50;
|
|
2450
|
+
const offset = options.offset ?? 0;
|
|
2284
2451
|
const grantees = [];
|
|
2285
2452
|
const endIndex = Math.min(offset + limit, total);
|
|
2286
2453
|
for (let i = offset; i < endIndex; i++) {
|
|
@@ -2428,7 +2595,7 @@ class PermissionsController {
|
|
|
2428
2595
|
* @private
|
|
2429
2596
|
*/
|
|
2430
2597
|
async buildRegisterGranteeTypedData(input) {
|
|
2431
|
-
const chainId = await this.context.
|
|
2598
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
2432
2599
|
const verifyingContract = getContractAddress(
|
|
2433
2600
|
chainId,
|
|
2434
2601
|
"DataPortabilityGrantees"
|
|
@@ -2461,6 +2628,7 @@ class PermissionsController {
|
|
|
2461
2628
|
* @private
|
|
2462
2629
|
*/
|
|
2463
2630
|
async submitSignedRegisterGranteeTransaction(typedData, _signature) {
|
|
2631
|
+
this.assertWallet();
|
|
2464
2632
|
const chainId = await this.context.walletClient.getChainId();
|
|
2465
2633
|
const DataPortabilityGranteesAddress = getContractAddress(
|
|
2466
2634
|
chainId,
|
|
@@ -2476,8 +2644,8 @@ class PermissionsController {
|
|
|
2476
2644
|
typedData.message.granteeAddress,
|
|
2477
2645
|
typedData.message.publicKey
|
|
2478
2646
|
],
|
|
2479
|
-
account: this.context.walletClient
|
|
2480
|
-
chain: this.context.walletClient
|
|
2647
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
2648
|
+
chain: this.context.walletClient?.chain ?? null
|
|
2481
2649
|
});
|
|
2482
2650
|
return txHash;
|
|
2483
2651
|
}
|
|
@@ -2492,7 +2660,7 @@ class PermissionsController {
|
|
|
2492
2660
|
*/
|
|
2493
2661
|
async getUserServerIds(userAddress) {
|
|
2494
2662
|
try {
|
|
2495
|
-
const targetAddress = userAddress
|
|
2663
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2496
2664
|
const chainId = await this.context.publicClient.getChainId();
|
|
2497
2665
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2498
2666
|
chainId,
|
|
@@ -2550,7 +2718,7 @@ class PermissionsController {
|
|
|
2550
2718
|
*/
|
|
2551
2719
|
async getUserServerCount(userAddress) {
|
|
2552
2720
|
try {
|
|
2553
|
-
const targetAddress = userAddress
|
|
2721
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2554
2722
|
const chainId = await this.context.publicClient.getChainId();
|
|
2555
2723
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2556
2724
|
chainId,
|
|
@@ -2579,7 +2747,7 @@ class PermissionsController {
|
|
|
2579
2747
|
*/
|
|
2580
2748
|
async getUserTrustedServers(userAddress) {
|
|
2581
2749
|
try {
|
|
2582
|
-
const targetAddress = userAddress
|
|
2750
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2583
2751
|
const chainId = await this.context.publicClient.getChainId();
|
|
2584
2752
|
const DataPortabilityServersAddress = getContractAddress(
|
|
2585
2753
|
chainId,
|
|
@@ -2696,7 +2864,7 @@ class PermissionsController {
|
|
|
2696
2864
|
*/
|
|
2697
2865
|
async getUserPermissionIds(userAddress) {
|
|
2698
2866
|
try {
|
|
2699
|
-
const targetAddress = userAddress
|
|
2867
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2700
2868
|
const chainId = await this.context.publicClient.getChainId();
|
|
2701
2869
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2702
2870
|
chainId,
|
|
@@ -2758,7 +2926,7 @@ class PermissionsController {
|
|
|
2758
2926
|
*/
|
|
2759
2927
|
async getUserPermissionCount(userAddress) {
|
|
2760
2928
|
try {
|
|
2761
|
-
const targetAddress = userAddress
|
|
2929
|
+
const targetAddress = userAddress ?? this.context.userAddress;
|
|
2762
2930
|
const chainId = await this.context.publicClient.getChainId();
|
|
2763
2931
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
2764
2932
|
chainId,
|
|
@@ -3200,9 +3368,11 @@ class PermissionsController {
|
|
|
3200
3368
|
*
|
|
3201
3369
|
* @param serverId - Server ID to update
|
|
3202
3370
|
* @param url - New URL for the server
|
|
3371
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
3203
3372
|
* @returns Promise resolving to transaction hash
|
|
3204
3373
|
*/
|
|
3205
|
-
async submitUpdateServer(serverId, url) {
|
|
3374
|
+
async submitUpdateServer(serverId, url, options) {
|
|
3375
|
+
this.assertWallet();
|
|
3206
3376
|
try {
|
|
3207
3377
|
const chainId = await this.context.walletClient.getChainId();
|
|
3208
3378
|
const DataPortabilityServersAddress = getContractAddress(
|
|
@@ -3210,18 +3380,33 @@ class PermissionsController {
|
|
|
3210
3380
|
"DataPortabilityServers"
|
|
3211
3381
|
);
|
|
3212
3382
|
const DataPortabilityServersAbi = getAbi("DataPortabilityServers");
|
|
3383
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3213
3384
|
const hash = await this.context.walletClient.writeContract({
|
|
3214
3385
|
address: DataPortabilityServersAddress,
|
|
3215
3386
|
abi: DataPortabilityServersAbi,
|
|
3216
3387
|
functionName: "updateServer",
|
|
3217
3388
|
args: [serverId, url],
|
|
3218
|
-
chain: this.context.walletClient
|
|
3219
|
-
account
|
|
3389
|
+
chain: this.context.walletClient?.chain,
|
|
3390
|
+
account,
|
|
3391
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
3392
|
+
...options?.nonce && { nonce: options.nonce },
|
|
3393
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3394
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3395
|
+
...options.maxFeePerGas && {
|
|
3396
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3397
|
+
},
|
|
3398
|
+
...options.maxPriorityFeePerGas && {
|
|
3399
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3400
|
+
}
|
|
3401
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3220
3402
|
});
|
|
3221
|
-
|
|
3403
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3404
|
+
return tx({
|
|
3222
3405
|
hash,
|
|
3223
|
-
from:
|
|
3224
|
-
|
|
3406
|
+
from: typeof account === "string" ? account : account.address,
|
|
3407
|
+
contract: "DataPortabilityServers",
|
|
3408
|
+
fn: "updateServer"
|
|
3409
|
+
});
|
|
3225
3410
|
} catch (error) {
|
|
3226
3411
|
throw new BlockchainError(
|
|
3227
3412
|
`Failed to update server: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3371,6 +3556,7 @@ class PermissionsController {
|
|
|
3371
3556
|
* @throws {NetworkError} When network communication fails
|
|
3372
3557
|
*/
|
|
3373
3558
|
async submitAddPermission(params) {
|
|
3559
|
+
this.assertWallet();
|
|
3374
3560
|
try {
|
|
3375
3561
|
const nonce = await this.getPermissionsUserNonce();
|
|
3376
3562
|
const addPermissionInput = {
|
|
@@ -3409,6 +3595,7 @@ class PermissionsController {
|
|
|
3409
3595
|
* @throws {NetworkError} When network communication fails
|
|
3410
3596
|
*/
|
|
3411
3597
|
async submitSignedAddPermission(typedData, signature) {
|
|
3598
|
+
this.assertWallet();
|
|
3412
3599
|
try {
|
|
3413
3600
|
let hash;
|
|
3414
3601
|
if (this.context.relayerCallbacks?.submitAddPermission) {
|
|
@@ -3422,10 +3609,14 @@ class PermissionsController {
|
|
|
3422
3609
|
signature
|
|
3423
3610
|
);
|
|
3424
3611
|
}
|
|
3425
|
-
|
|
3612
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3613
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3614
|
+
return tx({
|
|
3426
3615
|
hash,
|
|
3427
|
-
from:
|
|
3428
|
-
|
|
3616
|
+
from: typeof account === "string" ? account : account.address,
|
|
3617
|
+
contract: "DataPortabilityPermissions",
|
|
3618
|
+
fn: "addPermission"
|
|
3619
|
+
});
|
|
3429
3620
|
} catch (error) {
|
|
3430
3621
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
3431
3622
|
throw error;
|
|
@@ -3454,8 +3645,11 @@ class PermissionsController {
|
|
|
3454
3645
|
* @param params.serverAddress - Server wallet address for decryption permissions
|
|
3455
3646
|
* @param params.serverUrl - Server endpoint URL
|
|
3456
3647
|
* @param params.serverPublicKey - Server's public key for encryption.
|
|
3457
|
-
* Obtain via `vana.server.getIdentity(userAddress).
|
|
3648
|
+
* Obtain via `vana.server.getIdentity(userAddress).publicKey`.
|
|
3458
3649
|
* @param params.filePermissions - Nested array of permissions for each file
|
|
3650
|
+
* @param options - Optional transaction options for gas parameters and timeout.
|
|
3651
|
+
* Note: These options are only applied for direct blockchain transactions.
|
|
3652
|
+
* When using relayer callbacks (gasless transactions), these options are ignored.
|
|
3459
3653
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3460
3654
|
* @throws {Error} When schemaIds array length doesn't match fileUrls array length
|
|
3461
3655
|
* @throws {SchemaValidationError} When file data doesn't match the specified schema.
|
|
@@ -3469,6 +3663,7 @@ class PermissionsController {
|
|
|
3469
3663
|
*
|
|
3470
3664
|
* @example
|
|
3471
3665
|
* ```typescript
|
|
3666
|
+
* // Submit with custom gas parameters and timeout
|
|
3472
3667
|
* const result = await vana.permissions.submitAddServerFilesAndPermissions({
|
|
3473
3668
|
* granteeId: BigInt(1),
|
|
3474
3669
|
* grant: "ipfs://QmXxx...",
|
|
@@ -3476,17 +3671,25 @@ class PermissionsController {
|
|
|
3476
3671
|
* schemaIds: [123], // LinkedIn profile schema ID
|
|
3477
3672
|
* serverAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3478
3673
|
* serverUrl: "https://server.example.com",
|
|
3479
|
-
* serverPublicKey: serverInfo.
|
|
3674
|
+
* serverPublicKey: serverInfo.publicKey,
|
|
3480
3675
|
* filePermissions: [[{
|
|
3481
3676
|
* account: "0x742d35Cc6634C0532925a3b844Bc9e7595f0b0Bb",
|
|
3482
3677
|
* key: encryptedKey
|
|
3483
3678
|
* }]]
|
|
3679
|
+
* }, {
|
|
3680
|
+
* maxFeePerGas: 100n * 10n ** 9n, // 100 gwei
|
|
3681
|
+
* maxPriorityFeePerGas: 2n * 10n ** 9n, // 2 gwei tip
|
|
3484
3682
|
* });
|
|
3485
|
-
*
|
|
3486
|
-
*
|
|
3683
|
+
*
|
|
3684
|
+
* // Wait for confirmation with custom timeout
|
|
3685
|
+
* const receipt = await vana.waitForTransactionReceipt(result, {
|
|
3686
|
+
* timeout: 180000 // 3 minutes
|
|
3687
|
+
* });
|
|
3688
|
+
* console.log(`Transaction confirmed: ${receipt.transactionHash}`);
|
|
3487
3689
|
* ```
|
|
3488
3690
|
*/
|
|
3489
|
-
async submitAddServerFilesAndPermissions(params) {
|
|
3691
|
+
async submitAddServerFilesAndPermissions(params, options) {
|
|
3692
|
+
this.assertWallet();
|
|
3490
3693
|
try {
|
|
3491
3694
|
if (params.schemaIds.length !== params.fileUrls.length) {
|
|
3492
3695
|
throw new Error(
|
|
@@ -3511,7 +3714,8 @@ class PermissionsController {
|
|
|
3511
3714
|
const signature = await this.signTypedData(typedData);
|
|
3512
3715
|
return await this.submitSignedAddServerFilesAndPermissions(
|
|
3513
3716
|
typedData,
|
|
3514
|
-
signature
|
|
3717
|
+
signature,
|
|
3718
|
+
options
|
|
3515
3719
|
);
|
|
3516
3720
|
} catch (error) {
|
|
3517
3721
|
if (error instanceof RelayerError || error instanceof UserRejectedRequestError || error instanceof SerializationError || error instanceof SignatureError || error instanceof NetworkError || error instanceof NonceError) {
|
|
@@ -3532,6 +3736,9 @@ class PermissionsController {
|
|
|
3532
3736
|
*
|
|
3533
3737
|
* @param typedData - The EIP-712 typed data for AddServerFilesAndPermissions
|
|
3534
3738
|
* @param signature - The user's signature
|
|
3739
|
+
* @param options - Optional transaction options for gas parameters and timeout.
|
|
3740
|
+
* Note: These options are only applied for direct blockchain transactions.
|
|
3741
|
+
* When using relayer callbacks (gasless transactions), these options are ignored.
|
|
3535
3742
|
* @returns TransactionResult with immediate hash access and optional event data
|
|
3536
3743
|
* @throws {RelayerError} When gasless transaction submission fails
|
|
3537
3744
|
* @throws {BlockchainError} When server files and permissions addition fails
|
|
@@ -3550,7 +3757,8 @@ class PermissionsController {
|
|
|
3550
3757
|
* console.log(`Permission created with ID: ${permissionId}`);
|
|
3551
3758
|
* ```
|
|
3552
3759
|
*/
|
|
3553
|
-
async submitSignedAddServerFilesAndPermissions(typedData, signature) {
|
|
3760
|
+
async submitSignedAddServerFilesAndPermissions(typedData, signature, options) {
|
|
3761
|
+
this.assertWallet();
|
|
3554
3762
|
try {
|
|
3555
3763
|
console.debug("\u{1F50D} submitSignedAddServerFilesAndPermissions Debug Info:", {
|
|
3556
3764
|
hasRelayerCallbacks: !!this.context.relayerCallbacks,
|
|
@@ -3565,22 +3773,31 @@ class PermissionsController {
|
|
|
3565
3773
|
typedData,
|
|
3566
3774
|
signature
|
|
3567
3775
|
);
|
|
3568
|
-
|
|
3776
|
+
const account = this.context.walletClient?.account ?? this.context.userAddress;
|
|
3777
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3778
|
+
return tx({
|
|
3569
3779
|
hash,
|
|
3570
|
-
from:
|
|
3571
|
-
|
|
3780
|
+
from: typeof account === "string" ? account : account.address,
|
|
3781
|
+
contract: "DataPortabilityPermissions",
|
|
3782
|
+
fn: "addServerFilesAndPermissions"
|
|
3783
|
+
});
|
|
3572
3784
|
} else {
|
|
3573
3785
|
console.debug(
|
|
3574
3786
|
"\u{1F4DD} Using direct transaction for submitAddServerFilesAndPermissions"
|
|
3575
3787
|
);
|
|
3576
3788
|
const hash = await this.submitDirectAddServerFilesAndPermissionsTransaction(
|
|
3577
3789
|
typedData,
|
|
3578
|
-
signature
|
|
3790
|
+
signature,
|
|
3791
|
+
options
|
|
3579
3792
|
);
|
|
3580
|
-
|
|
3793
|
+
const account = this.context.userAddress;
|
|
3794
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3795
|
+
return tx({
|
|
3581
3796
|
hash,
|
|
3582
|
-
from:
|
|
3583
|
-
|
|
3797
|
+
from: account,
|
|
3798
|
+
contract: "DataPortabilityPermissions",
|
|
3799
|
+
fn: "addServerFilesAndPermissions"
|
|
3800
|
+
});
|
|
3584
3801
|
}
|
|
3585
3802
|
} catch (error) {
|
|
3586
3803
|
if (error instanceof RelayerError || error instanceof NetworkError || error instanceof UserRejectedRequestError || error instanceof SignatureError || error instanceof NonceError) {
|
|
@@ -3596,9 +3813,11 @@ class PermissionsController {
|
|
|
3596
3813
|
* Submit permission revocation with signature to the blockchain
|
|
3597
3814
|
*
|
|
3598
3815
|
* @param permissionId - Permission ID to revoke
|
|
3816
|
+
* @param options - Optional transaction options for gas parameters and timeout
|
|
3599
3817
|
* @returns Promise resolving to transaction hash
|
|
3600
3818
|
*/
|
|
3601
|
-
async submitRevokePermission(permissionId) {
|
|
3819
|
+
async submitRevokePermission(permissionId, options) {
|
|
3820
|
+
this.assertWallet();
|
|
3602
3821
|
try {
|
|
3603
3822
|
const chainId = await this.context.walletClient.getChainId();
|
|
3604
3823
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
@@ -3608,18 +3827,36 @@ class PermissionsController {
|
|
|
3608
3827
|
const DataPortabilityPermissionsAbi = getAbi(
|
|
3609
3828
|
"DataPortabilityPermissions"
|
|
3610
3829
|
);
|
|
3830
|
+
const { account } = this.context.walletClient;
|
|
3831
|
+
if (!account) {
|
|
3832
|
+
throw new Error("No wallet account connected");
|
|
3833
|
+
}
|
|
3611
3834
|
const hash = await this.context.walletClient.writeContract({
|
|
3612
3835
|
address: DataPortabilityPermissionsAddress,
|
|
3613
3836
|
abi: DataPortabilityPermissionsAbi,
|
|
3614
3837
|
functionName: "revokePermission",
|
|
3615
3838
|
args: [permissionId],
|
|
3616
|
-
chain: this.context.walletClient
|
|
3617
|
-
account
|
|
3839
|
+
chain: this.context.walletClient?.chain,
|
|
3840
|
+
account,
|
|
3841
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
3842
|
+
...options?.nonce && { nonce: options.nonce },
|
|
3843
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3844
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3845
|
+
...options.maxFeePerGas && {
|
|
3846
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3847
|
+
},
|
|
3848
|
+
...options.maxPriorityFeePerGas && {
|
|
3849
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3850
|
+
}
|
|
3851
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3618
3852
|
});
|
|
3619
|
-
|
|
3853
|
+
const { tx } = await import("../utils/transactionHelpers");
|
|
3854
|
+
return tx({
|
|
3620
3855
|
hash,
|
|
3621
|
-
from:
|
|
3622
|
-
|
|
3856
|
+
from: typeof account === "string" ? account : account.address,
|
|
3857
|
+
contract: "DataPortabilityPermissions",
|
|
3858
|
+
fn: "revokePermission"
|
|
3859
|
+
});
|
|
3623
3860
|
} catch (error) {
|
|
3624
3861
|
throw new BlockchainError(
|
|
3625
3862
|
`Failed to revoke permission: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
@@ -3635,6 +3872,7 @@ class PermissionsController {
|
|
|
3635
3872
|
* @returns Promise resolving to the transaction hash
|
|
3636
3873
|
*/
|
|
3637
3874
|
async submitDirectAddPermissionTransaction(typedData, signature) {
|
|
3875
|
+
this.assertWallet();
|
|
3638
3876
|
const chainId = await this.context.walletClient.getChainId();
|
|
3639
3877
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
3640
3878
|
chainId,
|
|
@@ -3645,7 +3883,7 @@ class PermissionsController {
|
|
|
3645
3883
|
nonce: typedData.message.nonce,
|
|
3646
3884
|
granteeId: typedData.message.granteeId,
|
|
3647
3885
|
grant: typedData.message.grant,
|
|
3648
|
-
fileIds: typedData.message.fileIds
|
|
3886
|
+
fileIds: typedData.message.fileIds ?? []
|
|
3649
3887
|
};
|
|
3650
3888
|
const formattedSignature = formatSignatureForContract(signature);
|
|
3651
3889
|
const hash = await this.context.walletClient.writeContract({
|
|
@@ -3653,8 +3891,8 @@ class PermissionsController {
|
|
|
3653
3891
|
abi: DataPortabilityPermissionsAbi,
|
|
3654
3892
|
functionName: "addPermission",
|
|
3655
3893
|
args: [permissionInput, formattedSignature],
|
|
3656
|
-
account: this.context.walletClient
|
|
3657
|
-
chain: this.context.walletClient
|
|
3894
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3895
|
+
chain: this.context.walletClient?.chain ?? null
|
|
3658
3896
|
});
|
|
3659
3897
|
return hash;
|
|
3660
3898
|
}
|
|
@@ -3665,8 +3903,9 @@ class PermissionsController {
|
|
|
3665
3903
|
* @param signature - The cryptographic signature authorizing the transaction
|
|
3666
3904
|
* @returns Promise resolving to the transaction hash
|
|
3667
3905
|
*/
|
|
3668
|
-
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature) {
|
|
3669
|
-
|
|
3906
|
+
async submitDirectAddServerFilesAndPermissionsTransaction(typedData, signature, options) {
|
|
3907
|
+
this.assertWallet();
|
|
3908
|
+
const chainId = await this.context.publicClient.getChainId();
|
|
3670
3909
|
const DataPortabilityPermissionsAddress = getContractAddress(
|
|
3671
3910
|
chainId,
|
|
3672
3911
|
"DataPortabilityPermissions"
|
|
@@ -3690,8 +3929,20 @@ class PermissionsController {
|
|
|
3690
3929
|
functionName: "addServerFilesAndPermissions",
|
|
3691
3930
|
// @ts-expect-error - Viem's type inference for nested Permission[][] arrays is incompatible with our Permission type
|
|
3692
3931
|
args: [serverFilesAndPermissionInput, formattedSignature],
|
|
3693
|
-
account: this.context.walletClient
|
|
3694
|
-
chain: this.context.walletClient
|
|
3932
|
+
account: this.context.walletClient?.account ?? this.context.userAddress,
|
|
3933
|
+
chain: this.context.walletClient?.chain ?? null,
|
|
3934
|
+
...options?.gasLimit && { gas: options.gasLimit },
|
|
3935
|
+
...options?.nonce && { nonce: options.nonce },
|
|
3936
|
+
...options?.value && { value: options.value },
|
|
3937
|
+
// Use EIP-1559 if available, otherwise fall back to legacy gasPrice
|
|
3938
|
+
...options?.maxFeePerGas || options?.maxPriorityFeePerGas ? {
|
|
3939
|
+
...options.maxFeePerGas && {
|
|
3940
|
+
maxFeePerGas: options.maxFeePerGas
|
|
3941
|
+
},
|
|
3942
|
+
...options.maxPriorityFeePerGas && {
|
|
3943
|
+
maxPriorityFeePerGas: options.maxPriorityFeePerGas
|
|
3944
|
+
}
|
|
3945
|
+
} : options?.gasPrice && { gasPrice: options.gasPrice }
|
|
3695
3946
|
});
|
|
3696
3947
|
return hash;
|
|
3697
3948
|
}
|