Skip to content

Commit

Permalink
Merge branch 'devnet' into testdevnet
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahschwartz committed May 15, 2024
2 parents b7ab5e0 + dfa9318 commit 22ecfdb
Show file tree
Hide file tree
Showing 92 changed files with 6,746 additions and 3,242 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/guides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ jobs:
- name: Lint Check
run: markdownlint --config .markdownlint.yaml --ignore-path .markdownlintignore '**/*.mdx'

## QUICKSTART E2E TESTS
quickstart-e2e-tests:
## GUIDES E2E TESTS
guides-e2e-tests:
timeout-minutes: 30
name: Quickstart E2E Tests
name: Guides E2E Tests
runs-on: ubuntu-latest
strategy:
matrix:
# note: must match the names in test.spec.ts
guide:
- "dev quickstart"
- "counter-dapp"
- "intro to sway"
- "intro to predicates"

Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@
[submodule "docs/nightly/fuels-wallet"]
path = docs/nightly/fuels-wallet
url = https://github.com/FuelLabs/fuels-wallet.git
[submodule "docs/sway-libs"]
path = docs/sway-libs
url = https://github.com/FuelLabs/sway-libs.git
[submodule "docs/nightly/sway-libs"]
path = docs/nightly/sway-libs
url = https://github.com/FuelLabs/sway-libs.git
4 changes: 4 additions & 0 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ const includeDirs = [
'docs/guides/docs',
'docs/intro',
'docs/contributing',
'docs/sway-libs/docs/book/src',
// NIGHTLY DOCS
'docs/nightly/sway/docs/book/src',
'docs/nightly/fuels-rs/docs/src',
'docs/nightly/fuels-ts/apps/docs/src',
'docs/nightly/fuel-specs/src',
'docs/nightly/fuel-graphql-docs/docs',
'docs/nightly/fuels-wallet/packages/docs/docs',
'docs/nightly/sway-libs/docs/book/src',
];

