import {
utils,
} from "./modify_ethers/modify_ethers.js";
export default class Utils {
static toWei ( amount ) {
if (typeof ( amount ) !== "string") {
throw Error( "这里的amount必须是一个string类型,不能进行类型转换,否则小数点超过6位ethers库会报异常【具体原因还未知】" );
}
// parseUnits第一个参数amount必须是string类型,第二个参数代表小数点多少位【如果不传默认是18位】
return amount ? utils.parseUnits( amount, 18 ) : 0;
}
static fromWei ( amount ) {
let wei = utils.bigNumberify( `${amount}` );
return amount ? utils.formatEther( wei ) : 0;
}
}