1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | const cssReset_1 = require("./lib/cssReset");
|
7 | const WalletLinkProvider_1 = require("./provider/WalletLinkProvider");
|
8 | const WalletLinkRelay_1 = require("./relay/WalletLinkRelay");
|
9 | const util_1 = require("./util");
|
10 | const WALLETLINK_URL = process.env.WALLETLINK_URL || "https://www.walletlink.org";
|
11 | const WALLETLINK_VERSION = process.env.WALLETLINK_VERSION ||
|
12 | require("../package.json").version ||
|
13 | "unknown";
|
14 | class WalletLink {
|
15 | |
16 |
|
17 |
|
18 |
|
19 | constructor(options) {
|
20 | this._appName = "";
|
21 | this._appLogoUrl = null;
|
22 | this._relay = new WalletLinkRelay_1.WalletLinkRelay({
|
23 | walletLinkUrl: options.walletLinkUrl || WALLETLINK_URL,
|
24 | version: WALLETLINK_VERSION,
|
25 | darkMode: !!options.darkMode
|
26 | });
|
27 | this.setAppInfo(options.appName, options.appLogoUrl);
|
28 | this._relay.attach(document.documentElement);
|
29 | cssReset_1.injectCssReset();
|
30 | }
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | makeWeb3Provider(jsonRpcUrl, chainId = 1) {
|
38 | return new WalletLinkProvider_1.WalletLinkProvider({
|
39 | relay: this._relay,
|
40 | jsonRpcUrl,
|
41 | chainId
|
42 | });
|
43 | }
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 | setAppInfo(appName, appLogoUrl) {
|
50 | this._appName = appName || "DApp";
|
51 | this._appLogoUrl = appLogoUrl || util_1.getFavicon();
|
52 | this._relay.setAppInfo(this._appName, this._appLogoUrl);
|
53 | }
|
54 | |
55 |
|
56 |
|
57 |
|
58 | disconnect() {
|
59 | this._relay.resetAndReload();
|
60 | }
|
61 | }
|
62 | exports.WalletLink = WalletLink;
|
63 |
|
64 |
|
65 |
|
66 | WalletLink.VERSION = WALLETLINK_VERSION;
|