Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALL-9581 - Fix missing decimals function in TRON #1144

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,20 @@ export const ZERO_ADDRESS = {
ZERO_ADDRESS_42_CHARS: '0x0000000000000000000000000000000000000000',
ZERO_ADDRESS_58_CHARS: '0000000000000000000000000000000000000000000000000000000000',
}

export const TRC_20_MIN_ABI = [
{
"constant": true,
"inputs": [],
"name": "decimals",
"outputs": [
{
"name": "",
"type": "uint8"
}
],
"payable": false,
"stateMutability": "View",
"type": "Function"
}
];
4 changes: 2 additions & 2 deletions src/transaction/tron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AxiosRequestConfig } from 'axios';
import BigNumber from 'bignumber.js';
import { tronBroadcast } from '../blockchain';
import { axios, validateBody } from '../connector/tatum';
import { TATUM_API_URL } from '../constants';
import { TATUM_API_URL, TRC_20_MIN_ABI } from '../constants'
import { listing } from '../contracts/marketplace';
import abi from '../contracts/trc20/token_abi';
import bytecode from '../contracts/trc20/token_bytecode';
Expand Down Expand Up @@ -324,7 +324,7 @@ export const getTronTrc20ContractDecimals = async (testnet: boolean, contractAdd
}
const tronWeb = prepareTronWeb(testnet, provider)
tronWeb.setAddress(contractAddress)
const contractInstance = await tronWeb.contract().at(contractAddress)
const contractInstance = await tronWeb.contract(TRC_20_MIN_ABI, contractAddress);
const decimalsBigNum = await contractInstance.decimals().call()
return new BigNumber(decimalsBigNum).toNumber()
}
Expand Down
Loading