Skip to content

Commit

Permalink
Flatten out gasLimits and gasPrices
Browse files Browse the repository at this point in the history
  • Loading branch information
Inkvi committed Jul 24, 2024
1 parent ea7732f commit b4658c6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
6 changes: 4 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ type SendPacketFeeDeposited @entity {
id: ID!
channelId: String! @index
sequence: BigInt! @index
gasLimits: [Int!]!
gasPrices: [Int!]!
sendGasLimit: BigInt!
sendGasPrice: BigInt!
ackGasLimit: BigInt!
ackGasPrice: BigInt!
blockNumber: BigInt!
blockTimestamp: BigInt! @index
transactionHash: String! @index
Expand Down
11 changes: 9 additions & 2 deletions src/handlers/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ import { OpenChannelFeeDeposited, SendPacketFeeDeposited } from "../model";
export function handleSendPacketFee(block: Block, log: Log) {
let event = fee.events.SendPacketFeeDeposited.decode(log)
let channelId = ethers.decodeBytes32String(event.channelId)

if (event.gasLimits.length !== 2 || event.gasPrices.length !== 2) {
throw new Error('Invalid gas limits or gas prices')
}

return new SendPacketFeeDeposited({
id: log.id,
channelId: channelId,
sequence: event.sequence,
gasLimits: event.gasLimits.map(Number),
gasPrices: event.gasPrices.map(Number),
sendGasLimit: BigInt(event.gasLimits[0]),
sendGasPrice: BigInt(event.gasPrices[0]),
ackGasLimit: BigInt(event.gasLimits[1]),
ackGasPrice: BigInt(event.gasPrices[1]),
blockNumber: BigInt(block.height),
blockTimestamp: BigInt(log.block.timestamp),
transactionHash: log.transactionHash,
Expand Down
14 changes: 10 additions & 4 deletions src/model/generated/sendPacketFeeDeposited.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ export class SendPacketFeeDeposited {
@BigIntColumn_({nullable: false})
sequence!: bigint

@IntColumn_({array: true, nullable: false})
gasLimits!: (number)[]
@BigIntColumn_({nullable: false})
sendGasLimit!: bigint

@BigIntColumn_({nullable: false})
sendGasPrice!: bigint

@IntColumn_({array: true, nullable: false})
gasPrices!: (number)[]
@BigIntColumn_({nullable: false})
ackGasLimit!: bigint

@BigIntColumn_({nullable: false})
ackGasPrice!: bigint

@BigIntColumn_({nullable: false})
blockNumber!: bigint
Expand Down

0 comments on commit b4658c6

Please sign in to comment.