Skip to content

Commit 36a617a

Browse files
tomiirCopilot
andauthored
feat: debug - add manual sa version override (#5311)
Co-authored-by: Copilot <[email protected]>
1 parent bd86560 commit 36a617a

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { useEffect, useState } from 'react'
2+
3+
import { Flex, FormControl, FormLabel, HStack, Radio, RadioGroup, Switch } from '@chakra-ui/react'
4+
5+
const SmartAccountVersionInput = () => {
6+
const [smartAccountVersion, setSmartAccountVersion] = useState<'v6' | 'v7'>('v7')
7+
const [isForced, setIsForced] = useState(false)
8+
useEffect(() => {
9+
try {
10+
const saved = localStorage.getItem('@appkit-wallet/dapp_smart_account_version')
11+
if (saved === 'v6' || saved === 'v7') {
12+
setSmartAccountVersion(saved)
13+
setIsForced(true)
14+
}
15+
} catch {
16+
// no-op
17+
}
18+
}, [])
19+
20+
useEffect(() => {
21+
try {
22+
if (isForced) {
23+
localStorage.setItem('@appkit-wallet/dapp_smart_account_version', smartAccountVersion)
24+
} else {
25+
localStorage.removeItem('@appkit-wallet/dapp_smart_account_version')
26+
}
27+
} catch {
28+
// no-op
29+
}
30+
}, [isForced, smartAccountVersion])
31+
return (
32+
<Flex gridGap="4" flexDirection="column">
33+
<FormControl>
34+
<HStack>
35+
<FormLabel m={0}>Force Smart Account Version</FormLabel>
36+
<Switch isChecked={isForced} onChange={e => setIsForced(e.target.checked)} />
37+
</HStack>
38+
</FormControl>
39+
<FormControl isDisabled={!isForced}>
40+
<FormLabel>Smart Account Version</FormLabel>
41+
<RadioGroup
42+
onChange={val => setSmartAccountVersion(val as 'v6' | 'v7')}
43+
value={smartAccountVersion}
44+
>
45+
<HStack spacing="4">
46+
<Radio value="v6">v6</Radio>
47+
<Radio value="v7">v7</Radio>
48+
</HStack>
49+
</RadioGroup>
50+
</FormControl>
51+
</Flex>
52+
)
53+
}
54+
55+
export default SmartAccountVersionInput

apps/laboratory/src/layout/OptionsDrawer.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import MixColorInput from '@/src/components/Theming/MixColorInput'
2020
import QrColorInput from '@/src/components/Theming/QrColorInput'
2121
import { ThemeStore } from '@/src/utils/StoreUtil'
2222

23+
import SmartAccountVersionInput from '../components/SmartAccount/SmartAccountVersionInput'
24+
2325
interface Props {
2426
controls: ReturnType<typeof useDisclosure>
2527
}
@@ -84,6 +86,9 @@ export function OptionsDrawer({ controls }: Props) {
8486
<Flex gridGap="4" flexDirection="column">
8587
<BorderRadiusInput />
8688
</Flex>
89+
<Flex gridGap="4" flexDirection="column">
90+
<SmartAccountVersionInput />
91+
</Flex>
8792
</Flex>
8893
</DrawerBody>
8994
</DrawerContent>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const PACKAGE_VERSION = '1.8.11'
1+
export const PACKAGE_VERSION = '1.8.12'

packages/wallet/src/W3mFrame.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { ConstantsUtil } from '@reown/appkit-common'
33
import { SECURE_SITE_SDK, SECURE_SITE_SDK_VERSION, W3mFrameConstants } from './W3mFrameConstants.js'
44
import { W3mFrameHelpers } from './W3mFrameHelpers.js'
55
import { W3mFrameSchema } from './W3mFrameSchema.js'
6+
import { W3mFrameStorage } from './W3mFrameStorage.js'
67
import type { W3mFrameTypes } from './W3mFrameTypes.js'
78

89
type EventKey = typeof W3mFrameConstants.APP_EVENT_KEY | typeof W3mFrameConstants.FRAME_EVENT_KEY
@@ -36,6 +37,12 @@ function createSecureSiteSdkUrl({
3637
url.searchParams.set('version', SECURE_SITE_SDK_VERSION)
3738
url.searchParams.set('enableLogger', String(enableLogger))
3839
url.searchParams.set('rpcUrl', rpcUrl)
40+
// Intended for debug usage only
41+
const smartAccountVersion = W3mFrameStorage.get('dapp_smart_account_version')
42+
if (smartAccountVersion && (smartAccountVersion === 'v6' || smartAccountVersion === 'v7')) {
43+
console.warn('>> AppKit - Forcing smart account version', smartAccountVersion)
44+
url.searchParams.set('smartAccountVersion', smartAccountVersion)
45+
}
3946
if (enableCloudAuthAccount) {
4047
url.searchParams.set('enableCloudAuthAccount', 'true')
4148
}

0 commit comments

Comments
 (0)