Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3ba36f5
feat: add Miden mainnet widget demo
codex Oct 21, 2026
a43eb1b
fix: consume buildable Flows Git package
codex Oct 21, 2026
da3f685
fix: wire widget to runtime Miden flows
codex Oct 21, 2026
f33b8bb
fix(demo): allow production preview host
codex Oct 21, 2026
3546611
fix: expose Miden funding on mainnet
codex Oct 21, 2026
7c7ed42
fix(demo): route earn markets through deployment proxy
codex Oct 21, 2026
a847cec
fix(demo): use absolute live markets endpoint
codex Oct 21, 2026
95e275b
fix(widget): guard Miden runtime and quote readiness
codex Oct 21, 2026
0e9e2bb
fix(widget): allow private Miden funding accounts
codex Oct 21, 2026
c1d0860
feat(demo): add local EVM private key signer
Man-Jain Oct 21, 2026
58eba18
Merge demo local signer commit 42c0156 into miden-mainnet-prep
Man-Jain Oct 21, 2026
b791367
feat: prepare Miden mainnet widget demo
Abhimanyu121 Oct 26, 2026
29f8427
fix: complete Miden earn and withdrawal handling
Abhimanyu121 Oct 26, 2026
395f058
chore: update epoch SDK dependencies
Abhimanyu121 Oct 28, 2026
38ab855
miden mainnet changes
jasspreetbawa13 Oct 28, 2026
e518e04
test: evaluate demo config factory in mainnet check
jasspreetbawa13 Oct 28, 2026
60016d0
Add packages
Man-Jain Oct 28, 2026
e8c0f93
Add Robinhood and Miden USDG to widget demo
Man-Jain Oct 28, 2026
141cdf9
Switch Polygon demo RPC to PublicNode
Man-Jain Oct 29, 2026
f89e2b8
Add update
Man-Jain Oct 29, 2026
3d10ae0
Add miden-mainnet prep
Man-Jain Nov 1, 2026
050bca7
Merge branch 'main' into miden-mainnet-prep
Man-Jain Nov 1, 2026
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: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ dist/
*.log
.env
./demo/.env
# local pnpm link override (do not commit)
pnpm-workspace.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const config = createConfig({
[base.id]: http("https://mainnet.base.org"),
[optimism.id]: http("https://mainnet.optimism.io"),
[arbitrum.id]: http("https://arb1.arbitrum.io/rpc"),
[polygon.id]: http("https://polygon.lava.build"),
[polygon.id]: http("https://polygon-bor-rpc.publicnode.com"),
},
});

Expand Down Expand Up @@ -340,7 +340,7 @@ Useful Earn props: `earnDefaultTab` (`'deposit'`|`'withdraw'`), `earnHideTabs`,
| `toAmount` (flat pay) | `string` | Human / decimal | `"0.15"` |
| `intent.requiredAmount` | `bigint` | Atomic (smallest unit) | `5_000_000n` (5 USDC) |

**Built-in registry.** The widget bundles common stablecoins + WETH across Ethereum, Base, Optimism, Polygon, Arbitrum (and Sepolia testnets). For flat-pay with a registry token you can omit `toTokenSymbol`/`toTokenDecimals`. For anything else, pass them.
**Built-in registry.** The widget bundles common stablecoins, WETH, and native ETH across Ethereum, Base, Optimism, Arbitrum, and supported ETH testnets. Polygon keeps its native asset separate. WETH remains an ERC-20 and can be selected alongside ETH. Native ETH uses the zero-address token sentinel and 18 decimals; balances use the wallet's native balance, and deposits send ETH as transaction value without ERC-20 approval. Keep ETH available for network fees. Pay, Swap, Earn deposits, and Smart Withdraw support ETH when the selected route is available. For flat-pay with a registry token you can omit `toTokenSymbol`/`toTokenDecimals`. For anything else, pass them.

You can read the registries yourself:

Expand Down
21 changes: 15 additions & 6 deletions demo/.env
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# VITE_EPOCH_API_BASE_URL=https://testnet-dev.epochprotocol.xyz
VITE_EPOCH_API_BASE_URL=https://mainnet-api.epochprotocol.xyz
VITE_TESTNET_API_BASE_URL=https://testnet-dev.epochprotocol.xyz
VITE_TESTNET_API_BASE_URL=http://localhost:3000
VITE_POSITIONS_API_BASE_URL=http://positions-testnet-dev.epochprotocol.xyz
VITE_TESTNET_POSITIONS_API_BASE_URL=http://localhost:4024
VITE_POSITIONS_API_BASE_URL=https://positions-mainnet.epochprotocol.xyz
VITE_TESTNET_POSITIONS_API_BASE_URL=https://positions-mainnet.epochprotocol.xyz

