Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8c78233
[gdpatchagent] fix(superfluid-campaign-web): follow AppKit active cha…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
8dd95c0
[gdpatchagent] fix(citizen-claim-widget): declarative per-chain claim…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
99876d1
[gdpatchagent] fix(citizen-claim-widget): load claimables for every s…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
949bdc3
[gdpatchagent] feat(citizen-claim-widget): accept address/chain/switc…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
a048f1e
[gdpatchagent] feat(core): thread override props through WalletContex…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
00f0fab
[gdpatchagent] feat(core): add address/chain/switch-chain override pr…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
c658b49
[gdpatchagent] refactor(embed): export DEFAULT_APPKIT_NETWORKS for ch…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
3adebac
[gdpatchagent] refactor(embed): re-export useAppKitNetwork and DEFAUL…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
11750ff
[gdpatchagent] fix(superfluid-campaign-widget): wire override props i…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
7279ad8
[gdpatchagent] feat(superfluid-campaign-widget): pass disconnectLabel…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
a46f15a
[gdpatchagent] feat(superfluid-campaign-widget): pass disconnectLabel…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
f1dd8af
[gdpatchagent] feat(superfluid-campaign-widget): support a configurab…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
88aa28a
[gdpatchagent] feat(superfluid-campaign-widget): accept address/chain…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
8de277c
[gdpatchagent] fix(core,citizen-claim-widget,superfluid-campaign-widg…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
e248ebe
[gdpatchagent] fix(citizen-claim-widget,superfluid-campaign-widget): …
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
07dec0f
[gdpatchagent] fix(citizen-claim-widget,superfluid-campaign-web): cle…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
0e7221a
[gdpatchagent] docs(citizen-claim-widget,superfluid-campaign-widget):…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
baed5d1
[gdpatchagent] fix(citizen-claim-widget): stop rethrowing handled swi…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
79eed90
[gdpatchagent] fix(citizen-claim-widget): add unsupported_chain statu…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
8715ebd
[gdpatchagent] fix(superfluid-campaign-widget): fix gardens-funding l…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
f05f878
[gdpatchagent] fix(citizen-claim-widget,core): fix custodial status-r…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
00d029c
[gdpatchagent] fix(citizen-claim-widget,superfluid-campaign-widget): …
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
e14d1a1
[gdpatchagent] fix(superfluid-campaign-web,superfluid-campaign-widget…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
ed76c51
[gdpatchagent] fix(citizen-claim-widget): fix conflicting unsupported…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
17faecf
[gdpatchagent] fix(citizen-claim-widget): surface switch-chain failur…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
0ed69d5
[gdpatchagent] fix(citizen-claim-widget,superfluid-campaign-widget): …
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
e77f788
[gdpatchagent] fix(core,citizen-claim-widget): add switch-chain timeo…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
b512ce0
[gdpatchagent] fix(superfluid-campaign-web): throw from switchChainOv…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
a001272
[gdpatchagent] fix(citizen-claim-widget): prioritize unsupported_chai…
goodbounties-nanoclaw-agent[bot] Aug 13, 2026
b27abc2
[gdpatchagent] fix(citizen-claim-widget,embed,superfluid-campaign-wid…
goodbounties-nanoclaw-agent[bot] Aug 13, 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
78 changes: 75 additions & 3 deletions apps/superfluid-campaign-web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,101 @@
import React, { useRef } from 'react'
import React, { useMemo, useRef } from 'react'
import { SuperfluidCampaignWidget } from '@goodwidget/superfluid-campaign-widget'
import type { EIP1193Provider } from '@goodwidget/core'
import {
DEFAULT_APPKIT_NETWORKS,
DefaultAppKitProvider,
useAppKit,
useAppKitAccount,
useAppKitNetwork,
useAppKitProvider,
} from '@goodwidget/embed/appkit-provider'
import { TamaguiProvider } from '@tamagui/core'
import { YStack, defaultConfig } from '@goodwidget/ui'

const DESKTOP_WIDGET_MAX_WIDTH = 960

/**
* Pressing the disconnect-menu item under AppKit opens AppKit's own Account
* view (see disconnectOverride below) rather than ending the session
* directly, so the button is labeled to match what it actually does.
*/
const APPKIT_DISCONNECT_LABEL = 'Network settings'

const SWITCH_CHAIN_MANUAL_SELECTION_ERROR = 'Select the network in the wallet dialog, then try again.'

function AppKitSuperfluidCampaignWidget() {
const { open } = useAppKit()
const { address } = useAppKitAccount()
const { address, status: accountStatus } = useAppKitAccount()
const { walletProvider } = useAppKitProvider<EIP1193Provider | undefined>('eip155')
const { chainId, switchNetwork, approvedCaipNetworkIds } = useAppKitNetwork()
const addressRef = useRef(address)
addressRef.current = address

// AppKit reports `address: undefined` both while it's still restoring a prior
// session ('connecting'/'reconnecting'/not yet reported) and once it has
// definitively resolved to "no wallet". Only the latter is a real override —
// during the unresolved window this stays `undefined` so the core provider's
// own EIP-1193 fallback tracking (rather than a premature "disconnected"
// override) covers the gap until AppKit reports a final status. `chainId`
// below is gated on the same flag so it doesn't fall back to a stale
// previously-tracked chain once the account is known to be disconnected.
const isAccountResolved = accountStatus === 'connected' || accountStatus === 'disconnected'

// AppKit's switchNetwork takes the network descriptor object, not a chain id,
// so this looks up the descriptor for whichever chain the widget wants to
// switch to. AppKit's own active-network state (chainId here) is always the
// source of truth for what's "current" — the widget never tracks it separately.
const appKitNetworksByChainId = useMemo(
() => new Map(DEFAULT_APPKIT_NETWORKS.map((network) => [Number(network.id), network])),
[],
)
Comment thread
L03TJ3 marked this conversation as resolved.
Comment thread
L03TJ3 marked this conversation as resolved.

// CAIP network ids are formatted like "eip155:122" — the widget's execute
// gating needs plain numeric chain ids. `undefined` (AppKit hasn't reported
// approved networks yet) is kept as `null`, meaning "no restriction known"
// rather than "nothing is available".
const availableChainIds = useMemo(
() =>
approvedCaipNetworkIds
? approvedCaipNetworkIds
.map((caipId) => Number(caipId.split(':')[1]))
.filter((id) => Number.isFinite(id))
: null,
[approvedCaipNetworkIds],
)

return (
<SuperfluidCampaignWidget
provider={walletProvider}
defaultTheme="dark"
contentMaxWidth={DESKTOP_WIDGET_MAX_WIDTH}
addressOverride={isAccountResolved ? (address ?? null) : undefined}
chainIdOverride={isAccountResolved ? (chainId == null ? null : Number(chainId)) : undefined}
availableChainIdsOverride={availableChainIds}
switchChainOverride={async (targetChainId) => {
const targetNetwork = appKitNetworksByChainId.get(targetChainId)
// Falling through to AppKit's own network-selection modal is the
// documented recovery path when a target chain has no direct
// programmatic descriptor here, or when switchNetwork itself fails
// (e.g. the connected wallet rejects the automatic switch request).
// The modal only lets the user attempt the switch themselves — it
// never confirms synchronously that one actually happened — so this
// throws rather than resolves, otherwise the caller (core's
// switchChain, and the claim widget's error handling built on top of
// it) would treat an opened modal as an already-finished switch.
if (!targetNetwork) {
await open({ view: 'Networks' })
throw new Error(SWITCH_CHAIN_MANUAL_SELECTION_ERROR)
}
try {
await switchNetwork(targetNetwork)
} catch {
await open({ view: 'Networks' })
throw new Error(SWITCH_CHAIN_MANUAL_SELECTION_ERROR)
}
}}
Comment thread
L03TJ3 marked this conversation as resolved.
disconnectLabel={APPKIT_DISCONNECT_LABEL}
disconnectIcon="settings"
connectOverride={async () => {
await open({ view: 'Connect' })
if (!addressRef.current) throw new Error('wallet_connect_cancelled')
Expand All @@ -35,7 +107,7 @@ function AppKitSuperfluidCampaignWidget() {
'flow-state-vote': 'https://ubi.gd/4fEqvrS',
'flow-state-funding': 'https://ubi.gd/4z2tH8y',
'gardens-donation': 'https://ubi.gd/4xhk4kv',
'gardens-funding': 'https:/ubi.gd/3TABl9O',
'gardens-funding': 'https://ubi.gd/3TABl9O',
'invite-users': 'https://ubi.gd/4xhYTyH',
'claim-ubi': 'https://ubi.gd/3RNtzJd',
}}
Expand Down
Loading
Loading