@fystack/sdk 0.1.2 → 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 +111 -54
- package/dist/index.d.cts +318 -269
- package/dist/index.d.mts +318 -269
- package/dist/index.esm.d.ts +318 -269
- package/dist/index.esm.js +111 -55
- package/dist/index.mjs +111 -55
- package/dist/types/index.d.ts +318 -269
- package/package.json +1 -1
- package/readme.md +7 -1
- package/src/api.ts +42 -13
- 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 +4 -3
- package/src/solanaSigner.ts +4 -3
- package/src/types.ts +11 -30
- package/test.js +0 -76
package/dist/types/index.d.ts
CHANGED
|
@@ -1,146 +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
|
-
authToken?: string;
|
|
27
|
-
}
|
|
28
|
-
interface WebhookEvent {
|
|
29
|
-
webhook_id: string;
|
|
30
|
-
resource_id: string;
|
|
31
|
-
url: string;
|
|
32
|
-
payload: any;
|
|
33
|
-
event: string;
|
|
34
|
-
}
|
|
35
|
-
interface SignRequestParams {
|
|
36
|
-
method: string;
|
|
37
|
-
message: string;
|
|
38
|
-
chain_id: number;
|
|
39
|
-
typed_data?: string;
|
|
40
|
-
}
|
|
41
|
-
interface SignResponse {
|
|
42
|
-
transaction_id: string;
|
|
43
|
-
}
|
|
44
|
-
interface SignatureStatusResponse {
|
|
45
|
-
status: TxStatus;
|
|
46
|
-
signature?: string;
|
|
47
|
-
transaction_id: string;
|
|
48
|
-
created_at: string;
|
|
49
|
-
updated_at: string;
|
|
50
|
-
approvals: Array<{
|
|
51
|
-
user_id: string;
|
|
52
|
-
status: TxApprovalStatus;
|
|
53
|
-
}>;
|
|
54
|
-
}
|
|
55
|
-
interface ApprovalInfo {
|
|
56
|
-
user_id: string;
|
|
57
|
-
status: TxApprovalStatus;
|
|
58
|
-
}
|
|
59
|
-
interface TransactionStatusResponse {
|
|
60
|
-
transaction_id: string;
|
|
61
|
-
status: TxStatus;
|
|
62
|
-
method: string;
|
|
63
|
-
hash?: string;
|
|
64
|
-
created_at: string;
|
|
65
|
-
updated_at: string;
|
|
66
|
-
approvals: ApprovalInfo[];
|
|
67
|
-
failed_reason?: string;
|
|
68
|
-
}
|
|
69
|
-
declare enum WalletType {
|
|
70
|
-
Standard = "standard",
|
|
71
|
-
MPC = "mpc"
|
|
72
|
-
}
|
|
73
|
-
interface CreateWalletOptions {
|
|
74
|
-
name: string;
|
|
75
|
-
walletType: WalletType;
|
|
76
|
-
}
|
|
77
|
-
declare enum WalletCreationStatus {
|
|
78
|
-
Pending = "pending",
|
|
79
|
-
Success = "success",
|
|
80
|
-
Error = "error"
|
|
81
|
-
}
|
|
82
|
-
interface CreateWalletResponse {
|
|
83
|
-
wallet_id: string;
|
|
84
|
-
status: WalletCreationStatus;
|
|
85
|
-
}
|
|
86
|
-
interface WalletCreationStatusResponse {
|
|
87
|
-
wallet_id: string;
|
|
88
|
-
status: WalletCreationStatus;
|
|
89
|
-
}
|
|
90
|
-
interface WalletAssetNetwork {
|
|
91
|
-
id: string;
|
|
92
|
-
created_at: string;
|
|
93
|
-
updated_at: string;
|
|
94
|
-
name: string;
|
|
95
|
-
description?: string;
|
|
96
|
-
is_evm: boolean;
|
|
97
|
-
chain_id: number;
|
|
98
|
-
native_currency: string;
|
|
99
|
-
is_testnet?: boolean;
|
|
100
|
-
internal_code: string;
|
|
101
|
-
explorer_tx: string;
|
|
102
|
-
explorer_address: string;
|
|
103
|
-
explorer_token: string;
|
|
104
|
-
confirmation_blocks: number;
|
|
105
|
-
block_interval_in_seconds: number;
|
|
106
|
-
disabled: boolean;
|
|
107
|
-
logo_url: string;
|
|
108
|
-
}
|
|
109
|
-
interface WalletAssetDetail {
|
|
110
|
-
id: string;
|
|
111
|
-
created_at: string;
|
|
112
|
-
updated_at: string;
|
|
113
|
-
name: string;
|
|
114
|
-
symbol: string;
|
|
115
|
-
decimals: number;
|
|
116
|
-
logo_url: string;
|
|
117
|
-
is_native: boolean;
|
|
118
|
-
address_type: string;
|
|
119
|
-
is_whitelisted: boolean;
|
|
120
|
-
address?: string;
|
|
121
|
-
network_id: string;
|
|
122
|
-
network?: WalletAssetNetwork;
|
|
123
|
-
}
|
|
124
|
-
interface WalletAsset {
|
|
125
|
-
id: string;
|
|
126
|
-
created_at: string;
|
|
127
|
-
updated_at: string;
|
|
128
|
-
wallet_id: string;
|
|
129
|
-
asset_id: string;
|
|
130
|
-
deposit_address: string;
|
|
131
|
-
hidden: boolean;
|
|
132
|
-
asset: WalletAssetDetail;
|
|
133
|
-
}
|
|
134
|
-
declare enum AddressType {
|
|
135
|
-
Evm = "evm",
|
|
136
|
-
Solana = "sol"
|
|
137
|
-
}
|
|
138
|
-
interface DepositAddressResponse {
|
|
139
|
-
asset_id?: string;
|
|
140
|
-
address: string;
|
|
141
|
-
qr_code: string;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
4
|
declare enum Environment {
|
|
145
5
|
Local = "local",
|
|
146
6
|
Sandbox = "sandbox",
|
|
@@ -160,6 +20,7 @@ interface APIEndpoints {
|
|
|
160
20
|
getWalletCreationStatus: (walletId: string) => string;
|
|
161
21
|
getWalletAssets: (walletId: string) => string;
|
|
162
22
|
getDepositAddress: (walletId: string, addressType: string) => string;
|
|
23
|
+
rescanTransaction: () => string;
|
|
163
24
|
}
|
|
164
25
|
interface APIConfig {
|
|
165
26
|
baseURL: string;
|
|
@@ -167,129 +28,6 @@ interface APIConfig {
|
|
|
167
28
|
}
|
|
168
29
|
declare const createAPI: (env: Environment) => APIConfig;
|
|
169
30
|
|
|
170
|
-
interface SDKOptions {
|
|
171
|
-
credentials: APICredentials;
|
|
172
|
-
environment?: Environment;
|
|
173
|
-
logger?: boolean;
|
|
174
|
-
}
|
|
175
|
-
declare class FystackSDK {
|
|
176
|
-
private apiService;
|
|
177
|
-
private enableLogging;
|
|
178
|
-
constructor(options: SDKOptions);
|
|
179
|
-
private log;
|
|
180
|
-
/**
|
|
181
|
-
* Creates a new wallet
|
|
182
|
-
* @param options Wallet creation options
|
|
183
|
-
* @param waitForCompletion Whether to wait for the wallet creation to complete
|
|
184
|
-
* @returns Promise with wallet ID and status
|
|
185
|
-
*/
|
|
186
|
-
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
187
|
-
/**
|
|
188
|
-
* Gets the current status of a wallet creation process
|
|
189
|
-
* @param walletId The ID of the wallet being created
|
|
190
|
-
* @returns Promise with wallet creation status details
|
|
191
|
-
*/
|
|
192
|
-
getWalletCreationStatus(walletId: string): Promise<WalletCreationStatusResponse>;
|
|
193
|
-
/**
|
|
194
|
-
* Waits for a wallet to be created and returns the final status
|
|
195
|
-
* @param walletId The ID of the wallet being created
|
|
196
|
-
* @returns Promise with wallet ID and final status
|
|
197
|
-
*/
|
|
198
|
-
private waitForWalletCreation;
|
|
199
|
-
/**
|
|
200
|
-
* Gets assets associated with a wallet
|
|
201
|
-
* @param walletId The ID of the wallet
|
|
202
|
-
* @returns Promise with wallet assets
|
|
203
|
-
*/
|
|
204
|
-
getWalletAssets(walletId: string): Promise<WalletAsset[]>;
|
|
205
|
-
/**
|
|
206
|
-
* Gets deposit address for a wallet by address type
|
|
207
|
-
* @param walletId The wallet ID
|
|
208
|
-
* @param addressType The type of address (evm, sol)
|
|
209
|
-
* @returns Promise with deposit address information
|
|
210
|
-
*/
|
|
211
|
-
getDepositAddress(walletId: string, addressType: AddressType): Promise<DepositAddressResponse>;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
interface StatusPollerOptions {
|
|
215
|
-
maxAttempts?: number;
|
|
216
|
-
interval?: number;
|
|
217
|
-
backoffFactor?: number;
|
|
218
|
-
maxInterval?: number;
|
|
219
|
-
timeoutMs?: number;
|
|
220
|
-
}
|
|
221
|
-
declare const DEFAULT_POLLER_OPTIONS: StatusPollerOptions;
|
|
222
|
-
declare class StatusPoller {
|
|
223
|
-
private startTime;
|
|
224
|
-
private attempts;
|
|
225
|
-
private currentInterval;
|
|
226
|
-
private readonly options;
|
|
227
|
-
constructor(options?: StatusPollerOptions);
|
|
228
|
-
private wait;
|
|
229
|
-
private shouldContinue;
|
|
230
|
-
poll<T>(pollingFn: () => Promise<T>, successCondition: (result: T) => boolean, errorCondition?: (result: T) => boolean | void): Promise<T>;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
declare class EtherSigner extends AbstractSigner {
|
|
234
|
-
private address;
|
|
235
|
-
private APICredentials;
|
|
236
|
-
private APIService;
|
|
237
|
-
private walletDetail;
|
|
238
|
-
private environment;
|
|
239
|
-
private pollerOptions?;
|
|
240
|
-
constructor(credentials: APICredentials, environment: Environment, provider?: null | Provider, pollerOptions?: StatusPollerOptions);
|
|
241
|
-
setWallet(walletId: string): void;
|
|
242
|
-
getAddress(): Promise<string>;
|
|
243
|
-
private getChainId;
|
|
244
|
-
connect(provider: null | Provider): EtherSigner;
|
|
245
|
-
private waitForSignature;
|
|
246
|
-
private waitForTransactonStatus;
|
|
247
|
-
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
248
|
-
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
|
249
|
-
signMessage(message: string | Uint8Array): Promise<string>;
|
|
250
|
-
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
declare class SolanaSigner {
|
|
254
|
-
private address;
|
|
255
|
-
private APIService;
|
|
256
|
-
private APIKey;
|
|
257
|
-
private walletDetail;
|
|
258
|
-
private pollerOptions?;
|
|
259
|
-
private APICredentials;
|
|
260
|
-
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
261
|
-
setWallet(walletId: string): void;
|
|
262
|
-
getAddress(): Promise<string>;
|
|
263
|
-
private waitForTransactionStatus;
|
|
264
|
-
/**
|
|
265
|
-
* Signs a Solana transaction
|
|
266
|
-
* @param transaction Base64 encoded serialized transaction
|
|
267
|
-
* @returns Signature as a base58 encoded string
|
|
268
|
-
*/
|
|
269
|
-
signTransaction(transaction: string): Promise<string>;
|
|
270
|
-
/**
|
|
271
|
-
* Signs a Solana message
|
|
272
|
-
* @param message The message to sign (string or Uint8Array)
|
|
273
|
-
* @returns Signature as a base58 encoded string
|
|
274
|
-
*/
|
|
275
|
-
signMessage(message: string | Uint8Array): Promise<string>;
|
|
276
|
-
/**
|
|
277
|
-
* Signs and sends a Solana transaction
|
|
278
|
-
* @param transaction Base64 encoded serialized transaction
|
|
279
|
-
* @returns Transaction signature
|
|
280
|
-
*/
|
|
281
|
-
signAndSendTransaction(transaction: string): Promise<string>;
|
|
282
|
-
/**
|
|
283
|
-
* Signs multiple Solana transactions
|
|
284
|
-
* @param transactions Array of base64 encoded serialized transactions
|
|
285
|
-
* @returns Array of signatures as base58 encoded strings
|
|
286
|
-
*/
|
|
287
|
-
signAllTransactions(transactions: string[]): Promise<{
|
|
288
|
-
transactions: string[];
|
|
289
|
-
}>;
|
|
290
|
-
private incorporateSignatureIntoTransaction;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
31
|
interface Network {
|
|
294
32
|
id: string;
|
|
295
33
|
created_at: string;
|
|
@@ -536,6 +274,46 @@ interface GetCheckoutPaymentResponse {
|
|
|
536
274
|
deposit_qr: string;
|
|
537
275
|
}
|
|
538
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
|
+
|
|
539
317
|
interface APIResponse {
|
|
540
318
|
data: any;
|
|
541
319
|
success: boolean;
|
|
@@ -554,24 +332,28 @@ interface WalletDetail {
|
|
|
554
332
|
AddressType: string;
|
|
555
333
|
Address: string;
|
|
556
334
|
}
|
|
335
|
+
interface SweepTaskParams {
|
|
336
|
+
minTriggerValueUsd: number;
|
|
337
|
+
destinationWalletId: string;
|
|
338
|
+
destinationType: DestinationType;
|
|
339
|
+
}
|
|
557
340
|
interface CreateWalletPayload {
|
|
558
341
|
name: string;
|
|
559
342
|
walletType: WalletType;
|
|
343
|
+
walletPurpose?: WalletPurpose;
|
|
344
|
+
sweepTaskParams?: SweepTaskParams;
|
|
345
|
+
sweepTaskId?: string;
|
|
560
346
|
}
|
|
561
347
|
interface PaymentServiceParams {
|
|
562
348
|
apiKey: string;
|
|
563
349
|
environment: Environment;
|
|
564
350
|
}
|
|
565
|
-
declare enum WalletAddressType {
|
|
566
|
-
Evm = "evm",
|
|
567
|
-
Sol = "sol"
|
|
568
|
-
}
|
|
569
351
|
declare class APIService {
|
|
570
352
|
private credentials;
|
|
571
353
|
Webhook: WebhookService;
|
|
572
354
|
private API;
|
|
573
355
|
constructor(credentials: APICredentials, environment: Environment);
|
|
574
|
-
getWalletDetail(addressType?:
|
|
356
|
+
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
575
357
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
576
358
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
577
359
|
signTransaction(walletId: string, body: Record<string, any>): Promise<SignResponse>;
|
|
@@ -587,6 +369,12 @@ declare class APIService {
|
|
|
587
369
|
* @returns Deposit address response
|
|
588
370
|
*/
|
|
589
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>;
|
|
590
378
|
}
|
|
591
379
|
declare class PaymentService {
|
|
592
380
|
private apiKey;
|
|
@@ -606,8 +394,269 @@ declare function get(endpoint: string, headers?: Record<string, string>): Promis
|
|
|
606
394
|
declare function post(endpoint: string, body: any, headers?: Record<string, string>): Promise<APIResponse>;
|
|
607
395
|
declare function transformWalletDetail(data: Record<string, string>): WalletDetail;
|
|
608
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;
|
|
609
404
|
name: string;
|
|
610
405
|
wallet_type: WalletType;
|
|
611
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
|
+
}
|
|
612
661
|
|
|
613
|
-
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)
|