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

Remove temporary ccipMessage struct used for CR QueryKey #302

Merged
merged 2 commits into from
Nov 12, 2024
Merged
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
54 changes: 2 additions & 52 deletions pkg/reader/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,56 +278,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 @@ -342,7 +292,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 @@ -394,7 +344,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
Loading