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

feat: upgrade freighter-api to 1.5.0 & soroban-client to 0.8.1 #708

Merged
merged 3 commits into from
Jun 19, 2023

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Jun 16, 2023

TODO

What

For JS libraries generated with soroban contract bindings typescript:

  • upgrade to freighter-api 1.5.0

  • use the new methods from freighter-api@1.5.0 to avoid popping
    pop-ups over and over every time a view call is invoked

  • if the transaction only needs to be simulated, then the user doesn't
    need to have Freighter connected. This now uses a default/dummy
    account for such calls, but throws an error if the app author tries to
    signAndSend such calls.

  • upgrade soroban-client to 0.8.1, which allows removing the pinned version of stellar-base

Why

This greatly improves the devx & ux of apps that use these generated libraries.

Known limitations

N/A

chadoh added a commit to AhaLabs/soroban-example-dapp that referenced this pull request Jun 16, 2023
Uses the version with updated freighter-api stellar/stellar-cli#708
@chadoh chadoh force-pushed the feat/upgrade-freighter branch from c00eca9 to 9f20723 Compare June 16, 2023 20:32
@chadoh chadoh force-pushed the feat/upgrade-freighter branch from 9f20723 to 9fbf755 Compare June 16, 2023 20:41
chadoh added a commit to AhaLabs/soroban-example-dapp that referenced this pull request Jun 16, 2023
Uses the version with updated freighter-api stellar/stellar-cli#708
- if the transaction only needs to be simulated, then the user doesn't
  need to have Freighter connected. This now uses a default/dummy
  account for such calls, but throws an error if the app author tries to
  `signAndSend` such calls.

- use the new methods from `freighter-api@1.5.0` to avoid popping
  pop-ups over and over every time a view call is invoked
@chadoh chadoh force-pushed the feat/upgrade-freighter branch from 9fbf755 to 5e6315e Compare June 19, 2023 15:02
chadoh added 2 commits June 19, 2023 11:25
this version correctly pins the stellar-base version, so we can remove
that from the explicit list of dependencies
@chadoh chadoh changed the title feat: upgrade freighter-api to 1.5.0 feat: upgrade freighter-api to 1.5.0 & soroban-client to 0.8.1 Jun 19, 2023
@tomerweller tomerweller merged commit 9f045c0 into stellar:main Jun 19, 2023
const freighterAccount = await getAccount()

