@opendatalabs/vana-sdk 3.4.0 → 3.4.1-canary.a244135

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 +381 -128
  3. package/dist/index.browser.js.map +4 -4
  4. package/dist/index.node.cjs +403 -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 +381 -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 +27 -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 +27 -63
  42. package/dist/protocol/grants.js.map +1 -1
  43. package/package.json +3 -2
@@ -32509,6 +32509,7 @@ function formatOAuthError(body, status) {
32509
32509
  // src/protocol/eip712.ts
32510
32510
  var DOMAIN_NAME = "Vana Data Portability";
32511
32511
  var DOMAIN_VERSION = "1";
32512
+ var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
32512
32513
  function buildDomain(chainId, verifyingContract) {
32513
32514
  return {
32514
32515
  name: DOMAIN_NAME,
@@ -32517,13 +32518,7 @@ function buildDomain(chainId, verifyingContract) {
32517
32518
  verifyingContract
32518
32519
  };
32519
32520
  }
32520
- function fileRegistrationDomain(config) {
32521
- return buildDomain(
32522
- config.chainId,
32523
- config.contracts.dataRegistry
32524
- );
32525
- }
32526
- function fileDeletionDomain(config) {
32521
+ function dataRegistryDomain(config) {
32527
32522
  return buildDomain(
32528
32523
  config.chainId,
32529
32524
  config.contracts.dataRegistry
@@ -32553,31 +32548,26 @@ function builderRegistrationDomain(config) {
32553
32548
  config.contracts.dataPortabilityGrantees
32554
32549
  );
32555
32550
  }
32556
- var FILE_REGISTRATION_TYPES = {
32557
- FileRegistration: [
32558
- { name: "ownerAddress", type: "address" },
32559
- { name: "url", type: "string" },
32560
- { name: "schemaId", type: "bytes32" }
32561
- ]
32562
- };
32563
- var FILE_DELETION_TYPES = {
32564
- FileDeletion: [
32565
- { name: "ownerAddress", type: "address" },
32566
- { name: "fileId", type: "bytes32" }
32567
- ]
32568
- };
32551
+ function escrowPaymentDomain(config) {
32552
+ return buildDomain(
32553
+ config.chainId,
32554
+ config.contracts.dataPortabilityEscrow
32555
+ );
32556
+ }
32569
32557
  var GRANT_REGISTRATION_TYPES = {
32570
32558
  GrantRegistration: [
32571
32559
  { name: "grantorAddress", type: "address" },
32572
32560
  { name: "granteeId", type: "bytes32" },
32573
- { name: "grant", type: "string" },
32574
- { name: "fileIds", type: "uint256[]" }
32561
+ { name: "scopes", type: "string[]" },
32562
+ { name: "grantVersion", type: "uint256" },
32563
+ { name: "expiresAt", type: "uint256" }
32575
32564
  ]
32576
32565
  };
32577
32566
  var GRANT_REVOCATION_TYPES = {
32578
32567
  GrantRevocation: [
32579
32568
  { name: "grantorAddress", type: "address" },
32580
- { name: "grantId", type: "bytes32" }
32569
+ { name: "grantId", type: "bytes32" },
32570
+ { name: "grantVersion", type: "uint256" }
32581
32571
  ]
32582
32572
  };
32583
32573
  var SERVER_REGISTRATION_TYPES = {
@@ -32596,6 +32586,34 @@ var BUILDER_REGISTRATION_TYPES = {
32596
32586
  { name: "appUrl", type: "string" }
32597
32587
  ]
32598
32588
  };
32589
+ var GENERIC_PAYMENT_TYPES = {
32590
+ GenericPayment: [
32591
+ { name: "payerAddress", type: "address" },
32592
+ { name: "opType", type: "string" },
32593
+ { name: "opId", type: "bytes32" },
32594
+ { name: "asset", type: "address" },
32595
+ { name: "amount", type: "uint256" },
32596
+ { name: "paymentNonce", type: "uint256" }
32597
+ ]
32598
+ };
32599
+ var ADD_DATA_TYPES = {
32600
+ AddData: [
32601
+ { name: "ownerAddress", type: "address" },
32602
+ { name: "scope", type: "string" },
32603
+ { name: "dataHash", type: "bytes32" },
32604
+ { name: "metadataHash", type: "bytes32" },
32605
+ { name: "expectedVersion", type: "uint256" }
32606
+ ]
32607
+ };
32608
+ var RECORD_DATA_ACCESS_TYPES = {
32609
+ RecordDataAccess: [
32610
+ { name: "ownerAddress", type: "address" },
32611
+ { name: "scope", type: "string" },
32612
+ { name: "version", type: "uint256" },
32613
+ { name: "accessor", type: "address" },
32614
+ { name: "recordId", type: "bytes32" }
32615
+ ]
32616
+ };
32599
32617
 
32600
32618
  // src/protocol/personal-server-registration.ts
32601
32619
  import {
@@ -33037,67 +33055,34 @@ function isDataPortabilityGatewayConfig(value) {
33037
33055
  return false;
33038
33056
  }
33039
33057
  const c = contracts;
33040
- return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
33058
+ return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
33041
33059
  }
33042
- function parseGrantRegistrationPayload(grant) {
33043
- let parsed;
33060
+ function toUint256(value) {
33044
33061
  try {
33045
- parsed = JSON.parse(grant);
33046
- } catch {
33047
- return null;
33048
- }
33049
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
33050
- return null;
33051
- }
33052
- const value = parsed;
33053
- if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
33054
- return null;
33055
- }
33056
- if (!value["scopes"].every((scope) => typeof scope === "string")) {
33057
- return null;
33058
- }
33059
- if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
33060
- return null;
33061
- }
33062
- if (value["user"] !== void 0 && !isHexString(value["user"])) {
33063
- return null;
33064
- }
33065
- if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
33066
- return null;
33067
- }
33068
- if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
33069
- return null;
33070
- }
33071
- return {
33072
- user: value["user"],
33073
- builder: value["builder"],
33074
- scopes: value["scopes"],
33075
- expiresAt: value["expiresAt"],
33076
- nonce: value["nonce"]
33077
- };
33078
- }
33079
- function parseFileIds(fileIds) {
33080
- try {
33081
- const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
33082
- return {
33083
- values,
33084
- display: values.map((fileId) => fileId.toString())
33085
- };
33062
+ if (typeof value === "number" && !Number.isSafeInteger(value)) {
33063
+ return null;
33064
+ }
33065
+ const big = typeof value === "bigint" ? value : BigInt(value);
33066
+ if (big < 0n) return null;
33067
+ return big;
33086
33068
  } catch {
33087
33069
  return null;
33088
33070
  }
33089
33071
  }
