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: add fuelnaut game #203

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8353003
start adding fuelnaut game
sarahschwartz Mar 15, 2024
3a47288
configurables test
sarahschwartz Mar 15, 2024
7e86e46
fixes
sarahschwartz Mar 15, 2024
5ba7339
fix spelling
sarahschwartz Mar 15, 2024
9c616e6
hide nightly wallet examples
sarahschwartz Mar 16, 2024
c12b036
lint guides
sarahschwartz Mar 16, 2024
14e3961
fix
sarahschwartz Mar 16, 2024
51ac95c
patch fix
sarahschwartz Mar 16, 2024
3831452
bump nightly wallet
sarahschwartz Mar 16, 2024
ef61c36
fix
sarahschwartz Mar 16, 2024
77ca044
progress
sarahschwartz Mar 16, 2024
1f622ef
progress, configurables still broken
sarahschwartz Mar 17, 2024
b8f9669
cleanup
sarahschwartz Mar 18, 2024
e922096
Merge branch 'master' into sarah/fuelnaut
sarahschwartz Mar 18, 2024
3e95fd5
hide vault level
sarahschwartz Mar 18, 2024
4d608fd
Merge branch 'sarah/fuelnaut' of https://github.com/FuelLabs/docs-hub…
sarahschwartz Mar 18, 2024
2bb0758
fix env
sarahschwartz Mar 18, 2024
ac9840c
add vault back for testing
sarahschwartz Mar 20, 2024
aff1f60
Merge branch 'master' into sarah/fuelnaut
sarahschwartz Mar 26, 2024
0a5266d
fix
sarahschwartz Mar 26, 2024
c3593ef
update build version
sarahschwartz Mar 26, 2024
4005f60
fix
sarahschwartz Mar 26, 2024
029052c
cleanup
sarahschwartz Mar 26, 2024
fbc984a
fix lint
sarahschwartz Mar 26, 2024
bd4015d
progress
sarahschwartz Mar 27, 2024
0853c56
add hello world level, add window helpers
sarahschwartz Mar 27, 2024
5b75698
fix
sarahschwartz Mar 27, 2024
78205e2
fix
sarahschwartz Mar 27, 2024
b68e8ad
Merge branch 'master' into sarah/fuelnaut
sarahschwartz Apr 10, 2024
df6d4ab
fixes
sarahschwartz Apr 10, 2024
bff0ddb
try new bytecode input fix
sarahschwartz Apr 10, 2024
7880b05
Merge branch 'master' into sarah/fuelnaut
sarahschwartz Jun 7, 2024
7de0abd
bump contracts and tests
sarahschwartz Jun 7, 2024
f6731bc
fixes
sarahschwartz Jun 7, 2024
e7f4c92
cleanup
sarahschwartz Jun 7, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# misc
.DS_Store
*.pem
.fuels/

# debug
npm-debug.log*
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "explicit"
},
Expand Down
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"dist",
"**/node_modules",
"pnpm-lock.yaml",
"./next.config.js"
"./next.config.js",
"src/fuelnaut-api"
]
}
}
21 changes: 21 additions & 0 deletions docs/guides/docs/fuelnaut/coin-flip.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Coin Flip
category: Fuelnaut
parent:
label: All Guides
link: /guides
---

# Coin Flip

<FuelnautLevel
description="To beat this level, you'll need to guess the coin flip correctly 10 times"
level={props.level}
bytecode={props.bytecode}
abiJSON={props.abiJSON}
/>

<CodeImport
file="../../examples/fuelnaut/coin-flip/src/main.sw"
lang="sway"
/>
31 changes: 31 additions & 0 deletions docs/guides/docs/fuelnaut/hello-world.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Hello World
category: Fuelnaut
parent:
label: All Guides
link: /guides
---

# Hello World

