stellar / soroban-example-dapp

End-to-End Example Soroban Dapp
Apache License 2.0
1.03k stars 829 forks source link

Fix standalone network deployment #126

Closed Julian-dev28 closed 11 months ago

Julian-dev28 commented 11 months ago

What version are you using?

soroban-cli alias : 0.9.1 soroban-sdk: 0.9.2 docker: 4.20.1 example dapp: main (https://github.com/stellar/soroban-example-dapp/commit/ab19ca1869fb7e600baec8ca6f0f6d2028bf20c7)

What did you do?

Installed soroban alias and added to ./target/bin/ PATH

I followed the steps for standalone deployment as listed here

First, build the image

make build-docker

Then, In one terminal, run the backend docker containers and wait for them to start:

./quickstart.sh standalone

Next, run the initialization script for the standalone network

NETWORK=standalone npm run setup

What did you expect to see?

A series of deployed contract IDs and success messages

What did you see instead?

The following error message:

> soroban-example-dapp@0.1.0 setup
> ./initialize.sh ${NETWORK:-futurenet} && npm install

Using soroban binary from ./target/bin
Using standalone network
  RPC URL: http://localhost:8000
  Friendbot URL: http://localhost:8000/friendbot
Add the standalone network to cli client
Add standalone to .soroban-example-dapp for use with npm scripts
Create the token-admin identity
Fund token-admin account from friendbot
Build contracts
cargo rustc --manifest-path=contracts/abundance/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished release [optimized] target(s) in 0.06s
cargo rustc --manifest-path=contracts/crowdfund/Cargo.toml --crate-type=cdylib --target=wasm32-unknown-unknown --release
    Finished release [optimized] target(s) in 0.08s
Deploy the abundance token contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Contract deployed succesfully with ID: 
Deploy the crowdfund contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Contract deployed succesfully with ID: 
Initialize the abundance token contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Initialize the crowdfund contract
error: jsonrpc error: Networking or low-level protocol error: Server returned an error status code: 405
Done

> soroban-example-dapp@0.1.0 postinstall
> rm -rf ./.soroban/crowdfund-contract && rm -rf ./.soroban/abundance-token && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --output-dir ./.soroban/crowdfund-contract --network $(cat ./.soroban-example-dapp/network) --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --output-dir ./.soroban/abundance-token --network $(cat ./.soroban-example-dapp/network) --contract-name abundance-token

error: a value is required for '--contract-id <CONTRACT_ID>' but none was supplied

For more information, try '--help'.
npm ERR! code 2
npm ERR! path /Users/julianmartinez/Documents/GitHub/soroban-example-dapp
npm ERR! command failed
npm ERR! command sh -c rm -rf ./.soroban/crowdfund-contract && rm -rf ./.soroban/abundance-token && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --output-dir ./.soroban/crowdfund-contract --network $(cat ./.soroban-example-dapp/network) --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --output-dir ./.soroban/abundance-token --network $(cat ./.soroban-example-dapp/network) --contract-name abundance-token

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/julianmartinez/.npm/_logs/2023-07-17T23_30_21_380Z-debug-0.log

PT2: Using zsh

What did you do?

Ran the set up above and then tried to use zsh to for the standalone deployment

zsh ./initialize.sh standalone 

What did you expect to see?

A series of deployed contract IDs and success messages

What did you see instead?

the following message:

Using soroban binary from ./target/bin
Using standalone network
  RPC URL: http://localhost:8000
  Friendbot URL: http://localhost:8000/friendbot
Add the standalone network to cli client
Add standalone to .soroban-example-dapp for use with npm scripts
./initialize.sh:65: parse error near `)'

Reference: https://github.com/stellar/soroban-example-dapp/blob/main/initialize.sh#L60C1-L70C1

PT3: Using Docker

What did you do?

Ran the set up above and then tried to use docker to for the standalone deployment

docker exec soroban-preview ./initialize.sh standalone

What did you expect to see?

A series of deployed contract IDs and success messages

What did you see instead?

the following message:

Using soroban binary from ./target/bin
Using standalone network
  RPC URL: http://stellar:8000
  Friendbot URL: http://stellar:8000/friendbot
Add the standalone network to cli client
./initialize.sh: line 57: ./target/bin/soroban: cannot execute binary file: Exec format error

Reference: https://github.com/stellar/soroban-example-dapp/blob/main/initialize.sh#L56-L59

Julian-dev28 commented 11 months ago

Noting that this issue overlaps with PR #127

sreuland commented 11 months ago

@Julian-dev28 , can you approve https://github.com/stellar/soroban-example-dapp/pull/127, I'll merge and should resolve this issue.

Julian-dev28 commented 11 months ago

@sreuland Absolutely. I'm going to run locally and then I'll approve 👍🏽

Julian-dev28 commented 11 months ago

@sreuland Do you have an idea why this error appears on the frontend?:

 1 of 1 unhandled error

Unhandled Runtime Error
TypeError: Cannot read properties of null (reading 'length')

Call Stack
e.eval
.soroban/abundance-token/node_modules/soroban-client/dist/soroban-client.min.js (2:308484)
l
.soroban/abundance-token/node_modules/soroban-client/dist/soroban-client.min.js (2:300691)
Generator.eval
.soroban/abundance-token/node_modules/soroban-client/dist/soroban-client.min.js (2:302042)
Generator.eval [as next]
.soroban/abundance-token/node_modules/soroban-client/dist/soroban-client.min.js (2:301062)
B
.soroban/abundance-token/node_modules/soroban-client/dist/soroban-client.min.js (2:306691)
a
.soroban/abundance-token/node_modules/soroban-client/dist/soroban-client.min.js (2:306904)
esteblock commented 11 months ago

I am having the same problems

sreuland commented 11 months ago

yes, to confirm seeing the same when running latest from the https://github.com/stellar/soroban-example-dapp/pull/127 for standalone:

# in one terminal
$ quickstart.sh standalone

# in second terminal
$ npm run clean
$ NETWORK=standalone npm run setup
$ npm run dev
sreuland commented 11 months ago

i built with un-minified source, and it looks like getting an error on simulate transaction call to rpc server, there has been a new version of core/rpc for preview 10 as of late today, so, will try those newer versions in the quickstart here and see if changes results

sreuland commented 11 months ago

thanks to @chadoh for help on troubleshooting this issue, identified new version of soroban-client, 0.9.2 helped resolve this issue, have pushed new fix commit onto the pr - https://github.com/stellar/soroban-example-dapp/pull/127

running that for standalone locally:

cargo install_soroban
npm run clean
NETWORK=standalone npm run setup
npm run dev

note, you have to fund your wallet address on friendbot for the target network first.

Julian-dev28 commented 11 months ago

@sreuland its working for me!

Screenshot 2023-07-19 at 3 59 51 PM