diff --git a/demo/src/components/wallet/LocalSignerButton.tsx b/demo/src/components/wallet/LocalSignerButton.tsx index 22bd962..7ede3dc 100644 --- a/demo/src/components/wallet/LocalSignerButton.tsx +++ b/demo/src/components/wallet/LocalSignerButton.tsx @@ -37,8 +37,6 @@ export function LocalSignerButton({ network, className }: Props) { ) : ( diff --git a/demo/src/components/wallet/LocalSignerForm.tsx b/demo/src/components/wallet/LocalSignerForm.tsx index a6549c0..691cd7d 100644 --- a/demo/src/components/wallet/LocalSignerForm.tsx +++ b/demo/src/components/wallet/LocalSignerForm.tsx @@ -1,5 +1,5 @@ import { useId, useRef, useState, type FormEvent } from 'react'; -import { useChainId, useChains, useConnect } from 'wagmi'; +import { useAccount, useChainId, useChains, useConnect, useDisconnect } from 'wagmi'; import type { LocalSignerConnector } from '../../wallet/local-signer'; interface Props { @@ -18,6 +18,8 @@ export function LocalSignerForm({ connector, network, onConnected, onCancel }: P const [selectedChainId, setSelectedChainId] = useState(currentChainId); const chainId = chains.find((chain) => chain.id === selectedChainId)?.id ?? chains[0]?.id; const { connectAsync, isPending } = useConnect(); + const { connector: activeConnector, isConnected } = useAccount(); + const { disconnectAsync } = useDisconnect(); const [error, setError] = useState(); async function submit(event: FormEvent) { @@ -35,6 +37,9 @@ export function LocalSignerForm({ connector, network, onConnected, onCancel }: P } try { // The key never enters Wagmi/React Query mutation variables or storage. + if (isConnected && activeConnector) { + await disconnectAsync({ connector: activeConnector }); + } await connectAsync({ connector, chainId }); onConnected(); } catch { @@ -48,6 +53,7 @@ export function LocalSignerForm({ connector, network, onConnected, onCancel }: P

Use a development account. The key stays in this page’s memory until disconnect or reload. Signing happens locally without wallet confirmation popups. + {isConnected && ' Connecting will disconnect the current EVM wallet.'}

{ + const recipient = AccountId.fromHex('0x0e9089055fb6f54170bbf6159da028'); + assert.equal(recipient.isPublic(), false); + const faucet = Address.fromBech32( + 'mm1arnfum9xuwwlrvgvrefejwvlavn3vk24_qr7qqq9wr6w', + ).accountId(); + // Construct a note locally; no client, proof, or network submission is used. + const note = createP2IDNote({ + from: '0x5d38246547d94e5165c9e0fafbc667', + to: recipient, + assets: [{ token: faucet, amount: 10000n }], + type: 'public', + }); + assert.equal(note.metadata().noteType(), NoteType.Public); + assert.match(note.id().toString(), /^0x[0-9a-f]{64}$/); +}); diff --git a/package.json b/package.json index 69d4c97..fd4b465 100644 --- a/package.json +++ b/package.json @@ -90,5 +90,10 @@ "react", "wagmi", "viem" - ] + ], + "pnpm": { + "patchedDependencies": { + "@epoch-protocol/epoch-intents-sdk@1.0.39": "patches/@epoch-protocol__epoch-intents-sdk.patch" + } + } } diff --git a/patches/@epoch-protocol__epoch-intents-sdk.patch b/patches/@epoch-protocol__epoch-intents-sdk.patch new file mode 100644 index 0000000..658e278 --- /dev/null +++ b/patches/@epoch-protocol__epoch-intents-sdk.patch @@ -0,0 +1,53 @@ +diff --git a/dist/constants.js b/dist/constants.js +index e097c8340879d07992d7430128449e7e7376ea6b..7281fb79c30e251c924200949999f5e45c143911 100644 +--- a/dist/constants.js ++++ b/dist/constants.js +@@ -1,4 +1,4 @@ +-import { sepolia, baseSepolia, optimismSepolia, polygon, arbitrum, base, optimism, } from "viem/chains"; ++import { mainnet, sepolia, baseSepolia, optimismSepolia, polygon, arbitrum, base, optimism, } from "viem/chains"; + export { ALLOCATOR_ADDRESS, ARBITER_ADDRESS, getAllocatorAddress, getArbiterAddress, } from "@epoch-protocol/epoch-commons-sdk"; + // The Compact is deployed at the same address on all networks + export const COMPACT_ADDRESS = { +@@ -14,6 +14,7 @@ export const COMPACT_ADDRESS = { + 999999999: "0x00000000000000171ede64904551eeDF3C6C9788", + }; + export const SUPPORTED_CHAINS = [ ++ mainnet, + sepolia, + baseSepolia, + optimismSepolia, +diff --git a/dist/gasless/constants.js b/dist/gasless/constants.js +index 8c70395fc1440caffe22c7f4585edc99517dc106..338f9d1ef4051ad1fd745e53d17cf445bdf8b86b 100644 +--- a/dist/gasless/constants.js ++++ b/dist/gasless/constants.js +@@ -1,5 +1,9 @@ +-/** MetaMask DelegationManager (delegation-framework env on testnets). */ ++/** Canonical MetaMask Delegation Framework deployments on supported chains. */ + export const DELEGATION_MANAGER_ADDRESS = { ++ 1: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", ++ 10: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", ++ 137: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", ++ 8453: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", + 11155111: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", + 11155420: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", + 84532: "0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3", +@@ -8,6 +12,10 @@ export const DELEGATION_MANAGER_ADDRESS = { + /** EIP-7702 delegated-code prefix (implementation address after 0xef0100). */ + /** MetaMask EIP7702StatelessDeleGator — canonical delegate for gasless. */ + export const METAMASK_STATELESS_7702_IMPLEMENTATION = { ++ 1: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", ++ 10: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", ++ 137: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", ++ 8453: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", + 11155111: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", + 11155420: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", + 84532: "0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B", +@@ -29,7 +37,7 @@ export function isApproved7702Implementation(chainId, delegateAddress) { + return delegate === metamask || delegate === legacy; + } + export const GASLESS_SUPPORTED_CHAIN_IDS = [ +- 84532, 11155111, 11155420, 80002, ++ 1, 10, 137, 8453, 84532, 11155111, 11155420, 80002, + ]; + /** USDT-style tokens that need approve(0) before a new allowance on some chains. */ + export const APPROVE_RESET_TOKENS = { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 949c53d..7f7dbf4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + '@epoch-protocol/epoch-intents-sdk@1.0.39': + hash: mpz3uqsople55es62obpsuzahq + path: patches/@epoch-protocol__epoch-intents-sdk.patch + importers: .: @@ -16,7 +21,7 @@ importers: version: git+https://git@github.com:epochprotocol/epoch-flows-sdk.git#812a2c814dee1bc7b1b3c2ed20748372b79a2675(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3) '@epoch-protocol/epoch-intents-sdk': specifier: 1.0.39 - version: 1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3) + version: 1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3) clsx: specifier: ^2.1.1 version: 2.1.1 @@ -80,7 +85,7 @@ importers: version: file:(@tanstack/react-query@5.101.4(react@18.3.1))(bufferutil@4.1.0)(lucide-react@1.33.0(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(wagmi@2.19.5(@tanstack/query-core@5.101.4)(@tanstack/react-query@5.101.4(react@18.3.1))(@types/react@18.3.31)(bufferutil@4.1.0)(react@18.3.1)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76))(zod@3.25.76) '@epoch-protocol/epoch-intents-sdk': specifier: ^1.0.38 - version: 1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) + version: 1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) '@miden-sdk/miden-sdk': specifier: 0.17.5 version: 0.17.5 @@ -4397,7 +4402,7 @@ snapshots: '@epoch-protocol/epoch-flows-sdk@git+https://git@github.com:epochprotocol/epoch-flows-sdk.git#812a2c814dee1bc7b1b3c2ed20748372b79a2675(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76)': dependencies: '@epoch-protocol/epoch-commons-sdk': git+https://git@github.com:epochprotocol/epoch-commons-sdk.git#caa9e302c7d8d1e663f3f725fee3c57eab3269a0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) - '@epoch-protocol/epoch-intents-sdk': 1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) + '@epoch-protocol/epoch-intents-sdk': 1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) viem: 2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) transitivePeerDependencies: - bufferutil @@ -4409,7 +4414,7 @@ snapshots: '@epoch-protocol/epoch-flows-sdk@git+https://git@github.com:epochprotocol/epoch-flows-sdk.git#812a2c814dee1bc7b1b3c2ed20748372b79a2675(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3)': dependencies: '@epoch-protocol/epoch-commons-sdk': git+https://git@github.com:epochprotocol/epoch-commons-sdk.git#caa9e302c7d8d1e663f3f725fee3c57eab3269a0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3) - '@epoch-protocol/epoch-intents-sdk': 1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3) + '@epoch-protocol/epoch-intents-sdk': 1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3) viem: 2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3) transitivePeerDependencies: - bufferutil @@ -4422,7 +4427,7 @@ snapshots: dependencies: '@epoch-protocol/epoch-commons-sdk': git+https://git@github.com:epochprotocol/epoch-commons-sdk.git#caa9e302c7d8d1e663f3f725fee3c57eab3269a0(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@epoch-protocol/epoch-flows-sdk': git+https://git@github.com:epochprotocol/epoch-flows-sdk.git#812a2c814dee1bc7b1b3c2ed20748372b79a2675(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) - '@epoch-protocol/epoch-intents-sdk': 1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) + '@epoch-protocol/epoch-intents-sdk': 1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) '@tanstack/react-query': 5.101.4(react@18.3.1) clsx: 2.1.1 lucide-react: 1.33.0(react@18.3.1) @@ -4438,7 +4443,7 @@ snapshots: - utf-8-validate - zod - '@epoch-protocol/epoch-intents-sdk@1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76)': + '@epoch-protocol/epoch-intents-sdk@1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76)': dependencies: '@epoch-protocol/epoch-commons-sdk': 0.1.20(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76) '@metamask/smart-accounts-kit': 1.7.0(typescript@5.9.3)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@3.25.76))(zod@3.25.76) @@ -4450,7 +4455,7 @@ snapshots: - utf-8-validate - zod - '@epoch-protocol/epoch-intents-sdk@1.0.39(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3)': + '@epoch-protocol/epoch-intents-sdk@1.0.39(patch_hash=mpz3uqsople55es62obpsuzahq)(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3)': dependencies: '@epoch-protocol/epoch-commons-sdk': 0.1.20(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3) '@metamask/smart-accounts-kit': 1.7.0(typescript@5.9.3)(viem@2.55.19(bufferutil@4.1.0)(typescript@5.9.3)(utf-8-validate@5.0.10)(zod@4.4.3))(zod@4.4.3) diff --git a/src/components/EarnIntentWidget.tsx b/src/components/EarnIntentWidget.tsx index 00ba718..1906d42 100644 --- a/src/components/EarnIntentWidget.tsx +++ b/src/components/EarnIntentWidget.tsx @@ -101,11 +101,7 @@ export function EarnIntentWidget(props: EarnIntentWidgetProps) { earnFlow.stepLabel ?? (smartWithdraw ? "Routing…" : "Withdrawing…") ); if (earnFlow.isQuoting) return "Fetching quote…"; - if ( - ctaState.action === "switch" || - ctaState.action === "retry" || - ctaState.action === "disabled" - ) + if (ctaState.action !== "submit") return ctaState.label; // Idle + ready. "Confirm" (not "Review") — the click executes: it re-quotes // both legs and opens the wallet, it does not open a separate review step. @@ -256,4 +252,4 @@ export function EarnIntentWidget(props: EarnIntentWidgetProps) { {modalView.content} ); -} \ No newline at end of file +} diff --git a/src/components/earn/EarnWithdrawDetailView.tsx b/src/components/earn/EarnWithdrawDetailView.tsx index 27d88e7..56f7b0c 100644 --- a/src/components/earn/EarnWithdrawDetailView.tsx +++ b/src/components/earn/EarnWithdrawDetailView.tsx @@ -73,7 +73,7 @@ export function EarnWithdrawDetailView({ midenRecipientAccount={earnMiden?.accountId} midenFaucets={miden.destFaucets} buildError={withdrawBuildError} - quoteError={earnFlow.quoteError} + quoteError={earnFlow.error ?? earnFlow.quoteError} isQuoting={earnFlow.isQuoting} approxUsd={(() => { const usd = position.underlyingUsdValue; diff --git a/src/earn/use-earn-engine.ts b/src/earn/use-earn-engine.ts index 55bc368..cfd355d 100644 --- a/src/earn/use-earn-engine.ts +++ b/src/earn/use-earn-engine.ts @@ -499,6 +499,16 @@ export function useEarnEngine(props: EarnIntentWidgetProps) { (!earnMiden?.connected || !miden.quoteSource) ) return; + // A withdraw is sourced from the selected position's chain. Do not quote + // while the connected EVM wallet is still on another chain: the SDK would + // otherwise use the wallet chain as the intent origin and can construct a + // malformed route (for example, an Optimism token looked up on Base). + if ( + fundingSource === "evm" && + effectiveSourceChainId !== null && + chainId !== effectiveSourceChainId + ) + return; // Destination not yet moved off the position's own chain/token → no route // to quote. Skip until the user picks a real destination. if (isSmartWithdrawDegenerate) return; @@ -526,6 +536,7 @@ export function useEarnEngine(props: EarnIntentWidgetProps) { activeMarket, effectiveSourceChainId, effectiveSourceToken?.address, + chainId, address, earnTab, smartWithdraw, diff --git a/src/earn/use-earn-intent-flow.ts b/src/earn/use-earn-intent-flow.ts index 8382339..3cbc3ec 100644 --- a/src/earn/use-earn-intent-flow.ts +++ b/src/earn/use-earn-intent-flow.ts @@ -553,7 +553,14 @@ export function useEarnIntentFlow({ pendingQuoteRef.current = null; try { - const originChainId = params.isMidenDeposit ? input.sourceChainId : undefined; + // Withdrawals originate on the position's chain, not necessarily on + // the wallet's currently selected chain. Keeping this explicit avoids + // asking SIO/dex solvers to resolve a position token on the wrong EVM + // chain while the UI is switching networks. + const originChainId = + params.isMidenDeposit || input.tab === 'withdraw' + ? input.sourceChainId + : undefined; const sdk = createEarnIntentSdk(apiBaseUrl, walletClient, originChainId); const { taskTypeString, intentData } = await sdk.getTaskData({ @@ -625,6 +632,22 @@ export function useEarnIntentFlow({ try { const statusList = await sdk.getIntentStatus(address, nonceStr); if (!mountedRef.current) return; + const failed = Array.isArray(statusList) && statusList.some( + (s: { status?: string }) => s.status?.toLowerCase() === 'failed', + ); + if (failed) { + if (pollingRef.current) { + clearInterval(pollingRef.current); + pollingRef.current = null; + } + const failure = new Error('Intent execution failed on-chain. No deposit was completed.'); + setStatus('error'); + setError(failure.message); + setStatusProgress(0); + setActiveStep(0); + onErrorRef.current?.({ sessionId, error: failure }); + return; + } const isComplete = Array.isArray(statusList) ? statusList.some( (s: { status?: string }) => @@ -740,7 +763,7 @@ export function useEarnIntentFlow({ setStatus('submitting'); setActiveStep(1); setStatusProgress(10); - setStepLabel('Quoting withdrawal…'); + setStepLabel('Preparing withdrawal and bridge quote…'); onStartRef.current?.({ sessionId, mode: 'earn' }); swLog('submit:begin — executeActions(Withdraw)', { amount: input.amount, @@ -873,7 +896,9 @@ export function useEarnIntentFlow({ const submitParams = buildParams(input); const originChainId = pendingQuoteRef.current?.originChainId ?? - (submitParams.isMidenDeposit ? input.sourceChainId : undefined); + (submitParams.isMidenDeposit || input.tab === 'withdraw' + ? input.sourceChainId + : undefined); const sdk = createEarnIntentSdk(apiBaseUrl, walletClient, originChainId); let taskTypeString: string; diff --git a/src/earn/use-earn-miden.ts b/src/earn/use-earn-miden.ts index 9723ed8..17a2506 100644 --- a/src/earn/use-earn-miden.ts +++ b/src/earn/use-earn-miden.ts @@ -198,14 +198,14 @@ export function useEarnMiden({ // The withdrawal still executes on the EVM position chain; only the swap-leg // output is bridged. The connected adapter account is the recipient — the same - // one used to fund Miden deposits. + // one used to fund Miden deposits. Public P2ID notes can target either public + // or private accounts; recipient storage mode does not limit note delivery. const smartDest = useMemo(() => { if ( earnTab !== 'withdraw' || !smartWithdraw || smartDestChainId !== MIDEN_VIRTUAL_CHAIN_ID || !earnMiden?.accountId || - earnMiden.accountIsPublic === false || !smartDestTokenAddress ) { return undefined; @@ -224,7 +224,6 @@ export function useEarnMiden({ smartDestChainId, smartDestTokenAddress, earnMiden?.accountId, - earnMiden?.accountIsPublic, graphTokens, ]); diff --git a/test/earn-miden-mainnet.test.tsx b/test/earn-miden-mainnet.test.tsx index 745369e..a70120a 100644 --- a/test/earn-miden-mainnet.test.tsx +++ b/test/earn-miden-mainnet.test.tsx @@ -98,12 +98,14 @@ test("Miden earn submits once source metadata is ready", () => { ); }); -function PrivateMidenDestinationProbe() { +function PrivateMidenDestinationProbe({ + accountId = "0x0e9089055fb6f54170bbf6159da028", +}: { accountId?: string | null }) { const miden = useEarnMiden({ earnMiden: { enabled: true, connected: true, - accountId: "0x0e9089055fb6f54170bbf6159da028", + accountId, accountIsPublic: false, assets: [], createP2IDNote: async () => ({ success: false }), @@ -118,12 +120,20 @@ function PrivateMidenDestinationProbe() { smartDestTokenAddress: DEFAULT_MIDEN_FAUCET.faucetId, }); - return createElement("output", null, String(miden.smartDestNotReady)); + return createElement("output", null, + `${miden.smartDestNotReady}:${miden.smartDest?.recipientAccount ?? ""}`); } -test("private Miden accounts remain blocked as withdrawal destinations", () => { +test("private Miden recipients can receive public P2ID withdrawal notes", () => { assert.equal( renderToStaticMarkup(createElement(PrivateMidenDestinationProbe)), - "true", + "false:0x0e9089055fb6f54170bbf6159da028", + ); +}); + +test("a missing Miden recipient still blocks withdrawal preparation", () => { + assert.equal( + renderToStaticMarkup(createElement(PrivateMidenDestinationProbe, { accountId: null })), + "true:", ); });