# Miden testnet endpoints.
VITE_MIDEN_RPC_URL=https://rpc.testnet.miden.io
# Miden mainnet endpoints.
VITE_MIDEN_RPC_URL=https://rpc.cedar.miden.io
VITE_MIDEN_NOTE_TRANSPORT_URL=https://transport.miden.io


# VITE_EPOCH_API_BASE_URL=http://localhost:3000
# VITE_TESTNET_API_BASE_URL=http://localhost:3000
# VITE_POSITIONS_API_BASE_URL=https://positions-mainnet.epochprotocol.xyz
# VITE_TESTNET_POSITIONS_API_BASE_URL=http://localhost:4024

# # Miden mainnet endpoints.
# VITE_MIDEN_RPC_URL=https://rpc.testnet.miden.io
# VITE_MIDEN_NOTE_TRANSPORT_URL=https://transport.miden.io
27 changes: 23 additions & 4 deletions demo/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
# Epoch services for the local demo.
# Local Epoch services. The allocator forwards quotes to local SIO on port 8080,
# which selects the local 1delta adapter. Hosted deployments can use /allocator.
VITE_EPOCH_API_BASE_URL=http://localhost:3000
VITE_TESTNET_API_BASE_URL=http://localhost:3000
VITE_EARN_SOLVER_URL=http://localhost:3011
VITE_POSITIONS_API_BASE_URL=http://localhost:4023
VITE_TESTNET_POSITIONS_API_BASE_URL=http://localhost:4024

# Miden testnet endpoints.
VITE_MIDEN_RPC_URL=https://rpc.testnet.miden.io
VITE_MIDEN_NOTE_TRANSPORT_URL=https://transport.miden.io
# Miden mainnet note transport (also the runtime default).
VITE_MIDEN_NOTE_TRANSPORT_URL=https://transport.cedar.miden.io

# Mainnet defaults come from @epoch-protocol/epoch-flows-sdk. Override only for diagnostics.
# VITE_MIDEN_RPC_URL=https://rpc.cedar.miden.io

# Base uses https://mainnet.base.org without a key. Optional keyed Ankr override:
# VITE_ANKR_API_KEY=

# Optional Infura RPC for all configured EVM chains through the Vite proxy.
# Enabled automatically when INFURA_API_KEY is present. Keep the credential
# in ignored .env.local; do not prefix INFURA_API_KEY with VITE_.
# INFURA_API_KEY=<base64-encoded key:secret>
# Miden uses its own RPC; Robinhood is not supported by this Infura proxy.

# Robinhood uses its own public RPCs, including when Infura is enabled.
# Optional provider overrides:
# VITE_ROBINHOOD_RPC_URL=https://rpc.mainnet.chain.robinhood.com
# VITE_ROBINHOOD_TESTNET_RPC_URL=https://rpc.testnet.chain.robinhood.com
3 changes: 2 additions & 1 deletion demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
dist/
.DS_Store
*.log
.env
.env
.env.local
46 changes: 34 additions & 12 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,42 @@ pnpm run typecheck

Copy `.env.example` to `.env`, then set the local service URLs as needed.

