Skip to content

Commit

Permalink
Merge pull request #4898 from iron-fish/staging
Browse files Browse the repository at this point in the history
STAGING -> MASTER
  • Loading branch information
danield9tqh committed Apr 16, 2024
2 parents 04d3678 + 7f5fc04 commit f792fd7
Show file tree
Hide file tree
Showing 135 changed files with 6,088 additions and 3,643 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/deploy-node-docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Deploy Node Docker Image
on:
push:
branches:
'staging'
workflow_dispatch:
inputs:
github_tag_mainnet:
Expand Down Expand Up @@ -78,6 +81,13 @@ jobs:
docker tag ironfish ghcr.io/iron-fish/ironfish:${{ github.ref_name }}
docker push ghcr.io/iron-fish/ironfish:${{ github.ref_name }}
# Used to deploy images for specific branches
- name: Deploy Node Image to GitHub:${{ github.ref_name }}
if: ${{ github.ref_type == 'branch' }}
run: |
docker tag ironfish ghcr.io/iron-fish/ironfish:${{ github.ref_name }}
docker push ghcr.io/iron-fish/ironfish:${{ github.ref_name }}
- name: Deploy Node Image to GitHub:testnet
if: ${{ inputs.github_tag_testnet }}
run: |
Expand Down
29 changes: 24 additions & 5 deletions .github/workflows/publish-binaries.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: Build @ironfish binaries

# on:
# push
on:
workflow_dispatch:
inputs:
checkout_ref:
description: 'Git ref (branch, tag, commit SHA)'
required: false
release:
types:
- published
Expand All @@ -26,7 +29,7 @@ jobs:
arch: x86_64
system: linux

- host: macos-latest-large
- host: macos-latest-xlarge
arch: arm64
system: apple

Expand All @@ -41,6 +44,19 @@ jobs:
name: Build ${{ matrix.settings.system }} ${{ matrix.settings.arch }}
runs-on: ${{ matrix.settings.host }}
steps:
- name: Check runner architecture
shell: bash
run: |
if [[ "$(uname -m)" != "${{ matrix.settings.arch }}" ]]; then
echo "Runner architecture does not match specified architecture"
exit 1
fi
# needed for distutils, which is used by nodegyp, arm64 mac runners have 3.12
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.11

- name: Use node.js
uses: actions/setup-node@v4
Expand All @@ -54,6 +70,8 @@ jobs:

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.checkout_ref }}

- name: Create random identifier so binary extraction will be unique
id: identifier
Expand All @@ -76,7 +94,7 @@ jobs:
cd build
cp $(node -e "console.log(process.execPath)") ${{ matrix.settings.system != 'windows' && 'node' || 'node.exe' }}
npm init -y
npm install ironfish@${{ github.event.release.tag_name }}
npm install ironfish@${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.checkout_ref }}
tar -czf ../tools/build.tar.gz -C . .
- name: Create binary
Expand All @@ -88,7 +106,7 @@ jobs:
id: set_paths
shell: bash
run: |
name="ironfish-${{ matrix.settings.system }}-${{ matrix.settings.arch }}-${{ github.event.release.tag_name }}"
name="ironfish-standalone-${{ matrix.settings.system }}-${{ matrix.settings.arch }}-${{ github.event_name == 'release' && github.event.release.tag_name || github.event.inputs.checkout_ref }}"
echo "name=${name}" >> $GITHUB_OUTPUT
echo "zip=${name}.zip" >> $GITHUB_OUTPUT
echo "binary=${{ matrix.settings.system != 'windows' && 'ironfish' || 'ironfish.exe' }}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -183,6 +201,7 @@ jobs:

- name: Upload release asset
id: upload-release-asset
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/rust_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,26 @@ jobs:
run: |
cargo clippy --all-targets -- -D warnings
cargo_vet:
name: Vet Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
save-if: false
shared-key: base

