本文整理匯總了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);
}