本文整理汇总了TypeScript中web3.utils类的典型用法代码示例。如果您正苦于以下问题:TypeScript utils类的具体用法?TypeScript utils怎么用?TypeScript utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了utils类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getWeiBalanceFromString
export function getWeiBalanceFromString(balanceString: string) {
if (!balanceString) {
return 0;
}
const match = balanceString.match(balanceRegex);
if (!match) {
throw new Error(__("Unrecognized balance string \"%s\"", balanceString));
}
if (!match[2]) {
return web3.utils.toHex(match[1]);
}
return web3.utils.toWei(match[1], match[2]);
}
示例2: postRequest
postRequest(factory.testAppForSuccessRegistration(), '/user/activate').send(activateParams).end((err, res) => {
expect(res.status).to.eq(200);
expect(res.body.accessToken).to.eq('token');
expect(res.body.wallets[0].ticker).to.eq('ETH');
expect(res.body.wallets[0].balance).to.eq('0');
expect(res.body.wallets[0]).to.have.property('privateKey');
expect(res.body.wallets[0]).to.not.have.property('salt');
expect(bip39.validateMnemonic(res.body.wallets[0].mnemonic)).to.eq(true);
expect(Web3.utils.isAddress(res.body.wallets[0].address)).to.eq(true);
done();
});
示例3: next
method.send(sendParams).on('receipt', (receipt) => {
try {
let time: number = Math.ceil((Date.now() - startTime) / 1000.0)
let topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let testPassed: boolean = false
for (let i in receipt.events) {
let event = receipt.events[i]
if (event.raw.topics.indexOf(topic) >= 0) {
const testEvent = web3.eth.abi.decodeParameters(['bool', 'string'], event.raw.data)
if (!testEvent[0]) {
const resp: TestResultInterface = {
type: 'testFailure',
value: changeCase.sentenceCase(func.name),
time: time,
errMsg: testEvent[1],
context: testName
};
testCallback(undefined, resp)
failureNum += 1
return next()
}
testPassed = true
}
}
if (testPassed) {
const resp: TestResultInterface = {
type: 'testPass',
value: changeCase.sentenceCase(func.name),
time: time,
context: testName
}
testCallback(undefined, resp)
passingNum += 1
}
return next()
} catch (err) {
console.error(err)
return next(err)
}
}).on('error', function (err: Error | null | undefined) {
示例4: soliditySha3
export function soliditySha3(arg: any) {
return web3.utils.soliditySha3(arg);
}
示例5: isHex
export function isHex(hex: string) {
return web3.utils.isHex(hex);
}
示例6: sha3
export function sha3(arg: any) {
return web3.utils.sha3(arg);
}