soroban-cli icon indicating copy to clipboard operation
soroban-cli copied to clipboard

Alias is currently overwrote with no warning

Open willemneal opened this issue 1 year ago • 3 comments

Currently when reusing an alias it will overwrite the old contract id. Should we add a --force flag to allow this but fail otherwise?

willemneal avatar Jun 28 '24 14:06 willemneal

The original implementation had --force, but Leigh suggested to always replace the contract id. Is there any real case where you wouldn't want to persist the latest contract id?

https://github.com/stellar/stellar-cli/pull/1356#discussion_r1626762468

fnando avatar Jun 28 '24 16:06 fnando

My feedback was that --force is confusing because it doesn't communicate the scope of what is being forced. An option like --force should be focused on the primary action being performed by a command which in this case is deploying the contract, and not related to an ancillary action being performed like saving an alias. Why: It's natural to see options related to their primary action. For example, if we add --force, this command looks like it forces deployment but is actually invalid:

$ stellar contract deploy --wasm ... --force

Or this command which is valid but I think most folks would assume means deployment is forced and the force is unrelated to the alias:

$ stellar contract deploy --wasm ... --force --alias c1

If we want aliases to not overwrite by default, then I think the path that results in a clearer API is:

  1. Disallow overriding and add no options for overwriting
  2. Add a rm command for removing the alias

leighmcculloch avatar Jul 11 '24 02:07 leighmcculloch

I expect that someone interacting with a pubnet network is probably keeping a record of their contract addresses concretely somewhere that isn't just in these aliases given that it is a production use case, and that these aliases are more useful during development, in which case overwriting feels fine. We overwrite elsewhere.

We could output a log line, or a stderr output saying the alias is being ovewritten and what the old value was and new value, so if someone accidentally ovewrites they can fix it.

leighmcculloch avatar Jul 11 '24 02:07 leighmcculloch

This issue is stale because it has been assigned for 30 days with no activity. It will be closed in 30 days unless the stale label is removed, and the assignee is removed or updated.

github-actions[bot] avatar Dec 05 '24 18:12 github-actions[bot]