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

Support contract aliases in caller arguments #1764

Closed
Ifropc opened this issue Nov 29, 2024 · 1 comment · May be fixed by #1765
Closed

Support contract aliases in caller arguments #1764

Ifropc opened this issue Nov 29, 2024 · 1 comment · May be fixed by #1765
Assignees

Comments

@Ifropc
Copy link
Contributor

Ifropc commented Nov 29, 2024

What problem does your feature solve?

When using contract aliases they can't be used in contract arguments (see example)

[ /tmp/soroban-project ] > echo $MAIN_CONTRACT 
CB4RERBQMEEXGUFPRZDIN46WTMETHR6EMTWRWXIZO6Q3527GTZI3EK7U
[ /tmp/soroban-project ] > echo $ADD_CONTRACT
CCXZXWJ4FXPEG2453SOYSU5BHCVXSAGDJX63TGNCM6KTCOFJ2KJUTQKF
[ /tmp/soroban-project ] > stellar contract alias ls
ℹ️ Aliases available for network 'Test SDF Network ; September 2015'
test_add_contract: CCXZXWJ4FXPEG2453SOYSU5BHCVXSAGDJX63TGNCM6KTCOFJ2KJUTQKF
test_main: CB4RERBQMEEXGUFPRZDIN46WTMETHR6EMTWRWXIZO6Q3527GTZI3EK7U
[ /tmp/soroban-project ] > stellar contract invoke --id $MAIN_CONTRACT --network testnet -- add_with --contract $ADD_CONTRACT --x 9 --y 10
ℹ️ Send skipped because simulation identified as read-only. Send by rerunning with `--send=yes`.
19
[ /tmp/soroban-project ] > stellar contract invoke --id test_main --network testnet -- add_with --contract $ADD_CONTRACT --x 9 --y 10 
ℹ️ Send skipped because simulation identified as read-only. Send by rerunning with `--send=yes`.
19
[ /tmp/soroban-project ] > stellar contract invoke --id test_main --network testnet -- add_with --contract test_add_contract --x 9 --y 10
❌ error: parsing argument contract: value is not parseable to Some(
    Address,
)

As a result, it's required to pass contract id as an env variable or just string

What would you like to see?

CLI to be able to convert contract alias to Address internally when calling contracts

What alternatives are there?

Using env variables

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Nov 29, 2024
@estherbreath
Copy link

I would like to work on this issue, please

Here are clues on how I intend to go about it:

  1. Implement a feature in the CLI to automatically convert contract aliases to addresses when invoking functions.
  2. Add a new internal conversion function that takes an alias and returns the corresponding full address.
  3. Modify the contract invocation logic to use this conversion function for alias inputs.
  4. Update the CLI's argument parsing to recognize both full addresses and aliases.
  5. This change will simplify usage, allowing developers to work with familiar alias names instead of full addresses throughout their workflow.

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 a pull request may close this issue.

4 participants