-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cli] Checks on cmds + support use of signer
- Loading branch information
Showing
35 changed files
with
882 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
node_modules | ||
oclif.manifest.json | ||
src/generated | ||
.devchain/ |
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,19 @@ | ||
import Web3 from 'web3' | ||
import { testWithGanache } from '../../test-utils/ganache-test' | ||
import Authorize from './authorize' | ||
import Register from './register' | ||
|
||
testWithGanache('account:authorize cmd', (web3: Web3) => { | ||
test('can authorize account', async () => { | ||
const accounts = await web3.eth.getAccounts() | ||
await Register.run(['--from', accounts[0]]) | ||
await Authorize.run(['--from', accounts[0], '--role', 'validator', '--to', accounts[1]]) | ||
}) | ||
|
||
test('fails if from is not an account', async () => { | ||
const accounts = await web3.eth.getAccounts() | ||
await expect( | ||
Authorize.run(['--from', accounts[0], '--role', 'validator', '--to', accounts[1]]) | ||
).rejects.toThrow() | ||
}) | ||
}) |
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,17 @@ | ||
import Web3 from 'web3' | ||
import { testWithGanache } from '../../test-utils/ganache-test' | ||
import Register from './register' | ||
|
||
testWithGanache('account:register cmd', (web3: Web3) => { | ||
test('can register account', async () => { | ||
const accounts = await web3.eth.getAccounts() | ||
|
||
await Register.run(['--from', accounts[0]]) | ||
}) | ||
|
||
test('fails if from is missing', async () => { | ||
// const accounts = await web3.eth.getAccounts() | ||
|
||
await expect(Register.run()).rejects.toThrow('Missing required flag') | ||
}) | ||
}) |
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
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,22 @@ | ||
import { BaseCommand } from '../../base' | ||
import { printValueMap } from '../../utils/cli' | ||
|
||
export default class ValidatorRequirements extends BaseCommand { | ||
static description = 'Get Requirements for Validators' | ||
|
||
static flags = { | ||
...BaseCommand.flags, | ||
} | ||
|
||
static examples = ['requirements'] | ||
|
||
async run() { | ||
this.parse(ValidatorRequirements) | ||
|
||
const validators = await this.kit.contracts.getValidators() | ||
|
||
const requirements = await validators.getBalanceRequirements() | ||
|
||
printValueMap(requirements) | ||
} | ||
} |
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,32 @@ | ||
import { BaseCommand } from '../../base' | ||
import { newCheckBuilder } from '../../utils/checks' | ||
import { displaySendTx } from '../../utils/cli' | ||
import { Flags } from '../../utils/command' | ||
|
||
export default class ValidatorGroupDeRegister extends BaseCommand { | ||
static description = 'Deregister a ValidatorGroup' | ||
|
||
static flags = { | ||
...BaseCommand.flags, | ||
from: Flags.address({ required: true, description: "Signer or ValidatorGroup's address" }), | ||
} | ||
|
||
static examples = ['deregister --from 0x47e172f6cfb6c7d01c1574fa3e2be7cc73269d95'] | ||
|
||
async run() { | ||
const res = this.parse(ValidatorGroupDeRegister) | ||
|
||
this.kit.defaultAccount = res.flags.from | ||
const validators = await this.kit.contracts.getValidators() | ||
|
||
const account = await validators.signerToAccount(res.flags.from) | ||
|
||
await newCheckBuilder(this, res.flags.from) | ||
.isSignerOrAccount() | ||
.canSignValidatorTxs() | ||
.signerAccountIsValidatorGroup() | ||
.runChecks() | ||
|
||
await displaySendTx('deregister', await validators.deregisterValidatorGroup(account)) | ||
} | ||
} |
Oops, something went wrong.