diff --git a/db/migrations/1724433908520-Data.js b/db/migrations/1724433908520-Data.js new file mode 100644 index 0000000..f23fc00 --- /dev/null +++ b/db/migrations/1724433908520-Data.js @@ -0,0 +1,31 @@ +module.exports = class Data1724433908520 { + name = 'Data1724433908520' + + async up(db) { + await db.query(`ALTER TABLE "channel_open_init" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "channel_open_try" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "channel_open_ack" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "channel_open_confirm" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "close_ibc_channel" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "send_packet" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "recv_packet" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "write_ack_packet" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "acknowledgement" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "timeout" ADD "gas_used" numeric`) + await db.query(`ALTER TABLE "write_timeout_packet" ADD "gas_used" numeric`) + } + + async down(db) { + await db.query(`ALTER TABLE "channel_open_init" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "channel_open_try" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "channel_open_ack" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "channel_open_confirm" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "close_ibc_channel" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "send_packet" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "recv_packet" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "write_ack_packet" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "acknowledgement" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "timeout" DROP COLUMN "gas_used"`) + await db.query(`ALTER TABLE "write_timeout_packet" DROP COLUMN "gas_used"`) + } +} diff --git a/schema.graphql b/schema.graphql index e436bf2..ff9eb56 100644 --- a/schema.graphql +++ b/schema.graphql @@ -44,6 +44,7 @@ type SendPacket @entity { packetDataSender: String @index uchEventSender: String @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -72,6 +73,7 @@ type RecvPacket @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -94,6 +96,7 @@ type WriteAckPacket @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -117,6 +120,7 @@ type Acknowledgement @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -137,6 +141,7 @@ type Timeout @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -159,6 +164,7 @@ type WriteTimeoutPacket @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -227,6 +233,7 @@ type ChannelOpenInit @entity { chainId: Int! @index from: String! gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -256,6 +263,7 @@ type ChannelOpenTry @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt from: String! @@ -279,6 +287,7 @@ type ChannelOpenAck @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -303,6 +312,7 @@ type ChannelOpenConfirm @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt @@ -325,6 +335,7 @@ type CloseIbcChannel @entity { transactionHash: String! @index chainId: Int! @index gas: BigInt! + gasUsed: BigInt gasPrice: BigInt maxFeePerGas: BigInt maxPriorityFeePerGas: BigInt diff --git a/src/handlers/channels.ts b/src/handlers/channels.ts index 7ce1b58..de29e14 100644 --- a/src/handlers/channels.ts +++ b/src/handlers/channels.ts @@ -42,6 +42,7 @@ export function handleChannelOpenInit(portPrefix: string, block: Block, log: Log chainId: log.transaction?.chainId || 0, from: log.transaction?.from || '', gas: log.transaction?.gas, + gasUsed: log.transaction?.gasUsed, maxFeePerGas: log.transaction?.maxFeePerGas, maxPriorityFeePerGas: log.transaction?.maxPriorityFeePerGas, }); @@ -74,6 +75,7 @@ export function handleChannelOpenTry(block: Block, log: Log): ChannelOpenTry { chainId: log.transaction?.chainId || 0, from: log.transaction?.from || '', gas: log.transaction?.gas, + gasUsed: log.transaction?.gasUsed, maxFeePerGas: log.transaction?.maxFeePerGas, maxPriorityFeePerGas: log.transaction?.maxPriorityFeePerGas, }) @@ -101,6 +103,7 @@ export function handleChannelOpenAck(block: Block, log: Log): ChannelOpenAck { chainId: log.transaction?.chainId || 0, from: log.transaction?.from || '', gas: log.transaction?.gas, + gasUsed: log.transaction?.gasUsed, maxFeePerGas: log.transaction?.maxFeePerGas, maxPriorityFeePerGas: log.transaction?.maxPriorityFeePerGas }) @@ -127,6 +130,7 @@ export function handleChannelOpenConfirm(block: Block, log: Log): ChannelOpenCon chainId: log.transaction?.chainId || 0, from: log.transaction?.from || '', gas: log.transaction?.gas, + gasUsed: log.transaction?.gasUsed, maxFeePerGas: log.transaction?.maxFeePerGas, maxPriorityFeePerGas: log.transaction?.maxPriorityFeePerGas }) diff --git a/src/handlers/packets.ts b/src/handlers/packets.ts index 9959f48..d8bc08b 100644 --- a/src/handlers/packets.ts +++ b/src/handlers/packets.ts @@ -16,6 +16,7 @@ export function handleSendPacket(block: Block, log: Log, portPrefix: string, uch let sourceChannelId = ethers.decodeBytes32String(event.sourceChannelId) const packetHash = ethers.sha256(event.packet) const gas = BigInt(log.transaction!.gas) + const gasUsed = BigInt(log.transaction!.gasUsed) const gasPrice = log.transaction?.gasPrice ? BigInt(log.transaction.gasPrice) : null const maxFeePerGas = log.transaction?.maxFeePerGas ? BigInt(log.transaction.maxFeePerGas) : null const maxPriorityFeePerGas = log.transaction?.maxPriorityFeePerGas ? BigInt(log.transaction.maxPriorityFeePerGas) : null @@ -38,6 +39,7 @@ export function handleSendPacket(block: Block, log: Log, portPrefix: string, uch uchEventSender, packetDataSender, gas, + gasUsed, gasPrice, maxFeePerGas, maxPriorityFeePerGas, @@ -51,6 +53,7 @@ export function handleRecvPacket(block: Block, log: Log, portPrefix: string): mo let event = dispatcher.events.RecvPacket.decode(log) let destChannelId = ethers.decodeBytes32String(event.destChannelId) const gas = BigInt(log.transaction!.gas) + const gasUsed = BigInt(log.transaction!.gasUsed) const gasPrice = log.transaction?.gasPrice ? BigInt(log.transaction.gasPrice) : null const maxFeePerGas = log.transaction?.maxFeePerGas ? BigInt(log.transaction.maxFeePerGas) : null const maxPriorityFeePerGas = log.transaction?.maxPriorityFeePerGas ? BigInt(log.transaction.maxPriorityFeePerGas) : null @@ -68,6 +71,7 @@ export function handleRecvPacket(block: Block, log: Log, portPrefix: string): mo transactionHash: log.transactionHash, chainId: log.transaction?.chainId || 0, gas, + gasUsed, gasPrice, maxFeePerGas, maxPriorityFeePerGas, @@ -80,6 +84,7 @@ export function handleWriteAckPacket(block: Block, log: Log, portPrefix: string) let writerChannelId = ethers.decodeBytes32String(event.writerChannelId); const packetHash = ethers.sha256(event.ackPacket.data); const gas = BigInt(log.transaction!.gas) + const gasUsed = BigInt(log.transaction!.gasUsed) const gasPrice = log.transaction?.gasPrice ? BigInt(log.transaction.gasPrice) : null const maxFeePerGas = log.transaction?.maxFeePerGas ? BigInt(log.transaction.maxFeePerGas) : null const maxPriorityFeePerGas = log.transaction?.maxPriorityFeePerGas ? BigInt(log.transaction.maxPriorityFeePerGas) : null @@ -99,6 +104,7 @@ export function handleWriteAckPacket(block: Block, log: Log, portPrefix: string) transactionHash: log.transactionHash, chainId: log.transaction?.chainId || 0, gas, + gasUsed, gasPrice, maxFeePerGas, maxPriorityFeePerGas, @@ -109,6 +115,7 @@ export function handleWriteAckPacket(block: Block, log: Log, portPrefix: string) export function handleAcknowledgement(block: Block, log: Log, portPrefix: string): models.Acknowledgement { let event = dispatcher.events.Acknowledgement.decode(log); const gas = BigInt(log.transaction!.gas) + const gasUsed = BigInt(log.transaction!.gasUsed) const gasPrice = log.transaction?.gasPrice ? BigInt(log.transaction.gasPrice) : null const maxFeePerGas = log.transaction?.maxFeePerGas ? BigInt(log.transaction.maxFeePerGas) : null const maxPriorityFeePerGas = log.transaction?.maxPriorityFeePerGas ? BigInt(log.transaction.maxPriorityFeePerGas) : null @@ -126,6 +133,7 @@ export function handleAcknowledgement(block: Block, log: Log, portPrefix: string transactionHash: log.transactionHash, chainId: log.transaction?.chainId || 0, gas, + gasUsed, gasPrice, maxFeePerGas, maxPriorityFeePerGas, @@ -137,6 +145,7 @@ export function handleTimeout(block: Block, log: Log, portPrefix: string): model let event = dispatcher.events.Timeout.decode(log); let sourceChannelId = ethers.decodeBytes32String(event.sourceChannelId); const gas = BigInt(log.transaction!.gas) + const gasUsed = BigInt(log.transaction!.gasUsed) const gasPrice = log.transaction?.gasPrice ? BigInt(log.transaction.gasPrice) : null const maxFeePerGas = log.transaction?.maxFeePerGas ? BigInt(log.transaction.maxFeePerGas) : null const maxPriorityFeePerGas = log.transaction?.maxPriorityFeePerGas ? BigInt(log.transaction.maxPriorityFeePerGas) : null @@ -154,6 +163,7 @@ export function handleTimeout(block: Block, log: Log, portPrefix: string): model transactionHash: log.transactionHash, chainId: log.transaction?.chainId || 0, gas, + gasUsed, gasPrice, maxFeePerGas, maxPriorityFeePerGas, @@ -165,6 +175,7 @@ export function handleWriteTimeoutPacket(block: Block, log: Log, portPrefix: str let event = dispatcher.events.WriteTimeoutPacket.decode(log); let writerChannelId = ethers.decodeBytes32String(event.writerChannelId); const gas = BigInt(log.transaction!.gas) + const gasUsed = BigInt(log.transaction!.gasUsed) const gasPrice = log.transaction?.gasPrice ? BigInt(log.transaction.gasPrice) : null const maxFeePerGas = log.transaction?.maxFeePerGas ? BigInt(log.transaction.maxFeePerGas) : null const maxPriorityFeePerGas = log.transaction?.maxPriorityFeePerGas ? BigInt(log.transaction.maxPriorityFeePerGas) : null @@ -185,6 +196,7 @@ export function handleWriteTimeoutPacket(block: Block, log: Log, portPrefix: str transactionHash: log.transactionHash, chainId: log.transaction?.chainId || 0, gas, + gasUsed, gasPrice, maxFeePerGas, maxPriorityFeePerGas, diff --git a/src/model/generated/acknowledgement.model.ts b/src/model/generated/acknowledgement.model.ts index 1415c59..49c9456 100644 --- a/src/model/generated/acknowledgement.model.ts +++ b/src/model/generated/acknowledgement.model.ts @@ -46,6 +46,9 @@ export class Acknowledgement { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/channelOpenAck.model.ts b/src/model/generated/channelOpenAck.model.ts index 191aa91..284ac50 100644 --- a/src/model/generated/channelOpenAck.model.ts +++ b/src/model/generated/channelOpenAck.model.ts @@ -51,6 +51,9 @@ export class ChannelOpenAck { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/channelOpenConfirm.model.ts b/src/model/generated/channelOpenConfirm.model.ts index f4ac4c0..ada8429 100644 --- a/src/model/generated/channelOpenConfirm.model.ts +++ b/src/model/generated/channelOpenConfirm.model.ts @@ -51,6 +51,9 @@ export class ChannelOpenConfirm { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/channelOpenInit.model.ts b/src/model/generated/channelOpenInit.model.ts index e92f284..88022c0 100644 --- a/src/model/generated/channelOpenInit.model.ts +++ b/src/model/generated/channelOpenInit.model.ts @@ -67,6 +67,9 @@ export class ChannelOpenInit { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/channelOpenTry.model.ts b/src/model/generated/channelOpenTry.model.ts index fa2c69c..5886ffb 100644 --- a/src/model/generated/channelOpenTry.model.ts +++ b/src/model/generated/channelOpenTry.model.ts @@ -63,6 +63,9 @@ export class ChannelOpenTry { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) maxFeePerGas!: bigint | undefined | null diff --git a/src/model/generated/closeIbcChannel.model.ts b/src/model/generated/closeIbcChannel.model.ts index 1523034..5597b5e 100644 --- a/src/model/generated/closeIbcChannel.model.ts +++ b/src/model/generated/closeIbcChannel.model.ts @@ -45,6 +45,9 @@ export class CloseIbcChannel { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/recvPacket.model.ts b/src/model/generated/recvPacket.model.ts index a69566c..3617298 100644 --- a/src/model/generated/recvPacket.model.ts +++ b/src/model/generated/recvPacket.model.ts @@ -48,6 +48,9 @@ export class RecvPacket { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/sendPacket.model.ts b/src/model/generated/sendPacket.model.ts index f968046..48529aa 100644 --- a/src/model/generated/sendPacket.model.ts +++ b/src/model/generated/sendPacket.model.ts @@ -70,6 +70,9 @@ export class SendPacket { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/timeout.model.ts b/src/model/generated/timeout.model.ts index 48961d2..4df4260 100644 --- a/src/model/generated/timeout.model.ts +++ b/src/model/generated/timeout.model.ts @@ -45,6 +45,9 @@ export class Timeout { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/writeAckPacket.model.ts b/src/model/generated/writeAckPacket.model.ts index e03f4fb..5d7058a 100644 --- a/src/model/generated/writeAckPacket.model.ts +++ b/src/model/generated/writeAckPacket.model.ts @@ -52,6 +52,9 @@ export class WriteAckPacket { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null diff --git a/src/model/generated/writeTimeoutPacket.model.ts b/src/model/generated/writeTimeoutPacket.model.ts index 76ecd4e..552e975 100644 --- a/src/model/generated/writeTimeoutPacket.model.ts +++ b/src/model/generated/writeTimeoutPacket.model.ts @@ -54,6 +54,9 @@ export class WriteTimeoutPacket { @BigIntColumn_({nullable: false}) gas!: bigint + @BigIntColumn_({nullable: true}) + gasUsed!: bigint | undefined | null + @BigIntColumn_({nullable: true}) gasPrice!: bigint | undefined | null