@chipi-stack/backend 14.6.0 → 14.8.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/index.d.mts CHANGED
@@ -281,6 +281,143 @@ declare class ChipiExchanges {
281
281
  getUsdAmount(currencyAmount: number, currency: Currency, bearerToken: string): Promise<number>;
282
282
  }
283
283
 
284
+ /**
285
+ * SHHH multisig treasury coordination client (Plus Wave 9 / P1).
286
+ *
287
+ * A thin, typed HTTP client for the chipi-back `/v1/treasuries/:id/...`
288
+ * endpoints. It implements the same transport contract `@chipi-stack/chipi-react`
289
+ * injects into `useProposeAction` / `useTreasuryProposals` (`MultisigTransport`),
290
+ * so an integrator can wire `sdk.treasury.forTreasury(...)` straight into those
291
+ * hooks instead of hand-writing fetch glue.
292
+ *
293
+ * Auth model (decision §11.2 — owner-signature-as-authorization):
294
+ * - propose / sign: `pk_` (the public api key) PLUS the owner's V2_SNIP12
295
+ * envelope (already inside the proposal body) AND the owner's STARK
296
+ * `ownerPubkey`. chipi-back's OwnerSignatureVerifier proves the request
297
+ * came from a current on-chain owner, so no secret is needed — these are
298
+ * safe to call from the browser.
299
+ * - execute / list / allowance: `sk_` (a secret key bearer). execute relays
300
+ * through the paymaster and meters; reads are org-private. Call these from
301
+ * a server (a Next.js route handler / your backend), never the browser.
302
+ *
303
+ * The types below mirror `@chipi-stack/chipi-react/multisig`'s `TreasuryProposal`
304
+ * / `ProposeBody` field-for-field (post-#324: OE `executeAfter` is derived from
305
+ * `executeBefore`, never sent or stored). They're duplicated (not imported) so
306
+ * the server SDK never depends on the React package; TypeScript's structural
307
+ * typing makes a `TreasuryTransport` assignable to the hook's `MultisigTransport`.
308
+ */
309
+ /** One owner's collected signature on a proposal. */
310
+ interface TreasuryProposalSignature {
311
+ ownerId: number;
312
+ signerKind: string;
313
+ /** The owner's serialized inner V2_SNIP12 envelope (comma-joined felts). */
314
+ signature: string;
315
+ }
316
+ /** A treasury proposal as returned by the coordination backend. */
317
+ interface TreasuryProposal {
318
+ id: string;
319
+ /** Set for generalized actions (vote / call any contract); null for payments. */
320
+ calls?: {
321
+ to: string;
322
+ entrypoint: string;
323
+ calldata: string[];
324
+ }[] | null;
325
+ /** Human label for an action ("Vote YES on Proposal #5"). */
326
+ title?: string | null;
327
+ /** Arbitrary integrator context. chipi-back has no column for it today, so
328
+ * it is absent on every proposal it returns (kept for contract parity). */
329
+ meta?: Record<string, string | number> | null;
330
+ oeMessageHash: string;
331
+ oeNonce: string | null;
332
+ /** chipi-back persists only `oeExecuteBefore`; the OE `executeAfter` is
333
+ * re-derived as `executeBefore - 2h` by executors (see chipi-react #324). */
334
+ oeExecuteBefore: string | null;
335
+ requiredApprovals: number;
336
+ status: "PROPOSED" | "APPROVED" | "EXECUTED" | "CANCELED" | "EXPIRED";
337
+ executedTxHash?: string | null;
338
+ signatures: TreasuryProposalSignature[];
339
+ }
340
+ /** The body the coordination backend's `propose` endpoint accepts. */
341
+ interface ProposeBody {
342
+ proposerOwnerId: number;
343
+ recipient: string;
344
+ tokenAddress: string;
345
+ amount: string;
346
+ title: string;
347
+ calls: {
348
+ to: string;
349
+ entrypoint: string;
350
+ calldata: string[];
351
+ }[];
352
+ /** Arbitrary integrator context. NOTE: not persisted by chipi-back today
353
+ * (no column) — the global ValidationPipe strips it. Kept for parity. */
354
+ meta?: Record<string, string | number>;
355
+ oeMessageHash: string;
356
+ oeNonce: string;
357
+ oeExecuteBefore: string;
358
+ requiredApprovals: number;
359
+ proposerSignature: string;
360
+ proposerSignerKind: string;
361
+ }
362
+ /** The approver's body for `sign` (mirrors chipi-react's call site). */
363
+ interface ApproveBody {
364
+ ownerId: number;
365
+ signature: string;
366
+ signerKind: string;
367
+ }
368
+ /** Result of relaying an execute through the paymaster. */
369
+ interface ExecuteResult {
370
+ executedTxHash?: string;
371
+ transactionHash?: string;
372
+ }
373
+ /** Free-execute meter for the org (shape owned by chipi-back's treasury svc). */
374
+ interface MultisigAllowance {
375
+ freeExecutesRemaining?: number;
376
+ priceUsd?: number;
377
+ creditsUsd?: number;
378
+ canExecuteNow?: boolean;
379
+ [key: string]: unknown;
380
+ }
381
+ /**
382
+ * A transport bound to one treasury + the local owner's STARK pubkey.
383
+ * Structurally compatible with `@chipi-stack/chipi-react`'s `MultisigTransport`.
384
+ */
385
+ interface TreasuryTransport {
386
+ list(): Promise<{
387
+ items: TreasuryProposal[];
388
+ }>;
389
+ propose(body: ProposeBody): Promise<TreasuryProposal>;
390
+ sign(proposalId: string, body: ApproveBody): Promise<unknown>;
391
+ execute(proposalId: string, calldata: string[]): Promise<ExecuteResult>;
392
+ /** Read the org's free-execute meter (sk_). Not part of MultisigTransport. */
393
+ getMultisigAllowance(): Promise<MultisigAllowance>;
394
+ }
395
+ interface ForTreasuryConfig {
396
+ /** The org treasury id (the multisig wallet's row id in chipi-back). */
397
+ treasuryId: string;
398
+ /** The local owner's STARK public key (one 0x-hex felt). Sent with propose /
399
+ * sign so the backend can verify the envelope commits to a current owner. */
400
+ ownerPubkey: string;
401
+ /** A secret key (`sk_`) for execute / list / allowance. Falls back to the
402
+ * SDK's configured `apiSecretKey`. Required only for those three; propose /
403
+ * sign authenticate with `pk_` + the owner signature. */
404
+ bearerToken?: string;
405
+ }
406
+ declare class ChipiTreasury {
407
+ private client;
408
+ private apiSecretKey?;
409
+ constructor(client: ChipiClient, apiSecretKey?: string | undefined);
410
+ private base;
411
+ /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
412
+ private secret;
413
+ /**
414
+ * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
415
+ * returned object directly into chipi-react's `useProposeAction` /
416
+ * `useTreasuryProposals` `transport` prop, or call its methods yourself.
417
+ */
418
+ forTreasury(config: ForTreasuryConfig): TreasuryTransport;
419
+ }
420
+
284
421
  /**
285
422
  * PaymasterAdapter implementation that uses Chipi's backend API for gasless transactions.
286
423
  *
@@ -382,6 +519,7 @@ declare class ChipiSDK {
382
519
  readonly skus: ChipiSkus;
383
520
  readonly sessions: ChipiSessions;
384
521
  readonly exchanges: ChipiExchanges;
522
+ readonly treasury: ChipiTreasury;
385
523
  constructor(config: ChipiSDKConfig);
386
524
  /**
387
525
  * Resolve bearer token - uses provided token or falls back to apiSecretKey
@@ -481,7 +619,7 @@ declare class ChipiSDK {
481
619
  * });
482
620
  * ```
483
621
  */
