@opendatalabs/vana-sdk 0.1.0-alpha.f2a82f7 → 0.1.0-alpha.f35bb9c

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.
Files changed (51) hide show
  1. package/dist/controllers/base.cjs +0 -33
  2. package/dist/controllers/base.cjs.map +1 -1
  3. package/dist/controllers/base.d.ts +0 -10
  4. package/dist/controllers/base.js +0 -33
  5. package/dist/controllers/base.js.map +1 -1
  6. package/dist/controllers/data.cjs +19 -26
  7. package/dist/controllers/data.cjs.map +1 -1
  8. package/dist/controllers/data.d.ts +9 -9
  9. package/dist/controllers/data.js +19 -26
  10. package/dist/controllers/data.js.map +1 -1
  11. package/dist/controllers/permissions.cjs +65 -124
  12. package/dist/controllers/permissions.cjs.map +1 -1
  13. package/dist/controllers/permissions.d.ts +11 -20
  14. package/dist/controllers/permissions.js +65 -124
  15. package/dist/controllers/permissions.js.map +1 -1
  16. package/dist/core.cjs +1 -4
  17. package/dist/core.cjs.map +1 -1
  18. package/dist/core.d.ts +1 -2
  19. package/dist/core.js +1 -4
  20. package/dist/core.js.map +1 -1
  21. package/dist/index.node.cjs +0 -2
  22. package/dist/index.node.cjs.map +1 -1
  23. package/dist/index.node.d.ts +4 -27
  24. package/dist/index.node.js +0 -2
  25. package/dist/index.node.js.map +1 -1
  26. package/dist/server/relayerHandler.cjs +87 -201
  27. package/dist/server/relayerHandler.cjs.map +1 -1
  28. package/dist/server/relayerHandler.d.ts +1 -3
  29. package/dist/server/relayerHandler.js +87 -201
  30. package/dist/server/relayerHandler.js.map +1 -1
  31. package/dist/types/config.cjs.map +1 -1
  32. package/dist/types/config.d.ts +0 -32
  33. package/dist/types/config.js.map +1 -1
  34. package/dist/types/controller-context.cjs.map +1 -1
  35. package/dist/types/controller-context.d.ts +1 -3
  36. package/dist/types/generics.cjs.map +1 -1
  37. package/dist/types/generics.d.ts +1 -1
  38. package/dist/types/index.cjs.map +1 -1
  39. package/dist/types/index.d.ts +2 -3
  40. package/dist/types/index.js.map +1 -1
  41. package/dist/types/operations.cjs.map +1 -1
  42. package/dist/types/operations.d.ts +0 -46
  43. package/dist/types/operations.js.map +1 -1
  44. package/dist/types/relayer.cjs.map +1 -1
  45. package/dist/types/relayer.d.ts +8 -19
  46. package/dist/utils/ipfs.cjs +4 -2
  47. package/dist/utils/ipfs.cjs.map +1 -1
  48. package/dist/utils/ipfs.d.ts +1 -1
  49. package/dist/utils/ipfs.js +4 -2
  50. package/dist/utils/ipfs.js.map +1 -1
  51. package/package.json +1 -3
@@ -75,39 +75,6 @@ class BaseController {
75
75
  );
76
76
  }
77
77
  }
78
- /**
79
- * Helper to safely spread transaction options for viem compatibility.
80
- * Handles EIP-1559 vs legacy gas pricing correctly.
81
- *
82
- * @param options - Transaction options to spread
83
- * @returns Properly formatted options for viem
84
- * @internal
85
- */
86
- spreadTransactionOptions(options) {
87
- if (!options) return {};
88
- const baseOptions = {
89
- ...options.nonce !== void 0 && { nonce: options.nonce },
90
- ...options.gas !== void 0 && { gas: options.gas }
91
- };
92
- if (options.maxFeePerGas !== void 0 || options.maxPriorityFeePerGas !== void 0) {
93
- return {
94
- ...baseOptions,
95
- ...options.maxFeePerGas !== void 0 && {
96
- maxFeePerGas: options.maxFeePerGas
97
- },
98
- ...options.maxPriorityFeePerGas !== void 0 && {
99
- maxPriorityFeePerGas: options.maxPriorityFeePerGas
100
- }
101
- };
102
- }
103
- if (options.gasPrice !== void 0) {
104
- return {
105
- ...baseOptions,
106
- gasPrice: options.gasPrice
107
- };
108
- }
109
- return baseOptions;
110
- }
111
78
  }
112
79
  // Annotate the CommonJS export names for ESM import in node:
