@chipi-stack/backend 14.10.1 → 14.12.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/README.md CHANGED
@@ -43,6 +43,56 @@ const tx = await sdk.transfer({
43
43
  });
44
44
  ```
45
45
 
46
+ ## Confirming a transaction
47
+
48
+ Every gasless write returns a transaction hash and nothing else, so
49
+ `waitForTransaction` answers the two questions that follow: did it succeed, and
50
+ what did it emit.
51
+
52
+ ```typescript
53
+ import { waitForTransaction } from "@chipi-stack/backend";
54
+
55
+ const receipt = await waitForTransaction(tx);
56
+
57
+ if (!receipt.success) {
58
+ throw new Error(receipt.revertReason ?? "reverted on chain");
59
+ }
60
+
61
+ // Raw events, decode against your own ABI.
62
+ const transferred = receipt.events.filter((e) => e.from_address === USDC);
63
+ ```
64
+
65
+ A revert comes back as a **result** (`success: false` plus `revertReason`), not
66
+ a throw, because a revert is a normal outcome you branch on. Only "we do not
67
+ know yet" throws, meaning a timeout or transport failure, where retrying is the
68
+ correct response.
69
+
70
+ Options: `nodeUrl`, `retryIntervalMs` (default 3000) and `timeoutMs`
71
+ (default 300000). `nodeUrl` is your preferred endpoint rather than the only one
72
+ tried, since reading a receipt is idempotent and falls through the RPC chain.
73
+
74
+ ## Treasuries
75
+
76
+ `sdk.treasury` drives a SHHH multisig from your own server. All three below need
77
+ a `sk_`, so keep them server-side.
78
+
79
+ ```typescript
80
+ // Discover a treasury instead of pinning its id in an env var.
81
+ const { items } = await sdk.treasury.list();
82
+ const ops = items.find((t) => t.name === "Ops Treasury");
83
+
84
+ // Require more signatures to borrow than to repay.
85
+ await sdk.treasury.setPolicy(ops.id, { sensitiveQuorum: 3 });
86
+ const policy = await sdk.treasury.getPolicy(ops.id);
87
+
88
+ // A transport bound to one treasury + owner, wireable into chipi-react's hooks.
89
+ const transport = sdk.treasury.forTreasury({ treasuryId: ops.id, ownerPubkey });
90
+ ```
91
+
92
+ A quorum can only **raise** `requiredApprovals` above the wallet's on-chain
93
+ threshold. The chain is the hard floor, so a quorum below it produces proposals
94
+ that reach approved and then revert at execute.
95
+
46
96
  ## What you can ship
47
97
 
48
98
  - **Wallet-as-a-service APIs** — provision and manage wallets for your users from your backend
package/dist/index.d.mts CHANGED
@@ -157,7 +157,9 @@ declare class ChipiSessions {
157
157
  * 1. Generated via `createSessionKey()`
158
158
  * 2. Registered on-chain via `addSessionKeyToContract()`
159
159
  *
160
- * CHIPI wallets only - will throw if wallet type is not CHIPI.
160
+ * CHIPI v29 and SHHH V8.4 only: both embed the SNIP-163 sessions
161
+ * component. Throws for any other wallet type, notably READY (Argent X),
162
+ * which does not. See `validateWalletSupportsSessions`.
161
163
  *
162
164
  * @param params - Session execution parameters
163
165
  * @param bearerToken - Authentication token
@@ -387,6 +389,72 @@ interface MultisigAllowance {
387
389
  canExecuteNow?: boolean;
388
390
  [key: string]: unknown;
389
391
  }
392
+ /** One treasury as returned by `list()`. Mirrors chipi-back's `OrgTreasury`
393
+ * row plus the joined wallet projection. Dates arrive as ISO strings. */
394
+ interface TreasurySummary {
395
+ /** The id `forTreasury({ treasuryId })` expects. */
396
+ id: string;
397
+ organizationId: string;
398
+ name: string;
399
+ walletId: string;
400
+ createdAt: string;
401
+ updatedAt: string;
402
+ /** Non-null once archived. Archived treasuries are excluded unless
403
+ * `includeArchived` is set. */
404
+ archivedAt: string | null;
405
+ routineQuorum: number | null;
406
+ sensitiveQuorum: number | null;
407
+ wallet: {
408
+ id: string;
409
+ publicKey: string;
410
+ walletType: string;
411
+ isDeployed: boolean;
412
+ chain: string;
413
+ };
414
+ }
415
+ /** Page of treasuries owned by the api key's org. */
416
+ interface ListTreasuriesResult {
417
+ items: TreasurySummary[];
418
+ total: number;
419
+ page: number;
420
+ limit: number;
421
+ hasMore: boolean;
422
+ }
423
+ /**
424
+ * Risk-tier quorum policy for one treasury.
425
+ *
426
+ * A proposal filed with `risk: "ROUTINE" | "SENSITIVE"` gets its
427
+ * `requiredApprovals` overridden server-side from the matching quorum, so you
428
+ * can require more signatures for `borrow` than for `repay` without changing
429
+ * the wallet's on-chain threshold.
430
+ *
431
+ * `null` means the tier has no policy and the client's `requiredApprovals`
432
+ * stands.
433
+ */
434
+ interface TreasuryPolicy {
435
+ treasuryId: string;
436
+ name: string;
437
+ routineQuorum: number | null;
438
+ sensitiveQuorum: number | null;
439
+ }
440
+ interface SetTreasuryPolicyOptions {
441
+ /** Omit to leave unchanged. Pass `null` to clear the tier. */
442
+ routineQuorum?: number | null;
443
+ /** Omit to leave unchanged. Pass `null` to clear the tier. */
444
+ sensitiveQuorum?: number | null;
445
+ /** A `sk_`. Falls back to the SDK's configured `apiSecretKey`. */
446
+ bearerToken?: string;
447
+ }
448
+ interface ListTreasuriesOptions {
449
+ /** 1-based. Defaults to 1 server-side. */
450
+ page?: number;
451
+ /** Server clamps to 1..100; defaults to 25. */
452
+ limit?: number;
453
+ /** Include archived treasuries. Defaults to false. */
454
+ includeArchived?: boolean;
455
+ /** A `sk_`. Falls back to the SDK's configured `apiSecretKey`. */
456
+ bearerToken?: string;
457
+ }
390
458
  /**
391
459
  * A transport bound to one treasury + the local owner's public key.
392
460
  * Structurally compatible with `@chipi-stack/chipi-react`'s `MultisigTransport`.
@@ -431,6 +499,56 @@ declare class ChipiTreasury {
431
499
  private base;
432
500
  /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
433
501
  private secret;
502
+ /**
503
+ * List every treasury owned by the api key's organization (`sk_`).
504
+ *
505
+ * This is the discovery entry point for {@link ForTreasuryConfig.treasuryId}.
506
+ * The secret key resolves the org server-side, so there is no org id to
507
+ * pass and nothing to look up in the dashboard first. Use it to recover a
508
+ * `treasuryId` that fell out of your config, or to avoid pinning one in an
509
+ * environment variable at all.
510
+ *
511
+ * Server-only: it needs a `sk_`, so never call it from the browser.
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * const { items } = await sdk.treasury.list();
516
+ * const ops = items.find((t) => t.name === "Ops Treasury");
517
+ * const transport = sdk.treasury.forTreasury({
518
+ * treasuryId: ops.id,
519
+ * ownerPubkey,
520
+ * });
521
+ * ```
522
+ */
523
+ list(options?: ListTreasuriesOptions): Promise<ListTreasuriesResult>;
524
+ /**
525
+ * Read a treasury's risk-tier quorum policy (`sk_`).
526
+ */
527
+ getPolicy(treasuryId: string, options?: {
528
+ bearerToken?: string;
529
+ }): Promise<TreasuryPolicy>;
530
+ /**
531
+ * Set a treasury's risk-tier quorums (`sk_`).
532
+ *
533
+ * An omitted tier is left unchanged; passing `null` clears it. Configuring
534
+ * this used to require the dashboard, so an integrator driving governance
535
+ * from their own server could see a quorum applied to a proposal but never
536
+ * choose it.
537
+ *
538
+ * IMPORTANT: a quorum can only RAISE `requiredApprovals` above the wallet's
539
+ * on-chain threshold. The chain is the hard floor, so a quorum set below it
540
+ * produces proposals that reach `APPROVED` here and then revert at execute.
541
+ *
542
+ * Server-only: it needs a `sk_`.
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * // Founding a pool and borrowing need 3 owners; repaying needs the
547
+ * // wallet's own threshold.
548
+ * await sdk.treasury.setPolicy(treasuryId, { sensitiveQuorum: 3 });
549
+ * ```
550
+ */
551
+ setPolicy(treasuryId: string, options?: SetTreasuryPolicyOptions): Promise<TreasuryPolicy>;
434
552
  /**
435
553
  * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
436
554
  * returned object directly into chipi-react's `useProposeAction` /
@@ -828,6 +946,81 @@ declare const signTypedDataArray: ({ params, }: {
828
946
  params: SignTypedDataParams;
829
947
  }) => Promise<string[]>;
830
948
 
949
+ /**
950
+ * Wait for a Starknet transaction and report what happened, without throwing
951
+ * on an on-chain revert.
952
+ *
953
+ * Every gasless write in this SDK returns a transaction hash and nothing else,
954
+ * so integrators were each writing the same receipt-polling loop to answer two
955
+ * questions: did it actually succeed, and what events did it emit. Getting that
956
+ * loop wrong is expensive in a money flow. A revert that reads as success
957
+ * double-credits a ledger; a timeout treated as failure strands a confirmed
958
+ * transfer.
959
+ *
960
+ * The contract here is deliberately narrow: a REVERTED transaction is a
961
+ * RESULT, not an exception, because a revert is a normal outcome your code
962
+ * must branch on. Exceptions are reserved for "we do not know yet": a timeout
963
+ * or a transport failure, where retrying is the correct response and treating
964
+ * it as failure would be wrong.
965
+ */
966
+ /** One raw event from the receipt. Decode against your own ABI. */
967
+ interface ContractEventLog {
968
+ /** Emitting contract address. Filter on this before matching keys. */
969
+ from_address: string;
970
+ /** Indexed fields. `keys[0]` is the selector of the event name. */
971
+ keys: string[];
972
+ /** Non-indexed fields, in declaration order. */
973
+ data: string[];
974
+ }
975
+ interface WaitForTransactionResult {
976
+ transactionHash: string;
977
+ /** True only for an accepted, non-reverted transaction. */
978
+ success: boolean;
979
+ /** Raw `execution_status` from the node, when it reported one. */
980
+ executionStatus?: string;
981
+ /** Raw `finality_status` from the node, when it reported one. */
982
+ finalityStatus?: string;
983
+ /** Present when `success` is false and the node gave a reason. */
984
+ revertReason?: string;
985
+ /** Empty on a revert: reverted transactions emit no events. */
986
+ events: ContractEventLog[];
987
+ blockNumber?: number;
988
+ }
989
+ interface WaitForTransactionOptions {
990
+ /**
991
+ * Preferred endpoint. It is the caller's slot in the ordered RPC chain, not
992
+ * the only endpoint tried: reading a receipt is idempotent, so a transport
993
+ * failure falls through to the next endpoint rather than aborting the wait.
994
+ * Defaults to the endpoint the SDK already uses for CHIPI wallets.
995
+ */
996
+ nodeUrl?: string;
997
+ /** Poll interval. Default 3000ms, roughly Starknet's block cadence. */
998
+ retryIntervalMs?: number;
999
+ /** Total budget before giving up. Default 300000ms (5 minutes). */
1000
+ timeoutMs?: number;
1001
+ }
1002
+ /**
1003
+ * Poll until `transactionHash` reaches a terminal state.
1004
+ *
1005
+ * @throws if the timeout elapses before the node sequences the transaction.
1006
+ * It does NOT throw when the transaction reverted: check `success`.
1007
+ *
1008
+ * @example
1009
+ * ```typescript
1010
+ * const txHash = await sdk.callAnyContract({ params, bearerToken });
1011
+ * const receipt = await sdk.waitForTransaction(txHash);
1012
+ *
1013
+ * if (!receipt.success) {
1014
+ * throw new Error(receipt.revertReason ?? "reverted on chain");
1015
+ * }
1016
+ *
1017
+ * const created = receipt.events.find(
1018
+ * (e) => e.from_address === FACTORY && e.keys[0] === POOL_CREATED_SELECTOR
1019
+ * );
1020
+ * ```
1021
+ */
1022
+ declare function waitForTransaction(transactionHash: string, options?: WaitForTransactionOptions): Promise<WaitForTransactionResult>;
1023
+
831
1024
  declare const encryptPrivateKey: (privateKey: string, password: string) => string;
