leap-node
Version:
[](https://codecov.io/gh/leapdao/leap-node) [](https://quay.io/re
37 lines (30 loc) • 1.21 kB
JavaScript
/**
* Copyright (c) 2018-present, Leap DAO (leapdao.org)
*
* This source code is licensed under the Mozilla Public License Version 2.0
* found in the LICENSE file in the root directory of this source tree.
*/
/* eslint-disable global-require */
const { Type } = require('leap-core');
const { checkOutpoints, removeInputs, addOutputs } = require('./utils');
const checks = {
[]: require('./checkDeposit'),
[]: require('./checkEpochLength'),
[]: require('./checkEpochLengthV2'),
[]: require('./checkMinGasPrice'),
[]: require('./checkExit'),
[]: require('./checkTransfer'),
[]: require('./checkValidatorJoin'),
[]: require('./checkValidatorLogout'),
[]: require('./checkSpendCond'),
[]: require('./checkPeriodVote'),
};
module.exports = async (state, tx, bridgeState, nodeConfig, isCheck) => {
if (!checks[tx.type]) {
throw new Error('Unsupported tx type');
}
checkOutpoints(state, tx);
await checks[tx.type](state, tx, bridgeState, nodeConfig, isCheck);
removeInputs(state, tx);
addOutputs(state, tx);
};