Skip to content

Commit

Permalink
feat: implement new Fuel Wallet Connector (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
luizstacio authored Jan 25, 2024
1 parent 0ec5273 commit fdfa7d7
Show file tree
Hide file tree
Showing 312 changed files with 10,263 additions and 5,037 deletions.
7 changes: 7 additions & 0 deletions .changeset/afraid-terms-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@fuel-wallet/sdk': minor
---

feat: add hooks `useAddAssets`, `useAddNetwork`, `useAssets` and `useNetwork`.
feat: improve hooks `useWallet` `useConnect` and `useAccounts`.
feat: remove `FuelConnectorProvider` and consolidate into `FuelProvider`.
2 changes: 2 additions & 0 deletions .changeset/angry-eggs-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
7 changes: 1 addition & 6 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": [
"docs",
"@fuel-wallet/sdk-v2",
"@fuel-wallet/e2e-contract-tests",
"@fuels/update-sdk"
],
"ignore": ["docs", "@fuel-wallet/e2e-contract-tests", "@fuels/update-sdk"],
"snapshot": {
"useCalculatedVersion": true,
"prereleaseTemplate": "{tag}-{commit}"
Expand Down
5 changes: 5 additions & 0 deletions .changeset/itchy-ducks-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fuel-wallet/react': patch
---

Feat support for image from connector metadata
2 changes: 2 additions & 0 deletions .changeset/large-shoes-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
9 changes: 9 additions & 0 deletions .changeset/tasty-insects-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@fuel-wallet/connections': minor
'@fuel-wallet/react': minor
'@fuel-wallet/types': minor
'fuels-wallet': minor
'@fuel-wallet/sdk': minor
---

feat: update sdk for the new connectors standard.
10 changes: 10 additions & 0 deletions .changeset/ten-snails-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@fuel-wallet/connections': minor
'@fuel-wallet/playwright-utils': minor
'@fuel-wallet/react': minor
'@fuel-wallet/types': minor
'fuels-wallet': minor
'@fuel-wallet/sdk': minor
---

feat: remove fuel-ui from connectors ui and update to the new connectors api.
2 changes: 2 additions & 0 deletions .changeset/tender-yaks-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Tests

on:
pull_request:
branches: [main, master]
branches: [main, master, sdk-v2]
types: [opened, synchronize, reopened]

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: FuelLabs/github-actions/setups/node@master

- name: Validate Changeset
run: pnpm changeset status --since=origin/master
run: pnpm changeset status --since=origin/${{ github.base_ref }}

audit:
name: Audit
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
platform: linux/amd64
container_name: '${PROJECT:-fuel-node}_fuel-core'
environment:
NETWORK_NAME: '${PROJECT} local'
MIN_GAS_PRICE: ${MIN_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
Expand Down
17 changes: 4 additions & 13 deletions docker/fuel-core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ FROM ghcr.io/fuellabs/fuel-core:v0.22.0

ENV MIN_GAS_PRICE="${MIN_GAS_PRICE}"
ENV CONSENSUS_KEY="${CONSENSUS_KEY}"
ENV NETWORK_NAME="${NETWORK_NAME}"

# Install curl to use on
# healthcheck config
Expand All @@ -11,17 +12,7 @@ RUN apt install curl -y
WORKDIR /root/

COPY chainConfig.json .

# https://stackoverflow.com/a/44671685
# https://stackoverflow.com/a/40454758
# hadolint ignore=DL3025
CMD ./fuel-core run \
--ip 0.0.0.0 \
--port 4000 \
--db-path ./mnt/db/ \
--utxo-validation \
--min-gas-price ${MIN_GAS_PRICE} \
--consensus-key ${CONSENSUS_KEY} \
--chain ./chainConfig.json

COPY run.sh .
EXPOSE ${PORT}

CMD ["sh", "./run.sh"]
10 changes: 10 additions & 0 deletions docker/fuel-core/accounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"account": "0xc8e615a4089466174459ef19cfd257d2e17adfabff3b8f219dbb5fb4eca87c50",
"privateKey": "0xba9e8401405cd4327119548bccf0cd8b195c3fb716c848d9571c60bb230c6978"
},
{
"account": "0x92dffc873b56f219329ed03bb69bebe8c3d8b041088574882f7a6404f02e2f28",
"privateKey": "0xa349d39f614a3085b7f7f8cef63fd5189136924fc1238e6d25ccdaa43a901cd0"
}
]
12 changes: 11 additions & 1 deletion docker/fuel-core/chainConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,17 @@
},
{
"owner": "0x6684dd7bb61364e1ac458e9241f969178c4a2e302bbc23e143c49d8b6dba701a",
"amount": "0xFFFFFFFFFFFFFFFF",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"owner": "0xc8e615a4089466174459ef19cfd257d2e17adfabff3b8f219dbb5fb4eca87c50",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
},
{
"owner": "0x92dffc873b56f219329ed03bb69bebe8c3d8b041088574882f7a6404f02e2f28",
"amount": "0x00000000FFFFFFFF",
"asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
]
Expand Down
14 changes: 14 additions & 0 deletions docker/fuel-core/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Change the network name
sed -i "s/local_testnet/$NETWORK_NAME/g" ./chainConfig.json

# Start the Fuel Core node
/root/fuel-core run \
--ip 0.0.0.0 \
--port 4000 \
--db-path ./mnt/db/ \
--utxo-validation \
--min-gas-price ${MIN_GAS_PRICE} \
--consensus-key ${CONSENSUS_KEY} \
--chain ./chainConfig.json
23 changes: 23 additions & 0 deletions examples/cra-dapp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
46 changes: 46 additions & 0 deletions examples/cra-dapp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
33 changes: 33 additions & 0 deletions examples/cra-dapp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "cra-dapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fuel-wallet/react": "workspace:*",
"@types/node": "^16.18.61",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"fuels": "0.67.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added examples/cra-dapp/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/cra-dapp/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions examples/cra-dapp/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions examples/cra-dapp/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
49 changes: 49 additions & 0 deletions examples/cra-dapp/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.App {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 100px;
height: 100vh;
width: 100vw;
}

.App[data-theme='dark'] {
background-color: #282c34;
color: white;
}

button {
all: unset;
border: 1px solid black;
padding: 10px 20px;
border-radius: 4px;
box-shadow: 1px 1px 1px 1px rgba(0, 0, 0, 0.2);
transition: box-shadow 0.2s ease-in-out;
cursor: pointer;
}

button:active {
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.2);
}

.Actions {
display: flex;
flex-direction: row;
align-items: center;
gap: 10px;
}

.Accounts {
margin-top: 20px;
text-align: center;
}

.Accounts > div {
font-style: italic;
}

.Error {
color: #d60000;
width: 100%;
text-align: center;
}
Loading

0 comments on commit fdfa7d7

Please sign in to comment.