Skip to content

Commit

Permalink
Merge branch 'main' into remap-test
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Dec 20, 2024
2 parents 832d534 + 2790dc1 commit c57c464
Show file tree
Hide file tree
Showing 40 changed files with 340 additions and 242 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,6 @@ jobs:
repo: context.repo.repo,
release_id: ${{ github.event.release.id }},
name: '${{ env.STELLAR_CLI_INSTALLER }}',
data: fs.readFileSync('Output/stellar-installer.exe'),
data: fs.readFileSync('${{ env.STELLAR_CLI_INSTALLER }}'),
});
2 changes: 1 addition & 1 deletion .github/workflows/bindings-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
NETWORK: local
ENABLE_SOROBAN_RPC: true
options: >-
--health-cmd "curl --no-progress-meter --fail-with-body -X POST \"http://localhost:8000/soroban/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}' && curl --no-progress-meter \"http://localhost:8000/friendbot\" | grep '\"invalid_field\": \"addr\"'"
--health-cmd "curl --no-progress-meter --fail-with-body -X POST \"http://localhost:8000/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}' && curl --no-progress-meter \"http://localhost:8000/friendbot\" | grep '\"invalid_field\": \"addr\"'"
--health-interval 10s
--health-timeout 5s
--health-retries 50
Expand Down
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ exclude = [
]

[workspace.package]
version = "22.0.1"
version = "22.1.0"
rust-version = "1.81.0"

# Dependencies located in this repo:
[workspace.dependencies.soroban-cli]
version = "=22.0.1"
version = "=22.1.0"
path = "cmd/soroban-cli"

[workspace.dependencies.soroban-spec-json]
version = "=22.0.1"
version = "=22.1.0"
path = "./cmd/crates/soroban-spec-json"

[workspace.dependencies.soroban-spec-typescript]
version = "22.0.1"
version = "22.1.0"
path = "./cmd/crates/soroban-spec-typescript"

[workspace.dependencies.soroban-spec-tools]
version = "22.0.1"
version = "22.1.0"
path = "./cmd/crates/soroban-spec-tools"

# Dependencies from the rs-stellar-xdr repo:
Expand Down
51 changes: 28 additions & 23 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Anything after the `--` double dash (the "slop") is parsed as arguments to the c

* `contract` — Tools for smart contract developers
* `events` — Watch the network for contract events
* `env` — Prints the current environment variables or defaults to the stdout, in a format that can be used as .env file. Environment variables have precedency over defaults
* `env` — Prints the environment variables
* `keys` — Create and manage identities including keys and addresses
* `network` — Configure connection to networks
* `container` — Start local networks in containers
Expand Down Expand Up @@ -290,20 +290,21 @@ Generate Rust bindings

Generate a TypeScript / JavaScript package

**Usage:** `stellar contract bindings typescript [OPTIONS] --output-dir <OUTPUT_DIR>`
**Usage:** `stellar contract bindings typescript [OPTIONS] --output-dir <OUTPUT_DIR> <--wasm <WASM>|--wasm-hash <WASM_HASH>|--contract-id <CONTRACT_ID>>`

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

* `--wasm <WASM>` — Path to wasm file on local filesystem. You must either include this OR `--contract-id`
* `--contract-id <CONTRACT_ID>` — A contract ID/address on a network (if no network settings provided, Testnet will be assumed). You must either include this OR `--wasm`
* `--output-dir <OUTPUT_DIR>` — Where to place generated project
* `--overwrite` — Whether to overwrite output directory if it already exists
* `--wasm <WASM>` — Wasm file path on local filesystem. Provide this OR `--wasm-hash` OR `--contract-id`
* `--wasm-hash <WASM_HASH>` — Hash of Wasm blob on a network. Provide this OR `--wasm` OR `--contract-id`
* `--contract-id <CONTRACT_ID>` — Contract ID/alias on a network. Provide this OR `--wasm-hash` OR `--wasm`
* `--rpc-url <RPC_URL>` — RPC server endpoint
* `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
* `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
* `--network <NETWORK>` — Name of network to use from config
* `--global` — Use global config
* `--config-dir <CONFIG_DIR>` — Location of config directory, default is "."
* `--output-dir <OUTPUT_DIR>` — Where to place generated project
* `--overwrite` — Whether to overwrite output directory if it already exists



Expand Down Expand Up @@ -525,13 +526,13 @@ The data outputted by this command is a stream of `SCSpecEntry` XDR values. See

Outputs no data when no data is present in the contract.

