Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more info to event models #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export default createSchema((p) => ({
MessageAcceptedV2: p.createTable({
id: p.string(),

chainId: p.bigint(),
blockNumber: p.bigint(),
blockTimestamp: p.bigint(),
transactionHash: p.string(),

transactionIndex: p.int(),
logIndex: p.int(),

msgHash: p.string(),
root: p.string(),
// message struct
Expand All @@ -34,19 +36,25 @@ export default createSchema((p) => ({
MessageDispatchedV2: p.createTable({
id: p.string(),

chainId: p.bigint(),
blockNumber: p.bigint(),
blockTimestamp: p.bigint(),
transactionHash: p.string(),
transactionIndex: p.int(),
logIndex: p.int(),

msgHash: p.string(),
dispatchResult: p.boolean(),
}),
MessageAssignedV2: p.createTable({
id: p.string(),

chainId: p.bigint(),
blockNumber: p.bigint(),
blockTimestamp: p.bigint(),
transactionHash: p.string(),
transactionIndex: p.int(),
logIndex: p.int(),

msgHash: p.string(),
oracle: p.hex(),
Expand All @@ -57,9 +65,12 @@ export default createSchema((p) => ({
HashImportedV2: p.createTable({
id: p.string(),

chainId: p.bigint(),
blockNumber: p.bigint(),
blockTimestamp: p.bigint(),
transactionHash: p.string(),
transactionIndex: p.int(),
logIndex: p.int(),

srcChainId: p.bigint(),
oracle: p.hex(),
Expand All @@ -70,11 +81,14 @@ export default createSchema((p) => ({
SignatureSubmittion: p.createTable({
id: p.string(),

chainId: p.bigint(),
blockNumber: p.bigint(),
blockTimestamp: p.bigint(),
transactionHash: p.string(),
transactionIndex: p.int(),
logIndex: p.int(),

chainId: p.bigint(),
sChainId: p.bigint(),
channel: p.hex(),
msgIndex: p.bigint(),
signer: p.hex(),
Expand Down
32 changes: 23 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ ponder.on("ORMPV2:MessageAccepted", async ({ event, context }) => {
const { MessageAcceptedV2 } = context.db;
const message = event.args.message;
await MessageAcceptedV2.create({
id: event.log.id,
id: `${context.network.chainId}-${event.block.number}-${event.log.transactionIndex}-${event.log.logIndex}`,
data: {
chainId: BigInt(context.network.chainId),
blockNumber: event.block.number,
blockTimestamp: event.block.timestamp,
transactionHash: event.transaction.hash,

transactionIndex: event.log.transactionIndex,
logIndex: event.log.logIndex,

msgHash: event.args.msgHash,
root: `${event.args.root}`,
messageChannel: message.channel,
Expand All @@ -32,11 +34,14 @@ ponder.on("ORMPV2:MessageAccepted", async ({ event, context }) => {
ponder.on("ORMPV2:MessageDispatched", async ({ event, context }) => {
const { MessageDispatchedV2 } = context.db;
await MessageDispatchedV2.create({
id: event.log.id,
id: `${context.network.chainId}-${event.block.number}-${event.log.transactionIndex}-${event.log.logIndex}`,
data: {
chainId: BigInt(context.network.chainId),
blockNumber: event.block.number,
blockTimestamp: event.block.timestamp,
transactionHash: event.transaction.hash,
transactionIndex: event.log.transactionIndex,
logIndex: event.log.logIndex,

msgHash: event.args.msgHash,
dispatchResult: event.args.dispatchResult,
Expand All @@ -47,11 +52,14 @@ ponder.on("ORMPV2:MessageDispatched", async ({ event, context }) => {
ponder.on("ORMPV2:MessageAssigned", async ({ event, context }) => {
const { MessageAssignedV2, MessageAcceptedV2 } = context.db;
await MessageAssignedV2.create({
id: event.log.id,
id: `${context.network.chainId}-${event.block.number}-${event.log.transactionIndex}-${event.log.logIndex}`,
data: {
chainId: BigInt(context.network.chainId),
blockNumber: event.block.number,
blockTimestamp: event.block.timestamp,
transactionHash: event.transaction.hash,
transactionIndex: event.log.transactionIndex,
logIndex: event.log.logIndex,

msgHash: event.args.msgHash,
oracle: event.args.oracle,
Expand Down Expand Up @@ -99,11 +107,14 @@ ponder.on("ORMPV2:HashImported", async ({ event, context }) => {
// filter other oracle
if (listenOracle.includes(event.args.oracle)) {
await HashImportedV2.create({
id: event.log.id,
data: {
id: `${context.network.chainId}-${event.block.number}-${event.log.transactionIndex}-${event.log.logIndex}`,
data: {
chainId: BigInt(context.network.chainId),
blockNumber: event.block.number,
blockTimestamp: event.block.timestamp,
transactionHash: event.transaction.hash,
transactionIndex: event.log.transactionIndex,
logIndex: event.log.logIndex,

srcChainId: event.args.srcChainId,
oracle: event.args.oracle,
Expand All @@ -120,13 +131,16 @@ ponder.on("SignaturePub:SignatureSubmittion", async ({ event, context }) => {
// filter other channels
if (listenSignature.includes(event.args.channel)) {
await SignatureSubmittion.create({
id: event.log.id,
data: {
id: `${context.network.chainId}-${event.block.number}-${event.log.transactionIndex}-${event.log.logIndex}`,
data: {
chainId: BigInt(context.network.chainId),
blockNumber: event.block.number,
blockTimestamp: event.block.timestamp,
transactionHash: event.transaction.hash,
transactionIndex: event.log.transactionIndex,
logIndex: event.log.logIndex,

chainId: event.args.chainId,
sChainId: event.args.chainId,
channel: event.args.channel,
msgIndex: event.args.msgIndex,
signer: event.args.signer,
Expand Down