Skip to content

Commit

Permalink
Merge branch 'master' into dp/fuels-version-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaiwat10 committed Oct 3, 2024
2 parents 28bd961 + 8321098 commit e95f401
Show file tree
Hide file tree
Showing 195 changed files with 7,342 additions and 5,381 deletions.
5 changes: 0 additions & 5 deletions .changeset/odd-starfishes-flash.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/popular-bikes-allow.md

This file was deleted.

4 changes: 0 additions & 4 deletions .changeset/serious-crabs-begin.md

This file was deleted.

3 changes: 2 additions & 1 deletion apps/create-fuels-counter-guide/.env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_FUEL_NODE_PORT=4000
VITE_DAPP_ENVIRONMENT=local
VITE_DAPP_ENVIRONMENT=local
VITE_GENESIS_WALLET_PRIVATE_KEY=0x01
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ src/sway-api/index.ts
sway-programs/**/out
.turbo

playwright-report
test-results
test-results
playwright-report
17 changes: 7 additions & 10 deletions apps/create-fuels-counter-guide/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import js from '@eslint/js';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config({
extends: [js.configs.recommended, ...tseslint.configs.recommended],
Expand All @@ -18,9 +18,6 @@ export default tseslint.config({
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
})
});
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/fuel-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
channel = "testnet"

[components]
forc = "0.63.1"
fuel-core = "0.34.0"
forc = "0.63.5"
fuel-core = "0.35.0"
6 changes: 3 additions & 3 deletions apps/create-fuels-counter-guide/fuels.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #region fuels-config-file-env
import { createConfig } from 'fuels';
import dotenv from 'dotenv';
import { NODE_URL } from './src/lib';
import { providerUrl } from './src/lib';

dotenv.config({
path: ['.env.local', '.env'],
Expand All @@ -14,8 +14,8 @@ export default createConfig({
workspace: './sway-programs', // Path to your Sway workspace
output: './src/sway-api', // Where your generated types will be saved
fuelCorePort,
providerUrl: NODE_URL,
fuelCorePath: 'fuels-core',
providerUrl,
forcPath: 'fuels-forc',
fuelCorePath: 'fuels-core',
});
// #endregion fuels-config-file-env
2 changes: 1 addition & 1 deletion apps/create-fuels-counter-guide/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/fuel.ico" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fuel dApp</title>
</head>
Expand Down
12 changes: 5 additions & 7 deletions apps/create-fuels-counter-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,22 @@
"@fuels/connectors": "^0.27.1",
"@fuels/react": "^0.27.1",
"@tanstack/react-query": "^5.55.4",
"@tanstack/react-router": "^1.58.3",
"fuels": "workspace:*",
"clsx": "2.1.1",
"@wagmi/connectors": "^5.1.12",
"@wagmi/core": "^2.13.6",
"dotenv": "^16.4.5",
"fuels": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-use": "^17.5.1"
"react-toastify": "^10.0.5"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.1",
"@eslint/js": "^9.10.0",
"@tanstack/router-plugin": "^1.56.4",
"@types/node": "^22.5.5",
"@playwright/test": "^1.47.2",
"@types/react": "^18.3.8",
"@types/react-dom": "^18.3",
"@vitejs/plugin-react-swc": "^3.7.0",
"autoprefixer": "^10.4.20",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
Expand All @@ -45,6 +43,6 @@
"typescript": "~5.6.2",
"typescript-eslint": "^8.5.0",
"vite": "^5.4.7",
"vitest": "^2.0.5"
"vitest": "~2.0.5"
}
}
4 changes: 2 additions & 2 deletions apps/create-fuels-counter-guide/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ export default defineConfig({
command: 'pnpm run fuels:dev',
port: 4000,
reuseExistingServer: !process.env.CI,
}
]
},
],
});
2 changes: 1 addition & 1 deletion apps/create-fuels-counter-guide/postcss.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export default {
tailwindcss: {},
autoprefixer: {},
},
}
};
1 change: 0 additions & 1 deletion apps/create-fuels-counter-guide/public/copy.svg

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions apps/create-fuels-counter-guide/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { useConnectUI, useIsConnected, useNetwork } from "@fuels/react";
import { useEffect } from "react";

import { useRouter } from "./hooks/useRouter";
import Button from "./components/Button";
import Info from "./components/Info";
import Wallet from "./components/Wallet";
import Contract from "./components/Contract";
import Predicate from "./components/Predicate";
import Script from "./components/Script";
import Faucet from "./components/Faucet";
import { providerUrl } from './lib'

function App() {
const { connect } = useConnectUI();
const { isConnected, refetch } = useIsConnected();
const { network } = useNetwork();
const { view, views, setRoute } = useRouter();
const isConnectedToCorrectNetwork = network?.url === providerUrl;


useEffect(() => {
refetch();
}, [refetch]);

return (
<main
data-theme="dark"
className="flex items-center justify-center lg:pt-6 text-zinc-50/90"
>
<div id="container" className="mx-8 mb-32 w-full max-w-6xl">
<nav id="nav" className="flex items-center justify-center py-1 md:py-6">
<a href="https://fuel.network/" target="_blank" rel="noreferrer">
<img src="./logo_white.png" alt="Fuel Logo" className="w-[124px]" />
</a>
</nav>

<div className="gradient-border rounded-2xl">
<div className="grain rounded-2xl p-1.5 drop-shadow-xl">
<div
id="grid"
className="lg:grid lg:grid-cols-7 lg:grid-rows-1 lg:gap-12"
>
<Info />
<div className="col-span-5">
<div className="gradient-border h-full rounded-xl bg-gradient-to-b from-zinc-900 to-zinc-950/80">
{!isConnected && (
<section className="flex h-full flex-col justify-center space-y-6 px-4 py-8 lg:px-[25%]">
<Button onClick={() => connect()}>Connect Wallet</Button>
</section>
)}

{isConnected && !isConnectedToCorrectNetwork && (
<section className="flex h-full flex-col justify-center space-y-6 px-4 py-8">
<p className="text-center">
You are connected to the wrong network. Please switch to{" "}
<a
href={providerUrl}
target="_blank"
rel="noreferrer"
className="text-green-500/80 transition-colors hover:text-green-500"
>
{providerUrl}
</a>
&nbsp;in your wallet.
</p>
</section>
)}

{isConnected && isConnectedToCorrectNetwork && (
<section className="flex h-full flex-col justify-center space-y-6 px-4 py-8">
<div className="flex flex-col sm:flex-row gap-3">
{views.map((viewName) => (
<Button
key={viewName}
className="w-full sm:flex-1 capitalize"
color={view === viewName ? "primary" : "inactive"}
onClick={() => setRoute(viewName)}
>
{viewName}
</Button>
))}
</div>

{view === "wallet" && <Wallet />}
{view === "contract" && <Contract />}
{view === "predicate" && <Predicate />}
{view === "script" && <Script />}
{view === "faucet" && <Faucet />}
</section>
)}
</div>
</div>
</div>
</div>
</div>
</div>
</main>
);
}

export default App;
29 changes: 21 additions & 8 deletions apps/create-fuels-counter-guide/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
export const Button: React.FC<{
children: React.ReactNode;
className?: string;
onClick?: () => void;
}> = ({ children, className, onClick }) => {
import React from "react";
import clsx from "clsx";

export type Props = {
color?: "primary" | "secondary" | "inactive";
} & React.ComponentProps<"button">;

export default function Button(props: Props) {
const { color = "primary", children, disabled, className, ...rest } = props;

return (
<button
className={`bg-fuel-green text-white px-4 py-2 rounded-md ${className}`}
onClick={onClick}
type="button"
className={clsx(
"btn",
color === "primary" && "btn-primary",
color === "secondary" && "btn-secondary",
color === "inactive" && "btn-inactive",
className,
)}
disabled={disabled}
{...rest}
>
{children}
</button>
);
};
}
Loading

0 comments on commit e95f401

Please sign in to comment.