Skip to content

Commit

Permalink
Fixes docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrubal committed Jun 18, 2024
1 parent 1b134d4 commit a36179a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/book/src/forc/plugins/forc_client/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Another alternative is the `--target` option, which provides useful aliases to a
forc-deploy --target beta-3
```

Since deploying and running projects on the testnet cost gas, you will need coins to pay for them. You can get some using the [testnet faucet](https://faucet-beta-4.fuel.network/).
Since deploying and running projects on the testnet cost gas, you will need coins to pay for them. You can get some using the [testnet faucet](https://faucet-testnet.fuel.network/).

## Deployment Artifacts

Expand Down
4 changes: 2 additions & 2 deletions docs/reference/src/code/language/annotations/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ fn read() {
#[storage(write)]
// ANCHOR_END: write
fn write() {
storage.var.write(storage::my_storage_namespace.var.read() + 1);
storage::my_storage_namespace.var.write(storage::my_storage_namespace.var.read() + 1);
}

// ANCHOR: read_write
#[storage(read, write)]
// ANCHOR_END: read_write
fn read_write() {
let var = storage::my_storage_namespace.var.read();
storage.var.write(var + 1);
storage::my_storage_namespace.var.write(var + 1);
}

fn example() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ enum Role {
NoAccess: (),
}

// based on sha256("storage.current_owners")
const HASH_KEY: b256 = 0x84f905e3f560d70fbfab9ffcd92198998ce6f936e3d45f8fcb16b00f6a6a8d7e;
const HASH_KEY: b256 = 0x7616e5793ef977b22465f0c843bcad56155c4369245f347bcc8a61edb08b7645;

// ANCHOR_END: data_structures
// ANCHOR: initialization
storage {
// ANCHOR: in_keyword
new_current_owners in HASH_KEY: u64 = 0,
current_owners in HASH_KEY: u64 = 0,
// ANCHOR_END: in_keyword
explicit_declaration: Owner = Owner {
maximum_owners: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ The `in` keyword can be used within a storage variable to override the position

## Example

The `in` keword and position value are used as follows:
The `in` keyword and position value are used as follows:

```sway
{{#include ../../../../code/operations/storage/storage_in_keyword/src/main.sw:in_keyword}}
```

The code above will force the storage of the variable into the position `HASH_KEY` which is set to `0x84f905e3f560d70fbfab9ffcd92198998ce6f936e3d45f8fcb16b00f6a6a8d7e` calculated from `sha256("storage.current_owners")` instead of the position that would be calculated from the variable name `sha256("storage.new_current_owners")` which would be `0x7616e5793ef977b22465f0c843bcad56155c4369245f347bcc8a61edb08b7645`
The code above will force the storage of the variable into the position `HASH_KEY` which is set to `0x7616e5793ef977b22465f0c843bcad56155c4369245f347bcc8a61edb08b7645` instead of the position that would be calculated from the variable name `sha256("storage.current_owners")` which would be `0x84f905e3f560d70fbfab9ffcd92198998ce6f936e3d45f8fcb16b00f6a6a8d7e`
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ The hash calculations determining the position of variables in a block with name
## Example

A namespace can be declared as follows:

```sway
{{#include ../../../../code/language/annotations/src/main.sw:storage_namespace}}
```

A variable inside a namespace can be accessed as follows:

```sway
{{#include ../../../../code/language/annotations/src/main.sw:storage_namespace_access}}
```

0 comments on commit a36179a

Please sign in to comment.