-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
51 lines (47 loc) · 1.7 KB
/
index.ts
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import ConnectWallet from "./components/ConnectWallet.vue";
import ConnectButton from "./components/ConnectButton.vue";
import ConnectButtonWrapper from "./components/ConnectButtonWrapper.vue";
import DisconnectButton from "./components/DisconnectButton.vue";
import DisconnectButtonWrapper from "./components/DisconnectButtonWrapper.vue";
import type { App } from "vue";
import {
useSignerOrProvider,
useSigner,
onConnect,
useInitializing,
} from "./wallet";
import type { WalletOptions } from "./types";
import { getChainData, getBalance, getTokenContract } from "./chain";
import { useConnectedStore } from "./store";
import { createPinia } from "pinia";
import piniaPersist from "pinia-plugin-persist";
const walletPlugin = {
getChainData,
getTokenContract,
getBalance,
onConnect,
useConnectedStore,
useSignerOrProvider,
useSigner,
useInitializing,
install(app: App, options: WalletOptions): WalletOptions {
const version = Number(app.version.split(".")[0]);
if (version < 3) {
console.warn("This plugin requires Vue 3");
}
// TODO set default chain / infura key then get the rpc url and network from supportedchains object
// TODO also set supportedchains
const pinia = createPinia();
pinia.use(piniaPersist);
app.use(pinia);
app.component("ConnectWallet", ConnectWallet);
app.component("ConnectButton", ConnectButton);
app.component("ConnectButtonWrapper", ConnectButtonWrapper);
app.component("DisconnectButton", DisconnectButton);
app.component("DisconnectButtonWrapper", DisconnectButtonWrapper);
app.provide("WalletOptions", options);
app.provide("WalletStore", useConnectedStore);
return options;
},
};
export default walletPlugin;