Skip to content

Commit

Permalink
ALL-9581 - Fix missing decimals function in TRON
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr JelΓ­nek committed Jan 31, 2025
1 parent 1b0db9e commit 5956d11
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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 TRON_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, TRON_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(TRON_ABI, contractAddress);
const decimalsBigNum = await contractInstance.decimals().call()
return new BigNumber(decimalsBigNum).toNumber()
}
Expand Down

0 comments on commit 5956d11

Please sign in to comment.