Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Rumeyst authored Jun 9, 2024
2 parents 6453274 + 8d0a439 commit df0bf5b
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 45 deletions.
1 change: 1 addition & 0 deletions .github/workflows/guides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- "counter-dapp"
- "intro to sway"
- "intro to predicates"
- "quickstart"

steps:
# SETUP
Expand Down
49 changes: 49 additions & 0 deletions docs/guides/docs/contract-quickstart/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,32 @@ Getting started with Fuel as a smart contract developer is as simple as:

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

{/* TODO: Replace when forc template command is stable
```sh
forc template --template-name counter counter-contract
```
*/}

{/*TODO: Remove when forc template command is stable*/}

<TestAction
id="create-contract-project"
action={{
name: 'runCommand',
commandFolder: 'guides-testing/'
}}
/>

<CodeImport
file="../counter-dapp/building-a-smart-contract.mdx"
comment="new_forc_contract"
commentType="{/*"
lang="sh"
trim="true"
/>

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

<TextImport
Expand All @@ -76,8 +98,35 @@ To build a contract, move inside the `counter-contract` folder:
cd counter-contract
```

{/*TODO: Remove when forc template command is stable*/}

Copy and paste the code below into your `src/main.sw` file

<TestAction
id="copy-contract"
action={{
name: 'writeToFile',
filepath: 'guides-testing/counter-contract/src/main.sw'
}}
/>

<CodeImport
file="../../examples/counter-dapp/counter-contract/src/main.sw"
comment="all"
commentType="/*"
lang="sway"
/>

Next, run the `forc build` command:

<TestAction
id="build-contract"
action={{
name: 'runCommand',
commandFolder: 'guides-testing/counter-contract'
}}
/>

```sh
forc build
```
Expand Down
4 changes: 4 additions & 0 deletions docs/guides/docs/counter-dapp/building-a-smart-contract.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ action={{
}}
/>

{/*ANCHOR: new_forc_contract*/}

```sh
forc new counter-contract
```

{/*ANCHOR_END: new_forc_contract*/}

You will get this output:

```sh
Expand Down
5 changes: 2 additions & 3 deletions scripts/update-nightly/versions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ export function getExistingVersions() {
rust: getRustSDKVersion(false),
ts: getTSSDKVersion(false),
wallet: getWalletVersion(false),
// TODO: uncomment when sway-libs is bumped to 0.22.0
// sway_libs: getSwayLibsVersion(false),
sway_libs: getSwayLibsVersion(false),
sway_standards: getSwayStandardsVersion(false),
};
versions.nightly = {
forc: getForcVersion(true),
rust: getRustSDKVersion(true),
ts: getTSSDKVersion(true),
wallet: getWalletVersion(true),
// sway_libs: getSwayLibsVersion(true),
sway_libs: getSwayLibsVersion(true),
sway_standards: getSwayStandardsVersion(true),
};

Expand Down
2 changes: 1 addition & 1 deletion src/config/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"rust": "0.63.0",
"ts": "0.89.1",
"wallet": "0.21.0",
"sway_libs": "0.21.0",
"sway_libs": "0.22.0",
"sway_standards": "0.5.0"
}
}
10 changes: 4 additions & 6 deletions src/lib/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ function getForcVersion(docsDir: string) {
}

