@opendatalabs/vana-sdk 2.2.1 → 2.2.3-canary.046cb7e

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 (65) hide show
  1. package/dist/config/features.cjs +1 -24
  2. package/dist/config/features.cjs.map +1 -1
  3. package/dist/config/features.d.ts +13 -44
  4. package/dist/config/features.js +1 -24
  5. package/dist/config/features.js.map +1 -1
  6. package/dist/controllers/permissions.cjs +19 -14
  7. package/dist/controllers/permissions.cjs.map +1 -1
  8. package/dist/controllers/permissions.js +19 -14
  9. package/dist/controllers/permissions.js.map +1 -1
  10. package/dist/controllers/staking.cjs +539 -0
  11. package/dist/controllers/staking.cjs.map +1 -0
  12. package/dist/controllers/staking.d.ts +404 -0
  13. package/dist/controllers/staking.js +515 -0
  14. package/dist/controllers/staking.js.map +1 -0
  15. package/dist/core.cjs +4 -0
  16. package/dist/core.cjs.map +1 -1
  17. package/dist/core.d.ts +3 -0
  18. package/dist/core.js +4 -0
  19. package/dist/core.js.map +1 -1
  20. package/dist/crypto/ecies/index.cjs.map +1 -1
  21. package/dist/crypto/ecies/index.d.ts +10 -2
  22. package/dist/crypto/ecies/index.js.map +1 -1
  23. package/dist/generated/abi/VanaPoolEntityImplementation.cjs +37 -0
  24. package/dist/generated/abi/VanaPoolEntityImplementation.cjs.map +1 -1
  25. package/dist/generated/abi/VanaPoolEntityImplementation.d.ts +29 -0
  26. package/dist/generated/abi/VanaPoolEntityImplementation.js +37 -0
  27. package/dist/generated/abi/VanaPoolEntityImplementation.js.map +1 -1
  28. package/dist/generated/abi/VanaPoolStakingImplementation.cjs +156 -19
  29. package/dist/generated/abi/VanaPoolStakingImplementation.cjs.map +1 -1
  30. package/dist/generated/abi/VanaPoolStakingImplementation.d.ts +120 -14
  31. package/dist/generated/abi/VanaPoolStakingImplementation.js +156 -19
  32. package/dist/generated/abi/VanaPoolStakingImplementation.js.map +1 -1
  33. package/dist/generated/abi/index.d.ts +149 -14
  34. package/dist/generated/event-types.cjs.map +1 -1
  35. package/dist/generated/event-types.d.ts +4 -0
  36. package/dist/generated/eventRegistry.cjs +24 -0
  37. package/dist/generated/eventRegistry.cjs.map +1 -1
  38. package/dist/generated/eventRegistry.js +24 -0
  39. package/dist/generated/eventRegistry.js.map +1 -1
  40. package/dist/index.browser.d.ts +4 -0
  41. package/dist/index.browser.js +12 -0
  42. package/dist/index.browser.js.map +1 -1
  43. package/dist/index.node.cjs +15 -0
  44. package/dist/index.node.cjs.map +1 -1
  45. package/dist/index.node.d.ts +5 -0
  46. package/dist/index.node.js +14 -0
  47. package/dist/index.node.js.map +1 -1
  48. package/dist/platform/browser.cjs +40 -119
  49. package/dist/platform/browser.cjs.map +1 -1
  50. package/dist/platform/browser.d.ts +7 -7
  51. package/dist/platform/browser.js +40 -119
  52. package/dist/platform/browser.js.map +1 -1
  53. package/dist/platform/node.cjs +51 -129
  54. package/dist/platform/node.cjs.map +1 -1
  55. package/dist/platform/node.d.ts +5 -5
  56. package/dist/platform/node.js +51 -129
  57. package/dist/platform/node.js.map +1 -1
  58. package/dist/tests/staking.test.d.ts +1 -0
  59. package/dist/types/permissions.cjs.map +1 -1
  60. package/dist/types/permissions.d.ts +2 -0
  61. package/package.json +1 -2
  62. package/dist/types/eccrypto-js.d.cjs +0 -2
  63. package/dist/types/eccrypto-js.d.cjs.map +0 -1
  64. package/dist/types/eccrypto-js.d.js +0 -1
  65. package/dist/types/eccrypto-js.d.js.map +0 -1
@@ -21,30 +21,7 @@ __export(features_exports, {
21
21
  features: () => features
22
22
  });
23
23
  module.exports = __toCommonJS(features_exports);
