-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
107 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import { Command } from "commander"; | ||
import Entropy from "@entropyxyz/sdk"; | ||
import { cliWrite, endpointOption, loadEntropy, passwordOption } from "src/common/utils-cli"; | ||
|
||
import { EntropyBalance } from "./main"; | ||
import { cliWrite, endpointOption, loadEntropy, passwordOption } from "../common/utils-cli"; | ||
import { findAccountByAddressOrName } from "../common/utils"; | ||
import * as config from "../config"; | ||
|
||
export function entropyBalanceCommand () { | ||
const balanceCommand = new Command('balance') | ||
balanceCommand | ||
.description('Command to retrieive the balance of an account on the Entropy Network') | ||
.argument('address', 'Account address whose balance you want to query') | ||
.addOption(passwordOption()) | ||
.argument('account <address|name>', 'Account address whose balance you want to query') | ||
.addOption(endpointOption()) | ||
.action(async (address, opts) => { | ||
const entropy: Entropy = await loadEntropy(address, opts.endpoint) | ||
.addOption(passwordOption()) | ||
.action(async (account, opts) => { | ||
const entropy: Entropy = await loadEntropy(account, opts.endpoint) | ||
const BalanceService = new EntropyBalance(entropy, opts.endpoint) | ||
|
||
const { accounts } = await config.get() | ||
const address = findAccountByAddressOrName(accounts, account)?.address | ||
|
||
const balance = await BalanceService.getBalance(address) | ||
cliWrite(`${balance.toLocaleString('en-US')} BITS`) | ||
process.exit(0) | ||
}) | ||
|
||
return balanceCommand | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#! /usr/bin/bash | ||
|
||
ENTROPY_ENDPOINT=ws://127.0.0.1:9944 | ||
|
||
rm ~/.config/entropy-cryptography/entropy-cli.json | ||
# backup config | ||
# mv ~/.config/entropy-cryptography/entropy-cli{.json,.backup.json} | ||
|
||
print () { | ||
COLOR='\033[0;35m' | ||
RESET='\033[0m' | ||
echo "" | ||
echo -e "${COLOR}> $1${RESET}" | ||
} | ||
|
||
print "// ACCOUNT /////////////////////////////////////////////////" | ||
|
||
# Errors (correct, but messy?) | ||
# print "account ls:" | ||
# entropy account ls | jq | ||
|
||
print "account create" | ||
entropy account create naynay | jq | ||
|
||
print "account import" | ||
entropy account import faucet 0x358f394d157e31be23313a1500f5e2c8871e514e530a35aa5c05334be7a39ba6 | jq | ||
|
||
print "account list" | ||
entropy account list | jq | ||
|
||
|
||
|
||
print "// BALANCE ///////////////////////////////////////////////// " | ||
|
||
print "balance naynay" | ||
entropy balance naynay | ||
|
||
print "balance 5CqJyjALDFz4sKjQgK8NXBQGHCWAiV63xXn2Dye393Y6Vghz" | ||
# entropy balance faucet | ||
entropy balance 5CqJyjALDFz4sKjQgK8NXBQGHCWAiV63xXn2Dye393Y6Vghz | ||
|
||
|
||
|
||
print "// TRANSFER ////////////////////////////////////////////////" | ||
|
||
print "entropy transfer" | ||
NAYNAY_ADDRESS=`entropy account ls | jq --raw-output ".[0].address"` | ||
# NOTE: --raw-output is needed to drop the quotes | ||
entropy transfer -a faucet ${NAYNAY_ADDRESS} 2.5 | ||
entropy balance naynay | ||
|
||
# restore config | ||
# mv ~/.config/entropy-cryptography/entropy-cli{.backup.json,.json} |