@fystack/sdk 0.1.2 → 0.1.4
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 +145 -55
- package/dist/index.d.cts +352 -270
- package/dist/index.d.mts +352 -270
- package/dist/index.esm.d.ts +352 -270
- package/dist/index.esm.js +145 -56
- package/dist/index.mjs +145 -56
- package/dist/types/index.d.ts +352 -270
- package/package.json +1 -1
- package/readme.md +7 -1
- package/src/api.ts +50 -13
- package/src/config.ts +6 -2
- package/src/enum.ts +52 -0
- package/src/index.ts +1 -0
- package/src/sdk.ts +54 -8
- package/src/signer.ts +16 -3
- package/src/solanaSigner.ts +4 -3
- package/src/types.ts +33 -30
- package/test.js +0 -76
package/dist/index.d.cts
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",
|
|
@@ -152,6 +12,7 @@ interface APIEndpoints {
|
|
|
152
12
|
getSignStatus: (walletId: string, transactionId: string) => string;
|
|
153
13
|
getTransactionStatus: (walletId: string, transactionId: string) => string;
|
|
154
14
|
getWalletDetail: (walletId?: string) => string;
|
|
15
|
+
getWallets: (workspaceId: string) => string;
|
|
155
16
|
createWallet: () => string;
|
|
156
17
|
createCheckout: () => string;
|
|
157
18
|
getCheckout: (checkoutId: string) => string;
|
|
@@ -160,6 +21,7 @@ interface APIEndpoints {
|
|
|
160
21
|
getWalletCreationStatus: (walletId: string) => string;
|
|
161
22
|
getWalletAssets: (walletId: string) => string;
|
|
162
23
|
getDepositAddress: (walletId: string, addressType: string) => string;
|
|
24
|
+
rescanTransaction: () => string;
|
|
163
25
|
}
|
|
164
26
|
interface APIConfig {
|
|
165
27
|
baseURL: string;
|
|
@@ -167,129 +29,6 @@ interface APIConfig {
|
|
|
167
29
|
}
|
|
168
30
|
declare const createAPI: (env: Environment) => APIConfig;
|
|
169
31
|
|
|
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
32
|
interface Network {
|
|
294
33
|
id: string;
|
|
295
34
|
created_at: string;
|
|
@@ -536,6 +275,51 @@ interface GetCheckoutPaymentResponse {
|
|
|
536
275
|
deposit_qr: string;
|
|
537
276
|
}
|
|
538
277
|
|
|
278
|
+
declare enum WalletType {
|
|
279
|
+
Standard = "standard",
|
|
280
|
+
MPC = "mpc"
|
|
281
|
+
}
|
|
282
|
+
declare enum WalletPurpose {
|
|
283
|
+
General = "general",
|
|
284
|
+
Gastank = "gas_tank",
|
|
285
|
+
Deployment = "deployment",
|
|
286
|
+
Custody = "custody",
|
|
287
|
+
User = "user",
|
|
288
|
+
Payment = "payment"
|
|
289
|
+
}
|
|
290
|
+
declare enum WalletCreationStatus {
|
|
291
|
+
Pending = "pending",
|
|
292
|
+
Success = "success",
|
|
293
|
+
Error = "error"
|
|
294
|
+
}
|
|
295
|
+
declare enum AddressType {
|
|
296
|
+
Evm = "evm",
|
|
297
|
+
Solana = "sol",
|
|
298
|
+
Tron = "tron"
|
|
299
|
+
}
|
|
300
|
+
declare enum DestinationType {
|
|
301
|
+
InternalWallet = "internal_wallet",
|
|
302
|
+
AddressBook = "address_book"
|
|
303
|
+
}
|
|
304
|
+
declare enum TxStatus {
|
|
305
|
+
Pending = "pending",
|
|
306
|
+
Completed = "completed",
|
|
307
|
+
Confirmed = "confirmed",
|
|
308
|
+
Failed = "failed",
|
|
309
|
+
PendingApproval = "pending_approval",
|
|
310
|
+
Rejected = "rejected"
|
|
311
|
+
}
|
|
312
|
+
declare enum TxApprovalStatus {
|
|
313
|
+
Pending = "pending",
|
|
314
|
+
Approved = "approved",
|
|
315
|
+
Rejected = "rejected"
|
|
316
|
+
}
|
|
317
|
+
declare enum WalletRole {
|
|
318
|
+
Admin = "wallet_admin",
|
|
319
|
+
Signer = "wallet_signer",
|
|
320
|
+
Viewer = "wallet_viewer"
|
|
321
|
+
}
|
|
322
|
+
|
|
539
323
|
interface APIResponse {
|
|
540
324
|
data: any;
|
|
541
325
|
success: boolean;
|
|
@@ -554,24 +338,29 @@ interface WalletDetail {
|
|
|
554
338
|
AddressType: string;
|
|
555
339
|
Address: string;
|
|
556
340
|
}
|
|
341
|
+
interface SweepTaskParams {
|
|
342
|
+
minTriggerValueUsd: number;
|
|
343
|
+
destinationWalletId: string;
|
|
344
|
+
destinationType: DestinationType;
|
|
345
|
+
}
|
|
557
346
|
interface CreateWalletPayload {
|
|
558
347
|
name: string;
|
|
559
348
|
walletType: WalletType;
|
|
349
|
+
walletPurpose?: WalletPurpose;
|
|
350
|
+
sweepTaskParams?: SweepTaskParams;
|
|
351
|
+
sweepTaskId?: string;
|
|
560
352
|
}
|
|
561
353
|
interface PaymentServiceParams {
|
|
562
354
|
apiKey: string;
|
|
563
|
-
environment: Environment;
|
|
564
|
-
}
|
|
565
|
-
declare enum WalletAddressType {
|
|
566
|
-
Evm = "evm",
|
|
567
|
-
Sol = "sol"
|
|
355
|
+
environment: Environment;
|
|
568
356
|
}
|
|
569
357
|
declare class APIService {
|
|
570
358
|
private credentials;
|
|
571
359
|
Webhook: WebhookService;
|
|
572
360
|
private API;
|
|
573
361
|
constructor(credentials: APICredentials, environment: Environment);
|
|
574
|
-
|
|
362
|
+
getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
|
|
363
|
+
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
575
364
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
576
365
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
577
366
|
signTransaction(walletId: string, body: Record<string, any>): Promise<SignResponse>;
|
|
@@ -587,6 +376,12 @@ declare class APIService {
|
|
|
587
376
|
* @returns Deposit address response
|
|
588
377
|
*/
|
|
589
378
|
getDepositAddress(walletId: string, addressType: AddressType): Promise<DepositAddressResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Rescans a transaction on a specific network
|
|
381
|
+
* @param params Transaction hash and network ID
|
|
382
|
+
* @returns API response
|
|
383
|
+
*/
|
|
384
|
+
rescanTransaction(params: RescanTransactionParams): Promise<void>;
|
|
590
385
|
}
|
|
591
386
|
declare class PaymentService {
|
|
592
387
|
private apiKey;
|
|
@@ -606,8 +401,295 @@ declare function get(endpoint: string, headers?: Record<string, string>): Promis
|
|
|
606
401
|
declare function post(endpoint: string, body: any, headers?: Record<string, string>): Promise<APIResponse>;
|
|
607
402
|
declare function transformWalletDetail(data: Record<string, string>): WalletDetail;
|
|
608
403
|
declare function transformCreateWalletPayload(data: CreateWalletPayload): {
|
|
404
|
+
sweep_task_id?: string | undefined;
|
|
405
|
+
sweep_task_params?: {
|
|
406
|
+
min_trigger_value_usd: number;
|
|
407
|
+
destination_wallet_id: string;
|
|
408
|
+
destination_type: DestinationType;
|
|
409
|
+
} | undefined;
|
|
410
|
+
wallet_purpose?: WalletPurpose | undefined;
|
|
609
411
|
name: string;
|
|
610
412
|
wallet_type: WalletType;
|
|
611
413
|
};
|
|
414
|
+
declare function transformRescanTransactionParams(data: RescanTransactionParams): {
|
|
415
|
+
tx_hash: string;
|
|
416
|
+
network_id: string;
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
declare class TransactionError extends Error {
|
|
420
|
+
readonly code: string;
|
|
421
|
+
readonly transactionId?: string | undefined;
|
|
422
|
+
readonly originalError?: Error | undefined;
|
|
423
|
+
constructor(message: string, code: string, transactionId?: string | undefined, originalError?: Error | undefined);
|
|
424
|
+
}
|
|
425
|
+
interface APICredentials {
|
|
426
|
+
apiKey: string;
|
|
427
|
+
apiSecret: string;
|
|
428
|
+
authToken?: string;
|
|
429
|
+
}
|
|
430
|
+
interface WebhookEvent {
|
|
431
|
+
webhook_id: string;
|
|
432
|
+
resource_id: string;
|
|
433
|
+
url: string;
|
|
434
|
+
payload: any;
|
|
435
|
+
event: string;
|
|
436
|
+
}
|
|
437
|
+
interface SignRequestParams {
|
|
438
|
+
method: string;
|
|
439
|
+
message: string;
|
|
440
|
+
chain_id: number;
|
|
441
|
+
typed_data?: string;
|
|
442
|
+
}
|
|
443
|
+
interface SignResponse {
|
|
444
|
+
transaction_id: string;
|
|
445
|
+
}
|
|
446
|
+
interface SignatureStatusResponse {
|
|
447
|
+
status: TxStatus;
|
|
448
|
+
signature?: string;
|
|
449
|
+
transaction_id: string;
|
|
450
|
+
created_at: string;
|
|
451
|
+
updated_at: string;
|
|
452
|
+
approvals: Array<{
|
|
453
|
+
user_id: string;
|
|
454
|
+
status: TxApprovalStatus;
|
|
455
|
+
}>;
|
|
456
|
+
}
|
|
457
|
+
interface ApprovalInfo {
|
|
458
|
+
user_id: string;
|
|
459
|
+
status: TxApprovalStatus;
|
|
460
|
+
}
|
|
461
|
+
interface TransactionStatusResponse {
|
|
462
|
+
transaction_id: string;
|
|
463
|
+
status: TxStatus;
|
|
464
|
+
method: string;
|
|
465
|
+
hash?: string;
|
|
466
|
+
created_at: string;
|
|
467
|
+
updated_at: string;
|
|
468
|
+
approvals: ApprovalInfo[];
|
|
469
|
+
failed_reason?: string;
|
|
470
|
+
}
|
|
471
|
+
interface CreateWalletOptions {
|
|
472
|
+
name: string;
|
|
473
|
+
walletType: WalletType;
|
|
474
|
+
walletPurpose?: WalletPurpose;
|
|
475
|
+
sweepTaskParams?: SweepTaskParams;
|
|
476
|
+
sweepTaskId?: string;
|
|
477
|
+
}
|
|
478
|
+
interface CreateWalletResponse {
|
|
479
|
+
wallet_id: string;
|
|
480
|
+
status: WalletCreationStatus;
|
|
481
|
+
}
|
|
482
|
+
interface WalletCreationStatusResponse {
|
|
483
|
+
wallet_id: string;
|
|
484
|
+
status: WalletCreationStatus;
|
|
485
|
+
}
|
|
486
|
+
interface WalletAssetNetwork {
|
|
487
|
+
id: string;
|
|
488
|
+
created_at: string;
|
|
489
|
+
updated_at: string;
|
|
490
|
+
name: string;
|
|
491
|
+
description?: string;
|
|
492
|
+
is_evm: boolean;
|
|
493
|
+
chain_id: number;
|
|
494
|
+
native_currency: string;
|
|
495
|
+
is_testnet?: boolean;
|
|
496
|
+
internal_code: string;
|
|
497
|
+
explorer_tx: string;
|
|
498
|
+
explorer_address: string;
|
|
499
|
+
explorer_token: string;
|
|
500
|
+
confirmation_blocks: number;
|
|
501
|
+
block_interval_in_seconds: number;
|
|
502
|
+
disabled: boolean;
|
|
503
|
+
logo_url: string;
|
|
504
|
+
}
|
|
505
|
+
interface WalletAssetDetail {
|
|
506
|
+
id: string;
|
|
507
|
+
created_at: string;
|
|
508
|
+
updated_at: string;
|
|
509
|
+
name: string;
|
|
510
|
+
symbol: string;
|
|
511
|
+
decimals: number;
|
|
512
|
+
logo_url: string;
|
|
513
|
+
is_native: boolean;
|
|
514
|
+
address_type: string;
|
|
515
|
+
is_whitelisted: boolean;
|
|
516
|
+
address?: string;
|
|
517
|
+
network_id: string;
|
|
518
|
+
network?: WalletAssetNetwork;
|
|
519
|
+
}
|
|
520
|
+
interface WalletAsset {
|
|
521
|
+
id: string;
|
|
522
|
+
created_at: string;
|
|
523
|
+
updated_at: string;
|
|
524
|
+
wallet_id: string;
|
|
525
|
+
asset_id: string;
|
|
526
|
+
deposit_address: string;
|
|
527
|
+
hidden: boolean;
|
|
528
|
+
asset: WalletAssetDetail;
|
|
529
|
+
}
|
|
530
|
+
interface DepositAddressResponse {
|
|
531
|
+
asset_id?: string;
|
|
532
|
+
address: string;
|
|
533
|
+
qr_code: string;
|
|
534
|
+
}
|
|
535
|
+
interface RescanTransactionParams {
|
|
536
|
+
txHash: string;
|
|
537
|
+
networkId: string;
|
|
538
|
+
}
|
|
539
|
+
interface WalletResponse {
|
|
540
|
+
id: string;
|
|
541
|
+
name: string;
|
|
542
|
+
value_usd: string;
|
|
543
|
+
role: WalletRole;
|
|
544
|
+
}
|
|
545
|
+
interface TopAssets {
|
|
546
|
+
symbol: string;
|
|
547
|
+
logo_url: string;
|
|
548
|
+
}
|
|
549
|
+
interface WalletByWorkspaceResponse {
|
|
550
|
+
id: string;
|
|
551
|
+
name: string;
|
|
552
|
+
role: string;
|
|
553
|
+
wallet_type: string;
|
|
554
|
+
value_usd: string;
|
|
555
|
+
top_assets: TopAssets[];
|
|
556
|
+
wallet_purpose: string;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
interface SDKOptions {
|
|
560
|
+
credentials: APICredentials;
|
|
561
|
+
workspaceId?: string;
|
|
562
|
+
environment?: Environment;
|
|
563
|
+
logger?: boolean;
|
|
564
|
+
}
|
|
565
|
+
declare class FystackSDK {
|
|
566
|
+
private apiService;
|
|
567
|
+
private enableLogging;
|
|
568
|
+
private workspaceId?;
|
|
569
|
+
constructor(options: SDKOptions);
|
|
570
|
+
private log;
|
|
571
|
+
/**
|
|
572
|
+
* Creates a new wallet
|
|
573
|
+
* @param options Wallet creation options
|
|
574
|
+
* @param waitForCompletion Whether to wait for the wallet creation to complete
|
|
575
|
+
* @returns Promise with wallet ID and status
|
|
576
|
+
*/
|
|
577
|
+
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
578
|
+
/**
|
|
579
|
+
* Gets all wallets for the workspace
|
|
580
|
+
* @returns Promise with list of wallets
|
|
581
|
+
*/
|
|
582
|
+
getWallets(): Promise<WalletByWorkspaceResponse[]>;
|
|
583
|
+
/**
|
|
584
|
+
* Gets the current status of a wallet creation process
|
|
585
|
+
* @param walletId The ID of the wallet being created
|
|
586
|
+
* @returns Promise with wallet creation status details
|
|
587
|
+
*/
|
|
588
|
+
getWalletCreationStatus(walletId: string): Promise<WalletCreationStatusResponse>;
|
|
589
|
+
/**
|
|
590
|
+
* Waits for a wallet to be created and returns the final status
|
|
591
|
+
* @param walletId The ID of the wallet being created
|
|
592
|
+
* @returns Promise with wallet ID and final status
|
|
593
|
+
*/
|
|
594
|
+
private waitForWalletCreation;
|
|
595
|
+
/**
|
|
596
|
+
* Gets assets associated with a wallet
|
|
597
|
+
* @param walletId The ID of the wallet
|
|
598
|
+
* @returns Promise with wallet assets
|
|
599
|
+
*/
|
|
600
|
+
getWalletAssets(walletId: string): Promise<WalletAsset[]>;
|
|
601
|
+
/**
|
|
602
|
+
* Gets deposit address for a wallet by address type
|
|
603
|
+
* @param walletId The wallet ID
|
|
604
|
+
* @param addressType The type of address (evm, sol)
|
|
605
|
+
* @returns Promise with deposit address information
|
|
606
|
+
*/
|
|
607
|
+
getDepositAddress(walletId: string, addressType: AddressType): Promise<DepositAddressResponse>;
|
|
608
|
+
/**
|
|
609
|
+
* Rescans a transaction on a specific network
|
|
610
|
+
* @param params Transaction hash and network ID
|
|
611
|
+
* @returns Promise that resolves when the rescan is initiated
|
|
612
|
+
*/
|
|
613
|
+
rescanTransaction(params: RescanTransactionParams): Promise<void>;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
interface StatusPollerOptions {
|
|
617
|
+
maxAttempts?: number;
|
|
618
|
+
interval?: number;
|
|
619
|
+
backoffFactor?: number;
|
|
620
|
+
maxInterval?: number;
|
|
621
|
+
timeoutMs?: number;
|
|
622
|
+
}
|
|
623
|
+
declare const DEFAULT_POLLER_OPTIONS: StatusPollerOptions;
|
|
624
|
+
declare class StatusPoller {
|
|
625
|
+
private startTime;
|
|
626
|
+
private attempts;
|
|
627
|
+
private currentInterval;
|
|
628
|
+
private readonly options;
|
|
629
|
+
constructor(options?: StatusPollerOptions);
|
|
630
|
+
private wait;
|
|
631
|
+
private shouldContinue;
|
|
632
|
+
poll<T>(pollingFn: () => Promise<T>, successCondition: (result: T) => boolean, errorCondition?: (result: T) => boolean | void): Promise<T>;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
declare class EtherSigner extends AbstractSigner {
|
|
636
|
+
private address;
|
|
637
|
+
private APICredentials;
|
|
638
|
+
private APIService;
|
|
639
|
+
private walletDetail;
|
|
640
|
+
private environment;
|
|
641
|
+
private pollerOptions?;
|
|
642
|
+
constructor(credentials: APICredentials, environment: Environment, provider?: null | Provider, pollerOptions?: StatusPollerOptions);
|
|
643
|
+
setWallet(walletId: string): void;
|
|
644
|
+
getAddress(): Promise<string>;
|
|
645
|
+
private getChainId;
|
|
646
|
+
connect(provider: null | Provider): EtherSigner;
|
|
647
|
+
private waitForSignature;
|
|
648
|
+
private waitForTransactonStatus;
|
|
649
|
+
signTransaction(tx: TransactionRequest): Promise<string>;
|
|
650
|
+
sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>;
|
|
651
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
652
|
+
signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>): Promise<string>;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
declare class SolanaSigner {
|
|
656
|
+
private address;
|
|
657
|
+
private APIService;
|
|
658
|
+
private APIKey;
|
|
659
|
+
private walletDetail;
|
|
660
|
+
private pollerOptions?;
|
|
661
|
+
private APICredentials;
|
|
662
|
+
constructor(credentials: APICredentials, environment: Environment, pollerOptions?: StatusPollerOptions);
|
|
663
|
+
setWallet(walletId: string): void;
|
|
664
|
+
getAddress(): Promise<string>;
|
|
665
|
+
private waitForTransactionStatus;
|
|
666
|
+
/**
|
|
667
|
+
* Signs a Solana transaction
|
|
668
|
+
* @param transaction Base64 encoded serialized transaction
|
|
669
|
+
* @returns Signature as a base58 encoded string
|
|
670
|
+
*/
|
|
671
|
+
signTransaction(transaction: string): Promise<string>;
|
|
672
|
+
/**
|
|
673
|
+
* Signs a Solana message
|
|
674
|
+
* @param message The message to sign (string or Uint8Array)
|
|
675
|
+
* @returns Signature as a base58 encoded string
|
|
676
|
+
*/
|
|
677
|
+
signMessage(message: string | Uint8Array): Promise<string>;
|
|
678
|
+
/**
|
|
679
|
+
* Signs and sends a Solana transaction
|
|
680
|
+
* @param transaction Base64 encoded serialized transaction
|
|
681
|
+
* @returns Transaction signature
|
|
682
|
+
*/
|
|
683
|
+
signAndSendTransaction(transaction: string): Promise<string>;
|
|
684
|
+
/**
|
|
685
|
+
* Signs multiple Solana transactions
|
|
686
|
+
* @param transactions Array of base64 encoded serialized transactions
|
|
687
|
+
* @returns Array of signatures as base58 encoded strings
|
|
688
|
+
*/
|
|
689
|
+
signAllTransactions(transactions: string[]): Promise<{
|
|
690
|
+
transactions: string[];
|
|
691
|
+
}>;
|
|
692
|
+
private incorporateSignatureIntoTransaction;
|
|
693
|
+
}
|
|
612
694
|
|
|
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,
|
|
695
|
+
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, type TopAssets, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, type WalletByWorkspaceResponse, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, type WalletResponse, WalletRole, WalletType, type WebhookEvent, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|