GithubHelp home page GithubHelp logo

stellar / soroban-example-dapp Goto Github PK

View Code? Open in Web Editor NEW
970.0 970.0 779.0 1.36 MB

End-to-End Example Soroban Dapp

License: Apache License 2.0

Makefile 1.27% Rust 45.82% Shell 7.38% TypeScript 35.76% JavaScript 0.12% CSS 9.06% Dockerfile 0.60%

soroban-example-dapp's People

Contributors

chadoh avatar dogstarcoin avatar elliotfriend avatar esteblock avatar jacekn avatar julian-dev28 avatar kalepail avatar leighmcculloch avatar lucasmagnus avatar paulbellamy avatar satyamz avatar shaptic avatar sisuresh avatar sreuland avatar stellar-terraform avatar tamirms avatar tomerweller avatar willemneal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soroban-example-dapp's Issues

initialize.sh compiles in /target folder but then is looking in /target-tiny

What did you do?

./initialize.sh sandbox

What did you expect to see?

Contracts deploy sucessfully

What did you see instead?

got the following result:

Deploy the token contract
Build the crowdfund contract
cargo fmt --all
cargo build --target wasm32-unknown-unknown --release

---

Finished release [optimized] target(s) in 34.23s
cd target/wasm32-unknown-unknown/release/ && \
	for i in *.wasm ; do \
		ls -l "$i"; \
	done
-rwxrwxr-x 2 user user 8731 nov 16 hh:hh soroban_crowdfund_contract.wasm
Deploy the crowdfund contract
error: reading file target-tiny/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm: No such file or directory (os error 2)


