@fystack/sdk 0.1.7 → 0.1.9

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.mts CHANGED
@@ -22,6 +22,8 @@ interface APIEndpoints {
22
22
  getWalletAssets: (walletId: string) => string;
23
23
  getDepositAddress: (walletId: string, addressType: string) => string;
24
24
  rescanTransaction: () => string;
25
+ requestWithdrawal: (walletId: string) => string;
26
+ getWebhookPublicKey: (workspaceId: string) => string;
25
27
  }
26
28
  interface APIConfig {
27
29
  baseURL: string;
@@ -319,6 +321,15 @@ declare enum WalletRole {
319
321
  Signer = "wallet_signer",
320
322
  Viewer = "wallet_viewer"
321
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
+ }
322
333
 
323
334
  interface APIResponse {
324
335
  data: any;
@@ -361,9 +372,9 @@ declare class APIService {
361
372
  constructor(credentials: APICredentials, environment: Environment);
362
373
  getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
363
374
  getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
364
- requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
375
+ requestSign(walletId: string, params: SignRequestParams, options?: Record<string, string>): Promise<SignResponse>;
365
376
  getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
366
- signTransaction(walletId: string, body: Record<string, any>): Promise<SignResponse>;
377
+ signTransaction(walletId: string, body: Record<string, any>, options?: Record<string, string>): Promise<SignResponse>;
367
378
  getTransactionStatus(walletId: string, transactionId: string): Promise<TransactionStatusResponse>;
368
379
  createWallet(payload: CreateWalletPayload): Promise<CreateWalletResponse>;
369
380
  createCheckout(payload: CreateCheckoutPayload): Promise<CreateCheckoutResponse>;
@@ -382,6 +393,19 @@ declare class APIService {
382
393
  * @returns API response
383
394
  */
384
395
  rescanTransaction(params: RescanTransactionParams): Promise<void>;
396
+ /**
397
+ * Requests a withdrawal from a wallet
398
+ * @param walletId The wallet ID
399
+ * @param params Withdrawal parameters
400
+ * @returns Withdrawal response with auto_approved status and withdrawal details
401
+ */
402
+ requestWithdrawal(walletId: string, params: RequestWithdrawalParams): Promise<RequestWithdrawalResponse>;
403
+ /**
404
+ * Gets the webhook public key for a workspace
405
+ * @param workspaceId The workspace ID
406
+ * @returns Webhook public key response with base64 encoded ed25519 public key
407
+ */
408
+ getWebhookPublicKey(workspaceId: string): Promise<WebhookPublicKeyResponse>;
385
409
  }
386
410
  declare class PaymentService {
387
411
  private apiKey;
@@ -415,6 +439,13 @@ declare function transformRescanTransactionParams(data: RescanTransactionParams)
415
439
  tx_hash: string;
416
440
  network_id: string;
417
441
  };
442
+ declare function transformRequestWithdrawalParams(data: RequestWithdrawalParams): {
443
+ skip_balance_check?: boolean | undefined;
444
+ notes?: string | undefined;
445
+ asset_id: string;
446
+ amount: string;
447
+ recipient_address: string;
448
+ };
418
449
 
419
450
  declare class TransactionError extends Error {
420
451
  readonly code: string;
@@ -555,6 +586,57 @@ interface WalletByWorkspaceResponse {
555
586
  top_assets: TopAssets[];
556
587
  wallet_purpose: string;
557
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
+ }
558
640
 
559
641
  interface SDKOptions {
560
642
  credentials: APICredentials;
@@ -611,6 +693,19 @@ declare class FystackSDK {
611
693
  * @returns Promise that resolves when the rescan is initiated
612
694
  */
613
695
  rescanTransaction(params: RescanTransactionParams): Promise<void>;
696
+ /**
697
+ * Requests a withdrawal from a wallet
698
+ * @param walletId The ID of the wallet to withdraw from
699
+ * @param params Withdrawal parameters including asset, amount, and recipient
700
+ * @returns Promise with withdrawal response including auto_approved status and withdrawal details
701
+ */
702
+ requestWithdrawal(walletId: string, params: RequestWithdrawalParams): Promise<RequestWithdrawalResponse>;
703
+ /**
704
+ * Gets the webhook public key for a workspace
705
+ * @param workspaceId The workspace ID
706
+ * @returns Promise with webhook public key (base64 encoded ed25519 public key)
707
+ */
708
+ getWebhookPublicKey(workspaceId: string): Promise<WebhookPublicKeyResponse>;
614
709
  }
615
710
 
616
711
  interface StatusPollerOptions {
@@ -646,10 +741,18 @@ declare class EtherSigner extends AbstractSigner {
646
741
  connect(provider: null | Provider): EtherSigner;
647
742
  private waitForSignature;
648
743
  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>;
744
+ signTransaction(tx: TransactionRequest, options?: {
745
+ idempotencyKey?: string;
746
+ }): Promise<string>;
747
+ sendTransaction(tx: TransactionRequest, options?: {
748
+ idempotencyKey?: string;
749
+ }): Promise<TransactionResponse>;
750
+ signMessage(message: string | Uint8Array, options?: {
751
+ idempotencyKey?: string;
752
+ }): Promise<string>;
753
+ signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, options?: {
754
+ idempotencyKey?: string;
755
+ }): Promise<string>;
653
756
  }
654
757
 
655
758
  declare class SolanaSigner {
@@ -668,28 +771,36 @@ declare class SolanaSigner {
668
771
  * @param transaction Base64 encoded serialized transaction
669
772
  * @returns Signature as a base58 encoded string
670
773
  */
671
- signTransaction(transaction: string): Promise<string>;
774
+ signTransaction(transaction: string, options?: {
775
+ idempotencyKey?: string;
776
+ }): Promise<string>;
672
777
  /**
673
778
  * Signs a Solana message
674
779
  * @param message The message to sign (string or Uint8Array)
675
780
  * @returns Signature as a base58 encoded string
676
781
  */
677
- signMessage(message: string | Uint8Array): Promise<string>;
782
+ signMessage(message: string | Uint8Array, options?: {
783
+ idempotencyKey?: string;
784
+ }): Promise<string>;
678
785
  /**
679
786
  * Signs and sends a Solana transaction
680
787
  * @param transaction Base64 encoded serialized transaction
681
788
  * @returns Transaction signature
682
789
  */
683
- signAndSendTransaction(transaction: string): Promise<string>;
790
+ signAndSendTransaction(transaction: string, options?: {
791
+ idempotencyKey?: string;
792
+ }): Promise<string>;
684
793
  /**
685
794
  * Signs multiple Solana transactions
686
795
  * @param transactions Array of base64 encoded serialized transactions
687
796
  * @returns Array of signatures as base58 encoded strings
688
797
  */
689
- signAllTransactions(transactions: string[]): Promise<{
798
+ signAllTransactions(transactions: string[], options?: {
799
+ idempotencyKey?: string;
800
+ }): Promise<{
690
801
  transactions: string[];
691
802
  }>;
692
803
  private incorporateSignatureIntoTransaction;
693
804
  }
694
805
 
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 };
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 };
@@ -22,6 +22,8 @@ interface APIEndpoints {
22
22
  getWalletAssets: (walletId: string) => string;
23
23
  getDepositAddress: (walletId: string, addressType: string) => string;
24
24
  rescanTransaction: () => string;
25
+ requestWithdrawal: (walletId: string) => string;
26
+ getWebhookPublicKey: (workspaceId: string) => string;
25
27
  }
26
28
  interface APIConfig {
27
29
  baseURL: string;
@@ -319,6 +321,15 @@ declare enum WalletRole {
319
321
  Signer = "wallet_signer",
320
322
  Viewer = "wallet_viewer"
321
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
+ }
322
333
 
323
334
  interface APIResponse {
324
335
  data: any;
@@ -361,9 +372,9 @@ declare class APIService {
361
372
  constructor(credentials: APICredentials, environment: Environment);
362
373
  getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
363
374
  getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
364
- requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
375
+ requestSign(walletId: string, params: SignRequestParams, options?: Record<string, string>): Promise<SignResponse>;
365
376
  getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
366
- signTransaction(walletId: string, body: Record<string, any>): Promise<SignResponse>;
377
+ signTransaction(walletId: string, body: Record<string, any>, options?: Record<string, string>): Promise<SignResponse>;
367
378
  getTransactionStatus(walletId: string, transactionId: string): Promise<TransactionStatusResponse>;
368
379
  createWallet(payload: CreateWalletPayload): Promise<CreateWalletResponse>;
369
380
  createCheckout(payload: CreateCheckoutPayload): Promise<CreateCheckoutResponse>;
@@ -382,6 +393,19 @@ declare class APIService {
382
393
  * @returns API response
383
394
  */
384
395
  rescanTransaction(params: RescanTransactionParams): Promise<void>;
396
+ /**
397
+ * Requests a withdrawal from a wallet
398
+ * @param walletId The wallet ID
399
+ * @param params Withdrawal parameters
400
+ * @returns Withdrawal response with auto_approved status and withdrawal details
401
+ */
402
+ requestWithdrawal(walletId: string, params: RequestWithdrawalParams): Promise<RequestWithdrawalResponse>;
403
+ /**
404
+ * Gets the webhook public key for a workspace
405
+ * @param workspaceId The workspace ID
406
+ * @returns Webhook public key response with base64 encoded ed25519 public key
407
+ */
408
+ getWebhookPublicKey(workspaceId: string): Promise<WebhookPublicKeyResponse>;
385
409
  }
386
410
  declare class PaymentService {
387
411
  private apiKey;
@@ -415,6 +439,13 @@ declare function transformRescanTransactionParams(data: RescanTransactionParams)
415
439
  tx_hash: string;
416
440
  network_id: string;
417
441
  };
442
+ declare function transformRequestWithdrawalParams(data: RequestWithdrawalParams): {
443
+ skip_balance_check?: boolean | undefined;
444
+ notes?: string | undefined;
445
+ asset_id: string;
446
+ amount: string;
447
+ recipient_address: string;
448
+ };
418
449
 
419
450
  declare class TransactionError extends Error {
420
451
  readonly code: string;
@@ -555,6 +586,57 @@ interface WalletByWorkspaceResponse {
555
586
  top_assets: TopAssets[];
556
587
  wallet_purpose: string;
557
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
+ }
558
640
 
559
641
  interface SDKOptions {
560
642
  credentials: APICredentials;
@@ -611,6 +693,19 @@ declare class FystackSDK {
611
693
  * @returns Promise that resolves when the rescan is initiated
612
694
  */
613
695
  rescanTransaction(params: RescanTransactionParams): Promise<void>;
696
+ /**
697
+ * Requests a withdrawal from a wallet
698
+ * @param walletId The ID of the wallet to withdraw from
699
+ * @param params Withdrawal parameters including asset, amount, and recipient
700
+ * @returns Promise with withdrawal response including auto_approved status and withdrawal details
701
+ */
702
+ requestWithdrawal(walletId: string, params: RequestWithdrawalParams): Promise<RequestWithdrawalResponse>;
703
+ /**
704
+ * Gets the webhook public key for a workspace
705
+ * @param workspaceId The workspace ID
706
+ * @returns Promise with webhook public key (base64 encoded ed25519 public key)
707
+ */
708
+ getWebhookPublicKey(workspaceId: string): Promise<WebhookPublicKeyResponse>;
614
709
  }
615
710
 
616
711
  interface StatusPollerOptions {
@@ -646,10 +741,18 @@ declare class EtherSigner extends AbstractSigner {
646
741
  connect(provider: null | Provider): EtherSigner;
647
742
  private waitForSignature;
648
743
  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>;
744
+ signTransaction(tx: TransactionRequest, options?: {
745
+ idempotencyKey?: string;
746
+ }): Promise<string>;
747
+ sendTransaction(tx: TransactionRequest, options?: {
748
+ idempotencyKey?: string;
749
+ }): Promise<TransactionResponse>;
750
+ signMessage(message: string | Uint8Array, options?: {
751
+ idempotencyKey?: string;
752
+ }): Promise<string>;
753
+ signTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, options?: {
754
+ idempotencyKey?: string;
755
+ }): Promise<string>;
653
756
  }
654
757
 
655
758
  declare class SolanaSigner {
@@ -668,28 +771,36 @@ declare class SolanaSigner {
668
771
  * @param transaction Base64 encoded serialized transaction
669
772
  * @returns Signature as a base58 encoded string
670
773
  */
671
- signTransaction(transaction: string): Promise<string>;
774
+ signTransaction(transaction: string, options?: {
775
+ idempotencyKey?: string;
776
+ }): Promise<string>;
672
777
  /**
673
778
  * Signs a Solana message
674
779
  * @param message The message to sign (string or Uint8Array)
675
780
  * @returns Signature as a base58 encoded string
676
781
  */
677
- signMessage(message: string | Uint8Array): Promise<string>;
782
+ signMessage(message: string | Uint8Array, options?: {
783
+ idempotencyKey?: string;
784
+ }): Promise<string>;
678
785
  /**
679
786
  * Signs and sends a Solana transaction
680
787
  * @param transaction Base64 encoded serialized transaction
681
788
  * @returns Transaction signature
682
789
  */
683
- signAndSendTransaction(transaction: string): Promise<string>;
790
+ signAndSendTransaction(transaction: string, options?: {
791
+ idempotencyKey?: string;
792
+ }): Promise<string>;
684
793
  /**
685
794
  * Signs multiple Solana transactions
686
795
  * @param transactions Array of base64 encoded serialized transactions
687
796
  * @returns Array of signatures as base58 encoded strings
688
797
  */
689
- signAllTransactions(transactions: string[]): Promise<{
798
+ signAllTransactions(transactions: string[], options?: {
799
+ idempotencyKey?: string;
800
+ }): Promise<{
690
801
  transactions: string[];
691
802
  }>;
692
803
  private incorporateSignatureIntoTransaction;
693
804
  }
694
805
 
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 };
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 };