Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions demo/.env_example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Figment dApp token (app ID). Exposed to the client as import.meta.env.VITE_DAPP_TOKEN.
VITE_DAPP_TOKEN=d500a3f1bdc613c4ece8964f5c7b9f173393cf53b4eb4eadb520e80435c4ece3
48 changes: 48 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Figment Elements Demo

A simple demo app for the [Figment Elements](https://docs.figment.io/docs/elements) staking widget. It lets you try Ethereum (Hoodi) and Solana (Devnet) staking in an embeddable iframe.

## Getting started

### 1. Install dependencies

From the `demo` folder:

```bash
npm install
```


### 2. Set your Figment dApp token

Copy the example env file and add your token:

```bash
cp .env_example .env
```

Edit `.env` and set your Figment dApp token (app ID):

```
VITE_DAPP_TOKEN=your-figment-app-id
```


### 3. Run the demo

```bash
npm run dev
```

Open the URL shown in the terminal (usually `http://localhost:5173`) in your browser.

## What you can do

- **Protocol:** Switch between ETH (Hoodi) and SOL (Devnet).
- **Network:** Choose the network (e.g. Hoodi for Ethereum, Devnet for Solana).
- **Theme:** Toggle light, dark, or system theme.
- **Wallet:** Use the default wallet flow (WalletConnect for ETH, Solana Wallet Adapter for SOL) or a custom wallet.

The staking UI is loaded in an iframe from Figment; your token in `VITE_DAPP_TOKEN` identifies your app to that service.


4 changes: 2 additions & 2 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function App() {
id: "ethereum",
});
const [selectedNetwork, setSelectedNetwork] = React.useState<Network>({
name: "Mainnet",
id: "mainnet",
name: "Hoodi",
id: "hoodi",
});
const [theme, setTheme] = React.useState<"light" | "dark" | "system">(
"system"
Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function MainContent({
<Staking
appId={import.meta.env.VITE_DAPP_TOKEN}
protocol={selectedProtocol.id as "solana"}
network={selectedNetwork.id as "mainnet"}
network={selectedNetwork.id as "mainnet" | "hoodi"}
wallet={
walletType === "custom"
? customWalletConfigMap[
Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const protocols: Protocol[] = [

const networksByProtocol: Record<Protocol["id"], Network[]> = {
ethereum: [
{ name: "Holesky", id: "holesky" },
{ name: "Hoodi", id: "hoodi" },
{ name: "Mainnet", id: "mainnet", disabled: true },
],
solana: [
Expand Down
4 changes: 2 additions & 2 deletions demo/src/components/ToggleGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const getIcon = (value: string) => {
return <SolanaIcon className="w-5 h-5" />;
case "mainnet":
return <GlobeIcon className="w-4 h-4" />;
case "holesky":
case "hoodi":
case "devnet":
case "signet":
return <TestTubeIcon className="w-4 h-4 -rotate-45" />;
Expand All @@ -46,7 +46,7 @@ const shouldShowIcon = (value: string) => {
"babylon",
"solana",
"mainnet",
"holesky",
"hoodi",
"devnet",
"signet",
].includes(value);
Expand Down
8 changes: 8 additions & 0 deletions demo/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_DAPP_TOKEN: string;
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}
2 changes: 1 addition & 1 deletion src/elements/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enum Protocol {

enum EthereumNetwork {
mainnet = "mainnet",
holesky = "holesky",
hoodi = "hoodi",
}

enum BabylonNetwork {
Expand Down
Loading