Skip to content

Commit c51dc60

Browse files
authored
Merge pull request #345 from oasisprotocol/ml/rofl-paymaster-testnet-integration
ROFL Paymaster testnet integration
2 parents 5b419ea + 5e94643 commit c51dc60

File tree

32 files changed

+1687
-50
lines changed

32 files changed

+1687
-50
lines changed

.changelog/345.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ROFL Paymaster testnet integration

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ VITE_WALLET_CONNECT_PROJECT_ID=e3727c2e231abb0791d9cc90b55fb1e1
22
# VITE_ROFL_APP_BACKEND=http://localhost:8899
33
VITE_ROFL_APP_BACKEND=https://backend.rofl.app
44
VITE_FATHOM_SIDE_ID=ADZXERYI
5-
VITE_NITRO_PARTNER_ID=309
5+
VITE_FEATURE_FLAG_PAYMASTER=1

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_ROFL_APP_BACKEND=https://backend.rofl.app
2+
VITE_FEATURE_FLAG_PAYMASTER=

src/components/RainbowKitConnectButton/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useIsMobile } from '@oasisprotocol/ui-library/src/hooks/use-mobile'
1515
import { useNavigate } from 'react-router-dom'
1616
import { sapphire, sapphireTestnet } from 'viem/chains'
1717
import { useRoflAppBackendAuthContext } from '../../contexts/RoflAppBackendAuth/hooks.ts'
18+
import { ROFL_PAYMASTER_ENABLED_CHAINS_IDS } from '../../constants/rofl-paymaster-config.ts'
1819

1920
type ConnectButtonRenderProps = Parameters<React.ComponentProps<typeof ConnectButton.Custom>['children']>[0]
2021

@@ -37,8 +38,10 @@ const useNavigateToDashboardOnChainChange = ({ enabled }: { enabled: boolean })
3738
if (!enabled) return
3839

3940
if (chainId && chainId !== selectedChainId && isAuthenticated) {
40-
setSelectedChainId(chainId)
41-
navigate('/dashboard', { replace: true })
41+
if (!ROFL_PAYMASTER_ENABLED_CHAINS_IDS.includes(chainId.toString())) {
42+
setSelectedChainId(chainId)
43+
navigate('/dashboard', { replace: true })
44+
}
4245
}
4346
// eslint-disable-next-line react-hooks/exhaustive-deps -- selectedChainId should not trigger effect
4447
}, [enabled, chainId, navigate, isAuthenticated])

src/components/top-up/FaucetInfo/index.tsx renamed to src/components/rofl-paymaster/FaucetInfo/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { FC } from 'react'
2-
import { Card } from '@oasisprotocol/ui-library/src/components/ui/card.tsx'
2+
import { Card } from '@oasisprotocol/ui-library/src/components/ui/card'
33
import { ExternalLink } from 'lucide-react'
4-
import { FAUCET_URL } from '../../../constants/top-up-config.ts'
4+
import { FAUCET_URL } from '../../../constants/global'
55

66
export const FaucetInfo: FC = () => {
77
return (
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type { FC } from 'react'
2+
import { ChainNativeCurrency } from '../../../types/rofl-paymaster.ts'
3+
import { ROFL_PAYMASTER_ENABLED_CHAINS } from '../../../constants/rofl-paymaster-config.ts'
4+
5+
interface ChainTokenLogoProps {
6+
chainId?: number
7+
token?: ChainNativeCurrency
8+
}
9+
10+
// TODO: use the token logo once available
11+
export const TokenLogo: FC<ChainTokenLogoProps> = ({ chainId, token }) => {
12+
let displayToken: (ChainNativeCurrency & { logoURI?: string }) | undefined =
13+
token ||
14+
(chainId ? ROFL_PAYMASTER_ENABLED_CHAINS?.find(t => t.id === chainId)?.nativeCurrency : undefined)
15+
16+
displayToken = {
17+
name: '',
18+
symbol: '',
19+
decimals: 18,
20+
...(displayToken || {}),
21+
logoURI: '',
22+
}
23+
24+
return (
25+
<div className="w-4 h-4">
26+
{displayToken?.logoURI ? (
27+
<img
28+
src={displayToken.logoURI}
29+
alt={displayToken.symbol}
30+
className="w-full h-full rounded-full object-cover"
31+
/>
32+
) : (
33+
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
34+
<circle cx="8" cy="8" r="8" fill="currentColor" />
35+
</svg>
36+
)}
37+
</div>
38+
)
39+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
[rainbowkit]: Hacky way to hide Sapphire Mainnet from switch chain modal
3+
*/
4+
:global(body):global(.topUp) {
5+
[data-rk] {
6+
&& {
7+
[data-testid='rk-chain-option-23294'] {
8+
display: none;
9+
}
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)