Skip to content

Commit 9a92a00

Browse files
committed
feat: add keplr and okx extensions
1 parent 20afac3 commit 9a92a00

File tree

3 files changed

+75
-39
lines changed

3 files changed

+75
-39
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"starknet-react-chains-next": "npm:@starknet-react/[email protected]",
3333
"starknet-react-core-next": "npm:@starknet-react/[email protected]",
3434
"starknetkit-latest": "npm:starknetkit@^1.1.9",
35-
"starknetkit-next": "npm:starknetkit@^2.3.2"
35+
"starknetkit-next": "npm:starknetkit@^2.3.3"
3636
},
3737
"devDependencies": {
3838
"@types/lodash-es": "^4.17.12",

pnpm-lock.yaml

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/connect/ConnectButtonStarknetkitNext.tsx

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { starknetkitVersionAtom } from "@/state/versionState"
88
import { Button, Flex } from "@chakra-ui/react"
99
import { useSetAtom } from "jotai"
1010
import { useRouter } from "next/navigation"
11+
import { useState } from "react"
1112
import { connect } from "starknetkit-next"
13+
import { ArgentMobileBaseConnector } from "starknetkit-next/argentMobile"
14+
import { InjectedConnector } from "starknetkit-next/injected"
15+
import { WebWalletConnector } from "starknetkit-next/webwallet"
1216

1317
const ConnectButtonStarknetkitNext = () => {
1418
const setWallet = useSetAtom(walletStarknetkitNextAtom)
@@ -17,17 +21,38 @@ const ConnectButtonStarknetkitNext = () => {
1721
const setStarknetkitVersion = useSetAtom(starknetkitVersionAtom)
1822
const navigate = useRouter()
1923

24+
const [withAdditionalWallets, setWithAdditionalWallets] = useState(false)
25+
2026
const connectFn = async () => {
21-
const res = await connect({
22-
modalMode: "alwaysAsk",
23-
webWalletUrl: ARGENT_WEBWALLET_URL,
24-
argentMobileOptions: {
25-
dappName: "Starknetkit example dapp",
26-
url: window.location.hostname,
27-
chainId: CHAIN_ID,
28-
icons: [],
29-
},
30-
})
27+
const res = await connect(
28+
withAdditionalWallets
29+
? {
30+
modalMode: "alwaysAsk",
31+
connectors: [
32+
new InjectedConnector({ options: { id: "argentX" } }),
33+
new InjectedConnector({ options: { id: "braavos" } }),
34+
new InjectedConnector({ options: { id: "keplr" } }),
35+
new InjectedConnector({ options: { id: "okxwallet" } }),
36+
new ArgentMobileBaseConnector({
37+
dappName: "Starknetkit example dapp",
38+
url: window.location.hostname,
39+
chainId: CHAIN_ID,
40+
icons: [],
41+
}),
42+
new WebWalletConnector({ url: ARGENT_WEBWALLET_URL }),
43+
],
44+
}
45+
: {
46+
modalMode: "alwaysAsk",
47+
webWalletUrl: ARGENT_WEBWALLET_URL,
48+
argentMobileOptions: {
49+
dappName: "Starknetkit example dapp",
50+
url: window.location.hostname,
51+
chainId: CHAIN_ID,
52+
icons: [],
53+
},
54+
},
55+
)
3156

3257
const { wallet, connectorData, connector } = res
3358
setWallet(wallet)
@@ -40,19 +65,30 @@ const ConnectButtonStarknetkitNext = () => {
4065
}
4166

4267
return (
43-
<Flex flexDirection="column" alignItems="center">
44-
<Button
45-
p="4"
46-
rounded="lg"
47-
colorScheme="primary"
48-
onClick={connectFn}
49-
h="20"
50-
w="full"
51-
>
52-
starknetkit@next ({process.env.starknetkitNextVersion})
53-
</Button>
54-
<strong>(with session keys)</strong> {/* TODO: will be removed */}
55-
</Flex>
68+
<>
69+
<Flex flexDirection="column" alignItems="center">
70+
<Button
71+
p="4"
72+
rounded="lg"
73+
colorScheme="primary"
74+
onClick={connectFn}
75+
h="20"
76+
w="full"
77+
>
78+
starknetkit@next ({process.env.starknetkitNextVersion}) +
79+
<strong>(with session keys)</strong> {/* TODO: will be removed */}
80+
</Button>
81+
</Flex>
82+
<Flex gap="1">
83+
<input
84+
type="checkbox"
85+
checked={withAdditionalWallets}
86+
onChange={() => setWithAdditionalWallets(!withAdditionalWallets)}
87+
/>
88+
Include Keplr and OKX wallets with starknetkit@next (
89+
{process.env.starknetkitNextVersion})
90+
</Flex>
91+
</>
5692
)
5793
}
5894

0 commit comments

Comments
 (0)