@opendatalabs/vana-sdk 3.3.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 +379 -125
  3. package/dist/index.browser.js.map +4 -4
  4. package/dist/index.node.cjs +401 -130
  5. package/dist/index.node.cjs.map +4 -4
  6. package/dist/index.node.d.ts +6 -3
  7. package/dist/index.node.js +379 -125
  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 +111 -35
  34. package/dist/protocol/gateway.cjs.map +1 -1
  35. package/dist/protocol/gateway.d.ts +240 -45
  36. package/dist/protocol/gateway.js +111 -35
  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,15 +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
- };
32598
- }
32599
32751
  function getMutationId(body, key) {
32600
32752
  const value = body[key] ?? body["id"];
32601
32753
  return typeof value === "string" ? value : void 0;
@@ -32645,27 +32797,34 @@ function createGatewayClient(baseUrl) {
32645
32797
  }
32646
32798
  return unwrapEnvelope(res);
32647
32799
  },
32648
- async getFile(fileId) {
32649
- const res = await fetch(`${base}/v1/files/${fileId}`);
32800
+ async getDataPoint(dataPointId) {
32801
+ const res = await fetch(`${base}/v1/data/${dataPointId}`);
32650
32802
  if (res.status === 404) return null;
32651
32803
  if (!res.ok) {
32652
32804
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32653
32805
  }
32654
- return normalizeFileRecord(await unwrapEnvelope(res));
32806
+ return unwrapEnvelope(res);
32655
32807
  },
32656
- async listFilesSince(owner, cursor) {
32808
+ async listDataPointsByOwner(owner, cursor, options) {
32657
32809
  const params = new URLSearchParams({ user: owner });
32658
32810
  if (cursor !== null) {
32659
- params.set("since", cursor);
32811
+ params.set("cursor", cursor);
32812
+ }
32813
+ if (options?.since) {
32814
+ params.set("since", options.since);
32815
+ }
32816
+ if (options?.limit !== void 0) {
32817
+ params.set("limit", String(options.limit));
32660
32818
  }
32661
- const res = await fetch(`${base}/v1/files?${params.toString()}`);
32819
+ const res = await fetch(`${base}/v1/data?${params.toString()}`);
32662
32820
  if (!res.ok) {
32663
32821
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32664
32822
  }
32665
- const data = await unwrapEnvelope(res);
32823
+ const envelope = await res.json();
32824
+ const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
32666
32825
  return {
32667
- files: data.files.map(normalizeFileRecord),
32668
- cursor: data.cursor
32826
+ dataPoints: envelope.data.dataPoints,
32827
+ cursor: nextCursor
32669
32828
  };
32670
32829
  },
32671
32830
  async getSchema(schemaId) {
@@ -32706,8 +32865,8 @@ function createGatewayClient(baseUrl) {
32706
32865
  alreadyRegistered: false
32707
32866
  };
32708
32867
  },
32709
- async registerFile(params) {
32710
- const res = await fetch(`${base}/v1/files`, {
32868
+ async registerBuilder(params) {
32869
+ const res = await fetch(`${base}/v1/builders`, {
32711
32870
  method: "POST",
32712
32871
  headers: {
32713
32872
  "Content-Type": "application/json",
@@ -32715,22 +32874,57 @@ function createGatewayClient(baseUrl) {
32715
32874
  },
32716
32875
  body: JSON.stringify({
32717
32876
  ownerAddress: params.ownerAddress,
32718
- url: params.url,
32719
- schemaId: params.schemaId
32877
+ granteeAddress: params.granteeAddress,
32878
+ publicKey: params.publicKey,
32879
+ appUrl: params.appUrl
32720
32880
  })
32721
32881
  });
32722
32882
  if (res.status === 409) {
32723
32883
  const body2 = await res.json().catch(() => ({}));
32724
32884
  return {
32725
- fileId: getMutationId(body2, "fileId")
32885
+ builderId: getMutationId(
32886
+ body2,
32887
+ "builderId"
32888
+ ),
32889
+ alreadyRegistered: true
32726
32890
  };
32727
32891
  }
32728
32892
  if (!res.ok) {
32729
32893
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32730
32894
  }
32731
- const body = await res.json();
32895
+ const body = await res.json().catch(() => ({}));
32732
32896
  return {
32733
- 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
32734
32928
  };
32735
32929
  },
32736
32930
  async createGrant(params) {
@@ -32743,8 +32937,9 @@ function createGatewayClient(baseUrl) {
32743
32937
  body: JSON.stringify({
32744
32938
  grantorAddress: params.grantorAddress,
32745
32939
  granteeId: params.granteeId,
32746
- grant: params.grant,
32747
- fileIds: params.fileIds
32940
+ scopes: params.scopes,
32941
+ grantVersion: params.grantVersion,
32942
+ expiresAt: params.expiresAt
32748
32943
  })
32749
32944
  });
32750
32945
  if (res.status === 409) {
@@ -32769,7 +32964,8 @@ function createGatewayClient(baseUrl) {
32769
32964
  Authorization: `Web3Signed ${params.signature}`
32770
32965
  },
32771
32966
  body: JSON.stringify({
32772
- grantorAddress: params.grantorAddress
32967
+ grantorAddress: params.grantorAddress,
32968
+ grantVersion: params.grantVersion
32773
32969
  })
32774
32970
  });
32775
32971
  if (res.status === 409) return;
@@ -32777,21 +32973,62 @@ function createGatewayClient(baseUrl) {
32777
32973
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32778
32974
  }
32779
32975
  },
32780
- async deleteFile(params) {
32781
- const res = await fetch(`${base}/v1/files/${params.fileId}`, {
32782
- 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",
32783
33008
  headers: {
32784
33009
  "Content-Type": "application/json",
32785
33010
  Authorization: `Web3Signed ${params.signature}`
32786
33011
  },
32787
- body: JSON.stringify({
32788
- ownerAddress: params.ownerAddress
32789
- })
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 ?? {})
32790
33027
  });
32791
- if (res.status === 409) return;
32792
33028
  if (!res.ok) {
32793
33029
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
32794
33030
  }
33031
+ return await res.json();
32795
33032
  }
32796
33033
  };
32797
33034
  }
@@ -32860,6 +33097,7 @@ async function parsePSError(response) {
32860
33097
  }
32861
33098
  export {
32862
33099
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33100
+ ADD_DATA_TYPES,
32863
33101
  AccountPersonalServerLiteOwnerBindingError,
32864
33102
  AccountPersonalServerRegistrationError,
32865
33103
  BUILDER_REGISTRATION_TYPES,
@@ -32870,12 +33108,15 @@ export {
32870
33108
  CallbackStorage,
32871
33109
  ContractFactory,
32872
33110
  ContractNotFoundError,
33111
+ DATA_REGISTRY_STATUS_ABI,
32873
33112
  DataFileEnvelopeSchema,
33113
+ DataPointStatus,
32874
33114
  DropboxStorage,
32875
33115
  ECIESError,
33116
+ ESCROW_DEPOSIT_ABI,
32876
33117
  ExpiredTokenError,
32877
- FILE_DELETION_TYPES,
32878
- FILE_REGISTRATION_TYPES,
33118
+ FEE_REGISTRY_ABI,
33119
+ GENERIC_PAYMENT_TYPES,
32879
33120
  GRANT_REGISTRATION_TYPES,
32880
33121
  GRANT_REVOCATION_TYPES,
32881
33122
  GoogleDriveStorage,
@@ -32886,6 +33127,7 @@ export {
32886
33127
  IpfsStorage,
32887
33128
  MASTER_KEY_MESSAGE,
32888
33129
  MissingAuthError,
33130
+ NATIVE_VANA_ASSET,
32889
33131
  NetworkError,
32890
33132
  NonceError,
32891
33133
  OAuthClient,
@@ -32901,6 +33143,8 @@ export {
32901
33143
  PersonalServerError,
32902
33144
  PinataStorage,
32903
33145
  R2Storage,
33146
+ RECORD_DATA_ACCESS_TYPES,
33147
+ REGISTRATION_KIND_FOR_OP,
32904
33148
  ReadOnlyError,
32905
33149
  RelayerError,
32906
33150
  SERVER_REGISTRATION_TYPES,
@@ -32915,10 +33159,14 @@ export {
32915
33159
  VanaError,
32916
33160
  VanaStorage,
32917
33161
  assertValidPkceVerifier,
33162
+ buildDepositNativeRequest,
33163
+ buildDepositTokenRequest,
33164
+ buildMarkDataPointUnavailableRequest,
32918
33165
  buildPersonalServerLiteOwnerBindingMessage,
32919
33166
  buildPersonalServerLiteOwnerBindingSignature,
32920
33167
  buildPersonalServerRegistrationSignature,
32921
33168
  buildPersonalServerRegistrationTypedData,
33169
+ buildSetDataPointStatusRequest,
32922
33170
  buildWeb3SignedHeader,
32923
33171
  builderRegistrationDomain,
32924
33172
  chains,
@@ -32933,14 +33181,19 @@ export {
32933
33181
  createVanaStorageProvider,
32934
33182
  createViemPersonalServerLiteOwnerBindingSigner,
32935
33183
  createViemPersonalServerRegistrationSigner,
33184
+ dataRegistryContractAddress,
33185
+ dataRegistryDomain,
32936
33186
  decryptWithPassword,
32937
33187
  deriveMasterKey,
32938
33188
  deriveScopeKey,
32939
33189
  deserializeECIES,
32940
33190
  detectPlatform,
33191
+ encodeDepositNativeData,
33192
+ encodeDepositTokenData,
33193
+ encodeSetDataPointStatusData,
32941
33194
  encryptWithPassword,
32942
- fileDeletionDomain,
32943
- fileRegistrationDomain,
33195
+ escrowContractAddress,
33196
+ escrowPaymentDomain,
32944
33197
  generatePkceVerifier,
32945
33198
  getAbi,
32946
33199
  getAllChains,
@@ -32948,6 +33201,8 @@ export {
32948
33201
  getContractAddress,
32949
33202
  getContractController,
32950
33203
  getContractInfo,
33204
+ getFee,
33205
+ getOpFee,
32951
33206
  getPlatformCapabilities,
32952
33207
  getServiceEndpoints,
32953
33208
  grantRegistrationDomain,
@@ -32959,7 +33214,6 @@ export {
32959
33214
  moksha,
32960
33215
  mokshaServices,
32961
33216
  mokshaTestnet2 as mokshaTestnet,
32962
- parseGrantRegistrationPayload,
32963
33217
  parsePSError,
32964
33218
  parseScope,
32965
33219
  parseWeb3SignedHeader,