@meshconnect/uwc-tron-connector 0.1.0

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.
Files changed (80) hide show
  1. package/dist/events/state-machine.d.ts +26 -0
  2. package/dist/events/state-machine.d.ts.map +1 -0
  3. package/dist/events/state-machine.js +21 -0
  4. package/dist/events/state-machine.js.map +1 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +3 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/rest/abi.d.ts +23 -0
  10. package/dist/rest/abi.d.ts.map +1 -0
  11. package/dist/rest/abi.js +28 -0
  12. package/dist/rest/abi.js.map +1 -0
  13. package/dist/rest/address.d.ts +45 -0
  14. package/dist/rest/address.d.ts.map +1 -0
  15. package/dist/rest/address.js +124 -0
  16. package/dist/rest/address.js.map +1 -0
  17. package/dist/rest/trongrid-client.d.ts +57 -0
  18. package/dist/rest/trongrid-client.d.ts.map +1 -0
  19. package/dist/rest/trongrid-client.js +133 -0
  20. package/dist/rest/trongrid-client.js.map +1 -0
  21. package/dist/shared/error-utils.d.ts +9 -0
  22. package/dist/shared/error-utils.d.ts.map +1 -0
  23. package/dist/shared/error-utils.js +52 -0
  24. package/dist/shared/error-utils.js.map +1 -0
  25. package/dist/tron-connector.d.ts +85 -0
  26. package/dist/tron-connector.d.ts.map +1 -0
  27. package/dist/tron-connector.js +456 -0
  28. package/dist/tron-connector.js.map +1 -0
  29. package/dist/types.d.ts +8 -0
  30. package/dist/types.d.ts.map +1 -0
  31. package/dist/types.js +2 -0
  32. package/dist/types.js.map +1 -0
  33. package/dist/wallets/base.d.ts +87 -0
  34. package/dist/wallets/base.d.ts.map +1 -0
  35. package/dist/wallets/base.js +118 -0
  36. package/dist/wallets/base.js.map +1 -0
  37. package/dist/wallets/bitget.d.ts +8 -0
  38. package/dist/wallets/bitget.d.ts.map +1 -0
  39. package/dist/wallets/bitget.js +14 -0
  40. package/dist/wallets/bitget.js.map +1 -0
  41. package/dist/wallets/okx.d.ts +4 -0
  42. package/dist/wallets/okx.d.ts.map +1 -0
  43. package/dist/wallets/okx.js +10 -0
  44. package/dist/wallets/okx.js.map +1 -0
  45. package/dist/wallets/registry.d.ts +8 -0
  46. package/dist/wallets/registry.d.ts.map +1 -0
  47. package/dist/wallets/registry.js +18 -0
  48. package/dist/wallets/registry.js.map +1 -0
  49. package/dist/wallets/tokenpocket.d.ts +9 -0
  50. package/dist/wallets/tokenpocket.d.ts.map +1 -0
  51. package/dist/wallets/tokenpocket.js +15 -0
  52. package/dist/wallets/tokenpocket.js.map +1 -0
  53. package/dist/wallets/tronlink.d.ts +8 -0
  54. package/dist/wallets/tronlink.d.ts.map +1 -0
  55. package/dist/wallets/tronlink.js +15 -0
  56. package/dist/wallets/tronlink.js.map +1 -0
  57. package/dist/wallets/trust.d.ts +9 -0
  58. package/dist/wallets/trust.d.ts.map +1 -0
  59. package/dist/wallets/trust.js +15 -0
  60. package/dist/wallets/trust.js.map +1 -0
  61. package/package.json +34 -0
  62. package/src/events/state-machine.ts +44 -0
  63. package/src/index.ts +17 -0
  64. package/src/rest/abi.test.ts +25 -0
  65. package/src/rest/abi.ts +33 -0
  66. package/src/rest/address.test.ts +55 -0
  67. package/src/rest/address.ts +140 -0
  68. package/src/rest/trongrid-client.test.ts +169 -0
  69. package/src/rest/trongrid-client.ts +205 -0
  70. package/src/shared/error-utils.ts +60 -0
  71. package/src/tron-connector.test.ts +612 -0
  72. package/src/tron-connector.ts +568 -0
  73. package/src/types.ts +11 -0
  74. package/src/wallets/base.ts +184 -0
  75. package/src/wallets/bitget.ts +17 -0
  76. package/src/wallets/okx.ts +10 -0
  77. package/src/wallets/registry.ts +26 -0
  78. package/src/wallets/tokenpocket.ts +15 -0
  79. package/src/wallets/tronlink.ts +15 -0
  80. package/src/wallets/trust.ts +18 -0
