@manahippo/aptos-wallet-adapter 1.0.3 → 1.0.6
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/README.md +2 -0
- package/dist/WalletAdapters/BaseAdapter.d.ts +6 -6
- package/dist/WalletAdapters/BaseAdapter.d.ts.map +1 -1
- package/dist/WalletAdapters/BitkeepWallet.d.ts +1 -1
- package/dist/WalletAdapters/BitkeepWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/BloctoWallet.d.ts +1 -1
- package/dist/WalletAdapters/BloctoWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/BloctoWallet.js +2 -2
- package/dist/WalletAdapters/BloctoWallet.js.map +1 -1
- package/dist/WalletAdapters/CloverWallet.d.ts +57 -0
- package/dist/WalletAdapters/CloverWallet.d.ts.map +1 -0
- package/dist/WalletAdapters/CloverWallet.js +213 -0
- package/dist/WalletAdapters/CloverWallet.js.map +1 -0
- package/dist/WalletAdapters/Coin98Wallet.d.ts +1 -1
- package/dist/WalletAdapters/Coin98Wallet.d.ts.map +1 -1
- package/dist/WalletAdapters/FoxWallet.d.ts +1 -1
- package/dist/WalletAdapters/FoxWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/MsafeWallet.d.ts +0 -38
- package/dist/WalletAdapters/MsafeWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/MsafeWallet.js +226 -224
- package/dist/WalletAdapters/MsafeWallet.js.map +1 -1
- package/dist/WalletAdapters/NightlyWallet.js +8 -8
- package/dist/WalletAdapters/NightlyWallet.js.map +1 -1
- package/dist/WalletAdapters/ONTOWallet.d.ts +1 -1
- package/dist/WalletAdapters/ONTOWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/OpenBlockWallet.d.ts +56 -0
- package/dist/WalletAdapters/OpenBlockWallet.d.ts.map +1 -0
- package/dist/WalletAdapters/OpenBlockWallet.js +243 -0
- package/dist/WalletAdapters/OpenBlockWallet.js.map +1 -0
- package/dist/WalletAdapters/PetraWallet.d.ts +1 -1
- package/dist/WalletAdapters/PetraWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/PetraWallet.js +1 -1
- package/dist/WalletAdapters/PetraWallet.js.map +1 -1
- package/dist/WalletAdapters/PontemWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/PontemWallet.js +8 -7
- package/dist/WalletAdapters/PontemWallet.js.map +1 -1
- package/dist/WalletAdapters/RiseWallet.d.ts +11 -3
- package/dist/WalletAdapters/RiseWallet.d.ts.map +1 -1
- package/dist/WalletAdapters/RiseWallet.js +40 -16
- package/dist/WalletAdapters/RiseWallet.js.map +1 -1
- package/dist/WalletAdapters/SpacecyWallet.d.ts +79 -0
- package/dist/WalletAdapters/SpacecyWallet.d.ts.map +1 -0
- package/dist/WalletAdapters/SpacecyWallet.js +258 -0
- package/dist/WalletAdapters/SpacecyWallet.js.map +1 -0
- package/dist/WalletAdapters/index.d.ts +3 -1
- package/dist/WalletAdapters/index.d.ts.map +1 -1
- package/dist/WalletAdapters/index.js +4 -1
- package/dist/WalletAdapters/index.js.map +1 -1
- package/dist/WalletProviders/WalletProvider.d.ts.map +1 -1
- package/dist/WalletProviders/WalletProvider.js +6 -7
- package/dist/WalletProviders/WalletProvider.js.map +1 -1
- package/package.json +3 -3
- package/src/WalletAdapters/BloctoWallet.ts +3 -4
- package/src/WalletAdapters/CloverWallet.ts +274 -0
- package/src/WalletAdapters/MsafeWallet.ts +261 -261
- package/src/WalletAdapters/OpenBlockWallet.ts +293 -0
- package/src/WalletAdapters/PetraWallet.ts +1 -1
- package/src/WalletAdapters/PontemWallet.ts +14 -11
- package/src/WalletAdapters/RiseWallet.ts +52 -17
- package/src/WalletAdapters/SpacecyWallet.ts +350 -0
- package/src/WalletAdapters/index.ts +4 -1
- package/src/WalletProviders/WalletProvider.tsx +5 -6
@@ -0,0 +1,293 @@
|
|
1
|
+
import { Types } from 'aptos';
|
2
|
+
import {
|
3
|
+
WalletAccountChangeError,
|
4
|
+
WalletDisconnectionError,
|
5
|
+
WalletNetworkChangeError,
|
6
|
+
WalletNotConnectedError,
|
7
|
+
WalletNotReadyError,
|
8
|
+
WalletSignAndSubmitMessageError,
|
9
|
+
WalletSignMessageError,
|
10
|
+
WalletSignTransactionError
|
11
|
+
} from '../WalletProviders/errors';
|
12
|
+
|
13
|
+
import {
|
14
|
+
AccountKeys,
|
15
|
+
BaseWalletAdapter,
|
16
|
+
NetworkInfo,
|
17
|
+
scopePollingDetectionStrategy,
|
18
|
+
SignMessagePayload,
|
19
|
+
SignMessageResponse,
|
20
|
+
WalletAdapterNetwork,
|
21
|
+
WalletName,
|
22
|
+
WalletReadyState
|
23
|
+
} from './BaseAdapter';
|
24
|
+
|
25
|
+
type AddressInfo = { address: string; publicKey: string; authKey?: string };
|
26
|
+
|
27
|
+
interface IOpenBlockWallet {
|
28
|
+
connect: () => Promise<AddressInfo>;
|
29
|
+
account: () => Promise<AddressInfo>;
|
30
|
+
network: () => Promise<NetworkInfo>;
|
31
|
+
isConnected: () => Promise<boolean>;
|
32
|
+
signAndSubmitTransaction(transaction: any): Promise<{ hash: string }>;
|
33
|
+
signTransaction(payload: any): Promise<string>;
|
34
|
+
signMessage(message: SignMessagePayload): Promise<SignMessageResponse>;
|
35
|
+
disconnect(): Promise<void>;
|
36
|
+
onAccountChange: (listener: (newAddress: AddressInfo) => void) => void;
|
37
|
+
onNetworkChange: (listener: (network: NetworkInfo) => void) => void;
|
38
|
+
}
|
39
|
+
|
40
|
+
interface OpenBlockWindow extends Window {
|
41
|
+
openblock?: {
|
42
|
+
aptos?: IOpenBlockWallet;
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
declare const window: OpenBlockWindow;
|
47
|
+
|
48
|
+
export const OpenBlockWalletName = 'OpenBlock' as WalletName<'OpenBlock'>;
|
49
|
+
|
50
|
+
export interface OpenBlockWalletAdapterConfig {
|
51
|
+
provider?: IOpenBlockWallet;
|
52
|
+
// network?: WalletAdapterNetwork;
|
53
|
+
timeout?: number;
|
54
|
+
}
|
55
|
+
|
56
|
+
export class OpenBlockWalletAdapter extends BaseWalletAdapter {
|
57
|
+
name = OpenBlockWalletName;
|
58
|
+
|
59
|
+
url = 'https://openblock.com/';
|
60
|
+
|
61
|
+
icon = 'https://obstatic.243096.com/download/dapp/sdk/images/logo_blue.svg';
|
62
|
+
|
63
|
+
protected _provider: IOpenBlockWallet;
|
64
|
+
|
65
|
+
protected _network: WalletAdapterNetwork;
|
66
|
+
|
67
|
+
protected _chainId: string;
|
68
|
+
|
69
|
+
protected _api: string;
|
70
|
+
|
71
|
+
protected _timeout: number;
|
72
|
+
|
73
|
+
protected _readyState: WalletReadyState =
|
74
|
+
typeof window === 'undefined' || typeof document === 'undefined'
|
75
|
+
? WalletReadyState.Unsupported
|
76
|
+
: WalletReadyState.NotDetected;
|
77
|
+
|
78
|
+
protected _connecting: boolean;
|
79
|
+
|
80
|
+
protected _wallet: any | null;
|
81
|
+
|
82
|
+
constructor({
|
83
|
+
// provider,
|
84
|
+
// network = WalletAdapterNetwork.Testnet,
|
85
|
+
timeout = 10000
|
86
|
+
}: OpenBlockWalletAdapterConfig = {}) {
|
87
|
+
super();
|
88
|
+
|
89
|
+
this._provider = typeof window !== 'undefined' ? window.openblock?.aptos : undefined;
|
90
|
+
this._network = undefined;
|
91
|
+
this._timeout = timeout;
|
92
|
+
this._connecting = false;
|
93
|
+
this._wallet = null;
|
94
|
+
|
95
|
+
if (typeof window !== 'undefined' && this._readyState !== WalletReadyState.Unsupported) {
|
96
|
+
require('@openblockhq/dappsdk');
|
97
|
+
scopePollingDetectionStrategy(() => {
|
98
|
+
if (window.openblock?.aptos) {
|
99
|
+
this._readyState = WalletReadyState.Installed;
|
100
|
+
this.emit('readyStateChange', this._readyState);
|
101
|
+
return true;
|
102
|
+
}
|
103
|
+
return false;
|
104
|
+
});
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
get publicAccount(): AccountKeys {
|
109
|
+
return {
|
110
|
+
publicKey: this._wallet?.publicKey || null,
|
111
|
+
address: this._wallet?.address || null,
|
112
|
+
authKey: this._wallet?.authKey || null
|
113
|
+
};
|
114
|
+
}
|
115
|
+
|
116
|
+
get network(): NetworkInfo {
|
117
|
+
return {
|
118
|
+
name: this._network,
|
119
|
+
api: this._api,
|
120
|
+
chainId: this._chainId
|
121
|
+
};
|
122
|
+
}
|
123
|
+
|
124
|
+
get connecting(): boolean {
|
125
|
+
return this._connecting;
|
126
|
+
}
|
127
|
+
|
128
|
+
get connected(): boolean {
|
129
|
+
return !!this._wallet?.isConnected;
|
130
|
+
}
|
131
|
+
|
132
|
+
get readyState(): WalletReadyState {
|
133
|
+
return this._readyState;
|
134
|
+
}
|
135
|
+
|
136
|
+
async connect(): Promise<void> {
|
137
|
+
try {
|
138
|
+
if (this.connected || this.connecting) return;
|
139
|
+
if (
|
140
|
+
!(
|
141
|
+
this._readyState === WalletReadyState.Loadable ||
|
142
|
+
this._readyState === WalletReadyState.Installed
|
143
|
+
)
|
144
|
+
)
|
145
|
+
throw new WalletNotReadyError();
|
146
|
+
this._connecting = true;
|
147
|
+
|
148
|
+
const provider = this._provider || window?.openblock?.aptos;
|
149
|
+
const isConnected = await this._provider?.isConnected();
|
150
|
+
if (isConnected === true) {
|
151
|
+
await provider?.disconnect();
|
152
|
+
}
|
153
|
+
|
154
|
+
const response = await provider?.connect();
|
155
|
+
if (response.address) {
|
156
|
+
this._wallet = {
|
157
|
+
address: response?.address,
|
158
|
+
publicKey: response?.publicKey,
|
159
|
+
isConnected: true
|
160
|
+
};
|
161
|
+
const network = await provider?.network();
|
162
|
+
|
163
|
+
this._network = network.name;
|
164
|
+
this._chainId = network.chainId;
|
165
|
+
this._api = network.api;
|
166
|
+
} else {
|
167
|
+
throw new Error('failed to connect');
|
168
|
+
}
|
169
|
+
this.emit('connect', this._wallet.publicKey);
|
170
|
+
} catch (error: any) {
|
171
|
+
this.emit('error', error);
|
172
|
+
throw error;
|
173
|
+
} finally {
|
174
|
+
this._connecting = false;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
async disconnect(): Promise<void> {
|
179
|
+
const wallet = this._wallet;
|
180
|
+
const provider = this._provider || window?.openblock?.aptos;
|
181
|
+
if (wallet) {
|
182
|
+
this._wallet = null;
|
183
|
+
|
184
|
+
try {
|
185
|
+
await provider?.disconnect();
|
186
|
+
} catch (error: any) {
|
187
|
+
this.emit('error', new WalletDisconnectionError(error?.message, error));
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
this.emit('disconnect');
|
192
|
+
}
|
193
|
+
|
194
|
+
async signTransaction(transaction: Types.TransactionPayload): Promise<Uint8Array> {
|
195
|
+
try {
|
196
|
+
const wallet = this._wallet;
|
197
|
+
const provider = this._provider || window?.openblock?.aptos;
|
198
|
+
if (!wallet || !provider) throw new WalletNotConnectedError();
|
199
|
+
|
200
|
+
const response = await provider.signTransaction(transaction);
|
201
|
+
if (response) {
|
202
|
+
return new TextEncoder().encode(response);
|
203
|
+
}
|
204
|
+
throw new Error('failed to SignTransaction');
|
205
|
+
} catch (error: any) {
|
206
|
+
const errMsg = error.message;
|
207
|
+
this.emit('error', new WalletSignTransactionError(errMsg));
|
208
|
+
throw error;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
async signAndSubmitTransaction(
|
213
|
+
transaction: Types.TransactionPayload
|
214
|
+
): Promise<{ hash: Types.HexEncodedBytes }> {
|
215
|
+
try {
|
216
|
+
const wallet = this._wallet;
|
217
|
+
const provider = this._provider || window?.openblock?.aptos;
|
218
|
+
if (!wallet || !provider) throw new WalletNotConnectedError();
|
219
|
+
const response = await provider.signAndSubmitTransaction(transaction);
|
220
|
+
if (response) {
|
221
|
+
return response;
|
222
|
+
}
|
223
|
+
throw new Error('Failed to SignAndSubmitTransaction');
|
224
|
+
} catch (error: any) {
|
225
|
+
const errMsg = error.message;
|
226
|
+
this.emit('error', new WalletSignAndSubmitMessageError(errMsg));
|
227
|
+
throw error;
|
228
|
+
}
|
229
|
+
}
|
230
|
+
|
231
|
+
async signMessage(msgPayload: SignMessagePayload): Promise<SignMessageResponse> {
|
232
|
+
try {
|
233
|
+
const wallet = this._wallet;
|
234
|
+
const provider = this._provider || window?.openblock?.aptos;
|
235
|
+
if (!wallet || !provider) throw new WalletNotConnectedError();
|
236
|
+
if (typeof msgPayload !== 'object' || !msgPayload.nonce) {
|
237
|
+
throw new WalletSignMessageError('Invalid signMessage Payload');
|
238
|
+
}
|
239
|
+
|
240
|
+
const response = await provider?.signMessage(msgPayload);
|
241
|
+
if (response) {
|
242
|
+
return response;
|
243
|
+
}
|
244
|
+
|
245
|
+
throw new Error('Failed to signMessage');
|
246
|
+
} catch (error: any) {
|
247
|
+
const errMsg = error.message;
|
248
|
+
this.emit('error', new WalletSignMessageError(errMsg));
|
249
|
+
throw error;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
async onAccountChange(): Promise<void> {
|
254
|
+
try {
|
255
|
+
const wallet = this._wallet;
|
256
|
+
const provider = this._provider || window?.openblock?.aptos;
|
257
|
+
if (!wallet || !provider) throw new WalletNotConnectedError();
|
258
|
+
const handleAccountChange = async (newAccount: AddressInfo) => {
|
259
|
+
this._wallet = {
|
260
|
+
...this._wallet,
|
261
|
+
publicKey: newAccount.publicKey || this._wallet?.publicKey,
|
262
|
+
authKey: newAccount.authKey || this._wallet?.authKey,
|
263
|
+
address: newAccount.address || this._wallet?.address
|
264
|
+
};
|
265
|
+
this.emit('accountChange', newAccount.publicKey);
|
266
|
+
};
|
267
|
+
provider?.onAccountChange(handleAccountChange);
|
268
|
+
} catch (error: any) {
|
269
|
+
const errMsg = error.message;
|
270
|
+
this.emit('error', new WalletAccountChangeError(errMsg));
|
271
|
+
throw error;
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
async onNetworkChange(): Promise<void> {
|
276
|
+
try {
|
277
|
+
const wallet = this._wallet;
|
278
|
+
const provider = this._provider || window?.openblock?.aptos;
|
279
|
+
if (!wallet || !provider) throw new WalletNotConnectedError();
|
280
|
+
const handleNetworkChange = async (newNetwork: NetworkInfo) => {
|
281
|
+
this._network = newNetwork.name;
|
282
|
+
this._api = newNetwork.api;
|
283
|
+
this._chainId = newNetwork.chainId;
|
284
|
+
this.emit('networkChange', this._network);
|
285
|
+
};
|
286
|
+
provider?.onNetworkChange(handleNetworkChange);
|
287
|
+
} catch (error: any) {
|
288
|
+
const errMsg = error.message;
|
289
|
+
this.emit('error', new WalletNetworkChangeError(errMsg));
|
290
|
+
throw error;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
}
|
@@ -175,7 +175,7 @@ export class AptosWalletAdapter extends BaseWalletAdapter {
|
|
175
175
|
throw error;
|
176
176
|
}
|
177
177
|
|
178
|
-
this.emit('connect', this._wallet.
|
178
|
+
this.emit('connect', this._wallet.address);
|
179
179
|
} catch (error: any) {
|
180
180
|
this.emit('error', error);
|
181
181
|
throw error;
|
@@ -287,18 +287,21 @@ export class PontemWalletAdapter extends BaseWalletAdapter {
|
|
287
287
|
if (!wallet || !provider) throw new WalletNotConnectedError();
|
288
288
|
const handleAccountChange = async (newAccount: string | undefined) => {
|
289
289
|
// disconnect wallet if newAccount is undefined
|
290
|
-
if (newAccount
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
290
|
+
if (newAccount) {
|
291
|
+
const newPublicKey = await provider?.publicKey();
|
292
|
+
this._wallet = {
|
293
|
+
...this._wallet,
|
294
|
+
address: newAccount,
|
295
|
+
publicKey: newPublicKey
|
296
|
+
};
|
297
|
+
} else {
|
298
|
+
const response = await provider?.connect();
|
299
|
+
this._wallet = {
|
300
|
+
...this._wallet,
|
301
|
+
address: response?.address || this._wallet?.address,
|
302
|
+
publicKey: response?.publicKey || this._wallet?.publicKey
|
303
|
+
};
|
295
304
|
}
|
296
|
-
const newPublicKey = await provider?.publicKey();
|
297
|
-
this._wallet = {
|
298
|
-
...this._wallet,
|
299
|
-
address: newAccount,
|
300
|
-
publicKey: newPublicKey
|
301
|
-
};
|
302
305
|
this.emit('accountChange', newAccount);
|
303
306
|
};
|
304
307
|
await provider?.onAccountChange(handleAccountChange);
|
@@ -28,8 +28,10 @@ interface RiseAccount {
|
|
28
28
|
isConnected: boolean;
|
29
29
|
}
|
30
30
|
|
31
|
+
type AddressInfo = { address: string; publicKey: string; authKey?: string };
|
32
|
+
|
31
33
|
interface IRiseWallet {
|
32
|
-
connect: () => Promise<
|
34
|
+
connect: () => Promise<AddressInfo>;
|
33
35
|
account(): Promise<RiseAccount>;
|
34
36
|
isConnected: () => Promise<boolean>;
|
35
37
|
signAndSubmitTransaction(transaction: any): Promise<{ hash: Types.HexEncodedBytes }>;
|
@@ -37,6 +39,10 @@ interface IRiseWallet {
|
|
37
39
|
signMessage(message: SignMessagePayload): Promise<SignMessageResponse>;
|
38
40
|
disconnect(): Promise<void>;
|
39
41
|
network(): Promise<NetworkInfo>;
|
42
|
+
on(event: string, listener: () => any): void;
|
43
|
+
off(event: string, listener: () => any): void;
|
44
|
+
onAccountChange: (listener: (newAddress: AddressInfo) => void) => void;
|
45
|
+
onNetworkChange: (listener: (network: NetworkInfo) => void) => void;
|
40
46
|
}
|
41
47
|
|
42
48
|
interface RiseWindow extends Window {
|
@@ -156,22 +162,20 @@ export class RiseWalletAdapter extends BaseWalletAdapter {
|
|
156
162
|
throw new WalletNotConnectedError('User has rejected the request');
|
157
163
|
}
|
158
164
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
const errMsg = error.message;
|
170
|
-
this.emit('error', new WalletGetNetworkError(errMsg));
|
171
|
-
throw error;
|
172
|
-
}
|
165
|
+
try {
|
166
|
+
const { chainId, api, name } = await provider.network();
|
167
|
+
|
168
|
+
this._network = name;
|
169
|
+
this._chainId = chainId;
|
170
|
+
this._api = api;
|
171
|
+
} catch (error: any) {
|
172
|
+
const errMsg = error.message;
|
173
|
+
this.emit('error', new WalletGetNetworkError(errMsg));
|
174
|
+
throw error;
|
173
175
|
}
|
174
176
|
|
177
|
+
provider?.on('disconnect', this.handleDisconnect);
|
178
|
+
|
175
179
|
const account = await provider?.account();
|
176
180
|
if (account) {
|
177
181
|
const { publicKey, address, authKey } = account;
|
@@ -200,6 +204,7 @@ export class RiseWalletAdapter extends BaseWalletAdapter {
|
|
200
204
|
|
201
205
|
try {
|
202
206
|
const provider = this._provider || window.rise;
|
207
|
+
provider?.off('disconnect', this.handleDisconnect);
|
203
208
|
await provider?.disconnect();
|
204
209
|
} catch (error: any) {
|
205
210
|
this.emit('error', new WalletDisconnectionError(error?.message, error));
|
@@ -275,7 +280,18 @@ export class RiseWalletAdapter extends BaseWalletAdapter {
|
|
275
280
|
const wallet = this._wallet;
|
276
281
|
const provider = this._provider || window.rise;
|
277
282
|
if (!wallet || !provider) throw new WalletNotConnectedError();
|
278
|
-
|
283
|
+
const handleAccountChange = async (newAccount?: AddressInfo) => {
|
284
|
+
if (newAccount?.publicKey) {
|
285
|
+
this._wallet = {
|
286
|
+
...this._wallet,
|
287
|
+
publicKey: newAccount.publicKey || this._wallet?.publicKey,
|
288
|
+
authKey: newAccount.authKey || this._wallet?.authKey,
|
289
|
+
address: newAccount.address || this._wallet?.address
|
290
|
+
};
|
291
|
+
this.emit('accountChange', newAccount?.publicKey);
|
292
|
+
}
|
293
|
+
};
|
294
|
+
await provider?.onAccountChange?.(handleAccountChange);
|
279
295
|
} catch (error: any) {
|
280
296
|
const errMsg = error.message;
|
281
297
|
this.emit('error', new WalletAccountChangeError(errMsg));
|
@@ -288,11 +304,30 @@ export class RiseWalletAdapter extends BaseWalletAdapter {
|
|
288
304
|
const wallet = this._wallet;
|
289
305
|
const provider = this._provider || window.rise;
|
290
306
|
if (!wallet || !provider) throw new WalletNotConnectedError();
|
291
|
-
|
307
|
+
const handleNetworkChange = async (newNetwork: NetworkInfo) => {
|
308
|
+
const { chainId, api, name } = newNetwork;
|
309
|
+
this._network = name;
|
310
|
+
this._chainId = chainId;
|
311
|
+
this._api = api;
|
312
|
+
this.emit('networkChange', this._network);
|
313
|
+
};
|
314
|
+
await provider?.onNetworkChange?.(handleNetworkChange);
|
292
315
|
} catch (error: any) {
|
293
316
|
const errMsg = error.message;
|
294
317
|
this.emit('error', new WalletNetworkChangeError(errMsg));
|
295
318
|
throw error;
|
296
319
|
}
|
297
320
|
}
|
321
|
+
|
322
|
+
private handleDisconnect = () => {
|
323
|
+
try {
|
324
|
+
const provider = this._provider || window.rise;
|
325
|
+
|
326
|
+
provider?.off('disconnect', this.handleDisconnect);
|
327
|
+
|
328
|
+
this._wallet = null;
|
329
|
+
} finally {
|
330
|
+
this.emit('disconnect');
|
331
|
+
}
|
332
|
+
};
|
298
333
|
}
|