@rango-dev/provider-tron-link 0.1.16-next.6 → 0.1.16-next.8
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/helpers.d.ts +2 -1
- package/dist/helpers.d.ts.map +1 -0
- package/dist/index.d.ts +15 -14
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -8
- package/dist/index.js.map +7 -0
- package/dist/signer.d.ts +3 -2
- package/dist/signer.d.ts.map +1 -0
- package/package.json +6 -8
- package/dist/provider-tron-link.cjs.development.js +0 -460
- package/dist/provider-tron-link.cjs.development.js.map +0 -1
- package/dist/provider-tron-link.cjs.production.min.js +0 -2
- package/dist/provider-tron-link.cjs.production.min.js.map +0 -1
- package/dist/provider-tron-link.esm.js +0 -450
- package/dist/provider-tron-link.esm.js.map +0 -1
package/dist/helpers.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function tronLink(): any;
|
|
1
|
+
export declare function tronLink(): any;
|
|
2
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,QAIvB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Subscribe } from '@rango-dev/wallets-shared';
|
|
2
|
-
import { Network, WalletTypes, CanSwitchNetwork, Connect, WalletInfo } from '@rango-dev/wallets-shared';
|
|
3
|
-
import { tronLink as tronLink_instance } from './helpers';
|
|
4
|
-
import { SignerFactory, BlockchainMeta } from 'rango-types';
|
|
5
|
-
export declare const config: {
|
|
6
|
-
type: WalletTypes;
|
|
7
|
-
defaultNetwork: Network;
|
|
8
|
-
};
|
|
9
|
-
export declare const getInstance: typeof tronLink_instance;
|
|
10
|
-
export declare const connect: Connect;
|
|
11
|
-
export declare const subscribe: Subscribe;
|
|
12
|
-
export declare const canSwitchNetworkTo: CanSwitchNetwork;
|
|
13
|
-
export declare const getSigners: (provider: any) => SignerFactory;
|
|
14
|
-
export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
|
|
1
|
+
import { Subscribe } from '@rango-dev/wallets-shared';
|
|
2
|
+
import { Network, WalletTypes, CanSwitchNetwork, Connect, WalletInfo } from '@rango-dev/wallets-shared';
|
|
3
|
+
import { tronLink as tronLink_instance } from './helpers';
|
|
4
|
+
import { SignerFactory, BlockchainMeta } from 'rango-types';
|
|
5
|
+
export declare const config: {
|
|
6
|
+
type: WalletTypes;
|
|
7
|
+
defaultNetwork: Network;
|
|
8
|
+
};
|
|
9
|
+
export declare const getInstance: typeof tronLink_instance;
|
|
10
|
+
export declare const connect: Connect;
|
|
11
|
+
export declare const subscribe: Subscribe;
|
|
12
|
+
export declare const canSwitchNetworkTo: CanSwitchNetwork;
|
|
13
|
+
export declare const getSigners: (provider: any) => SignerFactory;
|
|
14
|
+
export declare const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo;
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,UAAU,EACX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAkB,MAAM,aAAa,CAAC;AAM5E,eAAO,MAAM,MAAM;;;CAGlB,CAAC;AAEF,eAAO,MAAM,WAAW,0BAAoB,CAAC;AAE7C,eAAO,MAAM,OAAO,EAAE,OAiBrB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,SAevB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAA8B,CAAC;AAEhE,eAAO,MAAM,UAAU,EAAE,CAAC,QAAQ,EAAE,GAAG,KAAK,aAAsB,CAAC;AAEnE,eAAO,MAAM,aAAa,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,UAiBjE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (process.env.NODE_ENV === 'production') {
|
|
5
|
-
module.exports = require('./provider-tron-link.cjs.production.min.js')
|
|
6
|
-
} else {
|
|
7
|
-
module.exports = require('./provider-tron-link.cjs.development.js')
|
|
8
|
-
}
|
|
1
|
+
var c=Object.defineProperty;var o=(e,t)=>c(e,"name",{value:t,configurable:!0});import{Network as i,WalletTypes as d}from"@rango-dev/wallets-shared";function a(){let{tronLink:e}=window;return e||null}o(a,"tronLink");import{DefaultTronSigner as l}from"@rango-dev/signer-tron";import{DefaultSignerFactory as g,TransactionType as m}from"rango-types";function r(e){let t=new g;return t.registerSigner(m.TRON,new l(e)),t}o(r,"getSigners");import{tronBlockchain as p}from"rango-types";var f=d.TRON_LINK,A={type:f,defaultNetwork:i.TRON},B=a,O=o(async({instance:e})=>{let t;if(e&&!e.ready){if(t=await e.request({method:"tron_requestAccounts"}),!t)throw new Error("Please unlock your TronLink extension first.");if(t.code!==200){if(t?.code&&t.message)throw new Error(t.message)}}let n=e.tronWeb.address.fromHex((await e.tronWeb.trx.getAccount()).address.toString());return{accounts:n?[n]:[],chainId:i.TRON}},"connect"),j=o(({updateAccounts:e,disconnect:t})=>{window.addEventListener("message",n=>{if(n.data.isTronLink&&n.data.message&&n.data.message.action=="accountsChanged"){let s=n?.data?.message?.data?.address;s?e([s]):t()}})},"subscribe"),D=o(()=>!1,"canSwitchNetworkTo"),M=r,_=o(e=>{let t=p(e);return{name:"TronLink",img:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png",installLink:{CHROME:"https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec",BRAVE:"https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec",DEFAULT:"https://www.tronlink.org"},color:"#96e7ed",supportedChains:t}},"getWalletInfo");export{D as canSwitchNetworkTo,A as config,O as connect,B as getInstance,M as getSigners,_ as getWalletInfo,j as subscribe};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/helpers.ts", "../src/signer.ts"],
|
|
4
|
+
"sourcesContent": ["import { Subscribe } from '@rango-dev/wallets-shared';\nimport {\n Network,\n WalletTypes,\n CanSwitchNetwork,\n Connect,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { tronLink as tronLink_instance } from './helpers';\nimport signer from './signer';\nimport { SignerFactory, BlockchainMeta, tronBlockchain } from 'rango-types';\n\n// https://docs.tronlink.org/dapp/start-developing\n// https://developers.tron.network/docs/tronlink-events\nconst WALLET = WalletTypes.TRON_LINK;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.TRON,\n};\n\nexport const getInstance = tronLink_instance;\n\nexport const connect: Connect = async ({ instance }) => {\n let r = undefined;\n if (!!instance && !instance.ready) {\n r = await instance.request({ method: 'tron_requestAccounts' });\n if (!r) {\n throw new Error('Please unlock your TronLink extension first.');\n }\n if (r.code === 200) {\n } else if (!!r?.code && !!r.message) {\n throw new Error(r.message);\n }\n }\n const address = instance.tronWeb.address.fromHex(\n (await instance.tronWeb.trx.getAccount()).address.toString()\n );\n // TODO check connected network\n return { accounts: !!address ? [address] : [], chainId: Network.TRON };\n};\n\nexport const subscribe: Subscribe = ({ updateAccounts, disconnect }) => {\n window.addEventListener('message', (e) => {\n if (\n e.data.isTronLink &&\n e.data.message &&\n e.data.message.action == 'accountsChanged'\n ) {\n const account = e?.data?.message?.data?.address;\n if (!!account) {\n updateAccounts([account]);\n } else {\n disconnect();\n }\n }\n });\n};\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = () => false;\n\nexport const getSigners: (provider: any) => SignerFactory = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const tron = tronBlockchain(allBlockChains);\n return {\n name: 'TronLink',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n DEFAULT: 'https://www.tronlink.org',\n },\n color: '#96e7ed',\n supportedChains: tron,\n };\n};\n", "export function tronLink() {\n const { tronLink } = window;\n if (!!tronLink) return tronLink;\n return null;\n}\n", "import { DefaultTronSigner } from '@rango-dev/signer-tron';\nimport {\n DefaultSignerFactory,\n SignerFactory,\n TransactionType as TxType,\n} from 'rango-types';\n\nexport default function getSigners(provider: any): SignerFactory {\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(provider));\n return signers;\n}\n"],
|
|
5
|
+
"mappings": "+EACA,OACE,WAAAA,EACA,eAAAC,MAIK,4BCPA,SAASC,GAAW,CACzB,GAAM,CAAE,SAAAA,CAAS,EAAI,OACrB,OAAMA,GACC,IACT,CAJgBC,EAAAD,EAAA,YCAhB,OAAS,qBAAAE,MAAyB,yBAClC,OACE,wBAAAC,EAEA,mBAAmBC,MACd,cAEQ,SAARC,EAA4BC,EAA8B,CAC/D,IAAMC,EAAU,IAAIC,EACpB,OAAAD,EAAQ,eAAeE,EAAO,KAAM,IAAIC,EAAkBJ,CAAQ,CAAC,EAC5DC,CACT,CAJwBI,EAAAN,EAAA,cFGxB,OAAwC,kBAAAO,MAAsB,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"TxType", "getSigners", "provider", "signers", "DefaultSignerFactory", "TxType", "DefaultTronSigner", "__name", "tronBlockchain", "WALLET", "WalletTypes", "config", "Network", "getInstance", "tronLink", "connect", "__name", "instance", "r", "address", "subscribe", "updateAccounts", "disconnect", "e", "account", "canSwitchNetworkTo", "getSigners", "getWalletInfo", "allBlockChains", "tron", "tronBlockchain"]
|
|
7
|
+
}
|
package/dist/signer.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { SignerFactory } from 'rango-types';
|
|
2
|
-
export default function getSigners(provider: any): SignerFactory;
|
|
1
|
+
import { SignerFactory } from 'rango-types';
|
|
2
|
+
export default function getSigners(provider: any): SignerFactory;
|
|
3
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,aAAa,EAEd,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,aAAa,CAI/D"}
|
package/package.json
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/provider-tron-link",
|
|
3
|
-
"version": "0.1.16-next.
|
|
3
|
+
"version": "0.1.16-next.8",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"module": "dist/provider-tron-link.esm.js",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"typings": "dist/index.d.ts",
|
|
8
5
|
"type": "module",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"typings": "dist/index.d.ts",
|
|
9
8
|
"files": [
|
|
10
9
|
"dist",
|
|
11
10
|
"src"
|
|
12
11
|
],
|
|
13
12
|
"scripts": {
|
|
14
|
-
"
|
|
15
|
-
"build": "tsdx build --tsconfig ./tsconfig.json",
|
|
13
|
+
"build": "node ../../scripts/build/command.mjs --path wallets/provider-tron-link",
|
|
16
14
|
"clean": "rimraf dist",
|
|
17
15
|
"format": "prettier --write '{.,src}/**/*.{ts,tsx}'",
|
|
18
16
|
"lint": "eslint \"**/*.{ts,tsx}\" --ignore-path ../../.eslintignore"
|
|
19
17
|
},
|
|
20
18
|
"dependencies": {
|
|
21
|
-
"@rango-dev/signer-tron": "^0.1.15-next.
|
|
22
|
-
"@rango-dev/wallets-shared": "^0.1.15-next.
|
|
19
|
+
"@rango-dev/signer-tron": "^0.1.15-next.6",
|
|
20
|
+
"@rango-dev/wallets-shared": "^0.1.15-next.7",
|
|
23
21
|
"rango-types": "^0.1.38"
|
|
24
22
|
},
|
|
25
23
|
"publishConfig": {
|
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var walletsShared = require('@rango-dev/wallets-shared');
|
|
6
|
-
var signerTron = require('@rango-dev/signer-tron');
|
|
7
|
-
var rangoTypes = require('rango-types');
|
|
8
|
-
|
|
9
|
-
function _regeneratorRuntime() {
|
|
10
|
-
_regeneratorRuntime = function () {
|
|
11
|
-
return exports;
|
|
12
|
-
};
|
|
13
|
-
var exports = {},
|
|
14
|
-
Op = Object.prototype,
|
|
15
|
-
hasOwn = Op.hasOwnProperty,
|
|
16
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
17
|
-
obj[key] = desc.value;
|
|
18
|
-
},
|
|
19
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
20
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
21
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
22
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
23
|
-
function define(obj, key, value) {
|
|
24
|
-
return Object.defineProperty(obj, key, {
|
|
25
|
-
value: value,
|
|
26
|
-
enumerable: !0,
|
|
27
|
-
configurable: !0,
|
|
28
|
-
writable: !0
|
|
29
|
-
}), obj[key];
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
define({}, "");
|
|
33
|
-
} catch (err) {
|
|
34
|
-
define = function (obj, key, value) {
|
|
35
|
-
return obj[key] = value;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
39
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
40
|
-
generator = Object.create(protoGenerator.prototype),
|
|
41
|
-
context = new Context(tryLocsList || []);
|
|
42
|
-
return defineProperty(generator, "_invoke", {
|
|
43
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
44
|
-
}), generator;
|
|
45
|
-
}
|
|
46
|
-
function tryCatch(fn, obj, arg) {
|
|
47
|
-
try {
|
|
48
|
-
return {
|
|
49
|
-
type: "normal",
|
|
50
|
-
arg: fn.call(obj, arg)
|
|
51
|
-
};
|
|
52
|
-
} catch (err) {
|
|
53
|
-
return {
|
|
54
|
-
type: "throw",
|
|
55
|
-
arg: err
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.wrap = wrap;
|
|
60
|
-
var ContinueSentinel = {};
|
|
61
|
-
function Generator() {}
|
|
62
|
-
function GeneratorFunction() {}
|
|
63
|
-
function GeneratorFunctionPrototype() {}
|
|
64
|
-
var IteratorPrototype = {};
|
|
65
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
66
|
-
return this;
|
|
67
|
-
});
|
|
68
|
-
var getProto = Object.getPrototypeOf,
|
|
69
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
70
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
71
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
72
|
-
function defineIteratorMethods(prototype) {
|
|
73
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
74
|
-
define(prototype, method, function (arg) {
|
|
75
|
-
return this._invoke(method, arg);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
80
|
-
function invoke(method, arg, resolve, reject) {
|
|
81
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
82
|
-
if ("throw" !== record.type) {
|
|
83
|
-
var result = record.arg,
|
|
84
|
-
value = result.value;
|
|
85
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
86
|
-
invoke("next", value, resolve, reject);
|
|
87
|
-
}, function (err) {
|
|
88
|
-
invoke("throw", err, resolve, reject);
|
|
89
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
90
|
-
result.value = unwrapped, resolve(result);
|
|
91
|
-
}, function (error) {
|
|
92
|
-
return invoke("throw", error, resolve, reject);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
reject(record.arg);
|
|
96
|
-
}
|
|
97
|
-
var previousPromise;
|
|
98
|
-
defineProperty(this, "_invoke", {
|
|
99
|
-
value: function (method, arg) {
|
|
100
|
-
function callInvokeWithMethodAndArg() {
|
|
101
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
102
|
-
invoke(method, arg, resolve, reject);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
110
|
-
var state = "suspendedStart";
|
|
111
|
-
return function (method, arg) {
|
|
112
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
113
|
-
if ("completed" === state) {
|
|
114
|
-
if ("throw" === method) throw arg;
|
|
115
|
-
return doneResult();
|
|
116
|
-
}
|
|
117
|
-
for (context.method = method, context.arg = arg;;) {
|
|
118
|
-
var delegate = context.delegate;
|
|
119
|
-
if (delegate) {
|
|
120
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
121
|
-
if (delegateResult) {
|
|
122
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
123
|
-
return delegateResult;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
127
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
128
|
-
context.dispatchException(context.arg);
|
|
129
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
130
|
-
state = "executing";
|
|
131
|
-
var record = tryCatch(innerFn, self, context);
|
|
132
|
-
if ("normal" === record.type) {
|
|
133
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
134
|
-
return {
|
|
135
|
-
value: record.arg,
|
|
136
|
-
done: context.done
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
144
|
-
var methodName = context.method,
|
|
145
|
-
method = delegate.iterator[methodName];
|
|
146
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
147
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
148
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
149
|
-
var info = record.arg;
|
|
150
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
151
|
-
}
|
|
152
|
-
function pushTryEntry(locs) {
|
|
153
|
-
var entry = {
|
|
154
|
-
tryLoc: locs[0]
|
|
155
|
-
};
|
|
156
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
157
|
-
}
|
|
158
|
-
function resetTryEntry(entry) {
|
|
159
|
-
var record = entry.completion || {};
|
|
160
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
161
|
-
}
|
|
162
|
-
function Context(tryLocsList) {
|
|
163
|
-
this.tryEntries = [{
|
|
164
|
-
tryLoc: "root"
|
|
165
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
166
|
-
}
|
|
167
|
-
function values(iterable) {
|
|
168
|
-
if (iterable) {
|
|
169
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
170
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
171
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
172
|
-
if (!isNaN(iterable.length)) {
|
|
173
|
-
var i = -1,
|
|
174
|
-
next = function next() {
|
|
175
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
176
|
-
return next.value = undefined, next.done = !0, next;
|
|
177
|
-
};
|
|
178
|
-
return next.next = next;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
next: doneResult
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function doneResult() {
|
|
186
|
-
return {
|
|
187
|
-
value: undefined,
|
|
188
|
-
done: !0
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
192
|
-
value: GeneratorFunctionPrototype,
|
|
193
|
-
configurable: !0
|
|
194
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
195
|
-
value: GeneratorFunction,
|
|
196
|
-
configurable: !0
|
|
197
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
198
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
199
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
200
|
-
}, exports.mark = function (genFun) {
|
|
201
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
202
|
-
}, exports.awrap = function (arg) {
|
|
203
|
-
return {
|
|
204
|
-
__await: arg
|
|
205
|
-
};
|
|
206
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
207
|
-
return this;
|
|
208
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
209
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
210
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
211
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
212
|
-
return result.done ? result.value : iter.next();
|
|
213
|
-
});
|
|
214
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
215
|
-
return this;
|
|
216
|
-
}), define(Gp, "toString", function () {
|
|
217
|
-
return "[object Generator]";
|
|
218
|
-
}), exports.keys = function (val) {
|
|
219
|
-
var object = Object(val),
|
|
220
|
-
keys = [];
|
|
221
|
-
for (var key in object) keys.push(key);
|
|
222
|
-
return keys.reverse(), function next() {
|
|
223
|
-
for (; keys.length;) {
|
|
224
|
-
var key = keys.pop();
|
|
225
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
226
|
-
}
|
|
227
|
-
return next.done = !0, next;
|
|
228
|
-
};
|
|
229
|
-
}, exports.values = values, Context.prototype = {
|
|
230
|
-
constructor: Context,
|
|
231
|
-
reset: function (skipTempReset) {
|
|
232
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
233
|
-
},
|
|
234
|
-
stop: function () {
|
|
235
|
-
this.done = !0;
|
|
236
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
237
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
238
|
-
return this.rval;
|
|
239
|
-
},
|
|
240
|
-
dispatchException: function (exception) {
|
|
241
|
-
if (this.done) throw exception;
|
|
242
|
-
var context = this;
|
|
243
|
-
function handle(loc, caught) {
|
|
244
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
245
|
-
}
|
|
246
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
247
|
-
var entry = this.tryEntries[i],
|
|
248
|
-
record = entry.completion;
|
|
249
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
250
|
-
if (entry.tryLoc <= this.prev) {
|
|
251
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
252
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
253
|
-
if (hasCatch && hasFinally) {
|
|
254
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
255
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
256
|
-
} else if (hasCatch) {
|
|
257
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
258
|
-
} else {
|
|
259
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
260
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
abrupt: function (type, arg) {
|
|
266
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
267
|
-
var entry = this.tryEntries[i];
|
|
268
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
269
|
-
var finallyEntry = entry;
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
274
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
275
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
276
|
-
},
|
|
277
|
-
complete: function (record, afterLoc) {
|
|
278
|
-
if ("throw" === record.type) throw record.arg;
|
|
279
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
280
|
-
},
|
|
281
|
-
finish: function (finallyLoc) {
|
|
282
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
283
|
-
var entry = this.tryEntries[i];
|
|
284
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
catch: function (tryLoc) {
|
|
288
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
289
|
-
var entry = this.tryEntries[i];
|
|
290
|
-
if (entry.tryLoc === tryLoc) {
|
|
291
|
-
var record = entry.completion;
|
|
292
|
-
if ("throw" === record.type) {
|
|
293
|
-
var thrown = record.arg;
|
|
294
|
-
resetTryEntry(entry);
|
|
295
|
-
}
|
|
296
|
-
return thrown;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
throw new Error("illegal catch attempt");
|
|
300
|
-
},
|
|
301
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
|
302
|
-
return this.delegate = {
|
|
303
|
-
iterator: values(iterable),
|
|
304
|
-
resultName: resultName,
|
|
305
|
-
nextLoc: nextLoc
|
|
306
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
307
|
-
}
|
|
308
|
-
}, exports;
|
|
309
|
-
}
|
|
310
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
311
|
-
try {
|
|
312
|
-
var info = gen[key](arg);
|
|
313
|
-
var value = info.value;
|
|
314
|
-
} catch (error) {
|
|
315
|
-
reject(error);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
if (info.done) {
|
|
319
|
-
resolve(value);
|
|
320
|
-
} else {
|
|
321
|
-
Promise.resolve(value).then(_next, _throw);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function _asyncToGenerator(fn) {
|
|
325
|
-
return function () {
|
|
326
|
-
var self = this,
|
|
327
|
-
args = arguments;
|
|
328
|
-
return new Promise(function (resolve, reject) {
|
|
329
|
-
var gen = fn.apply(self, args);
|
|
330
|
-
function _next(value) {
|
|
331
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
332
|
-
}
|
|
333
|
-
function _throw(err) {
|
|
334
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
335
|
-
}
|
|
336
|
-
_next(undefined);
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
function tronLink() {
|
|
342
|
-
var _window = window,
|
|
343
|
-
tronLink = _window.tronLink;
|
|
344
|
-
if (!!tronLink) return tronLink;
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function getSigners(provider) {
|
|
349
|
-
var signers = new rangoTypes.DefaultSignerFactory();
|
|
350
|
-
signers.registerSigner(rangoTypes.TransactionType.TRON, new signerTron.DefaultTronSigner(provider));
|
|
351
|
-
return signers;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// https://docs.tronlink.org/dapp/start-developing
|
|
355
|
-
// https://developers.tron.network/docs/tronlink-events
|
|
356
|
-
var WALLET = walletsShared.WalletTypes.TRON_LINK;
|
|
357
|
-
var config = {
|
|
358
|
-
type: WALLET,
|
|
359
|
-
defaultNetwork: walletsShared.Network.TRON
|
|
360
|
-
};
|
|
361
|
-
var getInstance = tronLink;
|
|
362
|
-
var connect = /*#__PURE__*/function () {
|
|
363
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
364
|
-
var instance, r, _r, address;
|
|
365
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
366
|
-
while (1) switch (_context.prev = _context.next) {
|
|
367
|
-
case 0:
|
|
368
|
-
instance = _ref.instance;
|
|
369
|
-
r = undefined;
|
|
370
|
-
if (!(!!instance && !instance.ready)) {
|
|
371
|
-
_context.next = 13;
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
_context.next = 5;
|
|
375
|
-
return instance.request({
|
|
376
|
-
method: 'tron_requestAccounts'
|
|
377
|
-
});
|
|
378
|
-
case 5:
|
|
379
|
-
r = _context.sent;
|
|
380
|
-
if (r) {
|
|
381
|
-
_context.next = 8;
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
throw new Error('Please unlock your TronLink extension first.');
|
|
385
|
-
case 8:
|
|
386
|
-
if (!(r.code === 200)) {
|
|
387
|
-
_context.next = 11;
|
|
388
|
-
break;
|
|
389
|
-
}
|
|
390
|
-
_context.next = 13;
|
|
391
|
-
break;
|
|
392
|
-
case 11:
|
|
393
|
-
if (!(!!((_r = r) != null && _r.code) && !!r.message)) {
|
|
394
|
-
_context.next = 13;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
throw new Error(r.message);
|
|
398
|
-
case 13:
|
|
399
|
-
_context.t0 = instance.tronWeb.address;
|
|
400
|
-
_context.next = 16;
|
|
401
|
-
return instance.tronWeb.trx.getAccount();
|
|
402
|
-
case 16:
|
|
403
|
-
_context.t1 = _context.sent.address.toString();
|
|
404
|
-
address = _context.t0.fromHex.call(_context.t0, _context.t1);
|
|
405
|
-
return _context.abrupt("return", {
|
|
406
|
-
accounts: !!address ? [address] : [],
|
|
407
|
-
chainId: walletsShared.Network.TRON
|
|
408
|
-
});
|
|
409
|
-
case 19:
|
|
410
|
-
case "end":
|
|
411
|
-
return _context.stop();
|
|
412
|
-
}
|
|
413
|
-
}, _callee);
|
|
414
|
-
}));
|
|
415
|
-
return function connect(_x) {
|
|
416
|
-
return _ref2.apply(this, arguments);
|
|
417
|
-
};
|
|
418
|
-
}();
|
|
419
|
-
var subscribe = function subscribe(_ref3) {
|
|
420
|
-
var updateAccounts = _ref3.updateAccounts,
|
|
421
|
-
disconnect = _ref3.disconnect;
|
|
422
|
-
window.addEventListener('message', function (e) {
|
|
423
|
-
if (e.data.isTronLink && e.data.message && e.data.message.action == 'accountsChanged') {
|
|
424
|
-
var _e$data, _e$data$message, _e$data$message$data;
|
|
425
|
-
var account = e == null ? void 0 : (_e$data = e.data) == null ? void 0 : (_e$data$message = _e$data.message) == null ? void 0 : (_e$data$message$data = _e$data$message.data) == null ? void 0 : _e$data$message$data.address;
|
|
426
|
-
if (!!account) {
|
|
427
|
-
updateAccounts([account]);
|
|
428
|
-
} else {
|
|
429
|
-
disconnect();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
});
|
|
433
|
-
};
|
|
434
|
-
var canSwitchNetworkTo = function canSwitchNetworkTo() {
|
|
435
|
-
return false;
|
|
436
|
-
};
|
|
437
|
-
var getSigners$1 = getSigners;
|
|
438
|
-
var getWalletInfo = function getWalletInfo(allBlockChains) {
|
|
439
|
-
var tron = rangoTypes.tronBlockchain(allBlockChains);
|
|
440
|
-
return {
|
|
441
|
-
name: 'TronLink',
|
|
442
|
-
img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png',
|
|
443
|
-
installLink: {
|
|
444
|
-
CHROME: 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',
|
|
445
|
-
BRAVE: 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',
|
|
446
|
-
DEFAULT: 'https://www.tronlink.org'
|
|
447
|
-
},
|
|
448
|
-
color: '#96e7ed',
|
|
449
|
-
supportedChains: tron
|
|
450
|
-
};
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
exports.canSwitchNetworkTo = canSwitchNetworkTo;
|
|
454
|
-
exports.config = config;
|
|
455
|
-
exports.connect = connect;
|
|
456
|
-
exports.getInstance = getInstance;
|
|
457
|
-
exports.getSigners = getSigners$1;
|
|
458
|
-
exports.getWalletInfo = getWalletInfo;
|
|
459
|
-
exports.subscribe = subscribe;
|
|
460
|
-
//# sourceMappingURL=provider-tron-link.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-tron-link.cjs.development.js","sources":["../src/helpers.ts","../src/signer.ts","../src/index.ts"],"sourcesContent":["export function tronLink() {\n const { tronLink } = window;\n if (!!tronLink) return tronLink;\n return null;\n}\n","import { DefaultTronSigner } from '@rango-dev/signer-tron';\nimport {\n DefaultSignerFactory,\n SignerFactory,\n TransactionType as TxType,\n} from 'rango-types';\n\nexport default function getSigners(provider: any): SignerFactory {\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(provider));\n return signers;\n}\n","import { Subscribe } from '@rango-dev/wallets-shared';\nimport {\n Network,\n WalletTypes,\n CanSwitchNetwork,\n Connect,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { tronLink as tronLink_instance } from './helpers';\nimport signer from './signer';\nimport { SignerFactory, BlockchainMeta, tronBlockchain } from 'rango-types';\n\n// https://docs.tronlink.org/dapp/start-developing\n// https://developers.tron.network/docs/tronlink-events\nconst WALLET = WalletTypes.TRON_LINK;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.TRON,\n};\n\nexport const getInstance = tronLink_instance;\n\nexport const connect: Connect = async ({ instance }) => {\n let r = undefined;\n if (!!instance && !instance.ready) {\n r = await instance.request({ method: 'tron_requestAccounts' });\n if (!r) {\n throw new Error('Please unlock your TronLink extension first.');\n }\n if (r.code === 200) {\n } else if (!!r?.code && !!r.message) {\n throw new Error(r.message);\n }\n }\n const address = instance.tronWeb.address.fromHex(\n (await instance.tronWeb.trx.getAccount()).address.toString()\n );\n // TODO check connected network\n return { accounts: !!address ? [address] : [], chainId: Network.TRON };\n};\n\nexport const subscribe: Subscribe = ({ updateAccounts, disconnect }) => {\n window.addEventListener('message', (e) => {\n if (\n e.data.isTronLink &&\n e.data.message &&\n e.data.message.action == 'accountsChanged'\n ) {\n const account = e?.data?.message?.data?.address;\n if (!!account) {\n updateAccounts([account]);\n } else {\n disconnect();\n }\n }\n });\n};\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = () => false;\n\nexport const getSigners: (provider: any) => SignerFactory = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const tron = tronBlockchain(allBlockChains);\n return {\n name: 'TronLink',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n DEFAULT: 'https://www.tronlink.org',\n },\n color: '#96e7ed',\n supportedChains: tron,\n };\n};\n"],"names":["tronLink","_window","window","getSigners","provider","signers","DefaultSignerFactory","registerSigner","TxType","TRON","DefaultTronSigner","WALLET","WalletTypes","TRON_LINK","config","type","defaultNetwork","Network","getInstance","tronLink_instance","connect","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref","instance","r","_r","address","wrap","_callee$","_context","prev","next","undefined","ready","request","method","sent","Error","code","message","t0","tronWeb","trx","getAccount","t1","toString","fromHex","call","abrupt","accounts","chainId","stop","_x","apply","arguments","subscribe","_ref3","updateAccounts","disconnect","addEventListener","e","data","isTronLink","action","_e$data","_e$data$message","_e$data$message$data","account","canSwitchNetworkTo","signer","getWalletInfo","allBlockChains","tron","tronBlockchain","name","img","installLink","CHROME","BRAVE","DEFAULT","color","supportedChains"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAgBA,QAAQA;EACtB,IAAAC,OAAA,GAAqBC,MAAM;IAAnBF,QAAQ,GAAAC,OAAA,CAARD,QAAQ;EAChB,IAAI,CAAC,CAACA,QAAQ,EAAE,OAAOA,QAAQ;EAC/B,OAAO,IAAI;A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AAC,eAAA,EAAAC,oBAAA;MACA,IAAMC,OAAO,GAAGP,CAAC,qBAAAI,OAAA,GAADJ,CAAC,CAAEC,IAAI,sBAAAI,eAAA,GAAPD,OAAA,CAASzB,OAAO,sBAAA2B,oBAAA,GAAhBD,eAAA,CAAkBJ,IAAI,qBAAtBK,oBAAA,CAAwBxC,OAAO;MAC/C,IAAI,CAAC,CAACyC,OAAO,EAAE;QACbV,cAAc,CAAC,CAACU,OAAO,CAAC,CAAC;OAC1B,MAAM;QACLT,UAAU,EAAE;;;GAGjB,CAAC;AACJ,CAAC;AAED,IAAaU,kBAAkB,GAAqB,SAAvCA,kBAAkBA;EAAA,OAA2B,KAAK;AAAA;AAE/D,IAAarE,YAAU,GAAqCsE;AAE5D,IAAaC,aAAa,GAAqD,SAAlEA,aAAaA,CACxBC,cAAc;EAEd,IAAMC,IAAI,GAAGC,yBAAc,CAACF,cAAc,CAAC;EAC3C,OAAO;IACLG,IAAI,EAAE,UAAU;IAChBC,GAAG,EAAE,qGAAqG;IAC1GC,WAAW,EAAE;MACXC,MAAM,EACJ,qFAAqF;MACvFC,KAAK,EACH,qFAAqF;MACvFC,OAAO,EAAE;KACV;IACDC,KAAK,EAAE,SAAS;IAChBC,eAAe,EAAET;GAClB;AACH,CAAC;;;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@rango-dev/wallets-shared"),e=require("@rango-dev/signer-tron"),r=require("rango-types");function n(){n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var i=Object.create((e&&e.prototype instanceof p?e:p).prototype),a=new _(n||[]);return o(i,"_invoke",{value:L(t,r,a)}),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var h={};function p(){}function d(){}function v(){}var g={};s(g,a,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(j([])));m&&m!==e&&r.call(m,a)&&(g=m);var w=v.prototype=p.prototype=Object.create(g);function x(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var n;o(this,"_invoke",{value:function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}})}function L(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=k(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function k(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function _(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function j(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:T}}function T(){return{value:void 0,done:!0}}return d.prototype=v,o(w,"constructor",{value:v,configurable:!0}),o(v,"constructor",{value:d,configurable:!0}),d.displayName=s(v,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},x(b.prototype),s(b.prototype,c,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new b(l(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},x(w),s(w,u,"Generator"),s(w,a,(function(){return this})),s(w,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=j,_.prototype={constructor:_,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:j(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function o(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function c(t){o(a,n,i,c,u,"next",t)}function u(t){o(a,n,i,c,u,"throw",t)}c(void 0)}))}}var a={type:t.WalletTypes.TRON_LINK,defaultNetwork:t.Network.TRON},c=function(){var e=i(n().mark((function e(r){var o,i,a,c;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=void 0,!(o=r.instance)||o.ready){e.next=13;break}return e.next=5,o.request({method:"tron_requestAccounts"});case 5:if(i=e.sent){e.next=8;break}throw new Error("Please unlock your TronLink extension first.");case 8:if(200!==i.code){e.next=11;break}e.next=13;break;case 11:if(null==(a=i)||!a.code||!i.message){e.next=13;break}throw new Error(i.message);case 13:return e.t0=o.tronWeb.address,e.next=16,o.tronWeb.trx.getAccount();case 16:return e.t1=e.sent.address.toString(),c=e.t0.fromHex.call(e.t0,e.t1),e.abrupt("return",{accounts:c?[c]:[],chainId:t.Network.TRON});case 19:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();exports.canSwitchNetworkTo=function(){return!1},exports.config=a,exports.connect=c,exports.getInstance=function(){return window.tronLink||null},exports.getSigners=function(t){var n=new r.DefaultSignerFactory;return n.registerSigner(r.TransactionType.TRON,new e.DefaultTronSigner(t)),n},exports.getWalletInfo=function(t){return{name:"TronLink",img:"https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png",installLink:{CHROME:"https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec",BRAVE:"https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec",DEFAULT:"https://www.tronlink.org"},color:"#96e7ed",supportedChains:r.tronBlockchain(t)}},exports.subscribe=function(t){var e=t.updateAccounts,r=t.disconnect;window.addEventListener("message",(function(t){if(t.data.isTronLink&&t.data.message&&"accountsChanged"==t.data.message.action){var n,o,i,a=null==t||null==(n=t.data)||null==(o=n.message)||null==(i=o.data)?void 0:i.address;a?e([a]):r()}}))};
|
|
2
|
-
//# sourceMappingURL=provider-tron-link.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-tron-link.cjs.production.min.js","sources":["../src/index.ts","../src/helpers.ts","../src/signer.ts"],"sourcesContent":["import { Subscribe } from '@rango-dev/wallets-shared';\nimport {\n Network,\n WalletTypes,\n CanSwitchNetwork,\n Connect,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { tronLink as tronLink_instance } from './helpers';\nimport signer from './signer';\nimport { SignerFactory, BlockchainMeta, tronBlockchain } from 'rango-types';\n\n// https://docs.tronlink.org/dapp/start-developing\n// https://developers.tron.network/docs/tronlink-events\nconst WALLET = WalletTypes.TRON_LINK;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.TRON,\n};\n\nexport const getInstance = tronLink_instance;\n\nexport const connect: Connect = async ({ instance }) => {\n let r = undefined;\n if (!!instance && !instance.ready) {\n r = await instance.request({ method: 'tron_requestAccounts' });\n if (!r) {\n throw new Error('Please unlock your TronLink extension first.');\n }\n if (r.code === 200) {\n } else if (!!r?.code && !!r.message) {\n throw new Error(r.message);\n }\n }\n const address = instance.tronWeb.address.fromHex(\n (await instance.tronWeb.trx.getAccount()).address.toString()\n );\n // TODO check connected network\n return { accounts: !!address ? [address] : [], chainId: Network.TRON };\n};\n\nexport const subscribe: Subscribe = ({ updateAccounts, disconnect }) => {\n window.addEventListener('message', (e) => {\n if (\n e.data.isTronLink &&\n e.data.message &&\n e.data.message.action == 'accountsChanged'\n ) {\n const account = e?.data?.message?.data?.address;\n if (!!account) {\n updateAccounts([account]);\n } else {\n disconnect();\n }\n }\n });\n};\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = () => false;\n\nexport const getSigners: (provider: any) => SignerFactory = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const tron = tronBlockchain(allBlockChains);\n return {\n name: 'TronLink',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n DEFAULT: 'https://www.tronlink.org',\n },\n color: '#96e7ed',\n supportedChains: tron,\n };\n};\n","export function tronLink() {\n const { tronLink } = window;\n if (!!tronLink) return tronLink;\n return null;\n}\n","import { DefaultTronSigner } from '@rango-dev/signer-tron';\nimport {\n DefaultSignerFactory,\n SignerFactory,\n TransactionType as TxType,\n} from 'rango-types';\n\nexport default function getSigners(provider: any): SignerFactory {\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(provider));\n return signers;\n}\n"],"names":["config","type","WalletTypes","TRON_LINK","defaultNetwork","Network","TRON","connect","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref","instance","r","_r","address","wrap","_context","prev","next","undefined","ready","request","method","sent","Error","code","message","t0","tronWeb","trx","getAccount","t1","toString","fromHex","call","abrupt","accounts","chainId","stop","_x","apply","arguments","window","tronLink","provider","signers","DefaultSignerFactory","registerSigner","TxType","DefaultTronSigner","allBlockChains","name","img","installLink","CHROME","BRAVE","DEFAULT","color","supportedChains","tronBlockchain","_ref3","updateAccounts","disconnect","addEventListener","e","data","isTronLink","action","_e$data","_e$data$message","_e$data$message$data","account"],"mappings":"+6NAcA,IAEaA,EAAS,CACpBC,KAHaC,cAAYC,UAIzBC,eAAgBC,UAAQC,MAKbC,aAAO,IAAAC,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AxBM,SAAdU,OAAiBC,EAAcD,EAAdC,eAAgBC,EAAUF,EAAVE,WACrDpB,OAAOqB,iBAAiB,WAAW,SAACC,GAClC,GACEA,EAAEC,KAAKC,YACPF,EAAEC,KAAKvC,SACkB,mBAAzBsC,EAAEC,KAAKvC,QAAQyC,OACf,CAAA,IAAAC,EAAAC,EAAAC,EACMC,QAAUP,UAACI,EAADJ,EAAGC,cAAII,EAAPD,EAAS1C,iBAAO4C,EAAhBD,EAAkBJ,aAAlBK,EAAwBxD,QAClCyD,EACJV,EAAe,CAACU,IAEhBT"}
|
|
@@ -1,450 +0,0 @@
|
|
|
1
|
-
import { Network, WalletTypes } from '@rango-dev/wallets-shared';
|
|
2
|
-
import { DefaultTronSigner } from '@rango-dev/signer-tron';
|
|
3
|
-
import { DefaultSignerFactory, TransactionType, tronBlockchain } from 'rango-types';
|
|
4
|
-
|
|
5
|
-
function _regeneratorRuntime() {
|
|
6
|
-
_regeneratorRuntime = function () {
|
|
7
|
-
return exports;
|
|
8
|
-
};
|
|
9
|
-
var exports = {},
|
|
10
|
-
Op = Object.prototype,
|
|
11
|
-
hasOwn = Op.hasOwnProperty,
|
|
12
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
13
|
-
obj[key] = desc.value;
|
|
14
|
-
},
|
|
15
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
16
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
17
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
18
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
19
|
-
function define(obj, key, value) {
|
|
20
|
-
return Object.defineProperty(obj, key, {
|
|
21
|
-
value: value,
|
|
22
|
-
enumerable: !0,
|
|
23
|
-
configurable: !0,
|
|
24
|
-
writable: !0
|
|
25
|
-
}), obj[key];
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
define({}, "");
|
|
29
|
-
} catch (err) {
|
|
30
|
-
define = function (obj, key, value) {
|
|
31
|
-
return obj[key] = value;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
35
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
36
|
-
generator = Object.create(protoGenerator.prototype),
|
|
37
|
-
context = new Context(tryLocsList || []);
|
|
38
|
-
return defineProperty(generator, "_invoke", {
|
|
39
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
40
|
-
}), generator;
|
|
41
|
-
}
|
|
42
|
-
function tryCatch(fn, obj, arg) {
|
|
43
|
-
try {
|
|
44
|
-
return {
|
|
45
|
-
type: "normal",
|
|
46
|
-
arg: fn.call(obj, arg)
|
|
47
|
-
};
|
|
48
|
-
} catch (err) {
|
|
49
|
-
return {
|
|
50
|
-
type: "throw",
|
|
51
|
-
arg: err
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.wrap = wrap;
|
|
56
|
-
var ContinueSentinel = {};
|
|
57
|
-
function Generator() {}
|
|
58
|
-
function GeneratorFunction() {}
|
|
59
|
-
function GeneratorFunctionPrototype() {}
|
|
60
|
-
var IteratorPrototype = {};
|
|
61
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
62
|
-
return this;
|
|
63
|
-
});
|
|
64
|
-
var getProto = Object.getPrototypeOf,
|
|
65
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
66
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
67
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
68
|
-
function defineIteratorMethods(prototype) {
|
|
69
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
70
|
-
define(prototype, method, function (arg) {
|
|
71
|
-
return this._invoke(method, arg);
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
76
|
-
function invoke(method, arg, resolve, reject) {
|
|
77
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
78
|
-
if ("throw" !== record.type) {
|
|
79
|
-
var result = record.arg,
|
|
80
|
-
value = result.value;
|
|
81
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
82
|
-
invoke("next", value, resolve, reject);
|
|
83
|
-
}, function (err) {
|
|
84
|
-
invoke("throw", err, resolve, reject);
|
|
85
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
86
|
-
result.value = unwrapped, resolve(result);
|
|
87
|
-
}, function (error) {
|
|
88
|
-
return invoke("throw", error, resolve, reject);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
reject(record.arg);
|
|
92
|
-
}
|
|
93
|
-
var previousPromise;
|
|
94
|
-
defineProperty(this, "_invoke", {
|
|
95
|
-
value: function (method, arg) {
|
|
96
|
-
function callInvokeWithMethodAndArg() {
|
|
97
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
98
|
-
invoke(method, arg, resolve, reject);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function makeInvokeMethod(innerFn, self, context) {
|
|
106
|
-
var state = "suspendedStart";
|
|
107
|
-
return function (method, arg) {
|
|
108
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
109
|
-
if ("completed" === state) {
|
|
110
|
-
if ("throw" === method) throw arg;
|
|
111
|
-
return doneResult();
|
|
112
|
-
}
|
|
113
|
-
for (context.method = method, context.arg = arg;;) {
|
|
114
|
-
var delegate = context.delegate;
|
|
115
|
-
if (delegate) {
|
|
116
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
117
|
-
if (delegateResult) {
|
|
118
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
119
|
-
return delegateResult;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
123
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
124
|
-
context.dispatchException(context.arg);
|
|
125
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
126
|
-
state = "executing";
|
|
127
|
-
var record = tryCatch(innerFn, self, context);
|
|
128
|
-
if ("normal" === record.type) {
|
|
129
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
130
|
-
return {
|
|
131
|
-
value: record.arg,
|
|
132
|
-
done: context.done
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
140
|
-
var methodName = context.method,
|
|
141
|
-
method = delegate.iterator[methodName];
|
|
142
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
143
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
144
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
145
|
-
var info = record.arg;
|
|
146
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
147
|
-
}
|
|
148
|
-
function pushTryEntry(locs) {
|
|
149
|
-
var entry = {
|
|
150
|
-
tryLoc: locs[0]
|
|
151
|
-
};
|
|
152
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
153
|
-
}
|
|
154
|
-
function resetTryEntry(entry) {
|
|
155
|
-
var record = entry.completion || {};
|
|
156
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
157
|
-
}
|
|
158
|
-
function Context(tryLocsList) {
|
|
159
|
-
this.tryEntries = [{
|
|
160
|
-
tryLoc: "root"
|
|
161
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
162
|
-
}
|
|
163
|
-
function values(iterable) {
|
|
164
|
-
if (iterable) {
|
|
165
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
166
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
167
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
168
|
-
if (!isNaN(iterable.length)) {
|
|
169
|
-
var i = -1,
|
|
170
|
-
next = function next() {
|
|
171
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
172
|
-
return next.value = undefined, next.done = !0, next;
|
|
173
|
-
};
|
|
174
|
-
return next.next = next;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
next: doneResult
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
function doneResult() {
|
|
182
|
-
return {
|
|
183
|
-
value: undefined,
|
|
184
|
-
done: !0
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
188
|
-
value: GeneratorFunctionPrototype,
|
|
189
|
-
configurable: !0
|
|
190
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
191
|
-
value: GeneratorFunction,
|
|
192
|
-
configurable: !0
|
|
193
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
194
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
195
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
196
|
-
}, exports.mark = function (genFun) {
|
|
197
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
198
|
-
}, exports.awrap = function (arg) {
|
|
199
|
-
return {
|
|
200
|
-
__await: arg
|
|
201
|
-
};
|
|
202
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
203
|
-
return this;
|
|
204
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
205
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
206
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
207
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
208
|
-
return result.done ? result.value : iter.next();
|
|
209
|
-
});
|
|
210
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
211
|
-
return this;
|
|
212
|
-
}), define(Gp, "toString", function () {
|
|
213
|
-
return "[object Generator]";
|
|
214
|
-
}), exports.keys = function (val) {
|
|
215
|
-
var object = Object(val),
|
|
216
|
-
keys = [];
|
|
217
|
-
for (var key in object) keys.push(key);
|
|
218
|
-
return keys.reverse(), function next() {
|
|
219
|
-
for (; keys.length;) {
|
|
220
|
-
var key = keys.pop();
|
|
221
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
222
|
-
}
|
|
223
|
-
return next.done = !0, next;
|
|
224
|
-
};
|
|
225
|
-
}, exports.values = values, Context.prototype = {
|
|
226
|
-
constructor: Context,
|
|
227
|
-
reset: function (skipTempReset) {
|
|
228
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
229
|
-
},
|
|
230
|
-
stop: function () {
|
|
231
|
-
this.done = !0;
|
|
232
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
233
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
234
|
-
return this.rval;
|
|
235
|
-
},
|
|
236
|
-
dispatchException: function (exception) {
|
|
237
|
-
if (this.done) throw exception;
|
|
238
|
-
var context = this;
|
|
239
|
-
function handle(loc, caught) {
|
|
240
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
241
|
-
}
|
|
242
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
243
|
-
var entry = this.tryEntries[i],
|
|
244
|
-
record = entry.completion;
|
|
245
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
246
|
-
if (entry.tryLoc <= this.prev) {
|
|
247
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
248
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
249
|
-
if (hasCatch && hasFinally) {
|
|
250
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
251
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
252
|
-
} else if (hasCatch) {
|
|
253
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
254
|
-
} else {
|
|
255
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
256
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
abrupt: function (type, arg) {
|
|
262
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
263
|
-
var entry = this.tryEntries[i];
|
|
264
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
265
|
-
var finallyEntry = entry;
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
270
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
271
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
272
|
-
},
|
|
273
|
-
complete: function (record, afterLoc) {
|
|
274
|
-
if ("throw" === record.type) throw record.arg;
|
|
275
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
276
|
-
},
|
|
277
|
-
finish: function (finallyLoc) {
|
|
278
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
279
|
-
var entry = this.tryEntries[i];
|
|
280
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
catch: function (tryLoc) {
|
|
284
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
285
|
-
var entry = this.tryEntries[i];
|
|
286
|
-
if (entry.tryLoc === tryLoc) {
|
|
287
|
-
var record = entry.completion;
|
|
288
|
-
if ("throw" === record.type) {
|
|
289
|
-
var thrown = record.arg;
|
|
290
|
-
resetTryEntry(entry);
|
|
291
|
-
}
|
|
292
|
-
return thrown;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
throw new Error("illegal catch attempt");
|
|
296
|
-
},
|
|
297
|
-
delegateYield: function (iterable, resultName, nextLoc) {
|
|
298
|
-
return this.delegate = {
|
|
299
|
-
iterator: values(iterable),
|
|
300
|
-
resultName: resultName,
|
|
301
|
-
nextLoc: nextLoc
|
|
302
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
303
|
-
}
|
|
304
|
-
}, exports;
|
|
305
|
-
}
|
|
306
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
307
|
-
try {
|
|
308
|
-
var info = gen[key](arg);
|
|
309
|
-
var value = info.value;
|
|
310
|
-
} catch (error) {
|
|
311
|
-
reject(error);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
if (info.done) {
|
|
315
|
-
resolve(value);
|
|
316
|
-
} else {
|
|
317
|
-
Promise.resolve(value).then(_next, _throw);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
function _asyncToGenerator(fn) {
|
|
321
|
-
return function () {
|
|
322
|
-
var self = this,
|
|
323
|
-
args = arguments;
|
|
324
|
-
return new Promise(function (resolve, reject) {
|
|
325
|
-
var gen = fn.apply(self, args);
|
|
326
|
-
function _next(value) {
|
|
327
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
328
|
-
}
|
|
329
|
-
function _throw(err) {
|
|
330
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
331
|
-
}
|
|
332
|
-
_next(undefined);
|
|
333
|
-
});
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function tronLink() {
|
|
338
|
-
var _window = window,
|
|
339
|
-
tronLink = _window.tronLink;
|
|
340
|
-
if (!!tronLink) return tronLink;
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function getSigners(provider) {
|
|
345
|
-
var signers = new DefaultSignerFactory();
|
|
346
|
-
signers.registerSigner(TransactionType.TRON, new DefaultTronSigner(provider));
|
|
347
|
-
return signers;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// https://docs.tronlink.org/dapp/start-developing
|
|
351
|
-
// https://developers.tron.network/docs/tronlink-events
|
|
352
|
-
var WALLET = WalletTypes.TRON_LINK;
|
|
353
|
-
var config = {
|
|
354
|
-
type: WALLET,
|
|
355
|
-
defaultNetwork: Network.TRON
|
|
356
|
-
};
|
|
357
|
-
var getInstance = tronLink;
|
|
358
|
-
var connect = /*#__PURE__*/function () {
|
|
359
|
-
var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
360
|
-
var instance, r, _r, address;
|
|
361
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
362
|
-
while (1) switch (_context.prev = _context.next) {
|
|
363
|
-
case 0:
|
|
364
|
-
instance = _ref.instance;
|
|
365
|
-
r = undefined;
|
|
366
|
-
if (!(!!instance && !instance.ready)) {
|
|
367
|
-
_context.next = 13;
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
_context.next = 5;
|
|
371
|
-
return instance.request({
|
|
372
|
-
method: 'tron_requestAccounts'
|
|
373
|
-
});
|
|
374
|
-
case 5:
|
|
375
|
-
r = _context.sent;
|
|
376
|
-
if (r) {
|
|
377
|
-
_context.next = 8;
|
|
378
|
-
break;
|
|
379
|
-
}
|
|
380
|
-
throw new Error('Please unlock your TronLink extension first.');
|
|
381
|
-
case 8:
|
|
382
|
-
if (!(r.code === 200)) {
|
|
383
|
-
_context.next = 11;
|
|
384
|
-
break;
|
|
385
|
-
}
|
|
386
|
-
_context.next = 13;
|
|
387
|
-
break;
|
|
388
|
-
case 11:
|
|
389
|
-
if (!(!!((_r = r) != null && _r.code) && !!r.message)) {
|
|
390
|
-
_context.next = 13;
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
throw new Error(r.message);
|
|
394
|
-
case 13:
|
|
395
|
-
_context.t0 = instance.tronWeb.address;
|
|
396
|
-
_context.next = 16;
|
|
397
|
-
return instance.tronWeb.trx.getAccount();
|
|
398
|
-
case 16:
|
|
399
|
-
_context.t1 = _context.sent.address.toString();
|
|
400
|
-
address = _context.t0.fromHex.call(_context.t0, _context.t1);
|
|
401
|
-
return _context.abrupt("return", {
|
|
402
|
-
accounts: !!address ? [address] : [],
|
|
403
|
-
chainId: Network.TRON
|
|
404
|
-
});
|
|
405
|
-
case 19:
|
|
406
|
-
case "end":
|
|
407
|
-
return _context.stop();
|
|
408
|
-
}
|
|
409
|
-
}, _callee);
|
|
410
|
-
}));
|
|
411
|
-
return function connect(_x) {
|
|
412
|
-
return _ref2.apply(this, arguments);
|
|
413
|
-
};
|
|
414
|
-
}();
|
|
415
|
-
var subscribe = function subscribe(_ref3) {
|
|
416
|
-
var updateAccounts = _ref3.updateAccounts,
|
|
417
|
-
disconnect = _ref3.disconnect;
|
|
418
|
-
window.addEventListener('message', function (e) {
|
|
419
|
-
if (e.data.isTronLink && e.data.message && e.data.message.action == 'accountsChanged') {
|
|
420
|
-
var _e$data, _e$data$message, _e$data$message$data;
|
|
421
|
-
var account = e == null ? void 0 : (_e$data = e.data) == null ? void 0 : (_e$data$message = _e$data.message) == null ? void 0 : (_e$data$message$data = _e$data$message.data) == null ? void 0 : _e$data$message$data.address;
|
|
422
|
-
if (!!account) {
|
|
423
|
-
updateAccounts([account]);
|
|
424
|
-
} else {
|
|
425
|
-
disconnect();
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
};
|
|
430
|
-
var canSwitchNetworkTo = function canSwitchNetworkTo() {
|
|
431
|
-
return false;
|
|
432
|
-
};
|
|
433
|
-
var getSigners$1 = getSigners;
|
|
434
|
-
var getWalletInfo = function getWalletInfo(allBlockChains) {
|
|
435
|
-
var tron = tronBlockchain(allBlockChains);
|
|
436
|
-
return {
|
|
437
|
-
name: 'TronLink',
|
|
438
|
-
img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png',
|
|
439
|
-
installLink: {
|
|
440
|
-
CHROME: 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',
|
|
441
|
-
BRAVE: 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',
|
|
442
|
-
DEFAULT: 'https://www.tronlink.org'
|
|
443
|
-
},
|
|
444
|
-
color: '#96e7ed',
|
|
445
|
-
supportedChains: tron
|
|
446
|
-
};
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
export { canSwitchNetworkTo, config, connect, getInstance, getSigners$1 as getSigners, getWalletInfo, subscribe };
|
|
450
|
-
//# sourceMappingURL=provider-tron-link.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-tron-link.esm.js","sources":["../src/helpers.ts","../src/signer.ts","../src/index.ts"],"sourcesContent":["export function tronLink() {\n const { tronLink } = window;\n if (!!tronLink) return tronLink;\n return null;\n}\n","import { DefaultTronSigner } from '@rango-dev/signer-tron';\nimport {\n DefaultSignerFactory,\n SignerFactory,\n TransactionType as TxType,\n} from 'rango-types';\n\nexport default function getSigners(provider: any): SignerFactory {\n const signers = new DefaultSignerFactory();\n signers.registerSigner(TxType.TRON, new DefaultTronSigner(provider));\n return signers;\n}\n","import { Subscribe } from '@rango-dev/wallets-shared';\nimport {\n Network,\n WalletTypes,\n CanSwitchNetwork,\n Connect,\n WalletInfo,\n} from '@rango-dev/wallets-shared';\nimport { tronLink as tronLink_instance } from './helpers';\nimport signer from './signer';\nimport { SignerFactory, BlockchainMeta, tronBlockchain } from 'rango-types';\n\n// https://docs.tronlink.org/dapp/start-developing\n// https://developers.tron.network/docs/tronlink-events\nconst WALLET = WalletTypes.TRON_LINK;\n\nexport const config = {\n type: WALLET,\n defaultNetwork: Network.TRON,\n};\n\nexport const getInstance = tronLink_instance;\n\nexport const connect: Connect = async ({ instance }) => {\n let r = undefined;\n if (!!instance && !instance.ready) {\n r = await instance.request({ method: 'tron_requestAccounts' });\n if (!r) {\n throw new Error('Please unlock your TronLink extension first.');\n }\n if (r.code === 200) {\n } else if (!!r?.code && !!r.message) {\n throw new Error(r.message);\n }\n }\n const address = instance.tronWeb.address.fromHex(\n (await instance.tronWeb.trx.getAccount()).address.toString()\n );\n // TODO check connected network\n return { accounts: !!address ? [address] : [], chainId: Network.TRON };\n};\n\nexport const subscribe: Subscribe = ({ updateAccounts, disconnect }) => {\n window.addEventListener('message', (e) => {\n if (\n e.data.isTronLink &&\n e.data.message &&\n e.data.message.action == 'accountsChanged'\n ) {\n const account = e?.data?.message?.data?.address;\n if (!!account) {\n updateAccounts([account]);\n } else {\n disconnect();\n }\n }\n });\n};\n\nexport const canSwitchNetworkTo: CanSwitchNetwork = () => false;\n\nexport const getSigners: (provider: any) => SignerFactory = signer;\n\nexport const getWalletInfo: (allBlockChains: BlockchainMeta[]) => WalletInfo = (\n allBlockChains\n) => {\n const tron = tronBlockchain(allBlockChains);\n return {\n name: 'TronLink',\n img: 'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/icons/wallets/tronlink.png',\n installLink: {\n CHROME:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n BRAVE:\n 'https://chrome.google.com/webstore/detail/tronlink/ibnejdfjmmkpcnlpebklmnkoeoihofec',\n DEFAULT: 'https://www.tronlink.org',\n },\n color: '#96e7ed',\n supportedChains: tron,\n };\n};\n"],"names":["tronLink","_window","window","getSigners","provider","signers","DefaultSignerFactory","registerSigner","TxType","TRON","DefaultTronSigner","WALLET","WalletTypes","TRON_LINK","config","type","defaultNetwork","Network","getInstance","tronLink_instance","connect","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_ref","instance","r","_r","address","wrap","_callee$","_context","prev","next","undefined","ready","request","method","sent","Error","code","message","t0","tronWeb","trx","getAccount","t1","toString","fromHex","call","abrupt","accounts","chainId","stop","_x","apply","arguments","subscribe","_ref3","updateAccounts","disconnect","addEventListener","e","data","isTronLink","action","_e$data","_e$data$message","_e$data$message$data","account","canSwitchNetworkTo","signer","getWalletInfo","allBlockChains","tron","tronBlockchain","name","img","installLink","CHROME","BRAVE","DEFAULT","color","supportedChains"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAAgBA,QAAQA;EACtB,IAAAC,OAAA,GAAqBC,MAAM;IAAnBF,QAAQ,GAAAC,OAAA,CAARD,QAAQ;EAChB,IAAI,CAAC,CAACA,QAAQ,EAAE,OAAOA,QAAQ;EAC/B,OAAO,IAAI;AACb;;SCGwBG,UAAUA,CAACC,QAAa;EAC9C,IAAMC,OAAO,GAAG,IAAIC,oBAAoB,EAAE;EAC1CD,OAAO,CAACE,cAAc,CAACC,eAAM,CAACC,IAAI,EAAE,IAAIC,iBAAiB,CAACN,QAAQ,CAAC,CAAC;EACpE,OAAOC,OAAO;AAChB;;ACCA;AACA;AACA,IAAMM,MAAM,GAAGC,WAAW,CAACC,SAAS;AAEpC,IAAaC,MAAM,GAAG;EACpBC,IAAI,EAAEJ,MAAM;EACZK,cAAc,E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