Skip to content

Commit

Permalink
refactor(account)!: remove unnecessary balance, nonce commands
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `account balance`, `account nonce` commands removed
Use `inspect <ak-address>` instead.
```diff
- aecli account balance wallet.json --password=123
- aecli account nonce wallet.json --password=123
+ address=$(aecli account address wallet.json --json --password=123 | jq -r .publicKey)
+ aecli inspect $address
```
  • Loading branch information
davidyuk committed Apr 24, 2023
1 parent 0a9f093 commit b4792e6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 79 deletions.
10 changes: 0 additions & 10 deletions CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,6 @@ Wallet saved
Wallet address________________ ak_2a1j2Mk9YSmC1gioUq4PWRm3bsv887MbuRVwyv4KaUGoR1eiKi
Wallet path___________________ /Users/spushkar/Desktop/aepp-sdk-js-develop/bin/test
```
#### balance

This command is used to check the balance of your wallet.
```
$ aecli account balance test
```
You will get the account balance:
```
Your balance is: 998547
```
#### spend

Using this command, you can send coins to another wallet. Just indicate another account's address and an amount which should be sent.
Expand Down
35 changes: 0 additions & 35 deletions src/actions/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,6 @@ export async function spend(
printTransaction(tx, json);
}

// ## Get `balance` function
// This function allow you retrieve account `balance`
export async function getBalance(walletPath, options) {
const { height, hash, json } = options;
const sdk = await initSdkByWalletFile(walletPath, options);
const { nextNonce: nonce } = await sdk.api.getAccountNextNonce(sdk.address);
const balance = await sdk.getBalance(sdk.address, { height: height && +height, hash });
if (json) {
print({ address: sdk.address, nonce, balance });
} else {
printUnderscored('Balance', balance);
printUnderscored('ID', sdk.address);
printUnderscored('Nonce', nonce);
}
}

// ## Get `address` function
// This function allow you retrieve account `public` and `private` keys
export async function getAddress(walletPath, options) {
Expand All @@ -129,25 +113,6 @@ export async function getAddress(walletPath, options) {
}
}

// ## Get `nonce` function
// This function allow you retrieve account `nonce`
export async function getAccountNonce(walletPath, options) {
const { json } = options;
const sdk = await initSdkByWalletFile(walletPath, options);
const { nextNonce: nonce } = await sdk.api.getAccountNextNonce(sdk.address);
if (json) {
print({
id: sdk.address,
nonce: nonce - 1,
nextNonce: nonce,
});
} else {
printUnderscored('ID', sdk.address);
printUnderscored('Nonce', nonce - 1);
printUnderscored('Next Nonce', nonce);
}
}

// ## Create secure `wallet` file
// This function allow you to generate `keypair` and write it to secure `ethereum` like key-file
export async function createSecureWallet(walletPath, { password, overwrite, json }) {
Expand Down
22 changes: 0 additions & 22 deletions src/commands/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,6 @@ addCommonOptions(program
.description('Check if message was signed by wallet')
.action(Account.verifyMessage));

// ## Initialize `balance` command
//
// You can use this command to retrieve balance of account
//
// Example: `aecli account balance ./myWalletKeyFile --password testpassword`
addCommonOptions(program
.command('balance <wallet_path>')
.option('--height [height]', 'Specific block height')
.option('--hash [hash]', 'Specific block hash')
.description('Get wallet balance')
.action(Account.getBalance));

// ## Initialize `address` command
//
// You can use this command to retrieve get your public and private key
Expand Down Expand Up @@ -136,16 +124,6 @@ addCommonOptions(program
.description('Save a private keys string to a password protected file wallet')
.action(Account.createSecureWalletByPrivKey));

// ## Initialize `nonce` command
//
// You can use this command to get `account nonce`.
//
// Example: `aecli account nonce myWalletName --password testpassword
addCommonOptions(program
.command('nonce <wallet_path>')
.description('Get account nonce')
.action(Account.getAccountNonce));

// ## Initialize `generateKeyPairs` command
//
// You can use this command to generate KeyPair's.
Expand Down
12 changes: 0 additions & 12 deletions test/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ describe('Account Module', () => {
.to.be.a('string');
});

it('Check Wallet Balance', async () => {
const balance = await sdk.getBalance(sdk.address);
expect((await executeAccount(['balance', WALLET_NAME, '--password', 'test', '--json'])).balance)
.to.equal(balance);
});

it('Spend coins to another wallet', async () => {
const amount = 100;
const { publicKey } = generateKeyPair();
Expand Down Expand Up @@ -135,12 +129,6 @@ Version _________________________________ 1
expect(+await sdk.getBalance(publicKey)).to.be.equal(balanceBefore * 0.42);
});

it('Get account nonce', async () => {
const { nextNonce } = await sdk.api.getAccountNextNonce(sdk.address);
expect((await executeAccount(['nonce', WALLET_NAME, '--password', 'test', '--json'])).nextNonce)
.to.equal(nextNonce);
});

it('Generate accounts', async () => {
const accounts = await executeAccount(['generate', 2, '--json']);
accounts.length.should.be.equal(2);
Expand Down

0 comments on commit b4792e6

Please sign in to comment.