**Usage:** `stellar contract info interface [OPTIONS] <--wasm <WASM>|--wasm-hash <WASM_HASH>|--id <CONTRACT_ID>>`
**Usage:** `stellar contract info interface [OPTIONS] <--wasm <WASM>|--wasm-hash <WASM_HASH>|--contract-id <CONTRACT_ID>>`

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

* `--wasm <WASM>` — Wasm file to extract the data from
* `--wasm-hash <WASM_HASH>` — Wasm hash to get the data for
* `--id <CONTRACT_ID>` — Contract id or contract alias to get the data for
* `--wasm <WASM>` — Wasm file path on local filesystem. Provide this OR `--wasm-hash` OR `--contract-id`
* `--wasm-hash <WASM_HASH>`Hash of Wasm blob on a network. Provide this OR `--wasm` OR `--contract-id`
* `--contract-id <CONTRACT_ID>` — Contract ID/alias on a network. Provide this OR `--wasm-hash` OR `--wasm`
* `--rpc-url <RPC_URL>` — RPC server endpoint
* `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
* `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
Expand Down Expand Up @@ -565,13 +566,13 @@ The data outputted by this command is a stream of `SCMetaEntry` XDR values. See

Outputs no data when no data is present in the contract.

**Usage:** `stellar contract info meta [OPTIONS] <--wasm <WASM>|--wasm-hash <WASM_HASH>|--id <CONTRACT_ID>>`
**Usage:** `stellar contract info meta [OPTIONS] <--wasm <WASM>|--wasm-hash <WASM_HASH>|--contract-id <CONTRACT_ID>>`

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

* `--wasm <WASM>` — Wasm file to extract the data from
* `--wasm-hash <WASM_HASH>` — Wasm hash to get the data for
* `--id <CONTRACT_ID>` — Contract id or contract alias to get the data for
* `--wasm <WASM>` — Wasm file path on local filesystem. Provide this OR `--wasm-hash` OR `--contract-id`
* `--wasm-hash <WASM_HASH>`Hash of Wasm blob on a network. Provide this OR `--wasm` OR `--contract-id`
* `--contract-id <CONTRACT_ID>` — Contract ID/alias on a network. Provide this OR `--wasm-hash` OR `--wasm`
* `--rpc-url <RPC_URL>` — RPC server endpoint
* `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
* `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
Expand Down Expand Up @@ -605,13 +606,13 @@ The data outputted by this command is a stream of `SCEnvMetaEntry` XDR values. S

Outputs no data when no data is present in the contract.

**Usage:** `stellar contract info env-meta [OPTIONS] <--wasm <WASM>|--wasm-hash <WASM_HASH>|--id <CONTRACT_ID>>`
**Usage:** `stellar contract info env-meta [OPTIONS] <--wasm <WASM>|--wasm-hash <WASM_HASH>|--contract-id <CONTRACT_ID>>`

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

* `--wasm <WASM>` — Wasm file to extract the data from
* `--wasm-hash <WASM_HASH>` — Wasm hash to get the data for
* `--id <CONTRACT_ID>` — Contract id or contract alias to get the data for
* `--wasm <WASM>` — Wasm file path on local filesystem. Provide this OR `--wasm-hash` OR `--contract-id`
* `--wasm-hash <WASM_HASH>`Hash of Wasm blob on a network. Provide this OR `--wasm` OR `--contract-id`
* `--contract-id <CONTRACT_ID>` — Contract ID/alias on a network. Provide this OR `--wasm-hash` OR `--wasm`
* `--rpc-url <RPC_URL>` — RPC server endpoint
* `--rpc-header <RPC_HEADERS>` — RPC Header(s) to include in requests to the RPC provider
* `--network-passphrase <NETWORK_PASSPHRASE>` — Network passphrase to sign the transaction sent to the rpc server
Expand Down Expand Up @@ -914,7 +915,11 @@ Watch the network for contract events

## `stellar env`

Prints the current environment variables or defaults to the stdout, in a format that can be used as .env file. Environment variables have precedency over defaults
Prints the environment variables

Prints to stdout in a format that can be used as .env file. Environment variables have precedence over defaults.

If there are no environment variables in use, prints the defaults.

**Usage:** `stellar env [OPTIONS]`

Expand All @@ -939,7 +944,7 @@ Create and manage identities including keys and addresses
* `generate` — Generate a new identity with a seed phrase, currently 12 words
* `ls` — List identities
* `rm` — Remove an identity
* `show`Given an identity return its private key
* `secret`Output an identity's secret key
* `use` — Set the default identity that will be used on all commands. This allows you to skip `--source-account` or setting a environment variable, while reusing this value in all commands that require it


