@fystack/sdk 0.1.3 → 0.1.5
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 +35 -1
- package/dist/index.d.cts +34 -1
- package/dist/index.d.mts +34 -1
- package/dist/index.esm.d.ts +34 -1
- package/dist/index.esm.js +36 -2
- package/dist/index.mjs +36 -2
- package/dist/types/index.d.ts +34 -1
- package/package.json +1 -1
- package/src/api.ts +9 -1
- package/src/config.ts +2 -0
- package/src/enum.ts +6 -0
- package/src/sdk.ts +24 -2
- package/src/signer.ts +13 -0
- package/src/types.ts +23 -1
package/dist/index.cjs
CHANGED
|
@@ -37,6 +37,7 @@ const createAPI = (env)=>{
|
|
|
37
37
|
endpoints: {
|
|
38
38
|
signTransaction: (walletId)=>withBaseURL(`/web3/transaction/${walletId}/signRaw`),
|
|
39
39
|
getWalletDetail: (walletId)=>walletId ? withBaseURL(`/web3/wallet-detail/${walletId}`) : withBaseURL('/web3/wallet-detail'),
|
|
40
|
+
getWallets: (workspaceId)=>withBaseURL(`/workspaces/${workspaceId}/wallets`),
|
|
40
41
|
createWallet: ()=>withBaseURL('/wallets'),
|
|
41
42
|
createCheckout: ()=>withBaseURL('/checkouts'),
|
|
42
43
|
getCheckout: (checkoutId)=>withBaseURL(`/checkouts/${checkoutId}`),
|
|
@@ -174,6 +175,12 @@ exports.TxApprovalStatus = void 0;
|
|
|
174
175
|
TxApprovalStatus["Approved"] = "approved";
|
|
175
176
|
TxApprovalStatus["Rejected"] = "rejected";
|
|
176
177
|
})(exports.TxApprovalStatus || (exports.TxApprovalStatus = {}));
|
|
178
|
+
exports.WalletRole = void 0;
|
|
179
|
+
(function(WalletRole) {
|
|
180
|
+
WalletRole["Admin"] = "wallet_admin";
|
|
181
|
+
WalletRole["Signer"] = "wallet_signer";
|
|
182
|
+
WalletRole["Viewer"] = "wallet_viewer";
|
|
183
|
+
})(exports.WalletRole || (exports.WalletRole = {}));
|
|
177
184
|
|
|
178
185
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
179
186
|
if (credentials.apiSecret == '') {
|
|
@@ -205,6 +212,12 @@ async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}
|
|
|
205
212
|
return headers;
|
|
206
213
|
}
|
|
207
214
|
class APIService {
|
|
215
|
+
async getWallets(workspaceId) {
|
|
216
|
+
const endpoint = this.API.endpoints.getWallets(workspaceId);
|
|
217
|
+
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
218
|
+
const response = await get(endpoint, headers);
|
|
219
|
+
return response.data;
|
|
220
|
+
}
|
|
208
221
|
async getWalletDetail(addressType = exports.AddressType.Evm, walletId) {
|
|
209
222
|
const endpoint = this.API.endpoints.getWalletDetail(walletId);
|
|
210
223
|
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
@@ -493,6 +506,16 @@ class FystackSDK {
|
|
|
493
506
|
return response;
|
|
494
507
|
}
|
|
495
508
|
/**
|
|
509
|
+
* Gets all wallets for the workspace
|
|
510
|
+
* @returns Promise with list of wallets
|
|
511
|
+
*/ async getWallets() {
|
|
512
|
+
if (!this.workspaceId) {
|
|
513
|
+
throw new Error('Workspace ID is required. Please set workspaceId in the constructor.');
|
|
514
|
+
}
|
|
515
|
+
const wallets = await this.apiService.getWallets(this.workspaceId);
|
|
516
|
+
return wallets;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
496
519
|
* Gets the current status of a wallet creation process
|
|
497
520
|
* @param walletId The ID of the wallet being created
|
|
498
521
|
* @returns Promise with wallet creation status details
|
|
@@ -560,9 +583,10 @@ class FystackSDK {
|
|
|
560
583
|
await this.apiService.rescanTransaction(params);
|
|
561
584
|
}
|
|
562
585
|
constructor(options){
|
|
563
|
-
const { credentials, environment = exports.Environment.Production, logger = false } = options;
|
|
586
|
+
const { credentials, workspaceId, environment = exports.Environment.Production, logger = false } = options;
|
|
564
587
|
this.apiService = new APIService(credentials, environment);
|
|
565
588
|
this.enableLogging = logger;
|
|
589
|
+
this.workspaceId = workspaceId;
|
|
566
590
|
}
|
|
567
591
|
}
|
|
568
592
|
|
|
@@ -663,6 +687,12 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
663
687
|
async signTransaction(tx) {
|
|
664
688
|
const startTime = new Date();
|
|
665
689
|
console.log(`[WalletSDK] Transaction started at: ${startTime.toLocaleString()}`);
|
|
690
|
+
if (!this.address) {
|
|
691
|
+
await this.getAddress();
|
|
692
|
+
}
|
|
693
|
+
if (!this.walletDetail) {
|
|
694
|
+
this.walletDetail = await this.APIService.getWalletDetail();
|
|
695
|
+
}
|
|
666
696
|
// Replace any Addressable or ENS name with an address
|
|
667
697
|
const { to, from } = await ethers.resolveProperties({
|
|
668
698
|
to: tx.to ? ethers.resolveAddress(tx.to, this.provider) : undefined,
|
|
@@ -706,9 +736,13 @@ class EtherSigner extends ethers.AbstractSigner {
|
|
|
706
736
|
async sendTransaction(tx) {
|
|
707
737
|
const startTime = new Date();
|
|
708
738
|
console.log(`[WalletSDK] sendTransaction started at: ${startTime.toLocaleString()}`);
|
|
739
|
+
debugger;
|
|
709
740
|
if (!this.address) {
|
|
710
741
|
await this.getAddress();
|
|
711
742
|
}
|
|
743
|
+
if (!this.walletDetail) {
|
|
744
|
+
this.walletDetail = await this.APIService.getWalletDetail();
|
|
745
|
+
}
|
|
712
746
|
checkProvider(this, 'sendTransaction');
|
|
713
747
|
// Only populate if gas fees are not set
|
|
714
748
|
const hasGasFees = tx.gasPrice != null || tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null;
|
package/dist/index.d.cts
CHANGED
|
@@ -12,6 +12,7 @@ interface APIEndpoints {
|
|
|
12
12
|
getSignStatus: (walletId: string, transactionId: string) => string;
|
|
13
13
|
getTransactionStatus: (walletId: string, transactionId: string) => string;
|
|
14
14
|
getWalletDetail: (walletId?: string) => string;
|
|
15
|
+
getWallets: (workspaceId: string) => string;
|
|
15
16
|
createWallet: () => string;
|
|
16
17
|
createCheckout: () => string;
|
|
17
18
|
getCheckout: (checkoutId: string) => string;
|
|
@@ -313,6 +314,11 @@ declare enum TxApprovalStatus {
|
|
|
313
314
|
Approved = "approved",
|
|
314
315
|
Rejected = "rejected"
|
|
315
316
|
}
|
|
317
|
+
declare enum WalletRole {
|
|
318
|
+
Admin = "wallet_admin",
|
|
319
|
+
Signer = "wallet_signer",
|
|
320
|
+
Viewer = "wallet_viewer"
|
|
321
|
+
}
|
|
316
322
|
|
|
317
323
|
interface APIResponse {
|
|
318
324
|
data: any;
|
|
@@ -353,6 +359,7 @@ declare class APIService {
|
|
|
353
359
|
Webhook: WebhookService;
|
|
354
360
|
private API;
|
|
355
361
|
constructor(credentials: APICredentials, environment: Environment);
|
|
362
|
+
getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
|
|
356
363
|
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
357
364
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
358
365
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
@@ -529,15 +536,36 @@ interface RescanTransactionParams {
|
|
|
529
536
|
txHash: string;
|
|
530
537
|
networkId: string;
|
|
531
538
|
}
|
|
539
|
+
interface WalletResponse {
|
|
540
|
+
id: string;
|
|
541
|
+
name: string;
|
|
542
|
+
value_usd: string;
|
|
543
|
+
role: WalletRole;
|
|
544
|
+
}
|
|
545
|
+
interface TopAssets {
|
|
546
|
+
symbol: string;
|
|
547
|
+
logo_url: string;
|
|
548
|
+
}
|
|
549
|
+
interface WalletByWorkspaceResponse {
|
|
550
|
+
id: string;
|
|
551
|
+
name: string;
|
|
552
|
+
role: string;
|
|
553
|
+
wallet_type: string;
|
|
554
|
+
value_usd: string;
|
|
555
|
+
top_assets: TopAssets[];
|
|
556
|
+
wallet_purpose: string;
|
|
557
|
+
}
|
|
532
558
|
|
|
533
559
|
interface SDKOptions {
|
|
534
560
|
credentials: APICredentials;
|
|
561
|
+
workspaceId?: string;
|
|
535
562
|
environment?: Environment;
|
|
536
563
|
logger?: boolean;
|
|
537
564
|
}
|
|
538
565
|
declare class FystackSDK {
|
|
539
566
|
private apiService;
|
|
540
567
|
private enableLogging;
|
|
568
|
+
private workspaceId?;
|
|
541
569
|
constructor(options: SDKOptions);
|
|
542
570
|
private log;
|
|
543
571
|
/**
|
|
@@ -547,6 +575,11 @@ declare class FystackSDK {
|
|
|
547
575
|
* @returns Promise with wallet ID and status
|
|
548
576
|
*/
|
|
549
577
|
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
578
|
+
/**
|
|
579
|
+
* Gets all wallets for the workspace
|
|
580
|
+
* @returns Promise with list of wallets
|
|
581
|
+
*/
|
|
582
|
+
getWallets(): Promise<WalletByWorkspaceResponse[]>;
|
|
550
583
|
/**
|
|
551
584
|
* Gets the current status of a wallet creation process
|
|
552
585
|
* @param walletId The ID of the wallet being created
|
|
@@ -659,4 +692,4 @@ declare class SolanaSigner {
|
|
|
659
692
|
private incorporateSignatureIntoTransaction;
|
|
660
693
|
}
|
|
661
694
|
|
|
662
|
-
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, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, WalletType, type WebhookEvent, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
|
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 };
|
package/dist/index.d.mts
CHANGED
|
@@ -12,6 +12,7 @@ interface APIEndpoints {
|
|
|
12
12
|
getSignStatus: (walletId: string, transactionId: string) => string;
|
|
13
13
|
getTransactionStatus: (walletId: string, transactionId: string) => string;
|
|
14
14
|
getWalletDetail: (walletId?: string) => string;
|
|
15
|
+
getWallets: (workspaceId: string) => string;
|
|
15
16
|
createWallet: () => string;
|
|
16
17
|
createCheckout: () => string;
|
|
17
18
|
getCheckout: (checkoutId: string) => string;
|
|
@@ -313,6 +314,11 @@ declare enum TxApprovalStatus {
|
|
|
313
314
|
Approved = "approved",
|
|
314
315
|
Rejected = "rejected"
|
|
315
316
|
}
|
|
317
|
+
declare enum WalletRole {
|
|
318
|
+
Admin = "wallet_admin",
|
|
319
|
+
Signer = "wallet_signer",
|
|
320
|
+
Viewer = "wallet_viewer"
|
|
321
|
+
}
|
|
316
322
|
|
|
317
323
|
interface APIResponse {
|
|
318
324
|
data: any;
|
|
@@ -353,6 +359,7 @@ declare class APIService {
|
|
|
353
359
|
Webhook: WebhookService;
|
|
354
360
|
private API;
|
|
355
361
|
constructor(credentials: APICredentials, environment: Environment);
|
|
362
|
+
getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
|
|
356
363
|
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
357
364
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
358
365
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
@@ -529,15 +536,36 @@ interface RescanTransactionParams {
|
|
|
529
536
|
txHash: string;
|
|
530
537
|
networkId: string;
|
|
531
538
|
}
|
|
539
|
+
interface WalletResponse {
|
|
540
|
+
id: string;
|
|
541
|
+
name: string;
|
|
542
|
+
value_usd: string;
|
|
543
|
+
role: WalletRole;
|
|
544
|
+
}
|
|
545
|
+
interface TopAssets {
|
|
546
|
+
symbol: string;
|
|
547
|
+
logo_url: string;
|
|
548
|
+
}
|
|
549
|
+
interface WalletByWorkspaceResponse {
|
|
550
|
+
id: string;
|
|
551
|
+
name: string;
|
|
552
|
+
role: string;
|
|
553
|
+
wallet_type: string;
|
|
554
|
+
value_usd: string;
|
|
555
|
+
top_assets: TopAssets[];
|
|
556
|
+
wallet_purpose: string;
|
|
557
|
+
}
|
|
532
558
|
|
|
533
559
|
interface SDKOptions {
|
|
534
560
|
credentials: APICredentials;
|
|
561
|
+
workspaceId?: string;
|
|
535
562
|
environment?: Environment;
|
|
536
563
|
logger?: boolean;
|
|
537
564
|
}
|
|
538
565
|
declare class FystackSDK {
|
|
539
566
|
private apiService;
|
|
540
567
|
private enableLogging;
|
|
568
|
+
private workspaceId?;
|
|
541
569
|
constructor(options: SDKOptions);
|
|
542
570
|
private log;
|
|
543
571
|
/**
|
|
@@ -547,6 +575,11 @@ declare class FystackSDK {
|
|
|
547
575
|
* @returns Promise with wallet ID and status
|
|
548
576
|
*/
|
|
549
577
|
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
578
|
+
/**
|
|
579
|
+
* Gets all wallets for the workspace
|
|
580
|
+
* @returns Promise with list of wallets
|
|
581
|
+
*/
|
|
582
|
+
getWallets(): Promise<WalletByWorkspaceResponse[]>;
|
|
550
583
|
/**
|
|
551
584
|
* Gets the current status of a wallet creation process
|
|
552
585
|
* @param walletId The ID of the wallet being created
|
|
@@ -659,4 +692,4 @@ declare class SolanaSigner {
|
|
|
659
692
|
private incorporateSignatureIntoTransaction;
|
|
660
693
|
}
|
|
661
694
|
|
|
662
|
-
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, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, WalletType, type WebhookEvent, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
|
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 };
|
package/dist/index.esm.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ interface APIEndpoints {
|
|
|
12
12
|
getSignStatus: (walletId: string, transactionId: string) => string;
|
|
13
13
|
getTransactionStatus: (walletId: string, transactionId: string) => string;
|
|
14
14
|
getWalletDetail: (walletId?: string) => string;
|
|
15
|
+
getWallets: (workspaceId: string) => string;
|
|
15
16
|
createWallet: () => string;
|
|
16
17
|
createCheckout: () => string;
|
|
17
18
|
getCheckout: (checkoutId: string) => string;
|
|
@@ -313,6 +314,11 @@ declare enum TxApprovalStatus {
|
|
|
313
314
|
Approved = "approved",
|
|
314
315
|
Rejected = "rejected"
|
|
315
316
|
}
|
|
317
|
+
declare enum WalletRole {
|
|
318
|
+
Admin = "wallet_admin",
|
|
319
|
+
Signer = "wallet_signer",
|
|
320
|
+
Viewer = "wallet_viewer"
|
|
321
|
+
}
|
|
316
322
|
|
|
317
323
|
interface APIResponse {
|
|
318
324
|
data: any;
|
|
@@ -353,6 +359,7 @@ declare class APIService {
|
|
|
353
359
|
Webhook: WebhookService;
|
|
354
360
|
private API;
|
|
355
361
|
constructor(credentials: APICredentials, environment: Environment);
|
|
362
|
+
getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
|
|
356
363
|
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
357
364
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
358
365
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
@@ -529,15 +536,36 @@ interface RescanTransactionParams {
|
|
|
529
536
|
txHash: string;
|
|
530
537
|
networkId: string;
|
|
531
538
|
}
|
|
539
|
+
interface WalletResponse {
|
|
540
|
+
id: string;
|
|
541
|
+
name: string;
|
|
542
|
+
value_usd: string;
|
|
543
|
+
role: WalletRole;
|
|
544
|
+
}
|
|
545
|
+
interface TopAssets {
|
|
546
|
+
symbol: string;
|
|
547
|
+
logo_url: string;
|
|
548
|
+
}
|
|
549
|
+
interface WalletByWorkspaceResponse {
|
|
550
|
+
id: string;
|
|
551
|
+
name: string;
|
|
552
|
+
role: string;
|
|
553
|
+
wallet_type: string;
|
|
554
|
+
value_usd: string;
|
|
555
|
+
top_assets: TopAssets[];
|
|
556
|
+
wallet_purpose: string;
|
|
557
|
+
}
|
|
532
558
|
|
|
533
559
|
interface SDKOptions {
|
|
534
560
|
credentials: APICredentials;
|
|
561
|
+
workspaceId?: string;
|
|
535
562
|
environment?: Environment;
|
|
536
563
|
logger?: boolean;
|
|
537
564
|
}
|
|
538
565
|
declare class FystackSDK {
|
|
539
566
|
private apiService;
|
|
540
567
|
private enableLogging;
|
|
568
|
+
private workspaceId?;
|
|
541
569
|
constructor(options: SDKOptions);
|
|
542
570
|
private log;
|
|
543
571
|
/**
|
|
@@ -547,6 +575,11 @@ declare class FystackSDK {
|
|
|
547
575
|
* @returns Promise with wallet ID and status
|
|
548
576
|
*/
|
|
549
577
|
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
578
|
+
/**
|
|
579
|
+
* Gets all wallets for the workspace
|
|
580
|
+
* @returns Promise with list of wallets
|
|
581
|
+
*/
|
|
582
|
+
getWallets(): Promise<WalletByWorkspaceResponse[]>;
|
|
550
583
|
/**
|
|
551
584
|
* Gets the current status of a wallet creation process
|
|
552
585
|
* @param walletId The ID of the wallet being created
|
|
@@ -659,4 +692,4 @@ declare class SolanaSigner {
|
|
|
659
692
|
private incorporateSignatureIntoTransaction;
|
|
660
693
|
}
|
|
661
694
|
|
|
662
|
-
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, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, WalletType, type WebhookEvent, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
|
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 };
|
package/dist/index.esm.js
CHANGED
|
@@ -29,6 +29,7 @@ const createAPI = (env)=>{
|
|
|
29
29
|
endpoints: {
|
|
30
30
|
signTransaction: (walletId)=>withBaseURL(`/web3/transaction/${walletId}/signRaw`),
|
|
31
31
|
getWalletDetail: (walletId)=>walletId ? withBaseURL(`/web3/wallet-detail/${walletId}`) : withBaseURL('/web3/wallet-detail'),
|
|
32
|
+
getWallets: (workspaceId)=>withBaseURL(`/workspaces/${workspaceId}/wallets`),
|
|
32
33
|
createWallet: ()=>withBaseURL('/wallets'),
|
|
33
34
|
createCheckout: ()=>withBaseURL('/checkouts'),
|
|
34
35
|
getCheckout: (checkoutId)=>withBaseURL(`/checkouts/${checkoutId}`),
|
|
@@ -166,6 +167,12 @@ var TxApprovalStatus;
|
|
|
166
167
|
TxApprovalStatus["Approved"] = "approved";
|
|
167
168
|
TxApprovalStatus["Rejected"] = "rejected";
|
|
168
169
|
})(TxApprovalStatus || (TxApprovalStatus = {}));
|
|
170
|
+
var WalletRole;
|
|
171
|
+
(function(WalletRole) {
|
|
172
|
+
WalletRole["Admin"] = "wallet_admin";
|
|
173
|
+
WalletRole["Signer"] = "wallet_signer";
|
|
174
|
+
WalletRole["Viewer"] = "wallet_viewer";
|
|
175
|
+
})(WalletRole || (WalletRole = {}));
|
|
169
176
|
|
|
170
177
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
171
178
|
if (credentials.apiSecret == '') {
|
|
@@ -197,6 +204,12 @@ async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}
|
|
|
197
204
|
return headers;
|
|
198
205
|
}
|
|
199
206
|
class APIService {
|
|
207
|
+
async getWallets(workspaceId) {
|
|
208
|
+
const endpoint = this.API.endpoints.getWallets(workspaceId);
|
|
209
|
+
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
210
|
+
const response = await get(endpoint, headers);
|
|
211
|
+
return response.data;
|
|
212
|
+
}
|
|
200
213
|
async getWalletDetail(addressType = AddressType.Evm, walletId) {
|
|
201
214
|
const endpoint = this.API.endpoints.getWalletDetail(walletId);
|
|
202
215
|
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
@@ -485,6 +498,16 @@ class FystackSDK {
|
|
|
485
498
|
return response;
|
|
486
499
|
}
|
|
487
500
|
/**
|
|
501
|
+
* Gets all wallets for the workspace
|
|
502
|
+
* @returns Promise with list of wallets
|
|
503
|
+
*/ async getWallets() {
|
|
504
|
+
if (!this.workspaceId) {
|
|
505
|
+
throw new Error('Workspace ID is required. Please set workspaceId in the constructor.');
|
|
506
|
+
}
|
|
507
|
+
const wallets = await this.apiService.getWallets(this.workspaceId);
|
|
508
|
+
return wallets;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
488
511
|
* Gets the current status of a wallet creation process
|
|
489
512
|
* @param walletId The ID of the wallet being created
|
|
490
513
|
* @returns Promise with wallet creation status details
|
|
@@ -552,9 +575,10 @@ class FystackSDK {
|
|
|
552
575
|
await this.apiService.rescanTransaction(params);
|
|
553
576
|
}
|
|
554
577
|
constructor(options){
|
|
555
|
-
const { credentials, environment = Environment.Production, logger = false } = options;
|
|
578
|
+
const { credentials, workspaceId, environment = Environment.Production, logger = false } = options;
|
|
556
579
|
this.apiService = new APIService(credentials, environment);
|
|
557
580
|
this.enableLogging = logger;
|
|
581
|
+
this.workspaceId = workspaceId;
|
|
558
582
|
}
|
|
559
583
|
}
|
|
560
584
|
|
|
@@ -655,6 +679,12 @@ class EtherSigner extends AbstractSigner {
|
|
|
655
679
|
async signTransaction(tx) {
|
|
656
680
|
const startTime = new Date();
|
|
657
681
|
console.log(`[WalletSDK] Transaction started at: ${startTime.toLocaleString()}`);
|
|
682
|
+
if (!this.address) {
|
|
683
|
+
await this.getAddress();
|
|
684
|
+
}
|
|
685
|
+
if (!this.walletDetail) {
|
|
686
|
+
this.walletDetail = await this.APIService.getWalletDetail();
|
|
687
|
+
}
|
|
658
688
|
// Replace any Addressable or ENS name with an address
|
|
659
689
|
const { to, from } = await resolveProperties({
|
|
660
690
|
to: tx.to ? resolveAddress(tx.to, this.provider) : undefined,
|
|
@@ -698,9 +728,13 @@ class EtherSigner extends AbstractSigner {
|
|
|
698
728
|
async sendTransaction(tx) {
|
|
699
729
|
const startTime = new Date();
|
|
700
730
|
console.log(`[WalletSDK] sendTransaction started at: ${startTime.toLocaleString()}`);
|
|
731
|
+
debugger;
|
|
701
732
|
if (!this.address) {
|
|
702
733
|
await this.getAddress();
|
|
703
734
|
}
|
|
735
|
+
if (!this.walletDetail) {
|
|
736
|
+
this.walletDetail = await this.APIService.getWalletDetail();
|
|
737
|
+
}
|
|
704
738
|
checkProvider(this, 'sendTransaction');
|
|
705
739
|
// Only populate if gas fees are not set
|
|
706
740
|
const hasGasFees = tx.gasPrice != null || tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null;
|
|
@@ -999,4 +1033,4 @@ class SolanaSigner {
|
|
|
999
1033
|
}
|
|
1000
1034
|
}
|
|
1001
1035
|
|
|
1002
|
-
export { APIService, AddressType, DEFAULT_POLLER_OPTIONS, DestinationType, Environment, EtherSigner, FystackSDK, PaymentService, SolanaSigner, StatusPoller, TransactionError, TxApprovalStatus, TxStatus, WalletCreationStatus, WalletPurpose, WalletType, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
|
1036
|
+
export { APIService, AddressType, DEFAULT_POLLER_OPTIONS, DestinationType, Environment, EtherSigner, FystackSDK, PaymentService, SolanaSigner, StatusPoller, TransactionError, TxApprovalStatus, TxStatus, WalletCreationStatus, WalletPurpose, WalletRole, WalletType, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
package/dist/index.mjs
CHANGED
|
@@ -29,6 +29,7 @@ const createAPI = (env)=>{
|
|
|
29
29
|
endpoints: {
|
|
30
30
|
signTransaction: (walletId)=>withBaseURL(`/web3/transaction/${walletId}/signRaw`),
|
|
31
31
|
getWalletDetail: (walletId)=>walletId ? withBaseURL(`/web3/wallet-detail/${walletId}`) : withBaseURL('/web3/wallet-detail'),
|
|
32
|
+
getWallets: (workspaceId)=>withBaseURL(`/workspaces/${workspaceId}/wallets`),
|
|
32
33
|
createWallet: ()=>withBaseURL('/wallets'),
|
|
33
34
|
createCheckout: ()=>withBaseURL('/checkouts'),
|
|
34
35
|
getCheckout: (checkoutId)=>withBaseURL(`/checkouts/${checkoutId}`),
|
|
@@ -166,6 +167,12 @@ var TxApprovalStatus;
|
|
|
166
167
|
TxApprovalStatus["Approved"] = "approved";
|
|
167
168
|
TxApprovalStatus["Rejected"] = "rejected";
|
|
168
169
|
})(TxApprovalStatus || (TxApprovalStatus = {}));
|
|
170
|
+
var WalletRole;
|
|
171
|
+
(function(WalletRole) {
|
|
172
|
+
WalletRole["Admin"] = "wallet_admin";
|
|
173
|
+
WalletRole["Signer"] = "wallet_signer";
|
|
174
|
+
WalletRole["Viewer"] = "wallet_viewer";
|
|
175
|
+
})(WalletRole || (WalletRole = {}));
|
|
169
176
|
|
|
170
177
|
async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}) {
|
|
171
178
|
if (credentials.apiSecret == '') {
|
|
@@ -197,6 +204,12 @@ async function composeAPIHeaders(credentials, httpMethod, apiEndpoint, body = {}
|
|
|
197
204
|
return headers;
|
|
198
205
|
}
|
|
199
206
|
class APIService {
|
|
207
|
+
async getWallets(workspaceId) {
|
|
208
|
+
const endpoint = this.API.endpoints.getWallets(workspaceId);
|
|
209
|
+
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
210
|
+
const response = await get(endpoint, headers);
|
|
211
|
+
return response.data;
|
|
212
|
+
}
|
|
200
213
|
async getWalletDetail(addressType = AddressType.Evm, walletId) {
|
|
201
214
|
const endpoint = this.API.endpoints.getWalletDetail(walletId);
|
|
202
215
|
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint);
|
|
@@ -485,6 +498,16 @@ class FystackSDK {
|
|
|
485
498
|
return response;
|
|
486
499
|
}
|
|
487
500
|
/**
|
|
501
|
+
* Gets all wallets for the workspace
|
|
502
|
+
* @returns Promise with list of wallets
|
|
503
|
+
*/ async getWallets() {
|
|
504
|
+
if (!this.workspaceId) {
|
|
505
|
+
throw new Error('Workspace ID is required. Please set workspaceId in the constructor.');
|
|
506
|
+
}
|
|
507
|
+
const wallets = await this.apiService.getWallets(this.workspaceId);
|
|
508
|
+
return wallets;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
488
511
|
* Gets the current status of a wallet creation process
|
|
489
512
|
* @param walletId The ID of the wallet being created
|
|
490
513
|
* @returns Promise with wallet creation status details
|
|
@@ -552,9 +575,10 @@ class FystackSDK {
|
|
|
552
575
|
await this.apiService.rescanTransaction(params);
|
|
553
576
|
}
|
|
554
577
|
constructor(options){
|
|
555
|
-
const { credentials, environment = Environment.Production, logger = false } = options;
|
|
578
|
+
const { credentials, workspaceId, environment = Environment.Production, logger = false } = options;
|
|
556
579
|
this.apiService = new APIService(credentials, environment);
|
|
557
580
|
this.enableLogging = logger;
|
|
581
|
+
this.workspaceId = workspaceId;
|
|
558
582
|
}
|
|
559
583
|
}
|
|
560
584
|
|
|
@@ -655,6 +679,12 @@ class EtherSigner extends AbstractSigner {
|
|
|
655
679
|
async signTransaction(tx) {
|
|
656
680
|
const startTime = new Date();
|
|
657
681
|
console.log(`[WalletSDK] Transaction started at: ${startTime.toLocaleString()}`);
|
|
682
|
+
if (!this.address) {
|
|
683
|
+
await this.getAddress();
|
|
684
|
+
}
|
|
685
|
+
if (!this.walletDetail) {
|
|
686
|
+
this.walletDetail = await this.APIService.getWalletDetail();
|
|
687
|
+
}
|
|
658
688
|
// Replace any Addressable or ENS name with an address
|
|
659
689
|
const { to, from } = await resolveProperties({
|
|
660
690
|
to: tx.to ? resolveAddress(tx.to, this.provider) : undefined,
|
|
@@ -698,9 +728,13 @@ class EtherSigner extends AbstractSigner {
|
|
|
698
728
|
async sendTransaction(tx) {
|
|
699
729
|
const startTime = new Date();
|
|
700
730
|
console.log(`[WalletSDK] sendTransaction started at: ${startTime.toLocaleString()}`);
|
|
731
|
+
debugger;
|
|
701
732
|
if (!this.address) {
|
|
702
733
|
await this.getAddress();
|
|
703
734
|
}
|
|
735
|
+
if (!this.walletDetail) {
|
|
736
|
+
this.walletDetail = await this.APIService.getWalletDetail();
|
|
737
|
+
}
|
|
704
738
|
checkProvider(this, 'sendTransaction');
|
|
705
739
|
// Only populate if gas fees are not set
|
|
706
740
|
const hasGasFees = tx.gasPrice != null || tx.maxFeePerGas != null && tx.maxPriorityFeePerGas != null;
|
|
@@ -999,4 +1033,4 @@ class SolanaSigner {
|
|
|
999
1033
|
}
|
|
1000
1034
|
}
|
|
1001
1035
|
|
|
1002
|
-
export { APIService, AddressType, DEFAULT_POLLER_OPTIONS, DestinationType, Environment, EtherSigner, FystackSDK, PaymentService, SolanaSigner, StatusPoller, TransactionError, TxApprovalStatus, TxStatus, WalletCreationStatus, WalletPurpose, WalletType, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
|
1036
|
+
export { APIService, AddressType, DEFAULT_POLLER_OPTIONS, DestinationType, Environment, EtherSigner, FystackSDK, PaymentService, SolanaSigner, StatusPoller, TransactionError, TxApprovalStatus, TxStatus, WalletCreationStatus, WalletPurpose, WalletRole, WalletType, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ interface APIEndpoints {
|
|
|
12
12
|
getSignStatus: (walletId: string, transactionId: string) => string;
|
|
13
13
|
getTransactionStatus: (walletId: string, transactionId: string) => string;
|
|
14
14
|
getWalletDetail: (walletId?: string) => string;
|
|
15
|
+
getWallets: (workspaceId: string) => string;
|
|
15
16
|
createWallet: () => string;
|
|
16
17
|
createCheckout: () => string;
|
|
17
18
|
getCheckout: (checkoutId: string) => string;
|
|
@@ -313,6 +314,11 @@ declare enum TxApprovalStatus {
|
|
|
313
314
|
Approved = "approved",
|
|
314
315
|
Rejected = "rejected"
|
|
315
316
|
}
|
|
317
|
+
declare enum WalletRole {
|
|
318
|
+
Admin = "wallet_admin",
|
|
319
|
+
Signer = "wallet_signer",
|
|
320
|
+
Viewer = "wallet_viewer"
|
|
321
|
+
}
|
|
316
322
|
|
|
317
323
|
interface APIResponse {
|
|
318
324
|
data: any;
|
|
@@ -353,6 +359,7 @@ declare class APIService {
|
|
|
353
359
|
Webhook: WebhookService;
|
|
354
360
|
private API;
|
|
355
361
|
constructor(credentials: APICredentials, environment: Environment);
|
|
362
|
+
getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]>;
|
|
356
363
|
getWalletDetail(addressType?: AddressType, walletId?: string): Promise<WalletDetail>;
|
|
357
364
|
requestSign(walletId: string, params: SignRequestParams): Promise<SignResponse>;
|
|
358
365
|
getSignStatus(walletId: string, transactionId: string): Promise<SignatureStatusResponse>;
|
|
@@ -529,15 +536,36 @@ interface RescanTransactionParams {
|
|
|
529
536
|
txHash: string;
|
|
530
537
|
networkId: string;
|
|
531
538
|
}
|
|
539
|
+
interface WalletResponse {
|
|
540
|
+
id: string;
|
|
541
|
+
name: string;
|
|
542
|
+
value_usd: string;
|
|
543
|
+
role: WalletRole;
|
|
544
|
+
}
|
|
545
|
+
interface TopAssets {
|
|
546
|
+
symbol: string;
|
|
547
|
+
logo_url: string;
|
|
548
|
+
}
|
|
549
|
+
interface WalletByWorkspaceResponse {
|
|
550
|
+
id: string;
|
|
551
|
+
name: string;
|
|
552
|
+
role: string;
|
|
553
|
+
wallet_type: string;
|
|
554
|
+
value_usd: string;
|
|
555
|
+
top_assets: TopAssets[];
|
|
556
|
+
wallet_purpose: string;
|
|
557
|
+
}
|
|
532
558
|
|
|
533
559
|
interface SDKOptions {
|
|
534
560
|
credentials: APICredentials;
|
|
561
|
+
workspaceId?: string;
|
|
535
562
|
environment?: Environment;
|
|
536
563
|
logger?: boolean;
|
|
537
564
|
}
|
|
538
565
|
declare class FystackSDK {
|
|
539
566
|
private apiService;
|
|
540
567
|
private enableLogging;
|
|
568
|
+
private workspaceId?;
|
|
541
569
|
constructor(options: SDKOptions);
|
|
542
570
|
private log;
|
|
543
571
|
/**
|
|
@@ -547,6 +575,11 @@ declare class FystackSDK {
|
|
|
547
575
|
* @returns Promise with wallet ID and status
|
|
548
576
|
*/
|
|
549
577
|
createWallet(options: CreateWalletOptions, waitForCompletion?: boolean): Promise<CreateWalletResponse>;
|
|
578
|
+
/**
|
|
579
|
+
* Gets all wallets for the workspace
|
|
580
|
+
* @returns Promise with list of wallets
|
|
581
|
+
*/
|
|
582
|
+
getWallets(): Promise<WalletByWorkspaceResponse[]>;
|
|
550
583
|
/**
|
|
551
584
|
* Gets the current status of a wallet creation process
|
|
552
585
|
* @param walletId The ID of the wallet being created
|
|
@@ -659,4 +692,4 @@ declare class SolanaSigner {
|
|
|
659
692
|
private incorporateSignatureIntoTransaction;
|
|
660
693
|
}
|
|
661
694
|
|
|
662
|
-
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, TransactionError, type TransactionStatusResponse, TxApprovalStatus, TxStatus, type WalletAsset, type WalletAssetDetail, type WalletAssetNetwork, WalletCreationStatus, type WalletCreationStatusResponse, type WalletDetail, WalletPurpose, WalletType, type WebhookEvent, WebhookService, createAPI, get, post, transformCreateWalletPayload, transformRescanTransactionParams, transformWalletDetail };
|
|
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 };
|
package/package.json
CHANGED
package/src/api.ts
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
WalletCreationStatusResponse,
|
|
13
13
|
WalletAsset,
|
|
14
14
|
DepositAddressResponse,
|
|
15
|
-
RescanTransactionParams
|
|
15
|
+
RescanTransactionParams,
|
|
16
|
+
WalletByWorkspaceResponse
|
|
16
17
|
} from './types'
|
|
17
18
|
import {
|
|
18
19
|
CreateCheckoutPayload,
|
|
@@ -113,6 +114,13 @@ export class APIService {
|
|
|
113
114
|
this.API = createAPI(environment)
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
async getWallets(workspaceId: string): Promise<WalletByWorkspaceResponse[]> {
|
|
118
|
+
const endpoint = this.API.endpoints.getWallets(workspaceId)
|
|
119
|
+
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint)
|
|
120
|
+
const response = await get(endpoint, headers)
|
|
121
|
+
return response.data
|
|
122
|
+
}
|
|
123
|
+
|
|
116
124
|
async getWalletDetail(addressType = AddressType.Evm, walletId?: string): Promise<WalletDetail> {
|
|
117
125
|
const endpoint = this.API.endpoints.getWalletDetail(walletId)
|
|
118
126
|
const headers = await composeAPIHeaders(this.credentials, 'GET', endpoint)
|
package/src/config.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface APIEndpoints {
|
|
|
11
11
|
getSignStatus: (walletId: string, transactionId: string) => string
|
|
12
12
|
getTransactionStatus: (walletId: string, transactionId: string) => string
|
|
13
13
|
getWalletDetail: (walletId?: string) => string
|
|
14
|
+
getWallets: (workspaceId: string) => string
|
|
14
15
|
createWallet: () => string
|
|
15
16
|
createCheckout: () => string
|
|
16
17
|
getCheckout: (checkoutId: string) => string
|
|
@@ -51,6 +52,7 @@ const createAPI = (env: Environment): APIConfig => {
|
|
|
51
52
|
walletId
|
|
52
53
|
? withBaseURL(`/web3/wallet-detail/${walletId}`)
|
|
53
54
|
: withBaseURL('/web3/wallet-detail'),
|
|
55
|
+
getWallets: (workspaceId: string) => withBaseURL(`/workspaces/${workspaceId}/wallets`),
|
|
54
56
|
createWallet: () => withBaseURL('/wallets'),
|
|
55
57
|
createCheckout: () => withBaseURL('/checkouts'),
|
|
56
58
|
getCheckout: (checkoutId: string) => withBaseURL(`/checkouts/${checkoutId}`),
|
package/src/enum.ts
CHANGED
package/src/sdk.ts
CHANGED
|
@@ -8,13 +8,15 @@ import {
|
|
|
8
8
|
DepositAddressResponse,
|
|
9
9
|
APICredentials,
|
|
10
10
|
CreateWalletOptions,
|
|
11
|
-
RescanTransactionParams
|
|
11
|
+
RescanTransactionParams,
|
|
12
|
+
WalletByWorkspaceResponse
|
|
12
13
|
} from './types'
|
|
13
14
|
import { validateUUID } from './utils'
|
|
14
15
|
import { AddressType, WalletCreationStatus, WalletType } from './enum'
|
|
15
16
|
|
|
16
17
|
export interface SDKOptions {
|
|
17
18
|
credentials: APICredentials
|
|
19
|
+
workspaceId?: string
|
|
18
20
|
environment?: Environment
|
|
19
21
|
logger?: boolean
|
|
20
22
|
}
|
|
@@ -22,11 +24,18 @@ export interface SDKOptions {
|
|
|
22
24
|
export class FystackSDK {
|
|
23
25
|
private apiService: APIService
|
|
24
26
|
private enableLogging: boolean
|
|
27
|
+
private workspaceId?: string
|
|
25
28
|
|
|
26
29
|
constructor(options: SDKOptions) {
|
|
27
|
-
const {
|
|
30
|
+
const {
|
|
31
|
+
credentials,
|
|
32
|
+
workspaceId,
|
|
33
|
+
environment = Environment.Production,
|
|
34
|
+
logger = false
|
|
35
|
+
} = options
|
|
28
36
|
this.apiService = new APIService(credentials, environment)
|
|
29
37
|
this.enableLogging = logger
|
|
38
|
+
this.workspaceId = workspaceId
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
private log(message: string): void {
|
|
@@ -68,6 +77,19 @@ export class FystackSDK {
|
|
|
68
77
|
return response
|
|
69
78
|
}
|
|
70
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Gets all wallets for the workspace
|
|
82
|
+
* @returns Promise with list of wallets
|
|
83
|
+
*/
|
|
84
|
+
async getWallets(): Promise<WalletByWorkspaceResponse[]> {
|
|
85
|
+
if (!this.workspaceId) {
|
|
86
|
+
throw new Error('Workspace ID is required. Please set workspaceId in the constructor.')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const wallets = await this.apiService.getWallets(this.workspaceId)
|
|
90
|
+
return wallets
|
|
91
|
+
}
|
|
92
|
+
|
|
71
93
|
/**
|
|
72
94
|
* Gets the current status of a wallet creation process
|
|
73
95
|
* @param walletId The ID of the wallet being created
|
package/src/signer.ts
CHANGED
|
@@ -169,6 +169,14 @@ export class EtherSigner extends AbstractSigner {
|
|
|
169
169
|
const startTime = new Date()
|
|
170
170
|
console.log(`[WalletSDK] Transaction started at: ${startTime.toLocaleString()}`)
|
|
171
171
|
|
|
172
|
+
if (!this.address) {
|
|
173
|
+
await this.getAddress()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (!this.walletDetail) {
|
|
177
|
+
this.walletDetail = await this.APIService.getWalletDetail()
|
|
178
|
+
}
|
|
179
|
+
|
|
172
180
|
// Replace any Addressable or ENS name with an address
|
|
173
181
|
const { to, from } = await resolveProperties({
|
|
174
182
|
to: tx.to ? resolveAddress(tx.to, this.provider) : undefined,
|
|
@@ -226,10 +234,15 @@ export class EtherSigner extends AbstractSigner {
|
|
|
226
234
|
const startTime = new Date()
|
|
227
235
|
console.log(`[WalletSDK] sendTransaction started at: ${startTime.toLocaleString()}`)
|
|
228
236
|
|
|
237
|
+
debugger
|
|
229
238
|
if (!this.address) {
|
|
230
239
|
await this.getAddress()
|
|
231
240
|
}
|
|
232
241
|
|
|
242
|
+
if (!this.walletDetail) {
|
|
243
|
+
this.walletDetail = await this.APIService.getWalletDetail()
|
|
244
|
+
}
|
|
245
|
+
|
|
233
246
|
checkProvider(this, 'sendTransaction')
|
|
234
247
|
|
|
235
248
|
// Only populate if gas fees are not set
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SweepTaskParams } from './api'
|
|
2
|
-
import { TxApprovalStatus, TxStatus, WalletCreationStatus, WalletPurpose, WalletType } from './enum'
|
|
2
|
+
import { TxApprovalStatus, TxStatus, WalletCreationStatus, WalletPurpose, WalletRole, WalletType } from './enum'
|
|
3
3
|
|
|
4
4
|
export class TransactionError extends Error {
|
|
5
5
|
constructor(
|
|
@@ -143,3 +143,25 @@ export interface RescanTransactionParams {
|
|
|
143
143
|
txHash: string
|
|
144
144
|
networkId: string
|
|
145
145
|
}
|
|
146
|
+
|
|
147
|
+
export interface WalletResponse {
|
|
148
|
+
id: string
|
|
149
|
+
name: string
|
|
150
|
+
value_usd: string
|
|
151
|
+
role: WalletRole
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface TopAssets {
|
|
155
|
+
symbol: string
|
|
156
|
+
logo_url: string
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface WalletByWorkspaceResponse {
|
|
160
|
+
id: string
|
|
161
|
+
name: string
|
|
162
|
+
role: string
|
|
163
|
+
wallet_type: string
|
|
164
|
+
value_usd: string
|
|
165
|
+
top_assets: TopAssets[]
|
|
166
|
+
wallet_purpose: string
|
|
167
|
+
}
|