@arcai/chatbot 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WalletBot.d.ts +14 -0
- package/dist/WalletBot.js +60 -0
- package/dist/chatbot.min.js +6126 -8
- package/dist/index.d.ts +8 -24
- package/dist/index.js +108 -96
- package/dist/styles.d.ts +1 -1
- package/dist/styles.js +1 -0
- package/dist/types.d.ts +14 -0
- package/package.json +5 -2
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { WalletState, WalletHandlers } from './types';
|
2
|
+
export declare class WalletBot {
|
3
|
+
private static instance;
|
4
|
+
walletState: WalletState;
|
5
|
+
web3Modal: any;
|
6
|
+
private config;
|
7
|
+
private projectId;
|
8
|
+
handlers: WalletHandlers | undefined;
|
9
|
+
static getInstance(projectId?: string): WalletBot;
|
10
|
+
private constructor();
|
11
|
+
private initializeWeb3;
|
12
|
+
setWalletHandlers(handlers: WalletHandlers): void;
|
13
|
+
updateWalletState(state: Partial<WalletState>): void;
|
14
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { createWeb3Modal } from '@web3modal/wagmi/react';
|
2
|
+
import { walletConnectProvider } from '@web3modal/wagmi';
|
3
|
+
import { createConfig, configureChains } from 'wagmi';
|
4
|
+
import { mainnet, arbitrum } from 'wagmi/chains';
|
5
|
+
import { InjectedConnector } from 'wagmi/connectors/injected';
|
6
|
+
import { WalletConnectConnector } from 'wagmi/connectors/walletConnect';
|
7
|
+
import { publicProvider } from 'wagmi/providers/public';
|
8
|
+
export class WalletBot {
|
9
|
+
static getInstance(projectId) {
|
10
|
+
if (!WalletBot.instance) {
|
11
|
+
WalletBot.instance = new WalletBot(projectId);
|
12
|
+
}
|
13
|
+
return WalletBot.instance;
|
14
|
+
}
|
15
|
+
constructor(projectId) {
|
16
|
+
this.walletState = {
|
17
|
+
address: null,
|
18
|
+
isConnecting: false,
|
19
|
+
isConnected: false,
|
20
|
+
error: null
|
21
|
+
};
|
22
|
+
this.projectId = projectId || 'YOUR_PROJECT_ID';
|
23
|
+
this.initializeWeb3();
|
24
|
+
}
|
25
|
+
initializeWeb3() {
|
26
|
+
const { chains, publicClient } = configureChains([mainnet, arbitrum], [walletConnectProvider({ projectId: this.projectId }), publicProvider()]);
|
27
|
+
const metadata = {
|
28
|
+
name: 'Simple Chat Bot',
|
29
|
+
description: 'Chat bot with wallet integration',
|
30
|
+
url: window.location.origin,
|
31
|
+
icons: [`${window.location.origin}/icon.png`]
|
32
|
+
};
|
33
|
+
this.config = createConfig({
|
34
|
+
autoConnect: true,
|
35
|
+
connectors: [
|
36
|
+
new InjectedConnector({ chains }),
|
37
|
+
new WalletConnectConnector({
|
38
|
+
chains,
|
39
|
+
options: {
|
40
|
+
projectId: this.projectId,
|
41
|
+
metadata,
|
42
|
+
},
|
43
|
+
}),
|
44
|
+
],
|
45
|
+
publicClient,
|
46
|
+
});
|
47
|
+
this.web3Modal = createWeb3Modal({
|
48
|
+
wagmiConfig: this.config,
|
49
|
+
projectId: this.projectId,
|
50
|
+
chains
|
51
|
+
});
|
52
|
+
}
|
53
|
+
setWalletHandlers(handlers) {
|
54
|
+
this.handlers = handlers;
|
55
|
+
}
|
56
|
+
updateWalletState(state) {
|
57
|
+
this.walletState = { ...this.walletState, ...state };
|
58
|
+
}
|
59
|
+
}
|
60
|
+
WalletBot.instance = null;
|