24
- const features = {
25
- /**
26
- * Use custom ECIES implementation instead of eccrypto
27
- *
28
- * When false (default): Uses the original eccrypto/eccrypto-js libraries for stability
29
- * When true: Uses the custom platform-specific ECIES implementation
30
- *
31
- * Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true
32
- *
33
- * @example
34
- * ```bash
35
- * # Use eccrypto-js (default)
36
- * VANA_USE_CUSTOM_ECIES=false npm run your-app
37
- *
38
- * # Use custom ECIES implementation
39
- * VANA_USE_CUSTOM_ECIES=true npm run your-app
40
- * ```
41
- *
42
- * @returns Whether to use custom ECIES implementation
43
- */
44
- get useCustomECIES() {
45
- return process.env.VANA_USE_CUSTOM_ECIES === "true";
46
- }
47
- };
24
+ const features = {};
48
25
  // Annotate the CommonJS export names for ESM import in node:
49
26
  0 && (module.exports = {
50
27
  features
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ## Dual-Mode ECIES Support\n *\n * The SDK supports two encryption implementations:\n *\n * 1. **eccrypto-js** (Default)\n * - Pure JavaScript implementation\n * - Works everywhere (Node.js and browsers)\n * - No native dependencies\n * - Good performance for most use cases\n *\n * 2. **Custom ECIES** (Opt-in)\n * - Uses native `secp256k1` module in Node.js for optimal performance\n * - Uses `@noble/secp256k1` in browsers (pure JS)\n * - Slightly faster in Node.js environments\n * - Currently used by tests to ensure compatibility\n *\n * ### Architecture Notes\n * - Browser builds: Never reference native `secp256k1`, use `@noble/secp256k1` instead\n * - Node builds: Include both implementations, feature flag chooses at runtime\n * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues\n *\n * ### Future Plans\n * Once the custom ECIES implementation is battle-tested:\n * 1. Make custom ECIES the default\n * 2. Eventually remove eccrypto-js dependency\n * 3. Keep the same architecture (native for Node, @noble for browser)\n */\n\n/**\n * Feature flag configuration\n */\nexport const features = {\n /**\n * Use custom ECIES implementation instead of eccrypto\n *\n * When false (default): Uses the original eccrypto/eccrypto-js libraries for stability\n * When true: Uses the custom platform-specific ECIES implementation\n *\n * Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true\n *\n * @example\n * ```bash\n * # Use eccrypto-js (default)\n * VANA_USE_CUSTOM_ECIES=false npm run your-app\n *\n * # Use custom ECIES implementation\n * VANA_USE_CUSTOM_ECIES=true npm run your-app\n * ```\n *\n * @returns Whether to use custom ECIES implementation\n */\n get useCustomECIES(): boolean {\n // Default to false (use eccrypto for stability)\n // Tests will override this to true since they test the custom implementation\n return process.env.VANA_USE_CUSTOM_ECIES === \"true\";\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCO,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBtB,IAAI,iBAA0B;AAG5B,WAAO,QAAQ,IAAI,0BAA0B;AAAA,EAC/C;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ## ECIES Encryption\n *\n * The SDK uses a custom ECIES implementation:\n * - **Node.js**: Uses native `secp256k1` module for optimal performance\n * - **Browser**: Uses `@noble/secp256k1` (pure JavaScript)\n * - Fully compatible with eccrypto format for backward compatibility\n *\n * ### Architecture Notes\n * - Browser builds: Use `@noble/secp256k1` (no native dependencies)\n * - Node builds: Use native `secp256k1` when available for better performance\n * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues\n * - All encrypted data is compatible with the eccrypto format specification\n */\n\n/**\n * Feature flag configuration\n *\n * @remarks\n * Currently empty as all feature flags have been graduated to default behavior.\n * This module is kept for future feature flag additions.\n */\nexport const features = {};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BO,MAAM,WAAW,CAAC;","names":[]}
@@ -8,55 +8,24 @@
8
8
  * The getter pattern is used to allow dynamic evaluation of environment variables,
9
9
  * which is necessary for tests to override the default before modules are loaded.
10
10
  *
11
- * ## Dual-Mode ECIES Support
11
+ * ## ECIES Encryption
12
12
  *
13
- * The SDK supports two encryption implementations:
14
- *
15
- * 1. **eccrypto-js** (Default)
16
- * - Pure JavaScript implementation
17
- * - Works everywhere (Node.js and browsers)
18
- * - No native dependencies
19
- * - Good performance for most use cases
20
- *
21
- * 2. **Custom ECIES** (Opt-in)
22
- * - Uses native `secp256k1` module in Node.js for optimal performance
23
- * - Uses `@noble/secp256k1` in browsers (pure JS)
24
- * - Slightly faster in Node.js environments
25
- * - Currently used by tests to ensure compatibility
13
+ * The SDK uses a custom ECIES implementation:
14
+ * - **Node.js**: Uses native `secp256k1` module for optimal performance
15
+ * - **Browser**: Uses `@noble/secp256k1` (pure JavaScript)
16
+ * - Fully compatible with eccrypto format for backward compatibility
26
17
  *
27
18
  * ### Architecture Notes
28
- * - Browser builds: Never reference native `secp256k1`, use `@noble/secp256k1` instead
29
- * - Node builds: Include both implementations, feature flag chooses at runtime
19
+ * - Browser builds: Use `@noble/secp256k1` (no native dependencies)
20
+ * - Node builds: Use native `secp256k1` when available for better performance
30
21
  * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues
31
- *
32
- * ### Future Plans
33
- * Once the custom ECIES implementation is battle-tested:
34
- * 1. Make custom ECIES the default
35
- * 2. Eventually remove eccrypto-js dependency
36
- * 3. Keep the same architecture (native for Node, @noble for browser)
22
+ * - All encrypted data is compatible with the eccrypto format specification
37
23
  */
38
24
  /**
39
25
  * Feature flag configuration
26
+ *
27
+ * @remarks
28
+ * Currently empty as all feature flags have been graduated to default behavior.
29
+ * This module is kept for future feature flag additions.
40
30
  */
41
- export declare const features: {
42
- /**
43
- * Use custom ECIES implementation instead of eccrypto
44
- *
45
- * When false (default): Uses the original eccrypto/eccrypto-js libraries for stability
46
- * When true: Uses the custom platform-specific ECIES implementation
47
- *
48
- * Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true
49
- *
50
- * @example
51
- * ```bash
52
- * # Use eccrypto-js (default)
53
- * VANA_USE_CUSTOM_ECIES=false npm run your-app
54
- *
55
- * # Use custom ECIES implementation
56
- * VANA_USE_CUSTOM_ECIES=true npm run your-app
57
- * ```
58
- *
59
- * @returns Whether to use custom ECIES implementation
60
- */
61
- readonly useCustomECIES: boolean;
62
- };
31
+ export declare const features: {};
@@ -1,27 +1,4 @@
1
- const features = {
2
- /**
3
- * Use custom ECIES implementation instead of eccrypto
4
- *
5
- * When false (default): Uses the original eccrypto/eccrypto-js libraries for stability
6
- * When true: Uses the custom platform-specific ECIES implementation
7
- *
8
- * Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true
9
- *
10
- * @example
11
- * ```bash
12
- * # Use eccrypto-js (default)
13
- * VANA_USE_CUSTOM_ECIES=false npm run your-app
14
- *
15
- * # Use custom ECIES implementation
16
- * VANA_USE_CUSTOM_ECIES=true npm run your-app
17
- * ```
18
- *
19
- * @returns Whether to use custom ECIES implementation
20
- */
21
- get useCustomECIES() {
22
- return process.env.VANA_USE_CUSTOM_ECIES === "true";
23
- }
24
- };
1
+ const features = {};
25
2
  export {
26
3
  features
27
4
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ## Dual-Mode ECIES Support\n *\n * The SDK supports two encryption implementations:\n *\n * 1. **eccrypto-js** (Default)\n * - Pure JavaScript implementation\n * - Works everywhere (Node.js and browsers)\n * - No native dependencies\n * - Good performance for most use cases\n *\n * 2. **Custom ECIES** (Opt-in)\n * - Uses native `secp256k1` module in Node.js for optimal performance\n * - Uses `@noble/secp256k1` in browsers (pure JS)\n * - Slightly faster in Node.js environments\n * - Currently used by tests to ensure compatibility\n *\n * ### Architecture Notes\n * - Browser builds: Never reference native `secp256k1`, use `@noble/secp256k1` instead\n * - Node builds: Include both implementations, feature flag chooses at runtime\n * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues\n *\n * ### Future Plans\n * Once the custom ECIES implementation is battle-tested:\n * 1. Make custom ECIES the default\n * 2. Eventually remove eccrypto-js dependency\n * 3. Keep the same architecture (native for Node, @noble for browser)\n */\n\n/**\n * Feature flag configuration\n */\nexport const features = {\n /**\n * Use custom ECIES implementation instead of eccrypto\n *\n * When false (default): Uses the original eccrypto/eccrypto-js libraries for stability\n * When true: Uses the custom platform-specific ECIES implementation\n *\n * Enable by setting environment variable: VANA_USE_CUSTOM_ECIES=true\n *\n * @example\n * ```bash\n * # Use eccrypto-js (default)\n * VANA_USE_CUSTOM_ECIES=false npm run your-app\n *\n * # Use custom ECIES implementation\n * VANA_USE_CUSTOM_ECIES=true npm run your-app\n * ```\n *\n * @returns Whether to use custom ECIES implementation\n */\n get useCustomECIES(): boolean {\n // Default to false (use eccrypto for stability)\n // Tests will override this to true since they test the custom implementation\n return process.env.VANA_USE_CUSTOM_ECIES === \"true\";\n },\n};\n"],"mappings":"AAyCO,MAAM,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoBtB,IAAI,iBAA0B;AAG5B,WAAO,QAAQ,IAAI,0BAA0B;AAAA,EAC/C;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/config/features.ts"],"sourcesContent":["/**\n * Feature flags for the Vana SDK\n *\n * @remarks\n * This module controls feature toggles that allow switching between different\n * implementations or enabling experimental features.\n *\n * The getter pattern is used to allow dynamic evaluation of environment variables,\n * which is necessary for tests to override the default before modules are loaded.\n *\n * ## ECIES Encryption\n *\n * The SDK uses a custom ECIES implementation:\n * - **Node.js**: Uses native `secp256k1` module for optimal performance\n * - **Browser**: Uses `@noble/secp256k1` (pure JavaScript)\n * - Fully compatible with eccrypto format for backward compatibility\n *\n * ### Architecture Notes\n * - Browser builds: Use `@noble/secp256k1` (no native dependencies)\n * - Node builds: Use native `secp256k1` when available for better performance\n * - `secp256k1`: Remains an `optionalDependency` so browser-only users don't face build issues\n * - All encrypted data is compatible with the eccrypto format specification\n */\n\n/**\n * Feature flag configuration\n *\n * @remarks\n * Currently empty as all feature flags have been graduated to default behavior.\n * This module is kept for future feature flag additions.\n */\nexport const features = {};\n"],"mappings":"AA+BO,MAAM,WAAW,CAAC;","names":[]}
@@ -43,6 +43,7 @@ var import_signatureCache = require("../utils/signatureCache");
43
43
  var import_signatureFormatter = require("../utils/signatureFormatter");
44
44
  var import_typedDataConverter = require("../utils/typedDataConverter");
45
45
  var import_base = require("./base");
46
+ const MAX_UINT256 = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
46
47
  class PermissionsController extends import_base.BaseController {
47
48
  constructor(context) {
48
49
  super(context);
@@ -1499,20 +1500,24 @@ class PermissionsController extends import_base.BaseController {
1499
1500
  }
1500
1501
  }
1501
1502
  const onChainGrants = allPermissions.map(
1502
- (permission) => ({
1503
- id: BigInt(permission.id),
1504
- grantUrl: permission.grant,
1505
- grantSignature: permission.signature,
1506
- nonce: BigInt(permission.nonce),
1507
- startBlock: BigInt(permission.startBlock),
1508
- addedAtBlock: BigInt(permission.addedAtBlock),
1509
- addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1510
- transactionHash: permission.transactionHash ?? "",
1511
- grantor: userAddress,
1512
- grantee: permission.grantee,
1513
- active: !permission.endBlock || BigInt(permission.endBlock) === 0n
1514
- // Active if no end block or end block is 0
1515
- })
1503
+ (permission) => {
1504
+ const endBlock = permission.endBlock === void 0 || permission.endBlock === null ? 0n : BigInt(permission.endBlock);
1505
+ const active = !permission.endBlock || endBlock === 0n || endBlock === MAX_UINT256;
1506
+ return {
1507
+ id: BigInt(permission.id),
1508
+ grantUrl: permission.grant,
1509
+ grantSignature: permission.signature,
1510
+ nonce: BigInt(permission.nonce),
1511
+ startBlock: BigInt(permission.startBlock),
1512
+ endBlock,
1513
+ addedAtBlock: BigInt(permission.addedAtBlock),
1514
+ addedAtTimestamp: BigInt(permission.addedAtTimestamp ?? "0"),
1515
+ transactionHash: permission.transactionHash ?? "",
1516
+ grantor: userAddress,
1517
+ grantee: permission.grantee,
1518
+ active
1519
+ };
1520
+ }
1516
1521
  );
1517
1522
  return onChainGrants.sort((a, b) => {
1518
1523
  if (a.id < b.id) return 1;