Skip to content

Commit 2f24326

Browse files
Merge branch 'main' into assembly-eulogia
2 parents 0391bfe + 9b8013a commit 2f24326

File tree

10 files changed

+101
-26
lines changed

10 files changed

+101
-26
lines changed

Cargo.lock

+14-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FULL_HELP_DOCS.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ Generate code client bindings for a contract
258258
* `json` — Generate Json Bindings
259259
* `rust` — Generate Rust bindings
260260
* `typescript` — Generate a TypeScript / JavaScript package
261+
* `python` — Generate Python bindings
261262

262263

263264

@@ -306,6 +307,14 @@ Generate a TypeScript / JavaScript package
306307

307308

308309

310+
## `stellar contract bindings python`
311+
312+
Generate Python bindings
313+
314+
**Usage:** `stellar contract bindings python`
315+
316+
317+
309318
## `stellar contract build`
310319

311320
Build a contract from source
@@ -1654,7 +1663,7 @@ Creates and funds a new account with the specified starting balance
16541663
* `--destination <DESTINATION>` — Account Id to create, e.g. `GBX...`
16551664
* `--starting-balance <STARTING_BALANCE>` — Initial balance in stroops of the account, default 1 XLM
16561665

1657-
Default value: `10000000`
1666+
Default value: `10_000_000`
16581667

16591668

16601669

@@ -1681,7 +1690,7 @@ Sets, modifies, or deletes a data entry (name/value pair) that is attached to an
16811690
* `--hd-path <HD_PATH>` — If using a seed phrase, which hierarchical deterministic path to use, e.g. `m/44'/148'/{hd_path}`. Example: `--hd-path 1`. Default: `0`
16821691
* `--global` — Use global config
16831692
* `--config-dir <CONFIG_DIR>` — Location of config directory, default is "."
1684-
* `--data-name <DATA_NAME>`Line to change, either 4 or 12 alphanumeric characters, or "native" if not specified
1693+
* `--data-name <DATA_NAME>`String up to 64 bytes long. If this is a new Name it will add the given name/value pair to the account. If this Name is already present then the associated value will be modified
16851694
* `--data-value <DATA_VALUE>` — Up to 64 bytes long hex string If not present then the existing Name will be deleted. If present then this value will be set in the `DataEntry`
16861695

16871696

@@ -1713,7 +1722,7 @@ Sends an amount in a specific asset to a destination account
17131722
* `--asset <ASSET>` — Asset to send, default native, e.i. XLM
17141723

17151724
Default value: `native`
1716-
* `--amount <AMOUNT>` — Amount of the aforementioned asset to send
1725+
* `--amount <AMOUNT>` — Amount of the aforementioned asset to send. e.g. `10_000_000` (1 XLM)
17171726

17181727

17191728

cmd/crates/soroban-test/tests/it/integration/tx/operations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async fn payment() {
9393
"--destination",
9494
test1.as_str(),
9595
"--amount",
96-
ONE_XLM.to_string().as_str(),
96+
"10_000_000",
9797
])
9898
.assert()
9999
.success();

cmd/soroban-cli/src/commands/contract/bindings.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod json;
2+
pub mod python;
23
pub mod rust;
34
pub mod typescript;
45

@@ -12,6 +13,9 @@ pub enum Cmd {
1213

1314
/// Generate a TypeScript / JavaScript package
1415
Typescript(typescript::Cmd),
16+
17+
/// Generate Python bindings
18+
Python(python::Cmd),
1519
}
1620

