@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.cjs +110 -26
- package/dist/index.d.cts +122 -11
- package/dist/index.d.mts +122 -11
- package/dist/index.esm.d.ts +122 -11
- package/dist/index.esm.js +110 -27
- package/dist/index.mjs +110 -27
- package/dist/types/index.d.ts +122 -11
- package/package.json +1 -1
- package/src/api.ts +61 -9
- package/src/config.ts +5 -1
- package/src/enum.ts +10 -0
- package/src/sdk.ts +53 -1
- package/src/signer.ts +40 -18
- package/src/solanaSigner.ts +41 -17
- package/src/types.ts +67 -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
|
};
|
|
@@ -181,8 +183,18 @@ 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
|
-
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
197
|
+
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}, headers) {
|
|
186
198
|
if (!credentials.apiSecret || credentials.apiSecret === '') {
|
|
187
199
|
// If APISecret is not provided, use authToken
|
|
188
200
|
if (credentials.authToken) {
|
|
@@ -204,12 +216,13 @@ async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}
|
|
|
204
216
|
body: Object.keys(body).length ? JSON.stringify(body) : ''
|
|
205
217
|
};
|
|
206
218
|
const digest = await computeHMAC(credentials.apiSecret, params);
|
|
207
|
-
const
|
|
219
|
+
const combinedHeaders = {
|
|
208
220
|
'ACCESS-API-KEY': credentials.apiKey,
|
|
209
221
|
'ACCESS-TIMESTAMP': String(currentTimestampInSeconds),
|
|
210
|
-
'ACCESS-SIGN': btoa(digest)
|
|
222
|
+
'ACCESS-SIGN': btoa(digest),
|
|
223
|
+
...headers ?? {}
|
|
211
224
|
};
|
|
212
|
-
return
|
|
225
|
+
return combinedHeaders;
|
|
213
226
|
}
|
|
214
227
|
class APIService {
|
|
215
228
|
async getWallets(workspaceId) {
|
|
@@ -225,9 +238,9 @@ class APIService {
|
|
|
225
238
|
const resp = await get(endpoint + `?address_type=${addressType}`, headers);
|
|
226
239
|
return transformWalletDetail(resp.data);
|
|
227
240
|
}
|
|
228
|
-
async requestSign(walletId, params) {
|
|
241
|
+
async requestSign(walletId, params, options) {
|
|
229
242
|
const endpoint = this.API.endpoints.requestSign(walletId);
|
|
230
|
-
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, params);
|
|
243
|
+
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, params, options);
|
|
231
244
|
const response = await post(endpoint, params, headers);
|
|
232
245
|
return response.data;
|
|
233
246
|
}
|
|
@@ -237,10 +250,10 @@ class APIService {
|
|
|
237
250
|
const response = await get(endpoint, headers);
|
|
238
251
|
return response.data;
|
|
239
252
|
}
|
|
240
|
-
async signTransaction(walletId, body) {
|
|
253
|
+
async signTransaction(walletId, body, options) {
|
|
241
254
|
const startTime = Date.now();
|
|
242
255
|
const endpoint = this.API.endpoints.signTransaction(walletId);
|
|
243
|
-
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, body);
|
|
256
|
+
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, body, options);
|
|
244
257
|
const response = await post(endpoint, body, headers);
|
|
245
258
|
const elapsedTime = Date.now() - startTime;
|
|
246
259
|
console.log(`[WalletSDK] Sign transaction completed in ${elapsedTime}ms`);
|
|
@@ -299,6 +312,28 @@ class APIService {
|
|
|
299
312
|
const headers = await composeAPIHeaders(this.credentials, 'POST', endpoint, transformedParams);
|
|
300
313
|
await post(endpoint, transformedParams, headers);
|
|
301
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
|
+
}
|
|
302
337
|
constructor(credentials, environment){
|
|
303
338
|
this.credentials = credentials;
|
|
304
339
|
this.Webhook = new WebhookService(credentials);
|
|
@@ -422,6 +457,19 @@ function transformRescanTransactionParams(data) {
|
|
|
422
457
|
network_id: data.networkId
|
|
423
458
|
};
|
|
424
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
|
+
}
|
|
425
473
|
BigInt.prototype.toJSON = function() {
|
|
426
474
|
return this.toString();
|
|
427
475
|
};
|
|
@@ -582,6 +630,41 @@ class FystackSDK {
|
|
|
582
630
|
}
|
|
583
631
|
await this.apiService.rescanTransaction(params);
|
|
584
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
|
+
}
|
|
585
668
|
constructor(options){
|
|
586
669
|
const { credentials, workspaceId, environment = exports.Environment.Production, logger = false } = options;
|
|
587
670
|
this.apiService = new APIService(credentials, environment);
|
|
@@ -677,14 +760,14 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
677
760
|
}
|
|
678
761
|
return result.status === exports.TxStatus.Rejected;
|
|
679
762
|
});
|
|
680
|
-
console.log('
|
|
763
|
+
console.log('result', result);
|
|
681
764
|
if (!result.hash) {
|
|
682
765
|
throw new TransactionError('Transaction hash not found in successful response', 'TRANSACTION_HASH_MISSING', result.transaction_id);
|
|
683
766
|
}
|
|
684
767
|
return result.hash;
|
|
685
768
|
}
|
|
686
769
|
// Copied and editted from ethers.js -> Wallet -> BaseWallet
|
|
687
|
-
async signTransaction(tx) {
|
|
770
|
+
async signTransaction(tx, options) {
|
|
688
771
|
const startTime = new Date();
|
|
689
772
|
console.log(`[WalletSDK] Transaction started at: ${startTime.toLocaleString()}`);
|
|
690
773
|
if (!this.address) {
|
|
@@ -724,7 +807,7 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
724
807
|
accessList: btx.accessList
|
|
725
808
|
};
|
|
726
809
|
// return unseralized as API signTransaction is an asynchoronous action
|
|
727
|
-
const response = await this.APIService.signTransaction(this.walletDetail.WalletID, data);
|
|
810
|
+
const response = await this.APIService.signTransaction(this.walletDetail.WalletID, data, options);
|
|
728
811
|
const txHash = await this.waitForTransactonStatus(response.transaction_id);
|
|
729
812
|
const endTime = new Date();
|
|
730
813
|
const elapsedTimeMs = endTime.getTime() - startTime.getTime();
|
|
@@ -733,7 +816,7 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
733
816
|
console.log('[WalletSDK] Transaction succeed!');
|
|
734
817
|
return txHash;
|
|
735
818
|
}
|
|
736
|
-
async sendTransaction(tx) {
|
|
819
|
+
async sendTransaction(tx, options) {
|
|
737
820
|
const startTime = new Date();
|
|
738
821
|
console.log(`[WalletSDK] sendTransaction started at: ${startTime.toLocaleString()}`);
|
|
739
822
|
if (!this.address) {
|
|
@@ -761,7 +844,7 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
761
844
|
const resolvedTx = await ethers.resolveProperties(populatedTx);
|
|
762
845
|
const txObj = ethers.Transaction.from(resolvedTx);
|
|
763
846
|
console.log('[WalletSDK] Tx Data', txObj);
|
|
764
|
-
const txHash = await this.signTransaction(txObj);
|
|
847
|
+
const txHash = await this.signTransaction(txObj, options);
|
|
765
848
|
// Instead of creating a mock response, get the actual transaction from the provider
|
|
766
849
|
const endTime = new Date();
|
|
767
850
|
const totalElapsedMs = endTime.getTime() - startTime.getTime();
|
|
@@ -810,7 +893,7 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
810
893
|
// Let the provider create the TransactionResponse using the txHash
|
|
811
894
|
return new ethers.TransactionResponse(txResponse, this.provider);
|
|
812
895
|
}
|
|
813
|
-
async signMessage(message) {
|
|
896
|
+
async signMessage(message, options) {
|
|
814
897
|
if (!this.provider) {
|
|
815
898
|
throw new Error('Provider is required for signing operations');
|
|
816
899
|
}
|
|
@@ -826,10 +909,10 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
826
909
|
method: 'eth_sign',
|
|
827
910
|
message: messageStr,
|
|
828
911
|
chain_id: chainId
|
|
829
|
-
});
|
|
912
|
+
}, options);
|
|
830
913
|
return this.waitForSignature(this.walletDetail.WalletID, response.transaction_id);
|
|
831
914
|
}
|
|
832
|
-
async signTypedData(domain, types, value) {
|
|
915
|
+
async signTypedData(domain, types, value, options) {
|
|
833
916
|
if (!this.provider) {
|
|
834
917
|
throw new Error('Provider is required for signing operations');
|
|
835
918
|
}
|
|
@@ -850,7 +933,7 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
850
933
|
message: '',
|
|
851
934
|
chain_id: chainId,
|
|
852
935
|
typed_data: typedData
|
|
853
|
-
});
|
|
936
|
+
}, options);
|
|
854
937
|
return this.waitForSignature(this.walletDetail.WalletID, response.transaction_id);
|
|
855
938
|
}
|
|
856
939
|
constructor(credentials, environment, provider, pollerOptions){
|
|
@@ -929,7 +1012,7 @@ class SolanaSigner {
|
|
|
929
1012
|
* Signs a Solana transaction
|
|
930
1013
|
* @param transaction Base64 encoded serialized transaction
|
|
931
1014
|
* @returns Signature as a base58 encoded string
|
|
932
|
-
*/ async signTransaction(transaction) {
|
|
1015
|
+
*/ async signTransaction(transaction, options) {
|
|
933
1016
|
if (!this.address) {
|
|
934
1017
|
await this.getAddress();
|
|
935
1018
|
}
|
|
@@ -944,7 +1027,7 @@ class SolanaSigner {
|
|
|
944
1027
|
tx_method: 'solana_signTransaction'
|
|
945
1028
|
},
|
|
946
1029
|
chainId: '1399811149'
|
|
947
|
-
});
|
|
1030
|
+
}, options);
|
|
948
1031
|
// Wait for the signature
|
|
949
1032
|
return this.waitForTransactionStatus(response.transaction_id);
|
|
950
1033
|
}
|
|
@@ -952,7 +1035,7 @@ class SolanaSigner {
|
|
|
952
1035
|
* Signs a Solana message
|
|
953
1036
|
* @param message The message to sign (string or Uint8Array)
|
|
954
1037
|
* @returns Signature as a base58 encoded string
|
|
955
|
-
*/ async signMessage(message) {
|
|
1038
|
+
*/ async signMessage(message, options) {
|
|
956
1039
|
if (!this.address) {
|
|
957
1040
|
await this.getAddress();
|
|
958
1041
|
}
|
|
@@ -961,14 +1044,14 @@ class SolanaSigner {
|
|
|
961
1044
|
method: 'solana_signMessage',
|
|
962
1045
|
message: messageStr,
|
|
963
1046
|
chain_id: 0 // Not used for Solana but required by API
|
|
964
|
-
});
|
|
1047
|
+
}, options);
|
|
965
1048
|
return this.waitForTransactionStatus(response.transaction_id);
|
|
966
1049
|
}
|
|
967
1050
|
/**
|
|
968
1051
|
* Signs and sends a Solana transaction
|
|
969
1052
|
* @param transaction Base64 encoded serialized transaction
|
|
970
1053
|
* @returns Transaction signature
|
|
971
|
-
*/ async signAndSendTransaction(transaction) {
|
|
1054
|
+
*/ async signAndSendTransaction(transaction, options) {
|
|
972
1055
|
if (!this.address) {
|
|
973
1056
|
await this.getAddress();
|
|
974
1057
|
}
|
|
@@ -977,7 +1060,7 @@ class SolanaSigner {
|
|
|
977
1060
|
from: this.address,
|
|
978
1061
|
method: 'solana_signAndSendTransaction'
|
|
979
1062
|
};
|
|
980
|
-
const response = await this.APIService.signTransaction(this.walletDetail.WalletID, data);
|
|
1063
|
+
const response = await this.APIService.signTransaction(this.walletDetail.WalletID, data, options);
|
|
981
1064
|
const txHash = await this.waitForTransactionStatus(response.transaction_id);
|
|
982
1065
|
console.log('transaction succeed!');
|
|
983
1066
|
return txHash;
|
|
@@ -986,14 +1069,14 @@ class SolanaSigner {
|
|
|
986
1069
|
* Signs multiple Solana transactions
|
|
987
1070
|
* @param transactions Array of base64 encoded serialized transactions
|
|
988
1071
|
* @returns Array of signatures as base58 encoded strings
|
|
989
|
-
*/ async signAllTransactions(transactions) {
|
|
1072
|
+
*/ async signAllTransactions(transactions, options) {
|
|
990
1073
|
if (!this.address) {
|
|
991
1074
|
await this.getAddress();
|
|
992
1075
|
}
|
|
993
1076
|
// We need to get the signatures and then incorporate them into the transactions
|
|
994
1077
|
const signaturePromises = transactions.map(async (transaction)=>{
|
|
995
1078
|
// Get the signature
|
|
996
|
-
const signature = await this.signTransaction(transaction);
|
|
1079
|
+
const signature = await this.signTransaction(transaction, options);
|
|
997
1080
|
// Here you would need to incorporate the signature into the transaction
|
|
998
1081
|
// This is a placeholder - you'll need to implement actual signature incorporation
|
|
999
1082
|
// based on your Solana transaction structure
|
|
@@ -1053,5 +1136,6 @@ exports.createAPI = createAPI;
|
|
|
1053
1136
|
exports.get = get;
|
|
1054
1137
|
exports.post = post;
|
|
1055
1138
|
exports.transformCreateWalletPayload = transformCreateWalletPayload;
|
|
1139
|
+
exports.transformRequestWithdrawalParams = transformRequestWithdrawalParams;
|
|
1056
1140
|
exports.transformRescanTransactionParams = transformRescanTransactionParams;
|
|
1057
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;
|
|
@@ -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
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
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
|
|
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
|
|
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
|
|
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[]
|
|
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 };
|