484
- signTypedData({ params, }: {
622
+ signTypedData({ params }: {
485
623
  params: SignTypedDataParams;
486
624
  }): Promise<SignTypedDataResult>;
487
625
  /**
@@ -1142,6 +1280,51 @@ declare function buildEd25519Envelope(params: {
1142
1280
  */
1143
1281
  ownerIndex?: bigint;
1144
1282
  }): Promise<bigint[]>;
1283
+ /**
1284
+ * Build a V2_SNIP12 Ed25519 envelope from an **externally-produced**
1285
+ * signature — the Phantom / Solana flow. Phantom (and every external
1286
+ * Ed25519 wallet) never exposes the private key: the user signs via
1287
+ * `window.solana.signMessage(...)`, which returns a 64-byte signature
1288
+ * (R‖s). This is the from-signature counterpart of
1289
+ * `buildEd25519Envelope`, mirroring `buildEip191EnvelopeFromSignature`
1290
+ * for MetaMask.
1291
+ *
1292
+ * IMPORTANT — what the wallet MUST sign:
1293
+ * The wallet must sign the EXACT bytes returned by
1294
+ * `ed25519SignedBytes(messageHash)` — the 64-byte hex-ASCII encoding
1295
+ * of the SNIP-12 OE hash — NOT the raw 32-byte `messageHash`. The
1296
+ * Cairo verifier reconstructs those same bytes from `messageHash`, so
1297
+ * a mismatch fails on chain. The dashboard adapter does:
1298
+ * await window.solana.connect();
1299
+ * // Phantom returns the 32-byte Ed25519 pubkey as a Solana PublicKey;
1300
+ * // `.toBytes()` is the Uint8Array this API expects.
1301
+ * const publicKey = window.solana.publicKey.toBytes();
1302
+ * const msg = ed25519SignedBytes(messageHash);
1303
+ * // Phantom's signMessage returns { signature: Uint8Array (64B), publicKey }.
1304
+ * const { signature } = await window.solana.signMessage(msg);
1305
+ * const env = await buildEd25519EnvelopeFromSignature({
1306
+ * signature, publicKey, messageHash,
1307
+ * });
1308
+ *
1309
+ * Async (unlike the synchronous EIP-191 from-signature path): the
1310
+ * Garaga WASM hint builder must be initialized to produce the EC hints
1311
+ * the Cairo Ed25519 verifier needs. The issue sketch (#311) showed a
1312
+ * sync return; Ed25519 cannot avoid the WASM init that secp256k1 does.
1313
+ */
1314
+ declare function buildEd25519EnvelopeFromSignature(params: {
1315
+ /** 64-byte Ed25519 signature R(32)‖s(32) from the wallet's signMessage. */
1316
+ signature: Uint8Array;
1317
+ /** 32-byte Ed25519 public key (as Phantom returns it). */
1318
+ publicKey: Uint8Array;
1319
+ /** SNIP-12 hash of the OutsideExecution — see oe.ts::computeOeHash. */
1320
+ messageHash: bigint;
1321
+ /**
1322
+ * Owner index in the wallet's owner_set. **Defaults to 0n (primary).**
1323
+ * MUST fit in u32. Same semantics + footgun as `buildEd25519Envelope`:
1324
+ * pass the INDEX, never an `ed25519OwnerId` commitment.
1325
+ */
1326
+ ownerIndex?: bigint;
1327
+ }): Promise<bigint[]>;
1145
1328
 
