@chipi-stack/types 0.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.
@@ -0,0 +1,274 @@
1
+ import { TypedData, Call } from 'starknet';
2
+
3
+ /**
4
+ * Core configuration and environment types
5
+ */
6
+ interface ChipiSDKConfig {
7
+ apiPublicKey: string;
8
+ environment?: 'development' | 'production';
9
+ nodeUrl?: string;
10
+ }
11
+ type Environment = 'development' | 'production';
12
+ type Chain = 'STARKNET_MAINNET' | 'STARKNET_SEPOLIA';
13
+ type ChainToken = 'USDC' | 'USDT' | 'ETH' | 'STRK' | 'DAI';
14
+ interface PaginationQuery {
15
+ page?: number;
16
+ limit?: number;
17
+ }
18
+ interface PaginatedResponse<T> {
19
+ data: T[];
20
+ total: number;
21
+ page: number;
22
+ limit: number;
23
+ totalPages: number;
24
+ }
25
+
26
+ /**
27
+ * Wallet-related types
28
+ */
29
+ interface WalletData {
30
+ publicKey: string;
31
+ encryptedPrivateKey: string;
32
+ }
33
+ interface CreateWalletParams {
34
+ encryptKey: string;
35
+ apiPublicKey: string;
36
+ bearerToken: string;
37
+ }
38
+ interface CreateWalletParams {
39
+ encryptKey: string;
40
+ bearerToken: string;
41
+ apiPublicKey: string;
42
+ nodeUrl?: string;
43
+ }
44
+ interface CreateWalletResponse {
45
+ success: boolean;
46
+ txHash: string;
47
+ walletPublicKey: string;
48
+ wallet: WalletData;
49
+ }
50
+ interface PrepareWalletCreationParams {
51
+ encryptKey: string;
52
+ apiPublicKey: string;
53
+ }
54
+ interface PrepareWalletCreationResponse {
55
+ typeData: TypedData;
56
+ accountClassHash: string;
57
+ }
58
+ interface CreateCustodialWalletParams {
59
+ chain: Chain;
60
+ orgId: string;
61
+ }
62
+ interface GetMerchantWalletParams {
63
+ apiKeyId: string;
64
+ chain: Chain;
65
+ orgId: string;
66
+ }
67
+
68
+ /**
69
+ * Transaction-related types
70
+ */
71
+ interface ExecuteTransactionParams {
72
+ encryptKey: string;
73
+ wallet: WalletData;
74
+ calls: Call[];
75
+ bearerToken: string;
76
+ apiPublicKey: string;
77
+ }
78
+ interface Transaction {
79
+ id: string;
80
+ chain: 'STARKNET' | 'BASE' | 'ARBITRUM' | 'OPTIMISM' | 'ROOTSTOCK' | 'SCROLL' | 'WORLDCHAIN';
81
+ apiPublicKey: string;
82
+ transactionHash: string;
83
+ blockNumber: number;
84
+ senderAddress: string;
85
+ destinationAddress: string;
86
+ amount: string;
87
+ token: 'USDC' | 'USDT' | 'DAI' | 'ETH' | 'STRK' | 'SLINK' | 'ALF' | 'BROTHER' | 'ARB' | 'DOC' | 'MXNB' | 'WLD';
88
+ calledFunction?: string;
89
+ amountInUSD: number;
90
+ status: string;
91
+ isChipiWallet: boolean;
92
+ createdAt: Date;
93
+ updatedAt: Date;
94
+ }
95
+ interface PrepareTypedDataParams {
96
+ calls: Call[];
97
+ walletAddress: string;
98
+ }
99
+ interface ExecuteSponsoredTransactionParams {
100
+ calls: Call[];
101
+ walletAddress: string;
102
+ signature: string[];
103
+ apiPublicKey: string;
104
+ }
105
+ interface ExecuteSponsoredTransactionResponse {
106
+ transactionHash: string;
107
+ success: boolean;
108
+ }
109
+ interface RecordSendTransactionParams {
110
+ walletAddress: string;
111
+ transactionHash: string;
112
+ amount: number;
113
+ chain: Chain;
114
+ chainToken: ChainToken;
115
+ apiKey: any;
116
+ }
117
+ interface TransferParams {
118
+ encryptKey: string;
119
+ wallet: WalletData;
120
+ contractAddress: string;
121
+ recipient: string;
122
+ amount: string | number;
123
+ decimals?: number;
124
+ bearerToken: string;
125
+ apiPublicKey: string;
126
+ }
127
+ interface ApproveParams {
128
+ encryptKey: string;
129
+ wallet: WalletData;
130
+ contractAddress: string;
131
+ spender: string;
132
+ amount: string | number;
133
+ decimals?: number;
134
+ bearerToken: string;
135
+ apiPublicKey: string;
136
+ }
137
+ interface StakeVesuUsdcParams {
138
+ encryptKey: string;
139
+ wallet: WalletData;
140
+ amount: string | number;
141
+ receiverWallet: string;
142
+ bearerToken: string;
143
+ apiPublicKey: string;
144
+ }
145
+ interface WithdrawVesuUsdcParams {
146
+ encryptKey: string;
147
+ wallet: WalletData;
148
+ amount: string | number;
149
+ recipient: string;
150
+ bearerToken: string;
151
+ apiPublicKey: string;
152
+ }
153
+ interface CallAnyContractParams {
154
+ encryptKey: string;
155
+ wallet: WalletData;
156
+ contractAddress: string;
157
+ calls: Call[];
158
+ bearerToken: string;
159
+ apiPublicKey: string;
160
+ }
161
+ interface GetTransactionsParams {
162
+ page?: number;
163
+ limit?: number;
164
+ orgId: string;
165
+ }
166
+
167
+ /**
168
+ * SKU (Stock Keeping Unit) related types
169
+ */
170
+ type SkuCategory = 'MOBILE_RECHARGE' | 'UTILITIES' | 'ENTERTAINMENT' | 'GIFT_CARDS' | 'TRANSPORTATION';
171
+ interface Sku {
172
+ id: string;
173
+ name: string;
174
+ description?: string;
175
+ category: SkuCategory;
176
+ price: number;
177
+ currency: string;
178
+ isActive: boolean;
179
+ metadata?: Record<string, any>;
180
+ createdAt: Date;
181
+ updatedAt: Date;
182
+ }
183
+ interface FindSkusParams {
184
+ categories?: SkuCategory[];
185
+ }
186
+ interface FindSkusResponse {
187
+ skus: Sku[];
188
+ }
189
+ interface CreateSkuTransactionParams {
190
+ walletAddress: string;
191
+ skuId: string;
192
+ chain: Chain;
193
+ chainToken: ChainToken;
194
+ mxnAmount: number;
195
+ reference: string;
196
+ transactionHash: string;
197
+ apiKey: any;
198
+ }
199
+ interface SkuTransaction {
200
+ id: string;
201
+ walletAddress: string;
202
+ skuId: string;
203
+ sku?: Sku;
204
+ chain: Chain;
205
+ chainToken: ChainToken;
206
+ mxnAmount: number;
207
+ reference: string;
208
+ transactionHash: string;
209
+ status: 'PENDING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
210
+ createdAt: Date;
211
+ updatedAt: Date;
212
+ }
213
+
214
+ /**
215
+ * API-related types and interfaces
216
+ */
217
+ interface ApiKey {
218
+ id: string;
219
+ publicKey: string;
220
+ secretKey: string;
221
+ environment: 'development' | 'production';
222
+ isActive: boolean;
223
+ orgId: string;
224
+ createdAt: Date;
225
+ updatedAt: Date;
226
+ }
227
+ interface ApiResponse<T = any> {
228
+ success: boolean;
229
+ data?: T;
230
+ error?: string;
231
+ message?: string;
232
+ }
233
+ interface ApiError {
234
+ code: string;
235
+ message: string;
236
+ details?: any;
237
+ }
238
+ interface AuthContext {
239
+ apiKey: ApiKey;
240
+ orgId: string;
241
+ userId?: string;
242
+ }
243
+ interface JwtPayload {
244
+ sub: string;
245
+ iss: string;
246
+ aud: string;
247
+ exp: number;
248
+ iat: number;
249
+ [key: string]: any;
250
+ }
251
+
252
+ /**
253
+ * Utility types and helper interfaces
254
+ */
255
+ type Prettify<T> = {
256
+ [K in keyof T]: T[K];
257
+ } & {};
258
+ type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
259
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
260
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
261
+ }[Keys];
262
+ type DeepPartial<T> = {
263
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
264
+ };
265
+ type NonEmptyArray<T> = [T, ...T[]];
266
+ interface ErrorWithCode extends Error {
267
+ code?: string;
268
+ status?: number;
269
+ }
270
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
271
+ type ValueOrFunction<T> = T | (() => T);
272
+ type MaybePromise<T> = T | Promise<T>;
273
+
274
+ export type { ApiError, ApiKey, ApiResponse, ApproveParams, AsyncReturnType, AuthContext, CallAnyContractParams, Chain, ChainToken, ChipiSDKConfig, CreateCustodialWalletParams, CreateSkuTransactionParams, CreateWalletParams, CreateWalletResponse, DeepPartial, Environment, ErrorWithCode, ExecuteSponsoredTransactionParams, ExecuteSponsoredTransactionResponse, ExecuteTransactionParams, FindSkusParams, FindSkusResponse, GetMerchantWalletParams, GetTransactionsParams, JwtPayload, MaybePromise, NonEmptyArray, Optional, PaginatedResponse, PaginationQuery, PrepareTypedDataParams, PrepareWalletCreationParams, PrepareWalletCreationResponse, Prettify, RecordSendTransactionParams, RequireAtLeastOne, Sku, SkuCategory, SkuTransaction, StakeVesuUsdcParams, Transaction, TransferParams, ValueOrFunction, WalletData, WithdrawVesuUsdcParams };
@@ -0,0 +1,274 @@
1
+ import { TypedData, Call } from 'starknet';
2
+
3
+ /**
4
+ * Core configuration and environment types
5
+ */
6
+ interface ChipiSDKConfig {
7
+ apiPublicKey: string;
8
+ environment?: 'development' | 'production';
9
+ nodeUrl?: string;
10
+ }
11
+ type Environment = 'development' | 'production';
12
+ type Chain = 'STARKNET_MAINNET' | 'STARKNET_SEPOLIA';
13
+ type ChainToken = 'USDC' | 'USDT' | 'ETH' | 'STRK' | 'DAI';
14
+ interface PaginationQuery {
15
+ page?: number;
16
+ limit?: number;
17
+ }
18
+ interface PaginatedResponse<T> {
19
+ data: T[];
20
+ total: number;
21
+ page: number;
22
+ limit: number;
23
+ totalPages: number;
24
+ }
25
+
26
+ /**
27
+ * Wallet-related types
28
+ */
29
+ interface WalletData {
30
+ publicKey: string;
31
+ encryptedPrivateKey: string;
32
+ }
33
+ interface CreateWalletParams {
34
+ encryptKey: string;
35
+ apiPublicKey: string;
36
+ bearerToken: string;
37
+ }
38
+ interface CreateWalletParams {
39
+ encryptKey: string;
40
+ bearerToken: string;
41
+ apiPublicKey: string;
42
+ nodeUrl?: string;
43
+ }
44
+ interface CreateWalletResponse {
45
+ success: boolean;
46
+ txHash: string;
47
+ walletPublicKey: string;
48
+ wallet: WalletData;
49
+ }
50
+ interface PrepareWalletCreationParams {
51
+ encryptKey: string;
52
+ apiPublicKey: string;
53
+ }
54
+ interface PrepareWalletCreationResponse {
55
+ typeData: TypedData;
56
+ accountClassHash: string;
57
+ }
58
+ interface CreateCustodialWalletParams {
59
+ chain: Chain;
60
+ orgId: string;
61
+ }
62
+ interface GetMerchantWalletParams {
63
+ apiKeyId: string;
64
+ chain: Chain;
65
+ orgId: string;
66
+ }
67
+
68
+ /**
69
+ * Transaction-related types
70
+ */
71
+ interface ExecuteTransactionParams {
72
+ encryptKey: string;
73
+ wallet: WalletData;
74
+ calls: Call[];
75
+ bearerToken: string;
76
+ apiPublicKey: string;
77
+ }
78
+ interface Transaction {
79
+ id: string;
80
+ chain: 'STARKNET' | 'BASE' | 'ARBITRUM' | 'OPTIMISM' | 'ROOTSTOCK' | 'SCROLL' | 'WORLDCHAIN';
81
+ apiPublicKey: string;
82
+ transactionHash: string;
83
+ blockNumber: number;
84
+ senderAddress: string;
85
+ destinationAddress: string;
86
+ amount: string;
87
+ token: 'USDC' | 'USDT' | 'DAI' | 'ETH' | 'STRK' | 'SLINK' | 'ALF' | 'BROTHER' | 'ARB' | 'DOC' | 'MXNB' | 'WLD';
88
+ calledFunction?: string;
89
+ amountInUSD: number;
90
+ status: string;
91
+ isChipiWallet: boolean;
92
+ createdAt: Date;
93
+ updatedAt: Date;
94
+ }
95
+ interface PrepareTypedDataParams {
96
+ calls: Call[];
97
+ walletAddress: string;
98
+ }
99
+ interface ExecuteSponsoredTransactionParams {
100
+ calls: Call[];
101
+ walletAddress: string;
102
+ signature: string[];
103
+ apiPublicKey: string;
104
+ }
105
+ interface ExecuteSponsoredTransactionResponse {
106
+ transactionHash: string;
107
+ success: boolean;
108
+ }
109
+ interface RecordSendTransactionParams {
110
+ walletAddress: string;
111
+ transactionHash: string;
112
+ amount: number;
113
+ chain: Chain;
114
+ chainToken: ChainToken;
115
+ apiKey: any;
116
+ }
117
+ interface TransferParams {
118
+ encryptKey: string;
119
+ wallet: WalletData;
120
+ contractAddress: string;
121
+ recipient: string;
122
+ amount: string | number;
123
+ decimals?: number;
124
+ bearerToken: string;
125
+ apiPublicKey: string;
126
+ }
127
+ interface ApproveParams {
128
+ encryptKey: string;
129
+ wallet: WalletData;
130
+ contractAddress: string;
131
+ spender: string;
132
+ amount: string | number;
133
+ decimals?: number;
134
+ bearerToken: string;
135
+ apiPublicKey: string;
136
+ }
137
+ interface StakeVesuUsdcParams {
138
+ encryptKey: string;
139
+ wallet: WalletData;
140
+ amount: string | number;
141
+ receiverWallet: string;
142
+ bearerToken: string;
143
+ apiPublicKey: string;
144
+ }
145
+ interface WithdrawVesuUsdcParams {
146
+ encryptKey: string;
147
+ wallet: WalletData;
148
+ amount: string | number;
149
+ recipient: string;
150
+ bearerToken: string;
151
+ apiPublicKey: string;
152
+ }
153
+ interface CallAnyContractParams {
154
+ encryptKey: string;
155
+ wallet: WalletData;
156
+ contractAddress: string;
157
+ calls: Call[];
158
+ bearerToken: string;
159
+ apiPublicKey: string;
160
+ }
161
+ interface GetTransactionsParams {
162
+ page?: number;
163
+ limit?: number;
164
+ orgId: string;
165
+ }
166
+
167
+ /**
168
+ * SKU (Stock Keeping Unit) related types
169
+ */
170
+ type SkuCategory = 'MOBILE_RECHARGE' | 'UTILITIES' | 'ENTERTAINMENT' | 'GIFT_CARDS' | 'TRANSPORTATION';
171
+ interface Sku {
172
+ id: string;
173
+ name: string;
174
+ description?: string;
175
+ category: SkuCategory;
176
+ price: number;
177
+ currency: string;
178
+ isActive: boolean;
179
+ metadata?: Record<string, any>;
180
+ createdAt: Date;
181
+ updatedAt: Date;
182
+ }
183
+ interface FindSkusParams {
184
+ categories?: SkuCategory[];
185
+ }
186
+ interface FindSkusResponse {
187
+ skus: Sku[];
188
+ }
189
+ interface CreateSkuTransactionParams {
190
+ walletAddress: string;
191
+ skuId: string;
192
+ chain: Chain;
193
+ chainToken: ChainToken;
194
+ mxnAmount: number;
195
+ reference: string;
196
+ transactionHash: string;
197
+ apiKey: any;
198
+ }
199
+ interface SkuTransaction {
200
+ id: string;
201
+ walletAddress: string;
202
+ skuId: string;
203
+ sku?: Sku;
204
+ chain: Chain;
205
+ chainToken: ChainToken;
206
+ mxnAmount: number;
207
+ reference: string;
208
+ transactionHash: string;
209
+ status: 'PENDING' | 'COMPLETED' | 'FAILED' | 'CANCELLED';
210
+ createdAt: Date;
211
+ updatedAt: Date;
212
+ }
213
+
214
+ /**
215
+ * API-related types and interfaces
216
+ */
217
+ interface ApiKey {
218
+ id: string;
219
+ publicKey: string;
220
+ secretKey: string;
221
+ environment: 'development' | 'production';
222
+ isActive: boolean;
223
+ orgId: string;
224
+ createdAt: Date;
225
+ updatedAt: Date;
226
+ }
227
+ interface ApiResponse<T = any> {
228
+ success: boolean;
229
+ data?: T;
230
+ error?: string;
231
+ message?: string;
232
+ }
233
+ interface ApiError {
234
+ code: string;
235
+ message: string;
236
+ details?: any;
237
+ }
238
+ interface AuthContext {
239
+ apiKey: ApiKey;
240
+ orgId: string;
241
+ userId?: string;
242
+ }
243
+ interface JwtPayload {
244
+ sub: string;
245
+ iss: string;
246
+ aud: string;
247
+ exp: number;
248
+ iat: number;
249
+ [key: string]: any;
250
+ }
251
+
252
+ /**
253
+ * Utility types and helper interfaces
254
+ */
255
+ type Prettify<T> = {
256
+ [K in keyof T]: T[K];
257
+ } & {};
258
+ type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
259
+ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
260
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
261
+ }[Keys];
262
+ type DeepPartial<T> = {
263
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
264
+ };
265
+ type NonEmptyArray<T> = [T, ...T[]];
266
+ interface ErrorWithCode extends Error {
267
+ code?: string;
268
+ status?: number;
269
+ }
270
+ type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (...args: any) => Promise<infer R> ? R : any;
271
+ type ValueOrFunction<T> = T | (() => T);
272
+ type MaybePromise<T> = T | Promise<T>;
273
+
274
+ export type { ApiError, ApiKey, ApiResponse, ApproveParams, AsyncReturnType, AuthContext, CallAnyContractParams, Chain, ChainToken, ChipiSDKConfig, CreateCustodialWalletParams, CreateSkuTransactionParams, CreateWalletParams, CreateWalletResponse, DeepPartial, Environment, ErrorWithCode, ExecuteSponsoredTransactionParams, ExecuteSponsoredTransactionResponse, ExecuteTransactionParams, FindSkusParams, FindSkusResponse, GetMerchantWalletParams, GetTransactionsParams, JwtPayload, MaybePromise, NonEmptyArray, Optional, PaginatedResponse, PaginationQuery, PrepareTypedDataParams, PrepareWalletCreationParams, PrepareWalletCreationResponse, Prettify, RecordSendTransactionParams, RequireAtLeastOne, Sku, SkuCategory, SkuTransaction, StakeVesuUsdcParams, Transaction, TransferParams, ValueOrFunction, WalletData, WithdrawVesuUsdcParams };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/dist/index.mjs ADDED
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.mjs.map
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@chipi-stack/types",
3
+ "version": "0.1.0",
4
+ "description": "Type definitions for Chipi SDK packages",
5
+ "keywords": [
6
+ "chipi",
7
+ "blockchain",
8
+ "starknet",
9
+ "wallet",
10
+ "types",
11
+ "typescript"
12
+ ],
13
+ "homepage": "https://github.com/chipi-pay/chipi-sdk",
14
+ "bugs": {
15
+ "url": "https://github.com/chipi-pay/chipi-sdk/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/chipi-pay/chipi-sdk.git",
20
+ "directory": "sdks/types"
21
+ },
22
+ "license": "MIT",
23
+ "author": "Chipi Pay",
24
+ "main": "dist/index.js",
25
+ "module": "dist/esm/index.js",
26
+ "types": "dist/index.d.ts",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsup --env.NODE_ENV production",
32
+ "build:declarations": "tsc -p tsconfig.declarations.json",
33
+ "clean": "rimraf ./dist",
34
+ "dev": "tsup --watch",
35
+ "format": "prettier --write src/**/*.ts",
36
+ "format:check": "prettier --check src/**/*.ts",
37
+ "lint": "eslint src",
38
+ "typecheck": "tsc --noEmit"
39
+ },
40
+ "dependencies": {
41
+ "starknet": ">=6.23.1"
42
+ },
43
+ "devDependencies": {
44
+ "@types/node": "^22.15.15",
45
+ "eslint": "^9.33.0",
46
+ "prettier": "^3.0.0",
47
+ "rimraf": "^5.0.0",
48
+ "tsup": "^8.3.6",
49
+ "typescript": "^5.7.3"
50
+ },
51
+ "engines": {
52
+ "node": ">=18.17.0"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ }
57
+ }