diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..e69de29 diff --git a/bin/web3conv b/bin/web3conv index 974a6ea..f853efb 100644 --- a/bin/web3conv +++ b/bin/web3conv @@ -10,31 +10,54 @@ args .demandCommand() .recommendCommands() .strict() - .command("asciitobytes32", "[-s ]", yargs => { - let option = yargs.option("string", { alias: "s", demandOption: true }).argv; + .command("asciitobytes32", "[-s ]", (yargs) => { + let option = yargs.option("string", { alias: "s", demandOption: true }) + .argv; asciitobytes32(option.string); }) - .command("bytes32toascii", "[-s ]", yargs => { - let option = yargs.option("string", { alias: "s", demandOption: true, string: true }).argv; + .command("bytes32toascii", "[-s ]", (yargs) => { + let option = yargs.option("string", { + alias: "s", + demandOption: true, + string: true, + }).argv; bytes32ToAscii(option.string); }) - .command("hash", "[-a ] [-s [string] | -f [file]]", yargs => { + .command( + "hash", + "[-a ] [-s [string] | -f [file]]", + (yargs) => { + let option = yargs + .option("string", { alias: "s" }) + .option("algorithm", { alias: "a", demandOption: true }) + .option("file", { alias: "f" }).argv; + hash(option.algorithm, option.string, option.file); + } + ) + .command("checksumaddress", "[-a
] [-i [chainId]]", (yargs) => { let option = yargs - .option("string", { alias: "s" }) - .option("algorithm", { alias: "a", demandOption: true }) - .option("file", { alias: "f" }).argv; - hash(option.algorithm, option.string, option.file); + .option("address", { + alias: "a", + demandOption: true, + string: true, + }) + .option("chainId", { alias: "i", string: "true" }).argv; + toChecksumAddress(option.address, option.chainId); }) - .command("checksumaddress", "[-a ]", yargs => { - let option = yargs.option("address", { alias: "a", demandOption: true, string: true }).argv; - toChecksumAddress(option.address); - }) - .command("base58tohex", "[-s ]", yargs => { - let option = yargs.option("string", { alias: "s", demandOption: true, string: true }).argv; + .command("base58tohex", "[-s ]", (yargs) => { + let option = yargs.option("string", { + alias: "s", + demandOption: true, + string: true, + }).argv; base58tohex(option.string); }) - .command("hextobase58", "[-s ]", yargs => { - let option = yargs.option("string", { alias: "s", demandOption: true, string: true }).argv; + .command("hextobase58", "[-s ]", (yargs) => { + let option = yargs.option("string", { + alias: "s", + demandOption: true, + string: true, + }).argv; hextobase58(option.string); }) .help("h") diff --git a/package-lock.json b/package-lock.json index 1eed2de..722d30b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "web3conv", + "name": "@sebastinez/web3conv", "version": "1.1.0", "lockfileVersion": 1, "requires": true, diff --git a/package.json b/package.json index f0a276d..cd109a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "web3conv", - "version": "1.1.0", + "name": "@sebastinez/web3conv", + "version": "1.2.0", "description": "CLI App for type conversion in the cripto universe", "main": "web3conv", "scripts": {}, diff --git a/src/checksumAddress.js b/src/checksumAddress.js index 4371714..e226687 100644 --- a/src/checksumAddress.js +++ b/src/checksumAddress.js @@ -17,13 +17,18 @@ const toChecksumAddress = (address, chainId = null) => { let checksumAddress = "0x"; for (let i = 0; i < stripAddress.length; i += 1) - checksumAddress += parseInt(keccakHash[i], 16) >= 8 ? stripAddress[i].toUpperCase() : stripAddress[i]; - if (address === checksumAddress) console.log(chalk.underline("\nSupplied Address is valid")); + checksumAddress += + parseInt(keccakHash[i], 16) >= 8 + ? stripAddress[i].toUpperCase() + : stripAddress[i]; + + if (address === checksumAddress) + console.log(chalk.underline("\nSupplied Address is valid\n")); else console.log( - chalk.underline("\nConverted ASCII string to Bytes32 String\n\n") + - `Input: ${address}\nOutput: ${checksumAddress}` + chalk.underline(`\nChecksummed address to chainId ${chainId}\n\n`) + + `${checksumAddress}\n` ); };