- name: Install cargo-vet
run: |
cargo install --locked cargo-vet
- name: Vet dependencies
run: |
cargo vet
ironfish_rust:
name: Test ironfish-rust
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions ironfish-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ironfish",
"version": "2.1.0",
"version": "2.2.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,12 +62,13 @@
"@aws-sdk/client-s3": "3",
"@aws-sdk/client-secrets-manager": "3",
"@aws-sdk/s3-request-presigner": "3",
"@ironfish/rust-nodejs": "2.1.0",
"@ironfish/sdk": "2.1.0",
"@ironfish/rust-nodejs": "2.2.0",
"@ironfish/sdk": "2.2.0",
"@oclif/core": "1.23.1",
"@oclif/plugin-help": "5.1.12",
"@oclif/plugin-not-found": "2.3.1",
"@oclif/plugin-warn-if-update-available": "2.0.40",
"@oclif/plugin-autocomplete": "1.3.10",
"@types/tar": "6.1.1",
"axios": "0.21.4",
"bech32": "2.0.0",
Expand All @@ -93,7 +94,8 @@
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-not-found",
"@oclif/plugin-warn-if-update-available"
"@oclif/plugin-warn-if-update-available",
"@oclif/plugin-autocomplete"
],
"topics": {}
},
Expand Down
15 changes: 8 additions & 7 deletions ironfish-cli/src/commands/wallet/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BufferUtils } from '@ironfish/sdk'
import { CliUx } from '@oclif/core'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'
import { renderAssetNameFromHex } from '../../utils'
import { renderAssetWithVerificationStatus } from '../../utils'
import { TableCols } from '../../utils/table'

const MAX_ASSET_METADATA_COLUMN_WIDTH = ASSET_METADATA_LENGTH + 1
Expand Down Expand Up @@ -64,12 +64,13 @@ export class AssetsCommand extends IronfishCommand {
header: 'Name',
width: assetNameWidth,
get: (row) =>
renderAssetNameFromHex(row.name, {
verification: row.verification,
outputType: flags.output,
verbose: !!flags.verbose,
logWarn: this.warn.bind(this),
}),
renderAssetWithVerificationStatus(
BufferUtils.toHuman(Buffer.from(row.name, 'hex')),
{
verification: row.verification,
outputType: flags.output,
},
),
}),
id: {
header: 'ID',
Expand Down
92 changes: 48 additions & 44 deletions ironfish-cli/src/commands/wallet/balance.ts
Original file line number Diff line number Diff line change
@@ -1,11 +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 { CurrencyUtils, GetBalanceResponse, isNativeIdentifier } from '@ironfish/sdk'
import { CurrencyUtils, GetBalanceResponse, isNativeIdentifier, RpcAsset } from '@ironfish/sdk'
import { Flags } from '@oclif/core'
import { IronfishCommand } from '../../command'
import { RemoteFlags } from '../../flags'
import { renderAssetName } from '../../utils'
import { renderAssetWithVerificationStatus } from '../../utils'

export class BalanceCommand extends IronfishCommand {
static description =
Expand Down Expand Up @@ -54,60 +54,49 @@ export class BalanceCommand extends IronfishCommand {
confirmations: flags.confirmations,
})

const assetId = response.content.assetId

const asset = (
await client.wallet.getAsset({
account,
id: response.content.assetId,
id: assetId,
confirmations: flags.confirmations,
})
).content

const assetId = response.content.assetId
const assetName = renderAssetName(isNativeIdentifier(assetId) ? '$IRON' : assetId, {
verification: asset.verification,
verbose: !!flags.verbose,
logWarn: this.warn.bind(this),
})
let nameToRender
if (isNativeIdentifier(assetId)) {
nameToRender = '$IRON'
} else {
nameToRender = asset.verification.symbol || assetId
}
const assetName = renderAssetWithVerificationStatus(nameToRender, asset)

if (flags.explain) {
this.explainBalance(response.content, assetName)
this.explainBalance(response.content, asset, assetName)
return
}

const renderedAvailable = renderValue(response.content.available, asset, assetName)
const renderedConfirmed = renderValue(response.content.confirmed, asset, assetName)
const renderedUnconfirmed = renderValue(response.content.unconfirmed, asset, assetName)
const renderedPending = renderValue(response.content.pending, asset, assetName)
if (flags.all) {
this.log(`Account: ${response.content.account}`)
this.log(`Head Hash: ${response.content.blockHash || 'NULL'}`)
this.log(`Head Sequence: ${response.content.sequence || 'NULL'}`)
this.log(
`Available: ${CurrencyUtils.renderIron(response.content.available, true, assetName)}`,
)
this.log(
`Confirmed: ${CurrencyUtils.renderIron(response.content.confirmed, true, assetName)}`,
)
this.log(
`Unconfirmed: ${CurrencyUtils.renderIron(
response.content.unconfirmed,
true,
assetName,
)}`,
)
this.log(
`Pending: ${CurrencyUtils.renderIron(response.content.pending, true, assetName)}`,
)
this.log(`Available: ${renderedAvailable}`)
this.log(`Confirmed: ${renderedConfirmed}`)
this.log(`Unconfirmed: ${renderedUnconfirmed}`)
this.log(`Pending: ${renderedPending}`)
return
}

this.log(`Account: ${response.content.account}`)
this.log(
`Available Balance: ${CurrencyUtils.renderIron(
response.content.available,
true,
assetName,
)}`,
)
this.log(`Available Balance: ${renderedAvailable}`)
}

