Skip to content

Commit

Permalink
Resolve conflicts and merge branch 'command-examples'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastinez committed Jul 26, 2020
2 parents 103b2e2 + c974530 commit 85b5bcd
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 24 deletions.
Empty file added .npmrc
Empty file.
57 changes: 40 additions & 17 deletions bin/web3conv
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,54 @@ args
.demandCommand()
.recommendCommands()
.strict()
.command("asciitobytes32", "[-s <ascii string>]", yargs => {
let option = yargs.option("string", { alias: "s", demandOption: true }).argv;
.command("asciitobytes32", "[-s <ascii string>]", (yargs) => {
let option = yargs.option("string", { alias: "s", demandOption: true })
.argv;
asciitobytes32(option.string);
})
.command("bytes32toascii", "[-s <bytes32 string>]", yargs => {
let option = yargs.option("string", { alias: "s", demandOption: true, string: true }).argv;
.command("bytes32toascii", "[-s <bytes32 string>]", (yargs) => {
let option = yargs.option("string", {
alias: "s",
demandOption: true,
string: true,
}).argv;
bytes32ToAscii(option.string);
})
.command("hash", "[-a <hash algorithm>] [-s [string] | -f [file]]", yargs => {
.command(
"hash",
"[-a <hash algorithm>] [-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 <address>] [-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 <ETH Address>]", yargs => {
let option = yargs.option("address", { alias: "a", demandOption: true, string: true }).argv;
toChecksumAddress(option.address);
})
.command("base58tohex", "[-s <base85 string>]", yargs => {
let option = yargs.option("string", { alias: "s", demandOption: true, string: true }).argv;
.command("base58tohex", "[-s <base85 string>]", (yargs) => {
let option = yargs.option("string", {
alias: "s",
demandOption: true,
string: true,
}).argv;
base58tohex(option.string);
})
.command("hextobase58", "[-s <hex string>]", yargs => {
let option = yargs.option("string", { alias: "s", demandOption: true, string: true }).argv;
.command("hextobase58", "[-s <hex string>]", (yargs) => {
let option = yargs.option("string", {
alias: "s",
demandOption: true,
string: true,
}).argv;
hextobase58(option.string);
})
.help("h")
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down
13 changes: 9 additions & 4 deletions src/checksumAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
);
};

Expand Down

0 comments on commit 85b5bcd

Please sign in to comment.