| Variable | Purpose |
|----------|---------|
| `VITE_EPOCH_API_BASE_URL` | Epoch allocator / API base URL (default `http://0.0.0.0:3000`) |
| `VITE_ALLOCATOR_URL` | Fallback if `VITE_EPOCH_API_BASE_URL` is unset |
| `VITE_MIDEN_RPC_URL` | Miden testnet RPC URL (`https://rpc.testnet.miden.io`) |
| `VITE_MIDEN_NOTE_TRANSPORT_URL` | Miden testnet note transport URL (`https://transport.miden.io`) |
| `VITE_MIDENSCAN_URL` | Optional Miden explorer base (Advanced tab) |
| Variable | Purpose |
| ------------------------------- | ------------------------------------------------------------------ |
| `VITE_EPOCH_API_BASE_URL` | Local allocator: `http://localhost:3000`; forwards to SIO on port 8080 |
| `VITE_EARN_SOLVER_URL` | Local 1delta adapter: `http://localhost:3011` |
| `VITE_POSITIONS_API_BASE_URL` | Local 1delta positions API: `http://localhost:4023` |
| `VITE_TESTNET_API_BASE_URL` | Local testnet allocator: `http://localhost:3000` |
| `VITE_TESTNET_POSITIONS_API_BASE_URL` | Local dummy-lending positions API: `http://localhost:4024` |
| `VITE_MIDEN_RPC_URL` | Optional Miden mainnet RPC override (default Cedar from Flows SDK) |
| `VITE_MIDEN_NOTE_TRANSPORT_URL` | Mainnet note transport (default `https://transport.cedar.miden.io`) |
| `VITE_ANKR_API_KEY` | Optional Ankr Base RPC key; without it, Base uses public `https://mainnet.base.org` |
| `INFURA_API_KEY` | Server-only base64 `key:secret` credential in ignored `.env.local`; enables Infura for all configured EVM chains |
| Miden explorer | Midenscan mainnet from Flows SDK |

Open `http://localhost:5175/widget/` for the local demo. The service URLs above target local processes; the blockchain RPC and note transport URLs still target Cedar/Base so mainnet asset and position data remain available. Start the local backend services before requesting an Earn quote. Testing a mainnet deposit still requires an explicit wallet transaction.

## Where to copy from

| Path | Use |
|------|-----|
| [`src/pay/scenarios.ts`](src/pay/scenarios.ts) | Example `intent` payloads for Pay |
| [`src/earn/`](src/earn/) | Market list, search filter, APR preview, `buildEarnDepositProps` |
| [`src/app/App.tsx`](src/app/App.tsx) | Wiring `EpochIntentWidget` + `api.baseUrl` + callbacks |
With `INFURA_API_KEY` set, Wagmi, wallet chain metadata, and widget balance reads
share `/widget/rpc/*` endpoints for Ethereum, Base, Optimism, Polygon, Arbitrum,
and the configured Sepolia networks. The Vite dev/preview server adds Infura
authentication; the browser receives only relative paths. Static hosting needs
an equivalent server proxy. Miden keeps its native RPC, and Robinhood requires
its own public RPCs (mainnet `4663`, testnet `46630`) because this Infura
configuration does not support it. Set `VITE_ROBINHOOD_RPC_URL` or
`VITE_ROBINHOOD_TESTNET_RPC_URL` to override them. Both networks are available
in wallet switching and the local signer, and in the widget's chain/token pickers.
Mainnet offers USDG, USDe and WETH; testnet offers the graph's test tokens.

Miden mainnet includes USDG (6 decimals), faucet
`mm1ar7rgznnerajt52p9ul6rltd8g039qsa`, in the Pay/Swap and Earn token pickers.
The Advanced bridge remains the Base USDC/USDCX example.

| Path | Use |
| ---------------------------------------------- | ---------------------------------------------------------------- |
| [`src/pay/scenarios.ts`](src/pay/scenarios.ts) | Example `intent` payloads for Pay |
| [`src/earn/`](src/earn/) | Market list, search filter, APR preview, `buildEarnDepositProps` |
| [`src/app/App.tsx`](src/app/App.tsx) | Wiring `EpochIntentWidget` + `api.baseUrl` + callbacks |

