Skip to content

Commit

Permalink
Merge pull request #1019 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
NullSoldier authored Feb 15, 2022
2 parents 6b58708 + 1ca28c2 commit c9a493e
Show file tree
Hide file tree
Showing 139 changed files with 2,475 additions and 2,648 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ lerna-debug.log*
**/*/target/*
*.node

# ironfish-rust-nodejs
ironfish-rust-nodejs/*.map
ironfish-rust-nodejs/*.tsbuildinfo
ironfish-rust-nodejs/index.d.ts
ironfish-rust-nodejs/index.js

# ironfish-cli
bin/ironfish-cli/databases
.dockerignore
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ We welcome contributions from anyone on the internet, and are grateful for even
Thanks in advance for your help.


## We develop with Github
## We develop with GitHub

We use Github to host code, to track issues and feature requests, as well as accept pull requests.
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.


## Pull Requests Guidelines

Pull requests are the best way to propose a new change to the codebase (we use the classic [Github Flow](https://guides.github.com/introduction/flow/index.html)).
Pull requests are the best way to propose a new change to the codebase (we use the classic [GitHub Flow](https://guides.github.com/introduction/flow/index.html)).

To create a new pull request:
1. Fork the repo and check out a new branch from `master`.
2. Add test - if your code change doesn't require a test change, please explain why in the PR description.
3. Update the documentation - Especially if you've changed APIs or created new functions.
4. Ensure the test suite passes by running `yarn test`.
5. Make sure your code lints by running `yarn lint`.
6. Once 4 & 5 are passing, create a new pull request on Github.
6. Once 4 & 5 are passing, create a new pull request on GitHub.
7. Add the right label to your PR `documentation`, `bug`, `security-issue`, or `enhancement`.
8. Add a description of what the PR is changing:
* What problem is the PR solving
Expand All @@ -39,7 +39,7 @@ To create a new pull request:

Once the PR is created, one of the maintainers will review it and merge it into the master branch.

If you are thinking of working on a complex change, do not hesitate to discuss the change you wish to make via a Github Issue. You can also request feedback early, by opening a WIP pull request or discuss with a maintainer to ensure your work is in line with the philosophy and roadmap of Iron Fish.
If you are thinking of working on a complex change, do not hesitate to discuss the change you wish to make via a GitHub Issue. You can also request feedback early, by opening a WIP pull request or discuss with a maintainer to ensure your work is in line with the philosophy and roadmap of Iron Fish.


## Where to start
Expand All @@ -62,7 +62,7 @@ For our Rust codebase, you can run the test suites for each project by running `

## Continuous integration

After creating a PR on Github, the code will be tested automatically by GitHub Action. The tests can take up to 15 minutes to pass. We ask you to test your code on your machine before submitting a PR.
After creating a PR on GitHub, the code will be tested automatically by GitHub Action. The tests can take up to 15 minutes to pass. We ask you to test your code on your machine before submitting a PR.


## Style Guide
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ See https://ironfish.network
1. On Ubuntu: `apt install build-essential`
1. On Amazon Linux: `sudo yum groupinstall "Development Tools"`

- If `yarn install` fails with an error that includes "Error: Could not find any Python installation to use", you may need to install Python3 (required by node-gyp). on MacOS:
1. Run `brew install python`

## Usage

Once your environment is setup - you can run the CLI by following [these directions](https://github.com/iron-fish/ironfish/tree/master/ironfish-cli).
Expand Down
6 changes: 3 additions & 3 deletions ironfish-cli/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ if (process.platform !== 'win32') {
require('segfault-handler').registerHandler('segfault.log')
}

require('@oclif/command').run()
.then(require('@oclif/command/flush'))
.catch(require('@oclif/errors/handle'))
require('@oclif/core').run()
.then(require('@oclif/core/flush'))
.catch(require('@oclif/core/handle'))
6 changes: 2 additions & 4 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish-cli",
"version": "0.1.21",
"version": "0.1.22",
"description": "Command line Iron Fish node",
"author": "Iron Fish <[email protected]> (https://ironfish.network)",
"engines": {
Expand Down Expand Up @@ -42,13 +42,11 @@
},
"license": "MPL-2.0",
"dependencies": {
"@oclif/command": "1.8.0",
"@oclif/config": "1.17.0",
"@oclif/core": "1.3.1",
"@oclif/plugin-help": "3.2.2",
"@oclif/plugin-not-found": "1.2.4",
"axios": "0.21.4",
"blessed": "0.1.81",
"cli-ux": "^5.5.0",
"ironfish": "*",
"ironfish-rust-nodejs": "*",
"json-colorizer": "2.2.2",
Expand Down
8 changes: 4 additions & 4 deletions ironfish-cli/src/command.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { Command } from '@oclif/command'
import { IConfig } from '@oclif/config'
import { Command, Config } from '@oclif/core'
import { ConfigOptions, ConnectionError, createRootLogger, IronfishSdk, Logger } from 'ironfish'
import {
ConfigFlagKey,
Expand Down Expand Up @@ -53,7 +52,7 @@ export abstract class IronfishCommand extends Command {
*/
closing = false

