Period check fixes
This commit is contained in:
parent
78caf79b23
commit
73d00389a6
@ -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
|
||||
),
|
||||
|
||||
@ -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]
|
||||
);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
}))
|
||||
|
||||
@ -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
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user