Skip to content

Commit c3a8f31

Browse files
Feature/token acc v3 fix (#240)
* v3 reim fixes * fixes
1 parent 4561505 commit c3a8f31

File tree

12 files changed

+588
-32
lines changed

12 files changed

+588
-32
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,6 @@ yarn-error.log*
4444
# Sentry
4545
.sentryclirc
4646

47-
.vscode/settings.json
47+
.vscode/settings.json
48+
.claude
49+
.claude.local

components/App.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { useAsync } from 'react-async-hook'
4040
import { useVsrClient } from '../VoterWeightPlugins/useVsrClient'
4141
import { useRealmVoterWeightPlugins } from '@hooks/useRealmVoterWeightPlugins'
4242
import TermsPopupModal from './TermsPopup'
43+
import V2PromoModal from './V2PromoModal'
4344
import PlausibleProvider from 'next-plausible'
4445

4546
const Notifications = dynamic(() => import('../components/Notification'), {
@@ -326,16 +327,31 @@ export function AppContents(props: Props) {
326327
<ErrorBoundary>
327328
<ThemeProvider defaultTheme="Dark">
328329
<GatewayProvider>
329-
<div className="relative color-white z-10 text-center w-full py-2">
330-
Faster. Sharper. More. Yours.{' '}
331-
<a
332-
href="https://v2.realms.today"
333-
rel="noreferrer"
334-
target="_blank"
335-
className="underline"
336-
>
337-
Try Realms v2
338-
</a>
330+
<div className="v2-banner relative z-10 text-center w-full py-3">
331+
<div className="relative z-10 flex items-center justify-center gap-2 text-white font-medium">
332+
<span className="text-white/90">Faster. Sharper. More. Yours.</span>
333+
<a
334+
href="https://v2.realms.today"
335+
rel="noreferrer"
336+
target="_blank"
337+
className="inline-flex items-center gap-1 bg-white/20 hover:bg-white/30 px-3 py-1 rounded-full text-white font-semibold transition-all duration-200"
338+
>
339+
Try Realms v2
340+
<svg
341+
className="w-4 h-4"
342+
fill="none"
343+
stroke="currentColor"
344+
viewBox="0 0 24 24"
345+
>
346+
<path
347+
strokeLinecap="round"
348+
strokeLinejoin="round"
349+
strokeWidth={2}
350+
d="M13 7l5 5m0 0l-5 5m5-5H6"
351+
/>
352+
</svg>
353+
</a>
354+
</div>
339355
</div>
340356
<Telemetry></Telemetry>
341357
<NavBar />
@@ -346,6 +362,7 @@ export function AppContents(props: Props) {
346362
<DefiProvider>{props.children}</DefiProvider>
347363
</PageBodyContainer>
348364
<TermsPopupModal />
365+
<V2PromoModal />
349366
</GatewayProvider>
350367
</ThemeProvider>
351368
</ErrorBoundary>

components/TermsPopup.tsx

Lines changed: 91 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import Button, { SecondaryButton } from './Button'
33
import { useEffect, useState } from 'react'
44
import { useRouter } from 'next/router'
55

6+
const V2_PROMO_DISMISSED_KEY = 'v2-promo-dismissed'
7+
68
const TermsPopupModal = () => {
79
const [openModal, setOpenModal] = useState(true)
810
const [isClient, setIsClient] = useState(false)
@@ -25,8 +27,16 @@ const TermsPopupModal = () => {
2527
}
2628
})
2729

28-
const acceptTerms = () => {
30+
const acceptAndGoToV2 = () => {
31+
localStorage.setItem('accept-terms', 'true')
32+
localStorage.setItem(V2_PROMO_DISMISSED_KEY, 'true')
33+
window.open('https://v2.realms.today', '_blank')
34+
setOpenModal(false)
35+
}
36+
37+
const acceptAndStay = () => {
2938
localStorage.setItem('accept-terms', 'true')
39+
localStorage.setItem(V2_PROMO_DISMISSED_KEY, 'true')
3040
setOpenModal(false)
3141
}
3242

@@ -43,18 +53,87 @@ const TermsPopupModal = () => {
4353
onClose={() => setOpenModal(false)}
4454
bgClickClose={false}
4555
hideClose={true}
56+
sizeClassName="sm:max-w-lg"
4657
>
47-
<p className="text-justify">
48-
The operating entity of this site and owner of the related
49-
intellectual property has changed. The new operator is Realms Today
50-
Ltd. (the New Operator). We have accordingly amended the Terms and
51-
the Private Policy governing the relationship between our users and
52-
the New Operator. By clicking "accept", you represent and warrant
53-
that you agree to the revised Terms and Private Policy.
54-
</p>
55-
<div className="flex gap-4 mt-4 justify-center">
56-
<Button onClick={acceptTerms}>Accept</Button>
57-
<SecondaryButton onClick={rejectTerms}>Reject</SecondaryButton>
58+
{/* V2 Promo Section */}
59+
<div className="text-center mb-6 pb-6 border-b border-bkg-4">
60+
<div className="inline-flex items-center justify-center w-14 h-14 rounded-full bg-gradient-to-br from-[#7c3aed] to-[#6366f1] mb-3">
61+
<svg
62+
className="w-7 h-7 text-white"
63+
fill="none"
64+
stroke="currentColor"
65+
viewBox="0 0 24 24"
66+
>
67+
<path
68+
strokeLinecap="round"
69+
strokeLinejoin="round"
70+
strokeWidth={2}
71+
d="M13 10V3L4 14h7v7l9-11h-7z"
72+
/>
73+
</svg>
74+
</div>
75+
<h2 className="text-xl font-bold text-fgd-1 mb-1">
76+
Realms v2 is here
77+
</h2>
78+
<p className="text-fgd-3 text-sm mb-3">
79+
Faster, sharper, and built for you
80+
</p>
81+
<div className="flex flex-wrap justify-center gap-2">
82+
<div className="inline-flex items-center gap-2 text-sm text-green-400 bg-green-400/10 px-3 py-1.5 rounded-full">
83+
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
84+
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
85+
</svg>
86+
Treasury prices now available
87+
</div>
88+
<div className="inline-flex items-center gap-2 text-sm text-green-400 bg-green-400/10 px-3 py-1.5 rounded-full">
89+
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
90+
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
91+
</svg>
92+
All DAOs are there
93+
</div>
94+
</div>
95+
</div>
96+
97+
{/* Terms Section */}
98+
<div className="mb-6">
99+
<h3 className="text-sm font-semibold text-fgd-2 mb-2">Terms & Privacy Policy</h3>
100+
<p className="text-sm text-fgd-3 text-justify">
101+
The operating entity of this site and owner of the related
102+
intellectual property has changed. The new operator is Realms Today
103+
Ltd. (the New Operator). We have accordingly amended the Terms and
104+
the Private Policy governing the relationship between our users and
105+
the New Operator. By clicking &quot;accept&quot;, you represent and warrant
106+
that you agree to the revised Terms and Private Policy.
107+
</p>
108+
</div>
109+
110+
{/* CTA Buttons */}
111+
<div className="space-y-3">
112+
<Button
113+
className="w-full bg-gradient-to-r from-[#7c3aed] to-[#6366f1] hover:from-[#6d31d4] hover:to-[#5558e0]"
114+
onClick={acceptAndGoToV2}
115+
>
116+
<span className="flex items-center justify-center gap-2 text-white">
117+
Accept & Try Realms v2
118+
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
119+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 7l5 5m0 0l-5 5m5-5H6" />
120+
</svg>
121+
</span>
122+
</Button>
123+
<div className="flex gap-3">
124+
<SecondaryButton
125+
className="flex-1"
126+
onClick={acceptAndStay}
127+
>
128+
Accept & Stay on v1
129+
</SecondaryButton>
130+
<SecondaryButton
131+
className="flex-1 !text-red-400 hover:!text-red-300"
132+
onClick={rejectTerms}
133+
>
134+
Reject
135+
</SecondaryButton>
136+
</div>
58137
</div>
59138
</Modal>
60139
) : null}

components/V2PromoModal.tsx

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import Modal from './Modal'
2+
import Button, { SecondaryButton } from './Button'
3+
import { useEffect, useState } from 'react'
4+
5+
const STORAGE_KEY = 'v2-promo-dismissed'
6+
7+
const V2PromoModal = () => {
8+
const [isOpen, setIsOpen] = useState(false)
9+
const [isClient, setIsClient] = useState(false)
10+
11+
useEffect(() => {
12+
setIsClient(true)
13+
}, [])
14+
15+
useEffect(() => {
16+
if (typeof window !== 'undefined' && localStorage) {
17+
const isDismissed = localStorage.getItem(STORAGE_KEY) === 'true'
18+
const hasAcceptedTerms = localStorage.getItem('accept-terms') === 'true'
19+
20+
// Only show to existing users who already accepted terms
21+
// New users will see the combined Terms + V2 promo popup instead
22+
if (!isDismissed && hasAcceptedTerms) {
23+
// Small delay to not overwhelm user immediately
24+
const timer = setTimeout(() => setIsOpen(true), 1500)
25+
return () => clearTimeout(timer)
26+
}
27+
}
28+
}, [])
29+
30+
const dismissModal = () => {
31+
localStorage.setItem(STORAGE_KEY, 'true')
32+
setIsOpen(false)
33+
}
34+
35+
const goToV2 = () => {
36+
localStorage.setItem(STORAGE_KEY, 'true')
37+
window.open('https://v2.realms.today', '_blank')
38+
setIsOpen(false)
39+
}
40+
41+
if (!isClient || !isOpen) return null
42+
43+
return (
44+
<Modal
45+
isOpen={isOpen}
46+
onClose={dismissModal}
47+
sizeClassName="sm:max-w-lg"
48+
bgClickClose={true}
49+
>
50+
<div className="text-center">
51+
{/* Header with gradient */}
52+
<div className="mb-6">
53+
<div className="inline-flex items-center justify-center w-16 h-16 rounded-full bg-gradient-to-br from-[#7c3aed] to-[#6366f1] mb-4">
54+
<svg
55+
className="w-8 h-8 text-white"
56+
fill="none"
57+
stroke="currentColor"
58+
viewBox="0 0 24 24"
59+
>
60+
<path
61+
strokeLinecap="round"
62+
strokeLinejoin="round"
63+
strokeWidth={2}
64+
d="M13 10V3L4 14h7v7l9-11h-7z"
65+
/>
66+
</svg>
67+
</div>
68+
<h2 className="text-2xl font-bold text-fgd-1 mb-2">
69+
Realms v2 is here
70+
</h2>
71+
<p className="text-fgd-3">
72+
Experience the next generation of DAO governance
73+
</p>
74+
</div>
75+
76+
{/* Benefits list */}
77+
<div className="text-left space-y-3 mb-6">
78+
<div className="flex items-start gap-3">
79+
<div className="flex-shrink-0 w-5 h-5 rounded-full bg-green-500/20 flex items-center justify-center mt-0.5">
80+
<svg className="w-3 h-3 text-green-400" fill="currentColor" viewBox="0 0 20 20">
81+
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
82+
</svg>
83+
</div>
84+
<span className="text-fgd-2">Treasury prices now available</span>
85+
</div>
86+
<div className="flex items-start gap-3">
87+
<div className="flex-shrink-0 w-5 h-5 rounded-full bg-green-500/20 flex items-center justify-center mt-0.5">
88+
<svg className="w-3 h-3 text-green-400" fill="currentColor" viewBox="0 0 20 20">
89+
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
90+
</svg>
91+
</div>
92+
<span className="text-fgd-2">All DAOs are there</span>
93+
</div>
94+
<div className="flex items-start gap-3">
95+
<div className="flex-shrink-0 w-5 h-5 rounded-full bg-green-500/20 flex items-center justify-center mt-0.5">
96+
<svg className="w-3 h-3 text-green-400" fill="currentColor" viewBox="0 0 20 20">
97+
<path fillRule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clipRule="evenodd" />
98+
</svg>
99+
</div>
100+
<span className="text-fgd-2">Faster performance and improved UX</span>
101+
</div>
102+
</div>
103+
104+
{/* CTA buttons */}
105+
<div className="flex flex-col sm:flex-row gap-3 justify-center">
106+
<Button
107+
className="w-full sm:w-auto bg-gradient-to-r from-[#7c3aed] to-[#6366f1] hover:from-[#6d31d4] hover:to-[#5558e0]"
108+
onClick={goToV2}
109+
>
110+
<span className="flex items-center justify-center gap-2 text-white">
111+
Go to Realms v2
112+
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
113+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 7l5 5m0 0l-5 5m5-5H6" />
114+
</svg>
115+
</span>
116+
</Button>
117+
<SecondaryButton
118+
className="w-full sm:w-auto"
119+
onClick={dismissModal}
120+
>
121+
Maybe later
122+
</SecondaryButton>
123+
</div>
124+
</div>
125+
</Modal>
126+
)
127+
}
128+
129+
export default V2PromoModal

components/instructions/programs/mangoV4.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,6 +1872,48 @@ const instructions = () => ({
18721872
}
18731873
},
18741874
},
1875+
7395: {
1876+
name: 'Withdraw Insurance Fund',
1877+
accounts: [
1878+
{ name: 'Group' },
1879+
{ name: 'Admin' },
1880+
{ name: 'Insurance Vault' },
1881+
{ name: 'Destination' },
1882+
{ name: 'Token Program' },
1883+
],
1884+
getDataUI: async (
1885+
connection: Connection,
1886+
data: Uint8Array,
1887+
accounts: AccountMetaData[],
1888+
) => {
1889+
const args = await getDataObjectFlattened<any>(connection, data)
1890+
const group = accounts[0].pubkey
1891+
const client = await getClient(connection)
1892+
const mangoGroup = await getGroupForClient(client, group)
1893+
const insuranceMint = mangoGroup.insuranceMint
1894+
const mintInfo = await tryGetMint(connection, insuranceMint)
1895+
const tokenInfo = tokenPriceService.getTokenInfo(insuranceMint.toBase58())
1896+
1897+
try {
1898+
return (
1899+
<div>
1900+
<div>
1901+
Amount:{' '}
1902+
{mintInfo?.account.decimals
1903+
? formatNumber(
1904+
toUiDecimals(args.amount, mintInfo?.account.decimals),
1905+
)
1906+
: args.amount}{' '}
1907+
{tokenInfo?.symbol || 'tokens'}
1908+
</div>
1909+
</div>
1910+
)
1911+
} catch (e) {
1912+
console.log(e)
1913+
return <div>{JSON.stringify(data)}</div>
1914+
}
1915+
},
1916+
},
18751917
})
18761918

18771919
export const MANGO_V4_INSTRUCTIONS = {

components/instructions/tools.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,11 +516,24 @@ const MNGO_AUXILIARY_TOKEN_ACCOUNTS = [
516516
owner: 'FRYXAjyVnvXja8chgdq47qL3CKoyBjUg4ro7M7QQn1aD',
517517
accounts: ['24frxVoDzo7bAimBU6rDhB1McxWNvzX9qddPMSv9VACZ'],
518518
},
519-
//
519+
//v3 reimbursement - empty accounts array means include all token accounts from this owner
520+
{
521+
owner: 'D3SMRX2tBq5MYRuis3i4kbVt1fdQ5TkX1xfxhUpZ2pN3',
522+
accounts: [],
523+
},
524+
]
525+
526+
// v3 reimbursement accounts - shared across Mango realms
527+
const MNGO_V3_REIMBURSEMENT_ACCOUNTS = [
528+
{
529+
owner: 'D3SMRX2tBq5MYRuis3i4kbVt1fdQ5TkX1xfxhUpZ2pN3',
530+
accounts: [],
531+
},
520532
]
521533

522534
export const AUXILIARY_TOKEN_ACCOUNTS = {
523535
Mango: MNGO_AUXILIARY_TOKEN_ACCOUNTS,
536+
'Mango Developer Council v2': MNGO_V3_REIMBURSEMENT_ACCOUNTS,
524537
}
525538

526539
export const HIDDEN_TREASURES = [...HIDDEN_MNGO_TREASURES]

0 commit comments

Comments
 (0)