@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
@@ -1174,6 +1174,7 @@ var init_browser2 = __esm({
1174
1174
  var index_node_exports = {};
1175
1175
  __export(index_node_exports, {
1176
1176
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT: () => ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
1177
+ ADD_DATA_TYPES: () => ADD_DATA_TYPES,
1177
1178
  AccountPersonalServerLiteOwnerBindingError: () => AccountPersonalServerLiteOwnerBindingError,
1178
1179
  AccountPersonalServerRegistrationError: () => AccountPersonalServerRegistrationError,
1179
1180
  BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
@@ -1183,12 +1184,15 @@ __export(index_node_exports, {
1183
1184
  CallbackStorage: () => CallbackStorage,
1184
1185
  ContractFactory: () => ContractFactory,
1185
1186
  ContractNotFoundError: () => ContractNotFoundError,
1187
+ DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
1186
1188
  DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
1189
+ DataPointStatus: () => DataPointStatus,
1187
1190
  DropboxStorage: () => DropboxStorage,
1188
1191
  ECIESError: () => ECIESError,
1192
+ ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI,
1189
1193
  ExpiredTokenError: () => ExpiredTokenError,
1190
- FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
1191
- FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
1194
+ FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
1195
+ GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
1192
1196
  GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
1193
1197
  GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
1194
1198
  GoogleDriveStorage: () => GoogleDriveStorage,
@@ -1199,6 +1203,7 @@ __export(index_node_exports, {
1199
1203
  IpfsStorage: () => IpfsStorage,
1200
1204
  MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
1201
1205
  MissingAuthError: () => MissingAuthError,
1206
+ NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
1202
1207
  NetworkError: () => NetworkError,
1203
1208
  NodeECIESProvider: () => NodeECIESUint8Provider,
1204
1209
  NodePlatformAdapter: () => NodePlatformAdapter,
@@ -1216,6 +1221,8 @@ __export(index_node_exports, {
1216
1221
  PersonalServerError: () => PersonalServerError,
1217
1222
  PinataStorage: () => PinataStorage,
1218
1223
  R2Storage: () => R2Storage,
1224
+ RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
1225
+ REGISTRATION_KIND_FOR_OP: () => REGISTRATION_KIND_FOR_OP,
1219
1226
  ReadOnlyError: () => ReadOnlyError,
1220
1227
  RelayerError: () => RelayerError,
1221
1228
  SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
@@ -1230,10 +1237,14 @@ __export(index_node_exports, {
1230
1237
  VanaError: () => VanaError,
1231
1238
  VanaStorage: () => VanaStorage,
1232
1239
  assertValidPkceVerifier: () => assertValidPkceVerifier,
1240
+ buildDepositNativeRequest: () => buildDepositNativeRequest,
1241
+ buildDepositTokenRequest: () => buildDepositTokenRequest,
1242
+ buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
1233
1243
  buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
1234
1244
  buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
1235
1245
  buildPersonalServerRegistrationSignature: () => buildPersonalServerRegistrationSignature,
1236
1246
  buildPersonalServerRegistrationTypedData: () => buildPersonalServerRegistrationTypedData,
1247
+ buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
1237
1248
  buildWeb3SignedHeader: () => buildWeb3SignedHeader,
1238
1249
  builderRegistrationDomain: () => builderRegistrationDomain,
1239
1250
  chains: () => chains,
@@ -1251,14 +1262,19 @@ __export(index_node_exports, {
1251
1262
  createVanaStorageProvider: () => createVanaStorageProvider,
1252
1263
  createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
1253
1264
  createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
1265
+ dataRegistryContractAddress: () => dataRegistryContractAddress,
1266
+ dataRegistryDomain: () => dataRegistryDomain,
1254
1267
  decryptWithPassword: () => decryptWithPassword,
1255
1268
  deriveMasterKey: () => deriveMasterKey,
1256
1269
  deriveScopeKey: () => deriveScopeKey,
1257
1270
  deserializeECIES: () => deserializeECIES,
1258
1271
  detectPlatform: () => detectPlatform,
1272
+ encodeDepositNativeData: () => encodeDepositNativeData,
1273
+ encodeDepositTokenData: () => encodeDepositTokenData,
1274
+ encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
1259
1275
  encryptWithPassword: () => encryptWithPassword,
1260
- fileDeletionDomain: () => fileDeletionDomain,
1261
- fileRegistrationDomain: () => fileRegistrationDomain,
1276
+ escrowContractAddress: () => escrowContractAddress,
1277
+ escrowPaymentDomain: () => escrowPaymentDomain,
1262
1278
  generatePkceVerifier: () => generatePkceVerifier,
1263
1279
  getAbi: () => getAbi,
1264
1280
  getAllChains: () => getAllChains,
@@ -1266,6 +1282,8 @@ __export(index_node_exports, {
1266
1282
  getContractAddress: () => getContractAddress,
1267
1283
  getContractController: () => getContractController,
1268
1284
  getContractInfo: () => getContractInfo,
1285
+ getFee: () => getFee,
1286
+ getOpFee: () => getOpFee,
1269
1287
  getPlatformCapabilities: () => getPlatformCapabilities,
1270
1288
  getServiceEndpoints: () => getServiceEndpoints,
1271
1289
  grantRegistrationDomain: () => grantRegistrationDomain,
@@ -1277,7 +1295,6 @@ __export(index_node_exports, {
1277
1295
  moksha: () => moksha,
1278
1296
  mokshaServices: () => mokshaServices,
1279
1297
  mokshaTestnet: () => mokshaTestnet2,
1280
- parseGrantRegistrationPayload: () => parseGrantRegistrationPayload,
1281
1298
  parsePSError: () => parsePSError,
1282
1299
  parseScope: () => parseScope,
1283
1300
  parseWeb3SignedHeader: () => parseWeb3SignedHeader,
@@ -32649,6 +32666,7 @@ function formatOAuthError(body, status) {
32649
32666
  // src/protocol/eip712.ts
32650
32667
  var DOMAIN_NAME = "Vana Data Portability";
32651
32668
  var DOMAIN_VERSION = "1";
32669
+ var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
32652
32670
  function buildDomain(chainId, verifyingContract) {
32653
32671
  return {
32654
32672
  name: DOMAIN_NAME,
@@ -32657,13 +32675,7 @@ function buildDomain(chainId, verifyingContract) {
32657
32675
  verifyingContract
32658
32676
  };
32659
32677
  }
32660
- function fileRegistrationDomain(config) {
32661
- return buildDomain(
32662
- config.chainId,
32663
- config.contracts.dataRegistry
32664
- );
32665
- }
32666
- function fileDeletionDomain(config) {
32678
+ function dataRegistryDomain(config) {
32667
32679
  return buildDomain(
32668
32680
  config.chainId,
32669
32681
  config.contracts.dataRegistry
@@ -32693,31 +32705,26 @@ function builderRegistrationDomain(config) {
32693
32705
  config.contracts.dataPortabilityGrantees
32694
32706
  );
32695
32707
  }
32696
- var FILE_REGISTRATION_TYPES = {
32697
- FileRegistration: [
32698
- { name: "ownerAddress", type: "address" },
32699
- { name: "url", type: "string" },
32700
- { name: "schemaId", type: "bytes32" }
32701
- ]
32702
- };
32703
- var FILE_DELETION_TYPES = {
32704
- FileDeletion: [
32705
- { name: "ownerAddress", type: "address" },
32706
- { name: "fileId", type: "bytes32" }
32707
- ]
32708
- };
32708
+ function escrowPaymentDomain(config) {
32709
+ return buildDomain(
32710
+ config.chainId,
32711
+ config.contracts.dataPortabilityEscrow
32712
+ );
32713
+ }
32709
32714
  var GRANT_REGISTRATION_TYPES = {
32710
32715
  GrantRegistration: [
32711
32716
  { name: "grantorAddress", type: "address" },
32712
32717
  { name: "granteeId", type: "bytes32" },
32713
- { name: "grant", type: "string" },
32714
- { name: "fileIds", type: "uint256[]" }
32718
+ { name: "scopes", type: "string[]" },
32719
+ { name: "grantVersion", type: "uint256" },
32720
+ { name: "expiresAt", type: "uint256" }
32715
32721
  ]
32716
32722
  };
32717
32723
  var GRANT_REVOCATION_TYPES = {
32718
32724
  GrantRevocation: [
32719
32725
  { name: "grantorAddress", type: "address" },
32720
- { name: "grantId", type: "bytes32" }
32726
+ { name: "grantId", type: "bytes32" },
32727
+ { name: "grantVersion", type: "uint256" }
32721
32728
  ]
32722
32729
  };
32723
32730
  var SERVER_REGISTRATION_TYPES = {
@@ -32736,6 +32743,34 @@ var BUILDER_REGISTRATION_TYPES = {
32736
32743
  { name: "appUrl", type: "string" }
32737
32744
  ]
32738
32745
  };
32746
+ var GENERIC_PAYMENT_TYPES = {
32747
+ GenericPayment: [
32748
+ { name: "payerAddress", type: "address" },
32749
+ { name: "opType", type: "string" },
32750
+ { name: "opId", type: "bytes32" },
32751
+ { name: "asset", type: "address" },
32752
+ { name: "amount", type: "uint256" },
32753
+ { name: "paymentNonce", type: "uint256" }
32754
+ ]
32755
+ };
32756
+ var ADD_DATA_TYPES = {
32757
+ AddData: [
32758
+ { name: "ownerAddress", type: "address" },
32759
+ { name: "scope", type: "string" },
32760
+ { name: "dataHash", type: "bytes32" },
32761
+ { name: "metadataHash", type: "bytes32" },
32762
+ { name: "expectedVersion", type: "uint256" }
32763
+ ]
32764
+ };
32765
+ var RECORD_DATA_ACCESS_TYPES = {
32766
+ RecordDataAccess: [
32767
+ { name: "ownerAddress", type: "address" },
32768
+ { name: "scope", type: "string" },
32769
+ { name: "version", type: "uint256" },
32770
+ { name: "accessor", type: "address" },
32771
+ { name: "recordId", type: "bytes32" }
32772
+ ]
32773
+ };
32739
32774
 
32740
32775
  // src/protocol/personal-server-registration.ts
32741
32776
  var import_viem14 = require("viem");
@@ -33173,67 +33208,31 @@ function isDataPortabilityGatewayConfig(value) {
33173
33208
  return false;
33174
33209
  }
33175
33210
  const c = contracts;
33176
- return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
33177
- }
33178
- function parseGrantRegistrationPayload(grant) {
33179
- let parsed;
33180
- try {
33181
- parsed = JSON.parse(grant);
33182
- } catch {
33183
- return null;
33184
- }
33185
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
33186
- return null;
33187
- }
33188
- const value = parsed;
33189
- if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
33190
- return null;
33191
- }
33192
- if (!value["scopes"].every((scope) => typeof scope === "string")) {
33193
- return null;
33194
- }
33195
- if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
33196
- return null;
33197
- }
33198
- if (value["user"] !== void 0 && !isHexString(value["user"])) {
33199
- return null;
33200
- }
33201
- if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
33202
- return null;
33203
- }
33204
- if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
33205
- return null;
33206
- }
33207
- return {
33208
- user: value["user"],
33209
- builder: value["builder"],
33210
- scopes: value["scopes"],
33211
- expiresAt: value["expiresAt"],
33212
- nonce: value["nonce"]
33213
- };
33211
+ return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
33214
33212
  }
33215
- function parseFileIds(fileIds) {
33213
+ function toUint256(value) {
33216
33214
  try {
33217
- const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
33218
- return {
33219
- values,
33220
- display: values.map((fileId) => fileId.toString())
33221
- };
33215
+ const big = typeof value === "bigint" ? value : BigInt(value);
33216
+ if (big < 0n) return null;
33217
+ return big;
33222
33218
  } catch {
33223
33219
  return null;
33224
33220
  }
33225
33221
  }
33226
33222
  async function verifyGrantRegistration(input) {
33227
- const payload = parseGrantRegistrationPayload(input.grant);
33228
- if (!payload) {
33229
- return {
33230
- valid: false,
33231
- error: "Grant must be JSON with scopes and expiresAt"
33232
- };
33223
+ if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
33224
+ return { valid: false, error: "scopes must be a non-empty array" };
33225
+ }
33226
+ if (!input.scopes.every((scope) => typeof scope === "string")) {
33227
+ return { valid: false, error: "scopes must contain only strings" };
33228
+ }
33229
+ const grantVersion = toUint256(input.grantVersion);
33230
+ if (grantVersion === null || grantVersion < 1n) {
33231
+ return { valid: false, error: "grantVersion must be a uint256 >= 1" };
33233
33232
  }
33234
- const fileIds = parseFileIds(input.fileIds);
33235
- if (!fileIds) {
33236
- return { valid: false, error: "fileIds must contain integer values" };
33233
+ const expiresAt = toUint256(input.expiresAt);
33234
+ if (expiresAt === null) {
33235
+ return { valid: false, error: "expiresAt must be a non-negative uint256" };
33237
33236
  }
33238
33237
  let valid;
33239
33238
  try {
@@ -33245,8 +33244,9 @@ async function verifyGrantRegistration(input) {
33245
33244
  message: {
33246
33245
  grantorAddress: input.grantorAddress,
33247
33246
  granteeId: input.granteeId,
33248
- grant: input.grant,
33249
- fileIds: fileIds.values
33247
+ scopes: input.scopes,
33248
+ grantVersion,
33249
+ expiresAt
33250
33250
  },
33251
33251
  signature: input.signature
33252
33252
  });
@@ -33257,19 +33257,197 @@ async function verifyGrantRegistration(input) {
33257
33257
  return { valid: false, error: "Grant signature does not match grantor" };
33258
33258
  }
33259
33259
  const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
33260
- if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
33260
+ if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
33261
33261
  return { valid: false, error: "Grant has expired" };
33262
33262
  }
33263
- if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
33264
- return { valid: false, error: "Grant user does not match grantorAddress" };
33265
- }
33266
33263
  return {
33267
33264
  valid: true,
33268
33265
  grantorAddress: input.grantorAddress,
33269
33266
  granteeId: input.granteeId,
33270
- grant: input.grant,
33271
- payload,
33272
- fileIds: fileIds.display
33267
+ scopes: input.scopes,
33268
+ grantVersion: grantVersion.toString(),
33269
+ expiresAt: expiresAt.toString()
33270
+ };
33271
+ }
33272
+
33273
+ // src/protocol/escrow-deposit.ts
33274
+ var import_viem18 = require("viem");
33275
+ var ESCROW_DEPOSIT_ABI = [
33276
+ {
33277
+ type: "function",
33278
+ name: "depositNative",
33279
+ stateMutability: "payable",
33280
+ inputs: [{ name: "account", type: "address" }],
33281
+ outputs: []
33282
+ },
33283
+ {
33284
+ type: "function",
33285
+ name: "depositToken",
33286
+ stateMutability: "nonpayable",
33287
+ inputs: [
33288
+ { name: "account", type: "address" },
33289
+ { name: "token", type: "address" },
33290
+ { name: "amount", type: "uint256" }
33291
+ ],
33292
+ outputs: []
33293
+ }
33294
+ ];
33295
+ function escrowContractAddress(config) {
33296
+ return config.contracts.dataPortabilityEscrow;
33297
+ }
33298
+ function encodeDepositNativeData(input) {
33299
+ return (0, import_viem18.encodeFunctionData)({
33300
+ abi: ESCROW_DEPOSIT_ABI,
33301
+ functionName: "depositNative",
33302
+ args: [input.account]
33303
+ });
33304
+ }
33305
+ function encodeDepositTokenData(input) {
33306
+ return (0, import_viem18.encodeFunctionData)({
33307
+ abi: ESCROW_DEPOSIT_ABI,
33308
+ functionName: "depositToken",
33309
+ args: [input.account, input.token, input.amount]
33310
+ });
33311
+ }
33312
+ function buildDepositNativeRequest(config, input) {
33313
+ return {
33314
+ to: escrowContractAddress(config),
33315
+ data: encodeDepositNativeData({ account: input.account }),
33316
+ value: input.amount
33317
+ };
33318
+ }
33319
+ function buildDepositTokenRequest(config, input) {
33320
+ return {
33321
+ to: escrowContractAddress(config),
33322
+ data: encodeDepositTokenData(input)
33323
+ };
33324
+ }
33325
+
33326
+ // src/protocol/data-point-status.ts
33327
+ var import_viem19 = require("viem");
33328
+ var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
33329
+ DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
33330
+ DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
33331
+ DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
33332
+ DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
33333
+ return DataPointStatus2;
33334
+ })(DataPointStatus || {});
33335
+ var DATA_REGISTRY_STATUS_ABI = [
33336
+ {
33337
+ type: "function",
33338
+ name: "setStatus",
33339
+ stateMutability: "nonpayable",
33340
+ inputs: [
33341
+ { name: "scope", type: "string" },
33342
+ { name: "newStatus", type: "uint8" }
33343
+ ],
33344
+ outputs: []
33345
+ }
33346
+ ];
33347
+ function dataRegistryContractAddress(config) {
33348
+ return config.contracts.dataRegistry;
33349
+ }
33350
+ function encodeSetDataPointStatusData(input) {
33351
+ return (0, import_viem19.encodeFunctionData)({
33352
+ abi: DATA_REGISTRY_STATUS_ABI,
33353
+ functionName: "setStatus",
33354
+ args: [input.scope, input.status]
33355
+ });
33356
+ }
33357
+ function buildSetDataPointStatusRequest(config, input) {
33358
+ return {
33359
+ to: dataRegistryContractAddress(config),
33360
+ data: encodeSetDataPointStatusData(input)
33361
+ };
33362
+ }
33363
+ function buildMarkDataPointUnavailableRequest(config, input) {
33364
+ return buildSetDataPointStatusRequest(config, {
33365
+ scope: input.scope,
33366
+ status: 3 /* Unavailable */
33367
+ });
33368
+ }
33369
+
33370
+ // src/protocol/fee-registry.ts
33371
+ var import_viem20 = require("viem");
33372
+ var FEE_REGISTRY_ABI = (0, import_viem20.parseAbi)([
33373
+ "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
33374
+ "function fees(bytes32 operation) view returns (Fee)",
33375
+ "function operationKey(string name) pure returns (bytes32)"
33376
+ ]);
33377
+ var REGISTRATION_KIND_FOR_OP = {
33378
+ grant: "grant_registration",
33379
+ data: "data_registration",
33380
+ server: "server_registration",
33381
+ builder: "builder_registration"
33382
+ };
33383
+ function operationNameFor(kind, opts) {
33384
+ switch (kind) {
33385
+ case "grant_registration":
33386
+ return opts?.grantRegistrationOpName ?? "grant_registration";
33387
+ case "data_access":
33388
+ return opts?.dataAccessOpName ?? "data_access";
33389
+ case "data_registration":
33390
+ return opts?.dataRegistrationOpName ?? "data_registration";
33391
+ case "server_registration":
33392
+ return opts?.serverRegistrationOpName ?? "server_registration";
33393
+ case "builder_registration":
33394
+ return opts?.builderRegistrationOpName ?? "builder_registration";
33395
+ }
33396
+ }
33397
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
33398
+ async function getFee(client, config, kind, opts) {
33399
+ const address = config.contracts.feeRegistry;
33400
+ const opName = operationNameFor(kind, opts);
33401
+ const opKey = await client.readContract({
33402
+ address,
33403
+ abi: FEE_REGISTRY_ABI,
33404
+ functionName: "operationKey",
33405
+ args: [opName]
33406
+ });
33407
+ const fee = await client.readContract({
33408
+ address,
33409
+ abi: FEE_REGISTRY_ABI,
33410
+ functionName: "fees",
33411
+ args: [opKey]
33412
+ });
33413
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
33414
+ throw new Error(
33415
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
33416
+ );
33417
+ }
33418
+ return fee;
33419
+ }
33420
+ async function getOpFee(client, config, opType, opts) {
33421
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
33422
+ if (!registrationKind) {
33423
+ throw new Error(
33424
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
33425
+ );
33426
+ }
33427
+ const includeDataAccess = opType === "grant";
33428
+ const [registration, dataAccess] = await Promise.all([
33429
+ getFee(client, config, registrationKind, opts),
33430
+ includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
33431
+ amount: 0n,
33432
+ asset: ZERO_ADDRESS,
33433
+ payee: ZERO_ADDRESS,
33434
+ enabled: false
33435
+ })
33436
+ ]);
33437
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
33438
+ throw new Error(
33439
+ `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.`
33440
+ );
33441
+ }
33442
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
33443
+ return {
33444
+ asset,
33445
+ registrationFee: registration.enabled ? registration.amount : 0n,
33446
+ dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
33447
+ registrationEnabled: registration.enabled,
33448
+ dataAccessEnabled: dataAccess.enabled,
33449
+ registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
33450
+ dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
33273
33451
  };
33274
33452
  }
33275
33453
 
@@ -33350,15 +33528,6 @@ function createGatewayClient(baseUrl) {
33350
33528
  const envelope = await res.json();
33351
33529
  return envelope.data;
33352
33530
  }
33353
- function normalizeFileRecord(record) {
33354
- return {
33355
- fileId: record.fileId ?? record.id ?? "",
33356
- owner: record.owner ?? record.ownerAddress ?? "",
33357
- url: record.url,
33358
- schemaId: record.schemaId,
33359
- createdAt: record.createdAt ?? record.addedAt ?? ""
33360
- };
33361
- }
33362
33531
  function getMutationId(body, key) {
33363
33532
  const value = body[key] ?? body["id"];
33364
33533
  return typeof value === "string" ? value : void 0;
@@ -33408,27 +33577,34 @@ function createGatewayClient(baseUrl) {
33408
33577
  }
33409
33578
  return unwrapEnvelope(res);
33410
33579
  },
33411
- async getFile(fileId) {
33412
- const res = await fetch(`${base}/v1/files/${fileId}`);
33580
+ async getDataPoint(dataPointId) {
33581
+ const res = await fetch(`${base}/v1/data/${dataPointId}`);
33413
33582
  if (res.status === 404) return null;
33414
33583
  if (!res.ok) {
33415
33584
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33416
33585
  }
33417
- return normalizeFileRecord(await unwrapEnvelope(res));
33586
+ return unwrapEnvelope(res);
33418
33587
  },
33419
- async listFilesSince(owner, cursor) {
33588
+ async listDataPointsByOwner(owner, cursor, options) {
33420
33589
  const params = new URLSearchParams({ user: owner });
33421
33590
  if (cursor !== null) {
33422
- params.set("since", cursor);
33591
+ params.set("cursor", cursor);
33592
+ }
33593
+ if (options?.since) {
33594
+ params.set("since", options.since);
33595
+ }
33596
+ if (options?.limit !== void 0) {
33597
+ params.set("limit", String(options.limit));
33423
33598
  }
33424
- const res = await fetch(`${base}/v1/files?${params.toString()}`);
33599
+ const res = await fetch(`${base}/v1/data?${params.toString()}`);
33425
33600
  if (!res.ok) {
33426
33601
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33427
33602
  }
33428
- const data = await unwrapEnvelope(res);
33603
+ const envelope = await res.json();
33604
+ const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
33429
33605
  return {
33430
- files: data.files.map(normalizeFileRecord),
33431
- cursor: data.cursor
33606
+ dataPoints: envelope.data.dataPoints,
33607
+ cursor: nextCursor
33432
33608
  };
33433
33609
  },
33434
33610
  async getSchema(schemaId) {
@@ -33469,8 +33645,8 @@ function createGatewayClient(baseUrl) {
33469
33645
  alreadyRegistered: false
33470
33646
  };
33471
33647
  },
33472
- async registerFile(params) {
33473
- const res = await fetch(`${base}/v1/files`, {
33648
+ async registerBuilder(params) {
33649
+ const res = await fetch(`${base}/v1/builders`, {
33474
33650
  method: "POST",
33475
33651
  headers: {
33476
33652
  "Content-Type": "application/json",
@@ -33478,22 +33654,57 @@ function createGatewayClient(baseUrl) {
33478
33654
  },
33479
33655
  body: JSON.stringify({
33480
33656
  ownerAddress: params.ownerAddress,
33481
- url: params.url,
33482
- schemaId: params.schemaId
33657
+ granteeAddress: params.granteeAddress,
33658
+ publicKey: params.publicKey,
33659
+ appUrl: params.appUrl
33483
33660
  })
33484
33661
  });
33485
33662
  if (res.status === 409) {
33486
33663
  const body2 = await res.json().catch(() => ({}));
33487
33664
  return {
33488
- fileId: getMutationId(body2, "fileId")
33665
+ builderId: getMutationId(
33666
+ body2,
33667
+ "builderId"
33668
+ ),
33669
+ alreadyRegistered: true
33489
33670
  };
33490
33671
  }
33491
33672
  if (!res.ok) {
33492
33673
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33493
33674
  }
33494
- const body = await res.json();
33675
+ const body = await res.json().catch(() => ({}));
33495
33676
  return {
33496
- fileId: getMutationId(body, "fileId")
33677
+ builderId: getMutationId(body, "builderId"),
33678
+ alreadyRegistered: false
33679
+ };
33680
+ },
33681
+ async registerDataPoint(params) {
33682
+ const res = await fetch(`${base}/v1/data`, {
33683
+ method: "POST",
33684
+ headers: {
33685
+ "Content-Type": "application/json",
33686
+ Authorization: `Web3Signed ${params.signature}`
33687
+ },
33688
+ body: JSON.stringify({
33689
+ ownerAddress: params.ownerAddress,
33690
+ scope: params.scope,
33691
+ dataHash: params.dataHash,
33692
+ metadataHash: params.metadataHash,
33693
+ expectedVersion: params.expectedVersion
33694
+ })
33695
+ });
33696
+ if (!res.ok) {
33697
+ const body2 = await res.json().catch(() => ({}));
33698
+ const detail = body2.error ?? res.statusText;
33699
+ throw new Error(`Gateway error: ${res.status} ${detail}`);
33700
+ }
33701
+ const body = await res.json().catch(() => ({}));
33702
+ return {
33703
+ dataPointId: getMutationId(
33704
+ body,
33705
+ "dataPointId"
33706
+ ),
33707
+ expectedVersion: body.expectedVersion
33497
33708
  };
33498
33709
  },
33499
33710
  async createGrant(params) {
@@ -33506,8 +33717,9 @@ function createGatewayClient(baseUrl) {
33506
33717
  body: JSON.stringify({
33507
33718
  grantorAddress: params.grantorAddress,
33508
33719
  granteeId: params.granteeId,
33509
- grant: params.grant,
33510
- fileIds: params.fileIds
33720
+ scopes: params.scopes,
33721
+ grantVersion: params.grantVersion,
33722
+ expiresAt: params.expiresAt
33511
33723
  })
33512
33724
  });
33513
33725
  if (res.status === 409) {
@@ -33532,7 +33744,8 @@ function createGatewayClient(baseUrl) {
33532
33744
  Authorization: `Web3Signed ${params.signature}`
33533
33745
  },
33534
33746
  body: JSON.stringify({
33535
- grantorAddress: params.grantorAddress
33747
+ grantorAddress: params.grantorAddress,
33748
+ grantVersion: params.grantVersion
33536
33749
  })
33537
33750
  });
33538
33751
  if (res.status === 409) return;
@@ -33540,21 +33753,62 @@ function createGatewayClient(baseUrl) {
33540
33753
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33541
33754
  }
33542
33755
  },
33543
- async deleteFile(params) {
33544
- const res = await fetch(`${base}/v1/files/${params.fileId}`, {
33545
- method: "DELETE",
33756
+ async getEscrowBalance(account) {
33757
+ const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
33758
+ if (!res.ok) {
33759
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33760
+ }
33761
+ return await res.json();
33762
+ },
33763
+ async submitEscrowDeposit(params) {
33764
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
33765
+ method: "POST",
33766
+ headers: { "Content-Type": "application/json" },
33767
+ body: JSON.stringify({ txHash: params.txHash })
33768
+ });
33769
+ if (res.status !== 200 && res.status !== 202) {
33770
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33771
+ }
33772
+ return await res.json();
33773
+ },
33774
+ async payForOperation(params) {
33775
+ const body = {
33776
+ payerAddress: params.payerAddress,
33777
+ opType: params.opType,
33778
+ opId: params.opId,
33779
+ asset: params.asset,
33780
+ amount: params.amount,
33781
+ paymentNonce: params.paymentNonce
33782
+ };
33783
+ if (params.accessRecord) {
33784
+ body["accessRecord"] = params.accessRecord;
33785
+ }
33786
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33787
+ method: "POST",
33546
33788
  headers: {
33547
33789
  "Content-Type": "application/json",
33548
33790
  Authorization: `Web3Signed ${params.signature}`
33549
33791
  },
33550
- body: JSON.stringify({
33551
- ownerAddress: params.ownerAddress
33552
- })
33792
+ body: JSON.stringify(body)
33793
+ });
33794
+ if (!res.ok) {
33795
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33796
+ }
33797
+ return await res.json();
33798
+ },
33799
+ async settle(params) {
33800
+ const res = await fetch(`${base}/v1/settle`, {
33801
+ method: "POST",
33802
+ headers: { "Content-Type": "application/json" },
33803
+ // The gateway accepts an empty body; only `limit` is recognised.
33804
+ // Always send a JSON body so the gateway's req.body shape parse
33805
+ // doesn't have to deal with an undefined.
33806
+ body: JSON.stringify(params ?? {})
33553
33807
  });
33554
- if (res.status === 409) return;
33555
33808
  if (!res.ok) {
33556
33809
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33557
33810
  }
33811
+ return await res.json();
33558
33812
  }
33559
33813
  };
33560
33814
  }
@@ -33624,6 +33878,7 @@ async function parsePSError(response) {
33624
33878
  // Annotate the CommonJS export names for ESM import in node:
33625
33879
  0 && (module.exports = {
33626
33880
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33881
+ ADD_DATA_TYPES,
33627
33882
  AccountPersonalServerLiteOwnerBindingError,
33628
33883
  AccountPersonalServerRegistrationError,
33629
33884
  BUILDER_REGISTRATION_TYPES,
@@ -33633,12 +33888,15 @@ async function parsePSError(response) {
33633
33888
  CallbackStorage,
33634
33889
  ContractFactory,
33635
33890
  ContractNotFoundError,
33891
+ DATA_REGISTRY_STATUS_ABI,
33636
33892
  DataFileEnvelopeSchema,
33893
+ DataPointStatus,
33637
33894
  DropboxStorage,
33638
33895
  ECIESError,
33896
+ ESCROW_DEPOSIT_ABI,
33639
33897
  ExpiredTokenError,
33640
- FILE_DELETION_TYPES,
33641
- FILE_REGISTRATION_TYPES,
33898
+ FEE_REGISTRY_ABI,
33899
+ GENERIC_PAYMENT_TYPES,
33642
33900
  GRANT_REGISTRATION_TYPES,
33643
33901
  GRANT_REVOCATION_TYPES,
33644
33902
  GoogleDriveStorage,
@@ -33649,6 +33907,7 @@ async function parsePSError(response) {
33649
33907
  IpfsStorage,
33650
33908
  MASTER_KEY_MESSAGE,
33651
33909
  MissingAuthError,
33910
+ NATIVE_VANA_ASSET,
33652
33911
  NetworkError,
33653
33912
  NodeECIESProvider,
33654
33913
  NodePlatformAdapter,
@@ -33666,6 +33925,8 @@ async function parsePSError(response) {
33666
33925
  PersonalServerError,
33667
33926
  PinataStorage,
33668
33927
  R2Storage,
33928
+ RECORD_DATA_ACCESS_TYPES,
33929
+ REGISTRATION_KIND_FOR_OP,
33669
33930
  ReadOnlyError,
33670
33931
  RelayerError,
33671
33932
  SERVER_REGISTRATION_TYPES,
@@ -33680,10 +33941,14 @@ async function parsePSError(response) {
33680
33941
  VanaError,
33681
33942
  VanaStorage,
33682
33943
  assertValidPkceVerifier,
33944
+ buildDepositNativeRequest,
33945
+ buildDepositTokenRequest,
33946
+ buildMarkDataPointUnavailableRequest,
33683
33947
  buildPersonalServerLiteOwnerBindingMessage,
33684
33948
  buildPersonalServerLiteOwnerBindingSignature,
33685
33949
  buildPersonalServerRegistrationSignature,
33686
33950
  buildPersonalServerRegistrationTypedData,
33951
+ buildSetDataPointStatusRequest,
33687
33952
  buildWeb3SignedHeader,
33688
33953
  builderRegistrationDomain,
33689
33954
  chains,
@@ -33701,14 +33966,19 @@ async function parsePSError(response) {
33701
33966
  createVanaStorageProvider,
33702
33967
  createViemPersonalServerLiteOwnerBindingSigner,
33703
33968
  createViemPersonalServerRegistrationSigner,
33969
+ dataRegistryContractAddress,
33970
+ dataRegistryDomain,
33704
33971
  decryptWithPassword,
33705
33972
  deriveMasterKey,
33706
33973
  deriveScopeKey,
33707
33974
  deserializeECIES,
33708
33975
  detectPlatform,
33976
+ encodeDepositNativeData,
33977
+ encodeDepositTokenData,
33978
+ encodeSetDataPointStatusData,
33709
33979
  encryptWithPassword,
33710
- fileDeletionDomain,
33711
- fileRegistrationDomain,
33980
+ escrowContractAddress,
33981
+ escrowPaymentDomain,
33712
33982
  generatePkceVerifier,
33713
33983
  getAbi,
33714
33984
  getAllChains,
@@ -33716,6 +33986,8 @@ async function parsePSError(response) {
33716
33986
  getContractAddress,
33717
33987
  getContractController,
33718
33988
  getContractInfo,
33989
+ getFee,
33990
+ getOpFee,
33719
33991
  getPlatformCapabilities,
33720
33992
  getServiceEndpoints,
33721
33993
  grantRegistrationDomain,
@@ -33727,7 +33999,6 @@ async function parsePSError(response) {
33727
33999
  moksha,
33728
34000
  mokshaServices,
33729
34001
  mokshaTestnet,
33730
- parseGrantRegistrationPayload,
33731
34002
  parsePSError,
33732
34003
  parseScope,
33733
34004
  parseWeb3SignedHeader,