@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
@@ -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,34 @@ 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"]);
33211
+ return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
33177
33212
  }
33178
- function parseGrantRegistrationPayload(grant) {
33179
- let parsed;
33213
+ function toUint256(value) {
33180
33214
  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
- };
33214
- }
33215
- function parseFileIds(fileIds) {
33216
- try {
33217
- const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
33218
- return {
33219
- values,
33220
- display: values.map((fileId) => fileId.toString())
33221
- };
33215
+ if (typeof value === "number" && !Number.isSafeInteger(value)) {
33216
+ return null;
33217
+ }
33218
+ const big = typeof value === "bigint" ? value : BigInt(value);
33219
+ if (big < 0n) return null;
33220
+ return big;
33222
33221
  } catch {
33223
33222
  return null;
33224
33223
  }
33225
33224
  }
33226
33225
  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
- };
33226
+ if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
33227
+ return { valid: false, error: "scopes must be a non-empty array" };
33228
+ }
33229
+ if (!input.scopes.every((scope) => typeof scope === "string")) {
33230
+ return { valid: false, error: "scopes must contain only strings" };
33233
33231
  }
33234
- const fileIds = parseFileIds(input.fileIds);
33235
- if (!fileIds) {
33236
- return { valid: false, error: "fileIds must contain integer values" };
33232
+ const grantVersion = toUint256(input.grantVersion);
33233
+ if (grantVersion === null || grantVersion < 1n) {
33234
+ return { valid: false, error: "grantVersion must be a uint256 >= 1" };
33235
+ }
33236
+ const expiresAt = toUint256(input.expiresAt);
33237
+ if (expiresAt === null) {
33238
+ return { valid: false, error: "expiresAt must be a non-negative uint256" };
33237
33239
  }
33238
33240
  let valid;
33239
33241
  try {
@@ -33245,8 +33247,9 @@ async function verifyGrantRegistration(input) {
33245
33247
  message: {
33246
33248
  grantorAddress: input.grantorAddress,
33247
33249
  granteeId: input.granteeId,
33248
- grant: input.grant,
33249
- fileIds: fileIds.values
33250
+ scopes: input.scopes,
33251
+ grantVersion,
33252
+ expiresAt
33250
33253
  },
33251
33254
  signature: input.signature
33252
33255
  });
@@ -33257,19 +33260,197 @@ async function verifyGrantRegistration(input) {
33257
33260
  return { valid: false, error: "Grant signature does not match grantor" };
33258
33261
  }
33259
33262
  const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
33260
- if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
33263
+ if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
33261
33264
  return { valid: false, error: "Grant has expired" };
33262
33265
  }
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
33266
  return {
33267
33267
  valid: true,
33268
33268
  grantorAddress: input.grantorAddress,
33269
33269
  granteeId: input.granteeId,
33270
- grant: input.grant,
33271
- payload,
33272
- fileIds: fileIds.display
33270
+ scopes: input.scopes,
33271
+ grantVersion: grantVersion.toString(),
33272
+ expiresAt: expiresAt.toString()
33273
+ };
33274
+ }
33275
+
33276
+ // src/protocol/escrow-deposit.ts
33277
+ var import_viem18 = require("viem");
33278
+ var ESCROW_DEPOSIT_ABI = [
33279
+ {
33280
+ type: "function",
33281
+ name: "depositNative",
33282
+ stateMutability: "payable",
33283
+ inputs: [{ name: "account", type: "address" }],
33284
+ outputs: []
33285
+ },
33286
+ {
33287
+ type: "function",
33288
+ name: "depositToken",
33289
+ stateMutability: "nonpayable",
33290
+ inputs: [
33291
+ { name: "account", type: "address" },
33292
+ { name: "token", type: "address" },
33293
+ { name: "amount", type: "uint256" }
33294
+ ],
33295
+ outputs: []
33296
+ }
33297
+ ];
33298
+ function escrowContractAddress(config) {
33299
+ return config.contracts.dataPortabilityEscrow;
33300
+ }
33301
+ function encodeDepositNativeData(input) {
33302
+ return (0, import_viem18.encodeFunctionData)({
33303
+ abi: ESCROW_DEPOSIT_ABI,
33304
+ functionName: "depositNative",
33305
+ args: [input.account]
33306
+ });
33307
+ }
33308
+ function encodeDepositTokenData(input) {
33309
+ return (0, import_viem18.encodeFunctionData)({
33310
+ abi: ESCROW_DEPOSIT_ABI,
33311
+ functionName: "depositToken",
33312
+ args: [input.account, input.token, input.amount]
33313
+ });
33314
+ }
33315
+ function buildDepositNativeRequest(config, input) {
33316
+ return {
33317
+ to: escrowContractAddress(config),
33318
+ data: encodeDepositNativeData({ account: input.account }),
33319
+ value: input.amount
33320
+ };
33321
+ }
33322
+ function buildDepositTokenRequest(config, input) {
33323
+ return {
33324
+ to: escrowContractAddress(config),
33325
+ data: encodeDepositTokenData(input)
33326
+ };
33327
+ }
33328
+
33329
+ // src/protocol/data-point-status.ts
33330
+ var import_viem19 = require("viem");
33331
+ var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
33332
+ DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
33333
+ DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
33334
+ DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
33335
+ DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
33336
+ return DataPointStatus2;
33337
+ })(DataPointStatus || {});
33338
+ var DATA_REGISTRY_STATUS_ABI = [
33339
+ {
33340
+ type: "function",
33341
+ name: "setStatus",
33342
+ stateMutability: "nonpayable",
33343
+ inputs: [
33344
+ { name: "scope", type: "string" },
33345
+ { name: "newStatus", type: "uint8" }
33346
+ ],
33347
+ outputs: []
33348
+ }
33349
+ ];
33350
+ function dataRegistryContractAddress(config) {
33351
+ return config.contracts.dataRegistry;
33352
+ }
33353
+ function encodeSetDataPointStatusData(input) {
33354
+ return (0, import_viem19.encodeFunctionData)({
33355
+ abi: DATA_REGISTRY_STATUS_ABI,
33356
+ functionName: "setStatus",
33357
+ args: [input.scope, input.status]
33358
+ });
33359
+ }
33360
+ function buildSetDataPointStatusRequest(config, input) {
33361
+ return {
33362
+ to: dataRegistryContractAddress(config),
33363
+ data: encodeSetDataPointStatusData(input)
33364
+ };
33365
+ }
33366
+ function buildMarkDataPointUnavailableRequest(config, input) {
33367
+ return buildSetDataPointStatusRequest(config, {
33368
+ scope: input.scope,
33369
+ status: 3 /* Unavailable */
33370
+ });
33371
+ }
33372
+
33373
+ // src/protocol/fee-registry.ts
33374
+ var import_viem20 = require("viem");
33375
+ var FEE_REGISTRY_ABI = (0, import_viem20.parseAbi)([
33376
+ "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
33377
+ "function fees(bytes32 operation) view returns (Fee)",
33378
+ "function operationKey(string name) pure returns (bytes32)"
33379
+ ]);
33380
+ var REGISTRATION_KIND_FOR_OP = {
33381
+ grant: "grant_registration",
33382
+ data: "data_registration",
33383
+ server: "server_registration",
33384
+ builder: "builder_registration"
33385
+ };
33386
+ function operationNameFor(kind, opts) {
33387
+ switch (kind) {
33388
+ case "grant_registration":
33389
+ return opts?.grantRegistrationOpName ?? "grant_registration";
33390
+ case "data_access":
33391
+ return opts?.dataAccessOpName ?? "data_access";
33392
+ case "data_registration":
33393
+ return opts?.dataRegistrationOpName ?? "data_registration";
33394
+ case "server_registration":
33395
+ return opts?.serverRegistrationOpName ?? "server_registration";
33396
+ case "builder_registration":
33397
+ return opts?.builderRegistrationOpName ?? "builder_registration";
33398
+ }
33399
+ }
33400
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
33401
+ async function getFee(client, config, kind, opts) {
33402
+ const address = config.contracts.feeRegistry;
33403
+ const opName = operationNameFor(kind, opts);
33404
+ const opKey = await client.readContract({
33405
+ address,
33406
+ abi: FEE_REGISTRY_ABI,
33407
+ functionName: "operationKey",
33408
+ args: [opName]
33409
+ });
33410
+ const fee = await client.readContract({
33411
+ address,
33412
+ abi: FEE_REGISTRY_ABI,
33413
+ functionName: "fees",
33414
+ args: [opKey]
33415
+ });
33416
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
33417
+ throw new Error(
33418
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
33419
+ );
33420
+ }
33421
+ return fee;
33422
+ }
33423
+ async function getOpFee(client, config, opType, opts) {
33424
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
33425
+ if (!registrationKind) {
33426
+ throw new Error(
33427
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
33428
+ );
33429
+ }
33430
+ const includeDataAccess = opType === "grant";
33431
+ const [registration, dataAccess] = await Promise.all([
33432
+ getFee(client, config, registrationKind, opts),
33433
+ includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
33434
+ amount: 0n,
33435
+ asset: ZERO_ADDRESS,
33436
+ payee: ZERO_ADDRESS,
33437
+ enabled: false
33438
+ })
33439
+ ]);
33440
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
33441
+ throw new Error(
33442
+ `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.`
33443
+ );
33444
+ }
33445
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
33446
+ return {
33447
+ asset,
33448
+ registrationFee: registration.enabled ? registration.amount : 0n,
33449
+ dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
33450
+ registrationEnabled: registration.enabled,
33451
+ dataAccessEnabled: dataAccess.enabled,
33452
+ registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
33453
+ dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
33273
33454
  };
