@opendatalabs/vana-sdk 3.4.1-canary.e9d0aad → 3.5.0

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 (72) hide show
  1. package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
  2. package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
  3. package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
  4. package/dist/account/personal-server-lite-owner-binding.js +1 -1
  5. package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
  6. package/dist/index.browser.d.ts +5 -8
  7. package/dist/index.browser.js +250 -416
  8. package/dist/index.browser.js.map +4 -4
  9. package/dist/index.node.cjs +258 -439
  10. package/dist/index.node.cjs.map +4 -4
  11. package/dist/index.node.d.ts +5 -8
  12. package/dist/index.node.js +250 -416
  13. package/dist/index.node.js.map +4 -4
  14. package/dist/{protocol/personal-server-lite-owner-binding.cjs → personal-server-lite/owner-binding.cjs} +5 -5
  15. package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
  16. package/dist/{protocol/personal-server-lite-owner-binding.d.ts → personal-server-lite/owner-binding.d.ts} +3 -3
  17. package/dist/{protocol/personal-server-lite-owner-binding.js → personal-server-lite/owner-binding.js} +2 -2
  18. package/dist/personal-server-lite/owner-binding.js.map +1 -0
  19. package/dist/protocol/eip712.cjs +31 -53
  20. package/dist/protocol/eip712.cjs.map +1 -1
  21. package/dist/protocol/eip712.d.ts +43 -98
  22. package/dist/protocol/eip712.js +27 -47
  23. package/dist/protocol/eip712.js.map +1 -1
  24. package/dist/protocol/escrow.cjs +146 -0
  25. package/dist/protocol/escrow.cjs.map +1 -0
  26. package/dist/protocol/escrow.d.ts +336 -0
  27. package/dist/protocol/escrow.js +118 -0
  28. package/dist/protocol/escrow.js.map +1 -0
  29. package/dist/protocol/gateway.cjs +37 -107
  30. package/dist/protocol/gateway.cjs.map +1 -1
  31. package/dist/protocol/gateway.d.ts +57 -223
  32. package/dist/protocol/gateway.js +37 -107
  33. package/dist/protocol/gateway.js.map +1 -1
  34. package/dist/protocol/grants.cjs +64 -27
  35. package/dist/protocol/grants.cjs.map +1 -1
  36. package/dist/protocol/grants.d.ts +13 -6
  37. package/dist/protocol/grants.js +63 -27
  38. package/dist/protocol/grants.js.map +1 -1
  39. package/dist/protocol/personal-server-registration.cjs +16 -4
  40. package/dist/protocol/personal-server-registration.cjs.map +1 -1
  41. package/dist/protocol/personal-server-registration.d.ts +5 -2
  42. package/dist/protocol/personal-server-registration.js +16 -4
  43. package/dist/protocol/personal-server-registration.js.map +1 -1
  44. package/package.json +2 -3
  45. package/dist/protocol/data-point-status.cjs +0 -80
  46. package/dist/protocol/data-point-status.cjs.map +0 -1
  47. package/dist/protocol/data-point-status.d.ts +0 -34
  48. package/dist/protocol/data-point-status.js +0 -51
  49. package/dist/protocol/data-point-status.js.map +0 -1
  50. package/dist/protocol/escrow-deposit.cjs +0 -89
  51. package/dist/protocol/escrow-deposit.cjs.map +0 -1
  52. package/dist/protocol/escrow-deposit.d.ts +0 -47
  53. package/dist/protocol/escrow-deposit.js +0 -60
  54. package/dist/protocol/escrow-deposit.js.map +0 -1
  55. package/dist/protocol/escrow-flow.test.d.ts +0 -21
  56. package/dist/protocol/fee-registry.cjs +0 -116
  57. package/dist/protocol/fee-registry.cjs.map +0 -1
  58. package/dist/protocol/fee-registry.d.ts +0 -151
  59. package/dist/protocol/fee-registry.js +0 -89
  60. package/dist/protocol/fee-registry.js.map +0 -1
  61. package/dist/protocol/fee-registry.test.d.ts +0 -1
  62. package/dist/protocol/personal-server-data.cjs +0 -71
  63. package/dist/protocol/personal-server-data.cjs.map +0 -1
  64. package/dist/protocol/personal-server-data.d.ts +0 -16
  65. package/dist/protocol/personal-server-data.js +0 -47
  66. package/dist/protocol/personal-server-data.js.map +0 -1
  67. package/dist/protocol/personal-server-data.test.d.ts +0 -1
  68. package/dist/protocol/personal-server-lite-owner-binding.cjs.map +0 -1
  69. package/dist/protocol/personal-server-lite-owner-binding.js.map +0 -1
  70. package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +0 -1
  71. /package/dist/{protocol/data-point-status.test.d.ts → personal-server-lite/owner-binding.test.d.ts} +0 -0
  72. /package/dist/protocol/{escrow-deposit.test.d.ts → escrow.test.d.ts} +0 -0
@@ -1174,7 +1174,6 @@ 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,
1178
1177
  AccountPersonalServerLiteOwnerBindingError: () => AccountPersonalServerLiteOwnerBindingError,
1179
1178
  AccountPersonalServerRegistrationError: () => AccountPersonalServerRegistrationError,
1180
1179
  BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
