Skip to content

Commit

Permalink
Updates bat libraries
Browse files Browse the repository at this point in the history
Resolves brave#13509

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Mar 22, 2018
1 parent 251bb6e commit 8ab9127
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 49 deletions.
27 changes: 25 additions & 2 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2331,10 +2331,33 @@ const run = (state, delayTime) => {

if (data) {
let weights = []

let map = {}
data.forEach((datum) => {
weights.push({publisher: datum.publisherKey, weight: datum.weight / 100.0})
map[datum.publisherKey] = {
verified: datum.verified,
exclude: datum.exclude,
score: datum.score,
pinPercentage: datum.pinPercentage,
percentage: datum.percentage,
votes: 0,
weight: datum.weight
}

weights.push({
publisher: datum.publisherKey,
pinPercentage: datum.pinPercentage,
weight: datum.weight / 100.0
})
})
winners = synopsis.winners(ballots, weights)

winners = synopsis.winners(ballots, weights) || []

winners.forEach((winner) => {
if (map[winner]) map[winner].votes++
})

client.memo('run:ballots', Object.values(map))
}

if (!winners) winners = []
Expand Down
155 changes: 110 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"aphrodite": "1.1.0",
"async": "^2.0.1",
"bat-balance": "^1.0.7",
"bat-client": "^2.0.11",
"bat-publisher": "^2.0.13",
"bat-client": "^2.1.1",
"bat-publisher": "^2.0.15",
"bignumber.js": "^4.0.4",
"bloodhound-js": "brave/bloodhound",
"clipboard-copy": "^1.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('ledger api unit tests', function () {
getPaymentId: function () {
return 'payementIdGoesHere'
},
memo: () => {},
properties: {
wallet: {
paymentId: 12345
Expand Down

0 comments on commit 8ab9127

Please sign in to comment.