Skip to content

Commit

Permalink
fixed tests due to faulty config, added new dev choice to manually ju…
Browse files Browse the repository at this point in the history
…mp start network
  • Loading branch information
rh0delta committed Oct 22, 2024
1 parent fb786f0 commit 3ca8cb9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/balance/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { print } from "src/common/utils"
import { findAccountByAddressOrName, print } from "src/common/utils"
import { EntropyBalance } from "./main"

export async function entropyBalance (entropy, endpoint, storedConfig) {
try {
const balanceService = new EntropyBalance(entropy, endpoint)
const balance = await balanceService.getBalance(storedConfig.selectedAccount)
print(`Address ${storedConfig.selectedAccount} has a balance of: ${balance.toLocaleString('en-US')} BITS`)
const address = findAccountByAddressOrName(storedConfig.accounts, storedConfig.selectedAccount)?.address
const balance = await balanceService.getBalance(address)
print(`Entropy Account [${storedConfig.selectedAccount}] (${address}) has a balance of: ${balance.toLocaleString('en-US')} BITS`)
} catch (error) {
console.error('There was an error retrieving balance', error)
}
Expand Down
3 changes: 2 additions & 1 deletion 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 } from './common/utils-cli'
import { endpointOption, loadEntropy } from './common/utils-cli'
import * as config from './config'

import launchTui from './tui'
Expand All @@ -28,6 +28,7 @@ program
.env('DEV_MODE')
.hideHelp()
)
.addOption(endpointOption())
.addCommand(entropyBalanceCommand())
.addCommand(entropyAccountCommand())
.addCommand(entropyTransferCommand())
Expand Down
2 changes: 0 additions & 2 deletions src/common/utils-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ export async function loadEntropy (addressOrName: string, endpoint: string): Pro
if (!selectedAccount) throw new Error(`No account with name or address: "${addressOrName}"`)

const entropy = await initializeEntropy({ keyMaterial: selectedAccount.data, endpoint })
await entropy.substrate.tx.registry.jumpStartNetwork()
.signAndSend(entropy.keyring.accounts.registration.pair)

if (!entropy?.keyring?.accounts?.registration?.pair) {
throw new Error("Signer keypair is undefined or not properly initialized.")
Expand Down
7 changes: 7 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,10 @@ export function findAccountByAddressOrName (accounts: EntropyAccountConfig[], al
accounts.find(account => account.name === aliasOrAddress)
)
}

export async function jumpStartNetwork (entropy) {
await entropy.substrate.tx.registry.jumpStartNetwork()
.signAndSend(entropy.keyring.accounts.registration.pair)

return
}
19 changes: 17 additions & 2 deletions src/tui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Entropy from '@entropyxyz/sdk'
import * as config from './config'
import { EntropyTuiOptions } from './types'
import { logo } from './common/ascii'
import { print } from './common/utils'
import { jumpStartNetwork, print } from './common/utils'
import { loadEntropy } from './common/utils-cli'
import { EntropyLogger } from './common/logger'

Expand Down Expand Up @@ -44,6 +44,15 @@ export default function tui (entropy: Entropy, options: EntropyTuiOptions) {
'User Programs',
]

const devChoices = [
'Jump Start Network',
// 'Create and Fund Faucet(s)'
]

if (options.dev) {
choices = [...choices, ...devChoices]
}

// assign exit so its last
choices = [...choices, 'Exit']

Expand Down Expand Up @@ -129,8 +138,14 @@ async function main (entropy: Entropy, choices, options, logger: EntropyLogger)
.catch(err => console.error('There was an error with program dev', err))
break
}
case 'Jump Start Network': {
await jumpStartNetwork(entropy)
.catch(err => console.error('There was an issue jumpstarting the network', err))
break
}
default: {
throw Error(`unsupported choice: ${answers.choice}`)
console.error('Unsupported Action:' + answers.choice)
break
}
}
}
Expand Down

0 comments on commit 3ca8cb9

Please sign in to comment.