@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
@@ -1,7 +1,7 @@
1
1
  import type { Address } from "viem";
2
- import type { TransactionOptions, TransactionResult } from "../types/operations";
3
2
  import type { StorageUploadResult } from "../types/storage";
4
3
  import type { UserFile, UploadParams, UploadResult, UploadEncryptedFileResult, Refiner, AddRefinerParams, AddRefinerResult, UpdateSchemaIdParams, UpdateSchemaIdResult, TrustedServer, GetUserTrustedServersParams, EncryptedUploadParams, UnencryptedUploadParams, EncryptFileOptions, EncryptFileResult, DecryptFileOptions, UploadFileWithPermissionsParams, AddFilePermissionParams, DecryptFileWithPermissionOptions } from "../types/index";
4
+ import type { TransactionResult } from "../types/operations";
5
5
  import type { ControllerContext } from "./permissions";
6
6
  import { BaseController } from "./base";
7
7
  import { type DataSchema } from "../utils/schemaValidation";
@@ -560,7 +560,7 @@ export declare class DataController extends BaseController {
560
560
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
561
561
  * ```
562
562
  */
563
- registerFileWithSchema(url: string, schemaId: number, options?: TransactionOptions): Promise<TransactionResult<"DataRegistry", "addFileWithSchema">>;
563
+ registerFileWithSchema(url: string, schemaId: number): Promise<TransactionResult<"DataRegistry", "addFileWithSchema">>;
564
564
  /**
565
565
  * Gets the user's address from the wallet client.
566
566
  *
@@ -586,7 +586,7 @@ export declare class DataController extends BaseController {
586
586
  addFileWithPermissions(url: string, ownerAddress: Address, permissions?: Array<{
587
587
  account: Address;
588
588
  key: string;
589
- }>, options?: TransactionOptions): Promise<TransactionResult<"DataRegistry", "addFileWithPermissions">>;
589
+ }>): Promise<TransactionResult<"DataRegistry", "addFileWithPermissions">>;
590
590
  /**
591
591
  * Adds a file to the registry with permissions and schema.
592
592
  * This combines the functionality of addFileWithPermissions and schema validation.
@@ -629,7 +629,7 @@ export declare class DataController extends BaseController {
629
629
  addFileWithPermissionsAndSchema(url: string, ownerAddress: Address, permissions?: Array<{
630
630
  account: Address;
631
631
  publicKey: string;
632
- }>, schemaId?: number, options?: TransactionOptions): Promise<TransactionResult<"DataRegistry", "addFileWithPermissionsAndSchema">>;
632
+ }>, schemaId?: number): Promise<TransactionResult<"DataRegistry", "addFileWithPermissionsAndSchema">>;
633
633
  /**
634
634
  * Adds a file with pre-encrypted permissions and schema to the DataRegistry.
635
635
  *
@@ -671,7 +671,7 @@ export declare class DataController extends BaseController {
671
671
  addFileWithEncryptedPermissionsAndSchema(url: string, ownerAddress: Address, permissions?: Array<{
672
672
  account: Address;
673
673
  key: string;
674
- }>, schemaId?: number, options?: TransactionOptions): Promise<TransactionResult<"DataRegistry", "addFileWithPermissionsAndSchema">>;
674
+ }>, schemaId?: number): Promise<TransactionResult<"DataRegistry", "addFileWithPermissionsAndSchema">>;
675
675
  /**
676
676
  * Registers a data refiner for processing templates.
677
677
  *
@@ -704,7 +704,7 @@ export declare class DataController extends BaseController {
704
704
  * console.log(`Refiner ${result.refinerId} created`);
705
705
  * ```
706
706
  */
707
- addRefiner(params: AddRefinerParams, options?: TransactionOptions): Promise<AddRefinerResult>;
707
+ addRefiner(params: AddRefinerParams): Promise<AddRefinerResult>;
708
708
  /**
709
709
  * Retrieves refiner configuration by ID.
710
710
  *
@@ -795,7 +795,7 @@ export declare class DataController extends BaseController {
795
795
  * console.log(`Schema updated in tx ${result.transactionHash}`);
796
796
  * ```
797
797
  */
798
- updateSchemaId(params: UpdateSchemaIdParams, options?: TransactionOptions): Promise<UpdateSchemaIdResult>;
798
+ updateSchemaId(params: UpdateSchemaIdParams): Promise<UpdateSchemaIdResult>;
799
799
  /**
800
800
  * Uploads an encrypted file and grants permission to a party with a public key.
801
801
  *
@@ -852,7 +852,7 @@ export declare class DataController extends BaseController {
852
852
  * console.log(`Transaction: ${result.transactionHash}`);
853
853
  * ```
854
854
  */
855
- addPermissionToFile(params: AddFilePermissionParams, options?: TransactionOptions): Promise<TransactionResult<"DataRegistry", "addFilePermission">>;
855
+ addPermissionToFile(params: AddFilePermissionParams): Promise<TransactionResult<"DataRegistry", "addFilePermission">>;
856
856
  /**
857
857
  * Submits a file permission transaction to the blockchain.
858
858
  *
@@ -881,7 +881,7 @@ export declare class DataController extends BaseController {
881
881
  * console.log(`Permission granted with ID: ${result.permissionId}`);
882
882
  * ```
883
883
  */
884
- submitFilePermission(fileId: number, account: Address, publicKey: string, options?: TransactionOptions): Promise<TransactionResult<"DataRegistry", "addFilePermission">>;
884
+ submitFilePermission(fileId: number, account: Address, publicKey: string): Promise<TransactionResult<"DataRegistry", "addFilePermission">>;
885
885
  /**
886
886
  * Gets the encrypted key for a specific account's permission to access a file.
887
887
  *
@@ -124,7 +124,7 @@ class DataController extends BaseController {
124
124
  if (response.type === "error") {
125
125
  throw new Error(response.error);
126
126
  }
127
- if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
127
+ if (response.type !== "direct" || !("fileId" in response.result)) {
128
128
  throw new Error("Invalid response from relayer");
129
129
  }
130
130
  result = response.result;
@@ -1357,7 +1357,7 @@ class DataController extends BaseController {
1357
1357
  * console.log(`File ${fileId} registered with schema in tx ${transactionHash}`);
1358
1358
  * ```
1359
1359
  */
1360
- async registerFileWithSchema(url, schemaId, options) {
1360
+ async registerFileWithSchema(url, schemaId) {
1361
1361
  this.assertWallet();
1362
1362
  try {
1363
1363
  const chainId = this.context.publicClient.chain?.id;
@@ -1375,8 +1375,7 @@ class DataController extends BaseController {
1375
1375
  functionName: "addFileWithSchema",
1376
1376
  args: [url, BigInt(schemaId)],
1377
1377
  account,
1378
- chain: this.context.walletClient.chain ?? null,
1379
- ...this.spreadTransactionOptions(options)
1378
+ chain: this.context.walletClient.chain ?? null
1380
1379
  });
1381
1380
  const { tx } = await import("../utils/transactionHelpers");
1382
1381
  return tx({
@@ -1414,7 +1413,7 @@ class DataController extends BaseController {
1414
1413
  * with specific permissions on the DataRegistry contract. It can be used
1415
1414
  * by both direct transactions and relayer services.
1416
1415
  */
1417
- async addFileWithPermissions(url, ownerAddress, permissions = [], options) {
1416
+ async addFileWithPermissions(url, ownerAddress, permissions = []) {
1418
1417
  this.assertWallet();
1419
1418
  try {
1420
1419
  const chainId = this.context.publicClient.chain?.id;
@@ -1432,8 +1431,7 @@ class DataController extends BaseController {
1432
1431
  functionName: "addFileWithPermissions",
1433
1432
  args: [url, ownerAddress, permissions],
1434
1433
  account,
1435
- chain: this.context.walletClient.chain ?? null,
1436
- ...this.spreadTransactionOptions(options)
1434
+ chain: this.context.walletClient.chain ?? null
1437
1435
  });
1438
1436
  const { tx } = await import("../utils/transactionHelpers");
1439
1437
  return tx({
@@ -1488,7 +1486,7 @@ class DataController extends BaseController {
1488
1486
  * console.log(`File ${result.fileId} registered in tx ${result.hash}`);
1489
1487
  * ```
1490
1488
  */
1491
- async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1489
+ async addFileWithPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1492
1490
  this.assertWallet();
1493
1491
  try {
1494
1492
  let encryptedPermissions = [];
@@ -1522,8 +1520,7 @@ class DataController extends BaseController {
1522
1520
  url,
1523
1521
  ownerAddress,
1524
1522
  encryptedPermissions,
1525
- schemaId,
1526
- options
1523
+ schemaId
1527
1524
  );
1528
1525
  } catch (error) {
1529
1526
  console.error("Failed to add file with permissions and schema:", error);
@@ -1570,7 +1567,7 @@ class DataController extends BaseController {
1570
1567
  * console.log(`File registered in tx ${result.hash}`);
1571
1568
  * ```
1572
1569
  */
1573
- async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0, options) {
1570
+ async addFileWithEncryptedPermissionsAndSchema(url, ownerAddress, permissions = [], schemaId = 0) {
1574
1571
  try {
1575
1572
  const chainId = this.context.publicClient.chain?.id;
1576
1573
  if (!chainId) {
@@ -1587,8 +1584,7 @@ class DataController extends BaseController {
1587
1584
  functionName: "addFileWithPermissionsAndSchema",
1588
1585
  args: [url, ownerAddress, permissions, BigInt(schemaId)],
1589
1586
  account,
1590
- chain: this.context.walletClient.chain ?? null,
1591
- ...this.spreadTransactionOptions(options)
1587
+ chain: this.context.walletClient.chain ?? null
1592
1588
  });
1593
1589
  const { tx } = await import("../utils/transactionHelpers");
1594
1590
  return tx({
@@ -1636,7 +1632,7 @@ class DataController extends BaseController {
1636
1632
  * console.log(`Refiner ${result.refinerId} created`);
1637
1633
  * ```
1638
1634
  */
1639
- async addRefiner(params, options) {
1635
+ async addRefiner(params) {
1640
1636
  this.assertWallet();
1641
1637
  try {
1642
1638
  const chainId = this.context.publicClient.chain?.id;
@@ -1662,8 +1658,7 @@ class DataController extends BaseController {
1662
1658
  params.refinementInstructionUrl
1663
1659
  ],
1664
1660
  account,
1665
- chain: this.context.walletClient.chain ?? null,
1666
- ...this.spreadTransactionOptions(options)
1661
+ chain: this.context.walletClient.chain ?? null
1667
1662
  });
1668
1663
  const { tx } = await import("../utils/transactionHelpers");
1669
1664
  const txResult = tx({
@@ -1863,7 +1858,7 @@ class DataController extends BaseController {
1863
1858
  * console.log(`Schema updated in tx ${result.transactionHash}`);
1864
1859
  * ```
1865
1860
  */
1866
- async updateSchemaId(params, options) {
1861
+ async updateSchemaId(params) {
1867
1862
  this.assertWallet();
1868
1863
  try {
1869
1864
  const chainId = this.context.publicClient.chain?.id;
@@ -1883,8 +1878,7 @@ class DataController extends BaseController {
1883
1878
  functionName: "updateSchemaId",
1884
1879
  args: [BigInt(params.refinerId), BigInt(params.newSchemaId)],
1885
1880
  account,
1886
- chain: this.context.walletClient.chain ?? null,
1887
- ...this.spreadTransactionOptions(options)
1881
+ chain: this.context.walletClient.chain ?? null
1888
1882
  });
1889
1883
  await this.context.publicClient.waitForTransactionReceipt({ hash });
1890
1884
  return {
@@ -1953,7 +1947,7 @@ class DataController extends BaseController {
1953
1947
  if (response.type === "error") {
1954
1948
  throw new Error(response.error);
1955
1949
  }
1956
- if (response.type !== "direct" || typeof response.result !== "object" || response.result === null || !("fileId" in response.result)) {
1950
+ if (response.type !== "direct" || !("fileId" in response.result)) {
1957
1951
  throw new Error("Invalid response from relayer");
1958
1952
  }
1959
1953
  const result = response.result;
@@ -2045,7 +2039,7 @@ class DataController extends BaseController {
2045
2039
  );
2046
2040
  }
2047
2041
  }
2048
- const finalFilename = filename ?? `upload-${Date.now()}.dat`;
2042
+ const finalFilename = filename ?? encrypt ? `upload-${Date.now()}.enc` : `upload-${Date.now()}.dat`;
2049
2043
  const uploadResult = await this.context.storageManager.upload(
2050
2044
  finalBlob,
2051
2045
  finalFilename,
@@ -2090,10 +2084,10 @@ class DataController extends BaseController {
2090
2084
  * console.log(`Transaction: ${result.transactionHash}`);
2091
2085
  * ```
2092
2086
  */
2093
- async addPermissionToFile(params, options) {
2087
+ async addPermissionToFile(params) {
2094
2088
  this.assertWallet();
2095
2089
  const { fileId, account, publicKey } = params;
2096
- return await this.submitFilePermission(fileId, account, publicKey, options);
2090
+ return await this.submitFilePermission(fileId, account, publicKey);
2097
2091
  }
2098
2092
  /**
2099
2093
  * Submits a file permission transaction to the blockchain.
@@ -2123,7 +2117,7 @@ class DataController extends BaseController {
2123
2117
  * console.log(`Permission granted with ID: ${result.permissionId}`);
2124
2118
  * ```
2125
2119
  */
2126
- async submitFilePermission(fileId, account, publicKey, options) {
2120
+ async submitFilePermission(fileId, account, publicKey) {
2127
2121
  this.assertWallet();
2128
2122
  try {
2129
2123
  const userEncryptionKey = await generateEncryptionKey(
@@ -2150,8 +2144,7 @@ class DataController extends BaseController {
2150
2144
  functionName: "addFilePermission",
2151
2145
  args: [BigInt(fileId), account, encryptedKey],
2152
2146
  account: walletAccount,
2153
- chain: this.context.walletClient.chain ?? null,
2154
- ...this.spreadTransactionOptions(options)
2147
+ chain: this.context.walletClient.chain ?? null
2155
2148
  });
2156
2149
  const { tx } = await import("../utils/transactionHelpers");
2157
2150
  return tx({