forked from jfbeats/ArweaveWalletConnector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReactiveWallet.ts
31 lines (29 loc) · 1.1 KB
/
ReactiveWallet.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
// Import the wallet connector
import { ArweaveWebWallet } from 'arweave-wallet-connector'
import { reactive } from 'vue'
import type { AppInfo } from 'arweave-wallet-connector'
export class ReactiveWallet extends ArweaveWebWallet {
state = reactive({
url: import.meta.env.DEV ? 'http://localhost:8080' : 'arweave.app',
address: undefined as undefined | string,
keepPopup: false,
error: '',
})
constructor (appInfo?: AppInfo, url?: string) {
super(appInfo, url)
this.on('connect', (address) => {
this.state.address = address
this.state.url = wallet.url as string
})
this.on('disconnect', () => this.state.address = undefined)
this.on('keepPopup', (keep) => this.state.keepPopup = keep)
}
get url () { return this.state.url }
// @ts-ignore
get address () { return this.state.address }
get keepPopup () { return this.state.keepPopup }
set keepPopup (value) { super.keepPopup = value }
get error () { return this.state.error }
set error (value) { this.state.error = value }
}
export const wallet = new ReactiveWallet({ name: 'Connector Example', logo: `${location.href}placeholder.svg` })