Skip to content

Commit 3120949

Browse files
authored
Revert "staging -> master (#5451)" (#5453)
This reverts commit 2091d28.
1 parent 2091d28 commit 3120949

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+267
-2367
lines changed

ironfish-cli/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ironfish",
3-
"version": "2.7.0",
3+
"version": "2.6.0",
44
"description": "CLI for running and interacting with an Iron Fish node",
55
"author": "Iron Fish <[email protected]> (https://ironfish.network)",
66
"main": "build/src/index.js",
@@ -59,8 +59,8 @@
5959
"oclif:version": "oclif readme && git add README.md"
6060
},
6161
"dependencies": {
62-
"@ironfish/rust-nodejs": "2.7.0",
63-
"@ironfish/sdk": "2.7.0",
62+
"@ironfish/rust-nodejs": "2.6.0",
63+
"@ironfish/sdk": "2.6.0",
6464
"@ledgerhq/hw-transport-node-hid": "6.29.1",
6565
"@oclif/core": "4.0.11",
6666
"@oclif/plugin-help": "6.2.5",
@@ -69,8 +69,6 @@
6969
"@types/keccak": "3.0.4",
7070
"@types/tar": "6.1.1",
7171
"@zondax/ledger-ironfish": "0.1.2",
72-
"@zondax/ledger-ironfish-dkg": "npm:@zondax/[email protected]",
73-
"@zondax/ledger-js": "^1.0.1",
7472
"axios": "1.7.2",
7573
"bech32": "2.0.0",
7674
"blessed": "0.1.81",

ironfish-cli/src/commands/wallet/chainport/send.ts

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44

5+
import { Asset } from '@ironfish/rust-nodejs'
56
import {
67
CreateTransactionRequest,
78
CurrencyUtils,
8-
MAINNET,
99
RawTransaction,
1010
RawTransactionSerde,
1111
RpcAsset,
@@ -84,8 +84,8 @@ export class BridgeCommand extends IronfishCommand {
8484

8585
const networkId = (await client.chain.getNetworkInfo()).content.networkId
8686

87-
if (networkId !== TESTNET.id && networkId !== MAINNET.id) {
88-
this.error(`Chainport transactions are only available on testnet and mainnet.`)
87+
if (networkId !== TESTNET.id) {
88+
this.error(`Chainport transactions are only available on testnet.`)
8989
}
9090

9191
if (!flags.offline) {
@@ -184,44 +184,38 @@ export class BridgeCommand extends IronfishCommand {
184184

185185
const tokens = await fetchChainportVerifiedTokens(networkId)
186186

187-
const tokenNames = tokens.map(
188-
(t, index) => `${index + 1}. ${t.name} (${t.symbol}) - ${t.web3_address}`,
189-
)
190-
191-
if (!assetId) {
187+
if (assetId == null) {
192188
const asset = await ui.assetPrompt(client, from, {
193189
action: 'send',
194190
showNativeAsset: true,
195191
showNonCreatorAsset: true,
196-
showSingleAssetChoice: true,
192+
showSingleAssetChoice: false,
197193
filter: (asset) => {
198194
return tokens.some((t) => t.web3_address === asset.id)
199195
},
200196
})
201197

202-
if (!asset) {
203-
this.logger.error(
204-
`No supported Chainport asset found for this account. Here are the supported tokens: \n\n${tokenNames.join(
205-
'\n',
206-
)}\n`,
207-
)
208-
this.exit(1)
209-
}
198+
assetId = asset?.id
210199

211-
assetId = asset.id
200+
if (!assetId) {
201+
assetId = Asset.nativeId().toString('hex')
202+
}
212203
}
213204

214205
const asset: ChainportVerifiedToken | undefined = tokens.find(
215206
(t) => t.web3_address === assetId,
216207
)
217208

218209
if (!asset) {
219-
this.logger.error(
220-
`Asset ${assetId} not supported by Chainport. Here are the supported tokens: \n\n${tokenNames.join(
210+
const names = tokens.map(
211+
(t, index) => `${index + 1}. ${t.name} (${t.symbol}) - ${t.web3_address}`,
212+
)
213+
214+
this.error(
215+
`Asset ${assetId} not supported by Chainport. Here are the supported tokens: \n\n${names.join(
221216
'\n',
222217
)}\n`,
223218
)
224-
this.exit(1)
225219
}
226220

227221
const targetNetworks = asset.target_networks

ironfish-cli/src/commands/wallet/decrypt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { RemoteFlags } from '../../flags'
88
import { inputPrompt } from '../../ui'
99

1010
export class DecryptCommand extends IronfishCommand {
11+
static hidden = true
12+
1113
static description = 'decrypt accounts in the wallet'
1214

1315
static flags = {

ironfish-cli/src/commands/wallet/encrypt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { RemoteFlags } from '../../flags'
88
import { inputPrompt } from '../../ui'
99

1010
export class EncryptCommand extends IronfishCommand {
11+
static hidden = true
12+
1113
static description = 'encrypt accounts in the wallet'
1214

1315
static flags = {

ironfish-cli/src/commands/wallet/import.ts

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
/* This Source Code Form is subject to the terms of the Mozilla Public
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4-
import { AccountFormat, encodeAccountImport } from '@ironfish/sdk'
4+
import {
5+
AccountFormat,
6+
encodeAccountImport,
7+
RPC_ERROR_CODES,
8+
RpcRequestError,
9+
} from '@ironfish/sdk'
510
import { Args, Flags, ux } from '@oclif/core'
611
import { IronfishCommand } from '../../command'
712
import { RemoteFlags } from '../../flags'
813
import { checkWalletUnlocked, inputPrompt } from '../../ui'
914
import { importFile, importPipe, longPrompt } from '../../ui/longPrompt'
10-
import { importAccount } from '../../utils'
11-
import { Ledger, LedgerError } from '../../utils/ledger'
15+
import { Ledger } from '../../utils/ledger'
1216

1317
export class ImportCommand extends IronfishCommand {
1418
static description = `import an account`
@@ -98,15 +102,49 @@ export class ImportCommand extends IronfishCommand {
98102
flags.name = name
99103
}
100104

101-
const { name, isDefaultAccount } = await importAccount(
102-
client,
103-
account,
104-
this.logger,
105-
flags.name,
106-
flags.createdAt,
107-
flags.rescan,
108-
)
105+
let result
106+
107+
while (!result) {
108+
try {
109+
result = await client.wallet.importAccount({
110+
account,
111+
rescan: flags.rescan,
112+
name: flags.name,
113+
createdAt: flags.createdAt,
114+
})
115+
} catch (e) {
116+
if (
117+
e instanceof RpcRequestError &&
118+
(e.code === RPC_ERROR_CODES.DUPLICATE_ACCOUNT_NAME.toString() ||
119+
e.code === RPC_ERROR_CODES.IMPORT_ACCOUNT_NAME_REQUIRED.toString() ||
120+
e.code === RPC_ERROR_CODES.DUPLICATE_IDENTITY_NAME.toString())
121+
) {
122+
const message = 'Enter a name for the account'
123+
124+
if (e.code === RPC_ERROR_CODES.DUPLICATE_ACCOUNT_NAME.toString()) {
125+
this.log()
126+
this.log(e.codeMessage)
127+
}
128+
129+
if (e.code === RPC_ERROR_CODES.DUPLICATE_IDENTITY_NAME.toString()) {
130+
this.log()
131+
this.log(e.codeMessage)
132+
}
133+
134+
const name = await inputPrompt(message, true)
135+
if (name === flags.name) {
136+
this.error(`Entered the same name: '${name}'`)
137+
}
138+
139+
flags.name = name
140+
continue
141+
}
142+
143+
throw e
144+
}
145+
}
109146

147+
const { name, isDefaultAccount } = result.content
110148
this.log(`Account ${name} imported.`)
111149

112150
if (isDefaultAccount) {
@@ -123,9 +161,8 @@ export class ImportCommand extends IronfishCommand {
123161
const account = await ledger.importAccount()
124162
return encodeAccountImport(account, AccountFormat.Base64Json)
125163
} catch (e) {
126-
if (e instanceof LedgerError) {
127-
this.logger.error(e.message + '\n')
128-
this.exit(1)
164+
if (e instanceof Error) {
165+
this.error(e.message)
129166
} else {
130167
this.error('Unknown error while importing account from ledger device.')
131168
}

ironfish-cli/src/commands/wallet/lock.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { IronfishCommand } from '../../command'
66
import { RemoteFlags } from '../../flags'
77

88
export class LockCommand extends IronfishCommand {
9+
static hidden = true
10+
911
static description = 'lock accounts in the wallet'
1012

1113
static flags = {

ironfish-cli/src/commands/wallet/mint.ts

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { promptCurrency } from '../../utils/currency'
2323
import { promptExpiration } from '../../utils/expiration'
2424
import { getExplorer } from '../../utils/explorer'
2525
import { selectFee } from '../../utils/fees'
26-
import { sendTransactionWithLedger } from '../../utils/ledger'
2726
import { watchTransaction } from '../../utils/transaction'
2827

2928
export class Mint extends IronfishCommand {
@@ -97,22 +96,12 @@ This will create tokens and increase supply for a given asset.`
9796
transferOwnershipTo: Flags.string({
9897
description: 'The public address of the account to transfer ownership of this asset to.',
9998
}),
100-
transferTo: Flags.string({
101-
description: 'transfer all newly minted coins to this public address',
102-
}),
103-
transferToMemo: Flags.string({
104-
description: 'The memo of transfer when using transferTo',
105-
}),
10699
unsignedTransaction: Flags.boolean({
107100
default: false,
108101
description:
109102
'Return a serialized UnsignedTransaction. Use it to create a transaction and build proofs but not post to the network',
110103
exclusive: ['rawTransaction'],
111104
}),
112-
ledger: Flags.boolean({
113-
default: false,
114-
description: 'Mint a transaction using a Ledger device',
115-
}),
116105
}
117106

118107
async start(): Promise<void> {
@@ -151,7 +140,7 @@ This will create tokens and increase supply for a given asset.`
151140
name = await ui.inputPrompt('Enter the name for the new asset', true)
152141
}
153142

154-
if (metadata == null) {
143+
if (!metadata) {
155144
metadata = await ui.inputPrompt('Enter metadata for the new asset')
156145
}
157146

@@ -224,12 +213,6 @@ This will create tokens and increase supply for a given asset.`
224213
}
225214
}
226215

227-
if (flags.transferTo) {
228-
if (!isValidPublicAddress(flags.transferTo)) {
229-
this.error('transferTo must be a valid public address')
230-
}
231-
}
232-
233216
let expiration = flags.expiration
234217
if ((flags.rawTransaction || flags.unsignedTransaction) && expiration === undefined) {
235218
expiration = await promptExpiration({ logger: this.logger, client: client })
@@ -240,34 +223,25 @@ This will create tokens and increase supply for a given asset.`
240223
this.exit(1)
241224
}
242225

243-
const mint = {
244-
// Only provide the asset id if we are not minting an asset for the first time
245-
...(assetData != null ? { assetId } : {}),
246-
name: name,
247-
metadata: metadata,
248-
value: CurrencyUtils.encode(amount),
249-
transferOwnershipTo: flags.transferOwnershipTo,
250-
}
251-
252226
const params: CreateTransactionRequest = {
253227
account,
254228
outputs: [],
255-
mints: [mint],
229+
mints: [
230+
{
231+
// Only provide the asset id if we are not minting an asset for the first time
232+
...(assetData != null ? { assetId } : {}),
233+
name,
234+
metadata,
235+
value: CurrencyUtils.encode(amount),
236+
transferOwnershipTo: flags.transferOwnershipTo,
237+
},
238+
],
256239
fee: flags.fee ? CurrencyUtils.encode(flags.fee) : null,
257240
feeRate: flags.feeRate ? CurrencyUtils.encode(flags.feeRate) : null,
258241
expiration: expiration,
259242
confirmations: flags.confirmations,
260243
}
261244

262-
if (flags.transferTo) {
263-
params.outputs.push({
264-
publicAddress: flags.transferTo,
265-
amount: mint.value,
266-
assetId: assetId,
267-
memo: flags.transferToMemo,
268-
})
269-
}
270-
271245
let raw: RawTransaction
272246
if (params.fee === null && params.feeRate === null) {
273247
raw = await selectFee({
@@ -308,23 +282,10 @@ This will create tokens and increase supply for a given asset.`
308282
name,
309283
metadata,
310284
flags.transferOwnershipTo,
311-
flags.transferTo,
312285
flags.confirm,
313286
assetData,
314287
)
315288

316-
if (flags.ledger) {
317-
await sendTransactionWithLedger(
318-
client,
319-
raw,
320-
account,
321-
flags.watch,
322-
flags.confirm,
323-
this.logger,
324-
)
325-
this.exit(0)
326-
}
327-
328289
ux.action.start('Sending the transaction')
329290

330291
const response = await client.wallet.postTransaction({
@@ -363,7 +324,6 @@ This will create tokens and increase supply for a given asset.`
363324
Value: renderedValue,
364325
Fee: renderedFee,
365326
Hash: transaction.hash().toString('hex'),
366-
'Transfered To': flags.transferTo ? flags.transferTo : undefined,
367327
}),
368328
)
369329

@@ -396,7 +356,6 @@ This will create tokens and increase supply for a given asset.`
396356
name?: string,
397357
metadata?: string,
398358
transferOwnershipTo?: string,
399-
transferTo?: string,
400359
confirm?: boolean,
401360
assetData?: RpcAsset,
402361
): Promise<void> {
@@ -417,17 +376,6 @@ This will create tokens and increase supply for a given asset.`
417376
`Fee: ${renderedFee}`,
418377
]
419378

420-
if (transferTo) {
421-
confirmMessage.push(
422-
`\nAll ${CurrencyUtils.render(
423-
amount,
424-
false,
425-
assetId,
426-
assetData?.verification,
427-
)} of this asset will be transferred to ${transferTo}.`,
428-
)
429-
}
430-
431379
if (transferOwnershipTo) {
432380
confirmMessage.push(
433381
`Ownership of this asset will be transferred to ${transferOwnershipTo}. The current account will no longer have any permission to mint or modify this asset. This cannot be undone.`,

0 commit comments

Comments
 (0)