@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.
- package/LICENSE.md +193 -0
- package/README.md +44 -2
- package/dist/clients/protocol.d.ts +27 -0
- package/dist/clients/protocol.d.ts.map +1 -0
- package/dist/clients/protocol.js +53 -0
- package/dist/clients/protocol.js.map +1 -0
- package/dist/clients/provider.d.ts +30 -0
- package/dist/clients/provider.d.ts.map +1 -0
- package/dist/clients/provider.js +268 -0
- package/dist/clients/provider.js.map +1 -0
- package/dist/clients/signer.d.ts +16 -0
- package/dist/clients/signer.d.ts.map +1 -0
- package/dist/clients/signer.js +38 -0
- package/dist/clients/signer.js.map +1 -0
- package/dist/ethers/TronContractFactory.d.ts +32 -0
- package/dist/ethers/TronContractFactory.d.ts.map +1 -0
- package/dist/ethers/TronContractFactory.js +54 -0
- package/dist/ethers/TronContractFactory.js.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.d.ts +74 -0
- package/dist/ethers/TronJsonRpcProvider.d.ts.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.d.ts +2 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.d.ts.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.js +46 -0
- package/dist/ethers/TronJsonRpcProvider.integration.test.js.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.js +261 -0
- package/dist/ethers/TronJsonRpcProvider.js.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.test.d.ts +2 -0
- package/dist/ethers/TronJsonRpcProvider.test.d.ts.map +1 -0
- package/dist/ethers/TronJsonRpcProvider.test.js +336 -0
- package/dist/ethers/TronJsonRpcProvider.test.js.map +1 -0
- package/dist/ethers/TronWallet.d.ts +69 -0
- package/dist/ethers/TronWallet.d.ts.map +1 -0
- package/dist/ethers/TronWallet.integration.test.d.ts +2 -0
- package/dist/ethers/TronWallet.integration.test.d.ts.map +1 -0
- package/dist/ethers/TronWallet.integration.test.js +151 -0
- package/dist/ethers/TronWallet.integration.test.js.map +1 -0
- package/dist/ethers/TronWallet.js +295 -0
- package/dist/ethers/TronWallet.js.map +1 -0
- package/dist/ethers/TronWallet.test.d.ts +2 -0
- package/dist/ethers/TronWallet.test.d.ts.map +1 -0
- package/dist/ethers/TronWallet.test.js +216 -0
- package/dist/ethers/TronWallet.test.js.map +1 -0
- package/dist/ethers/index.d.ts +4 -0
- package/dist/ethers/index.d.ts.map +1 -0
- package/dist/ethers/index.js +4 -0
- package/dist/ethers/index.js.map +1 -0
- package/dist/ethers/urlUtils.d.ts +32 -0
- package/dist/ethers/urlUtils.d.ts.map +1 -0
- package/dist/ethers/urlUtils.js +67 -0
- package/dist/ethers/urlUtils.js.map +1 -0
- package/dist/ethers/urlUtils.test.d.ts +2 -0
- package/dist/ethers/urlUtils.test.d.ts.map +1 -0
- package/dist/ethers/urlUtils.test.js +106 -0
- package/dist/ethers/urlUtils.test.js.map +1 -0
- package/dist/factories/index.d.ts +2 -0
- package/dist/factories/index.d.ts.map +1 -0
- package/dist/factories/index.js +8 -0
- package/dist/factories/index.js.map +1 -0
- package/dist/hook/hook-query.d.ts +41 -0
- package/dist/hook/hook-query.d.ts.map +1 -0
- package/dist/hook/hook-query.js +79 -0
- package/dist/hook/hook-query.js.map +1 -0
- package/dist/hook/hook-tx.d.ts +39 -0
- package/dist/hook/hook-tx.d.ts.map +1 -0
- package/dist/hook/hook-tx.js +95 -0
- package/dist/hook/hook-tx.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/ism/ism-query.d.ts +70 -0
- package/dist/ism/ism-query.d.ts.map +1 -0
- package/dist/ism/ism-query.js +137 -0
- package/dist/ism/ism-query.js.map +1 -0
- package/dist/ism/ism-tx.d.ts +67 -0
- package/dist/ism/ism-tx.d.ts.map +1 -0
- package/dist/ism/ism-tx.js +110 -0
- package/dist/ism/ism-tx.js.map +1 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +6 -0
- package/dist/runtime.js.map +1 -0
- package/dist/testing/constants.d.ts +7 -0
- package/dist/testing/constants.d.ts.map +1 -0
- package/dist/testing/constants.js +7 -0
- package/dist/testing/constants.js.map +1 -0
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/node.d.ts +41 -0
- package/dist/testing/node.d.ts.map +1 -0
- package/dist/testing/node.js +119 -0
- package/dist/testing/node.js.map +1 -0
- package/dist/utils/index.d.ts +68 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +141 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.test.d.ts +2 -0
- package/dist/utils/index.test.d.ts.map +1 -0
- package/dist/utils/index.test.js +85 -0
- package/dist/utils/index.test.js.map +1 -0
- package/dist/utils/types.d.ts +94 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +13 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +74 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { TronWeb } from 'tronweb';
|
|
2
|
+
import { IABI, TronReceipt } from './types.js';
|
|
3
|
+
import { providers } from 'ethers';
|
|
4
|
+
export declare const TRON_EMPTY_ADDRESS = "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb";
|
|
5
|
+
export declare const TRON_EMPTY_MESSAGE = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
6
|
+
export declare const EIP1967_ADMIN_SLOT = "0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103";
|
|
7
|
+
export declare function decodeRevertReason(hex: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Subset of a Tron transaction-info receipt needed to detect execution failure.
|
|
10
|
+
*
|
|
11
|
+
* `receipt` is optional because non-contract transfers surface no execution
|
|
12
|
+
* receipt, and the top-level `result` is what flags those as failures.
|
|
13
|
+
*/
|
|
14
|
+
export type TronReceiptResult = Pick<TronReceipt, 'resMessage' | 'contractResult' | 'result'> & Partial<Pick<TronReceipt, 'receipt'>>;
|
|
15
|
+
/**
|
|
16
|
+
* Throws when a mined Tron transaction reverted or failed on-chain.
|
|
17
|
+
*
|
|
18
|
+
* Tron surfaces execution failures through `getTransactionInfo` rather than the
|
|
19
|
+
* broadcast result, so both the ethers-compatible wallet path (TronWallet) and
|
|
20
|
+
* the AltVM provider path (TronProvider) must inspect the receipt to fail
|
|
21
|
+
* loudly, mirroring EVM's CALL_EXCEPTION on a status-0 receipt.
|
|
22
|
+
*/
|
|
23
|
+
export declare function assertTronReceiptSuccess(info: TronReceiptResult, tronweb: TronWeb, txid: string): void;
|
|
24
|
+
export declare function createDeploymentTransaction(tronweb: Readonly<TronWeb>, abi: IABI, signer: string, parameters: unknown[]): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Constructs MetaProxy bytecode that embeds metadata in the contract
|
|
27
|
+
* @param implementationAddress - Address of implementation contract
|
|
28
|
+
* @param metadata - ABI-encoded metadata to embed
|
|
29
|
+
* @returns Complete MetaProxy bytecode
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildMetaProxyBytecode(implementationAddress: string, metadata: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Deploys a contract using raw bytecode (for MetaProxy deployments)
|
|
34
|
+
* @param tronweb - TronWeb instance
|
|
35
|
+
* @param bytecode - Complete bytecode to deploy
|
|
36
|
+
* @param signer - Deployer address
|
|
37
|
+
* @param contractName - Optional name for the contract
|
|
38
|
+
* @returns Transaction object
|
|
39
|
+
*/
|
|
40
|
+
export declare function createRawBytecodeDeploymentTransaction(tronweb: Readonly<TronWeb>, bytecode: string, signer: string, contractName?: string): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Convert an address to Tron's 41-prefixed hex form.
|
|
43
|
+
*
|
|
44
|
+
* Accepts ethers 0x-hex, base58 (`T…`) or already-41-prefixed hex. Base58 is
|
|
45
|
+
* resolved through TronWeb so the checksum is validated rather than assumed.
|
|
46
|
+
*/
|
|
47
|
+
export declare function toTronHex(tronWeb: Readonly<TronWeb>, address: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Fields required to invoke a TronWeb transactionBuilder trigger
|
|
50
|
+
* (`triggerSmartContract` write or `triggerConstantContract` read).
|
|
51
|
+
*/
|
|
52
|
+
export interface TronTriggerRequest {
|
|
53
|
+
contractAddress: string;
|
|
54
|
+
callValue: number;
|
|
55
|
+
input?: string;
|
|
56
|
+
issuerAddress: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Builds a Tron contract-trigger request from an ethers transaction. Response
|
|
60
|
+
* handling is left to the caller: writes assert on the build result, reads
|
|
61
|
+
* return the raw constant-call data so ethers can surface reverts itself.
|
|
62
|
+
*
|
|
63
|
+
* The empty functionSelector tells TronWeb to use the raw ABI-encoded `input`
|
|
64
|
+
* bytes directly instead of encoding named parameters.
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildTronTriggerRequest(tronWeb: Readonly<TronWeb>, tx: providers.TransactionRequest, sender: string | undefined): TronTriggerRequest;
|
|
67
|
+
export declare function convertEthersToTronTransaction(tronWeb: Readonly<TronWeb>, tx: providers.TransactionRequest, sender: string): Promise<any>;
|
|
68
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAa,SAAS,EAAS,MAAM,QAAQ,CAAC;AAErD,eAAO,MAAM,kBAAkB,uCAAuC,CAAC;AACvE,eAAO,MAAM,kBAAkB,u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B,CACrC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,EAAE,EAAE,SAAS,CAAC,kBAAkB,EAChC,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,kBAAkB,CAgBpB;AAED,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,EAC1B,EAAE,EAAE,SAAS,CAAC,kBAAkB,EAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,GAAG,CAAC,CAed"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { assert, isNullish, strip0x } from '@recoillink/utils';
|
|
2
|
+
import { BigNumber, utils } from 'ethers';
|
|
3
|
+
export const TRON_EMPTY_ADDRESS = 'T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb';
|
|
4
|
+
export const TRON_EMPTY_MESSAGE = '0x0000000000000000000000000000000000000000000000000000000000000000';
|
|
5
|
+
export const EIP1967_ADMIN_SLOT = '0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103';
|
|
6
|
+
export function decodeRevertReason(hex) {
|
|
7
|
+
try {
|
|
8
|
+
if (hex.startsWith('08c379a0')) {
|
|
9
|
+
// Standard Error(string) selector — decode the ABI-encoded string payload.
|
|
10
|
+
const data = '0x' + hex.substring(8);
|
|
11
|
+
return String(utils.defaultAbiCoder.decode(['string'], data)[0]);
|
|
12
|
+
}
|
|
13
|
+
return `Hex Error: ${hex}`;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return `Could not decode hex: ${hex}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Throws when a mined Tron transaction reverted or failed on-chain.
|
|
21
|
+
*
|
|
22
|
+
* Tron surfaces execution failures through `getTransactionInfo` rather than the
|
|
23
|
+
* broadcast result, so both the ethers-compatible wallet path (TronWallet) and
|
|
24
|
+
* the AltVM provider path (TronProvider) must inspect the receipt to fail
|
|
25
|
+
* loudly, mirroring EVM's CALL_EXCEPTION on a status-0 receipt.
|
|
26
|
+
*/
|
|
27
|
+
export function assertTronReceiptSuccess(info, tronweb, txid) {
|
|
28
|
+
const nested = info.receipt?.result;
|
|
29
|
+
const topLevelFailed = info.result === 'FAILED';
|
|
30
|
+
// Nested receipt.result is Tron's contractResult enum (SUCCESS/REVERT/
|
|
31
|
+
// OUT_OF_ENERGY/OUT_OF_TIME/...). Any value other than SUCCESS is a mined
|
|
32
|
+
// failure. It is absent for non-contract transfers, which are not failures.
|
|
33
|
+
const nestedFailed = !isNullish(nested) && nested !== 'SUCCESS';
|
|
34
|
+
if (!topLevelFailed && !nestedFailed) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let revertReason = 'Unknown Error';
|
|
38
|
+
if (info.resMessage) {
|
|
39
|
+
revertReason = tronweb.toUtf8(info.resMessage);
|
|
40
|
+
}
|
|
41
|
+
else if (info.contractResult && info.contractResult[0]) {
|
|
42
|
+
revertReason = decodeRevertReason(info.contractResult[0]);
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Tron Transaction Failed: ${revertReason} (txid: ${txid})`);
|
|
45
|
+
}
|
|
46
|
+
export async function createDeploymentTransaction(tronweb, abi, signer, parameters) {
|
|
47
|
+
return tronweb.transactionBuilder.createSmartContract({
|
|
48
|
+
feeLimit: 1_000_000_000,
|
|
49
|
+
abi: abi.abi,
|
|
50
|
+
bytecode: abi.bytecode,
|
|
51
|
+
parameters,
|
|
52
|
+
name: abi.contractName,
|
|
53
|
+
}, signer);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Constructs MetaProxy bytecode that embeds metadata in the contract
|
|
57
|
+
* @param implementationAddress - Address of implementation contract
|
|
58
|
+
* @param metadata - ABI-encoded metadata to embed
|
|
59
|
+
* @returns Complete MetaProxy bytecode
|
|
60
|
+
*/
|
|
61
|
+
export function buildMetaProxyBytecode(implementationAddress, metadata) {
|
|
62
|
+
const PREFIX = '600b380380600b3d393df3363d3d373d3d3d3d60368038038091363936013d73';
|
|
63
|
+
const SUFFIX = '5af43d3d93803e603457fd5bf3';
|
|
64
|
+
// Remove 0x prefix if present
|
|
65
|
+
const cleanMetadata = strip0x(metadata);
|
|
66
|
+
let cleanImpl = strip0x(implementationAddress);
|
|
67
|
+
// Tron addresses have 41 prefix byte - strip it to get 20 bytes
|
|
68
|
+
if (cleanImpl.startsWith('41')) {
|
|
69
|
+
cleanImpl = cleanImpl.slice(2);
|
|
70
|
+
}
|
|
71
|
+
// Validate address is exactly 20 bytes (40 hex chars)
|
|
72
|
+
if (cleanImpl.length !== 40) {
|
|
73
|
+
throw new Error(`Implementation address must be 20 bytes (40 hex chars), got ${cleanImpl.length}`);
|
|
74
|
+
}
|
|
75
|
+
// Convert metadata length to 32-byte hex (uint256)
|
|
76
|
+
const metadataLength = (cleanMetadata.length / 2)
|
|
77
|
+
.toString(16)
|
|
78
|
+
.padStart(64, '0');
|
|
79
|
+
return `0x${PREFIX}${cleanImpl}${SUFFIX}${cleanMetadata}${metadataLength}`;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Deploys a contract using raw bytecode (for MetaProxy deployments)
|
|
83
|
+
* @param tronweb - TronWeb instance
|
|
84
|
+
* @param bytecode - Complete bytecode to deploy
|
|
85
|
+
* @param signer - Deployer address
|
|
86
|
+
* @param contractName - Optional name for the contract
|
|
87
|
+
* @returns Transaction object
|
|
88
|
+
*/
|
|
89
|
+
export async function createRawBytecodeDeploymentTransaction(tronweb, bytecode, signer, contractName = 'MetaProxy') {
|
|
90
|
+
return tronweb.transactionBuilder.createSmartContract({
|
|
91
|
+
feeLimit: 1_000_000_000,
|
|
92
|
+
abi: [],
|
|
93
|
+
bytecode,
|
|
94
|
+
parameters: [],
|
|
95
|
+
name: contractName,
|
|
96
|
+
}, signer);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Convert an address to Tron's 41-prefixed hex form.
|
|
100
|
+
*
|
|
101
|
+
* Accepts ethers 0x-hex, base58 (`T…`) or already-41-prefixed hex. Base58 is
|
|
102
|
+
* resolved through TronWeb so the checksum is validated rather than assumed.
|
|
103
|
+
*/
|
|
104
|
+
export function toTronHex(tronWeb, address) {
|
|
105
|
+
if (address.startsWith('T')) {
|
|
106
|
+
return tronWeb.address.toHex(address);
|
|
107
|
+
}
|
|
108
|
+
const hex = strip0x(address).toLowerCase();
|
|
109
|
+
return hex.startsWith('41') && hex.length === 42 ? hex : `41${hex}`;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Builds a Tron contract-trigger request from an ethers transaction. Response
|
|
113
|
+
* handling is left to the caller: writes assert on the build result, reads
|
|
114
|
+
* return the raw constant-call data so ethers can surface reverts itself.
|
|
115
|
+
*
|
|
116
|
+
* The empty functionSelector tells TronWeb to use the raw ABI-encoded `input`
|
|
117
|
+
* bytes directly instead of encoding named parameters.
|
|
118
|
+
*/
|
|
119
|
+
export function buildTronTriggerRequest(tronWeb, tx, sender) {
|
|
120
|
+
assert(tx.to, 'Transaction must have a destination address');
|
|
121
|
+
const contractAddress = toTronHex(tronWeb, tx.to);
|
|
122
|
+
// A provider-connected ethers read omits `from`. Defaulting the caller to the
|
|
123
|
+
// contract itself would run the call with msg.sender == address(this), so
|
|
124
|
+
// caller-sensitive views return wrong/privileged state. Use the Tron zero
|
|
125
|
+
// address as the caller instead, mirroring eth_call's default sender.
|
|
126
|
+
const issuerAddress = isNullish(sender)
|
|
127
|
+
? toTronHex(tronWeb, TRON_EMPTY_ADDRESS)
|
|
128
|
+
: toTronHex(tronWeb, sender);
|
|
129
|
+
const callValue = tx.value ? BigNumber.from(tx.value).toNumber() : 0;
|
|
130
|
+
const input = isNullish(tx.data)
|
|
131
|
+
? undefined
|
|
132
|
+
: strip0x(utils.hexlify(tx.data));
|
|
133
|
+
return { contractAddress, callValue, input, issuerAddress };
|
|
134
|
+
}
|
|
135
|
+
export async function convertEthersToTronTransaction(tronWeb, tx, sender) {
|
|
136
|
+
const { contractAddress, callValue, input, issuerAddress } = buildTronTriggerRequest(tronWeb, tx, sender);
|
|
137
|
+
const response = await tronWeb.transactionBuilder.triggerSmartContract(contractAddress, '', { callValue, input }, [], issuerAddress);
|
|
138
|
+
assert(response.result?.result, `triggerSmartContract failed: ${response.result?.message}`);
|
|
139
|
+
return response.transaction;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAa,KAAK,EAAE,MAAM,QAAQ,CAAC;AAErD,MAAM,CAAC,MAAM,kBAAkB,GAAG,oCAAoC,CAAC;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,oEAAoE,CAAC;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,oEAAoE,CAAC;AAEvE,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,2EAA2E;YAC3E,MAAM,IAAI,GAAG,IAAI,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACrC,OAAO,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,cAAc,GAAG,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,yBAAyB,GAAG,EAAE,CAAC;IACxC,CAAC;AACH,CAAC;AAcD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,IAAuB,EACvB,OAAgB,EAChB,IAAY;IAEZ,MAAM,MAAM,GAAG,IAAI,CAA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,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,CACpE,eAAe,EACf,EAAE,EACF,EAAE,SAAS,EAAE,KAAK,EAAE,EACpB,EAAE,EACF,aAAa,CACd,CAAC;IACF,MAAM,CACJ,QAAQ,CAAC,MAAM,EAAE,MAAM,EACvB,gCAAgC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAC3D,CAAC;IACF,OAAO,QAAQ,CAAC,WAAW,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/utils/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { TronWeb } from 'tronweb';
|
|
4
|
+
import { strip0x } from '@recoillink/utils';
|
|
5
|
+
import { assertTronReceiptSuccess } from './index.js';
|
|
6
|
+
const TXID = 'abc123';
|
|
7
|
+
// Offline instance: only toUtf8 / abi decoding are exercised, no network calls.
|
|
8
|
+
const tronweb = new TronWeb({ fullHost: 'http://127.0.0.1:9090' });
|
|
9
|
+
// Standard Solidity Error(string) revert payload: 08c379a0 selector + abi("boom").
|
|
10
|
+
const ERROR_STRING_REVERT_DATA = '08c379a0' +
|
|
11
|
+
strip0x(ethers.utils.defaultAbiCoder.encode(['string'], ['boom']));
|
|
12
|
+
function makeReceipt(fields) {
|
|
13
|
+
return {
|
|
14
|
+
// Non-contract transfers surface no execution receipt, so omit it when the
|
|
15
|
+
// nested contractResult value is not provided.
|
|
16
|
+
receipt: fields.result === undefined
|
|
17
|
+
? undefined
|
|
18
|
+
: {
|
|
19
|
+
energy_usage: 0,
|
|
20
|
+
energy_fee: 0,
|
|
21
|
+
origin_energy_usage: 0,
|
|
22
|
+
energy_usage_total: 0,
|
|
23
|
+
net_usage: 0,
|
|
24
|
+
net_fee: 0,
|
|
25
|
+
result: fields.result,
|
|
26
|
+
energy_penalty_total: 0,
|
|
27
|
+
},
|
|
28
|
+
result: fields.topLevelResult,
|
|
29
|
+
resMessage: fields.resMessage ?? '',
|
|
30
|
+
contractResult: fields.contractResult ?? [],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const cases = [
|
|
34
|
+
{
|
|
35
|
+
name: 'throws on REVERT and decodes resMessage',
|
|
36
|
+
receipt: makeReceipt({
|
|
37
|
+
result: 'REVERT',
|
|
38
|
+
resMessage: tronweb.fromUtf8('out of energy'),
|
|
39
|
+
}),
|
|
40
|
+
expectedError: /Tron Transaction Failed: out of energy \(txid: abc123\)/,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'throws on OUT_OF_ENERGY with a decoded contractResult reason',
|
|
44
|
+
receipt: makeReceipt({
|
|
45
|
+
result: 'OUT_OF_ENERGY',
|
|
46
|
+
contractResult: [ERROR_STRING_REVERT_DATA],
|
|
47
|
+
}),
|
|
48
|
+
expectedError: /Tron Transaction Failed: boom \(txid: abc123\)/,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'throws on REVERT with unknown reason when no data present',
|
|
52
|
+
receipt: makeReceipt({ result: 'REVERT' }),
|
|
53
|
+
expectedError: /Tron Transaction Failed: Unknown Error \(txid: abc123\)/,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'throws on top-level FAILED even when the nested result is SUCCESS',
|
|
57
|
+
receipt: makeReceipt({ result: 'SUCCESS', topLevelResult: 'FAILED' }),
|
|
58
|
+
expectedError: /Tron Transaction Failed: Unknown Error \(txid: abc123\)/,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'does not throw on SUCCESS',
|
|
62
|
+
receipt: makeReceipt({ result: 'SUCCESS' }),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'does not throw on a plain transfer with no nested result',
|
|
66
|
+
receipt: makeReceipt({}),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'does not throw while pending',
|
|
70
|
+
receipt: makeReceipt({ topLevelResult: 'PENDING' }),
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
describe('assertTronReceiptSuccess', () => {
|
|
74
|
+
for (const c of cases) {
|
|
75
|
+
it(c.name, () => {
|
|
76
|
+
if (c.expectedError) {
|
|
77
|
+
expect(() => assertTronReceiptSuccess(c.receipt, tronweb, TXID)).to.throw(c.expectedError);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
expect(() => assertTronReceiptSuccess(c.receipt, tronweb, TXID)).to.not.throw();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/utils/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAqB,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEzE,MAAM,IAAI,GAAG,QAAQ,CAAC;AACtB,gFAAgF;AAChF,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,QAAQ,EAAE,uBAAuB,EAAE,CAAC,CAAC;AAEnE,mFAAmF;AACnF,MAAM,wBAAwB,GAC5B,UAAU;IACV,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAErE,SAAS,WAAW,CAAC,MAKpB;IACC,OAAO;QACL,2EAA2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AS,EAAE,CAAC;KAC5C;IACD;QACE,IAAI,EAAE,0DAA0D;QAChE,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;KACzB;IACD;QACE,IAAI,EAAE,8BAA8B;QACpC,OAAO,EAAE,WAAW,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;KACpD;CACF,CAAC;AAEF,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE;YACd,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;gBACpB,MAAM,CAAC,GAAG,EAAE,CACV,wBAAwB,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CACnD,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,EAAE,CACV,wBAAwB,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CACnD,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Address } from '@recoillink/utils';
|
|
2
|
+
export type TronTransaction = {
|
|
3
|
+
visible: boolean;
|
|
4
|
+
txID: string;
|
|
5
|
+
raw_data_hex: string;
|
|
6
|
+
raw_data: {
|
|
7
|
+
contract: {
|
|
8
|
+
parameter: {
|
|
9
|
+
value: any;
|
|
10
|
+
type_url: string;
|
|
11
|
+
};
|
|
12
|
+
type: any;
|
|
13
|
+
}[];
|
|
14
|
+
ref_block_bytes: string;
|
|
15
|
+
ref_block_hash: string;
|
|
16
|
+
expiration: number;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
fee_limit?: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
type HTTPMap<T extends string | number | symbol, U> = Record<T, U>[];
|
|
22
|
+
export type TronReceipt = {
|
|
23
|
+
id: string;
|
|
24
|
+
fee: number;
|
|
25
|
+
blockNumber: number;
|
|
26
|
+
blockTimeStamp: number;
|
|
27
|
+
contractResult: string[];
|
|
28
|
+
contract_address: string;
|
|
29
|
+
receipt: {
|
|
30
|
+
energy_usage: number;
|
|
31
|
+
energy_fee: number;
|
|
32
|
+
origin_energy_usage: number;
|
|
33
|
+
energy_usage_total: number;
|
|
34
|
+
net_usage: number;
|
|
35
|
+
net_fee: number;
|
|
36
|
+
result: string;
|
|
37
|
+
energy_penalty_total: number;
|
|
38
|
+
};
|
|
39
|
+
log: {
|
|
40
|
+
address: Address;
|
|
41
|
+
topics: string[];
|
|
42
|
+
data: string;
|
|
43
|
+
}[];
|
|
44
|
+
result?: 'SUCCESS' | 'PENDING' | 'FAILED';
|
|
45
|
+
resMessage: string;
|
|
46
|
+
assetIssueID: string;
|
|
47
|
+
withdraw_amount: number;
|
|
48
|
+
unfreeze_amount: number;
|
|
49
|
+
internal_transactions: {
|
|
50
|
+
hash: string;
|
|
51
|
+
caller_address: string;
|
|
52
|
+
transferTo_address: string;
|
|
53
|
+
callValueInfo: {
|
|
54
|
+
callValue: number;
|
|
55
|
+
tokenId: string;
|
|
56
|
+
}[];
|
|
57
|
+
note: string;
|
|
58
|
+
rejected: boolean;
|
|
59
|
+
extra: string;
|
|
60
|
+
}[];
|
|
61
|
+
exchange_received_amount: number;
|
|
62
|
+
exchange_inject_another_amount: number;
|
|
63
|
+
exchange_withdraw_another_amount: number;
|
|
64
|
+
shielded_transaction_fee: number;
|
|
65
|
+
withdraw_expire_amount: number;
|
|
66
|
+
cancel_unfreezeV2_amount: HTTPMap<string, number>;
|
|
67
|
+
exchange_id: string;
|
|
68
|
+
orderId: string;
|
|
69
|
+
orderDetails: {
|
|
70
|
+
makerOrderId: string;
|
|
71
|
+
takerOrderId: string;
|
|
72
|
+
fillSellQuantity: number;
|
|
73
|
+
fillBuyQuantity: number;
|
|
74
|
+
}[];
|
|
75
|
+
packingFee: number;
|
|
76
|
+
};
|
|
77
|
+
export interface IABI {
|
|
78
|
+
contractName: string;
|
|
79
|
+
abi: any[];
|
|
80
|
+
bytecode: string;
|
|
81
|
+
deployedBytecode: string;
|
|
82
|
+
}
|
|
83
|
+
export declare enum TronIsmTypes {
|
|
84
|
+
MERKLE_ROOT_MULTISIG = "MerkleRootMultisigIsm",
|
|
85
|
+
MESSAGE_ID_MULTISIG = "MessageIdMultisigIsm",
|
|
86
|
+
ROUTING_ISM = "RoutingIsm",
|
|
87
|
+
NOOP_ISM = "NoopIsm"
|
|
88
|
+
}
|
|
89
|
+
export declare enum TronHookTypes {
|
|
90
|
+
MERKLE_TREE = "merkleTreeHook",
|
|
91
|
+
INTERCHAIN_GAS_PAYMASTER = "interchainGasPaymaster"
|
|
92
|
+
}
|
|
93
|
+
export {};
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QACR,QAAQ,EAAE;YACR,SAAS,EAAE;gBACT,KAAK,EAAE,GAAG,CAAC;gBACX,QAAQ,EAAE,MAAM,CAAC;aAClB,CAAC;YACF,IAAI,EAAE,GAAG,CAAC;SACX,EAAE,CAAC;QACJ,eAAe,EAAE,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EA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AE,OAAO,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,wBAAwB,EAAE,MAAM,CAAC;IACjC,8BAA8B,EAAE,MAAM,CAAC;IACvC,gCAAgC,EAAE,MAAM,CAAC;IACzC,wBAAwB,EAAE,MAAM,CAAC;IACjC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,wBAAwB,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,EAAE,CAAC;IACJ,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,WAAW,IAAI;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,GAAG,EAAE,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,oBAAY,YAAY;IACtB,oBAAoB,0BAA0B;IAC9C,mBAAmB,yBAAyB;IAC5C,WAAW,eAAe;IAC1B,QAAQ,YAAY;CACrB;AAED,oBAAY,aAAa;IACvB,WAAW,mBAAmB;IAC9B,wBAAwB,2BAA2B;CACpD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export var TronIsmTypes;
|
|
2
|
+
(function (TronIsmTypes) {
|
|
3
|
+
TronIsmTypes["MERKLE_ROOT_MULTISIG"] = "MerkleRootMultisigIsm";
|
|
4
|
+
TronIsmTypes["MESSAGE_ID_MULTISIG"] = "MessageIdMultisigIsm";
|
|
5
|
+
TronIsmTypes["ROUTING_ISM"] = "RoutingIsm";
|
|
6
|
+
TronIsmTypes["NOOP_ISM"] = "NoopIsm";
|
|
7
|
+
})(TronIsmTypes || (TronIsmTypes = {}));
|
|
8
|
+
export var TronHookTypes;
|
|
9
|
+
(function (TronHookTypes) {
|
|
10
|
+
TronHookTypes["MERKLE_TREE"] = "merkleTreeHook";
|
|
11
|
+
TronHookTypes["INTERCHAIN_GAS_PAYMASTER"] = "interchainGasPaymaster";
|
|
12
|
+
})(TronHookTypes || (TronHookTypes = {}));
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":"AAuFA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,8DAA8C,CAAA;IAC9C,4DAA4C,CAAA;IAC5C,0CAA0B,CAAA;IAC1B,oCAAoB,CAAA;AACtB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,+CAA8B,CAAA;IAC9B,oEAAmD,CAAA;AACrD,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@recoillink/tron-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "26.0.1",
|
|
4
|
+
"description": "Recoil Link TypeScript SDK for Tron",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"blockchain",
|
|
7
|
+
"hyperlane",
|
|
8
|
+
"sdk",
|
|
9
|
+
"tron"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/recoil-labs/recoil-link",
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/recoil-labs/recoil-link"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"/dist",
|
|
19
|
+
"local-node"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./runtime": {
|
|
29
|
+
"types": "./dist/runtime.d.ts",
|
|
30
|
+
"default": "./dist/runtime.js"
|
|
31
|
+
},
|
|
32
|
+
"./testing": {
|
|
33
|
+
"types": "./dist/testing/index.d.ts",
|
|
34
|
+
"default": "./dist/testing/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@ethersproject/abi": "*",
|
|
39
|
+
"@ethersproject/providers": "*",
|
|
40
|
+
"@recoillink/core": "12.2.0",
|
|
41
|
+
"@recoillink/provider-sdk": "11.0.1",
|
|
42
|
+
"@recoillink/utils": "45.0.1",
|
|
43
|
+
"bignumber.js": "^9.1.1",
|
|
44
|
+
"ethers": "^5.8.0",
|
|
45
|
+
"tronweb": "^6.1.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@recoillink/tsconfig": "^45.0.1",
|
|
49
|
+
"@types/chai": "^4.3.11",
|
|
50
|
+
"@types/chai-as-promised": "^8",
|
|
51
|
+
"@types/mocha": "^10.0.1",
|
|
52
|
+
"@types/node": "^26.1.2",
|
|
53
|
+
"@types/unzipper": "^0",
|
|
54
|
+
"c8": "^10.1.3",
|
|
55
|
+
"chai": "^4.5.0",
|
|
56
|
+
"chai-as-promised": "^8.0.1",
|
|
57
|
+
"mocha": "^11.7.6",
|
|
58
|
+
"mocha-steps": "^1.3.0",
|
|
59
|
+
"node-fetch": "^3.3.2",
|
|
60
|
+
"testcontainers": "11.12.0",
|
|
61
|
+
"ts-node": "^10.9.2",
|
|
62
|
+
"tsx": "^4.23.1",
|
|
63
|
+
"typescript": "npm:@typescript/typescript6@6.0.2"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=22"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "rm -rf ./dist && tsc",
|
|
70
|
+
"format": "oxfmt --write src/**/*.ts",
|
|
71
|
+
"lint": "oxlint -c ../../oxlint.json",
|
|
72
|
+
"clean": "rm -rf ./dist ./cache ./coverage",
|
|
73
|
+
"dev": "tsc --watch",
|
|
74
|
+
"test": "mocha --config .mocharc.json './src/**/*.test.ts'",
|
|
75
|
+
"coverage": "c8 pnpm test"
|
|
76
|
+
}
|
|
6
77
|
}
|