33090
33072
  async function verifyGrantRegistration(input) {
33091
- const payload = parseGrantRegistrationPayload(input.grant);
33092
- if (!payload) {
33093
- return {
33094
- valid: false,
33095
- error: "Grant must be JSON with scopes and expiresAt"
33096
- };
33073
+ if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
33074
+ return { valid: false, error: "scopes must be a non-empty array" };
33075
+ }
33076
+ if (!input.scopes.every((scope) => typeof scope === "string")) {
33077
+ return { valid: false, error: "scopes must contain only strings" };
33097
33078
  }
33098
- const fileIds = parseFileIds(input.fileIds);
33099
- if (!fileIds) {
33100
- return { valid: false, error: "fileIds must contain integer values" };
33079
+ const grantVersion = toUint256(input.grantVersion);
33080
+ if (grantVersion === null || grantVersion < 1n) {
33081
+ return { valid: false, error: "grantVersion must be a uint256 >= 1" };
33082
+ }
33083
+ const expiresAt = toUint256(input.expiresAt);
33084
+ if (expiresAt === null) {
33085
+ return { valid: false, error: "expiresAt must be a non-negative uint256" };
33101
33086
  }
33102
33087
  let valid;
33103
33088
  try {
@@ -33109,8 +33094,9 @@ async function verifyGrantRegistration(input) {
33109
33094
  message: {
33110
33095
  grantorAddress: input.grantorAddress,
33111
33096
  granteeId: input.granteeId,
33112
- grant: input.grant,
33113
- fileIds: fileIds.values
33097
+ scopes: input.scopes,
33098
+ grantVersion,
33099
+ expiresAt
33114
33100
  },
33115
33101
  signature: input.signature
33116
33102
  });
@@ -33121,19 +33107,197 @@ async function verifyGrantRegistration(input) {
33121
33107
  return { valid: false, error: "Grant signature does not match grantor" };
33122
33108
  }
33123
33109
  const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
33124
- if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
33110
+ if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
33125
33111
  return { valid: false, error: "Grant has expired" };
33126
33112
  }
33127
- if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
33128
- return { valid: false, error: "Grant user does not match grantorAddress" };
33129
- }
33130
33113
  return {
33131
33114
  valid: true,
33132
33115
  grantorAddress: input.grantorAddress,
33133
33116
  granteeId: input.granteeId,
33134
- grant: input.grant,
33135
- payload,
33136
- fileIds: fileIds.display
33117
+ scopes: input.scopes,
33118
+ grantVersion: grantVersion.toString(),
33119
+ expiresAt: expiresAt.toString()
33120
+ };
33121
+ }
33122
+
33123
+ // src/protocol/escrow-deposit.ts
33124
+ import { encodeFunctionData } from "viem";
33125
+ var ESCROW_DEPOSIT_ABI = [
33126
+ {
33127
+ type: "function",
33128
+ name: "depositNative",
33129
+ stateMutability: "payable",
33130
+ inputs: [{ name: "account", type: "address" }],
33131
+ outputs: []
33132
+ },
33133
+ {
33134
+ type: "function",
33135
+ name: "depositToken",
33136
+ stateMutability: "nonpayable",
33137
+ inputs: [
33138
+ { name: "account", type: "address" },
33139
+ { name: "token", type: "address" },
33140
+ { name: "amount", type: "uint256" }
33141
+ ],
33142
+ outputs: []
33143
+ }
33144
+ ];
33145
+ function escrowContractAddress(config) {
33146
+ return config.contracts.dataPortabilityEscrow;
33147
+ }
33148
+ function encodeDepositNativeData(input) {
33149
+ return encodeFunctionData({
33150
+ abi: ESCROW_DEPOSIT_ABI,
33151
+ functionName: "depositNative",
33152
+ args: [input.account]
33153
+ });
33154
+ }
33155
+ function encodeDepositTokenData(input) {
33156
+ return encodeFunctionData({
33157
+ abi: ESCROW_DEPOSIT_ABI,
33158
+ functionName: "depositToken",
33159
+ args: [input.account, input.token, input.amount]
33160
+ });
33161
+ }
33162
+ function buildDepositNativeRequest(config, input) {
33163
+ return {
33164
+ to: escrowContractAddress(config),
33165
+ data: encodeDepositNativeData({ account: input.account }),
33166
+ value: input.amount
33167
+ };
33168
+ }
33169
+ function buildDepositTokenRequest(config, input) {
33170
+ return {
33171
+ to: escrowContractAddress(config),
33172
+ data: encodeDepositTokenData(input)
33173
+ };
33174
+ }
33175
+
33176
+ // src/protocol/data-point-status.ts
33177
+ import { encodeFunctionData as encodeFunctionData2 } from "viem";
33178
+ var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
33179
+ DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
33180
+ DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
33181
+ DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
33182
+ DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
33183
+ return DataPointStatus2;
33184
+ })(DataPointStatus || {});
33185
+ var DATA_REGISTRY_STATUS_ABI = [
33186
+ {
33187
+ type: "function",
33188
+ name: "setStatus",
33189
+ stateMutability: "nonpayable",
33190
+ inputs: [
33191
+ { name: "scope", type: "string" },
33192
+ { name: "newStatus", type: "uint8" }
33193
+ ],
33194
+ outputs: []
33195
+ }
33196
+ ];
33197
+ function dataRegistryContractAddress(config) {
33198
+ return config.contracts.dataRegistry;
33199
+ }
33200
+ function encodeSetDataPointStatusData(input) {
33201
+ return encodeFunctionData2({
33202
+ abi: DATA_REGISTRY_STATUS_ABI,
33203
+ functionName: "setStatus",
33204
+ args: [input.scope, input.status]
33205
+ });
33206
+ }
33207
+ function buildSetDataPointStatusRequest(config, input) {
33208
+ return {
33209
+ to: dataRegistryContractAddress(config),
33210
+ data: encodeSetDataPointStatusData(input)
33211
+ };
33212
+ }
33213
+ function buildMarkDataPointUnavailableRequest(config, input) {
33214
+ return buildSetDataPointStatusRequest(config, {
33215
+ scope: input.scope,
33216
+ status: 3 /* Unavailable */
33217
+ });
33218
+ }
33219
+
33220
+ // src/protocol/fee-registry.ts
33221
+ import { parseAbi } from "viem";
33222
+ var FEE_REGISTRY_ABI = parseAbi([
33223
+ "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
33224
+ "function fees(bytes32 operation) view returns (Fee)",
33225
+ "function operationKey(string name) pure returns (bytes32)"
33226
+ ]);
33227
+ var REGISTRATION_KIND_FOR_OP = {
33228
+ grant: "grant_registration",
33229
+ data: "data_registration",
33230
+ server: "server_registration",
33231
+ builder: "builder_registration"
33232
+ };
33233
+ function operationNameFor(kind, opts) {
33234
+ switch (kind) {
33235
+ case "grant_registration":
33236
+ return opts?.grantRegistrationOpName ?? "grant_registration";
33237
+ case "data_access":
33238
+ return opts?.dataAccessOpName ?? "data_access";
33239
+ case "data_registration":
33240
+ return opts?.dataRegistrationOpName ?? "data_registration";
33241
+ case "server_registration":
33242
+ return opts?.serverRegistrationOpName ?? "server_registration";
33243
+ case "builder_registration":
33244
+ return opts?.builderRegistrationOpName ?? "builder_registration";
33245
+ }
33246
+ }
33247
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
33248
+ async function getFee(client, config, kind, opts) {
33249
+ const address = config.contracts.feeRegistry;
33250
+ const opName = operationNameFor(kind, opts);
33251
+ const opKey = await client.readContract({
33252
+ address,
33253
+ abi: FEE_REGISTRY_ABI,
33254
+ functionName: "operationKey",
33255
+ args: [opName]
33256
+ });
33257
+ const fee = await client.readContract({
33258
+ address,
33259
+ abi: FEE_REGISTRY_ABI,
33260
+ functionName: "fees",
33261
+ args: [opKey]
33262
+ });
33263
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
33264
+ throw new Error(
33265
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
33266
+ );
33267
+ }
33268
+ return fee;
33269
+ }
33270
+ async function getOpFee(client, config, opType, opts) {
33271
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
33272
+ if (!registrationKind) {
33273
+ throw new Error(
33274
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
33275
+ );
33276
+ }
33277
+ const includeDataAccess = opType === "grant";
33278
+ const [registration, dataAccess] = await Promise.all([
33279
+ getFee(client, config, registrationKind, opts),
33280
+ includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
33281
+ amount: 0n,
33282
+ asset: ZERO_ADDRESS,
33283
+ payee: ZERO_ADDRESS,
33284
+ enabled: false
33285
+ })
33286
+ ]);
33287
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
33288
+ throw new Error(
33289
+ `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.`
33290
+ );
33291
+ }
33292
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
33293
+ return {
33294
+ asset,
33295
+ registrationFee: registration.enabled ? registration.amount : 0n,
33296
+ dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
33297
+ registrationEnabled: registration.enabled,
33298
+ dataAccessEnabled: dataAccess.enabled,
33299
+ registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
33300
+ dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
33137
33301
  };