Expand Down Expand Up @@ -1064,11 +1069,11 @@ Remove an identity



## `stellar keys show`
## `stellar keys secret`

Given an identity return its private key
Output an identity's secret key

**Usage:** `stellar keys show [OPTIONS] <NAME>`
**Usage:** `stellar keys secret [OPTIONS] <NAME>`

###### **Arguments:**

Expand Down
6 changes: 3 additions & 3 deletions cmd/crates/soroban-spec-typescript/ts-tests/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SOROBAN_NETWORK_PASSPHRASE="Standalone Network ; February 2017"
SOROBAN_RPC_URL="http://localhost:8000/soroban/rpc"
SOROBAN_FRIENDBOT_URL="http://localhost:8000/friendbot"
STELLAR_NETWORK_PASSPHRASE="Standalone Network ; February 2017"
STELLAR_RPC_URL="http://localhost:8000/rpc"
STELLAR_FRIENDBOT_URL="http://localhost:8000/friendbot"
20 changes: 10 additions & 10 deletions cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ done
unset IFS

echo Network
echo " RPC: $SOROBAN_RPC_URL"
echo " Passphrase: \"$SOROBAN_NETWORK_PASSPHRASE\""
echo " RPC: $STELLAR_RPC_URL"
echo " Passphrase: \"$STELLAR_NETWORK_PASSPHRASE\""

NETWORK_STATUS=$(curl -s -X POST "http://localhost:8000/soroban/rpc" -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 8675309, "method": "getHealth" }' | sed 's/.*"status":"\([^"]*\)".*/\1/') || { echo "Make sure you're running local RPC network on localhost:8000" && exit 1; }
NETWORK_STATUS=$(curl -s -X POST "http://localhost:8000/rpc" -H "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "id": 8675309, "method": "getHealth" }' | sed 's/.*"status":"\([^"]*\)".*/\1/') || { echo "Make sure you're running local RPC network on localhost:8000" && exit 1; }
echo " Status: $NETWORK_STATUS"

if [[ "$NETWORK_STATUS" != "healthy" ]]; then
Expand All @@ -22,28 +22,28 @@ if [[ "$NETWORK_STATUS" != "healthy" ]]; then
fi

# Print command before executing, from https://stackoverflow.com/a/23342259/249801
# Discussion: https://github.com/stellar/soroban-tools/pull/1034#pullrequestreview-1690667116
# Discussion: https://github.com/stellar/stellar-tools/pull/1034#pullrequestreview-1690667116
exe() { echo"${@/eval/}" ; "$@" ; }

function fund_all() {
exe eval "./soroban keys generate root"
exe eval "./soroban keys fund root"
exe eval "./stellar keys generate --fund root"
}
function upload() {
exe eval "(./soroban contract $1 --quiet --source root --wasm $2 --ignore-checks) > $3"
exe eval "(./stellar contract $1 --quiet --source root --wasm $2 --ignore-checks) > $3"
}
function deploy_all() {
upload deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm contract-id-custom-types.txt
# TODO: support `--wasm-hash` with `contract bindings`
upload install ../../../../target/wasm32-unknown-unknown/test-wasms/test_constructor.wasm contract-wasm-hash-constructor.txt
exe eval "./stellar contract asset deploy --asset native --source root"
}
function bind() {
exe eval "./soroban contract bindings typescript $1 $2 --output-dir ./node_modules/$3 --overwrite"
exe eval "./stellar contract bindings typescript $1 $2 --output-dir ./node_modules/$3 --overwrite"
exe eval "sh -c \"cd ./node_modules/$3 && npm install && npm run build\""
}
function bind_all() {
bind --contract-id $(cat contract-id-custom-types.txt) test-custom-types
bind --wasm ../../../../target/wasm32-unknown-unknown/test-wasms/test_constructor.wasm test-constructor
bind --wasm-hash $(cat contract-wasm-hash-constructor.txt) test-constructor
bind --contract-id $(./stellar contract id asset --asset native) xlm
}

fund_all
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import test from "ava"
import { rpcUrl, root, signer } from "./util.js"
import { Client, networks } from "xlm"

const contract = new Client({
...networks.standalone,
rpcUrl,
allowHttp: true,
publicKey: root.keypair.publicKey(),
...signer,
})

test("can generate a lib from a Stellar Asset Contract", async (t) => {
t.is((await contract.symbol()).result, "native");
});
Loading

0 comments on commit c57c464

Please sign in to comment.