832
1025
  declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
833
1026
 
@@ -2572,4 +2765,4 @@ declare class ShhhAccount {
2572
2765
  */
2573
2766
  declare function submitViaAccount(funded: Account): ShhhSubmit;
2574
2767
 
2575
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, type MultisigAllowance, type NewOwnerInput, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, type OutsideExecution, type OwnerRole, type ProposeBody, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, ShhhAccount, type ShhhAccountOptions, type ShhhExecuteOptions, type ShhhSignedExecution, type ShhhSubmit, type ShhhX402Wallet, TIMELOCK_SECONDS, type TreasuryProposal, type TreasuryProposalSignature, type TreasuryTransport, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519OwnerPubkeyParam, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191OwnerPubkeyParam, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, signTypedDataArray, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, submitViaAccount, webauthnOwnerId, webauthnOwnerPubkeyParam, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
2768
+ export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, type ContractEventLog, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, type ListTreasuriesOptions, type ListTreasuriesResult, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, type MultisigAllowance, type NewOwnerInput, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, type OutsideExecution, type OwnerRole, type ProposeBody, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, type SetTreasuryPolicyOptions, ShhhAccount, type ShhhAccountOptions, type ShhhExecuteOptions, type ShhhSignedExecution, type ShhhSubmit, type ShhhX402Wallet, TIMELOCK_SECONDS, type TreasuryPolicy, type TreasuryProposal, type TreasuryProposalSignature, type TreasurySummary, type TreasuryTransport, VIEW_SELECTORS, type WaitForTransactionOptions, type WaitForTransactionResult, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519OwnerPubkeyParam, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191OwnerPubkeyParam, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, signTypedDataArray, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, submitViaAccount, waitForTransaction, webauthnOwnerId, webauthnOwnerPubkeyParam, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
package/dist/index.d.ts CHANGED
@@ -157,7 +157,9 @@ declare class ChipiSessions {
157
157
  * 1. Generated via `createSessionKey()`
158
158
  * 2. Registered on-chain via `addSessionKeyToContract()`
159
159
  *
160
- * CHIPI wallets only - will throw if wallet type is not CHIPI.
160
+ * CHIPI v29 and SHHH V8.4 only: both embed the SNIP-163 sessions
161
+ * component. Throws for any other wallet type, notably READY (Argent X),
162
+ * which does not. See `validateWalletSupportsSessions`.
161
163
  *
162
164
  * @param params - Session execution parameters
163
165
  * @param bearerToken - Authentication token
@@ -387,6 +389,72 @@ interface MultisigAllowance {
387
389
  canExecuteNow?: boolean;
388
390
  [key: string]: unknown;
389
391
  }
392
+ /** One treasury as returned by `list()`. Mirrors chipi-back's `OrgTreasury`
393
+ * row plus the joined wallet projection. Dates arrive as ISO strings. */
394
+ interface TreasurySummary {
395
+ /** The id `forTreasury({ treasuryId })` expects. */
396
+ id: string;
397
+ organizationId: string;
398
+ name: string;
399
+ walletId: string;
400
+ createdAt: string;
401
+ updatedAt: string;
402
+ /** Non-null once archived. Archived treasuries are excluded unless
403
+ * `includeArchived` is set. */
404
+ archivedAt: string | null;
405
+ routineQuorum: number | null;
406
+ sensitiveQuorum: number | null;
407
+ wallet: {
408
+ id: string;
409
+ publicKey: string;
410
+ walletType: string;
411
+ isDeployed: boolean;
412
+ chain: string;
413
+ };
414
+ }
415
+ /** Page of treasuries owned by the api key's org. */
416
+ interface ListTreasuriesResult {
417
+ items: TreasurySummary[];
418
+ total: number;
419
+ page: number;
420
+ limit: number;
421
+ hasMore: boolean;
422
+ }
423
+ /**
424
+ * Risk-tier quorum policy for one treasury.
425
+ *
426
+ * A proposal filed with `risk: "ROUTINE" | "SENSITIVE"` gets its
427
+ * `requiredApprovals` overridden server-side from the matching quorum, so you
428
+ * can require more signatures for `borrow` than for `repay` without changing
429
+ * the wallet's on-chain threshold.
430
+ *
431
+ * `null` means the tier has no policy and the client's `requiredApprovals`
432
+ * stands.
433
+ */
434
+ interface TreasuryPolicy {
435
+ treasuryId: string;
436
+ name: string;
437
+ routineQuorum: number | null;
438
+ sensitiveQuorum: number | null;
439
+ }
440
+ interface SetTreasuryPolicyOptions {
441
+ /** Omit to leave unchanged. Pass `null` to clear the tier. */
442
+ routineQuorum?: number | null;
443
+ /** Omit to leave unchanged. Pass `null` to clear the tier. */
444
+ sensitiveQuorum?: number | null;
445
+ /** A `sk_`. Falls back to the SDK's configured `apiSecretKey`. */
446
+ bearerToken?: string;
447
+ }
448
+ interface ListTreasuriesOptions {
449
+ /** 1-based. Defaults to 1 server-side. */
450
+ page?: number;
451
+ /** Server clamps to 1..100; defaults to 25. */
452
+ limit?: number;
453
+ /** Include archived treasuries. Defaults to false. */
454
+ includeArchived?: boolean;
455
+ /** A `sk_`. Falls back to the SDK's configured `apiSecretKey`. */
456
+ bearerToken?: string;
457
+ }
390
458
  /**
391
459
  * A transport bound to one treasury + the local owner's public key.
392
460
  * Structurally compatible with `@chipi-stack/chipi-react`'s `MultisigTransport`.
@@ -431,6 +499,56 @@ declare class ChipiTreasury {
431
499
  private base;
432
500
  /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
433
501
  private secret;
502
+ /**
503
+ * List every treasury owned by the api key's organization (`sk_`).
504
+ *
505
+ * This is the discovery entry point for {@link ForTreasuryConfig.treasuryId}.
506
+ * The secret key resolves the org server-side, so there is no org id to
507
+ * pass and nothing to look up in the dashboard first. Use it to recover a
508
+ * `treasuryId` that fell out of your config, or to avoid pinning one in an
509
+ * environment variable at all.
510
+ *
511
+ * Server-only: it needs a `sk_`, so never call it from the browser.
512
+ *
513
+ * @example
514
+ * ```typescript
515
+ * const { items } = await sdk.treasury.list();
516
+ * const ops = items.find((t) => t.name === "Ops Treasury");
517
+ * const transport = sdk.treasury.forTreasury({
518
+ * treasuryId: ops.id,
519
+ * ownerPubkey,
520
+ * });
521
+ * ```
522
+ */
523
+ list(options?: ListTreasuriesOptions): Promise<ListTreasuriesResult>;
524
+ /**
525
+ * Read a treasury's risk-tier quorum policy (`sk_`).
526
+ */
527
+ getPolicy(treasuryId: string, options?: {
528
+ bearerToken?: string;
529
+ }): Promise<TreasuryPolicy>;
530
+ /**
531
+ * Set a treasury's risk-tier quorums (`sk_`).
532
+ *
533
+ * An omitted tier is left unchanged; passing `null` clears it. Configuring
534
+ * this used to require the dashboard, so an integrator driving governance
535
+ * from their own server could see a quorum applied to a proposal but never
536
+ * choose it.
537
+ *
538
+ * IMPORTANT: a quorum can only RAISE `requiredApprovals` above the wallet's
539
+ * on-chain threshold. The chain is the hard floor, so a quorum set below it
540
+ * produces proposals that reach `APPROVED` here and then revert at execute.
541
+ *
542
+ * Server-only: it needs a `sk_`.
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * // Founding a pool and borrowing need 3 owners; repaying needs the
547
+ * // wallet's own threshold.
548
+ * await sdk.treasury.setPolicy(treasuryId, { sensitiveQuorum: 3 });
549
+ * ```
550
+ */
551
+ setPolicy(treasuryId: string, options?: SetTreasuryPolicyOptions): Promise<TreasuryPolicy>;
434
552
  /**
435
553
  * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
436
554
  * returned object directly into chipi-react's `useProposeAction` /
@@ -828,6 +946,81 @@ declare const signTypedDataArray: ({ params, }: {
828
946
  params: SignTypedDataParams;
829
947
  }) => Promise<string[]>;
830
948
 
949
+ /**
950
+ * Wait for a Starknet transaction and report what happened, without throwing
951
+ * on an on-chain revert.
952
+ *
953
+ * Every gasless write in this SDK returns a transaction hash and nothing else,
954
+ * so integrators were each writing the same receipt-polling loop to answer two
955
+ * questions: did it actually succeed, and what events did it emit. Getting that
956
+ * loop wrong is expensive in a money flow. A revert that reads as success
957
+ * double-credits a ledger; a timeout treated as failure strands a confirmed
958
+ * transfer.
959
+ *
960
+ * The contract here is deliberately narrow: a REVERTED transaction is a
961
+ * RESULT, not an exception, because a revert is a normal outcome your code
962
+ * must branch on. Exceptions are reserved for "we do not know yet": a timeout
963
+ * or a transport failure, where retrying is the correct response and treating
964
+ * it as failure would be wrong.
965
+ */
966
+ /** One raw event from the receipt. Decode against your own ABI. */
967
+ interface ContractEventLog {
968
+ /** Emitting contract address. Filter on this before matching keys. */
969
+ from_address: string;
970
+ /** Indexed fields. `keys[0]` is the selector of the event name. */
971
+ keys: string[];
972
+ /** Non-indexed fields, in declaration order. */
973
+ data: string[];
974
+ }
975
+ interface WaitForTransactionResult {
976
+ transactionHash: string;
977
+ /** True only for an accepted, non-reverted transaction. */
978
+ success: boolean;
979
+ /** Raw `execution_status` from the node, when it reported one. */
980
+ executionStatus?: string;
981
+ /** Raw `finality_status` from the node, when it reported one. */
982
+ finalityStatus?: string;
983
+ /** Present when `success` is false and the node gave a reason. */
984
+ revertReason?: string;
985
+ /** Empty on a revert: reverted transactions emit no events. */
986
+ events: ContractEventLog[];
987
+ blockNumber?: number;
988
+ }
989
+ interface WaitForTransactionOptions {
990
+ /**
991
+ * Preferred endpoint. It is the caller's slot in the ordered RPC chain, not
992
+ * the only endpoint tried: reading a receipt is idempotent, so a transport
993
+ * failure falls through to the next endpoint rather than aborting the wait.
994
+ * Defaults to the endpoint the SDK already uses for CHIPI wallets.
995
+ */
996
+ nodeUrl?: string;
997
+ /** Poll interval. Default 3000ms, roughly Starknet's block cadence. */
998
+ retryIntervalMs?: number;
999
+ /** Total budget before giving up. Default 300000ms (5 minutes). */
1000
+ timeoutMs?: number;
1001
+ }
1002
+ /**
1003
+ * Poll until `transactionHash` reaches a terminal state.
1004
+ *
1005
+ * @throws if the timeout elapses before the node sequences the transaction.
1006
+ * It does NOT throw when the transaction reverted: check `success`.
1007
+ *
1008
+ * @example
1009
+ * ```typescript
1010
+ * const txHash = await sdk.callAnyContract({ params, bearerToken });
1011
+ * const receipt = await sdk.waitForTransaction(txHash);
1012
+ *
1013
+ * if (!receipt.success) {
1014
+ * throw new Error(receipt.revertReason ?? "reverted on chain");
1015
+ * }
1016
+ *
1017
+ * const created = receipt.events.find(
1018
+ * (e) => e.from_address === FACTORY && e.keys[0] === POOL_CREATED_SELECTOR
1019
+ * );
1020
+ * ```
1021
+ */
1022
+ declare function waitForTransaction(transactionHash: string, options?: WaitForTransactionOptions): Promise<WaitForTransactionResult>;
1023
+
831
1024
  declare const encryptPrivateKey: (privateKey: string, password: string) => string;
832
1025
  declare const decryptPrivateKey: (encryptedPrivateKey: string, password: string) => string;
833
1026
 
@@ -2572,4 +2765,4 @@ declare class ShhhAccount {
2572
2765
  */
2573
2766
  declare function submitViaAccount(funded: Account): ShhhSubmit;
2574
2767
 
2575
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, type MultisigAllowance, type NewOwnerInput, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, type OutsideExecution, type OwnerRole, type ProposeBody, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, ShhhAccount, type ShhhAccountOptions, type ShhhExecuteOptions, type ShhhSignedExecution, type ShhhSubmit, type ShhhX402Wallet, TIMELOCK_SECONDS, type TreasuryProposal, type TreasuryProposalSignature, type TreasuryTransport, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519OwnerPubkeyParam, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191OwnerPubkeyParam, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, signTypedDataArray, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, submitViaAccount, webauthnOwnerId, webauthnOwnerPubkeyParam, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
2768
+ export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, type ApproveBody, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiTreasury, ChipiWallets, type ComputeAddressInput, type ContractEventLog, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, type ExecuteResult, type ForTreasuryConfig, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, type ListTreasuriesOptions, type ListTreasuriesResult, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, type MultisigAllowance, type NewOwnerInput, OE_DOMAIN_NAME, OE_DOMAIN_REVISION, OE_DOMAIN_VERSION, OP_ADD_OWNER, OP_REMOVE_OWNER, OP_ROTATE_OWNER, OP_SET_THRESHOLD, type OutsideExecution, type OwnerRole, type ProposeBody, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, type SetTreasuryPolicyOptions, ShhhAccount, type ShhhAccountOptions, type ShhhExecuteOptions, type ShhhSignedExecution, type ShhhSubmit, type ShhhX402Wallet, TIMELOCK_SECONDS, type TreasuryPolicy, type TreasuryProposal, type TreasuryProposalSignature, type TreasurySummary, type TreasuryTransport, VIEW_SELECTORS, type WaitForTransactionOptions, type WaitForTransactionResult, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, buildEd25519EnvelopeFromSignature, buildEip191EnvelopeFromPrivateKey, buildEip191EnvelopeFromSignature, buildExecuteAddOwnerCall, buildExecuteRemoveOwnerCall, buildExecuteRotateOwnerCall, buildExecuteSetThresholdCall, buildFinalizeRecoveryCall, buildInitiateRecoveryCall, buildJwtAppleSubEnvelopeFromTestKey, buildJwtAppleSubEnvelopeFromTokenResponse, buildMigrationCalls, buildOutsideExecution, buildProposeAddOwnerCall, buildProposeRemoveOwnerCall, buildProposeRotateOwnerCall, buildProposeSetThresholdCall, buildStarkEnvelope, buildThresholdEnvelope, buildWebAuthnEnvelopeFromAssertion, buildWebAuthnEnvelopeFromPrivateKey, byteArrayToFelts, computeAddressSalt, computeBootstrapMessage, computeISignerId, computeOeHash, computeShhhAddress, computeSnip12Hash, decryptPrivateKey, ed25519OwnerId, ed25519OwnerPubkeyParam, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, eip191OwnerPubkeyParam, eip191PubkeyFelts, encryptPrivateKey, estimateThresholdGasOverhead, executeShhhSponsoredRaw, hashCall, hashCalls, hashOutsideExecutionStruct, hashStarknetDomain, isReadyToExecute, jwtAppleSubHash, jwtAppleSubOwnerId, jwtAppleSubPubkeyFelts, labelToFelt, locateSubClaim, messageHashToNonceB64url, ownerCommitment, parseAppleIdToken, parseDerEcdsaSignature, parseEip191Signature, parseThresholdEnvelope, resolveShhhChainId, secondsUntilExecutable, serializeExecuteFromOutsideV2Calldata, signBootstrapMessage, signTypedData, signTypedDataArray, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, submitViaAccount, waitForTransaction, webauthnOwnerId, webauthnOwnerPubkeyParam, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };