@ukeyfe/ukey-tron-provider 2.2.47 → 2.2.48
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/ProviderTron.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import SunWeb from 'sunweb';
|
|
|
4
4
|
import { IInpageProviderConfig } from '@ukeyfe/cross-inpage-provider-core';
|
|
5
5
|
import { ProviderTronBase } from './ProviderTronBase';
|
|
6
6
|
import { IProviderTron, ProviderEvents, ProviderEventsMap, ConsoleLike, Nodes, Callback, RequestArguments } from './types';
|
|
7
|
-
type
|
|
7
|
+
type UKeyTronProviderProps = IInpageProviderConfig & {
|
|
8
8
|
timeout?: number;
|
|
9
9
|
};
|
|
10
10
|
export declare const CONTRACT_ADDRESS: {
|
|
@@ -13,7 +13,7 @@ export declare const CONTRACT_ADDRESS: {
|
|
|
13
13
|
};
|
|
14
14
|
export declare const SIDE_CHAIN_ID = "41E209E4DE650F0150788E8EC5CAFA240A23EB8EB7";
|
|
15
15
|
export declare const AUTO_REQUEST_ACCOUNTS_ORIGIN_WHITE_LIST: string[];
|
|
16
|
-
export declare const TRON_REQUEST_ACCOUNTS_LOCAL_KEY = "
|
|
16
|
+
export declare const TRON_REQUEST_ACCOUNTS_LOCAL_KEY = "ukey_tron_request_accounts_local_key";
|
|
17
17
|
export declare const TRON_REQUEST_ACCOUNTS_INTERVAL: number;
|
|
18
18
|
declare class ProviderTron extends ProviderTronBase implements IProviderTron {
|
|
19
19
|
readonly isTronLink = true;
|
|
@@ -27,7 +27,7 @@ declare class ProviderTron extends ProviderTronBase implements IProviderTron {
|
|
|
27
27
|
private _accounts;
|
|
28
28
|
private _nodes;
|
|
29
29
|
private readonly _log;
|
|
30
|
-
constructor(props:
|
|
30
|
+
constructor(props: UKeyTronProviderProps);
|
|
31
31
|
private _registerTronWeb;
|
|
32
32
|
private _initialize;
|
|
33
33
|
private _registerEvents;
|
package/dist/ProviderTron.js
CHANGED
|
@@ -30,10 +30,10 @@ export const AUTO_REQUEST_ACCOUNTS_ORIGIN_WHITE_LIST = [
|
|
|
30
30
|
'https://tronscan.io',
|
|
31
31
|
'https://app.justlend.org',
|
|
32
32
|
];
|
|
33
|
-
export const TRON_REQUEST_ACCOUNTS_LOCAL_KEY = '
|
|
33
|
+
export const TRON_REQUEST_ACCOUNTS_LOCAL_KEY = 'ukey_tron_request_accounts_local_key';
|
|
34
34
|
export const TRON_REQUEST_ACCOUNTS_INTERVAL = 10 * 60 * 1000; // ten minutes
|
|
35
35
|
const globalWindow = typeof window !== 'undefined' ? window : global;
|
|
36
|
-
class
|
|
36
|
+
class UKeyTronWeb extends TronWeb {
|
|
37
37
|
constructor(props, provider) {
|
|
38
38
|
super(props);
|
|
39
39
|
this.provider = provider;
|
|
@@ -81,9 +81,9 @@ class ProviderTron extends ProviderTronBase {
|
|
|
81
81
|
_registerTronWeb(nodes) {
|
|
82
82
|
if (isEmpty(nodes))
|
|
83
83
|
return null;
|
|
84
|
-
const tronWeb = new
|
|
85
|
-
const tronWeb1 = new
|
|
86
|
-
const tronWeb2 = new
|
|
84
|
+
const tronWeb = new UKeyTronWeb(Object.assign({}, nodes), this);
|
|
85
|
+
const tronWeb1 = new UKeyTronWeb(Object.assign({}, nodes), this);
|
|
86
|
+
const tronWeb2 = new UKeyTronWeb(Object.assign({}, nodes), this);
|
|
87
87
|
const sunWeb = new SunWeb(tronWeb1, tronWeb2, CONTRACT_ADDRESS.MAIN, CONTRACT_ADDRESS.SIDE, SIDE_CHAIN_ID);
|
|
88
88
|
return { tronWeb, sunWeb };
|
|
89
89
|
}
|
|
@@ -98,10 +98,10 @@ class ProviderTron extends ProviderTronBase {
|
|
|
98
98
|
return;
|
|
99
99
|
const { sunWeb, tronWeb } = resp;
|
|
100
100
|
if (window.tronWeb !== undefined) {
|
|
101
|
-
this._log.warn('
|
|
101
|
+
this._log.warn('UKey: TronWeb is already initiated. Ukey will overwrite the current instance');
|
|
102
102
|
}
|
|
103
103
|
if (window.sunWeb !== undefined) {
|
|
104
|
-
this._log.warn('
|
|
104
|
+
this._log.warn('UKey: TronWeb is already initiated. Ukey will overwrite the current instance');
|
|
105
105
|
}
|
|
106
106
|
this.tronWeb = tronWeb;
|
|
107
107
|
this.sunWeb = sunWeb;
|
|
@@ -113,7 +113,7 @@ class ProviderTron extends ProviderTronBase {
|
|
|
113
113
|
get() {
|
|
114
114
|
var _a;
|
|
115
115
|
if (!self._connected) {
|
|
116
|
-
self._log.warn('
|
|
116
|
+
self._log.warn('UKey: We recommend that DApp developers use $ukey.tron.request({method: "tron_requestAccounts"}) to request users’ account information at the earliest time possible in order to get a complete TronWeb injection.');
|
|
117
117
|
const origin = ((_a = globalWindow === null || globalWindow === void 0 ? void 0 : globalWindow.location) === null || _a === void 0 ? void 0 : _a.origin) || '';
|
|
118
118
|
if (origin && AUTO_REQUEST_ACCOUNTS_ORIGIN_WHITE_LIST.includes(origin)) {
|
|
119
119
|
const requestAccountsLocalStr = localStorage.getItem(TRON_REQUEST_ACCOUNTS_LOCAL_KEY);
|
|
@@ -150,12 +150,12 @@ class ProviderTron extends ProviderTronBase {
|
|
|
150
150
|
this._initialized = true;
|
|
151
151
|
}
|
|
152
152
|
catch (error) {
|
|
153
|
-
this._log.error('
|
|
153
|
+
this._log.error('UKey: Failed to get initial state. Please report this bug.', error);
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
_registerEvents() {
|
|
158
|
-
window.addEventListener('
|
|
158
|
+
window.addEventListener('ukey_bridge_disconnect', () => {
|
|
159
159
|
this.__handleDisconnected();
|
|
160
160
|
});
|
|
161
161
|
this.on(ProviderEvents.MESSAGE_LOW_LEVEL, (payload) => {
|
|
@@ -179,12 +179,12 @@ class ProviderTron extends ProviderTronBase {
|
|
|
179
179
|
_handleAccountsChanged(accounts) {
|
|
180
180
|
let _accounts = accounts;
|
|
181
181
|
if (!Array.isArray(accounts)) {
|
|
182
|
-
this._log.error('
|
|
182
|
+
this._log.error('Ukey: Received invalid accounts parameter. Please report this bug.', accounts);
|
|
183
183
|
_accounts = [];
|
|
184
184
|
}
|
|
185
185
|
for (const account of _accounts) {
|
|
186
186
|
if (typeof account !== 'string') {
|
|
187
|
-
this._log.error('
|
|
187
|
+
this._log.error('Ukey: Received non-string account. Please report this bug.', accounts);
|
|
188
188
|
_accounts = [];
|
|
189
189
|
break;
|
|
190
190
|
}
|
package/dist/cjs/ProviderTron.js
CHANGED
|
@@ -38,10 +38,10 @@ exports.AUTO_REQUEST_ACCOUNTS_ORIGIN_WHITE_LIST = [
|
|
|
38
38
|
'https://tronscan.io',
|
|
39
39
|
'https://app.justlend.org',
|
|
40
40
|
];
|
|
41
|
-
exports.TRON_REQUEST_ACCOUNTS_LOCAL_KEY = '
|
|
41
|
+
exports.TRON_REQUEST_ACCOUNTS_LOCAL_KEY = 'ukey_tron_request_accounts_local_key';
|
|
42
42
|
exports.TRON_REQUEST_ACCOUNTS_INTERVAL = 10 * 60 * 1000; // ten minutes
|
|
43
43
|
const globalWindow = typeof window !== 'undefined' ? window : global;
|
|
44
|
-
class
|
|
44
|
+
class UKeyTronWeb extends tronweb_1.TronWeb {
|
|
45
45
|
constructor(props, provider) {
|
|
46
46
|
super(props);
|
|
47
47
|
this.provider = provider;
|
|
@@ -89,9 +89,9 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
|
|
|
89
89
|
_registerTronWeb(nodes) {
|
|
90
90
|
if ((0, lodash_es_1.isEmpty)(nodes))
|
|
91
91
|
return null;
|
|
92
|
-
const tronWeb = new
|
|
93
|
-
const tronWeb1 = new
|
|
94
|
-
const tronWeb2 = new
|
|
92
|
+
const tronWeb = new UKeyTronWeb(Object.assign({}, nodes), this);
|
|
93
|
+
const tronWeb1 = new UKeyTronWeb(Object.assign({}, nodes), this);
|
|
94
|
+
const tronWeb2 = new UKeyTronWeb(Object.assign({}, nodes), this);
|
|
95
95
|
const sunWeb = new sunweb_1.default(tronWeb1, tronWeb2, exports.CONTRACT_ADDRESS.MAIN, exports.CONTRACT_ADDRESS.SIDE, exports.SIDE_CHAIN_ID);
|
|
96
96
|
return { tronWeb, sunWeb };
|
|
97
97
|
}
|
|
@@ -106,10 +106,10 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
|
|
|
106
106
|
return;
|
|
107
107
|
const { sunWeb, tronWeb } = resp;
|
|
108
108
|
if (window.tronWeb !== undefined) {
|
|
109
|
-
this._log.warn('
|
|
109
|
+
this._log.warn('UKey: TronWeb is already initiated. Ukey will overwrite the current instance');
|
|
110
110
|
}
|
|
111
111
|
if (window.sunWeb !== undefined) {
|
|
112
|
-
this._log.warn('
|
|
112
|
+
this._log.warn('UKey: TronWeb is already initiated. Ukey will overwrite the current instance');
|
|
113
113
|
}
|
|
114
114
|
this.tronWeb = tronWeb;
|
|
115
115
|
this.sunWeb = sunWeb;
|
|
@@ -121,7 +121,7 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
|
|
|
121
121
|
get() {
|
|
122
122
|
var _a;
|
|
123
123
|
if (!self._connected) {
|
|
124
|
-
self._log.warn('
|
|
124
|
+
self._log.warn('UKey: We recommend that DApp developers use $ukey.tron.request({method: "tron_requestAccounts"}) to request users’ account information at the earliest time possible in order to get a complete TronWeb injection.');
|
|
125
125
|
const origin = ((_a = globalWindow === null || globalWindow === void 0 ? void 0 : globalWindow.location) === null || _a === void 0 ? void 0 : _a.origin) || '';
|
|
126
126
|
if (origin && exports.AUTO_REQUEST_ACCOUNTS_ORIGIN_WHITE_LIST.includes(origin)) {
|
|
127
127
|
const requestAccountsLocalStr = localStorage.getItem(exports.TRON_REQUEST_ACCOUNTS_LOCAL_KEY);
|
|
@@ -158,12 +158,12 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
|
|
|
158
158
|
this._initialized = true;
|
|
159
159
|
}
|
|
160
160
|
catch (error) {
|
|
161
|
-
this._log.error('
|
|
161
|
+
this._log.error('UKey: Failed to get initial state. Please report this bug.', error);
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
_registerEvents() {
|
|
166
|
-
window.addEventListener('
|
|
166
|
+
window.addEventListener('ukey_bridge_disconnect', () => {
|
|
167
167
|
this.__handleDisconnected();
|
|
168
168
|
});
|
|
169
169
|
this.on(types_1.ProviderEvents.MESSAGE_LOW_LEVEL, (payload) => {
|
|
@@ -187,12 +187,12 @@ class ProviderTron extends ProviderTronBase_1.ProviderTronBase {
|
|
|
187
187
|
_handleAccountsChanged(accounts) {
|
|
188
188
|
let _accounts = accounts;
|
|
189
189
|
if (!Array.isArray(accounts)) {
|
|
190
|
-
this._log.error('
|
|
190
|
+
this._log.error('Ukey: Received invalid accounts parameter. Please report this bug.', accounts);
|
|
191
191
|
_accounts = [];
|
|
192
192
|
}
|
|
193
193
|
for (const account of _accounts) {
|
|
194
194
|
if (typeof account !== 'string') {
|
|
195
|
-
this._log.error('
|
|
195
|
+
this._log.error('Ukey: Received non-string account. Please report this bug.', accounts);
|
|
196
196
|
_accounts = [];
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.registerTIP6963Provider = registerTIP6963Provider;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
|
-
function registerTIP6963Provider({ uuid = (0, uuid_1.v4)(), name = '
|
|
5
|
+
function registerTIP6963Provider({ uuid = (0, uuid_1.v4)(), name = 'UKey', rdns = 'so.ukey.app.wallet', image, provider, }) {
|
|
6
6
|
// TIP-6963: https://github.com/tronprotocol/tips/issues/737
|
|
7
7
|
const info = {
|
|
8
8
|
uuid,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidV4 } from 'uuid';
|
|
2
|
-
export function registerTIP6963Provider({ uuid = uuidV4(), name = '
|
|
2
|
+
export function registerTIP6963Provider({ uuid = uuidV4(), name = 'UKey', rdns = 'so.ukey.app.wallet', image, provider, }) {
|
|
3
3
|
// TIP-6963: https://github.com/tronprotocol/tips/issues/737
|
|
4
4
|
const info = {
|
|
5
5
|
uuid,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ukeyfe/ukey-tron-provider",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.48",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@noble/secp256k1": "1.7.1",
|
|
31
|
-
"@ukeyfe/cross-inpage-provider-core": "2.2.
|
|
32
|
-
"@ukeyfe/cross-inpage-provider-errors": "2.2.
|
|
33
|
-
"@ukeyfe/cross-inpage-provider-types": "2.2.
|
|
34
|
-
"@ukeyfe/extension-bridge-injected": "2.2.
|
|
31
|
+
"@ukeyfe/cross-inpage-provider-core": "2.2.48",
|
|
32
|
+
"@ukeyfe/cross-inpage-provider-errors": "2.2.48",
|
|
33
|
+
"@ukeyfe/cross-inpage-provider-types": "2.2.48",
|
|
34
|
+
"@ukeyfe/extension-bridge-injected": "2.2.48",
|
|
35
35
|
"lodash-es": "^4.17.21",
|
|
36
36
|
"querystring": "^0.2.1",
|
|
37
37
|
"sunweb": "^1.0.7",
|