把 executeMe 里对 wo.Store 的引用都改回从前的 wo.Account

This commit is contained in:
陆柯 2020-02-29 15:09:46 +08:00
parent cfad03864a
commit fa9980b45a
2 changed files with 15 additions and 5 deletions

View File

@ -170,6 +170,13 @@ DAD.api.getActionList = async function (option) {
return await DAD.getAll(option) return await DAD.getAll(option)
} }
DAD.api.getMyActionList = async function ({myAddress, config}={}) {
let list = {}
list.fromMe = await DAD.getAll({Action:{actorAddress:myAddress}, config:config})
list.toMe = await DAD.getAll({Action:{toAddress: myAddress}, config:config})
return list
}
DAD.api.prepare = async function (option) { DAD.api.prepare = async function (option) {
if (typeof option === 'string') { if (typeof option === 'string') {
try { try {

View File

@ -18,17 +18,20 @@ MOM.validateMe = function () {
} }
MOM.executableMe = async function() { MOM.executableMe = async function() {
let balance = await wo.Store.getBalance(this.actorAddress) let balance = await wo.Account.getBalance(this.actorAddress)
return balance >= this.amount + this.fee return balance >= this.amount + this.fee
} }
MOM.executeMe = async function () { MOM.executeMe = async function () {
let balance = await wo.Store.getBalance(this.actorAddress) let sender= await wo.Account.getOne({Account: { address: this.actorAddress }})
if (balance >= this.amount + this.fee) { if (sender && sender.type !== 'multisig' && this.toAddress != this.actorAddress && sender.balance >= this.amount + this.fee){
await wo.Store.decrease(this.actorAddress, this.amount + this.fee) await sender.setMe({Account:{ balance: sender.balance-this.amount-this.fee }, cond:{ address:sender.address}})
await wo.Store.increase(this.toAddress, this.amount) let getter= await wo.Account.getOne({Account: { address: this.toAddress }}) || await wo.Account.addOne({Account: { address: this.toAddress }})
await getter.setMe({Account:{ balance: getter.balance+this.amount }, cond:{ address:getter.address}})
mylog.info('Excecuted action='+JSON.stringify(this))
return this return this
} }
// mylog.info('balance('+sender.address+')='+sender.balance+' is less than '+this.amount+', 无法转账')
return null return null
} }