Skip to content

Commit

Permalink
Merge branch 'master' into dp/create-fuels-mobile-friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaiwat10 committed Aug 29, 2024
2 parents a2ddb07 + e87b51b commit ab2d389
Show file tree
Hide file tree
Showing 7 changed files with 306 additions and 165 deletions.
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
295 changes: 190 additions & 105 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

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
4 changes: 4 additions & 0 deletions templates/vite/src/routes/__root.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 { ActiveWalletProvider } from "../hooks/useActiveWallet";

Expand Down Expand Up @@ -60,6 +61,9 @@ export const Route = createRootRoute({
new BakoSafeConnector(),
new FueletWalletConnector(),
new FuelWalletDevelopmentConnector(),
new SolanaConnector({
fuelProvider: providerToUse,
}),
],
}}
>
Expand Down
79 changes: 49 additions & 30 deletions templates/vite/src/routes/faucet.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useFaucet } from "../hooks/useFaucet";
import { bn } from "fuels";
import { useEffect, useState } from "react";
import toast from "react-hot-toast";
import { CURRENT_ENVIRONMENT, Environments, TESTNET_FAUCET_LINK } from "../lib";

export const Route = createLazyFileRoute("/faucet")({
component: Index,
Expand Down Expand Up @@ -53,36 +54,54 @@ function Index() {

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"
/>
</>
)}
</>
);
}

0 comments on commit ab2d389

Please sign in to comment.