Skip to content

Commit

Permalink
feat: tictactoe UI (#780)
Browse files Browse the repository at this point in the history
## Type of change

- New feature

## Changes

The following changes have been made:

- Create a ui for the tic tac toe app


## Related Issues

Closes #110
  • Loading branch information
matt-user authored Mar 15, 2024
1 parent e9ed52b commit cf86982
Show file tree
Hide file tree
Showing 71 changed files with 9,249 additions and 103 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/deploy-contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Deploy Contracts

on:
workflow_dispatch:
inputs:
provider_url:
description: "Provider url"
required: true
default: "https://beta-5.fuel.network/graphql"
type: string
wallet_secret:
description: "Wallet secret used to deploy contracts"
required: true
type: string
gas_price:
description: "Min gas price required from the provider"
required: true
default: 1
type: number
commit_changes:
description: "Commit contract ids on the current branch"
required: true
default: true
type: boolean

env:
RUST_VERSION: 1.74.0
NODE_VERSION: 18
PNPM_VERSION: 8
WALLET_SECRET: ${{ github.event.inputs.wallet_secret }}
PROVIDER_URL: ${{ github.event.inputs.provider_url }}
GAS_PRICE: ${{ github.event.inputs.gas_price }}

jobs:
cancel-previous-run:
name: Cancel previous actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

test-inputs:
runs-on: ubuntu-latest
steps:
- name: Check provider_url format
run: |
if ! [[ "${{ github.event.inputs.provider_url }}" =~ ^https?:\/\/([a-z0-9\.-]){1,}(:[0-9]{1,4})?\/graphql$ ]]; then
echo "Provider url is not valid";
process 1;
fi
shell: bash

build-and-deploy:
needs: test-inputs
name: Build and deploy contracts
runs-on: ubuntu-latest

strategy:
matrix:
project: ["games/TicTacToe/frontend-app"]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Install Fuel toolchain
uses: FuelLabs/[email protected]
with:
toolchain: nightly
date: 2024-01-24

- name: PNPM install
id: pnpm-cache
run: |
cd ${{ matrix.project }}
pnpm recursive install --frozen-lockfile
- name: Build contracts
run: |
cd ${{ matrix.project }}
pnpm fuels build
- name: Deploy contracts
run: |
cd ${{ matrix.project }}
pnpm fuels deploy
env:
NODE_ENV: production

- name: Commit new contract ids
if: ${{ github.event.inputs.commit_changes && github.ref != 'refs/heads/master' }}
uses: EndBug/add-and-commit@v9
with:
message: "chore: update contract ids"
add: ${{ matrix.project }}/production-contract/contract-ids.json
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

# These are backup files generated by rustfmt
**/*.rs.bk

node_modules
.turbo
dist
2 changes: 0 additions & 2 deletions games/TicTacToe/.gitignore

This file was deleted.

32 changes: 21 additions & 11 deletions games/TicTacToe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,37 @@ The project consists of a smart contract.
```sh
TicTacToe
├── project
│   ├── contracts
│   │   └── tictactoe-contract
│   │   ├── src/main.sw
│   │   └── tests/harness.rs
│   ├── README.md
│   └── SPECIFICATION.md
├── ui
│ ├── README.md
│ └── SPECIFICATION.md
│   ├────── contracts
│   │   └────── tictactoe-contract
│   │   ├────── src/main.sw
│   │   └────── tests/harness.rs
│   ├────── README.md
│   └────── SPECIFICATION.md
├── app
│ ├────── package.json
│ ├────── index.html
│ └────── src/main.tsx
└── README.md
```

## Running the project

### User interface

TODO: The user interface does not currently exist therefore its [README.md](ui/README.md) and [SPECIFICATION.md](ui/SPECIFICATION.md) are empty.
In order to run the subsequent commands change into the following directory `/path/to/TicTacToe/packages/app/<here>`.

#### Run the frontend application

```bash
pnpm install
pnpm project-setup
```

You will need to install the [Fuel wallet](https://wallet.fuel.network/docs/install/) in order to interact with the application. Now you can open your browser and interact with the tic-tac-toe contract through the frontend. To play connect two of your wallet accounts and switch between them so each can take their turn. If you want to run this locally you will need to modify the `chainConfig.json` file to fund your wallet locally. Add your wallet address and give it some amount of asset id 0x0000...0000.

### Project

In order to run the subsequent commands change into the following directory `/path/to/TicTacToe/project/<here>`.
In order to run the subsequent commands change into the following directory `/path/to/TicTacToe/packages/project/<here>`.

#### Program compilation

Expand Down
1 change: 1 addition & 0 deletions games/TicTacToe/frontend-app/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_NODE_ENV=production
14 changes: 14 additions & 0 deletions games/TicTacToe/frontend-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

**/node_modules/
**/coverage/
*.js
*.html
dist
CHANGELOG.md
src/contract-types
contracts
**/*.typegen.ts
.eslintrc.js
**/__generated__/
**/generated/*
.changeset/**.md
12 changes: 12 additions & 0 deletions games/TicTacToe/frontend-app/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["plugin:@fuels/base"],
"rules": {
"import/prefer-default-export": "off",
"import/no-named-as-default": "off",
"import/export": "off",
"import/default": "off",
"no-console": "error",
"@typescript-eslint/no-empty-function": "off",
"jsx-a11y/alt-text": "off"
}
}
26 changes: 26 additions & 0 deletions games/TicTacToe/frontend-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
.env
.fuels

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
14 changes: 14 additions & 0 deletions games/TicTacToe/frontend-app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.coverage_*
.github
CHANGELOG.md
coverage
dist
dist-crx
node_modules
pnpm-lock.yaml
**/*.typegen.ts
.next
**/storybook/**/*
**/__generated__/
**/generated/
.changeset/**.md
9 changes: 9 additions & 0 deletions games/TicTacToe/frontend-app/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const fuelPrettierConfig = require('@fuels/prettier-config');

/** @type {import("prettier").Config} */
module.exports = {
...fuelPrettierConfig,
// trailingComma always adds comma on the end of functions params, that can cause
// issues, when a second param can't be undefined.
trailingComma: 'es5',
};
Loading

0 comments on commit cf86982

Please sign in to comment.