@recoillink/tron-sdk 0.0.0-stage → 26.0.1

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 (107) hide show
  1. package/LICENSE.md +193 -0
  2. package/README.md +44 -2
  3. package/dist/clients/protocol.d.ts +27 -0
  4. package/dist/clients/protocol.d.ts.map +1 -0
  5. package/dist/clients/protocol.js +53 -0
  6. package/dist/clients/protocol.js.map +1 -0
  7. package/dist/clients/provider.d.ts +30 -0
  8. package/dist/clients/provider.d.ts.map +1 -0
  9. package/dist/clients/provider.js +268 -0
  10. package/dist/clients/provider.js.map +1 -0
  11. package/dist/clients/signer.d.ts +16 -0
  12. package/dist/clients/signer.d.ts.map +1 -0
  13. package/dist/clients/signer.js +38 -0
  14. package/dist/clients/signer.js.map +1 -0
  15. package/dist/ethers/TronContractFactory.d.ts +32 -0
  16. package/dist/ethers/TronContractFactory.d.ts.map +1 -0
  17. package/dist/ethers/TronContractFactory.js +54 -0
  18. package/dist/ethers/TronContractFactory.js.map +1 -0
  19. package/dist/ethers/TronJsonRpcProvider.d.ts +74 -0
  20. package/dist/ethers/TronJsonRpcProvider.d.ts.map +1 -0
  21. package/dist/ethers/TronJsonRpcProvider.integration.test.d.ts +2 -0
  22. package/dist/ethers/TronJsonRpcProvider.integration.test.d.ts.map +1 -0
  23. package/dist/ethers/TronJsonRpcProvider.integration.test.js +46 -0
  24. package/dist/ethers/TronJsonRpcProvider.integration.test.js.map +1 -0
  25. package/dist/ethers/TronJsonRpcProvider.js +261 -0
  26. package/dist/ethers/TronJsonRpcProvider.js.map +1 -0
  27. package/dist/ethers/TronJsonRpcProvider.test.d.ts +2 -0
  28. package/dist/ethers/TronJsonRpcProvider.test.d.ts.map +1 -0
  29. package/dist/ethers/TronJsonRpcProvider.test.js +336 -0
  30. package/dist/ethers/TronJsonRpcProvider.test.js.map +1 -0
  31. package/dist/ethers/TronWallet.d.ts +69 -0
  32. package/dist/ethers/TronWallet.d.ts.map +1 -0
  33. package/dist/ethers/TronWallet.integration.test.d.ts +2 -0
  34. package/dist/ethers/TronWallet.integration.test.d.ts.map +1 -0
  35. package/dist/ethers/TronWallet.integration.test.js +151 -0
  36. package/dist/ethers/TronWallet.integration.test.js.map +1 -0
  37. package/dist/ethers/TronWallet.js +295 -0
  38. package/dist/ethers/TronWallet.js.map +1 -0
  39. package/dist/ethers/TronWallet.test.d.ts +2 -0
  40. package/dist/ethers/TronWallet.test.d.ts.map +1 -0
  41. package/dist/ethers/TronWallet.test.js +216 -0
  42. package/dist/ethers/TronWallet.test.js.map +1 -0
  43. package/dist/ethers/index.d.ts +4 -0
  44. package/dist/ethers/index.d.ts.map +1 -0
  45. package/dist/ethers/index.js +4 -0
  46. package/dist/ethers/index.js.map +1 -0
  47. package/dist/ethers/urlUtils.d.ts +32 -0
  48. package/dist/ethers/urlUtils.d.ts.map +1 -0
  49. package/dist/ethers/urlUtils.js +67 -0
  50. package/dist/ethers/urlUtils.js.map +1 -0
  51. package/dist/ethers/urlUtils.test.d.ts +2 -0
  52. package/dist/ethers/urlUtils.test.d.ts.map +1 -0
  53. package/dist/ethers/urlUtils.test.js +106 -0
  54. package/dist/ethers/urlUtils.test.js.map +1 -0
  55. package/dist/factories/index.d.ts +2 -0
  56. package/dist/factories/index.d.ts.map +1 -0
  57. package/dist/factories/index.js +8 -0
  58. package/dist/factories/index.js.map +1 -0
  59. package/dist/hook/hook-query.d.ts +41 -0
  60. package/dist/hook/hook-query.d.ts.map +1 -0
  61. package/dist/hook/hook-query.js +79 -0
  62. package/dist/hook/hook-query.js.map +1 -0
  63. package/dist/hook/hook-tx.d.ts +39 -0
  64. package/dist/hook/hook-tx.d.ts.map +1 -0
  65. package/dist/hook/hook-tx.js +95 -0
  66. package/dist/hook/hook-tx.js.map +1 -0
  67. package/dist/index.d.ts +7 -0
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +9 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/ism/ism-query.d.ts +70 -0
  72. package/dist/ism/ism-query.d.ts.map +1 -0
  73. package/dist/ism/ism-query.js +137 -0
  74. package/dist/ism/ism-query.js.map +1 -0
  75. package/dist/ism/ism-tx.d.ts +67 -0
  76. package/dist/ism/ism-tx.d.ts.map +1 -0
  77. package/dist/ism/ism-tx.js +110 -0
  78. package/dist/ism/ism-tx.js.map +1 -0
  79. package/dist/runtime.d.ts +8 -0
  80. package/dist/runtime.d.ts.map +1 -0
  81. package/dist/runtime.js +6 -0
  82. package/dist/runtime.js.map +1 -0
  83. package/dist/testing/constants.d.ts +7 -0
  84. package/dist/testing/constants.d.ts.map +1 -0
  85. package/dist/testing/constants.js +7 -0
  86. package/dist/testing/constants.js.map +1 -0
  87. package/dist/testing/index.d.ts +3 -0
  88. package/dist/testing/index.d.ts.map +1 -0
  89. package/dist/testing/index.js +4 -0
  90. package/dist/testing/index.js.map +1 -0
  91. package/dist/testing/node.d.ts +41 -0
  92. package/dist/testing/node.d.ts.map +1 -0
  93. package/dist/testing/node.js +119 -0
  94. package/dist/testing/node.js.map +1 -0
  95. package/dist/utils/index.d.ts +68 -0
  96. package/dist/utils/index.d.ts.map +1 -0
  97. package/dist/utils/index.js +141 -0
  98. package/dist/utils/index.js.map +1 -0
  99. package/dist/utils/index.test.d.ts +2 -0
  100. package/dist/utils/index.test.d.ts.map +1 -0
  101. package/dist/utils/index.test.js +85 -0
  102. package/dist/utils/index.test.js.map +1 -0
  103. package/dist/utils/types.d.ts +94 -0
  104. package/dist/utils/types.d.ts.map +1 -0
  105. package/dist/utils/types.js +13 -0
  106. package/dist/utils/types.js.map +1 -0
  107. package/package.json +74 -3
