Skip to content

Commit

Permalink
Opt accepted and assigned (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiguantong authored Apr 3, 2024
1 parent 8b23469 commit 1195152
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default createSchema((p) => ({
// === V2
MessageAcceptedV2: p.createTable({
id: p.string(),
logIndex: p.int(),
msgHash: p.string(),
root: p.string(),
// message struct
Expand All @@ -15,6 +16,13 @@ export default createSchema((p) => ({
messageTo: p.string(),
messageGasLimit: p.bigint(),
messageEncoded: p.string(),
// extra
oracleAssigned: p.boolean().optional(),
oracleAssignedFee: p.bigint().optional(),
oracleLogIndex: p.int().optional(),
relayerAssigned: p.boolean().optional(),
relayerAssignedFee: p.bigint().optional(),
relayerLogIndex: p.int().optional(),
}),
MessageDispatchedV2: p.createTable({
id: p.string(),
Expand Down
33 changes: 32 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ ponder.on("ORMPV2:MessageAccepted", async ({ event, context }) => {
await MessageAcceptedV2.create({
id: event.log.id,
data: {
logIndex: event.log.logIndex,
msgHash: event.args.msgHash,
root: `${event.args.root}`,
messageChannel: message.channel,
Expand All @@ -32,7 +33,7 @@ ponder.on("ORMPV2:MessageDispatched", async ({ event, context }) => {
});

ponder.on("ORMPV2:MessageAssigned", async ({ event, context }) => {
const { MessageAssignedV2 } = context.db;
const { MessageAssignedV2, MessageAcceptedV2 } = context.db;
await MessageAssignedV2.create({
id: event.log.id,
data: {
Expand All @@ -43,6 +44,36 @@ ponder.on("ORMPV2:MessageAssigned", async ({ event, context }) => {
relayerFee: event.args.relayerFee,
},
});
// filter other relayer
if (
!["0xb773319D6Eb7f34b8EAB26Ea5F5ea694E7EF6362"].includes(event.args.relayer)
) {
await MessageAcceptedV2.updateMany({
where: {
msgHash: {
equals: event.args.msgHash,
},
},
data: {
oracleAssigned: true,
oracleAssignedFee: event.args.relayerFee,
oracleLogIndex: event.log.logIndex,
},
});
}
// filter other oracle
if (
!["0xDD8c7c84DaCBbB60F1CfC4f10046245da1E0f33D"].includes(event.args.oracle)
) {
await MessageAcceptedV2.updateMany({
where: {},
data: {
relayerAssigned: true,
relayerAssignedFee: event.args.oracleFee,
relayerLogIndex: event.log.logIndex,
},
});
}
});

ponder.on("SignaturePub:SignatureSubmittion", async ({ event, context }) => {
Expand Down

0 comments on commit 1195152

Please sign in to comment.