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

chore: Bump intro to predicates for ignition #450

Merged
merged 6 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guides/docs/intro-to-predicates/checkpoint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ forc build
Your predicate root should be exactly:

```sh
0x9cdce04cdb323e5982bbd0c07f667c6ea2b97781a8ce6f3e2d96c0e1b5acde73
0x2d5e1058a695d6fd8bf30dfa1d8e987f99c9c99a6dd614103d2b4b0f11c1eb40
```

That's it! You've created your first **stateless** decentralized application, and we didn't even have to deploy it!
2 changes: 1 addition & 1 deletion docs/guides/docs/intro-to-predicates/predicate-root.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Unlike building a contract, constructing the predicate generates an additional p
Since everyone is starting with the exact same templated code, the predicate root should be exactly this:

```sh
0x1fb163b15211c39bd54e253a99d29130b2d7de06e0eeefdad6fe0dfc355cf5ec
0x68fec7a57e48f4ec6467d7e09c27272bd8ca72b312ea553a470b98731475ccf3
```

Looking at the predicate, you can immediately notice several differences. There is no ABI or implementation, but simply a main function that returns true or false.
Expand Down
28 changes: 28 additions & 0 deletions docs/guides/docs/intro-to-predicates/rust-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ action={{
cargo generate --init fuellabs/sway templates/sway-test-rs --name sway-store
```

{/*markdownlint-disable*/}
3. Update the Cargo.toml file
{/*markdownlint-disable*/}

<TestAction
id="temp-update-cargo-toml-file"
action={{
name: 'writeToFile',
filepath: 'guides-testing/multisig-predicate/predicate/Cargo.toml'
}}
/>

<CodeImport
file="../../examples/intro-to-predicates/multisig-predicate/Cargo.toml"
lang="rust"
/>

## Imports

Delete the templated code and copy the following imports into your harness file. It's important to pay attention to two main imports: `predicates`, for obvious reasons, and the `ScriptTransactionBuilder`, which we'll use to create transactions. These transactions must be signed before being broadcasted to our local network.
Expand Down Expand Up @@ -130,6 +147,17 @@ The three key setup steps include:

Since the predicate address is deterministic, we don't need to copy it as we do with smart contracts, which are deployed with a different address each time. We can leverage SDKs to build the predicate, ensuring we're working with the correct address without error!

{/*markdownlint-disable*/}
4. Gas isn't just used by the script itself; you also pay for the size of the transaction, signature checks, VM initialization, etc. These costs do not count towards the script gas so it might be hidden.
{/*markdownlint-disable*/}

<CodeImport
file="../../examples/intro-to-predicates/multisig-predicate/tests/harness.rs"
comment="get_accumulated_fee"
commentType="//"
lang="rust"
/>

## Test Cases

### Valid 2 of 3 signatures
Expand Down
3 changes: 2 additions & 1 deletion spell-check-custom-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ Metamask
Devnet
devnet
pre
NextJs
NextJs
toml
Loading