Skip to content

Commit

Permalink
Better find by symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
SethMcGuire committed Mar 21, 2024
1 parent cd11d32 commit 7bbc8ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/bitcore-client/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export class Wallet {
let payload;
if (token || tokenName) {
let tokenObj = tokenName && this.tokens.find(tok => tok.name === tokenName);
tokenObj = tokenObj || (token && this.tokens.find(tok => tok.symbol === token && tok.name == undefined));
tokenObj = tokenObj || (token && this.tokens.find(tok => tok.symbol === token && [token, undefined].includes(tok.name)));
if (!tokenObj) {
throw new Error(`${tokenName || token} not found on wallet ${this.name}`);
}
Expand Down Expand Up @@ -375,7 +375,7 @@ export class Wallet {
const { token, tokenName } = params;
if (token || tokenName) {
let tokenObj = tokenName && this.tokens.find(tok => tok.name === tokenName);
tokenObj = tokenObj || (token && this.tokens.find(tok => tok.symbol === token && tok.name == undefined));
tokenObj = tokenObj || (token && this.tokens.find(tok => tok.symbol === token && [token, undefined].includes(tok.name)));
if (!tokenObj) {
throw new Error(`${tokenName || token} not found on wallet ${this.name}`);
}
Expand Down Expand Up @@ -431,7 +431,7 @@ export class Wallet {
let tokenContractAddress;
if (params.token || params.tokenName) {
let tokenObj = params.tokenName && this.tokens.find(tok => tok.name === params.tokenName);
tokenObj = tokenObj || (params.token && this.tokens.find(tok => tok.symbol === params.token && tok.name == undefined));
tokenObj = tokenObj || (params.token && this.tokens.find(tok => tok.symbol === params.token && [params.token, undefined].includes(tok.name)));
if (!tokenObj) {
throw new Error(`${params.tokenName || params.token} not found on wallet ${this.name}`);
}
Expand Down

0 comments on commit 7bbc8ed

Please sign in to comment.