const excludeDirs = [
Expand All @@ -82,10 +84,12 @@ const excludeDirs = [
'docs/sway/docs/book/src/SUMMARY.md',
'docs/fuels-rs/docs/src/SUMMARY.md',
'docs/fuel-specs/src/SUMMARY.md',
'docs/sway-libs/docs/book/src/SUMMARY.md',
// NIGHTLY DOCS
'docs/nightly/sway/docs/book/src/SUMMARY.md',
'docs/nightly/fuels-rs/docs/src/SUMMARY.md',
'docs/nightly/fuel-specs/src/SUMMARY.md',
'docs/nightly/sway-libs/docs/book/src/SUMMARY.md',
];

export default makeSource({
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing/versions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ parent:

# Versions

There are three version sets of the docs available in the `docs-hub`: `beta-5`(the default version), `beta-4`, and `nightly`.
There are three version sets of the docs available in the `docs-hub`: `testnet`(the default version), `beta-5`, and `nightly`.

- The default version set is compatible with the `latest` toolchain and testnet.
- The `beta-4` version set is compatible with the `beta-4` toolchain and testnet.
- The `beta-5` version set is compatible with the `beta-5` toolchain and testnet.
- The `nightly` version set reflects the latest releases on GitHub. These versions may not be compatible with each other.

## Updating the Nightly Versions
Expand Down
2 changes: 1 addition & 1 deletion docs/fuel-core
Submodule fuel-core updated 467 files
2 changes: 1 addition & 1 deletion docs/fuel-graphql-docs
88 changes: 88 additions & 0 deletions docs/guides/docs/contract-quickstart/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
title: Contract Quickstart
category: Contract Quickstart
parent:
label: All Guides
link: /guides
---

# Smart Contract Quickstart

Getting started with Fuel as a smart contract developer is as simple as:

1. [Installing](#installation) `fuelup`
2. [Generating a counter contract](#generating-a-counter-contract)
3. [Building and deploying the contract](#building-and-deploying-the-contract)

## Installation

<TextImport
file="../installation/index.mdx"
comment="install_fuelup"
commentType="{/*"
/>

<CodeImport
file="../installation/index.mdx"
comment="install_fuelup_command"
commentType="{/*"
lang="sh"
trim="true"
/>

<TextImport
file="../counter-dapp/building-a-smart-contract.mdx"
comment="install_help"
commentType="{/*"
/>

<TextImport
file="../installation/index.mdx"
comment="install_VSCode_extensions"
commentType="{/*"
/>

## Generating a counter contract

Run the command below to generate a counter contract in Sway:

```sh
forc template --template-name counter counter-contract
```

The contract will be in the `src/main.sw` file.

<TextImport
file="../counter-dapp/building-a-smart-contract.mdx"
comment="forc_new"
commentType="{/*"
/>

## Building and deploying the contract

To build a contract, inside the `counter-contract` folder you can run:

```sh
forc build
```

To deploy the contract to the testnet, you can run:

```sh
forc deploy --node-url https://devnet.fuel.network/v1/graphql
```

<TextImport
file="../counter-dapp/building-a-smart-contract.mdx"
comment="forc_wallet"
commentType="{/*"
/>

## Next Steps

Ready to learn more? Check out the following resources:

- Learn the step-by-step instructions for how to build a full-stack [counter contract dapp](/guides/counter-dapp)
- Build a full-stack marketplace dapp with the [Intro to Sway](/guides/intro-to-sway) guide
- Try building with [Predicates](/guides/intro-to-predicates)
- Read the [Sway docs](/docs/sway)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Building a Frontend
category: Quickstart
category: Counter Dapp
parent:
label: All Guides
link: /guides
Expand All @@ -19,17 +19,9 @@ To build a frontend application for the counter contract, we'll do the following

## Install the Fuel Browser Wallet

> Make sure your browser is using the latest version of chromium.
Our frontend application will allow users to connect with a wallet, so you'll need to have a browser wallet installed.

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
Before going to the next steps, install the Fuel Wallet [here](https://chrome.google.com/webstore/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok).

If you have previously installed the wallet, make sure you have updated to the latest version.
</ConditionalContent>

Once you've setup your wallet, click the "Faucet" button in the wallet to get some testnet tokens.
You can use the [Fuel Wallet](https://chromewebstore.google.com/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok), [Fuelet](https://fuelet.app/), or [Metamask](https://metamask.io/).

## Initialize a React project

Expand Down Expand Up @@ -90,17 +82,12 @@ action={{
}}
/>

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>

```sh
npm install fuels@0.82.0 @fuels/react@0.18.0 @fuels/connectors@0.2.2 @tanstack/react-query@5.28.9
npm install fuels @fuels/react @fuels/connectors @tanstack/react-query
```

</ConditionalContent>

## Generate contract types

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
The `fuels init` command generates a `fuels.config.ts` file that is used by the SDK to generate contract types.
Use the `contracts` flag to define where your contract folder is located, and the `output` flag to define where you want the generated files to be created.

Expand All @@ -115,7 +102,7 @@ action={{
/>

```sh
npx fuels@0.82.0 init --contracts ../counter-contract/ --output ./src/sway-api
npx fuels init --contracts ../counter-contract/ --output ./src/sway-api
```

Now that you have a `fuels.config.ts` file, you can use the `fuels build` command to rebuild your contract and generate types.
Expand All @@ -133,7 +120,7 @@ action={{
/>

```sh
npx fuels@0.82.0 build
npx fuels build
```

A successful process should print and output like the following:
Expand All @@ -145,16 +132,12 @@ Generating types..
🎉 Build completed successfully!
```

> If you're having any issues with this part, try adding `useBuiltinForc: false,` to your `fuels.config.ts` config file to make sure it's using the same version of `forc` as your default toolchain.
Now you should be able to find a new folder `fuel-project/frontend/src/sway-api`.
</ConditionalContent>

## Modify the App

Inside the `frontend/src` folder let's add code that interacts with our contract.

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
Because we'll be using `@fuels/react`, first we need to wrap our app with the `FuelProvider` component.

Add the imports below to the top of your `frontend/src/index.tsx` file and setup a query client:
Expand All @@ -169,10 +152,10 @@ action={{
/>

<CodeImport
file="../../examples/quickstart/frontend/src/index.tsx"
file="../../examples/counter-dapp/frontend/src/index.tsx"
lang="tsx"
lineStart="6"
lineEnd="14"
lineEnd="15"
/>

Next, modify your `frontend/src/index.tsx` file to wrap the `App` component with the `FuelProvider` and `QueryClientProvider` components.
Expand All @@ -182,18 +165,17 @@ id="fuel-wallet-provider"
action={{
name: 'modifyFile',
filepath: 'guides-testing/fuel-project/frontend/src/index.tsx',
atLine: 21,
removeLines: [21],
atLine: 22,
removeLines: [22],
}}
/>

<CodeImport
file="../../examples/quickstart/frontend/src/index.tsx"
file="../../examples/counter-dapp/frontend/src/index.tsx"
lang="tsx"
lineStart="21"
lineEnd="33"
lineStart="22"
lineEnd="35"
/>
</ConditionalContent>

Next, change the file `fuel-project/frontend/src/App.tsx` to:

Expand All @@ -205,12 +187,10 @@ action={{
}}
/>

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
<CodeImport
file="../../examples/quickstart/frontend/src/App.tsx"
file="../../examples/counter-dapp/frontend/src/App.tsx"
lang="tsx"
/>
</ConditionalContent>

Finally, replace the value of the `CONTRACT_ID` variable at the top of your `App.tsx` file with the address of the contract you just deployed.

Expand All @@ -221,7 +201,7 @@ action={{
filepath: 'guides-testing/fuel-project/frontend/src/App.tsx',
atLine: 13,
removeLines: [13],
useSetData: ' "0xf2402a4c375550abc8c781bb59761135f88799dcfa81862f8233dfe234894dfe";'
useSetData: ' "0x92073699bd78dac70756a9e0e8bca1c7121c7adc4b90570800f0916fe4ac33dd";'
}}
/>

Expand Down Expand Up @@ -253,39 +233,33 @@ Note that the development build is not optimized.
To create a production build, use npm run build.
```

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
Click the "Connect" button and select "Fuel Wallet Development" to connect your wallet.
Once connected, you should see the counter value and increment button:
Click the "Connect" button and select the wallet you have installed to connect your wallet.

Once connected, if there are no funds in your wallet, you will see a link to get testnet funds.

If you have testnet ETH on Fuel, you should see the counter value and increment button:

<Box.Centered>
![screenshot of the UI](/images/quickstart-frontend.png)
</Box.Centered>
</ConditionalContent>

## You just built a fullstack dapp on Fuel! ⛽

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
[Here is the repo for this project](https://github.com/FuelLabs/docs-hub/tree/master/docs/guides/examples/quickstart).
</ConditionalContent>
[Here is the repo for this project](https://github.com/FuelLabs/docs-hub/tree/master/docs/guides/examples/counter-dapp).

If you run into any problems, a good first step is to compare your code to this repo and resolve any differences.

Tweet us [@fuel_network](https://twitter.com/fuel_network) letting us know you just built a dapp on Fuel, you might get invited to a private group of builders, be invited to the next Fuel dinner, get alpha on the project, or something 👀.

### Updating The Contract

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>
To develop and test faster, we recommend using the [`fuels dev` command](/docs/fuels-ts/fuels-cli/commands/) to start a local node and automatically redeploy and generate types for your contract on each change.
</ConditionalContent>
To develop and test faster, we recommend using the [`fuels dev` command](/docs/fuels-ts/fuels/commands/) to start a local node and automatically redeploy and generate types for your contract on each change.

Once you're ready to redeploy your contract to the testnet, here are the steps you should take to get your frontend and contract back in sync:

<ConditionalContent versionSet={props.versionSet} showForVersions={['default', 'nightly']}>

- In your frontend directory, re-run this command: `npx [email protected] build`.
- In your contract directory, redeploy the contract by running this command and following the same steps as above to sign the transaction with your wallet: `forc deploy --testnet`.
- In your frontend directory, re-run this command: `npx fuels build`.
- In your contract directory, redeploy the contract.
- In your frontend directory, update the contract ID in your `App.tsx` file.
</ConditionalContent>

## Need Help?

Expand Down
Loading

0 comments on commit 22ecfdb

Please sign in to comment.