33138
33302
  }
33139
33303
 
@@ -33214,16 +33378,6 @@ function createGatewayClient(baseUrl) {
33214
33378
  const envelope = await res.json();
33215
33379
  return envelope.data;
33216
33380
  }
33217
- function normalizeFileRecord(record) {
33218
- return {
33219
- fileId: record.fileId ?? record.id ?? "",
33220
- owner: record.owner ?? record.ownerAddress ?? "",
33221
- url: record.url,
33222
- schemaId: record.schemaId,
33223
- createdAt: record.createdAt ?? record.addedAt ?? "",
33224
- deletedAt: record.deletedAt ?? null
33225
- };
33226
- }
33227
33381
  function getMutationId(body, key) {
33228
33382
  const value = body[key] ?? body["id"];
33229
33383
  return typeof value === "string" ? value : void 0;
@@ -33273,30 +33427,34 @@ function createGatewayClient(baseUrl) {
33273
33427
  }
33274
33428
  return unwrapEnvelope(res);
33275
33429
  },
33276
- async getFile(fileId) {
33277
- const res = await fetch(`${base}/v1/files/${fileId}`);
33430
+ async getDataPoint(dataPointId) {
33431
+ const res = await fetch(`${base}/v1/data/${dataPointId}`);
33278
33432
  if (res.status === 404) return null;
33279
33433
  if (!res.ok) {
33280
33434
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33281
33435
  }
33282
- return normalizeFileRecord(await unwrapEnvelope(res));
33436
+ return unwrapEnvelope(res);
33283
33437
  },
33284
- async listFilesSince(owner, cursor, options) {
33438
+ async listDataPointsByOwner(owner, cursor, options) {
33285
33439
  const params = new URLSearchParams({ user: owner });
33286
33440
  if (cursor !== null) {
33287
- params.set("since", cursor);
33441
+ params.set("cursor", cursor);
33442
+ }
33443
+ if (options?.since) {
33444
+ params.set("since", options.since);
33288
33445
  }
33289
- if (options?.includeDeleted) {
33290
- params.set("includeDeleted", "true");
33446
+ if (options?.limit !== void 0) {
33447
+ params.set("limit", String(options.limit));
33291
33448
  }
33292
- const res = await fetch(`${base}/v1/files?${params.toString()}`);
33449
+ const res = await fetch(`${base}/v1/data?${params.toString()}`);
33293
33450
  if (!res.ok) {
33294
33451
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33295
33452
  }
33296
- const data = await unwrapEnvelope(res);
33453
+ const envelope = await res.json();
33454
+ const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
33297
33455
  return {
33298
- files: data.files.map(normalizeFileRecord),
33299
- cursor: data.cursor
33456
+ dataPoints: envelope.data.dataPoints,
33457
+ cursor: nextCursor
33300
33458
  };
33301
33459
  },
33302
33460
  async getSchema(schemaId) {
@@ -33337,8 +33495,8 @@ function createGatewayClient(baseUrl) {
33337
33495
  alreadyRegistered: false
33338
33496
  };
33339
33497
  },
33340
- async registerFile(params) {
33341
- const res = await fetch(`${base}/v1/files`, {
33498
+ async registerBuilder(params) {
33499
+ const res = await fetch(`${base}/v1/builders`, {
33342
33500
  method: "POST",
33343
33501
  headers: {
33344
33502
  "Content-Type": "application/json",
@@ -33346,22 +33504,57 @@ function createGatewayClient(baseUrl) {
33346
33504
  },
33347
33505
  body: JSON.stringify({
33348
33506
  ownerAddress: params.ownerAddress,
33349
- url: params.url,
33350
- schemaId: params.schemaId
33507
+ granteeAddress: params.granteeAddress,
33508
+ publicKey: params.publicKey,
33509
+ appUrl: params.appUrl
33351
33510
  })
33352
33511
  });
33353
33512
  if (res.status === 409) {
33354
33513
  const body2 = await res.json().catch(() => ({}));
33355
33514
  return {
33356
- fileId: getMutationId(body2, "fileId")
33515
+ builderId: getMutationId(
33516
+ body2,
33517
+ "builderId"
33518
+ ),
33519
+ alreadyRegistered: true
33357
33520
  };
33358
33521
  }
33359
33522
  if (!res.ok) {
33360
33523
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33361
33524
  }
33362
- const body = await res.json();
33525
+ const body = await res.json().catch(() => ({}));
33363
33526
  return {
33364
- fileId: getMutationId(body, "fileId")
33527
+ builderId: getMutationId(body, "builderId"),
33528
+ alreadyRegistered: false
33529
+ };
33530
+ },
33531
+ async registerDataPoint(params) {
33532
+ const res = await fetch(`${base}/v1/data`, {
33533
+ method: "POST",
33534
+ headers: {
33535
+ "Content-Type": "application/json",
33536
+ Authorization: `Web3Signed ${params.signature}`
33537
+ },
33538
+ body: JSON.stringify({
33539
+ ownerAddress: params.ownerAddress,
33540
+ scope: params.scope,
33541
+ dataHash: params.dataHash,
33542
+ metadataHash: params.metadataHash,
33543
+ expectedVersion: params.expectedVersion
33544
+ })
33545
+ });
33546
+ if (!res.ok) {
33547
+ const body2 = await res.json().catch(() => ({}));
33548
+ const detail = body2.error ?? res.statusText;
33549
+ throw new Error(`Gateway error: ${res.status} ${detail}`);
33550
+ }
33551
+ const body = await res.json().catch(() => ({}));
33552
+ return {
33553
+ dataPointId: getMutationId(
33554
+ body,
33555
+ "dataPointId"
33556
+ ),
33557
+ expectedVersion: body.expectedVersion
33365
33558
  };
33366
33559
  },
33367
33560
  async createGrant(params) {
@@ -33374,8 +33567,9 @@ function createGatewayClient(baseUrl) {
33374
33567
  body: JSON.stringify({
33375
33568
  grantorAddress: params.grantorAddress,
33376
33569
  granteeId: params.granteeId,
33377
- grant: params.grant,
33378
- fileIds: params.fileIds
33570
+ scopes: params.scopes,
33571
+ grantVersion: params.grantVersion,
33572
+ expiresAt: params.expiresAt
33379
33573
  })
33380
33574
  });
33381
33575
  if (res.status === 409) {
@@ -33400,7 +33594,8 @@ function createGatewayClient(baseUrl) {
33400
33594
  Authorization: `Web3Signed ${params.signature}`
33401
33595
  },
33402
33596
  body: JSON.stringify({
33403
- grantorAddress: params.grantorAddress
33597
+ grantorAddress: params.grantorAddress,
33598
+ grantVersion: params.grantVersion
33404
33599
  })
33405
33600
  });
33406
33601
  if (res.status === 409) return;
@@ -33408,21 +33603,62 @@ function createGatewayClient(baseUrl) {
33408
33603
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33409
33604
  }
33410
33605
  },
33411
- async deleteFile(params) {
33412
- const res = await fetch(`${base}/v1/files/${params.fileId}`, {
33413
- method: "DELETE",
33606
+ async getEscrowBalance(account) {
33607
+ const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
33608
+ if (!res.ok) {
33609
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33610
+ }
33611
+ return await res.json();
33612
+ },
33613
+ async submitEscrowDeposit(params) {
33614
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
33615
+ method: "POST",
33616
+ headers: { "Content-Type": "application/json" },
33617
+ body: JSON.stringify({ txHash: params.txHash })
33618
+ });
33619
+ if (res.status !== 200 && res.status !== 202) {
33620
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33621
+ }
33622
+ return await res.json();
33623
+ },
33624
+ async payForOperation(params) {
33625
+ const body = {
33626
+ payerAddress: params.payerAddress,
33627
+ opType: params.opType,
33628
+ opId: params.opId,
33629
+ asset: params.asset,
33630
+ amount: params.amount,
33631
+ paymentNonce: params.paymentNonce
33632
+ };
33633
+ if (params.accessRecord) {
33634
+ body["accessRecord"] = params.accessRecord;
33635
+ }
33636
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33637
+ method: "POST",
33414
33638
  headers: {
33415
33639
  "Content-Type": "application/json",
33416
33640
  Authorization: `Web3Signed ${params.signature}`
33417
33641
  },
33418
- body: JSON.stringify({
33419
- ownerAddress: params.ownerAddress
33420
- })
33642
+ body: JSON.stringify(body)
33643
+ });
33644
+ if (!res.ok) {
33645
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33646
+ }
33647
+ return await res.json();
33648
+ },
33649
+ async settle(params) {
33650
+ const res = await fetch(`${base}/v1/settle`, {
33651
+ method: "POST",
33652
+ headers: { "Content-Type": "application/json" },
33653
+ // The gateway accepts an empty body; only `limit` is recognised.
33654
+ // Always send a JSON body so the gateway's req.body shape parse
33655
+ // doesn't have to deal with an undefined.
33656
+ body: JSON.stringify(params ?? {})
33421
33657
  });
33422
- if (res.status === 409) return;
33423
33658
  if (!res.ok) {
33424
33659
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33425
33660
  }
33661
+ return await res.json();
33426
33662
  }
33427
33663
  };
33428
33664
  }
@@ -33491,6 +33727,7 @@ async function parsePSError(response) {
33491
33727
  }
33492
33728
  export {
33493
33729
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33730
+ ADD_DATA_TYPES,
33494
33731
  AccountPersonalServerLiteOwnerBindingError,
33495
33732
  AccountPersonalServerRegistrationError,
33496
33733
  BUILDER_REGISTRATION_TYPES,
@@ -33500,12 +33737,15 @@ export {
33500
33737
  CallbackStorage,
33501
33738
  ContractFactory,
33502
33739
  ContractNotFoundError,
33740
+ DATA_REGISTRY_STATUS_ABI,
33503
33741
  DataFileEnvelopeSchema,
33742
+ DataPointStatus,
33504
33743
  DropboxStorage,
33505
33744
  ECIESError,
33745
+ ESCROW_DEPOSIT_ABI,
33506
33746
  ExpiredTokenError,
33507
- FILE_DELETION_TYPES,
33508
- FILE_REGISTRATION_TYPES,
33747
+ FEE_REGISTRY_ABI,
33748
+ GENERIC_PAYMENT_TYPES,
33509
33749
  GRANT_REGISTRATION_TYPES,
33510
33750
  GRANT_REVOCATION_TYPES,
33511
33751
  GoogleDriveStorage,
@@ -33516,6 +33756,7 @@ export {
33516
33756
  IpfsStorage,
33517
33757
  MASTER_KEY_MESSAGE,
33518
33758
  MissingAuthError,
33759
+ NATIVE_VANA_ASSET,
33519
33760
  NetworkError,
33520
33761
  NodeECIESUint8Provider as NodeECIESProvider,
33521
33762
  NodePlatformAdapter,
@@ -33533,6 +33774,8 @@ export {
33533
33774
  PersonalServerError,
33534
33775
  PinataStorage,
33535
33776
  R2Storage,
33777
+ RECORD_DATA_ACCESS_TYPES,
33778
+ REGISTRATION_KIND_FOR_OP,
33536
33779
  ReadOnlyError,
33537
33780
  RelayerError,
33538
33781
  SERVER_REGISTRATION_TYPES,
@@ -33547,10 +33790,14 @@ export {
33547
33790
  VanaError,
33548
33791
  VanaStorage,
33549
33792
  assertValidPkceVerifier,
33793
+ buildDepositNativeRequest,
33794
+ buildDepositTokenRequest,
33795
+ buildMarkDataPointUnavailableRequest,
33550
33796
  buildPersonalServerLiteOwnerBindingMessage,
33551
33797
  buildPersonalServerLiteOwnerBindingSignature,
33552
33798
  buildPersonalServerRegistrationSignature,
33553
33799
  buildPersonalServerRegistrationTypedData,
33800
+ buildSetDataPointStatusRequest,
33554
33801
  buildWeb3SignedHeader,
33555
33802
  builderRegistrationDomain,
33556
33803
  chains,
@@ -33568,14 +33815,19 @@ export {
33568
33815
  createVanaStorageProvider,
33569
33816
  createViemPersonalServerLiteOwnerBindingSigner,
33570
33817
  createViemPersonalServerRegistrationSigner,
33818
+ dataRegistryContractAddress,
33819
+ dataRegistryDomain,
33571
33820
  decryptWithPassword,
33572
33821
  deriveMasterKey,
33573
33822
  deriveScopeKey,
33574
33823
  deserializeECIES,
33575
33824
  detectPlatform,
33825
+ encodeDepositNativeData,
33826
+ encodeDepositTokenData,
33827
+ encodeSetDataPointStatusData,
33576
33828
  encryptWithPassword,
33577
- fileDeletionDomain,
33578
- fileRegistrationDomain,
33829
+ escrowContractAddress,
33830
+ escrowPaymentDomain,
33579
33831
  generatePkceVerifier,
33580
33832
  getAbi,
33581
33833
  getAllChains,
@@ -33583,6 +33835,8 @@ export {
33583
33835
  getContractAddress,
33584
33836
  getContractController,
33585
33837
  getContractInfo,
33838
+ getFee,
33839
+ getOpFee,
33586
33840
  getPlatformCapabilities,
33587
33841
  getServiceEndpoints,
33588
33842
  grantRegistrationDomain,
@@ -33594,7 +33848,6 @@ export {
33594
33848
  moksha,
33595
33849
  mokshaServices,
33596
33850
  mokshaTestnet2 as mokshaTestnet,
33597
- parseGrantRegistrationPayload,
33598
33851
  parsePSError,
33599
33852
  parseScope,
33600
33853
  parseWeb3SignedHeader,