Period check fixes

This commit is contained in:
Jaco Greeff 2021-03-26 18:20:08 +01:00
parent 78caf79b23
commit 73d00389a6
No known key found for this signature in database
GPG Key ID: 270FB2D05A05357C
5 changed files with 14 additions and 14 deletions

View File

@ -34,8 +34,8 @@ function Auction ({ auctionInfo, campaigns, className, winningData }: Props): Re
? winners
: winners.map((w): WinnerData =>
campaigns.funds?.find(({ firstSlot, lastSlot, value }) =>
w.firstSlot === firstSlot &&
w.lastSlot === lastSlot &&
w.firstSlot.eq(firstSlot) &&
w.lastSlot.eq(lastSlot) &&
w.value.lt(value)
) || w
),

View File

@ -61,8 +61,8 @@ function Bid ({ auctionInfo, className, lastWinners, ownedIds }: Props): React.R
const currentWinner = useMemo(
() => lastWinners && lastWinners.winners.find(({ firstSlot, lastSlot }) =>
rangeOpts[range].firstSlot === firstSlot &&
rangeOpts[range].lastSlot === lastSlot
firstSlot.eqn(rangeOpts[range].firstSlot) &&
lastSlot.eqn(rangeOpts[range].lastSlot)
),
[lastWinners, range, rangeOpts]
);

View File

@ -65,9 +65,9 @@ export interface OwnerInfo {
export interface WinnerData {
accountId: string;
firstSlot: number;
firstSlot: BN;
isCrowdloan: boolean;
lastSlot: number;
lastSlot: BN;
paraId: ParaId;
value: BN;
}

View File

@ -30,7 +30,7 @@ function createAddress (paraId: ParaId): Uint8Array {
}
function isCrowdloadAccount (paraId: ParaId, accountId: AccountId): boolean {
return accountId.eq();
return accountId.eq(createAddress(paraId));
}
function hasLease (paraId: ParaId, leased: ParaId[]): boolean {
@ -123,10 +123,10 @@ const optFundMulti = {
.filter((v): v is [ParaId, FundInfo] => !!v[1])
.map(([paraId, info]): Campaign => ({
accountId: encodeAddress(createAddress(paraId)),
firstSlot: info.firstSlot.toNumber(),
firstSlot: info.firstSlot,
info,
isCrowdloan: true,
lastSlot: info.lastSlot.toNumber(),
lastSlot: info.lastSlot,
paraId,
value: info.raised
}))

View File

@ -22,8 +22,8 @@ function isNewWinners (a: WinnerData[], b: WinnerData[]): boolean {
function isNewOrdering (a: WinnerData[], b: WinnerData[]): boolean {
return a.length !== b.length || a.some(({ firstSlot, lastSlot, paraId }, index) =>
!paraId.eq(b[index].paraId) ||
firstSlot !== b[index].firstSlot ||
lastSlot !== b[index].lastSlot
!firstSlot.eq(b[index].firstSlot) ||
!lastSlot.eq(b[index].lastSlot)
);
}
@ -33,14 +33,14 @@ function extractWinners (auctionInfo: AuctionInfo, optData: Option<WinningData>)
: optData.unwrap().reduce<WinnerData[]>((winners, optEntry, index): WinnerData[] => {
if (optEntry.isSome) {
const [accountId, paraId, value] = optEntry.unwrap();
const period = auctionInfo.leasePeriod?.toNumber() || 0;
const period = auctionInfo.leasePeriod || BN_ZERO;
const [first, last] = RANGES[index];
winners.push({
accountId: accountId.toString(),
firstSlot: first + period,
firstSlot: period.addn(first),
isCrowdloan: u8aEq(CROWD_PREFIX, accountId.subarray(0, CROWD_PREFIX.length)),
lastSlot: last + period,
lastSlot: period.addn(last),
paraId,
value
});