diff --git a/examples/sell/src/pages/index.tsx b/examples/sell/src/pages/index.tsx index 6119d87..4e9b4e7 100644 --- a/examples/sell/src/pages/index.tsx +++ b/examples/sell/src/pages/index.tsx @@ -129,8 +129,8 @@ const IndexPage = () => { exchangeSDK.current ?.sell({ quoteId, - accountId: fromAccount, - amount: new BigNumber(amount), + fromAccountId: fromAccount, + fromAmount: new BigNumber(amount), feeStrategy: feeSelected as FeeStrategy, customFeeConfig, getSellPayload: async (nonce, address, amount) => { diff --git a/lib/src/sdk.test.ts b/lib/src/sdk.test.ts index e28b878..b37bb31 100644 --- a/lib/src/sdk.test.ts +++ b/lib/src/sdk.test.ts @@ -237,8 +237,8 @@ describe("sell", () => { }); const sellData = { quoteId: "quoteId", - accountId: "id-1", - amount: new BigNumber("1.908"), + fromAccountId: "id-1", + fromAmount: new BigNumber("1.908"), feeStrategy: "SLOW" as FeeStrategy, getSellPayload: mockSellPayload, }; @@ -276,8 +276,8 @@ describe("sell", () => { const sellData = { quoteId: "quoteId", - accountId: "id-1", - amount: new BigNumber("1.908"), + fromAccountId: "id-1", + fromAmount: new BigNumber("1.908"), feeStrategy: "SLOW" as FeeStrategy, toFiat: "EUR", rate: 1000, diff --git a/lib/src/sdk.ts b/lib/src/sdk.ts index 3945b45..3625ee5 100644 --- a/lib/src/sdk.ts +++ b/lib/src/sdk.ts @@ -80,10 +80,10 @@ export type GetSellPayload = ( */ export type SellInfo = { quoteId?: string; - accountId: string; - amount: BigNumber; + fromAccountId: string; + fromAmount: BigNumber; toFiat?: string; - feeStrategy: FeeStrategy; + feeStrategy?: FeeStrategy; rate?: number; customFeeConfig?: { [key: string]: BigNumber; @@ -93,6 +93,13 @@ export type SellInfo = { export type FeeStrategy = "SLOW" | "MEDIUM" | "FAST" | "CUSTOM"; +enum FeeStrategyEnum { + SLOW = "SLOW", + MEDIUM = "MEDIUM", + FAST = "FAST", + CUSTOM = "CUSTOM", +} + // Should be available from the WalletAPI (zod :( ) const ExchangeType = { FUND: "FUND", @@ -335,9 +342,9 @@ export class ExchangeSDK { this.logger.log("*** Start Sell ***"); const { - accountId, - amount: fromAmount, - feeStrategy, + fromAccountId, + fromAmount, + feeStrategy = FeeStrategyEnum.MEDIUM, customFeeConfig = {}, quoteId, rate, @@ -346,7 +353,7 @@ export class ExchangeSDK { } = info; const { account, currency } = await this.walletAPIDecorator - .retrieveUserAccount(accountId) + .retrieveUserAccount(fromAccountId) .catch((error: Error) => { this.handleError(error); throw error; @@ -418,7 +425,7 @@ export class ExchangeSDK { const tx = await this.exchangeModule .completeSell({ provider: this.providerId, - fromAccountId: accountId, + fromAccountId, transaction, binaryPayload: Buffer.from(binaryPayload), signature,