Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
feat: integrate Fuel Wallet with swayswap and update to beta-3 (#401)
Browse files Browse the repository at this point in the history
* refactor: bump deps and fix breaking changes

* refactor: update for breaking changes

* update deps

* fix: build errors

* refactor: comment create wallet code

* refactor: remove unused wallet code

* refactor: update swap machine

* chore: bump tool chain and regen types

* refactor: remove gas limit

* fix: test by adding timeout

* fix: tests

* chore: remove comments and change search text

* test: setup playwright and add some e2e code

* test: add more code to e2e playwright test

* fix: mint system

* chore: install next versions and rebuild types

* fix: flaky test behavoiour

* chore: update dist-crx

* fix: test and bump wallet

* refactor: remove old cypress code

* fix: lint and formatting

* ci: use playwright instead of cypress

* fix: lock file

* test: add timeout to component

* test: add logs on pages for debugging ci

* test: more ci debugging

* ci: upload test results

* ci: fix path to report

* ci: run node

* rebuild contracts and bump ci fuelup versions

* chore: remove logs

* fix: bump versions and fix breaking changes

* fix: breaking change

* fix: breaking changes

* fix: breaking changes

* ci: bump forc version

* rebuild types

* ci: bump fuel-core

* try to fix for ci

* fix: tests

* try to fix ci even though this works locally

* fix : ci

* chore: remove commented code

* refactor: remove any type

* refactor: improve use fuel hook

* chore: remove commented code

* chore: regen types

* feat: add connect wallet page

* feat: add welcome connect page

* fix: tests

* fix: e2e tests

* Fix: lint errors

* fix: e2e test

* chore: remove logs

* chore: add back logs

* chore: remove logs

* fix: don
't automatically connect

* refactor: remove automatic connection and add comments

* fix: test failing on ci only

* chore: remove dist-crx and try to download

* chore: bump and fix

* chore: update docker

* fix: breaking changes

* chore: fix and bump versions

* chore: remove logs

* fix: tests to work with unreleased wallet

* fix: lint erros

* fix: lint and formatting

* fix: test

* refactor: use another token instead of base asset

* fix: tests

* refactor: change remove liquidity amount

* fix: type errors

* refactor: use another token instead of eth

* refactor: use another token instead of eth

* refactor: use another token instead of base asset

* fix: tests

* refactor: mock mint

* fix: tests

* fix: tests

* refactor: change btc to eth

* ci: fix

* style: center steps indicator

* fix: wallet popup error

* ci: fix

* ci: fix

* ci: debugging

* ci: more debugging

* ci: more debugging

* ci: fix

* ci: fix

* ci: fix

* ci: fix

* refactor: remove logs

* ci: fix

* fix: version error

* chore: lint

* ci: bump versions for beta-3

* fix: use wallet instead of account

* feat: add faucet to welcome steps

* feat: add mint to state machine

* fix: welcome steps

* fix: welcome steps and tokens

* fix: some tests

* fix: e2e tests

* chore: bump fuels

* fix: tests

* chore: fix lint and fmt

* ci: temp fix

* fix: build error

* ci: debugging

* ci: possible fix

* ci: more debugging

* ci: actually fix rip

* fix: I have shit for brains

* ci: fix again

* chore: update contract ids

* fix: faucet url

* fix: lint

* refactor: use new logo

* refactor: use new logo

* chore: lint

* fix: reject flows and improve refresh handling

* feat: move logout to a settings menu

* ci: remove envs from gh deploy

* fix: types

* feat: add pool size on config

* feat: update ci

* chore: update env

* feat: improve remove wallet or disconnection

* fix: useWallet hooks

* feat: add more checks to avoid user to be locked on middle steps

* chore: change imports

* fix: tests

* fix: tests

* ci: add contract tests back

* feat: update tests

* feat: update start on test

* chore: update contract ids

* feat: add loader to mint button

---------

Co-authored-by: matt-user <[email protected]>
Co-authored-by: luizstacio <[email protected]>
Co-authored-by: luizstacio <[email protected]>
  • Loading branch information
4 people authored Apr 4, 2023
1 parent 7a3f70e commit 5ab985f
Show file tree
Hide file tree
Showing 132 changed files with 9,573 additions and 9,271 deletions.
9 changes: 6 additions & 3 deletions .github/setup-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ name: 'Setup Rust env'
inputs:
rust-version:
description: 'Rust version'
default: 1.64.0
default: 1.68.2
forc-version:
description: 'Forc version'
default: 0.26.0
default: 0.35.5
fuel-core-version:
description: 'Fuel core version'
default: 0.17.4


runs:
Expand Down Expand Up @@ -34,4 +37,4 @@ runs:
uses: FuelLabs/action-fuel-toolchain@master
with:
name: swayswap-toolchain
components: forc@${{ inputs.forc-version }}
components: forc@${{ inputs.forc-version }}, fuel-core@${{ inputs.fuel-core-version }}
17 changes: 8 additions & 9 deletions .github/workflows/deploy-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
provider_url:
description: 'Provider url'
required: true
default: 'https://testnet-01-preview.swayswap.io/graphql'
default: 'https://beta-3.fuel.network/graphql'
type: string
wallet_secret:
description: 'Wallet secret used to deploy and provide initial liquidity'
Expand All @@ -16,11 +16,9 @@ on:
required: true
default: 1
type: number
token_amount:
description: 'Token amount to be used on pool initialization'
type: string
eth_amount:
description: 'Eth amount to be used on pool initialization'
size_pool:
description: 'Pool size for initialization'
default: '1000000.0'
type: string
initiate_supply:
description: 'Should initialize the pool?'
Expand All @@ -34,15 +32,14 @@ on:
type: boolean

env:
RUST_VERSION: 1.61.0
RUST_VERSION: 1.68.2
NODE_VERSION: 16
PNPM_VERSION: 7.0.0
COMPOSE_VERSION: 2.6.0
WALLET_SECRET: ${{ github.event.inputs.wallet_secret || secrets.WALLET_SECRET }}
PROVIDER_URL: ${{ github.event.inputs.provider_url }}
GAS_PRICE: ${{ github.event.inputs.gas_price }}
TOKEN_AMOUNT: ${{ github.event.inputs.token_amount }}
ETH_AMOUNT: ${{ github.event.inputs.eth_amount }}
SIZE_POOL: ${{ github.event.inputs.size_pool }}
OUTPUT_ENV: .env.production

jobs:
Expand Down Expand Up @@ -87,6 +84,8 @@ jobs:
- name: Deploy contracts
run: |
pnpm exec swayswap-scripts run
env:
NODE_ENV: production

- name: Initiate token contract and liquidity pool
if: ${{ github.event.inputs.initiate_supply }}
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ jobs:
env:
CI: false
PUBLIC_URL: "/${{ github.event.repository.name }}"
VITE_FUEL_PROVIDER_URL: "https://node-beta-1.fuel.network/graphql"
VITE_FUEL_FAUCET_URL: "https://faucet-beta-1.fuel.network/dispense"
VITE_CONTRACT_ID: "0xc9a5366c269438d294ef942bc962dd2e6c86121e3bca00192723eb7eb58fa87d"
VITE_TOKEN_ID: "0x6dfc0f524d3006e103fc4bd733c4f012b5a089fd09361d44833cdf653e9afe5b"
run: |
pnpm build
Expand Down
59 changes: 15 additions & 44 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,52 +102,23 @@ jobs:

- name: Setup scripts
run: |
pnpm scripts:setup
pnpm services:setup-test
# using same dependencies from cypress/browsers:node16.5.0-chrome97-ff96 ...
# not using directly the container because we still need ubuntu-latest preset
- name: Install Cypress Dependencies
run: |
sudo apt-get update && \
sudo apt-get install --no-install-recommends -y \
libgtk2.0-0 \
libgtk-3-0 \
libnotify-dev \
libgconf-2-4 \
libgbm-dev \
libnss3 \
libxss1 \
libasound2 \
libxtst6 \
xauth \
xvfb \
vim-tiny \
nano \
fonts-noto-color-emoji \
fonts-arphic-bkai00mp \
fonts-arphic-bsmi00lp \
fonts-arphic-gbsn00lp \
fonts-arphic-gkai00mp \
fonts-arphic-ukai \
fonts-arphic-uming \
ttf-wqy-zenhei \
ttf-wqy-microhei \
xfonts-wqy \
fonts-liberation \
libappindicator3-1 \
xdg-utils \
zip
- name: "End-to-end tests"
uses: cypress-io/github-action@v4
with:
# skip install, as: 1 - we're doing in other step; 2 - cypress doesnt support pnpm yet https://github.com/cypress-io/github-action/issues/145
install: false
command: pnpm ci:test:e2e
browser: chrome
record: false
- name: Install Playwright
run: pnpm exec playwright install --with-deps chromium

- name: End-to-end tests
run: xvfb-run --auto-servernum -- pnpm test:e2e
env:
# Recommended: pass the GitHub token lets this action correctly
# determine the unique run id necessary to re-run the checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_ENV: "test"
NODE_ENV: "test"

- name: Upload test results
uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-report
path: packages/app/playwright-report/
retention-days: 30
5 changes: 1 addition & 4 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"./**/*.{js,jsx,ts,tsx,html}": [
"pnpm prettier:check",
"pnpm lint:check"
]
"./**/*.{js,jsx,ts,tsx,html}": ["pnpm prettier:check", "pnpm lint:check"]
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"jest.jestCommandLine": "cd packages/app && pnpm jest"
"jest.jestCommandLine": "cd packages/app && pnpm jest",
"[xml]": {
"editor.defaultFormatter": "ms-vsliveshare.vsliveshare"
}
}
13 changes: 0 additions & 13 deletions cypress.config.ts

