Skip to content

Commit 0f83539

Browse files
committed
fix some txHash
1 parent d5f8e3d commit 0f83539

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/templates/otoken/otoken-entity-producer.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class OTokenEntityProducer {
210210
address: await this.getOrCreateAddress(from),
211211
timestamp: new Date(this.otoken.block.header.timestamp),
212212
blockNumber: this.otoken.block.header.height,
213-
txHash: this.otoken.block.header.hash,
213+
txHash: trace.transaction!.hash,
214214
type: HistoryType.Sent,
215215
value: value,
216216
balance: this.otoken.balanceOf(from),
@@ -226,7 +226,7 @@ export class OTokenEntityProducer {
226226
address: await this.getOrCreateAddress(to),
227227
timestamp: new Date(this.otoken.block.header.timestamp),
228228
blockNumber: this.otoken.block.header.height,
229-
txHash: this.otoken.block.header.hash,
229+
txHash: trace.transaction!.hash,
230230
type: HistoryType.Received,
231231
value: value,
232232
balance: this.otoken.balanceOf(to),
@@ -238,7 +238,7 @@ export class OTokenEntityProducer {
238238
return entries
239239
}
240240

241-
private async getOrCreateAPYEntity(): Promise<OTokenAPY> {
241+
private async getOrCreateAPYEntity(trace: Trace): Promise<OTokenAPY> {
242242
const dateStr = new Date(this.otoken.block.header.timestamp).toISOString().split('T')[0]
243243
const id = `${this.ctx.chain.id}:${this.otoken.address}:${dateStr}`
244244

@@ -275,7 +275,7 @@ export class OTokenEntityProducer {
275275
otoken: this.otoken.address,
276276
timestamp: new Date(this.otoken.block.header.timestamp),
277277
blockNumber: this.otoken.block.header.height,
278-
txHash: this.otoken.block.header.hash,
278+
txHash: trace.transaction!.hash,
279279
date: dateStr,
280280
apr: 0,
281281
apy: 0,
@@ -290,7 +290,7 @@ export class OTokenEntityProducer {
290290
apy.rebasingCreditsPerToken = currentCreditsPerToken
291291
apy.timestamp = new Date(this.otoken.block.header.timestamp)
292292
apy.blockNumber = this.otoken.block.header.height
293-
apy.txHash = this.otoken.block.header.hash // Not a great field considering we can have more than one rebase per day.
293+
apy.txHash = trace.transaction!.hash // Not a great field considering we can have more than one rebase per day.
294294

295295
// Calculate APY if we have previous data
296296
if (previousApy) {
@@ -382,7 +382,7 @@ export class OTokenEntityProducer {
382382
otoken: this.otoken.address,
383383
timestamp: new Date(this.otoken.block.header.timestamp),
384384
blockNumber: this.otoken.block.header.height,
385-
txHash: this.otoken.block.header.hash,
385+
txHash: trace.transaction!.hash,
386386
totalSupply: this.otoken.totalSupply,
387387
rebasingCredits: this.otoken.rebasingCreditsHighres(),
388388
rebasingCreditsPerToken: this.otoken.rebasingCreditsPerTokenHighres(),
@@ -396,13 +396,13 @@ export class OTokenEntityProducer {
396396
}
397397

398398
// Update with current values
399-
rebase.apy = await this.getOrCreateAPYEntity()
399+
rebase.apy = await this.getOrCreateAPYEntity(trace)
400400
rebase.totalSupply = this.otoken.totalSupply
401401
rebase.rebasingCredits = this.otoken.rebasingCreditsHighres()
402402
rebase.rebasingCreditsPerToken = this.otoken.rebasingCreditsPerTokenHighres()
403403
rebase.timestamp = new Date(this.otoken.block.header.timestamp)
404404
rebase.blockNumber = this.otoken.block.header.height
405-
rebase.txHash = this.otoken.block.header.hash
405+
rebase.txHash = trace.transaction!.hash
406406

407407
this.rebaseMap.set(id, rebase)
408408
return rebase
@@ -469,7 +469,7 @@ export class OTokenEntityProducer {
469469

470470
async afterChangeSupply(trace: Trace, newTotalSupply: bigint, totalSupplyDiff: bigint): Promise<void> {
471471
await this.getOrCreateOTokenEntity()
472-
await this.getOrCreateAPYEntity()
472+
await this.getOrCreateAPYEntity(trace)
473473
await this.getOrCreateRebaseEntity(trace, totalSupplyDiff)
474474
await Promise.all(
475475
Object.entries(this.otoken.creditBalances)
@@ -488,7 +488,7 @@ export class OTokenEntityProducer {
488488
address: await this.getOrCreateAddress(account),
489489
timestamp: new Date(this.otoken.block.header.timestamp),
490490
blockNumber: this.otoken.block.header.height,
491-
txHash: this.otoken.block.header.hash,
491+
txHash: trace.transaction!.hash,
492492
type: HistoryType.Yield,
493493
value: earnedDiff,
494494
balance: this.otoken.balanceOf(account),

0 commit comments

Comments
 (0)