Skip to content

Commit

Permalink
Merge branch 'master' into dp/not-enough-coins-error
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf authored Aug 29, 2024
2 parents 68e9cd7 + e04947a commit 5c99b49
Show file tree
Hide file tree
Showing 26 changed files with 682 additions and 382 deletions.
6 changes: 6 additions & 0 deletions .changeset/fast-bulldogs-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/versions": patch
"create-fuels": patch
---

chore: upgraded forc to `0.63.3`
5 changes: 5 additions & 0 deletions .changeset/new-rivers-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

feat: add missing connectors to `create fuels` template
5 changes: 5 additions & 0 deletions .changeset/stupid-books-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

feat: embed testnet faucet in `create-fuels` template
5 changes: 5 additions & 0 deletions .changeset/tall-hairs-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-fuels": patch
---

feat: make `create-fuels` template app responsive
4 changes: 4 additions & 0 deletions .changeset/wet-hairs-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: increase test timeout to reduce flakiness
2 changes: 1 addition & 1 deletion internal/forc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.63.1
0.63.3
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,17 @@ const abi = {
{
"name": "SHOULD_RETURN",
"concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903",
"offset": 2720
"offset": 2776
},
{
"name": "AN_OPTION",
"concreteTypeId": "2da102c46c7263beeed95818cd7bee801716ba8303dddafdcd0f6c9efda4a0f1",
"offset": 2696
"offset": 2752
},
{
"name": "A_GENERIC_STRUCT",
"concreteTypeId": "71df88006611ffff852cf617defb70f77adaf507305088cedd41d276c783aab0",
"offset": 2712
"offset": 2768
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ const abi = {
{
"name": "FEE",
"concreteTypeId": "c89951a24c6ca28c13fd1cfdc646b2b656d69e61a92b91023be7eb58eb914b6b",
"offset": 928
"offset": 920
},
{
"name": "ADDRESS",
"concreteTypeId": "7c5ee1cecf5f8eacd1284feb5f0bf2bdea533a51e2f0c9aabe9236d335989f3b",
"offset": 896
"offset": 888
}
]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const abi = {
{
"name": "SHOULD_RETURN",
"concreteTypeId": "b760f44fa5965c2474a3b471467a22c43185152129295af588b022ae50b50903",
"offset": 704
"offset": 760
}
]
};
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/test-utils/launchNode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ vi.mock('fs', async () => {
/**
* @group node
*/
describe('launchNode', () => {
describe('launchNode', { timeout: 10000 }, () => {
test('using ephemeral port 0 is possible', async () => {
const { cleanup, port, url } = await launchNode({ port: '0' });
expect(await fetch(url)).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion packages/versions/src/lib/getBuiltinVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Versions } from './types';

export function getBuiltinVersions(): Versions {
return {
FORC: '0.63.1',
FORC: '0.63.3',
FUEL_CORE: '0.34.0',
FUELS: '0.94.2',
};
Expand Down
295 changes: 190 additions & 105 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions templates/nextjs/public/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions templates/nextjs/public/hamburger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 49 additions & 30 deletions templates/nextjs/src/app/faucet/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from "@/components/Button";
import { Input } from "@/components/Input";
import { useActiveWallet } from "@/hooks/useActiveWallet";
import { useFaucet } from "@/hooks/useFaucet";
import { CURRENT_ENVIRONMENT, Environments, TESTNET_FAUCET_LINK } from "@/lib";
import { bn } from "fuels";
import { useEffect, useState } from "react";
import toast from "react-hot-toast";
Expand Down Expand Up @@ -50,36 +51,54 @@ export default function Faucet() {

return (
<>
<h3 className="text-2xl font-semibold">Local Faucet</h3>

<div className="flex gap-4 items-center">
<label htmlFor="receiver-address-input" className="text-gray-400">
Receiving address:
</label>
<Input
className="w-full"
value={receiverAddress}
onChange={(e) => setReceiverAddress(e.target.value)}
placeholder="0x..."
id="receiver-address-input"
/>
</div>

<div className="flex gap-4 items-center">
<label htmlFor="amount-input" className="text-gray-400">
Amount (ETH):
</label>
<Input
className="w-full"
value={amountToSend}
onChange={(e) => setAmountToSend(e.target.value)}
placeholder="5"
type="number"
id="amount-input"
/>
</div>

<Button onClick={sendFunds}>Send Funds</Button>
{CURRENT_ENVIRONMENT === Environments.LOCAL && (
<>
<h3 className="text-2xl font-semibold">Local Faucet</h3>

<div className="flex gap-4 items-center">
<label htmlFor="receiver-address-input" className="text-gray-400">
Receiving address:
</label>
<Input
className="w-full"
value={receiverAddress}
onChange={(e) => setReceiverAddress(e.target.value)}
placeholder="0x..."
id="receiver-address-input"
/>
</div>

<div className="flex gap-4 items-center">
<label htmlFor="amount-input" className="text-gray-400">
Amount (ETH):
</label>
<Input
className="w-full"
value={amountToSend}
onChange={(e) => setAmountToSend(e.target.value)}
placeholder="5"
type="number"
id="amount-input"
/>
</div>

<Button onClick={sendFunds}>Send Funds</Button>
</>
)}

{CURRENT_ENVIRONMENT === Environments.TESTNET && (
<>
<iframe
src={
wallet
? `${TESTNET_FAUCET_LINK}?address=${wallet.address.toB256()}`
: TESTNET_FAUCET_LINK
}
title="faucet"
className="w-full h-screen overflow-scroll"
/>
</>
)}
</>
);
}
4 changes: 4 additions & 0 deletions templates/nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
FuelWalletDevelopmentConnector,
FueletWalletConnector,
WalletConnectConnector,
SolanaConnector,
} from "@fuels/connectors";
import { NODE_URL } from "@/lib";
import { ActiveWalletProvider } from "@/hooks/useActiveWallet";
Expand Down Expand Up @@ -70,6 +71,9 @@ export default function RootLayout({ children }: RootLayoutProps) {
new BakoSafeConnector(),
new FueletWalletConnector(),
new FuelWalletDevelopmentConnector(),
new SolanaConnector({
fuelProvider: providerToUse,
}),
],
}}
>
Expand Down
106 changes: 3 additions & 103 deletions templates/nextjs/src/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,8 @@
import toast, { Toaster } from "react-hot-toast";
import { Link } from "./Link";
import { Button } from "./Button";
import { CURRENT_ENVIRONMENT, NODE_URL, TESTNET_FAUCET_LINK } from "@/lib";
import { useConnectUI, useDisconnect } from "@fuels/react";
import { WalletDisplay } from "./WalletDisplay";
import { useBrowserWallet } from "@/hooks/useBrowserWallet";
import { useActiveWallet } from "@/hooks/useActiveWallet";
import { useFaucet } from "@/hooks/useFaucet";
import { Toaster } from "react-hot-toast";
import Head from "next/head";
import { bn } from "fuels";
import { Navbar } from "./Navbar";

export const Layout = ({ children }: { children: React.ReactNode }) => {
const { faucetWallet } = useFaucet();

const {
wallet: browserWallet,
isConnected: isBrowserWalletConnected,
network: browserWalletNetwork,
} = useBrowserWallet();

const { connect } = useConnectUI();
const { disconnect } = useDisconnect();

const { wallet, refreshWalletBalance, walletBalance } = useActiveWallet();

const topUpWallet = async () => {
if (!wallet) {
return console.error("Unable to topup wallet because wallet is not set.");
}

/**
* If the current environment is local, transfer 5 ETH to the wallet
* from the local faucet wallet
*/
if (CURRENT_ENVIRONMENT === "local") {
if (!faucetWallet) {
return toast.error("Faucet wallet not found.");
}

const tx = await faucetWallet?.transfer(
wallet.address,
bn.parseUnits("5"),
);
await tx?.waitForResult();

toast.success("Wallet topped up!");

return await refreshWalletBalance?.();
}

// If the current environment is testnet, open the testnet faucet link in a new tab
if (CURRENT_ENVIRONMENT === "testnet") {
return window.open(
`${TESTNET_FAUCET_LINK}?address=${wallet.address.toAddress()}`,
"_blank",
);
}
};

const showTopUpButton = walletBalance?.lt(bn.parseUnits("5"));

const showAddNetworkButton =
browserWallet &&
browserWalletNetwork &&
browserWalletNetwork?.url !== NODE_URL;

const tryToAddNetwork = () => {
return alert(
`Please add the network ${NODE_URL} to your Fuel wallet, or swtich to it if you have it already, and refresh the page.`,
);
};

return (
<>
<Head>
Expand All @@ -79,39 +11,7 @@ export const Layout = ({ children }: { children: React.ReactNode }) => {
</Head>
<Toaster />
<div className="flex flex-col">
<nav className="flex justify-between items-center p-4 bg-black text-white gap-6">
<Link href="/">Home</Link>

<Link
href={
CURRENT_ENVIRONMENT === "local" ? "/faucet" : TESTNET_FAUCET_LINK
}
target={CURRENT_ENVIRONMENT === "local" ? "_self" : "_blank"}
>
Faucet
</Link>

{isBrowserWalletConnected && (
<Button onClick={disconnect}>Disconnect Wallet</Button>
)}
{!isBrowserWalletConnected && (
<Button onClick={connect}>Connect Wallet</Button>
)}

{showAddNetworkButton && (
<Button onClick={tryToAddNetwork} className="bg-red-500">
Wrong Network
</Button>
)}

<div className="ml-auto">
<WalletDisplay />
</div>

{showTopUpButton && (
<Button onClick={() => topUpWallet()}>Top-up Wallet</Button>
)}
</nav>
<Navbar />

<div className="min-h-screen items-center p-24 flex flex-col gap-6">
{children}
Expand Down
Loading

0 comments on commit 5c99b49

Please sign in to comment.