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] CLI/TUI File Restructure #219

Closed
wants to merge 31 commits into from
Closed

Conversation

frankiebee
Copy link
Collaborator

This PR is for the restructure of the code base to allow it to be more flexible.

rh0delta and others added 21 commits July 31, 2024 15:46
- created new base entropy class to handle the shared nature of the intended use of the class
- restructured balance to be in its own parent directory in the root of src
- created command and util file to contain pure functions and controller functions
Co-authored-by: mix irving <mix@protozoa.nz>
…ance on every command; used to be passed down to each of the commands; added new option to define new address as selected account
- removed flows/entropyTransfer
- created new root directory for transfer to house utils, new command file, and types
- updated tui and cli with new transfer method
@rh0delta rh0delta changed the title Naynay/file restructure [NayNay] CLI/TUI File Restructure Aug 19, 2024
@rh0delta rh0delta changed the base branch from main to dev August 19, 2024 18:31
Copy link
Collaborator Author

@frankiebee frankiebee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inquirer is in the command files which means for programmatic cli we will be loading it and not using it. Lets find a way that we can leave it out of command.ts files

@mixmix
Copy link
Contributor

mixmix commented Aug 21, 2024

yeah that's an artifact of e.g. that initializeEntropy being written tui-first. I refactored enough to isolate it some, and wrote a warning that this needed to change. Excited we're at that point!

src/cli.ts Outdated
Comment on lines 107 to 118
.hook('preAction', async (_thisCommand, actionCommand) => {
if (!entropy || (entropy.keyring.accounts.registration.address !== actionCommand.args[0] || entropy.keyring.accounts.registration.address !== actionCommand.opts().account)) {
// balance includes an address argument, use that address to instantiate entropy
// can keep the conditional to check for length of args, and use the first index since it is our pattern to have the address as the first argument
if (RESTRUCTURED_COMMANDS.includes(actionCommand.name()) && actionCommand.args.length) {
await loadEntropy(actionCommand.args[0], actionCommand.opts().endpoint, actionCommand.opts().password)
} else {
// if address is not an argument, use the address from the option
await loadEntropy(actionCommand.opts().account, actionCommand.opts().endpoint, actionCommand.opts().password)
}
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mixmix this is the abstraction of entropy I had implemented, where we use the pre action hook to initialize/load entropy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rh0delta cool!

Why would the account address ever be args[0]? I would have expected it to be an option... also is this stuff gonna change when we get into CLI sessions?

rh0delta and others added 3 commits August 29, 2024 12:44
* [NayNay] File Restructure: Signing Restructure

- created new file structure for signing flow
- updated tui/cli with new changes

* some cleanup; fixed sign tests

* removed inquirer input from commands file, added file inoput back to signing

* added raw sign back in

* wip: raw sign stuff

* wip: finished off last changes for raw sign but need to test

* wip: porting to newly defined structure

* updated signing to new structure, and added utils-cli from mix pr

* updated file structure for balance

* updated file structure for transfer

* pr review updates

* updated to sign not signing

* signing-restructure tweeeeks (#220)

* tweeeeks

* more tweeks

* fix tests

* rename test

* fix maskPayload

* test fix

* change sign command to just return sig

* stdout cleanup for balance and sign

* tweeks

* fix transfer to allow decimal transfers

---------

Co-authored-by: mix irving <mix@protozoa.nz>
* [NayNay] File Restructure: Accounts Restructure

- refactoring file structure + flow of accounts in cli/tui

* updated new account, list account and selected account with new file structure; still need to update tests

* finished updated manage accoutns stuff, updated tests too

* updated register flow and moved methods to accounts namespace

* updated register tests

* cleanup from smoke test

* updated changelog

* start refactor

* WIP: part way refactored account stuff

* cleaning up the cleanup for accounts restructure;

* forgot something

* updated accounts restructure, continuing from mixs changes

* Update main.ts

* Update manage-accounts.test.ts

* fixups

* WIP

* fixups

* compleeeete

* get working for fresh install. see WIP

* fixed fresh install and using tui, might have fixed cli not sure

* updated initialization of entropy and formt of how we instantiate commands

* skipping faucet test for now, shenanigans occurring

* fixed faucet test

* updated tests;

* Update command.ts

Co-authored-by: mix irving <mix@protozoa.nz>

* pr review updates

* Update src/cli.ts

* account-restructure tweaks (#226)

---------

Co-authored-by: mixmix <mix@protozoa.nz>
mixmix and others added 6 commits September 23, 2024 10:46
* get all config.get* methods fail safely

* fix getSync so that it mkdirps
* fix config (again), rename > accountOption

* Update src/cli.ts
* add deploy to CLI, including start of CLI refactor

* refactor

* tweaks

* some renames

* migrate program => new structure

* fix bugs: no initial account, missing ProgramInfo interface

* update config to be more safe

* fix config (again), rename > accountOption
* [NayNay] File Restructure: Faucet

- restructured faucet to match the new structure

* completed restructure, working on tests

* updated faucet tests

* updated recursion for faucet retry mechanism, reduce calls to the chain

* documented some of the methods used for the faucet

* added changelog
@rh0delta rh0delta marked this pull request as ready for review September 24, 2024 19:21
@rh0delta rh0delta closed this Sep 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[anchor#102 sub issue] start with a better file structure
3 participants