-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,530 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
front/apps/auth/chains/ethereum/adapaters/wallet-connect.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { adapters, getAdapters } from './providers' | ||
import { providers, getProvider } from './providers' | ||
|
||
export const eth = { | ||
ttl: 600, | ||
|
||
id: 'chain:ethereum', | ||
name: 'Ethereum', | ||
|
||
key: 'chain:eth', | ||
|
||
adapters, | ||
getAdapters | ||
providers, | ||
getProvider | ||
} | ||
|
||
export default eth |
67 changes: 67 additions & 0 deletions
67
front/apps/auth/chains/ethereum/provider/wallet-connect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { ref } from 'vue' | ||
|
||
import { | ||
getAccount, | ||
signMessage, | ||
disconnect | ||
} from '@wagmi/core' | ||
|
||
import type { Web3Modal } from '@web3modal/html' | ||
import { getWeb3Modal } from '../util' | ||
|
||
export const useProvider = () => { | ||
const callback = ref<any>() | ||
|
||
const account = ref<any>('') | ||
|
||
const web3modal = ref<Web3Modal>() | ||
|
||
const init = () => { | ||
if (!web3modal.value) { | ||
const modal = getWeb3Modal() | ||
|
||
modal.subscribeEvents((event) => { | ||
if (event.name === 'ACCOUNT_CONNECTED') { | ||
account.value = getAccount() | ||
|
||
callback.value() | ||
} | ||
|
||
if (event.name === 'ACCOUNT_DISCONNECTED') { | ||
account.value = undefined | ||
} | ||
}) | ||
|
||
web3modal.value = modal | ||
} | ||
|
||
return web3modal.value | ||
} | ||
|
||
const connect = async (loginCallback = () => {}) => { | ||
const modal = await init() | ||
|
||
await modal.openModal() | ||
|
||
callback.value = loginCallback | ||
} | ||
|
||
const sendTransaction = () => {} | ||
|
||
return { | ||
account, | ||
connect, | ||
signMessage, | ||
sendTransaction, | ||
disconnect | ||
} | ||
} | ||
|
||
export default { | ||
id: 'provider:wallet-connect', | ||
name: 'Wallet Connector', | ||
icon: 'walletConnect', | ||
disabled: false, | ||
|
||
provider: useProvider() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { useWalletConnectAdapter } from './adapaters/wallet-connect' | ||
import xWallet from './provider/wallet-connect' | ||
|
||
export const adapters = { | ||
'provider:eth:adapter:wallet-connect': | ||
useWalletConnectAdapter() | ||
export const providers = { | ||
[xWallet.id]: xWallet | ||
} as any | ||
|
||
export const getAdapters = (key: string) => adapters[key] | ||
export const getProvider = (key: string) => providers[key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
arbitrum, | ||
mainnet, | ||
polygon | ||
} from '@wagmi/core/chains' | ||
|
||
import { configureChains, createConfig } from '@wagmi/core' | ||
|
||
import type { Chain } from '@wagmi/core/chains' | ||
|
||
import { | ||
EthereumClient, | ||
w3mConnectors, | ||
w3mProvider | ||
} from '@web3modal/ethereum' | ||
|
||
import { Web3Modal } from '@web3modal/html' | ||
|
||
export const projectId = '8354195026b85d657e3692c119242c19' | ||
|
||
export const chains: Chain[] = [arbitrum, mainnet, polygon] | ||
|
||
export const { publicClient } = configureChains(chains, [ | ||
w3mProvider({ projectId }) | ||
]) | ||
|
||
export const wagmiClient = createConfig({ | ||
connectors: w3mConnectors({ | ||
projectId, | ||
chains | ||
}), | ||
publicClient | ||
}) | ||
|
||
export const ethereumClient = () => | ||
new EthereumClient(wagmiClient, chains) | ||
|
||
export const getWeb3Modal = (): Web3Modal => | ||
new Web3Modal({ projectId }, ethereumClient()) |
Oops, something went wrong.