Skip to content

Commit

Permalink
feat: support link wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
wfnuser committed Jul 18, 2024
1 parent d0ffd3c commit a28960f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"tailwindcss-animate": "^1.0.7",
"viem": "~2.17.3",
"wagmi": "^2.10.10",
"youbet-sdk": "^0.0.7",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
23 changes: 23 additions & 0 deletions src/components/layout/ConnectButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ConnectButton } from '@rainbow-me/rainbowkit'
import Cookies from 'js-cookie'
import http from '../../service/instance'

export const CustomConnectButton = () => {
return (
<ConnectButton.Custom>
Expand All @@ -8,6 +11,26 @@ export const CustomConnectButton = () => {
const ready = mounted && authenticationStatus !== 'loading'
const connected =
ready && account && chain && (!authenticationStatus || authenticationStatus === 'authenticated')

const github = Cookies.get('username')

const linkWallet = async () => {
console.log('call link')
if (connected) {
const address = account.address
const linkedAddress = await fetch(`/api/get-linked-wallet?github=${github}`).then((res) => res.text())
console.log(linkedAddress)
if (linkedAddress == '0x0000000000000000000000000000000000000000') {
const res = await http.post('/link-wallet', {
github,
address,
})
console.log(res)
}
}
}
linkWallet()

return (
<div
{...(!ready && {
Expand Down

0 comments on commit a28960f

Please sign in to comment.