'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var minterjsUtil = require('minterjs-util');
var send = require('./send.js');
var convertSell = require('./convert-sell.js');
var convertSellAll = require('./convert-sell-all.js');
var convertSellPool = require('./convert-sell-pool.js');
var convertSellAllPool = require('./convert-sell-all-pool.js');
var poolCreate = require('./pool-create.js');
var poolAddLiquidity = require('./pool-add-liquidity.js');
var candidacyDeclare = require('./candidacy-declare.js');
var redeemCheck = require('./redeem-check.js');

var noop = function noop(x) {
  return x;
};

/**
 * @param {TxParams} txParams
 * @param {object} [options]
 * @param {boolean} [options.setGasCoinAsCoinToSpend]
 * @return {TxParams}
 */
function decorateTxParams(txParams) {
  var _TX_PARAMS_DECORATOR;
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
    setGasCoinAsCoinToSpend = _ref.setGasCoinAsCoinToSpend;
  var txType = minterjsUtil.normalizeTxType(txParams.type || txParams.txType);
  var TX_PARAMS_DECORATOR = (_TX_PARAMS_DECORATOR = {}, _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SEND, setGasCoinAsCoinToSpend ? send : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.MULTISEND, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SELL, setGasCoinAsCoinToSpend ? convertSell : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.BUY, setGasCoinAsCoinToSpend ? convertSell : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SELL_ALL, convertSellAll), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.CREATE_COIN, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.DECLARE_CANDIDACY, setGasCoinAsCoinToSpend ? candidacyDeclare : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.EDIT_CANDIDATE, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.EDIT_CANDIDATE_PUBLIC_KEY, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SET_CANDIDATE_ON, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SET_CANDIDATE_OFF, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.DELEGATE, setGasCoinAsCoinToSpend ? candidacyDeclare : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.UNBOND, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.REDEEM_CHECK, redeemCheck), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.CREATE_MULTISIG, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SET_HALT_BLOCK, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.RECREATE_COIN, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.EDIT_TICKER_OWNER, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.EDIT_MULTISIG, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.PRICE_VOTE, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.EDIT_CANDIDATE_PUBLIC_KEY, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.ADD_LIQUIDITY, setGasCoinAsCoinToSpend ? poolAddLiquidity : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.REMOVE_LIQUIDITY, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.BUY_SWAP_POOL, setGasCoinAsCoinToSpend ? convertSellPool : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SELL_SWAP_POOL, setGasCoinAsCoinToSpend ? convertSellPool : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.SELL_ALL_SWAP_POOL, convertSellAllPool), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.EDIT_CANDIDATE_COMMISSION, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.MOVE_STAKE, setGasCoinAsCoinToSpend ? candidacyDeclare : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.MINT_TOKEN, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.BURN_TOKEN, setGasCoinAsCoinToSpend ? send : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.CREATE_TOKEN, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.RECREATE_TOKEN, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.VOTE_COMMISSION, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.VOTE_UPDATE, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.CREATE_SWAP_POOL, setGasCoinAsCoinToSpend ? poolCreate : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.ADD_LIMIT_ORDER, setGasCoinAsCoinToSpend ? convertSell : noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.REMOVE_LIMIT_ORDER, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.LOCK_STAKE, noop), _defineProperty(_TX_PARAMS_DECORATOR, minterjsUtil.TX_TYPE.LOCK, setGasCoinAsCoinToSpend ? send : noop), _TX_PARAMS_DECORATOR);
  return TX_PARAMS_DECORATOR[txType](txParams);
}

module.exports = decorateTxParams;