<FuelnautLevel
description="This level will guide you through how to play the Fuelnaut game."
level={props.level}
bytecode={props.bytecode}
abiJSON={props.abiJSON}
>
<List type="ordered" css={{mb: '$4'}}>
<List.Item>Download the [Fuel Wallet](https://chromewebstore.google.com/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok) extension, setup an account, and use the "Faucet" button to get some testnet funds.</List.Item>
<List.Item>Press the "Connect Your Wallet" button below to connect your wallet if you haven't already.</List.Item>
<List.Item>Open up the developer console in your browser window. You can play the game from here! Try typing in `help()` in the console to see a full list of helper variables and functions.</List.Item>
<List.Item>Click the "Deploy New Instance" button to deploy a new instance of the level contract. Note: you will have to approve 2 transactions for this to work!</List.Item>
<List.Item>Take a look at the level contract. To beat a level in the game, you'll need to make sure the `attack_success` function returns `true`. For this level, you'll have to call the `hello_world` function to set the `value` variable in the storage block to `true`.</List.Item>
<List.Item>In the developer console, use the `instance` variable to call the `hello_world` function. (Hint: take a look at the `fuels` TypeScript [docs](/docs/fuels-ts/contracts/)). </List.Item>
<List.Item>Once you think you've beat the level, click the "Check If Completed" button to confirm.</List.Item>
</List>
</FuelnautLevel>

<CodeImport
file="../../examples/fuelnaut/hello-world/src/main.sw"
lang="sway"
/>
15 changes: 15 additions & 0 deletions docs/guides/docs/fuelnaut/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Fuelnaut
category: Fuelnaut
parent:
label: All Guides
link: /guides
---

# The Fuelnaut

The Fuelnaut is security-focused smart contract game inspired by [The Ethernaut](https://ethernaut.openzeppelin.com/).

The game is designed to teach players about potential security vulnerabilities while building in the Sway language.

<FuelnautCards />
21 changes: 21 additions & 0 deletions docs/guides/docs/fuelnaut/payback.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Payback
category: Fuelnaut
parent:
label: All Guides
link: /guides
---

# Payback

<FuelnautLevel
description="To beat this level, you'll need to trick the contract into sending you all its funds."
level={props.level}
bytecode={props.bytecode}
abiJSON={props.abiJSON}
/>

<CodeImport
file="../../examples/fuelnaut/payback/src/main.sw"
lang="sway"
/>
23 changes: 23 additions & 0 deletions docs/guides/docs/fuelnaut/vault.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: Vault
category: Fuelnaut
parent:
label: All Guides
link: /guides
---

# Vault

🚧 Under Construction 🚧

<FuelnautLevel
description="To beat this level, you'll need to correctly guess the vault password."
level={props.level}
bytecode={props.bytecode}
abiJSON={props.abiJSON}
/>

<CodeImport
file="../../examples/fuelnaut/vault/src/main.sw"
lang="sway"
/>
6 changes: 6 additions & 0 deletions docs/guides/docs/guides.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
"featured": false,
"tags": ["fuel-core"]
},
"fuelnaut": {
"title": "Fuelnaut",
"description": "Play The Fuelnaut: a security-focused smart contract game",
"featured": false,
"tags": []
},
"installation": {
"title": "Toolchain Installation",
"description": "Install the Fuel toolchain and binaries.",
Expand Down
3 changes: 2 additions & 1 deletion docs/guides/docs/nav.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"running_a_node": ["Running a Local Node", "Running a Testnet Node"],
"migration_guide": ["Breaking Changes Log"],
"intro_to_sway": ["Introduction to Sway", "Prerequisites", "Imports", "Structs", "ABI", "Storage", "Errors", "Functions", "Checkpoint", "Rust Testing", "Typescript Frontend", "Explore Fuel"],
"intro_to_predicates": ["Introduction to Sway", "Prerequisites", "Predicate Root", "Predicate Limitations", "Imports", "Configurables", "Signature Verification", "Main", "Checkpoint", "Debugging with Scripts", "Logging in Rust tests", "Rust Testing"]
"intro_to_predicates": ["Introduction to Sway", "Prerequisites", "Predicate Root", "Predicate Limitations", "Imports", "Configurables", "Signature Verification", "Main", "Checkpoint", "Debugging with Scripts", "Logging in Rust tests", "Rust Testing"],
"fuelnaut": ["Hello World", "Payback", "Coin Flip", "Vault"]
}
2 changes: 2 additions & 0 deletions docs/guides/examples/fuelnaut/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/out/deployments
target
45 changes: 45 additions & 0 deletions docs/guides/examples/fuelnaut/Forc.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[[package]]
name = "coin-flip"
source = "member"
dependencies = ["std"]

[[package]]
name = "core"
source = "path+from-root-E19CE48B3E858B72"

[[package]]
name = "fuelnaut"
source = "member"
dependencies = [
"standards",
"std",
"sway_libs",
]

[[package]]
name = "payback"
source = "member"
dependencies = ["std"]

[[package]]
name = "standards"
source = "git+https://github.com/FuelLabs/sway-standards?tag=v0.5.0#348f7175df4c012b23c86cdb18aab79025ca1f18"
dependencies = ["std"]

[[package]]
name = "std"
source = "git+https://github.com/fuellabs/sway?tag=v0.60.0#2f0392ee35a1e4dd80bd8034962d5b4083dfb8b6"
dependencies = ["core"]

[[package]]
name = "sway_libs"
source = "git+https://github.com/FuelLabs/sway-libs?tag=v0.22.0#172adbbcc36e561a56c5820209445f86f0856bfc"
dependencies = [
"standards",
"std",
]

[[package]]
name = "vault"
source = "member"
dependencies = ["std"]
2 changes: 2 additions & 0 deletions docs/guides/examples/fuelnaut/Forc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[workspace]
members = ["fuelnaut-contract", "coin-flip", "payback", "vault"]
Loading
Loading