Skip to content

Commit

Permalink
Merge pull request #3817 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
mat-if authored Apr 21, 2023
2 parents 79e7e05 + 3a83b27 commit 03bfdc4
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish",
"version": "1.0.0",
"version": "1.0.1",
"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 @@ -61,7 +61,7 @@
"@aws-sdk/client-secrets-manager": "3.276.0",
"@aws-sdk/s3-request-presigner": "3.127.0",
"@ironfish/rust-nodejs": "1.0.0",
"@ironfish/sdk": "1.0.0",
"@ironfish/sdk": "1.0.1",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
12 changes: 11 additions & 1 deletion ironfish-cli/src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
/* 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 { FileUtils, GetNodeStatusResponse, PromiseUtils, TimeUtils } from '@ironfish/sdk'
import {
defaultNetworkName,
FileUtils,
GetNodeStatusResponse,
PromiseUtils,
TimeUtils,
} from '@ironfish/sdk'
import { Assert } from '@ironfish/sdk'
import { Flags } from '@oclif/core'
import blessed from 'blessed'
Expand Down Expand Up @@ -111,6 +117,9 @@ function renderStatus(content: GetNodeStatusResponse, debugOutput: boolean): str

const blockGraffiti = `${content.miningDirector.blockGraffiti}`

const network =
defaultNetworkName(content.node.networkId) || content.node.networkId.toString()

const peerNetworkStatus = `${
content.peerNetwork.isReady ? 'CONNECTED' : 'WAITING'
} - In: ${FileUtils.formatFileSize(
Expand Down Expand Up @@ -195,6 +204,7 @@ Version ${content.node.version} @ ${content.node.git}
Node ${nodeStatus}
Node Name ${nodeName}
Block Graffiti ${blockGraffiti}
Network ${network}
Memory ${memoryStatus}
CPU ${cpuStatus}
P2P Network ${peerNetworkStatus}
Expand Down
13 changes: 10 additions & 3 deletions ironfish-cli/src/commands/wallet/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class Send extends IronfishCommand {
let assetId = flags.assetId
let to = flags.to?.trim()
let from = flags.account?.trim()
let memo = flags.memo?.trim()

const client = await this.sdk.connectRpc()

Expand Down Expand Up @@ -162,6 +163,10 @@ export class Send extends IronfishCommand {
})
}

if (!memo) {
memo = await CliUx.ux.prompt('Enter the memo (or leave blank)', { required: false })
}

if (!isValidPublicAddress(to)) {
this.log(`A valid public address is required`)
this.exit(1)
Expand All @@ -178,7 +183,7 @@ export class Send extends IronfishCommand {
{
publicAddress: to,
amount: CurrencyUtils.encode(amount),
memo: flags.memo,
memo,
assetId,
},
],
Expand Down Expand Up @@ -208,7 +213,7 @@ export class Send extends IronfishCommand {
this.exit(0)
}

if (!flags.confirm && !(await this.confirm(assetId, amount, raw.fee, from, to))) {
if (!flags.confirm && !(await this.confirm(assetId, amount, raw.fee, from, to, memo))) {
this.error('Transaction aborted.')
}

Expand All @@ -227,6 +232,7 @@ export class Send extends IronfishCommand {
this.log(`Sent ${CurrencyUtils.renderIron(amount, true, assetId)} to ${to} from ${from}`)
this.log(`Hash: ${transaction.hash().toString('hex')}`)
this.log(`Fee: ${CurrencyUtils.renderIron(transaction.fee(), true)}`)
this.log(`Memo: ${memo}`)
this.log(
`\nIf the transaction is mined, it will appear here https://explorer.ironfish.network/transaction/${transaction
.hash()
Expand All @@ -251,6 +257,7 @@ export class Send extends IronfishCommand {
fee: bigint,
from: string,
to: string,
memo: string,
): Promise<boolean> {
this.log(
`You are about to send a transaction: ${CurrencyUtils.renderIron(
Expand All @@ -260,7 +267,7 @@ export class Send extends IronfishCommand {
)} plus a transaction fee of ${CurrencyUtils.renderIron(
fee,
true,
)} to ${to} from the account ${from}`,
)} to ${to} from the account "${from}" with the memo "${memo}"`,
)

return await CliUx.ux.confirm('Do you confirm (Y/N)?')
Expand Down
2 changes: 1 addition & 1 deletion ironfish/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/sdk",
"version": "1.0.0",
"version": "1.0.1",
"description": "SDK for running and interacting with an Iron Fish node",
"author": "Iron Fish <[email protected]> (https://ironfish.network)",
"main": "build/src/index.js",
Expand Down
11 changes: 11 additions & 0 deletions ironfish/src/defaultNetworkDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ export function isDefaultNetworkId(networkId: number): boolean {
return networkId <= 100
}

export function defaultNetworkName(networkId: number): string | undefined {
switch (networkId) {
case 0:
return 'Testnet'
case 1:
return 'Mainnet'
case 2:
return 'Dev'
}
}

/**
* This account (IronFishGenesisAccount) can be imported to access the funds in the genesis block.
*
Expand Down
6 changes: 5 additions & 1 deletion ironfish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export * from './wallet'
export * from './assert'
export * from './blockchain'
export * from './consensus'
export { DEV_GENESIS_ACCOUNT } from './defaultNetworkDefinitions'
export {
DEV_GENESIS_ACCOUNT,
defaultNetworkName,
isDefaultNetworkId,
} from './defaultNetworkDefinitions'
export * from './chainProcessor'
export * from './event'
export * from './fileStores'
Expand Down
3 changes: 3 additions & 0 deletions ironfish/src/rpc/routes/node/getStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type GetNodeStatusResponse = {
version: string
git: string
nodeName: string
networkId: number
}
cpu: {
cores: number
Expand Down Expand Up @@ -116,6 +117,7 @@ export const GetStatusResponseSchema: yup.ObjectSchema<GetNodeStatusResponse> =
version: yup.string().defined(),
git: yup.string().defined(),
nodeName: yup.string().defined(),
networkId: yup.number().defined(),
})
.defined(),
cpu: yup
Expand Down Expand Up @@ -289,6 +291,7 @@ function getStatus(node: IronfishNode): GetNodeStatusResponse {
version: node.pkg.version,
git: node.pkg.git,
nodeName: node.config.get('nodeName'),
networkId: node.internal.get('networkId'),
},
cpu: {
cores: node.metrics.cpuCores,
Expand Down
1 change: 1 addition & 0 deletions ironfish/src/webApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class WebApi {
graffiti: block.graffiti,
main: block.main,
transactions: block.transactions,
work: block.work,
}))

const options = this.options({ 'Content-Type': 'application/json' })
Expand Down
2 changes: 1 addition & 1 deletion simulator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"docs:open": "open docs/index.html"
},
"dependencies": {
"@ironfish/sdk": "1.0.0",
"@ironfish/sdk": "1.0.1",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down

0 comments on commit 03bfdc4

Please sign in to comment.