@fystack/sdk 0.1.9 → 0.1.11

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.d.cts CHANGED
@@ -1,6 +1,71 @@
1
1
  import { AbstractSigner, Provider, TransactionResponse, TypedDataDomain, TypedDataField } from 'ethers';
2
2
  import { TransactionRequest } from 'ethers/src.ts/providers';
3
3
 
4
+ declare enum WalletType {
5
+ Hyper = "standard",
6
+ MPC = "mpc"
7
+ }
8
+ declare enum WalletPurpose {
9
+ General = "general",
10
+ Gastank = "gas_tank",
11
+ Deployment = "deployment",
12
+ Custody = "custody",
13
+ User = "user",
14
+ Payment = "payment"
15
+ }
16
+ declare enum WalletCreationStatus {
17
+ Pending = "pending",
18
+ Success = "success",
19
+ Error = "error"
20
+ }
21
+ declare enum AddressType {
22
+ Evm = "evm",
23
+ Solana = "sol",
24
+ Tron = "tron"
25
+ }
26
+ declare enum DestinationType {
27
+ InternalWallet = "internal_wallet",
28
+ AddressBook = "address_book"
29
+ }
30
+ declare enum TxStatus {
31
+ Pending = "pending",
32
+ Completed = "completed",
33
+ Confirmed = "confirmed",
34
+ Failed = "failed",
35
+ PendingApproval = "pending_approval",
36
+ Rejected = "rejected"
37
+ }
38
+ declare enum TxApprovalStatus {
39
+ Pending = "pending",
40
+ Approved = "approved",
41
+ Rejected = "rejected"
42
+ }
43
+ declare enum WalletRole {
44
+ Admin = "wallet_admin",
45
+ Signer = "wallet_signer",
46
+ Viewer = "wallet_viewer"
47
+ }
48
+ declare enum WithdrawalStatus {
49
+ Pending = "pending",
50
+ PendingApproval = "pending_approval",
51
+ Approved = "approved",
52
+ Rejected = "rejected",
53
+ Processing = "processing",
54
+ Completed = "completed",
55
+ Failed = "failed"
56
+ }
57
+ declare enum SweepStrategy {
58
+ Periodic = "periodic"
59
+ }
60
+ declare enum SweepType {
61
+ Default = "default",
62
+ PaymentLink = "payment_link",
63
+ Checkout = "checkout"
64
+ }
65
+ declare enum ReserveType {
66
+ FixedUsd = "fixed_usd"
67
+ }
68
+
4
69
  declare enum Environment {
5
70
  Local = "local",
6
71
  Sandbox = "sandbox",
@@ -24,6 +89,7 @@ interface APIEndpoints {
24
89
  rescanTransaction: () => string;
25
90
  requestWithdrawal: (walletId: string) => string;
26
91
  getWebhookPublicKey: (workspaceId: string) => string;
92
+ createSweepTask: (workspaceId: string) => string;
27
93
  }
28
94
  interface APIConfig {
29
95
  baseURL: string;
@@ -31,6 +97,247 @@ interface APIConfig {
31
97
  }
32
98
  declare const createAPI: (env: Environment) => APIConfig;
33
99
 
100
+ declare class TransactionError extends Error {
101
+ readonly code: string;
102
+ readonly transactionId?: string | undefined;
103
+ readonly originalError?: Error | undefined;
104
+ constructor(message: string, code: string, transactionId?: string | undefined, originalError?: Error | undefined);
105
+ }
106
+ interface APICredentials {
107
+ apiKey: string;
108
+ apiSecret: string;
109
+ authToken?: string;
110
+ }
111
+ interface WebhookEvent {
112
+ webhook_id: string;
113
+ resource_id: string;
114
+ url: string;
115
+ payload: any;
116
+ event: string;
117
+ }
118
+ interface SignRequestParams {
119
+ method: string;
120
+ message: string;
121
+ chain_id: number;
122
+ typed_data?: string;
123
+ }
124
+ interface SignResponse {
125
+ transaction_id: string;
126
+ }
127
+ interface SignatureStatusResponse {
128
+ status: TxStatus;
129
+ signature?: string;
130
+ transaction_id: string;
131
+ created_at: string;
132
+ updated_at: string;
133
+ approvals: Array<{
134
+ user_id: string;
135
+ status: TxApprovalStatus;
136
+ }>;
137
+ }
138
+ interface ApprovalInfo {
139
+ user_id: string;
140
+ status: TxApprovalStatus;
141
+ }
142
+ interface TransactionStatusResponse {
143
+ transaction_id: string;
144
+ status: TxStatus;
145
+ method: string;
146
+ hash?: string;
147
+ created_at: string;
148
+ updated_at: string;
149
+ approvals: ApprovalInfo[];
150
+ failed_reason?: string;
151
+ }
152
+ interface CreateWalletOptions {
153
+ name: string;
154
+ walletType: WalletType;
155
+ walletPurpose?: WalletPurpose;
156
+ sweepTaskParams?: SweepTaskParams;
157
+ sweepTaskId?: string;
158
+ }
159
+ interface CreateWalletResponse {
160
+ wallet_id: string;
161
+ status: WalletCreationStatus;
162
+ }
163
+ interface WalletCreationStatusResponse {
164
+ wallet_id: string;
165
+ status: WalletCreationStatus;
166
+ }
167
+ interface WalletAssetNetwork {
168
+ id: string;
169
+ created_at: string;
170
+ updated_at: string;
171
+ name: string;
172
+ description?: string;
173
+ is_evm: boolean;
174
+ chain_id: number;
175
+ native_currency: string;
176
+ is_testnet?: boolean;
177
+ internal_code: string;
178
+ explorer_tx: string;
179
+ explorer_address: string;
180
+ explorer_token: string;
181
+ confirmation_blocks: number;
182
+ block_interval_in_seconds: number;
183
+ disabled: boolean;
184
+ logo_url: string;
185
+ }
186
+ interface WalletAssetDetail {
187
+ id: string;
188
+ created_at: string;
189
+ updated_at: string;
190
+ name: string;
191
+ symbol: string;
192
+ decimals: number;
193
+ logo_url: string;
194
+ is_native: boolean;
195
+ address_type: string;
196
+ is_whitelisted: boolean;
197
+ address?: string;
198
+ network_id: string;
199
+ network?: WalletAssetNetwork;
200
+ }
201
+ interface WalletAsset {
202
+ id: string;
203
+ created_at: string;
204
+ updated_at: string;
205
+ wallet_id: string;
206
+ asset_id: string;
207
+ deposit_address: string;
208
+ hidden: boolean;
209
+ asset: WalletAssetDetail;
210
+ }
211
+ interface DepositAddressResponse {
212
+ asset_id?: string;
213
+ address: string;
214
+ qr_code: string;
215
+ }
216
+ interface RescanTransactionParams {
217
+ txHash: string;
218
+ networkId: string;
219
+ }
220
+ interface WalletResponse {
221
+ id: string;
222
+ name: string;
223
+ value_usd: string;
224
+ role: WalletRole;
225
+ }
226
+ interface TopAssets {
227
+ symbol: string;
228
+ logo_url: string;
229
+ }
230
+ interface WalletByWorkspaceResponse {
231
+ id: string;
232
+ name: string;
233
+ role: string;
234
+ wallet_type: string;
235
+ value_usd: string;
236
+ top_assets: TopAssets[];
237
+ wallet_purpose: string;
238
+ }
239
+ interface RequestWithdrawalParams {
240
+ assetId: string;
241
+ amount: string;
242
+ recipientAddress: string;
243
+ notes?: string;
244
+ skipBalanceCheck?: boolean;
245
+ }
246
+ interface WithdrawalApproval {
247
+ id: string;
248
+ user_id: string;
249
+ status: string;
250
+ created_at: string;
251
+ updated_at: string;
252
+ }
253
+ interface WithdrawalTransaction {
254
+ id: string;
255
+ hash?: string;
256
+ status: string;
257
+ created_at: string;
258
+ updated_at: string;
259
+ }
260
+ interface TxCategory {
261
+ id: string;
262
+ name: string;
263
+ }
264
+ interface Withdrawal {
265
+ id: string;
266
+ created_at: string;
267
+ updated_at: string;
268
+ amount: string;
269
+ status: WithdrawalStatus;
270
+ recipient_address: string;
271
+ notes?: string;
272
+ withdrawal_approvals: WithdrawalApproval[];
273
+ creator_id: string;
274
+ asset_id: string;
275
+ asset?: WalletAssetDetail;
276
+ wallet_id: string;
277
+ transaction_id?: string;
278
+ transaction?: WithdrawalTransaction;
279
+ asset_hold_id: string;
280
+ error_reason?: string;
281
+ categories?: TxCategory[];
282
+ }
283
+ interface RequestWithdrawalResponse {
284
+ auto_approved: boolean;
285
+ withdrawal: Withdrawal;
286
+ }
287
+ interface WebhookPublicKeyResponse {
288
+ public_key: string;
289
+ }
290
+ interface CreateSweepTaskParams {
291
+ /** Display name for the sweep task */
292
+ name: string;
293
+ /** Sweep execution strategy */
294
+ strategy: SweepStrategy;
295
+ /** Minimum USD value in a wallet to trigger a sweep */
296
+ minTriggerValueUsd: number;
297
+ /** UUID of the destination wallet or address book record that receives swept funds */
298
+ destinationWalletId: string;
299
+ /** How often (in seconds) the sweep task checks wallet balances */
300
+ frequencyInSeconds: number;
301
+ /** List of wallet UUIDs to sweep from */
302
+ walletIds: string[];
303
+ /** Type of sweep task. Defaults to "default" */
304
+ sweepType?: SweepType;
305
+ /** Whether the destination is an internal wallet or an address book entry. Defaults to "internal_wallet" */
306
+ destinationType?: DestinationType;
307
+ /** Optional list of specific asset UUIDs to sweep. If omitted, all assets are swept */
308
+ assetIds?: string[];
309
+ /** Reserve strategy type (e.g. keep a fixed USD amount in the source wallet) */
310
+ reserveType?: ReserveType;
311
+ /** Fixed USD amount to reserve in each source wallet (used when reserveType is "fixed_usd") */
312
+ reserveAmountUsd?: number;
313
+ /** Percentage of USD value to reserve in each source wallet */
314
+ reservePercentageUsd?: number;
315
+ /** Whether the task is enabled. Defaults to true */
316
+ enabled?: boolean;
317
+ }
318
+ interface SweepTaskResponse {
319
+ id: string;
320
+ created_at: string;
321
+ updated_at: string;
322
+ name: string;
323
+ workspace_id: string;
324
+ strategy: string;
325
+ min_trigger_value_usd: string;
326
+ destination_wallet_id: string;
327
+ frequency_in_seconds: number;
328
+ gas_tank_wallet_id: string;
329
+ last_executed_at: string | null;
330
+ is_executing: boolean;
331
+ enabled: boolean;
332
+ created_by_user_id: string;
333
+ sweep_type: string;
334
+ destination_type: string;
335
+ deviation_rate: string;
336
+ reserve_type?: string;
337
+ reserve_amount_usd?: string;
338
+ reserve_percentage_usd?: string;
339
+ }
340
+
34
341
  interface Network {
35
342
  id: string;
36
343
  created_at: string;
@@ -277,60 +584,6 @@ interface GetCheckoutPaymentResponse {
277
584
  deposit_qr: string;
278
585
  }
279
586
 
280
- declare enum WalletType {
281
- Standard = "standard",
282
- MPC = "mpc"
283
- }
284
- declare enum WalletPurpose {
285
- General = "general",
286
- Gastank = "gas_tank",
287
- Deployment = "deployment",
288
- Custody = "custody",
289
- User = "user",
290
- Payment = "payment"
291
- }
292
- declare enum WalletCreationStatus {
293
- Pending = "pending",
294
- Success = "success",
295
- Error = "error"
296
- }
297
- declare enum AddressType {
298
- Evm = "evm",
299
- Solana = "sol",
300
- Tron = "tron"
301
- }
302
- declare enum DestinationType {
303
- InternalWallet = "internal_wallet",
304
- AddressBook = "address_book"
305
- }
306
- declare enum TxStatus {
307
- Pending = "pending",
308
- Completed = "completed",
309
- Confirmed = "confirmed",
310
- Failed = "failed",
311
- PendingApproval = "pending_approval",
312
- Rejected = "rejected"
313
- }
314
- declare enum TxApprovalStatus {
315
- Pending = "pending",
316
- Approved = "approved",
317
- Rejected = "rejected"
318
- }
319
- declare enum WalletRole {
320
- Admin = "wallet_admin",
321
- Signer = "wallet_signer",
322
- Viewer = "wallet_viewer"
323
- }
324
- declare enum WithdrawalStatus {
325
- Pending = "pending",
326
- PendingApproval = "pending_approval",
327
- Approved = "approved",
328
- Rejected = "rejected",
329
- Processing = "processing",
330
- Completed = "completed",
331
- Failed = "failed"
332
- }
333
-
334
587
  interface APIResponse {
335
588
  data: any;
336
589
  success: boolean;
@@ -406,6 +659,7 @@ declare class APIService {
406
659
  * @returns Webhook public key response with base64 encoded ed25519 public key
407
660
  */
408
661
  getWebhookPublicKey(workspaceId: string): Promise<WebhookPublicKeyResponse>;
662
+ createSweepTask(workspaceId: string, params: CreateSweepTaskParams): Promise<SweepTaskResponse>;
409
663
  }
410
664
  declare class PaymentService {
411
665
  private apiKey;
@@ -446,208 +700,34 @@ declare function transformRequestWithdrawalParams(data: RequestWithdrawalParams)
446
700
  amount: string;
447
701
  recipient_address: string;
448
702
  };
449
-
450
- declare class TransactionError extends Error {
451
- readonly code: string;
452
- readonly transactionId?: string | undefined;
453
- readonly originalError?: Error | undefined;
454
- constructor(message: string, code: string, transactionId?: string | undefined, originalError?: Error | undefined);
455
- }
456
- interface APICredentials {
457
- apiKey: string;
458
- apiSecret: string;
459
- authToken?: string;
460
- }
461
- interface WebhookEvent {
462
- webhook_id: string;
463
- resource_id: string;
464
- url: string;
465
- payload: any;
466
- event: string;
467
- }
468
- interface SignRequestParams {
469
- method: string;
470
- message: string;
471
- chain_id: number;
472
- typed_data?: string;
473
- }
474
- interface SignResponse {
475
- transaction_id: string;
476
- }
477
- interface SignatureStatusResponse {
478
- status: TxStatus;
479
- signature?: string;
480
- transaction_id: string;
481
- created_at: string;
482
- updated_at: string;
483
- approvals: Array<{
484
- user_id: string;
485
- status: TxApprovalStatus;
486
- }>;
487
- }
488
- interface ApprovalInfo {
489
- user_id: string;
490
- status: TxApprovalStatus;
491
- }
492
- interface TransactionStatusResponse {
493
- transaction_id: string;
494
- status: TxStatus;
495
- method: string;
496
- hash?: string;
497
- created_at: string;
498
- updated_at: string;
499
- approvals: ApprovalInfo[];
500
- failed_reason?: string;
501
- }
502
- interface CreateWalletOptions {
703
+ declare function transformCreateSweepTaskParams(data: CreateSweepTaskParams): {
704
+ enabled?: boolean | undefined;
705
+ reserve_percentage_usd?: number | undefined;
706
+ reserve_amount_usd?: number | undefined;
707
+ reserve_type?: ReserveType | undefined;
708
+ asset_ids?: string[] | undefined;
709
+ destination_type?: DestinationType | undefined;
710
+ sweep_type?: SweepType | undefined;
503
711
  name: string;
504
- walletType: WalletType;
505
- walletPurpose?: WalletPurpose;
506
- sweepTaskParams?: SweepTaskParams;
507
- sweepTaskId?: string;
508
- }
509
- interface CreateWalletResponse {
510
- wallet_id: string;
511
- status: WalletCreationStatus;
512
- }
513
- interface WalletCreationStatusResponse {
514
- wallet_id: string;
515
- status: WalletCreationStatus;
516
- }
517
- interface WalletAssetNetwork {
518
- id: string;
519
- created_at: string;
520
- updated_at: string;
521
- name: string;
522
- description?: string;
523
- is_evm: boolean;
524
- chain_id: number;
525
- native_currency: string;
526
- is_testnet?: boolean;
527
- internal_code: string;
528
- explorer_tx: string;
529
- explorer_address: string;
530
- explorer_token: string;
531
- confirmation_blocks: number;
532
- block_interval_in_seconds: number;
533
- disabled: boolean;
534
- logo_url: string;
535
- }
536
- interface WalletAssetDetail {
537
- id: string;
538
- created_at: string;
539
- updated_at: string;
540
- name: string;
541
- symbol: string;
542
- decimals: number;
543
- logo_url: string;
544
- is_native: boolean;
545
- address_type: string;
546
- is_whitelisted: boolean;
547
- address?: string;
548
- network_id: string;
549
- network?: WalletAssetNetwork;
550
- }
551
- interface WalletAsset {
552
- id: string;
553
- created_at: string;
554
- updated_at: string;
555
- wallet_id: string;
556
- asset_id: string;
557
- deposit_address: string;
558
- hidden: boolean;
559
- asset: WalletAssetDetail;
560
- }
561
- interface DepositAddressResponse {
562
- asset_id?: string;
563
- address: string;
564
- qr_code: string;
565
- }
566
- interface RescanTransactionParams {
567
- txHash: string;
568
- networkId: string;
569
- }
570
- interface WalletResponse {
571
- id: string;
572
- name: string;
573
- value_usd: string;
574
- role: WalletRole;
575
- }
576
- interface TopAssets {
577
- symbol: string;
578
- logo_url: string;
579
- }
580
- interface WalletByWorkspaceResponse {
581
- id: string;
582
- name: string;
583
- role: string;
584
- wallet_type: string;
585
- value_usd: string;
586
- top_assets: TopAssets[];
587
- wallet_purpose: string;
588
- }
589
- interface RequestWithdrawalParams {
590
- assetId: string;
591
- amount: string;
592
- recipientAddress: string;
593
- notes?: string;
594
- skipBalanceCheck?: boolean;
595
- }
596
- interface WithdrawalApproval {
597
- id: string;
598
- user_id: string;
599
- status: string;
600
- created_at: string;
601
- updated_at: string;
602
- }
603
- interface WithdrawalTransaction {
604
- id: string;
605
- hash?: string;
606
- status: string;
607
- created_at: string;
608
- updated_at: string;
609
- }
610
- interface TxCategory {
611
- id: string;
612
- name: string;
613
- }
614
- interface Withdrawal {
615
- id: string;
616
- created_at: string;
617
- updated_at: string;
618
- amount: string;
619
- status: WithdrawalStatus;
620
- recipient_address: string;
621
- notes?: string;
622
- withdrawal_approvals: WithdrawalApproval[];
623
- creator_id: string;
624
- asset_id: string;
625
- asset?: WalletAssetDetail;
626
- wallet_id: string;
627
- transaction_id?: string;
628
- transaction?: WithdrawalTransaction;
629
- asset_hold_id: string;
630
- error_reason?: string;
631
- categories?: TxCategory[];
632
- }
633
- interface RequestWithdrawalResponse {
634
- auto_approved: boolean;
635
- withdrawal: Withdrawal;
636
- }
637
- interface WebhookPublicKeyResponse {
638
- public_key: string;
639
- }
712
+ strategy: SweepStrategy;
713
+ min_trigger_value_usd: number;
714
+ destination_wallet_id: string;
715
+ frequency_in_seconds: number;
716
+ wallet_ids: string[];
717
+ };
640
718
 
641
719
  interface SDKOptions {
642
720
  credentials: APICredentials;
643
721
  workspaceId?: string;
644
722
  environment?: Environment;
645
- logger?: boolean;
723
+ /** Enable debug logging. Defaults to false */
724
+ debug?: boolean;
646
725
  }
647
726
  declare class FystackSDK {
648
727
  private apiService;
649
- private enableLogging;
728
+ private debugEnabled;
650
729
  private workspaceId?;
730
+ automation: AutomationNamespace;
651
731
  constructor(options: SDKOptions);
652
732
  private log;
653
733
  /**
@@ -706,6 +786,17 @@ declare class FystackSDK {
706
786
  * @returns Promise with webhook public key (base64 encoded ed25519 public key)
707
787
  */
708
788
  getWebhookPublicKey(workspaceId: string): Promise<WebhookPublicKeyResponse>;
789
+ /** @internal */
790
+ _getApiService(): APIService;
791
+ /** @internal */
792
+ _log(message: string): void;
793
+ /** @internal */
794
+ _getWorkspaceId(): string;
795
+ }
796
+ declare class AutomationNamespace {
797
+ private sdk;
798
+ constructor(sdk: FystackSDK);
799
+ createSweepTask(params: CreateSweepTaskParams): Promise<SweepTaskResponse>;
709
800
  }
710
801
 
711
802
  interface StatusPollerOptions {
@@ -803,4 +894,4 @@ declare class SolanaSigner {
803
894
  private incorporateSignatureIntoTransaction;
804
895
  }
805
896
 
806
- 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 RequestWithdrawalParams, type RequestWithdrawalResponse, type RescanTransactionParams, type SDKOptions, type SignRequestParams, type SignResponse, type SignatureStatusResponse, SolanaSigner, StatusPoller, type StatusPollerOptions, type SweepTaskParams, type TopAssets, TransactionError, type TransactionStatusResponse, TxApprovalStatus, type TxCategory, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, type WalletByWorkspaceResponse, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, type WalletResponse, WalletRole, WalletType, type WebhookEvent, type WebhookPublicKeyResponse, WebhookService, type Withdrawal, type WithdrawalApproval, WithdrawalStatus, type WithdrawalTransaction, createAPI, get, post, transformCreateWalletPayload, transformRequestWithdrawalParams, transformRescanTransactionParams, transformWalletDetail };
897
+ export { type APIConfig, type APICredentials, type APIEndpoints, APIService, AddressType, type ApprovalInfo, type CreateSweepTaskParams, type CreateWalletOptions, type CreateWalletPayload, type CreateWalletResponse, DEFAULT_POLLER_OPTIONS, type DepositAddressResponse, DestinationType, Environment, EtherSigner, FystackSDK, type HMACParams, PaymentService, type PaymentServiceParams, type RequestWithdrawalParams, type RequestWithdrawalResponse, type RescanTransactionParams, ReserveType, type SDKOptions, type SignRequestParams, type SignResponse, type SignatureStatusResponse, SolanaSigner, StatusPoller, type StatusPollerOptions, SweepStrategy, type SweepTaskParams, type SweepTaskResponse, SweepType, type TopAssets, TransactionError, type TransactionStatusResponse, TxApprovalStatus, type TxCategory, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, type WalletByWorkspaceResponse, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, type WalletResponse, WalletRole, WalletType, type WebhookEvent, type WebhookPublicKeyResponse, WebhookService, type Withdrawal, type WithdrawalApproval, WithdrawalStatus, type WithdrawalTransaction, createAPI, get, post, transformCreateSweepTaskParams, transformCreateWalletPayload, transformRequestWithdrawalParams, transformRescanTransactionParams, transformWalletDetail };