Example #1
0
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]);
}
 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();
 });
Example #3
0
            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) {
Example #4
0
export function soliditySha3(arg: any) {
  return web3.utils.soliditySha3(arg);
}
Example #5
0
export function isHex(hex: string) {
  return web3.utils.isHex(hex);
}
Example #6
0
export function sha3(arg: any) {
  return web3.utils.sha3(arg);
}