@chipi-stack/types 13.14.0 → 14.1.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/LICENSE +21 -0
- package/README.md +18 -1
- package/dist/index.d.mts +258 -8
- package/dist/index.d.ts +258 -8
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Chipi Pay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
# @chipi-stack/types
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript type definitions shared across all @chipi-stack packages.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @chipi-stack/types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Key Exports
|
|
12
|
+
|
|
13
|
+
- **Wallet**: WalletType, WalletData, CreateWalletParams, GetWalletResponse, DeploymentData
|
|
14
|
+
- **Transaction**: Transaction, TxStatus, TxType, TransferParams, PrepareTypedDataParams
|
|
15
|
+
- **SKU**: Sku, SkuCategory, GetSkuListQuery
|
|
16
|
+
- **Core**: Chain, ChainToken, Currency, ChipiSDKConfig, PaginatedResponse
|
|
17
|
+
|
|
18
|
+
## License
|
|
19
|
+
|
|
20
|
+
MIT
|
package/dist/index.d.mts
CHANGED
|
@@ -71,8 +71,9 @@ declare const STARKNET_CONTRACTS: Record<ChainToken, {
|
|
|
71
71
|
* Supported wallet types
|
|
72
72
|
* - CHIPI: OpenZeppelin account with SNIP-9 session keys support (default)
|
|
73
73
|
* - READY: Argent X Account v0.4.0
|
|
74
|
+
* - Custom string values accepted for extensibility (e.g., community account implementations)
|
|
74
75
|
*/
|
|
75
|
-
type WalletType = "CHIPI" | "READY";
|
|
76
|
+
type WalletType = "CHIPI" | "READY" | (string & {});
|
|
76
77
|
interface WalletData {
|
|
77
78
|
publicKey: string;
|
|
78
79
|
encryptedPrivateKey: string;
|
|
@@ -93,9 +94,15 @@ interface CreateWalletParams {
|
|
|
93
94
|
/**
|
|
94
95
|
* The type of wallet to create.
|
|
95
96
|
* - "CHIPI" (default): OpenZeppelin account with SNIP-9 session keys support
|
|
96
|
-
* - "
|
|
97
|
+
* - "READY": Argent X Account v0.4.0
|
|
97
98
|
*/
|
|
98
99
|
walletType?: WalletType;
|
|
100
|
+
/**
|
|
101
|
+
* Optional custom class hash for wallet deployment.
|
|
102
|
+
* When provided, overrides the default class hash for the wallet type.
|
|
103
|
+
* Use this for custom account implementations (e.g., community-submitted accounts).
|
|
104
|
+
*/
|
|
105
|
+
classHash?: string;
|
|
99
106
|
usePasskey?: boolean;
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
@@ -170,6 +177,54 @@ interface PasskeyMetadata {
|
|
|
170
177
|
userId: string;
|
|
171
178
|
prfSupported: boolean;
|
|
172
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Parameters for preparing a wallet upgrade (e.g., READY → CHIPI or CHIPI v29 → v33).
|
|
182
|
+
* Server-only: requires API secret key.
|
|
183
|
+
*/
|
|
184
|
+
interface PrepareWalletUpgradeParams {
|
|
185
|
+
/** Wallet address to upgrade */
|
|
186
|
+
walletAddress: string;
|
|
187
|
+
/** Target class hash to upgrade to (defaults to latest CHIPI if omitted) */
|
|
188
|
+
targetClassHash?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Response from prepare-upgrade containing typed data for signing.
|
|
192
|
+
*/
|
|
193
|
+
interface PrepareWalletUpgradeResponse {
|
|
194
|
+
/** SNIP-12 typed data to sign for the upgrade */
|
|
195
|
+
typedData: TypedData;
|
|
196
|
+
/** Current class hash of the wallet */
|
|
197
|
+
currentClassHash: string;
|
|
198
|
+
/** Target class hash for upgrade */
|
|
199
|
+
targetClassHash: string;
|
|
200
|
+
/** Current wallet type */
|
|
201
|
+
currentWalletType: WalletType;
|
|
202
|
+
/** Target wallet type after upgrade */
|
|
203
|
+
targetWalletType: WalletType;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Parameters for executing a wallet upgrade after signing.
|
|
207
|
+
* Server-only: requires API secret key.
|
|
208
|
+
*/
|
|
209
|
+
interface ExecuteWalletUpgradeParams {
|
|
210
|
+
/** Wallet address being upgraded */
|
|
211
|
+
walletAddress: string;
|
|
212
|
+
/** SNIP-12 typed data (from prepare step) */
|
|
213
|
+
typedData: TypedData;
|
|
214
|
+
/** User signature over the typed data */
|
|
215
|
+
signature: string[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Response from wallet upgrade execution.
|
|
219
|
+
*/
|
|
220
|
+
interface ExecuteWalletUpgradeResponse {
|
|
221
|
+
/** Transaction hash for the upgrade */
|
|
222
|
+
transactionHash: string;
|
|
223
|
+
/** New class hash after upgrade */
|
|
224
|
+
newClassHash: string;
|
|
225
|
+
/** New wallet type after upgrade */
|
|
226
|
+
newWalletType: WalletType;
|
|
227
|
+
}
|
|
173
228
|
|
|
174
229
|
/**
|
|
175
230
|
* Transaction-related types
|
|
@@ -190,7 +245,6 @@ type ExecuteTransactionParams = PasskeyParams & {
|
|
|
190
245
|
};
|
|
191
246
|
type TxType = string;
|
|
192
247
|
type TxStatus = "PENDING" | "PROCESSING" | "SUCCESS" | "FAILED" | "CANCELLED";
|
|
193
|
-
type SkuStatus = "PENDING" | "PROCESSING" | "SUCCESS" | "FAILED" | "CANCELLED";
|
|
194
248
|
interface Transaction {
|
|
195
249
|
id: string;
|
|
196
250
|
type: TxType;
|
|
@@ -203,7 +257,7 @@ interface Transaction {
|
|
|
203
257
|
contractName?: string;
|
|
204
258
|
functionName?: string;
|
|
205
259
|
functionSelector?: string;
|
|
206
|
-
callData?:
|
|
260
|
+
callData?: unknown;
|
|
207
261
|
token?: ChainToken;
|
|
208
262
|
tokenAddress?: string;
|
|
209
263
|
amount?: string;
|
|
@@ -215,7 +269,6 @@ interface Transaction {
|
|
|
215
269
|
skuPurchaseAmount?: number;
|
|
216
270
|
skuPurchaseCurrency?: Currency;
|
|
217
271
|
skuFileNumber?: string;
|
|
218
|
-
skuStatus?: SkuStatus;
|
|
219
272
|
status: TxStatus;
|
|
220
273
|
createdAt: Date;
|
|
221
274
|
confirmedAt?: Date;
|
|
@@ -307,6 +360,88 @@ interface GetTransactionListQuery {
|
|
|
307
360
|
month?: number;
|
|
308
361
|
year?: number;
|
|
309
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Parameters for fetching a single transaction by hash or internal ID.
|
|
365
|
+
*/
|
|
366
|
+
interface GetTransactionParams {
|
|
367
|
+
/** Transaction hash (0x...) or internal database ID */
|
|
368
|
+
hashOrId: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Parameters for fetching on-chain transaction status.
|
|
372
|
+
*/
|
|
373
|
+
interface GetTransactionStatusParams {
|
|
374
|
+
/** Transaction hash (0x...) */
|
|
375
|
+
hash: string;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* On-chain transaction status from StarkNet sequencer.
|
|
379
|
+
*/
|
|
380
|
+
declare enum OnChainTxStatus {
|
|
381
|
+
RECEIVED = "RECEIVED",
|
|
382
|
+
PENDING = "PENDING",
|
|
383
|
+
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2",
|
|
384
|
+
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1",
|
|
385
|
+
REJECTED = "REJECTED",
|
|
386
|
+
REVERTED = "REVERTED",
|
|
387
|
+
NOT_RECEIVED = "NOT_RECEIVED"
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Response from the transaction status endpoint.
|
|
391
|
+
*/
|
|
392
|
+
interface TransactionStatusResponse {
|
|
393
|
+
/** Transaction hash */
|
|
394
|
+
transactionHash: string;
|
|
395
|
+
/** Current on-chain status */
|
|
396
|
+
status: OnChainTxStatus;
|
|
397
|
+
/** Block number (if included in a block) */
|
|
398
|
+
blockNumber?: number;
|
|
399
|
+
/** Revert reason (if status is REVERTED) */
|
|
400
|
+
revertReason?: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Minimal account interface for PaymasterAdapter.
|
|
404
|
+
* Compatible with starknet.js Account, external wallet objects, and Cartridge Controller.
|
|
405
|
+
*/
|
|
406
|
+
interface PaymasterAccount {
|
|
407
|
+
address: string;
|
|
408
|
+
signMessage(typedData: TypedData): Promise<unknown>;
|
|
409
|
+
getClassHashAt(contractAddress: string): Promise<string>;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Adapter for executing gasless (paymaster-sponsored) transactions.
|
|
413
|
+
*
|
|
414
|
+
* Handles the full flow: prepare typed data -> sign -> submit to paymaster.
|
|
415
|
+
* For external wallets (Argent X, Braavos), `account.signMessage()` triggers the wallet popup.
|
|
416
|
+
* For DirectSigner, signing happens programmatically.
|
|
417
|
+
*/
|
|
418
|
+
interface PaymasterAdapter {
|
|
419
|
+
execute(params: {
|
|
420
|
+
account: PaymasterAccount;
|
|
421
|
+
calls: Call[];
|
|
422
|
+
}): Promise<string>;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Parameters for signing SNIP-12 typed data without executing a transaction.
|
|
426
|
+
* Useful for x402 payment signatures and other off-chain signing flows.
|
|
427
|
+
*/
|
|
428
|
+
interface SignTypedDataParams {
|
|
429
|
+
/** Encryption key (PIN) to decrypt the private key */
|
|
430
|
+
encryptKey: string;
|
|
431
|
+
/** Wallet data containing encrypted private key */
|
|
432
|
+
wallet: WalletData;
|
|
433
|
+
/** SNIP-12 typed data to sign */
|
|
434
|
+
typedData: TypedData;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Result of signing SNIP-12 typed data.
|
|
438
|
+
*/
|
|
439
|
+
interface SignTypedDataResult {
|
|
440
|
+
/** Signature r component */
|
|
441
|
+
r: string;
|
|
442
|
+
/** Signature s component */
|
|
443
|
+
s: string;
|
|
444
|
+
}
|
|
310
445
|
|
|
311
446
|
/**
|
|
312
447
|
* SKU Purchase types
|
|
@@ -360,7 +495,7 @@ interface WithdrawVesuUsdcHookInputParams {
|
|
|
360
495
|
usePasskey?: boolean;
|
|
361
496
|
}
|
|
362
497
|
|
|
363
|
-
type SkuCategory =
|
|
498
|
+
type SkuCategory = "TELEPEAJE" | "TELEFONIA" | "GENERAL" | "TESORERIA" | "LUZ" | "INTERNET" | "TV" | "MOVILIDAD" | "RECARGAS" | "GIFT_CARDS" | "GAMING" | "VENTAS_CATALOGO" | "DEPORTES" | "STREAMING";
|
|
364
499
|
interface Sku {
|
|
365
500
|
id: string;
|
|
366
501
|
providerId: string;
|
|
@@ -372,6 +507,7 @@ interface Sku {
|
|
|
372
507
|
amountRegexValidation: string;
|
|
373
508
|
amountLabel: string;
|
|
374
509
|
fixedAmount?: number;
|
|
510
|
+
currency: Currency;
|
|
375
511
|
canCheckSkuReference: boolean;
|
|
376
512
|
logoUrl?: string;
|
|
377
513
|
createdAt: Date;
|
|
@@ -389,7 +525,7 @@ interface ApiKey {
|
|
|
389
525
|
id: string;
|
|
390
526
|
publicKey: string;
|
|
391
527
|
secretKey: string;
|
|
392
|
-
environment:
|
|
528
|
+
environment: "development" | "production";
|
|
393
529
|
isActive: boolean;
|
|
394
530
|
orgId: string;
|
|
395
531
|
createdAt: Date;
|
|
@@ -621,4 +757,118 @@ interface SessionWalletData extends WalletData {
|
|
|
621
757
|
walletType: WalletType;
|
|
622
758
|
}
|
|
623
759
|
|
|
624
|
-
|
|
760
|
+
/**
|
|
761
|
+
* x402 Payment Protocol types for HTTP 402 pay-per-request APIs.
|
|
762
|
+
*
|
|
763
|
+
* Implements the x402 open payment protocol (https://www.x402.org/) for Starknet,
|
|
764
|
+
* using SNIP-12 typed data signing and paymaster-sponsored USDC transfers.
|
|
765
|
+
*/
|
|
766
|
+
/** Payment requirement returned in 402 response PAYMENT-REQUIRED header */
|
|
767
|
+
interface PaymentRequirement {
|
|
768
|
+
/** Payment scheme — x402-starknet uses "exact" */
|
|
769
|
+
scheme: "exact";
|
|
770
|
+
/** Network identifier */
|
|
771
|
+
network: "starknet-mainnet";
|
|
772
|
+
/** Amount in token base units (e.g. "10000" = 0.01 USDC) */
|
|
773
|
+
maxAmountRequired: string;
|
|
774
|
+
/** URL of the resource being paid for */
|
|
775
|
+
resource: string;
|
|
776
|
+
/** Human-readable description of the payment */
|
|
777
|
+
description?: string;
|
|
778
|
+
/** MIME type of the resource */
|
|
779
|
+
mimeType?: string;
|
|
780
|
+
/** Recipient address (merchant) */
|
|
781
|
+
payTo: string;
|
|
782
|
+
/** Max seconds before payment expires */
|
|
783
|
+
maxTimeoutSeconds: number;
|
|
784
|
+
/** Token contract address (USDC) */
|
|
785
|
+
asset: string;
|
|
786
|
+
/** Additional protocol-specific data */
|
|
787
|
+
extra?: Record<string, unknown>;
|
|
788
|
+
}
|
|
789
|
+
/** Signed payment payload sent in X-PAYMENT header */
|
|
790
|
+
interface PaymentPayload {
|
|
791
|
+
x402Version: 1;
|
|
792
|
+
scheme: "exact";
|
|
793
|
+
network: "starknet-mainnet";
|
|
794
|
+
payload: {
|
|
795
|
+
signature: {
|
|
796
|
+
r: string;
|
|
797
|
+
s: string;
|
|
798
|
+
};
|
|
799
|
+
fromAddress: string;
|
|
800
|
+
toAddress: string;
|
|
801
|
+
amount: string;
|
|
802
|
+
asset: string;
|
|
803
|
+
validUntil: number;
|
|
804
|
+
nonce: string;
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
/** Facilitator verify response */
|
|
808
|
+
interface VerifyResponse {
|
|
809
|
+
isValid: boolean;
|
|
810
|
+
invalidReason?: string;
|
|
811
|
+
}
|
|
812
|
+
/** Facilitator settle response */
|
|
813
|
+
interface SettleResponse {
|
|
814
|
+
success: boolean;
|
|
815
|
+
transactionHash?: string;
|
|
816
|
+
errorReason?: string;
|
|
817
|
+
networkId?: string;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Pluggable nonce store for facilitator replay protection.
|
|
821
|
+
* Default: in-memory Set (resets on restart).
|
|
822
|
+
* For production: plug in Redis, PostgreSQL, DynamoDB, etc.
|
|
823
|
+
*/
|
|
824
|
+
interface NonceStore {
|
|
825
|
+
/** Check if nonce has been used (non-consuming read). */
|
|
826
|
+
has(nonce: string): Promise<boolean> | boolean;
|
|
827
|
+
/**
|
|
828
|
+
* Atomically consume a nonce. Returns true if successfully consumed (was new).
|
|
829
|
+
* Returns false if nonce was already used.
|
|
830
|
+
* Must be atomic to prevent concurrent replay attacks.
|
|
831
|
+
* Maps to Redis SETNX, PostgreSQL INSERT ON CONFLICT DO NOTHING, etc.
|
|
832
|
+
*/
|
|
833
|
+
consume(nonce: string): Promise<boolean> | boolean;
|
|
834
|
+
}
|
|
835
|
+
/** x402 client configuration */
|
|
836
|
+
interface X402ClientConfig {
|
|
837
|
+
/** Max amount willing to pay per request (in human-readable units, e.g. "1.00" = 1 USDC) */
|
|
838
|
+
maxPaymentAmount?: string;
|
|
839
|
+
/** Allowed recipient addresses (whitelist). Empty = allow all. */
|
|
840
|
+
allowedRecipients?: string[];
|
|
841
|
+
/** Custom header name (default: "X-PAYMENT") */
|
|
842
|
+
headerName?: string;
|
|
843
|
+
}
|
|
844
|
+
/** x402 facilitator configuration */
|
|
845
|
+
interface X402FacilitatorConfig {
|
|
846
|
+
/** Custom nonce store for persistent replay protection. Defaults to in-memory. */
|
|
847
|
+
nonceStore?: NonceStore;
|
|
848
|
+
/**
|
|
849
|
+
* RPC provider for on-chain SNIP-12 signature verification.
|
|
850
|
+
* When provided, the facilitator calls `is_valid_signature()` on the sender's
|
|
851
|
+
* account contract to cryptographically verify the payment signature.
|
|
852
|
+
* When omitted, falls back to presence-only signature check (backwards compatible).
|
|
853
|
+
*
|
|
854
|
+
* Accepts any object with a `callContract` method (e.g. starknet.js RpcProvider).
|
|
855
|
+
*/
|
|
856
|
+
provider?: {
|
|
857
|
+
callContract(call: {
|
|
858
|
+
contractAddress: string;
|
|
859
|
+
entrypoint: string;
|
|
860
|
+
calldata?: string[];
|
|
861
|
+
}): Promise<string[]>;
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
/** x402 middleware payment config for a protected endpoint */
|
|
865
|
+
interface X402PaymentConfig {
|
|
866
|
+
/** Amount in human-readable units (e.g. "0.01" for 0.01 USDC) */
|
|
867
|
+
amount: string;
|
|
868
|
+
/** Merchant receiving address */
|
|
869
|
+
payTo: string;
|
|
870
|
+
/** Human-readable description */
|
|
871
|
+
description?: string;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export { type AddSessionKeyParams, type ApiError, type ApiKey, type ApiResponse, type ApproveHookInput, type ApproveParams, type AsyncReturnType, type AuthContext, type CallAnyContractParams, Chain, ChainToken, type ChipiBrowserSDKConfig, type ChipiSDKConfig, type ChipiServerSDKConfig, type Country, type CreateCustodialWalletParams, type CreateSessionKeyParams, type CreateSkuPurchaseBody, type CreateSkuPurchaseParams, type CreateUserParams, type CreateWalletParams, type CreateWalletResponse, Currency, type DeepPartial, type DeploymentData, type ErrorWithCode, type ExecuteSponsoredTransactionParams, type ExecuteSponsoredTransactionResponse, type ExecuteTransactionParams, type ExecuteWalletUpgradeParams, type ExecuteWalletUpgradeResponse, type ExecuteWithSessionParams, type GetMerchantWalletParams, type GetSessionDataParams, type GetSkuListQuery, type GetTokenBalanceParams, type GetTokenBalanceResponse, type GetTransactionListQuery, type GetTransactionParams, type GetTransactionStatusParams, type GetTransactionsParams, type GetUserParams, type GetWalletParams, type GetWalletResponse, type JwtPayload, type MaybePromise, type MigrateWalletToPasskeyParams, type NonEmptyArray, type NonceStore, OnChainTxStatus, type Optional, type PaginatedResponse, type PaginationQuery, type PasskeyMetadata, type PaymasterAccount, type PaymasterAdapter, type PaymentPayload, type PaymentRequirement, type PrepareTypedDataParams, type PrepareTypedDataResponse, type PrepareWalletCreationParams, type PrepareWalletCreationResponse, type PrepareWalletUpgradeParams, type PrepareWalletUpgradeResponse, type Prettify, type RecordSendTransactionParams, type RequireAtLeastOne, type RevokeSessionKeyParams, STARKNET_CONTRACTS, type SessionConfig, type SessionDataResponse, type SessionKeyData, type SessionWalletData, type SettleResponse, type SignTypedDataParams, type SignTypedDataResult, type Sku, type SkuCategory, type StakeVesuUsdcHookInputParams, type StakeVesuUsdcParams, type Transaction, type TransactionStatusResponse, type TransferHookInput, type TransferParams, type TxStatus, type TxType, type UpdateWalletEncryptionParams, type UpdateWalletEncryptionResponse, type User, type ValueOrFunction, type VerifyResponse, type WalletData, type WalletType, type WithdrawVesuUsdcHookInputParams, type WithdrawVesuUsdcParams, type X402ClientConfig, type X402FacilitatorConfig, type X402PaymentConfig, type alphaUrl };
|
package/dist/index.d.ts
CHANGED
|
@@ -71,8 +71,9 @@ declare const STARKNET_CONTRACTS: Record<ChainToken, {
|
|
|
71
71
|
* Supported wallet types
|
|
72
72
|
* - CHIPI: OpenZeppelin account with SNIP-9 session keys support (default)
|
|
73
73
|
* - READY: Argent X Account v0.4.0
|
|
74
|
+
* - Custom string values accepted for extensibility (e.g., community account implementations)
|
|
74
75
|
*/
|
|
75
|
-
type WalletType = "CHIPI" | "READY";
|
|
76
|
+
type WalletType = "CHIPI" | "READY" | (string & {});
|
|
76
77
|
interface WalletData {
|
|
77
78
|
publicKey: string;
|
|
78
79
|
encryptedPrivateKey: string;
|
|
@@ -93,9 +94,15 @@ interface CreateWalletParams {
|
|
|
93
94
|
/**
|
|
94
95
|
* The type of wallet to create.
|
|
95
96
|
* - "CHIPI" (default): OpenZeppelin account with SNIP-9 session keys support
|
|
96
|
-
* - "
|
|
97
|
+
* - "READY": Argent X Account v0.4.0
|
|
97
98
|
*/
|
|
98
99
|
walletType?: WalletType;
|
|
100
|
+
/**
|
|
101
|
+
* Optional custom class hash for wallet deployment.
|
|
102
|
+
* When provided, overrides the default class hash for the wallet type.
|
|
103
|
+
* Use this for custom account implementations (e.g., community-submitted accounts).
|
|
104
|
+
*/
|
|
105
|
+
classHash?: string;
|
|
99
106
|
usePasskey?: boolean;
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
@@ -170,6 +177,54 @@ interface PasskeyMetadata {
|
|
|
170
177
|
userId: string;
|
|
171
178
|
prfSupported: boolean;
|
|
172
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Parameters for preparing a wallet upgrade (e.g., READY → CHIPI or CHIPI v29 → v33).
|
|
182
|
+
* Server-only: requires API secret key.
|
|
183
|
+
*/
|
|
184
|
+
interface PrepareWalletUpgradeParams {
|
|
185
|
+
/** Wallet address to upgrade */
|
|
186
|
+
walletAddress: string;
|
|
187
|
+
/** Target class hash to upgrade to (defaults to latest CHIPI if omitted) */
|
|
188
|
+
targetClassHash?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Response from prepare-upgrade containing typed data for signing.
|
|
192
|
+
*/
|
|
193
|
+
interface PrepareWalletUpgradeResponse {
|
|
194
|
+
/** SNIP-12 typed data to sign for the upgrade */
|
|
195
|
+
typedData: TypedData;
|
|
196
|
+
/** Current class hash of the wallet */
|
|
197
|
+
currentClassHash: string;
|
|
198
|
+
/** Target class hash for upgrade */
|
|
199
|
+
targetClassHash: string;
|
|
200
|
+
/** Current wallet type */
|
|
201
|
+
currentWalletType: WalletType;
|
|
202
|
+
/** Target wallet type after upgrade */
|
|
203
|
+
targetWalletType: WalletType;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Parameters for executing a wallet upgrade after signing.
|
|
207
|
+
* Server-only: requires API secret key.
|
|
208
|
+
*/
|
|
209
|
+
interface ExecuteWalletUpgradeParams {
|
|
210
|
+
/** Wallet address being upgraded */
|
|
211
|
+
walletAddress: string;
|
|
212
|
+
/** SNIP-12 typed data (from prepare step) */
|
|
213
|
+
typedData: TypedData;
|
|
214
|
+
/** User signature over the typed data */
|
|
215
|
+
signature: string[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Response from wallet upgrade execution.
|
|
219
|
+
*/
|
|
220
|
+
interface ExecuteWalletUpgradeResponse {
|
|
221
|
+
/** Transaction hash for the upgrade */
|
|
222
|
+
transactionHash: string;
|
|
223
|
+
/** New class hash after upgrade */
|
|
224
|
+
newClassHash: string;
|
|
225
|
+
/** New wallet type after upgrade */
|
|
226
|
+
newWalletType: WalletType;
|
|
227
|
+
}
|
|
173
228
|
|
|
174
229
|
/**
|
|
175
230
|
* Transaction-related types
|
|
@@ -190,7 +245,6 @@ type ExecuteTransactionParams = PasskeyParams & {
|
|
|
190
245
|
};
|
|
191
246
|
type TxType = string;
|
|
192
247
|
type TxStatus = "PENDING" | "PROCESSING" | "SUCCESS" | "FAILED" | "CANCELLED";
|
|
193
|
-
type SkuStatus = "PENDING" | "PROCESSING" | "SUCCESS" | "FAILED" | "CANCELLED";
|
|
194
248
|
interface Transaction {
|
|
195
249
|
id: string;
|
|
196
250
|
type: TxType;
|
|
@@ -203,7 +257,7 @@ interface Transaction {
|
|
|
203
257
|
contractName?: string;
|
|
204
258
|
functionName?: string;
|
|
205
259
|
functionSelector?: string;
|
|
206
|
-
callData?:
|
|
260
|
+
callData?: unknown;
|
|
207
261
|
token?: ChainToken;
|
|
208
262
|
tokenAddress?: string;
|
|
209
263
|
amount?: string;
|
|
@@ -215,7 +269,6 @@ interface Transaction {
|
|
|
215
269
|
skuPurchaseAmount?: number;
|
|
216
270
|
skuPurchaseCurrency?: Currency;
|
|
217
271
|
skuFileNumber?: string;
|
|
218
|
-
skuStatus?: SkuStatus;
|
|
219
272
|
status: TxStatus;
|
|
220
273
|
createdAt: Date;
|
|
221
274
|
confirmedAt?: Date;
|
|
@@ -307,6 +360,88 @@ interface GetTransactionListQuery {
|
|
|
307
360
|
month?: number;
|
|
308
361
|
year?: number;
|
|
309
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Parameters for fetching a single transaction by hash or internal ID.
|
|
365
|
+
*/
|
|
366
|
+
interface GetTransactionParams {
|
|
367
|
+
/** Transaction hash (0x...) or internal database ID */
|
|
368
|
+
hashOrId: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Parameters for fetching on-chain transaction status.
|
|
372
|
+
*/
|
|
373
|
+
interface GetTransactionStatusParams {
|
|
374
|
+
/** Transaction hash (0x...) */
|
|
375
|
+
hash: string;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* On-chain transaction status from StarkNet sequencer.
|
|
379
|
+
*/
|
|
380
|
+
declare enum OnChainTxStatus {
|
|
381
|
+
RECEIVED = "RECEIVED",
|
|
382
|
+
PENDING = "PENDING",
|
|
383
|
+
ACCEPTED_ON_L2 = "ACCEPTED_ON_L2",
|
|
384
|
+
ACCEPTED_ON_L1 = "ACCEPTED_ON_L1",
|
|
385
|
+
REJECTED = "REJECTED",
|
|
386
|
+
REVERTED = "REVERTED",
|
|
387
|
+
NOT_RECEIVED = "NOT_RECEIVED"
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Response from the transaction status endpoint.
|
|
391
|
+
*/
|
|
392
|
+
interface TransactionStatusResponse {
|
|
393
|
+
/** Transaction hash */
|
|
394
|
+
transactionHash: string;
|
|
395
|
+
/** Current on-chain status */
|
|
396
|
+
status: OnChainTxStatus;
|
|
397
|
+
/** Block number (if included in a block) */
|
|
398
|
+
blockNumber?: number;
|
|
399
|
+
/** Revert reason (if status is REVERTED) */
|
|
400
|
+
revertReason?: string;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Minimal account interface for PaymasterAdapter.
|
|
404
|
+
* Compatible with starknet.js Account, external wallet objects, and Cartridge Controller.
|
|
405
|
+
*/
|
|
406
|
+
interface PaymasterAccount {
|
|
407
|
+
address: string;
|
|
408
|
+
signMessage(typedData: TypedData): Promise<unknown>;
|
|
409
|
+
getClassHashAt(contractAddress: string): Promise<string>;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Adapter for executing gasless (paymaster-sponsored) transactions.
|
|
413
|
+
*
|
|
414
|
+
* Handles the full flow: prepare typed data -> sign -> submit to paymaster.
|
|
415
|
+
* For external wallets (Argent X, Braavos), `account.signMessage()` triggers the wallet popup.
|
|
416
|
+
* For DirectSigner, signing happens programmatically.
|
|
417
|
+
*/
|
|
418
|
+
interface PaymasterAdapter {
|
|
419
|
+
execute(params: {
|
|
420
|
+
account: PaymasterAccount;
|
|
421
|
+
calls: Call[];
|
|
422
|
+
}): Promise<string>;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Parameters for signing SNIP-12 typed data without executing a transaction.
|
|
426
|
+
* Useful for x402 payment signatures and other off-chain signing flows.
|
|
427
|
+
*/
|
|
428
|
+
interface SignTypedDataParams {
|
|
429
|
+
/** Encryption key (PIN) to decrypt the private key */
|
|
430
|
+
encryptKey: string;
|
|
431
|
+
/** Wallet data containing encrypted private key */
|
|
432
|
+
wallet: WalletData;
|
|
433
|
+
/** SNIP-12 typed data to sign */
|
|
434
|
+
typedData: TypedData;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Result of signing SNIP-12 typed data.
|
|
438
|
+
*/
|
|
439
|
+
interface SignTypedDataResult {
|
|
440
|
+
/** Signature r component */
|
|
441
|
+
r: string;
|
|
442
|
+
/** Signature s component */
|
|
443
|
+
s: string;
|
|
444
|
+
}
|
|
310
445
|
|
|
311
446
|
/**
|
|
312
447
|
* SKU Purchase types
|
|
@@ -360,7 +495,7 @@ interface WithdrawVesuUsdcHookInputParams {
|
|
|
360
495
|
usePasskey?: boolean;
|
|
361
496
|
}
|
|
362
497
|
|
|
363
|
-
type SkuCategory =
|
|
498
|
+
type SkuCategory = "TELEPEAJE" | "TELEFONIA" | "GENERAL" | "TESORERIA" | "LUZ" | "INTERNET" | "TV" | "MOVILIDAD" | "RECARGAS" | "GIFT_CARDS" | "GAMING" | "VENTAS_CATALOGO" | "DEPORTES" | "STREAMING";
|
|
364
499
|
interface Sku {
|
|
365
500
|
id: string;
|
|
366
501
|
providerId: string;
|
|
@@ -372,6 +507,7 @@ interface Sku {
|
|
|
372
507
|
amountRegexValidation: string;
|
|
373
508
|
amountLabel: string;
|
|
374
509
|
fixedAmount?: number;
|
|
510
|
+
currency: Currency;
|
|
375
511
|
canCheckSkuReference: boolean;
|
|
376
512
|
logoUrl?: string;
|
|
377
513
|
createdAt: Date;
|
|
@@ -389,7 +525,7 @@ interface ApiKey {
|
|
|
389
525
|
id: string;
|
|
390
526
|
publicKey: string;
|
|
391
527
|
secretKey: string;
|
|
392
|
-
environment:
|
|
528
|
+
environment: "development" | "production";
|
|
393
529
|
isActive: boolean;
|
|
394
530
|
orgId: string;
|
|
395
531
|
createdAt: Date;
|
|
@@ -621,4 +757,118 @@ interface SessionWalletData extends WalletData {
|
|
|
621
757
|
walletType: WalletType;
|
|
622
758
|
}
|
|
623
759
|
|
|
624
|
-
|
|
760
|
+
/**
|
|
761
|
+
* x402 Payment Protocol types for HTTP 402 pay-per-request APIs.
|
|
762
|
+
*
|
|
763
|
+
* Implements the x402 open payment protocol (https://www.x402.org/) for Starknet,
|
|
764
|
+
* using SNIP-12 typed data signing and paymaster-sponsored USDC transfers.
|
|
765
|
+
*/
|
|
766
|
+
/** Payment requirement returned in 402 response PAYMENT-REQUIRED header */
|
|
767
|
+
interface PaymentRequirement {
|
|
768
|
+
/** Payment scheme — x402-starknet uses "exact" */
|
|
769
|
+
scheme: "exact";
|
|
770
|
+
/** Network identifier */
|
|
771
|
+
network: "starknet-mainnet";
|
|
772
|
+
/** Amount in token base units (e.g. "10000" = 0.01 USDC) */
|
|
773
|
+
maxAmountRequired: string;
|
|
774
|
+
/** URL of the resource being paid for */
|
|
775
|
+
resource: string;
|
|
776
|
+
/** Human-readable description of the payment */
|
|
777
|
+
description?: string;
|
|
778
|
+
/** MIME type of the resource */
|
|
779
|
+
mimeType?: string;
|
|
780
|
+
/** Recipient address (merchant) */
|
|
781
|
+
payTo: string;
|
|
782
|
+
/** Max seconds before payment expires */
|
|
783
|
+
maxTimeoutSeconds: number;
|
|
784
|
+
/** Token contract address (USDC) */
|
|
785
|
+
asset: string;
|
|
786
|
+
/** Additional protocol-specific data */
|
|
787
|
+
extra?: Record<string, unknown>;
|
|
788
|
+
}
|
|
789
|
+
/** Signed payment payload sent in X-PAYMENT header */
|
|
790
|
+
interface PaymentPayload {
|
|
791
|
+
x402Version: 1;
|
|
792
|
+
scheme: "exact";
|
|
793
|
+
network: "starknet-mainnet";
|
|
794
|
+
payload: {
|
|
795
|
+
signature: {
|
|
796
|
+
r: string;
|
|
797
|
+
s: string;
|
|
798
|
+
};
|
|
799
|
+
fromAddress: string;
|
|
800
|
+
toAddress: string;
|
|
801
|
+
amount: string;
|
|
802
|
+
asset: string;
|
|
803
|
+
validUntil: number;
|
|
804
|
+
nonce: string;
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
/** Facilitator verify response */
|
|
808
|
+
interface VerifyResponse {
|
|
809
|
+
isValid: boolean;
|
|
810
|
+
invalidReason?: string;
|
|
811
|
+
}
|
|
812
|
+
/** Facilitator settle response */
|
|
813
|
+
interface SettleResponse {
|
|
814
|
+
success: boolean;
|
|
815
|
+
transactionHash?: string;
|
|
816
|
+
errorReason?: string;
|
|
817
|
+
networkId?: string;
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* Pluggable nonce store for facilitator replay protection.
|
|
821
|
+
* Default: in-memory Set (resets on restart).
|
|
822
|
+
* For production: plug in Redis, PostgreSQL, DynamoDB, etc.
|
|
823
|
+
*/
|
|
824
|
+
interface NonceStore {
|
|
825
|
+
/** Check if nonce has been used (non-consuming read). */
|
|
826
|
+
has(nonce: string): Promise<boolean> | boolean;
|
|
827
|
+
/**
|
|
828
|
+
* Atomically consume a nonce. Returns true if successfully consumed (was new).
|
|
829
|
+
* Returns false if nonce was already used.
|
|
830
|
+
* Must be atomic to prevent concurrent replay attacks.
|
|
831
|
+
* Maps to Redis SETNX, PostgreSQL INSERT ON CONFLICT DO NOTHING, etc.
|
|
832
|
+
*/
|
|
833
|
+
consume(nonce: string): Promise<boolean> | boolean;
|
|
834
|
+
}
|
|
835
|
+
/** x402 client configuration */
|
|
836
|
+
interface X402ClientConfig {
|
|
837
|
+
/** Max amount willing to pay per request (in human-readable units, e.g. "1.00" = 1 USDC) */
|
|
838
|
+
maxPaymentAmount?: string;
|
|
839
|
+
/** Allowed recipient addresses (whitelist). Empty = allow all. */
|
|
840
|
+
allowedRecipients?: string[];
|
|
841
|
+
/** Custom header name (default: "X-PAYMENT") */
|
|
842
|
+
headerName?: string;
|
|
843
|
+
}
|
|
844
|
+
/** x402 facilitator configuration */
|
|
845
|
+
interface X402FacilitatorConfig {
|
|
846
|
+
/** Custom nonce store for persistent replay protection. Defaults to in-memory. */
|
|
847
|
+
nonceStore?: NonceStore;
|
|
848
|
+
/**
|
|
849
|
+
* RPC provider for on-chain SNIP-12 signature verification.
|
|
850
|
+
* When provided, the facilitator calls `is_valid_signature()` on the sender's
|
|
851
|
+
* account contract to cryptographically verify the payment signature.
|
|
852
|
+
* When omitted, falls back to presence-only signature check (backwards compatible).
|
|
853
|
+
*
|
|
854
|
+
* Accepts any object with a `callContract` method (e.g. starknet.js RpcProvider).
|
|
855
|
+
*/
|
|
856
|
+
provider?: {
|
|
857
|
+
callContract(call: {
|
|
858
|
+
contractAddress: string;
|
|
859
|
+
entrypoint: string;
|
|
860
|
+
calldata?: string[];
|
|
861
|
+
}): Promise<string[]>;
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
/** x402 middleware payment config for a protected endpoint */
|
|
865
|
+
interface X402PaymentConfig {
|
|
866
|
+
/** Amount in human-readable units (e.g. "0.01" for 0.01 USDC) */
|
|
867
|
+
amount: string;
|
|
868
|
+
/** Merchant receiving address */
|
|
869
|
+
payTo: string;
|
|
870
|
+
/** Human-readable description */
|
|
871
|
+
description?: string;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
export { type AddSessionKeyParams, type ApiError, type ApiKey, type ApiResponse, type ApproveHookInput, type ApproveParams, type AsyncReturnType, type AuthContext, type CallAnyContractParams, Chain, ChainToken, type ChipiBrowserSDKConfig, type ChipiSDKConfig, type ChipiServerSDKConfig, type Country, type CreateCustodialWalletParams, type CreateSessionKeyParams, type CreateSkuPurchaseBody, type CreateSkuPurchaseParams, type CreateUserParams, type CreateWalletParams, type CreateWalletResponse, Currency, type DeepPartial, type DeploymentData, type ErrorWithCode, type ExecuteSponsoredTransactionParams, type ExecuteSponsoredTransactionResponse, type ExecuteTransactionParams, type ExecuteWalletUpgradeParams, type ExecuteWalletUpgradeResponse, type ExecuteWithSessionParams, type GetMerchantWalletParams, type GetSessionDataParams, type GetSkuListQuery, type GetTokenBalanceParams, type GetTokenBalanceResponse, type GetTransactionListQuery, type GetTransactionParams, type GetTransactionStatusParams, type GetTransactionsParams, type GetUserParams, type GetWalletParams, type GetWalletResponse, type JwtPayload, type MaybePromise, type MigrateWalletToPasskeyParams, type NonEmptyArray, type NonceStore, OnChainTxStatus, type Optional, type PaginatedResponse, type PaginationQuery, type PasskeyMetadata, type PaymasterAccount, type PaymasterAdapter, type PaymentPayload, type PaymentRequirement, type PrepareTypedDataParams, type PrepareTypedDataResponse, type PrepareWalletCreationParams, type PrepareWalletCreationResponse, type PrepareWalletUpgradeParams, type PrepareWalletUpgradeResponse, type Prettify, type RecordSendTransactionParams, type RequireAtLeastOne, type RevokeSessionKeyParams, STARKNET_CONTRACTS, type SessionConfig, type SessionDataResponse, type SessionKeyData, type SessionWalletData, type SettleResponse, type SignTypedDataParams, type SignTypedDataResult, type Sku, type SkuCategory, type StakeVesuUsdcHookInputParams, type StakeVesuUsdcParams, type Transaction, type TransactionStatusResponse, type TransferHookInput, type TransferParams, type TxStatus, type TxType, type UpdateWalletEncryptionParams, type UpdateWalletEncryptionResponse, type User, type ValueOrFunction, type VerifyResponse, type WalletData, type WalletType, type WithdrawVesuUsdcHookInputParams, type WithdrawVesuUsdcParams, type X402ClientConfig, type X402FacilitatorConfig, type X402PaymentConfig, type alphaUrl };
|
package/dist/index.js
CHANGED
|
@@ -97,9 +97,22 @@ var STARKNET_CONTRACTS = {
|
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
// src/transaction.ts
|
|
101
|
+
var OnChainTxStatus = /* @__PURE__ */ ((OnChainTxStatus2) => {
|
|
102
|
+
OnChainTxStatus2["RECEIVED"] = "RECEIVED";
|
|
103
|
+
OnChainTxStatus2["PENDING"] = "PENDING";
|
|
104
|
+
OnChainTxStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
105
|
+
OnChainTxStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
106
|
+
OnChainTxStatus2["REJECTED"] = "REJECTED";
|
|
107
|
+
OnChainTxStatus2["REVERTED"] = "REVERTED";
|
|
108
|
+
OnChainTxStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
109
|
+
return OnChainTxStatus2;
|
|
110
|
+
})(OnChainTxStatus || {});
|
|
111
|
+
|
|
100
112
|
exports.Chain = Chain;
|
|
101
113
|
exports.ChainToken = ChainToken;
|
|
102
114
|
exports.Currency = Currency;
|
|
115
|
+
exports.OnChainTxStatus = OnChainTxStatus;
|
|
103
116
|
exports.STARKNET_CONTRACTS = STARKNET_CONTRACTS;
|
|
104
117
|
//# sourceMappingURL=index.js.map
|
|
105
118
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core.ts"],"names":["Chain","Currency","ChainToken"],"mappings":";;;AAsBO,IAAK,KAAA,qBAAAA,MAAAA,KAAL;AACL,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,OAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,OAAA,YAAA,CAAA,GAAa,YAAA;AAPH,EAAA,OAAAA,MAAAA;AAAA,CAAA,EAAA,KAAA,IAAA,EAAA;AAUL,IAAK,QAAA,qBAAAC,SAAAA,KAAL;AACL,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAFI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAKL,IAAK,UAAA,qBAAAC,WAAAA,KAAL;AACL,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAA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AAAA,IACjB,eAAA,EACE,oEAAA;AAAA,IACF,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,sBAAmB;AAAA,IAClB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,0BAAqB;AAAA,IACpB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,oBAAkB;AAAA,IACjB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,sBAAmB;AAAA,IAClB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA;AAEd","file":"index.js","sourcesContent":["/**\n * Core configuration and environment types\n */\n\nexport interface ChipiSDKConfig {\n apiPublicKey: string;\n alphaUrl?: string;\n nodeUrl?: string;\n apiSecretKey?: string;\n}\n\nexport interface ChipiServerSDKConfig extends ChipiSDKConfig {\n apiSecretKey: string;\n}\n\nexport interface ChipiBrowserSDKConfig\n extends Omit<ChipiSDKConfig, \"apiSecretKey\"> {\n apiSecretKey?: never;\n}\n\nexport type alphaUrl = string;\n\nexport enum Chain {\n STARKNET = \"STARKNET\",\n BASE = \"BASE\",\n ARBITRUM = \"ARBITRUM\",\n OPTIMISM = \"OPTIMISM\",\n ROOTSTOCK = \"ROOTSTOCK\",\n SCROLL = \"SCROLL\",\n WORLDCHAIN = \"WORLDCHAIN\",\n}\n\nexport enum Currency {\n MXN = \"MXN\",\n USD = \"USD\",\n}\n\nexport enum ChainToken {\n USDC = \"USDC\",\n USDC_E = \"USDC_E\",\n USDT = \"USDT\",\n DAI = \"DAI\",\n ETH = \"ETH\",\n STRK = \"STRK\",\n SLINK = \"SLINK\",\n ALF = \"ALF\",\n BROTHER = \"BROTHER\",\n ARB = \"ARB\",\n DOC = \"DOC\",\n MXNB = \"MXNB\",\n WLD = \"WLD\",\n WBTC = \"WBTC\",\n OTHER = \"OTHER\",\n}\n\nexport interface PaginationQuery {\n page?: number;\n limit?: number;\n offset?: number;\n}\n\nexport interface PaginatedResponse<T> {\n data: T[];\n total: number;\n page: number;\n limit: number;\n totalPages: number;\n}\n\nexport const STARKNET_CONTRACTS: Record<\n ChainToken,\n { contractAddress: string; decimals: number }\n> = {\n [ChainToken.USDC]: {\n contractAddress:\n \"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb\",\n decimals: 6,\n },\n [ChainToken.USDC_E]: {\n contractAddress:\n \"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8\",\n decimals: 6,\n },\n [ChainToken.USDT]: {\n contractAddress:\n \"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8\",\n decimals: 6,\n },\n [ChainToken.DAI]: {\n contractAddress:\n \"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad\",\n decimals: 18,\n },\n [ChainToken.STRK]: {\n contractAddress:\n \"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d\",\n decimals: 18,\n },\n [ChainToken.ETH]: {\n contractAddress:\n \"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7\",\n decimals: 18,\n },\n [ChainToken.WBTC]: {\n contractAddress:\n \"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac\",\n decimals: 8,\n },\n [ChainToken.SLINK]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ALF]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.BROTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ARB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.DOC]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.MXNB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.WLD]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.OTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core.ts","../src/transaction.ts"],"names":["Chain","Currency","ChainToken","OnChainTxStatus"],"mappings":";;;AAqBO,IAAK,KAAA,qBAAAA,MAAAA,KAAL;AACL,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,OAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,OAAA,YAAA,CAAA,GAAa,YAAA;AAPH,EAAA,OAAAA,MAAAA;AAAA,CAAA,EAAA,KAAA,IAAA,EAAA;AAUL,IAAK,QAAA,qBAAAC,SAAAA,KAAL;AACL,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAFI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAKL,IAAK,UAAA,qBAAAC,WAAAA,KAAL;AACL,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,QAAA,CAAA,GAAS,QA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index.js","sourcesContent":["/**\n * Core configuration and environment types\n */\n\nexport interface ChipiSDKConfig {\n apiPublicKey: string;\n alphaUrl?: string;\n nodeUrl?: string;\n apiSecretKey?: string;\n}\n\nexport interface ChipiServerSDKConfig extends ChipiSDKConfig {\n apiSecretKey: string;\n}\n\nexport interface ChipiBrowserSDKConfig extends Omit<ChipiSDKConfig, \"apiSecretKey\"> {\n apiSecretKey?: never;\n}\n\nexport type alphaUrl = string;\n\nexport enum Chain {\n STARKNET = \"STARKNET\",\n BASE = \"BASE\",\n ARBITRUM = \"ARBITRUM\",\n OPTIMISM = \"OPTIMISM\",\n ROOTSTOCK = \"ROOTSTOCK\",\n SCROLL = \"SCROLL\",\n WORLDCHAIN = \"WORLDCHAIN\",\n}\n\nexport enum Currency {\n MXN = \"MXN\",\n USD = \"USD\",\n}\n\nexport enum ChainToken {\n USDC = \"USDC\",\n USDC_E = \"USDC_E\",\n USDT = \"USDT\",\n DAI = \"DAI\",\n ETH = \"ETH\",\n STRK = \"STRK\",\n SLINK = \"SLINK\",\n ALF = \"ALF\",\n BROTHER = \"BROTHER\",\n ARB = \"ARB\",\n DOC = \"DOC\",\n MXNB = \"MXNB\",\n WLD = \"WLD\",\n WBTC = \"WBTC\",\n OTHER = \"OTHER\",\n}\n\nexport interface PaginationQuery {\n page?: number;\n limit?: number;\n offset?: number;\n}\n\nexport interface PaginatedResponse<T> {\n data: T[];\n total: number;\n page: number;\n limit: number;\n totalPages: number;\n}\n\nexport const STARKNET_CONTRACTS: Record<ChainToken, { contractAddress: string; decimals: number }> =\n {\n [ChainToken.USDC]: {\n contractAddress: \"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb\",\n decimals: 6,\n },\n [ChainToken.USDC_E]: {\n contractAddress: \"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8\",\n decimals: 6,\n },\n [ChainToken.USDT]: {\n contractAddress: \"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8\",\n decimals: 6,\n },\n [ChainToken.DAI]: {\n contractAddress: \"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad\",\n decimals: 18,\n },\n [ChainToken.STRK]: {\n contractAddress: \"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d\",\n decimals: 18,\n },\n [ChainToken.ETH]: {\n contractAddress: \"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7\",\n decimals: 18,\n },\n [ChainToken.WBTC]: {\n contractAddress: \"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac\",\n decimals: 8,\n },\n [ChainToken.SLINK]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ALF]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.BROTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ARB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.DOC]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.MXNB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.WLD]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.OTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n };\n","import type { Call, TypedData } from \"starknet\";\nimport type { WalletData, WalletType } from \"./wallet\";\nimport { Chain, ChainToken, Currency } from \"./core\";\n\n/**\n * Transaction-related types\n */\n\ntype PasskeyEnabledParams = {\n usePasskey: true;\n externalUserId: string;\n};\n\ntype PasskeyDisabledParams = {\n usePasskey?: false;\n externalUserId?: string;\n};\n\ntype PasskeyParams = PasskeyEnabledParams | PasskeyDisabledParams;\n\nexport type ExecuteTransactionParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n calls: Call[];\n};\n\nexport type TxType = string;\nexport type TxStatus = \"PENDING\" | \"PROCESSING\" | \"SUCCESS\" | \"FAILED\" | \"CANCELLED\";\n\nexport interface Transaction {\n id: string;\n type: TxType;\n subType?: string;\n chain: Chain;\n transactionHash: string;\n\n // Parties\n senderAddress: string;\n destinationAddress: string;\n\n // Contract Interaction\n contractAddress?: string;\n contractName?: string;\n functionName?: string;\n functionSelector?: string;\n callData?: unknown;\n\n // Token Transfer (nullable for non-token operations)\n token?: ChainToken;\n tokenAddress?: string;\n amount?: string;\n\n // NFT Specific\n nftTokenId?: string;\n nftContract?: string;\n nftMetadata?: Record<string, unknown>;\n\n // SKU Specific\n skuId?: string;\n skuReference?: string;\n skuPurchaseAmount?: number;\n skuPurchaseCurrency?: Currency;\n skuFileNumber?: string;\n\n // Status\n status: TxStatus;\n\n // Timestamps\n createdAt: Date;\n confirmedAt?: Date;\n updatedAt: Date;\n\n // Relations\n apiPublicKey: string;\n chipiWalletId?: string;\n destinationChipiWalletId?: string;\n}\n\nexport interface PrepareTypedDataParams {\n calls: Call[];\n walletAddress: string;\n}\n\nexport interface PrepareTypedDataResponse {\n typedData: TypedData;\n walletType: WalletType;\n}\n\nexport interface ExecuteSponsoredTransactionParams {\n calls: Call[];\n walletAddress: string;\n signature: string[];\n apiPublicKey: string;\n}\n\nexport interface ExecuteSponsoredTransactionResponse {\n transactionHash: string;\n}\n\nexport interface RecordSendTransactionParams {\n transactionHash: string;\n expectedSender: string;\n expectedRecipient: string;\n expectedToken: ChainToken;\n expectedAmount: string;\n chain: Chain;\n}\n\n// Specific transaction types\nexport type TransferParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n token: ChainToken;\n otherToken?: {\n contractAddress: string;\n decimals: number;\n };\n recipient: string;\n amount: string;\n};\n\nexport type TransferHookInput = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n token: ChainToken;\n otherToken?: {\n contractAddress: string;\n decimals: number;\n };\n recipient: string;\n amount: number;\n};\n\nexport type ApproveParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n contractAddress: string;\n spender: string;\n amount: string;\n decimals?: number;\n};\n\nexport type ApproveHookInput = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n contractAddress: string;\n spender: string;\n decimals?: number;\n amount: number;\n};\n\nexport type CallAnyContractParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n contractAddress: string;\n calls: Call[];\n};\n\nexport interface GetTransactionsParams {\n page?: number;\n limit?: number;\n orgId: string;\n}\n\nexport interface GetTransactionListQuery {\n page?: number;\n limit?: number;\n calledFunction?: string;\n walletAddress: string; // Required: wallet address to filter transactions\n day?: number; // Day of the month (1-31)\n month?: number; // Month of the year (1-12)\n year?: number; // Year (e.g., 2025)\n}\n\n/**\n * Parameters for fetching a single transaction by hash or internal ID.\n */\nexport interface GetTransactionParams {\n /** Transaction hash (0x...) or internal database ID */\n hashOrId: string;\n}\n\n/**\n * Parameters for fetching on-chain transaction status.\n */\nexport interface GetTransactionStatusParams {\n /** Transaction hash (0x...) */\n hash: string;\n}\n\n/**\n * On-chain transaction status from StarkNet sequencer.\n */\nexport enum OnChainTxStatus {\n RECEIVED = \"RECEIVED\",\n PENDING = \"PENDING\",\n ACCEPTED_ON_L2 = \"ACCEPTED_ON_L2\",\n ACCEPTED_ON_L1 = \"ACCEPTED_ON_L1\",\n REJECTED = \"REJECTED\",\n REVERTED = \"REVERTED\",\n NOT_RECEIVED = \"NOT_RECEIVED\",\n}\n\n/**\n * Response from the transaction status endpoint.\n */\nexport interface TransactionStatusResponse {\n /** Transaction hash */\n transactionHash: string;\n /** Current on-chain status */\n status: OnChainTxStatus;\n /** Block number (if included in a block) */\n blockNumber?: number;\n /** Revert reason (if status is REVERTED) */\n revertReason?: string;\n}\n\n/**\n * Minimal account interface for PaymasterAdapter.\n * Compatible with starknet.js Account, external wallet objects, and Cartridge Controller.\n */\nexport interface PaymasterAccount {\n address: string;\n signMessage(typedData: TypedData): Promise<unknown>;\n getClassHashAt(contractAddress: string): Promise<string>;\n}\n\n/**\n * Adapter for executing gasless (paymaster-sponsored) transactions.\n *\n * Handles the full flow: prepare typed data -> sign -> submit to paymaster.\n * For external wallets (Argent X, Braavos), `account.signMessage()` triggers the wallet popup.\n * For DirectSigner, signing happens programmatically.\n */\nexport interface PaymasterAdapter {\n execute(params: { account: PaymasterAccount; calls: Call[] }): Promise<string>;\n}\n\n/**\n * Parameters for signing SNIP-12 typed data without executing a transaction.\n * Useful for x402 payment signatures and other off-chain signing flows.\n */\nexport interface SignTypedDataParams {\n /** Encryption key (PIN) to decrypt the private key */\n encryptKey: string;\n /** Wallet data containing encrypted private key */\n wallet: WalletData;\n /** SNIP-12 typed data to sign */\n typedData: TypedData;\n}\n\n/**\n * Result of signing SNIP-12 typed data.\n */\nexport interface SignTypedDataResult {\n /** Signature r component */\n r: string;\n /** Signature s component */\n s: string;\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -95,6 +95,18 @@ var STARKNET_CONTRACTS = {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
|
|
98
|
+
// src/transaction.ts
|
|
99
|
+
var OnChainTxStatus = /* @__PURE__ */ ((OnChainTxStatus2) => {
|
|
100
|
+
OnChainTxStatus2["RECEIVED"] = "RECEIVED";
|
|
101
|
+
OnChainTxStatus2["PENDING"] = "PENDING";
|
|
102
|
+
OnChainTxStatus2["ACCEPTED_ON_L2"] = "ACCEPTED_ON_L2";
|
|
103
|
+
OnChainTxStatus2["ACCEPTED_ON_L1"] = "ACCEPTED_ON_L1";
|
|
104
|
+
OnChainTxStatus2["REJECTED"] = "REJECTED";
|
|
105
|
+
OnChainTxStatus2["REVERTED"] = "REVERTED";
|
|
106
|
+
OnChainTxStatus2["NOT_RECEIVED"] = "NOT_RECEIVED";
|
|
107
|
+
return OnChainTxStatus2;
|
|
108
|
+
})(OnChainTxStatus || {});
|
|
109
|
+
|
|
110
|
+
export { Chain, ChainToken, Currency, OnChainTxStatus, STARKNET_CONTRACTS };
|
|
99
111
|
//# sourceMappingURL=index.mjs.map
|
|
100
112
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core.ts"],"names":["Chain","Currency","ChainToken"],"mappings":";AAsBO,IAAK,KAAA,qBAAAA,MAAAA,KAAL;AACL,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,OAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,OAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,OAAA,YAAA,CAAA,GAAa,YAAA;AAPH,EAAA,OAAAA,MAAAA;AAAA,CAAA,EAAA,KAAA,IAAA,EAAA;AAUL,IAAK,QAAA,qBAAAC,SAAAA,KAAL;AACL,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,UAAA,KAAA,CAAA,GAAM,KAAA;AAFI,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAKL,IAAK,UAAA,qBAAAC,WAAAA,KAAL;AACL,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,YAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,YAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAA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A,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,oBAAkB;AAAA,IACjB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,sBAAmB;AAAA,IAClB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA;AAEd","file":"index.mjs","sourcesContent":["/**\n * Core configuration and environment types\n */\n\nexport interface ChipiSDKConfig {\n apiPublicKey: string;\n alphaUrl?: string;\n nodeUrl?: string;\n apiSecretKey?: string;\n}\n\nexport interface ChipiServerSDKConfig extends ChipiSDKConfig {\n apiSecretKey: string;\n}\n\nexport interface ChipiBrowserSDKConfig\n extends Omit<ChipiSDKConfig, \"apiSecretKey\"> {\n apiSecretKey?: never;\n}\n\nexport type alphaUrl = string;\n\nexport enum Chain {\n STARKNET = \"STARKNET\",\n BASE = \"BASE\",\n ARBITRUM = \"ARBITRUM\",\n OPTIMISM = \"OPTIMISM\",\n ROOTSTOCK = \"ROOTSTOCK\",\n SCROLL = \"SCROLL\",\n WORLDCHAIN = \"WORLDCHAIN\",\n}\n\nexport enum Currency {\n MXN = \"MXN\",\n USD = \"USD\",\n}\n\nexport enum ChainToken {\n USDC = \"USDC\",\n USDC_E = \"USDC_E\",\n USDT = \"USDT\",\n DAI = \"DAI\",\n ETH = \"ETH\",\n STRK = \"STRK\",\n SLINK = \"SLINK\",\n ALF = \"ALF\",\n BROTHER = \"BROTHER\",\n ARB = \"ARB\",\n DOC = \"DOC\",\n MXNB = \"MXNB\",\n WLD = \"WLD\",\n WBTC = \"WBTC\",\n OTHER = \"OTHER\",\n}\n\nexport interface PaginationQuery {\n page?: number;\n limit?: number;\n offset?: number;\n}\n\nexport interface PaginatedResponse<T> {\n data: T[];\n total: number;\n page: number;\n limit: number;\n totalPages: number;\n}\n\nexport const STARKNET_CONTRACTS: Record<\n ChainToken,\n { contractAddress: string; decimals: number }\n> = {\n [ChainToken.USDC]: {\n contractAddress:\n \"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb\",\n decimals: 6,\n },\n [ChainToken.USDC_E]: {\n contractAddress:\n \"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8\",\n decimals: 6,\n },\n [ChainToken.USDT]: {\n contractAddress:\n \"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8\",\n decimals: 6,\n },\n [ChainToken.DAI]: {\n contractAddress:\n \"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad\",\n decimals: 18,\n },\n [ChainToken.STRK]: {\n contractAddress:\n \"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d\",\n decimals: 18,\n },\n [ChainToken.ETH]: {\n contractAddress:\n \"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7\",\n decimals: 18,\n },\n [ChainToken.WBTC]: {\n contractAddress:\n \"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac\",\n decimals: 8,\n },\n [ChainToken.SLINK]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ALF]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.BROTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ARB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.DOC]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.MXNB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.WLD]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.OTHER]: {\n contractAddress: \"\",\n decim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AA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,oBAAkB;AAAA,IACjB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,kBAAiB;AAAA,IAChB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA,GACZ;AAAA,EACA,CAAC,sBAAmB;AAAA,IAClB,eAAA,EAAiB,EAAA;AAAA,IACjB,QAAA,EAAU;AAAA;AAEd;;;AC+DK,IAAK,eAAA,qBAAAC,gBAAAA,KAAL;AACL,EAAAA,iBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,iBAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,iBAAA,gBAAA,CAAA,GAAiB,gBAAA;AACjB,EAAAA,iBAAA,gBAAA,CAAA,GAAiB,gBAAA;AACjB,EAAAA,iBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,iBAAA,UAAA,CAAA,GAAW,UAAA;AACX,EAAAA,iBAAA,cAAA,CAAA,GAAe,cAAA;AAPL,EAAA,OAAAA,gBAAAA;AAAA,CAAA,EAAA,eAAA,IAAA,EAAA","file":"index.mjs","sourcesContent":["/**\n * Core configuration and environment types\n */\n\nexport interface ChipiSDKConfig {\n apiPublicKey: string;\n alphaUrl?: string;\n nodeUrl?: string;\n apiSecretKey?: string;\n}\n\nexport interface ChipiServerSDKConfig extends ChipiSDKConfig {\n apiSecretKey: string;\n}\n\nexport interface ChipiBrowserSDKConfig extends Omit<ChipiSDKConfig, \"apiSecretKey\"> {\n apiSecretKey?: never;\n}\n\nexport type alphaUrl = string;\n\nexport enum Chain {\n STARKNET = \"STARKNET\",\n BASE = \"BASE\",\n ARBITRUM = \"ARBITRUM\",\n OPTIMISM = \"OPTIMISM\",\n ROOTSTOCK = \"ROOTSTOCK\",\n SCROLL = \"SCROLL\",\n WORLDCHAIN = \"WORLDCHAIN\",\n}\n\nexport enum Currency {\n MXN = \"MXN\",\n USD = \"USD\",\n}\n\nexport enum ChainToken {\n USDC = \"USDC\",\n USDC_E = \"USDC_E\",\n USDT = \"USDT\",\n DAI = \"DAI\",\n ETH = \"ETH\",\n STRK = \"STRK\",\n SLINK = \"SLINK\",\n ALF = \"ALF\",\n BROTHER = \"BROTHER\",\n ARB = \"ARB\",\n DOC = \"DOC\",\n MXNB = \"MXNB\",\n WLD = \"WLD\",\n WBTC = \"WBTC\",\n OTHER = \"OTHER\",\n}\n\nexport interface PaginationQuery {\n page?: number;\n limit?: number;\n offset?: number;\n}\n\nexport interface PaginatedResponse<T> {\n data: T[];\n total: number;\n page: number;\n limit: number;\n totalPages: number;\n}\n\nexport const STARKNET_CONTRACTS: Record<ChainToken, { contractAddress: string; decimals: number }> =\n {\n [ChainToken.USDC]: {\n contractAddress: \"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb\",\n decimals: 6,\n },\n [ChainToken.USDC_E]: {\n contractAddress: \"0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8\",\n decimals: 6,\n },\n [ChainToken.USDT]: {\n contractAddress: \"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8\",\n decimals: 6,\n },\n [ChainToken.DAI]: {\n contractAddress: \"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad\",\n decimals: 18,\n },\n [ChainToken.STRK]: {\n contractAddress: \"0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d\",\n decimals: 18,\n },\n [ChainToken.ETH]: {\n contractAddress: \"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7\",\n decimals: 18,\n },\n [ChainToken.WBTC]: {\n contractAddress: \"0x03fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac\",\n decimals: 8,\n },\n [ChainToken.SLINK]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ALF]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.BROTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.ARB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.DOC]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.MXNB]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.WLD]: {\n contractAddress: \"\",\n decimals: 18,\n },\n [ChainToken.OTHER]: {\n contractAddress: \"\",\n decimals: 18,\n },\n };\n","import type { Call, TypedData } from \"starknet\";\nimport type { WalletData, WalletType } from \"./wallet\";\nimport { Chain, ChainToken, Currency } from \"./core\";\n\n/**\n * Transaction-related types\n */\n\ntype PasskeyEnabledParams = {\n usePasskey: true;\n externalUserId: string;\n};\n\ntype PasskeyDisabledParams = {\n usePasskey?: false;\n externalUserId?: string;\n};\n\ntype PasskeyParams = PasskeyEnabledParams | PasskeyDisabledParams;\n\nexport type ExecuteTransactionParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n calls: Call[];\n};\n\nexport type TxType = string;\nexport type TxStatus = \"PENDING\" | \"PROCESSING\" | \"SUCCESS\" | \"FAILED\" | \"CANCELLED\";\n\nexport interface Transaction {\n id: string;\n type: TxType;\n subType?: string;\n chain: Chain;\n transactionHash: string;\n\n // Parties\n senderAddress: string;\n destinationAddress: string;\n\n // Contract Interaction\n contractAddress?: string;\n contractName?: string;\n functionName?: string;\n functionSelector?: string;\n callData?: unknown;\n\n // Token Transfer (nullable for non-token operations)\n token?: ChainToken;\n tokenAddress?: string;\n amount?: string;\n\n // NFT Specific\n nftTokenId?: string;\n nftContract?: string;\n nftMetadata?: Record<string, unknown>;\n\n // SKU Specific\n skuId?: string;\n skuReference?: string;\n skuPurchaseAmount?: number;\n skuPurchaseCurrency?: Currency;\n skuFileNumber?: string;\n\n // Status\n status: TxStatus;\n\n // Timestamps\n createdAt: Date;\n confirmedAt?: Date;\n updatedAt: Date;\n\n // Relations\n apiPublicKey: string;\n chipiWalletId?: string;\n destinationChipiWalletId?: string;\n}\n\nexport interface PrepareTypedDataParams {\n calls: Call[];\n walletAddress: string;\n}\n\nexport interface PrepareTypedDataResponse {\n typedData: TypedData;\n walletType: WalletType;\n}\n\nexport interface ExecuteSponsoredTransactionParams {\n calls: Call[];\n walletAddress: string;\n signature: string[];\n apiPublicKey: string;\n}\n\nexport interface ExecuteSponsoredTransactionResponse {\n transactionHash: string;\n}\n\nexport interface RecordSendTransactionParams {\n transactionHash: string;\n expectedSender: string;\n expectedRecipient: string;\n expectedToken: ChainToken;\n expectedAmount: string;\n chain: Chain;\n}\n\n// Specific transaction types\nexport type TransferParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n token: ChainToken;\n otherToken?: {\n contractAddress: string;\n decimals: number;\n };\n recipient: string;\n amount: string;\n};\n\nexport type TransferHookInput = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n token: ChainToken;\n otherToken?: {\n contractAddress: string;\n decimals: number;\n };\n recipient: string;\n amount: number;\n};\n\nexport type ApproveParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n contractAddress: string;\n spender: string;\n amount: string;\n decimals?: number;\n};\n\nexport type ApproveHookInput = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n contractAddress: string;\n spender: string;\n decimals?: number;\n amount: number;\n};\n\nexport type CallAnyContractParams = PasskeyParams & {\n encryptKey?: string;\n wallet: WalletData;\n contractAddress: string;\n calls: Call[];\n};\n\nexport interface GetTransactionsParams {\n page?: number;\n limit?: number;\n orgId: string;\n}\n\nexport interface GetTransactionListQuery {\n page?: number;\n limit?: number;\n calledFunction?: string;\n walletAddress: string; // Required: wallet address to filter transactions\n day?: number; // Day of the month (1-31)\n month?: number; // Month of the year (1-12)\n year?: number; // Year (e.g., 2025)\n}\n\n/**\n * Parameters for fetching a single transaction by hash or internal ID.\n */\nexport interface GetTransactionParams {\n /** Transaction hash (0x...) or internal database ID */\n hashOrId: string;\n}\n\n/**\n * Parameters for fetching on-chain transaction status.\n */\nexport interface GetTransactionStatusParams {\n /** Transaction hash (0x...) */\n hash: string;\n}\n\n/**\n * On-chain transaction status from StarkNet sequencer.\n */\nexport enum OnChainTxStatus {\n RECEIVED = \"RECEIVED\",\n PENDING = \"PENDING\",\n ACCEPTED_ON_L2 = \"ACCEPTED_ON_L2\",\n ACCEPTED_ON_L1 = \"ACCEPTED_ON_L1\",\n REJECTED = \"REJECTED\",\n REVERTED = \"REVERTED\",\n NOT_RECEIVED = \"NOT_RECEIVED\",\n}\n\n/**\n * Response from the transaction status endpoint.\n */\nexport interface TransactionStatusResponse {\n /** Transaction hash */\n transactionHash: string;\n /** Current on-chain status */\n status: OnChainTxStatus;\n /** Block number (if included in a block) */\n blockNumber?: number;\n /** Revert reason (if status is REVERTED) */\n revertReason?: string;\n}\n\n/**\n * Minimal account interface for PaymasterAdapter.\n * Compatible with starknet.js Account, external wallet objects, and Cartridge Controller.\n */\nexport interface PaymasterAccount {\n address: string;\n signMessage(typedData: TypedData): Promise<unknown>;\n getClassHashAt(contractAddress: string): Promise<string>;\n}\n\n/**\n * Adapter for executing gasless (paymaster-sponsored) transactions.\n *\n * Handles the full flow: prepare typed data -> sign -> submit to paymaster.\n * For external wallets (Argent X, Braavos), `account.signMessage()` triggers the wallet popup.\n * For DirectSigner, signing happens programmatically.\n */\nexport interface PaymasterAdapter {\n execute(params: { account: PaymasterAccount; calls: Call[] }): Promise<string>;\n}\n\n/**\n * Parameters for signing SNIP-12 typed data without executing a transaction.\n * Useful for x402 payment signatures and other off-chain signing flows.\n */\nexport interface SignTypedDataParams {\n /** Encryption key (PIN) to decrypt the private key */\n encryptKey: string;\n /** Wallet data containing encrypted private key */\n wallet: WalletData;\n /** SNIP-12 typed data to sign */\n typedData: TypedData;\n}\n\n/**\n * Result of signing SNIP-12 typed data.\n */\nexport interface SignTypedDataResult {\n /** Signature r component */\n r: string;\n /** Signature s component */\n s: string;\n}\n"]}
|