@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
@@ -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,31 @@ 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"]);
33041
- }
33042
- function parseGrantRegistrationPayload(grant) {
33043
- let parsed;
33044
- 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
- };
33058
+ return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
33078
33059
  }
33079
- function parseFileIds(fileIds) {
33060
+ function toUint256(value) {
33080
33061
  try {
33081
- const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
33082
- return {
33083
- values,
33084
- display: values.map((fileId) => fileId.toString())
33085
- };
33062
+ const big = typeof value === "bigint" ? value : BigInt(value);
33063
+ if (big < 0n) return null;
33064
+ return big;
33086
33065
  } catch {
33087
33066
  return null;
33088
33067
  }
33089
33068
  }
33090
33069
  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
- };
33070
+ if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
33071
+ return { valid: false, error: "scopes must be a non-empty array" };
33072
+ }
33073
+ if (!input.scopes.every((scope) => typeof scope === "string")) {
33074
+ return { valid: false, error: "scopes must contain only strings" };
33075
+ }
33076
+ const grantVersion = toUint256(input.grantVersion);
33077
+ if (grantVersion === null || grantVersion < 1n) {
33078
+ return { valid: false, error: "grantVersion must be a uint256 >= 1" };
33097
33079
  }
33098
- const fileIds = parseFileIds(input.fileIds);
33099
- if (!fileIds) {
33100
- return { valid: false, error: "fileIds must contain integer values" };
33080
+ const expiresAt = toUint256(input.expiresAt);
33081
+ if (expiresAt === null) {
33082
+ return { valid: false, error: "expiresAt must be a non-negative uint256" };
33101
33083
  }
33102
33084
  let valid;
33103
33085
  try {
@@ -33109,8 +33091,9 @@ async function verifyGrantRegistration(input) {
33109
33091
  message: {
33110
33092
  grantorAddress: input.grantorAddress,
33111
33093
  granteeId: input.granteeId,
33112
- grant: input.grant,
33113
- fileIds: fileIds.values
33094
+ scopes: input.scopes,
33095
+ grantVersion,
33096
+ expiresAt
33114
33097
  },
33115
33098
  signature: input.signature
33116
33099
  });
@@ -33121,19 +33104,197 @@ async function verifyGrantRegistration(input) {
33121
33104
  return { valid: false, error: "Grant signature does not match grantor" };
33122
33105
  }
33123
33106
  const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
33124
- if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
33107
+ if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
33125
33108
  return { valid: false, error: "Grant has expired" };
33126
33109
  }
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
33110
  return {
33131
33111
  valid: true,
33132
33112
  grantorAddress: input.grantorAddress,
33133
33113
  granteeId: input.granteeId,
33134
- grant: input.grant,
33135
- payload,
33136
- fileIds: fileIds.display
33114
+ scopes: input.scopes,
33115
+ grantVersion: grantVersion.toString(),
33116
+ expiresAt: expiresAt.toString()
33117
+ };
33118
+ }
33119
+
33120
+ // src/protocol/escrow-deposit.ts
33121
+ import { encodeFunctionData } from "viem";
33122
+ var ESCROW_DEPOSIT_ABI = [
33123
+ {
33124
+ type: "function",
33125
+ name: "depositNative",
33126
+ stateMutability: "payable",
33127
+ inputs: [{ name: "account", type: "address" }],
33128
+ outputs: []
33129
+ },
33130
+ {
33131
+ type: "function",
33132
+ name: "depositToken",
33133
+ stateMutability: "nonpayable",
33134
+ inputs: [
33135
+ { name: "account", type: "address" },
33136
+ { name: "token", type: "address" },
33137
+ { name: "amount", type: "uint256" }
33138
+ ],
33139
+ outputs: []
33140
+ }
33141
+ ];
33142
+ function escrowContractAddress(config) {
33143
+ return config.contracts.dataPortabilityEscrow;
33144
+ }
33145
+ function encodeDepositNativeData(input) {
33146
+ return encodeFunctionData({
33147
+ abi: ESCROW_DEPOSIT_ABI,
33148
+ functionName: "depositNative",
33149
+ args: [input.account]
33150
+ });
33151
+ }
33152
+ function encodeDepositTokenData(input) {
33153
+ return encodeFunctionData({
33154
+ abi: ESCROW_DEPOSIT_ABI,
33155
+ functionName: "depositToken",
33156
+ args: [input.account, input.token, input.amount]
33157
+ });
33158
+ }
33159
+ function buildDepositNativeRequest(config, input) {
33160
+ return {
33161
+ to: escrowContractAddress(config),
33162
+ data: encodeDepositNativeData({ account: input.account }),
33163
+ value: input.amount
33164
+ };
33165
+ }
33166
+ function buildDepositTokenRequest(config, input) {
33167
+ return {
33168
+ to: escrowContractAddress(config),
33169
+ data: encodeDepositTokenData(input)
33170
+ };
33171
+ }
33172
+
33173
+ // src/protocol/data-point-status.ts
33174
+ import { encodeFunctionData as encodeFunctionData2 } from "viem";
33175
+ var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
33176
+ DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
33177
+ DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
33178
+ DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
33179
+ DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
33180
+ return DataPointStatus2;
33181
+ })(DataPointStatus || {});
33182
+ var DATA_REGISTRY_STATUS_ABI = [
33183
+ {
33184
+ type: "function",
33185
+ name: "setStatus",
33186
+ stateMutability: "nonpayable",
33187
+ inputs: [
33188
+ { name: "scope", type: "string" },
33189
+ { name: "newStatus", type: "uint8" }
33190
+ ],
33191
+ outputs: []
33192
+ }
33193
+ ];
33194
+ function dataRegistryContractAddress(config) {
33195
+ return config.contracts.dataRegistry;
33196
+ }
33197
+ function encodeSetDataPointStatusData(input) {
33198
+ return encodeFunctionData2({
33199
+ abi: DATA_REGISTRY_STATUS_ABI,
33200
+ functionName: "setStatus",
33201
+ args: [input.scope, input.status]
33202
+ });
33203
+ }
33204
+ function buildSetDataPointStatusRequest(config, input) {
33205
+ return {
33206
+ to: dataRegistryContractAddress(config),
33207
+ data: encodeSetDataPointStatusData(input)
33208
+ };
33209
+ }
33210
+ function buildMarkDataPointUnavailableRequest(config, input) {
33211
+ return buildSetDataPointStatusRequest(config, {
33212
+ scope: input.scope,
33213
+ status: 3 /* Unavailable */
33214
+ });
33215
+ }
33216
+
33217
+ // src/protocol/fee-registry.ts
33218
+ import { parseAbi } from "viem";
33219
+ var FEE_REGISTRY_ABI = parseAbi([
33220
+ "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
33221
+ "function fees(bytes32 operation) view returns (Fee)",
33222
+ "function operationKey(string name) pure returns (bytes32)"
33223
+ ]);
33224
+ var REGISTRATION_KIND_FOR_OP = {
33225
+ grant: "grant_registration",
33226
+ data: "data_registration",
33227
+ server: "server_registration",
33228
+ builder: "builder_registration"
33229
+ };
33230
+ function operationNameFor(kind, opts) {
33231
+ switch (kind) {
33232
+ case "grant_registration":
33233
+ return opts?.grantRegistrationOpName ?? "grant_registration";
33234
+ case "data_access":
33235
+ return opts?.dataAccessOpName ?? "data_access";
33236
+ case "data_registration":
33237
+ return opts?.dataRegistrationOpName ?? "data_registration";
33238
+ case "server_registration":
33239
+ return opts?.serverRegistrationOpName ?? "server_registration";
33240
+ case "builder_registration":
33241
+ return opts?.builderRegistrationOpName ?? "builder_registration";
33242
+ }
33243
+ }
33244
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
33245
+ async function getFee(client, config, kind, opts) {
33246
+ const address = config.contracts.feeRegistry;
33247
+ const opName = operationNameFor(kind, opts);
33248
+ const opKey = await client.readContract({
33249
+ address,
33250
+ abi: FEE_REGISTRY_ABI,
33251
+ functionName: "operationKey",
33252
+ args: [opName]
33253
+ });
33254
+ const fee = await client.readContract({
33255
+ address,
33256
+ abi: FEE_REGISTRY_ABI,
33257
+ functionName: "fees",
33258
+ args: [opKey]
33259
+ });
33260
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
33261
+ throw new Error(
33262
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
33263
+ );
33264
+ }
33265
+ return fee;
33266
+ }
33267
+ async function getOpFee(client, config, opType, opts) {
33268
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
33269
+ if (!registrationKind) {
33270
+ throw new Error(
33271
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
33272
+ );
33273
+ }
33274
+ const includeDataAccess = opType === "grant";
33275
+ const [registration, dataAccess] = await Promise.all([
33276
+ getFee(client, config, registrationKind, opts),
33277
+ includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
33278
+ amount: 0n,
33279
+ asset: ZERO_ADDRESS,
33280
+ payee: ZERO_ADDRESS,
33281
+ enabled: false
33282
+ })
33283
+ ]);
33284
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
33285
+ throw new Error(
33286
+ `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.`
33287
+ );
33288
+ }
33289
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
33290
+ return {
33291
+ asset,
33292
+ registrationFee: registration.enabled ? registration.amount : 0n,
33293
+ dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
33294
+ registrationEnabled: registration.enabled,
33295
+ dataAccessEnabled: dataAccess.enabled,
33296
+ registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
33297
+ dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
33137
33298
  };
33138
33299
  }
33139
33300
 
@@ -33214,15 +33375,6 @@ function createGatewayClient(baseUrl) {
33214
33375
  const envelope = await res.json();
33215
33376
  return envelope.data;
33216
33377
  }
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
- };
33225
- }
33226
33378
  function getMutationId(body, key) {
33227
33379
  const value = body[key] ?? body["id"];
33228
33380
  return typeof value === "string" ? value : void 0;
@@ -33272,27 +33424,34 @@ function createGatewayClient(baseUrl) {
33272
33424
  }
33273
33425
  return unwrapEnvelope(res);
33274
33426
  },
33275
- async getFile(fileId) {
33276
- const res = await fetch(`${base}/v1/files/${fileId}`);
33427
+ async getDataPoint(dataPointId) {
33428
+ const res = await fetch(`${base}/v1/data/${dataPointId}`);
33277
33429
  if (res.status === 404) return null;
33278
33430
  if (!res.ok) {
33279
33431
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33280
33432
  }
33281
- return normalizeFileRecord(await unwrapEnvelope(res));
33433
+ return unwrapEnvelope(res);
33282
33434
  },
33283
- async listFilesSince(owner, cursor) {
33435
+ async listDataPointsByOwner(owner, cursor, options) {
33284
33436
  const params = new URLSearchParams({ user: owner });
33285
33437
  if (cursor !== null) {
33286
- params.set("since", cursor);
33438
+ params.set("cursor", cursor);
33439
+ }
33440
+ if (options?.since) {
33441
+ params.set("since", options.since);
33442
+ }
33443
+ if (options?.limit !== void 0) {
33444
+ params.set("limit", String(options.limit));
33287
33445
  }
33288
- const res = await fetch(`${base}/v1/files?${params.toString()}`);
33446
+ const res = await fetch(`${base}/v1/data?${params.toString()}`);
33289
33447
  if (!res.ok) {
33290
33448
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33291
33449
  }
33292
- const data = await unwrapEnvelope(res);
33450
+ const envelope = await res.json();
33451
+ const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
33293
33452
  return {
33294
- files: data.files.map(normalizeFileRecord),
33295
- cursor: data.cursor
33453
+ dataPoints: envelope.data.dataPoints,
33454
+ cursor: nextCursor
33296
33455
  };
33297
33456
  },
33298
33457
  async getSchema(schemaId) {
@@ -33333,8 +33492,8 @@ function createGatewayClient(baseUrl) {
33333
33492
  alreadyRegistered: false
33334
33493
  };
33335
33494
  },
33336
- async registerFile(params) {
33337
- const res = await fetch(`${base}/v1/files`, {
33495
+ async registerBuilder(params) {
33496
+ const res = await fetch(`${base}/v1/builders`, {
33338
33497
  method: "POST",
33339
33498
  headers: {
33340
33499
  "Content-Type": "application/json",
@@ -33342,22 +33501,57 @@ function createGatewayClient(baseUrl) {
33342
33501
  },
33343
33502
  body: JSON.stringify({
33344
33503
  ownerAddress: params.ownerAddress,
33345
- url: params.url,
33346
- schemaId: params.schemaId
33504
+ granteeAddress: params.granteeAddress,
33505
+ publicKey: params.publicKey,
33506
+ appUrl: params.appUrl
33347
33507
  })
33348
33508
  });
33349
33509
  if (res.status === 409) {
33350
33510
  const body2 = await res.json().catch(() => ({}));
33351
33511
  return {
33352
- fileId: getMutationId(body2, "fileId")
33512
+ builderId: getMutationId(
33513
+ body2,
33514
+ "builderId"
33515
+ ),
33516
+ alreadyRegistered: true
33353
33517
  };
33354
33518
  }
33355
33519
  if (!res.ok) {
33356
33520
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33357
33521
  }
33358
- const body = await res.json();
33522
+ const body = await res.json().catch(() => ({}));
33359
33523
  return {
33360
- fileId: getMutationId(body, "fileId")
33524
+ builderId: getMutationId(body, "builderId"),
33525
+ alreadyRegistered: false
33526
+ };
33527
+ },
33528
+ async registerDataPoint(params) {
33529
+ const res = await fetch(`${base}/v1/data`, {
33530
+ method: "POST",
33531
+ headers: {
33532
+ "Content-Type": "application/json",
33533
+ Authorization: `Web3Signed ${params.signature}`
33534
+ },
33535
+ body: JSON.stringify({
33536
+ ownerAddress: params.ownerAddress,
33537
+ scope: params.scope,
33538
+ dataHash: params.dataHash,
33539
+ metadataHash: params.metadataHash,
33540
+ expectedVersion: params.expectedVersion
33541
+ })
33542
+ });
33543
+ if (!res.ok) {
33544
+ const body2 = await res.json().catch(() => ({}));
33545
+ const detail = body2.error ?? res.statusText;
33546
+ throw new Error(`Gateway error: ${res.status} ${detail}`);
33547
+ }
33548
+ const body = await res.json().catch(() => ({}));
33549
+ return {
33550
+ dataPointId: getMutationId(
33551
+ body,
33552
+ "dataPointId"
33553
+ ),
33554
+ expectedVersion: body.expectedVersion
33361
33555
  };
33362
33556
  },
33363
33557
  async createGrant(params) {
@@ -33370,8 +33564,9 @@ function createGatewayClient(baseUrl) {
33370
33564
  body: JSON.stringify({
33371
33565
  grantorAddress: params.grantorAddress,
33372
33566
  granteeId: params.granteeId,
33373
- grant: params.grant,
33374
- fileIds: params.fileIds
33567
+ scopes: params.scopes,
33568
+ grantVersion: params.grantVersion,
33569
+ expiresAt: params.expiresAt
33375
33570
  })
33376
33571
  });
33377
33572
  if (res.status === 409) {
@@ -33396,7 +33591,8 @@ function createGatewayClient(baseUrl) {
33396
33591
  Authorization: `Web3Signed ${params.signature}`
33397
33592
  },
33398
33593
  body: JSON.stringify({
33399
- grantorAddress: params.grantorAddress
33594
+ grantorAddress: params.grantorAddress,
33595
+ grantVersion: params.grantVersion
33400
33596
  })
33401
33597
  });
33402
33598
  if (res.status === 409) return;
@@ -33404,21 +33600,62 @@ function createGatewayClient(baseUrl) {
33404
33600
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33405
33601
  }
33406
33602
  },
33407
- async deleteFile(params) {
33408
- const res = await fetch(`${base}/v1/files/${params.fileId}`, {
33409
- method: "DELETE",
33603
+ async getEscrowBalance(account) {
33604
+ const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
33605
+ if (!res.ok) {
33606
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33607
+ }
33608
+ return await res.json();
33609
+ },
33610
+ async submitEscrowDeposit(params) {
33611
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
33612
+ method: "POST",
33613
+ headers: { "Content-Type": "application/json" },
33614
+ body: JSON.stringify({ txHash: params.txHash })
33615
+ });
33616
+ if (res.status !== 200 && res.status !== 202) {
33617
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33618
+ }
33619
+ return await res.json();
33620
+ },
33621
+ async payForOperation(params) {
33622
+ const body = {
33623
+ payerAddress: params.payerAddress,
33624
+ opType: params.opType,
33625
+ opId: params.opId,
33626
+ asset: params.asset,
33627
+ amount: params.amount,
33628
+ paymentNonce: params.paymentNonce
33629
+ };
33630
+ if (params.accessRecord) {
33631
+ body["accessRecord"] = params.accessRecord;
33632
+ }
33633
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33634
+ method: "POST",
33410
33635
  headers: {
33411
33636
  "Content-Type": "application/json",
33412
33637
  Authorization: `Web3Signed ${params.signature}`
33413
33638
  },
33414
- body: JSON.stringify({
33415
- ownerAddress: params.ownerAddress
33416
- })
33639
+ body: JSON.stringify(body)
33640
+ });
33641
+ if (!res.ok) {
33642
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33643
+ }
33644
+ return await res.json();
33645
+ },
33646
+ async settle(params) {
33647
+ const res = await fetch(`${base}/v1/settle`, {
33648
+ method: "POST",
33649
+ headers: { "Content-Type": "application/json" },
33650
+ // The gateway accepts an empty body; only `limit` is recognised.
33651
+ // Always send a JSON body so the gateway's req.body shape parse
33652
+ // doesn't have to deal with an undefined.
33653
+ body: JSON.stringify(params ?? {})
33417
33654
  });
33418
- if (res.status === 409) return;
33419
33655
  if (!res.ok) {
33420
33656
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33421
33657
  }
33658
+ return await res.json();
33422
33659
  }
33423
33660
  };
33424
33661
  }
@@ -33487,6 +33724,7 @@ async function parsePSError(response) {
33487
33724
  }
33488
33725
  export {
33489
33726
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33727
+ ADD_DATA_TYPES,
33490
33728
  AccountPersonalServerLiteOwnerBindingError,
33491
33729
  AccountPersonalServerRegistrationError,
33492
33730
  BUILDER_REGISTRATION_TYPES,
@@ -33496,12 +33734,15 @@ export {
33496
33734
  CallbackStorage,
33497
33735
  ContractFactory,
33498
33736
  ContractNotFoundError,
33737
+ DATA_REGISTRY_STATUS_ABI,
33499
33738
  DataFileEnvelopeSchema,
33739
+ DataPointStatus,
33500
33740
  DropboxStorage,
33501
33741
  ECIESError,
33742
+ ESCROW_DEPOSIT_ABI,
33502
33743
  ExpiredTokenError,
33503
- FILE_DELETION_TYPES,
33504
- FILE_REGISTRATION_TYPES,
33744
+ FEE_REGISTRY_ABI,
33745
+ GENERIC_PAYMENT_TYPES,
33505
33746
  GRANT_REGISTRATION_TYPES,
33506
33747
  GRANT_REVOCATION_TYPES,
33507
33748
  GoogleDriveStorage,
@@ -33512,6 +33753,7 @@ export {
33512
33753
  IpfsStorage,
33513
33754
  MASTER_KEY_MESSAGE,
33514
33755
  MissingAuthError,
33756
+ NATIVE_VANA_ASSET,
33515
33757
  NetworkError,
33516
33758
  NodeECIESUint8Provider as NodeECIESProvider,
33517
33759
  NodePlatformAdapter,
@@ -33529,6 +33771,8 @@ export {
33529
33771
  PersonalServerError,
33530
33772
  PinataStorage,
33531
33773
  R2Storage,
33774
+ RECORD_DATA_ACCESS_TYPES,
33775
+ REGISTRATION_KIND_FOR_OP,
33532
33776
  ReadOnlyError,
33533
33777
  RelayerError,
33534
33778
  SERVER_REGISTRATION_TYPES,
@@ -33543,10 +33787,14 @@ export {
33543
33787
  VanaError,
33544
33788
  VanaStorage,
33545
33789
  assertValidPkceVerifier,
33790
+ buildDepositNativeRequest,
33791
+ buildDepositTokenRequest,
33792
+ buildMarkDataPointUnavailableRequest,
33546
33793
  buildPersonalServerLiteOwnerBindingMessage,
33547
33794
  buildPersonalServerLiteOwnerBindingSignature,
33548
33795
  buildPersonalServerRegistrationSignature,
33549
33796
  buildPersonalServerRegistrationTypedData,
33797
+ buildSetDataPointStatusRequest,
33550
33798
  buildWeb3SignedHeader,
33551
33799
  builderRegistrationDomain,
33552
33800
  chains,
@@ -33564,14 +33812,19 @@ export {
33564
33812
  createVanaStorageProvider,
33565
33813
  createViemPersonalServerLiteOwnerBindingSigner,
33566
33814
  createViemPersonalServerRegistrationSigner,
33815
+ dataRegistryContractAddress,
33816
+ dataRegistryDomain,
33567
33817
  decryptWithPassword,
33568
33818
  deriveMasterKey,
33569
33819
  deriveScopeKey,
33570
33820
  deserializeECIES,
33571
33821
  detectPlatform,
33822
+ encodeDepositNativeData,
33823
+ encodeDepositTokenData,
33824
+ encodeSetDataPointStatusData,
33572
33825
  encryptWithPassword,
33573
- fileDeletionDomain,
33574
- fileRegistrationDomain,
33826
+ escrowContractAddress,
33827
+ escrowPaymentDomain,
33575
33828
  generatePkceVerifier,
33576
33829
  getAbi,
33577
33830
  getAllChains,
@@ -33579,6 +33832,8 @@ export {
33579
33832
  getContractAddress,
33580
33833
  getContractController,
33581
33834
  getContractInfo,
33835
+ getFee,
33836
+ getOpFee,
33582
33837
  getPlatformCapabilities,
33583
33838
  getServiceEndpoints,
33584
33839
  grantRegistrationDomain,
@@ -33590,7 +33845,6 @@ export {
33590
33845
  moksha,
33591
33846
  mokshaServices,
33592
33847
  mokshaTestnet2 as mokshaTestnet,
33593
- parseGrantRegistrationPayload,
33594
33848
  parsePSError,
33595
33849
  parseScope,
33596
33850
  parseWeb3SignedHeader,