-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwallet.js
More file actions
30 lines (25 loc) · 751 Bytes
/
wallet.js
File metadata and controls
30 lines (25 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { TezosToolkit } from '@taquito/taquito'
import { BeaconWallet } from '@taquito/beacon-wallet'
const Tezos = new TezosToolkit()
const wallet = new BeaconWallet({ name: "ChainBorn" })
Tezos.setWalletProvider(wallet)
export async function setProvider(rpc) {
Tezos.setProvider({ rpc: rpc})
}
export async function getActiveAccount() {
const activeAccount = await wallet.client.getActiveAccount()
if (!activeAccount) return null
return activeAccount
}
export async function connectWallet(network) {
const account = await wallet.client.requestPermissions({
network: {
type: network.type,
rpcUrl: network.rpc
}
})
return account
}
export async function disconnectWallet() {
await wallet.clearActiveAccount()
}