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

sync with main #744

Merged
merged 9 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 162 additions & 204 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 2 additions & 15 deletions cmd/crates/soroban-spec-typescript/fixtures/ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ export async function void( {signAndSend, fee}: {signAndSend?: boolean, fee?: nu
return ;
}

export async function raw_val( {signAndSend, fee}: {signAndSend?: boolean, fee?: number} = {signAndSend: false, fee: 100}): Promise<any> {
export async function val( {signAndSend, fee}: {signAndSend?: boolean, fee?: number} = {signAndSend: false, fee: 100}): Promise<any> {
let invokeArgs: InvokeArgs = {
signAndSend,
fee,
method: 'raw_val',
method: 'val',

};

Expand Down Expand Up @@ -517,19 +517,6 @@ export async function map({map}: {map: Map<u32, boolean>}, {signAndSend, fee}: {
return scValStrToJs(response.xdr) as Map<u32, boolean>;
}

export async function set({set}: {set: Set<u32>}, {signAndSend, fee}: {signAndSend?: boolean, fee?: number} = {signAndSend: false, fee: 100}): Promise<Set<u32>> {
let invokeArgs: InvokeArgs = {
signAndSend,
fee,
method: 'set',
args: [((i) => i)(set)],
};

// @ts-ignore Type does exist
const response = await invoke(invokeArgs);
return scValStrToJs(response.xdr) as Set<u32>;
}

export async function vec({vec}: {vec: Array<u32>}, {signAndSend, fee}: {signAndSend?: boolean, fee?: number} = {signAndSend: false, fee: 100}): Promise<Array<u32>> {
let invokeArgs: InvokeArgs = {
signAndSend,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Contract {
#[cfg(test)]
mod test {

use soroban_sdk::{vec, Env, Symbol};
use soroban_sdk::{symbol_short, vec, Env};

use crate::{Contract, ContractClient};

Expand Down
4 changes: 2 additions & 2 deletions cmd/crates/soroban-test/tests/it/custom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ fn void() {
}

#[test]
fn raw_val() {
invoke(&TestEnv::default(), "raw_val")
fn val() {
invoke(&TestEnv::default(), "val")
.assert()
.success()
.stdout("null\n")
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jsonrpsee-http-client = "0.18.1"
jsonrpsee-core = "0.18.1"
http = "0.2.9"
regex = "1.6.0"
wasm-opt = { version = "0.112.0", optional = true }
wasm-opt = { version = "0.113.0", optional = true }
chrono = "0.4.23"
rpassword = "7.2.0"
dirs = "4.0.0"
Expand Down
22 changes: 12 additions & 10 deletions cmd/soroban-cli/src/commands/contract/bindings/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Cmd {

/// where to place generated project
#[arg(long)]
root_dir: PathBuf,
output_dir: PathBuf,

#[arg(long)]
contract_name: String,
Expand Down Expand Up @@ -52,14 +52,16 @@ pub enum Error {
impl Cmd {
pub fn run(&self) -> Result<(), Error> {
let spec = self.wasm.parse().unwrap().spec;
if self.root_dir.is_file() {
return Err(Error::IsFile(self.root_dir.clone()));
if self.output_dir.is_file() {
return Err(Error::IsFile(self.output_dir.clone()));
}
if self.root_dir.exists() {
std::fs::remove_dir_all(&self.root_dir)?;
}
std::fs::create_dir_all(&self.root_dir)?;
let p: Project = self.root_dir.clone().try_into()?;
let output_dir = if self.output_dir.exists() {
self.output_dir.join(&self.contract_name)
} else {
self.output_dir.clone()
};
std::fs::create_dir_all(&output_dir)?;
let p: Project = output_dir.clone().try_into()?;
let Network {
rpc_url,
network_passphrase,
Expand All @@ -76,13 +78,13 @@ impl Cmd {
)?;
std::process::Command::new("npm")
.arg("install")
.current_dir(&self.root_dir)
.current_dir(&output_dir)
.spawn()?
.wait()?;
std::process::Command::new("npm")
.arg("run")
.arg("build")
.current_dir(&self.root_dir)
.current_dir(&output_dir)
.spawn()?
.wait()?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ impl Cmd {
.iter()
.map(|i| {
let name = i.name.to_string().unwrap();
if let Some(mut raw_val) = matches_.get_raw(&name) {
let mut s = raw_val.next().unwrap().to_string_lossy().to_string();
if let Some(mut val) = matches_.get_raw(&name) {
let mut s = val.next().unwrap().to_string_lossy().to_string();
if matches!(i.type_, ScSpecTypeDef::Address) {
let cmd = crate::commands::config::identity::address::Cmd {
name: Some(s.clone()),
Expand Down
4 changes: 2 additions & 2 deletions docs/soroban-cli-full-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ Generate Rust bindings

Generate a TypeScript / JavaScript package

**Usage:** `soroban contract bindings typescript [OPTIONS] --wasm <WASM> --root-dir <ROOT_DIR> --contract-name <CONTRACT_NAME> --contract-id <CONTRACT_ID>`
**Usage:** `soroban contract bindings typescript [OPTIONS] --wasm <WASM> --output-dir <OUTPUT_DIR> --contract-name <CONTRACT_NAME> --contract-id <CONTRACT_ID>`

###### **Options:**

* `--wasm <WASM>` — Path to wasm binary
* `--root-dir <ROOT_DIR>` — where to place generated project
* `--output-dir <OUTPUT_DIR>` — where to place generated project
* `--contract-name <CONTRACT_NAME>`
* `--contract-id <CONTRACT_ID>`
* `--global` — Use global config
Expand Down