From e0f1fa156bd024c7589199150c6e38550d706f42 Mon Sep 17 00:00:00 2001 From: Nando Vieira Date: Mon, 24 Jun 2024 15:01:56 -0700 Subject: [PATCH] Add support for contract id alias on `stellar contract bindings typescript`. --- .../src/commands/contract/bindings/typescript.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs b/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs index b75804d72..635446b85 100644 --- a/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs +++ b/cmd/soroban-cli/src/commands/contract/bindings/typescript.rs @@ -71,6 +71,8 @@ pub enum Error { CannotParseContractId(String, DecodeError), #[error(transparent)] UtilsError(#[from] get_spec::Error), + #[error(transparent)] + Config(#[from] config::Error), } #[async_trait::async_trait] @@ -87,8 +89,15 @@ impl NetworkRunnable for Cmd { let wasm: wasm::Args = wasm.into(); wasm.parse()?.spec } else { - let contract_id = soroban_spec_tools::utils::contract_id_from_str(&self.contract_id) - .map_err(|e| Error::CannotParseContractId(self.contract_id.clone(), e))?; + let network = config.map_or_else( + || self.network.get(&self.locator).map_err(Error::from), + |c| c.get_network().map_err(Error::from), + )?; + + let contract_id = self + .locator + .resolve_contract_id(&self.contract_id, &network.network_passphrase)?; + get_remote_contract_spec( &contract_id, &self.locator,