33274
33455
  }
33275
33456
 
@@ -33350,16 +33531,6 @@ function createGatewayClient(baseUrl) {
33350
33531
  const envelope = await res.json();
33351
33532
  return envelope.data;
33352
33533
  }
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
- deletedAt: record.deletedAt ?? null
33361
- };
33362
- }
33363
33534
  function getMutationId(body, key) {
33364
33535
  const value = body[key] ?? body["id"];
33365
33536
  return typeof value === "string" ? value : void 0;
@@ -33409,30 +33580,34 @@ function createGatewayClient(baseUrl) {
33409
33580
  }
33410
33581
  return unwrapEnvelope(res);
33411
33582
  },
33412
- async getFile(fileId) {
33413
- const res = await fetch(`${base}/v1/files/${fileId}`);
33583
+ async getDataPoint(dataPointId) {
33584
+ const res = await fetch(`${base}/v1/data/${dataPointId}`);
33414
33585
  if (res.status === 404) return null;
33415
33586
  if (!res.ok) {
33416
33587
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33417
33588
  }
33418
- return normalizeFileRecord(await unwrapEnvelope(res));
33589
+ return unwrapEnvelope(res);
33419
33590
  },
33420
- async listFilesSince(owner, cursor, options) {
33591
+ async listDataPointsByOwner(owner, cursor, options) {
33421
33592
  const params = new URLSearchParams({ user: owner });
33422
33593
  if (cursor !== null) {
33423
- params.set("since", cursor);
33594
+ params.set("cursor", cursor);
33595
+ }
33596
+ if (options?.since) {
33597
+ params.set("since", options.since);
33424
33598
  }
33425
- if (options?.includeDeleted) {
33426
- params.set("includeDeleted", "true");
33599
+ if (options?.limit !== void 0) {
33600
+ params.set("limit", String(options.limit));
33427
33601
  }
33428
- const res = await fetch(`${base}/v1/files?${params.toString()}`);
33602
+ const res = await fetch(`${base}/v1/data?${params.toString()}`);
33429
33603
  if (!res.ok) {
33430
33604
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33431
33605
  }
33432
- const data = await unwrapEnvelope(res);
33606
+ const envelope = await res.json();
33607
+ const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
33433
33608
  return {
33434
- files: data.files.map(normalizeFileRecord),
33435
- cursor: data.cursor
33609
+ dataPoints: envelope.data.dataPoints,
33610
+ cursor: nextCursor
33436
33611
  };
33437
33612
  },
33438
33613
  async getSchema(schemaId) {
@@ -33473,8 +33648,8 @@ function createGatewayClient(baseUrl) {
33473
33648
  alreadyRegistered: false
33474
33649
  };
33475
33650
  },
33476
- async registerFile(params) {
33477
- const res = await fetch(`${base}/v1/files`, {
33651
+ async registerBuilder(params) {
33652
+ const res = await fetch(`${base}/v1/builders`, {
33478
33653
  method: "POST",
33479
33654
  headers: {
33480
33655
  "Content-Type": "application/json",
@@ -33482,22 +33657,57 @@ function createGatewayClient(baseUrl) {
33482
33657
  },
33483
33658
  body: JSON.stringify({
33484
33659
  ownerAddress: params.ownerAddress,
33485
- url: params.url,
33486
- schemaId: params.schemaId
33660
+ granteeAddress: params.granteeAddress,
33661
+ publicKey: params.publicKey,
33662
+ appUrl: params.appUrl
33487
33663
  })
33488
33664
  });
33489
33665
  if (res.status === 409) {
33490
33666
  const body2 = await res.json().catch(() => ({}));
33491
33667
  return {
33492
- fileId: getMutationId(body2, "fileId")
33668
+ builderId: getMutationId(
33669
+ body2,
33670
+ "builderId"
33671
+ ),
33672
+ alreadyRegistered: true
33493
33673
  };
33494
33674
  }
33495
33675
  if (!res.ok) {
33496
33676
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33497
33677
  }
33498
- const body = await res.json();
33678
+ const body = await res.json().catch(() => ({}));
33499
33679
  return {
33500
- fileId: getMutationId(body, "fileId")
33680
+ builderId: getMutationId(body, "builderId"),
33681
+ alreadyRegistered: false
33682
+ };
33683
+ },
33684
+ async registerDataPoint(params) {
33685
+ const res = await fetch(`${base}/v1/data`, {
33686
+ method: "POST",
33687
+ headers: {
33688
+ "Content-Type": "application/json",
33689
+ Authorization: `Web3Signed ${params.signature}`
33690
+ },
33691
+ body: JSON.stringify({
33692
+ ownerAddress: params.ownerAddress,
33693
+ scope: params.scope,
33694
+ dataHash: params.dataHash,
33695
+ metadataHash: params.metadataHash,
33696
+ expectedVersion: params.expectedVersion
33697
+ })
33698
+ });
33699
+ if (!res.ok) {
33700
+ const body2 = await res.json().catch(() => ({}));
33701
+ const detail = body2.error ?? res.statusText;
33702
+ throw new Error(`Gateway error: ${res.status} ${detail}`);
33703
+ }
33704
+ const body = await res.json().catch(() => ({}));
33705
+ return {
33706
+ dataPointId: getMutationId(
33707
+ body,
33708
+ "dataPointId"
33709
+ ),
33710
+ expectedVersion: body.expectedVersion
33501
33711
  };
33502
33712
  },
33503
33713
  async createGrant(params) {
@@ -33510,8 +33720,9 @@ function createGatewayClient(baseUrl) {
33510
33720
  body: JSON.stringify({
33511
33721
  grantorAddress: params.grantorAddress,
33512
33722
  granteeId: params.granteeId,
33513
- grant: params.grant,
33514
- fileIds: params.fileIds
33723
+ scopes: params.scopes,
33724
+ grantVersion: params.grantVersion,
33725
+ expiresAt: params.expiresAt
33515
33726
  })
33516
33727
  });
33517
33728
  if (res.status === 409) {
@@ -33536,7 +33747,8 @@ function createGatewayClient(baseUrl) {
33536
33747
  Authorization: `Web3Signed ${params.signature}`
33537
33748
  },
33538
33749
  body: JSON.stringify({
33539
- grantorAddress: params.grantorAddress
33750
+ grantorAddress: params.grantorAddress,
33751
+ grantVersion: params.grantVersion
33540
33752
  })
33541
33753
  });
33542
33754
  if (res.status === 409) return;
@@ -33544,21 +33756,62 @@ function createGatewayClient(baseUrl) {
33544
33756
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33545
33757
  }
33546
33758
  },
33547
- async deleteFile(params) {
33548
- const res = await fetch(`${base}/v1/files/${params.fileId}`, {
33549
- method: "DELETE",
33759
+ async getEscrowBalance(account) {
33760
+ const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
33761
+ if (!res.ok) {
33762
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33763
+ }
33764
+ return await res.json();
33765
+ },
33766
+ async submitEscrowDeposit(params) {
33767
+ const res = await fetch(`${base}/v1/escrow/deposit`, {
33768
+ method: "POST",
33769
+ headers: { "Content-Type": "application/json" },
33770
+ body: JSON.stringify({ txHash: params.txHash })
33771
+ });
33772
+ if (res.status !== 200 && res.status !== 202) {
33773
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33774
+ }
33775
+ return await res.json();
33776
+ },
33777
+ async payForOperation(params) {
33778
+ const body = {
33779
+ payerAddress: params.payerAddress,
33780
+ opType: params.opType,
33781
+ opId: params.opId,
33782
+ asset: params.asset,
33783
+ amount: params.amount,
33784
+ paymentNonce: params.paymentNonce
33785
+ };
33786
+ if (params.accessRecord) {
33787
+ body["accessRecord"] = params.accessRecord;
33788
+ }
33789
+ const res = await fetch(`${base}/v1/escrow/pay`, {
33790
+ method: "POST",
33550
33791
  headers: {
33551
33792
  "Content-Type": "application/json",
33552
33793
  Authorization: `Web3Signed ${params.signature}`
33553
33794
  },
33554
- body: JSON.stringify({
33555
- ownerAddress: params.ownerAddress
33556
- })
33795
+ body: JSON.stringify(body)
33796
+ });
33797
+ if (!res.ok) {
33798
+ throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33799
+ }
33800
+ return await res.json();
33801
+ },
33802
+ async settle(params) {
33803
+ const res = await fetch(`${base}/v1/settle`, {
33804
+ method: "POST",
33805
+ headers: { "Content-Type": "application/json" },
33806
+ // The gateway accepts an empty body; only `limit` is recognised.
33807
+ // Always send a JSON body so the gateway's req.body shape parse
33808
+ // doesn't have to deal with an undefined.
33809
+ body: JSON.stringify(params ?? {})
33557
33810
  });
33558
- if (res.status === 409) return;
33559
33811
  if (!res.ok) {
33560
33812
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33561
33813
  }
33814
+ return await res.json();
33562
33815
  }
33563
33816
  };
33564
33817
  }
@@ -33628,6 +33881,7 @@ async function parsePSError(response) {
33628
33881
  // Annotate the CommonJS export names for ESM import in node:
33629
33882
  0 && (module.exports = {
33630
33883
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33884
+ ADD_DATA_TYPES,
33631
33885
  AccountPersonalServerLiteOwnerBindingError,
33632
33886
  AccountPersonalServerRegistrationError,
33633
33887
  BUILDER_REGISTRATION_TYPES,
@@ -33637,12 +33891,15 @@ async function parsePSError(response) {
33637
33891
  CallbackStorage,
33638
33892
  ContractFactory,
33639
33893
  ContractNotFoundError,
33894
+ DATA_REGISTRY_STATUS_ABI,
33640
33895
  DataFileEnvelopeSchema,
33896
+ DataPointStatus,
33641
33897
  DropboxStorage,
33642
33898
  ECIESError,
33899
+ ESCROW_DEPOSIT_ABI,
33643
33900
  ExpiredTokenError,
33644
- FILE_DELETION_TYPES,
33645
- FILE_REGISTRATION_TYPES,
33901
+ FEE_REGISTRY_ABI,
33902
+ GENERIC_PAYMENT_TYPES,
33646
33903
  GRANT_REGISTRATION_TYPES,
33647
33904
  GRANT_REVOCATION_TYPES,
33648
33905
  GoogleDriveStorage,
@@ -33653,6 +33910,7 @@ async function parsePSError(response) {
33653
33910
  IpfsStorage,
33654
33911
  MASTER_KEY_MESSAGE,
33655
33912
  MissingAuthError,
33913
+ NATIVE_VANA_ASSET,
33656
33914
  NetworkError,
33657
33915
  NodeECIESProvider,
33658
33916
  NodePlatformAdapter,
@@ -33670,6 +33928,8 @@ async function parsePSError(response) {
33670
33928
  PersonalServerError,
33671
33929
  PinataStorage,
33672
33930
  R2Storage,
33931
+ RECORD_DATA_ACCESS_TYPES,
33932
+ REGISTRATION_KIND_FOR_OP,
33673
33933
  ReadOnlyError,
33674
33934
  RelayerError,
33675
33935
  SERVER_REGISTRATION_TYPES,
@@ -33684,10 +33944,14 @@ async function parsePSError(response) {
33684
33944
  VanaError,
33685
33945
  VanaStorage,
33686
33946
  assertValidPkceVerifier,
33947
+ buildDepositNativeRequest,
33948
+ buildDepositTokenRequest,
33949
+ buildMarkDataPointUnavailableRequest,
33687
33950
  buildPersonalServerLiteOwnerBindingMessage,
33688
33951
  buildPersonalServerLiteOwnerBindingSignature,
33689
33952
  buildPersonalServerRegistrationSignature,
33690
33953
  buildPersonalServerRegistrationTypedData,
33954
+ buildSetDataPointStatusRequest,
33691
33955
  buildWeb3SignedHeader,
33692
33956
  builderRegistrationDomain,
33693
33957
  chains,
@@ -33705,14 +33969,19 @@ async function parsePSError(response) {
33705
33969
  createVanaStorageProvider,
33706
33970
  createViemPersonalServerLiteOwnerBindingSigner,
33707
33971
  createViemPersonalServerRegistrationSigner,
33972
+ dataRegistryContractAddress,
33973
+ dataRegistryDomain,
33708
33974
  decryptWithPassword,
33709
33975
  deriveMasterKey,
33710
33976
  deriveScopeKey,
33711
33977
  deserializeECIES,
33712
33978
  detectPlatform,
33979
+ encodeDepositNativeData,
33980
+ encodeDepositTokenData,
33981
+ encodeSetDataPointStatusData,
33713
33982
  encryptWithPassword,
33714
- fileDeletionDomain,
33715
- fileRegistrationDomain,
33983
+ escrowContractAddress,
33984
+ escrowPaymentDomain,
33716
33985
  generatePkceVerifier,
33717
33986
  getAbi,
33718
33987
  getAllChains,
@@ -33720,6 +33989,8 @@ async function parsePSError(response) {
33720
33989
  getContractAddress,
33721
33990
  getContractController,
33722
33991
  getContractInfo,
33992
+ getFee,
33993
+ getOpFee,
33723
33994
  getPlatformCapabilities,
33724
33995
  getServiceEndpoints,
33725
33996
  grantRegistrationDomain,
@@ -33731,7 +34002,6 @@ async function parsePSError(response) {
33731
34002
  moksha,
33732
34003
  mokshaServices,
33733
34004
  mokshaTestnet,
33734
- parseGrantRegistrationPayload,
33735
34005
  parsePSError,
33736
34006
  parseScope,
33737
34007
  parseWeb3SignedHeader,