Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NayNay] Entropy Version #269

Merged
merged 9 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Version header format: `[version] Name - year-month-day (entropy-core compatibil
- new: './src/faucet/command.ts' - main entrypoint for CLI flows
- new: package added - yocto-spinner for adding loading spinners to the cli
- new: added new menu item for TUI to trigger a jumpstart to the network (needs to only be run once)
- new: option to display cli and core version

### Changed

Expand All @@ -58,6 +59,7 @@ Version header format: `[version] Name - year-month-day (entropy-core compatibil
- removed flow/entropyFaucet/*.ts directory with file restructure
- added faucet to main menu for TUI
- updated faucet to use loading spinner to indicate to user the progress of the transfer
- ascii art print out now shows up to date core version based, coming from SDK

### Broke

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Options:
"ws://testnet.entropy.xyz:9944/", env: ENDPOINT)

-h, --help display help for command
-v, --version display current cli version
-cv, --core-version display current core protocol version

Commands:
list|ls List all accounts. Output is JSON of form [{ name,
Expand Down
4 changes: 4 additions & 0 deletions dev/bin/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

source ./node_modules/@entropyxyz/sdk/dev/bin/ENTROPY_CORE_VERSION.sh
tsup --env.ENTROPY_CORE_VERSION $ENTROPY_CORE_VERSION
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"scripts": {
"start": "yarn build:global && entropy",
"start:debug": "DEBUG=@entropyxyz/cli yarn start",
"build": "tsup",
"build:global": "tsup && npm install -g",
"build": "./dev/bin/build.sh",
"build:global": "yarn build && npm install -g",
"lint": "eslint . --ext .ts --fix",
"test": "yarn test:types && yarn build:global && yarn test:ts && yarn test:only",
"test:only": "./dev/bin/test-only.sh",
Expand Down
14 changes: 12 additions & 2 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Command, Option } from 'commander'

import { EntropyTuiOptions } from './types'
import { loadEntropy, tuiEndpointOption } from './common/utils-cli'
import { coreVersion, loadEntropy, tuiEndpointOption, versionOption } from './common/utils-cli'
import * as config from './config'

import launchTui from './tui'
Expand All @@ -13,6 +13,7 @@ import { entropyTransferCommand } from './transfer/command'
import { entropySignCommand } from './sign/command'
import { entropyBalanceCommand } from './balance/command'
import { entropyProgramCommand } from './program/command'
import { print } from './common/utils'

const program = new Command()

Expand All @@ -29,17 +30,26 @@ program
.hideHelp()
)
.addOption(tuiEndpointOption())
.addOption(versionOption())
.addOption(coreVersion())
.addCommand(entropyBalanceCommand())
.addCommand(entropyAccountCommand())
.addCommand(entropyTransferCommand())
.addCommand(entropySignCommand())
.addCommand(entropyProgramCommand())

.action(async (opts: EntropyTuiOptions) => {
const { account, tuiEndpoint } = opts
const { account, tuiEndpoint, version, coreVersion } = opts
const entropy = account
? await loadEntropy(account, tuiEndpoint)
: undefined
if (version) {
print(`v${version}`)
process.exit(0)
} else if (coreVersion) {
print(coreVersion)
process.exit(0)
}
// NOTE: on initial startup you have no account
launchTui(entropy, opts)
})
Expand Down
2 changes: 1 addition & 1 deletion src/common/ascii.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export const logo =
@@@@@@ TEST
@@@@@@ *NET
@@@@@@ ENTROPY-CLI
@@@@@@ COREv0.1.0
@@@@@@ CORE${process.env.ENTROPY_CORE_VERSION.split('-')[1]}
`
20 changes: 20 additions & 0 deletions src/common/utils-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { findAccountByAddressOrName, stringify } from './utils'
import * as config from '../config'
import { initializeEntropy } from './initializeEntropy'

const entropyPackage = require('../../package.json')

export function cliWrite (result) {
const prettyResult = stringify(result, 0)
process.stdout.write(prettyResult)
Expand All @@ -18,6 +20,24 @@ function getConfigOrNull () {
}
}

export function versionOption () {
const { version } = entropyPackage

return new Option(
'-v, --version',
'Displays the current running version of Entropy CLI'
).argParser(() => version)
}

export function coreVersion () {
const coreVersion = process.env.ENTROPY_CORE_VERSION.split('-')[1]

return new Option(
'-cv, --core-version',
'Displays the current running version of the Entropy Protocol'
).argParser(() => coreVersion)
}

export function endpointOption () {
return new Option(
'-e, --endpoint <url>',
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export interface EntropyTuiOptions {
endpoint: string
tuiEndpoint: string
dev: boolean
version: string
coreVersion: string
}

type EntropyLoggerLogLevel = 'error' | 'warn' | 'info' | 'debug'
Expand Down
Loading