Skip to content

Commit

Permalink
Merge pull request #4263 from iron-fish/staging
Browse files Browse the repository at this point in the history
staging -> master
  • Loading branch information
rohanjadvani authored Aug 30, 2023
2 parents 4ea3ae4 + a1baf0b commit fbf32a7
Show file tree
Hide file tree
Showing 74 changed files with 3,760 additions and 3,177 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
wget -O tarpaulin.tar.gz https://github.com/xd009642/tarpaulin/releases/download/0.22.0/cargo-tarpaulin-0.22.0-travis.tar.gz
tar -xzf tarpaulin.tar.gz
mv cargo-tarpaulin ~/.cargo/bin/
cargo tarpaulin -p ironfish --release --out Xml --avoid-cfg-tarpaulin --skip-clean --timeout 180 -- --test-threads 1
cargo tarpaulin -p ironfish --release --out Xml --avoid-cfg-tarpaulin --skip-clean --timeout 300 -- --test-threads 1
# Upload code coverage to Codecov
- name: Upload to codecov.io
Expand All @@ -107,7 +107,7 @@ jobs:
wget -O tarpaulin.tar.gz https://github.com/xd009642/tarpaulin/releases/download/0.22.0/cargo-tarpaulin-0.22.0-travis.tar.gz
tar -xzf tarpaulin.tar.gz
mv cargo-tarpaulin ~/.cargo/bin/
cargo tarpaulin -p ironfish_zkp --release --out Xml --avoid-cfg-tarpaulin --skip-clean --timeout 180 -- --test-threads 1
cargo tarpaulin -p ironfish_zkp --release --out Xml --avoid-cfg-tarpaulin --skip-clean --timeout 300 -- --test-threads 1
# Upload code coverage to Codecov
- name: Upload to codecov.io
Expand Down
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.8.0",
"version": "1.9.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.7.0",
"@ironfish/sdk": "1.8.0",
"@ironfish/rust-nodejs": "1.8.0",
"@ironfish/sdk": "1.9.0",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
Expand Down
3 changes: 2 additions & 1 deletion ironfish-cli/src/commands/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default class Repl extends IronfishCommand {
this.log('\n List all account names')
this.log(` > wallet.listAccounts().map((a) => a.name)`)
this.log(`\n Get the balance of an account`)
this.log(` > await wallet.getBalance('default')`)
this.log(` > const account = await wallet.getAccountByName('default')`)
this.log(` > await wallet.getBalances(account)`)
this.log(`\n Use the RPC node/getStatus`)
this.log(` > (await client.status()).content`)
this.log('')
Expand Down
15 changes: 14 additions & 1 deletion ironfish-cli/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ export default class Start extends IronfishCommand {
description:
'Path to a JSON file containing the network definition of a custom network to connect to',
}),
wallet: Flags.boolean({
allowNo: true,
default: true,
description: `Enable the node's wallet to scan transactions and decrypt notes from the blockchain`,
}),
}

node: IronfishNode | null = null
Expand Down Expand Up @@ -140,6 +145,7 @@ export default class Start extends IronfishCommand {
upgrade,
networkId,
customNetwork,
wallet,
} = flags

