Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Elliot Voris <[email protected]>
  • Loading branch information
elizabethengelman and ElliotFriend authored Mar 4, 2024
1 parent 47ca56a commit 3b95639
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/getting-started/create-an-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Though we can run `soroban contract bindings typescript` for each of our contrac

In addition to generating the NPM packages, `initialize.js` will also:

- Generate and fund our soroban account
- Generate and fund our Stellar account
- Build all of the contracts in the `contracts` dir
- Deploy our contracts
- Create handy contract clients for each contract
Expand Down Expand Up @@ -310,7 +310,7 @@ Now you're ready to sign the call to `increment`!

### Call `increment`

Now we can import the increment contract client from `soroban_increment_contract` and start using it. We'll again create a new Astro component. Create a new file at `src/components/Counter.astro` with the following contents:
Now we can import the `increment` contract client from `soroban_increment_contract` and start using it. We'll again create a new Astro component. Create a new file at `src/components/Counter.astro` with the following contents:

```html title="src/components/Counter.astro"
<strong>Incrementor</strong><br />
Expand Down Expand Up @@ -350,7 +350,7 @@ The biggest difference from the call to `greeter.hello` is that this transaction

:::info

Destructuring `{ result }` If you're new to JavaScript, you may not know what's happening with those `const { result }` lines. This is using JavaScript's _destructuring_ feature. If the thing on the right of the equals sign is an object, then you can use this pattern to quickly grab specific keys from that object and assign them to variables. You can also name the variable something else, if you like. For example, try changing the code above to:
Destructuring `{ result }`: If you're new to JavaScript, you may not know what's happening with those `const { result }` lines. This is using JavaScript's _destructuring_ feature. If the thing on the right of the equals sign is an object, then you can use this pattern to quickly grab specific keys from that object and assign them to variables. You can also name the variable something else, if you like. For example, try changing the code above to:

```ts
const { result: newValue } = ...
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/hello-world.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ Building optimized contracts is only necessary when deploying to a network with

In this section, we wrote a simple contract that can be deployed to a Soroban network.

Next we'll learn to deploy the HelloWorld contract to Soroban's Testnet network and interact with it over RPC using the CLI.
Next we'll learn to deploy the HelloWorld contract to Stellar's Testnet network and interact with it over RPC using the CLI.

[Rust unit tests]: https://doc.rust-lang.org/rust-by-example/testing/unit_testing.html
[`soroban-cli`]: setup.mdx#install-the-soroban-cli
10 changes: 6 additions & 4 deletions docs/getting-started/storing-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import TabItem from "@theme/TabItem";

Now that we've built a basic Hello World example contract, we'll write a simple contract that stores and retrieves data. This will help you see the basics of Soroban's storage system.

This is going to follow along with the [increment example](https://github.com/stellar/soroban-examples/tree/v20.0.0/increment), which has a single function that increments an internal counter and returns the value. If you want to see a working example, [try it in GitPod](https://gitpod.io/#https://github.com/stellar/soroban-examples/tree/v20.0.0).
This is going to follow along with the [increment example](https://github.com/stellar/soroban-examples/tree/v20.2.0/increment), which has a single function that increments an internal counter and returns the value. If you want to see a working example, [try it in GitPod](https://gitpod.io/#https://github.com/stellar/soroban-examples/tree/v20.2.0).

This tutorial assumes that you've already completed the previous steps in Getting Started: [Setup](./setup.mdx), [Hello World](./hello-world.mdx), and [Deploy to Testnet](./deploy-to-testnet.mdx).

## Adding the increment contract

The `soroban contract init` command allows us to initialize a new project with any of the example contracts from the [soroban-examples](https://github.com/stellar/soroban-examples) repo, using the `--with-example` (or `-w`) flag.

It will not overwrite existing files, so we can also use this command to add a new contract to an existing project. Run the command again with a `--with-example` flag to add an `increment` contract to our project. From the our `getting-started-tutorial` directory, run:
It will not overwrite existing files, so we can also use this command to add a new contract to an existing project. Run the command again with a `--with-example` flag to add an `increment` contract to our project. From inside our `getting-started-tutorial` directory, run:

```sh
soroban contract init ./ --with-example increment
Expand Down Expand Up @@ -136,7 +136,7 @@ The `set()` function stores the new count value against the key, replacing the e
env.storage().instance().extend_ttl(100, 100);
```

All contract data has a Time To Live (TTL), measured in ledgers, that must be periodically extended. If an entry's TTL is not periodically extended, the entry will eventually become "archived". You can learn more about this in the [State Archival](../soroban-internals/state-archival.mdx) document.
All contract data has a Time To Live (TTL), measured in ledgers, that must be periodically extended. If an entry's TTL is not periodically extended, the entry will eventually become "archived." You can learn more about this in the [State Archival](../soroban-internals/state-archival.mdx) document.

For now, it's worth knowing that there are three kinds of storage: `Persistent`, `Temporary`, and `Instance`. This contract only uses `Instance` storage: `env.storage().instance()`. Every time the counter is incremented, this storage's TTL gets extended by 100 [ledgers](https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/ledgers), or about 500 seconds.

Expand All @@ -148,7 +148,9 @@ soroban contract build

Check that it built:

ls target/wasm32-unknown-unknown/release/*.wasm
```bash
ls target/wasm32-unknown-unknown/release/*.wasm
```

You should see both `soroban_hello_world_contract.wasm` and `soroban_increment_contract.wasm`.

Expand Down

0 comments on commit 3b95639

Please sign in to comment.