113
80
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport type { TransactionOptions } from \"../types/operations\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n\n /**\n * Helper to safely spread transaction options for viem compatibility.\n * Handles EIP-1559 vs legacy gas pricing correctly.\n *\n * @param options - Transaction options to spread\n * @returns Properly formatted options for viem\n * @internal\n */\n protected spreadTransactionOptions(options?: TransactionOptions) {\n if (!options) return {};\n\n const baseOptions: any = {\n ...(options.nonce !== undefined && { nonce: options.nonce }),\n ...(options.gas !== undefined && { gas: options.gas }),\n };\n\n // EIP-1559 and legacy gasPrice are mutually exclusive in viem\n // If EIP-1559 params are provided, use them and exclude gasPrice\n if (\n options.maxFeePerGas !== undefined ||\n options.maxPriorityFeePerGas !== undefined\n ) {\n return {\n ...baseOptions,\n ...(options.maxFeePerGas !== undefined && {\n maxFeePerGas: options.maxFeePerGas,\n }),\n ...(options.maxPriorityFeePerGas !== undefined && {\n maxPriorityFeePerGas: options.maxPriorityFeePerGas,\n }),\n };\n }\n\n // Otherwise, use legacy gasPrice if provided\n if (options.gasPrice !== undefined) {\n return {\n ...baseOptions,\n gasPrice: options.gasPrice,\n };\n }\n\n return baseOptions;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBA,oBAA8B;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,oBAA8B;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BlD,eAER;AACA,QAAI,CAAC,KAAK,QAAQ,cAAc;AAE9B,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,QAAQ,aAAa,SAAS;AAEtC,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR,+CAA+C,aAAa;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -15,7 +15,6 @@
15
15
  */
16
16
  import type { WalletClient } from "viem";
17
17
  import type { ControllerContext } from "../types/controller-context";
18
- import type { TransactionOptions } from "../types/operations";
19
18
  /**
20
19
  * Abstract base controller that all Vana SDK controllers extend.
21
20
  *
@@ -82,13 +81,4 @@ export declare abstract class BaseController {
82
81
  walletClient: WalletClient;
83
82
  };
84
83
  };
85
- /**
86
- * Helper to safely spread transaction options for viem compatibility.
87
- * Handles EIP-1559 vs legacy gas pricing correctly.
88
- *
89
- * @param options - Transaction options to spread
90
- * @returns Properly formatted options for viem
91
- * @internal
92
- */
93
- protected spreadTransactionOptions(options?: TransactionOptions): any;
94
84
  }
@@ -52,39 +52,6 @@ class BaseController {
52
52
  );
53
53
  }
54
54
  }
55
- /**
56
- * Helper to safely spread transaction options for viem compatibility.
57
- * Handles EIP-1559 vs legacy gas pricing correctly.
58
- *
59
- * @param options - Transaction options to spread
60
- * @returns Properly formatted options for viem
61
- * @internal
62
- */
63
- spreadTransactionOptions(options) {
64
- if (!options) return {};
65
- const baseOptions = {
66
- ...options.nonce !== void 0 && { nonce: options.nonce },
67
- ...options.gas !== void 0 && { gas: options.gas }
68
- };
69
- if (options.maxFeePerGas !== void 0 || options.maxPriorityFeePerGas !== void 0) {
70
- return {
71
- ...baseOptions,
72
- ...options.maxFeePerGas !== void 0 && {
73
- maxFeePerGas: options.maxFeePerGas
74
- },
75
- ...options.maxPriorityFeePerGas !== void 0 && {
76
- maxPriorityFeePerGas: options.maxPriorityFeePerGas
77
- }
78
- };
79
- }
80
- if (options.gasPrice !== void 0) {
81
- return {
82
- ...baseOptions,
83
- gasPrice: options.gasPrice
84
- };
85
- }
86
- return baseOptions;
87
- }
88
55
  }
89
56
  export {
90
57
  BaseController
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport type { TransactionOptions } from \"../types/operations\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n\n /**\n * Helper to safely spread transaction options for viem compatibility.\n * Handles EIP-1559 vs legacy gas pricing correctly.\n *\n * @param options - Transaction options to spread\n * @returns Properly formatted options for viem\n * @internal\n */\n protected spreadTransactionOptions(options?: TransactionOptions) {\n if (!options) return {};\n\n const baseOptions: any = {\n ...(options.nonce !== undefined && { nonce: options.nonce }),\n ...(options.gas !== undefined && { gas: options.gas }),\n };\n\n // EIP-1559 and legacy gasPrice are mutually exclusive in viem\n // If EIP-1559 params are provided, use them and exclude gasPrice\n if (\n options.maxFeePerGas !== undefined ||\n options.maxPriorityFeePerGas !== undefined\n ) {\n return {\n ...baseOptions,\n ...(options.maxFeePerGas !== undefined && {\n maxFeePerGas: options.maxFeePerGas,\n }),\n ...(options.maxPriorityFeePerGas !== undefined && {\n maxPriorityFeePerGas: options.maxPriorityFeePerGas,\n }),\n };\n }\n\n // Otherwise, use legacy gasPrice if provided\n if (options.gasPrice !== undefined) {\n return {\n ...baseOptions,\n gasPrice: options.gasPrice,\n };\n }\n\n return baseOptions;\n }\n}\n"],"mappings":"AAmBA,SAAS,qBAAqB;AA4BvB,MAAe,eAAe;AAAA;AAAA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,MACF;AAAA,IACF;AAGA,QAAI,QAAQ,aAAa,QAAW;AAClC,aAAO;AAAA,QACL,GAAG;AAAA,QACH,UAAU,QAAQ;AAAA,MACpB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/controllers/base.ts"],"sourcesContent":["/**\n * Base controller class providing common functionality for all controllers.\n *\n * @remarks\n * This abstract class establishes the foundation for all Vana SDK controllers,\n * providing shared utilities like wallet validation and context management.\n * All controllers should extend this base class to ensure consistency and\n * shared behavior across the SDK.\n *\n * The class follows the Single Responsibility Principle by handling only\n * the core controller concerns while leaving specific functionality to\n * implementing classes.\n *\n * @category Controllers\n */\n\nimport type { WalletClient } from \"viem\";\nimport type { ControllerContext } from \"../types/controller-context\";\nimport { ReadOnlyError } from \"../errors\";\n\n/**\n * Abstract base controller that all Vana SDK controllers extend.\n *\n * @remarks\n * Provides common functionality and patterns used across all controllers,\n * including wallet validation and context management. This ensures\n * consistency and reduces code duplication throughout the SDK.\n *\n * Key features:\n * - Wallet client validation with TypeScript assertion signatures\n * - Consistent error handling for read-only scenarios\n * - Shared context management patterns\n * - Type-safe wallet operations\n *\n * @example\n * ```typescript\n * class MyController extends BaseController {\n * async performWalletOperation() {\n * this.assertWallet(); // Ensures wallet is available\n * // Now this.context.walletClient is guaranteed to be available\n * const address = await this.context.walletClient.getAddresses();\n * return address[0];\n * }\n * }\n * ```\n */\nexport abstract class BaseController {\n /**\n * Creates a new controller instance with the provided context.\n *\n * @param context - The controller context containing clients and configuration\n */\n constructor(protected readonly context: ControllerContext) {}\n\n /**\n * Asserts that a wallet client with an account is available for operations requiring signing.\n *\n * @remarks\n * This method uses TypeScript assertion signatures to narrow the type of\n * `this.context` to guarantee that `walletClient` with an account is available\n * after the call succeeds. This provides compile-time safety for wallet operations\n * while enabling clear error messages for read-only scenarios.\n *\n * The assertion signature ensures that after calling this method,\n * TypeScript knows that `this.context.walletClient` is definitely available\n * with a configured account.\n *\n * @throws {ReadOnlyError} When no wallet client is configured\n * @throws {Error} When wallet client exists but no account is configured\n *\n * @example\n * ```typescript\n * async performWalletOperation() {\n * this.assertWallet(); // Type assertion + runtime check\n *\n * // TypeScript now knows walletClient and account are available\n * const account = this.context.walletClient.account;\n * const address = typeof account === 'string' ? account : account.address;\n * }\n * ```\n */\n protected assertWallet(): asserts this is {\n context: ControllerContext & { walletClient: WalletClient };\n } {\n if (!this.context.walletClient) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new ReadOnlyError(\n callingMethod,\n \"Initialize the SDK with a walletClient to perform this operation\",\n );\n }\n\n if (!this.context.walletClient.account) {\n // Get the calling method name from the stack trace for better error messages\n const stack = new Error().stack;\n const callingMethod =\n stack?.split(\"\\n\")[2]?.match(/at \\w+\\.(\\w+)/)?.[1] ?? \"this operation\";\n\n throw new Error(\n `No wallet account connected. Cannot perform ${callingMethod} without an account.`,\n );\n }\n }\n}\n"],"mappings":"AAkBA,SAAS,qBAAqB;AA4BvB,MAAe,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMnC,YAA+B,SAA4B;AAA5B;AAAA,EAA6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BlD,eAER;AACA,QAAI,CAAC,KAAK,QAAQ,cAAc;AAE9B,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAEA,QAAI,CAAC,KAAK,QAAQ,aAAa,SAAS;AAEtC,YAAM,QAAQ,IAAI,MAAM,EAAE;AAC1B,YAAM,gBACJ,OAAO,MAAM,IAAI,EAAE,CAAC,GAAG,MAAM,eAAe,IAAI,CAAC,KAAK;AAExD,YAAM,IAAI;AAAA,QACR,+CAA+C,aAAa;AAAA,MAC9D;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -140,7 +140,7 @@ class DataController extends import_base.BaseController {
140
140
  if (response.type === "error") {
141
141
  throw new Error(response.error);
142
142
  }
