Skip to content

Commit

Permalink
Merge pull request #4848 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
rohanjadvani authored Mar 14, 2024
2 parents f996f89 + 264df7b commit 04d3678
Show file tree
Hide file tree
Showing 88 changed files with 1,569 additions and 504 deletions.
3 changes: 1 addition & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ related documentation pull request for the website.

## Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.
Is this a breaking change? If yes, add notes below on why this is breaking and label it with `breaking-change-rpc` or `breaking-change-sdk`.

```
[ ] Yes
Expand Down
9 changes: 8 additions & 1 deletion 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": "2.0.0",
"version": "2.1.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 @@ -62,8 +62,8 @@
"@aws-sdk/client-s3": "3",
"@aws-sdk/client-secrets-manager": "3",
"@aws-sdk/s3-request-presigner": "3",
"@ironfish/rust-nodejs": "2.0.0",
"@ironfish/sdk": "2.0.0",
"@ironfish/rust-nodejs": "2.1.0",
"@ironfish/sdk": "2.1.0",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
9 changes: 2 additions & 7 deletions ironfish-cli/src/commands/wallet/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,15 @@ export class ImportCommand extends IronfishCommand {
if (
e instanceof RpcRequestError &&
(e.code === RPC_ERROR_CODES.DUPLICATE_ACCOUNT_NAME.toString() ||
e.code === RPC_ERROR_CODES.IMPORT_ACCOUNT_NAME_REQUIRED.toString() ||
e.code === RPC_ERROR_CODES.MULTISIG_SECRET_NAME_REQUIRED.toString())
e.code === RPC_ERROR_CODES.IMPORT_ACCOUNT_NAME_REQUIRED.toString())
) {
let message = 'Enter a name for the account'
const message = 'Enter a name for the account'

if (e.code === RPC_ERROR_CODES.DUPLICATE_ACCOUNT_NAME.toString()) {
this.log()
this.log(e.codeMessage)
}

if (e.code === RPC_ERROR_CODES.MULTISIG_SECRET_NAME_REQUIRED.toString()) {
message = 'Enter the name of the multisig secret'
}

const name = await CliUx.ux.prompt(message, {
required: true,
})
Expand Down
15 changes: 12 additions & 3 deletions ironfish-cli/src/commands/wallet/multisig/commitment/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { Flags } from '@oclif/core'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'
import { MultisigTransactionJson } from '../../../../utils/multisig'

export class CreateSigningPackage extends IronfishCommand {
static description = `Creates a signing package for a given transaction for a multisig account`
static hidden = true

static flags = {
...RemoteFlags,
Expand All @@ -28,20 +28,25 @@ export class CreateSigningPackage extends IronfishCommand {
'The signing commitments from participants to be used for creating the signing package',
multiple: true,
}),
path: Flags.string({
description: 'Path to a JSON file containing multisig transaction data',
}),
}

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

let unsignedTransaction = flags.unsignedTransaction?.trim()
const loaded = await MultisigTransactionJson.load(this.sdk.fileSystem, flags.path)
const options = MultisigTransactionJson.resolveFlags(flags, loaded)

let unsignedTransaction = options.unsignedTransaction
if (!unsignedTransaction) {
unsignedTransaction = await longPrompt('Enter the unsigned transaction', {
required: true,
})
}

let commitments = flags.commitment
let commitments = options.commitment
if (!commitments) {
const input = await longPrompt('Enter the signing commitments separated by commas', {
required: true,
Expand All @@ -60,5 +65,9 @@ export class CreateSigningPackage extends IronfishCommand {

this.log(`Signing Package for commitments from ${commitments.length} participants:\n`)
this.log(signingPackageResponse.content.signingPackage)

this.log()
this.log('Next step:')
this.log('Send the signing package to all of the participants who provided a commitment.')
}
}
16 changes: 13 additions & 3 deletions ironfish-cli/src/commands/wallet/multisig/commitment/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { CliUx, Flags } from '@oclif/core'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'
import { MultisigTransactionJson } from '../../../../utils/multisig'
import { renderUnsignedTransactionDetails } from '../../../../utils/transaction'

export class CreateSigningCommitmentCommand extends IronfishCommand {
static description = 'Create a signing commitment from a participant for a given transaction'
static hidden = true

static flags = {
...RemoteFlags,
Expand All @@ -34,12 +34,18 @@ export class CreateSigningCommitmentCommand extends IronfishCommand {
default: false,
description: 'Confirm creating signing commitment without confirming',
}),
path: Flags.string({
description: 'Path to a JSON file containing multisig transaction data',
}),
}

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

let identities = flags.identity
const loaded = await MultisigTransactionJson.load(this.sdk.fileSystem, flags.path)
const options = MultisigTransactionJson.resolveFlags(flags, loaded)

let identities = options.identity
if (!identities || identities.length < 2) {
const input = await longPrompt('Enter the identities separated by commas', {
required: true,
Expand All @@ -52,7 +58,7 @@ export class CreateSigningCommitmentCommand extends IronfishCommand {
}
identities = identities.map((i) => i.trim())

let unsignedTransactionInput = flags.unsignedTransaction?.trim()
let unsignedTransactionInput = options.unsignedTransaction
if (!unsignedTransactionInput) {
unsignedTransactionInput = await longPrompt('Enter the unsigned transaction', {
required: true,
Expand Down Expand Up @@ -86,5 +92,9 @@ export class CreateSigningCommitmentCommand extends IronfishCommand {

this.log('\nCommitment:\n')
this.log(response.content.commitment)

this.log()
this.log('Next step:')
this.log('Send the commitment to the multisig account coordinator.')
}
}
39 changes: 33 additions & 6 deletions ironfish-cli/src/commands/wallet/multisig/dealer/create.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* 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 { ACCOUNT_SCHEMA_VERSION } from '@ironfish/sdk'
import { ACCOUNT_SCHEMA_VERSION, RpcClient } from '@ironfish/sdk'
import { CliUx, Flags } from '@oclif/core'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'

export class MultisigCreateDealer extends IronfishCommand {
static description = `Create a set of multisig accounts from participant identities`
Expand Down Expand Up @@ -37,7 +38,7 @@ export class MultisigCreateDealer extends IronfishCommand {

let identities = flags.identity
if (!identities || identities.length < 2) {
const input = await CliUx.ux.prompt('Enter the identities separated by commas', {
const input = await longPrompt('Enter the identities separated by commas', {
required: true,
})
identities = input.split(',')
Expand All @@ -59,12 +60,10 @@ export class MultisigCreateDealer extends IronfishCommand {
}
}

const name =
flags.name?.trim() ??
(await CliUx.ux.prompt('Enter the name for the coordinator', { required: true }))

const client = await this.sdk.connectRpc()

const name = await this.getCoordinatorName(client, flags.name?.trim())

const response = await client.wallet.multisig.createTrustedDealerKeyPackage({
minSigners,
participants: identities.map((identity) => ({ identity })),
Expand Down Expand Up @@ -114,5 +113,33 @@ export class MultisigCreateDealer extends IronfishCommand {
}

this.log()
this.log('Next step:')
this.log('Send the account imports to the participant with the corresponding identity.')
}

async getCoordinatorName(client: RpcClient, inputName?: string): Promise<string> {
const accountsResponse = await client.wallet.getAccounts()
const accountNames = new Set(accountsResponse.content.accounts)

const identitiesResponse = await client.wallet.multisig.getIdentities()
const secretNames = new Set(identitiesResponse.content.identities.map((i) => i.name))

let name = inputName
do {
name =
name ?? (await CliUx.ux.prompt('Enter a name for the coordinator', { required: true }))

if (accountNames.has(name)) {
this.log(`Account with name ${name} already exists`)
this.log('')
name = undefined
} else if (secretNames.has(name)) {
this.log(`Multisig identity with name ${name} already exists`)
this.log('')
name = undefined
}
} while (name === undefined)

return name
}
}
14 changes: 9 additions & 5 deletions ironfish-cli/src/commands/wallet/multisig/participant/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { RemoteFlags } from '../../../../flags'

export class MultisigIdentityCreate extends IronfishCommand {
static description = `Create a multisig participant identity`
static hidden = true

static flags = {
...RemoteFlags,
Expand Down Expand Up @@ -39,15 +38,20 @@ export class MultisigIdentityCreate extends IronfishCommand {
) {
this.log()
this.log(e.codeMessage)
name = await CliUx.ux.prompt('Enter a new name for the identity', {
required: true,
})
} else {
throw e
}

name = await CliUx.ux.prompt('Enter a new name for the identity', {
required: true,
})
}
}

this.log('Identity:')
this.log(response.content.identity)

this.log()
this.log('Next step:')
this.log('Send the identity to the multisig account dealer.')
}
}
38 changes: 33 additions & 5 deletions ironfish-cli/src/commands/wallet/multisig/participant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
* 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/core'
import inquirer from 'inquirer'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'

export class MultisigIdentity extends IronfishCommand {
static description = `Retrieve a multisig participant identity from a name`
static hidden = true

static flags = {
...RemoteFlags,
name: Flags.string({
char: 'n',
description: 'Name of the participant identity',
required: true,
}),
}

Expand All @@ -23,9 +22,38 @@ export class MultisigIdentity extends IronfishCommand {

const client = await this.sdk.connectRpc()

const response = await client.wallet.multisig.getIdentity({ name: flags.name })
if (flags.name) {
const response = await client.wallet.multisig.getIdentity({ name: flags.name })

this.log('Identity:')
this.log(response.content.identity)
this.log('Identity:')
this.log(response.content.identity)
} else {
const response = await client.wallet.multisig.getIdentities()

const choices = []
for (const { name, identity } of response.content.identities) {
choices.push({
name,
value: identity,
})
}

// sort identities by name
choices.sort((a, b) => a.name.localeCompare(b.name))

const selection = await inquirer.prompt<{
identity: string
}>([
{
name: 'identity',
message: 'Select participant name to view identity',
type: 'list',
choices,
},
])

this.log('Identity:')
this.log(selection.identity)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { RemoteFlags } from '../../../../flags'

export class MultisigAccountParticipants extends IronfishCommand {
static description = `List the participant identities for a multisig account`
static hidden = true

static flags = {
...RemoteFlags,
Expand Down
Loading

0 comments on commit 04d3678

Please sign in to comment.