@onekeyfe/onekey-near-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.
|
@@ -133,9 +133,11 @@ declare class OneKeyNearProvider extends ProviderNearBase {
|
|
|
133
133
|
_registerEvents(): void;
|
|
134
134
|
_handleMessageNotificationEvent(payload: any): void;
|
|
135
135
|
_handleBridgeDisconnect(): void;
|
|
136
|
+
isAccountsChanged(account: NearAccountInfo | undefined): boolean;
|
|
136
137
|
_handleAccountsChanged(payload: NearAccountsChangedPayload, { emit }?: {
|
|
137
138
|
emit?: boolean | undefined;
|
|
138
139
|
}): void;
|
|
140
|
+
isNetworkChanged(networkId: string): boolean;
|
|
139
141
|
_handleNetworkChanged(payload: NearNetworkChangedPayload, { emit }?: {
|
|
140
142
|
emit?: boolean | undefined;
|
|
141
143
|
}): void;
|
|
@@ -192,11 +192,14 @@ class OneKeyNearProvider extends ProviderNearBase {
|
|
|
192
192
|
this._isInstalled = false;
|
|
193
193
|
this.emit(PROVIDER_EVENTS.disconnect);
|
|
194
194
|
}
|
|
195
|
+
isAccountsChanged(account) {
|
|
196
|
+
return (account === null || account === void 0 ? void 0 : account.accountId) !== this.getAccountId();
|
|
197
|
+
}
|
|
195
198
|
_handleAccountsChanged(payload, { emit = true } = {}) {
|
|
196
199
|
const accounts = (payload === null || payload === void 0 ? void 0 : payload.accounts) || [];
|
|
197
200
|
const account = accounts === null || accounts === void 0 ? void 0 : accounts[0];
|
|
198
201
|
const hasAccount = account && (account === null || account === void 0 ? void 0 : account.accountId);
|
|
199
|
-
if (hasAccount &&
|
|
202
|
+
if (hasAccount && this.isAccountsChanged(account)) {
|
|
200
203
|
this._saveAuthData(account);
|
|
201
204
|
emit && this.emit(PROVIDER_EVENTS.accountsChanged, payload);
|
|
202
205
|
}
|
|
@@ -205,9 +208,12 @@ class OneKeyNearProvider extends ProviderNearBase {
|
|
|
205
208
|
emit && this.emit(PROVIDER_EVENTS.accountsChanged, { accounts: [] });
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
|
-
|
|
211
|
+
isNetworkChanged(networkId) {
|
|
209
212
|
var _a;
|
|
210
|
-
|
|
213
|
+
return networkId !== ((_a = this._selectedNetwork) === null || _a === void 0 ? void 0 : _a.networkId);
|
|
214
|
+
}
|
|
215
|
+
_handleNetworkChanged(payload, { emit = true } = {}) {
|
|
216
|
+
if (payload && this.isNetworkChanged(payload.networkId)) {
|
|
211
217
|
this._selectedNetwork = payload;
|
|
212
218
|
emit && this.emit(PROVIDER_EVENTS.networkChanged, payload);
|
|
213
219
|
emit && this.emit(PROVIDER_EVENTS.chainChanged, payload);
|
|
@@ -199,11 +199,14 @@ class OneKeyNearProvider extends ProviderNearBase_1.ProviderNearBase {
|
|
|
199
199
|
this._isInstalled = false;
|
|
200
200
|
this.emit(PROVIDER_EVENTS.disconnect);
|
|
201
201
|
}
|
|
202
|
+
isAccountsChanged(account) {
|
|
203
|
+
return (account === null || account === void 0 ? void 0 : account.accountId) !== this.getAccountId();
|
|
204
|
+
}
|
|
202
205
|
_handleAccountsChanged(payload, { emit = true } = {}) {
|
|
203
206
|
const accounts = (payload === null || payload === void 0 ? void 0 : payload.accounts) || [];
|
|
204
207
|
const account = accounts === null || accounts === void 0 ? void 0 : accounts[0];
|
|
205
208
|
const hasAccount = account && (account === null || account === void 0 ? void 0 : account.accountId);
|
|
206
|
-
if (hasAccount &&
|
|
209
|
+
if (hasAccount && this.isAccountsChanged(account)) {
|
|
207
210
|
this._saveAuthData(account);
|
|
208
211
|
emit && this.emit(PROVIDER_EVENTS.accountsChanged, payload);
|
|
209
212
|
}
|
|
@@ -212,9 +215,12 @@ class OneKeyNearProvider extends ProviderNearBase_1.ProviderNearBase {
|
|
|
212
215
|
emit && this.emit(PROVIDER_EVENTS.accountsChanged, { accounts: [] });
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
|
-
|
|
218
|
+
isNetworkChanged(networkId) {
|
|
216
219
|
var _a;
|
|
217
|
-
|
|
220
|
+
return networkId !== ((_a = this._selectedNetwork) === null || _a === void 0 ? void 0 : _a.networkId);
|
|
221
|
+
}
|
|
222
|
+
_handleNetworkChanged(payload, { emit = true } = {}) {
|
|
223
|
+
if (payload && this.isNetworkChanged(payload.networkId)) {
|
|
218
224
|
this._selectedNetwork = payload;
|
|
219
225
|
emit && this.emit(PROVIDER_EVENTS.networkChanged, payload);
|
|
220
226
|
emit && this.emit(PROVIDER_EVENTS.chainChanged, payload);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-near-provider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"near-api-js": "^0.44.2"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@onekeyfe/cross-inpage-provider-core": "1.1.
|
|
39
|
-
"@onekeyfe/cross-inpage-provider-errors": "1.1.
|
|
40
|
-
"@onekeyfe/cross-inpage-provider-types": "1.1.
|
|
41
|
-
"@onekeyfe/extension-bridge-injected": "1.1.
|
|
38
|
+
"@onekeyfe/cross-inpage-provider-core": "1.1.7",
|
|
39
|
+
"@onekeyfe/cross-inpage-provider-errors": "1.1.7",
|
|
40
|
+
"@onekeyfe/cross-inpage-provider-types": "1.1.7",
|
|
41
|
+
"@onekeyfe/extension-bridge-injected": "1.1.7",
|
|
42
42
|
"borsh": "^0.6.0",
|
|
43
43
|
"depd": "^2.0.0",
|
|
44
44
|
"tweetnacl": "^1.0.3"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "caaa1fd03f388765f3d8b1bf8f013c2dfbba7a1b"
|
|
47
47
|
}
|