1721
#[derive(thiserror::Error, Debug)]
@@ -24,6 +28,9 @@ pub enum Error {
2428

2529
#[error(transparent)]
2630
Typescript(#[from] typescript::Error),
31+
32+
#[error(transparent)]
33+
Python(#[from] python::Error),
2734
}
2835

2936
impl Cmd {
@@ -32,6 +39,7 @@ impl Cmd {
3239
Cmd::Json(json) => json.run()?,
3340
Cmd::Rust(rust) => rust.run()?,
3441
Cmd::Typescript(ts) => ts.run().await?,
42+
Cmd::Python(python) => python.run()?,
3543
}
3644
Ok(())
3745
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use std::fmt::Debug;
2+
3+
use clap::Parser;
4+
5+
#[derive(Parser, Debug, Clone)]
6+
#[group(skip)]
7+
pub struct Cmd {}
8+
9+
#[derive(thiserror::Error, Debug)]
10+
pub enum Error {
11+
#[error("python binding generation is not implemented in the stellar-cli, but is available via the tool located here: https://github.com/lightsail-network/stellar-contract-bindings")]
12+
NotImplemented,
13+
}
14+
15+
impl Cmd {
16+
pub fn run(&self) -> Result<(), Error> {
17+
Err(Error::NotImplemented)
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clap::{command, Parser};
22

3-
use crate::{commands::tx, xdr};
3+
use crate::{commands::tx, tx::builder, xdr};
44

55
#[derive(Parser, Debug, Clone)]
66
#[group(skip)]
@@ -11,15 +11,15 @@ pub struct Cmd {
1111
#[arg(long)]
1212
pub destination: xdr::AccountId,
1313
/// Initial balance in stroops of the account, default 1 XLM
14-
#[arg(long, default_value = "10000000")]
15-
pub starting_balance: i64,
14+
#[arg(long, default_value = "10_000_000")]
15+
pub starting_balance: builder::Amount,
1616
}
1717

1818
impl From<&Cmd> for xdr::OperationBody {
1919
fn from(cmd: &Cmd) -> Self {
2020
xdr::OperationBody::CreateAccount(xdr::CreateAccountOp {
2121
destination: cmd.destination.clone(),
22-
starting_balance: cmd.starting_balance,
22+
starting_balance: cmd.starting_balance.into(),
2323
})
2424
}
2525
}

cmd/soroban-cli/src/commands/tx/new/manage_data.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use crate::{commands::tx, xdr};
77
pub struct Cmd {
88
#[command(flatten)]
99
pub tx: tx::Args,
10-
/// Line to change, either 4 or 12 alphanumeric characters, or "native" if not specified
10+
/// String up to 64 bytes long.
11+
/// If this is a new Name it will add the given name/value pair to the account.
12+
/// If this Name is already present then the associated value will be modified.
1113
#[arg(long)]
1214
pub data_name: xdr::StringM<64>,
1315
/// Up to 64 bytes long hex string

cmd/soroban-cli/src/commands/tx/new/payment.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ pub struct Cmd {
1313
/// Asset to send, default native, e.i. XLM
1414
#[arg(long, default_value = "native")]
1515
pub asset: builder::Asset,
16-
/// Amount of the aforementioned asset to send.
16+
/// Amount of the aforementioned asset to send. e.g. `10_000_000` (1 XLM)
1717
#[arg(long)]
18-
pub amount: i64,
18+
pub amount: builder::Amount,
1919
}
2020

2121
impl From<&Cmd> for xdr::OperationBody {
2222
fn from(cmd: &Cmd) -> Self {
2323
xdr::OperationBody::Payment(xdr::PaymentOp {
2424
destination: cmd.destination.clone(),
2525
asset: cmd.asset.clone().into(),
26-
amount: cmd.amount,
26+
amount: cmd.amount.into(),
2727
})
2828
}
2929
}

cmd/soroban-cli/src/tx/builder.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
pub mod amount;
12
pub mod asset;
23
pub mod transaction;
34

5+
pub use amount::Amount;
46
pub use asset::Asset;
57
pub use transaction::TxExt;
68

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::str::FromStr;
2+
3+
#[derive(Clone, Debug, Copy)]
4+
pub struct Amount(i64);
5+
6+
#[derive(thiserror::Error, Debug)]
7+
pub enum Error {
8+
#[error("cannot start or end with `_`: {0}")]
9+
CannotStartOrEndWithUnderscore(String),
10+
#[error(transparent)]
11+
IntParse(#[from] std::num::ParseIntError),
12+
}
13+
14+
impl FromStr for Amount {
15+
type Err = Error;
16+
17+
fn from_str(value: &str) -> Result<Self, Self::Err> {
18+
if value.starts_with('_') || value.ends_with('_') {
19+
return Err(Error::CannotStartOrEndWithUnderscore(value.to_string()));
20+
}
21+
Ok(Self(value.replace('_', "").parse::<i64>()?))
22+
}
23+
}
24+
25+
impl From<Amount> for i64 {
26+
fn from(builder: Amount) -> Self {
27+
builder.0
28+
}
29+
}
30+
31+
impl From<&Amount> for i64 {
32+
fn from(builder: &Amount) -> Self {
33+
(*builder).into()
34+
}
35+
}

0 commit comments

Comments
 (0)