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: use JS SDK's Client for "invoke contract" #1101

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

chadoh
Copy link
Contributor

@chadoh chadoh commented Nov 26, 2024

This page contained a very complicated, old-school example of how to invoke a smart contract. I've updated it with how to use contract.Client.

I made this somewhat more complicated than it needs to be, showing how to also deploy a new contract from an already-uploaded Wasm hash. I wanted to do this for a few reasons:

  • The part where we actually call increment has become so simple that
    the page feels almost unnecessary, if that's all we show. (Although
    maybe that would be good?)
  • The example contract ID is almost certainly invalid. If people want to
    walk through the whole thing, it would be nice to show them how to
    walk through the whole thing.
  • It's actually fairly straightforward! It allows us to show off more of
    Client's features.

That said, I would love to add the ability to deploy directly from a file:

Client.deploy({ wasm: "path/to/some/file.wasm" })

If the JS SDK gains this ability, then we can clean up this example even more, removing the stellar contract install CLI step.

Should we keep the old example?

Maybe it's nice to see a side-by-side of low-level JS SDK logic next to higher-level Client logic? Sort of a "peek under the hood", to show how much Client is doing. This seems most useful to SDK/client authors, since I can't imagine most app developers caring to dive into that logic. Unless they encounter some problem, and need to understand these lower-level details? Not sure if this is the document where we should do that, though. Honestly, it might be fine to refer them to the source code of Client.

@chadoh chadoh force-pushed the feat/js-sdk-invoke branch from 6947bcd to 44d1161 Compare November 26, 2024 15:20
@stellar-jenkins
Copy link

@stellar-jenkins
Copy link

@briwylde08
Copy link
Contributor

@chadoh and @willemneal, howdy! Are we still working on this one? Waiting on anything? Thanks! :)

@chadoh
Copy link
Contributor Author

chadoh commented Dec 17, 2024

It needs review! @Shaptic or @kalepail: do one of y'all have opinions on this?

chadoh added a commit to AhaLabs/js-stellar-sdk that referenced this pull request Dec 17, 2024
@willemneal [pointed out](stellar/stellar-docs#1101 (review))
that it's a bit of a bummer to create accounts with a pure-SDK interface
just to revert to `fetch` and a hard-coded Friendbot URL in order to
fund that account.

This uses `rpc.Server#requestAirdrop` to do the funding.

I find the name of this method a bit unexpected! I wonder if the
language here has evolved since the method was first added.
Copy link
Contributor

@Shaptic Shaptic left a comment

Choose a reason for hiding this comment

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

LGTM! 🤷

chadoh added a commit to AhaLabs/js-stellar-sdk that referenced this pull request Dec 20, 2024
@willemneal [pointed out](stellar/stellar-docs#1101 (review))
that it's a bit of a bummer to create accounts with a pure-SDK interface
just to revert to `fetch` and a hard-coded Friendbot URL in order to
fund that account.

This uses `rpc.Server#requestAirdrop` to do the funding.

I find the name of this method a bit unexpected! I wonder if the
language here has evolved since the method was first added.
chadoh added a commit to AhaLabs/js-stellar-sdk that referenced this pull request Dec 20, 2024
@willemneal [pointed out](stellar/stellar-docs#1101 (review))
that it's a bit of a bummer to create accounts with a pure-SDK interface
just to revert to `fetch` and a hard-coded Friendbot URL in order to
fund that account.

This uses `rpc.Server#requestAirdrop` to do the funding.

I find the name of this method a bit unexpected! I wonder if the
language here has evolved since the method was first added.
@chadoh chadoh force-pushed the feat/js-sdk-invoke branch 2 times, most recently from 28dbcaa to b491346 Compare December 20, 2024 21:09
This page contained a very complicated, old-school example of how to
invoke a smart contract. I've updated it with how to use
`contract.Client`.

I made this somewhat more complicated than it needs to be, showing how
to also deploy a new contract from an already-uploaded Wasm hash. I
wanted to do this for a few reasons:

- The part where we actually call `increment` has become so simple that
  the page feels almost unnecessary, if that's all we show. (Although
  maybe that would be good?)
- The example contract ID is almost certainly invalid. If people want to
  walk through the whole thing, it would be nice to show them how to
  walk through _the whole thing._
- It's actually fairly straightforward! It allows us to show off more of
  Client's features.

That said, I would love to add the ability to deploy directly from a
file:

```ts
Client.deploy({ wasm: "path/to/some/file.wasm" })
```

If the JS SDK gains this ability, then we can clean up this example even
more, removing the `stellar contract install` CLI step.
@chadoh chadoh force-pushed the feat/js-sdk-invoke branch from b491346 to 445c7e9 Compare December 20, 2024 21:11
chadoh added a commit to AhaLabs/js-stellar-sdk that referenced this pull request Dec 20, 2024
@willemneal [pointed out](stellar/stellar-docs#1101 (review))
that it's a bit of a bummer to create accounts with a pure-SDK interface
just to revert to `fetch` and a hard-coded Friendbot URL in order to
fund that account.

This uses `rpc.Server#requestAirdrop` to do the funding.

I find the name of this method a bit unexpected! I wonder if the
language here has evolved since the method was first added.
@stellar-jenkins
Copy link

2 similar comments
@stellar-jenkins
Copy link

@stellar-jenkins
Copy link

janewang pushed a commit to stellar/js-stellar-sdk that referenced this pull request Dec 20, 2024
@willemneal [pointed out](stellar/stellar-docs#1101 (review))
that it's a bit of a bummer to create accounts with a pure-SDK interface
just to revert to `fetch` and a hard-coded Friendbot URL in order to
fund that account.

This uses `rpc.Server#requestAirdrop` to do the funding.

I find the name of this method a bit unexpected! I wonder if the
language here has evolved since the method was first added.
@janewang janewang merged commit b18520c into stellar:main Dec 20, 2024
2 checks passed
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.

6 participants