@onekeyfe/onekey-conflux-provider 1.1.6 → 1.1.7
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.
|
@@ -18,7 +18,9 @@ declare class ProviderConflux extends ProviderConfluxBase implements IProviderCo
|
|
|
18
18
|
constructor(props: OneKeyConfluxProviderProps);
|
|
19
19
|
private _initializeState;
|
|
20
20
|
private _registerEvents;
|
|
21
|
+
isAccountsChanged(accounts: string[]): boolean;
|
|
21
22
|
private _handleAccountsChanged;
|
|
23
|
+
isNetworkChanged(chainId: string): boolean;
|
|
22
24
|
private _handleChainChanged;
|
|
23
25
|
private _handleConnected;
|
|
24
26
|
private _handleDisconnected;
|
package/dist/ProviderConflux.js
CHANGED
|
@@ -93,6 +93,9 @@ class ProviderConflux extends ProviderConfluxBase {
|
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
|
+
isAccountsChanged(accounts) {
|
|
97
|
+
return !dequal(this._accounts, accounts);
|
|
98
|
+
}
|
|
96
99
|
_handleAccountsChanged(accounts) {
|
|
97
100
|
let _accounts = accounts;
|
|
98
101
|
if (!Array.isArray(accounts)) {
|
|
@@ -106,7 +109,7 @@ class ProviderConflux extends ProviderConfluxBase {
|
|
|
106
109
|
break;
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
|
-
if (
|
|
112
|
+
if (this.isAccountsChanged(_accounts)) {
|
|
110
113
|
this._accounts = _accounts;
|
|
111
114
|
if (this._selectedAddress !== _accounts[0]) {
|
|
112
115
|
this._selectedAddress = _accounts[0];
|
|
@@ -116,6 +119,9 @@ class ProviderConflux extends ProviderConfluxBase {
|
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
}
|
|
122
|
+
isNetworkChanged(chainId) {
|
|
123
|
+
return chainId !== this._chainId;
|
|
124
|
+
}
|
|
119
125
|
_handleChainChanged({ chainId, networkId } = {}) {
|
|
120
126
|
if (!chainId ||
|
|
121
127
|
typeof chainId !== 'string' ||
|
|
@@ -133,7 +139,7 @@ class ProviderConflux extends ProviderConfluxBase {
|
|
|
133
139
|
}
|
|
134
140
|
else {
|
|
135
141
|
this._handleConnected({ chainId, networkId });
|
|
136
|
-
if (
|
|
142
|
+
if (this.isNetworkChanged(chainId)) {
|
|
137
143
|
this._chainId = chainId;
|
|
138
144
|
if (this._initialized) {
|
|
139
145
|
this.emit(ProviderEvents.CHAIN_CHANGED, chainId);
|
|
@@ -101,6 +101,9 @@ class ProviderConflux extends ProviderConfluxBase_1.ProviderConfluxBase {
|
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
+
isAccountsChanged(accounts) {
|
|
105
|
+
return !(0, fast_deep_equal_1.default)(this._accounts, accounts);
|
|
106
|
+
}
|
|
104
107
|
_handleAccountsChanged(accounts) {
|
|
105
108
|
let _accounts = accounts;
|
|
106
109
|
if (!Array.isArray(accounts)) {
|
|
@@ -114,7 +117,7 @@ class ProviderConflux extends ProviderConfluxBase_1.ProviderConfluxBase {
|
|
|
114
117
|
break;
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
if (
|
|
120
|
+
if (this.isAccountsChanged(_accounts)) {
|
|
118
121
|
this._accounts = _accounts;
|
|
119
122
|
if (this._selectedAddress !== _accounts[0]) {
|
|
120
123
|
this._selectedAddress = _accounts[0];
|
|
@@ -124,6 +127,9 @@ class ProviderConflux extends ProviderConfluxBase_1.ProviderConfluxBase {
|
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
}
|
|
130
|
+
isNetworkChanged(chainId) {
|
|
131
|
+
return chainId !== this._chainId;
|
|
132
|
+
}
|
|
127
133
|
_handleChainChanged({ chainId, networkId } = {}) {
|
|
128
134
|
if (!chainId ||
|
|
129
135
|
typeof chainId !== 'string' ||
|
|
@@ -141,7 +147,7 @@ class ProviderConflux extends ProviderConfluxBase_1.ProviderConfluxBase {
|
|
|
141
147
|
}
|
|
142
148
|
else {
|
|
143
149
|
this._handleConnected({ chainId, networkId });
|
|
144
|
-
if (
|
|
150
|
+
if (this.isNetworkChanged(chainId)) {
|
|
145
151
|
this._chainId = chainId;
|
|
146
152
|
if (this._initialized) {
|
|
147
153
|
this.emit(types_1.ProviderEvents.CHAIN_CHANGED, chainId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-conflux-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-errors": "1.1.
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.
|
|
34
|
-
"@onekeyfe/extension-bridge-injected": "1.1.
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.7",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.7",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.7",
|
|
34
|
+
"@onekeyfe/extension-bridge-injected": "1.1.7"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "caaa1fd03f388765f3d8b1bf8f013c2dfbba7a1b"
|
|
37
37
|
}
|