1146
1329
  /**
1147
1330
  * EIP-191 secp256k1 signer for SHHH V8.4 ShhhAccount.
@@ -2203,4 +2386,4 @@ declare function executeShhhSponsoredRaw(params: {
2203
2386
  chainId?: bigint | string;
2204
2387
  }): Promise<string>;
2205
2388
 
2206
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, 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, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, type ShhhX402Wallet, TIMELOCK_SECONDS, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, 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, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, 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, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
2389
+ 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, 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, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, 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, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
package/dist/index.d.ts CHANGED
@@ -281,6 +281,143 @@ declare class ChipiExchanges {
281
281
  getUsdAmount(currencyAmount: number, currency: Currency, bearerToken: string): Promise<number>;
282
282
  }
283
283
 
284
+ /**
285
+ * SHHH multisig treasury coordination client (Plus Wave 9 / P1).
286
+ *
287
+ * A thin, typed HTTP client for the chipi-back `/v1/treasuries/:id/...`
288
+ * endpoints. It implements the same transport contract `@chipi-stack/chipi-react`
289
+ * injects into `useProposeAction` / `useTreasuryProposals` (`MultisigTransport`),
290
+ * so an integrator can wire `sdk.treasury.forTreasury(...)` straight into those
291
+ * hooks instead of hand-writing fetch glue.
292
+ *
293
+ * Auth model (decision §11.2 — owner-signature-as-authorization):
294
+ * - propose / sign: `pk_` (the public api key) PLUS the owner's V2_SNIP12
295
+ * envelope (already inside the proposal body) AND the owner's STARK
296
+ * `ownerPubkey`. chipi-back's OwnerSignatureVerifier proves the request
297
+ * came from a current on-chain owner, so no secret is needed — these are
298
+ * safe to call from the browser.
299
+ * - execute / list / allowance: `sk_` (a secret key bearer). execute relays
300
+ * through the paymaster and meters; reads are org-private. Call these from
301
+ * a server (a Next.js route handler / your backend), never the browser.
302
+ *
303
+ * The types below mirror `@chipi-stack/chipi-react/multisig`'s `TreasuryProposal`
304
+ * / `ProposeBody` field-for-field (post-#324: OE `executeAfter` is derived from
305
+ * `executeBefore`, never sent or stored). They're duplicated (not imported) so
306
+ * the server SDK never depends on the React package; TypeScript's structural
307
+ * typing makes a `TreasuryTransport` assignable to the hook's `MultisigTransport`.
308
+ */
309
+ /** One owner's collected signature on a proposal. */
310
+ interface TreasuryProposalSignature {
311
+ ownerId: number;
312
+ signerKind: string;
313
+ /** The owner's serialized inner V2_SNIP12 envelope (comma-joined felts). */
314
+ signature: string;
315
+ }
316
+ /** A treasury proposal as returned by the coordination backend. */
317
+ interface TreasuryProposal {
318
+ id: string;
319
+ /** Set for generalized actions (vote / call any contract); null for payments. */
320
+ calls?: {
321
+ to: string;
322
+ entrypoint: string;
323
+ calldata: string[];
324
+ }[] | null;
325
+ /** Human label for an action ("Vote YES on Proposal #5"). */
326
+ title?: string | null;
327
+ /** Arbitrary integrator context. chipi-back has no column for it today, so
328
+ * it is absent on every proposal it returns (kept for contract parity). */
329
+ meta?: Record<string, string | number> | null;
330
+ oeMessageHash: string;
331
+ oeNonce: string | null;
332
+ /** chipi-back persists only `oeExecuteBefore`; the OE `executeAfter` is
333
+ * re-derived as `executeBefore - 2h` by executors (see chipi-react #324). */
334
+ oeExecuteBefore: string | null;
335
+ requiredApprovals: number;
336
+ status: "PROPOSED" | "APPROVED" | "EXECUTED" | "CANCELED" | "EXPIRED";
337
+ executedTxHash?: string | null;
338
+ signatures: TreasuryProposalSignature[];
339
+ }
340
+ /** The body the coordination backend's `propose` endpoint accepts. */
341
+ interface ProposeBody {
342
+ proposerOwnerId: number;
343
+ recipient: string;
344
+ tokenAddress: string;
345
+ amount: string;
346
+ title: string;
347
+ calls: {
348
+ to: string;
349
+ entrypoint: string;
350
+ calldata: string[];
351
+ }[];
352
+ /** Arbitrary integrator context. NOTE: not persisted by chipi-back today
353
+ * (no column) — the global ValidationPipe strips it. Kept for parity. */
354
+ meta?: Record<string, string | number>;
355
+ oeMessageHash: string;
356
+ oeNonce: string;
357
+ oeExecuteBefore: string;
358
+ requiredApprovals: number;
359
+ proposerSignature: string;
360
+ proposerSignerKind: string;
361
+ }
362
+ /** The approver's body for `sign` (mirrors chipi-react's call site). */
363
+ interface ApproveBody {
364
+ ownerId: number;
365
+ signature: string;
366
+ signerKind: string;
367
+ }
368
+ /** Result of relaying an execute through the paymaster. */
369
+ interface ExecuteResult {
370
+ executedTxHash?: string;
371
+ transactionHash?: string;
372
+ }
373
+ /** Free-execute meter for the org (shape owned by chipi-back's treasury svc). */
374
+ interface MultisigAllowance {
375
+ freeExecutesRemaining?: number;
376
+ priceUsd?: number;
377
+ creditsUsd?: number;
378
+ canExecuteNow?: boolean;
379
+ [key: string]: unknown;
380
+ }
381
+ /**
382
+ * A transport bound to one treasury + the local owner's STARK pubkey.
383
+ * Structurally compatible with `@chipi-stack/chipi-react`'s `MultisigTransport`.
384
+ */
385
+ interface TreasuryTransport {
386
+ list(): Promise<{
387
+ items: TreasuryProposal[];
388
+ }>;
389
+ propose(body: ProposeBody): Promise<TreasuryProposal>;
390
+ sign(proposalId: string, body: ApproveBody): Promise<unknown>;
391
+ execute(proposalId: string, calldata: string[]): Promise<ExecuteResult>;
392
+ /** Read the org's free-execute meter (sk_). Not part of MultisigTransport. */
393
+ getMultisigAllowance(): Promise<MultisigAllowance>;
394
+ }
395
+ interface ForTreasuryConfig {
396
+ /** The org treasury id (the multisig wallet's row id in chipi-back). */
397
+ treasuryId: string;
398
+ /** The local owner's STARK public key (one 0x-hex felt). Sent with propose /
399
+ * sign so the backend can verify the envelope commits to a current owner. */
400
+ ownerPubkey: string;
401
+ /** A secret key (`sk_`) for execute / list / allowance. Falls back to the
402
+ * SDK's configured `apiSecretKey`. Required only for those three; propose /
403
+ * sign authenticate with `pk_` + the owner signature. */
404
+ bearerToken?: string;
405
+ }
406
+ declare class ChipiTreasury {
407
+ private client;
408
+ private apiSecretKey?;
409
+ constructor(client: ChipiClient, apiSecretKey?: string | undefined);
410
+ private base;
411
+ /** Resolve a `sk_` for the secret-gated reads/execute, or fail loudly. */
412
+ private secret;
413
+ /**
414
+ * Build a {@link TreasuryTransport} for one treasury + owner. Wire the
415
+ * returned object directly into chipi-react's `useProposeAction` /
416
+ * `useTreasuryProposals` `transport` prop, or call its methods yourself.
417
+ */
418
+ forTreasury(config: ForTreasuryConfig): TreasuryTransport;
419
+ }
420
+
284
421
  /**
285
422
  * PaymasterAdapter implementation that uses Chipi's backend API for gasless transactions.
286
423
  *
@@ -382,6 +519,7 @@ declare class ChipiSDK {
382
519
  readonly skus: ChipiSkus;
383
520
  readonly sessions: ChipiSessions;
384
521
  readonly exchanges: ChipiExchanges;
522
+ readonly treasury: ChipiTreasury;
385
523
  constructor(config: ChipiSDKConfig);
386
524
  /**
387
525
  * Resolve bearer token - uses provided token or falls back to apiSecretKey
@@ -481,7 +619,7 @@ declare class ChipiSDK {
481
619
  * });
482
620
  * ```
483
621
  */
