@capxul/sdk 2.8.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OAuthBearerAuthClient-BZ6tXt4m.mjs +211 -0
- package/dist/OAuthBearerAuthClient-GkHnGqNi.d.mts +19 -0
- package/dist/{InMemoryAuthCacheAdapter-BrEN-men.mjs → clock-0c5NM-TY.mjs} +995 -2
- package/dist/{create-capxul-client-BKJHefmA.mjs → create-capxul-client-DwINzpXZ.mjs} +6 -978
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +5 -23
- package/dist/node/index.d.mts +3 -2
- package/dist/node/index.mjs +3 -2
- package/dist/{observation-D-oCDlMS.d.mts → observation-CR3_haBB.d.mts} +3 -65
- package/dist/{signer-BdDgF200.d.mts → signer-HY5Ju8xs.d.mts} +64 -2
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.mjs +2 -22
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import {
|
|
1
|
+
import { $ as CHAIN_UPSTREAMS, A as toBudgetId, B as toOrgId, C as ZERO_BYTES32, E as toAddress, F as toEmail, G as toRoleKey, H as toPayrollGroupId, J as CAPXUL_ERROR_CODES, M as toCountryCode, N as toCurrencyCode, Q as isCapxulError, S as WEI_RE, T as toAccountId, U as toPayrollRunId, V as toPartyId, X as EXPECTED_OPERATION_OUTCOMES, Y as CapxulError, Z as Errors, _ as deriveCapxulSafeAddress, at as revertSummaryText, b as EVM_ADDRESS_RE$1, et as FAILURE_MODES$1, it as isFailureMode, j as toChainId, k as toAuthUserId, n as InMemoryAuthCacheAdapter, nt as decodeChainCause, p as orgRoleKeyForLabel, r as BrowserAuthCacheAdapter, rt as failureFingerprint, tt as chainCauseProperties, v as APP_ID_RE, x as SUPPORTED_CURRENCY_CODES, y as BYTES32_RE } from "./clock-0c5NM-TY.mjs";
|
|
2
|
+
import { formatUnits, keccak256, parseUnits, recoverAddress, toBytes } from "viem";
|
|
3
3
|
import { Context, Data, Deferred, Duration, Effect, Exit, Fiber, Layer, Queue, Ref, Result, Schema, SchemaGetter, Scope } from "effect";
|
|
4
4
|
import { makeFunctionReference } from "convex/server";
|
|
5
5
|
//#region src/domain/identity/model.ts
|
|
@@ -398,938 +398,6 @@ const isRestoring = (state) => {
|
|
|
398
398
|
* it in #1521; this ticket ships the selector they move onto. */
|
|
399
399
|
const isClaimed = (state) => state.phase === "authenticated" && state.account.at === "claimed";
|
|
400
400
|
//#endregion
|
|
401
|
-
//#region ../config/src/tokens.ts
|
|
402
|
-
/** `TestUSDC` ("USDX") — Base Sepolia, 6 decimals, open `mint`. (Canon §1.) */
|
|
403
|
-
const USDX_ADDRESS_BASE_SEPOLIA = "0xf09fcbb6df9f8f918e58f9c8ab15a76ade862b77";
|
|
404
|
-
USDX_ADDRESS_BASE_SEPOLIA.toLowerCase();
|
|
405
|
-
//#endregion
|
|
406
|
-
//#region ../config/src/org-payments.ts
|
|
407
|
-
/** Zodiac MultiSendCallOnly module on Base Sepolia. */
|
|
408
|
-
const MULTI_SEND_CALL_ONLY = "0x9641d764fc13c8b624c04430c7356c1c7c8102e2";
|
|
409
|
-
//#endregion
|
|
410
|
-
//#region ../config/src/safe.ts
|
|
411
|
-
const BASE_SEPOLIA_CHAIN_ID = 84532;
|
|
412
|
-
const SAFE_PROXY_FACTORY = "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67";
|
|
413
|
-
const SAFE_L2_SINGLETON = "0x29fcB43b46531BcA003ddC8FCB67FFE91900C762";
|
|
414
|
-
const SAFE_MODULE_SETUP = "0x2dd68b007B46fBe91B9A7c3EDa5A7a1063cB5b47";
|
|
415
|
-
const SAFE_4337_MODULE = "0x75cf11467937ce3F2f357CE24ffc3DBF8fD5c226";
|
|
416
|
-
const MULTI_SEND = "0x38869bf66a61cF6bDB996A6aE40D5853Fd43B526";
|
|
417
|
-
/**
|
|
418
|
-
* The Capxul bootstrap owner — the sole `setup()` owner of every unclaimed
|
|
419
|
-
* personal Safe under derivation v2. This address is part of the CREATE2
|
|
420
|
-
* preimage of EVERY personal Safe address: treat it exactly like
|
|
421
|
-
* `SAFE_PROXY_FACTORY` (changing it is a derivation-version event → v3).
|
|
422
|
-
* The private key lives backend-only (`CAPXUL_BOOTSTRAP_OWNER_PRIVATE_KEY`)
|
|
423
|
-
* and signs exactly one kind of operation: the claim userOp that deploys the
|
|
424
|
-
* Safe and swaps this owner out for the user's signer (PRD #462). The earlier
|
|
425
|
-
* ClaimGuard derivation-v3 placeholder (#461) is closed; future mainnet-scale
|
|
426
|
-
* hardening should be filed against the current payments/claim architecture.
|
|
427
|
-
*/
|
|
428
|
-
const CAPXUL_BOOTSTRAP_OWNER = "0x425fca96f4a3e18fb80974e38096b5da460f2704";
|
|
429
|
-
const SAFE_PROXY_CREATION_CODE = "0x608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea264697066735822122003d1488ee65e08fa41e58e888a9865554c535f2c77126a82cb4c0f917f31441364736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564";
|
|
430
|
-
/**
|
|
431
|
-
* Normalize an email for use as a Capxul Safe salt input.
|
|
432
|
-
*
|
|
433
|
-
* Trims surrounding whitespace and lowercases the address so that
|
|
434
|
-
* `" User+Demo@Example.COM "` and `"user+demo@example.com"` derive
|
|
435
|
-
* the same `safeAddress`. This is the canonical normalization rule —
|
|
436
|
-
* any future change here would shift every existing user's Safe
|
|
437
|
-
* address, so the rule is pinned by the fixture matrix in
|
|
438
|
-
* `packages/config/tests/safe-address-conformance.test.ts`.
|
|
439
|
-
*
|
|
440
|
-
* @param email - The raw email address to normalize
|
|
441
|
-
* @returns The trimmed, lowercased email
|
|
442
|
-
*/
|
|
443
|
-
function normalizeSafeSaltEmail(email) {
|
|
444
|
-
return email.trim().toLowerCase();
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Compute the deterministic Safe salt nonce for a `(namespace, email)`
|
|
448
|
-
* pair. The salt nonce is the `bigint` reading of
|
|
449
|
-
* `keccak256(namespace + ":" + normalizeSafeSaltEmail(email))`.
|
|
450
|
-
*
|
|
451
|
-
* Namespace defaults to `CAPXUL_SAFE_SALT_NAMESPACE`
|
|
452
|
-
* (`"capxul:safe:email:v2"`) — the per-version Capxul scheme. Pass a
|
|
453
|
-
* different namespace only for pinned pre-v2 artifacts
|
|
454
|
-
* (`CAPXUL_SAFE_SALT_NAMESPACE_V1`, faucet Safe) or when bumping the scheme.
|
|
455
|
-
*
|
|
456
|
-
* @param input.email - The email to derive the salt nonce from
|
|
457
|
-
* @param input.namespace - Optional namespace override (defaults to `CAPXUL_SAFE_SALT_NAMESPACE`)
|
|
458
|
-
* @returns The Capxul-namespaced salt nonce as a `bigint`
|
|
459
|
-
*/
|
|
460
|
-
function computeCapxulSafeSaltNonce(input) {
|
|
461
|
-
const namespace = input.namespace ?? "capxul:safe:email:v2";
|
|
462
|
-
const normalizedEmail = normalizeSafeSaltEmail(input.email);
|
|
463
|
-
return BigInt(keccak256(toBytes(`${namespace}:${normalizedEmail}`)));
|
|
464
|
-
}
|
|
465
|
-
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
466
|
-
const safeSetupAbi = [{
|
|
467
|
-
type: "function",
|
|
468
|
-
name: "setup",
|
|
469
|
-
stateMutability: "nonpayable",
|
|
470
|
-
inputs: [
|
|
471
|
-
{
|
|
472
|
-
name: "_owners",
|
|
473
|
-
type: "address[]"
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
name: "_threshold",
|
|
477
|
-
type: "uint256"
|
|
478
|
-
},
|
|
479
|
-
{
|
|
480
|
-
name: "to",
|
|
481
|
-
type: "address"
|
|
482
|
-
},
|
|
483
|
-
{
|
|
484
|
-
name: "data",
|
|
485
|
-
type: "bytes"
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
name: "fallbackHandler",
|
|
489
|
-
type: "address"
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
name: "paymentToken",
|
|
493
|
-
type: "address"
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
name: "payment",
|
|
497
|
-
type: "uint256"
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
name: "paymentReceiver",
|
|
501
|
-
type: "address"
|
|
502
|
-
}
|
|
503
|
-
],
|
|
504
|
-
outputs: []
|
|
505
|
-
}];
|
|
506
|
-
const enableModulesAbi = [{
|
|
507
|
-
type: "function",
|
|
508
|
-
name: "enableModules",
|
|
509
|
-
stateMutability: "nonpayable",
|
|
510
|
-
inputs: [{
|
|
511
|
-
name: "modules",
|
|
512
|
-
type: "address[]"
|
|
513
|
-
}],
|
|
514
|
-
outputs: []
|
|
515
|
-
}];
|
|
516
|
-
const multiSendAbi = [{
|
|
517
|
-
type: "function",
|
|
518
|
-
name: "multiSend",
|
|
519
|
-
stateMutability: "payable",
|
|
520
|
-
inputs: [{
|
|
521
|
-
name: "transactions",
|
|
522
|
-
type: "bytes"
|
|
523
|
-
}],
|
|
524
|
-
outputs: []
|
|
525
|
-
}];
|
|
526
|
-
function buildCapxulSafeInitializer(owner) {
|
|
527
|
-
const enableModulesCall = encodeFunctionData({
|
|
528
|
-
abi: enableModulesAbi,
|
|
529
|
-
functionName: "enableModules",
|
|
530
|
-
args: [[SAFE_4337_MODULE]]
|
|
531
|
-
});
|
|
532
|
-
const enableModulesByteLen = BigInt((enableModulesCall.length - 2) / 2);
|
|
533
|
-
const multiSendPayload = encodePacked([
|
|
534
|
-
"uint8",
|
|
535
|
-
"address",
|
|
536
|
-
"uint256",
|
|
537
|
-
"uint256",
|
|
538
|
-
"bytes"
|
|
539
|
-
], [
|
|
540
|
-
1,
|
|
541
|
-
SAFE_MODULE_SETUP,
|
|
542
|
-
0n,
|
|
543
|
-
enableModulesByteLen,
|
|
544
|
-
enableModulesCall
|
|
545
|
-
]);
|
|
546
|
-
const setupData = encodeFunctionData({
|
|
547
|
-
abi: multiSendAbi,
|
|
548
|
-
functionName: "multiSend",
|
|
549
|
-
args: [multiSendPayload]
|
|
550
|
-
});
|
|
551
|
-
return encodeFunctionData({
|
|
552
|
-
abi: safeSetupAbi,
|
|
553
|
-
functionName: "setup",
|
|
554
|
-
args: [
|
|
555
|
-
[owner],
|
|
556
|
-
1n,
|
|
557
|
-
MULTI_SEND,
|
|
558
|
-
setupData,
|
|
559
|
-
SAFE_4337_MODULE,
|
|
560
|
-
ZERO_ADDRESS,
|
|
561
|
-
0n,
|
|
562
|
-
ZERO_ADDRESS
|
|
563
|
-
]
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
const ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/;
|
|
567
|
-
function validateAndNormalizeAddress(field, value) {
|
|
568
|
-
const address = value.toLowerCase();
|
|
569
|
-
if (!ADDRESS_REGEX.test(address)) throw Errors.invalidInput(field, `must be 0x + 40 hex chars, got ${value}`);
|
|
570
|
-
return address;
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Pure derivation of the Capxul personal Safe address — **v2: email only**
|
|
574
|
-
* (PRD #462). The Safe v1.4.1 (SafeL2) + 4337-module initializer's sole owner
|
|
575
|
-
* is the fixed `CAPXUL_BOOTSTRAP_OWNER`, so the address is a pure function of
|
|
576
|
-
* the (normalized) email and exists before any user signer does. The user's
|
|
577
|
-
* signer is installed at claim time via `swapOwner` — signer rotation can
|
|
578
|
-
* never move the address (org-domain rule D7, now system-wide).
|
|
579
|
-
*
|
|
580
|
-
* Returns the lowercased `0x` + 40 hex string (raw — no brand applied so this
|
|
581
|
-
* function is callable from both `@capxul/config` consumers that don't have
|
|
582
|
-
* `@capxul/types` available, and from packages that re-brand at their own
|
|
583
|
-
* boundary).
|
|
584
|
-
*
|
|
585
|
-
* Algorithm: exactly mirrors `permissionless.toSafeSmartAccount({ version:
|
|
586
|
-
* "1.4.1", safeSingletonAddress: SAFE_L2_SINGLETON, owners: [BOOTSTRAP] })`
|
|
587
|
-
* + the Capxul-canonical module setup (delegatecall into
|
|
588
|
-
* `SafeModuleSetup.enableModules([SAFE_4337_MODULE])` via the MultiSend lane
|
|
589
|
-
* during proxy setup). The proxy creation code is pinned at
|
|
590
|
-
* `SAFE_PROXY_CREATION_CODE`; the salt is Capxul-namespaced (v2) via
|
|
591
|
-
* `computeCapxulSafeSaltNonce({ email })`.
|
|
592
|
-
*
|
|
593
|
-
* Canonical: SDK deployment adapters and
|
|
594
|
-
* `packages/backend/convex/smartAccount/mutations.ts:provision` import this
|
|
595
|
-
* function; the conformance test at
|
|
596
|
-
* `packages/config/tests/safe-address-conformance.test.ts` pins the matrix.
|
|
597
|
-
*/
|
|
598
|
-
function deriveCapxulSafeAddress(input) {
|
|
599
|
-
return deriveCapxulSafeAddressForOwner({
|
|
600
|
-
ownerAddress: CAPXUL_BOOTSTRAP_OWNER,
|
|
601
|
-
email: input.email
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Owner-parametrized derivation core. Two callers only:
|
|
606
|
-
* 1. `deriveCapxulSafeAddress` (canonical v2: owner = bootstrap, namespace v2);
|
|
607
|
-
* 2. the backend faucet Safe (`testUsdcMint.ts`: owner = deployer EOA,
|
|
608
|
-
* namespace pinned to `CAPXUL_SAFE_SALT_NAMESPACE_V1` so its deployed
|
|
609
|
-
* address never moves).
|
|
610
|
-
* Do NOT introduce new owner-parametrized lanes — per-user owners in the
|
|
611
|
-
* derivation is exactly the v1 mistake v2 removes.
|
|
612
|
-
*/
|
|
613
|
-
function deriveCapxulSafeAddressForOwner(input) {
|
|
614
|
-
const initializer = buildCapxulSafeInitializer(validateAndNormalizeAddress("ownerAddress", input.ownerAddress));
|
|
615
|
-
const saltNonce = computeCapxulSafeSaltNonce(input.namespace === void 0 ? { email: input.email } : {
|
|
616
|
-
email: input.email,
|
|
617
|
-
namespace: input.namespace
|
|
618
|
-
});
|
|
619
|
-
const salt = keccak256(encodePacked(["bytes32", "uint256"], [keccak256(initializer), saltNonce]));
|
|
620
|
-
const deploymentCode = concat([SAFE_PROXY_CREATION_CODE, encodeAbiParameters([{ type: "uint256" }], [BigInt(SAFE_L2_SINGLETON)])]);
|
|
621
|
-
return getContractAddress({
|
|
622
|
-
opcode: "CREATE2",
|
|
623
|
-
from: SAFE_PROXY_FACTORY,
|
|
624
|
-
salt,
|
|
625
|
-
bytecodeHash: keccak256(deploymentCode)
|
|
626
|
-
}).toLowerCase();
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Normalize a raw email for binding id + Safe salt derivation.
|
|
630
|
-
* Delegates to {@link normalizeSafeSaltEmail} so binding resolution and
|
|
631
|
-
* `deriveCapxulSafeAddress` never drift apart.
|
|
632
|
-
*/
|
|
633
|
-
function normalizeBindingEmail(email) {
|
|
634
|
-
return normalizeSafeSaltEmail(email);
|
|
635
|
-
}
|
|
636
|
-
//#endregion
|
|
637
|
-
//#region ../config/src/capxul-payments-v2.ts
|
|
638
|
-
/** The exact compiled CapxulPaymentsV2 ABI. */
|
|
639
|
-
const CAPXUL_PAYMENTS_V2_ABI = [
|
|
640
|
-
{
|
|
641
|
-
type: "function",
|
|
642
|
-
name: "cancel",
|
|
643
|
-
inputs: [{
|
|
644
|
-
name: "commitmentId",
|
|
645
|
-
type: "uint256",
|
|
646
|
-
internalType: "uint256"
|
|
647
|
-
}, {
|
|
648
|
-
name: "documentHash",
|
|
649
|
-
type: "bytes32",
|
|
650
|
-
internalType: "bytes32"
|
|
651
|
-
}],
|
|
652
|
-
outputs: [],
|
|
653
|
-
stateMutability: "nonpayable"
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
type: "function",
|
|
657
|
-
name: "claim",
|
|
658
|
-
inputs: [{
|
|
659
|
-
name: "commitmentId",
|
|
660
|
-
type: "uint256",
|
|
661
|
-
internalType: "uint256"
|
|
662
|
-
}],
|
|
663
|
-
outputs: [],
|
|
664
|
-
stateMutability: "nonpayable"
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
type: "function",
|
|
668
|
-
name: "claimableAmount",
|
|
669
|
-
inputs: [{
|
|
670
|
-
name: "commitmentId",
|
|
671
|
-
type: "uint256",
|
|
672
|
-
internalType: "uint256"
|
|
673
|
-
}],
|
|
674
|
-
outputs: [{
|
|
675
|
-
name: "",
|
|
676
|
-
type: "uint256",
|
|
677
|
-
internalType: "uint256"
|
|
678
|
-
}],
|
|
679
|
-
stateMutability: "view"
|
|
680
|
-
},
|
|
681
|
-
{
|
|
682
|
-
type: "function",
|
|
683
|
-
name: "commitments",
|
|
684
|
-
inputs: [{
|
|
685
|
-
name: "",
|
|
686
|
-
type: "uint256",
|
|
687
|
-
internalType: "uint256"
|
|
688
|
-
}],
|
|
689
|
-
outputs: [
|
|
690
|
-
{
|
|
691
|
-
name: "settlementId",
|
|
692
|
-
type: "bytes32",
|
|
693
|
-
internalType: "bytes32"
|
|
694
|
-
},
|
|
695
|
-
{
|
|
696
|
-
name: "creator",
|
|
697
|
-
type: "address",
|
|
698
|
-
internalType: "address"
|
|
699
|
-
},
|
|
700
|
-
{
|
|
701
|
-
name: "recipient",
|
|
702
|
-
type: "address",
|
|
703
|
-
internalType: "address"
|
|
704
|
-
},
|
|
705
|
-
{
|
|
706
|
-
name: "token",
|
|
707
|
-
type: "address",
|
|
708
|
-
internalType: "address"
|
|
709
|
-
},
|
|
710
|
-
{
|
|
711
|
-
name: "totalAmount",
|
|
712
|
-
type: "uint256",
|
|
713
|
-
internalType: "uint256"
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
name: "claimed",
|
|
717
|
-
type: "uint256",
|
|
718
|
-
internalType: "uint256"
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
name: "startTime",
|
|
722
|
-
type: "uint48",
|
|
723
|
-
internalType: "uint48"
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
name: "cliffTime",
|
|
727
|
-
type: "uint48",
|
|
728
|
-
internalType: "uint48"
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
name: "endTime",
|
|
732
|
-
type: "uint48",
|
|
733
|
-
internalType: "uint48"
|
|
734
|
-
},
|
|
735
|
-
{
|
|
736
|
-
name: "kind",
|
|
737
|
-
type: "uint16",
|
|
738
|
-
internalType: "uint16"
|
|
739
|
-
},
|
|
740
|
-
{
|
|
741
|
-
name: "documentHash",
|
|
742
|
-
type: "bytes32",
|
|
743
|
-
internalType: "bytes32"
|
|
744
|
-
},
|
|
745
|
-
{
|
|
746
|
-
name: "cancelled",
|
|
747
|
-
type: "bool",
|
|
748
|
-
internalType: "bool"
|
|
749
|
-
}
|
|
750
|
-
],
|
|
751
|
-
stateMutability: "view"
|
|
752
|
-
},
|
|
753
|
-
{
|
|
754
|
-
type: "function",
|
|
755
|
-
name: "createCommitment",
|
|
756
|
-
inputs: [{
|
|
757
|
-
name: "input",
|
|
758
|
-
type: "tuple",
|
|
759
|
-
internalType: "struct CapxulPaymentsV2.CommitmentInput",
|
|
760
|
-
components: [
|
|
761
|
-
{
|
|
762
|
-
name: "settlementId",
|
|
763
|
-
type: "bytes32",
|
|
764
|
-
internalType: "bytes32"
|
|
765
|
-
},
|
|
766
|
-
{
|
|
767
|
-
name: "recipient",
|
|
768
|
-
type: "address",
|
|
769
|
-
internalType: "address"
|
|
770
|
-
},
|
|
771
|
-
{
|
|
772
|
-
name: "token",
|
|
773
|
-
type: "address",
|
|
774
|
-
internalType: "address"
|
|
775
|
-
},
|
|
776
|
-
{
|
|
777
|
-
name: "totalAmount",
|
|
778
|
-
type: "uint256",
|
|
779
|
-
internalType: "uint256"
|
|
780
|
-
},
|
|
781
|
-
{
|
|
782
|
-
name: "startTime",
|
|
783
|
-
type: "uint48",
|
|
784
|
-
internalType: "uint48"
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
name: "cliffTime",
|
|
788
|
-
type: "uint48",
|
|
789
|
-
internalType: "uint48"
|
|
790
|
-
},
|
|
791
|
-
{
|
|
792
|
-
name: "endTime",
|
|
793
|
-
type: "uint48",
|
|
794
|
-
internalType: "uint48"
|
|
795
|
-
},
|
|
796
|
-
{
|
|
797
|
-
name: "kind",
|
|
798
|
-
type: "uint16",
|
|
799
|
-
internalType: "uint16"
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
name: "documentHash",
|
|
803
|
-
type: "bytes32",
|
|
804
|
-
internalType: "bytes32"
|
|
805
|
-
}
|
|
806
|
-
]
|
|
807
|
-
}],
|
|
808
|
-
outputs: [{
|
|
809
|
-
name: "commitmentId",
|
|
810
|
-
type: "uint256",
|
|
811
|
-
internalType: "uint256"
|
|
812
|
-
}],
|
|
813
|
-
stateMutability: "nonpayable"
|
|
814
|
-
},
|
|
815
|
-
{
|
|
816
|
-
type: "function",
|
|
817
|
-
name: "nextCommitmentId",
|
|
818
|
-
inputs: [],
|
|
819
|
-
outputs: [{
|
|
820
|
-
name: "",
|
|
821
|
-
type: "uint256",
|
|
822
|
-
internalType: "uint256"
|
|
823
|
-
}],
|
|
824
|
-
stateMutability: "view"
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
type: "function",
|
|
828
|
-
name: "redirect",
|
|
829
|
-
inputs: [
|
|
830
|
-
{
|
|
831
|
-
name: "commitmentId",
|
|
832
|
-
type: "uint256",
|
|
833
|
-
internalType: "uint256"
|
|
834
|
-
},
|
|
835
|
-
{
|
|
836
|
-
name: "recipient",
|
|
837
|
-
type: "address",
|
|
838
|
-
internalType: "address"
|
|
839
|
-
},
|
|
840
|
-
{
|
|
841
|
-
name: "documentHash",
|
|
842
|
-
type: "bytes32",
|
|
843
|
-
internalType: "bytes32"
|
|
844
|
-
}
|
|
845
|
-
],
|
|
846
|
-
outputs: [],
|
|
847
|
-
stateMutability: "nonpayable"
|
|
848
|
-
},
|
|
849
|
-
{
|
|
850
|
-
type: "function",
|
|
851
|
-
name: "send",
|
|
852
|
-
inputs: [{
|
|
853
|
-
name: "item",
|
|
854
|
-
type: "tuple",
|
|
855
|
-
internalType: "struct CapxulPaymentsV2.PaymentItem",
|
|
856
|
-
components: [
|
|
857
|
-
{
|
|
858
|
-
name: "settlementId",
|
|
859
|
-
type: "bytes32",
|
|
860
|
-
internalType: "bytes32"
|
|
861
|
-
},
|
|
862
|
-
{
|
|
863
|
-
name: "recipient",
|
|
864
|
-
type: "address",
|
|
865
|
-
internalType: "address"
|
|
866
|
-
},
|
|
867
|
-
{
|
|
868
|
-
name: "token",
|
|
869
|
-
type: "address",
|
|
870
|
-
internalType: "address"
|
|
871
|
-
},
|
|
872
|
-
{
|
|
873
|
-
name: "amount",
|
|
874
|
-
type: "uint256",
|
|
875
|
-
internalType: "uint256"
|
|
876
|
-
},
|
|
877
|
-
{
|
|
878
|
-
name: "kind",
|
|
879
|
-
type: "uint16",
|
|
880
|
-
internalType: "uint16"
|
|
881
|
-
},
|
|
882
|
-
{
|
|
883
|
-
name: "documentHash",
|
|
884
|
-
type: "bytes32",
|
|
885
|
-
internalType: "bytes32"
|
|
886
|
-
}
|
|
887
|
-
]
|
|
888
|
-
}],
|
|
889
|
-
outputs: [],
|
|
890
|
-
stateMutability: "nonpayable"
|
|
891
|
-
},
|
|
892
|
-
{
|
|
893
|
-
type: "function",
|
|
894
|
-
name: "sendBatch",
|
|
895
|
-
inputs: [{
|
|
896
|
-
name: "items",
|
|
897
|
-
type: "tuple[]",
|
|
898
|
-
internalType: "struct CapxulPaymentsV2.PaymentItem[]",
|
|
899
|
-
components: [
|
|
900
|
-
{
|
|
901
|
-
name: "settlementId",
|
|
902
|
-
type: "bytes32",
|
|
903
|
-
internalType: "bytes32"
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
name: "recipient",
|
|
907
|
-
type: "address",
|
|
908
|
-
internalType: "address"
|
|
909
|
-
},
|
|
910
|
-
{
|
|
911
|
-
name: "token",
|
|
912
|
-
type: "address",
|
|
913
|
-
internalType: "address"
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
name: "amount",
|
|
917
|
-
type: "uint256",
|
|
918
|
-
internalType: "uint256"
|
|
919
|
-
},
|
|
920
|
-
{
|
|
921
|
-
name: "kind",
|
|
922
|
-
type: "uint16",
|
|
923
|
-
internalType: "uint16"
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
name: "documentHash",
|
|
927
|
-
type: "bytes32",
|
|
928
|
-
internalType: "bytes32"
|
|
929
|
-
}
|
|
930
|
-
]
|
|
931
|
-
}],
|
|
932
|
-
outputs: [],
|
|
933
|
-
stateMutability: "nonpayable"
|
|
934
|
-
},
|
|
935
|
-
{
|
|
936
|
-
type: "function",
|
|
937
|
-
name: "vestedAmount",
|
|
938
|
-
inputs: [{
|
|
939
|
-
name: "commitmentId",
|
|
940
|
-
type: "uint256",
|
|
941
|
-
internalType: "uint256"
|
|
942
|
-
}],
|
|
943
|
-
outputs: [{
|
|
944
|
-
name: "",
|
|
945
|
-
type: "uint256",
|
|
946
|
-
internalType: "uint256"
|
|
947
|
-
}],
|
|
948
|
-
stateMutability: "view"
|
|
949
|
-
},
|
|
950
|
-
{
|
|
951
|
-
type: "event",
|
|
952
|
-
name: "CommitmentCancelled",
|
|
953
|
-
inputs: [
|
|
954
|
-
{
|
|
955
|
-
name: "commitmentId",
|
|
956
|
-
type: "uint256",
|
|
957
|
-
indexed: true,
|
|
958
|
-
internalType: "uint256"
|
|
959
|
-
},
|
|
960
|
-
{
|
|
961
|
-
name: "settlementId",
|
|
962
|
-
type: "bytes32",
|
|
963
|
-
indexed: true,
|
|
964
|
-
internalType: "bytes32"
|
|
965
|
-
},
|
|
966
|
-
{
|
|
967
|
-
name: "creator",
|
|
968
|
-
type: "address",
|
|
969
|
-
indexed: true,
|
|
970
|
-
internalType: "address"
|
|
971
|
-
},
|
|
972
|
-
{
|
|
973
|
-
name: "vestedUnclaimed",
|
|
974
|
-
type: "uint256",
|
|
975
|
-
indexed: false,
|
|
976
|
-
internalType: "uint256"
|
|
977
|
-
},
|
|
978
|
-
{
|
|
979
|
-
name: "unvestedReturned",
|
|
980
|
-
type: "uint256",
|
|
981
|
-
indexed: false,
|
|
982
|
-
internalType: "uint256"
|
|
983
|
-
},
|
|
984
|
-
{
|
|
985
|
-
name: "documentHash",
|
|
986
|
-
type: "bytes32",
|
|
987
|
-
indexed: false,
|
|
988
|
-
internalType: "bytes32"
|
|
989
|
-
}
|
|
990
|
-
],
|
|
991
|
-
anonymous: false
|
|
992
|
-
},
|
|
993
|
-
{
|
|
994
|
-
type: "event",
|
|
995
|
-
name: "CommitmentCreated",
|
|
996
|
-
inputs: [
|
|
997
|
-
{
|
|
998
|
-
name: "commitmentId",
|
|
999
|
-
type: "uint256",
|
|
1000
|
-
indexed: true,
|
|
1001
|
-
internalType: "uint256"
|
|
1002
|
-
},
|
|
1003
|
-
{
|
|
1004
|
-
name: "settlementId",
|
|
1005
|
-
type: "bytes32",
|
|
1006
|
-
indexed: true,
|
|
1007
|
-
internalType: "bytes32"
|
|
1008
|
-
},
|
|
1009
|
-
{
|
|
1010
|
-
name: "creator",
|
|
1011
|
-
type: "address",
|
|
1012
|
-
indexed: true,
|
|
1013
|
-
internalType: "address"
|
|
1014
|
-
},
|
|
1015
|
-
{
|
|
1016
|
-
name: "recipient",
|
|
1017
|
-
type: "address",
|
|
1018
|
-
indexed: false,
|
|
1019
|
-
internalType: "address"
|
|
1020
|
-
},
|
|
1021
|
-
{
|
|
1022
|
-
name: "token",
|
|
1023
|
-
type: "address",
|
|
1024
|
-
indexed: false,
|
|
1025
|
-
internalType: "address"
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
name: "totalAmount",
|
|
1029
|
-
type: "uint256",
|
|
1030
|
-
indexed: false,
|
|
1031
|
-
internalType: "uint256"
|
|
1032
|
-
},
|
|
1033
|
-
{
|
|
1034
|
-
name: "startTime",
|
|
1035
|
-
type: "uint48",
|
|
1036
|
-
indexed: false,
|
|
1037
|
-
internalType: "uint48"
|
|
1038
|
-
},
|
|
1039
|
-
{
|
|
1040
|
-
name: "cliffTime",
|
|
1041
|
-
type: "uint48",
|
|
1042
|
-
indexed: false,
|
|
1043
|
-
internalType: "uint48"
|
|
1044
|
-
},
|
|
1045
|
-
{
|
|
1046
|
-
name: "endTime",
|
|
1047
|
-
type: "uint48",
|
|
1048
|
-
indexed: false,
|
|
1049
|
-
internalType: "uint48"
|
|
1050
|
-
},
|
|
1051
|
-
{
|
|
1052
|
-
name: "kind",
|
|
1053
|
-
type: "uint16",
|
|
1054
|
-
indexed: false,
|
|
1055
|
-
internalType: "uint16"
|
|
1056
|
-
},
|
|
1057
|
-
{
|
|
1058
|
-
name: "documentHash",
|
|
1059
|
-
type: "bytes32",
|
|
1060
|
-
indexed: false,
|
|
1061
|
-
internalType: "bytes32"
|
|
1062
|
-
}
|
|
1063
|
-
],
|
|
1064
|
-
anonymous: false
|
|
1065
|
-
},
|
|
1066
|
-
{
|
|
1067
|
-
type: "event",
|
|
1068
|
-
name: "CommitmentRedirected",
|
|
1069
|
-
inputs: [
|
|
1070
|
-
{
|
|
1071
|
-
name: "commitmentId",
|
|
1072
|
-
type: "uint256",
|
|
1073
|
-
indexed: true,
|
|
1074
|
-
internalType: "uint256"
|
|
1075
|
-
},
|
|
1076
|
-
{
|
|
1077
|
-
name: "settlementId",
|
|
1078
|
-
type: "bytes32",
|
|
1079
|
-
indexed: true,
|
|
1080
|
-
internalType: "bytes32"
|
|
1081
|
-
},
|
|
1082
|
-
{
|
|
1083
|
-
name: "oldRecipient",
|
|
1084
|
-
type: "address",
|
|
1085
|
-
indexed: true,
|
|
1086
|
-
internalType: "address"
|
|
1087
|
-
},
|
|
1088
|
-
{
|
|
1089
|
-
name: "newRecipient",
|
|
1090
|
-
type: "address",
|
|
1091
|
-
indexed: false,
|
|
1092
|
-
internalType: "address"
|
|
1093
|
-
},
|
|
1094
|
-
{
|
|
1095
|
-
name: "documentHash",
|
|
1096
|
-
type: "bytes32",
|
|
1097
|
-
indexed: false,
|
|
1098
|
-
internalType: "bytes32"
|
|
1099
|
-
}
|
|
1100
|
-
],
|
|
1101
|
-
anonymous: false
|
|
1102
|
-
},
|
|
1103
|
-
{
|
|
1104
|
-
type: "event",
|
|
1105
|
-
name: "FundsClaimed",
|
|
1106
|
-
inputs: [
|
|
1107
|
-
{
|
|
1108
|
-
name: "commitmentId",
|
|
1109
|
-
type: "uint256",
|
|
1110
|
-
indexed: true,
|
|
1111
|
-
internalType: "uint256"
|
|
1112
|
-
},
|
|
1113
|
-
{
|
|
1114
|
-
name: "settlementId",
|
|
1115
|
-
type: "bytes32",
|
|
1116
|
-
indexed: true,
|
|
1117
|
-
internalType: "bytes32"
|
|
1118
|
-
},
|
|
1119
|
-
{
|
|
1120
|
-
name: "recipient",
|
|
1121
|
-
type: "address",
|
|
1122
|
-
indexed: true,
|
|
1123
|
-
internalType: "address"
|
|
1124
|
-
},
|
|
1125
|
-
{
|
|
1126
|
-
name: "amount",
|
|
1127
|
-
type: "uint256",
|
|
1128
|
-
indexed: false,
|
|
1129
|
-
internalType: "uint256"
|
|
1130
|
-
},
|
|
1131
|
-
{
|
|
1132
|
-
name: "documentHash",
|
|
1133
|
-
type: "bytes32",
|
|
1134
|
-
indexed: false,
|
|
1135
|
-
internalType: "bytes32"
|
|
1136
|
-
}
|
|
1137
|
-
],
|
|
1138
|
-
anonymous: false
|
|
1139
|
-
},
|
|
1140
|
-
{
|
|
1141
|
-
type: "event",
|
|
1142
|
-
name: "PaymentSent",
|
|
1143
|
-
inputs: [
|
|
1144
|
-
{
|
|
1145
|
-
name: "settlementId",
|
|
1146
|
-
type: "bytes32",
|
|
1147
|
-
indexed: true,
|
|
1148
|
-
internalType: "bytes32"
|
|
1149
|
-
},
|
|
1150
|
-
{
|
|
1151
|
-
name: "sender",
|
|
1152
|
-
type: "address",
|
|
1153
|
-
indexed: true,
|
|
1154
|
-
internalType: "address"
|
|
1155
|
-
},
|
|
1156
|
-
{
|
|
1157
|
-
name: "recipient",
|
|
1158
|
-
type: "address",
|
|
1159
|
-
indexed: true,
|
|
1160
|
-
internalType: "address"
|
|
1161
|
-
},
|
|
1162
|
-
{
|
|
1163
|
-
name: "token",
|
|
1164
|
-
type: "address",
|
|
1165
|
-
indexed: false,
|
|
1166
|
-
internalType: "address"
|
|
1167
|
-
},
|
|
1168
|
-
{
|
|
1169
|
-
name: "amount",
|
|
1170
|
-
type: "uint256",
|
|
1171
|
-
indexed: false,
|
|
1172
|
-
internalType: "uint256"
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
name: "kind",
|
|
1176
|
-
type: "uint16",
|
|
1177
|
-
indexed: false,
|
|
1178
|
-
internalType: "uint16"
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
name: "documentHash",
|
|
1182
|
-
type: "bytes32",
|
|
1183
|
-
indexed: false,
|
|
1184
|
-
internalType: "bytes32"
|
|
1185
|
-
}
|
|
1186
|
-
],
|
|
1187
|
-
anonymous: false
|
|
1188
|
-
},
|
|
1189
|
-
{
|
|
1190
|
-
type: "error",
|
|
1191
|
-
name: "AlreadyCancelled",
|
|
1192
|
-
inputs: []
|
|
1193
|
-
},
|
|
1194
|
-
{
|
|
1195
|
-
type: "error",
|
|
1196
|
-
name: "AlreadyClaimed",
|
|
1197
|
-
inputs: []
|
|
1198
|
-
},
|
|
1199
|
-
{
|
|
1200
|
-
type: "error",
|
|
1201
|
-
name: "DocumentHashMismatch",
|
|
1202
|
-
inputs: [{
|
|
1203
|
-
name: "expected",
|
|
1204
|
-
type: "bytes32",
|
|
1205
|
-
internalType: "bytes32"
|
|
1206
|
-
}, {
|
|
1207
|
-
name: "supplied",
|
|
1208
|
-
type: "bytes32",
|
|
1209
|
-
internalType: "bytes32"
|
|
1210
|
-
}]
|
|
1211
|
-
},
|
|
1212
|
-
{
|
|
1213
|
-
type: "error",
|
|
1214
|
-
name: "InvalidTimeParams",
|
|
1215
|
-
inputs: []
|
|
1216
|
-
},
|
|
1217
|
-
{
|
|
1218
|
-
type: "error",
|
|
1219
|
-
name: "NotCreator",
|
|
1220
|
-
inputs: []
|
|
1221
|
-
},
|
|
1222
|
-
{
|
|
1223
|
-
type: "error",
|
|
1224
|
-
name: "NotRecipient",
|
|
1225
|
-
inputs: []
|
|
1226
|
-
},
|
|
1227
|
-
{
|
|
1228
|
-
type: "error",
|
|
1229
|
-
name: "NothingToClaim",
|
|
1230
|
-
inputs: []
|
|
1231
|
-
},
|
|
1232
|
-
{
|
|
1233
|
-
type: "error",
|
|
1234
|
-
name: "SettlementIdConsumed",
|
|
1235
|
-
inputs: [{
|
|
1236
|
-
name: "settlementId",
|
|
1237
|
-
type: "bytes32",
|
|
1238
|
-
internalType: "bytes32"
|
|
1239
|
-
}]
|
|
1240
|
-
},
|
|
1241
|
-
{
|
|
1242
|
-
type: "error",
|
|
1243
|
-
name: "TokenCallReturnedFalse",
|
|
1244
|
-
inputs: [{
|
|
1245
|
-
name: "token",
|
|
1246
|
-
type: "address",
|
|
1247
|
-
internalType: "address"
|
|
1248
|
-
}]
|
|
1249
|
-
},
|
|
1250
|
-
{
|
|
1251
|
-
type: "error",
|
|
1252
|
-
name: "TokenHasNoCode",
|
|
1253
|
-
inputs: [{
|
|
1254
|
-
name: "token",
|
|
1255
|
-
type: "address",
|
|
1256
|
-
internalType: "address"
|
|
1257
|
-
}]
|
|
1258
|
-
},
|
|
1259
|
-
{
|
|
1260
|
-
type: "error",
|
|
1261
|
-
name: "ZeroAddress",
|
|
1262
|
-
inputs: []
|
|
1263
|
-
},
|
|
1264
|
-
{
|
|
1265
|
-
type: "error",
|
|
1266
|
-
name: "ZeroAmount",
|
|
1267
|
-
inputs: []
|
|
1268
|
-
},
|
|
1269
|
-
{
|
|
1270
|
-
type: "error",
|
|
1271
|
-
name: "ZeroDocumentHash",
|
|
1272
|
-
inputs: []
|
|
1273
|
-
},
|
|
1274
|
-
{
|
|
1275
|
-
type: "error",
|
|
1276
|
-
name: "ZeroSettlementId",
|
|
1277
|
-
inputs: []
|
|
1278
|
-
}
|
|
1279
|
-
];
|
|
1280
|
-
/** Immutable CapxulPaymentsV2 deployment on Base Sepolia. */
|
|
1281
|
-
const CAPXUL_PAYMENTS_V2_ADDRESS = "0x7a5c25aB7ce91d7a475B71cd1ec33E230291f8a4";
|
|
1282
|
-
//#endregion
|
|
1283
|
-
//#region ../config/src/route.ts
|
|
1284
|
-
/** USDX on Base Sepolia — the only settlement token in v1. */
|
|
1285
|
-
const USDX_BASE_SEPOLIA_TOKEN = {
|
|
1286
|
-
chainId: BASE_SEPOLIA_CHAIN_ID,
|
|
1287
|
-
address: USDX_ADDRESS_BASE_SEPOLIA,
|
|
1288
|
-
decimals: 6
|
|
1289
|
-
};
|
|
1290
|
-
USDX_BASE_SEPOLIA_TOKEN.chainId;
|
|
1291
|
-
USDX_BASE_SEPOLIA_TOKEN.chainId;
|
|
1292
|
-
10n ** BigInt(6);
|
|
1293
|
-
function normalizeOrgRoleLabel(label) {
|
|
1294
|
-
const normalized = label.trim().replace(/\s+/g, " ");
|
|
1295
|
-
if (normalized.length === 0) throw Errors.invalidInput("role.label", "must be a non-empty role label");
|
|
1296
|
-
return normalized;
|
|
1297
|
-
}
|
|
1298
|
-
function orgRoleKeyForLabel(label) {
|
|
1299
|
-
return keccak256(toBytes(normalizeOrgRoleLabel(label).toLowerCase()));
|
|
1300
|
-
}
|
|
1301
|
-
padHex(stringToHex("FM_DAILY"), {
|
|
1302
|
-
size: 32,
|
|
1303
|
-
dir: "right"
|
|
1304
|
-
}), padHex(stringToHex("TL_DAILY"), {
|
|
1305
|
-
size: 32,
|
|
1306
|
-
dir: "right"
|
|
1307
|
-
});
|
|
1308
|
-
padHex(concat([MULTI_SEND_CALL_ONLY, "0x8d80ff0a"]), {
|
|
1309
|
-
dir: "right",
|
|
1310
|
-
size: 32
|
|
1311
|
-
});
|
|
1312
|
-
function paymentsV2Signature(name) {
|
|
1313
|
-
const item = CAPXUL_PAYMENTS_V2_ABI.find((candidate) => candidate.type === "function" && candidate.name === name);
|
|
1314
|
-
if (item === void 0) throw new Error(`CapxulPaymentsV2 ABI has no ${name} function`);
|
|
1315
|
-
return toFunctionSignature(item);
|
|
1316
|
-
}
|
|
1317
|
-
paymentsV2Signature("send");
|
|
1318
|
-
paymentsV2Signature("sendBatch");
|
|
1319
|
-
paymentsV2Signature("createCommitment");
|
|
1320
|
-
paymentsV2Signature("cancel");
|
|
1321
|
-
paymentsV2Signature("redirect");
|
|
1322
|
-
new Map([
|
|
1323
|
-
["assignRoles(address,bytes32[],bool[])", "AssignRoles(address,bytes32[],bool[])"],
|
|
1324
|
-
["allowTarget(bytes32,address,uint8)", "AllowTarget(bytes32,address,uint8)"],
|
|
1325
|
-
["scopeTarget(bytes32,address)", "ScopeTarget(bytes32,address)"],
|
|
1326
|
-
["revokeTarget(bytes32,address)", "RevokeTarget(bytes32,address)"],
|
|
1327
|
-
["allowFunction(bytes32,address,bytes4,uint8)", "AllowFunction(bytes32,address,bytes4,uint8)"],
|
|
1328
|
-
["scopeFunction(bytes32,address,bytes4,(uint8,uint8,uint8,bytes)[],uint8)", "ScopeFunction(bytes32,address,bytes4,(uint8,uint8,uint8,bytes)[],uint8)"],
|
|
1329
|
-
["revokeFunction(bytes32,address,bytes4)", "RevokeFunction(bytes32,address,bytes4)"],
|
|
1330
|
-
["setAllowance(bytes32,uint128,uint128,uint128,uint64,uint64)", "SetAllowance(bytes32,uint128,uint128,uint128,uint64,uint64)"]
|
|
1331
|
-
].map(([functionSignature, eventSignature]) => [toFunctionSelector(functionSignature), toEventSelector(eventSignature)]));
|
|
1332
|
-
//#endregion
|
|
1333
401
|
//#region ../wire/src/brands.ts
|
|
1334
402
|
const lowercasedString = Schema.String.pipe(Schema.decodeTo(Schema.String, {
|
|
1335
403
|
decode: SchemaGetter.transform((value) => value.toLowerCase()),
|
|
@@ -4546,7 +3614,7 @@ const moneyExecutionContract = {
|
|
|
4546
3614
|
};
|
|
4547
3615
|
//#endregion
|
|
4548
3616
|
//#region package.json
|
|
4549
|
-
var version = "
|
|
3617
|
+
var version = "3.0.0";
|
|
4550
3618
|
//#endregion
|
|
4551
3619
|
//#region src/telemetry/exception-projection.ts
|
|
4552
3620
|
/** Fixed fallback for failures that have no safe message. */
|
|
@@ -4743,7 +3811,7 @@ function report(adapter, kind, operation, cause, invocation, origin) {
|
|
|
4743
3811
|
}
|
|
4744
3812
|
} else if (reportedByMachine(cause)) return;
|
|
4745
3813
|
const operationName = normalizeOperation(operation);
|
|
4746
|
-
const kindName = normalizeErrorKind(errorKind
|
|
3814
|
+
const kindName = normalizeErrorKind(errorKind(cause));
|
|
4747
3815
|
const context = sanitizeObservationContext({
|
|
4748
3816
|
...invocation.context,
|
|
4749
3817
|
...isCapxulError(cause) && cause.correlationId !== void 0 ? { correlationId: cause.correlationId } : {}
|
|
@@ -4945,7 +4013,7 @@ function failureEvidence(cause) {
|
|
|
4945
4013
|
return {};
|
|
4946
4014
|
}
|
|
4947
4015
|
}
|
|
4948
|
-
function errorKind
|
|
4016
|
+
function errorKind(cause) {
|
|
4949
4017
|
try {
|
|
4950
4018
|
if (isCapxulError(cause)) return normalizeErrorKind(cause.code);
|
|
4951
4019
|
if (cause instanceof Error) return normalizeErrorKind(cause.name);
|
|
@@ -6214,42 +5282,6 @@ function mapOk(result, f) {
|
|
|
6214
5282
|
}
|
|
6215
5283
|
}
|
|
6216
5284
|
//#endregion
|
|
6217
|
-
//#region src/ports/auth-client.ts
|
|
6218
|
-
var AuthClientError = class extends Data.TaggedError("AuthClientError") {};
|
|
6219
|
-
var AuthClientPortTag = class extends Context.Service()("@capxul/sdk/ports/AuthClientPort") {};
|
|
6220
|
-
//#endregion
|
|
6221
|
-
//#region src/adapters/auth-client/effect-port.ts
|
|
6222
|
-
function authClientPortFromPromiseAdapter(adapter) {
|
|
6223
|
-
return {
|
|
6224
|
-
canSendOtp: (input, options) => fromResult("canSendOtp", () => adapter.canSendOtp(input, options)),
|
|
6225
|
-
sendOtp: (input, options) => fromResult("sendOtp", () => adapter.sendOtp(input, options)),
|
|
6226
|
-
verifyOtp: (input, options) => fromResult("verifyOtp", () => adapter.verifyOtp(input, options)),
|
|
6227
|
-
getSession: (options) => fromResult("getSession", () => adapter.getSession(options)),
|
|
6228
|
-
signOut: (options) => fromResult("signOut", () => adapter.signOut(options)),
|
|
6229
|
-
getConvexJwt: (options) => fromResult("getConvexJwt", () => adapter.getConvexJwt(options))
|
|
6230
|
-
};
|
|
6231
|
-
}
|
|
6232
|
-
function fromResult(operation, run) {
|
|
6233
|
-
return Effect.tryPromise({
|
|
6234
|
-
try: run,
|
|
6235
|
-
catch: (cause) => new AuthClientError({
|
|
6236
|
-
operation,
|
|
6237
|
-
kind: "thrown",
|
|
6238
|
-
cause
|
|
6239
|
-
})
|
|
6240
|
-
}).pipe(Effect.flatMap((result) => result.ok ? Effect.succeed(result.value) : Effect.fail(new AuthClientError({
|
|
6241
|
-
operation,
|
|
6242
|
-
kind: errorKind(result.error),
|
|
6243
|
-
cause: result.error
|
|
6244
|
-
}))));
|
|
6245
|
-
}
|
|
6246
|
-
function errorKind(error) {
|
|
6247
|
-
if (error.code === "CANCELLED") return "cancelled";
|
|
6248
|
-
if (error.code === "NETWORK_ERROR") return "network";
|
|
6249
|
-
if (error.code === "INVALID_INPUT" || error.code === "OTP_EXPIRED") return "validation";
|
|
6250
|
-
return "provider";
|
|
6251
|
-
}
|
|
6252
|
-
//#endregion
|
|
6253
5285
|
//#region src/ports/bootstrap.ts
|
|
6254
5286
|
var BootstrapError = class extends Data.TaggedError("BootstrapError") {};
|
|
6255
5287
|
function bootstrapErrorFromCapxul(kind, error) {
|
|
@@ -6263,10 +5295,6 @@ function bootstrapErrorFromCapxul(kind, error) {
|
|
|
6263
5295
|
}
|
|
6264
5296
|
var BootstrapPortTag = class extends Context.Service()("@capxul/sdk/ports/BootstrapPort") {};
|
|
6265
5297
|
//#endregion
|
|
6266
|
-
//#region src/ports/clock.ts
|
|
6267
|
-
var ClockError = class extends Data.TaggedError("ClockError") {};
|
|
6268
|
-
var ClockPortTag = class extends Context.Service()("@capxul/sdk/ports/ClockPort") {};
|
|
6269
|
-
//#endregion
|
|
6270
5298
|
//#region src/ports/convex-call.ts
|
|
6271
5299
|
var ConvexCallError = class extends Data.TaggedError("ConvexCallError") {};
|
|
6272
5300
|
function convexCallErrorFromCapxul(operation, error, transport) {
|
|
@@ -9809,4 +8837,4 @@ function withHostObservationControls(snapshot, input) {
|
|
|
9809
8837
|
return captured === void 0 ? copied : attachInvocationObservation(copied, captured);
|
|
9810
8838
|
}
|
|
9811
8839
|
//#endregion
|
|
9812
|
-
export {
|
|
8840
|
+
export { EngineeringTelemetryBootstrapPolicy as $, normalizeExceptionErrorKind as A, isSignerNotReadySignal as B, failureDetail as C, postHogFailureObservation as D, observeFailedResult as E, fromWei as F, readInvocationObservation as G, signerFailure as H, isSettingUpLifecycle as I, sanitizeObservationContext as J, OBSERVATION_CONTEXT_HEADER as K, formatTraceparent as L, projectSdkException as M, safeExceptionLabel as N, EXCEPTION_MESSAGE as O, version as P, BootstrapEnvelope as Q, causeChain as R, CAPXUL_SDK_EXPECTED_OUTCOME_EVENT as S, observationContextProps as T, resolveFailureMode as U, openfortSignerNotReadyCode as V, copyInvocationObservation as W, PAYMENT_STATUSES as X, PAYMENT_DIRECTIONS as Y, CAPXUL_FUNCTIONS as Z, convexCallErrorFromCapxul as _, AccountReadPortTag as a, fingerprintPaymentIntent as b, redactTelemetryEvent as c, retryIdempotentRead as d, destination as et, PRODUCT_INVOCATION as f, ConvexCallPortTag as g, identityErrorFromCapxul as h, smartAccountErrorFromCapxul as i, normalizeExceptionOperation as j, SDK_VERSION as k, redactTelemetryProps as l, IdentityPortTag as m, detectAuthCacheAdapter as n, isRestoring as nt, accountReadErrorFromCapxul as o, wireChainId as p, encodeObservationContextHeader as q, SmartAccountPortTag as r, TelemetryPortTag as s, assembleCapxulClient as t, isClaimed as tt, stampTelemetryEnvelope as u, BootstrapPortTag as v, failureEvidenceProps as w, toWei as x, bootstrapErrorFromCapxul as y, injectedWalletSigner as z };
|