tools/setup/branded_token/mint.js
function() {
    const oThis = this
    ;

    return new Promise(async function(onResolve, onReject) {

      // NOTE: NOT Relying on CACHE - this is because for in process memory, this goes into infinite loop
      const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
        , brandedToken = new BrandedTokenKlass({ERC20: oThis.erc20Address});

      const beforeBalanceResponse = await brandedToken._callMethod('balanceOf', [oThis.reserveAddr]);
      const beforeBalance = new BigNumber(beforeBalanceResponse.data.balanceOf);

      logger.info('Balance of Reserve for Branded Token before mint:', beforeBalance.toString(10));

      const getBalance = async function(){

        const afterBalanceResponse = await brandedToken._callMethod('balanceOf', [oThis.reserveAddr])
          , afterBalance = afterBalanceResponse.data.balanceOf;

        if(afterBalanceResponse.isSuccess() && (new BigNumber(afterBalance)).greaterThan(beforeBalance)){
          logger.info('Balance of Reserve for Branded Token after mint:', afterBalance.toString(10));
          return onResolve();
        } else {
          setTimeout(getBalance, 5000);
        }
      };

      getBalance();
    });
  }
function() {
    const oThis = this
    ;

    return new Promise(async function(onResolve, onReject) {

      // NOTE: NOT Relying on CACHE - this is because for in process memory, this goes into infinite loop
      const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
        , brandedToken = new BrandedTokenKlass({ERC20: oThis.erc20Address});

      const beforeBalanceResponse = await brandedToken._callMethod('balanceOf', [oThis.reserveAddr]);
      const beforeBalance = new BigNumber(beforeBalanceResponse.data.balanceOf);

      logger.info('Balance of Reserve for Branded Token before mint:', beforeBalance.toString(10));

      const getBalance = async function(){

        const afterBalanceResponse = await brandedToken._callMethod('balanceOf', [oThis.reserveAddr])
          , afterBalance = afterBalanceResponse.data.balanceOf;

        if(afterBalanceResponse.isSuccess() && (new BigNumber(afterBalance)).greaterThan(beforeBalance)){
          logger.info('Balance of Reserve for Branded Token after mint:', afterBalance.toString(10));
          return onResolve();
        } else {
          setTimeout(getBalance, 5000);
        }
      };

      getBalance();
    });
  }
function ( ) { const oThis = this ; return new Promise ( async function ( onResolve , onReject ) { // NOTE: NOT Relying on CACHE - this is because for in process memory, this goes into infinite loop const BrandedTokenKlass = require ( rootPrefix + '/lib/contract_interact/branded_token' ) , brandedToken = new BrandedTokenKlass ( { ERC20 : oThis . erc20Address } ) ; const beforeBalanceResponse = await brandedToken . _callMethod ( 'balanceOf' , [ oThis . reserveAddr ] ) ; const beforeBalance = new BigNumber ( beforeBalanceResponse . data . balanceOf ) ; logger . info ( 'Balance of Reserve for Branded Token before mint:' , beforeBalance . toString ( 10 ) ) ; const getBalance = async function ( ) { const afterBalanceResponse = await brandedToken . _callMethod ( 'balanceOf' , [ oThis . reserveAddr ] ) , afterBalance = afterBalanceResponse . data . balanceOf ; if ( afterBalanceResponse . isSuccess ( ) && ( new BigNumber ( afterBalance ) ) . greaterThan ( beforeBalance ) ) { logger . info ( 'Balance of Reserve for Branded Token after mint:' , afterBalance . toString ( 10 ) ) ; return onResolve ( ) ; } else { setTimeout ( getBalance , 5000 ) ; } } ; getBalance ( ) ; } ) ; }
Wait for Branded Token mint

@return {promise}
@private
Wait for Branded Token mint