This is because in initialize.sh line 53 is calling make build and not `make

I think that for example porpose, needs to stay as make build
and hence, change in initialize.sh to look into /targetfolder, and not into /target-tiny folder

Provide initialize.sh option to a remote rpc

What problem does your feature solve?

./initialize.sh futurenet defaults to rpc on localhost url

What would you like to see?

./initialize.sh futurenet <optional_rpc_url>

such as

./initialize.sh futurenet https://rpc-futurenet.stellar.org:443

What alternatives are there?

do the same commands as initialize.sh and save results manually in local .soroban-example-dapp

I found error while running this dapp

What version are you using?

soroban 20.3.4 (f30a47fc58ace4437b0252919420838550481420)
soroban-env 20.3.0 (befdf4b2b6061bd6da20b0f93d539d6ad8d8be22)
soroban-env interface version 85899345920
stellar-xdr 20.1.0 (8b9d623ef40423a8462442b86997155f2c04d3a1)
xdr curr (b96148cd4acc372cc9af17b909ffe4b12c43ecb6)

What did you do?

I followed the instructions as given in readme

What did you expect to see?

I want to see the result and the landing page

What did you see instead?

Error.
image
Please help. I have been facing it till months and unable to solve it

Update example to work with value overhaul

Epic

stellar/stellar-cli#471


What?

TL;DR: Update example to work with the ScVal overhaul.

This involves work across most of the dApp, but each item should be a fairly straightforward adaptation. A lot of the ScVal stuff is abstracted away, so fixing that abstraction is the bulk of the work:

  • Update the underlying js-soroban-client library and use it correctly (related/blocking: stellar/js-soroban-client#60)
  • Update the convert.ts helpers to conform to the new format

example-dapp: Update to support single-asset balances.

Related: stellar/go#4723. This is split off into a separate issue for better tracking.

Things to be done:

  • Investigation:
    • As part of stellar/stellar-cli#325, the token create subcommand is removed.
    • The dApp uses this to create its EXT token in initialize.sh.
    • It also interacts with that token via the approve() and mint() functions.
    • These need to be replaced with the Classic equivalents:
  • Implementation:
    • Replace the token creation with token wrapping.
    • Establish trustlines to the issuer from the wallet.
    • Coalesce all customizable decimal references to be 7 (all Stellar assets use this value).
    • Update the token contract spec WASM file.
    • Update token usage to the latest interface
    • Update crowdfunding contract test to interact with the new token interface. Moved to #81.
    • Replace minting with a payment operation
  • Testing:
    • Ensure everything runs with the new quickstart image, soroban-tools and js-soroban-client releases
    • Ensure the new initialization works
    • Ensure minting works, incl. decimal precision
    • Ensure approvals and deposits work
  • Documentation: Dropped sandbox instructions from the README, since we need classic transactions now (which ledger.json doesn't support).

Run `npm run build` as part of the github actions

What problem does your feature solve?

A bunch of simple bugs had crept into the build, because I don't run it often.

What would you like to see?

Add a github PR workflow, which would run npm run build to check it all compiles as expected.

What alternatives are there?

Make optimized builds optional

We should remove the optimized build steps from this example's main build process, and have it as an added optional thing. We have kept those steps out of our other examples because they're not really required and they add significant friction to a first build experience.

Related discussion

bigNumberToI128 not working for large numbers

What version are you using?

What did you do?

using convert.ts for large numbers

// A ten digital number works
//const b1 = new BigNumber("1234567890");

// A twenty digital number does not work, pos or neg
// FIXME: Not working
const b1 = new BigNumber("12345678901234567890");
console.log("b1", util.inspect(b1, false, 5), b1.toString());
const scv1 = bigNumberToI128(b1);
console.log("scv1", util.inspect(scv1, false, 5), scvalToBigNumber(scv1));
const b2 = scvalToBigNumber(scv1);
console.log("b2", util.inspect(b2, false, 5), b2.toString());

What did you expect to see?

12345678901234567890

What did you see instead?

b2 BigNumber { s: -1, e: 6, c: [ 4223278 ] } -4223278

Unable to complete ./initialize.sh

What version are you using?

Searched package-lock.json for stellar:

    "@stellar/freighter-api": {
      "version": "1.3.1",
...
    "stellar-base": {
      "version": "8.0.1-soroban.3",
...

What did you do?

Ran ./initialize.sh

What did you expect to see?

Successful completeness

What did you see instead?

...
    Finished release [optimized] target(s) in 1m 55s
CARGO_TARGET_DIR=target-tiny cargo +nightly build --target wasm32-unknown-unknown --release \
  -Z build-std=std,panic_abort \
  -Z build-std-features=panic_immediate_abort
error: toolchain 'nightly-x86_64-unknown-linux-gnu' is not installed
make: *** [Makefile:10: build] Error 1

error: jsonrpc error: Networking or low-level protocol error: Invalid Url: Invalid URL: invalid format

What version are you using?

soroban-cli 0.6.0

What did you do?

./quickstart.sh standalone
./initialize.sh standalone

What did you expect to see?

Success

What did you see instead?

Problem is while wrapping the token

Wrap the Stellar asset
error: jsonrpc error: Networking or low-level protocol error: Invalid Url: Invalid URL: invalid format

If I run all this manually:

soroban lab token wrap --network standalone --identity token-admin --asset "EXT:GDT2NORMZF6S2T4PT4OBJJ43OPD3GPRNTJG3WVVFB356TUHWZQMU6C3U

I get the exact error:

error: jsonrpc error: Networking or low-level protocol error: Invalid Url: Invalid URL: invalid format

Publish a docker image when we do a release of this repo

What problem does your feature solve?

Right now, users have to build their own soroban-preview docker image to run stuff locally.

What would you like to see?

We should add a github action which triggers when there is a release, and builds/pushes the docker image to dockerhub.

What alternatives are there?

Spawned from: #94

Quickstart script not working

Several people have reported that the quickstart.sh script in this repo doesn't work for them. But when they use the docker run command we advertise on the quickstart repo it works fine.

The conversation about this was in Discord: https://discord.com/channels/897514728459468821/966788672164855829/1035963928573911202

Given people are having good success with the docker command maybe we should delete quickstart.sh and just suggest using docker directly.

Alternatively maybe the revision needs updating that is hardcoded in the script.

example-dapp: Clean up and extract the JS client

  • separate out js sdk stuff
  • separate out react sdk stuff into... a react sdk repo? Where is this going?
  • clean up api provider thing, and setup process. can simplify a lot for us for now.
  • dropdowns for disconnect / network selection, or remove them from this example.

example-dapp: Clean up scval formatting/parsing code

What problem does your feature solve?

Right now the code for converting between u64s/hypers/BigNumber.js is pretty ad-hoc, and ugly.

What would you like to see?

Clean this up, test it, and standardize it, so it is a better example for other devs to follow.

What alternatives are there?

Fix standalone network deployment

What version are you using?

soroban-cli alias : 0.9.1
soroban-sdk: 0.9.2
docker: 4.20.1
example dapp: main (ab19ca1)

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:

> [email protected] 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

> [email protected] 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

Move useContractValue and useSendTransaction to @soroban-react library

What problem does your feature solve?

Errors while copy pasting code when building a new Dapp for Soroban

What would you like to see?

hooks/useSendTransaction.tsx and hooks/useContractValue.tsx as part of the @soroban-react library.
Will need to change a bit in order to receive the { activeChain, server } from the context (useSorobanReact() from @soroban-react/core

chore: Standardize build process

What problem does your feature solve?

Right now we have both a Makefile (for rust) and a package.json (for JS). The distinction is unclear and means the build is spread across two tools.

What would you like to see?

We should standardize onto JS if possible, as that will be more familiar for the target frontend-dev audience. Maybe gulp (or another tool) could help here? I'm not sure what the latest from the next.js build-pipeline tooling is.

What alternatives are there?

Standardize onto makefiles, but that will not really fit with the next.js approach (and we would still need a package.json).

Update dApp tests to support the single-asset balance model.

After #80, the tests still need to be updated.

Based on Discord threads (1 and 2), we need to manually create a LedgerSnapshot instance containing the xdr::TrustLineEntrys to the token admin for each of the participating accounts.

The following code gets part of the way there, but it relies on importing stellar_xdr as a separate crate, which conflicts with stellar_sdk::xdr, meaning the trustline entries can't actually be added to the entries vector due to differing types:

        // where `fxdr` comes from:
        //
        //    extern crate xdr as full_xdr;
        //    use full_xdr::next as fxdr;

        let token_admin = e.accounts().generate_and_create();

        let snap = e.to_snapshot();
        let entries = &snap.ledger_entries;

        for trustor in &std::vec![recipient, user1, user2] {
            let token_issuer = fxdr::AccountId(
                match TryInto::<xdr::AccountId>::try_into(token_admin).unwrap().0 {
                    xdr::PublicKey::PublicKeyTypeEd25519(pk) => {
                        fxdr::PublicKey::PublicKeyTypeEd25519(fxdr::Uint256(pk.0))
                    }
                },
            );

            let account_id = match TryInto::<xdr::AccountId>::try_into(trustor).unwrap().0 {
                xdr::PublicKey::PublicKeyTypeEd25519(pk) => {
                    fxdr::PublicKey::PublicKeyTypeEd25519(fxdr::Uint256(pk.0))
                }
            };

            let asset = fxdr::TrustLineAsset::CreditAlphanum4(fxdr::AlphaNum4 {
                asset_code: fxdr::AssetCode4([0x41; 4]),
                issuer: token_issuer,
            });

            let trustline = fxdr::LedgerKey::Trustline(fxdr::LedgerKeyTrustLine {
                account_id: fxdr::AccountId(account_id),
                asset,
            });

            let trustline_entry = (Box::new(key), Box::new(trustline));
            entries.push(trustline_entry);
        }

        snap.update_entries(&entries);
        e = soroban_sdk::Env::from_snapshot(snap);

Once stellar_sdk exposes all XDR types (or provides a convenient way to make trustlines), this can be modified to work.

Don't use provideWalletChains anymore

What problem does your feature solve?

Functions and variables defined in wallet/provideWalletChains,tsx are confusing.
At the end it does only add a iconBackground parameter to each chain.

What would you like to see?

We could avoid this either:

  • not using the iconBackground" parameter,
  • setting the iconBackground parameter in the @soroban-react/chains library
  • setting localy the iconBackground parameter in a more elegant way
setIconBacground(chain){
if (chain == chain1) return background1
else if (chain == chain2) return backgorund2
.
.
.

"Connect Wallet" button doesn't work & Contract information does not appear

What version are you using?

node 18.15.0
rustc 1.71.0

Two Freighter setup (same bug in both)
(1) Firefox & Freigher v5.2.3
(2) Brave & Freighter v5.1.2

What did you do?

(1)
In one terminal bash quickstart.sh standalone
In onother terminal

npm run clear
NETWORK=standalone npm run setup
npm run dev

What did you expect to see?

  • When pressing "Connect Wallet" button, Freigher should pop up.
  • After workaround (see down). I should see contract data and Dapp buttons (deposit, etc...)

What did you see instead?

  • When pressing "Connect Wallet", nothing happens.

However I did a workaround. Manually opened Freighter and type Password. Then Dapp showed my address, however, no Dapp information, neither buttons, just an infinite spinning circle:

Screenshot from 2023-07-20 11-30-32

Fails to deploy contract with soroban-client to 0.2.1 and sorban 0.3.2

What version are you using?

So, I was testing the new commit da61364 that uses soroban-sdk 0.3.2

I had different errors with different versions of soroban-cli

With soroban 0.2.1, while running ./initialize, I managed to deploy the contract, but not to initialized it.

Initialize the crowdfund contract
error: parsing contract spec: parsing contract spec

Then, I updated to soroban 0.3.3, and I did not even manged to deploy the contract. Got:

Deploy the token contract
error: transaction submission failed

I was looking at the recent changes, and found that in the Docs it is used

docker run --rm -it \
  --platform linux/amd64 \
  -p 8000:8000 \
  --name stellar \
  stellar/quickstart:soroban-dev@sha256:8046391718f8e58b2b88b9c379abda3587bb874689fa09b2ed4871a764ebda27 \
  --standalone \
  --enable-soroban-rpc

Did the change to ./quickstart.sh and now works.
Will open PR

Run ./initialize.sh inside a Docker container

What problem does your feature solve?

Evey time there is a new releases (let's say soroban CLI), devs need to upgrade their local setup (soroban-cli, sometimes rust, maybe even node version) in order to try this Dapp. This is a problem when devs are working in other projects that are not using the same setup.

What would you like to see?

  • Build a Docker containter with all the dependencies.
  • docker-compose.yml
  • run the initialize.sh inside that docker containter

When wallet authorized & refresh, should connect automatically to wallet

What problem does your feature solve?

1.- I manually connect to wallet
2.- I have to authorize in my wallet
3.- I can see my address
4.- I refresh the page
5.- (PROBLEM) I cannot see my address even if the wallet already authorized this connection
6.- If I click on "Connect", I don't need to authorize again to see my address

What would you like to see?

On step 5 I should see my address, without needing to explicitly press the "Connect Wallet" button again

How we could do it?

Implementing the isAllowed method of Freighter API (https://docs.freighter.app/docs/playground/isallowed/)
on @soroban-react paltalabs/soroban-react#38

Server Error Error: Unsupported address type

What version are you using?

"version": "0.1.0",

What did you do?

I ran npm run dev after I got the backend running locally.

What did you expect to see?

I can spin out the frontend at localhost and see the UI.

What did you see instead?

Screen Shot 2023-05-17 at 6 27 00 PM
Screen Shot 2023-05-17 at 6 27 17 PM

The UI was able to run if I delete this variable SorobanClient.Address.contract(Buffer.from(Constants.CrowdfundId, 'hex')).toScVal()

The issue and error looks like it's coming out from stellar-base/lib/address.js file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.