@fystack/sdk 0.1.8 → 0.1.10
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 +86 -3
- package/dist/index.d.cts +97 -2
- package/dist/index.d.mts +97 -2
- package/dist/index.esm.d.ts +97 -2
- package/dist/index.esm.js +86 -4
- package/dist/index.mjs +86 -4
- package/dist/types/index.d.ts +97 -2
- package/package.json +1 -1
- package/src/api.ts +43 -1
- package/src/config.ts +5 -1
- package/src/enum.ts +11 -1
- package/src/sdk.ts +54 -2
- package/src/types.ts +60 -1
- package/test.js +76 -0
package/dist/index.cjs
CHANGED
|
@@ -50,7 +50,9 @@ const createAPI = (env)=>{
|
|
|
50
50
|
getWalletCreationStatus: (walletId)=>withBaseURL(`/wallets/creation-status/${walletId}`),
|
|
51
51
|
getWalletAssets: (walletId)=>withBaseURL(`/wallets/${walletId}/assets`),
|
|
52
52
|
getDepositAddress: (walletId, addressType)=>withBaseURL(`/wallets/${walletId}/deposit-address?address_type=${addressType}`),
|
|
53
|
-
rescanTransaction: ()=>withBaseURL('/networks/rescan-transaction')
|
|
53
|
+
rescanTransaction: ()=>withBaseURL('/networks/rescan-transaction'),
|
|
54
|
+
requestWithdrawal: (walletId)=>withBaseURL(`/wallets/${walletId}/request-withdrawal`),
|
|
55
|
+
getWebhookPublicKey: (workspaceId)=>withBaseURL(`/workspaces/${workspaceId}/webhook-verification-key`)
|
|
54
56
|
}
|
|
55
57
|
};
|
|
56
58
|
};
|
|
@@ -131,7 +133,7 @@ async function computeHMACForWebhook(apiSecret, event) {
|
|
|
131
133
|
// Wallets
|
|
132
134
|
exports.WalletType = void 0;
|
|
133
135
|
(function(WalletType) {
|
|
134
|
-
WalletType["
|
|
136
|
+
WalletType["Hyper"] = "standard";
|
|
135
137
|
WalletType["MPC"] = "mpc";
|
|
136
138
|
})(exports.WalletType || (exports.WalletType = {}));
|
|
137
139
|
exports.WalletPurpose = void 0;
|
|
@@ -181,6 +183,16 @@ exports.WalletRole = void 0;
|
|
|
181
183
|
WalletRole["Signer"] = "wallet_signer";
|
|
182
184
|
WalletRole["Viewer"] = "wallet_viewer";
|
|
183
185
|
})(exports.WalletRole || (exports.WalletRole = {}));
|
|
186
|
+
exports.WithdrawalStatus = void 0;
|
|
187
|
+
(function(WithdrawalStatus) {
|
|
188
|
+
WithdrawalStatus["Pending"] = "pending";
|
|
189
|
+
WithdrawalStatus["PendingApproval"] = "pending_approval";
|
|
190
|
+
WithdrawalStatus["Approved"] = "approved";
|
|
191
|
+
WithdrawalStatus["Rejected"] = "rejected";
|
|
192
|
+
WithdrawalStatus["Processing"] = "processing";
|
|
193
|
+
WithdrawalStatus["Completed"] = "completed";
|
|
194
|
+
WithdrawalStatus["Failed"] = "failed";
|
|
195
|
+
})(exports.WithdrawalStatus || (exports.WithdrawalStatus = {}));
|
|
184
196
|
|
|
185
197
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}, headers) {
|
|
186
198
|
if (!credentials.apiSecret || credentials.apiSecret === '') {
|
|
@@ -300,6 +312,28 @@ class APIService {
|
|
|
300
312
|
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, transformedParams);
|
|
301
313
|
await post(endpoint, transformedParams, headers);
|
|
302
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Requests a withdrawal from a wallet
|
|
317
|
+
* @param walletId The wallet ID
|
|
318
|
+
* @param params Withdrawal parameters
|
|
319
|
+
* @returns Withdrawal response with auto_approved status and withdrawal details
|
|
320
|
+
*/ async requestWithdrawal(walletId, params) {
|
|
321
|
+
const endpoint = this.API.endpoints.requestWithdrawal(walletId);
|
|
322
|
+
const transformedParams = transformRequestWithdrawalParams(params);
|
|
323
|
+
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, transformedParams);
|
|
324
|
+
const response = await post(endpoint, transformedParams, headers);
|
|
325
|
+
return response.data;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Gets the webhook public key for a workspace
|
|
329
|
+
* @param workspaceId The workspace ID
|
|
330
|
+
* @returns Webhook public key response with base64 encoded ed25519 public key
|
|
331
|
+
*/ async getWebhookPublicKey(workspaceId) {
|
|
332
|
+
const endpoint = this.API.endpoints.getWebhookPublicKey(workspaceId);
|
|
333
|
+
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
334
|
+
const response = await get(endpoint, headers);
|
|
335
|
+
return response.data;
|
|
336
|
+
}
|
|
303
337
|
constructor(credentials, environment){
|
|
304
338
|
this.credentials = credentials;
|
|
305
339
|
this.Webhook = new WebhookService(credentials);
|
|
@@ -423,6 +457,19 @@ function transformRescanTransactionParams(data) {
|
|
|
423
457
|
network_id: data.networkId
|
|
424
458
|
};
|
|
425
459
|
}
|
|
460
|
+
function transformRequestWithdrawalParams(data) {
|
|
461
|
+
return {
|
|
462
|
+
asset_id: data.assetId,
|
|
463
|
+
amount: data.amount,
|
|
464
|
+
recipient_address: data.recipientAddress,
|
|
465
|
+
...data.notes !== undefined && {
|
|
466
|
+
notes: data.notes
|
|
467
|
+
},
|
|
468
|
+
...data.skipBalanceCheck !== undefined && {
|
|
469
|
+
skip_balance_check: data.skipBalanceCheck
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
426
473
|
BigInt.prototype.toJSON = function() {
|
|
427
474
|
return this.toString();
|
|
428
475
|
};
|
|
@@ -493,7 +540,7 @@ class FystackSDK {
|
|
|
493
540
|
* @param waitForCompletion Whether to wait for the wallet creation to complete
|
|
494
541
|
* @returns Promise with wallet ID and status
|
|
495
542
|
*/ async createWallet(options, waitForCompletion = true) {
|
|
496
|
-
const { name, walletType = exports.WalletType.
|
|
543
|
+
const { name, walletType = exports.WalletType.Hyper, sweepTaskParams, walletPurpose, sweepTaskId } = options;
|
|
497
544
|
const response = await this.apiService.createWallet({
|
|
498
545
|
name,
|
|
499
546
|
walletType,
|
|
@@ -583,6 +630,41 @@ class FystackSDK {
|
|
|
583
630
|
}
|
|
584
631
|
await this.apiService.rescanTransaction(params);
|
|
585
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Requests a withdrawal from a wallet
|
|
635
|
+
* @param walletId The ID of the wallet to withdraw from
|
|
636
|
+
* @param params Withdrawal parameters including asset, amount, and recipient
|
|
637
|
+
* @returns Promise with withdrawal response including auto_approved status and withdrawal details
|
|
638
|
+
*/ async requestWithdrawal(walletId, params) {
|
|
639
|
+
validateUUID(walletId, 'walletId');
|
|
640
|
+
validateUUID(params.assetId, 'assetId');
|
|
641
|
+
if (!params.amount || params.amount.trim() === '') {
|
|
642
|
+
throw new Error('Invalid amount provided');
|
|
643
|
+
}
|
|
644
|
+
if (!params.recipientAddress || params.recipientAddress.trim() === '') {
|
|
645
|
+
throw new Error('Invalid recipient address provided');
|
|
646
|
+
}
|
|
647
|
+
if (params.recipientAddress.length > 256) {
|
|
648
|
+
throw new Error('Recipient address exceeds maximum length of 256 characters');
|
|
649
|
+
}
|
|
650
|
+
if (params.notes && params.notes.length > 500) {
|
|
651
|
+
throw new Error('Notes exceed maximum length of 500 characters');
|
|
652
|
+
}
|
|
653
|
+
this.log(`Requesting withdrawal from wallet ${walletId}`);
|
|
654
|
+
const response = await this.apiService.requestWithdrawal(walletId, params);
|
|
655
|
+
this.log(`Withdrawal request completed, auto_approved: ${response.auto_approved}`);
|
|
656
|
+
return response;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Gets the webhook public key for a workspace
|
|
660
|
+
* @param workspaceId The workspace ID
|
|
661
|
+
* @returns Promise with webhook public key (base64 encoded ed25519 public key)
|
|
662
|
+
*/ async getWebhookPublicKey(workspaceId) {
|
|
663
|
+
validateUUID(workspaceId, 'workspaceId');
|
|
664
|
+
this.log(`Getting webhook public key for workspace ${workspaceId}`);
|
|
665
|
+
const response = await this.apiService.getWebhookPublicKey(workspaceId);
|
|
666
|
+
return response;
|
|
667
|
+
}
|
|
586
668
|
constructor(options){
|
|
587
669
|
const { credentials, workspaceId, environment = exports.Environment.Production, logger = false } = options;
|
|
588
670
|
this.apiService = new APIService(credentials, environment);
|
|
@@ -1054,5 +1136,6 @@ exports.createAPI = createAPI;
|
|
|
1054
1136
|
exports.get = get;
|
|
1055
1137
|
exports.post = post;
|
|
1056
1138
|
exports.transformCreateWalletPayload = transformCreateWalletPayload;
|
|
1139
|
+
exports.transformRequestWithdrawalParams = transformRequestWithdrawalParams;
|
|
1057
1140
|
exports.transformRescanTransactionParams = transformRescanTransactionParams;
|
|
1058
1141
|
exports.transformWalletDetail = transformWalletDetail;
|
package/dist/index.d.cts
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;
|
|
@@ -276,7 +278,7 @@ interface GetCheckoutPaymentResponse {
|
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
declare enum WalletType {
|
|
279
|
-
|
|
281
|
+
Hyper = "standard",
|
|
280
282
|
MPC = "mpc"
|
|
281
283
|
}
|
|
282
284
|
declare enum WalletPurpose {
|
|
@@ -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;
|
|
@@ -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 {
|
|
@@ -708,4 +803,4 @@ declare class SolanaSigner {
|
|
|
708
803
|
private incorporateSignatureIntoTransaction;
|
|
709
804
|
}
|
|
710
805
|
|
|
711
|
-
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 };
|
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;
|
|
@@ -276,7 +278,7 @@ interface GetCheckoutPaymentResponse {
|
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
declare enum WalletType {
|
|
279
|
-
|
|
281
|
+
Hyper = "standard",
|
|
280
282
|
MPC = "mpc"
|
|
281
283
|
}
|
|
282
284
|
declare enum WalletPurpose {
|
|
@@ -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;
|
|
@@ -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 {
|
|
@@ -708,4 +803,4 @@ declare class SolanaSigner {
|
|
|
708
803
|
private incorporateSignatureIntoTransaction;
|
|
709
804
|
}
|
|
710
805
|
|
|
711
|
-
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 };
|
package/dist/index.esm.d.ts
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;
|
|
@@ -276,7 +278,7 @@ interface GetCheckoutPaymentResponse {
|
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
declare enum WalletType {
|
|
279
|
-
|
|
281
|
+
Hyper = "standard",
|
|
280
282
|
MPC = "mpc"
|
|
281
283
|
}
|
|
282
284
|
declare enum WalletPurpose {
|
|
@@ -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;
|
|
@@ -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 {
|
|
@@ -708,4 +803,4 @@ declare class SolanaSigner {
|
|
|
708
803
|
private incorporateSignatureIntoTransaction;
|
|
709
804
|
}
|
|
710
805
|
|
|
711
|
-
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 };
|