// use a placeholder account if not yet connected to Freighter so that view calls can still work
const account = freighterAccount ?? new SorobanClient.Account('GBZXP4PWQLOTBL3P6OE6DQ7QXNYDAZMWQG27V7ATM7P3TKSRDLQS4V7Q', '0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non urgent followup: Not a big deal since the seq num is zero this tx will be unusable and I assume no one has the priv key, but to communicate even clearer that this account is meaningless I'd replace it with the zero account.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just meant for simulation only calls. Does the sequence number matter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'd love to replace it with the zero account. I haven't seen that around yet and don't see it documented at soroban.stellar.org/docs. Is this correct?

G0000000000000000000000000000000000000000000000000000000

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use stellar_strkey::ed25519::PublicKey;
fn main() {
    let zero = PublicKey([0; 32]);
    println!("{zero}");
}
GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF

Copy link
Member

@leighmcculloch leighmcculloch Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strkeys are base32 encoded. Lots of zeros encode into AAAAAAAAAA...

The WHF at the end is because strkeys end with a CRC16. Helps to catch typos.

The G prefix indicates it's a public key.

The first character after the G will be affected by the type of public key. We only support ed25519 right now, but there's room for us to support a few different keys if needed.

SEP-23 is the spec.

@chadoh chadoh deleted the feat/upgrade-freighter branch June 19, 2023 18:51
chadoh added a commit to AhaLabs/soroban-example-dapp that referenced this pull request Jul 5, 2023
Uses the version with updated freighter-api stellar/stellar-cli#708
paulbellamy pushed a commit to stellar/soroban-example-dapp that referenced this pull request Jul 6, 2023
* feat: switch from soroban-react to generated libs

* feat: add ft-contract source; rm `../examples`

- don't use `soroban lab token` to generate/deploy token
- instead, copy example token from examples repo
- remove `../examples` reference in `generate` script
- add `target/bin/soroban` with pinned version of `soroban` to be used
  throughout initialize.sh

* fix: use workspace dependency versions; update sdk

* feat: no more embedding secret keys

This copies ideas from the contract in
https://github.com/AhaLabs/soroban-abundance-token, allowing anyone to
mint themselves tokens. Now this can be used from the frontend directly,
so we no longer need to embed the admin's secret key in the JS. Hooray!

Upon closer inspection, we didn't need any of those constants anymore,
since the contract IDs are embedded in the token libraries.

* fix: add mint_100 and comment out events

* fix: start tryna fix event subscriptions

* fix: update UI after minting 100 ABND

* fix: signAndSend `deposit`; fix modal; update form

The whole page no longer reloads after a pledge. Instead, FormPledge now
takes an `onPledge` param, which it calls after the pledge succeeds.

The now-somewhat-awkward `resultSubmit` has also been filled back out to
match what the modal expects, so the modal looks correct.

* docs: update AlmostUnnecessaryProvider comment

* build: allow newer node versions; improve package name

* build: generate contract clients

* build: fill in .soroban-example-dapp/* first

The CI script needs the values there before it can generate the
libraries, of course.

And the `token_admin*` stuff isn't needed anymore.

* build: install locked CLI version with alias

* build: build contracts before generating clients

* build: s/run-script/run/

Replace `run-script` with the much more common alias `run` to match the
rest of the workflow file

* build: make convert.ts pass strict; exclude target/ from type checking

* build: use node 18 in CI

* build: update lockfile; cat lockfiles during build

* build: switch to yarn; will it work better?

* build: omg yarn works with relative paths but not file:

* build: rm busted debug steps; update docs for yarn

* build: s/yarn ci/yarn install --frozen-lockfile

* build: back to npm we go

* build: switch to postinstall script

* build: rm outdated build step

* build: warn, don't deny, on clippy complaints

and add .cargo/config.toml to match CI settings

* feat: use freighter-api@1.5

* feat: straightforward copy/paste of subscribe logic

This gets the subscriptions working, and finally breaks all dependence
on the @soroban-react packages. The logic is a little confusing, but it
works!

* feat: move subscribe logic to useSubscription hook

This is a hook that can be copy/pasted into other React projects that
need such functionality, to work alongside their generated libraries
until these generated libraries expose subscription logic natively.

* fix: update all relevant UI after pledging

* fix: avoid Freighter error if not yet connected

* fix: can't default build to wasm because tests

* build: use latest soroban-cli

Uses the version with updated freighter-api stellar/stellar-cli#708

* build: use latest cli/soroban-client; rm stellar-base pin

* build: use latest CLI rev from stellar repo

* fix: deal with undefined case

* build: rm RUSTFLAGS from Makefile

Since d771b3f, the default settings are
now set in `.cargo/config.toml`

* fix: allow using standalone

Everything looks correct, but when running the app it fails with:

    Error: Cannot connect to insecure soroban-rpc server

* build: update freighter-api

* build: update pinned soroban-cli version

* build(ci): stub .soroban-example-dapp/network

* fix: add 'await'

---------

Co-authored-by: Willem Wyndham <willem@ahalabs.dev>
maxymkotko added a commit to maxymkotko/Soroban-dApp that referenced this pull request Dec 13, 2023
* feat: switch from soroban-react to generated libs

* feat: add ft-contract source; rm `../examples`

- don't use `soroban lab token` to generate/deploy token
- instead, copy example token from examples repo
- remove `../examples` reference in `generate` script
- add `target/bin/soroban` with pinned version of `soroban` to be used
  throughout initialize.sh

* fix: use workspace dependency versions; update sdk

* feat: no more embedding secret keys

This copies ideas from the contract in
https://github.com/AhaLabs/soroban-abundance-token, allowing anyone to
mint themselves tokens. Now this can be used from the frontend directly,
so we no longer need to embed the admin's secret key in the JS. Hooray!

Upon closer inspection, we didn't need any of those constants anymore,
since the contract IDs are embedded in the token libraries.

* fix: add mint_100 and comment out events

* fix: start tryna fix event subscriptions

* fix: update UI after minting 100 ABND

* fix: signAndSend `deposit`; fix modal; update form

The whole page no longer reloads after a pledge. Instead, FormPledge now
takes an `onPledge` param, which it calls after the pledge succeeds.

The now-somewhat-awkward `resultSubmit` has also been filled back out to
match what the modal expects, so the modal looks correct.

* docs: update AlmostUnnecessaryProvider comment

* build: allow newer node versions; improve package name

* build: generate contract clients

* build: fill in .soroban-example-dapp/* first

The CI script needs the values there before it can generate the
libraries, of course.

And the `token_admin*` stuff isn't needed anymore.

* build: install locked CLI version with alias

* build: build contracts before generating clients

* build: s/run-script/run/

Replace `run-script` with the much more common alias `run` to match the
rest of the workflow file

* build: make convert.ts pass strict; exclude target/ from type checking

* build: use node 18 in CI

* build: update lockfile; cat lockfiles during build

* build: switch to yarn; will it work better?

* build: omg yarn works with relative paths but not file:

* build: rm busted debug steps; update docs for yarn

* build: s/yarn ci/yarn install --frozen-lockfile

* build: back to npm we go

* build: switch to postinstall script

* build: rm outdated build step

* build: warn, don't deny, on clippy complaints

and add .cargo/config.toml to match CI settings

* feat: use freighter-api@1.5

* feat: straightforward copy/paste of subscribe logic

This gets the subscriptions working, and finally breaks all dependence
on the @soroban-react packages. The logic is a little confusing, but it
works!

* feat: move subscribe logic to useSubscription hook

This is a hook that can be copy/pasted into other React projects that
need such functionality, to work alongside their generated libraries
until these generated libraries expose subscription logic natively.

* fix: update all relevant UI after pledging

* fix: avoid Freighter error if not yet connected

* fix: can't default build to wasm because tests

* build: use latest soroban-cli

Uses the version with updated freighter-api stellar/stellar-cli#708

* build: use latest cli/soroban-client; rm stellar-base pin

* build: use latest CLI rev from stellar repo

* fix: deal with undefined case

* build: rm RUSTFLAGS from Makefile

Since d771b3f28599664d3e96c313397bb6aad3b71d38, the default settings are
now set in `.cargo/config.toml`

* fix: allow using standalone

Everything looks correct, but when running the app it fails with:

    Error: Cannot connect to insecure soroban-rpc server

* build: update freighter-api

* build: update pinned soroban-cli version

* build(ci): stub .soroban-example-dapp/network

* fix: add 'await'

---------

Co-authored-by: Willem Wyndham <willem@ahalabs.dev>
spotlight301 pushed a commit to spotlight301/Dapp-Soro that referenced this pull request Sep 30, 2024
* feat: switch from soroban-react to generated libs

* feat: add ft-contract source; rm `../examples`

- don't use `soroban lab token` to generate/deploy token
- instead, copy example token from examples repo
- remove `../examples` reference in `generate` script
- add `target/bin/soroban` with pinned version of `soroban` to be used
  throughout initialize.sh

* fix: use workspace dependency versions; update sdk

* feat: no more embedding secret keys

This copies ideas from the contract in
https://github.com/AhaLabs/soroban-abundance-token, allowing anyone to
mint themselves tokens. Now this can be used from the frontend directly,
so we no longer need to embed the admin's secret key in the JS. Hooray!

Upon closer inspection, we didn't need any of those constants anymore,
since the contract IDs are embedded in the token libraries.

* fix: add mint_100 and comment out events

* fix: start tryna fix event subscriptions

* fix: update UI after minting 100 ABND

* fix: signAndSend `deposit`; fix modal; update form

The whole page no longer reloads after a pledge. Instead, FormPledge now
takes an `onPledge` param, which it calls after the pledge succeeds.

The now-somewhat-awkward `resultSubmit` has also been filled back out to
match what the modal expects, so the modal looks correct.

* docs: update AlmostUnnecessaryProvider comment

* build: allow newer node versions; improve package name

* build: generate contract clients

* build: fill in .soroban-example-dapp/* first

The CI script needs the values there before it can generate the
libraries, of course.

And the `token_admin*` stuff isn't needed anymore.

* build: install locked CLI version with alias

* build: build contracts before generating clients

* build: s/run-script/run/

Replace `run-script` with the much more common alias `run` to match the
rest of the workflow file

* build: make convert.ts pass strict; exclude target/ from type checking

* build: use node 18 in CI

* build: update lockfile; cat lockfiles during build

* build: switch to yarn; will it work better?

* build: omg yarn works with relative paths but not file:

* build: rm busted debug steps; update docs for yarn

* build: s/yarn ci/yarn install --frozen-lockfile

* build: back to npm we go

* build: switch to postinstall script

* build: rm outdated build step

* build: warn, don't deny, on clippy complaints

and add .cargo/config.toml to match CI settings

* feat: use freighter-api@1.5

* feat: straightforward copy/paste of subscribe logic

This gets the subscriptions working, and finally breaks all dependence
on the @soroban-react packages. The logic is a little confusing, but it
works!

* feat: move subscribe logic to useSubscription hook

This is a hook that can be copy/pasted into other React projects that
need such functionality, to work alongside their generated libraries
until these generated libraries expose subscription logic natively.

* fix: update all relevant UI after pledging

* fix: avoid Freighter error if not yet connected

* fix: can't default build to wasm because tests

* build: use latest soroban-cli

Uses the version with updated freighter-api stellar/stellar-cli#708

* build: use latest cli/soroban-client; rm stellar-base pin

* build: use latest CLI rev from stellar repo

* fix: deal with undefined case

* build: rm RUSTFLAGS from Makefile

Since d771b3f28599664d3e96c313397bb6aad3b71d38, the default settings are
now set in `.cargo/config.toml`

* fix: allow using standalone

Everything looks correct, but when running the app it fails with:

    Error: Cannot connect to insecure soroban-rpc server

* build: update freighter-api

* build: update pinned soroban-cli version

* build(ci): stub .soroban-example-dapp/network

* fix: add 'await'

---------

Co-authored-by: Willem Wyndham <willem@ahalabs.dev>
joaovmp pushed a commit to joaovmp/Soroban_dapp that referenced this pull request Oct 23, 2024
* feat: switch from soroban-react to generated libs

* feat: add ft-contract source; rm `../examples`

- don't use `soroban lab token` to generate/deploy token
- instead, copy example token from examples repo
- remove `../examples` reference in `generate` script
- add `target/bin/soroban` with pinned version of `soroban` to be used
  throughout initialize.sh

* fix: use workspace dependency versions; update sdk

* feat: no more embedding secret keys

This copies ideas from the contract in
https://github.com/AhaLabs/soroban-abundance-token, allowing anyone to
mint themselves tokens. Now this can be used from the frontend directly,
so we no longer need to embed the admin's secret key in the JS. Hooray!

Upon closer inspection, we didn't need any of those constants anymore,
since the contract IDs are embedded in the token libraries.

* fix: add mint_100 and comment out events

* fix: start tryna fix event subscriptions

* fix: update UI after minting 100 ABND

* fix: signAndSend `deposit`; fix modal; update form

The whole page no longer reloads after a pledge. Instead, FormPledge now
takes an `onPledge` param, which it calls after the pledge succeeds.

The now-somewhat-awkward `resultSubmit` has also been filled back out to
match what the modal expects, so the modal looks correct.

* docs: update AlmostUnnecessaryProvider comment

* build: allow newer node versions; improve package name

* build: generate contract clients

* build: fill in .soroban-example-dapp/* first

The CI script needs the values there before it can generate the
libraries, of course.

And the `token_admin*` stuff isn't needed anymore.

* build: install locked CLI version with alias

* build: build contracts before generating clients

* build: s/run-script/run/

Replace `run-script` with the much more common alias `run` to match the
rest of the workflow file

* build: make convert.ts pass strict; exclude target/ from type checking

* build: use node 18 in CI

* build: update lockfile; cat lockfiles during build

* build: switch to yarn; will it work better?

* build: omg yarn works with relative paths but not file:

* build: rm busted debug steps; update docs for yarn

* build: s/yarn ci/yarn install --frozen-lockfile

* build: back to npm we go

* build: switch to postinstall script

* build: rm outdated build step

* build: warn, don't deny, on clippy complaints

and add .cargo/config.toml to match CI settings

* feat: use freighter-api@1.5

* feat: straightforward copy/paste of subscribe logic

This gets the subscriptions working, and finally breaks all dependence
on the @soroban-react packages. The logic is a little confusing, but it
works!

* feat: move subscribe logic to useSubscription hook

This is a hook that can be copy/pasted into other React projects that
need such functionality, to work alongside their generated libraries
until these generated libraries expose subscription logic natively.

* fix: update all relevant UI after pledging

* fix: avoid Freighter error if not yet connected

* fix: can't default build to wasm because tests

* build: use latest soroban-cli

Uses the version with updated freighter-api stellar/stellar-cli#708

* build: use latest cli/soroban-client; rm stellar-base pin

* build: use latest CLI rev from stellar repo

* fix: deal with undefined case

* build: rm RUSTFLAGS from Makefile

Since d771b3f28599664d3e96c313397bb6aad3b71d38, the default settings are
now set in `.cargo/config.toml`

* fix: allow using standalone

Everything looks correct, but when running the app it fails with:

    Error: Cannot connect to insecure soroban-rpc server

* build: update freighter-api

* build: update pinned soroban-cli version

* build(ci): stub .soroban-example-dapp/network

* fix: add 'await'

---------

Co-authored-by: Willem Wyndham <willem@ahalabs.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants