@opendatalabs/vana-sdk 3.4.0 → 3.4.1-canary.5ef490b

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 (43) hide show
  1. package/dist/index.browser.d.ts +6 -3
  2. package/dist/index.browser.js +378 -128
  3. package/dist/index.browser.js.map +4 -4
  4. package/dist/index.node.cjs +400 -133
  5. package/dist/index.node.cjs.map +4 -4
  6. package/dist/index.node.d.ts +6 -3
  7. package/dist/index.node.js +378 -128
  8. package/dist/index.node.js.map +4 -4
  9. package/dist/protocol/data-point-status.cjs +80 -0
  10. package/dist/protocol/data-point-status.cjs.map +1 -0
  11. package/dist/protocol/data-point-status.d.ts +34 -0
  12. package/dist/protocol/data-point-status.js +51 -0
  13. package/dist/protocol/data-point-status.js.map +1 -0
  14. package/dist/protocol/data-point-status.test.d.ts +1 -0
  15. package/dist/protocol/eip712.cjs +53 -31
  16. package/dist/protocol/eip712.cjs.map +1 -1
  17. package/dist/protocol/eip712.d.ts +98 -43
  18. package/dist/protocol/eip712.js +47 -27
  19. package/dist/protocol/eip712.js.map +1 -1
  20. package/dist/protocol/escrow-deposit.cjs +89 -0
  21. package/dist/protocol/escrow-deposit.cjs.map +1 -0
  22. package/dist/protocol/escrow-deposit.d.ts +47 -0
  23. package/dist/protocol/escrow-deposit.js +60 -0
  24. package/dist/protocol/escrow-deposit.js.map +1 -0
  25. package/dist/protocol/escrow-deposit.test.d.ts +1 -0
  26. package/dist/protocol/escrow-flow.test.d.ts +21 -0
  27. package/dist/protocol/fee-registry.cjs +116 -0
  28. package/dist/protocol/fee-registry.cjs.map +1 -0
  29. package/dist/protocol/fee-registry.d.ts +151 -0
  30. package/dist/protocol/fee-registry.js +89 -0
  31. package/dist/protocol/fee-registry.js.map +1 -0
  32. package/dist/protocol/fee-registry.test.d.ts +1 -0
  33. package/dist/protocol/gateway.cjs +110 -38
  34. package/dist/protocol/gateway.cjs.map +1 -1
  35. package/dist/protocol/gateway.d.ts +238 -56
  36. package/dist/protocol/gateway.js +110 -38
  37. package/dist/protocol/gateway.js.map +1 -1
  38. package/dist/protocol/grants.cjs +24 -64
  39. package/dist/protocol/grants.cjs.map +1 -1
  40. package/dist/protocol/grants.d.ts +6 -13
  41. package/dist/protocol/grants.js +24 -63
  42. package/dist/protocol/grants.js.map +1 -1
  43. package/package.json +3 -2
@@ -31882,6 +31882,7 @@ async function verifyWeb3Signed(params) {
31882
31882
  // src/protocol/eip712.ts
31883
31883
  var DOMAIN_NAME = "Vana Data Portability";
31884
31884
  var DOMAIN_VERSION = "1";
31885
+ var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
31885
31886
  function buildDomain(chainId, verifyingContract) {
31886
31887
  return {
31887
31888
  name: DOMAIN_NAME,
@@ -31890,13 +31891,7 @@ function buildDomain(chainId, verifyingContract) {
31890
31891
  verifyingContract
31891
31892
  };
31892
31893
  }
31893
- function fileRegistrationDomain(config) {
31894
- return buildDomain(
31895
- config.chainId,
31896
- config.contracts.dataRegistry
31897
- );
31898
- }
31899
- function fileDeletionDomain(config) {
31894
+ function dataRegistryDomain(config) {
31900
31895
  return buildDomain(
31901
31896
  config.chainId,
31902
31897
  config.contracts.dataRegistry
@@ -31926,31 +31921,26 @@ function builderRegistrationDomain(config) {
31926
31921
  config.contracts.dataPortabilityGrantees
31927
31922
  );
31928
31923
  }
31929
- var FILE_REGISTRATION_TYPES = {
31930
- FileRegistration: [
31931
- { name: "ownerAddress", type: "address" },
31932
- { name: "url", type: "string" },
31933
- { name: "schemaId", type: "bytes32" }
31934
- ]
31935
- };
31936
- var FILE_DELETION_TYPES = {
31937
- FileDeletion: [
31938
- { name: "ownerAddress", type: "address" },
31939
- { name: "fileId", type: "bytes32" }
31940
- ]
31941
- };
31924
+ function escrowPaymentDomain(config) {
31925
+ return buildDomain(
31926
+ config.chainId,
31927
+ config.contracts.dataPortabilityEscrow
31928
+ );
31929
+ }
31942
31930
  var GRANT_REGISTRATION_TYPES = {
31943
31931
  GrantRegistration: [
31944
31932
  { name: "grantorAddress", type: "address" },
31945
31933
  { name: "granteeId", type: "bytes32" },
31946
- { name: "grant", type: "string" },
31947
- { name: "fileIds", type: "uint256[]" }
31934
+ { name: "scopes", type: "string[]" },
31935
+ { name: "grantVersion", type: "uint256" },
31936
+ { name: "expiresAt", type: "uint256" }
31948
31937
  ]
31949
31938
  };
31950
31939
  var GRANT_REVOCATION_TYPES = {
31951
31940
  GrantRevocation: [
31952
31941
  { name: "grantorAddress", type: "address" },
31953
- { name: "grantId", type: "bytes32" }
31942
+ { name: "grantId", type: "bytes32" },
31943
+ { name: "grantVersion", type: "uint256" }
31954
31944
  ]
31955
31945
  };
31956
31946
  var SERVER_REGISTRATION_TYPES = {
@@ -31969,6 +31959,34 @@ var BUILDER_REGISTRATION_TYPES = {
31969
31959
  { name: "appUrl", type: "string" }
31970
31960
  ]
31971
31961
  };
31962
+ var GENERIC_PAYMENT_TYPES = {
31963
+ GenericPayment: [
31964
+ { name: "payerAddress", type: "address" },
31965
+ { name: "opType", type: "string" },
31966
+ { name: "opId", type: "bytes32" },
31967
+ { name: "asset", type: "address" },
31968
+ { name: "amount", type: "uint256" },
31969
+ { name: "paymentNonce", type: "uint256" }
31970
+ ]
31971
+ };
31972
+ var ADD_DATA_TYPES = {
31973
+ AddData: [
31974
+ { name: "ownerAddress", type: "address" },
31975
+ { name: "scope", type: "string" },
31976
+ { name: "dataHash", type: "bytes32" },
31977
+ { name: "metadataHash", type: "bytes32" },
31978
+ { name: "expectedVersion", type: "uint256" }
31979
+ ]
31980
+ };
31981
+ var RECORD_DATA_ACCESS_TYPES = {
31982
+ RecordDataAccess: [
31983
+ { name: "ownerAddress", type: "address" },
31984
+ { name: "scope", type: "string" },
31985
+ { name: "version", type: "uint256" },
31986
+ { name: "accessor", type: "address" },
31987
+ { name: "recordId", type: "bytes32" }
31988
+ ]
31989
+ };
31972
31990
 
31973
31991
  // src/protocol/personal-server-registration.ts
31974
31992
  import {
@@ -32410,67 +32428,31 @@ function isDataPortabilityGatewayConfig(value) {
32410
32428
  return false;
32411
32429
  }
32412
32430
  const c = contracts;
32413
- return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
32414
- }
32415
- function parseGrantRegistrationPayload(grant) {
32416
- let parsed;
32417
- try {
32418
- parsed = JSON.parse(grant);
32419
- } catch {
32420
- return null;
32421
- }
32422
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
32423
- return null;
32424
- }
32425
- const value = parsed;
32426
- if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
32427
- return null;
32428
- }
32429
- if (!value["scopes"].every((scope) => typeof scope === "string")) {
32430
- return null;
32431
- }
32432
- if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
32433
- return null;
32434
- }
32435
- if (value["user"] !== void 0 && !isHexString(value["user"])) {
32436
- return null;
32437
- }
32438
- if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
32439
- return null;
32440
- }
32441
- if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
32442
- return null;
32443
- }
32444
- return {
32445
- user: value["user"],
32446
- builder: value["builder"],
32447
- scopes: value["scopes"],
32448
- expiresAt: value["expiresAt"],
32449
- nonce: value["nonce"]
32450
- };
32431
+ return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
32451
32432
  }
