update with changes from 'redelidevery-fixes' branch
This commit is contained in:
parent
2cf9fb0dca
commit
3cac2165b4
|
@ -1,4 +1,4 @@
|
||||||
import { BigNumber, ethers} from "ethers"
|
import { BigNumber, ethers } from "ethers"
|
||||||
import { arrayify } from "ethers/lib/utils"
|
import { arrayify } from "ethers/lib/utils"
|
||||||
|
|
||||||
export enum RelayerPayloadId {
|
export enum RelayerPayloadId {
|
||||||
|
@ -34,6 +34,8 @@ export interface RedeliveryByTxHashInstruction {
|
||||||
sourceTxHash: Buffer
|
sourceTxHash: Buffer
|
||||||
sourceNonce: BigNumber
|
sourceNonce: BigNumber
|
||||||
targetChain: number
|
targetChain: number
|
||||||
|
deliveryIndex: number
|
||||||
|
multisendIndex: number
|
||||||
newMaximumRefundTarget: BigNumber
|
newMaximumRefundTarget: BigNumber
|
||||||
newApplicationBudgetTarget: BigNumber
|
newApplicationBudgetTarget: BigNumber
|
||||||
executionParameters: ExecutionParameters
|
executionParameters: ExecutionParameters
|
||||||
|
@ -123,13 +125,23 @@ export function parseRedeliveryByTxHashInstruction(
|
||||||
|
|
||||||
const sourceNonce = BigNumber.from(bytes.slice(idx, idx + 32))
|
const sourceNonce = BigNumber.from(bytes.slice(idx, idx + 32))
|
||||||
idx += 32
|
idx += 32
|
||||||
|
|
||||||
const targetChain = bytes.readUInt16BE(idx)
|
const targetChain = bytes.readUInt16BE(idx)
|
||||||
idx += 2
|
idx += 2
|
||||||
|
|
||||||
|
const deliveryIndex = bytes.readUint8(idx)
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
const multisendIndex = bytes.readUint8(idx)
|
||||||
|
idx += 1
|
||||||
|
|
||||||
// note: confirmed that BigNumber.from(<Buffer>) assumes big endian
|
// note: confirmed that BigNumber.from(<Buffer>) assumes big endian
|
||||||
const newMaximumRefundTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
const newMaximumRefundTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
||||||
idx += 32
|
idx += 32
|
||||||
|
|
||||||
const newApplicationBudgetTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
const newApplicationBudgetTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
||||||
idx += 32
|
idx += 32
|
||||||
|
|
||||||
const executionParameters = parseExecutionParameters(bytes, idx)
|
const executionParameters = parseExecutionParameters(bytes, idx)
|
||||||
return {
|
return {
|
||||||
payloadId,
|
payloadId,
|
||||||
|
@ -137,6 +149,8 @@ export function parseRedeliveryByTxHashInstruction(
|
||||||
sourceTxHash,
|
sourceTxHash,
|
||||||
sourceNonce,
|
sourceNonce,
|
||||||
targetChain,
|
targetChain,
|
||||||
|
deliveryIndex,
|
||||||
|
multisendIndex,
|
||||||
newMaximumRefundTarget,
|
newMaximumRefundTarget,
|
||||||
newApplicationBudgetTarget,
|
newApplicationBudgetTarget,
|
||||||
executionParameters,
|
executionParameters,
|
||||||
|
|
|
@ -282,9 +282,6 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
|
||||||
).toString("base64")}`
|
).toString("base64")}`
|
||||||
)
|
)
|
||||||
const payloadId = parsePayloadType(coreRelayerVaa.payload)
|
const payloadId = parsePayloadType(coreRelayerVaa.payload)
|
||||||
if (payloadId !== RelayerPayloadId.Delivery) {
|
|
||||||
// todo: support redelivery
|
|
||||||
}
|
|
||||||
switch (payloadId) {
|
switch (payloadId) {
|
||||||
case RelayerPayloadId.Delivery:
|
case RelayerPayloadId.Delivery:
|
||||||
return this.consumeDeliveryEvent(coreRelayerVaa, db)
|
return this.consumeDeliveryEvent(coreRelayerVaa, db)
|
||||||
|
@ -561,7 +558,7 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
|
||||||
encodedVMs: payload.vaas,
|
encodedVMs: payload.vaas,
|
||||||
deliveryIndex: payload.deliveryVaaIndex,
|
deliveryIndex: payload.deliveryVaaIndex,
|
||||||
multisendIndex: i,
|
multisendIndex: i,
|
||||||
relayerRefundAddress: relayProvider.address,
|
relayerRefundAddress: wallet.address,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await relayProvider.approvedSender(wallet.address))) {
|
if (!(await relayProvider.approvedSender(wallet.address))) {
|
||||||
|
@ -611,8 +608,8 @@ export class GenericRelayerPlugin implements Plugin<WorkflowPayload> {
|
||||||
const budget = newApplicationBudgetTarget.add(newMaximumRefundTarget).add(100)
|
const budget = newApplicationBudgetTarget.add(newMaximumRefundTarget).add(100)
|
||||||
const input: CoreRelayerStructs.TargetRedeliveryByTxHashParamsSingleStruct = {
|
const input: CoreRelayerStructs.TargetRedeliveryByTxHashParamsSingleStruct = {
|
||||||
sourceEncodedVMs: payload.vaas,
|
sourceEncodedVMs: payload.vaas,
|
||||||
deliveryIndex: payload.deliveryVaaIndex,
|
redeliveryVM: redelivery.vaa.bytes,
|
||||||
multisendIndex: redelivery.ix.mul,
|
relayerRefundAddress: wallet.address,
|
||||||
}
|
}
|
||||||
|
|
||||||
relayProvider
|
relayProvider
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { BigNumber, ethers} from "ethers"
|
import { BigNumber, ethers } from "ethers"
|
||||||
import { arrayify } from "ethers/lib/utils"
|
import { arrayify } from "ethers/lib/utils"
|
||||||
|
|
||||||
export enum RelayerPayloadId {
|
export enum RelayerPayloadId {
|
||||||
|
@ -34,6 +34,8 @@ export interface RedeliveryByTxHashInstruction {
|
||||||
sourceTxHash: Buffer
|
sourceTxHash: Buffer
|
||||||
sourceNonce: BigNumber
|
sourceNonce: BigNumber
|
||||||
targetChain: number
|
targetChain: number
|
||||||
|
deliveryIndex: number
|
||||||
|
multisendIndex: number
|
||||||
newMaximumRefundTarget: BigNumber
|
newMaximumRefundTarget: BigNumber
|
||||||
newApplicationBudgetTarget: BigNumber
|
newApplicationBudgetTarget: BigNumber
|
||||||
executionParameters: ExecutionParameters
|
executionParameters: ExecutionParameters
|
||||||
|
@ -123,13 +125,23 @@ export function parseRedeliveryByTxHashInstruction(
|
||||||
|
|
||||||
const sourceNonce = BigNumber.from(bytes.slice(idx, idx + 32))
|
const sourceNonce = BigNumber.from(bytes.slice(idx, idx + 32))
|
||||||
idx += 32
|
idx += 32
|
||||||
|
|
||||||
const targetChain = bytes.readUInt16BE(idx)
|
const targetChain = bytes.readUInt16BE(idx)
|
||||||
idx += 2
|
idx += 2
|
||||||
|
|
||||||
|
const deliveryIndex = bytes.readUint8(idx)
|
||||||
|
idx += 1
|
||||||
|
|
||||||
|
const multisendIndex = bytes.readUint8(idx)
|
||||||
|
idx += 1
|
||||||
|
|
||||||
// note: confirmed that BigNumber.from(<Buffer>) assumes big endian
|
// note: confirmed that BigNumber.from(<Buffer>) assumes big endian
|
||||||
const newMaximumRefundTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
const newMaximumRefundTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
||||||
idx += 32
|
idx += 32
|
||||||
|
|
||||||
const newApplicationBudgetTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
const newApplicationBudgetTarget = BigNumber.from(bytes.slice(idx, idx + 32))
|
||||||
idx += 32
|
idx += 32
|
||||||
|
|
||||||
const executionParameters = parseExecutionParameters(bytes, idx)
|
const executionParameters = parseExecutionParameters(bytes, idx)
|
||||||
return {
|
return {
|
||||||
payloadId,
|
payloadId,
|
||||||
|
@ -137,6 +149,8 @@ export function parseRedeliveryByTxHashInstruction(
|
||||||
sourceTxHash,
|
sourceTxHash,
|
||||||
sourceNonce,
|
sourceNonce,
|
||||||
targetChain,
|
targetChain,
|
||||||
|
deliveryIndex,
|
||||||
|
multisendIndex,
|
||||||
newMaximumRefundTarget,
|
newMaximumRefundTarget,
|
||||||
newApplicationBudgetTarget,
|
newApplicationBudgetTarget,
|
||||||
executionParameters,
|
executionParameters,
|
||||||
|
|
Loading…
Reference in New Issue