function getSwayLibsVersion(docsDir: string) {
// TODO: uncomment this once sway-libs 0.22.0 is released
// const filedir = join(docsDir, 'sway-libs/Cargo.toml');
// const file = fs.readFileSync(filedir, 'utf-8');
// const tomfile = toml.parse(file);
// const version = tomfile.package.version;
const version = '0.21.0';
const filedir = join(docsDir, 'sway-libs/Cargo.toml');
const file = fs.readFileSync(filedir, 'utf-8');
const tomfile = toml.parse(file);
const version = tomfile.package.version;
return {
name: 'sway-libs',
category: 'Sway Libraries',
Expand Down
83 changes: 50 additions & 33 deletions tests/test.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
import { test } from './utils/fixtures';
import { runTest } from './utils/runTest';
import { setupFolders, startServers, stopServers } from './utils/setup';
import { useFuelWallet } from './utils/wallet';
import { test } from "./utils/fixtures";
import { runTest } from "./utils/runTest";
import { setupFolders, startServers, stopServers } from "./utils/setup";
import { useFuelWallet } from "./utils/wallet";

test.describe('Guides', () => {
test('counter-dapp', async ({ context, extensionId, page }) => {
const CONTRACT_PAGE_URL = 'guides/counter-dapp/building-a-smart-contract';
const FRONTEND_PAGE_URL = 'guides/counter-dapp/building-a-frontend';
test.describe("Guides", () => {
test("quickstart", async ({ context, extensionId, page }) => {
const CONTRACT_QUICKSTART_PAGE_URL = "guides/contract-quickstart";

// SETUP
stopServers();
await useFuelWallet(context, extensionId, page);
await setupFolders('fuel-project');
await setupFolders("fuel-project");
await startServers(page);

// TEST CONTRACT QUICKSTART
await runTest(page, context, CONTRACT_QUICKSTART_PAGE_URL);

// SHUT DOWN
stopServers();
// context.close();
});

test("counter-dapp", async ({ context, extensionId, page }) => {
const CONTRACT_PAGE_URL = "guides/counter-dapp/building-a-smart-contract";
const FRONTEND_PAGE_URL = "guides/counter-dapp/building-a-frontend";

// SETUP
stopServers();
await useFuelWallet(context, extensionId, page);
await setupFolders("fuel-project");
await startServers(page);

// TEST CONTRACT
Expand All @@ -25,22 +42,22 @@ test.describe('Guides', () => {
// context.close();
});

test('intro to sway', async ({ context, extensionId, page }) => {
const PREREQUISITES_PAGE_URL = 'guides/intro-to-sway/prerequisites';
const IMPORTS_PAGE_URL = 'guides/intro-to-sway/contract-imports';
const STRUCTS_PAGE_URL = 'guides/intro-to-sway/contract-structs';
const ABI_PAGE_URL = 'guides/intro-to-sway/contract-abi';
const STORAGE_PAGE_URL = 'guides/intro-to-sway/contract-storage';
const ERRORS_PAGE_URL = 'guides/intro-to-sway/contract-errors';
const FUNCTIONS_PAGE_URL = 'guides/intro-to-sway/contract-functions';
const CHECKPOINT_PAGE_URL = 'guides/intro-to-sway/checkpoint';
const FUELS_RS_PAGE_URL = 'guides/intro-to-sway/rust-sdk';
const FUELS_TS_PAGE_URL = 'guides/intro-to-sway/typescript-sdk';
test("intro to sway", async ({ context, extensionId, page }) => {
const PREREQUISITES_PAGE_URL = "guides/intro-to-sway/prerequisites";
const IMPORTS_PAGE_URL = "guides/intro-to-sway/contract-imports";
const STRUCTS_PAGE_URL = "guides/intro-to-sway/contract-structs";
const ABI_PAGE_URL = "guides/intro-to-sway/contract-abi";
const STORAGE_PAGE_URL = "guides/intro-to-sway/contract-storage";
const ERRORS_PAGE_URL = "guides/intro-to-sway/contract-errors";
const FUNCTIONS_PAGE_URL = "guides/intro-to-sway/contract-functions";
const CHECKPOINT_PAGE_URL = "guides/intro-to-sway/checkpoint";
const FUELS_RS_PAGE_URL = "guides/intro-to-sway/rust-sdk";
const FUELS_TS_PAGE_URL = "guides/intro-to-sway/typescript-sdk";

// SETUP
stopServers();
await useFuelWallet(context, extensionId, page);
await setupFolders('fuel-project');
await setupFolders("fuel-project");
await startServers(page);

// TEST CONTRACT
Expand All @@ -60,25 +77,25 @@ test.describe('Guides', () => {
// context.close();
});

test('intro to predicates', async ({ context, extensionId, page }) => {
const PREREQUISITES_PAGE_URL = 'guides/intro-to-predicates/prerequisites';
const PREDICATE_ROOT_PAGE_URL = 'guides/intro-to-predicates/predicate-root';
const IMPORTS_PAGE_URL = 'guides/intro-to-predicates/imports';
const CONFIGURABLES_PAGE_URL = 'guides/intro-to-predicates/configurables';
test("intro to predicates", async ({ context, extensionId, page }) => {
const PREREQUISITES_PAGE_URL = "guides/intro-to-predicates/prerequisites";
const PREDICATE_ROOT_PAGE_URL = "guides/intro-to-predicates/predicate-root";
const IMPORTS_PAGE_URL = "guides/intro-to-predicates/imports";
const CONFIGURABLES_PAGE_URL = "guides/intro-to-predicates/configurables";
const SIGNATURE_VERIFICATION_PAGE_URL =
'guides/intro-to-predicates/signature-verification';
const MAIN_PAGE_URL = 'guides/intro-to-predicates/main';
const CHECKPOINT_PAGE_URL = 'guides/intro-to-predicates/checkpoint';
"guides/intro-to-predicates/signature-verification";
const MAIN_PAGE_URL = "guides/intro-to-predicates/main";
const CHECKPOINT_PAGE_URL = "guides/intro-to-predicates/checkpoint";
const SCRIPT_DEBUG_PAGE_URL =
'guides/intro-to-predicates/debugging-with-scripts';
"guides/intro-to-predicates/debugging-with-scripts";
const SCRIPT_LOGS_PAGE_URL =
'guides/intro-to-predicates/debugging-with-scripts-rust';
const FUELS_RS_PAGE_URL = 'guides/intro-to-predicates/rust-sdk';
"guides/intro-to-predicates/debugging-with-scripts-rust";
const FUELS_RS_PAGE_URL = "guides/intro-to-predicates/rust-sdk";

// SETUP
stopServers();
await useFuelWallet(context, extensionId, page);
await setupFolders('fuel-project');
await setupFolders("fuel-project");
await startServers(page);

// TEST CONTRACT
Expand Down

0 comments on commit df0bf5b

Please sign in to comment.