@capxul/mcp 2.3.1 → 2.4.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 (2) hide show
  1. package/dist/main.mjs +276 -248
  2. package/package.json +5 -5
package/dist/main.mjs CHANGED
@@ -240,7 +240,7 @@ function normalizeEmail(email) {
240
240
  }
241
241
  //#endregion
242
242
  //#region package.json
243
- var version$2 = "2.3.1";
243
+ var version$2 = "2.4.0";
244
244
  //#endregion
245
245
  //#region ../../packages/errors/src/errors.ts
246
246
  const CAPXUL_ERROR_CODES = [
@@ -2554,7 +2554,8 @@ const EngineeringTelemetryBootstrapPolicy = Schema.Struct({
2554
2554
  capxulEnv: Schema.Union([
2555
2555
  Schema.Literal("development"),
2556
2556
  Schema.Literal("staging"),
2557
- Schema.Literal("production")
2557
+ Schema.Literal("production"),
2558
+ Schema.Literal("local")
2558
2559
  ])
2559
2560
  });
2560
2561
  /**
@@ -2645,7 +2646,8 @@ const CAPXUL_FUNCTIONS = {
2645
2646
  "movement/activity": {
2646
2647
  annotate: "movement/activity:annotate",
2647
2648
  get: "movement/activity:get",
2648
- list: "movement/activity:list"
2649
+ list: "movement/activity:list",
2650
+ summary: "movement/activity:summary"
2649
2651
  },
2650
2652
  "moneyExecution/actions": {
2651
2653
  preparePermissionExecution: "moneyExecution/actions:preparePermissionExecution",
@@ -3047,8 +3049,8 @@ const nonEmpty = (name) => Schema.String.pipe(Schema.refine((value) => value.len
3047
3049
  const nonNegativeInteger = (name) => Schema.Number.pipe(Schema.refine((value) => Number.isSafeInteger(value) && value >= 0, { message: `${name} must be a non-negative safe integer` }));
3048
3050
  const BaseSepoliaChainIdSchema = ChainIdSchema$1.pipe(Schema.refine((value) => value === 84532, { message: "chainId must be 84532" }));
3049
3051
  const Uint16Schema = Schema.Number.pipe(Schema.refine((value) => Number.isSafeInteger(value) && value >= 0 && value <= 65535, { message: "kind must be a uint16 value" }));
3050
- const Uint8Schema = Schema.Number.pipe(Schema.refine((value) => Number.isSafeInteger(value) && value >= 0 && value <= 255, { message: "must be a uint8 value" }));
3051
- const Bytes4Schema = Schema.String.pipe(Schema.refine((value) => /^0x[0-9a-fA-F]{8}$/u.test(value), { message: "must be a 0x-prefixed bytes4 value" }));
3052
+ Schema.Number.pipe(Schema.refine((value) => Number.isSafeInteger(value) && value >= 0 && value <= 255, { message: "must be a uint8 value" }));
3053
+ Schema.String.pipe(Schema.refine((value) => /^0x[0-9a-fA-F]{8}$/u.test(value), { message: "must be a 0x-prefixed bytes4 value" }));
3052
3054
  const HexDataSchema = Schema.String.pipe(Schema.refine((value) => /^0x(?:[0-9a-fA-F]{2})*$/u.test(value), { message: "must be 0x-prefixed byte data" }));
3053
3055
  const Uint48Schema = Schema.Number.pipe(Schema.refine((value) => Number.isSafeInteger(value) && value >= 0 && value <= 0xffffffffffff, { message: "must be a uint48 value" }));
3054
3056
  const Uint256StringSchema = Schema.String.pipe(Schema.refine((value) => {
@@ -3191,8 +3193,7 @@ const PermissionStateSchema = Schema.Literals([
3191
3193
  "active",
3192
3194
  "suspended",
3193
3195
  "revoked",
3194
- "superseded",
3195
- "quarantined"
3196
+ "superseded"
3196
3197
  ]);
3197
3198
  const StoredPermissionCommandSchema = Schema.Struct({
3198
3199
  commandId: PaymentCommandIdSchema,
@@ -3216,8 +3217,7 @@ Schema.Struct({
3216
3217
  Schema.Union([
3217
3218
  Schema.Struct({
3218
3219
  status: Schema.Literal("pending"),
3219
- reason: Schema.Literals(["receipt_missing", "not_finalized"]),
3220
- receipt: Schema.optional(ReceiptRefSchema)
3220
+ reason: Schema.Literal("receipt_missing")
3221
3221
  }),
3222
3222
  Schema.Struct({
3223
3223
  status: Schema.Literal("verified"),
@@ -3486,112 +3486,6 @@ Schema.Struct({
3486
3486
  transfers: Schema.Array(FinalizedTransferEvidenceSchema),
3487
3487
  requestCount: nonNegativeInteger("requestCount")
3488
3488
  });
3489
- const FinalizedPermissionFactRangeSchema = Schema.Struct({
3490
- chainId: BaseSepoliaChainIdSchema,
3491
- organizationSafe: SafeAddressSchema,
3492
- rolesModules: Schema.Array(ModuleAddressSchema),
3493
- fromBlock: BlockNumberSchema$1,
3494
- toBlock: BlockNumberSchema$1
3495
- }).pipe(Schema.refine((range) => range.toBlock >= range.fromBlock && range.toBlock - range.fromBlock < 1e4, { message: "toBlock must be at or after fromBlock and the range must contain fewer than 10,000 block intervals" }));
3496
- const FinalizedPermissionFactCommonSchema = Schema.Struct({
3497
- chainId: BaseSepoliaChainIdSchema,
3498
- transactionHash: TxHashSchema$1,
3499
- blockNumber: BlockNumberSchema$1,
3500
- blockHash: Bytes32Schema,
3501
- logIndex: LogIndexSchema,
3502
- emitter: AddressSchema$1,
3503
- topic0: Bytes32Schema,
3504
- dataHash: Bytes32Schema,
3505
- authorityHash: Bytes32Schema
3506
- });
3507
- const FinalizedPermissionModuleFactSchema = Schema.Struct({
3508
- ...FinalizedPermissionFactCommonSchema.fields,
3509
- kind: Schema.Literals(["module_enabled", "module_disabled"]),
3510
- organizationSafe: SafeAddressSchema,
3511
- module: ModuleAddressSchema
3512
- });
3513
- const FinalizedPermissionRoleAssignmentFactSchema = Schema.Struct({
3514
- ...FinalizedPermissionFactCommonSchema.fields,
3515
- kind: Schema.Literal("assignment"),
3516
- rolesModule: ModuleAddressSchema,
3517
- memberSafe: SafeAddressSchema,
3518
- roleKeys: Schema.Array(RoleKeySchema),
3519
- memberOf: Schema.Array(Schema.Boolean)
3520
- });
3521
- const FinalizedPermissionTargetAuthorityFactSchema = Schema.Union([Schema.Struct({
3522
- ...FinalizedPermissionFactCommonSchema.fields,
3523
- kind: Schema.Literal("allow_target"),
3524
- rolesModule: ModuleAddressSchema,
3525
- roleKey: RoleKeySchema,
3526
- target: AddressSchema$1,
3527
- options: Uint8Schema
3528
- }), Schema.Struct({
3529
- ...FinalizedPermissionFactCommonSchema.fields,
3530
- kind: Schema.Literals(["scope_target", "revoke_target"]),
3531
- rolesModule: ModuleAddressSchema,
3532
- roleKey: RoleKeySchema,
3533
- target: AddressSchema$1
3534
- })]);
3535
- const PermissionScopeConditionSchema = Schema.Struct({
3536
- parent: Uint8Schema,
3537
- paramType: Uint8Schema,
3538
- operator: Uint8Schema,
3539
- compValue: HexDataSchema
3540
- });
3541
- const FinalizedPermissionFunctionAuthorityFactSchema = Schema.Union([
3542
- Schema.Struct({
3543
- ...FinalizedPermissionFactCommonSchema.fields,
3544
- kind: Schema.Literal("allow_function"),
3545
- rolesModule: ModuleAddressSchema,
3546
- roleKey: RoleKeySchema,
3547
- target: AddressSchema$1,
3548
- selector: Bytes4Schema,
3549
- options: Uint8Schema
3550
- }),
3551
- Schema.Struct({
3552
- ...FinalizedPermissionFactCommonSchema.fields,
3553
- kind: Schema.Literal("scope_function"),
3554
- rolesModule: ModuleAddressSchema,
3555
- roleKey: RoleKeySchema,
3556
- target: AddressSchema$1,
3557
- selector: Bytes4Schema,
3558
- options: Uint8Schema,
3559
- conditions: Schema.Array(PermissionScopeConditionSchema)
3560
- }),
3561
- Schema.Struct({
3562
- ...FinalizedPermissionFactCommonSchema.fields,
3563
- kind: Schema.Literal("revoke_function"),
3564
- rolesModule: ModuleAddressSchema,
3565
- roleKey: RoleKeySchema,
3566
- target: AddressSchema$1,
3567
- selector: Bytes4Schema
3568
- })
3569
- ]);
3570
- const FinalizedPermissionAllowanceAuthorityFactSchema = Schema.Struct({
3571
- ...FinalizedPermissionFactCommonSchema.fields,
3572
- kind: Schema.Literal("allowance"),
3573
- rolesModule: ModuleAddressSchema,
3574
- allowanceKey: AllowanceKeySchema,
3575
- balance: WeiAmountSchema$1,
3576
- maxRefill: WeiAmountSchema$1,
3577
- refill: WeiAmountSchema$1,
3578
- period: Uint256StringSchema,
3579
- timestamp: Uint256StringSchema
3580
- });
3581
- const FinalizedPermissionFactSchema = Schema.Union([
3582
- FinalizedPermissionModuleFactSchema,
3583
- FinalizedPermissionRoleAssignmentFactSchema,
3584
- FinalizedPermissionTargetAuthorityFactSchema,
3585
- FinalizedPermissionFunctionAuthorityFactSchema,
3586
- FinalizedPermissionAllowanceAuthorityFactSchema
3587
- ]);
3588
- Schema.Struct({
3589
- range: FinalizedPermissionFactRangeSchema,
3590
- finalizedHead: FinalizedBlockReferenceSchema,
3591
- anchor: FinalizedBlockReferenceSchema,
3592
- facts: Schema.Array(FinalizedPermissionFactSchema),
3593
- requestCount: nonNegativeInteger("requestCount")
3594
- });
3595
3489
  const FinalizedMoneyEvidenceCommonSchema = Schema.Struct({
3596
3490
  chainId: BaseSepoliaChainIdSchema,
3597
3491
  contractAddress: AddressSchema$1,
@@ -5920,6 +5814,31 @@ const transition = (state, event, config = DEFAULT_CONFIG) => {
5920
5814
  };
5921
5815
  const PRIVATE_TAGS = new Set(PRIVATE_EVENT_TAGS);
5922
5816
  const isPrivate = (event) => PRIVATE_TAGS.has(event._tag);
5817
+ Object.freeze({
5818
+ terminal: false,
5819
+ outcome: null,
5820
+ needsAction: false
5821
+ });
5822
+ Object.freeze({
5823
+ terminal: false,
5824
+ outcome: null,
5825
+ needsAction: true
5826
+ });
5827
+ Object.freeze({
5828
+ terminal: true,
5829
+ outcome: "good",
5830
+ needsAction: false
5831
+ });
5832
+ Object.freeze({
5833
+ terminal: true,
5834
+ outcome: "bad",
5835
+ needsAction: false
5836
+ });
5837
+ Object.freeze({
5838
+ terminal: true,
5839
+ outcome: "neutral",
5840
+ needsAction: false
5841
+ });
5923
5842
  //#endregion
5924
5843
  //#region ../../packages/sdk/src/surface/_shared/provisioning-telemetry.ts
5925
5844
  async function emitProvisioningTelemetry(telemetry, smartAccount) {
@@ -7262,7 +7181,7 @@ function mapActorRequest(request, payer) {
7262
7181
  ...resolvedPayer === void 0 ? {} : { payer: resolvedPayer },
7263
7182
  amount: request.amount,
7264
7183
  reference: request.reference,
7265
- status: mapActorRequestStatus(request.status),
7184
+ status: request.status,
7266
7185
  expiresAt: request.expiresAt ?? null
7267
7186
  };
7268
7187
  }
@@ -7320,28 +7239,17 @@ function mapApprovedInboxPayment(command, input) {
7320
7239
  };
7321
7240
  }
7322
7241
  }
7323
- function mapActorRequestStatus(status) {
7242
+ function mapInboxStatus(status) {
7324
7243
  switch (status) {
7325
7244
  case "draft":
7326
7245
  case "sent":
7327
- case "viewed":
7246
+ case "viewed": return "open";
7247
+ case "pending_settlement": return "approved";
7328
7248
  case "paid":
7329
- case "pending_settlement":
7330
- case "declined":
7331
- case "cancelled":
7332
- case "expired": return status;
7333
- default: return "sent";
7334
- }
7335
- }
7336
- function mapInboxStatus(status) {
7337
- switch (status) {
7338
- case "approved":
7339
7249
  case "declined":
7340
- case "paid":
7341
7250
  case "cancelled":
7342
7251
  case "expired": return status;
7343
- case "pending_settlement": return "approved";
7344
- default: return "open";
7252
+ default: throw Errors.invalidInput("status", "unknown request status");
7345
7253
  }
7346
7254
  }
7347
7255
  function normalizeRefForBackend$1(ref, field) {
@@ -7660,6 +7568,7 @@ const financialOpsContract = {
7660
7568
  listPayments: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/queries"].listPayments),
7661
7569
  getPayment: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/queries"].getPayment),
7662
7570
  activityList: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].list),
7571
+ activitySummary: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].summary),
7663
7572
  activityGet: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].get),
7664
7573
  activityAnnotate: makeFunctionReference(CAPXUL_FUNCTIONS["movement/activity"].annotate),
7665
7574
  verifyPaymentDocument: makeFunctionReference(CAPXUL_FUNCTIONS["financialOps/queries"].verifyPaymentDocument),
@@ -7911,6 +7820,40 @@ function actorReferenceToBackend(actor) {
7911
7820
  case "org": return actor;
7912
7821
  }
7913
7822
  }
7823
+ /**
7824
+ * The activity backend gives its actor a different name than the other
7825
+ * financialOps functions: `{kind: "organization", orgId}`, and not
7826
+ * `{kind: "org", orgId}`. Thus it does not use `actorReferenceToBackend`.
7827
+ *
7828
+ * The `personal` case sends NO actor. This is correct, and it does not lose
7829
+ * data. `requireActivityActor` uses the signed-in Account when the actor is
7830
+ * absent, and `canReadActor` refuses all other account identifiers
7831
+ * (`packages/backend/convex/movement/activityAuth.ts`). Thus "personal" and
7832
+ * "absent" both name the one Account that an SDK caller can read. The SDK does
7833
+ * not hold an account identifier to send.
7834
+ *
7835
+ * The `switch` is exhaustive. A new `ActorReference` variant is a compile error
7836
+ * here. The conditional expression that this function replaced removed each
7837
+ * value that was not an organization.
7838
+ */
7839
+ function activityActorField(actor) {
7840
+ if (actor === void 0) return {};
7841
+ switch (actor.kind) {
7842
+ case "personal": return {};
7843
+ case "organization": return { actor: {
7844
+ kind: "organization",
7845
+ orgId: actor.organizationId
7846
+ } };
7847
+ }
7848
+ }
7849
+ /** An absent actor and a `personal` actor both name the signed-in Account. */
7850
+ function actorScopeKey(actor) {
7851
+ return actor === void 0 || actor.kind === "personal" ? "personal" : `org:${actor.organizationId}`;
7852
+ }
7853
+ /** Two actor references name the same scope. */
7854
+ function sameActor(left, right) {
7855
+ return actorScopeKey(left) === actorScopeKey(right);
7856
+ }
7914
7857
  const memoryPaymentRequestKeys = /* @__PURE__ */ new Map();
7915
7858
  const paymentAttemptReleases = /* @__PURE__ */ new Set();
7916
7859
  let paymentAttemptPagehideInstalled = false;
@@ -8341,31 +8284,48 @@ function makeFinancialOpsMethods(deps) {
8341
8284
  },
8342
8285
  activity: {
8343
8286
  list: (params, options) => runIfActive(options?.signal, "activity.list", () => deps.convexCall.query(fns.activityList, { input: {
8344
- ...params?.actor?.kind === "organization" ? { actor: {
8345
- kind: "organization",
8346
- orgId: params.actor.organizationId
8347
- } } : {},
8287
+ ...activityActorField(params?.actor),
8348
8288
  ...params?.cursor === void 0 ? {} : { cursor: params.cursor },
8349
- ...params?.limit === void 0 ? {} : { limit: params.limit }
8289
+ ...params?.limit === void 0 ? {} : { limit: params.limit },
8290
+ ...params?.range === void 0 ? {} : { range: params.range },
8291
+ ...params?.filter === void 0 ? {} : { filter: params.filter }
8350
8292
  } })),
8351
- get: (reference, options) => runIfActive(options?.signal, "activity.get", () => deps.convexCall.query(fns.activityGet, { input: {
8352
- kind: reference.kind,
8353
- id: reference.id,
8354
- ...reference.kind === "payment" && reference.actor?.kind === "organization" ? { actor: {
8355
- kind: "organization",
8356
- orgId: reference.actor.organizationId
8357
- } } : {}
8293
+ summary: (params, options) => runIfActive(options?.signal, "activity.summary", () => deps.convexCall.query(fns.activitySummary, { input: {
8294
+ ...activityActorField(params?.actor),
8295
+ ...params?.window === void 0 ? {} : { window: params.window }
8358
8296
  } })),
8359
- annotate: (input, options) => runIfActive(options?.signal, "activity.annotate", () => deps.convexCall.mutation(fns.activityAnnotate, { input: {
8360
- ...input.actor?.kind === "organization" ? { actor: {
8361
- kind: "organization",
8362
- orgId: input.actor.organizationId
8363
- } } : {},
8364
- movementId: input.movementId,
8365
- ...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
8366
- ...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
8367
- ...input.memo === void 0 ? {} : { memo: input.memo }
8368
- } }))
8297
+ get: (reference, options) => {
8298
+ const actor = actorReferenceToBackend(options?.actor);
8299
+ return runIfActive(options?.signal, "activity.get", () => deps.convexCall.query(fns.activityGet, {
8300
+ input: {
8301
+ kind: reference.kind,
8302
+ id: reference.id,
8303
+ ...reference.kind === "payment" ? activityActorField(reference.actor) : {}
8304
+ },
8305
+ ...actor === void 0 ? {} : { actor }
8306
+ }));
8307
+ },
8308
+ annotate: (input, options) => {
8309
+ if (input.actor !== void 0 && input.reference.kind === "payment" && input.reference.actor !== void 0 && !sameActor(input.actor, input.reference.actor)) return Promise.resolve({
8310
+ ok: false,
8311
+ error: Errors.invalidInput("reference.actor", "must match the annotation actor")
8312
+ });
8313
+ const referenceActor = input.reference.kind === "payment" ? activityActorField(input.reference.actor).actor : void 0;
8314
+ return runIfActive(options?.signal, "activity.annotate", () => deps.convexCall.mutation(fns.activityAnnotate, { input: {
8315
+ ...activityActorField(input.actor),
8316
+ reference: input.reference.kind === "payment" && referenceActor !== void 0 ? {
8317
+ kind: "payment",
8318
+ id: input.reference.id,
8319
+ actor: referenceActor
8320
+ } : {
8321
+ kind: input.reference.kind,
8322
+ id: input.reference.id
8323
+ },
8324
+ ...input.counterpartyLabel === void 0 ? {} : { counterpartyLabel: input.counterpartyLabel },
8325
+ ...input.accountingCategory === void 0 ? {} : { accountingCategory: input.accountingCategory },
8326
+ ...input.memo === void 0 ? {} : { memo: input.memo }
8327
+ } }));
8328
+ }
8369
8329
  },
8370
8330
  offramp: {
8371
8331
  quote: (input, options) => {
@@ -8856,9 +8816,15 @@ async function recoverRawDigestSigner(input) {
8856
8816
  }
8857
8817
  //#endregion
8858
8818
  //#region ../../packages/sdk/package.json
8859
- var version = "2.3.1";
8819
+ var version = "2.4.0";
8860
8820
  //#endregion
8861
8821
  //#region ../../packages/observability/src/engineering.ts
8822
+ const ENGINEERING_CAPXUL_ENVS = [
8823
+ "development",
8824
+ "staging",
8825
+ "production",
8826
+ "local"
8827
+ ];
8862
8828
  const SAFE_TRACED_HEADER_NAMES = [
8863
8829
  "content-length",
8864
8830
  "content-type",
@@ -8881,11 +8847,7 @@ const postHogOtlpEndpoints = (host) => {
8881
8847
  traces: `${base}/i/v1/traces`
8882
8848
  };
8883
8849
  };
8884
- const ENGINEERING_CAPXUL_ENVS = new Set([
8885
- "development",
8886
- "staging",
8887
- "production"
8888
- ]);
8850
+ const ENGINEERING_CAPXUL_ENV_SET = new Set(ENGINEERING_CAPXUL_ENVS);
8889
8851
  const ENGINEERING_PRODUCERS = new Set(["browser", "server"]);
8890
8852
  const PUBLIC_POSTHOG_AUTHORIZATION = /^Bearer phc_[A-Za-z0-9_-]{1,191}$/u;
8891
8853
  const SAFE_RESOURCE_VALUE = /^[A-Za-z0-9][A-Za-z0-9._+@/-]{0,127}$/u;
@@ -8897,7 +8859,7 @@ const validateEngineeringTelemetryConfig = (config) => {
8897
8859
  throw new TypeError("engineering telemetry host must be an absolute HTTPS URL");
8898
8860
  }
8899
8861
  if (url.protocol !== "https:" || url.username.length > 0 || url.password.length > 0 || url.pathname !== "/" || url.search.length > 0 || url.hash.length > 0 || !(url.hostname === "posthog.com" || url.hostname.endsWith(".posthog.com"))) throw new TypeError("engineering telemetry host must be a credential-free HTTPS origin");
8900
- if (!ENGINEERING_CAPXUL_ENVS.has(config.capxulEnv)) throw new TypeError("engineering telemetry capxulEnv is not canonical");
8862
+ if (!ENGINEERING_CAPXUL_ENV_SET.has(config.capxulEnv)) throw new TypeError("engineering telemetry capxulEnv is not canonical");
8901
8863
  if (!ENGINEERING_PRODUCERS.has(config.producer)) throw new TypeError("engineering telemetry producer is not canonical");
8902
8864
  if (!SAFE_RESOURCE_VALUE.test(config.sdkVersion)) throw new TypeError("engineering telemetry sdkVersion must be a bounded safe value");
8903
8865
  if (config.serviceName !== void 0 && !SAFE_RESOURCE_VALUE.test(config.serviceName)) throw new TypeError("engineering telemetry serviceName must be a bounded safe value");
@@ -13739,7 +13701,8 @@ const TelemetryEnvelopeProps = {
13739
13701
  "development",
13740
13702
  "staging",
13741
13703
  "production",
13742
- "unknown"
13704
+ "unknown",
13705
+ "local"
13743
13706
  ]),
13744
13707
  producer: Schema.Literals([
13745
13708
  "server",
@@ -14010,8 +13973,6 @@ const PermissionMirrorVerificationProps = Schema.Struct({
14010
13973
  outcome: Schema.String,
14011
13974
  reason: Schema.String,
14012
13975
  chain_id: Schema.Number,
14013
- finality: Schema.String,
14014
- lag_blocks: Schema.Number,
14015
13976
  retry_count: Schema.Number
14016
13977
  });
14017
13978
  const MovementScanWindowProps = Schema.Struct({
@@ -39198,13 +39159,74 @@ const organizationPaymentExecutionUnavailable = () => Promise.resolve({
39198
39159
  //#region ../../packages/sdk/src/contract/holdings.ts
39199
39160
  const holdingsContract = { current: makeFunctionReference(CAPXUL_FUNCTIONS["holdings/actions"].current) };
39200
39161
  //#endregion
39162
+ //#region ../../packages/sdk/src/domain/money/primary-holding.ts
39163
+ const CURRENCY_BY_TOKEN_SYMBOL = new Map([["USDX", toCurrencyCode("USD")]]);
39164
+ /**
39165
+ * The designated display asset: the payable row holding the most money, or
39166
+ * `null` when no row is payable.
39167
+ *
39168
+ * A `HoldingRow` (`packages/wire/src/money.ts`) is a RAW CHAIN ROW, and three
39169
+ * of its shapes cannot become a `Holding`. Each is SKIPPED rather than
39170
+ * reported, because a row nobody can render is not a failure of the read:
39171
+ *
39172
+ * - no `decimals` — the raw balance cannot be lifted into major units;
39173
+ * - no `symbol` — the asset cannot be named;
39174
+ * - a symbol that stands for no supported `CurrencyCode` — the balance
39175
+ * cannot be stated as `Money` without inventing a currency for it.
39176
+ *
39177
+ * This replaces the app's hand pick in `formatCurrentHoldingsBalance`
39178
+ * (`dashboard-formatters.ts`): a `.find()` over a hardcoded `["USDX","USDC"]`
39179
+ * list falling back to `rows[0]`. Ties keep the earlier row, so the same
39180
+ * snapshot always yields the same answer.
39181
+ */
39182
+ function primaryHolding(rows) {
39183
+ let primary = null;
39184
+ for (const row of rows) {
39185
+ const holding = toHolding(row);
39186
+ if (holding === null) continue;
39187
+ if (primary === null || compareDecimal(holding.available.value, primary.available.value) > 0) primary = holding;
39188
+ }
39189
+ return primary;
39190
+ }
39191
+ function toHolding(row) {
39192
+ if (row.symbol === void 0 || row.decimals === void 0) return null;
39193
+ const currency = currencyForTokenSymbol(row.symbol);
39194
+ if (currency === null) return null;
39195
+ return {
39196
+ id: row.assetKind === "native" ? "native" : row.tokenAddress.toLowerCase(),
39197
+ symbol: row.symbol,
39198
+ available: fromWei(row.rawBalance, row.decimals, currency)
39199
+ };
39200
+ }
39201
+ function currencyForTokenSymbol(symbol) {
39202
+ return CURRENCY_BY_TOKEN_SYMBOL.get(symbol.toUpperCase()) ?? null;
39203
+ }
39204
+ /**
39205
+ * Order two non-negative major-unit decimal strings without converting either
39206
+ * to a JavaScript number. Rows carry different `decimals`, so the raw integers
39207
+ * are not comparable: 1999999999 at 9 decimals is LESS than 2000000 at 6.
39208
+ */
39209
+ function compareDecimal(first, second) {
39210
+ const [firstWhole = "0", firstFraction = ""] = first.split(".");
39211
+ const [secondWhole = "0", secondFraction = ""] = second.split(".");
39212
+ const width = Math.max(firstFraction.length, secondFraction.length);
39213
+ const firstScaled = BigInt(firstWhole + firstFraction.padEnd(width, "0"));
39214
+ const secondScaled = BigInt(secondWhole + secondFraction.padEnd(width, "0"));
39215
+ if (firstScaled === secondScaled) return 0;
39216
+ return firstScaled < secondScaled ? -1 : 1;
39217
+ }
39218
+ //#endregion
39201
39219
  //#region ../../packages/sdk/src/surface/holdings.ts
39202
39220
  function makeHoldingsMethods(deps) {
39203
39221
  const functions = deps.functions ?? holdingsContract;
39204
- return { current: (input, options) => runIfActive(options?.signal, "holdings.current", () => deps.convexCall.action(functions.current, input?.actor?.kind === "organization" ? { actor: {
39222
+ const read = (operation, actor, signal, pick) => runIfActive(signal, operation, () => deps.convexCall.action(functions.current, actor?.kind === "organization" ? { actor: {
39205
39223
  kind: "organization",
39206
- orgId: input.actor.organizationId
39207
- } } : {})) };
39224
+ orgId: actor.organizationId
39225
+ } } : {}).pipe(Effect.map(pick)));
39226
+ return {
39227
+ current: (input, options) => read("holdings.current", input?.actor, options?.signal, (snapshot) => snapshot),
39228
+ primary: (input, options) => read("holdings.primary", input?.actor, options?.signal, (snapshot) => primaryHolding(snapshot.rows))
39229
+ };
39208
39230
  }
39209
39231
  //#endregion
39210
39232
  //#region ../../packages/sdk/src/ports/auth-cache.ts
@@ -42685,50 +42707,59 @@ const BUNDLER_RPC_METHODS = new Set([
42685
42707
  "pm_getPaymasterStubData",
42686
42708
  "pm_getPaymasterData"
42687
42709
  ]);
42688
- function providerFor(method) {
42689
- return BUNDLER_RPC_METHODS.has(method) ? "account-abstraction" : "alchemy";
42710
+ function rpcProviderRole(chainId, method) {
42711
+ if (BUNDLER_RPC_METHODS.has(method)) return "account-abstraction";
42712
+ if (chainId === 84532 && EVIDENCE_RPC_METHODS.has(method) && optionalEnv("BASE_SEPOLIA_EVIDENCE_RPC_URL") !== void 0) return "chain-evidence";
42713
+ return "chain-rpc";
42690
42714
  }
42691
42715
  function accountAbstractionUrl(chainId) {
42692
42716
  if (chainId !== 84532) throw Errors.invalidInput("chainId", `owned account-abstraction rail supports Base Sepolia; got ${String(chainId)}`);
42693
42717
  return requireEnvOrThrow("BASE_SEPOLIA_BUNDLER_RPC_URL");
42694
42718
  }
42695
- function rethrowProvider(method) {
42719
+ function rpcProviderError(operation, cause, chainId) {
42720
+ const method = operation.split(" ", 1)[0] ?? operation;
42721
+ return Errors.providerError(rpcProviderRole(chainId, method), operation, cause);
42722
+ }
42723
+ function rethrowProvider(chainId, method) {
42696
42724
  return (e) => {
42697
- throw Errors.providerError(providerFor(method), method, e);
42725
+ throw rpcProviderError(method, e, chainId);
42698
42726
  };
42699
42727
  }
42700
- function parseAlchemyQuantity(value, operation, field) {
42728
+ function parseRpcQuantity(value, operation, field, chainId) {
42701
42729
  try {
42702
42730
  return BigInt(value);
42703
42731
  } catch (cause) {
42704
- throw Errors.providerError("alchemy", `${operation} ${field}`, `invalid ${field} ${value} (${String(cause)})`);
42732
+ throw rpcProviderError(`${operation} ${field}`, `invalid ${field} ${value} (${String(cause)})`, chainId);
42705
42733
  }
42706
42734
  }
42707
- function providerValue(value, pattern, operation, field) {
42708
- if (typeof value !== "string" || !pattern.test(value)) throw Errors.providerError(providerFor(operation), operation, `invalid ${field}`);
42735
+ function providerValue(value, pattern, operation, field, chainId) {
42736
+ if (typeof value !== "string" || !pattern.test(value)) throw rpcProviderError(operation, `invalid ${field}`, chainId);
42709
42737
  return value.toLowerCase();
42710
42738
  }
42711
- function providerAddress(value, operation, field) {
42712
- return providerValue(value, ADDRESS_HEX, operation, field);
42739
+ function providerAddress(value, operation, field, chainId) {
42740
+ return providerValue(value, ADDRESS_HEX, operation, field, chainId);
42713
42741
  }
42714
- function providerBytes32(value, operation, field) {
42715
- return providerValue(value, BYTES32_HEX, operation, field);
42742
+ function providerBytes32(value, operation, field, chainId) {
42743
+ return providerValue(value, BYTES32_HEX, operation, field, chainId);
42716
42744
  }
42717
- function providerData(value, operation, field) {
42718
- return providerValue(value, EVEN_DATA_HEX, operation, field);
42745
+ function providerData(value, operation, field, chainId) {
42746
+ if (typeof value !== "string" || !EVEN_DATA_HEX.test(value)) throw rpcProviderError(operation, `invalid ${field}`, chainId);
42747
+ return value.toLowerCase();
42719
42748
  }
42749
+ /** The standard public Base node endpoints. Each one is overridable by env. */
42750
+ const BASE_SEPOLIA_NODE_RPC_URL = "https://sepolia.base.org";
42751
+ const BASE_MAINNET_NODE_RPC_URL = "https://mainnet.base.org";
42720
42752
  /**
42721
42753
  * Construct the node RPC URL for a given chain. Account-abstraction methods
42722
42754
  * use the separate owned gateway URL.
42755
+ *
42756
+ * The default is the standard public Base endpoint. An operator points a chain
42757
+ * at a different node with `BASE_SEPOLIA_RPC_URL` or `BASE_MAINNET_RPC_URL`.
42723
42758
  */
42724
- function alchemyUrl(chainId) {
42759
+ function nodeRpcUrl(chainId) {
42725
42760
  switch (chainId) {
42726
- case 84532: {
42727
- const baseSepoliaRpcUrl = optionalEnv("BASE_SEPOLIA_RPC_URL");
42728
- if (baseSepoliaRpcUrl !== void 0) return baseSepoliaRpcUrl.replace(/\/+$/, "");
42729
- return `https://base-sepolia.g.alchemy.com/v2/${requireEnvOrThrow("ALCHEMY_API_KEY")}`;
42730
- }
42731
- case 8453: return `https://base-mainnet.g.alchemy.com/v2/${requireEnvOrThrow("ALCHEMY_API_KEY")}`;
42761
+ case 84532: return (optionalEnv("BASE_SEPOLIA_RPC_URL") ?? BASE_SEPOLIA_NODE_RPC_URL).replace(/\/+$/, "");
42762
+ case 8453: return (optionalEnv("BASE_MAINNET_RPC_URL") ?? BASE_MAINNET_NODE_RPC_URL).replace(/\/+$/, "");
42732
42763
  default: throw Errors.invalidInput("chainId", `unsupported chainId ${String(chainId)}`);
42733
42764
  }
42734
42765
  }
@@ -42742,16 +42773,16 @@ function isValidJsonRpcEnvelope(value) {
42742
42773
  function isValidJsonRpcError(value) {
42743
42774
  return isRecord(value) && typeof value.code === "number" && Number.isInteger(value.code) && typeof value.message === "string";
42744
42775
  }
42745
- var DefinitiveUserOperationRpcRejection = class extends Error {
42776
+ var DefinitiveBundlerJsonRpcRejection = class extends Error {
42746
42777
  constructor() {
42747
- super("The bundler returned an explicit JSON-RPC rejection");
42748
- this.name = "DefinitiveUserOperationRpcRejection";
42778
+ super("Bundler returned an explicit JSON-RPC rejection");
42779
+ this.name = "DefinitiveBundlerJsonRpcRejection";
42749
42780
  }
42750
42781
  };
42751
42782
  async function alchemyRpc(chainId, method, params, timeoutMs, externalSignal) {
42752
42783
  const bundlerUrl = BUNDLER_RPC_METHODS.has(method) ? accountAbstractionUrl(chainId) : void 0;
42753
42784
  const evidenceUrl = chainId === 84532 && EVIDENCE_RPC_METHODS.has(method) ? optionalEnv("BASE_SEPOLIA_EVIDENCE_RPC_URL") : void 0;
42754
- const url = bundlerUrl?.replace(/\/+$/u, "") ?? evidenceUrl?.replace(/\/+$/u, "") ?? alchemyUrl(chainId);
42785
+ const url = bundlerUrl?.replace(/\/+$/u, "") ?? evidenceUrl?.replace(/\/+$/u, "") ?? nodeRpcUrl(chainId);
42755
42786
  const timeoutSignal = timeoutMs === void 0 ? void 0 : AbortSignal.timeout(timeoutMs);
42756
42787
  const signal = externalSignal === void 0 ? timeoutSignal : timeoutSignal === void 0 ? externalSignal : AbortSignal.any([externalSignal, timeoutSignal]);
42757
42788
  const res = await fetch(url, {
@@ -42764,47 +42795,47 @@ async function alchemyRpc(chainId, method, params, timeoutMs, externalSignal) {
42764
42795
  params
42765
42796
  }),
42766
42797
  ...signal === void 0 ? {} : { signal }
42767
- }).catch(rethrowProvider(method));
42798
+ }).catch(rethrowProvider(chainId, method));
42768
42799
  if (!res.ok) {
42769
42800
  const body = await res.text().catch(() => "<no body>");
42770
- throw Errors.providerError(providerFor(method), `${method} ${res.status}`, body);
42801
+ throw rpcProviderError(`${method} ${res.status}`, body, chainId);
42771
42802
  }
42772
42803
  let json;
42773
42804
  try {
42774
42805
  json = await res.json();
42775
42806
  } catch (cause) {
42776
- throw Errors.providerError(providerFor(method), `${method} json`, cause);
42807
+ throw rpcProviderError(`${method} json`, cause, chainId);
42777
42808
  }
42778
- if (!isValidJsonRpcEnvelope(json)) throw Errors.providerError(providerFor(method), method, "malformed JSON-RPC envelope");
42809
+ if (!isValidJsonRpcEnvelope(json)) throw rpcProviderError(method, "malformed JSON-RPC envelope", chainId);
42779
42810
  if (json.error !== void 0) {
42780
- if (!isValidJsonRpcError(json.error)) throw Errors.providerError(providerFor(method), method, "malformed JSON-RPC error");
42781
- throw Errors.providerError(providerFor(method), method, method === "eth_sendUserOperation" ? new DefinitiveUserOperationRpcRejection() : json.error.message);
42811
+ if (!isValidJsonRpcError(json.error)) throw rpcProviderError(method, "malformed JSON-RPC error", chainId);
42812
+ throw rpcProviderError(method, method === "eth_sendUserOperation" ? new DefinitiveBundlerJsonRpcRejection() : json.error.message, chainId);
42782
42813
  }
42783
- if (json.result === void 0) throw Errors.providerError(providerFor(method), method, "missing result");
42814
+ if (json.result === void 0) throw rpcProviderError(method, "missing result", chainId);
42784
42815
  return json.result;
42785
42816
  }
42786
- function parseReceiptLogs(raw) {
42817
+ function parseReceiptLogs(raw, chainId) {
42787
42818
  if (raw === void 0 || raw === null) return [];
42788
- if (!Array.isArray(raw)) throw Errors.providerError("account-abstraction", "eth_getUserOperationReceipt", "logs is not an array");
42819
+ if (!Array.isArray(raw)) throw rpcProviderError("eth_getUserOperationReceipt", "logs is not an array", chainId);
42789
42820
  return raw.map((entry) => {
42790
- if (typeof entry !== "object" || entry === null || typeof entry.address !== "string" || !Array.isArray(entry.topics) || typeof entry.data !== "string") throw Errors.providerError("account-abstraction", "eth_getUserOperationReceipt", `malformed receipt log: ${JSON.stringify(entry)}`);
42821
+ if (typeof entry !== "object" || entry === null || typeof entry.address !== "string" || !Array.isArray(entry.topics) || typeof entry.data !== "string") throw rpcProviderError("eth_getUserOperationReceipt", `malformed receipt log: ${JSON.stringify(entry)}`, chainId);
42791
42822
  const log = entry;
42792
42823
  const operation = "eth_getUserOperationReceipt";
42793
- if (log.logIndex !== void 0 && typeof log.logIndex !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid logIndex");
42794
- if (log.blockNumber !== void 0 && typeof log.blockNumber !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid blockNumber");
42795
- if (log.blockHash !== void 0 && typeof log.blockHash !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid blockHash");
42796
- if (log.transactionHash !== void 0 && typeof log.transactionHash !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid transactionHash");
42797
- if (log.transactionIndex !== void 0 && typeof log.transactionIndex !== "string") throw Errors.providerError(providerFor(operation), operation, "invalid transactionIndex");
42798
- if (log.removed !== void 0 && typeof log.removed !== "boolean") throw Errors.providerError(providerFor(operation), operation, "invalid removed");
42824
+ if (log.logIndex !== void 0 && typeof log.logIndex !== "string") throw rpcProviderError(operation, "invalid logIndex", chainId);
42825
+ if (log.blockNumber !== void 0 && typeof log.blockNumber !== "string") throw rpcProviderError(operation, "invalid blockNumber", chainId);
42826
+ if (log.blockHash !== void 0 && typeof log.blockHash !== "string") throw rpcProviderError(operation, "invalid blockHash", chainId);
42827
+ if (log.transactionHash !== void 0 && typeof log.transactionHash !== "string") throw rpcProviderError(operation, "invalid transactionHash", chainId);
42828
+ if (log.transactionIndex !== void 0 && typeof log.transactionIndex !== "string") throw rpcProviderError(operation, "invalid transactionIndex", chainId);
42829
+ if (log.removed !== void 0 && typeof log.removed !== "boolean") throw rpcProviderError(operation, "invalid removed", chainId);
42799
42830
  return {
42800
- address: providerAddress(log.address, operation, "log address"),
42801
- topics: log.topics.map((topic, index) => providerBytes32(topic, operation, `topic ${String(index)}`)),
42802
- data: providerData(log.data, operation, "log data"),
42803
- ...typeof log.logIndex === "string" ? { logIndex: hexToSafeInteger(log.logIndex, operation) } : {},
42804
- ...typeof log.blockNumber === "string" ? { blockNumber: hexToSafeInteger(log.blockNumber, operation) } : {},
42805
- ...typeof log.blockHash === "string" ? { blockHash: providerBytes32(log.blockHash, operation, "blockHash") } : {},
42806
- ...typeof log.transactionHash === "string" ? { transactionHash: providerBytes32(log.transactionHash, operation, "transactionHash") } : {},
42807
- ...typeof log.transactionIndex === "string" ? { transactionIndex: hexToSafeInteger(log.transactionIndex, operation) } : {},
42831
+ address: providerAddress(log.address, operation, "log address", chainId),
42832
+ topics: log.topics.map((topic, index) => providerBytes32(topic, operation, `topic ${String(index)}`, chainId)),
42833
+ data: providerData(log.data, operation, "log data", chainId),
42834
+ ...typeof log.logIndex === "string" ? { logIndex: hexToSafeInteger(log.logIndex, operation, chainId) } : {},
42835
+ ...typeof log.blockNumber === "string" ? { blockNumber: hexToSafeInteger(log.blockNumber, operation, chainId) } : {},
42836
+ ...typeof log.blockHash === "string" ? { blockHash: providerBytes32(log.blockHash, operation, "blockHash", chainId) } : {},
42837
+ ...typeof log.transactionHash === "string" ? { transactionHash: providerBytes32(log.transactionHash, operation, "transactionHash", chainId) } : {},
42838
+ ...typeof log.transactionIndex === "string" ? { transactionIndex: hexToSafeInteger(log.transactionIndex, operation, chainId) } : {},
42808
42839
  ...typeof log.removed === "boolean" ? { removed: log.removed } : {}
42809
42840
  };
42810
42841
  });
@@ -42812,17 +42843,17 @@ function parseReceiptLogs(raw) {
42812
42843
  async function fetchUserOperationReceipt(args) {
42813
42844
  const raw = await alchemyRpc(args.chainId, "eth_getUserOperationReceipt", [args.userOpHash]);
42814
42845
  if (raw === null) return null;
42815
- if (typeof raw !== "object" || typeof raw.userOpHash !== "string" || typeof raw.sender !== "string" || typeof raw.success !== "boolean" || typeof raw.receipt !== "object" || typeof raw.receipt.blockNumber !== "string" || typeof raw.receipt.blockHash !== "string" || typeof raw.receipt.transactionHash !== "string" || typeof raw.receipt.transactionIndex !== "string") throw Errors.providerError("account-abstraction", "eth_getUserOperationReceipt", `unexpected shape: ${JSON.stringify(raw)}`);
42846
+ if (typeof raw !== "object" || typeof raw.userOpHash !== "string" || typeof raw.sender !== "string" || typeof raw.success !== "boolean" || typeof raw.receipt !== "object" || typeof raw.receipt.blockNumber !== "string" || typeof raw.receipt.blockHash !== "string" || typeof raw.receipt.transactionHash !== "string" || typeof raw.receipt.transactionIndex !== "string") throw rpcProviderError("eth_getUserOperationReceipt", `unexpected shape: ${JSON.stringify(raw)}`, args.chainId);
42816
42847
  return {
42817
- userOpHash: providerBytes32(raw.userOpHash, "eth_getUserOperationReceipt", "userOpHash"),
42818
- sender: providerAddress(raw.sender, "eth_getUserOperationReceipt", "sender"),
42848
+ userOpHash: providerBytes32(raw.userOpHash, "eth_getUserOperationReceipt", "userOpHash", args.chainId),
42849
+ sender: providerAddress(raw.sender, "eth_getUserOperationReceipt", "sender", args.chainId),
42819
42850
  success: raw.success,
42820
42851
  receipt: {
42821
- blockNumber: hexToSafeInteger(raw.receipt.blockNumber, "eth_getUserOperationReceipt"),
42822
- blockHash: providerBytes32(raw.receipt.blockHash, "eth_getUserOperationReceipt", "blockHash"),
42823
- transactionHash: providerBytes32(raw.receipt.transactionHash, "eth_getUserOperationReceipt", "transactionHash"),
42824
- transactionIndex: hexToSafeInteger(raw.receipt.transactionIndex, "eth_getUserOperationReceipt"),
42825
- logs: parseReceiptLogs(raw.logs)
42852
+ blockNumber: hexToSafeInteger(raw.receipt.blockNumber, "eth_getUserOperationReceipt", args.chainId),
42853
+ blockHash: providerBytes32(raw.receipt.blockHash, "eth_getUserOperationReceipt", "blockHash", args.chainId),
42854
+ transactionHash: providerBytes32(raw.receipt.transactionHash, "eth_getUserOperationReceipt", "transactionHash", args.chainId),
42855
+ transactionIndex: hexToSafeInteger(raw.receipt.transactionIndex, "eth_getUserOperationReceipt", args.chainId),
42856
+ logs: parseReceiptLogs(raw.logs, args.chainId)
42826
42857
  }
42827
42858
  };
42828
42859
  }
@@ -42831,16 +42862,16 @@ async function fetchUserOperationReceipt(args) {
42831
42862
  * `Errors.providerError` if the value exceeds `Number.MAX_SAFE_INTEGER`
42832
42863
  * (would silently round under `parseInt` per `.claude/rules/numeric-parsing.md`).
42833
42864
  */
42834
- function hexToSafeInteger(hex, op) {
42835
- if (typeof hex !== "string" || !QUANTITY_HEX.test(hex)) throw Errors.providerError(providerFor(op), op, `expected a canonical hex quantity, got ${String(hex)}`);
42865
+ function hexToSafeInteger(hex, op, chainId) {
42866
+ if (typeof hex !== "string" || !QUANTITY_HEX.test(hex)) throw rpcProviderError(op, `expected a canonical hex quantity, got ${String(hex)}`, chainId);
42836
42867
  let big;
42837
42868
  try {
42838
42869
  big = BigInt(hex);
42839
42870
  } catch (cause) {
42840
- throw Errors.providerError(providerFor(op), op, `invalid hex integer: ${hex} (${String(cause)})`);
42871
+ throw rpcProviderError(op, `invalid hex integer: ${hex} (${String(cause)})`, chainId);
42841
42872
  }
42842
42873
  const n = Number(big);
42843
- if (!Number.isSafeInteger(n)) throw Errors.providerError(providerFor(op), op, `hex value ${hex} exceeds MAX_SAFE_INTEGER`);
42874
+ if (!Number.isSafeInteger(n)) throw rpcProviderError(op, `hex value ${hex} exceeds MAX_SAFE_INTEGER`, chainId);
42844
42875
  return n;
42845
42876
  }
42846
42877
  /**
@@ -42861,8 +42892,8 @@ async function fetchCommitmentState(args) {
42861
42892
  to: CAPXUL_PAYMENTS_V2_ADDRESS,
42862
42893
  data
42863
42894
  }, "latest"]);
42864
- if (typeof raw !== "string" || !raw.startsWith("0x")) throw Errors.providerError("alchemy", "eth_call commitments", `unexpected shape: ${String(raw)}`);
42865
- if (raw === "0x") throw Errors.providerError("alchemy", "eth_call commitments", "empty commitments() return (0x)");
42895
+ if (typeof raw !== "string" || !raw.startsWith("0x")) throw rpcProviderError("eth_call commitments", `unexpected shape: ${String(raw)}`, args.chainId);
42896
+ if (raw === "0x") throw rpcProviderError("eth_call commitments", "empty commitments() return (0x)", args.chainId);
42866
42897
  let decoded;
42867
42898
  try {
42868
42899
  decoded = decodeFunctionResult({
@@ -42871,7 +42902,7 @@ async function fetchCommitmentState(args) {
42871
42902
  data: raw
42872
42903
  });
42873
42904
  } catch (cause) {
42874
- throw Errors.providerError("alchemy", "eth_call commitments", `decode failed: ${String(cause)}`);
42905
+ throw rpcProviderError("eth_call commitments", `decode failed: ${String(cause)}`, args.chainId);
42875
42906
  }
42876
42907
  const [settlementId, creator, recipient, token, totalAmount, claimed, startTime, cliffTime, endTime, kind, documentHash, cancelled] = decoded;
42877
42908
  return {
@@ -42920,31 +42951,28 @@ async function fetchEntryPointNonce(args) {
42920
42951
  try {
42921
42952
  return BigInt(result);
42922
42953
  } catch (cause) {
42923
- throw Errors.providerError("alchemy", "eth_call getNonce", `invalid nonce ${result} (${String(cause)})`);
42954
+ throw rpcProviderError("eth_call getNonce", `invalid nonce ${result} (${String(cause)})`, args.chainId);
42924
42955
  }
42925
42956
  }
42926
42957
  /** EIP-1559 max + priority fees with a 2x base-fee inclusion buffer. */
42927
42958
  async function fetchUserOperationFees(args) {
42928
- const priority = parseAlchemyQuantity(await alchemyRpc(args.chainId, "eth_maxPriorityFeePerGas", []), "eth_maxPriorityFeePerGas", "maxPriorityFeePerGas");
42959
+ const priority = parseRpcQuantity(await alchemyRpc(args.chainId, "eth_maxPriorityFeePerGas", []), "eth_maxPriorityFeePerGas", "maxPriorityFeePerGas", args.chainId);
42929
42960
  const block = await alchemyRpc(args.chainId, "eth_getBlockByNumber", ["latest", false]);
42930
- if (block.baseFeePerGas === void 0) {
42931
- const blockRef = block.number ?? block.hash ?? "<unknown>";
42932
- throw Errors.providerError("alchemy", "eth_getBlockByNumber baseFeePerGas", `missing baseFeePerGas in latest block ${blockRef}: ${JSON.stringify(block)}`);
42933
- }
42961
+ if (block.baseFeePerGas === void 0) throw rpcProviderError("eth_getBlockByNumber baseFeePerGas", `missing baseFeePerGas in latest block ${block.number ?? block.hash ?? "<unknown>"}: ${JSON.stringify(block)}`, args.chainId);
42934
42962
  return {
42935
- maxFeePerGas: parseAlchemyQuantity(block.baseFeePerGas, "eth_getBlockByNumber", "baseFeePerGas") * EIP1559_BASE_FEE_BUFFER_MULTIPLIER + priority,
42963
+ maxFeePerGas: parseRpcQuantity(block.baseFeePerGas, "eth_getBlockByNumber", "baseFeePerGas", args.chainId) * EIP1559_BASE_FEE_BUFFER_MULTIPLIER + priority,
42936
42964
  maxPriorityFeePerGas: priority
42937
42965
  };
42938
42966
  }
42939
42967
  async function estimateUserOperationGas(args) {
42940
42968
  const raw = await alchemyRpc(args.chainId, "eth_estimateUserOperationGas", [args.userOp, ENTRY_POINT_07_ADDRESS]);
42941
- if (typeof raw !== "object" || typeof raw.preVerificationGas !== "string" || typeof raw.verificationGasLimit !== "string" || typeof raw.callGasLimit !== "string") throw Errors.providerError("account-abstraction", "eth_estimateUserOperationGas", `unexpected shape: ${JSON.stringify(raw)}`);
42969
+ if (typeof raw !== "object" || typeof raw.preVerificationGas !== "string" || typeof raw.verificationGasLimit !== "string" || typeof raw.callGasLimit !== "string") throw rpcProviderError("eth_estimateUserOperationGas", `unexpected shape: ${JSON.stringify(raw)}`, args.chainId);
42942
42970
  return raw;
42943
42971
  }
42944
- function optionalPaymasterHex(raw, method, field) {
42972
+ function optionalPaymasterHex(raw, method, field, chainId) {
42945
42973
  const value = raw[field];
42946
42974
  if (value === void 0) return void 0;
42947
- if (typeof value !== "string" || !isHex(value)) throw Errors.providerError("account-abstraction", method, `unexpected ${field}: expected hex string`);
42975
+ if (typeof value !== "string" || !isHex(value)) throw rpcProviderError(method, `unexpected ${field}: expected hex string`, chainId);
42948
42976
  return value;
42949
42977
  }
42950
42978
  function definedPaymasterFields(result) {
@@ -42962,12 +42990,12 @@ async function paymasterRpc(method, args) {
42962
42990
  toHex(args.chainId),
42963
42991
  {}
42964
42992
  ]);
42965
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw Errors.providerError("account-abstraction", method, `unexpected shape: ${JSON.stringify(raw)}`);
42993
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw rpcProviderError(method, `unexpected shape: ${JSON.stringify(raw)}`, args.chainId);
42966
42994
  const result = raw;
42967
- const paymaster = optionalPaymasterHex(result, method, "paymaster");
42968
- const paymasterData = optionalPaymasterHex(result, method, "paymasterData");
42969
- const paymasterVerificationGasLimit = optionalPaymasterHex(result, method, "paymasterVerificationGasLimit");
42970
- const paymasterPostOpGasLimit = optionalPaymasterHex(result, method, "paymasterPostOpGasLimit");
42995
+ const paymaster = optionalPaymasterHex(result, method, "paymaster", args.chainId);
42996
+ const paymasterData = optionalPaymasterHex(result, method, "paymasterData", args.chainId);
42997
+ const paymasterVerificationGasLimit = optionalPaymasterHex(result, method, "paymasterVerificationGasLimit", args.chainId);
42998
+ const paymasterPostOpGasLimit = optionalPaymasterHex(result, method, "paymasterPostOpGasLimit", args.chainId);
42971
42999
  return {
42972
43000
  ...paymaster === void 0 ? {} : { paymaster },
42973
43001
  ...paymasterData === void 0 ? {} : { paymasterData },
@@ -42983,7 +43011,7 @@ function getPaymasterStubData(args) {
42983
43011
  function getPaymasterData(args) {
42984
43012
  return paymasterRpc("pm_getPaymasterData", args);
42985
43013
  }
42986
- /** Sponsor one Base Sepolia UserOperation through the owned ERC-7677 gateway. */
43014
+ /** Run the owned ERC-7677 sponsorship flow. */
42987
43015
  async function sponsorUserOperation(args) {
42988
43016
  let request = args.userOp;
42989
43017
  request = {
@@ -43014,7 +43042,7 @@ async function sponsorUserOperation(args) {
43014
43042
  userOp: request
43015
43043
  }))
43016
43044
  };
43017
- if (request.paymaster === void 0 || request.paymasterData === void 0) throw Errors.providerError("account-abstraction", "pm_getPaymasterData", "missing paymaster sponsorship");
43045
+ if (request.paymaster === void 0 || request.paymasterData === void 0) throw rpcProviderError("pm_getPaymasterData", "missing paymaster sponsorship", args.chainId);
43018
43046
  return {
43019
43047
  ...request,
43020
43048
  paymaster: request.paymaster,
@@ -43024,7 +43052,7 @@ async function sponsorUserOperation(args) {
43024
43052
  /** Submit the signed UserOperation through the bundler — returns the userOpHash. */
43025
43053
  async function sendUserOperation(args) {
43026
43054
  const hash = await alchemyRpc(args.chainId, "eth_sendUserOperation", [args.userOp, ENTRY_POINT_07_ADDRESS]);
43027
- if (typeof hash !== "string" || !TX_HASH_HEX.test(hash)) throw Errors.providerError("account-abstraction", "eth_sendUserOperation", `unexpected hash: ${String(hash)}; expected 0x-prefixed 32-byte hex`);
43055
+ if (typeof hash !== "string" || !TX_HASH_HEX.test(hash)) throw rpcProviderError("eth_sendUserOperation", `unexpected hash: ${String(hash)}; expected 0x-prefixed 32-byte hex`, args.chainId);
43028
43056
  return hash;
43029
43057
  }
43030
43058
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capxul/mcp",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "private": false,
5
5
  "description": "Capxul MCP server for auth, Account readiness, identity, Organizations, relationships, requests, destinations, and testnet funding over Streamable HTTP.",
6
6
  "keywords": [
@@ -47,12 +47,12 @@
47
47
  "typescript": "npm:@typescript/typescript6@6.0.2",
48
48
  "vite": "npm:@voidzero-dev/vite-plus-core@0.1.23",
49
49
  "vite-plus": "0.1.23",
50
- "@capxul/backend": "0.2.4",
50
+ "@capxul/backend": "0.2.6",
51
51
  "@capxul/config": "0.2.0",
52
- "@capxul/sdk": "2.3.1",
52
+ "@capxul/sdk": "2.4.0",
53
53
  "@capxul/types": "0.2.0",
54
- "@capxul/wire": "0.4.0",
55
- "@capxul/typescript-config": "0.0.0"
54
+ "@capxul/typescript-config": "0.0.0",
55
+ "@capxul/wire": "0.5.0"
56
56
  },
57
57
  "scripts": {
58
58
  "dev": "vp exec tsx src/main.ts serve",