Skip to content

Commit

Permalink
chore: update param names for sell
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiercinska committed Sep 11, 2024
1 parent 0961bda commit 156337d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions examples/sell/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 4 additions & 4 deletions lib/src/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
Expand Down
23 changes: 15 additions & 8 deletions lib/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 156337d

Please sign in to comment.