@fystack/sdk 0.1.1 → 0.1.3
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.cjs +121 -57
- package/dist/index.d.cts +318 -267
- package/dist/index.d.mts +318 -267
- package/dist/index.esm.d.ts +318 -267
- package/dist/index.esm.js +121 -58
- package/dist/index.mjs +121 -58
- package/dist/types/index.d.ts +318 -267
- package/package.json +1 -1
- package/readme.md +7 -1
- package/src/api.ts +49 -14
- package/src/config.ts +4 -2
- package/src/enum.ts +46 -0
- package/src/index.ts +1 -0
- package/src/sdk.ts +31 -7
- package/src/signer.ts +9 -4
- package/src/solanaSigner.ts +11 -4
- package/src/types.ts +14 -30
- package/test.js +0 -76
package/dist/types/index.d.ts
CHANGED
|
@@ -1,145 +1,6 @@
|
|
|
1
1
|
import { AbstractSigner, Provider, TransactionResponse, TypedDataDomain, TypedDataField } from 'ethers';
|
|
2
2
|
import { TransactionRequest } from 'ethers/src.ts/providers';
|
|
3
3
|
|
|
4
|
-
declare class TransactionError extends Error {
|
|
5
|
-
readonly code: string;
|
|
6
|
-
readonly transactionId?: string | undefined;
|
|
7
|
-
readonly originalError?: Error | undefined;
|
|
8
|
-
constructor(message: string, code: string, transactionId?: string | undefined, originalError?: Error | undefined);
|
|
9
|
-
}
|
|
10
|
-
declare enum TxStatus {
|
|
11
|
-
Pending = "pending",
|
|
12
|
-
Completed = "completed",
|
|
13
|
-
Confirmed = "confirmed",
|
|
14
|
-
Failed = "failed",
|
|
15
|
-
PendingApproval = "pending_approval",
|
|
16
|
-
Rejected = "rejected"
|
|
17
|
-
}
|
|
18
|
-
declare enum TxApprovalStatus {
|
|
19
|
-
Pending = "pending",
|
|
20
|
-
Approved = "approved",
|
|
21
|
-
Rejected = "rejected"
|
|
22
|
-
}
|
|
23
|
-
interface APICredentials {
|
|
24
|
-
apiKey: string;
|
|
25
|
-
apiSecret: string;
|
|
26
|
-
}
|
|
27
|
-
interface WebhookEvent {
|
|
28
|
-
webhook_id: string;
|
|
29
|
-
resource_id: string;
|
|
30
|
-
url: string;
|
|
31
|
-
payload: any;
|
|
32
|
-
event: string;
|
|
33
|
-
}
|
|
34
|
-
interface SignRequestParams {
|
|
35
|
-
method: string;
|
|
36
|
-
message: string;
|
|
37
|
-
chain_id: number;
|
|
38
|
-
typed_data?: string;
|
|
39
|
-
}
|
|
40
|
-
interface SignResponse {
|
|
41
|
-
transaction_id: string;
|
|
42
|
-
}
|
|
43
|
-
interface SignatureStatusResponse {
|
|
44
|
-
status: TxStatus;
|
|
45
|
-
signature?: string;
|
|
46
|
-
transaction_id: string;
|
|
47
|
-
created_at: string;
|
|
48
|
-
updated_at: string;
|
|
49
|
-
approvals: Array<{
|
|
50
|
-
user_id: string;
|
|
51
|
-
status: TxApprovalStatus;
|
|
52
|
-
}>;
|
|
53
|
-
}
|
|
54
|
-
interface ApprovalInfo {
|
|
55
|
-
user_id: string;
|
|
56
|
-
status: TxApprovalStatus;
|
|
57
|
-
}
|
|
58
|
-
interface TransactionStatusResponse {
|
|
59
|
-
transaction_id: string;
|
|
60
|
-
status: TxStatus;
|
|
61
|
-
method: string;
|
|
62
|
-
hash?: string;
|
|
63
|
-
created_at: string;
|
|
64
|
-
updated_at: string;
|
|
65
|
-
approvals: ApprovalInfo[];
|
|
66
|
-
failed_reason?: string;
|
|
67
|
-
}
|
|
68
|
-
declare enum WalletType {
|
|
69
|
-
Standard = "standard",
|
|
70
|
-
MPC = "mpc"
|
|
71
|
-
}
|
|
72
|
-
interface CreateWalletOptions {
|
|
73
|
-
name: string;
|
|
74
|
-
walletType: WalletType;
|
|
75
|
-
}
|
|
76
|
-
declare enum WalletCreationStatus {
|
|
77
|
-
Pending = "pending",
|
|
78
|
-
Success = "success",
|
|
79
|
-
Error = "error"
|
|
80
|
-
}
|
|
81
|
-
interface CreateWalletResponse {
|
|
82
|
-
wallet_id: string;
|
|
83
|
-
status: WalletCreationStatus;
|
|
84
|
-
}
|
|
85
|
-
interface WalletCreationStatusResponse {
|
|
86
|
-
wallet_id: string;
|
|
87
|
-
status: WalletCreationStatus;
|
|
88
|
-
}
|
|
89
|
-
interface WalletAssetNetwork {
|
|
90
|
-
id: string;
|
|
91
|
-
created_at: string;
|
|
92
|
-
updated_at: string;
|
|
93
|
-
name: string;
|
|
94
|
-
description?: string;
|
|
95
|
-
is_evm: boolean;
|
|
96
|
-
chain_id: number;
|
|
97
|
-
native_currency: string;
|
|
98
|
-
is_testnet?: boolean;
|
|
99
|
-
internal_code: string;
|
|
100
|
-
explorer_tx: string;
|
|
101
|
-
explorer_address: string;
|
|
102
|
-
explorer_token: string;
|
|
103
|
-
confirmation_blocks: number;
|
|
104
|
-
block_interval_in_seconds: number;
|
|
105
|
-
disabled: boolean;
|
|
106
|
-
logo_url: string;
|
|
107
|
-
}
|
|
108
|
-
interface WalletAssetDetail {
|
|
109
|
-
id: string;
|
|
110
|
-
created_at: string;
|
|
111
|
-
updated_at: string;
|
|
112
|
-
name: string;
|
|
113
|
-
symbol: string;
|
|
114
|
-
decimals: number;
|
|
115
|
-
logo_url: string;
|
|
116
|
-
is_native: boolean;
|
|
117
|
-
address_type: string;
|
|
118
|
-
is_whitelisted: boolean;
|
|
119
|
-
address?: string;
|
|
120
|
-
network_id: string;
|
|
121
|
-
network?: WalletAssetNetwork;
|
|
122
|
-
}
|
|
123
|
-
interface WalletAsset {
|
|
124
|
-
id: string;
|
|
125
|
-
created_at: string;
|
|
126
|
-
updated_at: string;
|
|
127
|
-
wallet_id: string;
|
|
128
|
-
asset_id: string;
|
|
129
|
-
deposit_address: string;
|
|
130
|
-
hidden: boolean;
|
|
131
|
-
asset: WalletAssetDetail;
|
|
132
|
-
}
|
|
133
|
-
declare enum AddressType {
|
|
134
|
-
Evm = "evm",
|
|
135
|
-
Solana = "sol"
|
|
136
|
-
}
|
|
137
|
-
interface DepositAddressResponse {
|
|
138
|
-
asset_id?: string;
|
|
139
|
-
address: string;
|
|
140
|
-
qr_code: string;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
4
|
declare enum Environment {
|
|
144
5
|
Local = "local",
|
|
145
6
|
Sandbox = "sandbox",
|
|
@@ -159,6 +20,7 @@ interface APIEndpoints {
|
|
|
159
20
|
getWalletCreationStatus: (walletId: string) => string;
|
|
160
21
|
getWalletAssets: (walletId: string) => string;
|
|
161
22
|
getDepositAddress: (walletId: string, addressType: string) => string;
|
|
23
|
+
rescanTransaction: () => string;
|
|
162
24
|
}
|
|
163
25
|
interface APIConfig {
|
|
164
26
|
baseURL: string;
|
|
@@ -166,128 +28,6 @@ interface APIConfig {
|
|
|
166
28
|
}
|
|
167
29
|
declare const createAPI: (env: Environment) => APIConfig;
|
|
168
30
|
|
|
169
|
-
interface SDKOptions {
|
|
170
|
-
credentials: APICredentials;
|
|
171
|
-
environment?: Environment;
|
|
172
|
-
logger?: boolean;
|
|
173
|
-
}
|
|
174
|
-
declare class FystackSDK {
|
|
175
|
-
private apiService;
|
|
176
|
-
private enableLogging;
|
|
177
|
-
constructor(options: SDKOptions);
|
|
178
|
-
private log;
|
|
179
|
-
/**
|
|
180
|
-
* Creates a new wallet
|
|
181
|
-
* @param options Wallet creation options
|
|
182
|
-
* @param waitForCompletion Whether to wait for the wallet creation to complete
|
|
183
|
-
* @returns Promise with wallet ID and status
|
|
184
|
-
*/
|
|
185
|
-
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
186
|
-
/**
|
|
187
|
-
* Gets the current status of a wallet creation process
|
|
188
|
-
* @param walletId The ID of the wallet being created
|
|
189
|
-
* @returns Promise with wallet creation status details
|
|
190
|
-
*/
|
|
191
|
-
getWalletCreationStatus(walletId: string): Promise<WalletCreationStatusResponse>;
|
|
192
|
-
/**
|
|
193
|
-
* Waits for a wallet to be created and returns the final status
|
|
194
|
-
* @param walletId The ID of the wallet being created
|
|
195
|
-
* @returns Promise with wallet ID and final status
|
|
196
|
-
*/
|
|
197
|
-
private waitForWalletCreation;
|
|
198
|
-
/**
|
|
199
|
-
* Gets assets associated with a wallet
|
|
200
|
-
* @param walletId The ID of the wallet
|
|
201
|
-
* @returns Promise with wallet assets
|
|
202
|
-
*/
|
|
203
|
-
getWalletAssets(walletId: string): Promise<WalletAsset[]>;
|
|
204
|
-
/**
|
|
205
|
-
* Gets deposit address for a wallet by address type
|
|
206
|
-
* @param walletId The wallet ID
|
|
207
|
-
* @param addressType The type of address (evm, sol)
|
|
208
|
-
* @returns Promise with deposit address information
|
|
209
|
-
*/
|
|
210
|
-
getDepositAddress(walletId: string, addressType: AddressType): Promise<DepositAddressResponse>;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
interface StatusPollerOptions {
|
|
214
|
-
maxAttempts?: number;
|
|
215
|
-
interval?: number;
|
|
216
|
-
backoffFactor?: number;
|
|
217
|
-
maxInterval?: number;
|
|
218
|
-
timeoutMs?: number;
|
|
219
|
-
}
|
|
220
|
-
declare const DEFAULT_POLLER_OPTIONS: StatusPollerOptions;
|
|
221
|
-
declare class StatusPoller {
|
|
222
|
-
private startTime;
|
|
223
|
-
private attempts;
|
|
224
|
-
private currentInterval;
|
|
225
|
-
private readonly options;
|
|
226
|
-
constructor(options?: StatusPollerOptions);
|
|
227
|
-
private wait;
|
|
228
|
-
private shouldContinue;
|
|
229
|
-
poll<T>(pollingFn: () => Promise<T>, successCondition: (result: T) => boolean, errorCondition?: (result: T) => boolean | void): Promise<T>;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
declare class EtherSigner extends AbstractSigner {
|
|
233
|
-
private address;
|
|
234
|
-
private APICredentials;
|
|
235
|
-
private APIService;
|
|
236
|
-
private walletDetail;
|
|
237
|
-
private environment;
|
|
238
|
-
private pollerOptions?;
|
|
239
|
-
constructor(credentials: APICredentials, environment: Environment, provider?: null | Provider, pollerOptions?: StatusPollerOptions);
|
|
240
|
-
setWallet(walletId: string): void;
|
|
241
|
-
getAddress(): Promise<string>;
|
|
242
|
-
private getChainId;
|
|
243
|
-
connect(provider: null | Provider): EtherSigner;
|
|
244
|
-
private waitForSignature;
|
|
245
|
-
private waitForTransactonStatus;
|
|
246
|
-
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
247
|
-
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
|
248
|
-
signMessage(message: string | Uint8Array): Promise<string>;
|
|
249
|
-
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
declare class SolanaSigner {
|
|
253
|
-
private address;
|
|
254
|
-
private APIService;
|
|
255
|
-
private APIKey;
|
|
256
|
-
private walletDetail;
|
|
257
|
-
private pollerOptions?;
|
|
258
|
-
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
259
|
-
setWallet(walletId: string): void;
|
|
260
|
-
getAddress(): Promise<string>;
|
|
261
|
-
private waitForTransactionStatus;
|
|
262
|
-
/**
|
|
263
|
-
* Signs a Solana transaction
|
|
264
|
-
* @param transaction Base64 encoded serialized transaction
|
|
265
|
-
* @returns Signature as a base58 encoded string
|
|
266
|
-
*/
|
|
267
|
-
signTransaction(transaction: string): Promise<string>;
|
|
268
|
-
/**
|
|
269
|
-
* Signs a Solana message
|
|
270
|
-
* @param message The message to sign (string or Uint8Array)
|
|
271
|
-
* @returns Signature as a base58 encoded string
|
|
272
|
-
*/
|
|
273
|
-
signMessage(message: string | Uint8Array): Promise<string>;
|
|
274
|
-
/**
|
|
275
|
-
* Signs and sends a Solana transaction
|
|
276
|
-
* @param transaction Base64 encoded serialized transaction
|
|
277
|
-
* @returns Transaction signature
|
|
278
|
-
*/
|
|
279
|
-
signAndSendTransaction(transaction: string): Promise<string>;
|
|
280
|
-
/**
|
|
281
|
-
* Signs multiple Solana transactions
|
|
282
|
-
* @param transactions Array of base64 encoded serialized transactions
|
|
283
|
-
* @returns Array of signatures as base58 encoded strings
|
|
284
|
-
*/
|
|
285
|
-
signAllTransactions(transactions: string[]): Promise<{
|
|
286
|
-
transactions: string[];
|
|
287
|
-
}>;
|
|
288
|
-
private incorporateSignatureIntoTransaction;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
31
|
interface Network {
|
|
292
32
|
id: string;
|
|
293
33
|
created_at: string;
|
|
@@ -534,6 +274,46 @@ interface GetCheckoutPaymentResponse {
|
|
|
534
274
|
deposit_qr: string;
|
|
535
275
|
}
|
|
536
276
|
|
|
277
|
+
declare enum WalletType {
|
|
278
|
+
Standard = "standard",
|
|
279
|
+
MPC = "mpc"
|
|
280
|
+
}
|
|
281
|
+
declare enum WalletPurpose {
|
|
282
|
+
General = "general",
|
|
283
|
+
Gastank = "gas_tank",
|
|
284
|
+
Deployment = "deployment",
|
|
285
|
+
Custody = "custody",
|
|
286
|
+
User = "user",
|
|
287
|
+
Payment = "payment"
|
|
288
|
+
}
|
|
289
|
+
declare enum WalletCreationStatus {
|
|
290
|
+
Pending = "pending",
|
|
291
|
+
Success = "success",
|
|
292
|
+
Error = "error"
|
|
293
|
+
}
|
|
294
|
+
declare enum AddressType {
|
|
295
|
+
Evm = "evm",
|
|
296
|
+
Solana = "sol",
|
|
297
|
+
Tron = "tron"
|
|
298
|
+
}
|
|
299
|
+
declare enum DestinationType {
|
|
300
|
+
InternalWallet = "internal_wallet",
|
|
301
|
+
AddressBook = "address_book"
|
|
302
|
+
}
|
|
303
|
+
declare enum TxStatus {
|
|
304
|
+
Pending = "pending",
|
|
305
|
+
Completed = "completed",
|
|
306
|
+
Confirmed = "confirmed",
|
|
307
|
+
Failed = "failed",
|
|
308
|
+
PendingApproval = "pending_approval",
|
|
309
|
+
Rejected = "rejected"
|
|
310
|
+
}
|
|
311
|
+
declare enum TxApprovalStatus {
|
|
312
|
+
Pending = "pending",
|
|
313
|
+
Approved = "approved",
|
|
314
|
+
Rejected = "rejected"
|
|
315
|
+
}
|
|
316
|
+
|
|
537
317
|
interface APIResponse {
|
|
538
318
|
data: any;
|
|
539
319
|
success: boolean;
|
|
@@ -552,24 +332,28 @@ interface WalletDetail {
|
|
|
552
332
|
AddressType: string;
|
|
553
333
|
Address: string;
|
|
554
334
|
}
|
|
335
|
+
interface SweepTaskParams {
|
|
336
|
+
minTriggerValueUsd: number;
|
|
337
|
+
destinationWalletId: string;
|
|
338
|
+
destinationType: DestinationType;
|
|
339
|
+
}
|
|
555
340
|
interface CreateWalletPayload {
|
|
556
341
|
name: string;
|
|
557
342
|
walletType: WalletType;
|
|
343
|
+
walletPurpose?: WalletPurpose;
|
|
344
|
+
sweepTaskParams?: SweepTaskParams;
|
|
345
|
+
sweepTaskId?: string;
|
|
558
346
|
}
|
|
559
347
|
interface PaymentServiceParams {
|
|
560
348
|
apiKey: string;
|
|
561
349
|
environment: Environment;
|
|
562
350
|
}
|
|
563
|
-
declare enum WalletAddressType {
|
|
564
|
-
Evm = "evm",
|
|
565
|
-
Sol = "sol"
|
|
566
|
-
}
|
|
567
351
|
declare class APIService {
|
|
568
352
|
private credentials;
|
|
569
353
|
Webhook: WebhookService;
|
|
570
354
|
private API;
|
|
571
355
|
constructor(credentials: APICredentials, environment: Environment);
|
|
572
|
-
getWalletDetail(addressType?:
|
|
356
|
+
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
573
357
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
574
358
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
575
359
|
signTransaction(walletId: string, body: Record<string, any>): Promise<SignResponse>;
|
|
@@ -585,6 +369,12 @@ declare class APIService {
|
|
|
585
369
|
* @returns Deposit address response
|
|
586
370
|
*/
|
|
587
371
|
getDepositAddress(walletId: string, addressType: AddressType): Promise<DepositAddressResponse>;
|
|
372
|
+
/**
|
|
373
|
+
* Rescans a transaction on a specific network
|
|
374
|
+
* @param params Transaction hash and network ID
|
|
375
|
+
* @returns API response
|
|
376
|
+
*/
|
|
377
|
+
rescanTransaction(params: RescanTransactionParams): Promise<void>;
|
|
588
378
|
}
|
|
589
379
|
declare class PaymentService {
|
|
590
380
|
private apiKey;
|
|
@@ -604,8 +394,269 @@ declare function get(endpoint: string, headers?: Record<string, string>): Promis
|
|
|
604
394
|
declare function post(endpoint: string, body: any, headers?: Record<string, string>): Promise<APIResponse>;
|
|
605
395
|
declare function transformWalletDetail(data: Record<string, string>): WalletDetail;
|
|
606
396
|
declare function transformCreateWalletPayload(data: CreateWalletPayload): {
|
|
397
|
+
sweep_task_id?: string | undefined;
|
|
398
|
+
sweep_task_params?: {
|
|
399
|
+
min_trigger_value_usd: number;
|
|
400
|
+
destination_wallet_id: string;
|
|
401
|
+
destination_type: DestinationType;
|
|
402
|
+
} | undefined;
|
|
403
|
+
wallet_purpose?: WalletPurpose | undefined;
|
|
607
404
|
name: string;
|
|
608
405
|
wallet_type: WalletType;
|
|
609
406
|
};
|
|
407
|
+
declare function transformRescanTransactionParams(data: RescanTransactionParams): {
|
|
408
|
+
tx_hash: string;
|
|
409
|
+
network_id: string;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
declare class TransactionError extends Error {
|
|
413
|
+
readonly code: string;
|
|
414
|
+
readonly transactionId?: string | undefined;
|
|
415
|
+
readonly originalError?: Error | undefined;
|
|
416
|
+
constructor(message: string, code: string, transactionId?: string | undefined, originalError?: Error | undefined);
|
|
417
|
+
}
|
|
418
|
+
interface APICredentials {
|
|
419
|
+
apiKey: string;
|
|
420
|
+
apiSecret: string;
|
|
421
|
+
authToken?: string;
|
|
422
|
+
}
|
|
423
|
+
interface WebhookEvent {
|
|
424
|
+
webhook_id: string;
|
|
425
|
+
resource_id: string;
|
|
426
|
+
url: string;
|
|
427
|
+
payload: any;
|
|
428
|
+
event: string;
|
|
429
|
+
}
|
|
430
|
+
interface SignRequestParams {
|
|
431
|
+
method: string;
|
|
432
|
+
message: string;
|
|
433
|
+
chain_id: number;
|
|
434
|
+
typed_data?: string;
|
|
435
|
+
}
|
|
436
|
+
interface SignResponse {
|
|
437
|
+
transaction_id: string;
|
|
438
|
+
}
|
|
439
|
+
interface SignatureStatusResponse {
|
|
440
|
+
status: TxStatus;
|
|
441
|
+
signature?: string;
|
|
442
|
+
transaction_id: string;
|
|
443
|
+
created_at: string;
|
|
444
|
+
updated_at: string;
|
|
445
|
+
approvals: Array<{
|
|
446
|
+
user_id: string;
|
|
447
|
+
status: TxApprovalStatus;
|
|
448
|
+
}>;
|
|
449
|
+
}
|
|
450
|
+
interface ApprovalInfo {
|
|
451
|
+
user_id: string;
|
|
452
|
+
status: TxApprovalStatus;
|
|
453
|
+
}
|
|
454
|
+
interface TransactionStatusResponse {
|
|
455
|
+
transaction_id: string;
|
|
456
|
+
status: TxStatus;
|
|
457
|
+
method: string;
|
|
458
|
+
hash?: string;
|
|
459
|
+
created_at: string;
|
|
460
|
+
updated_at: string;
|
|
461
|
+
approvals: ApprovalInfo[];
|
|
462
|
+
failed_reason?: string;
|
|
463
|
+
}
|
|
464
|
+
interface CreateWalletOptions {
|
|
465
|
+
name: string;
|
|
466
|
+
walletType: WalletType;
|
|
467
|
+
walletPurpose?: WalletPurpose;
|
|
468
|
+
sweepTaskParams?: SweepTaskParams;
|
|
469
|
+
sweepTaskId?: string;
|
|
470
|
+
}
|
|
471
|
+
interface CreateWalletResponse {
|
|
472
|
+
wallet_id: string;
|
|
473
|
+
status: WalletCreationStatus;
|
|
474
|
+
}
|
|
475
|
+
interface WalletCreationStatusResponse {
|
|
476
|
+
wallet_id: string;
|
|
477
|
+
status: WalletCreationStatus;
|
|
478
|
+
}
|
|
479
|
+
interface WalletAssetNetwork {
|
|
480
|
+
id: string;
|
|
481
|
+
created_at: string;
|
|
482
|
+
updated_at: string;
|
|
483
|
+
name: string;
|
|
484
|
+
description?: string;
|
|
485
|
+
is_evm: boolean;
|
|
486
|
+
chain_id: number;
|
|
487
|
+
native_currency: string;
|
|
488
|
+
is_testnet?: boolean;
|
|
489
|
+
internal_code: string;
|
|
490
|
+
explorer_tx: string;
|
|
491
|
+
explorer_address: string;
|
|
492
|
+
explorer_token: string;
|
|
493
|
+
confirmation_blocks: number;
|
|
494
|
+
block_interval_in_seconds: number;
|
|
495
|
+
disabled: boolean;
|
|
496
|
+
logo_url: string;
|
|
497
|
+
}
|
|
498
|
+
interface WalletAssetDetail {
|
|
499
|
+
id: string;
|
|
500
|
+
created_at: string;
|
|
501
|
+
updated_at: string;
|
|
502
|
+
name: string;
|
|
503
|
+
symbol: string;
|
|
504
|
+
decimals: number;
|
|
505
|
+
logo_url: string;
|
|
506
|
+
is_native: boolean;
|
|
507
|
+
address_type: string;
|
|
508
|
+
is_whitelisted: boolean;
|
|
509
|
+
address?: string;
|
|
510
|
+
network_id: string;
|
|
511
|
+
network?: WalletAssetNetwork;
|
|
512
|
+
}
|
|
513
|
+
interface WalletAsset {
|
|
514
|
+
id: string;
|
|
515
|
+
created_at: string;
|
|
516
|
+
updated_at: string;
|
|
517
|
+
wallet_id: string;
|
|
518
|
+
asset_id: string;
|
|
519
|
+
deposit_address: string;
|
|
520
|
+
hidden: boolean;
|
|
521
|
+
asset: WalletAssetDetail;
|
|
522
|
+
}
|
|
523
|
+
interface DepositAddressResponse {
|
|
524
|
+
asset_id?: string;
|
|
525
|
+
address: string;
|
|
526
|
+
qr_code: string;
|
|
527
|
+
}
|
|
528
|
+
interface RescanTransactionParams {
|
|
529
|
+
txHash: string;
|
|
530
|
+
networkId: string;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
interface SDKOptions {
|
|
534
|
+
credentials: APICredentials;
|
|
535
|
+
environment?: Environment;
|
|
536
|
+
logger?: boolean;
|
|
537
|
+
}
|
|
538
|
+
declare class FystackSDK {
|
|
539
|
+
private apiService;
|
|
540
|
+
private enableLogging;
|
|
541
|
+
constructor(options: SDKOptions);
|
|
542
|
+
private log;
|
|
543
|
+
/**
|
|
544
|
+
* Creates a new wallet
|
|
545
|
+
* @param options Wallet creation options
|
|
546
|
+
* @param waitForCompletion Whether to wait for the wallet creation to complete
|
|
547
|
+
* @returns Promise with wallet ID and status
|
|
548
|
+
*/
|
|
549
|
+
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
550
|
+
/**
|
|
551
|
+
* Gets the current status of a wallet creation process
|
|
552
|
+
* @param walletId The ID of the wallet being created
|
|
553
|
+
* @returns Promise with wallet creation status details
|
|
554
|
+
*/
|
|
555
|
+
getWalletCreationStatus(walletId: string): Promise<WalletCreationStatusResponse>;
|
|
556
|
+
/**
|
|
557
|
+
* Waits for a wallet to be created and returns the final status
|
|
558
|
+
* @param walletId The ID of the wallet being created
|
|
559
|
+
* @returns Promise with wallet ID and final status
|
|
560
|
+
*/
|
|
561
|
+
private waitForWalletCreation;
|
|
562
|
+
/**
|
|
563
|
+
* Gets assets associated with a wallet
|
|
564
|
+
* @param walletId The ID of the wallet
|
|
565
|
+
* @returns Promise with wallet assets
|
|
566
|
+
*/
|
|
567
|
+
getWalletAssets(walletId: string): Promise<WalletAsset[]>;
|
|
568
|
+
/**
|
|
569
|
+
* Gets deposit address for a wallet by address type
|
|
570
|
+
* @param walletId The wallet ID
|
|
571
|
+
* @param addressType The type of address (evm, sol)
|
|
572
|
+
* @returns Promise with deposit address information
|
|
573
|
+
*/
|
|
574
|
+
getDepositAddress(walletId: string, addressType: AddressType): Promise<DepositAddressResponse>;
|
|
575
|
+
/**
|
|
576
|
+
* Rescans a transaction on a specific network
|
|
577
|
+
* @param params Transaction hash and network ID
|
|
578
|
+
* @returns Promise that resolves when the rescan is initiated
|
|
579
|
+
*/
|
|
580
|
+
rescanTransaction(params: RescanTransactionParams): Promise<void>;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
interface StatusPollerOptions {
|
|
584
|
+
maxAttempts?: number;
|
|
585
|
+
interval?: number;
|
|
586
|
+
backoffFactor?: number;
|
|
587
|
+
maxInterval?: number;
|
|
588
|
+
timeoutMs?: number;
|
|
589
|
+
}
|
|
590
|
+
declare const DEFAULT_POLLER_OPTIONS: StatusPollerOptions;
|
|
591
|
+
declare class StatusPoller {
|
|
592
|
+
private startTime;
|
|
593
|
+
private attempts;
|
|
594
|
+
private currentInterval;
|
|
595
|
+
private readonly options;
|
|
596
|
+
constructor(options?: StatusPollerOptions);
|
|
597
|
+
private wait;
|
|
598
|
+
private shouldContinue;
|
|
599
|
+
poll<T>(pollingFn: () => Promise<T>, successCondition: (result: T) => boolean, errorCondition?: (result: T) => boolean | void): Promise<T>;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
declare class EtherSigner extends AbstractSigner {
|
|
603
|
+
private address;
|
|
604
|
+
private APICredentials;
|
|
605
|
+
private APIService;
|
|
606
|
+
private walletDetail;
|
|
607
|
+
private environment;
|
|
608
|
+
private pollerOptions?;
|
|
609
|
+
constructor(credentials: APICredentials, environment: Environment, provider?: null | Provider, pollerOptions?: StatusPollerOptions);
|
|
610
|
+
setWallet(walletId: string): void;
|
|
611
|
+
getAddress(): Promise<string>;
|
|
612
|
+
private getChainId;
|
|
613
|
+
connect(provider: null | Provider): EtherSigner;
|
|
614
|
+
private waitForSignature;
|
|
615
|
+
private waitForTransactonStatus;
|
|
616
|
+
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
617
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
|
618
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
619
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
declare class SolanaSigner {
|
|
623
|
+
private address;
|
|
624
|
+
private APIService;
|
|
625
|
+
private APIKey;
|
|
626
|
+
private walletDetail;
|
|
627
|
+
private pollerOptions?;
|
|
628
|
+
private APICredentials;
|
|
629
|
+
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
630
|
+
setWallet(walletId: string): void;
|
|
631
|
+
getAddress(): Promise<string>;
|
|
632
|
+
private waitForTransactionStatus;
|
|
633
|
+
/**
|
|
634
|
+
* Signs a Solana transaction
|
|
635
|
+
* @param transaction Base64 encoded serialized transaction
|
|
636
|
+
* @returns Signature as a base58 encoded string
|
|
637
|
+
*/
|
|
638
|
+
signTransaction(transaction: string): Promise<string>;
|
|
639
|
+
/**
|
|
640
|
+
* Signs a Solana message
|
|
641
|
+
* @param message The message to sign (string or Uint8Array)
|
|
642
|
+
* @returns Signature as a base58 encoded string
|
|
643
|
+
*/
|
|
644
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
645
|
+
/**
|
|
646
|
+
* Signs and sends a Solana transaction
|
|
647
|
+
* @param transaction Base64 encoded serialized transaction
|
|
648
|
+
* @returns Transaction signature
|
|
649
|
+
*/
|
|
650
|
+
signAndSendTransaction(transaction: string): Promise<string>;
|
|
651
|
+
/**
|
|
652
|
+
* Signs multiple Solana transactions
|
|
653
|
+
* @param transactions Array of base64 encoded serialized transactions
|
|
654
|
+
* @returns Array of signatures as base58 encoded strings
|
|
655
|
+
*/
|
|
656
|
+
signAllTransactions(transactions: string[]): Promise<{
|
|
657
|
+
transactions: string[];
|
|
658
|
+
}>;
|
|
659
|
+
private incorporateSignatureIntoTransaction;
|
|
660
|
+
}
|
|
610
661
|
|
|
611
|
-
export { type APIConfig, type APICredentials, type APIEndpoints, APIService, AddressType, type ApprovalInfo, type CreateWalletOptions, type CreateWalletPayload, type CreateWalletResponse, DEFAULT_POLLER_OPTIONS, type DepositAddressResponse, Environment, EtherSigner, FystackSDK, type HMACParams, PaymentService, type PaymentServiceParams, type SDKOptions, type SignRequestParams, type SignResponse, type SignatureStatusResponse, SolanaSigner, StatusPoller, type StatusPollerOptions, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus,
|
|
662
|
+
export { type APIConfig, type APICredentials, type APIEndpoints, APIService, AddressType, type ApprovalInfo, type CreateWalletOptions, type CreateWalletPayload, type CreateWalletResponse, DEFAULT_POLLER_OPTIONS, type DepositAddressResponse, DestinationType, Environment, EtherSigner, FystackSDK, type HMACParams, PaymentService, type PaymentServiceParams, type RescanTransactionParams, type SDKOptions, type SignRequestParams, type SignResponse, type SignatureStatusResponse, SolanaSigner, StatusPoller, type StatusPollerOptions, type SweepTaskParams, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, WalletType, type WebhookEvent, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -30,7 +30,13 @@ const sdk = new FystackSDK({
|
|
|
30
30
|
|
|
31
31
|
const response = await sdk.createWallet({
|
|
32
32
|
name: 'My Blockchain Wallet',
|
|
33
|
-
walletType: WalletType.MPC // Multi-Party Computation wallet
|
|
33
|
+
walletType: WalletType.MPC, // Multi-Party Computation wallet
|
|
34
|
+
walletPurpose: WalletPurpose.User,
|
|
35
|
+
sweepTaskParams: {
|
|
36
|
+
minTriggerValueUsd: 100,
|
|
37
|
+
destinationWalletId: '0e123131211323xx1213',
|
|
38
|
+
destinationType: DestinationType.InternalWallet
|
|
39
|
+
}
|
|
34
40
|
})
|
|
35
41
|
|
|
36
42
|
console.log('Wallet ID:', response.wallet_id)
|