This file was deleted.

3 changes: 2 additions & 1 deletion docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ WALLET_SECRET=0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
DISPENSE_AMOUNT=500000000
GAS_PRICE=1
# Used by SwaySwap scripts
PROVIDER_URL=http://localhost:4000/graphql
PROVIDER_URL=http://localhost:4000/graphql
SIZE_POOL="1000000.0"
1 change: 1 addition & 0 deletions docker/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ DISPENSE_AMOUNT=500000000
GAS_PRICE=1
# Used by SwaySwap scripts
PROVIDER_URL=http://localhost:4001/graphql
SIZE_POOL="1000000.0"
7 changes: 6 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ version: "3"

services:
swayswap-fuel-core:
platform: linux/amd64
container_name: "swayswap-fuel-core-${ENVIRONMENT:-development}"
environment:
MIN_GAS_PRICE: ${GAS_PRICE}
# This is the private key of the consensus.PoA.signing_key in the chainConfig.json
# this key is responsible for validating the transactions
CONSENSUS_KEY: 0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298
build: ./fuel-core
ports:
- "${FUEL_CORE_PORT:-4000}:4000"
Expand All @@ -16,6 +20,7 @@ services:
timeout: 5s
retries: 10
swayswap-faucet:
platform: linux/amd64
container_name: "swayswap-faucet-${ENVIRONMENT:-development}"
environment:
MIN_GAS_PRICE: ${GAS_PRICE}
Expand All @@ -24,7 +29,7 @@ services:
FUEL_NODE_URL: http://swayswap-fuel-core-${ENVIRONMENT:-development}:4000/graphql
# Other configurations can be found at;
# https://github.com/FuelLabs/faucet#configuration
image: ghcr.io/fuellabs/faucet:v0.1.3
image: ghcr.io/fuellabs/faucet:v0.5.0
ports:
- "${FUEL_FAUCET_PORT:-4040}:3000"
links:
Expand Down
11 changes: 8 additions & 3 deletions docker/fuel-core/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/fuellabs/fuel-core:v0.10.1
FROM ghcr.io/fuellabs/fuel-core:v0.17.3

