Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeHowarth committed Apr 3, 2023
1 parent c60bc97 commit d1d0abc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
4 changes: 2 additions & 2 deletions relayer-engine-v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion relayer-engine-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@types/koa": "^2.13.5",
"clone": "^2.1.2",
"koa": "^2.14.1",
"wormhole-relayer": "github:gabzim/wormhole-relayer#fcc1b7f05e19f4bfdbc2d44c919ee088b5fe5cf3",
"wormhole-relayer": "github:gabzim/wormhole-relayer#0c82a15",
"yargs": "^17.7.1"
},
"peerDependencies": {
Expand Down
26 changes: 21 additions & 5 deletions relayer-engine-v2/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as wh from "@certusone/wormhole-sdk"
import { Next } from "wormhole-relayer"
import {
IDelivery,
MessageInfoType,
parseDeliveryInstructionsContainer,
parsePayloadType,
parseRedeliveryByTxHashInstruction,
Expand Down Expand Up @@ -33,11 +34,16 @@ async function processDelivery(ctx: GRContext) {
return
}

if (
payload.messages.findIndex((m) => m.payloadType !== MessageInfoType.EmitterSequence)
) {
throw new Error(`Only supports EmitterSequence MessageInfoType`)
}
const fetchedVaas = await ctx.fetchVaas({
ids: payload.messages.map((m) => ({
emitterAddress: m.emitterAddress,
emitterAddress: m.emitterAddress!,
emitterChain: chainId,
sequence: m.sequence.toBigInt(),
sequence: m.sequence!.toBigInt(),
})),
txHash: ctx.sourceTxHash,
})
Expand All @@ -55,7 +61,7 @@ async function processDelivery(ctx: GRContext) {

const input: IDelivery.TargetDeliveryParametersSingleStruct = {
encodedVMs: fetchedVaas.map((v) => v.bytes),
deliveryVAA: ctx.vaaBytes!,
encodedDeliveryVAA: ctx.vaaBytes!,
multisendIndex: i,
relayerRefundAddress: wallet.address,
}
Expand Down Expand Up @@ -94,11 +100,20 @@ async function processRedelivery(ctx: GRContext) {
const deliveryInstructionsContainer = parseDeliveryInstructionsContainer(
deliveryVAA.payload
)

if (
deliveryInstructionsContainer.messages.findIndex(
(m) => m.payloadType !== MessageInfoType.EmitterSequence
)
) {
throw new Error(`Only supports EmitterSequence MessageInfoType`)
}

const fetchedVaas = await ctx.fetchVaas({
ids: deliveryInstructionsContainer.messages.map((m) => ({
emitterAddress: m.emitterAddress,
emitterAddress: m.emitterAddress!,
emitterChain: chainId,
sequence: m.sequence.toBigInt(),
sequence: m.sequence!.toBigInt(),
})),
txHash: redelivery.sourceTxHash.toString("hex"), // todo: confirm this works
})
Expand All @@ -119,6 +134,7 @@ async function processRedelivery(ctx: GRContext) {
const budget = newReceiverValueTarget.add(newMaximumRefundTarget).add(100)
const input: IDelivery.TargetRedeliveryByTxHashParamsSingleStruct = {
sourceEncodedVMs: [...fetchedVaas.map((v) => v.bytes), deliveryVAA.bytes],
originalEncodedDeliveryVAA: deliveryVAA.bytes,
redeliveryVM: ctx.vaaBytes!,
relayerRefundAddress: wallet.address,
}
Expand Down

0 comments on commit d1d0abc

Please sign in to comment.