Skip to content

Commit

Permalink
fix delegations update
Browse files Browse the repository at this point in the history
  • Loading branch information
harpagon210 committed Jun 28, 2019
1 parent 05182fe commit a4dfcd0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions contracts/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ actions.delegate = async (payload) => {
}

// look for an existing delegation
let delegation = await api.db.findOne('delegations', { to, symbol });
let delegation = await api.db.findOne('delegations', { to: finalTo, from: api.sender, symbol });
const blockDate = new Date(`${api.steemBlockTimestamp}.000Z`);
const timestamp = blockDate.getTime();

Expand Down Expand Up @@ -1104,7 +1104,7 @@ actions.undelegate = async (payload) => {

if (api.assert(balanceFrom !== null, 'balanceFrom does not exist')) {
// look for an existing delegation
const delegation = await api.db.findOne('delegations', { to: finalFrom, symbol });
const delegation = await api.db.findOne('delegations', { to: finalFrom, from: api.sender, symbol });

if (api.assert(delegation !== null, 'delegation does not exist')
&& api.assert(api.BigNumber(delegation.quantity).gte(quantity), 'overdrawn delegation')) {
Expand Down
37 changes: 31 additions & 6 deletions plugins/Blockchain.js

Large diffs are not rendered by default.

0 comments on commit a4dfcd0

Please sign in to comment.