ARG IP=0.0.0.0
ARG PORT=4000
Expand All @@ -7,6 +7,8 @@ ARG DB_PATH=./mnt/db/
ENV IP="${IP}"
ENV PORT="${PORT}"
ENV DB_PATH="${DB_PATH}"
ENV MIN_GAS_PRICE="${MIN_GAS_PRICE}"
ENV CONSENSUS_KEY="${CONSENSUS_KEY}"

# Install curl to use on
# healthcheck config
Expand All @@ -17,12 +19,15 @@ WORKDIR /root/

COPY chainConfig.json .

CMD ./fuel-core \
CMD exec ./fuel-core run \
--ip ${IP} \
--port ${PORT} \
--db-path ${DB_PATH} \
--utxo-validation \
--min-gas-price ${MIN_GAS_PRICE} \
--vm-backtrace \
--poa-instant=true \
--consensus-key ${CONSENSUS_KEY} \
--utxo-validation \
--chain ./chainConfig.json

EXPOSE ${PORT}
16 changes: 14 additions & 2 deletions docker/fuel-core/chainConfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"chain_name": "local_testnet",
"block_production": "Instant",
"consensus": {
"PoA": {
"signing_key": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d"
}
},
"parent_network": {
"type": "LocalTest"
},
"block_gas_limit": 5000000000,
"transaction_parameters": {
"contract_max_size": 16777216,
"max_inputs": 255,
Expand All @@ -16,7 +21,9 @@
"max_storage_slots": 255,
"max_predicate_length": 1048576,
"max_predicate_data_length": 1048576,
"gas_price_factor": 1000000
"gas_price_factor": 1000000000,
"gas_per_byte": 4,
"max_message_data_length": 1048576
},
"wallet": {
"address": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
Expand All @@ -28,6 +35,11 @@
"owner": "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
"amount": "0xFFFFFFFFFFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"owner": "0x80d5e88c2b23ec2be6b2e76f3499a1a2755bb2773363785111a719513fb57b8e",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
]
}
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"contracts:deploy": "pnpm exec swayswap-scripts deploy",
"contracts:init": "pnpm run --filter swayswap-app contracts:init",
"contracts:init-pool": "pnpm run --filter swayswap-app contracts:init --init-pool",
"cy:open": "cypress open",
"cy:run": "cypress run --headless",
"dev": "turbo run dev --parallel",
"gh-preview": "pnpm run --filter swayswap-app gh-preview",
"lint:check": "eslint . --ext .ts,.tsx,.js,.jsx",
Expand All @@ -45,26 +43,27 @@
"services:reset": "run-s services:clean services:setup",
"services:clean-test": "make -C docker services-clean-test",
"services:setup-test": "NODE_ENV=test run-s scripts:setup create:test-env services:run-test contracts contracts:init",
"services:setup-test-init": "NODE_ENV=test run-s scripts:setup create:test-env services:run-test contracts contracts:init-pool",
"services:run-test": "make -C docker services-run-test",
"services:reset-test": "NODE_ENV=test run-s services:clean-test services:setup-test",
"deps:update": "./scripts/update-deps.sh",
"test": "pnpm run --filter=swayswap-app test",
"test:coverage": "pnpm run --filter=swayswap-app test --coverage",
"test": "NODE_ENV=test pnpm run --filter=swayswap-app test",
"test:coverage": "NODE_ENV=test pnpm run --filter=swayswap-app test --coverage",
"test:clear": "pnpm -r exec jest --clearCache",
"test:e2e": "run-p --race dev cy:run"
"test:e2e": "NODE_ENV=test playwright test --config=packages/app/playwright.config.ts"
},
"devDependencies": {
"@babel/core": "^7.19.0",
"@cypress/react": "^5.12.5",
"@jest/types": "^28.1.3",
"@playwright/test": "^1.30.0",
"@swayswap/test-utils": "workspace:0.1.0",
"@swc/core": "^1.2.249",
"@swc/jest": "^0.2.22",
"@types/chrome": "^0.0.226",
"@types/jest": "^28.1.8",
"@types/node": "^17.0.45",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"cypress": "^10.7.0",
"dotenv": "^16.0.2",
"eslint": "^8.23.0",
"husky": "^8.0.1",
Expand Down Expand Up @@ -94,5 +93,8 @@
"react-dom"
]
}
},
"dependencies": {
"fuels": "0.35.0"
}
}
3 changes: 2 additions & 1 deletion packages/app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ VITE_FUEL_PROVIDER_URL=http://localhost:4000/graphql
VITE_FUEL_FAUCET_URL=http://localhost:4040/dispense
VITE_FAUCET_RECAPTCHA_KEY=
VITE_CONTRACT_ID=0x0000000000000000000000000000000000000000000000000000000000000000
VITE_TOKEN_ID=0x0000000000000000000000000000000000000000000000000000000000000000
VITE_TOKEN_ID1=0x0000000000000000000000000000000000000000000000000000000000000000
VITE_TOKEN_ID2=0x0000000000000000000000000000000000000000000000000000000000000000
9 changes: 5 additions & 4 deletions packages/app/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Production env file
# This was added due to vercel issues on updating env variables
#
VITE_FUEL_PROVIDER_URL=https://testnet-01-preview.swayswap.io/graphql
VITE_FUEL_FAUCET_URL=https://faucet-testnet-01-preview.swayswap.io/dispense
VITE_FUEL_PROVIDER_URL=https://beta-3.fuel.network/graphql
VITE_FUEL_FAUCET_URL=https://faucet-beta-3.fuel.network/dispense
VITE_FAUCET_RECAPTCHA_KEY=6Ld3cEwfAAAAAMd4QTs7aO85LyKGdgj0bFsdBfre
VITE_CONTRACT_ID=0x0c451a5915bde9057529affc618ea12c917bc2b1e2d65adc24207425053ecfee
VITE_TOKEN_ID=0xc4e32fb2bbb59215b639047082596ad073ebc3ccf85d1e84a1738c1d38163e09
VITE_CONTRACT_ID=0x004ff2b3b79a67c1d574fa84a52af46cf42dbc1ac0229d13ec7802460ede9118
VITE_TOKEN_ID1=0x1bdeed96ee1e5eca0bd1d7eeeb51d03b0202c1faf764fec1b276ba27d5d61d89
VITE_TOKEN_ID2=0x0d9be25f6bef5c945ce44db64b33da9235fbf1a9f690298698d899ad550abae1
9 changes: 9 additions & 0 deletions packages/app/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
.env.test
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
/playwright/fuel-wallet.zip
/playwright/dist-crx
/test-results/
/playwright-report/
/playwright/.cache/
4 changes: 0 additions & 4 deletions packages/app/cypress/.eslintrc.json

This file was deleted.

Loading

0 comments on commit 5ab985f

Please sign in to comment.