diff --git a/.github/workflows/bindings-ts.yml b/.github/workflows/bindings-ts.yml new file mode 100644 index 0000000000..62469fd7d5 --- /dev/null +++ b/.github/workflows/bindings-ts.yml @@ -0,0 +1,43 @@ + +name: bindings typescript + +on: + push: + branches: [main, release/**] + pull_request: + +jobs: + test: + name: test generated libraries + runs-on: ubuntu-22.04 + services: + rpc: + image: stellar/quickstart:soroban-dev@sha256:0ad51035cf7caba2fd99c7c1fad0945df6932be7d5c893e1520ccdef7d6a6ffe + ports: + - 8000:8000 + env: + ENABLE_LOGS: true + 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-interval 10s + --health-timeout 5s + --health-retries 50 + steps: + - uses: actions/checkout@v3 + - uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - run: rustup update + - run: cargo build + - run: rustup target add wasm32-unknown-unknown + - run: make build-test-wasms + - run: npm ci && npm run test + working-directory: cmd/crates/soroban-spec-typescript/ts-tests diff --git a/cmd/crates/soroban-spec-typescript/src/project_template/package.json b/cmd/crates/soroban-spec-typescript/src/project_template/package.json index 3c6b89642a..efb4aa5ccd 100644 --- a/cmd/crates/soroban-spec-typescript/src/project_template/package.json +++ b/cmd/crates/soroban-spec-typescript/src/project_template/package.json @@ -15,6 +15,6 @@ }, "typings": "dist/types/index.d.ts", "devDependencies": { - "typescript": "5.1.6" + "typescript": "5.3.3" } } diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh b/cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh index 9a2a83b63b..621be2bc3f 100755 --- a/cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh +++ b/cmd/crates/soroban-spec-typescript/ts-tests/initialize.sh @@ -16,22 +16,28 @@ echo " Passphrase: \"$SOROBAN_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; } echo " Status: $NETWORK_STATUS" +if [[ "$NETWORK_STATUS" != "healthy" ]]; then + echo "Network is not healthy (not running?), exiting" + exit 1 +fi + # Print command before executing, from https://stackoverflow.com/a/23342259/249801 # Discussion: https://github.com/stellar/soroban-tools/pull/1034#pullrequestreview-1690667116 exe() { echo"${@/eval/}" ; "$@" ; } function fund_all() { - exe eval "./soroban config identity fund" - exe eval "./soroban config identity generate alice" - exe eval "./soroban config identity fund alice" - exe eval "./soroban config identity generate bob" - exe eval "./soroban config identity fund bob" + exe eval "./soroban keys generate root" + exe eval "./soroban keys fund root" + exe eval "./soroban keys generate alice" + exe eval "./soroban keys fund alice" + exe eval "./soroban keys generate bob" + exe eval "./soroban keys fund bob" } function upload() { - exe eval "(./soroban contract $1 --wasm $2 --ignore-checks) > $3" + exe eval "(./soroban contract $1 --source root --wasm $2 --ignore-checks) > $3" } function deploy() { - exe eval "(./soroban contract deploy --wasm-hash $(cat $1) --ignore-checks) > $2" + exe eval "(./soroban contract deploy --source root --wasm-hash $(cat $1) --ignore-checks) > $2" } function deploy_all() { upload deploy ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm contract-id-custom-types.txt @@ -42,7 +48,7 @@ function deploy_all() { deploy contract-token-hash.txt contract-id-token-b.txt } function initialize() { - exe eval "./soroban contract invoke --id $(cat $1) -- initialize --admin $(./soroban config identity address) --decimal 0 --name 'Token $2' --symbol '$2'" + exe eval "./soroban contract invoke --source root --id $(cat $1) -- initialize --admin $(./soroban keys address root) --decimal 0 --name 'Token $2' --symbol '$2'" } function initialize_all() { initialize contract-id-token-a.txt A @@ -59,14 +65,13 @@ function bind_all() { } function mint() { - exe eval "./soroban contract invoke --id $(cat $1) -- mint --amount 2000000 --to $(./soroban config identity address $2)" + exe eval "./soroban contract invoke --source root --id $(cat $1) -- mint --amount 2000000 --to $(./soroban keys address $2)" } function mint_all() { mint contract-id-token-a.txt alice mint contract-id-token-b.txt bob } -curl -X POST "http://localhost:8000/soroban/rpc" || { echo "Make sure you're running standalone RPC network on localhost:8000" && exit 1; } fund_all deploy_all initialize_all diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json b/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json index 1ed2de71f0..03c4965187 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json @@ -14,7 +14,7 @@ "dotenv": "^16.3.1", "eslint": "^8.53.0", "stellar-sdk": "11.1.0", - "typescript": "^5.1.6" + "typescript": "^5.3.3" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/package.json b/cmd/crates/soroban-spec-typescript/ts-tests/package.json index 37633c7d49..ee458c703a 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/package.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/package.json @@ -15,7 +15,7 @@ "dotenv": "^16.3.1", "eslint": "^8.53.0", "stellar-sdk": "11.1.0", - "typescript": "^5.1.6" + "typescript": "^5.3.3" }, "ava": { "typescript": {