Skip to content

Commit

Permalink
rework resday loads
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-converter committed Dec 5, 2020
1 parent a94987c commit 995b5cc
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ for (let i = 1; i <= 50; i++) {
max = MAX_SUPPLY_6
break
}
day.supply = null
day.minSupply = min
day.maxSupply = max
day.totalAmount = BigInt.fromI32(0)
Expand Down Expand Up @@ -172,13 +173,7 @@ export function handleWiseReservation(event: WiseReservation): void {
user.reservedEth = user.reservedEth.plus(reservation.amount)
user.save()

let gResDayID = reservation.investmentDay.toString()
let gResDay = new GlobalReservationDay(gResDayID)
gResDay.investmentDay = reservation.investmentDay
gResDay.totalAmount = BigInt.fromI32(0)
gResDay.totalRealAmount = BigInt.fromI32(0)
gResDay.reservationCount = BigInt.fromI32(0)
gResDay.userCount = BigInt.fromI32(0)
let gResDay = GlobalReservationDay.load(reservation.investmentDay.toString())
gResDay.totalAmount = gResDay.totalAmount.plus(reservation.amount)
gResDay.totalRealAmount = gResDay.totalRealAmount.plus(reservation.amount)
gResDay.reservationCount = gResDay.reservationCount.plus(BigInt.fromI32(1))
Expand Down Expand Up @@ -214,13 +209,13 @@ export function handleWiseReservation(event: WiseReservation): void {
}

export function handleGeneratedStaticSupply(event: GeneratedStaticSupply): void {
let day = GlobalReservationDay.load(event.params.investmentDay.toString())
let day = new GlobalReservationDay(event.params.investmentDay.toString())
day.supply = event.params.staticSupply
day.save()
}

export function handleGeneratedRandomSupply(event: GeneratedRandomSupply): void {
let day = GlobalReservationDay.load(event.params.investmentDay.toString())
let day = new GlobalReservationDay(event.params.investmentDay.toString())
day.supply = event.params.randomSupply
day.save()
}
Expand Down

0 comments on commit 995b5cc

Please sign in to comment.