32452
- function parseFileIds(fileIds) {
32433
+ function toUint256(value) {
32453
32434
  try {
32454
- const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
32455
- return {
32456
- values,
32457
- display: values.map((fileId) => fileId.toString())
32458
- };
32435
+ const big = typeof value === "bigint" ? value : BigInt(value);
32436
+ if (big < 0n) return null;
32437
+ return big;
32459
32438
  } catch {
32460
32439
  return null;
32461
32440
  }
32462
32441
  }
32463
32442
  async function verifyGrantRegistration(input) {
32464
- const payload = parseGrantRegistrationPayload(input.grant);
32465
- if (!payload) {
32466
- return {
32467
- valid: false,
32468
- error: "Grant must be JSON with scopes and expiresAt"
32469
- };
32443
+ if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
32444
+ return { valid: false, error: "scopes must be a non-empty array" };
32445
+ }
32446
+ if (!input.scopes.every((scope) => typeof scope === "string")) {
32447
+ return { valid: false, error: "scopes must contain only strings" };
32448
+ }
32449
+ const grantVersion = toUint256(input.grantVersion);
32450
+ if (grantVersion === null || grantVersion < 1n) {
32451
+ return { valid: false, error: "grantVersion must be a uint256 >= 1" };
32470
32452
  }
32471
- const fileIds = parseFileIds(input.fileIds);
32472
- if (!fileIds) {
32473
- return { valid: false, error: "fileIds must contain integer values" };
32453
+ const expiresAt = toUint256(input.expiresAt);
32454
+ if (expiresAt === null) {
32455
+ return { valid: false, error: "expiresAt must be a non-negative uint256" };
32474
32456
  }
32475
32457
  let valid;
32476
32458
  try {
@@ -32482,8 +32464,9 @@ async function verifyGrantRegistration(input) {
32482
32464
  message: {
32483
32465
  grantorAddress: input.grantorAddress,
32484
32466
  granteeId: input.granteeId,
32485
- grant: input.grant,
32486
- fileIds: fileIds.values
32467
+ scopes: input.scopes,
32468
+ grantVersion,
32469
+ expiresAt
32487
32470
  },
32488
32471
  signature: input.signature
32489
32472
  });
@@ -32494,19 +32477,197 @@ async function verifyGrantRegistration(input) {
32494
32477
  return { valid: false, error: "Grant signature does not match grantor" };
32495
32478
  }
32496
32479
  const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
32497
- if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
32480
+ if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
32498
32481
  return { valid: false, error: "Grant has expired" };
32499
32482
  }
32500
- if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
32501
- return { valid: false, error: "Grant user does not match grantorAddress" };
32502
- }
32503
32483
  return {
32504
32484
  valid: true,
32505
32485
  grantorAddress: input.grantorAddress,
32506
32486
  granteeId: input.granteeId,
32507
- grant: input.grant,
32508
- payload,
32509
- fileIds: fileIds.display
32487
+ scopes: input.scopes,
32488
+ grantVersion: grantVersion.toString(),
32489
+ expiresAt: expiresAt.toString()
32490
+ };
32491
+ }
32492
+
32493
+ // src/protocol/escrow-deposit.ts
32494
+ import { encodeFunctionData } from "viem";
32495
+ var ESCROW_DEPOSIT_ABI = [
32496
+ {
32497
+ type: "function",
32498
+ name: "depositNative",
32499
+ stateMutability: "payable",
32500
+ inputs: [{ name: "account", type: "address" }],
32501
+ outputs: []
32502
+ },
32503
+ {
32504
+ type: "function",
32505
+ name: "depositToken",
32506
+ stateMutability: "nonpayable",
32507
+ inputs: [
32508
+ { name: "account", type: "address" },
32509
+ { name: "token", type: "address" },
32510
+ { name: "amount", type: "uint256" }
32511
+ ],
32512
+ outputs: []
32513
+ }
32514
+ ];
32515
+ function escrowContractAddress(config) {
32516
+ return config.contracts.dataPortabilityEscrow;
32517
+ }
32518
+ function encodeDepositNativeData(input) {
32519
+ return encodeFunctionData({
32520
+ abi: ESCROW_DEPOSIT_ABI,
32521
+ functionName: "depositNative",
32522
+ args: [input.account]
32523
+ });
32524
+ }
32525
+ function encodeDepositTokenData(input) {
32526
+ return encodeFunctionData({
32527
+ abi: ESCROW_DEPOSIT_ABI,
32528
+ functionName: "depositToken",
32529
+ args: [input.account, input.token, input.amount]
32530
+ });
32531
+ }
32532
+ function buildDepositNativeRequest(config, input) {
32533
+ return {
32534
+ to: escrowContractAddress(config),
32535
+ data: encodeDepositNativeData({ account: input.account }),
32536
+ value: input.amount
32537
+ };
32538
+ }
32539
+ function buildDepositTokenRequest(config, input) {
32540
+ return {
32541
+ to: escrowContractAddress(config),
32542
+ data: encodeDepositTokenData(input)
32543
+ };
32544
+ }
32545
+
32546
+ // src/protocol/data-point-status.ts
32547
+ import { encodeFunctionData as encodeFunctionData2 } from "viem";
32548
+ var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
32549
+ DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
32550
+ DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
32551
+ DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
32552
+ DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
32553
+ return DataPointStatus2;
32554
+ })(DataPointStatus || {});
32555
+ var DATA_REGISTRY_STATUS_ABI = [
32556
+ {
32557
+ type: "function",
32558
+ name: "setStatus",
32559
+ stateMutability: "nonpayable",
32560
+ inputs: [
32561
+ { name: "scope", type: "string" },
32562
+ { name: "newStatus", type: "uint8" }
32563
+ ],
32564
+ outputs: []
32565
+ }
32566
+ ];
32567
+ function dataRegistryContractAddress(config) {
32568
+ return config.contracts.dataRegistry;
32569
+ }
32570
+ function encodeSetDataPointStatusData(input) {
32571
+ return encodeFunctionData2({
32572
+ abi: DATA_REGISTRY_STATUS_ABI,
32573
+ functionName: "setStatus",
32574
+ args: [input.scope, input.status]
32575
+ });
32576
+ }
32577
+ function buildSetDataPointStatusRequest(config, input) {
32578
+ return {
32579
+ to: dataRegistryContractAddress(config),
32580
+ data: encodeSetDataPointStatusData(input)
32581
+ };
32582
+ }
32583
+ function buildMarkDataPointUnavailableRequest(config, input) {
32584
+ return buildSetDataPointStatusRequest(config, {
32585
+ scope: input.scope,
32586
+ status: 3 /* Unavailable */
32587
+ });
32588
+ }
32589
+
32590
+ // src/protocol/fee-registry.ts
32591
+ import { parseAbi } from "viem";
32592
+ var FEE_REGISTRY_ABI = parseAbi([
32593
+ "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
32594
+ "function fees(bytes32 operation) view returns (Fee)",
32595
+ "function operationKey(string name) pure returns (bytes32)"
32596
+ ]);
32597
+ var REGISTRATION_KIND_FOR_OP = {
32598
+ grant: "grant_registration",
32599
+ data: "data_registration",
32600
+ server: "server_registration",
32601
+ builder: "builder_registration"
32602
+ };
32603
+ function operationNameFor(kind, opts) {
32604
+ switch (kind) {
32605
+ case "grant_registration":
32606
+ return opts?.grantRegistrationOpName ?? "grant_registration";
32607
+ case "data_access":
32608
+ return opts?.dataAccessOpName ?? "data_access";
32609
+ case "data_registration":
32610
+ return opts?.dataRegistrationOpName ?? "data_registration";
32611
+ case "server_registration":
32612
+ return opts?.serverRegistrationOpName ?? "server_registration";
32613
+ case "builder_registration":
32614
+ return opts?.builderRegistrationOpName ?? "builder_registration";
32615
+ }
32616
+ }
32617
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
32618
+ async function getFee(client, config, kind, opts) {
32619
+ const address = config.contracts.feeRegistry;
32620
+ const opName = operationNameFor(kind, opts);
32621
+ const opKey = await client.readContract({
32622
+ address,
32623
+ abi: FEE_REGISTRY_ABI,
32624
+ functionName: "operationKey",
32625
+ args: [opName]
32626
+ });
32627
+ const fee = await client.readContract({
32628
+ address,
32629
+ abi: FEE_REGISTRY_ABI,
32630
+ functionName: "fees",
32631
+ args: [opKey]
32632
+ });
32633
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
32634
+ throw new Error(
32635
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
32636
+ );
32637
+ }
32638
+ return fee;
32639
+ }
32640
+ async function getOpFee(client, config, opType, opts) {
32641
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
32642
+ if (!registrationKind) {
32643
+ throw new Error(
32644
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
32645
+ );
32646
+ }
32647
+ const includeDataAccess = opType === "grant";
32648
+ const [registration, dataAccess] = await Promise.all([
32649
+ getFee(client, config, registrationKind, opts),
32650
+ includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
32651
+ amount: 0n,
32652
+ asset: ZERO_ADDRESS,
32653
+ payee: ZERO_ADDRESS,
32654
+ enabled: false
32655
+ })
32656
+ ]);
32657
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
32658
+ throw new Error(
32659
+ `FeeRegistry asset mismatch for "${opType}": registration=${registration.asset} vs data_access=${dataAccess.asset}. The gateway requires both kinds to settle in the same asset when both are enabled.`
32660
+ );
32661
+ }
32662
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
32663
+ return {
32664
+ asset,
32665
+ registrationFee: registration.enabled ? registration.amount : 0n,
32666
+ dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
32667
+ registrationEnabled: registration.enabled,
32668
+ dataAccessEnabled: dataAccess.enabled,
32669
+ registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
32670
+ dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
32510
32671
  };
