@onekeyfe/onekey-tron-provider 2.2.43 → 2.2.44

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.
@@ -218,6 +218,7 @@ class ProviderTron extends ProviderTronBase {
218
218
  this._postMessage(ProviderEvents.ACCOUNTS_CHANGED, {
219
219
  address,
220
220
  });
221
+ this.emit(ProviderEvents.ACCOUNTS_CHANGED, [address]);
221
222
  }
222
223
  }
223
224
  }
@@ -263,6 +264,7 @@ class ProviderTron extends ProviderTronBase {
263
264
  chainId,
264
265
  chain: '_',
265
266
  } }));
267
+ this.emit(ProviderEvents.CHAIN_CHANGED, chainId);
266
268
  }
267
269
  }
268
270
  _requestAccounts(args) {
@@ -226,6 +226,7 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
226
226
  this._postMessage(types_1.ProviderEvents.ACCOUNTS_CHANGED, {
227
227
  address,
228
228
  });
229
+ this.emit(types_1.ProviderEvents.ACCOUNTS_CHANGED, [address]);
229
230
  }
230
231
  }
231
232
  }
@@ -271,6 +272,7 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
271
272
  chainId,
272
273
  chain: '_',
273
274
  } }));
275
+ this.emit(types_1.ProviderEvents.CHAIN_CHANGED, chainId);
274
276
  }
275
277
  }
276
278
  _requestAccounts(args) {
package/dist/cjs/index.js CHANGED
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ProviderTronBase"), exports);
18
18
  __exportStar(require("./ProviderTron"), exports);
19
+ __exportStar(require("./registerTIP6963Provider"), exports);
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerTIP6963Provider = registerTIP6963Provider;
4
+ const uuid_1 = require("uuid");
5
+ function registerTIP6963Provider({ uuid = (0, uuid_1.v4)(), name = 'OneKey', rdns = 'so.onekey.app.wallet', image, provider, }) {
6
+ // TIP-6963: https://github.com/tronprotocol/tips/issues/737
7
+ const info = {
8
+ uuid,
9
+ name,
10
+ icon: image,
11
+ rdns,
12
+ };
13
+ function announceProvider() {
14
+ window.dispatchEvent(new CustomEvent('TIP6963:announceProvider', {
15
+ detail: { info, provider: provider },
16
+ }));
17
+ }
18
+ window.addEventListener('TIP6963:requestProvider', announceProvider);
19
+ announceProvider();
20
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './ProviderTronBase';
2
2
  export * from './ProviderTron';
3
+ export * from './registerTIP6963Provider';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './ProviderTronBase';
2
2
  export * from './ProviderTron';
3
+ export * from './registerTIP6963Provider';
@@ -0,0 +1,8 @@
1
+ import type { ProviderTron } from './ProviderTron';
2
+ export declare function registerTIP6963Provider({ uuid, name, rdns, image, provider, }: {
3
+ uuid?: string;
4
+ name?: string;
5
+ rdns?: string;
6
+ image: string;
7
+ provider: ProviderTron;
8
+ }): void;
@@ -0,0 +1,17 @@
1
+ import { v4 as uuidV4 } from 'uuid';
2
+ export function registerTIP6963Provider({ uuid = uuidV4(), name = 'OneKey', rdns = 'so.onekey.app.wallet', image, provider, }) {
3
+ // TIP-6963: https://github.com/tronprotocol/tips/issues/737
4
+ const info = {
5
+ uuid,
6
+ name,
7
+ icon: image,
8
+ rdns,
9
+ };
10
+ function announceProvider() {
11
+ window.dispatchEvent(new CustomEvent('TIP6963:announceProvider', {
12
+ detail: { info, provider: provider },
13
+ }));
14
+ }
15
+ window.addEventListener('TIP6963:requestProvider', announceProvider);
16
+ announceProvider();
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/onekey-tron-provider",
3
- "version": "2.2.43",
3
+ "version": "2.2.44",
4
4
  "keywords": [
5
5
  "cross-inpage-provider"
6
6
  ],
@@ -28,17 +28,19 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@noble/secp256k1": "1.7.1",
31
- "@onekeyfe/cross-inpage-provider-core": "2.2.43",
32
- "@onekeyfe/cross-inpage-provider-errors": "2.2.43",
33
- "@onekeyfe/cross-inpage-provider-types": "2.2.43",
34
- "@onekeyfe/extension-bridge-injected": "2.2.43",
31
+ "@onekeyfe/cross-inpage-provider-core": "2.2.44",
32
+ "@onekeyfe/cross-inpage-provider-errors": "2.2.44",
33
+ "@onekeyfe/cross-inpage-provider-types": "2.2.44",
34
+ "@onekeyfe/extension-bridge-injected": "2.2.44",
35
35
  "lodash-es": "^4.17.21",
36
36
  "querystring": "^0.2.1",
37
37
  "sunweb": "^1.0.7",
38
- "tronweb": "^6.0.1"
38
+ "tronweb": "^6.0.1",
39
+ "uuid": "^8.3.2"
39
40
  },
40
41
  "devDependencies": {
41
- "@types/lodash-es": "^4.17.12"
42
+ "@types/lodash-es": "^4.17.12",
43
+ "@types/uuid": "^8.3.2"
42
44
  },
43
- "gitHead": "c0402a33d082e18d93f59c8c1d7bee969ad480d6"
45
+ "gitHead": "ce30bbf920e51ab3603115a17342df4899018139"
44
46
  }