Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_aliases_to_markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethengelman authored Jan 22, 2025
2 parents 9d3c0ef + bfe8e65 commit 3b849b8
Show file tree
Hide file tree
Showing 20 changed files with 55 additions and 7 deletions.
6 changes: 4 additions & 2 deletions cmd/soroban-cli/src/commands/contract/asset.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::commands::global;

use super::{deploy, id};

#[derive(Debug, clap::Subcommand)]
Expand All @@ -17,10 +19,10 @@ pub enum Error {
}

impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
match &self {
Cmd::Id(id) => id.run()?,
Cmd::Deploy(asset) => asset.run().await?,
Cmd::Deploy(asset) => asset.run(global_args).await?,
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum Error {
impl Cmd {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
match &self {
Cmd::Asset(asset) => asset.run().await?,
Cmd::Asset(asset) => asset.run(global_args).await?,
Cmd::Wasm(wasm) => wasm.run(global_args).await?,
}
Ok(())
Expand Down
14 changes: 13 additions & 1 deletion cmd/soroban-cli/src/commands/contract/deploy/asset.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::config::locator;
use crate::print::Print;
use crate::xdr::{
Asset, ContractDataDurability, ContractExecutable, ContractIdPreimage, CreateContractArgs,
Error as XdrError, Hash, HostFunction, InvokeHostFunctionOp, LedgerKey::ContractData,
Expand Down Expand Up @@ -73,14 +74,25 @@ pub struct Cmd {
}

impl Cmd {
pub async fn run(&self) -> Result<(), Error> {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
let res = self.run_against_rpc_server(None, None).await?.to_envelope();
match res {
TxnEnvelopeResult::TxnEnvelope(tx) => println!("{}", tx.to_xdr_base64(Limits::none())?),
TxnEnvelopeResult::Res(contract) => {
let network = self.config.get_network()?;

if let Some(alias) = self.alias.clone() {
if let Some(existing_contract) = self
.config
.locator
.get_contract_id(&alias, &network.network_passphrase)?
{
let print = Print::new(global_args.quiet);
print.warnln(format!(
"Overwriting existing contract id: {existing_contract}"
));
};

self.config.locator.save_contract_id(
&network.network_passphrase,
&contract,
Expand Down
11 changes: 11 additions & 0 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ impl Cmd {
let network = self.config.get_network()?;

if let Some(alias) = self.alias.clone() {
if let Some(existing_contract) = self
.config
.locator
.get_contract_id(&alias, &network.network_passphrase)?
{
let print = Print::new(global_args.quiet);
print.warnln(format!(
"Overwriting existing contract id: {existing_contract}"
));
};

self.config.locator.save_contract_id(
&network.network_passphrase,
&contract,
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub enum Error {
impl Cmd {
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> {
match &self {
Cmd::Asset(asset) => asset.run().await?,
Cmd::Asset(asset) => asset.run(global_args).await?,
Cmd::Bindings(bindings) => bindings.run().await?,
Cmd::Build(build) => build.run(global_args)?,
Cmd::Extend(extend) => extend.run().await?,
Expand Down
9 changes: 9 additions & 0 deletions cmd/soroban-cli/src/utils/contract-template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ use soroban_sdk::{contract, contractimpl, vec, Env, String, Vec};
#[contract]
pub struct Contract;

// This is a sample contract. Replace this placeholder with your own contract logic.
// A corresponding test example is available in `test.rs`.
//
// For comprehensive examples, visit <https://github.com/stellar/soroban-examples>.
// The repository includes use cases for the Stellar ecosystem, such as data storage on
// the blockchain, token swaps, liquidity pools, and more.
//
// Refer to the official documentation:
// <https://developers.stellar.org/docs/build/smart-contracts/overview>.
#[contractimpl]
impl Contract {
pub fn hello(env: Env, to: String) -> Vec<String> {
Expand Down
1 change: 1 addition & 0 deletions cookbook/contract-lifecycle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Contract Lifecycle
hide_table_of_contents: true
description: Manage the lifecycle of a Stellar smart contract using the CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/contract-lifecycle.mdx
---

To manage the lifecycle of a Stellar smart contract using the CLI, follow these steps:
Expand Down
1 change: 1 addition & 0 deletions cookbook/deploy-contract.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Deploy a contract from installed Wasm bytecode
hide_table_of_contents: true
description: Deploy an instance of a compiled contract that is already installed on the network
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/deploy-contract.mdx
---

To deploy an instance of a compiled smart contract that has already been installed onto the Stellar network, use the `stellar contract deploy` command:
Expand Down
1 change: 1 addition & 0 deletions cookbook/deploy-stellar-asset-contract.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Deploy the Stellar Asset Contract for a Stellar asset
hide_table_of_contents: true
description: Deploy an SAC for a Stellar asset so that it can interact with smart contracts
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/deploy-stellar-asset-contract.mdx
---

The Stellar CLI can deploy a [Stellar Asset Contract] for a Stellar asset so that any Stellar smart contract can interact with the asset.
Expand Down
1 change: 1 addition & 0 deletions cookbook/extend-contract-instance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Extend a deployed contract instance's TTL
hide_table_of_contents: true
description: Use the CLI to extend the time to live (TTL) of a contract instance
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/extend-contract-instance.mdx
---

You can use the Stellar CLI to extend the TTL of a contract instance like so:
Expand Down
1 change: 1 addition & 0 deletions cookbook/extend-contract-storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Extend a deployed contract's storage entry TTL
hide_table_of_contents: true
description: Use the CLI to extend the time to live (TTL) of a contract's persistent storage entry
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/extend-contract-storage.mdx
---

You can use the Stellar CLI to extend the TTL of a contract's persistent storage entry. For a storage entry that uses a simple `Symbol` as its storage key, you can run a command like so:
Expand Down
1 change: 1 addition & 0 deletions cookbook/extend-contract-wasm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Extend a deployed contract's Wasm code TTL
hide_table_of_contents: true
description: Use Stellar CLI to extend contract's Wasm bytecode TTL, with or without local binary
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/extend-contract-wasm.mdx
---

You can use the Stellar CLI to extend the TTL of a contract's Wasm bytecode. This can be done in two forms: if you do or do not have the compiled contract locally. If you do have the compiled binary on your local machine:
Expand Down
1 change: 1 addition & 0 deletions cookbook/install-deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Install and deploy a smart contract
hide_table_of_contents: true
description: Combine the install and deploy commands in the Stellar CLI to accomplish both tasks
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/install-deploy.mdx
---

You can combine the `install` and `deploy` commands of the Stellar CLI to accomplish both tasks:
Expand Down
1 change: 1 addition & 0 deletions cookbook/install-wasm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Install Wasm bytecode
hide_table_of_contents: true
description: Use the Stellar CLI to install a compiled smart contract on the ledger
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/install-wasm.mdx
---

To use the Stellar CLI to install a compiled smart contract on the ledger, use the `stellar contract install` command:
Expand Down
1 change: 1 addition & 0 deletions cookbook/payments-and-assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Payments and Assets
hide_table_of_contents: true
description: Send XLM, stellar classic, or a soroban asset using the Stellar CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/payments-and-assets.mdx
---

To send payments and work with assets using the Stellar CLI, follow these steps:
Expand Down
1 change: 1 addition & 0 deletions cookbook/restore-contract-instance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Restore an archived contract using the Stellar CLI
hide_table_of_contents: true
description: Restore an archived contract instance using the Stellar CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/restore-contract-instance.mdx
---

If your contract instance has been archived, it can easily be restored using the Stellar CLI.
Expand Down
1 change: 1 addition & 0 deletions cookbook/restore-contract-storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Restore archived contract data using the Stellar CLI
hide_table_of_contents: true
description: Restore archived contract storage entries using Stellar CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/restore-contract-storage.mdx
---

If a contract's persistent storage entry has been archived, you can restore it using the Stellar CLI. For a storage entry that uses a simple `Symbol` as its storage key, you can run a command like so:
Expand Down
1 change: 1 addition & 0 deletions cookbook/tx-new.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: `tx` Commands
hide_table_of_contents: true
description: Create stellar transactions using the Stellar CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/tx-new.mdx
---

So far the examples of the CLI interacting with the blockchain have been through the `contract` command. Uploading contracts, deploying contracts, and invoking them.
Expand Down
3 changes: 2 additions & 1 deletion cookbook/tx-op-add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: `tx op add`
hide_table_of_contents: true
description: Create stellar transactions using the Stellar CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/tx-op-add.mdx
---

As see before you can use pipes to pass a transaction envolope between commands. Before we have only been looking at transactions with one operation,
Expand Down Expand Up @@ -48,4 +49,4 @@ stellar tx new set-trustline-flags --fee 1000 --build-only --source issuer --ass
| stellar tx op add set-trustline-flags --asset $ASSET --trustor distributor --clear-authorize \
| stellar tx sign --sign-with-key issuer \
| stellar tx send
```
```
3 changes: 2 additions & 1 deletion cookbook/tx-sign.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: `tx sign` and `tx send`
hide_table_of_contents: true
description: Create stellar transactions using the Stellar CLI
custom_edit_url: https://github.com/stellar/stellar-cli/edit/main/cookbook/tx-sign.mdx
---

The previous examples of using `tx new` showed how to create transactions. However, these transactions were immediately ready to be signed and submitted to the network.
Expand Down Expand Up @@ -69,4 +70,4 @@ stellar tx new create-account \
--build-only \
| stellar tx sign --sign-with-key alice \
| stellar tx send
```
```

0 comments on commit 3b849b8

Please sign in to comment.