@@ -0,0 +1,295 @@
1
+ import { BigNumber, Wallet, ethers } from 'ethers';
2
+ import { keccak256 as ethersKeccak256 } from 'ethers/lib/utils.js';
3
+ import { TronWeb } from 'tronweb';
4
+ import { assert, ensure0x, isNullish, retryAsync, sleep, strip0x, } from '@recoillink/utils';
5
+ import { MAX_TRON_ORIGIN_ENERGY_LIMIT, TronJsonRpcProvider, } from './TronJsonRpcProvider.js';
6
+ import { assertTronReceiptSuccess, toTronHex } from '../utils/index.js';
7
+ import { stripCustomRpcHeaders, toHttpApiUrl } from './urlUtils.js';
8
+ /** Interval between confirmation polls while waiting for a receipt. */
9
+ const TX_CONFIRMATION_POLL_MS = 1_000;
10
+ /**
11
+ * TronWallet extends ethers Wallet to handle Tron's transaction format.
12
+ *
13
+ * Takes a single Tron node URL (e.g. http://localhost:9090) and derives:
14
+ * - JSON-RPC provider at {url}/jsonrpc for ethers compatibility
15
+ * - TronWeb HTTP client at {url} for transaction building/signing
16
+ *
17
+ * Tron's JSON-RPC doesn't support eth_sendRawTransaction, so we override
18
+ * sendTransaction to use TronWeb for building, signing, and broadcasting.
19
+ *
20
+ * Gas estimation is handled by ethers (via eth_estimateGas), and we convert
21
+ * gasLimit to Tron's feeLimit using: feeLimit = gasLimit × gasPrice.
22
+ */
23
+ export class TronWallet extends Wallet {
24
+ /**
25
+ * Static counter to ensure unique txIDs across all wallet instances.
26
+ * Must be static because connect() creates new instances, and Tron txIDs
27
+ * are derived from transaction content + expiration. Without a shared counter,
28
+ * two instances could generate identical txIDs in the same block.
29
+ */
30
+ static txCounter = 0;
31
+ originalTronUrl;
32
+ tronWeb;
33
+ tronAddress;
34
+ tronAddressHex;
35
+ txBuilder;
36
+ constructor(privateKey, tronUrl) {
37
+ // `tronUrl` is the chain's HTTP RPC endpoint (root URL or a .../jsonrpc URL).
38
+ // TronWeb needs the Tron HTTP API base host; use the caller-provided host
39
+ // directly (matching the AltVM TronProvider) so a private/custom RPC is
40
+ // honored for building, signing and broadcasting instead of being silently
41
+ // redirected to the public TronGrid endpoint. Custom headers (e.g. API keys)
42
+ // are preserved via `custom_rpc_header`.
43
+ const { headers } = stripCustomRpcHeaders(tronUrl);
44
+ const tronWebUrl = toHttpApiUrl(tronUrl);
45
+ super(privateKey, new TronJsonRpcProvider(tronUrl));
46
+ this.originalTronUrl = tronUrl;
47
+ this.tronWeb = new TronWeb({ fullHost: tronWebUrl, headers });
48
+ const cleanKey = strip0x(privateKey);
49
+ this.tronWeb.setPrivateKey(cleanKey);
50
+ const derivedAddress = this.tronWeb.address.fromPrivateKey(cleanKey);
51
+ assert(derivedAddress, 'Failed to derive Tron address from private key');
52
+ this.tronAddress = derivedAddress;
53
+ this.tronAddressHex = this.tronWeb.address.toHex(this.tronAddress);
54
+ this.tronWeb.setAddress(this.tronAddress);
55
+ this.txBuilder = new TronTransactionBuilder(tronWebUrl, this.tronAddress, tronUrl, headers);
56
+ }
57
+ /**
58
+ * Override connect to preserve TronWallet type.
59
+ * Base Wallet.connect() returns a plain Wallet, losing Tron behavior.
60
+ */
61
+ connect(_provider) {
62
+ return new TronWallet(this.privateKey, this.originalTronUrl);
63
+ }
64
+ /** Convert Tron address (base58 or 41-hex) to ethers 0x address */
65
+ toEvmAddress(tronAddress) {
66
+ const hex = this.tronWeb.address.toHex(tronAddress);
67
+ const rawAddress = ensure0x(hex.slice(2)).toLowerCase();
68
+ return ethers.utils.getAddress(rawAddress);
69
+ }
70
+ /** Tron doesn't use nonces */
71
+ async getTransactionCount(_blockTag) {
72
+ return 0;
73
+ }
74
+ async sendTransaction(transaction) {
75
+ // Populate transaction (estimates gas and gas price if not set)
76
+ const tx = await this.populateTransaction(transaction);
77
+ assert(tx.gasLimit, 'gasLimit is required');
78
+ assert(tx.gasPrice, 'gasPrice is required');
79
+ let tronTx = await this.txBuilder.buildTransaction(tx);
80
+ // Ensure unique txID by extending expiration with a counter.
81
+ // Tron has no nonces, so identical txs in the same block produce the same txID.
82
+ tronTx = await this.makeUnique(tronTx);
83
+ // Sign and broadcast
84
+ const signedTx = await this.tronWeb.trx.sign(tronTx);
85
+ const broadcastResult = await this.tronWeb.trx.sendRawTransaction(signedTx);
86
+ assert(broadcastResult.result, `Broadcast failed: ${broadcastResult.message}`);
87
+ return this.txBuilder.getTransactionResponse(tx, tronTx);
88
+ }
89
+ async makeUnique(tronTx) {
90
+ const counter = ++TronWallet.txCounter;
91
+ // Use data (memo field) instead of extension to avoid TronWeb's
92
+ // time-based validation which fails when node clock drifts.
93
+ const data = '0x' + counter.toString(16).padStart(8, '0');
94
+ const altered = await this.tronWeb.transactionBuilder.alterTransaction(tronTx, {
95
+ data,
96
+ dataFormat: 'hex',
97
+ txLocal: true,
98
+ });
99
+ // For deployments, recompute contract_address from the new txID.
100
+ // genContractAddress = '41' + keccak256(txID + ownerHex)[24:]
101
+ if ('contract_address' in tronTx) {
102
+ const hash = ethersKeccak256(Buffer.from(altered.txID + this.tronAddressHex, 'hex'));
103
+ altered.contract_address = '41' + hash.substring(2).slice(24);
104
+ }
105
+ return altered;
106
+ }
107
+ }
108
+ export class TronTransactionBuilder extends TronWeb {
109
+ tronAddress;
110
+ tronAddressHex;
111
+ confirmationTimeoutMs;
112
+ confirmationPollMs;
113
+ constructor(tronWebUrl, tronAddress, _jsonRpcUrl, headers, confirmationTimeoutMs, confirmationPollMs = TX_CONFIRMATION_POLL_MS) {
114
+ // Strip custom_rpc_header from the URL and merge with any provided headers
115
+ const { url: cleanTronWebUrl, headers: parsedHeaders } = stripCustomRpcHeaders(tronWebUrl);
116
+ const mergedHeaders = { ...parsedHeaders, ...headers };
117
+ super({ fullHost: cleanTronWebUrl, headers: mergedHeaders });
118
+ this.tronAddress = tronAddress;
119
+ this.setAddress(this.tronAddress);
120
+ this.tronAddressHex = this.address.toHex(this.tronAddress);
121
+ this.confirmationTimeoutMs = confirmationTimeoutMs;
122
+ this.confirmationPollMs = confirmationPollMs;
123
+ }
124
+ getTransactionResponse(evmTx, tronTx, txHash) {
125
+ const originalTxHash = ensure0x(tronTx.txID);
126
+ const gasPrice = evmTx.gasPrice
127
+ ? BigNumber.from(evmTx.gasPrice)
128
+ : BigNumber.from(0);
129
+ const gasLimit = evmTx.gasLimit
130
+ ? BigNumber.from(evmTx.gasLimit)
131
+ : BigNumber.from(0);
132
+ return {
133
+ hash: txHash ?? originalTxHash,
134
+ confirmations: 0,
135
+ from: ethers.utils.getAddress(ensure0x(this.tronAddressHex.slice(2)).toLowerCase()),
136
+ to: evmTx.to ?? undefined,
137
+ nonce: 0,
138
+ gasLimit,
139
+ gasPrice,
140
+ data: isNullish(evmTx.data) ? '0x' : ethers.utils.hexlify(evmTx.data),
141
+ value: BigNumber.from(evmTx.value ?? 0),
142
+ chainId: evmTx.chainId,
143
+ tronTransaction: tronTx,
144
+ wait: async (confirmations) => {
145
+ const hash = txHash ? ensure0x(txHash) : originalTxHash;
146
+ const receipt = await this.waitForTransactionReceipt(hash, confirmations, evmTx);
147
+ // CAST: ethers v5 types `TransactionResponse.wait` as returning a
148
+ // non-null `TransactionReceipt`, yet its own runtime resolves `null`
149
+ // from `wait(0)` for a still-pending tx (see MultiProvider.handleTx,
150
+ // which branches on that null). `waitForTransactionReceipt` mirrors
151
+ // that contract, so the null escapes here exactly as ethers' own
152
+ // `wait` does; the declared ethers type cannot be widened.
153
+ return receipt;
154
+ },
155
+ };
156
+ }
157
+ async waitForTransactionReceipt(txHash, confirmations = 1, evmTx) {
158
+ const txid = strip0x(txHash);
159
+ // ethers v5 `waitForTransaction(hash, 0)` resolves immediately: the receipt
160
+ // if the tx is already mined, otherwise `null` for a still-pending tx.
161
+ // MultiProvider.handleTx relies on this non-blocking probe before deciding
162
+ // whether to wait for inclusion, so `wait(0)` must not enter the poll loop.
163
+ if (confirmations < 1) {
164
+ const info = await retryAsync(() => this.trx.getUnconfirmedTransactionInfo(txid), 5, 500);
165
+ if (info?.id && info.blockNumber) {
166
+ // A mined tx must surface its on-chain failure even on the wait(0)
167
+ // probe, matching ethers, whose wait(0) throws CALL_EXCEPTION on a
168
+ // status-0 receipt (only a still-pending tx resolves null).
169
+ assertTronReceiptSuccess(info, this, txid);
170
+ return this.buildReceipt(info, 1, evmTx);
171
+ }
172
+ return null;
173
+ }
174
+ const deadline = isNullish(this.confirmationTimeoutMs)
175
+ ? undefined
176
+ : Date.now() + this.confirmationTimeoutMs;
177
+ while (isNullish(deadline) || Date.now() < deadline) {
178
+ const info = await retryAsync(() => this.trx.getUnconfirmedTransactionInfo(txid), 5, 500);
179
+ if (info?.id && info.blockNumber) {
180
+ const currentBlock = confirmations > 1
181
+ ? await retryAsync(() => this.trx.getCurrentBlock(), 5, 500)
182
+ : undefined;
183
+ const actualConfirmations = (currentBlock?.block_header.raw_data.number ?? info.blockNumber) -
184
+ info.blockNumber +
185
+ 1;
186
+ if (actualConfirmations >= confirmations) {
187
+ // Only finalize success/failure once the requested depth is reached,
188
+ // so a reorgable on-chain failure is not rejected prematurely at a
189
+ // single confirmation when the caller asked for more.
190
+ assertTronReceiptSuccess(info, this, txid);
191
+ return this.buildReceipt(info, actualConfirmations, evmTx);
192
+ }
193
+ }
194
+ await sleep(this.confirmationPollMs);
195
+ }
196
+ throw new Error(`Tron transaction ${txid} not confirmed within ${this.confirmationTimeoutMs}ms`);
197
+ }
198
+ /** Convert a Tron `41`-prefixed (or bare) hex address to a checksummed EVM address. */
199
+ tronHexToEvmAddress(address) {
200
+ const stripped = address.startsWith('41') && address.length === 42
201
+ ? address.slice(2)
202
+ : address;
203
+ return ethers.utils.getAddress(ensure0x(stripped));
204
+ }
205
+ async buildReceipt(info, confirmations, evmTx) {
206
+ const block = await retryAsync(() => this.trx.getBlockByNumber(info.blockNumber), 5, 500);
207
+ return this.toEthersReceipt(info, confirmations, evmTx, ensure0x(block.blockID));
208
+ }
209
+ toEthersReceipt(info, confirmations, evmTx, blockHash) {
210
+ const transactionHash = ensure0x(info.id);
211
+ const logs = (info.log ?? []).map((log, logIndex) => ({
212
+ blockNumber: info.blockNumber,
213
+ blockHash,
214
+ transactionIndex: 0,
215
+ removed: false,
216
+ address: this.tronHexToEvmAddress(log.address),
217
+ data: ensure0x(log.data ?? ''),
218
+ topics: (log.topics ?? []).map((topic) => ensure0x(topic)),
219
+ transactionHash,
220
+ logIndex,
221
+ }));
222
+ const gasUsed = BigNumber.from(info.receipt?.energy_usage_total ?? 0);
223
+ const receipt = {
224
+ to: evmTx.to ?? ethers.constants.AddressZero,
225
+ from: ethers.utils.getAddress(ensure0x(this.tronAddressHex.slice(2)).toLowerCase()),
226
+ // Tron surfaces the created contract address only for deployments; a
227
+ // contract call leaves it empty, matching ethers' null contractAddress.
228
+ contractAddress: info.contract_address
229
+ ? this.tronHexToEvmAddress(info.contract_address)
230
+ : ethers.constants.AddressZero,
231
+ transactionIndex: 0,
232
+ gasUsed,
233
+ logsBloom: `0x${'0'.repeat(512)}`,
234
+ blockHash,
235
+ transactionHash,
236
+ logs,
237
+ blockNumber: info.blockNumber,
238
+ confirmations,
239
+ cumulativeGasUsed: gasUsed,
240
+ effectiveGasPrice: BigNumber.from(0),
241
+ byzantium: true,
242
+ type: 0,
243
+ status: 1,
244
+ };
245
+ return receipt;
246
+ }
247
+ async buildTransaction(tx) {
248
+ const gasPrice = tx.gasPrice
249
+ ? BigNumber.from(tx.gasPrice)
250
+ : BigNumber.from(0);
251
+ const gasLimit = tx.gasLimit
252
+ ? BigNumber.from(tx.gasLimit)
253
+ : BigNumber.from(0);
254
+ let feeLimit = gasLimit.mul(gasPrice).toNumber() * 1.5;
255
+ feeLimit = Math.min(feeLimit, 1000000000);
256
+ feeLimit = feeLimit <= 0 ? 1000000000 : feeLimit;
257
+ const callValue = tx.value ? BigNumber.from(tx.value).toNumber() : 0;
258
+ if (!tx.to) {
259
+ return this.buildDeployment(tx, feeLimit, callValue, gasLimit);
260
+ }
261
+ else if (tx.data && tx.data !== '0x') {
262
+ return this.buildContractCall(tx, feeLimit, callValue);
263
+ }
264
+ else {
265
+ return this.buildTransfer(tx.to, callValue);
266
+ }
267
+ }
268
+ async buildDeployment(tx, feeLimit, callValue, gasLimit) {
269
+ assert(tx.data, 'Deployment transaction must have data');
270
+ return this.transactionBuilder.createSmartContract({
271
+ abi: [],
272
+ bytecode: strip0x(ethers.utils.hexlify(tx.data)),
273
+ feeLimit,
274
+ callValue,
275
+ originEnergyLimit: Math.min(gasLimit.toNumber(), MAX_TRON_ORIGIN_ENERGY_LIMIT),
276
+ }, this.tronAddress);
277
+ }
278
+ async buildContractCall(tx, feeLimit, callValue) {
279
+ assert(tx.to, 'Contract call transaction must have a destination');
280
+ assert(tx.data, 'Contract call transaction must have data');
281
+ const tronHexTo = toTronHex(this, tx.to);
282
+ const result = await this.transactionBuilder.triggerSmartContract(tronHexTo, '', {
283
+ feeLimit,
284
+ callValue,
285
+ input: strip0x(ethers.utils.hexlify(tx.data)),
286
+ }, [], this.tronAddress);
287
+ assert(result.result?.result, `triggerSmartContract failed: ${result.result?.message}`);
288
+ return result.transaction;
289
+ }
290
+ async buildTransfer(to, callValue) {
291
+ const tronHexTo = toTronHex(this, to);
292
+ return this.transactionBuilder.sendTrx(tronHexTo, callValue, this.tronAddress);
293
+ }
294
+ }
295
+ //# sourceMappingURL=TronWallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TronWallet.js","sourceRoot":"","sources":["../../src/ethers/TronWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAa,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,SAAS,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAS,MAAM,SAAS,CAAC;AAEzC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,EACV,KAAK,EACL,OAAO,GACR,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEpE,uEAAuE;AACvE,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAgBtC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,UAAW,SAAQ,MAAM;IACpC;;;;;OAKG;IACK,MAAM,CAA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O,KAAK,CAAC,aAAa,CACzB,EAAU,EACV,SAAiB;QAEjB,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CACpC,SAAS,EACT,SAAS,EACT,IAAI,CAAC,WAAW,CACjB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TronWallet.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TronWallet.test.d.ts","sourceRoot":"","sources":["../../src/ethers/TronWallet.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,216 @@
1
+ import chai, { expect } from 'chai';
2
+ import chaiAsPromised from 'chai-as-promised';
3
+ import { BigNumber, constants, utils } from 'ethers';
4
+ import { assert, strip0x } from '@recoillink/utils';
5
+ import { TronTransactionBuilder } from './TronWallet.js';
6
+ chai.use(chaiAsPromised);
7
+ const TXID = '42'.repeat(32);
8
+ const ADDRESS = 'TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE';
9
+ const BLOCK_HASH = 'ab'.repeat(32);
10
+ // Tron surfaces the deployed contract address as a `41`-prefixed hex string.
11
+ const DEPLOYED_TRON_HEX = '4119335987d77120c462ca7df51cf29f68a38e6d6c';
12
+ const DEPLOYED_EVM = '0x19335987d77120c462ca7dF51cf29f68A38E6D6C';
13
+ function makeBuilder(confirmationTimeoutMs, confirmationPollMs) {
14
+ return new TronTransactionBuilder('https://node.example.com', ADDRESS, undefined, undefined, confirmationTimeoutMs, confirmationPollMs);
15
+ }
16
+ function injectTrx(builder, trx) {
17
+ // CAST: overwrite the builder's private `trx` field with a minimal double.
18
+ builder.trx = trx;
19
+ }
20
+ const blockByNumber = async () => ({ blockID: BLOCK_HASH });
21
+ // getTransactionResponse only reads `txID` off the Tron transaction; a full
22
+ // TronWeb transaction-union member is impractical to construct here.
23
+ function makeTronTx(txID) {
24
+ // CAST: minimal stand-in for the TronTransaction union.
25
+ return { txID };
26
+ }
27
+ function buildResponse(builder) {
28
+ return builder.getTransactionResponse({
29
+ chainId: 728126428,
30
+ gasLimit: BigNumber.from(10),
31
+ gasPrice: BigNumber.from(1),
32
+ to: '0x496ba8ba0871a037ec1617f002f0a4afe5c2bae1',
33
+ }, makeTronTx(TXID));
34
+ }
35
+ // A deployment response carries no `to`; the receipt's contractAddress must be
36
+ // derived from the Tron transaction info instead.
37
+ function buildDeploymentResponse(builder) {
38
+ return builder.getTransactionResponse({
39
+ chainId: 728126428,
40
+ gasLimit: BigNumber.from(10),
41
+ gasPrice: BigNumber.from(1),
42
+ data: '0x60016002',
43
+ }, makeTronTx(TXID));
44
+ }
45
+ describe('TronTransactionBuilder', () => {
46
+ it('confirms transactions through the Tron HTTP API', async () => {
47
+ const builder = makeBuilder();
48
+ injectTrx(builder, {
49
+ getUnconfirmedTransactionInfo: async () => ({
50
+ id: TXID,
51
+ blockNumber: 123,
52
+ receipt: { result: 'SUCCESS', energy_usage_total: 7 },
53
+ log: [
54
+ {
55
+ address: '496ba8ba0871a037ec1617f002f0a4afe5c2bae1',
56
+ topics: ['8c5be1e5'],
57
+ data: '01',
58
+ },
59
+ {
60
+ address: '19335987d77120c462ca7df51cf29f68a38e6d6c',
61
+ topics: ['788dbc1b'],
62
+ },
63
+ ],
64
+ }),
65
+ getBlockByNumber: blockByNumber,
66
+ });
67
+ const receipt = await buildResponse(builder).wait(1);
68
+ expect(receipt.transactionHash).to.equal(`0x${TXID}`);
69
+ expect(receipt.blockHash).to.equal(`0x${BLOCK_HASH}`);
70
+ expect(receipt.status).to.equal(1);
71
+ const [firstLog, secondLog] = receipt.logs;
72
+ assert(firstLog && secondLog, 'Expected two receipt logs');
73
+ expect(firstLog.address).to.equal('0x496bA8BA0871A037eC1617f002F0A4AfE5C2bae1');
74
+ expect(secondLog.data).to.equal('0x');
75
+ });
76
+ it('returns once the requested confirmation depth is reached', async () => {
77
+ // Short timeout so a broken actualConfirmations computation fails fast
78
+ // instead of polling until the caller's (here unbounded) production wait.
79
+ const builder = makeBuilder(200, 5);
80
+ injectTrx(builder, {
81
+ getUnconfirmedTransactionInfo: async () => ({
82
+ id: TXID,
83
+ blockNumber: 100,
84
+ receipt: { result: 'SUCCESS', energy_usage_total: 7 },
85
+ log: [],
86
+ }),
87
+ getCurrentBlock: async () => ({
88
+ block_header: { raw_data: { number: 101 } },
89
+ }),
90
+ getBlockByNumber: blockByNumber,
91
+ });
92
+ const receipt = await buildResponse(builder).wait(2);
93
+ // actualConfirmations = currentBlock(101) - txBlock(100) + 1 = 2.
94
+ // Without the `+ 1` this would be 1 (< 2) and the poll would time out.
95
+ expect(receipt.confirmations).to.equal(2);
96
+ expect(receipt.blockNumber).to.equal(100);
97
+ });
98
+ it('wait(0) returns null without blocking for a still-pending tx', async () => {
99
+ // Unbounded builder: proves the wait(0) probe returns immediately rather
100
+ // than entering (and hanging in) the confirmation poll loop.
101
+ const builder = makeBuilder();
102
+ let lookups = 0;
103
+ injectTrx(builder, {
104
+ getUnconfirmedTransactionInfo: async () => {
105
+ lookups += 1;
106
+ return {};
107
+ },
108
+ });
109
+ const receipt = await buildResponse(builder).wait(0);
110
+ expect(receipt).to.equal(null);
111
+ expect(lookups).to.equal(1);
112
+ });
113
+ it('wait(0) returns the receipt for an already-mined tx', async () => {
114
+ const builder = makeBuilder();
115
+ injectTrx(builder, {
116
+ getUnconfirmedTransactionInfo: async () => ({
117
+ id: TXID,
118
+ blockNumber: 123,
119
+ receipt: { result: 'SUCCESS', energy_usage_total: 7 },
120
+ log: [],
121
+ }),
122
+ getBlockByNumber: blockByNumber,
123
+ });
124
+ const receipt = await buildResponse(builder).wait(0);
125
+ expect(receipt).to.not.equal(null);
126
+ expect(receipt?.blockNumber).to.equal(123);
127
+ expect(receipt?.blockHash).to.equal(`0x${BLOCK_HASH}`);
128
+ expect(receipt?.confirmations).to.equal(1);
129
+ });
130
+ it('wait(0) rejects with the revert reason for a mined-but-reverted tx', async () => {
131
+ const builder = makeBuilder();
132
+ const revertReason = 'insufficient allowance';
133
+ const encodedRevert = '08c379a0' +
134
+ strip0x(utils.defaultAbiCoder.encode(['string'], [revertReason]));
135
+ injectTrx(builder, {
136
+ getUnconfirmedTransactionInfo: async () => ({
137
+ id: TXID,
138
+ blockNumber: 123,
139
+ receipt: { result: 'REVERT' },
140
+ contractResult: [encodedRevert],
141
+ }),
142
+ });
143
+ // Mined-but-reverted must surface as a failure even on the wait(0) probe,
144
+ // matching ethers' status-0 CALL_EXCEPTION rather than a status-1 receipt.
145
+ await expect(buildResponse(builder).wait(0)).to.be.rejectedWith(new RegExp(`Tron Transaction Failed: ${revertReason} \\(txid: ${TXID}\\)`));
146
+ });
147
+ it('does not finalize a failed receipt before the requested depth', async () => {
148
+ const builder = makeBuilder(200, 5);
149
+ const revertReason = 'insufficient allowance';
150
+ const encodedRevert = '08c379a0' +
151
+ strip0x(utils.defaultAbiCoder.encode(['string'], [revertReason]));
152
+ let blockChecks = 0;
153
+ injectTrx(builder, {
154
+ getUnconfirmedTransactionInfo: async () => ({
155
+ id: TXID,
156
+ blockNumber: 100,
157
+ receipt: { result: 'REVERT' },
158
+ contractResult: [encodedRevert],
159
+ }),
160
+ // First poll yields depth 1 (< 2) so the failure must NOT be finalized;
161
+ // the second poll reaches depth 2 and only then may reject.
162
+ getCurrentBlock: async () => {
163
+ blockChecks += 1;
164
+ const number = blockChecks < 2 ? 100 : 101;
165
+ return {
166
+ block_header: { raw_data: { number } },
167
+ };
168
+ },
169
+ });
170
+ await expect(buildResponse(builder).wait(2)).to.be.rejectedWith(new RegExp(`Tron Transaction Failed: ${revertReason} \\(txid: ${TXID}\\)`));
171
+ // Proves the reorgable failure was not finalized at the first confirmation.
172
+ expect(blockChecks).to.be.greaterThan(1);
173
+ });
174
+ it('populates the deployed contract address and block hash for a deployment', async () => {
175
+ const builder = makeBuilder();
176
+ injectTrx(builder, {
177
+ getUnconfirmedTransactionInfo: async () => ({
178
+ id: TXID,
179
+ blockNumber: 123,
180
+ contract_address: DEPLOYED_TRON_HEX,
181
+ receipt: { result: 'SUCCESS', energy_usage_total: 7 },
182
+ log: [],
183
+ }),
184
+ getBlockByNumber: blockByNumber,
185
+ });
186
+ const receipt = await buildDeploymentResponse(builder).wait(1);
187
+ expect(receipt.contractAddress).to.equal(DEPLOYED_EVM);
188
+ expect(receipt.contractAddress).to.not.equal(constants.AddressZero);
189
+ expect(receipt.blockHash).to.equal(`0x${BLOCK_HASH}`);
190
+ });
191
+ it('rejects with the revert reason when the receipt reports a failure', async () => {
192
+ const builder = makeBuilder();
193
+ const revertReason = 'insufficient allowance';
194
+ const encodedRevert = '08c379a0' +
195
+ strip0x(utils.defaultAbiCoder.encode(['string'], [revertReason]));
196
+ injectTrx(builder, {
197
+ getUnconfirmedTransactionInfo: async () => ({
198
+ id: TXID,
199
+ blockNumber: 123,
200
+ receipt: { result: 'REVERT' },
201
+ contractResult: [encodedRevert],
202
+ }),
203
+ });
204
+ await expect(buildResponse(builder).wait(1)).to.be.rejectedWith(new RegExp(`Tron Transaction Failed: ${revertReason} \\(txid: ${TXID}\\)`));
205
+ });
206
+ it('rejects with the txid once the confirmation timeout elapses', async () => {
207
+ const timeoutMs = 40;
208
+ const builder = makeBuilder(timeoutMs, 5);
209
+ injectTrx(builder, {
210
+ // Never surfaces an `id`, so the poll never confirms and must time out.
211
+ getUnconfirmedTransactionInfo: async () => ({}),
212
+ });
213
+ await expect(buildResponse(builder).wait(1)).to.be.rejectedWith(new RegExp(`Tron transaction ${TXID} not confirmed within ${timeoutMs}ms`));
214
+ });
215
+ });
216
+ //# sourceMappingURL=TronWallet.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TronWallet.test.js","sourceRoot":"","sources":["../../src/ethers/TronWallet.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,E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,CAAC;SACH,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,CAC7D,IAAI,MAAM,CACR,4BAA4B,YAAY,aAAa,IAAI,KAAK,CAC/D,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QAC1C,SAAS,CAAC,OAAO,EAAE;YACjB,wEAAwE;YACxE,6BAA6B,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,YAAY,CAC7D,IAAI,MAAM,CACR,oBAAoB,IAAI,yBAAyB,SAAS,IAAI,CAC/D,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { TronContractFactory } from './TronContractFactory.js';
2
+ export { TronJsonRpcProvider } from './TronJsonRpcProvider.js';
3
+ export { TronTransaction, TronTransactionResponse, TronWallet, TronTransactionBuilder, } from './TronWallet.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ethers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,UAAU,EACV,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { TronContractFactory } from './TronContractFactory.js';
2
+ export { TronJsonRpcProvider } from './TronJsonRpcProvider.js';
3
+ export { TronWallet, TronTransactionBuilder, } from './TronWallet.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ethers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAGL,UAAU,EACV,sBAAsB,GACvB,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Parse custom_rpc_header query params from a URL into a headers object.
3
+ * e.g. "https://api.trongrid.io?custom_rpc_header=TRON-PRO-API-KEY:abc"
4
+ * returns { "TRON-PRO-API-KEY": "abc" }
5
+ */
6
+ export declare function parseCustomHeaders(url: string): Record<string, string>;
7
+ /**
8
+ * Strip custom_rpc_header query params from a URL and return the clean URL
9
+ * along with the extracted headers.
10
+ *
11
+ * e.g. "https://host/jsonrpc?custom_rpc_header=x-api-key:abc&other=1"
12
+ * returns { url: "https://host/jsonrpc?other=1", headers: { "x-api-key": "abc" } }
13
+ *
14
+ * If no custom_rpc_header params are present, returns the original URL unchanged.
15
+ */
16
+ export declare function stripCustomRpcHeaders(url: string): {
17
+ url: string;
18
+ headers: Record<string, string>;
19
+ };
20
+ /**
21
+ * Derive the Tron HTTP API base host from an RPC URL.
22
+ *
23
+ * TronWeb needs the base HTTP API host (serving `/wallet/*`), which differs
24
+ * from the ethers JSON-RPC endpoint. This strips any `custom_rpc_header` query
25
+ * params (they are auth headers, not part of the host) and a trailing
26
+ * `/jsonrpc` path segment.
27
+ *
28
+ * e.g. "https://node.example.com/jsonrpc?custom_rpc_header=x-api-key:abc"
29
+ * returns "https://node.example.com/"
30
+ */
31
+ export declare function toHttpApiUrl(url: string): string;
32
+ //# sourceMappingURL=urlUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlUtils.d.ts","sourceRoot":"","sources":["../../src/ethers/urlUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAetE;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,CAaA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAOhD"}