Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions helpers/voting/makePriceRequestsByKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ function formatPriceRequests(priceRequests: RawPriceRequestDataT[]) {
function formatPriceRequest(
priceRequest: RawPriceRequestDataT
): PriceRequestT & VoteParticipationT & VoteResultsT {
const time =
priceRequest.time instanceof BigNumber
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the instanceof check was failing so the value was not being converted to a number

? priceRequest.time.toNumber()
: priceRequest.time;
const time = BigNumber.isBigNumber(priceRequest.time)
? priceRequest.time.toNumber()
: priceRequest.time;
const timeMilliseconds = time * 1000;
const timeAsDate = new Date(timeMilliseconds);
const identifier = priceRequest.identifier;
Expand Down
5 changes: 3 additions & 2 deletions helpers/voting/makeUniqueKeyForVote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber } from "ethers";
import { BigNumber, utils } from "ethers";

export function makeUniqueKeyForVote(
decodedIdentifier: string,
Expand All @@ -8,5 +8,6 @@ export function makeUniqueKeyForVote(
if (typeof time !== "number") {
time = time.toNumber();
}
return `${decodedIdentifier}-${time}-${ancillaryData}`;
const ancillaryDataHash = utils.keccak256(utils.toUtf8Bytes(ancillaryData));
return `${decodedIdentifier}-${time}-${ancillaryDataHash}`;
}