monitors/ethwallet.js
/**
   * Send a txn to a function on a truffle contract. Automatically computes
   * the gas used and factors into estimates.
   */
Send a txn to a function on a truffle contract. Automatically computes
the gas used and factors into estimates.
Send a txn to a function on a truffle contract . Automatically computes the gas used and factors into estimates .
async call(state, contractMethod, ...params) {
    await state.checkDirty();
    state.assertNoExceptions();
    if (params != null && params.length > 0) {
      const p = params[params.length - 1]; 
      if (typeof p === 'object' && (p.from == undefined || p.from == null)) {
        p.from = this.address;
      } else {
        params.push({from: this.address});
      }
    } else {
      params = [{from: this.address}];
    }
    let gasCost = asBN(0);
    let res = null;
    try {
      res = await contractMethod(...params);
      gasCost = await gasForCall(res);
      this.expectGas(gasCost);
    } catch (exc) {
      if (exc.receipt) {
        const gasPrice = await gasForReceipt(exc.receipt);
        this.expectGas(gasPrice);
      }
      throw exc;
    }
    return res;
  }
async call ( state , contractMethod , ... params ) { await state . checkDirty ( ) ; state . assertNoExceptions ( ) ; if ( params != null && params . length > 0 ) { const p = params [ params . length - 1 ] ; if ( typeof p === 'object' && ( p . from == undefined || p . from == null ) ) { p . from = this . address ; } else { params . push ( { from : this . address } ) ; } } else { params = [ { from : this . address } ] ; } let gasCost = asBN ( 0 ) ; let res = null ; try { res = await contractMethod ( ... params ) ; gasCost = await gasForCall ( res ) ; this . expectGas ( gasCost ) ; } catch ( exc ) { if ( exc . receipt ) { const gasPrice = await gasForReceipt ( exc . receipt ) ; this . expectGas ( gasPrice ) ; } throw exc ; } return res ; }
Send a txn to a function on a truffle contract.
Send a txn to a function on a truffle contract .
// to enforce validation between txn calls, always assert that // we are not dirty before allowing a call(..) // automatically set {from:<x>} on the txn. // last elt is the txn options. // if this is a failed txn, it will have a transaction receipt on this // exception. We can assume gas consumption from this. // rethrow.