Skip to content

Commit

Permalink
Merge pull request #4074 from iron-fish/staging
Browse files Browse the repository at this point in the history
Merge staging into master (1.6.0 release)
  • Loading branch information
andiflabs authored Jul 17, 2023
2 parents e27a127 + 7676c8b commit e5551dc
Show file tree
Hide file tree
Showing 141 changed files with 3,129 additions and 1,189 deletions.
71 changes: 42 additions & 29 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish",
"version": "1.5.0",
"version": "1.6.0",
"description": "CLI for running and interacting with an Iron Fish node",
"author": "Iron Fish <[email protected]> (https://ironfish.network)",
"main": "build/src/index.js",
Expand Down Expand Up @@ -59,8 +59,8 @@
"@aws-sdk/client-s3": "3",
"@aws-sdk/client-secrets-manager": "3",
"@aws-sdk/s3-request-presigner": "3",
"@ironfish/rust-nodejs": "1.4.0",
"@ironfish/sdk": "1.5.0",
"@ironfish/rust-nodejs": "1.5.0",
"@ironfish/sdk": "1.6.0",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
1 change: 0 additions & 1 deletion ironfish-cli/scripts/import-export-test/README

This file was deleted.

2 changes: 1 addition & 1 deletion ironfish-cli/src/commands/chain/broadcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class BroadcastCommand extends IronfishCommand {

CliUx.ux.action.start(`Broadcasting transaction`)
const client = await this.sdk.connectRpc()
const response = await client.broadcastTransaction({ transaction })
const response = await client.chain.broadcastTransaction({ transaction })
if (response.content) {
CliUx.ux.action.stop(`Transaction broadcasted: ${response.content.hash}`)
}
Expand Down
67 changes: 18 additions & 49 deletions ironfish-cli/src/commands/wallet/export.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* 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 { spendingKeyToWords } from '@ironfish/rust-nodejs'
import { Assert, Bech32m, ErrorUtils, LanguageKey, LanguageUtils } from '@ironfish/sdk'
import { AccountFormat, ErrorUtils, LanguageUtils } from '@ironfish/sdk'
import { CliUx, Flags } from '@oclif/core'
import fs from 'fs'
import inquirer from 'inquirer'
import jsonColorizer from 'json-colorizer'
import path from 'path'
import { IronfishCommand } from '../../command'
Expand Down Expand Up @@ -64,52 +62,23 @@ export class ExportCommand extends IronfishCommand {
flags.mnemonic = true
}

const client = await this.sdk.connectRpc(local)
const response = await client.wallet.exportAccount({ account: account, viewOnly: viewOnly })
let output

if (flags.mnemonic) {
let languageCode = flags.language ? LanguageUtils.LANGUAGES[flags.language] : null

if (languageCode == null) {
languageCode = LanguageUtils.inferLanguageCode()

if (languageCode !== null) {
CliUx.ux.info(
`Detected Language as '${LanguageUtils.languageCodeToKey(
languageCode,
)}', exporting:`,
)
}
}
const format = flags.mnemonic
? AccountFormat.Mnemonic
: flags.json
? AccountFormat.JSON
: AccountFormat.Bech32

if (languageCode == null) {
CliUx.ux.info(`Could not detect your language, please select language for export`)
const response = await inquirer.prompt<{
language: LanguageKey
}>([
{
name: 'language',
message: `Select your language`,
type: 'list',
choices: LanguageUtils.LANGUAGE_KEYS,
},
])
languageCode = LanguageUtils.LANGUAGES[response.language]
}
Assert.isTruthy(
response.content.account.spendingKey,
'The account you are trying to export does not have a spending key, therefore a mnemonic cannot be generated for it',
)
output = spendingKeyToWords(response.content.account.spendingKey, languageCode)
} else if (flags.json) {
output = JSON.stringify(response.content.account, undefined, ' ')

if (color && flags.json && !exportPath) {
output = jsonColorizer(output)
}
} else {
output = Bech32m.encode(JSON.stringify(response.content.account), 'ironfishaccount00000')
const client = await this.sdk.connectRpc(local)
const response = await client.wallet.exportAccount({
account,
viewOnly,
format,
language: flags.language,
})

let output = response.content.account as string
if (color && flags.json && !exportPath) {
output = jsonColorizer(output)
}

if (exportPath) {
Expand All @@ -135,7 +104,7 @@ export class ExportCommand extends IronfishCommand {
}

await fs.promises.writeFile(resolved, output)
this.log(`Exported account ${response.content.account.name} to ${resolved}`)
this.log(`Exported account ${account} to ${resolved}`)
} catch (err: unknown) {
if (ErrorUtils.isNoEntityError(err)) {
await fs.promises.mkdir(path.dirname(resolved), { recursive: true })
Expand Down
Loading

0 comments on commit e5551dc

Please sign in to comment.