@xyo-network/xl1-protocol-sdk 2.1.7 → 2.1.9

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 (36) hide show
  1. package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts +26 -5
  2. package/dist/neutral/CreatableProvider/AbstractCreatableProvider.d.ts.map +1 -1
  3. package/dist/neutral/config/Actor.d.ts +156 -30
  4. package/dist/neutral/config/Actor.d.ts.map +1 -1
  5. package/dist/neutral/config/Actors.d.ts +26 -5
  6. package/dist/neutral/config/Actors.d.ts.map +1 -1
  7. package/dist/neutral/config/Base.d.ts +26 -5
  8. package/dist/neutral/config/Base.d.ts.map +1 -1
  9. package/dist/neutral/config/Config.d.ts +104 -20
  10. package/dist/neutral/config/Config.d.ts.map +1 -1
  11. package/dist/neutral/config/HostActor.d.ts +156 -30
  12. package/dist/neutral/config/HostActor.d.ts.map +1 -1
  13. package/dist/neutral/config/index.d.ts +2 -1
  14. package/dist/neutral/config/index.d.ts.map +1 -1
  15. package/dist/neutral/config/storage/Storage.d.ts +26 -5
  16. package/dist/neutral/config/storage/Storage.d.ts.map +1 -1
  17. package/dist/neutral/config/storage/driver/S3.d.ts +77 -0
  18. package/dist/neutral/config/storage/driver/S3.d.ts.map +1 -0
  19. package/dist/neutral/config/storage/driver/index.d.ts +1 -1
  20. package/dist/neutral/context/Actor.d.ts +156 -30
  21. package/dist/neutral/context/Actor.d.ts.map +1 -1
  22. package/dist/neutral/context/HostActor.d.ts +156 -30
  23. package/dist/neutral/context/HostActor.d.ts.map +1 -1
  24. package/dist/neutral/getFileConfig.d.ts +52 -10
  25. package/dist/neutral/getFileConfig.d.ts.map +1 -1
  26. package/dist/neutral/getFileConfig.mjs +36 -56
  27. package/dist/neutral/getFileConfig.mjs.map +4 -4
  28. package/dist/neutral/index.mjs +71 -74
  29. package/dist/neutral/index.mjs.map +4 -4
  30. package/dist/neutral/model/CreatableProviderContext.zod.d.ts +156 -30
  31. package/dist/neutral/model/CreatableProviderContext.zod.d.ts.map +1 -1
  32. package/dist/neutral/test/index.mjs +40 -60
  33. package/dist/neutral/test/index.mjs.map +4 -4
  34. package/package.json +14 -14
  35. package/dist/neutral/config/storage/driver/R2.d.ts +0 -27
  36. package/dist/neutral/config/storage/driver/R2.d.ts.map +0 -1
@@ -1162,7 +1162,7 @@ import {
1162
1162
  zodIsFactory as zodIsFactory2,
1163
1163
  zodToFactory as zodToFactory2
1164
1164
  } from "@xylabs/sdk-js";
1165
- import { globalRegistry as globalRegistry13, z as z18 } from "zod/mini";
1165
+ import { globalRegistry as globalRegistry12, z as z18 } from "zod/mini";
1166
1166
 
1167
1167
  // src/config/Base.ts
1168
1168
  import { z as z17 } from "zod/mini";
@@ -1370,65 +1370,61 @@ var MongoConfigZod = z12.object({
1370
1370
  })
1371
1371
  });
1372
1372
 
1373
- // src/config/storage/driver/R2.ts
1374
- import { isDefined as isDefined5, isUndefined as isUndefined6 } from "@xylabs/sdk-js";
1375
- import { globalRegistry as globalRegistry9, z as z13 } from "zod";
1376
- var hasR2Config = (config) => {
1377
- if (isUndefined6(config)) return false;
1378
- return isDefined5(config.accountId) && isDefined5(config.accessKeyId) && isDefined5(config.secretAccessKey) && isDefined5(config.bucket);
1379
- };
1380
- var R2ConfigZod = z13.object({
1381
- accessKeyId: z13.string().nonempty().optional().register(globalRegistry9, {
1382
- description: "Cloudflare R2 access key id (from an R2 API token)",
1383
- title: "storage.r2.accessKeyId",
1384
- type: "string"
1385
- }),
1386
- accountId: z13.string().nonempty().optional().register(globalRegistry9, {
1387
- description: "Cloudflare account id; determines the R2 endpoint https://<accountId>.r2.cloudflarestorage.com",
1388
- title: "storage.r2.accountId",
1389
- type: "string"
1390
- }),
1391
- bucket: z13.string().nonempty().optional().register(globalRegistry9, {
1392
- description: "Cloudflare R2 bucket name",
1393
- title: "storage.r2.bucket",
1394
- type: "string"
1395
- }),
1396
- chainStateBucket: z13.string().nonempty().optional().register(globalRegistry9, {
1397
- description: "Cloudflare R2 bucket for the mutable chain state (the head pointer); defaults to `bucket` when unset",
1398
- title: "storage.r2.chainStateBucket",
1399
- type: "string"
1400
- }),
1401
- indexBucket: z13.string().nonempty().optional().register(globalRegistry9, {
1402
- description: "Cloudflare R2 bucket for the chain index (the step-summary families); defaults to `bucket` when unset",
1403
- title: "storage.r2.indexBucket",
1404
- type: "string"
1405
- }),
1406
- prefix: z13.string().nonempty().optional().register(globalRegistry9, {
1407
- description: "Optional key prefix namespacing this store within the bucket",
1408
- title: "storage.r2.prefix",
1409
- type: "string"
1410
- }),
1411
- secretAccessKey: z13.string().nonempty().optional().register(globalRegistry9, {
1412
- description: "Cloudflare R2 secret access key (from an R2 API token)",
1413
- title: "storage.r2.secretAccessKey",
1414
- type: "string"
1415
- })
1373
+ // src/config/storage/driver/S3.ts
1374
+ import { isDefined as isDefined5 } from "@xylabs/sdk-js";
1375
+ import { z as z13 } from "zod";
1376
+ var S3BucketConfigZod = z13.object({
1377
+ accessKeyId: z13.string().nonempty().optional().describe("S3-compatible access key id for this bucket (overrides the shared default)"),
1378
+ accountId: z13.string().nonempty().optional().describe("Account id for this bucket; on Cloudflare R2 it forms the endpoint (overrides the shared default)"),
1379
+ bucket: z13.string().nonempty().optional().describe("S3-compatible bucket name"),
1380
+ prefix: z13.string().nonempty().optional().describe("Optional key prefix within the bucket"),
1381
+ readUrl: z13.string().nonempty().optional().describe("Public HTTP/CDN base URL for anonymous reads of this bucket"),
1382
+ secretAccessKey: z13.string().nonempty().optional().describe("S3-compatible secret access key for this bucket (overrides the shared default)")
1383
+ });
1384
+ var S3ConfigZod = z13.object({
1385
+ accessKeyId: z13.string().nonempty().optional().describe("Shared S3-compatible access key id (default for all buckets)"),
1386
+ accountId: z13.string().nonempty().optional().describe("Shared account id (default for all buckets; on Cloudflare R2 it forms the endpoint)"),
1387
+ chainState: S3BucketConfigZod.optional().describe("Bucket for the mutable chain state (the head pointer)"),
1388
+ finalized: S3BucketConfigZod.optional().describe("Bucket for the finalized files (blocks, payloads, manifest)"),
1389
+ index: S3BucketConfigZod.optional().describe("Bucket for the chain index (the step-summary families)"),
1390
+ prefix: z13.string().nonempty().optional().describe("Shared key prefix (default for all buckets)"),
1391
+ secretAccessKey: z13.string().nonempty().optional().describe("Shared S3-compatible secret access key (default for all buckets)")
1416
1392
  });
1393
+ function resolveS3Bucket(config, which) {
1394
+ if (config === void 0) return void 0;
1395
+ const entry = config[which];
1396
+ const accessKeyId = entry?.accessKeyId ?? config.accessKeyId;
1397
+ const accountId = entry?.accountId ?? config.accountId;
1398
+ const secretAccessKey = entry?.secretAccessKey ?? config.secretAccessKey;
1399
+ const bucket = entry?.bucket ?? config.finalized?.bucket;
1400
+ if (!isDefined5(accessKeyId) || !isDefined5(accountId) || !isDefined5(secretAccessKey) || !isDefined5(bucket)) return void 0;
1401
+ return {
1402
+ accessKeyId,
1403
+ accountId,
1404
+ bucket,
1405
+ prefix: entry?.prefix ?? config.prefix,
1406
+ readUrl: entry?.readUrl,
1407
+ secretAccessKey
1408
+ };
1409
+ }
1410
+ function hasS3Config(config, which = "finalized") {
1411
+ return resolveS3Bucket(config, which) !== void 0;
1412
+ }
1417
1413
 
1418
1414
  // src/config/storage/Storage.ts
1419
- import { globalRegistry as globalRegistry10, z as z14 } from "zod";
1415
+ import { globalRegistry as globalRegistry9, z as z14 } from "zod";
1420
1416
  var StorageConfigZod = z14.object({
1421
1417
  mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
1422
- r2: R2ConfigZod.optional().describe("Configuration for the Cloudflare R2 storage driver"),
1423
- root: z14.string().optional().register(globalRegistry10, {
1418
+ root: z14.string().optional().register(globalRegistry9, {
1424
1419
  description: "Root directory for local storage",
1425
1420
  title: "storage.root",
1426
1421
  type: "string"
1427
- })
1422
+ }),
1423
+ s3: S3ConfigZod.optional().describe("Configuration for S3-compatible object storage (e.g. Cloudflare R2)")
1428
1424
  }).describe("Storage configuration options");
1429
1425
 
1430
1426
  // src/config/Telemetry.ts
1431
- import { globalRegistry as globalRegistry11, z as z15 } from "zod";
1427
+ import { globalRegistry as globalRegistry10, z as z15 } from "zod";
1432
1428
  var DefaultMetricsScrapePorts = {
1433
1429
  api: 9465,
1434
1430
  bridge: 9468,
@@ -1437,13 +1433,13 @@ var DefaultMetricsScrapePorts = {
1437
1433
  rewardRedemptionApi: 9467
1438
1434
  };
1439
1435
  var MetricsScrapeConfigZod = z15.object({
1440
- path: z15.string().default("/metrics").register(globalRegistry11, {
1436
+ path: z15.string().default("/metrics").register(globalRegistry10, {
1441
1437
  default: "/metrics",
1442
1438
  description: "Path for the metrics scrape endpoint",
1443
1439
  title: "telemetry.metrics.scrape.path",
1444
1440
  type: "string"
1445
1441
  }),
1446
- port: z15.coerce.number().int().positive().optional().register(globalRegistry11, {
1442
+ port: z15.coerce.number().int().positive().optional().register(globalRegistry10, {
1447
1443
  description: "Port for the metrics scrape endpoint",
1448
1444
  title: "telemetry.metrics.scrape.port",
1449
1445
  type: "number"
@@ -1452,7 +1448,7 @@ var MetricsScrapeConfigZod = z15.object({
1452
1448
  var MetricsConfigZod = z15.object({ scrape: MetricsScrapeConfigZod }).describe("Metrics configuration options");
1453
1449
  var OpenTelemetryConfigZod = z15.object({
1454
1450
  // OpenTelemetry options
1455
- otlpEndpoint: z15.url().optional().register(globalRegistry11, {
1451
+ otlpEndpoint: z15.url().optional().register(globalRegistry10, {
1456
1452
  description: "OTLP endpoint for exporting telemetry data",
1457
1453
  title: "telemetry.otel.otlpEndpoint",
1458
1454
  type: "string"
@@ -1467,7 +1463,7 @@ var TelemetryConfigZod = z15.object({
1467
1463
 
1468
1464
  // src/config/Validation.ts
1469
1465
  import { XyoAddressZod as XyoAddressZod2 } from "@xyo-network/address";
1470
- import { globalRegistry as globalRegistry12, z as z16 } from "zod";
1466
+ import { globalRegistry as globalRegistry11, z as z16 } from "zod";
1471
1467
 
1472
1468
  // src/primitives/block/range/blockRangeSteps.ts
1473
1469
  import { asXL1BlockNumber as asXL1BlockNumber2, StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol-lib";
@@ -2101,7 +2097,7 @@ async function activeStakeAtTimeByAddress(chain, staked, time, staker) {
2101
2097
  }
2102
2098
 
2103
2099
  // src/primitives/stake/activeStakeAtTimeByPosition.ts
2104
- import { isUndefined as isUndefined7 } from "@xylabs/sdk-js";
2100
+ import { isUndefined as isUndefined6 } from "@xylabs/sdk-js";
2105
2101
 
2106
2102
  // src/primitives/stake/mergedAddRemoveStakeEventsByPosition.ts
2107
2103
  async function mergedAddRemoveStakeEventsByPosition(chainEvents, range, position) {
@@ -2119,7 +2115,7 @@ async function activeStakeAtTimeByPosition(chainStakeEvents, externalTime, posit
2119
2115
  let result = 0n;
2120
2116
  for (const event of stakeEvents) {
2121
2117
  if (event.time > externalTime) break;
2122
- if (isUndefined7(position) || position === Number(event.args.id)) {
2118
+ if (isUndefined6(position) || position === Number(event.args.id)) {
2123
2119
  if (event.name === "StakeAdded") {
2124
2120
  result += event.args.amount;
2125
2121
  } else if (event.name === "StakeRemoved") {
@@ -2367,23 +2363,23 @@ function findUncles(context, finalizedWindowedChain, blocks) {
2367
2363
 
2368
2364
  // src/config/Validation.ts
2369
2365
  var ValidationConfigZod = z16.object({
2370
- allowedRewardRedeemers: z16.array(XyoAddressZod2).optional().register(globalRegistry12, {
2366
+ allowedRewardRedeemers: z16.array(XyoAddressZod2).optional().register(globalRegistry11, {
2371
2367
  description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
2372
2368
  title: "allowedRewardRedeemers",
2373
2369
  type: "array"
2374
2370
  }),
2375
- allowedRewardEscrowAccountSigners: z16.array(XyoAddressZod2).optional().register(globalRegistry12, {
2371
+ allowedRewardEscrowAccountSigners: z16.array(XyoAddressZod2).optional().register(globalRegistry11, {
2376
2372
  description: "List of allowed reward escrow account signer addresses, if undefined anyone can participate",
2377
2373
  title: "allowedRewardEscrowAccountSigners",
2378
2374
  type: "array"
2379
2375
  }),
2380
- minCandidates: z16.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry12, {
2376
+ minCandidates: z16.coerce.number().default(DEFAULT_MIN_CANDIDATES).register(globalRegistry11, {
2381
2377
  default: DEFAULT_MIN_CANDIDATES,
2382
2378
  description: "Minimum number of uncle candidates before selecting the best uncle",
2383
2379
  title: "validation.minCandidates",
2384
2380
  type: "number"
2385
2381
  }),
2386
- backoffMs: z16.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry12, {
2382
+ backoffMs: z16.coerce.number().default(DEFAULT_BACKOFF_MS).register(globalRegistry11, {
2387
2383
  default: DEFAULT_BACKOFF_MS,
2388
2384
  description: "Back-off timeout in ms. If head age exceeds this, minCandidates is ignored",
2389
2385
  title: "validation.backoffMs",
@@ -2411,7 +2407,7 @@ var AccountPathZod = z18.string().check(z18.regex(
2411
2407
  ));
2412
2408
  var ActorConfigZod = z18.extend(BaseConfigZod, {
2413
2409
  name: z18.string(),
2414
- accountPath: z18.optional(AccountPathZod).register(globalRegistry13, {
2410
+ accountPath: z18.optional(AccountPathZod).register(globalRegistry12, {
2415
2411
  description: 'BIP-32 derivation path for the actor wallet. Absolute when it starts with "m/"; otherwise relative to the root wallet base path. Each actor must derive to a distinct path.',
2416
2412
  title: "accountPath",
2417
2413
  type: "string"
@@ -2429,10 +2425,10 @@ var ActorsConfigZod = z19._default(
2429
2425
  );
2430
2426
 
2431
2427
  // src/config/Config.ts
2432
- import { globalRegistry as globalRegistry14, z as z20 } from "zod/mini";
2428
+ import { globalRegistry as globalRegistry13, z as z20 } from "zod/mini";
2433
2429
  var ConfigZod = z20.extend(BaseConfigZod, {
2434
2430
  actors: ActorsConfigZod,
2435
- healthCheckPort: z20.optional(z20.coerce.number()).register(globalRegistry14, {
2431
+ healthCheckPort: z20.optional(z20.coerce.number()).register(globalRegistry13, {
2436
2432
  description: "Port for the system-wide health, readiness, and liveness endpoints (/healthz, /livez, /readyz). Set to 0 to disable.",
2437
2433
  title: "healthCheckPort",
2438
2434
  type: "number"
@@ -2457,15 +2453,15 @@ import {
2457
2453
  zodIsFactory as zodIsFactory3,
2458
2454
  zodToFactory as zodToFactory3
2459
2455
  } from "@xylabs/sdk-js";
2460
- import { globalRegistry as globalRegistry15, z as z21 } from "zod/mini";
2456
+ import { globalRegistry as globalRegistry14, z as z21 } from "zod/mini";
2461
2457
  var HostActorConfigZod = z21.extend(ActorConfigZod, {
2462
- host: z21._default(z21.string(), "localhost").register(globalRegistry15, {
2458
+ host: z21._default(z21.string(), "localhost").register(globalRegistry14, {
2463
2459
  default: "localhost",
2464
2460
  description: "Host for the Actor",
2465
2461
  title: "host",
2466
2462
  type: "string"
2467
2463
  }),
2468
- port: z21._default(z21.coerce.number(), 8080).register(globalRegistry15, {
2464
+ port: z21._default(z21.coerce.number(), 8080).register(globalRegistry14, {
2469
2465
  default: 8080,
2470
2466
  description: "Port for the Actor",
2471
2467
  title: "port",
@@ -3492,7 +3488,7 @@ var signEIP712Message = async (signer, data) => {
3492
3488
  };
3493
3489
 
3494
3490
  // src/eip-712/verify.ts
3495
- import { asHash as asHash3, isUndefined as isUndefined8 } from "@xylabs/sdk-js";
3491
+ import { asHash as asHash3, isUndefined as isUndefined7 } from "@xylabs/sdk-js";
3496
3492
  import { PayloadBuilder as PayloadBuilder16 } from "@xyo-network/sdk-js";
3497
3493
  import { verifyTypedData } from "ethers";
3498
3494
  var verifyEIP712Message = async (data, sig) => {
@@ -3503,7 +3499,7 @@ var verifyEIP712Message = async (data, sig) => {
3503
3499
  } = sig;
3504
3500
  const { schema, ...fields } = data;
3505
3501
  const signedHash = asHash3(hash);
3506
- if (isUndefined8(signedHash) || signedHash !== await PayloadBuilder16.hash(data)) return false;
3502
+ if (isUndefined7(signedHash) || signedHash !== await PayloadBuilder16.hash(data)) return false;
3507
3503
  const recoveredAddress = verifyTypedData(fields.domain, fields.types, fields.values, signature);
3508
3504
  return recoveredAddress.toLowerCase() === address.toLowerCase();
3509
3505
  };
@@ -4232,7 +4228,7 @@ SimpleAccountBalanceViewer = __decorateClass([
4232
4228
  import {
4233
4229
  assertEx as assertEx34,
4234
4230
  exists as exists4,
4235
- isUndefined as isUndefined9
4231
+ isUndefined as isUndefined8
4236
4232
  } from "@xylabs/sdk-js";
4237
4233
  import { LruCacheMap as LruCacheMap2 } from "@xyo-network/xl1-driver-memory";
4238
4234
  import {
@@ -4344,7 +4340,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4344
4340
  async blockByNumber(blockNumber) {
4345
4341
  return await this.spanAsync("blockByNumber", async () => {
4346
4342
  const chainContext = await this.getChainContextRead();
4347
- if (isUndefined9(chainContext.head)) {
4343
+ if (isUndefined8(chainContext.head)) {
4348
4344
  return null;
4349
4345
  }
4350
4346
  return await this.blockByNumberWithContext(chainContext, blockNumber);
@@ -4370,7 +4366,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4370
4366
  assertEx34(limit > 0, () => "limit must be greater than 0");
4371
4367
  assertEx34(limit <= 100, () => "limit must be less than 100");
4372
4368
  const chainContext = await this.getChainContextRead();
4373
- if (isUndefined9(chainContext.head)) {
4369
+ if (isUndefined8(chainContext.head)) {
4374
4370
  return [];
4375
4371
  }
4376
4372
  const blocks = [];
@@ -4393,7 +4389,7 @@ var SimpleBlockViewer = class extends AbstractCreatableProvider {
4393
4389
  () => `blocksByStep does not support step levels above ${blocksMaxStep} (requested ${stepLevel})`
4394
4390
  );
4395
4391
  const chainContext = await this.getChainContextRead();
4396
- if (isUndefined9(chainContext.head)) {
4392
+ if (isUndefined8(chainContext.head)) {
4397
4393
  return [];
4398
4394
  }
4399
4395
  const start = stepIndex * size;
@@ -5805,7 +5801,7 @@ function deduplicateWithBundleBySigner(items) {
5805
5801
  }
5806
5802
 
5807
5803
  // src/simple/network/SimpleXyoNetwork.ts
5808
- import { fetchJsonGet, isUndefined as isUndefined10 } from "@xylabs/sdk-js";
5804
+ import { fetchJsonGet, isUndefined as isUndefined9 } from "@xylabs/sdk-js";
5809
5805
  import { isNetworkStatus } from "@xyo-network/xl1-protocol-lib";
5810
5806
 
5811
5807
  // src/simple/network/lib/FailedNetworkStatusPayloads.ts
@@ -5853,7 +5849,7 @@ var SimpleXyoNetwork = class {
5853
5849
  }
5854
5850
  async status() {
5855
5851
  const statusNetwork = StatusNetworks[this._networkId];
5856
- if (isUndefined10(statusNetwork)) {
5852
+ if (isUndefined9(statusNetwork)) {
5857
5853
  throw new Error(`Unknown status network ID: ${this._networkId}`);
5858
5854
  }
5859
5855
  return await this.makeRequest(statusNetwork.statusUrl);
@@ -7568,7 +7564,7 @@ export {
7568
7564
  getWindowedChain,
7569
7565
  hasLabels,
7570
7566
  hasMongoConfig,
7571
- hasR2Config,
7567
+ hasS3Config,
7572
7568
  hashFromBlockNumber,
7573
7569
  hydrateBlock,
7574
7570
  hydrateElevatedTransaction,
@@ -7622,6 +7618,7 @@ export {
7622
7618
  registerCreatableProviderFactory,
7623
7619
  resolveConfig,
7624
7620
  resolveProviders,
7621
+ resolveS3Bucket,
7625
7622
  rewardFromBlockNumber,
7626
7623
  schemasMaxStep,
7627
7624
  schemasStepSummaryFromRange,