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

feat(sns): Add list and add-sns-wasm-for-tests command #139

Merged
merged 5 commits into from
Sep 12, 2024

Conversation

anchpop
Copy link
Contributor

@anchpop anchpop commented Sep 3, 2024

This brings it in sync with the monorepo's sns cli.

add-sns-wasm-for-tests is hidden as it's relatively "developer only" and I don't have a good idea of when it's needed, other than that I know snsdemo uses it.

The commands were implemented in the monorepo, and are just called from here.

@anchpop anchpop requested review from a team as code owners September 3, 2024 16:49
@anchpop anchpop enabled auto-merge (squash) September 3, 2024 16:49
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
fn get_agent(ic_url: &str) -> Result<Agent> {
Agent::builder()
.with_url(ic_url)
.with_verify_query_signatures(false)

Choose a reason for hiding this comment

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

I'm not really sure what this does, but it looks scary, like leaving your house without locking the door. Sure, if there are no evil doers around, everything works just fine. But you still wouldn't do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, done

extensions/sns/src/main.rs Show resolved Hide resolved
}
};

let agent = utils::get_mainnet_agent()?;

Choose a reason for hiding this comment

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

NCR

IIUC, this is only used in one of the branches, specifically, List. Perhaps the list::exec can built agent for itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, that's tricky because list::exec in the future won't have the necessary information to create the agent

Comment on lines +115 to +129
SnsLibSubCommand::DeployTestflight(args) => deploy_testflight(args),
SnsLibSubCommand::InitConfigFile(args) => init_config_file::exec(args),
SnsLibSubCommand::PrepareCanisters(args) => prepare_canisters::exec(args),
SnsLibSubCommand::Propose(args) => propose::exec(args),
SnsLibSubCommand::NeuronIdToCandidSubaccount(args) => {
neuron_id_to_candid_subaccount::exec(args)
}
}?;
Ok(())
SnsLibSubCommand::AddSnsWasmForTests(args) => add_sns_wasm_for_tests(args),
SnsLibSubCommand::List(args) => list::exec(args, &agent).await,

Choose a reason for hiding this comment

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

NCR

Would be nice if all these looked the same. I.e.

X::Y(y) => y::exec(y),

Even better (but more work, and therefore, not recommended now, but next time):

subcommand.unwrap().exec()

where unwrap returns a Box<dyn Exec>, and Exec is a new trait that requires fn exec(&self) -> Result<...>;, and all the args types implement it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this difference is an annoying consequence of the scoping of add_sns_wasm_for_tests, which can't be fixed in this PR as it's determined by the monorepo :(

@anchpop anchpop force-pushed the @anchpop/update-sns-extension-with-new-commands branch 4 times, most recently from fa4a856 to a7f999a Compare September 10, 2024 16:14
@anchpop anchpop force-pushed the @anchpop/update-sns-extension-with-new-commands branch 2 times, most recently from 31e9a4a to fc0789f Compare September 11, 2024 22:30
@anchpop anchpop force-pushed the @anchpop/update-sns-extension-with-new-commands branch from fc0789f to 02a6247 Compare September 11, 2024 23:05
@anchpop anchpop merged commit 079889d into main Sep 12, 2024
7 checks passed
@anchpop anchpop deleted the @anchpop/update-sns-extension-with-new-commands branch September 12, 2024 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants