proc/worker/account.go
func (w *Worker) PreAccountAddBalance(job *data.Job) error {
	logger := w.logger.Add("method", "PreAccountAddBalance", "job", job)

	acc, err := w.relatedAccount(logger, job, data.JobPreAccountAddBalance)
	if err != nil {
		return err
	}

	jobData, err := w.approvedBalanceData(logger, job)
	if err != nil {
		return err
	}

	key, err := w.key(logger, acc.PrivateKey)
	if err != nil {
		return err
	}

	auth := bind.NewKeyedTransactor(key)
	auth.GasLimit = w.gasConf.PSC.AddBalanceERC20
	auth.GasPrice = new(big.Int).SetUint64(jobData.GasPrice)
	tx, err := w.ethBack.PSCAddBalanceERC20(auth, uint64(jobData.Amount))
	if err != nil {
		logger.Error(err.Error())
		return ErrPSCAddBalance
	}

	return w.saveEthTX(logger, job, tx, "PSCAddBalanceERC20", job.RelatedType,
		job.RelatedID, acc.EthAddr, data.HexFromBytes(w.pscAddr.Bytes()))
}
func (w *Worker) PreAccountAddBalance(job *data.Job) error {
	logger := w.logger.Add("method", "PreAccountAddBalance", "job", job)

	acc, err := w.relatedAccount(logger, job, data.JobPreAccountAddBalance)
	if err != nil {
		return err
	}

	jobData, err := w.approvedBalanceData(logger, job)
	if err != nil {
		return err
	}

	key, err := w.key(logger, acc.PrivateKey)
	if err != nil {
		return err
	}

	auth := bind.NewKeyedTransactor(key)
	auth.GasLimit = w.gasConf.PSC.AddBalanceERC20
	auth.GasPrice = new(big.Int).SetUint64(jobData.GasPrice)
	tx, err := w.ethBack.PSCAddBalanceERC20(auth, uint64(jobData.Amount))
	if err != nil {
		logger.Error(err.Error())
		return ErrPSCAddBalance
	}

	return w.saveEthTX(logger, job, tx, "PSCAddBalanceERC20", job.RelatedType,
		job.RelatedID, acc.EthAddr, data.HexFromBytes(w.pscAddr.Bytes()))
}
func ( w * Worker ) PreAccountAddBalance ( job * data . Job ) error { logger := w . logger . Add ( " " , " " , " " , job ) acc , err := w . relatedAccount ( logger , job , data . JobPreAccountAddBalance ) if err != nil { return err } jobData , err := w . approvedBalanceData ( logger , job ) if err != nil { return err } key , err := w . key ( logger , acc . PrivateKey ) if err != nil { return err } auth := bind . NewKeyedTransactor ( key ) auth . GasLimit = w . gasConf . PSC . AddBalanceERC20 auth . GasPrice = new ( big . Int ) . SetUint64 ( jobData . GasPrice ) tx , err := w . ethBack . PSCAddBalanceERC20 ( auth , uint64 ( jobData . Amount ) ) if err != nil { logger . Error ( err . Error ( ) ) return ErrPSCAddBalance } return w . saveEthTX ( logger , job , tx , " " , job . RelatedType , job . RelatedID , acc . EthAddr , data . HexFromBytes ( w . pscAddr . Bytes ( ) ) ) }
// PreAccountAddBalance adds balance to psc.
PreAccountAddBalance adds balance to psc .