Skip to content

Commit

Permalink
Remove temporary ccipMessage struct used for CR QueryKey
Browse files Browse the repository at this point in the history
  • Loading branch information
ilija42 committed Nov 6, 2024
1 parent 4c9ee21 commit 255fa17
Showing 1 changed file with 2 additions and 52 deletions.
54 changes: 2 additions & 52 deletions pkg/reader/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,56 +276,6 @@ func (r *ccipChainReader) ExecutedMessageRanges(
return executed, nil
}

// Temporary struct to properly deserialize cciptypes.Message before we have support for cciptypes.BigInt
type ccipMessageTokenAmount struct {
SourcePoolAddress cciptypes.UnknownAddress
DestTokenAddress cciptypes.UnknownAddress
ExtraData cciptypes.Bytes
Amount *big.Int
DestExecData cciptypes.Bytes
}

func (t *ccipMessageTokenAmount) ToOnRampToken() cciptypes.RampTokenAmount {
return cciptypes.RampTokenAmount{
SourcePoolAddress: t.SourcePoolAddress,
DestTokenAddress: t.DestTokenAddress,
ExtraData: t.ExtraData,
Amount: cciptypes.NewBigInt(t.Amount),
DestExecData: t.DestExecData,
}
}

type ccipMessage struct {
Header cciptypes.RampMessageHeader
Sender cciptypes.UnknownAddress
Data cciptypes.Bytes
Receiver cciptypes.UnknownAddress
ExtraArgs cciptypes.Bytes
FeeToken cciptypes.UnknownAddress
FeeTokenAmount *big.Int
FeeValueJuels *big.Int
TokenAmounts []ccipMessageTokenAmount
}

func (m *ccipMessage) ToMessage() cciptypes.Message {
tk := make([]cciptypes.RampTokenAmount, len(m.TokenAmounts))
for i := range m.TokenAmounts {
tk[i] = m.TokenAmounts[i].ToOnRampToken()
}

return cciptypes.Message{
Header: m.Header,
Sender: m.Sender,
Data: m.Data,
Receiver: m.Receiver,
ExtraArgs: m.ExtraArgs,
FeeToken: m.FeeToken,
FeeTokenAmount: cciptypes.NewBigInt(m.FeeTokenAmount),
FeeValueJuels: cciptypes.NewBigInt(m.FeeValueJuels),
TokenAmounts: tk,
}
}

func (r *ccipChainReader) MsgsBetweenSeqNums(
ctx context.Context, sourceChainSelector cciptypes.ChainSelector, seqNumRange cciptypes.SeqNumRange,
) ([]cciptypes.Message, error) {
Expand All @@ -340,7 +290,7 @@ func (r *ccipChainReader) MsgsBetweenSeqNums(

type SendRequestedEvent struct {
DestChainSelector cciptypes.ChainSelector
Message ccipMessage
Message cciptypes.Message
}

seq, err := r.contractReaders[sourceChainSelector].ExtendedQueryKey(
Expand Down Expand Up @@ -392,7 +342,7 @@ func (r *ccipChainReader) MsgsBetweenSeqNums(
}

msg.Message.Header.OnRamp = onRampAddress
msgs = append(msgs, msg.Message.ToMessage())
msgs = append(msgs, msg.Message)
}

r.lggr.Infow("decoded messages between sequence numbers", "msgs", msgs,
Expand Down

0 comments on commit 255fa17

Please sign in to comment.