explainBalance(response: GetBalanceResponse, assetId: string): void {
explainBalance(response: GetBalanceResponse, asset: RpcAsset, assetName: string): void {
const unconfirmed = CurrencyUtils.decode(response.unconfirmed)
const confirmed = CurrencyUtils.decode(response.confirmed)
const pending = CurrencyUtils.decode(response.pending)
Expand All @@ -116,6 +105,13 @@ export class BalanceCommand extends IronfishCommand {
const unconfirmedDelta = unconfirmed - confirmed
const pendingDelta = pending - unconfirmed

const renderedUnconfirmed = renderValue(unconfirmed, asset, assetName)
const renderedUnconfirmedDelta = renderValue(unconfirmedDelta, asset, assetName)
const renderedConfirmed = renderValue(confirmed, asset, assetName)
const renderedPending = renderValue(pending, asset, assetName)
const renderedPendingDelta = renderValue(pendingDelta, asset, assetName)
const renderedAvailable = renderValue(available, asset, assetName)

this.log(`Account: ${response.account}`)

this.log(
Expand All @@ -126,26 +122,34 @@ export class BalanceCommand extends IronfishCommand {
this.log('')

this.log(`Your available balance is made of notes on the chain that are safe to spend`)
this.log(`Available: ${CurrencyUtils.renderIron(available, true, assetId)}`)
this.log(`Available: ${renderedAvailable}`)
this.log('')

this.log('Your confirmed balance includes all notes from transactions on the chain')
this.log(`Confirmed: ${CurrencyUtils.renderIron(confirmed, true, assetId)}`)
this.log(`Confirmed: ${renderedConfirmed}`)
this.log('')

this.log(
`${response.unconfirmedCount} transactions worth ${CurrencyUtils.renderIron(
unconfirmedDelta,
)} are on the chain within ${response.confirmations} blocks of the head`,
`${response.unconfirmedCount} transactions worth ${renderedUnconfirmedDelta} are on the chain within ${response.confirmations} blocks of the head`,
)
this.log(`Unconfirmed: ${CurrencyUtils.renderIron(unconfirmed, true, assetId)}`)
this.log(`Unconfirmed: ${renderedUnconfirmed}`)
this.log('')

this.log(
`${response.pendingCount} transactions worth ${CurrencyUtils.renderIron(
pendingDelta,
)} are pending and have not been added to the chain`,
`${response.pendingCount} transactions worth ${renderedPendingDelta} are pending and have not been added to the chain`,
)
this.log(`Pending: ${CurrencyUtils.renderIron(pending, true, assetId)}`)
this.log(`Pending: ${renderedPending}`)
}
}

// TODO(mat): Eventually this logic should probably be rolled into
// CurrencyUtils.render() via additional options
function renderValue(amount: string | bigint, asset: RpcAsset, assetName: string): string {
const renderNameManually = asset.verification.status === 'verified'

if (renderNameManually) {
return `${assetName} ${CurrencyUtils.render(amount, false, asset.id, asset.verification)}`
} else {
return CurrencyUtils.render(amount, true, asset.id, asset.verification)
}
}
Loading

0 comments on commit f792fd7

Please sign in to comment.