Skip to content

Commit

Permalink
Merge pull request #1959 from ExchangeUnion/fix/addcurrency-yargs-con…
Browse files Browse the repository at this point in the history
…next-address-#1957

fix:incorrect address conversion for connext currencies while adding currencies #1957
  • Loading branch information
sangaman authored Oct 27, 2020
2 parents b2aa76d + 9d85c89 commit 41d103c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/cli/commands/addcurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export const builder = (argv: Argv) => argv
.option('token_address', {
description: 'the contract address for tokens such as ERC20',
type: 'string',
coerce: (address) => {
if (address.startsWith('0x')) {
return address;
}
// yargs converts only number addresses into decimal, so we need to revert it to hexadecimal
const hexAddress = address.toString(16);
return `0x${hexAddress.padStart(41 - hexAddress.length, '0')}`;
},
})
.example('$0 addcurrency BTC Lnd', 'add BTC')
.example('$0 addcurrency ETH Connext 18 0x0000000000000000000000000000000000000000', 'add ETH');
Expand Down

0 comments on commit 41d103c

Please sign in to comment.