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

Add contract alias ls. #1572

Merged
merged 7 commits into from
Aug 31, 2024
Merged

Add contract alias ls. #1572

merged 7 commits into from
Aug 31, 2024

Conversation

fnando
Copy link
Member

@fnando fnando commented Aug 28, 2024

What

$ cargo run contract alias ls --global
   Compiling soroban-cli v21.4.1 (/Users/fnando/Projects/stellar/stellar-cli/cmd/soroban-cli)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.08s
     Running `target/debug/soroban contract alias list --global`
ℹ️ Aliases available for network 'Test SDF Network ; September 2015'
hello_world: CAXUMKGXAOY6IAO36XJV6DSOQBMBANSUJ6NR5EXIF27ZWNPW7OOTTHPC
increment: CALLOOCCCJRZ6AZAJSKNCTDZ766N4ANVRKRJPHC65KDV7RJCS37PS4XY

ℹ️ Aliases available for network 'Standalone Network ; February 2017'
hello_world: CC47LWR7ZJH2QQTFUUNRERMBPBAUHIVLKHIKACV6VVZEEQJIHJOJNGPL


$ echo $?
0

$ cargo run contract alias ls
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
     Running `target/debug/soroban contract alias list`
⚠️ No aliases defined for network

$ echo $?
1

Why

#1420

Known limitations

N/A

cmd/soroban-cli/src/commands/contract/alias/list.rs Outdated Show resolved Hide resolved
cmd/soroban-cli/src/commands/contract/alias/list.rs Outdated Show resolved Hide resolved
FULL_HELP_DOCS.md Outdated Show resolved Hide resolved
Copy link
Member

@willemneal willemneal left a comment

Choose a reason for hiding this comment

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

My one thought is that it would be good to have a way to list all across all networks. Like -l on other list commands.

@fnando
Copy link
Member Author

fnando commented Aug 28, 2024

@willemneal I think that's a good idea (#1420 even mentions it), but I wonder how we can achieve that by using command(flatten). 🤔

I tried to make it work, but failed to make everything work.

@Ifropc
Copy link
Contributor

Ifropc commented Aug 28, 2024

As an idea we can add list --all that conflicts with --network
The only thing is that our current flags are already pretty complicated, not sure if it makes sense to complicate it even further

@fnando
Copy link
Member Author

fnando commented Aug 28, 2024

@Ifropc I did that, but network options are required, and simply using Option<network::Args> doesn't work (it complains about #[group(skip)], and even without it doesn't work).

@Ifropc
Copy link
Contributor

Ifropc commented Aug 28, 2024

Yeah, I was looking into groups, unfortunately we can't make it work easily while using derive API, this is a known issue in clap (and I don't think it will be changed, based on the discussion in Clap repo). So our only option is to migrate to builder for networks and maybe other flags as well, which we probably don't want to spend our time on right now.
What I suggest is to not use Option<network::Args> and instead only use network name as a string (testnet/mainnet/etc) -> as we don't need to know RPC url to fetch aliases.
But it will conflict with how we are using network everywhere else, so maybe not a very good idea

@fnando
Copy link
Member Author

fnando commented Aug 28, 2024

I guess we should ignore --all for now.

@leighmcculloch
Copy link
Member

I think we can keep this command simpler and output all aliases for all networks, and provide no filtering options.

@fnando
Copy link
Member Author

fnando commented Aug 28, 2024

@leighmcculloch works for me!

@fnando
Copy link
Member Author

fnando commented Aug 29, 2024

The list output is currently this:

$ cargo run contract alias ls --global
   Compiling soroban-cli v21.4.1 (/Users/fnando/Projects/stellar/stellar-cli/cmd/soroban-cli)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.08s
     Running `target/debug/soroban contract alias list --global`
ℹ️ Aliases available for network 'Test SDF Network ; September 2015'
hello_world: CAXUMKGXAOY6IAO36XJV6DSOQBMBANSUJ6NR5EXIF27ZWNPW7OOTTHPC
increment: CALLOOCCCJRZ6AZAJSKNCTDZ766N4ANVRKRJPHC65KDV7RJCS37PS4XY

ℹ️ Aliases available for network 'Standalone Network ; February 2017'
hello_world: CC47LWR7ZJH2QQTFUUNRERMBPBAUHIVLKHIKACV6VVZEEQJIHJOJNGPL


$ echo $?
0

$ cargo run contract alias ls
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
     Running `target/debug/soroban contract alias list`
⚠️ No aliases defined for network

$ echo $?
1

@fnando fnando changed the title Add contract alias list. Add contract alias ls. Aug 29, 2024
Copy link
Contributor

@chadoh chadoh left a comment

Choose a reason for hiding this comment

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

Thanks!

@fnando fnando merged commit d90cd78 into main Aug 31, 2024
26 checks passed
@fnando fnando deleted the contract-alias-ls branch August 31, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants