Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle sell flow retrieveUserAccount display error #65

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type SwapInfo = {
export type GetSellPayload = (
nonce: string,
sellAddress: string,
amount: bigint,
amount: bigint
) => Promise<{
recipientAddress: string;
amount: BigNumber;
Expand Down Expand Up @@ -113,7 +113,7 @@ export class ExchangeSDK {
providerId: string,
transport?: Transport,
walletAPI?: WalletAPIClient<typeof getCustomModule>,
customUrl?: string,
customUrl?: string
) {
this.providerId = providerId;
if (!walletAPI) {
Expand All @@ -126,7 +126,7 @@ export class ExchangeSDK {
}

this.walletAPIDecorator = walletApiDecorator(
new WalletAPIClient(this.transport, defaultLogger, getCustomModule),
new WalletAPIClient(this.transport, defaultLogger, getCustomModule)
);
} else {
this.walletAPIDecorator = walletApiDecorator(walletAPI);
Expand Down Expand Up @@ -303,6 +303,7 @@ export class ExchangeSDK {
const { account, currency } = await this.walletAPIDecorator
.retrieveUserAccount(accountId)
.catch((error: Error) => {
this.handleError(error);
throw error;
});

Expand All @@ -328,7 +329,7 @@ export class ExchangeSDK {
await getSellPayload(
deviceTransactionId,
account.address,
BigInt(initialAtomicAmount.toString()),
BigInt(initialAtomicAmount.toString())
);

// Check enough fund on the amount being set on the sell payload
Expand Down Expand Up @@ -385,11 +386,11 @@ export class ExchangeSDK {
function canSpendAmount(
account: Account,
amount: bigint,
logger: Logger,
logger: Logger
): void {
if (
account.spendableBalance.isGreaterThanOrEqualTo(
new BigNumber(amount.toString()),
new BigNumber(amount.toString())
) === false
) {
const err = new NotEnoughFunds();
Expand Down
Loading