484
- signTypedData({ params, }: {
622
+ signTypedData({ params }: {
485
623
  params: SignTypedDataParams;
486
624
  }): Promise<SignTypedDataResult>;
487
625
  /**
@@ -1142,6 +1280,51 @@ declare function buildEd25519Envelope(params: {
1142
1280
  */
1143
1281
  ownerIndex?: bigint;
1144
1282
  }): Promise<bigint[]>;
1283
+ /**
1284
+ * Build a V2_SNIP12 Ed25519 envelope from an **externally-produced**
1285
+ * signature — the Phantom / Solana flow. Phantom (and every external
1286
+ * Ed25519 wallet) never exposes the private key: the user signs via
1287
+ * `window.solana.signMessage(...)`, which returns a 64-byte signature
1288
+ * (R‖s). This is the from-signature counterpart of
1289
+ * `buildEd25519Envelope`, mirroring `buildEip191EnvelopeFromSignature`
1290
+ * for MetaMask.
1291
+ *
1292
+ * IMPORTANT — what the wallet MUST sign:
1293
+ * The wallet must sign the EXACT bytes returned by
1294
+ * `ed25519SignedBytes(messageHash)` — the 64-byte hex-ASCII encoding
1295
+ * of the SNIP-12 OE hash — NOT the raw 32-byte `messageHash`. The
1296
+ * Cairo verifier reconstructs those same bytes from `messageHash`, so
1297
+ * a mismatch fails on chain. The dashboard adapter does:
1298
+ * await window.solana.connect();
1299
+ * // Phantom returns the 32-byte Ed25519 pubkey as a Solana PublicKey;
1300
+ * // `.toBytes()` is the Uint8Array this API expects.
1301
+ * const publicKey = window.solana.publicKey.toBytes();
1302
+ * const msg = ed25519SignedBytes(messageHash);
1303
+ * // Phantom's signMessage returns { signature: Uint8Array (64B), publicKey }.
1304
+ * const { signature } = await window.solana.signMessage(msg);
1305
+ * const env = await buildEd25519EnvelopeFromSignature({
1306
+ * signature, publicKey, messageHash,
1307
+ * });
1308
+ *
1309
+ * Async (unlike the synchronous EIP-191 from-signature path): the
1310
+ * Garaga WASM hint builder must be initialized to produce the EC hints
1311
+ * the Cairo Ed25519 verifier needs. The issue sketch (#311) showed a
1312
+ * sync return; Ed25519 cannot avoid the WASM init that secp256k1 does.
1313
+ */
1314
+ declare function buildEd25519EnvelopeFromSignature(params: {
1315
+ /** 64-byte Ed25519 signature R(32)‖s(32) from the wallet's signMessage. */
1316
+ signature: Uint8Array;
1317
+ /** 32-byte Ed25519 public key (as Phantom returns it). */
1318
+ publicKey: Uint8Array;
1319
+ /** SNIP-12 hash of the OutsideExecution — see oe.ts::computeOeHash. */
1320
+ messageHash: bigint;
1321
+ /**
1322
+ * Owner index in the wallet's owner_set. **Defaults to 0n (primary).**
1323
+ * MUST fit in u32. Same semantics + footgun as `buildEd25519Envelope`:
1324
+ * pass the INDEX, never an `ed25519OwnerId` commitment.
1325
+ */
1326
+ ownerIndex?: bigint;
1327
+ }): Promise<bigint[]>;
1145
1328
 