143
- if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
143
+ if (response.type !== "direct" || !("fileId" in response.result)) {
144
144
  throw new Error("Invalid response from relayer");
145
145
  }
146
146
  result = response.result;
@@ -1373,7 +1373,7 @@ class DataController extends import_base.BaseController {
1373
1373
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
1374
1374
  * ```
1375
1375
  */
1376
- async registerFileWithSchema(url, schemaId, options) {
1376
+ async registerFileWithSchema(url, schemaId) {
1377
1377
  this.assertWallet();
1378
1378
  try {
1379
1379
  const chainId = this.context.publicClient.chain?.id;
@@ -1391,8 +1391,7 @@ class DataController extends import_base.BaseController {
1391
1391
  functionName: "addFileWithSchema",
1392
1392
  args: [url, BigInt(schemaId)],
1393
1393
  account,
1394
- chain: this.context.walletClient.chain ?? null,
1395
- ...this.spreadTransactionOptions(options)
1394
+ chain: this.context.walletClient.chain ?? null
1396
1395
  });
1397
1396
  const { tx } = await import("../utils/transactionHelpers");
1398
1397
  return tx({
@@ -1430,7 +1429,7 @@ class DataController extends import_base.BaseController {
1430
1429
  * with specific permissions on the DataRegistry contract. It can be used
1431
1430
  * by both direct transactions and relayer services.
1432
1431
  */
1433
- async addFileWithPermissions(url, ownerAddress, permissions = [], options) {
1432
+ async addFileWithPermissions(url, ownerAddress, permissions = []) {
1434
1433
  this.assertWallet();
1435
1434
  try {
1436
1435
  const chainId = this.context.publicClient.chain?.id;
@@ -1448,8 +1447,7 @@ class DataController extends import_base.BaseController {
1448
1447
  functionName: "addFileWithPermissions",
1449
1448
  args: [url, ownerAddress, permissions],
1450
1449
  account,
1451
- chain: this.context.walletClient.chain ?? null,
1452
- ...this.spreadTransactionOptions(options)
1450
+ chain: this.context.walletClient.chain ?? null
1453
1451
  });
1454
1452
  const { tx } = await import("../utils/transactionHelpers");
1455
1453
  return tx({
@@ -1504,7 +1502,7 @@ class DataController extends import_base.BaseController {
1504
1502
  * console.log(`File ${result.fileId} registered in tx ${result.hash}`);
1505
1503
  * ```
1506
1504
  */
1507
- async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1505
+ async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1508
1506
  this.assertWallet();
1509
1507
  try {
1510
1508
  let encryptedPermissions = [];
@@ -1538,8 +1536,7 @@ class DataController extends import_base.BaseController {
1538
1536
  url,
1539
1537
  ownerAddress,
1540
1538
  encryptedPermissions,
1541
- schemaId,
1542
- options
1539
+ schemaId
1543
1540
  );
1544
1541
  } catch (error) {
1545
1542
  console.error("Failed to add file with permissions and schema:", error);
@@ -1586,7 +1583,7 @@ class DataController extends import_base.BaseController {
1586
1583
  * console.log(`File registered in tx ${result.hash}`);
1587
1584
  * ```
1588
1585
  */
1589
- async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1586
+ async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1590
1587
  try {
1591
1588
  const chainId = this.context.publicClient.chain?.id;
1592
1589
  if (!chainId) {
@@ -1603,8 +1600,7 @@ class DataController extends import_base.BaseController {
1603
1600
  functionName: "addFileWithPermissionsAndSchema",
1604
1601
  args: [url, ownerAddress, permissions, BigInt(schemaId)],
1605
1602
  account,
1606
- chain: this.context.walletClient.chain ?? null,
1607
- ...this.spreadTransactionOptions(options)
1603
+ chain: this.context.walletClient.chain ?? null
1608
1604
  });
1609
1605
  const { tx } = await import("../utils/transactionHelpers");
1610
1606
  return tx({
@@ -1652,7 +1648,7 @@ class DataController extends import_base.BaseController {
1652
1648
  * console.log(`Refiner ${result.refinerId} created`);
1653
1649
  * ```
1654
1650
  */
1655
- async addRefiner(params, options) {
1651
+ async addRefiner(params) {
1656
1652
  this.assertWallet();
1657
1653
  try {
1658
1654
  const chainId = this.context.publicClient.chain?.id;
@@ -1678,8 +1674,7 @@ class DataController extends import_base.BaseController {
1678
1674
  params.refinementInstructionUrl
1679
1675
  ],
1680
1676
  account,
1681
- chain: this.context.walletClient.chain ?? null,
1682
- ...this.spreadTransactionOptions(options)
1677
+ chain: this.context.walletClient.chain ?? null
1683
1678
  });
1684
1679
  const { tx } = await import("../utils/transactionHelpers");
1685
1680
  const txResult = tx({
@@ -1879,7 +1874,7 @@ class DataController extends import_base.BaseController {
1879
1874
  * console.log(`Schema updated in tx ${result.transactionHash}`);
1880
1875
  * ```
1881
1876
  */
1882
- async updateSchemaId(params, options) {
1877
+ async updateSchemaId(params) {
1883
1878
  this.assertWallet();
1884
1879
  try {
1885
1880
  const chainId = this.context.publicClient.chain?.id;
@@ -1899,8 +1894,7 @@ class DataController extends import_base.BaseController {
1899
1894
  functionName: "updateSchemaId",
1900
1895
  args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
1901
1896
  account,
1902
- chain: this.context.walletClient.chain ?? null,
1903
- ...this.spreadTransactionOptions(options)
1897
+ chain: this.context.walletClient.chain ?? null
1904
1898
  });
1905
1899
  await this.context.publicClient.waitForTransactionReceipt({ hash });
1906
1900
  return {
@@ -1969,7 +1963,7 @@ class DataController extends import_base.BaseController {
1969
1963
  if (response.type === "error") {
1970
1964
  throw new Error(response.error);
1971
1965
  }
1972
- if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
1966
+ if (response.type !== "direct" || !("fileId" in response.result)) {
1973
1967
  throw new Error("Invalid response from relayer");
1974
1968
  }
1975
1969
  const result = response.result;
@@ -2061,7 +2055,7 @@ class DataController extends import_base.BaseController {
2061
2055
  );
2062
2056
  }
2063
2057
  }
2064
- const finalFilename = filename ?? `upload-${Date.now()}.dat`;
2058
+ const finalFilename = filename ?? encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`;
2065
2059
  const uploadResult = await this.context.storageManager.upload(
2066
2060
  finalBlob,
2067
2061
  finalFilename,
@@ -2106,10 +2100,10 @@ class DataController extends import_base.BaseController {
2106
2100
  * console.log(`Transaction: ${result.transactionHash}`);
2107
2101
  * ```
2108
2102
  */
2109
- async addPermissionToFile(params, options) {
2103
+ async addPermissionToFile(params) {
2110
2104
  this.assertWallet();
2111
2105
  const { fileId, account, publicKey } = params;
2112
- return await this.submitFilePermission(fileId, account, publicKey, options);
2106
+ return await this.submitFilePermission(fileId, account, publicKey);
2113
2107
  }
2114
2108
  /**
2115
2109
  * Submits a file permission transaction to the blockchain.
@@ -2139,7 +2133,7 @@ class DataController extends import_base.BaseController {
2139
2133
  * console.log(`Permission granted with ID: ${result.permissionId}`);
2140
2134
  * ```
2141
2135
  */
2142
- async submitFilePermission(fileId, account, publicKey, options) {
2136
+ async submitFilePermission(fileId, account, publicKey) {
2143
2137
  this.assertWallet();
2144
2138
  try {
2145
2139
  const userEncryptionKey = await (0, import_encryption.generateEncryptionKey)(
@@ -2166,8 +2160,7 @@ class DataController extends import_base.BaseController {
2166
2160
  functionName: "addFilePermission",
2167
2161
  args: [BigInt(fileId), account, encryptedKey],
2168
2162
  account: walletAccount,
2169
- chain: this.context.walletClient.chain ?? null,
2170
- ...this.spreadTransactionOptions(options)
2163
+ chain: this.context.walletClient.chain ?? null
2171
2164
  });
2172
2165
  const { tx } = await import("../utils/transactionHelpers");
2173
2166
  return tx({