This commit is contained in:
Luk Lu
2022-06-05 11:30:32 +08:00
parent cfad03864a
commit e3920911b0
3 changed files with 84 additions and 42 deletions

View File

@@ -1,11 +1,11 @@
const Action = require('./Action.js')
const ticCrypto = require('tic.crypto')
const ticrypto = require('tic-crypto')
const DAD = module.exports = function ActionTransfer (prop) {
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
@@ -13,13 +13,19 @@ MOM.__proto__ = Action.prototype
MOM.validateMe = function () {
// if (sender && sender.type !== 'multisig' && action.toAddress != action.actorAddress && sender.balance >= action.amount + action.fee){
return this.actorPubkey && this.toAddress && ticCrypto.pubkey2address(this.actorPubkey)!== this.toAddress // 不能转帐给自己。
&& this.amount && this.amount > 0 && (this.fee >= 0)
return (
this.actorPubkey &&
this.toAddress &&
ticrypto.pubkey2address(this.actorPubkey) !== this.toAddress && // 不能转帐给自己。
this.amount &&
this.amount > 0 &&
this.fee >= 0
)
}
MOM.executableMe = async function() {
MOM.executableMe = async function () {
let balance = await wo.Store.getBalance(this.actorAddress)
return balance >= this.amount + this.fee
return balance >= this.amount + this.fee
}
MOM.executeMe = async function () {