Earn markets are **static demo data** in [`src/earn/earnMarkets.ts`](src/earn/earnMarkets.ts). Replace with your allocator when you have a real endpoint.
21 changes: 11 additions & 10 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"dev": "pnpm --dir .. build:css && vite",
"build": "pnpm --dir .. build:css && vite build",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@epoch-protocol/epoch-commons-sdk": "file:../../epoch-commons-sdk",
"@epoch-protocol/epoch-intents-sdk": "^1.0.38",
"@epoch-protocol/epoch-intent-widget": "file:../",
"@miden-sdk/miden-sdk": "0.16.0",
"@miden-sdk/miden-wallet-adapter-base": "0.16.0",
"@miden-sdk/miden-wallet-adapter-react": "0.16.0",
"@miden-sdk/react": "0.16.0",
"@epoch-protocol/epoch-commons-sdk": "2.1.0",
"@epoch-protocol/epoch-flows-sdk": "file:../../epoch-flows-sdk",
"@epoch-protocol/epoch-intent-widget": "workspace:*",
"@epoch-protocol/epoch-intents-sdk": "2.1.0",
"@miden-sdk/miden-sdk": "0.17.5",
"@miden-sdk/miden-wallet-adapter-base": "0.17.5",
"@miden-sdk/miden-wallet-adapter-react": "0.17.5",
"@miden-sdk/react": "0.17.5",
"@rainbow-me/rainbowkit": "^2.2.9",
"@tanstack/react-query": "^5.90.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sonner": "^2.0.3",
"viem": "^2.42.1",
"viem": "^2.57.13",
"wagmi": "^2.9.0"
},
"devDependencies": {
Expand Down
92 changes: 92 additions & 0 deletions demo/src/RuntimeApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { useState } from "react";
import { WagmiProvider, createConfig, http } from "wagmi";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { RainbowKitProvider, getDefaultWallets } from "@rainbow-me/rainbowkit";
import { Toaster } from "sonner";
import { getDemoChains, getDemoRpcUrls } from "./config/rpc";
import { AllowedPrivateData } from "@miden-sdk/miden-wallet-adapter-base";
import { MidenFiSignerProvider } from "@miden-sdk/miden-wallet-adapter-react";
import { MidenProvider } from "@miden-sdk/react";
import {
themeToCssVars,
LIGHT_THEME,
} from "@epoch-protocol/epoch-intent-widget";
import App from "./app/App";
import type { DemoNetwork } from "./app/AppShell";
import { MIDEN_MAINNET } from "./config/miden-mainnet";
import { MIDEN_TESTNET } from "./config/miden-testnet";
import {
MIDEN_MAINNET_WALLET_NETWORK,
MIDEN_TESTNET_WALLET_NETWORK,
} from "./miden/lib/mainnet-wallet-compat";
import { localSigner } from "./wallet/local-signer";

// Project the library's `--epoch-*` design tokens onto `:root` so Tailwind
// utilities aliased in `index.css` (`bg-canvas`, `text-fg`, `border-line`, …)
// resolve everywhere — including portalled modals rendered into
// `document.body`. We write to `document.documentElement.style` instead of a
// wrapper `<div style={...}>` because portal children sit outside the React
// tree and can't inherit from a JSX ancestor.
{
const vars = themeToCssVars(LIGHT_THEME) as Record<string, string>;
for (const [key, value] of Object.entries(vars)) {
document.documentElement.style.setProperty(key, value);
}
}

const { connectors } = getDefaultWallets({
appName: "EpochIntentWidget Demo",
projectId: "demo", // WalletConnect project ID — replace with a real one for WC support
});

const rpcUrls = getDemoRpcUrls(import.meta.env);
const config = createConfig({
connectors: [...connectors, localSigner()],
chains: getDemoChains(rpcUrls),
transports: Object.fromEntries(
Object.entries(rpcUrls).map(([chainId, url]) => [Number(chainId), http(url)]),
),
ssr: false,
});

const queryClient = new QueryClient();

export default function RuntimeApp() {
const [network, setNetwork] = useState<DemoNetwork>("mainnet");
const midenConfig =
network === "testnet"
? {
rpcUrl: MIDEN_TESTNET.rpcUrl,
noteTransportUrl: MIDEN_TESTNET.noteTransportUrl,
}
: {
rpcUrl:
import.meta.env.VITE_MIDEN_RPC_URL?.trim() || MIDEN_MAINNET.rpcUrl,
noteTransportUrl:
import.meta.env.VITE_MIDEN_NOTE_TRANSPORT_URL?.trim() ||
MIDEN_MAINNET.noteTransportUrl,
};

return (
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider>
<MidenProvider key={network} config={midenConfig}>
<MidenFiSignerProvider
network={
network === "testnet"
? MIDEN_TESTNET_WALLET_NETWORK
: MIDEN_MAINNET_WALLET_NETWORK
}
appName="Epoch Intent Widget Demo"
allowedPrivateData={AllowedPrivateData.Assets}
>
<App network={network} onNetworkChange={setNetwork} />
</MidenFiSignerProvider>
</MidenProvider>
<Toaster position="bottom-right" closeButton duration={5000} />
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
);
}
Loading
Loading