@capxul/mcp 4.20.0-beta.34 → 4.20.0-beta.36

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.
@@ -1,5 +1,5 @@
1
1
  import { r as __commonJSMin } from "./lib-DnmstTkB.mjs";
2
- import { a as anumber, h as u32$1, l as createHasher, m as toBytes$2, n as abytes, o as aoutput, p as swap32IfBE, r as aexists, s as clean, t as Hash$1 } from "./utils-CenTnkL6.mjs";
2
+ import { c as clean, f as swap32IfBE, i as aexists, m as u32$1, n as Hash$1, o as anumber, p as toBytes$2, r as abytes, s as aoutput, t as sha256$2, u as createHasher } from "./sha2-D5rBHwg7.mjs";
3
3
  import { Cause, Clock, Context, Data, Deferred, Effect, Exit, Fiber, Layer, Option, Predicate, Queue, Ref, Result, Schema, SchemaAST, SchemaGetter, SchemaIssue, SchemaParser } from "effect";
4
4
  //#region ../../packages/protocol/src/errors/failure-modes.ts
5
5
  /**
@@ -139,6 +139,17 @@ const Errors = {
139
139
  ...opts?.chain === void 0 ? {} : { chain: opts.chain }
140
140
  });
141
141
  },
142
+ /**
143
+ * The provider answered, but its answer cannot be used: `field` names the
144
+ * part that is missing or malformed and `reason` says what is wrong with it.
145
+ * Distinct from `PROVIDER_ERROR`, where the call itself failed or was refused.
146
+ */
147
+ providerResponseInvalid: (provider, operation, field, reason) => new CapxulError("PROVIDER_RESPONSE_INVALID", `${provider} ${operation} answered with an unusable ${field}: ${reason}`, { details: {
148
+ provider,
149
+ operation,
150
+ field,
151
+ reason
152
+ } }),
142
153
  capabilityUnavailable: (provider, operation) => new CapxulError("CAPABILITY_UNAVAILABLE", "Provider capability is unavailable", { details: {
143
154
  provider,
144
155
  operation
@@ -2158,6 +2169,7 @@ const CAPXUL_ERROR_CODES = [
2158
2169
  "ACCOUNT_NOT_FOUND",
2159
2170
  "ACCOUNT_CLAIMED_BY_OTHER_SIGNER",
2160
2171
  "PROVIDER_ERROR",
2172
+ "PROVIDER_RESPONSE_INVALID",
2161
2173
  "CAPABILITY_UNAVAILABLE",
2162
2174
  "INVALID_INPUT",
2163
2175
  "ENV_MISSING",
@@ -2179,6 +2191,15 @@ const CAPXUL_ERROR_CODES = [
2179
2191
  "WORK_DIED",
2180
2192
  "ACTOR_STOPPED"
2181
2193
  ];
2194
+ /** The existing Organization authority refusal vocabulary. */
2195
+ const ROLE_PERMISSION_DENIED_REASONS = [
2196
+ "over_cap",
2197
+ "daily_cap",
2198
+ "not_member",
2199
+ "disallowed_recipient",
2200
+ "condition_violation",
2201
+ "budget_exhausted"
2202
+ ];
2182
2203
  const EXPECTED_OUTCOME_CODES = /* @__PURE__ */ new Set([
2183
2204
  "INVALID_INPUT",
2184
2205
  "NOT_AUTHENTICATED",
@@ -7278,7 +7299,7 @@ function publicKeyToAddress(publicKey) {
7278
7299
  //#region ../../node_modules/.pnpm/viem@2.55.18_patch_hash=6dka2762lzcggf7at6h6xt4khq_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
7279
7300
  async function recoverPublicKey({ hash, signature }) {
7280
7301
  const hashHex = isHex$1(hash) ? hash : toHex(hash);
7281
- const { secp256k1 } = await import("./secp256k1-BSimfttS.mjs");
7302
+ const { secp256k1 } = await import("./secp256k1-CLeVBma1.mjs");
7282
7303
  return `0x${(() => {
7283
7304
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
7284
7305
  const { r, s, v, yParity } = signature;
@@ -7372,6 +7393,28 @@ function getSizeOfLength(length) {
7372
7393
  throw new BaseError("Length is too large.");
7373
7394
  }
7374
7395
  //#endregion
7396
+ //#region ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
7397
+ /**
7398
+ * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
7399
+ *
7400
+ * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
7401
+ * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
7402
+ *
7403
+ * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
7404
+ * @module
7405
+ * @deprecated
7406
+ */
7407
+ /** @deprecated Use import from `noble/hashes/sha2` module */
7408
+ const sha256$1 = sha256$2;
7409
+ //#endregion
7410
+ //#region ../../node_modules/.pnpm/viem@2.55.18_patch_hash=6dka2762lzcggf7at6h6xt4khq_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/hash/sha256.js
7411
+ function sha256(value, to_) {
7412
+ const to = to_ || "hex";
7413
+ const bytes = sha256$1(isHex$1(value, { strict: false }) ? toBytes$1(value) : value);
7414
+ if (to === "bytes") return bytes;
7415
+ return toHex(bytes);
7416
+ }
7417
+ //#endregion
7375
7418
  //#region ../../node_modules/.pnpm/viem@2.55.18_patch_hash=6dka2762lzcggf7at6h6xt4khq_@typescript+typescript6@6.0.2_zod@4.6.5/node_modules/viem/_esm/utils/abi/decodeFunctionData.js
7376
7419
  function decodeFunctionData(parameters) {
7377
7420
  const { abi, data } = parameters;
@@ -7747,7 +7790,7 @@ function isQuantityHex(value) {
7747
7790
  function isBytes32(value) {
7748
7791
  return typeof value === "string" && BYTES32_HEX.test(value);
7749
7792
  }
7750
- function refused(field, shape, value) {
7793
+ function refused$1(field, shape, value) {
7751
7794
  throw Errors.invalidInput(field, invalidValueReason(`must be ${shape}`, value));
7752
7795
  }
7753
7796
  /** Rebuilding the `0x` prefix keeps the result a `Hex`; lowercasing never changes the bytes. */
@@ -7756,19 +7799,19 @@ function lowered(value) {
7756
7799
  }
7757
7800
  /** Hex data exactly as given: case kept, for text another party compares or hashes as is. */
7758
7801
  function toExactHex(value, field = "value") {
7759
- return isHex(value) ? value : refused(field, "0x-prefixed hex", value);
7802
+ return isHex(value) ? value : refused$1(field, "0x-prefixed hex", value);
7760
7803
  }
7761
7804
  /** Hex data, lowercased. */
7762
7805
  function toLowerHex(value, field = "value") {
7763
- return isHex(value) ? lowered(value) : refused(field, "0x-prefixed hex", value);
7806
+ return isHex(value) ? lowered(value) : refused$1(field, "0x-prefixed hex", value);
7764
7807
  }
7765
7808
  /** A bytes32 value, lowercased. */
7766
7809
  function toLowerBytes32(value, field = "value") {
7767
- return isBytes32(value) ? lowered(value) : refused(field, "a 0x-prefixed bytes32 value", value);
7810
+ return isBytes32(value) ? lowered(value) : refused$1(field, "a 0x-prefixed bytes32 value", value);
7768
7811
  }
7769
7812
  /** An address, lowercased: the form stored rows and digests compare. */
7770
7813
  function toLowerAddress(value, field = "address") {
7771
- return isAddress(value) ? lowered(value) : refused(field, "an EVM address", value);
7814
+ return isAddress(value) ? lowered(value) : refused$1(field, "an EVM address", value);
7772
7815
  }
7773
7816
  //#endregion
7774
7817
  //#region ../../packages/protocol/src/evm/schema.ts
@@ -8321,16 +8364,19 @@ const PaymentCommandSchema = Schema.Union([
8321
8364
  PaymentBirthCommandSchema,
8322
8365
  Schema.Struct({
8323
8366
  kind: Schema.Literal("claim_commitment"),
8367
+ requestKey: Schema.optional(nonEmpty("requestKey")),
8324
8368
  actor: AccountActorRefSchema,
8325
8369
  paymentId: PaymentIdSchema
8326
8370
  }),
8327
8371
  Schema.Struct({
8328
8372
  kind: Schema.Literal("cancel_commitment"),
8373
+ requestKey: Schema.optional(nonEmpty("requestKey")),
8329
8374
  actor: ActorRefSchema,
8330
8375
  paymentId: PaymentIdSchema
8331
8376
  }),
8332
8377
  Schema.Struct({
8333
8378
  kind: Schema.Literal("redirect_commitment"),
8379
+ requestKey: Schema.optional(nonEmpty("requestKey")),
8334
8380
  actor: ActorRefSchema,
8335
8381
  paymentId: PaymentIdSchema,
8336
8382
  recipient: ActorOrDestinationRefSchema
@@ -8355,8 +8401,10 @@ const PreparedMoneyItemSchema = Schema.Union([
8355
8401
  tokenAddress: AddressSchema$1,
8356
8402
  rawAmount: WeiAmountSchema$1,
8357
8403
  kind: Uint16Schema,
8358
- documentHash: NonzeroDocumentHashSchema
8359
- }),
8404
+ documentHash: NonzeroDocumentHashSchema,
8405
+ jobNonce: Schema.optional(Bytes32Schema),
8406
+ executor: Schema.optional(AddressSchema$1)
8407
+ }).pipe(Schema.refine((item) => item.jobNonce === void 0 === (item.executor === void 0), { message: "Prepared V3 identity requires both jobNonce and executor" })),
8360
8408
  Schema.Struct({
8361
8409
  operation: Schema.Literal("create_commitment"),
8362
8410
  paymentId: PaymentIdSchema,
@@ -8458,6 +8506,12 @@ const PersonalUnsignedUserOperationSchema = Schema.Struct({
8458
8506
  entryPoint: Schema.optional(Schema.Never),
8459
8507
  safe4337ModuleAddress: Schema.optional(Schema.Never)
8460
8508
  });
8509
+ const SubmittedPaymentExecutionSchema = Schema.Struct({
8510
+ executionId: MoneyExecutionIdSchema,
8511
+ commandId: PaymentCommandIdSchema,
8512
+ userOpHash: Bytes32Schema,
8513
+ payment: Payment
8514
+ });
8461
8515
  const PreparedPaymentExecutionSchema = Schema.Struct({
8462
8516
  actorAccountId: AccountIdSchema$1,
8463
8517
  item: PreparedMoneyItemSchema,
@@ -8475,7 +8529,8 @@ const PreparedPaymentExecutionSchema = Schema.Struct({
8475
8529
  chainId: BaseSepoliaChainIdSchema,
8476
8530
  signerAddress: AddressSchema$1,
8477
8531
  userOpSenderSafe: SafeAddressSchema,
8478
- digest: Bytes32Schema
8532
+ digest: Bytes32Schema,
8533
+ settled: Schema.optional(SubmittedPaymentExecutionSchema)
8479
8534
  });
8480
8535
  const SubmitPaymentExecutionInputSchema = Schema.Struct({
8481
8536
  executionId: MoneyExecutionIdSchema,
@@ -8489,12 +8544,6 @@ const AbandonPaymentExecutionInputSchema = Schema.Struct({
8489
8544
  "prepared_mismatch"
8490
8545
  ])
8491
8546
  });
8492
- const SubmittedPaymentExecutionSchema = Schema.Struct({
8493
- executionId: MoneyExecutionIdSchema,
8494
- commandId: PaymentCommandIdSchema,
8495
- userOpHash: Bytes32Schema,
8496
- payment: Payment
8497
- });
8498
8547
  const SubmittedPaymentCommandExecutionSchema = Schema.Struct({
8499
8548
  executionId: MoneyExecutionIdSchema,
8500
8549
  commandId: PaymentCommandIdSchema,
@@ -8509,14 +8558,17 @@ const PaymentLifecycleExecutionIntentSchema = Schema.Union([
8509
8558
  }),
8510
8559
  Schema.Struct({
8511
8560
  kind: Schema.Literal("claim"),
8512
- paymentId: PaymentIdSchema
8561
+ paymentId: PaymentIdSchema,
8562
+ requestKey: Schema.optional(nonEmpty("requestKey"))
8513
8563
  }),
8514
8564
  Schema.Struct({
8515
8565
  kind: Schema.Literal("cancel"),
8516
- paymentId: PaymentIdSchema
8566
+ paymentId: PaymentIdSchema,
8567
+ requestKey: Schema.optional(nonEmpty("requestKey"))
8517
8568
  }),
8518
8569
  Schema.Struct({
8519
8570
  kind: Schema.Literal("redirect"),
8571
+ requestKey: Schema.optional(nonEmpty("requestKey")),
8520
8572
  paymentId: PaymentIdSchema,
8521
8573
  recipient: RedirectPaymentRef
8522
8574
  })
@@ -8575,10 +8627,12 @@ const RequestPaymentConfirmationFields = {
8575
8627
  const RequestPaymentTermsSchema = Schema.Struct(RequestPaymentConfirmationFields);
8576
8628
  const RequestPaymentConfirmationSchema = Schema.Union([Schema.Struct({
8577
8629
  ...RequestPaymentConfirmationFields,
8630
+ requestKey: Schema.optional(nonEmpty("requestKey")),
8578
8631
  payer: Schema.Struct({ kind: Schema.Literal("account") }),
8579
8632
  permissionId: Schema.optional(Schema.Never)
8580
8633
  }), Schema.Struct({
8581
8634
  ...RequestPaymentConfirmationFields,
8635
+ requestKey: Schema.optional(nonEmpty("requestKey")),
8582
8636
  payer: OrganizationActorRefSchema,
8583
8637
  permissionId: PermissionIdSchema
8584
8638
  })]);
@@ -8638,13 +8692,14 @@ const PreparedPaymentCommandExecutionSchema = Schema.Struct({
8638
8692
  commitmentId: Uint256StringSchema,
8639
8693
  documentHash: NonzeroDocumentHashSchema
8640
8694
  })),
8641
- documentBundles: Schema.optional(Schema.Array(PaymentDocumentBundleV3Schema))
8695
+ documentBundles: Schema.optional(Schema.Array(PaymentDocumentBundleV3Schema)),
8696
+ settled: Schema.optional(SubmittedPaymentCommandExecutionSchema)
8642
8697
  }).check(Schema.makeFilter((execution) => {
8643
8698
  if (!("kind" in execution.request) || execution.request.kind !== "payment_request") return true;
8644
8699
  const source = execution.sourceCommand;
8645
8700
  const prepared = execution.preparedCommand;
8646
8701
  if (source?.kind !== "birth" || prepared === void 0 || source.lineage?.kind !== "payment_request") return false;
8647
- if (source.lineage.requestId !== execution.request.confirmation.requestId || source.requestKey !== execution.request.requestKey || source.requestKey !== execution.request.confirmation.requestId || execution.userOperation === void 0) return false;
8702
+ if (source.lineage.requestId !== execution.request.confirmation.requestId || source.requestKey !== execution.request.requestKey || source.requestKey !== (execution.request.confirmation.requestKey ?? execution.request.confirmation.requestId) || execution.userOperation === void 0) return false;
8648
8703
  if ([
8649
8704
  source.items.length,
8650
8705
  execution.request.items.length,
@@ -8657,7 +8712,7 @@ const PreparedPaymentCommandExecutionSchema = Schema.Struct({
8657
8712
  prepared.instructionDocuments?.length
8658
8713
  ].some((length) => length !== 1)) return false;
8659
8714
  const item = prepared.items[0];
8660
- return "recipientSafe" in item && item.operation === source.items[0].operation && item.operation === execution.request.items[0].operation && item.paymentId === execution.paymentIds[0] && item.paymentId === execution.sourcePaymentIds?.[0] && item.recipientSafe === execution.sourceRecipientSafes?.[0];
8715
+ return "recipientSafe" in item && item.operation === source.items[0].operation && item.operation === execution.request.items[0].operation && [item.paymentId, execution.sourcePaymentIds?.[0]].every((id) => id === execution.paymentIds[0]) && item.recipientSafe === execution.sourceRecipientSafes?.[0];
8661
8716
  }));
8662
8717
  //#endregion
8663
8718
  //#region ../../packages/protocol/src/accounts/approval-schema.ts
@@ -8725,6 +8780,7 @@ const ApprovalSummarySchema = Schema.Struct({
8725
8780
  /** The exact operation the signature covers: the digest is the one thing the key signs. */
8726
8781
  const ApprovalOperationSchema = Schema.Struct({
8727
8782
  executionId: MoneyExecutionIdSchema,
8783
+ commandId: Schema.optional(nonEmpty("commandId")),
8728
8784
  digest: Bytes32Schema,
8729
8785
  userOperation: PersonalUnsignedUserOperationSchema,
8730
8786
  paymentIds: Schema.Array(PaymentIdSchema)
@@ -8917,6 +8973,21 @@ const approvals = {
8917
8973
  ...APPROVAL
8918
8974
  ]
8919
8975
  }),
8976
+ /** Read the signed operation's progress. Consumption alone does not prove completion. */
8977
+ observe: Operation.query("accounts.approvals.observe", {
8978
+ input: Schema.Struct({ approvalId: ApprovalIdSchema }),
8979
+ output: Schema.Struct({
8980
+ approval: ApprovalSchema,
8981
+ completed: Schema.Boolean
8982
+ }),
8983
+ errors: [
8984
+ ...CALL$10,
8985
+ ...DEFECTS,
8986
+ ...APPROVAL,
8987
+ "SUPERSEDED",
8988
+ "TRANSACTION_FAILED"
8989
+ ]
8990
+ }),
8920
8991
  /** The person opened the approval page: stamp the first review of a pending approval. */
8921
8992
  review: Operation.mutation("accounts.approvals.review", {
8922
8993
  input: Schema.Struct({ approvalId: ApprovalIdSchema }),
@@ -9123,6 +9194,8 @@ const errors = [
9123
9194
  ...DEFECTS
9124
9195
  ];
9125
9196
  const writeErrors = [...errors, "WRONG_STATE"];
9197
+ /** Bank-details writes also read Bridge's answer back, which can be unusable. */
9198
+ const bridgeWriteErrors = [...writeErrors, "PROVIDER_RESPONSE_INVALID"];
9126
9199
  const bankDetails = {
9127
9200
  list: Operation.query("banking.bankDetails.list", {
9128
9201
  input: Schema.Struct({ actor: actor$3 }),
@@ -9137,7 +9210,7 @@ const bankDetails = {
9137
9210
  open: Operation.action("banking.bankDetails.open", {
9138
9211
  input: Schema.Struct(target),
9139
9212
  output: BankDetailsSchema,
9140
- errors: writeErrors
9213
+ errors: bridgeWriteErrors
9141
9214
  }),
9142
9215
  settle: Operation.action("banking.bankDetails.settle", {
9143
9216
  input: Schema.Struct({
@@ -9145,17 +9218,17 @@ const bankDetails = {
9145
9218
  token: SettlementTokenSchema
9146
9219
  }),
9147
9220
  output: BankDetailsSchema,
9148
- errors: writeErrors
9221
+ errors: bridgeWriteErrors
9149
9222
  }),
9150
9223
  deactivate: Operation.action("banking.bankDetails.deactivate", {
9151
9224
  input: Schema.Struct(target),
9152
9225
  output: BankDetailsSchema,
9153
- errors: writeErrors
9226
+ errors: bridgeWriteErrors
9154
9227
  }),
9155
9228
  reactivate: Operation.action("banking.bankDetails.reactivate", {
9156
9229
  input: Schema.Struct(target),
9157
9230
  output: BankDetailsSchema,
9158
- errors: writeErrors
9231
+ errors: bridgeWriteErrors
9159
9232
  })
9160
9233
  };
9161
9234
  const deposits = {
@@ -10042,6 +10115,12 @@ function toOrgId(raw) {
10042
10115
  //#endregion
10043
10116
  //#region ../../packages/protocol/src/errors/schema.ts
10044
10117
  const FailureModeSchema$1 = Schema.Literals(FAILURE_MODES$1);
10118
+ Schema.Struct({
10119
+ reason: Schema.Literals(ROLE_PERMISSION_DENIED_REASONS),
10120
+ operation: Schema.optionalKey(Schema.String),
10121
+ remaining: Schema.optionalKey(AssetAmountSchema),
10122
+ required: Schema.optionalKey(AssetAmountSchema)
10123
+ });
10045
10124
  const ChainUpstreamSchema$1 = Schema.Literals(CHAIN_UPSTREAMS);
10046
10125
  const ChainCauseSchema = Schema.Struct({
10047
10126
  mode: FailureModeSchema$1,
@@ -12663,6 +12742,7 @@ const inboxes = {
12663
12742
  input: Schema.Struct({
12664
12743
  actor,
12665
12744
  paymentRequestId: Schema.String,
12745
+ requestKey: Schema.optionalKey(nonEmpty("requestKey")),
12666
12746
  timing: Schema.optionalKey(PaymentTiming),
12667
12747
  permissionId: Schema.optionalKey(Schema.String)
12668
12748
  }),
@@ -13039,7 +13119,8 @@ const PEOPLE_OPERATIONS = {
13039
13119
  expire: "accounts.approvals.expire",
13040
13120
  recordApproval: "accounts.approvals.recordApproval",
13041
13121
  recordExpiry: "accounts.approvals.recordExpiry",
13042
- sendApproved: "accounts.approvals.sendApproved"
13122
+ sendApproved: "accounts.approvals.sendApproved",
13123
+ rescheduleApproved: "accounts.approvals.rescheduleApproved"
13043
13124
  },
13044
13125
  balances: { readBinding: "accounts.balances.readBinding" },
13045
13126
  claims: {
@@ -16831,7 +16912,7 @@ function mapAccountLifecycle(input) {
16831
16912
  }
16832
16913
  //#endregion
16833
16914
  //#region ../../packages/sdk/package.json
16834
- var version$1 = "4.20.0-beta.34";
16915
+ var version$1 = "4.20.0-beta.36";
16835
16916
  //#endregion
16836
16917
  //#region ../../packages/sdk/src/observability/telemetry/exception-projection.ts
16837
16918
  /** Fixed fallback for failures that have no safe message. */
@@ -17394,6 +17475,126 @@ function mapOk(result, f) {
17394
17475
  }
17395
17476
  }
17396
17477
  //#endregion
17478
+ //#region ../../packages/protocol/src/evm/test-assets.ts
17479
+ const SYNTHETIC_TEST_ASSET_SOURCE = "synthetic-test-liquidity";
17480
+ /**
17481
+ * Owned test assets, with metadata read from each creation receipt and contract.
17482
+ * Settlement admission lives in assets.ts. The fixed test exchange uses the
17483
+ * original five assets; bank EURC has its own deployment.
17484
+ *
17485
+ * `symbol` is the display string the owned contract returns. A
17486
+ * provider-supported USDC would be a different contract at a different
17487
+ * address returning the same symbol, which is why the resolvers below key on
17488
+ * `assetId`, or on chain plus address, and never on a symbol.
17489
+ */
17490
+ const SYNTHETIC_TEST_ASSET_FIXTURES = {
17491
+ usdc: {
17492
+ assetId: assetIdFor(84532, "0x06ba8b863ca77490b0e7008427562bdbfcff730e"),
17493
+ chainId: toChainId(84532),
17494
+ tokenAddress: "0x06ba8b863ca77490b0e7008427562bdbfcff730e",
17495
+ symbol: "USDC",
17496
+ decimals: 6,
17497
+ peg: toCurrencyCode("USD"),
17498
+ deploymentStartBlock: 46690061,
17499
+ deploymentTransaction: "0x2661b7af5f62b9e31c707a59746cda65b90ba4448852317ac1968162fb94ff52",
17500
+ source: SYNTHETIC_TEST_ASSET_SOURCE
17501
+ },
17502
+ usdt: {
17503
+ assetId: assetIdFor(84532, "0xcb5f361ae070e75d573941b8cd54995fa3876d75"),
17504
+ chainId: toChainId(84532),
17505
+ tokenAddress: "0xcb5f361ae070e75d573941b8cd54995fa3876d75",
17506
+ symbol: "USDT",
17507
+ decimals: 6,
17508
+ peg: toCurrencyCode("USD"),
17509
+ deploymentStartBlock: 46690061,
17510
+ deploymentTransaction: "0x98e5303f97974a31eddb61ad030072d900ce7283ce8080bfe0b9e5ea6f297749",
17511
+ source: SYNTHETIC_TEST_ASSET_SOURCE
17512
+ },
17513
+ weth: {
17514
+ assetId: assetIdFor(84532, "0x85b7bd39ce3df9a85135e1e307225dd435f67e47"),
17515
+ chainId: toChainId(84532),
17516
+ tokenAddress: "0x85b7bd39ce3df9a85135e1e307225dd435f67e47",
17517
+ symbol: "WETH",
17518
+ decimals: 18,
17519
+ peg: null,
17520
+ deploymentStartBlock: 46690061,
17521
+ deploymentTransaction: "0x48dfacc01c15adc34f6c629aec5c9ff7bb84176d448017da0d0d4fdaf8b5a68a",
17522
+ source: SYNTHETIC_TEST_ASSET_SOURCE
17523
+ },
17524
+ wbtc: {
17525
+ assetId: assetIdFor(84532, "0xcf433a81f507dcc88c2c404650ffafb40750b451"),
17526
+ chainId: toChainId(84532),
17527
+ tokenAddress: "0xcf433a81f507dcc88c2c404650ffafb40750b451",
17528
+ symbol: "WBTC",
17529
+ decimals: 8,
17530
+ peg: null,
17531
+ deploymentStartBlock: 46690061,
17532
+ deploymentTransaction: "0xa975fcda0a67509742243bbfc386032d2e0d6ca78404c255fae2e4ffae1c7f4d",
17533
+ source: SYNTHETIC_TEST_ASSET_SOURCE
17534
+ },
17535
+ cngn: {
17536
+ assetId: assetIdFor(84532, "0xda515a7267e190710f0003f951c62bcfd70d6b2a"),
17537
+ chainId: toChainId(84532),
17538
+ tokenAddress: "0xda515a7267e190710f0003f951c62bcfd70d6b2a",
17539
+ symbol: "cNGN",
17540
+ decimals: 6,
17541
+ peg: toCurrencyCode("NGN"),
17542
+ deploymentStartBlock: 46690061,
17543
+ deploymentTransaction: "0x6f6b0302448c7cd7db5c118a8250e548c6e72821df373e5a27550e5cdfa635a1",
17544
+ source: SYNTHETIC_TEST_ASSET_SOURCE
17545
+ },
17546
+ eurc: {
17547
+ assetId: assetIdFor(84532, "0x15055b4ed1d248c169b92705757cd9c3d985ad5f"),
17548
+ chainId: toChainId(84532),
17549
+ tokenAddress: "0x15055b4ed1d248c169b92705757cd9c3d985ad5f",
17550
+ symbol: "EURC",
17551
+ decimals: 6,
17552
+ peg: toCurrencyCode("EUR"),
17553
+ deploymentStartBlock: 47893251,
17554
+ deploymentTransaction: "0x4e0ab412d980a672336487afd10da007d51f34f17876b19b13732c8125be90ca",
17555
+ source: SYNTHETIC_TEST_ASSET_SOURCE
17556
+ }
17557
+ };
17558
+ /** EURC is minted for bank deposits and has no admission to the fixed test exchange. */
17559
+ const SYNTHETIC_TEST_ASSETS = [...[
17560
+ SYNTHETIC_TEST_ASSET_FIXTURES.usdc,
17561
+ SYNTHETIC_TEST_ASSET_FIXTURES.usdt,
17562
+ SYNTHETIC_TEST_ASSET_FIXTURES.weth,
17563
+ SYNTHETIC_TEST_ASSET_FIXTURES.wbtc,
17564
+ SYNTHETIC_TEST_ASSET_FIXTURES.cngn
17565
+ ], SYNTHETIC_TEST_ASSET_FIXTURES.eurc];
17566
+ toChainId(84532);
17567
+ /**
17568
+ * The settlement tier: the owned test assets admitted to the exact-transfer
17569
+ * path and to the treasury reads. USDC, USDT, WETH and EURC are admitted assets.
17570
+ * There is no default token.
17571
+ */
17572
+ const SETTLEMENT_ASSETS_BASE_SEPOLIA = Object.freeze({
17573
+ CAPXUL_TEST_USDC: SYNTHETIC_TEST_ASSET_FIXTURES.usdc,
17574
+ CAPXUL_TEST_USDT: SYNTHETIC_TEST_ASSET_FIXTURES.usdt,
17575
+ CAPXUL_TEST_WETH: SYNTHETIC_TEST_ASSET_FIXTURES.weth,
17576
+ CAPXUL_TEST_EURC: SYNTHETIC_TEST_ASSET_FIXTURES.eurc
17577
+ });
17578
+ const CONFIGURED_MONEY_ASSETS = Object.freeze(Object.values(SETTLEMENT_ASSETS_BASE_SEPOLIA));
17579
+ Object.freeze({ BASE_SEPOLIA: Object.freeze({
17580
+ CAPXUL_TEST_USDC: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_USDC.assetId,
17581
+ CAPXUL_TEST_USDT: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_USDT.assetId,
17582
+ CAPXUL_TEST_WETH: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_WETH.assetId,
17583
+ CAPXUL_TEST_EURC: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_EURC.assetId
17584
+ }) });
17585
+ /**
17586
+ * Every known asset in ONE identity space. The tiers above declare admission;
17587
+ * this is the only list an identity resolves against, so an asset is never
17588
+ * two different things depending on which list a caller happened to read.
17589
+ */
17590
+ const MONEY_ASSET_REGISTRY = [...SYNTHETIC_TEST_ASSETS];
17591
+ CONFIGURED_MONEY_ASSETS.map((asset) => asset.tokenAddress.toLowerCase());
17592
+ /** The registry row for `assetId` across every tier, or `null`. */
17593
+ function configuredMoneyAssetById(assetId) {
17594
+ const canonical = toAssetId(assetId);
17595
+ return MONEY_ASSET_REGISTRY.find((asset) => asset.assetId === canonical) ?? null;
17596
+ }
17597
+ //#endregion
17397
17598
  //#region ../../packages/sdk/src/platform/transport/call-operation.ts
17398
17599
  function callOperation(port, row, args, options) {
17399
17600
  const op = row;
@@ -18735,6 +18936,23 @@ async function verifyPaymentDocumentSignatureV3(input) {
18735
18936
  })).toLowerCase() === envelope.signature.signer;
18736
18937
  }
18737
18938
  //#endregion
18939
+ //#region ../../packages/protocol/src/documents/identities.ts
18940
+ /** A caller handed this module a value its own types rule out: a defect, named. */
18941
+ function defect$1(step, message) {
18942
+ return new CapxulError("UNKNOWN", message, { details: { step } });
18943
+ }
18944
+ function hashDocumentOriginIdV3(input) {
18945
+ if (!Number.isSafeInteger(input.chainId) || input.chainId <= 0 || !Number.isSafeInteger(input.itemIndex) || input.itemIndex < 0 || input.actorKind !== "account" && input.actorKind !== "organization" || input.actorId.length === 0 || input.requestKey.length === 0) throw defect$1("hashDocumentOriginIdV3", "Invalid document origin input");
18946
+ return keccak256$1(encodeAbiParameters$1(parseAbiParameters("string namespace, uint256 chainId, string actorKind, string actorId, string requestKey, uint256 itemIndex"), [
18947
+ "capxul.document-origin.v3",
18948
+ BigInt(input.chainId),
18949
+ input.actorKind,
18950
+ input.actorId,
18951
+ input.requestKey,
18952
+ BigInt(input.itemIndex)
18953
+ ]));
18954
+ }
18955
+ //#endregion
18738
18956
  //#region ../../packages/sdk/src/documents/birth-context.ts
18739
18957
  function sourcePurpose(source) {
18740
18958
  if ("purposeKind" in source) return source.purposeKind;
@@ -18749,13 +18967,20 @@ function isBirthItem(item) {
18749
18967
  function requestRetryInstruction(input) {
18750
18968
  const request = input.evidence.request;
18751
18969
  const original = input.evidence.sourceCommand;
18752
- if (!("kind" in request) || request.kind !== "retry" || original?.kind !== "birth" || original.lineage?.kind !== "payment_request" && original.lineage?.kind !== "invoice_checkout" || original.lineage.requestId !== original.requestKey || !input.evidence.sourcePaymentIds?.includes(request.paymentId)) return void 0;
18970
+ if (!("kind" in request) || request.kind !== "retry" || original?.kind !== "birth" || original.lineage?.kind !== "payment_request" && original.lineage?.kind !== "invoice_checkout" || !input.evidence.sourcePaymentIds?.includes(request.paymentId)) return void 0;
18753
18971
  const document = original.items[input.index]?.document;
18754
18972
  if (document?.kind !== "envelope") return void 0;
18755
18973
  const bytes = decodeCanonicalBase64V3(document.bytesBase64);
18756
18974
  const envelope = decodeSupportedPaymentDocumentEnvelope(bytes);
18757
18975
  if (envelope.primaryType !== "Memo" && envelope.primaryType !== "Invoice") return void 0;
18758
18976
  if (envelope.version === 5) return void 0;
18977
+ if (original.lineage.requestId !== original.requestKey && (original.lineage.kind !== "payment_request" || envelope.primaryType !== "Invoice" || envelope.message.originId !== hashDocumentOriginIdV3({
18978
+ chainId: input.evidence.chainId,
18979
+ actorKind: original.actor.kind,
18980
+ actorId: original.actor.kind === "account" ? original.actor.accountId : original.actor.orgId,
18981
+ requestKey: original.lineage.requestId,
18982
+ itemIndex: input.index
18983
+ }))) return void 0;
18759
18984
  return {
18760
18985
  documentHash: hashSupportedPaymentDocument(envelope),
18761
18986
  contentHash: hashPaymentDocumentContentV3(bytes),
@@ -18784,11 +19009,7 @@ function requestBirthContext(evidence) {
18784
19009
  ].some((items) => items?.length !== 1)) return null;
18785
19010
  const item = command.items[0];
18786
19011
  const instruction = command.instructionDocuments?.[0];
18787
- if (!isBirthItem(item) || instruction === void 0 || source.lineage?.kind !== "payment_request" || [
18788
- source.lineage.requestId,
18789
- source.requestKey,
18790
- request.requestKey
18791
- ].some((key) => key !== request.confirmation.requestId) || documentJson(request.actor) !== documentJson(source.actor) || documentJson(request.items) !== documentJson(source.items) || evidence.sourcePaymentIds?.[0] !== evidence.paymentIds[0] || evidence.sourceRecipientSafes?.[0]?.toLowerCase() !== request.confirmation.issuerSafe.toLowerCase() || documentJson(evidence.documentBundles) !== documentJson(command.documentBundles) || !confirmedRequestFactsMatch(request.confirmation, source, item, instruction)) return null;
19012
+ if (!isBirthItem(item) || instruction === void 0 || source.lineage?.kind !== "payment_request" || source.lineage.requestId !== request.confirmation.requestId || [source.requestKey, request.requestKey].some((key) => key !== (request.confirmation.requestKey ?? request.confirmation.requestId)) || documentJson(request.actor) !== documentJson(source.actor) || documentJson(request.items) !== documentJson(source.items) || evidence.sourcePaymentIds?.[0] !== evidence.paymentIds[0] || evidence.sourceRecipientSafes?.[0]?.toLowerCase() !== request.confirmation.issuerSafe.toLowerCase() || documentJson(evidence.documentBundles) !== documentJson(command.documentBundles) || !confirmedRequestFactsMatch(request.confirmation, source, item, instruction)) return null;
18792
19013
  return {
18793
19014
  source: source.items,
18794
19015
  actorKind: source.actor.kind,
@@ -18814,126 +19035,6 @@ function retryBirthContext(evidence) {
18814
19035
  };
18815
19036
  }
18816
19037
  //#endregion
18817
- //#region ../../packages/protocol/src/evm/test-assets.ts
18818
- const SYNTHETIC_TEST_ASSET_SOURCE = "synthetic-test-liquidity";
18819
- /**
18820
- * Owned test assets, with metadata read from each creation receipt and contract.
18821
- * Settlement admission lives in assets.ts. The fixed test exchange uses the
18822
- * original five assets; bank EURC has its own deployment.
18823
- *
18824
- * `symbol` is the display string the owned contract returns. A
18825
- * provider-supported USDC would be a different contract at a different
18826
- * address returning the same symbol, which is why the resolvers below key on
18827
- * `assetId`, or on chain plus address, and never on a symbol.
18828
- */
18829
- const SYNTHETIC_TEST_ASSET_FIXTURES = {
18830
- usdc: {
18831
- assetId: assetIdFor(84532, "0x06ba8b863ca77490b0e7008427562bdbfcff730e"),
18832
- chainId: toChainId(84532),
18833
- tokenAddress: "0x06ba8b863ca77490b0e7008427562bdbfcff730e",
18834
- symbol: "USDC",
18835
- decimals: 6,
18836
- peg: toCurrencyCode("USD"),
18837
- deploymentStartBlock: 46690061,
18838
- deploymentTransaction: "0x2661b7af5f62b9e31c707a59746cda65b90ba4448852317ac1968162fb94ff52",
18839
- source: SYNTHETIC_TEST_ASSET_SOURCE
18840
- },
18841
- usdt: {
18842
- assetId: assetIdFor(84532, "0xcb5f361ae070e75d573941b8cd54995fa3876d75"),
18843
- chainId: toChainId(84532),
18844
- tokenAddress: "0xcb5f361ae070e75d573941b8cd54995fa3876d75",
18845
- symbol: "USDT",
18846
- decimals: 6,
18847
- peg: toCurrencyCode("USD"),
18848
- deploymentStartBlock: 46690061,
18849
- deploymentTransaction: "0x98e5303f97974a31eddb61ad030072d900ce7283ce8080bfe0b9e5ea6f297749",
18850
- source: SYNTHETIC_TEST_ASSET_SOURCE
18851
- },
18852
- weth: {
18853
- assetId: assetIdFor(84532, "0x85b7bd39ce3df9a85135e1e307225dd435f67e47"),
18854
- chainId: toChainId(84532),
18855
- tokenAddress: "0x85b7bd39ce3df9a85135e1e307225dd435f67e47",
18856
- symbol: "WETH",
18857
- decimals: 18,
18858
- peg: null,
18859
- deploymentStartBlock: 46690061,
18860
- deploymentTransaction: "0x48dfacc01c15adc34f6c629aec5c9ff7bb84176d448017da0d0d4fdaf8b5a68a",
18861
- source: SYNTHETIC_TEST_ASSET_SOURCE
18862
- },
18863
- wbtc: {
18864
- assetId: assetIdFor(84532, "0xcf433a81f507dcc88c2c404650ffafb40750b451"),
18865
- chainId: toChainId(84532),
18866
- tokenAddress: "0xcf433a81f507dcc88c2c404650ffafb40750b451",
18867
- symbol: "WBTC",
18868
- decimals: 8,
18869
- peg: null,
18870
- deploymentStartBlock: 46690061,
18871
- deploymentTransaction: "0xa975fcda0a67509742243bbfc386032d2e0d6ca78404c255fae2e4ffae1c7f4d",
18872
- source: SYNTHETIC_TEST_ASSET_SOURCE
18873
- },
18874
- cngn: {
18875
- assetId: assetIdFor(84532, "0xda515a7267e190710f0003f951c62bcfd70d6b2a"),
18876
- chainId: toChainId(84532),
18877
- tokenAddress: "0xda515a7267e190710f0003f951c62bcfd70d6b2a",
18878
- symbol: "cNGN",
18879
- decimals: 6,
18880
- peg: toCurrencyCode("NGN"),
18881
- deploymentStartBlock: 46690061,
18882
- deploymentTransaction: "0x6f6b0302448c7cd7db5c118a8250e548c6e72821df373e5a27550e5cdfa635a1",
18883
- source: SYNTHETIC_TEST_ASSET_SOURCE
18884
- },
18885
- eurc: {
18886
- assetId: assetIdFor(84532, "0x15055b4ed1d248c169b92705757cd9c3d985ad5f"),
18887
- chainId: toChainId(84532),
18888
- tokenAddress: "0x15055b4ed1d248c169b92705757cd9c3d985ad5f",
18889
- symbol: "EURC",
18890
- decimals: 6,
18891
- peg: toCurrencyCode("EUR"),
18892
- deploymentStartBlock: 47893251,
18893
- deploymentTransaction: "0x4e0ab412d980a672336487afd10da007d51f34f17876b19b13732c8125be90ca",
18894
- source: SYNTHETIC_TEST_ASSET_SOURCE
18895
- }
18896
- };
18897
- /** EURC is minted for bank deposits and has no admission to the fixed test exchange. */
18898
- const SYNTHETIC_TEST_ASSETS = [...[
18899
- SYNTHETIC_TEST_ASSET_FIXTURES.usdc,
18900
- SYNTHETIC_TEST_ASSET_FIXTURES.usdt,
18901
- SYNTHETIC_TEST_ASSET_FIXTURES.weth,
18902
- SYNTHETIC_TEST_ASSET_FIXTURES.wbtc,
18903
- SYNTHETIC_TEST_ASSET_FIXTURES.cngn
18904
- ], SYNTHETIC_TEST_ASSET_FIXTURES.eurc];
18905
- toChainId(84532);
18906
- /**
18907
- * The settlement tier: the owned test assets admitted to the exact-transfer
18908
- * path and to the treasury reads. USDC, USDT, WETH and EURC are admitted assets.
18909
- * There is no default token.
18910
- */
18911
- const SETTLEMENT_ASSETS_BASE_SEPOLIA = Object.freeze({
18912
- CAPXUL_TEST_USDC: SYNTHETIC_TEST_ASSET_FIXTURES.usdc,
18913
- CAPXUL_TEST_USDT: SYNTHETIC_TEST_ASSET_FIXTURES.usdt,
18914
- CAPXUL_TEST_WETH: SYNTHETIC_TEST_ASSET_FIXTURES.weth,
18915
- CAPXUL_TEST_EURC: SYNTHETIC_TEST_ASSET_FIXTURES.eurc
18916
- });
18917
- const CONFIGURED_MONEY_ASSETS = Object.freeze(Object.values(SETTLEMENT_ASSETS_BASE_SEPOLIA));
18918
- Object.freeze({ BASE_SEPOLIA: Object.freeze({
18919
- CAPXUL_TEST_USDC: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_USDC.assetId,
18920
- CAPXUL_TEST_USDT: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_USDT.assetId,
18921
- CAPXUL_TEST_WETH: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_WETH.assetId,
18922
- CAPXUL_TEST_EURC: SETTLEMENT_ASSETS_BASE_SEPOLIA.CAPXUL_TEST_EURC.assetId
18923
- }) });
18924
- /**
18925
- * Every known asset in ONE identity space. The tiers above declare admission;
18926
- * this is the only list an identity resolves against, so an asset is never
18927
- * two different things depending on which list a caller happened to read.
18928
- */
18929
- const MONEY_ASSET_REGISTRY = [...SYNTHETIC_TEST_ASSETS];
18930
- CONFIGURED_MONEY_ASSETS.map((asset) => asset.tokenAddress.toLowerCase());
18931
- /** The registry row for `assetId` across every tier, or `null`. */
18932
- function configuredMoneyAssetById(assetId) {
18933
- const canonical = toAssetId(assetId);
18934
- return MONEY_ASSET_REGISTRY.find((asset) => asset.assetId === canonical) ?? null;
18935
- }
18936
- //#endregion
18937
19038
  //#region ../../packages/protocol/src/documents/receipts.ts
18938
19039
  async function parseSupportingReceiptV3(input) {
18939
19040
  const supporting = SchemaParser.decodeUnknownSync(SupportingReceiptInputSchema, { onExcessProperty: "error" })(input);
@@ -18964,23 +19065,6 @@ async function parseSupportingReceiptV3(input) {
18964
19065
  };
18965
19066
  }
18966
19067
  //#endregion
18967
- //#region ../../packages/protocol/src/documents/identities.ts
18968
- /** A caller handed this module a value its own types rule out: a defect, named. */
18969
- function defect$1(step, message) {
18970
- return new CapxulError("UNKNOWN", message, { details: { step } });
18971
- }
18972
- function hashDocumentOriginIdV3(input) {
18973
- if (!Number.isSafeInteger(input.chainId) || input.chainId <= 0 || !Number.isSafeInteger(input.itemIndex) || input.itemIndex < 0 || input.actorKind !== "account" && input.actorKind !== "organization" || input.actorId.length === 0 || input.requestKey.length === 0) throw defect$1("hashDocumentOriginIdV3", "Invalid document origin input");
18974
- return keccak256$1(encodeAbiParameters$1(parseAbiParameters("string namespace, uint256 chainId, string actorKind, string actorId, string requestKey, uint256 itemIndex"), [
18975
- "capxul.document-origin.v3",
18976
- BigInt(input.chainId),
18977
- input.actorKind,
18978
- input.actorId,
18979
- input.requestKey,
18980
- BigInt(input.itemIndex)
18981
- ]));
18982
- }
18983
- //#endregion
18984
19068
  //#region ../../packages/protocol/src/documents/context.ts
18985
19069
  function sameAmount(left, right) {
18986
19070
  return left.asset === right.asset && left.minorUnits === right.minorUnits && left.decimals === right.decimals;
@@ -19261,6 +19345,25 @@ function verifiesInvoiceCheckoutBirthEvidence(evidence, invoice, chainId, source
19261
19345
  return "kind" in evidence.request && evidence.request.kind === "invoice_checkout" && evidence.request.linkToken === invoice.linkToken && evidence.preparedCommand?.items.length === 1 && item?.operation === "send" && evidence.preparedCommand.senderSafe.toLowerCase() === sourceWallet.toLowerCase() && evidence.preparedCommand.contractAddress.toLowerCase() === invoice.contractAddress.toLowerCase() && item.settlementId === invoice.settlementId && item.documentHash === invoice.documentHash && item.recipientSafe.toLowerCase() === invoice.recipientSafe.toLowerCase() && item.tokenAddress.toLowerCase() === invoice.tokenAddress.toLowerCase() && item.rawAmount === invoice.rawAmount && item.kind === (invoice.documentKind === "memo" ? 0 : 1) && invoice.chainId === chainId;
19262
19346
  }
19263
19347
  //#endregion
19348
+ //#region ../../packages/protocol/src/payments/execution-identity.ts
19349
+ /** A command and its exact signed operation have one durable execution identity. */
19350
+ function moneyExecutionId(commandId, digest) {
19351
+ return `money_execution_${keccak256$1(encodeAbiParameters$1([
19352
+ { type: "string" },
19353
+ { type: "string" },
19354
+ { type: "bytes32" }
19355
+ ], [
19356
+ "capxul.money-execution.v1",
19357
+ commandId,
19358
+ toLowerBytes32(digest)
19359
+ ])).slice(2)}`;
19360
+ }
19361
+ /** Existing stored executions keep their digest-derived identity. */
19362
+ function matchesMoneyExecutionId(executionId, digest, commandId) {
19363
+ const exactDigest = toLowerBytes32(digest);
19364
+ return executionId === `money_execution_${exactDigest.slice(2)}` || commandId !== void 0 && executionId === moneyExecutionId(commandId, exactDigest);
19365
+ }
19366
+ //#endregion
19264
19367
  //#region ../../packages/protocol/src/evm/payments-abi.ts
19265
19368
  /** The exact compiled CapxulPaymentsV2 ABI. */
19266
19369
  const CAPXUL_PAYMENTS_V2_ABI = [
@@ -19815,17 +19918,280 @@ const CAPXUL_PAYMENTS_V2_ABI = [
19815
19918
  },
19816
19919
  {
19817
19920
  type: "error",
19818
- name: "AlreadyCancelled",
19819
- inputs: []
19921
+ name: "AlreadyCancelled",
19922
+ inputs: []
19923
+ },
19924
+ {
19925
+ type: "error",
19926
+ name: "AlreadyClaimed",
19927
+ inputs: []
19928
+ },
19929
+ {
19930
+ type: "error",
19931
+ name: "DocumentHashMismatch",
19932
+ inputs: [{
19933
+ name: "expected",
19934
+ type: "bytes32",
19935
+ internalType: "bytes32"
19936
+ }, {
19937
+ name: "supplied",
19938
+ type: "bytes32",
19939
+ internalType: "bytes32"
19940
+ }]
19941
+ },
19942
+ {
19943
+ type: "error",
19944
+ name: "InvalidTimeParams",
19945
+ inputs: []
19946
+ },
19947
+ {
19948
+ type: "error",
19949
+ name: "NotCreator",
19950
+ inputs: []
19951
+ },
19952
+ {
19953
+ type: "error",
19954
+ name: "NotRecipient",
19955
+ inputs: []
19956
+ },
19957
+ {
19958
+ type: "error",
19959
+ name: "NothingToClaim",
19960
+ inputs: []
19961
+ },
19962
+ {
19963
+ type: "error",
19964
+ name: "SettlementIdConsumed",
19965
+ inputs: [{
19966
+ name: "settlementId",
19967
+ type: "bytes32",
19968
+ internalType: "bytes32"
19969
+ }]
19970
+ },
19971
+ {
19972
+ type: "error",
19973
+ name: "TokenCallReturnedFalse",
19974
+ inputs: [{
19975
+ name: "token",
19976
+ type: "address",
19977
+ internalType: "address"
19978
+ }]
19979
+ },
19980
+ {
19981
+ type: "error",
19982
+ name: "TokenHasNoCode",
19983
+ inputs: [{
19984
+ name: "token",
19985
+ type: "address",
19986
+ internalType: "address"
19987
+ }]
19988
+ },
19989
+ {
19990
+ type: "error",
19991
+ name: "ZeroAddress",
19992
+ inputs: []
19993
+ },
19994
+ {
19995
+ type: "error",
19996
+ name: "ZeroAmount",
19997
+ inputs: []
19998
+ },
19999
+ {
20000
+ type: "error",
20001
+ name: "ZeroDocumentHash",
20002
+ inputs: []
20003
+ },
20004
+ {
20005
+ type: "error",
20006
+ name: "ZeroSettlementId",
20007
+ inputs: []
20008
+ }
20009
+ ];
20010
+ /** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
20011
+ const CAPXUL_PAYMENTS_V2_ADDRESS = "0x7a5c25aB7ce91d7a475B71cd1ec33E230291f8a4";
20012
+ //#endregion
20013
+ //#region ../../packages/protocol/src/evm/payments-v3.ts
20014
+ const PAYMENT_ITEM_COMPONENTS = [
20015
+ {
20016
+ name: "settlementId",
20017
+ type: "bytes32",
20018
+ internalType: "bytes32"
20019
+ },
20020
+ {
20021
+ name: "recipient",
20022
+ type: "address",
20023
+ internalType: "address"
20024
+ },
20025
+ {
20026
+ name: "token",
20027
+ type: "address",
20028
+ internalType: "address"
20029
+ },
20030
+ {
20031
+ name: "amount",
20032
+ type: "uint256",
20033
+ internalType: "uint256"
20034
+ },
20035
+ {
20036
+ name: "kind",
20037
+ type: "uint16",
20038
+ internalType: "uint16"
20039
+ },
20040
+ {
20041
+ name: "documentHash",
20042
+ type: "bytes32",
20043
+ internalType: "bytes32"
20044
+ },
20045
+ {
20046
+ name: "jobNonce",
20047
+ type: "bytes32",
20048
+ internalType: "bytes32"
20049
+ },
20050
+ {
20051
+ name: "executor",
20052
+ type: "address",
20053
+ internalType: "address"
20054
+ }
20055
+ ];
20056
+ const PAYMENT_ITEM_INPUT = {
20057
+ name: "item",
20058
+ type: "tuple",
20059
+ internalType: "struct CapxulPaymentsV3.PaymentItem",
20060
+ components: PAYMENT_ITEM_COMPONENTS
20061
+ };
20062
+ /** The exact compiled CapxulPaymentsV3 ABI. */
20063
+ const CAPXUL_PAYMENTS_V3_ABI = [
20064
+ {
20065
+ type: "function",
20066
+ name: "paymentId",
20067
+ inputs: [PAYMENT_ITEM_INPUT],
20068
+ outputs: [{
20069
+ name: "",
20070
+ type: "bytes32",
20071
+ internalType: "bytes32"
20072
+ }],
20073
+ stateMutability: "view"
20074
+ },
20075
+ {
20076
+ type: "function",
20077
+ name: "send",
20078
+ inputs: [PAYMENT_ITEM_INPUT],
20079
+ outputs: [],
20080
+ stateMutability: "nonpayable"
20081
+ },
20082
+ {
20083
+ type: "function",
20084
+ name: "sendBatch",
20085
+ inputs: [{
20086
+ name: "items",
20087
+ type: "tuple[]",
20088
+ internalType: "struct CapxulPaymentsV3.PaymentItem[]",
20089
+ components: PAYMENT_ITEM_COMPONENTS
20090
+ }],
20091
+ outputs: [],
20092
+ stateMutability: "nonpayable"
20093
+ },
20094
+ {
20095
+ type: "function",
20096
+ name: "settled",
20097
+ inputs: [{
20098
+ name: "",
20099
+ type: "bytes32",
20100
+ internalType: "bytes32"
20101
+ }],
20102
+ outputs: [{
20103
+ name: "",
20104
+ type: "bool",
20105
+ internalType: "bool"
20106
+ }],
20107
+ stateMutability: "view"
20108
+ },
20109
+ {
20110
+ type: "event",
20111
+ name: "PaymentSent",
20112
+ inputs: [
20113
+ {
20114
+ name: "settlementId",
20115
+ type: "bytes32",
20116
+ indexed: true,
20117
+ internalType: "bytes32"
20118
+ },
20119
+ {
20120
+ name: "sender",
20121
+ type: "address",
20122
+ indexed: true,
20123
+ internalType: "address"
20124
+ },
20125
+ {
20126
+ name: "recipient",
20127
+ type: "address",
20128
+ indexed: true,
20129
+ internalType: "address"
20130
+ },
20131
+ {
20132
+ name: "token",
20133
+ type: "address",
20134
+ indexed: false,
20135
+ internalType: "address"
20136
+ },
20137
+ {
20138
+ name: "amount",
20139
+ type: "uint256",
20140
+ indexed: false,
20141
+ internalType: "uint256"
20142
+ },
20143
+ {
20144
+ name: "kind",
20145
+ type: "uint16",
20146
+ indexed: false,
20147
+ internalType: "uint16"
20148
+ },
20149
+ {
20150
+ name: "documentHash",
20151
+ type: "bytes32",
20152
+ indexed: false,
20153
+ internalType: "bytes32"
20154
+ }
20155
+ ],
20156
+ anonymous: false
20157
+ },
20158
+ {
20159
+ type: "error",
20160
+ name: "InexactTransfer",
20161
+ inputs: [
20162
+ {
20163
+ name: "token",
20164
+ type: "address",
20165
+ internalType: "address"
20166
+ },
20167
+ {
20168
+ name: "expected",
20169
+ type: "uint256",
20170
+ internalType: "uint256"
20171
+ },
20172
+ {
20173
+ name: "received",
20174
+ type: "uint256",
20175
+ internalType: "uint256"
20176
+ }
20177
+ ]
19820
20178
  },
19821
20179
  {
19822
20180
  type: "error",
19823
- name: "AlreadyClaimed",
19824
- inputs: []
20181
+ name: "InvalidExecutor",
20182
+ inputs: [{
20183
+ name: "expected",
20184
+ type: "address",
20185
+ internalType: "address"
20186
+ }, {
20187
+ name: "supplied",
20188
+ type: "address",
20189
+ internalType: "address"
20190
+ }]
19825
20191
  },
19826
20192
  {
19827
20193
  type: "error",
19828
- name: "DocumentHashMismatch",
20194
+ name: "PaymentIdMismatch",
19829
20195
  inputs: [{
19830
20196
  name: "expected",
19831
20197
  type: "bytes32",
@@ -19838,22 +20204,7 @@ const CAPXUL_PAYMENTS_V2_ABI = [
19838
20204
  },
19839
20205
  {
19840
20206
  type: "error",
19841
- name: "InvalidTimeParams",
19842
- inputs: []
19843
- },
19844
- {
19845
- type: "error",
19846
- name: "NotCreator",
19847
- inputs: []
19848
- },
19849
- {
19850
- type: "error",
19851
- name: "NotRecipient",
19852
- inputs: []
19853
- },
19854
- {
19855
- type: "error",
19856
- name: "NothingToClaim",
20207
+ name: "ReentrantCall",
19857
20208
  inputs: []
19858
20209
  },
19859
20210
  {
@@ -19898,14 +20249,73 @@ const CAPXUL_PAYMENTS_V2_ABI = [
19898
20249
  name: "ZeroDocumentHash",
19899
20250
  inputs: []
19900
20251
  },
20252
+ {
20253
+ type: "error",
20254
+ name: "ZeroJobNonce",
20255
+ inputs: []
20256
+ },
19901
20257
  {
19902
20258
  type: "error",
19903
20259
  name: "ZeroSettlementId",
19904
20260
  inputs: []
19905
20261
  }
19906
20262
  ];
19907
- /** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
19908
- const CAPXUL_PAYMENTS_V2_ADDRESS = "0x7a5c25aB7ce91d7a475B71cd1ec33E230291f8a4";
20263
+ /** The fixed CREATE2 deployment on every admitted chain. */
20264
+ const CAPXUL_PAYMENTS_V3_ADDRESS = "0x46b28f455c8de7c1505e3185A3f8f87B07eaE1aE";
20265
+ //#endregion
20266
+ //#region ../../packages/protocol/src/evm/payments/encoding.ts
20267
+ const CAPXUL_PAYMENT_V3_TYPEHASH = keccak256$1(toBytes$1("CapxulPayment(uint256 chainId,address router,bytes32 jobNonce,address executor,address recipient,address token,uint256 amount,uint16 kind,bytes32 documentHash)"));
20268
+ function paymentJobNonce(commandId, itemIndex) {
20269
+ if (!Number.isSafeInteger(itemIndex) || itemIndex < 0) throw Errors.invalidInput("itemIndex", "must be a non-negative safe integer");
20270
+ return sha256(toBytes$1(`{"commandId":${JSON.stringify(commandId)},"index":${itemIndex},"version":1}`));
20271
+ }
20272
+ function capxulPaymentsV3PaymentId(chainId, router, item) {
20273
+ return keccak256$1(encodeAbiParameters$1(parseAbiParameters("bytes32,uint256,address,bytes32,address,address,address,uint256,uint16,bytes32"), [
20274
+ CAPXUL_PAYMENT_V3_TYPEHASH,
20275
+ BigInt(chainId),
20276
+ router,
20277
+ item.jobNonce,
20278
+ item.executor,
20279
+ item.recipient,
20280
+ item.token,
20281
+ item.amount,
20282
+ item.kind,
20283
+ item.documentHash
20284
+ ]));
20285
+ }
20286
+ function encodeCapxulPaymentsV3Send(item) {
20287
+ return encodeFunctionData({
20288
+ abi: CAPXUL_PAYMENTS_V3_ABI,
20289
+ functionName: "send",
20290
+ args: [item]
20291
+ });
20292
+ }
20293
+ function encodeCapxulPaymentsV3SendBatch(items) {
20294
+ return encodeFunctionData({
20295
+ abi: CAPXUL_PAYMENTS_V3_ABI,
20296
+ functionName: "sendBatch",
20297
+ args: [items]
20298
+ });
20299
+ }
20300
+ function v3Item(command, item, itemIndex) {
20301
+ const { commandId, chainId, senderSafe } = command;
20302
+ if (commandId === void 0 || chainId === void 0 || senderSafe === void 0) throw Errors.invalidInput("command", "CapxulPaymentsV3 requires its command identity");
20303
+ const terms = {
20304
+ recipient: item.recipientSafe,
20305
+ token: item.tokenAddress,
20306
+ amount: BigInt(item.rawAmount),
20307
+ kind: item.kind,
20308
+ documentHash: item.documentHash,
20309
+ jobNonce: item.jobNonce ?? paymentJobNonce(commandId, itemIndex),
20310
+ executor: item.executor ?? senderSafe
20311
+ };
20312
+ const settlementId = capxulPaymentsV3PaymentId(chainId, command.contractAddress, terms);
20313
+ if (settlementId.toLowerCase() !== item.settlementId.toLowerCase()) throw Errors.invalidInput("settlementId", "does not match CapxulPaymentsV3 terms");
20314
+ return {
20315
+ settlementId,
20316
+ ...terms
20317
+ };
20318
+ }
19909
20319
  //#endregion
19910
20320
  //#region ../../packages/protocol/src/evm/zodiac-abi.ts
19911
20321
  const MODULE_PROXY_FACTORY_ABI = [{
@@ -20270,7 +20680,8 @@ function requiredByPaymentToken(items) {
20270
20680
  }
20271
20681
  return totals;
20272
20682
  }
20273
- function birthCall(contract, item) {
20683
+ function birthCall(command, item, itemIndex) {
20684
+ const contract = command.contractAddress;
20274
20685
  const common = {
20275
20686
  settlementId: item.settlementId,
20276
20687
  recipient: item.recipientSafe,
@@ -20281,7 +20692,7 @@ function birthCall(contract, item) {
20281
20692
  return {
20282
20693
  to: contract,
20283
20694
  value: 0n,
20284
- data: item.operation === "send" ? encodeCapxulPaymentsV2Send({
20695
+ data: item.operation === "send" ? contract.toLowerCase() === "0x46b28f455c8de7c1505e3185A3f8f87B07eaE1aE".toLowerCase() ? encodeCapxulPaymentsV3Send(v3Item(command, item, itemIndex)) : encodeCapxulPaymentsV2Send({
20285
20696
  ...common,
20286
20697
  amount: BigInt(item.rawAmount)
20287
20698
  }) : encodeCapxulPaymentsV2CreateCommitment({
@@ -20293,7 +20704,8 @@ function birthCall(contract, item) {
20293
20704
  })
20294
20705
  };
20295
20706
  }
20296
- function birthCalls(contract, items) {
20707
+ function birthCalls(command, items) {
20708
+ const contract = command.contractAddress;
20297
20709
  const approvals = [...requiredByPaymentToken(items).values()].map(({ token, total }) => ({
20298
20710
  to: token,
20299
20711
  value: 0n,
@@ -20307,7 +20719,7 @@ function birthCalls(contract, items) {
20307
20719
  if (items.length > 1 && sends.length === items.length) return [...approvals, {
20308
20720
  to: contract,
20309
20721
  value: 0n,
20310
- data: encodeCapxulPaymentsV2SendBatch(sends.map((item) => ({
20722
+ data: contract.toLowerCase() === "0x46b28f455c8de7c1505e3185A3f8f87B07eaE1aE".toLowerCase() ? encodeCapxulPaymentsV3SendBatch(sends.map((item, index) => v3Item(command, item, index))) : encodeCapxulPaymentsV2SendBatch(sends.map((item) => ({
20311
20723
  settlementId: item.settlementId,
20312
20724
  recipient: item.recipientSafe,
20313
20725
  token: item.tokenAddress,
@@ -20316,7 +20728,7 @@ function birthCalls(contract, items) {
20316
20728
  documentHash: item.documentHash
20317
20729
  })))
20318
20730
  }];
20319
- return [...approvals, ...items.map((item) => birthCall(contract, item))];
20731
+ return [...approvals, ...items.map((item, index) => birthCall(command, item, index))];
20320
20732
  }
20321
20733
  function lifecycleData(item) {
20322
20734
  switch (item.operation) {
@@ -20331,7 +20743,7 @@ function encodePreparedPaymentCallData(command) {
20331
20743
  if (command.items.length === 0) throw Errors.invalidInput("items", "must not be empty");
20332
20744
  const births = command.items.filter(isBirth);
20333
20745
  if (births.length === command.items.length) {
20334
- const calls = birthCalls(command.contractAddress, births);
20746
+ const calls = birthCalls(command, births);
20335
20747
  return command.executionRoute.kind === "direct" ? safe4337MultiSendUserOpCallData({ calls }) : buildOrgRoleSpendPersonalCallData(buildOrgRoleMultiCall({
20336
20748
  rolesModuleAddress: command.executionRoute.rolesModule,
20337
20749
  roleKey: command.executionRoute.roleKey,
@@ -20394,15 +20806,16 @@ function verifiesMoneyOperation(evidence, expectedSafe, chainId, permissionId) {
20394
20806
  try {
20395
20807
  const command = evidence.preparedCommand;
20396
20808
  const operation = evidence.userOperation;
20397
- if (command === void 0 || operation === void 0 || false) return false;
20398
- if (command.commandId !== evidence.commandId || command.chainId !== chainId || evidence.chainId !== chainId || command.contractAddress.toLowerCase() !== "0x7a5c25aB7ce91d7a475B71cd1ec33E230291f8a4".toLowerCase() || command.items.length !== evidence.paymentIds.length || command.items.some((item, index) => item.paymentId !== evidence.paymentIds[index]) || evidence.userOpSenderSafe.toLowerCase() !== expectedSafe.toLowerCase() || command.executionRoute.userOpSenderSafe.toLowerCase() !== expectedSafe.toLowerCase() || operation.sender.toLowerCase() !== expectedSafe.toLowerCase()) return false;
20809
+ if (command === void 0 || operation === void 0) return false;
20810
+ const knownRouter = command.contractAddress.toLowerCase() === "0x7a5c25aB7ce91d7a475B71cd1ec33E230291f8a4".toLowerCase() || command.contractAddress.toLowerCase() === "0x46b28f455c8de7c1505e3185A3f8f87B07eaE1aE".toLowerCase();
20811
+ if (command.commandId !== evidence.commandId || command.chainId !== chainId || evidence.chainId !== chainId || !knownRouter || command.items.length !== evidence.paymentIds.length || command.items.some((item, index) => item.paymentId !== evidence.paymentIds[index]) || evidence.userOpSenderSafe.toLowerCase() !== expectedSafe.toLowerCase() || command.executionRoute.userOpSenderSafe.toLowerCase() !== expectedSafe.toLowerCase() || operation.sender.toLowerCase() !== expectedSafe.toLowerCase()) return false;
20399
20812
  const route = command.executionRoute;
20400
20813
  if (route.kind === "direct") {
20401
20814
  if (permissionId !== void 0 || command.senderSafe.toLowerCase() !== expectedSafe.toLowerCase()) return false;
20402
20815
  } else if ((permissionId === void 0 ? !isOwnerLifecycle(command) : route.roleKey.toLowerCase() !== roleKeyForPermission(permissionId).toLowerCase()) || command.senderSafe.toLowerCase() !== route.organizationSafe.toLowerCase()) return false;
20403
20816
  if (operation.callData.toLowerCase() !== encodePreparedPaymentCallData(command).toLowerCase()) return false;
20404
20817
  const digest = moneySafeOpDigest(operation, chainId);
20405
- return evidence.digest.toLowerCase() === digest.toLowerCase() && evidence.executionId === `money_execution_${digest.slice(2).toLowerCase()}`;
20818
+ return evidence.digest.toLowerCase() === digest.toLowerCase() && matchesMoneyExecutionId(evidence.executionId, digest, evidence.commandId);
20406
20819
  } catch {
20407
20820
  return false;
20408
20821
  }
@@ -20538,6 +20951,29 @@ function reportMoneyTelemetryFailure(kind, name, cause) {
20538
20951
  }));
20539
20952
  }
20540
20953
  //#endregion
20954
+ //#region ../../packages/protocol/src/payments/request-finality.ts
20955
+ /** Add a proved request outcome without changing the original failure. */
20956
+ function withPaymentRequestFinality(error, paymentRequestFinality) {
20957
+ const marked = new CapxulError(error.code, error.message, {
20958
+ cause: error.cause,
20959
+ details: {
20960
+ ...error.details,
20961
+ paymentRequestFinality
20962
+ },
20963
+ ...error.correlationId === void 0 ? {} : { correlationId: error.correlationId },
20964
+ ...error.layer === void 0 ? {} : { layer: error.layer },
20965
+ ...error.mode === void 0 ? {} : { mode: error.mode },
20966
+ ...error.chain === void 0 ? {} : { chain: error.chain }
20967
+ });
20968
+ marked.name = error.name;
20969
+ if (error.stack !== void 0) marked.stack = error.stack;
20970
+ return marked;
20971
+ }
20972
+ /** Only an authoritative failed-key response or confirmed durable closure resolves a key. */
20973
+ function isFinalPaymentRequestError(error) {
20974
+ return error.details?.paymentRequestFinality === "closed" || error.code === "INVALID_INPUT" && error.details?.field === "requestKey" && error.details.paymentRequestFinality === "failed";
20975
+ }
20976
+ //#endregion
20541
20977
  //#region ../../packages/sdk/src/payments/prepared-execution.ts
20542
20978
  async function abandonPrepared(deps, executionId, reason, result, onPreparedClosed) {
20543
20979
  const abandoned = await runIfActive(void 0, executions.abandon.name, () => callOperation(deps.convexCall, executions.abandon, {
@@ -20545,8 +20981,12 @@ async function abandonPrepared(deps, executionId, reason, result, onPreparedClos
20545
20981
  reason
20546
20982
  }).pipe(Effect.mapError((publicError) => ({ publicError }))), deps.runPromise);
20547
20983
  if (!abandoned.ok) return abandoned;
20548
- if (abandoned.value) onPreparedClosed?.();
20549
- return result;
20984
+ if (!abandoned.value) return result;
20985
+ onPreparedClosed?.();
20986
+ return result.ok ? result : {
20987
+ ok: false,
20988
+ error: withPaymentRequestFinality(result.error, "closed")
20989
+ };
20550
20990
  }
20551
20991
  async function notifyVerifiedPaymentPrepared(onPrepared, paymentId) {
20552
20992
  if (onPrepared === void 0) return {
@@ -20590,14 +21030,31 @@ async function abandonPreparedCommand(deps, executionId, closePayment, reason, r
20590
21030
  reason
20591
21031
  })).pipe(Effect.mapError((publicError) => ({ publicError })))), controls), deps.runPromise);
20592
21032
  if (!abandoned.ok) return abandoned;
20593
- if (abandoned.value) onPreparedClosed?.();
20594
- return result;
21033
+ if (!abandoned.value) return result;
21034
+ onPreparedClosed?.();
21035
+ return result.ok ? result : {
21036
+ ok: false,
21037
+ error: withPaymentRequestFinality(result.error, "closed")
21038
+ };
20595
21039
  }
20596
21040
  //#endregion
20597
21041
  //#region ../../packages/sdk/src/payments/command-execution.ts
20598
21042
  function isAborted$3(signal) {
20599
21043
  return signal?.aborted === true;
20600
21044
  }
21045
+ function settledPaymentsMatch(evidence) {
21046
+ try {
21047
+ return evidence.settled?.payments.every((payment, index) => {
21048
+ const item = evidence.preparedCommand?.items[index];
21049
+ const instructions = payment.documents.filter((document) => document.role === "instruction");
21050
+ const amount = toExactAssetAmount(payment.amount, CONFIGURED_MONEY_ASSETS);
21051
+ const asset = CONFIGURED_MONEY_ASSETS.find((row) => row.assetId === amount.asset);
21052
+ return item?.operation === "send" && payment.status === "settled" && payment.direction === "out" && payment.receipt?.chainId === evidence.chainId && item.tokenAddress.toLowerCase() === asset?.tokenAddress.toLowerCase() && item.rawAmount === amount.minorUnits && instructions.length === 1 && canonicalJson(instructions[0]) === canonicalJson(evidence.preparedCommand?.instructionDocuments?.[index]);
21053
+ }) === true;
21054
+ } catch {
21055
+ return false;
21056
+ }
21057
+ }
20601
21058
  async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnExit, onPreparedClosed, signal, controls, onPrepared, readAcceptedReplay, checkout, sourceWallet) {
20602
21059
  if (isAborted$3(signal)) return {
20603
21060
  ok: false,
@@ -20630,7 +21087,7 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
20630
21087
  const prepared = await prepare(signerAddress);
20631
21088
  if (!current()) return cancelled;
20632
21089
  if (!prepared.ok) return prepared;
20633
- const accepted = readAcceptedReplay?.();
21090
+ const accepted = readAcceptedReplay?.() ?? prepared.value.settled;
20634
21091
  const closePrepared = closePaymentOnExit && accepted === void 0;
20635
21092
  const executionId = Schema.decodeUnknownResult(MoneyExecutionIdSchema)(readField(prepared.value, "executionId"));
20636
21093
  if (executionId._tag === "Failure") return {
@@ -20656,12 +21113,12 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
20656
21113
  if (!verified) return abandon("prepared_mismatch", Errors.invalidInput("execution", "prepared Money operation mismatch"));
20657
21114
  if (accepted !== void 0) {
20658
21115
  const decodedSubmission = Schema.decodeResult(SubmittedPaymentCommandExecutionSchema, { onExcessProperty: "error" })(accepted);
20659
- if (decodedSubmission._tag === "Failure" || !acceptedSubmissionMatches(evidence, decodedSubmission.success)) return {
21116
+ if (decodedSubmission._tag === "Failure" || !acceptedSubmissionMatches(evidence, decodedSubmission.success) || evidence.settled !== void 0 && !settledPaymentsMatch(evidence)) return {
20660
21117
  ok: false,
20661
- error: Errors.invalidInput("execution", "accepted Payroll replay evidence mismatch")
21118
+ error: Errors.invalidInput("execution", "accepted Money replay evidence mismatch")
20662
21119
  };
20663
21120
  if (!current() || isAborted$3(signal)) return cancelled;
20664
- return {
21121
+ if (evidence.settled === void 0) return {
20665
21122
  ok: true,
20666
21123
  value: decodedSubmission.success
20667
21124
  };
@@ -20678,6 +21135,10 @@ async function executePrepared(deps, prepare, isExpectedRequest, closePaymentOnE
20678
21135
  }
20679
21136
  if (!current()) return cancelled;
20680
21137
  if (isAborted$3(signal)) return abandon("cancelled", Errors.cancelled({ operation: "payments" }));
21138
+ if (evidence.settled !== void 0) return {
21139
+ ok: true,
21140
+ value: evidence.settled
21141
+ };
20681
21142
  await emitPreparedInitiation(deps, evidence);
20682
21143
  if (!current()) return cancelled;
20683
21144
  if (isAborted$3(signal)) return abandon("cancelled", Errors.cancelled({ operation: "payments" }));
@@ -20728,10 +21189,10 @@ function itemMatches(prepared, amount) {
20728
21189
  return item.paymentId === prepared.paymentId && Object.entries(PAYMENT_PURPOSE_KIND_CODES).some(([name, code]) => name === prepared.purposeKind && code === item.kind) && expectedPurpose === prepared.purposeKind && documentKind === "invoice" === (purpose === "invoice") && purpose !== "payroll" && item.tokenAddress.toLowerCase() === asset?.tokenAddress.toLowerCase() && (item.operation === "send" ? item.rawAmount : item.totalAmount) === amount.minorUnits && plannedCommitmentMatches(prepared) && recipientMatches(prepared, item.recipientSafe.toLowerCase());
20729
21190
  }
20730
21191
  /** The callData a personal Payment birth item must carry: approve, then send or commit. */
20731
- function expectedPersonalCallData(prepared) {
21192
+ function expectedPersonalCallData(prepared, expectedSafe, chainId) {
20732
21193
  const item = prepared.item;
20733
21194
  if (item.operation !== "send" && item.operation !== "create_commitment") throw new Error("Expected personal Payment birth item");
20734
- const contract = CAPXUL_PAYMENTS_V2_ADDRESS;
21195
+ const contract = toAddress(CAPXUL_PAYMENTS_V2_ADDRESS);
20735
21196
  const { settlementId, recipientSafe, tokenAddress, documentHash } = item;
20736
21197
  const amount = BigInt(item.operation === "send" ? item.rawAmount : item.totalAmount);
20737
21198
  const paymentData = item.operation === "send" ? encodeCapxulPaymentsV2Send({
@@ -20752,26 +21213,61 @@ function expectedPersonalCallData(prepared) {
20752
21213
  kind: item.kind,
20753
21214
  documentHash
20754
21215
  });
20755
- return safe4337MultiSendUserOpCallData({ calls: [{
21216
+ const calls = (router, encodedPaymentData) => safe4337MultiSendUserOpCallData({ calls: [{
20756
21217
  to: tokenAddress,
20757
21218
  value: 0n,
20758
21219
  data: encodeFunctionData({
20759
21220
  abi: ERC20_APPROVE_ABI,
20760
21221
  functionName: "approve",
20761
- args: [contract, amount]
21222
+ args: [router, amount]
20762
21223
  })
20763
21224
  }, {
20764
- to: contract,
21225
+ to: router,
20765
21226
  value: 0n,
20766
- data: paymentData
21227
+ data: encodedPaymentData
20767
21228
  }] });
21229
+ const v2 = calls(contract, paymentData);
21230
+ if (item.operation !== "send") return [v2];
21231
+ const terms = {
21232
+ recipient: item.recipientSafe,
21233
+ token: item.tokenAddress,
21234
+ amount,
21235
+ kind: item.kind,
21236
+ documentHash,
21237
+ jobNonce: paymentJobNonce(prepared.commandId, 0),
21238
+ executor: toAddress(expectedSafe)
21239
+ };
21240
+ const v3Contract = toAddress(CAPXUL_PAYMENTS_V3_ADDRESS);
21241
+ const v3SettlementId = capxulPaymentsV3PaymentId(chainId, v3Contract, terms);
21242
+ if (v3SettlementId.toLowerCase() !== settlementId.toLowerCase()) return [v2];
21243
+ return [calls(v3Contract, encodeCapxulPaymentsV3Send({
21244
+ settlementId: v3SettlementId,
21245
+ ...terms
21246
+ }))];
20768
21247
  }
20769
21248
  function verifiesPersonalOperation(prepared, expectedSafe, chainId) {
20770
21249
  try {
20771
21250
  const operation = prepared.userOperation;
20772
- if (operation.sender.toLowerCase() !== expectedSafe.toLowerCase() || operation.callData.toLowerCase() !== expectedPersonalCallData(prepared).toLowerCase()) return false;
21251
+ if (operation.sender.toLowerCase() !== expectedSafe.toLowerCase() || !expectedPersonalCallData(prepared, expectedSafe, chainId).some((callData) => operation.callData.toLowerCase() === callData.toLowerCase())) return false;
20773
21252
  const digest = moneySafeOpDigest(operation, chainId);
20774
- return prepared.digest.toLowerCase() === digest.toLowerCase() && prepared.executionId === `money_execution_${digest.slice(2).toLowerCase()}`;
21253
+ return prepared.digest.toLowerCase() === digest.toLowerCase() && matchesMoneyExecutionId(prepared.executionId, digest, prepared.commandId);
21254
+ } catch {
21255
+ return false;
21256
+ }
21257
+ }
21258
+ /** A settled reply retains the verified operation, quantity, instruction and receipt. */
21259
+ function verifiesSettledPersonalReplay(evidence) {
21260
+ const settled = evidence.settled;
21261
+ if (settled === void 0) return true;
21262
+ try {
21263
+ const instructions = settled.payment.documents.filter((document) => document.role === "instruction");
21264
+ return acceptedSubmissionMatches({
21265
+ ...evidence,
21266
+ paymentIds: [evidence.paymentId]
21267
+ }, {
21268
+ ...settled,
21269
+ payments: [settled.payment]
21270
+ }) && settled.payment.status === "settled" && settled.payment.direction === "out" && settled.payment.receipt?.chainId === evidence.chainId && itemMatches(evidence, toExactAssetAmount(settled.payment.amount, CONFIGURED_MONEY_ASSETS)) && instructions.length === 1 && canonicalJson(instructions[0]) === canonicalJson(evidence.instructionDocument);
20775
21271
  } catch {
20776
21272
  return false;
20777
21273
  }
@@ -20885,6 +21381,7 @@ async function preparedMismatch(chainId, evidence, payment, expected) {
20885
21381
  if (evidence.userOpSenderSafe.toLowerCase() !== expected.expectedSafe.toLowerCase()) return mismatch$1("userOpSenderSafe", "prepared Payment execution uses another Account Safe");
20886
21382
  if (!await verifiesPersonalDocument(evidence)) return mismatch$1("document", "prepared Payment document does not match the request");
20887
21383
  if (!verifiesPersonalOperation(evidence, expected.expectedSafe, chainId)) return mismatch$1("execution", "prepared Payment operation does not match the request");
21384
+ if (!verifiesSettledPersonalReplay(evidence)) return mismatch$1("execution", "settled Payment replay evidence mismatch");
20888
21385
  }
20889
21386
  /**
20890
21387
  * Prepare one personal Payment for this signer and check what the backend
@@ -20935,19 +21432,27 @@ async function emitPreparedPaymentInitiated(deps, evidence) {
20935
21432
  async function executePersonalPayment(deps, payment, signal, requestKey, onPreparedClosed, onPrepared) {
20936
21433
  if (isAborted$2(signal)) return cancelled$1(CAPXUL_OPERATIONS.payments.pay);
20937
21434
  if (deps.signer === void 0) return mismatch$1("signer", "payments.pay requires a configured CapxulSigner");
20938
- if (deps.actor.authSession() === null) return {
21435
+ const session = deps.actor.authSession();
21436
+ if (session === null) return {
20939
21437
  ok: false,
20940
21438
  error: Errors.notAuthenticated()
20941
21439
  };
21440
+ const lifetime = deps.actor.authLifetime();
21441
+ const current = () => deps.actor.matchesAuthLifetime(lifetime, session.authUserId);
20942
21442
  const signerAddress = await signerCall(deps.signer.source, "getAddress", () => deps.signer.getAddress());
20943
21443
  if (!signerAddress.ok) return signerAddress;
20944
21444
  const prepared = await prepareVerifiedPersonalPayment(deps, payment, signerAddress.value, requestKey ?? `pay_${crypto.randomUUID()}`, signal, onPreparedClosed);
20945
21445
  if (!prepared.ok) return prepared;
20946
21446
  const evidence = prepared.value;
21447
+ if (evidence.settled !== void 0 && !current()) return cancelled$1(CAPXUL_OPERATIONS.payments.pay);
20947
21448
  const digest = evidence.digest;
20948
21449
  if (isAborted$2(signal)) return abandonPrepared(deps, evidence.executionId, "cancelled", cancelled$1(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
20949
21450
  const delivered = await notifyVerifiedPaymentPrepared(onPrepared, evidence.paymentId);
20950
21451
  if (!delivered.ok) return delivered;
21452
+ if (evidence.settled !== void 0) return current() ? {
21453
+ ok: true,
21454
+ value: evidence.settled
21455
+ } : cancelled$1(CAPXUL_OPERATIONS.payments.pay);
20951
21456
  if (isAborted$2(signal)) return abandonPrepared(deps, evidence.executionId, "cancelled", cancelled$1(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
20952
21457
  await emitPreparedPaymentInitiated(deps, evidence);
20953
21458
  if (isAborted$2(signal)) return abandonPrepared(deps, evidence.executionId, "cancelled", cancelled$1(CAPXUL_OPERATIONS.payments.pay), onPreparedClosed);
@@ -21450,6 +21955,41 @@ function resolvedTargetFromResolution(resolution) {
21450
21955
  };
21451
21956
  }
21452
21957
  //#endregion
21958
+ //#region ../../packages/sdk/src/requests/request-keys.ts
21959
+ /** Keep an Invoice attempt through uncertainty; renew an old failed default only before preparation. */
21960
+ async function withInvoiceRequestKey(actorId, intent, provided, run) {
21961
+ let key;
21962
+ let prepared = false;
21963
+ try {
21964
+ key = await paymentRequestKeyLifecycle(`invoice-request:${actorId}`, intent, provided);
21965
+ let result = await run(key.key, () => {
21966
+ prepared = true;
21967
+ });
21968
+ const renew = provided === void 0 && !prepared && !result.ok && isFinalPaymentRequestError(result.error) && result.error.details?.paymentRequestFinality === "failed";
21969
+ let finished = true;
21970
+ try {
21971
+ await key.finish(!result.ok && isFinalPaymentRequestError(result.error));
21972
+ } catch {
21973
+ finished = false;
21974
+ }
21975
+ if (renew && finished) {
21976
+ key = await paymentRequestKeyLifecycle(`invoice-request:${actorId}`, intent);
21977
+ result = await run(key.key, () => {
21978
+ prepared = true;
21979
+ });
21980
+ await key.finish(!result.ok && isFinalPaymentRequestError(result.error)).catch(() => void 0);
21981
+ }
21982
+ return result;
21983
+ } catch (cause) {
21984
+ return {
21985
+ ok: false,
21986
+ error: asCapxulError(cause)
21987
+ };
21988
+ } finally {
21989
+ await key?.finish(false).catch(() => void 0);
21990
+ }
21991
+ }
21992
+ //#endregion
21453
21993
  //#region ../../packages/sdk/src/requests/checkout-payments.ts
21454
21994
  const missing$1 = async () => ({
21455
21995
  ok: false,
@@ -21639,72 +22179,96 @@ function makeCheckoutMethods(deps) {
21639
22179
  }
21640
22180
  //#endregion
21641
22181
  //#region ../../packages/sdk/src/requests/inbox-payments.ts
21642
- function mapApprovedInboxPayment(command, input) {
22182
+ const refused = () => ({
22183
+ ok: false,
22184
+ error: Errors.providerError("convex", inboxes.approve.name, "approved Payment read does not match its command")
22185
+ });
22186
+ /** Read the approved command's actual Payment under the payer's existing scope. */
22187
+ async function readApprovedInboxPayment(calls, command, controls, current) {
21643
22188
  const item = command.items[0];
21644
- if (item === void 0 || item.operation !== "send" && item.operation !== "create_commitment") return {
22189
+ const cancelled = {
21645
22190
  ok: false,
21646
- error: Errors.providerError("convex", inboxes.approve.name, "reply has no payment birth item")
22191
+ error: Errors.cancelled({ operation: inboxes.approve.name })
21647
22192
  };
21648
- try {
21649
- const asset = CONFIGURED_MONEY_ASSETS.find((candidate) => candidate.tokenAddress.toLowerCase() === item.tokenAddress.toLowerCase());
21650
- if (asset === void 0) return {
21651
- ok: false,
21652
- error: Errors.providerError("convex", inboxes.approve.name, "prepared payment asset is not configured")
21653
- };
21654
- const amount = {
21655
- asset: asset.assetId,
21656
- value: formatUnits(BigInt(item.operation === "send" ? item.rawAmount : item.totalAmount), asset.decimals)
21657
- };
21658
- const zero = {
21659
- ...amount,
21660
- value: "0"
21661
- };
21662
- const timing = input.timing ?? { kind: "instant" };
21663
- return {
21664
- ok: true,
21665
- value: {
21666
- id: item.paymentId,
21667
- status: timing.kind === "instant" ? "pending" : timing.kind === "scheduled" ? "scheduled" : "streaming",
21668
- amount,
21669
- paymentType: "invoice",
21670
- direction: "out",
21671
- counterpartyLabel: item.recipientSafe,
21672
- receipt: null,
21673
- recipient: {
21674
- kind: "external_address",
21675
- label: item.recipientSafe
21676
- },
21677
- documents: [],
21678
- timing,
21679
- released: zero,
21680
- availableToClaim: zero,
21681
- createdAt: 0,
21682
- updatedAt: 0
21683
- }
21684
- };
21685
- } catch (cause) {
21686
- return {
21687
- ok: false,
21688
- error: Errors.unknown(cause)
21689
- };
21690
- }
22193
+ if (command.items.length !== 1 || item === void 0 || item.operation !== "send" && item.operation !== "create_commitment") return refused();
22194
+ if (!current()) return cancelled;
22195
+ const check = (payment) => {
22196
+ if (!current()) return cancelled;
22197
+ if (payment === null || payment.id !== item.paymentId || payment.direction !== "out") return refused();
22198
+ try {
22199
+ const amount = toExactAssetAmount(payment.amount, CONFIGURED_MONEY_ASSETS);
22200
+ const asset = CONFIGURED_MONEY_ASSETS.find((row) => row.assetId === amount.asset);
22201
+ const instruction = payment.documents.find((document) => document.role === "instruction");
22202
+ const expected = command.instructionDocuments?.[0];
22203
+ if (asset?.tokenAddress.toLowerCase() !== item.tokenAddress.toLowerCase() || amount.minorUnits !== (item.operation === "send" ? item.rawAmount : item.totalAmount) || instruction?.documentHash !== item.documentHash || expected !== void 0 && (instruction.contentHash !== expected.contentHash || instruction.format !== expected.format) || payment.status === "settled" && payment.receipt?.chainId !== command.chainId) return refused();
22204
+ return {
22205
+ ok: true,
22206
+ value: normalizePaymentTiming(payment)
22207
+ };
22208
+ } catch (cause) {
22209
+ return {
22210
+ ok: false,
22211
+ error: Errors.unknown(cause)
22212
+ };
22213
+ }
22214
+ };
22215
+ const actor = calls.actor;
22216
+ const result = actor.kind === "account" ? await calls.bookChecked(records.get, { paymentId: item.paymentId }, controls, check) : await calls.bookChecked(records.getForOrganization, {
22217
+ orgId: actor.orgId,
22218
+ paymentId: item.paymentId
22219
+ }, controls, (response) => response.orgId === actor.orgId ? check(response.payment) : refused());
22220
+ return current() ? result : cancelled;
21691
22221
  }
21692
22222
  //#endregion
21693
22223
  //#region ../../packages/sdk/src/requests/inboxes.ts
21694
22224
  function makeInboxMethods(calls) {
21695
- const { actor, convexCall, deps, observeContactScope, book, bookChecked } = calls;
22225
+ const { actor, convexCall, deps, observeContactScope, book } = calls;
21696
22226
  return {
21697
22227
  paymentTerms: (requestId, options) => book(inboxes.paymentTerms, {
21698
22228
  actor,
21699
22229
  paymentRequestId: requestId
21700
22230
  }, options, (terms) => terms),
21701
22231
  list: (options) => book(inboxes.listCurrent, { actor }, options, (items) => mapPage(items, mapInboxItem)),
21702
- approve: (input, options) => bookChecked(inboxes.approve, {
21703
- actor,
21704
- paymentRequestId: input.requestId,
21705
- ...input.timing === void 0 ? {} : { timing: input.timing },
21706
- ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
21707
- }, options, (prepared) => mapApprovedInboxPayment(prepared, input)),
22232
+ approve: async (providedInput, options) => {
22233
+ const input = structuredClone(providedInput);
22234
+ const identity = deps.identityActor;
22235
+ const lifetime = identity?.authLifetime();
22236
+ const current = () => identity === void 0 || lifetime !== void 0 && identity.matchesAuthLifetime(lifetime, lifetime.authUserId);
22237
+ const cancelled = {
22238
+ ok: false,
22239
+ error: Errors.cancelled({ operation: inboxes.approve.name })
22240
+ };
22241
+ const controls = deps.invocationControls?.(options) ?? options;
22242
+ const approve = async (requestKey) => {
22243
+ if (!current()) return cancelled;
22244
+ const prepared = await book(inboxes.approve, {
22245
+ actor,
22246
+ paymentRequestId: input.requestId,
22247
+ ...requestKey === void 0 ? {} : { requestKey },
22248
+ ...input.timing === void 0 ? {} : { timing: input.timing },
22249
+ ...input.permissionId === void 0 ? {} : { permissionId: input.permissionId }
22250
+ }, controls, (value) => value);
22251
+ if (!current()) return cancelled;
22252
+ if (!prepared.ok) return prepared;
22253
+ return readApprovedInboxPayment(calls, prepared.value, controls, current);
22254
+ };
22255
+ const terms = await book(inboxes.paymentTerms, {
22256
+ actor,
22257
+ paymentRequestId: input.requestId
22258
+ }, controls, (value) => value);
22259
+ if (!current()) return cancelled;
22260
+ if (!terms.ok) return terms;
22261
+ if (terms.value.instruction.kind !== "invoice") return approve(input.requestKey);
22262
+ return withInvoiceRequestKey(lifetime?.authUserId ?? "signed-out", {
22263
+ ...terms.value,
22264
+ payer: actor.kind === "account" ? { kind: "account" } : {
22265
+ kind: "organization",
22266
+ orgId: actor.orgId
22267
+ },
22268
+ permissionId: input.permissionId,
22269
+ release: input.timing ?? { kind: "instant" }
22270
+ }, input.requestKey, (key) => approve(key));
22271
+ },
21708
22272
  fulfill: (input, options) => {
21709
22273
  const onPrepared = options?.onPrepared;
21710
22274
  const decoded = Schema.decodeResult(RequestPaymentConfirmationSchema, { onExcessProperty: "error" })(input);
@@ -21727,20 +22291,26 @@ function makeInboxMethods(calls) {
21727
22291
  const controls = deps.invocationControls?.(options) ?? options;
21728
22292
  return runCapxulEffect(Effect.gen(function* () {
21729
22293
  const parent = yield* Effect.currentSpan.pipe(Effect.orDie);
21730
- return yield* awaitCapxulResult(() => executeRequestPayment({
22294
+ const run = (named, prepared) => executeRequestPayment({
21731
22295
  actor: identityActor,
21732
22296
  chainId,
21733
22297
  signer,
21734
22298
  convexCall,
21735
22299
  runPromise: deps.runPromise,
21736
22300
  ...deps.telemetry === void 0 ? {} : { telemetry: deps.telemetry }
21737
- }, confirmation, carryInvocationParentSpan(controls, parent), onPrepared === void 0 ? void 0 : async (paymentIds) => {
21738
- await onPrepared({ paymentIds });
22301
+ }, named, carryInvocationParentSpan(controls, parent), async (paymentIds) => {
22302
+ prepared();
22303
+ await onPrepared?.({ paymentIds });
21739
22304
  return {
21740
22305
  ok: true,
21741
22306
  value: void 0
21742
22307
  };
21743
- }));
22308
+ });
22309
+ const { requestKey, ...intent } = confirmation;
22310
+ return yield* awaitCapxulResult(() => confirmation.instruction.kind !== "invoice" ? run(confirmation, () => void 0) : withInvoiceRequestKey(identityActor.authSession()?.authUserId ?? "signed-out", intent, requestKey, (key, prepared) => run({
22311
+ ...confirmation,
22312
+ requestKey: key
22313
+ }, prepared)));
21744
22314
  }).pipe(Effect.tap(() => observeContactScope)), controls, CAPXUL_OPERATIONS.inbox.fulfill, deps.runPromise);
21745
22315
  },
21746
22316
  decline: (requestId, options) => book(inboxes.decline, {
@@ -22666,7 +23236,7 @@ function makePersonalPay(deps) {
22666
23236
  };
22667
23237
  }
22668
23238
  release(false);
22669
- await finishQuietly(requestKey, submitted.ok || flight.requestState.resolved);
23239
+ await finishQuietly(requestKey, submitted.ok || flight.requestState.resolved || isFinalPaymentRequestError(submitted.error));
22670
23240
  return mapOk(submitted, (value) => normalizePaymentTiming(value.payment));
22671
23241
  };
22672
23242
  }
@@ -22743,6 +23313,7 @@ function makePaymentsMethods(deps) {
22743
23313
  createCommitment: (input, options) => pay(input, options),
22744
23314
  claim: (paymentId, options) => runLifecycle({
22745
23315
  kind: "claim",
23316
+ requestKey: options?.requestKey ?? `pay_${crypto.randomUUID()}`,
22746
23317
  paymentId
22747
23318
  }, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.claim),
22748
23319
  list: (options) => {
@@ -22755,6 +23326,7 @@ function makePaymentsMethods(deps) {
22755
23326
  },
22756
23327
  cancel: (paymentId, options) => runLifecycle({
22757
23328
  kind: "cancel",
23329
+ requestKey: options?.requestKey ?? `pay_${crypto.randomUUID()}`,
22758
23330
  paymentId
22759
23331
  }, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.payments.cancel),
22760
23332
  redirect: async (input, options) => {
@@ -22763,6 +23335,7 @@ function makePaymentsMethods(deps) {
22763
23335
  if (!recipient.ok) return runCapxulEffect(Effect.fail(recipient.error), observationOnlyControls(controls), CAPXUL_OPERATIONS.payments.redirect, deps.runPromise);
22764
23336
  return runLifecycle({
22765
23337
  kind: "redirect",
23338
+ requestKey: options?.requestKey ?? `pay_${crypto.randomUUID()}`,
22766
23339
  paymentId: input.paymentId,
22767
23340
  recipient: recipient.value
22768
23341
  }, controls, CAPXUL_OPERATIONS.payments.redirect);
@@ -23016,7 +23589,7 @@ async function executeOrganizationBatch(scope, input, signal, operation, control
23016
23589
  }
23017
23590
  release(false);
23018
23591
  try {
23019
- await requestKey.finish(result.ok || flight.requestState.resolved);
23592
+ await requestKey.finish(result.ok || flight.requestState.resolved || isFinalPaymentRequestError(result.error));
23020
23593
  } catch {}
23021
23594
  const normalized = mapOk(result, (value) => value.payments.map((payment) => normalizePaymentTiming(payment)));
23022
23595
  if (!normalized.ok) return normalized;
@@ -23117,7 +23690,8 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
23117
23690
  },
23118
23691
  cancel: (paymentId, options) => ownerLifecycle({
23119
23692
  kind: "cancel",
23120
- paymentId
23693
+ paymentId,
23694
+ requestKey: options?.requestKey ?? `pay_${crypto.randomUUID()}`
23121
23695
  }, deps.invocationControls?.(options) ?? options, CAPXUL_OPERATIONS.organizationPayments.cancel),
23122
23696
  redirect: (input, options) => {
23123
23697
  const controls = deps.invocationControls?.(options) ?? options;
@@ -23125,7 +23699,8 @@ function makeOrganizationPaymentsMethods(deps, orgId) {
23125
23699
  return recipient.ok ? ownerLifecycle({
23126
23700
  kind: "redirect",
23127
23701
  paymentId: input.paymentId,
23128
- recipient: recipient.value
23702
+ recipient: recipient.value,
23703
+ requestKey: options?.requestKey ?? `pay_${crypto.randomUUID()}`
23129
23704
  }, controls, CAPXUL_OPERATIONS.organizationPayments.redirect) : runCapxulEffect(Effect.fail(recipient.error), observationOnlyControls(controls), CAPXUL_OPERATIONS.organizationPayments.redirect, deps.runPromise);
23130
23705
  },
23131
23706
  payBatch: (input, options) => {
@@ -23745,6 +24320,46 @@ function makeAccountMethods(deps) {
23745
24320
  };
23746
24321
  }
23747
24322
  //#endregion
24323
+ //#region ../../packages/sdk/src/accounts/approval-rules.ts
24324
+ const IN_FLIGHT = /* @__PURE__ */ new Set([
24325
+ "pending",
24326
+ "settling",
24327
+ "in_transit"
24328
+ ]);
24329
+ /** A Payment the chain has not decided yet. */
24330
+ function inFlight(payment) {
24331
+ return IN_FLIGHT.has(payment.status);
24332
+ }
24333
+ /**
24334
+ * The operation the approval describes is the one its digest signs: the
24335
+ * SafeOp digest of its UserOperation on this client's chain, and the
24336
+ * execution that digest names. Anything else is refused before the key signs.
24337
+ */
24338
+ function describedOperation(approval, chainId) {
24339
+ const { operation, summary } = approval;
24340
+ if (chainId !== void 0 && summary.network.chainId !== chainId) return Errors.invalidInput("approval", "the approval is for another chain");
24341
+ try {
24342
+ const digest = moneySafeOpDigest(operation.userOperation, summary.network.chainId);
24343
+ if (digest.toLowerCase() === operation.digest.toLowerCase() && matchesMoneyExecutionId(operation.executionId, digest, operation.commandId)) return void 0;
24344
+ } catch {}
24345
+ return Errors.invalidInput("approval", "the operation does not match the digest it asks to sign");
24346
+ }
24347
+ /** Wait, unless the caller gives up first. False when aborted. */
24348
+ function sleep(ms, signal) {
24349
+ if (signal?.aborted === true) return Promise.resolve(false);
24350
+ return new Promise((resolve) => {
24351
+ const timer = setTimeout(() => {
24352
+ signal?.removeEventListener("abort", onAbort);
24353
+ resolve(true);
24354
+ }, ms);
24355
+ const onAbort = () => {
24356
+ clearTimeout(timer);
24357
+ resolve(false);
24358
+ };
24359
+ signal?.addEventListener("abort", onAbort, { once: true });
24360
+ });
24361
+ }
24362
+ //#endregion
23748
24363
  //#region ../../packages/sdk/src/accounts/organization-approvals.ts
23749
24364
  /** The Organization Payment prepared for `signerAddress` and checked, before any approval. */
23750
24365
  async function prepareVerifiedOrganizationPayment(deps, input, signerAddress, signal) {
@@ -23837,58 +24452,6 @@ async function checkedBankApproval(deps, input, opened) {
23837
24452
  });
23838
24453
  }
23839
24454
  //#endregion
23840
- //#region ../../packages/sdk/src/accounts/approval-rules.ts
23841
- const IN_FLIGHT = /* @__PURE__ */ new Set([
23842
- "pending",
23843
- "settling",
23844
- "in_transit"
23845
- ]);
23846
- /** A Payment the chain has not decided yet. */
23847
- function inFlight(payment) {
23848
- return IN_FLIGHT.has(payment.status);
23849
- }
23850
- /**
23851
- * The approved operation is not sent yet: the approval is approved, or it was
23852
- * consumed but a Payment is still `pending` (a recorded send moves it to
23853
- * `settling`), so the send did not land.
23854
- */
23855
- function unsent(approval, payments) {
23856
- return approval.state === "approved" || approval.state === "consumed" && payments.some((payment) => payment.status === "pending");
23857
- }
23858
- /** The send was refused because another send of the same operation holds its claim. */
23859
- function anotherSendInFlight(error) {
23860
- return error.code === "SUPERSEDED" && error.details?.reason === "unobservable-claim";
23861
- }
23862
- /**
23863
- * The operation the approval describes is the one its digest signs: the
23864
- * SafeOp digest of its UserOperation on this client's chain, and the
23865
- * execution that digest names. Anything else is refused before the key signs.
23866
- */
23867
- function describedOperation(approval, chainId) {
23868
- const { operation, summary } = approval;
23869
- if (chainId !== void 0 && summary.network.chainId !== chainId) return Errors.invalidInput("approval", "the approval is for another chain");
23870
- try {
23871
- const digest = moneySafeOpDigest(operation.userOperation, summary.network.chainId);
23872
- if (digest.toLowerCase() === operation.digest.toLowerCase() && operation.executionId === `money_execution_${digest.slice(2).toLowerCase()}`) return void 0;
23873
- } catch {}
23874
- return Errors.invalidInput("approval", "the operation does not match the digest it asks to sign");
23875
- }
23876
- /** Wait, unless the caller gives up first. False when aborted. */
23877
- function sleep(ms, signal) {
23878
- if (signal?.aborted === true) return Promise.resolve(false);
23879
- return new Promise((resolve) => {
23880
- const timer = setTimeout(() => {
23881
- signal?.removeEventListener("abort", onAbort);
23882
- resolve(true);
23883
- }, ms);
23884
- const onAbort = () => {
23885
- clearTimeout(timer);
23886
- resolve(false);
23887
- };
23888
- signal?.addEventListener("abort", onAbort, { once: true });
23889
- });
23890
- }
23891
- //#endregion
23892
24455
  //#region ../../packages/protocol/src/payroll/model.ts
23893
24456
  function toPayrollRunId(raw) {
23894
24457
  return toNonEmptyStringBrand(raw, "payrollRunId", (value) => isNonEmptyString(value));
@@ -24350,7 +24913,8 @@ function lifecycleIntent(input) {
24350
24913
  ok: true,
24351
24914
  value: {
24352
24915
  kind: "cancel",
24353
- paymentId: input.cancel
24916
+ paymentId: input.cancel,
24917
+ requestKey: input.requestKey ?? `pay_${crypto.randomUUID()}`
24354
24918
  }
24355
24919
  };
24356
24920
  const recipient = normalizeTargetForBackend(input.to, "to");
@@ -24359,7 +24923,8 @@ function lifecycleIntent(input) {
24359
24923
  value: {
24360
24924
  kind: "redirect",
24361
24925
  paymentId: input.redirect,
24362
- recipient: recipient.value
24926
+ recipient: recipient.value,
24927
+ requestKey: input.requestKey ?? `pay_${crypto.randomUUID()}`
24363
24928
  }
24364
24929
  } : recipient;
24365
24930
  }
@@ -24391,10 +24956,19 @@ async function prepareVerifiedRequestPayment(deps, input, signerAddress, signal)
24391
24956
  error: Errors.invalidInput("confirmation", "invalid request confirmation")
24392
24957
  };
24393
24958
  const confirmation = decoded.success;
24394
- return checked(deps, signerAddress, await runIfActive(signal, commands$1.prepareRequest.name, () => callOperation(deps.convexCall, commands$1.prepareRequest, {
24395
- confirmation,
24396
- signerAddress
24397
- }).pipe(Effect.mapError((publicError) => ({ publicError }))), deps.runPromise), requestPaymentCheck(confirmation), false);
24959
+ const run = async (named, prepared) => {
24960
+ const result = await runIfActive(signal, commands$1.prepareRequest.name, () => callOperation(deps.convexCall, commands$1.prepareRequest, {
24961
+ confirmation: named,
24962
+ signerAddress
24963
+ }).pipe(Effect.mapError((publicError) => ({ publicError }))), deps.runPromise);
24964
+ if (result.ok) prepared();
24965
+ return checked(deps, signerAddress, result, requestPaymentCheck(named), false);
24966
+ };
24967
+ const { requestKey, ...intent } = confirmation;
24968
+ return confirmation.instruction.kind !== "invoice" ? run(confirmation, () => void 0) : withInvoiceRequestKey(deps.actor?.authSession()?.authUserId ?? "signed-out", intent, requestKey, (key, prepared) => run({
24969
+ ...confirmation,
24970
+ requestKey: key
24971
+ }, prepared));
24398
24972
  }
24399
24973
  /** One payroll run: the run the backend writes and the batch that pays it, checked together. */
24400
24974
  async function prepareVerifiedPayrollRun(deps, input, signerAddress, signal) {
@@ -24489,7 +25063,7 @@ function makeApprovalsMethods(deps) {
24489
25063
  const signal = options?.signal;
24490
25064
  if (isCommandApproval(input)) return openApproval(signal, (signerAddress) => prepareVerifiedCommand(deps, input, signerAddress, signal));
24491
25065
  if (isPermissionChange(input)) return openApproval(signal, async (signerAddress) => {
24492
- const { prepareVerifiedPermissionChange } = await import("./permission-approvals-CCCJ2aYL.mjs");
25066
+ const { prepareVerifiedPermissionChange } = await import("./permission-approvals-DcF1OYMa.mjs");
24493
25067
  return prepareVerifiedPermissionChange(deps, input, signerAddress, signal);
24494
25068
  });
24495
25069
  if ("organizationId" in input) return checkedBankApproval(deps, input, await openApproval(signal, (signerAddress) => prepareVerifiedOrganizationPayment(deps, input, signerAddress, signal)));
@@ -24586,43 +25160,33 @@ function makeApprovalsMethods(deps) {
24586
25160
  };
24587
25161
  /**
24588
25162
  * One read of the approval: its outcome when it has ended, or null to read
24589
- * again. The Payments are read before anything is sent, so a send is never
24590
- * made for Payments this caller cannot follow.
25163
+ * again. This path only reads. The backend owns submission and recovery.
24591
25164
  */
24592
25165
  const step = async (approvalId, signal, organizationId) => {
24593
- const read = await call(approvals.get.name, approvals.get, { approvalId }, signal);
25166
+ const read = await call(approvals.observe.name, approvals.observe, { approvalId }, signal);
24594
25167
  if (!read.ok) return read;
24595
- const approval = read.value;
25168
+ const { approval, completed } = read.value;
24596
25169
  if (approval.state === "pending") return {
24597
25170
  ok: true,
24598
25171
  value: null
24599
25172
  };
24600
- if (endsOnceSent(approval)) {
24601
- if (approval.state !== "approved" && approval.state !== "consumed") return {
24602
- ok: true,
24603
- value: {
24604
- approval,
24605
- payments: []
24606
- }
24607
- };
24608
- const sent = await submit(approvalId);
24609
- return sent.ok || !anotherSendInFlight(sent.error) ? sent : {
24610
- ok: true,
24611
- value: null
24612
- };
24613
- }
25173
+ const closed = approval.state === "rejected" || approval.state === "expired";
25174
+ if (!closed && !completed) return {
25175
+ ok: true,
25176
+ value: null
25177
+ };
25178
+ if (!movesMoney(approval)) return {
25179
+ ok: true,
25180
+ value: {
25181
+ approval,
25182
+ payments: []
25183
+ }
25184
+ };
24614
25185
  const payments = await readApprovalPayments(deps, approval.operation.paymentIds, organizationId ?? (approval.actor.kind === "organization" ? approval.actor.orgId : void 0), signal);
24615
25186
  if (!payments.ok) return payments;
24616
- if (unsent(approval, payments.value)) {
24617
- const sent = await submit(approvalId);
24618
- return sent.ok || anotherSendInFlight(sent.error) ? {
24619
- ok: true,
24620
- value: null
24621
- } : sent;
24622
- }
24623
25187
  return {
24624
25188
  ok: true,
24625
- value: approval.state !== "consumed" || !payments.value.some(inFlight) ? {
25189
+ value: closed || endsOnceSent(approval) || !payments.value.some(inFlight) ? {
24626
25190
  approval,
24627
25191
  payments: payments.value
24628
25192
  } : null
@@ -25251,7 +25815,7 @@ function decodeStatus(body) {
25251
25815
  */
25252
25816
  const HEADS = {
25253
25817
  transfer: "select \"id\", \"chain_id\", \"tx_hash\", \"transaction_log_ordinal\", \"log_index\", \"block_number\", \"block_hash\", \"timestamp\", \"asset_id\", \"token\", \"from\", \"to\", \"amount\" from \"transfer\" where (\"transfer\".\"from\" = $1 or \"transfer\".\"to\" = $2) order by \"transfer\".\"block_number\" desc, \"transfer\".\"id\" desc",
25254
- payment: "select \"id\", \"chain_id\", \"tx_hash\", \"transaction_log_ordinal\", \"log_index\", \"block_number\", \"block_hash\", \"timestamp\", \"contract\", \"settlement_id\", \"sender\", \"recipient\", \"asset_id\", \"token\", \"amount\", \"kind\", \"document_hash\" from \"payment\" where (\"payment\".\"sender\" = $1 or \"payment\".\"recipient\" = $2) order by \"payment\".\"block_number\" desc, \"payment\".\"id\" desc",
25818
+ payment: "select \"id\", \"chain_id\", \"tx_hash\", \"transaction_log_ordinal\", \"log_index\", \"block_number\", \"block_hash\", \"timestamp\", \"contract\", \"settlement_id\", \"sender\", \"recipient\", \"asset_id\", \"token\", \"amount\", \"kind\", \"document_hash\", \"job_nonce\", \"executor\" from \"payment\" where (\"payment\".\"sender\" = $1 or \"payment\".\"recipient\" = $2) order by \"payment\".\"block_number\" desc, \"payment\".\"id\" desc",
25255
25819
  balance: "select \"chain_id\", \"asset_id\", \"to\", \"amount\" from \"balance\" where \"balance\".\"to\" = $1"
25256
25820
  };
25257
25821
  /** How many times the statement binds the Safe address. */
@@ -25294,7 +25858,7 @@ function ponderQuery(table, input) {
25294
25858
  input.limit
25295
25859
  ];
25296
25860
  return {
25297
- sql: `${HEADS.payment.slice(0, HEADS.payment.indexOf("where "))}where (("payment"."sender" = $1 or "payment"."recipient" = $2) and "payment"."settlement_id" in (${input.settlements.map((_, i) => `$${i + 3}`).join(", ")})) limit $${params.length}`,
25861
+ sql: `${HEADS.payment.slice(0, HEADS.payment.indexOf("where ")).replace(" from \"payment\"", ", \"contract\" as \"router\" from \"payment\"")}where (("payment"."sender" = $1 or "payment"."recipient" = $2) and "payment"."settlement_id" in (${input.settlements.map((_, i) => `$${i + 3}`).join(", ")})) limit $${params.length}`,
25298
25862
  params,
25299
25863
  typings: params.map(() => "none")
25300
25864
  };
@@ -38257,7 +38821,7 @@ function verifyPermissionExecution(raw, command, orgId, expectedSafe, signerAddr
38257
38821
  const callData = direct.length === 1 ? safe4337ExecuteUserOpCallData(direct[0]) : safe4337MultiSendUserOpCallData({ calls: direct });
38258
38822
  if (operation.callData.toLowerCase() !== callData.toLowerCase()) return mismatch("UserOperation call data mismatch");
38259
38823
  const digest = moneySafeOpDigest(operation, chainId);
38260
- if (evidence.digest.toLowerCase() !== digest.toLowerCase() || evidence.executionId !== `money_execution_${digest.slice(2).toLowerCase()}`) return mismatch("Prepared digest or execution identity mismatch");
38824
+ if (evidence.digest.toLowerCase() !== digest.toLowerCase() || !matchesMoneyExecutionId(evidence.executionId, digest, evidence.commandId)) return mismatch("Prepared digest or execution identity mismatch");
38261
38825
  return {
38262
38826
  ok: true,
38263
38827
  value: {
@@ -40114,4 +40678,4 @@ var ConvexOrganizationSetupAdapter = class {
40114
40678
  }
40115
40679
  };
40116
40680
  //#endregion
40117
- export { isSignerNotReadySignal as $, ChainIdSchema$1 as $t, bindProductTelemetryInvocation as A, detectAuthCacheAdapter as An, publicKeyToAddress as At, BASE_SEPOLIA_CHAIN_ID as B, redactUrlSecrets as Bn, toBytes$1 as Bt, PonderIndexerAdapter as C, copyInvocationObservation as Cn, toOrgId as Ct, TelemetryPortTag as D, toPublishableKey as Dn, isBytes32 as Dt, AccountReadPortTag as E, toAllowedOrigin as En, images as Et, makeCheckoutMethods as F, AuthCachePortTag as Fn, concatHex as Ft, failureEvidenceProps as G, CapxulError as Gn, hexToBigInt as Gt, asCapxulError as H, isRecord as Hn, numberToHex as Ht, makeTargetsMethods as I, deserializeCapxulError as In, isAddress$1 as It, withCapturedAttemptContext as J, isFailureMode as Jn, BaseError as Jt, observeFailedResult as K, isCapxulError as Kn, hexToNumber as Kt, makeVerificationMethods as L, serializeCapxulError as Ln, InvalidAddressError as Lt, makeAccountMethods as M, toEpochMs as Mn, createCursor as Mt, makePaymentsMethods as N, toAuthUserId as Nn, slice as Nt, ConvexCallPortTag as O, AuthClientError as On, hashTypedData as Ot, makeDestinationsMethods as P, toEmail as Pn, concat$1 as Pt, isEcdsaSignatureHex as Q, EpochMsSchema$1 as Qt, abandonPrepared as R, decodeChainCause as Rn, keccak256$1 as Rt, makeHoldingsMethods as S, attachInvocationObservation as Sn, ORGANIZATION_SETUP_STATUSES as St, ConvexAccountLayer as T, sanitizeObservationContext as Tn, AppIdSchema$1 as Tt, toPublicError$1 as U, readField as Un, stringToHex as Ut, callOperation as V, isCredentialField as Vn, bytesToHex as Vt, failureDetail as W, Errors as Wn, toHex as Wt, UNOBSERVABLE_SIGNER_STATUS as X, isHex$1 as Xt, version$1 as Y, size as Yt, causeChain as Z, DurationMsSchema$1 as Zt, makeActivityMethods as _, SystemClockLayer as _n, OPERATIONS as _t, prepareConfiguration as a, askIdentity as an, toCountryCode as at, ConvexSmartAccountLayer as b, BetterAuthBrowserLayer as bn, setups as bt, OrgPortTag as c, runPortEffect as cn, toHandle as ct, verifiedPreparation as d, toCapxulResult as dn, CLI_CAPABILITIES as dt, isEvmAddress as en, openfortSignerNotReadyCode as et, buildCommand as f, formatTraceparent as fn, CLI_COMMAND_NAMES as ft, makeMeMethods as g, oauthBearerAuthClient as gn, normalizeCapxulOperation as gt, bootIdentityFlow as h, carryInvocationParentSpan as hn, isCapxulOperation as ht, authorInvitation as i, makeAuthMethods as in, makeClientRequestMethods as it, makeApprovalsMethods as j, globalLocalStorage as jn, formatGwei as jt, convexCallErrorFromCapxul as k, AuthClientPortTag as kn, toRlp as kt, preparePermission as l, sessionFromActor as ln, validateHandle as lt, executeIdentityProductObservation as m, ActorFailure as mn, CAPXUL_OPERATIONS as mt, makeOrgMethods as n, absurd as nn, signerFailure as nt, verifiedConfiguration as o, publicIdentityFailure as on, toKycTier as ot, validateReplacementInput as p, CAPXUL_ERROR_CODES as pn, CLI_INVOCATION_KINDS as pt, observeSdkClient as q, FAILURE_MODES$1 as qn, trim as qt, makeBankingMethods as r, getFunctionName as rn, makeCurrentUserMethods as rt, ConvexOrganizationAdapter as s, runIdentityFacade as sn, toTesterKind as st, ConvexOrganizationSetupAdapter as t, toAddress as tn, recoverRawDigestSigner as tt, preparedIdentity as u, runCapxulEffect as un, redactTelemetryProps as ut, makePaymentDocumentsMethods as v, ClockPortTag as vn, details as vt, makeAccountsMethods as w, readInvocationObservation as wn, diagnostics as wt, SmartAccountPortTag as x, observationRequestHeaders as xn, ORGANIZATION_SETUP_REASONS as xt, makeSmartAccountMethods as y, BetterAuthNodeLayer as yn, onboardings as yt, normalizeSafeSaltEmail as z, redactSecrets as zn, hexToBytes as zt };
40681
+ export { isSignerNotReadySignal as $, ChainIdSchema$1 as $t, bindProductTelemetryInvocation as A, detectAuthCacheAdapter as An, toRlp as At, BASE_SEPOLIA_CHAIN_ID as B, redactUrlSecrets as Bn, hexToBytes as Bt, PonderIndexerAdapter as C, copyInvocationObservation as Cn, toOrgId as Ct, TelemetryPortTag as D, toPublishableKey as Dn, isBytes32 as Dt, AccountReadPortTag as E, toAllowedOrigin as En, images as Et, makeCheckoutMethods as F, AuthCachePortTag as Fn, concat$1 as Ft, failureEvidenceProps as G, CapxulError as Gn, hexToBigInt as Gt, asCapxulError as H, isRecord as Hn, numberToHex as Ht, makeTargetsMethods as I, deserializeCapxulError as In, concatHex as It, withCapturedAttemptContext as J, isFailureMode as Jn, BaseError as Jt, observeFailedResult as K, isCapxulError as Kn, hexToNumber as Kt, makeVerificationMethods as L, serializeCapxulError as Ln, isAddress$1 as Lt, makeAccountMethods as M, toEpochMs as Mn, formatGwei as Mt, makePaymentsMethods as N, toAuthUserId as Nn, createCursor as Nt, ConvexCallPortTag as O, AuthClientError as On, hashTypedData as Ot, makeDestinationsMethods as P, toEmail as Pn, slice as Pt, isEcdsaSignatureHex as Q, EpochMsSchema$1 as Qt, abandonPrepared as R, decodeChainCause as Rn, InvalidAddressError as Rt, makeHoldingsMethods as S, attachInvocationObservation as Sn, ORGANIZATION_SETUP_STATUSES as St, ConvexAccountLayer as T, sanitizeObservationContext as Tn, AppIdSchema$1 as Tt, toPublicError$1 as U, readField as Un, stringToHex as Ut, callOperation as V, isCredentialField as Vn, bytesToHex as Vt, failureDetail as W, Errors as Wn, toHex as Wt, UNOBSERVABLE_SIGNER_STATUS as X, isHex$1 as Xt, version$1 as Y, size as Yt, causeChain as Z, DurationMsSchema$1 as Zt, makeActivityMethods as _, SystemClockLayer as _n, OPERATIONS as _t, prepareConfiguration as a, askIdentity as an, toCountryCode as at, ConvexSmartAccountLayer as b, BetterAuthBrowserLayer as bn, setups as bt, OrgPortTag as c, runPortEffect as cn, toHandle as ct, verifiedPreparation as d, toCapxulResult as dn, CLI_CAPABILITIES as dt, isEvmAddress as en, openfortSignerNotReadyCode as et, buildCommand as f, formatTraceparent as fn, CLI_COMMAND_NAMES as ft, makeMeMethods as g, oauthBearerAuthClient as gn, normalizeCapxulOperation as gt, bootIdentityFlow as h, carryInvocationParentSpan as hn, isCapxulOperation as ht, authorInvitation as i, makeAuthMethods as in, makeClientRequestMethods as it, makeApprovalsMethods as j, globalLocalStorage as jn, publicKeyToAddress as jt, convexCallErrorFromCapxul as k, AuthClientPortTag as kn, sha256 as kt, preparePermission as l, sessionFromActor as ln, validateHandle as lt, executeIdentityProductObservation as m, ActorFailure as mn, CAPXUL_OPERATIONS as mt, makeOrgMethods as n, absurd as nn, signerFailure as nt, verifiedConfiguration as o, publicIdentityFailure as on, toKycTier as ot, validateReplacementInput as p, CAPXUL_ERROR_CODES as pn, CLI_INVOCATION_KINDS as pt, observeSdkClient as q, FAILURE_MODES$1 as qn, trim as qt, makeBankingMethods as r, getFunctionName as rn, makeCurrentUserMethods as rt, ConvexOrganizationAdapter as s, runIdentityFacade as sn, toTesterKind as st, ConvexOrganizationSetupAdapter as t, toAddress as tn, recoverRawDigestSigner as tt, preparedIdentity as u, runCapxulEffect as un, redactTelemetryProps as ut, makePaymentDocumentsMethods as v, ClockPortTag as vn, details as vt, makeAccountsMethods as w, readInvocationObservation as wn, diagnostics as wt, SmartAccountPortTag as x, observationRequestHeaders as xn, ORGANIZATION_SETUP_REASONS as xt, makeSmartAccountMethods as y, BetterAuthNodeLayer as yn, onboardings as yt, normalizeSafeSaltEmail as z, redactSecrets as zn, keccak256$1 as zt };