@opendatalabs/vana-sdk 3.13.0 → 3.13.2

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.
@@ -29204,6 +29204,21 @@ async function buildWeb3SignedHeader(params) {
29204
29204
  return `Web3Signed ${payloadBase64}.${signature}`;
29205
29205
  }
29206
29206
 
29207
+ // src/protocol/networks.ts
29208
+ var PROTOCOL_NETWORK_CHAIN_IDS = {
29209
+ mainnet: 1480,
29210
+ moksha: 14800
29211
+ };
29212
+ function isProtocolNetwork(value) {
29213
+ return typeof value === "string" && Object.hasOwn(PROTOCOL_NETWORK_CHAIN_IDS, value);
29214
+ }
29215
+ function getProtocolNetworkChainId(network) {
29216
+ if (!isProtocolNetwork(network)) {
29217
+ throw new Error(`Unsupported Vana protocol network: ${String(network)}`);
29218
+ }
29219
+ return PROTOCOL_NETWORK_CHAIN_IDS[network];
29220
+ }
29221
+
29207
29222
  // src/storage/providers/vana-storage.ts
29208
29223
  var DEFAULT_ENDPOINT = "https://storage.vana.org";
29209
29224
  var LEGACY_BLOB_PATH_PREFIX = "/v1/blobs";
@@ -29212,6 +29227,7 @@ var MAX_UPLOAD_ATTEMPTS = 4;
29212
29227
  var MAX_RATE_LIMIT_DELAY_MS = 3e4;
29213
29228
  var VanaStorage = class {
29214
29229
  endpoint;
29230
+ network;
29215
29231
  chainId;
29216
29232
  blobPathPrefix;
29217
29233
  signer;
@@ -29226,14 +29242,9 @@ var VanaStorage = class {
29226
29242
  );
29227
29243
  }
29228
29244
  this.endpoint = (config.endpoint ?? DEFAULT_ENDPOINT).replace(/\/+$/, "");
29229
- if (config.chainId !== void 0 && !isValidChainId(config.chainId)) {
29230
- throw new StorageError(
29231
- `Unsupported vana-storage chainId '${String(config.chainId)}'`,
29232
- "INVALID_CHAIN_ID",
29233
- "vana-storage"
29234
- );
29235
- }
29236
- this.chainId = config.chainId;
29245
+ const resolved = resolveStorageNamespace(config);
29246
+ this.network = resolved.network;
29247
+ this.chainId = resolved.chainId;
29237
29248
  this.blobPathPrefix = this.chainId !== void 0 ? `/v1/chains/${this.chainId}/blobs` : LEGACY_BLOB_PATH_PREFIX;
29238
29249
  this.signer = config.signer;
29239
29250
  this.ownerAddress = (config.ownerAddress ?? config.signer.address).toLowerCase();
@@ -29433,17 +29444,51 @@ var VanaStorage = class {
29433
29444
  }
29434
29445
  if (route.chainId !== this.chainId) {
29435
29446
  throw new StorageError(
29436
- `URL chainId '${route.chainId ?? "legacy"}' does not match provider chainId '${this.chainId ?? "legacy"}'`,
29447
+ `URL chainId '${route.chainId ?? "legacy"}' does not match provider namespace '${this.namespaceDescription()}'`,
29437
29448
  "INVALID_URL",
29438
29449
  "vana-storage"
29439
29450
  );
29440
29451
  }
29441
29452
  return parsed.pathname;
29442
29453
  }
29454
+ namespaceDescription() {
29455
+ if (this.network !== void 0) {
29456
+ return `${this.network} (${this.chainId})`;
29457
+ }
29458
+ return this.chainId === void 0 ? "legacy" : String(this.chainId);
29459
+ }
29443
29460
  };
29444
29461
  function isValidChainId(value) {
29445
29462
  return typeof value === "number" && Number.isInteger(value) && value > 0;
29446
29463
  }
29464
+ function resolveStorageNamespace(config) {
29465
+ if (config.network !== void 0 && !isProtocolNetwork(config.network)) {
29466
+ throw new StorageError(
29467
+ `Unsupported vana-storage network '${String(config.network)}'`,
29468
+ "INVALID_NETWORK",
29469
+ "vana-storage"
29470
+ );
29471
+ }
29472
+ if (config.chainId !== void 0 && !isValidChainId(config.chainId)) {
29473
+ throw new StorageError(
29474
+ `Unsupported vana-storage chainId '${String(config.chainId)}'`,
29475
+ "INVALID_CHAIN_ID",
29476
+ "vana-storage"
29477
+ );
29478
+ }
29479
+ if (config.network === void 0) {
29480
+ return { chainId: config.chainId };
29481
+ }
29482
+ const networkChainId = getProtocolNetworkChainId(config.network);
29483
+ if (config.chainId !== void 0 && config.chainId !== networkChainId) {
29484
+ throw new StorageError(
29485
+ `vana-storage network '${config.network}' resolves to chainId '${networkChainId}', not '${config.chainId}'`,
29486
+ "INVALID_CHAIN_ID",
29487
+ "vana-storage"
29488
+ );
29489
+ }
29490
+ return { chainId: networkChainId, network: config.network };
29491
+ }
29447
29492
  function parseBlobPath(pathname) {
29448
29493
  const segments = pathname.split("/").filter((s) => s.length > 0);
29449
29494
  const isTraversal = (s) => s === "." || s === "..";