const Action = require('./Action.js') const DAD = module.exports = function ActionTransfer (prop) { this._class = this.constructor.name this.setProp(prop) // 没有定义 ActionTransfer.prototype._model,因此继承了上级Action.prototype._model,因此通过this.setProp,继承了上级Action定义的实例自有数据。另一个方案是,调用 Action.call(this, prop) this.type = this.constructor.name } DAD.__proto__ = Action const MOM = DAD.prototype MOM.__proto__ = Action.prototype MOM.validateMe = function () { // if (sender && sender.type !== 'multisig' && action.toAddress != action.actorAddress && sender.balance >= action.amount + action.fee){ return this.actorAddress && this.toAddress && this.toAddress != this.actorAddress && this.amount && this.amount > 0 && (this.fee >= wo.Config.MIN_FEE_ActionTransfer || 0) } MOM.executableMe = async function() { let balance = await wo.Store.getBalance(this.actorAddress) return balance >= this.amount + this.fee } MOM.executeMe = async function () { let balance = await wo.Store.getBalance(this.actorAddress) if (balance >= this.amount + this.fee) { await wo.Store.decrease(this.actorAddress, this.amount + this.fee) await wo.Store.increase(this.toAddress, this.amount) return this } return null } /** ****************** Public of class ********************/ DAD.api = {}