Skip to content

Conversation

@BlaineHeffron
Copy link
Contributor

@BlaineHeffron BlaineHeffron commented Jun 4, 2025

Adds import_contract macro. Arguments are name, registry_name (optional) and network (optional). name is the imported client symbol, registry_name is the name of the contract on the registry and defaults to name unless provided, network defaults to testnet unless provided.

This retrieves the named contract's contract id, gets the wasm hash, saves the wasm if the wasm isn't already cached, and uses stellar-sdk's contract_import macro on the wasm bytecode. It also adds a new_from_registry method which hard codes the contract ID, e.g:

                /// Creates a new client instance for the registered contract
                pub fn new_from_registry(env: &'a soroban_sdk::Env) -> Self {
                    let contract_id = soroban_sdk::Address::from_string(
                        &soroban_sdk::String::from_str(
                            env,
                            "CBUB57A2IJFHVDG7CCXCULDJ6NELLY45KBZM27TF72LHV33CZ7MBECHC",
                        ),
                    );
                    Self::new(env, &contract_id)
                }

@BlaineHeffron BlaineHeffron requested a review from willemneal June 4, 2025 17:23
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