constructor(argv: string[], config: IConfig) {
constructor(argv: string[], config: Config) {
super(argv, config)
this.logger = createRootLogger().withTag(this.ctor.id)
}
Expand All @@ -79,7 +78,8 @@ export abstract class IronfishCommand extends Command {
async init(): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
const commandClass = this.constructor as any
const { flags } = this.parse(commandClass)
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { flags } = await this.parse(commandClass)

// Get the flags from the flag object which is unknown
const dataDirFlag = getFlag(flags, DataDirFlagKey)
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/accounts/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export class BalanceCommand extends IronfishCommand {
static args = [
{
name: 'account',
parse: (input: string): string => input.trim(),
parse: (input: string): Promise<string> => Promise.resolve(input.trim()),
required: false,
description: 'name of the account to get balance for',
},
]

async start(): Promise<void> {
const { args } = this.parse(BalanceCommand)
const { args } = await this.parse(BalanceCommand)
const account = args.account as string | undefined

const client = await this.sdk.connectRpc()
Expand Down
4 changes: 2 additions & 2 deletions ironfish-cli/src/commands/accounts/create.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { CliUx } from '@oclif/core'
import { expect as expectCli, test } from '@oclif/test'
import cli from 'cli-ux'
import * as ironfishmodule from 'ironfish'

describe('accounts:create command', () => {
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('accounts:create command', () => {
})

test
.stub(cli, 'prompt', () => async () => await Promise.resolve(name))
.stub(CliUx.ux, 'prompt', () => async () => await Promise.resolve(name))
.stdout()
.command(['accounts:create'])
.exit(0)
Expand Down
8 changes: 4 additions & 4 deletions ironfish-cli/src/commands/accounts/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import cli from 'cli-ux'
import { CliUx } from '@oclif/core'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'

Expand All @@ -12,7 +12,7 @@ export class CreateCommand extends IronfishCommand {
static args = [
{
name: 'name',
parse: (input: string): string => input.trim(),
parse: (input: string): Promise<string> => Promise.resolve(input.trim()),
required: false,
description: 'name of the account',
},
Expand All @@ -23,11 +23,11 @@ export class CreateCommand extends IronfishCommand {
}

async start(): Promise<void> {
const { args } = this.parse(CreateCommand)
const { args } = await this.parse(CreateCommand)
let name = args.name as string

if (!name) {
name = (await cli.prompt('Enter the name of the account', {
name = (await CliUx.ux.prompt('Enter the name of the account', {
required: true,
})) as string
}
Expand Down
13 changes: 6 additions & 7 deletions ironfish-cli/src/commands/accounts/export.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { flags } from '@oclif/command'
import cli from 'cli-ux'
import { CliUx, Flags } from '@oclif/core'
import fs from 'fs'
import { ErrorUtils } from 'ironfish'
import jsonColorizer from 'json-colorizer'
Expand All @@ -16,7 +15,7 @@ export class ExportCommand extends IronfishCommand {
static flags = {
...RemoteFlags,
[ColorFlagKey]: ColorFlag,
local: flags.boolean({
local: Flags.boolean({
default: false,
description: 'Export an account without an online node',
}),
Expand All @@ -25,20 +24,20 @@ export class ExportCommand extends IronfishCommand {
static args = [
{
name: 'account',
parse: (input: string): string => input.trim(),
parse: (input: string): Promise<string> => Promise.resolve(input.trim()),
required: false,
description: 'name of the account to export',
},
{
name: 'path',
parse: (input: string): string => input.trim(),
parse: (input: string): Promise<string> => Promise.resolve(input.trim()),
required: false,
description: 'a path to export the account to',
},
]

async start(): Promise<void> {
const { flags, args } = this.parse(ExportCommand)
const { flags, args } = await this.parse(ExportCommand)
const { color, local } = flags
const account = args.account as string
const exportPath = args.path as string | undefined
Expand All @@ -61,7 +60,7 @@ export class ExportCommand extends IronfishCommand {
if (fs.existsSync(resolved)) {
this.log(`There is already an account backup at ${exportPath}`)

const confirmed = await cli.confirm(
const confirmed = await CliUx.ux.confirm(
`\nOverwrite the account backup with new file?\nAre you sure? (Y)es / (N)o`,
)

Expand Down
21 changes: 10 additions & 11 deletions ironfish-cli/src/commands/accounts/import.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { flags } from '@oclif/command'
import { cli } from 'cli-ux'
import { CliUx, Flags } from '@oclif/core'
import { JSONUtils, PromiseUtils, SerializedAccount } from 'ironfish'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'
Expand All @@ -12,7 +11,7 @@ export class ImportCommand extends IronfishCommand {

static flags = {
...RemoteFlags,
rescan: flags.boolean({
rescan: Flags.boolean({
allowNo: true,
default: true,
description: 'rescan the blockchain once the account is imported',
Expand All @@ -22,14 +21,14 @@ export class ImportCommand extends IronfishCommand {
static args = [
{
name: 'path',
parse: (input: string): string => input.trim(),
parse: (input: string): Promise<string> => Promise.resolve(input.trim()),
required: false,
description: 'a path to import the account from',
},
]

async start(): Promise<void> {
const { flags, args } = this.parse(ImportCommand)
const { flags, args } = await this.parse(ImportCommand)
const importPath = args.path as string | undefined

const client = await this.sdk.connectRpc()
Expand All @@ -45,7 +44,7 @@ export class ImportCommand extends IronfishCommand {

if (account === null) {
this.log('No account to import provided')
this.exit(1)
return this.exit(1)
}

const result = await client.importAccount({
Expand Down Expand Up @@ -89,23 +88,23 @@ export class ImportCommand extends IronfishCommand {
}

async importTTY(): Promise<SerializedAccount> {
const accountName = (await cli.prompt('Enter the account name', {
const accountName = (await CliUx.ux.prompt('Enter the account name', {
required: true,
})) as string

const spendingKey = (await cli.prompt('Enter the account spending key', {
const spendingKey = (await CliUx.ux.prompt('Enter the account spending key', {
required: true,
})) as string

const incomingViewKey = (await cli.prompt('Enter the account incoming view key', {
const incomingViewKey = (await CliUx.ux.prompt('Enter the account incoming view key', {
required: true,
})) as string

const outgoingViewKey = (await cli.prompt('Enter the account outgoing view key', {
const outgoingViewKey = (await CliUx.ux.prompt('Enter the account outgoing view key', {
required: true,
})) as string

const publicAddress = (await cli.prompt('Enter the account public address', {
const publicAddress = (await CliUx.ux.prompt('Enter the account public address', {
required: true,
})) as string

Expand Down
6 changes: 3 additions & 3 deletions ironfish-cli/src/commands/accounts/list.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { flags } from '@oclif/command'
import { Flags } from '@oclif/core'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'

Expand All @@ -10,14 +10,14 @@ export class ListCommand extends IronfishCommand {

static flags = {
...RemoteFlags,
displayName: flags.boolean({
displayName: Flags.boolean({
default: false,
description: `Display a hash of the account's read-only keys along with the account name`,
}),
}

async start(): Promise<void> {
const { flags } = this.parse(ListCommand)
const { flags } = await this.parse(ListCommand)

const client = await this.sdk.connectRpc()

Expand Down
Loading

0 comments on commit c9a493e

Please sign in to comment.