-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinPageScript.ts
36 lines (33 loc) · 1.08 KB
/
inPageScript.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
import { WindowPostMessageStream } from "@theqrl/zond-wallet-provider/post-message-stream";
import { initializeProvider } from "@theqrl/zond-wallet-provider/providers";
import log from "loglevel";
import { v4 as uuid } from "uuid";
import {
ZOND_POST_MESSAGE_STREAM,
ZOND_WEB3_WALLET_PROVIDER_INFO,
} from "./constants/streamConstants";
const initializeInPageScript = () => {
try {
const zondStream = new WindowPostMessageStream({
name: ZOND_POST_MESSAGE_STREAM.INPAGE,
target: ZOND_POST_MESSAGE_STREAM.CONTENT_SCRIPT,
});
initializeProvider({
connectionStream: zondStream,
logger: log,
providerInfo: {
uuid: uuid(),
name: ZOND_WEB3_WALLET_PROVIDER_INFO.NAME,
icon: ZOND_WEB3_WALLET_PROVIDER_INFO.ICON,
rdns: ZOND_WEB3_WALLET_PROVIDER_INFO.RDNS,
},
});
} catch (error) {
console.warn(
"ZondWeb3Wallet: Failed to initialize the in-page script\n",
error,
);
}
};
// This function accounces the zond web3 wallet provider(based on EIP-6963), to be detected by the dApps.
initializeInPageScript();