if (bootstrap !== undefined) {
Expand Down Expand Up @@ -169,6 +175,9 @@ export default class Start extends IronfishCommand {
if (forceMining !== undefined && forceMining !== this.sdk.config.get('miningForce')) {
this.sdk.config.setOverride('miningForce', forceMining)
}
if (wallet !== undefined && wallet !== this.sdk.config.get('enableWallet')) {
this.sdk.config.setOverride('enableWallet', wallet)
}
if (
logPeerMessages !== undefined &&
logPeerMessages !== this.sdk.config.get('logPeerMessages')
Expand Down Expand Up @@ -210,6 +219,7 @@ export default class Start extends IronfishCommand {
const blockGraffiti = this.sdk.config.get('blockGraffiti').trim() || null
const peerPort = this.sdk.config.get('peerPort')
const bootstraps = this.sdk.config.getArray('bootstrapNodes')
const walletEnabled = this.sdk.config.get('enableWallet')

this.log(`\n${ONE_FISH_IMAGE}`)
this.log(`Version ${node.pkg.version} @ ${node.pkg.git}`)
Expand All @@ -218,6 +228,7 @@ export default class Start extends IronfishCommand {
this.log(`Peer Identity ${node.peerNetwork.localPeer.publicIdentity}`)
this.log(`Peer Agent ${node.peerNetwork.localPeer.agent}`)
this.log(`Peer Port ${peerPort}`)
this.log(`Wallet ${walletEnabled ? 'ENABLED' : 'DISABLED'}`)
this.log(`Bootstrap ${bootstraps.join(',') || 'NONE'}`)
if (inspector.url()) {
this.log(`Inspector ${String(inspector.url())}`)
Expand Down Expand Up @@ -296,7 +307,9 @@ export default class Start extends IronfishCommand {
*/
async setDefaultAccount(node: IronfishNode): Promise<void> {
if (!node.wallet.accountExists(DEFAULT_ACCOUNT_NAME)) {
const account = await node.wallet.createAccount(DEFAULT_ACCOUNT_NAME, true)
const account = await node.wallet.createAccount(DEFAULT_ACCOUNT_NAME, {
setDefault: true,
})

this.log(`New default account created: ${account.name}`)
this.log(`Account's public address: ${account.publicAddress}`)
Expand Down
6 changes: 5 additions & 1 deletion ironfish-cli/src/commands/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* 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 {
Assert,
defaultNetworkName,
FileUtils,
GetNodeStatusResponse,
PromiseUtils,
TimeUtils,
} from '@ironfish/sdk'
import { Assert } from '@ironfish/sdk'
import { Flags } from '@oclif/core'
import blessed from 'blessed'
import { IronfishCommand } from '../command'
Expand Down Expand Up @@ -192,6 +192,10 @@ function renderStatus(content: GetNodeStatusResponse, debugOutput: boolean): str
}
}

if (!content.accounts.enabled) {
accountStatus += accountStatus.length === 0 ? `DISABLED` : ` (DISABLED)`
}

const cores = `Cores: ${content.cpu.cores}`
const current = `Current: ${content.cpu.percentCurrent.toFixed(1)}%`
const rollingAvg = `Rolling Avg: ${content.cpu.percentRollingAvg.toFixed(1)}%`
Expand Down
6 changes: 6 additions & 0 deletions ironfish-cli/src/commands/wallet/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class TransactionsCommand extends IronfishCommand {
const columns = this.getColumns(flags.extended, flags.notes, format)

let showHeader = !flags['no-header']
let hasTransactions = false

for await (const transaction of response.contentStream()) {
const transactionRows = flags.notes
Expand All @@ -93,6 +94,11 @@ export class TransactionsCommand extends IronfishCommand {
})

showHeader = false
hasTransactions = true
}

if (!hasTransactions) {
this.log('No transactions found')
}
}

Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-darwin-arm64",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-darwin-x64",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-arm64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-arm64-gnu",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-arm64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-arm64-musl",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-x64-gnu",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-linux-x64-musl",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs-win32-x64-msvc",
"version": "1.7.0",
"version": "1.8.0",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion ironfish-rust-nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ironfish/rust-nodejs",
"version": "1.7.0",
"version": "1.8.0",
"description": "Node.js bindings for Rust code required by the Iron Fish SDK",
"main": "index.js",
"types": "index.d.ts",
Expand Down
9 changes: 6 additions & 3 deletions ironfish-rust-nodejs/src/structs/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,13 @@ impl NativeTransactionPosted {
}

#[napi]
pub fn hash(&self) -> Buffer {
let hash = self.transaction.transaction_signature_hash();
pub fn hash(&self) -> Result<Buffer> {
let hash = self
.transaction
.transaction_signature_hash()
.map_err(to_napi_err)?;

Buffer::from(hash.as_ref())
Ok(Buffer::from(hash.as_ref()))
}

#[napi]
Expand Down
29 changes: 29 additions & 0 deletions ironfish-rust-nodejs/tests/transaction.test.slow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* 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 { Asset, Transaction, generateKey } from ".."

describe('Transaction', () => {
describe('post', () => {
it('throws an error when posting an invalid transaction version', () => {
const key = generateKey()
const asset = new Asset(key.publicAddress, 'testcoin', '')
// Version 1 transactions cannot have an ownership transfer
const proposedTx = new Transaction(key.spendingKey, 1)
proposedTx.mint(asset, 5n, key.publicAddress)

expect(() => { proposedTx.post(null, 0n)}).toThrow('InvalidTransactionVersion')
})

it('can post a valid transaction', () => {
const key = generateKey()
const asset = new Asset(key.publicAddress, 'testcoin', '')
const proposedTx = new Transaction(key.spendingKey, 1)
proposedTx.mint(asset, 5n)

expect(() => { proposedTx.post(null, 0n)}).not.toThrow()

})
})
})
Loading

0 comments on commit fbf32a7

Please sign in to comment.