@@ -0,0 +1,85 @@
1
+ import type { ConnectorResult, DetectedTronWalletInfo, Namespace, Network, SignatureType, SwitchNetworkResult, TransactionRequest, WalletMetadata } from '@meshconnect/uwc-types';
2
+ import { type TronStateListener } from './events/state-machine';
3
+ import type { TronConnectorConfig } from './types';
4
+ /**
5
+ * Mesh-owned Tron wallet connector. Zero third-party Tron runtime deps.
6
+ *
7
+ * One instance fronts all 5 supported wallets — TronLink, Bitget, OKX,
8
+ * TokenPocket, Trust — selected per-connect by the wallet id. Per-wallet
9
+ * enablement is controlled by `config.enabledWallets`.
10
+ *
11
+ * Transactions are built and broadcast against the Tron full-node HTTP API
12
+ * (`/wallet/*`); signing goes through the wallet's own injected
13
+ * `provider.tronWeb.trx.sign(unsigned)`, so the crypto stays in the wallet and
14
+ * costs us no bundle.
15
+ */
16
+ export declare class TronConnector {
17
+ private readonly config;
18
+ private readonly enabled;
19
+ private readonly clientByNetwork;
20
+ private readonly state;
21
+ private active;
22
+ private activeNetworkId;
23
+ /** Listeners attached to the active provider, kept so we can detach on cleanup. */
24
+ private boundListeners;
25
+ constructor(config: TronConnectorConfig);
26
+ /** Subscribe to connection-state transitions (decision D3). */
27
+ subscribe(listener: TronStateListener): () => void;
28
+ /**
29
+ * Returns the wallets that are (a) enabled in config and (b) currently
30
+ * injected into the page. Conforms to `Connector.getAvailableWallets` for
31
+ * namespace `'tron'`.
32
+ */
33
+ getAvailableWallets(namespace: Namespace, expectedWallets?: WalletMetadata[]): Promise<DetectedTronWalletInfo[]>;
34
+ /**
35
+ * Connect to a Tron wallet on the given network. The wallet is identified by
36
+ * `walletProvider.uuid` (or `.walletId`), which must be an enabled
37
+ * `TronWalletId`. On success this connector holds the active provider until
38
+ * `disconnect()` or the next `connect()`.
39
+ */
40
+ connect(network: Network, walletProvider?: {
41
+ uuid?: string;
42
+ } | {
43
+ walletId?: string;
44
+ }): Promise<ConnectorResult>;
45
+ /**
46
+ * Tron network selection is wallet-driven (the user picks the chain in the
47
+ * wallet UI); there is no standardised programmatic switch across these
48
+ * injected providers. We repoint the build/broadcast endpoint to the target
49
+ * network and report the current address.
50
+ */
51
+ switchNetwork(network: Network): Promise<SwitchNetworkResult>;
52
+ disconnect(): Promise<void>;
53
+ signMessage(message: string): Promise<SignatureType>;
54
+ sendTransaction(request: TransactionRequest): Promise<string>;
55
+ /**
56
+ * Verify the node-built transaction encodes exactly what we asked for, before
57
+ * handing it to the wallet to sign. Reads `raw_data.contract[0].parameter.value`:
58
+ * native → owner/to/amount; TRC20 → owner/contract + the full `transfer` call
59
+ * data. Addresses are compared hex-normalized (base58/hex agnostic), falling
60
+ * back to exact string match for non-decodable placeholders.
61
+ */
62
+ private assertBuiltTxMatchesRequest;
63
+ /** The wallet only signs for its own key — reject a mismatched `from` early. */
64
+ private assertFromMatchesActive;
65
+ private assertTronNetwork;
66
+ private requireActive;
67
+ /**
68
+ * Reject amounts that aren't safe non-negative integers. Two reasons, both on
69
+ * the money path: a fractional value makes `BigInt(amount)` throw a raw
70
+ * `RangeError` (and the build runs outside the sign/broadcast try/catch, so it
71
+ * would escape unwrapped); and a value beyond `Number.MAX_SAFE_INTEGER` can't
72
+ * be represented exactly, so it would silently transfer the wrong amount.
73
+ * `Number.isSafeInteger` covers both.
74
+ */
75
+ private assertValidAmount;
76
+ /** Verify a TRC20 recipient's base58 checksum, surfaced as a typed error. */
77
+ private assertValidRecipient;
78
+ private resolveAllowedIds;
79
+ private requireWalletId;
80
+ private getClient;
81
+ private bindWalletEvents;
82
+ private onWalletEvent;
83
+ private cleanupActive;
84
+ }
85
+ //# sourceMappingURL=tron-connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-connector.d.ts","sourceRoot":"","sources":["../src/tron-connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,OAAO,EAEP,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAGlB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAG/B,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAA;AAqB/B,OA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;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IASzB,6EAA6E;YAC/D,oBAAoB;IAclC,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,aAAa;IAkCrB,OAAO,CAAC,aAAa;CAUtB"}
@@ -0,0 +1,456 @@
1
+ import { WalletConnectorError } from '@meshconnect/uwc-types';
2
+ import { parseError } from './shared/error-utils';
3
+ import { TronStateMachine } from './events/state-machine';
4
+ import { TronGridClient } from './rest/trongrid-client';
5
+ import { assertValidTronChecksum, tronAddressToHex } from './rest/address';
6
+ import { encodeTrc20TransferParams, TRC20_TRANSFER_SELECTOR_HASH } from './rest/abi';
7
+ import { detectProvider, waitForWalletAddress } from './wallets/base';
8
+ import { ALL_TRON_WALLET_IDS, TRON_WALLET_REGISTRY, isTronWalletId } from './wallets/registry';
9
+ /** Wallet events we mirror into the state machine while connected. */
10
+ const WALLET_EVENTS = ['accountsChanged', 'disconnect'];
11
+ /**
12
+ * Default probe window for `getAvailableWallets`. Short on purpose — see the
13
+ * rationale in that method. Override via `TronConnectorConfig.discoveryTimeoutMs`.
14
+ */
15
+ const DEFAULT_DISCOVERY_TIMEOUT_MS = 300;
16
+ /**
17
+ * Mesh-owned Tron wallet connector. Zero third-party Tron runtime deps.
18
+ *
19
+ * One instance fronts all 5 supported wallets — TronLink, Bitget, OKX,
20
+ * TokenPocket, Trust — selected per-connect by the wallet id. Per-wallet
21
+ * enablement is controlled by `config.enabledWallets`.
22
+ *
23
+ * Transactions are built and broadcast against the Tron full-node HTTP API
24
+ * (`/wallet/*`); signing goes through the wallet's own injected
25
+ * `provider.tronWeb.trx.sign(unsigned)`, so the crypto stays in the wallet and
26
+ * costs us no bundle.
27
+ */
28
+ export class TronConnector {
29
+ config;
30
+ enabled;
31
+ clientByNetwork = new Map();
32
+ state = new TronStateMachine();
33
+ active = null;
34
+ activeNetworkId = null;
35
+ /** Listeners attached to the active provider, kept so we can detach on cleanup. */
36
+ boundListeners = [];
37
+ constructor(config) {
38
+ this.config = config;
39
+ this.enabled = new Set(Array.from(config.enabledWallets));
40
+ }
41
+ /** Subscribe to connection-state transitions (decision D3). */
42
+ subscribe(listener) {
43
+ return this.state.subscribe(listener);
44
+ }
45
+ /**
46
+ * Returns the wallets that are (a) enabled in config and (b) currently
47
+ * injected into the page. Conforms to `Connector.getAvailableWallets` for
48
+ * namespace `'tron'`.
49
+ */
50
+ async getAvailableWallets(namespace, expectedWallets) {
51
+ if (namespace !== 'tron')
52
+ return [];
53
+ // Discovery uses a deliberately SHORT timeout, distinct from connect()'s
54
+ // longer `readyStateTimeoutMs`. `detectProvider` only resolves early when a
55
+ // wallet *appears* — an absent wallet always waits out the full timeout. In
56
+ // discovery every enabled-but-not-installed wallet is probed in parallel, so
57
+ // a 3s timeout would make a user who has only TronLink installed wait ~3s
58
+ // for the wallet list on every call. A short window still catches wallets
59
+ // that inject slightly after page load (injection is async) without
60
+ // stalling the UI; connect(), which targets one already-chosen wallet and
61
+ // can afford to wait, keeps the longer timeout.
62
+ const timeout = this.config.discoveryTimeoutMs ?? DEFAULT_DISCOVERY_TIMEOUT_MS;
63
+ const interval = this.config.readyStatePollIntervalMs ?? 50;
64
+ const allowedIds = this.resolveAllowedIds(expectedWallets);
65
+ // Probe in parallel but place each result by its index, so the returned
66
+ // order is stable (matches resolveAllowedIds) regardless of which wallet's
67
+ // probe resolves first.
68
+ const detected = await Promise.all(allowedIds.map(async (id) => {
69
+ const wrapper = TRON_WALLET_REGISTRY[id];
70
+ const provider = await detectProvider(wrapper, timeout, interval);
71
+ return provider ? { uuid: id, name: wrapper.displayName } : null;
72
+ }));
73
+ return detected.filter((w) => w !== null);
74
+ }
75
+ /**
76
+ * Connect to a Tron wallet on the given network. The wallet is identified by
77
+ * `walletProvider.uuid` (or `.walletId`), which must be an enabled
78
+ * `TronWalletId`. On success this connector holds the active provider until
79
+ * `disconnect()` or the next `connect()`.
80
+ */
81
+ async connect(network, walletProvider) {
82
+ this.assertTronNetwork(network, 'connect');
83
+ const walletId = this.requireWalletId(walletProvider);
84
+ const wrapper = TRON_WALLET_REGISTRY[walletId];
85
+ this.state.set({ status: 'connecting', walletId });
86
+ const provider = await detectProvider(wrapper, this.config.readyStateTimeoutMs ?? 3000, this.config.readyStatePollIntervalMs ?? 50);
87
+ if (!provider) {
88
+ // Same consistency guard as the catch below: a failed reconnect (target
89
+ // not installed) must not leave `active` pointing at the prior wallet.
90
+ this.cleanupActive();
91
+ this.state.set({ status: 'disconnected' });
92
+ throw new WalletConnectorError({
93
+ type: 'unknown',
94
+ message: `Tron wallet "${wrapper.displayName}" is not installed`
95
+ });
96
+ }
97
+ try {
98
+ // Prompts the wallet to expose the account. The wallet populates its
99
+ // `tronWeb` + account a tick after this resolves, so poll briefly.
100
+ await provider.request?.({ method: 'tron_requestAccounts' });
101
+ const address = await waitForWalletAddress(provider, this.config.readyStateTimeoutMs ?? 3000, this.config.readyStatePollIntervalMs ?? 50);
102
+ if (!address) {
103
+ throw new WalletConnectorError({
104
+ type: 'unknown',
105
+ message: `Tron wallet "${wrapper.displayName}" connected but exposed no address`
106
+ });
107
+ }
108
+ // Pre-warm the per-network client so the first send doesn't pay the cost.
109
+ this.getClient(network.id);
110
+ this.cleanupActive();
111
+ this.active = { walletId, provider, address };
112
+ this.activeNetworkId = network.id;
113
+ this.bindWalletEvents(provider);
114
+ this.state.set({ status: 'connected', walletId, address });
115
+ const availableAddresses = [
116
+ { networkId: network.id, address }
117
+ ];
118
+ return { networkId: network.id, address, availableAddresses };
119
+ }
120
+ catch (error) {
121
+ // Clear any prior/partial connection so `active` can't be left pointing
122
+ // at a stale wallet while we report 'disconnected' (e.g. a failed
123
+ // reconnect after a previous connect succeeded).
124
+ this.cleanupActive();
125
+ this.state.set({ status: 'disconnected' });
126
+ parseError(error);
127
+ }
128
+ }
129
+ /**
130
+ * Tron network selection is wallet-driven (the user picks the chain in the
131
+ * wallet UI); there is no standardised programmatic switch across these
132
+ * injected providers. We repoint the build/broadcast endpoint to the target
133
+ * network and report the current address.
134
+ */
135
+ async switchNetwork(network) {
136
+ this.assertTronNetwork(network, 'switchNetwork');
137
+ if (!this.active) {
138
+ throw new WalletConnectorError({
139
+ type: 'unknown',
140
+ message: 'TronConnector.switchNetwork called before connect()'
141
+ });
142
+ }
143
+ try {
144
+ this.getClient(network.id);
145
+ }
146
+ catch (error) {
147
+ // Surface a missing-endpoint (or similar) failure as a WalletConnectorError,
148
+ // consistent with connect/sendTransaction/signMessage.
149
+ parseError(error);
150
+ }
151
+ this.activeNetworkId = network.id;
152
+ return { networkId: network.id, address: this.active.address };
153
+ }
154
+ async disconnect() {
155
+ this.cleanupActive();
156
+ this.state.set({ status: 'disconnected' });
157
+ }
158
+ async signMessage(message) {
159
+ const active = this.requireActive('signMessage');
160
+ const tronWeb = active.provider.tronWeb;
161
+ const signMessageV2 = tronWeb?.trx.signMessageV2;
162
+ if (!tronWeb || !signMessageV2) {
163
+ throw new WalletConnectorError({
164
+ type: 'unknown',
165
+ message: 'Active Tron wallet does not support message signing'
166
+ });
167
+ }
168
+ try {
169
+ const signature = await signMessageV2.call(tronWeb.trx, message);
170
+ // Match the existing injected-connector tron path, which wraps the
171
+ // signature as a StandardSignature rather than the TronSignature variant.
172
+ return { type: 'standard', signature };
173
+ }
174
+ catch (error) {
175
+ parseError(error);
176
+ }
177
+ }
178
+ async sendTransaction(request) {
179
+ const active = this.requireActive('sendTransaction');
180
+ if (!this.activeNetworkId) {
181
+ throw new WalletConnectorError({
182
+ type: 'unknown',
183
+ message: 'TronConnector.sendTransaction: no active network'
184
+ });
185
+ }
186
+ const client = this.getClient(this.activeNetworkId);
187
+ // Build, sign, and broadcast all run inside the try so node/network errors
188
+ // from the build step surface as WalletConnectorError (via parseError),
189
+ // consistent with the sign/broadcast path; the validation/guard throws below
190
+ // are already WalletConnectorError and pass through parseError unchanged.
191
+ try {
192
+ let unsigned;
193
+ if (isTronTRC20(request)) {
194
+ this.assertValidAmount(request.amount);
195
+ this.assertFromMatchesActive(request.from, active.address);
196
+ // TRC20 encodes `to`/`contract` as raw hex, so the node never sees (or
197
+ // checksum-validates) the base58 forms — verify both here so a typo'd
198
+ // recipient or contract can't silently misdirect funds.
199
+ await this.assertValidRecipient(request.to);
200
+ await this.assertValidRecipient(request.contractAddress);
201
+ unsigned = await client.createTrc20Transfer({
202
+ from: request.from,
203
+ to: request.to,
204
+ amount: request.amount,
205
+ contractAddress: request.contractAddress
206
+ });
207
+ }
208
+ else if (isTronNative(request)) {
209
+ // The node validates `to` (sent as base58 with visible:true), so no
210
+ // checksum check is needed on this path.
211
+ this.assertValidAmount(request.amount);
212
+ this.assertFromMatchesActive(request.from, active.address);
213
+ unsigned = await client.createTransaction({
214
+ from: request.from,
215
+ to: request.to,
216
+ amount: request.amount
217
+ });
218
+ }
219
+ else {
220
+ throw new WalletConnectorError({
221
+ type: 'unknown',
222
+ message: 'TronConnector.sendTransaction: unsupported request shape'
223
+ });
224
+ }
225
+ // Don't blindly sign what the node returned: confirm the built tx encodes
226
+ // the requested recipient/amount/contract. A compromised or MITM'd
227
+ // endpoint could otherwise swap the destination, with the wallet's confirm
228
+ // UI as the only backstop.
229
+ this.assertBuiltTxMatchesRequest(unsigned, request);
230
+ // A wallet can lock/disconnect without firing an event, dropping
231
+ // `tronWeb`. Guard so we surface a clear error, not a raw TypeError.
232
+ const tronWeb = active.provider.tronWeb;
233
+ if (!tronWeb) {
234
+ throw new WalletConnectorError({
235
+ type: 'unknown',
236
+ message: 'Active Tron wallet is unavailable; reconnect and try again'
237
+ });
238
+ }
239
+ const signed = await tronWeb.trx.sign(unsigned);
240
+ return await client.broadcastTransaction(signed);
241
+ }
242
+ catch (error) {
243
+ parseError(error);
244
+ }
245
+ }
246
+ /**
247
+ * Verify the node-built transaction encodes exactly what we asked for, before
248
+ * handing it to the wallet to sign. Reads `raw_data.contract[0].parameter.value`:
249
+ * native → owner/to/amount; TRC20 → owner/contract + the full `transfer` call
250
+ * data. Addresses are compared hex-normalized (base58/hex agnostic), falling
251
+ * back to exact string match for non-decodable placeholders.
252
+ */
253
+ assertBuiltTxMatchesRequest(unsigned, request) {
254
+ const mismatch = () => {
255
+ throw new WalletConnectorError({
256
+ type: 'unknown',
257
+ message: 'TronConnector.sendTransaction: the node-built transaction does not match the request (possible tampered/MITM endpoint)'
258
+ });
259
+ };
260
+ const value = unsigned.raw_data?.contract?.[0]?.parameter?.value;
261
+ if (!value) {
262
+ throw new WalletConnectorError({
263
+ type: 'unknown',
264
+ message: 'TronConnector.sendTransaction: the node-built transaction does not match the request (possible tampered/MITM endpoint)'
265
+ });
266
+ }
267
+ const sameAddress = (built, requested) => {
268
+ const a = String(built ?? '');
269
+ if (a === requested)
270
+ return true;
271
+ try {
272
+ return tronAddressToHex(a) === tronAddressToHex(requested);
273
+ }
274
+ catch {
275
+ return false;
276
+ }
277
+ };
278
+ if (!sameAddress(value['owner_address'], request.from))
279
+ mismatch();
280
+ if (isTronTRC20(request)) {
281
+ if (!sameAddress(value['contract_address'], request.contractAddress)) {
282
+ mismatch();
283
+ }
284
+ const expectedData = (TRC20_TRANSFER_SELECTOR_HASH +
285
+ encodeTrc20TransferParams(request.to, request.amount)).toLowerCase();
286
+ if (String(value['data'] ?? '').toLowerCase() !== expectedData)
287
+ mismatch();
288
+ }
289
+ else {
290
+ if (!sameAddress(value['to_address'], request.to))
291
+ mismatch();
292
+ if (Number(value['amount']) !== request.amount)
293
+ mismatch();
294
+ }
295
+ }
296
+ /** The wallet only signs for its own key — reject a mismatched `from` early. */
297
+ assertFromMatchesActive(from, activeAddress) {
298
+ if (from !== activeAddress) {
299
+ throw new WalletConnectorError({
300
+ type: 'unknown',
301
+ message: `TronConnector.sendTransaction: "from" (${from}) does not match the connected address (${activeAddress})`
302
+ });
303
+ }
304
+ }
305
+ // ---- internals -----------------------------------------------------------
306
+ assertTronNetwork(network, method) {
307
+ if (network.namespace !== 'tron') {
308
+ throw new Error(`TronConnector.${method}: expected a 'tron' network, got '${network.namespace}'`);
309
+ }
310
+ }
311
+ requireActive(method) {
312
+ if (!this.active) {
313
+ throw new WalletConnectorError({
314
+ type: 'unknown',
315
+ message: `TronConnector.${method} called before connect()`
316
+ });
317
+ }
318
+ return this.active;
319
+ }
320
+ /**
321
+ * Reject amounts that aren't safe non-negative integers. Two reasons, both on
322
+ * the money path: a fractional value makes `BigInt(amount)` throw a raw
323
+ * `RangeError` (and the build runs outside the sign/broadcast try/catch, so it
324
+ * would escape unwrapped); and a value beyond `Number.MAX_SAFE_INTEGER` can't
325
+ * be represented exactly, so it would silently transfer the wrong amount.
326
+ * `Number.isSafeInteger` covers both.
327
+ */
328
+ assertValidAmount(amount) {
329
+ if (!Number.isSafeInteger(amount) || amount < 0) {
330
+ throw new WalletConnectorError({
331
+ type: 'unknown',
332
+ message: `TronConnector.sendTransaction: amount must be a non-negative integer within the safe range, got ${amount}`
333
+ });
334
+ }
335
+ }
336
+ /** Verify a TRC20 recipient's base58 checksum, surfaced as a typed error. */
337
+ async assertValidRecipient(to) {
338
+ try {
339
+ await assertValidTronChecksum(to);
340
+ }
341
+ catch (error) {
342
+ throw new WalletConnectorError({
343
+ type: 'unknown',
344
+ message: error instanceof Error
345
+ ? error.message
346
+ : 'TronConnector.sendTransaction: invalid recipient address'
347
+ });
348
+ }
349
+ }
350
+ resolveAllowedIds(expectedWallets) {
351
+ if (!expectedWallets || expectedWallets.length === 0) {
352
+ return ALL_TRON_WALLET_IDS.filter(id => this.enabled.has(id));
353
+ }
354
+ const expectedIds = new Set(expectedWallets.map(wallet => wallet.id));
355
+ return ALL_TRON_WALLET_IDS.filter(id => this.enabled.has(id) && expectedIds.has(id));
356
+ }
357
+ requireWalletId(provider) {
358
+ const raw = provider?.uuid ??
359
+ provider?.walletId;
360
+ if (!raw) {
361
+ throw new WalletConnectorError({
362
+ type: 'unknown',
363
+ message: 'TronConnector.connect: missing wallet identifier'
364
+ });
365
+ }
366
+ if (!isTronWalletId(raw)) {
367
+ throw new WalletConnectorError({
368
+ type: 'unknown',
369
+ message: `TronConnector.connect: unknown wallet "${raw}"`
370
+ });
371
+ }
372
+ if (!this.enabled.has(raw)) {
373
+ throw new WalletConnectorError({
374
+ type: 'unknown',
375
+ message: `TronConnector.connect: wallet "${raw}" is not enabled in config`
376
+ });
377
+ }
378
+ return raw;
379
+ }
380
+ getClient(networkId) {
381
+ let client = this.clientByNetwork.get(networkId);
382
+ if (!client) {
383
+ client = new TronGridClient(networkId, this.config.tronGrid);
384
+ this.clientByNetwork.set(networkId, client);
385
+ }
386
+ return client;
387
+ }
388
+ bindWalletEvents(provider) {
389
+ if (!provider.on)
390
+ return;
391
+ for (const event of WALLET_EVENTS) {
392
+ const handler = (...args) => this.onWalletEvent(event, args[0]);
393
+ provider.on(event, handler);
394
+ this.boundListeners.push({ event, handler });
395
+ }
396
+ }
397
+ onWalletEvent(event, payload) {
398
+ if (!this.active)
399
+ return;
400
+ if (event === 'disconnect') {
401
+ this.cleanupActive();
402
+ this.state.set({ status: 'disconnected' });
403
+ return;
404
+ }
405
+ // accountsChanged payload shape varies by wallet: TronLink/TIP-1193 emit a
406
+ // bare address string, while the EIP-1193-style providers (OKX, Trust,
407
+ // Bitget) emit an array. An empty array is the logout signal. We normalise
408
+ // both, falling back to the wallet's current default address only when the
409
+ // payload carries nothing usable.
410
+ let nextAddress;
411
+ if (typeof payload === 'string') {
412
+ nextAddress = payload;
413
+ }
414
+ else if (Array.isArray(payload)) {
415
+ nextAddress = payload[0];
416
+ }
417
+ else {
418
+ nextAddress =
419
+ this.active.provider.tronWeb?.defaultAddress?.base58 || undefined;
420
+ }
421
+ if (!nextAddress) {
422
+ this.cleanupActive();
423
+ this.state.set({ status: 'disconnected' });
424
+ return;
425
+ }
426
+ this.active = { ...this.active, address: nextAddress };
427
+ this.state.set({
428
+ status: 'connected',
429
+ walletId: this.active.walletId,
430
+ address: nextAddress
431
+ });
432
+ }
433
+ cleanupActive() {
434
+ if (this.active?.provider.removeListener) {
435
+ for (const { event, handler } of this.boundListeners) {
436
+ this.active.provider.removeListener(event, handler);
437
+ }
438
+ }
439
+ this.boundListeners = [];
440
+ this.active = null;
441
+ this.activeNetworkId = null;
442
+ }
443
+ }
444
+ function isTronNative(request) {
445
+ return ('from' in request &&
446
+ 'to' in request &&
447
+ typeof request.amount === 'number' &&
448
+ !('contractAddress' in request));
449
+ }
450
+ function isTronTRC20(request) {
451
+ return ('from' in request &&
452
+ 'to' in request &&
453
+ 'contractAddress' in request &&
454
+ typeof request.amount === 'number');
455
+ }
456
+ //# sourceMappingURL=tron-connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-connector.js","sourceRoot":"","sources":["../src/tron-connector.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,gBAAgB,EAEjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,cAAc,EAEf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC1E,OAAO,EACL,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,cAAc,EACd,oBAAoB,EAErB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EAEf,MAAM,oBAAoB,CAAA;AAG3B,sEAAsE;AACtE,MAAM,aAAa,GAAG,CAAC,iBAAiB,EAAE,YAAY,CAAU,CAAA;AAEhE;;;GAGG;AACH,MAAM,4BAA4B,GAAG,GAAG,CAAA;AAQxC;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,aAAa;IACP,MAAM,CAAqB;IAC3B,OAAO,CAA2B;IAClC,eAAe,GAAG,IAAI,GAAG,EAA6B,CAAA;IACtD,KAAK,GAAG,IAA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,CAAC,CAAA;IACJ,CAAC;IAEO,aAAa;QACnB,IAAI,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,EAAE,CAAC;YACzC,KAAK,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;gBACrD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;QAClB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;IAC7B,CAAC;CACF;AAED,SAAS,YAAY,CACnB,OAA2B;IAE3B,OAAO,CACL,MAAM,IAAI,OAAO;QACjB,IAAI,IAAI,OAAO;QACf,OAAQ,OAAqC,CAAC,MAAM,KAAK,QAAQ;QACjE,CAAC,CAAC,iBAAiB,IAAI,OAAO,CAAC,CAChC,CAAA;AACH,CAAC;AAED,SAAS,WAAW,CAClB,OAA2B;IAE3B,OAAO,CACL,MAAM,IAAI,OAAO;QACjB,IAAI,IAAI,OAAO;QACf,iBAAiB,IAAI,OAAO;QAC5B,OAAQ,OAAoC,CAAC,MAAM,KAAK,QAAQ,CACjE,CAAA;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Public configuration types for the Tron connector now live in
3
+ * `@meshconnect/uwc-types` (alongside `TonConnectConfig` / `WalletConnectConfig`)
4
+ * so they can thread through `UniversalWalletConnector`. Re-exported here for
5
+ * convenience and backward compatibility.
6
+ */
7
+ export type { TronConnectorConfig, TronGridConfig, TronWalletId } from '@meshconnect/uwc-types';
8
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,YAAY,EACb,MAAM,wBAAwB,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}