32511
32672
  }
32512
32673
 
@@ -32587,16 +32748,6 @@ function createGatewayClient(baseUrl) {
32587
32748
  const envelope = await res.json();
32588
32749
  return envelope.data;
32589
32750
  }
32590
- function normalizeFileRecord(record) {
32591
- return {
32592
- fileId: record.fileId ?? record.id ?? "",
32593
- owner: record.owner ?? record.ownerAddress ?? "",
32594
- url: record.url,
32595
- schemaId: record.schemaId,
32596
- createdAt: record.createdAt ?? record.addedAt ?? "",
32597
- deletedAt: record.deletedAt ?? null
32598
- };
32599
- }
32600
32751
  function getMutationId(body, key) {
32601
32752
  const value = body[key] ?? body["id"];
32602
32753
  return typeof value === "string" ? value : void 0;
@@ -32646,30 +32797,34 @@ function createGatewayClient(baseUrl) {
32646
32797
  }
32647
32798
  return unwrapEnvelope(res);
32648
32799
  },
32649
- async getFile(fileId) {
32650
- const res = await fetch(`${base}/v1/files/${fileId}`);
32800
+ async getDataPoint(dataPointId) {
32801
+ const res = await fetch(`${base}/v1/data/${dataPointId}`);
32651
32802
  if (res.status === 404) return null;
32652
32803
  if (!res.ok) {
32653
32804
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32654
32805
  }
32655
- return normalizeFileRecord(await unwrapEnvelope(res));
32806
+ return unwrapEnvelope(res);
32656
32807
  },
32657
- async listFilesSince(owner, cursor, options) {
32808
+ async listDataPointsByOwner(owner, cursor, options) {
32658
32809
  const params = new URLSearchParams({ user: owner });
32659
32810
  if (cursor !== null) {
32660
- params.set("since", cursor);
32811
+ params.set("cursor", cursor);
32661
32812
  }
32662
- if (options?.includeDeleted) {
32663
- params.set("includeDeleted", "true");
32813
+ if (options?.since) {
32814
+ params.set("since", options.since);
32815
+ }
32816
+ if (options?.limit !== void 0) {
32817
+ params.set("limit", String(options.limit));
32664
32818
  }
32665
- const res = await fetch(`${base}/v1/files?${params.toString()}`);
32819
+ const res = await fetch(`${base}/v1/data?${params.toString()}`);
32666
32820
  if (!res.ok) {
32667
32821
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32668
32822
  }
32669
- const data = await unwrapEnvelope(res);
32823
+ const envelope = await res.json();
32824
+ const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
32670
32825
  return {
32671
- files: data.files.map(normalizeFileRecord),
32672
- cursor: data.cursor
32826
+ dataPoints: envelope.data.dataPoints,
32827
+ cursor: nextCursor
32673
32828
  };
32674
32829
  },
32675
32830
  async getSchema(schemaId) {
@@ -32710,8 +32865,8 @@ function createGatewayClient(baseUrl) {
32710
32865
  alreadyRegistered: false
32711
32866
  };
32712
32867
  },
32713
- async registerFile(params) {
32714
- const res = await fetch(`${base}/v1/files`, {
32868
+ async registerBuilder(params) {
32869
+ const res = await fetch(`${base}/v1/builders`, {
32715
32870
  method: "POST",
32716
32871
  headers: {
32717
32872
  "Content-Type": "application/json",
@@ -32719,22 +32874,57 @@ function createGatewayClient(baseUrl) {
32719
32874
  },
32720
32875
  body: JSON.stringify({
32721
32876
  ownerAddress: params.ownerAddress,
32722
- url: params.url,
32723
- schemaId: params.schemaId
32877
+ granteeAddress: params.granteeAddress,
32878
+ publicKey: params.publicKey,
32879
+ appUrl: params.appUrl
32724
32880
  })
32725
32881
  });
32726
32882
  if (res.status === 409) {
32727
32883
  const body2 = await res.json().catch(() => ({}));
32728
32884
  return {
32729
- fileId: getMutationId(body2, "fileId")
32885
+ builderId: getMutationId(
32886
+ body2,
32887
+ "builderId"
32888
+ ),
32889
+ alreadyRegistered: true
32730
32890
  };
32731
32891
  }
32732
32892
  if (!res.ok) {
32733
32893
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32734
32894
  }
32735
- const body = await res.json();
32895
+ const body = await res.json().catch(() => ({}));
32736
32896
  return {
32737
- fileId: getMutationId(body, "fileId")
32897
+ builderId: getMutationId(body, "builderId"),
32898
+ alreadyRegistered: false
32899
+ };
32900
+ },
32901
+ async registerDataPoint(params) {
32902
+ const res = await fetch(`${base}/v1/data`, {
32903
+ method: "POST",
32904
+ headers: {
32905
+ "Content-Type": "application/json",
32906
+ Authorization: `Web3Signed ${params.signature}`
32907
+ },
32908
+ body: JSON.stringify({
32909
+ ownerAddress: params.ownerAddress,
32910
+ scope: params.scope,
32911
+ dataHash: params.dataHash,
32912
+ metadataHash: params.metadataHash,
32913
+ expectedVersion: params.expectedVersion
32914
+ })
32915
+ });
32916
+ if (!res.ok) {
32917
+ const body2 = await res.json().catch(() => ({}));
32918
+ const detail = body2.error ?? res.statusText;
32919
+ throw new Error(`Gateway error: ${res.status} ${detail}`);
32920
+ }
32921
+ const body = await res.json().catch(() => ({}));
32922
+ return {
32923
+ dataPointId: getMutationId(
32924
+ body,
32925
+ "dataPointId"
32926
+ ),
32927
+ expectedVersion: body.expectedVersion
32738
32928
  };
32739
32929
  },
32740
32930
  async createGrant(params) {
@@ -32747,8 +32937,9 @@ function createGatewayClient(baseUrl) {
32747
32937
  body: JSON.stringify({
32748
32938
  grantorAddress: params.grantorAddress,
32749
32939
  granteeId: params.granteeId,
32750
- grant: params.grant,
32751
- fileIds: params.fileIds
32940
+ scopes: params.scopes,
32941
+ grantVersion: params.grantVersion,
32942
+ expiresAt: params.expiresAt
32752
32943
  })
32753
32944
  });
32754
32945
  if (res.status === 409) {
@@ -32773,7 +32964,8 @@ function createGatewayClient(baseUrl) {
32773
32964
  Authorization: `Web3Signed ${params.signature}`
32774
32965
  },
32775
32966
  body: JSON.stringify({
32776
- grantorAddress: params.grantorAddress
32967
+ grantorAddress: params.grantorAddress,
32968
+ grantVersion: params.grantVersion
32777
32969
  })
32778
32970
  });
32779
32971
  if (res.status === 409) return;
@@ -32781,21 +32973,62 @@ function createGatewayClient(baseUrl) {
32781
32973
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32782
32974
  }
32783
32975
  },
32784
- async deleteFile(params) {
32785
- const res = await fetch(`${base}/v1/files/${params.fileId}`, {
32786
- method: "DELETE",
32976
+ async getEscrowBalance(account) {
32977
+ const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
32978
+ if (!res.ok) {
32979
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32980
+ }
32981
+ return await res.json();
32982
+ },
32983
+ async submitEscrowDeposit(params) {
32984
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
32985
+ method: "POST",
32986
+ headers: { "Content-Type": "application/json" },
32987
+ body: JSON.stringify({ txHash: params.txHash })
32988
+ });
32989
+ if (res.status !== 200 && res.status !== 202) {
32990
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32991
+ }
32992
+ return await res.json();
32993
+ },
32994
+ async payForOperation(params) {
32995
+ const body = {
32996
+ payerAddress: params.payerAddress,
32997
+ opType: params.opType,
32998
+ opId: params.opId,
32999
+ asset: params.asset,
33000
+ amount: params.amount,
33001
+ paymentNonce: params.paymentNonce
33002
+ };
33003
+ if (params.accessRecord) {
33004
+ body["accessRecord"] = params.accessRecord;
33005
+ }
33006
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33007
+ method: "POST",
32787
33008
  headers: {
32788
33009
  "Content-Type": "application/json",
32789
33010
  Authorization: `Web3Signed ${params.signature}`
32790
33011
  },
32791
- body: JSON.stringify({
32792
- ownerAddress: params.ownerAddress
32793
- })
33012
+ body: JSON.stringify(body)
33013
+ });
33014
+ if (!res.ok) {
33015
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33016
+ }
33017
+ return await res.json();
33018
+ },
33019
+ async settle(params) {
33020
+ const res = await fetch(`${base}/v1/settle`, {
33021
+ method: "POST",
33022
+ headers: { "Content-Type": "application/json" },
33023
+ // The gateway accepts an empty body; only `limit` is recognised.
33024
+ // Always send a JSON body so the gateway's req.body shape parse
33025
+ // doesn't have to deal with an undefined.
33026
+ body: JSON.stringify(params ?? {})
32794
33027
  });
32795
- if (res.status === 409) return;
32796
33028
  if (!res.ok) {
32797
33029
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32798
33030
  }
33031
+ return await res.json();
32799
33032
  }
32800
33033
  };
32801
33034
  }
@@ -32864,6 +33097,7 @@ async function parsePSError(response) {
32864
33097
  }
32865
33098
  export {
32866
33099
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33100
+ ADD_DATA_TYPES,
32867
33101
  AccountPersonalServerLiteOwnerBindingError,
32868
33102
  AccountPersonalServerRegistrationError,
32869
33103
  BUILDER_REGISTRATION_TYPES,
@@ -32874,12 +33108,15 @@ export {
32874
33108
  CallbackStorage,
32875
33109
  ContractFactory,
32876
33110
  ContractNotFoundError,
33111
+ DATA_REGISTRY_STATUS_ABI,
32877
33112
  DataFileEnvelopeSchema,
33113
+ DataPointStatus,
32878
33114
  DropboxStorage,
32879
33115
  ECIESError,
33116
+ ESCROW_DEPOSIT_ABI,
32880
33117
  ExpiredTokenError,
32881
- FILE_DELETION_TYPES,
32882
- FILE_REGISTRATION_TYPES,
33118
+ FEE_REGISTRY_ABI,
33119
+ GENERIC_PAYMENT_TYPES,
32883
33120
  GRANT_REGISTRATION_TYPES,
32884
33121
  GRANT_REVOCATION_TYPES,
32885
33122
  GoogleDriveStorage,
@@ -32890,6 +33127,7 @@ export {
32890
33127
  IpfsStorage,
32891
33128
  MASTER_KEY_MESSAGE,
32892
33129
  MissingAuthError,
33130
+ NATIVE_VANA_ASSET,
32893
33131
  NetworkError,
32894
33132
  NonceError,
32895
33133
  OAuthClient,
@@ -32905,6 +33143,8 @@ export {
32905
33143
  PersonalServerError,
32906
33144
  PinataStorage,
32907
33145
  R2Storage,
33146
+ RECORD_DATA_ACCESS_TYPES,
33147
+ REGISTRATION_KIND_FOR_OP,
32908
33148
  ReadOnlyError,
32909
33149
  RelayerError,
32910
33150
  SERVER_REGISTRATION_TYPES,
@@ -32919,10 +33159,14 @@ export {
32919
33159
  VanaError,
32920
33160
  VanaStorage,
32921
33161
  assertValidPkceVerifier,
33162
+ buildDepositNativeRequest,
33163
+ buildDepositTokenRequest,
33164
+ buildMarkDataPointUnavailableRequest,
32922
33165
  buildPersonalServerLiteOwnerBindingMessage,
32923
33166
  buildPersonalServerLiteOwnerBindingSignature,
32924
33167
  buildPersonalServerRegistrationSignature,
32925
33168
  buildPersonalServerRegistrationTypedData,
33169
+ buildSetDataPointStatusRequest,
32926
33170
  buildWeb3SignedHeader,
32927
33171
  builderRegistrationDomain,
32928
33172
  chains,
@@ -32937,14 +33181,19 @@ export {
32937
33181
  createVanaStorageProvider,
32938
33182
  createViemPersonalServerLiteOwnerBindingSigner,
32939
33183
  createViemPersonalServerRegistrationSigner,
33184
+ dataRegistryContractAddress,
33185
+ dataRegistryDomain,
32940
33186
  decryptWithPassword,
32941
33187
  deriveMasterKey,
32942
33188
  deriveScopeKey,
32943
33189
  deserializeECIES,
32944
33190
  detectPlatform,
33191
+ encodeDepositNativeData,
33192
+ encodeDepositTokenData,
33193
+ encodeSetDataPointStatusData,
32945
33194
  encryptWithPassword,
32946
- fileDeletionDomain,
32947
- fileRegistrationDomain,
33195
+ escrowContractAddress,
33196
+ escrowPaymentDomain,
32948
33197
  generatePkceVerifier,
32949
33198
  getAbi,
32950
33199
  getAllChains,
@@ -32952,6 +33201,8 @@ export {
32952
33201
  getContractAddress,
32953
33202
  getContractController,
32954
33203
  getContractInfo,
33204
+ getFee,
33205
+ getOpFee,
32955
33206
  getPlatformCapabilities,
32956
33207
  getServiceEndpoints,
32957
33208
  grantRegistrationDomain,
@@ -32963,7 +33214,6 @@ export {
32963
33214
  moksha,
32964
33215
  mokshaServices,
32965
33216
  mokshaTestnet2 as mokshaTestnet,
32966
- parseGrantRegistrationPayload,
32967
33217
  parsePSError,
32968
33218
  parseScope,
32969
33219
  parseWeb3SignedHeader,