@@ -1184,14 +1183,13 @@ __export(index_node_exports, {
1184
1183
  CallbackStorage: () => CallbackStorage,
1185
1184
  ContractFactory: () => ContractFactory,
1186
1185
  ContractNotFoundError: () => ContractNotFoundError,
1187
- DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
1188
1186
  DataFileEnvelopeSchema: () => DataFileEnvelopeSchema,
1189
- DataPointStatus: () => DataPointStatus,
1190
1187
  DropboxStorage: () => DropboxStorage,
1191
1188
  ECIESError: () => ECIESError,
1192
1189
  ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI,
1193
1190
  ExpiredTokenError: () => ExpiredTokenError,
1194
- FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
1191
+ FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
1192
+ FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
1195
1193
  GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
1196
1194
  GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
1197
1195
  GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
@@ -1203,7 +1201,7 @@ __export(index_node_exports, {
1203
1201
  IpfsStorage: () => IpfsStorage,
1204
1202
  MASTER_KEY_MESSAGE: () => MASTER_KEY_MESSAGE,
1205
1203
  MissingAuthError: () => MissingAuthError,
1206
- NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
1204
+ NATIVE_ASSET_ADDRESS: () => NATIVE_ASSET_ADDRESS,
1207
1205
  NetworkError: () => NetworkError,
1208
1206
  NodeECIESProvider: () => NodeECIESUint8Provider,
1209
1207
  NodePlatformAdapter: () => NodePlatformAdapter,
@@ -1221,8 +1219,6 @@ __export(index_node_exports, {
1221
1219
  PersonalServerError: () => PersonalServerError,
1222
1220
  PinataStorage: () => PinataStorage,
1223
1221
  R2Storage: () => R2Storage,
1224
- RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
1225
- REGISTRATION_KIND_FOR_OP: () => REGISTRATION_KIND_FOR_OP,
1226
1222
  ReadOnlyError: () => ReadOnlyError,
1227
1223
  RelayerError: () => RelayerError,
1228
1224
  SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
@@ -1237,15 +1233,10 @@ __export(index_node_exports, {
1237
1233
  VanaError: () => VanaError,
1238
1234
  VanaStorage: () => VanaStorage,
1239
1235
  assertValidPkceVerifier: () => assertValidPkceVerifier,
1240
- buildDepositNativeRequest: () => buildDepositNativeRequest,
1241
- buildDepositTokenRequest: () => buildDepositTokenRequest,
1242
- buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
1243
- buildPersonalServerDataReadRequest: () => buildPersonalServerDataReadRequest,
1244
1236
  buildPersonalServerLiteOwnerBindingMessage: () => buildPersonalServerLiteOwnerBindingMessage,
1245
1237
  buildPersonalServerLiteOwnerBindingSignature: () => buildPersonalServerLiteOwnerBindingSignature,
1246
1238
  buildPersonalServerRegistrationSignature: () => buildPersonalServerRegistrationSignature,
1247
1239
  buildPersonalServerRegistrationTypedData: () => buildPersonalServerRegistrationTypedData,
1248
- buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
1249
1240
  buildWeb3SignedHeader: () => buildWeb3SignedHeader,
1250
1241
  builderRegistrationDomain: () => builderRegistrationDomain,
1251
1242
  chains: () => chains,
@@ -1255,6 +1246,7 @@ __export(index_node_exports, {
1255
1246
  contractCacheForTesting: () => contractCacheForTesting,
1256
1247
  createBrowserPlatformAdapter: () => createBrowserPlatformAdapter,
1257
1248
  createDataFileEnvelope: () => createDataFileEnvelope,
1249
+ createEscrowGatewayClient: () => createEscrowGatewayClient,
1258
1250
  createGatewayClient: () => createGatewayClient,
1259
1251
  createNodePlatformAdapter: () => createNodePlatformAdapter,
1260
1252
  createPlatformAdapter: () => createPlatformAdapter,
@@ -1263,28 +1255,22 @@ __export(index_node_exports, {
1263
1255
  createVanaStorageProvider: () => createVanaStorageProvider,
1264
1256
  createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
1265
1257
  createViemPersonalServerRegistrationSigner: () => createViemPersonalServerRegistrationSigner,
1266
- dataRegistryContractAddress: () => dataRegistryContractAddress,
1267
- dataRegistryDomain: () => dataRegistryDomain,
1268
1258
  decryptWithPassword: () => decryptWithPassword,
1269
1259
  deriveMasterKey: () => deriveMasterKey,
1270
1260
  deriveScopeKey: () => deriveScopeKey,
1271
1261
  deserializeECIES: () => deserializeECIES,
1272
1262
  detectPlatform: () => detectPlatform,
1273
- encodeDepositNativeData: () => encodeDepositNativeData,
1274
- encodeDepositTokenData: () => encodeDepositTokenData,
1275
- encodeSetDataPointStatusData: () => encodeSetDataPointStatusData,
1276
1263
  encryptWithPassword: () => encryptWithPassword,
1277
- escrowContractAddress: () => escrowContractAddress,
1278
- escrowPaymentDomain: () => escrowPaymentDomain,
1264
+ fileDeletionDomain: () => fileDeletionDomain,
1265
+ fileRegistrationDomain: () => fileRegistrationDomain,
1279
1266
  generatePkceVerifier: () => generatePkceVerifier,
1267
+ genericPaymentDomain: () => genericPaymentDomain,
1280
1268
  getAbi: () => getAbi,
1281
1269
  getAllChains: () => getAllChains,
1282
1270
  getChainConfig: () => getChainConfig,
1283
1271
  getContractAddress: () => getContractAddress,
1284
1272
  getContractController: () => getContractController,
1285
1273
  getContractInfo: () => getContractInfo,
1286
- getFee: () => getFee,
1287
- getOpFee: () => getOpFee,
1288
1274
  getPlatformCapabilities: () => getPlatformCapabilities,
1289
1275
  getServiceEndpoints: () => getServiceEndpoints,
1290
1276
  grantRegistrationDomain: () => grantRegistrationDomain,
@@ -1296,12 +1282,11 @@ __export(index_node_exports, {
1296
1282
  moksha: () => moksha,
1297
1283
  mokshaServices: () => mokshaServices,
1298
1284
  mokshaTestnet: () => mokshaTestnet2,
1285
+ parseGrantRegistrationPayload: () => parseGrantRegistrationPayload,
1299
1286
  parsePSError: () => parsePSError,
1300
1287
  parseScope: () => parseScope,
1301
1288
  parseWeb3SignedHeader: () => parseWeb3SignedHeader,
1302
- personalServerDataReadPath: () => personalServerDataReadPath,
1303
1289
  personalServerRegistrationDomain: () => personalServerRegistrationDomain,
1304
- readPersonalServerData: () => readPersonalServerData,
1305
1290
  recoverServerOwner: () => recoverServerOwner,
1306
1291
  registerPersonalServerSignature: () => registerPersonalServerSignature,
1307
1292
  scopeCoveredByGrant: () => scopeCoveredByGrant,
@@ -32669,7 +32654,6 @@ function formatOAuthError(body, status) {
32669
32654
  // src/protocol/eip712.ts
32670
32655
  var DOMAIN_NAME = "Vana Data Portability";
32671
32656
  var DOMAIN_VERSION = "1";
32672
- var NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
32673
32657
  function buildDomain(chainId, verifyingContract) {
32674
32658
  return {
32675
32659
  name: DOMAIN_NAME,
@@ -32678,7 +32662,13 @@ function buildDomain(chainId, verifyingContract) {
32678
32662
  verifyingContract
32679
32663
  };
32680
32664
  }
32681
- function dataRegistryDomain(config) {
32665
+ function fileRegistrationDomain(config) {
32666
+ return buildDomain(
32667
+ config.chainId,
32668
+ config.contracts.dataRegistry
32669
+ );
32670
+ }
32671
+ function fileDeletionDomain(config) {
32682
32672
  return buildDomain(
32683
32673
  config.chainId,
32684
32674
  config.contracts.dataRegistry
@@ -32708,26 +32698,31 @@ function builderRegistrationDomain(config) {
32708
32698
  config.contracts.dataPortabilityGrantees
32709
32699
  );
32710
32700
  }
32711
- function escrowPaymentDomain(config) {
32712
- return buildDomain(
32713
- config.chainId,
32714
- config.contracts.dataPortabilityEscrow
32715
- );
32716
- }
32701
+ var FILE_REGISTRATION_TYPES = {
32702
+ FileRegistration: [
32703
+ { name: "ownerAddress", type: "address" },
32704
+ { name: "url", type: "string" },
32705
+ { name: "schemaId", type: "bytes32" }
32706
+ ]
32707
+ };
32708
+ var FILE_DELETION_TYPES = {
32709
+ FileDeletion: [
32710
+ { name: "ownerAddress", type: "address" },
32711
+ { name: "fileId", type: "bytes32" }
32712
+ ]
32713
+ };
32717
32714
  var GRANT_REGISTRATION_TYPES = {
32718
32715
  GrantRegistration: [
32719
32716
  { name: "grantorAddress", type: "address" },
32720
32717
  { name: "granteeId", type: "bytes32" },
32721
- { name: "scopes", type: "string[]" },
32722
- { name: "grantVersion", type: "uint256" },
32723
- { name: "expiresAt", type: "uint256" }
32718
+ { name: "grant", type: "string" },
32719
+ { name: "fileIds", type: "uint256[]" }
32724
32720
  ]
32725
32721
  };
32726
32722
  var GRANT_REVOCATION_TYPES = {
32727
32723
  GrantRevocation: [
32728
32724
  { name: "grantorAddress", type: "address" },
32729
- { name: "grantId", type: "bytes32" },
32730
- { name: "grantVersion", type: "uint256" }
32725
+ { name: "grantId", type: "bytes32" }
32731
32726
  ]
32732
32727
  };
32733
32728
  var SERVER_REGISTRATION_TYPES = {
@@ -32746,39 +32741,14 @@ var BUILDER_REGISTRATION_TYPES = {
32746
32741
  { name: "appUrl", type: "string" }
32747
32742
  ]
32748
32743
  };
32749
- var GENERIC_PAYMENT_TYPES = {
32750
- GenericPayment: [
32751
- { name: "payerAddress", type: "address" },
32752
- { name: "opType", type: "string" },
32753
- { name: "opId", type: "bytes32" },
32754
- { name: "asset", type: "address" },
32755
- { name: "amount", type: "uint256" },
32756
- { name: "paymentNonce", type: "uint256" }
32757
- ]
32758
- };
32759
- var ADD_DATA_TYPES = {
32760
- AddData: [
32761
- { name: "ownerAddress", type: "address" },
32762
- { name: "scope", type: "string" },
32763
- { name: "dataHash", type: "bytes32" },
32764
- { name: "metadataHash", type: "bytes32" },
32765
- { name: "expectedVersion", type: "uint256" }
32766
- ]
32767
- };
32768
- var RECORD_DATA_ACCESS_TYPES = {
32769
- RecordDataAccess: [
32770
- { name: "ownerAddress", type: "address" },
32771
- { name: "scope", type: "string" },
32772
- { name: "version", type: "uint256" },
32773
- { name: "accessor", type: "address" },
32774
- { name: "recordId", type: "bytes32" }
32775
- ]
32776
- };
32777
32744
 
32778
32745
  // src/protocol/personal-server-registration.ts
32779
32746
  var import_viem14 = require("viem");
32780
- var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
32781
- var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
32747
+ var PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet2.id;
32748
+ var PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
32749
+ PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
32750
+ "DataPortabilityServers"
32751
+ );
32782
32752
  function assertAddress(value, name) {
32783
32753
  if (!(0, import_viem14.isAddress)(value)) {
32784
32754
  throw new Error(`${name} must be a valid EVM address`);
@@ -32793,6 +32763,12 @@ function getAccountAddress(account) {
32793
32763
  function isPersonalServerRegistrationSigner(source) {
32794
32764
  return "address" in source && typeof source.signTypedData === "function";
32795
32765
  }
32766
+ function getDefaultServerRegistrationContract(chainId) {
32767
+ return getContractAddress(
32768
+ chainId,
32769
+ "DataPortabilityServers"
32770
+ );
32771
+ }
32796
32772
  function createViemPersonalServerRegistrationSigner(source, options = {}) {
32797
32773
  if (isPersonalServerRegistrationSigner(source)) {
32798
32774
  return source;
@@ -32815,12 +32791,13 @@ function personalServerRegistrationDomain(input = {}) {
32815
32791
  if (input.config) {
32816
32792
  return serverRegistrationDomain(input.config);
32817
32793
  }
32818
- const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
32794
+ const chainId = input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;
32795
+ const verifyingContract = input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);
32819
32796
  assertAddress(verifyingContract, "verifyingContract");
32820
32797
  return {
32821
32798
  name: "Vana Data Portability",
32822
32799
  version: "1",
32823
- chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
32800
+ chainId,
32824
32801
  verifyingContract
32825
32802
  };
32826
32803
  }
@@ -32858,9 +32835,9 @@ async function buildPersonalServerRegistrationSignature(input) {
32858
32835
  }
32859
32836
  var registerPersonalServerSignature = buildPersonalServerRegistrationSignature;
32860
32837
 
32861
- // src/protocol/personal-server-lite-owner-binding.ts
32838
+ // src/personal-server-lite/owner-binding.ts
32862
32839
  var import_viem15 = require("viem");
32863
- var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.account.v1";
32840
+ var PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
32864
32841
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
32865
32842
  var PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
32866
32843
  function assertAddress2(value, name) {
@@ -33211,34 +33188,67 @@ function isDataPortabilityGatewayConfig(value) {
33211
33188
  return false;
33212
33189
  }
33213
33190
  const c = contracts;
33214
- return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]) && isHexString(c["dataPortabilityEscrow"]) && isHexString(c["feeRegistry"]);
33191
+ return isHexString(c["dataRegistry"]) && isHexString(c["dataPortabilityPermissions"]) && isHexString(c["dataPortabilityServer"]) && isHexString(c["dataPortabilityGrantees"]);
33215
33192
  }
33216
- function toUint256(value) {
33193
+ function parseGrantRegistrationPayload(grant) {
33194
+ let parsed;
33217
33195
  try {
33218
- if (typeof value === "number" && !Number.isSafeInteger(value)) {
33219
- return null;
33220
- }
33221
- const big = typeof value === "bigint" ? value : BigInt(value);
33222
- if (big < 0n) return null;
33223
- return big;
33196
+ parsed = JSON.parse(grant);
33224
33197
  } catch {
33225
33198
  return null;
33226
33199
  }
33227
- }
33228
- async function verifyGrantRegistration(input) {
33229
- if (!Array.isArray(input.scopes) || input.scopes.length === 0) {
33230
- return { valid: false, error: "scopes must be a non-empty array" };
33200
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
33201
+ return null;
33202
+ }
33203
+ const value = parsed;
33204
+ if (!Array.isArray(value["scopes"]) || value["scopes"].length === 0) {
33205
+ return null;
33206
+ }
33207
+ if (!value["scopes"].every((scope) => typeof scope === "string")) {
33208
+ return null;
33209
+ }
33210
+ if (typeof value["expiresAt"] !== "number" || !Number.isFinite(value["expiresAt"])) {
33211
+ return null;
33212
+ }
33213
+ if (value["user"] !== void 0 && !isHexString(value["user"])) {
33214
+ return null;
33215
+ }
33216
+ if (value["builder"] !== void 0 && !isHexString(value["builder"])) {
33217
+ return null;
33231
33218
  }
33232
- if (!input.scopes.every((scope) => typeof scope === "string")) {
33233
- return { valid: false, error: "scopes must contain only strings" };
33219
+ if (value["nonce"] !== void 0 && (typeof value["nonce"] !== "number" || !Number.isFinite(value["nonce"]))) {
33220
+ return null;
33234
33221
  }
33235
- const grantVersion = toUint256(input.grantVersion);
33236
- if (grantVersion === null || grantVersion < 1n) {
33237
- return { valid: false, error: "grantVersion must be a uint256 >= 1" };
33222
+ return {
33223
+ user: value["user"],
33224
+ builder: value["builder"],
33225
+ scopes: value["scopes"],
33226
+ expiresAt: value["expiresAt"],
33227
+ nonce: value["nonce"]
33228
+ };
33229
+ }
33230
+ function parseFileIds(fileIds) {
33231
+ try {
33232
+ const values = (fileIds ?? []).map((fileId) => BigInt(fileId));
33233
+ return {
33234
+ values,
33235
+ display: values.map((fileId) => fileId.toString())
33236
+ };
33237
+ } catch {
33238
+ return null;
33238
33239
  }
33239
- const expiresAt = toUint256(input.expiresAt);
33240
- if (expiresAt === null) {
33241
- return { valid: false, error: "expiresAt must be a non-negative uint256" };
33240
+ }
33241
+ async function verifyGrantRegistration(input) {
33242
+ const payload = parseGrantRegistrationPayload(input.grant);
33243
+ if (!payload) {
33244
+ return {
33245
+ valid: false,
33246
+ error: "Grant must be JSON with scopes and expiresAt"
33247
+ };
33248
+ }
33249
+ const fileIds = parseFileIds(input.fileIds);
33250
+ if (!fileIds) {
33251
+ return { valid: false, error: "fileIds must contain integer values" };
33242
33252
  }
33243
33253
  let valid;
33244
33254
  try {
@@ -33250,9 +33260,8 @@ async function verifyGrantRegistration(input) {
33250
33260
  message: {
33251
33261
  grantorAddress: input.grantorAddress,
33252
33262
  granteeId: input.granteeId,
33253
- scopes: input.scopes,
33254
- grantVersion,
33255
- expiresAt
33263
+ grant: input.grant,
33264
+ fileIds: fileIds.values
33256
33265
  },
33257
33266
  signature: input.signature
33258
33267
  });
@@ -33263,197 +33272,19 @@ async function verifyGrantRegistration(input) {
33263
33272
  return { valid: false, error: "Grant signature does not match grantor" };
33264
33273
  }
33265
33274
  const nowSeconds = input.nowSeconds ?? Math.floor(Date.now() / 1e3);
33266
- if (expiresAt > 0n && expiresAt < BigInt(nowSeconds)) {
33275
+ if (payload.expiresAt > 0 && payload.expiresAt < nowSeconds) {
33267
33276
  return { valid: false, error: "Grant has expired" };
33268
33277
  }
33278
+ if (payload.user !== void 0 && payload.user.toLowerCase() !== input.grantorAddress.toLowerCase()) {
33279
+ return { valid: false, error: "Grant user does not match grantorAddress" };
33280
+ }
33269
33281
  return {
33270
33282
  valid: true,
33271
33283
  grantorAddress: input.grantorAddress,
33272
33284
  granteeId: input.granteeId,
33273
- scopes: input.scopes,
33274
- grantVersion: grantVersion.toString(),
33275
- expiresAt: expiresAt.toString()
33276
- };
33277
- }
33278
-
33279
- // src/protocol/escrow-deposit.ts
33280
- var import_viem18 = require("viem");
33281
- var ESCROW_DEPOSIT_ABI = [
33282
- {
33283
- type: "function",
33284
- name: "depositNative",
33285
- stateMutability: "payable",
33286
- inputs: [{ name: "account", type: "address" }],
33287
- outputs: []
33288
- },
33289
- {
33290
- type: "function",
33291
- name: "depositToken",
33292
- stateMutability: "nonpayable",
33293
- inputs: [
33294
- { name: "account", type: "address" },
33295
- { name: "token", type: "address" },
33296
- { name: "amount", type: "uint256" }
33297
- ],
33298
- outputs: []
33299
- }
33300
- ];
33301
- function escrowContractAddress(config) {
33302
- return config.contracts.dataPortabilityEscrow;
33303
- }
33304
- function encodeDepositNativeData(input) {
33305
- return (0, import_viem18.encodeFunctionData)({
33306
- abi: ESCROW_DEPOSIT_ABI,
33307
- functionName: "depositNative",
33308
- args: [input.account]
33309
- });
33310
- }
33311
- function encodeDepositTokenData(input) {
33312
- return (0, import_viem18.encodeFunctionData)({
33313
- abi: ESCROW_DEPOSIT_ABI,
33314
- functionName: "depositToken",
33315
- args: [input.account, input.token, input.amount]
33316
- });
33317
- }
33318
- function buildDepositNativeRequest(config, input) {
33319
- return {
33320
- to: escrowContractAddress(config),
33321
- data: encodeDepositNativeData({ account: input.account }),
33322
- value: input.amount
33323
- };
33324
- }
33325
- function buildDepositTokenRequest(config, input) {
33326
- return {
33327
- to: escrowContractAddress(config),
33328
- data: encodeDepositTokenData(input)
33329
- };
33330
- }
33331
-
33332
- // src/protocol/data-point-status.ts
33333
- var import_viem19 = require("viem");
33334
- var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
33335
- DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
33336
- DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
33337
- DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
33338
- DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
33339
- return DataPointStatus2;
33340
- })(DataPointStatus || {});
33341
- var DATA_REGISTRY_STATUS_ABI = [
33342
- {
33343
- type: "function",
33344
- name: "setStatus",
33345
- stateMutability: "nonpayable",
33346
- inputs: [
33347
- { name: "scope", type: "string" },
33348
- { name: "newStatus", type: "uint8" }
33349
- ],
33350
- outputs: []
33351
- }
33352
- ];
33353
- function dataRegistryContractAddress(config) {
33354
- return config.contracts.dataRegistry;
33355
- }
33356
- function encodeSetDataPointStatusData(input) {
33357
- return (0, import_viem19.encodeFunctionData)({
33358
- abi: DATA_REGISTRY_STATUS_ABI,
33359
- functionName: "setStatus",
33360
- args: [input.scope, input.status]
33361
- });
33362
- }
33363
- function buildSetDataPointStatusRequest(config, input) {
33364
- return {
33365
- to: dataRegistryContractAddress(config),
33366
- data: encodeSetDataPointStatusData(input)
33367
- };
33368
- }
33369
- function buildMarkDataPointUnavailableRequest(config, input) {
33370
- return buildSetDataPointStatusRequest(config, {
33371
- scope: input.scope,
33372
- status: 3 /* Unavailable */
33373
- });
33374
- }
33375
-
33376
- // src/protocol/fee-registry.ts
33377
- var import_viem20 = require("viem");
33378
- var FEE_REGISTRY_ABI = (0, import_viem20.parseAbi)([
33379
- "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
33380
- "function fees(bytes32 operation) view returns (Fee)",
33381
- "function operationKey(string name) pure returns (bytes32)"
33382
- ]);
33383
- var REGISTRATION_KIND_FOR_OP = {
33384
- grant: "grant_registration",
33385
- data: "data_registration",
33386
- server: "server_registration",
33387
- builder: "builder_registration"
33388
- };
33389
- function operationNameFor(kind, opts) {
33390
- switch (kind) {
33391
- case "grant_registration":
33392
- return opts?.grantRegistrationOpName ?? "grant_registration";
33393
- case "data_access":
33394
- return opts?.dataAccessOpName ?? "data_access";
33395
- case "data_registration":
33396
- return opts?.dataRegistrationOpName ?? "data_registration";
33397
- case "server_registration":
33398
- return opts?.serverRegistrationOpName ?? "server_registration";
33399
- case "builder_registration":
33400
- return opts?.builderRegistrationOpName ?? "builder_registration";
33401
- }
33402
- }
33403
- var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
33404
- async function getFee(client, config, kind, opts) {
33405
- const address = config.contracts.feeRegistry;
33406
- const opName = operationNameFor(kind, opts);
33407
- const opKey = await client.readContract({
33408
- address,
33409
- abi: FEE_REGISTRY_ABI,
33410
- functionName: "operationKey",
33411
- args: [opName]
33412
- });
33413
- const fee = await client.readContract({
33414
- address,
33415
- abi: FEE_REGISTRY_ABI,
33416
- functionName: "fees",
33417
- args: [opKey]
33418
- });
33419
- if (fee.enabled && fee.payee === ZERO_ADDRESS) {
33420
- throw new Error(
33421
- `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
33422
- );
33423
- }
33424
- return fee;
33425
- }
33426
- async function getOpFee(client, config, opType, opts) {
33427
- const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
33428
- if (!registrationKind) {
33429
- throw new Error(
33430
- `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
33431
- );
33432
- }
33433
- const includeDataAccess = opType === "grant";
33434
- const [registration, dataAccess] = await Promise.all([
33435
- getFee(client, config, registrationKind, opts),
33436
- includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
33437
- amount: 0n,
33438
- asset: ZERO_ADDRESS,
33439
- payee: ZERO_ADDRESS,
33440
- enabled: false
33441
- })
33442
- ]);
33443
- if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
33444
- throw new Error(
33445
- `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.`
33446
- );
33447
- }
33448
- const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
33449
- return {
33450
- asset,
33451
- registrationFee: registration.enabled ? registration.amount : 0n,
33452
- dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
33453
- registrationEnabled: registration.enabled,
33454
- dataAccessEnabled: dataAccess.enabled,
33455
- registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
33456
- dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
33285
+ grant: input.grant,
33286
+ payload,
33287
+ fileIds: fileIds.display
33457
33288
  };
33458
33289
  }
33459
33290
 
@@ -33527,45 +33358,6 @@ var IngestResponseSchema = import_zod2.z.object({
33527
33358
  status: import_zod2.z.enum(["stored", "syncing"])
33528
33359
  });
33529
33360
 
33530
- // src/protocol/personal-server-data.ts
33531
- function personalServerDataReadPath(scope) {
33532
- return `/v1/data/${encodeURIComponent(scope)}`;
33533
- }
33534
- async function buildPersonalServerDataReadRequest(params) {
33535
- const path = personalServerDataReadPath(params.scope);
33536
- const baseUrl = params.personalServerUrl.replace(/\/+$/, "");
33537
- const audience = params.audience ?? baseUrl;
33538
- const headers = new Headers(params.headers);
33539
- headers.set(
33540
- "Authorization",
33541
- await buildWeb3SignedHeader({
33542
- aud: audience,
33543
- grantId: params.grantId,
33544
- method: "GET",
33545
- signMessage: params.signMessage,
33546
- uri: path
33547
- })
33548
- );
33549
- return new Request(`${baseUrl}${path}`, {
33550
- headers,
33551
- method: "GET"
33552
- });
33553
- }
33554
- async function readPersonalServerData(params) {
33555
- const fetchFn = params.fetch ?? globalThis.fetch;
33556
- if (fetchFn === void 0) {
33557
- throw new Error("No fetch implementation available");
33558
- }
33559
- const request = await buildPersonalServerDataReadRequest(params);
33560
- const response = await fetchFn(request);
33561
- if (!response.ok) {
33562
- throw new Error(
33563
- `Personal Server data read failed: ${response.status} ${response.statusText}`
33564
- );
33565
- }
33566
- return DataFileEnvelopeSchema.parse(await response.json());
33567
- }
33568
-
33569
33361
  // src/protocol/gateway.ts
33570
33362
  function createGatewayClient(baseUrl) {
33571
33363
  const base = baseUrl.replace(/\/+$/, "");
@@ -33573,6 +33365,16 @@ function createGatewayClient(baseUrl) {
33573
33365
  const envelope = await res.json();
33574
33366
  return envelope.data;
33575
33367
  }
33368
+ function normalizeFileRecord(record) {
33369
+ return {
33370
+ fileId: record.fileId ?? record.id ?? "",
33371
+ owner: record.owner ?? record.ownerAddress ?? "",
33372
+ url: record.url,
33373
+ schemaId: record.schemaId,
33374
+ createdAt: record.createdAt ?? record.addedAt ?? "",
33375
+ deletedAt: record.deletedAt ?? null
33376
+ };
33377
+ }
33576
33378
  function getMutationId(body, key) {
33577
33379
  const value = body[key] ?? body["id"];
33578
33380
  return typeof value === "string" ? value : void 0;
@@ -33622,33 +33424,31 @@ function createGatewayClient(baseUrl) {
33622
33424
  }
33623
33425
  return unwrapEnvelope(res);
33624
33426
  },
33625
- async getDataPoint(dataPointId) {
33626
- const res = await fetch(`${base}/v1/data/${dataPointId}`);
33427
+ async getFile(fileId) {
33428
+ const res = await fetch(`${base}/v1/files/${fileId}`);
33627
33429
  if (res.status === 404) return null;
33628
33430
  if (!res.ok) {
33629
33431
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33630
33432
  }
33631
- return unwrapEnvelope(res);
33433
+ return normalizeFileRecord(await unwrapEnvelope(res));
33632
33434
  },
33633
- async listDataPointsByOwner(owner, cursor, options) {
33435
+ async listFilesSince(owner, cursor, options) {
33634
33436
  const params = new URLSearchParams({ user: owner });
33635
33437
  if (cursor !== null) {
33636
33438
  params.set("cursor", cursor);
33637
33439
  }
33638
- if (options?.since) {
33639
- params.set("since", options.since);
33440
+ if (options?.includeDeleted) {
33441
+ params.set("includeDeleted", "true");
33640
33442
  }
33641
- if (options?.limit !== void 0) {
33642
- params.set("limit", String(options.limit));
33643
- }
33644
- const res = await fetch(`${base}/v1/data?${params.toString()}`);
33443
+ const res = await fetch(`${base}/v1/files?${params.toString()}`);
33645
33444
  if (!res.ok) {
33646
33445
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33647
33446
  }
33648
33447
  const envelope = await res.json();
33649
- const nextCursor = envelope.pagination?.hasMore === false ? null : envelope.pagination?.nextCursor ?? null;
33448
+ const { pagination } = envelope;
33449
+ const nextCursor = pagination?.hasMore === false ? null : pagination?.nextCursor ?? envelope.data.cursor ?? null;
33650
33450
  return {
33651
- dataPoints: envelope.data.dataPoints,
33451
+ files: envelope.data.files.map(normalizeFileRecord),
33652
33452
  cursor: nextCursor
33653
33453
  };
33654
33454
  },
@@ -33690,8 +33490,8 @@ function createGatewayClient(baseUrl) {
33690
33490
  alreadyRegistered: false
33691
33491
  };
33692
33492
  },
33693
- async registerBuilder(params) {
33694
- const res = await fetch(`${base}/v1/builders`, {
33493
+ async registerFile(params) {
33494
+ const res = await fetch(`${base}/v1/files`, {
33695
33495
  method: "POST",
33696
33496
  headers: {
33697
33497
  "Content-Type": "application/json",
@@ -33699,57 +33499,22 @@ function createGatewayClient(baseUrl) {
33699
33499
  },
33700
33500
  body: JSON.stringify({
33701
33501
  ownerAddress: params.ownerAddress,
33702
- granteeAddress: params.granteeAddress,
33703
- publicKey: params.publicKey,
33704
- appUrl: params.appUrl
33502
+ url: params.url,
33503
+ schemaId: params.schemaId
33705
33504
  })
33706
33505
  });
33707
33506
  if (res.status === 409) {
33708
33507
  const body2 = await res.json().catch(() => ({}));
33709
33508
  return {
33710
- builderId: getMutationId(
33711
- body2,
33712
- "builderId"
33713
- ),
33714
- alreadyRegistered: true
33509
+ fileId: getMutationId(body2, "fileId")
33715
33510
  };
33716
33511
  }
33717
33512
  if (!res.ok) {
33718
33513
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33719
33514
  }
33720
- const body = await res.json().catch(() => ({}));
33721
- return {
33722
- builderId: getMutationId(body, "builderId"),
33723
- alreadyRegistered: false
33724
- };
33725
- },
33726
- async registerDataPoint(params) {
33727
- const res = await fetch(`${base}/v1/data`, {
33728
- method: "POST",
33729
- headers: {
33730
- "Content-Type": "application/json",
33731
- Authorization: `Web3Signed ${params.signature}`
33732
- },
33733
- body: JSON.stringify({
33734
- ownerAddress: params.ownerAddress,
33735
- scope: params.scope,
33736
- dataHash: params.dataHash,
33737
- metadataHash: params.metadataHash,
33738
- expectedVersion: params.expectedVersion
33739
- })
33740
- });
33741
- if (!res.ok) {
33742
- const body2 = await res.json().catch(() => ({}));
33743
- const detail = body2.error ?? res.statusText;
33744
- throw new Error(`Gateway error: ${res.status} ${detail}`);
33745
- }
33746
- const body = await res.json().catch(() => ({}));
33515
+ const body = await res.json();
33747
33516
  return {
33748
- dataPointId: getMutationId(
33749
- body,
33750
- "dataPointId"
33751
- ),
33752
- expectedVersion: body.expectedVersion
33517
+ fileId: getMutationId(body, "fileId")
33753
33518
  };
33754
33519
  },
33755
33520
  async createGrant(params) {
@@ -33762,9 +33527,8 @@ function createGatewayClient(baseUrl) {
33762
33527
  body: JSON.stringify({
33763
33528
  grantorAddress: params.grantorAddress,
33764
33529
  granteeId: params.granteeId,
33765
- scopes: params.scopes,
33766
- grantVersion: params.grantVersion,
33767
- expiresAt: params.expiresAt
33530
+ grant: params.grant,
33531
+ fileIds: params.fileIds
33768
33532
  })
33769
33533
  });
33770
33534
  if (res.status === 409) {
@@ -33789,8 +33553,7 @@ function createGatewayClient(baseUrl) {
33789
33553
  Authorization: `Web3Signed ${params.signature}`
33790
33554
  },
33791
33555
  body: JSON.stringify({
33792
- grantorAddress: params.grantorAddress,
33793
- grantVersion: params.grantVersion
33556
+ grantorAddress: params.grantorAddress
33794
33557
  })
33795
33558
  });
33796
33559
  if (res.status === 409) return;
@@ -33798,62 +33561,133 @@ function createGatewayClient(baseUrl) {
33798
33561
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33799
33562
  }
33800
33563
  },
33801
- async getEscrowBalance(account) {
33802
- const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
33564
+ async deleteFile(params) {
33565
+ const res = await fetch(`${base}/v1/files/${params.fileId}`, {
33566
+ method: "DELETE",
33567
+ headers: {
33568
+ "Content-Type": "application/json",
33569
+ Authorization: `Web3Signed ${params.signature}`
33570
+ },
33571
+ body: JSON.stringify({
33572
+ ownerAddress: params.ownerAddress
33573
+ })
33574
+ });
33575
+ if (res.status === 409) return;
33803
33576
  if (!res.ok) {
33804
33577
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33805
33578
  }
33806
- return await res.json();
33807
- },
33808
- async submitEscrowDeposit(params) {
33579
+ }
33580
+ };
33581
+ }
33582
+
33583
+ // src/protocol/escrow.ts
33584
+ var GENERIC_PAYMENT_TYPES = {
33585
+ GenericPayment: [
33586
+ { name: "payerAddress", type: "address" },
33587
+ { name: "opType", type: "string" },
33588
+ { name: "opId", type: "bytes32" },
33589
+ { name: "asset", type: "address" },
33590
+ { name: "amount", type: "uint256" },
33591
+ { name: "paymentNonce", type: "uint256" }
33592
+ ]
33593
+ };
33594
+ function genericPaymentDomain(chainId, escrowContract) {
33595
+ return {
33596
+ name: "Vana Data Portability",
33597
+ version: "1",
33598
+ chainId,
33599
+ verifyingContract: escrowContract
33600
+ };
33601
+ }
33602
+ var ESCROW_DEPOSIT_ABI = [
33603
+ {
33604
+ type: "function",
33605
+ name: "depositNative",
33606
+ stateMutability: "payable",
33607
+ inputs: [{ name: "account", type: "address" }],
33608
+ outputs: []
33609
+ },
33610
+ {
33611
+ type: "function",
33612
+ name: "depositToken",
33613
+ stateMutability: "nonpayable",
33614
+ inputs: [
33615
+ { name: "account", type: "address" },
33616
+ { name: "token", type: "address" },
33617
+ { name: "amount", type: "uint256" }
33618
+ ],
33619
+ outputs: []
33620
+ }
33621
+ ];
33622
+ var NATIVE_ASSET_ADDRESS = "0x0000000000000000000000000000000000000000";
33623
+ function createEscrowGatewayClient(baseUrl) {
33624
+ const base = baseUrl.replace(/\/+$/, "");
33625
+ async function throwOnError(res, context) {
33626
+ if (!res.ok) {
33627
+ let detail = "";
33628
+ try {
33629
+ const body = await res.json();
33630
+ if (body.error) detail = `: ${body.error}`;
33631
+ } catch {
33632
+ }
33633
+ throw new Error(
33634
+ `Escrow gateway error (${context}): ${res.status} ${res.statusText}${detail}`
33635
+ );
33636
+ }
33637
+ }
33638
+ return {
33639
+ async submitDeposit({ txHash }) {
33809
33640
  const res = await fetch(`${base}/v1/escrow/deposit`, {
33810
33641
  method: "POST",
33811
33642
  headers: { "Content-Type": "application/json" },
33812
- body: JSON.stringify({ txHash: params.txHash })
33643
+ body: JSON.stringify({ txHash })
33813
33644
  });
33814
33645
  if (res.status !== 200 && res.status !== 202) {
33815
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33646
+ await throwOnError(res, "POST /v1/escrow/deposit");
33816
33647
  }
33817
- return await res.json();
33648
+ return res.json();
33818
33649
  },
33819
- async payForOperation(params) {
33820
- const body = {
33821
- payerAddress: params.payerAddress,
33822
- opType: params.opType,
33823
- opId: params.opId,
33824
- asset: params.asset,
33825
- amount: params.amount,
33826
- paymentNonce: params.paymentNonce
33827
- };
33828
- if (params.accessRecord) {
33829
- body["accessRecord"] = params.accessRecord;
33830
- }
33650
+ async getEscrowBalance(account) {
33651
+ const res = await fetch(
33652
+ `${base}/v1/escrow/balance?account=${encodeURIComponent(account)}`
33653
+ );
33654
+ await throwOnError(res, "GET /v1/escrow/balance");
33655
+ return res.json();
33656
+ },
33657
+ async syncEscrowBalance(account) {
33658
+ const res = await fetch(
33659
+ `${base}/v1/escrow/balance/sync?account=${encodeURIComponent(account)}`,
33660
+ { method: "POST" }
33661
+ );
33662
+ await throwOnError(res, "POST /v1/escrow/balance/sync");
33663
+ return res.json();
33664
+ },
33665
+ async payForOp({
33666
+ payerAddress,
33667
+ opType,
33668
+ opId,
33669
+ asset,
33670
+ amount,
33671
+ paymentNonce,
33672
+ signature
33673
+ }) {
33831
33674
  const res = await fetch(`${base}/v1/escrow/pay`, {
33832
33675
  method: "POST",
33833
33676
  headers: {
33834
33677
  "Content-Type": "application/json",
33835
- Authorization: `Web3Signed ${params.signature}`
33678
+ Authorization: `Web3Signed ${signature}`
33836
33679
  },
33837
- body: JSON.stringify(body)
33838
- });
33839
- if (!res.ok) {
33840
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33841
- }
33842
- return await res.json();
33843
- },
33844
- async settle(params) {
33845
- const res = await fetch(`${base}/v1/settle`, {
33846
- method: "POST",
33847
- headers: { "Content-Type": "application/json" },
33848
- // The gateway accepts an empty body; only `limit` is recognised.
33849
- // Always send a JSON body so the gateway's req.body shape parse
33850
- // doesn't have to deal with an undefined.
33851
- body: JSON.stringify(params ?? {})
33680
+ body: JSON.stringify({
33681
+ payerAddress,
33682
+ opType,
33683
+ opId,
33684
+ asset,
33685
+ amount,
33686
+ paymentNonce
33687
+ })
33852
33688
  });
33853
- if (!res.ok) {
33854
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
33855
- }
33856
- return await res.json();
33689
+ await throwOnError(res, "POST /v1/escrow/pay");
33690
+ return res.json();
33857
33691
  }
33858
33692
  };
33859
33693
  }
@@ -33923,7 +33757,6 @@ async function parsePSError(response) {
33923
33757
  // Annotate the CommonJS export names for ESM import in node:
33924
33758
  0 && (module.exports = {
33925
33759
  ACCOUNT_PERSONAL_SERVER_REGISTRATION_INTENT,
33926
- ADD_DATA_TYPES,
33927
33760
  AccountPersonalServerLiteOwnerBindingError,
33928
33761
  AccountPersonalServerRegistrationError,
33929
33762
  BUILDER_REGISTRATION_TYPES,
@@ -33933,14 +33766,13 @@ async function parsePSError(response) {
33933
33766
  CallbackStorage,
33934
33767
  ContractFactory,
33935
33768
  ContractNotFoundError,
33936
- DATA_REGISTRY_STATUS_ABI,
33937
33769
  DataFileEnvelopeSchema,
33938
- DataPointStatus,
33939
33770
  DropboxStorage,
33940
33771
  ECIESError,
33941
33772
  ESCROW_DEPOSIT_ABI,
33942
33773
  ExpiredTokenError,
33943
- FEE_REGISTRY_ABI,
33774
+ FILE_DELETION_TYPES,
33775
+ FILE_REGISTRATION_TYPES,
33944
33776
  GENERIC_PAYMENT_TYPES,
33945
33777
  GRANT_REGISTRATION_TYPES,
33946
33778
  GRANT_REVOCATION_TYPES,
@@ -33952,7 +33784,7 @@ async function parsePSError(response) {
33952
33784
  IpfsStorage,
33953
33785
  MASTER_KEY_MESSAGE,
33954
33786
  MissingAuthError,
33955
- NATIVE_VANA_ASSET,
33787
+ NATIVE_ASSET_ADDRESS,
33956
33788
  NetworkError,
33957
33789
  NodeECIESProvider,
33958
33790
  NodePlatformAdapter,
@@ -33970,8 +33802,6 @@ async function parsePSError(response) {
33970
33802
  PersonalServerError,
33971
33803
  PinataStorage,
33972
33804
  R2Storage,
33973
- RECORD_DATA_ACCESS_TYPES,
33974
- REGISTRATION_KIND_FOR_OP,
33975
33805
  ReadOnlyError,
33976
33806
  RelayerError,
33977
33807
  SERVER_REGISTRATION_TYPES,
@@ -33986,15 +33816,10 @@ async function parsePSError(response) {
33986
33816
  VanaError,
33987
33817
  VanaStorage,
33988
33818
  assertValidPkceVerifier,
33989
- buildDepositNativeRequest,
33990
- buildDepositTokenRequest,
33991
- buildMarkDataPointUnavailableRequest,
33992
- buildPersonalServerDataReadRequest,
33993
33819
  buildPersonalServerLiteOwnerBindingMessage,
33994
33820
  buildPersonalServerLiteOwnerBindingSignature,
33995
33821
  buildPersonalServerRegistrationSignature,
33996
33822
  buildPersonalServerRegistrationTypedData,
33997
- buildSetDataPointStatusRequest,
33998
33823
  buildWeb3SignedHeader,
33999
33824
  builderRegistrationDomain,
34000
33825
  chains,
@@ -34004,6 +33829,7 @@ async function parsePSError(response) {
34004
33829
  contractCacheForTesting,
34005
33830
  createBrowserPlatformAdapter,
34006
33831
  createDataFileEnvelope,
33832
+ createEscrowGatewayClient,
34007
33833
  createGatewayClient,
34008
33834
  createNodePlatformAdapter,
34009
33835
  createPlatformAdapter,
@@ -34012,28 +33838,22 @@ async function parsePSError(response) {
34012
33838
  createVanaStorageProvider,
34013
33839
  createViemPersonalServerLiteOwnerBindingSigner,
34014
33840
  createViemPersonalServerRegistrationSigner,
34015
- dataRegistryContractAddress,
34016
- dataRegistryDomain,
34017
33841
  decryptWithPassword,
34018
33842
  deriveMasterKey,
34019
33843
  deriveScopeKey,
34020
33844
  deserializeECIES,
34021
33845
  detectPlatform,
34022
- encodeDepositNativeData,
34023
- encodeDepositTokenData,
34024
- encodeSetDataPointStatusData,
34025
33846
  encryptWithPassword,
34026
- escrowContractAddress,
34027
- escrowPaymentDomain,
33847
+ fileDeletionDomain,
33848
+ fileRegistrationDomain,
34028
33849
  generatePkceVerifier,
33850
+ genericPaymentDomain,
34029
33851
  getAbi,
34030
33852
  getAllChains,
34031
33853
  getChainConfig,
34032
33854
  getContractAddress,
34033
33855
  getContractController,
34034
33856
  getContractInfo,
34035
- getFee,
34036
- getOpFee,
34037
33857
  getPlatformCapabilities,
34038
33858
  getServiceEndpoints,
34039
33859
  grantRegistrationDomain,
@@ -34045,12 +33865,11 @@ async function parsePSError(response) {
34045
33865
  moksha,
34046
33866
  mokshaServices,
34047
33867
  mokshaTestnet,
33868
+ parseGrantRegistrationPayload,
34048
33869
  parsePSError,
34049
33870
  parseScope,
34050
33871
  parseWeb3SignedHeader,
34051
- personalServerDataReadPath,
34052
33872
  personalServerRegistrationDomain,
34053
- readPersonalServerData,
34054
33873
  recoverServerOwner,
34055
33874
  registerPersonalServerSignature,
34056
33875
  scopeCoveredByGrant,