Skip to content

Commit

Permalink
refactor(cli,ironfish): Rename multisig RPC / CLI (#4806)
Browse files Browse the repository at this point in the history
* refactor(cli,ironfish): Rename multisig RPC / CLI

* Revert aggregate commitments

* Update index.ts

* Update route

* Fix lint

* Update description

* Update help text
  • Loading branch information
rohanjadvani authored Mar 5, 2024
1 parent 4970b26 commit 737e6ae
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import { Flags } from '@oclif/core'
import { IronfishCommand } from '../../../command'
import { RemoteFlags } from '../../../flags'
import { longPrompt } from '../../../utils/longPrompt'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'

export class CreateSigningPackage extends IronfishCommand {
static description = `Creates a signing package for a given transaction for a multisig account`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { UnsignedTransaction } from '@ironfish/sdk'
import { CliUx, Flags } from '@oclif/core'
import { IronfishCommand } from '../../../command'
import { RemoteFlags } from '../../../flags'
import { longPrompt } from '../../../utils/longPrompt'
import { renderUnsignedTransactionDetails } from '../../../utils/transaction'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'
import { renderUnsignedTransactionDetails } from '../../../../utils/transaction'

export class CreateSigningCommitmentCommand extends IronfishCommand {
static description = 'Create a signing commitment from a participant for a given transaction'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { CliUx, Flags } from '@oclif/core'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'

export class MultisigCreate extends IronfishCommand {
static description = `Create a set of multisig accounts from identities`
export class MultisigCreateDealer extends IronfishCommand {
static description = `Create a set of multisig accounts from participant identities`
static hidden = true

static flags = {
Expand All @@ -33,7 +33,7 @@ export class MultisigCreate extends IronfishCommand {
}

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

let identities = flags.identity
if (!identities || identities.length < 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'

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

static flags = {
Expand All @@ -31,7 +31,7 @@ export class MultisigIdentityCreate extends IronfishCommand {
let response
while (!response) {
try {
response = await client.wallet.multisig.createIdentity({ name })
response = await client.wallet.multisig.createParticipant({ name })
} catch (e) {
if (
e instanceof RpcRequestError &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'

export class MultisigIdentity extends IronfishCommand {
static description = `Retrieve a multisig identity`
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 identity',
description: 'Name of the participant identity',
required: true,
}),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { Flags } from '@oclif/core'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'

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

static flags = {
Expand All @@ -18,7 +18,7 @@ export class MultisigAccountIdentities extends IronfishCommand {
}

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

const client = await this.sdk.connectRpc()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { CurrencyUtils, Transaction } from '@ironfish/sdk'
import { CliUx, Flags } from '@oclif/core'
import { IronfishCommand } from '../../../command'
import { RemoteFlags } from '../../../flags'
import { longPrompt } from '../../../utils/longPrompt'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'

export class MultisigSign extends IronfishCommand {
static description = 'Aggregate signature shares from participants to sign a transaction'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/* 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 { UnsignedTransaction } from '@ironfish/sdk'
import { CliUx, Flags } from '@oclif/core'
import { IronfishCommand } from '../../../command'
import { RemoteFlags } from '../../../flags'
import { longPrompt } from '../../../utils/longPrompt'
import { renderUnsignedTransactionDetails } from '../../../utils/transaction'
import { IronfishCommand } from '../../../../command'
import { RemoteFlags } from '../../../../flags'
import { longPrompt } from '../../../../utils/longPrompt'
import { renderUnsignedTransactionDetails } from '../../../../utils/transaction'

export class CreateSignatureShareCommand extends IronfishCommand {
static description = `Creates a signature share for a participant for a given transaction`
Expand Down
14 changes: 7 additions & 7 deletions ironfish/src/rpc/clients/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import type {
BurnAssetResponse,
CreateAccountRequest,
CreateAccountResponse,
CreateIdentityRequest,
CreateIdentityResponse,
CreateParticipantRequest,
CreateParticipantResponse,
CreateSignatureShareRequest,
CreateSignatureShareResponse,
CreateSigningCommitmentRequest,
Expand Down Expand Up @@ -234,11 +234,11 @@ export abstract class RpcClient {
).waitForEnd()
},

createIdentity: (
params: CreateIdentityRequest,
): Promise<RpcResponseEnded<CreateIdentityResponse>> => {
return this.request<CreateIdentityResponse>(
`${ApiNamespace.wallet}/multisig/createIdentity`,
createParticipant: (
params: CreateParticipantRequest,
): Promise<RpcResponseEnded<CreateParticipantResponse>> => {
return this.request<CreateParticipantResponse>(
`${ApiNamespace.wallet}/multisig/createParticipant`,
params,
).waitForEnd()
},
Expand Down
4 changes: 2 additions & 2 deletions ironfish/src/rpc/routes/wallet/exportAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { JsonEncoder } from '../../../wallet/account/encoder/json'
import { MnemonicEncoder } from '../../../wallet/account/encoder/mnemonic'
import { SpendingKeyEncoder } from '../../../wallet/account/encoder/spendingKey'
import { ExportAccountResponse } from './exportAccount'
import { CreateIdentityResponse } from './multisig/createIdentity'
import { CreateParticipantResponse } from './multisig/createParticipant'

describe('Route wallet/exportAccount', () => {
const routeTest = createRouteTest(true)
Expand Down Expand Up @@ -149,7 +149,7 @@ describe('Route wallet/exportAccount', () => {
async (name) =>
(
await routeTest.client
.request<CreateIdentityResponse>('wallet/multisig/createIdentity', { name })
.request<CreateParticipantResponse>('wallet/multisig/createParticipant', { name })
.waitForEnd()
).content,
),
Expand Down
10 changes: 5 additions & 5 deletions ironfish/src/rpc/routes/wallet/importAccount.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Bech32JsonEncoder } from '../../../wallet/account/encoder/bech32json'
import { AccountFormat } from '../../../wallet/account/encoder/encoder'
import { RpcClient } from '../../clients'
import { ImportResponse } from './importAccount'
import { CreateIdentityResponse } from './multisig/createIdentity'
import { CreateParticipantResponse } from './multisig/createParticipant'

describe('Route wallet/importAccount', () => {
const routeTest = createRouteTest(true)
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('Route wallet/importAccount', () => {

const identity = (
await routeTest.client
.request<CreateIdentityResponse>('wallet/multisig/createIdentity', { name })
.request<CreateParticipantResponse>('wallet/multisig/createParticipant', { name })
.waitForEnd()
).content.identity
const base64 = encodeAccount(createAccountImport(name), AccountFormat.Base64Json, {
Expand Down Expand Up @@ -371,11 +371,11 @@ describe('Route wallet/importAccount', () => {
const name = 'multisig-encrypted-base64 (wrong key)'

await routeTest.client
.request<CreateIdentityResponse>('wallet/multisig/createIdentity', { name })
.request<CreateParticipantResponse>('wallet/multisig/createParticipant', { name })
.waitForEnd()
const encryptingIdentity = ParticipantSecret.random().toIdentity()
const encryptingParticipant = ParticipantSecret.random().toIdentity()
const base64 = encodeAccount(createAccountImport(name), AccountFormat.Base64Json, {
encryptWith: { kind: 'MultisigIdentity', identity: encryptingIdentity },
encryptWith: { kind: 'MultisigIdentity', identity: encryptingParticipant },
})

await expect(
Expand Down
Loading

0 comments on commit 737e6ae

Please sign in to comment.