1146
1329
  /**
1147
1330
  * EIP-191 secp256k1 signer for SHHH V8.4 ShhhAccount.
@@ -2203,4 +2386,4 @@ declare function executeShhhSponsoredRaw(params: {
2203
2386
  chainId?: bigint | string;
2204
2387
  }): Promise<string>;
2205
2388
 
2206
- export { ANY_CALLER_FELT, APPLE_ISSUER, type AppleTokenResponse, BOOTSTRAP_DOMAIN_SEPARATOR, type BootstrapMessageParams, type BuildBootstrapSignedCallParams, type BuildMigrationCallsParams, ChipiBrowserSDK, ChipiClient, ChipiPaymasterAdapter, ChipiSDK, ChipiServerSDK, ChipiSessions, ChipiSkuPurchases, ChipiSkus, ChipiTransactions, ChipiWallets, type ComputeAddressInput, DEFAULT_OP_EXPIRY_SECONDS, type Eip191Pubkey, ISIGNER_CANONICAL_LABEL, ISIGNER_ID, ISRC9_V2_ID, type JwtAppleSubPubkey, MAX_OE_VALIDITY_WINDOW_SECONDS, MIN_THRESHOLD_OWNERS, 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, ROLE_GUARDIAN, ROLE_OWNER, SIG_VERSION_V1_HEX_ASCII, SIG_VERSION_V2_SNIP12, SIG_VERSION_V2_THRESHOLD, STARKNET_MESSAGE_PREFIX, type ShhhX402Wallet, TIMELOCK_SECONDS, VIEW_SELECTORS, type WebAuthnPubkey, X402Facilitator, type X402FacilitatorCreateOptions, type X402MiddlewareConfig, type X402MiddlewareFlatConfig, X402ShhhClient, type X402ShhhClientConfig, assertValidV2Snip12Envelope, buildBootstrapSignedCall, buildCancelPendingOpCall, buildCancelRecoveryCall, buildEd25519Envelope, 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, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, 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, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };
2389
+ 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, 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, ed25519PubkeyFelts, ed25519SignedBytes, eip191OwnerId, 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, snip12HashToHexAsciiBytes, starkOwnerId, starkPubkeyFelts, webauthnOwnerId, webauthnPubkeyFelts, wrapV2Snip12Envelope, wrapV2ThresholdEnvelope, x402Middleware };