Skip to content

Commit

Permalink
A little more flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ly0va committed May 25, 2021
1 parent 9241311 commit 8df1951
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions sdk/zksync.js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ export type Ratio = [BigNumberish, BigNumberish];

export type TokenRatio = {
type: 'Token';
[token: string]: string;
[token: number]: string;
[token: string]: string | number;
[token: number]: string | number;
};

export type WeiRatio = {
Expand Down
2 changes: 1 addition & 1 deletion sdk/zksync.js/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const AMOUNT_MANTISSA_BIT_WIDTH = 35;
const FEE_EXPONENT_BIT_WIDTH = 5;
const FEE_MANTISSA_BIT_WIDTH = 11;

export function tokenRatio(ratio: { [token: string]: string; [token: number]: string }): TokenRatio {
export function tokenRatio(ratio: { [token: string]: string | number; [token: number]: string | number }): TokenRatio {
return {
type: 'Token',
...ratio
Expand Down
6 changes: 4 additions & 2 deletions sdk/zksync.js/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ export class Wallet {
ratio = [
isNFT(sell)
? BigNumber.from(order.ratio[sell])
: this.provider.tokenSet.parseToken(sell, order.ratio[sell]),
isNFT(buy) ? BigNumber.from(order.ratio[buy]) : this.provider.tokenSet.parseToken(buy, order.ratio[buy])
: this.provider.tokenSet.parseToken(sell, order.ratio[sell].toString()),
isNFT(buy)
? BigNumber.from(order.ratio[buy])
: this.provider.tokenSet.parseToken(buy, order.ratio[buy].toString())
];
}

Expand Down

0 comments on commit 8df1951

Please sign in to comment.