mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
add decimals() function
This commit is contained in:
parent
a7c0cff63c
commit
b3102c78c1
@ -117,6 +117,7 @@ export async function getPoolCreationParams(
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function unitsToAmount(
|
export async function unitsToAmount(
|
||||||
web3: Web3,
|
web3: Web3,
|
||||||
token: string,
|
token: string,
|
||||||
|
@ -183,3 +183,14 @@ export async function balance(
|
|||||||
|
|
||||||
return await unitsToAmount(web3, tokenAddress, trxReceipt, tokenDecimals)
|
return await unitsToAmount(web3, tokenAddress, trxReceipt, tokenDecimals)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get decimals for any erc20
|
||||||
|
* @param {Web3} web3
|
||||||
|
* @param {String} tokenAdress
|
||||||
|
* @return {Promise<number>} Number of decimals of the token
|
||||||
|
*/
|
||||||
|
export async function decimals(web3: Web3, tokenAddress: string): Promise<number> {
|
||||||
|
const tokenContract = new web3.eth.Contract(minAbi, tokenAddress)
|
||||||
|
return await tokenContract.methods.decimals().call()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user