From d52648ad5e6327709e8fddd0b906840dd75b3826 Mon Sep 17 00:00:00 2001 From: sherpalden Date: Thu, 12 Dec 2024 13:21:32 +0545 Subject: [PATCH] feat: implement cluster connection recv_message in stellar --- relayer/chains/steller/tx.go | 15 +++++++++++++++ relayer/chains/steller/types/msg.go | 11 +++++++++++ 2 files changed, 26 insertions(+) diff --git a/relayer/chains/steller/tx.go b/relayer/chains/steller/tx.go index 57e882f3..32af2519 100644 --- a/relayer/chains/steller/tx.go +++ b/relayer/chains/steller/tx.go @@ -241,6 +241,21 @@ func (p *Provider) newContractCallArgs(msg relayertypes.Message) (*xdr.InvokeCon stellerMsg.ScvData(), }, }, nil + case evtypes.PacketAcknowledged: + scConnAddr, err := p.scContractAddr(p.cfg.Contracts[relayertypes.ConnectionContract]) + if err != nil { + return nil, err + } + return &xdr.InvokeContractArgs{ + ContractAddress: *scConnAddr, + FunctionName: xdr.ScSymbol("recv_message_with_signatures"), + Args: []xdr.ScVal{ + stellerMsg.ScvSrc(), + stellerMsg.ScvSn(), + stellerMsg.ScvData(), + stellerMsg.ScvSignatures(), + }, + }, nil case evtypes.CallMessage: scXcallAddr, err := p.scContractAddr(p.cfg.Contracts[relayertypes.XcallContract]) if err != nil { diff --git a/relayer/chains/steller/types/msg.go b/relayer/chains/steller/types/msg.go index ebac0f75..8fb144cb 100644 --- a/relayer/chains/steller/types/msg.go +++ b/relayer/chains/steller/types/msg.go @@ -59,3 +59,14 @@ func (m StellerMsg) ScvData() xdr.ScVal { scVal, _ := xdr.NewScVal(xdr.ScValTypeScvBytes, xdr.ScBytes(m.Data)) return scVal } + +func (m StellerMsg) ScvSignatures() xdr.ScVal { + var scSignatures xdr.ScVec + for _, sign := range m.Signatures { + scVal, _ := xdr.NewScVal(xdr.ScValTypeScvBytes, xdr.ScBytes(sign)) + scSignatures = append(scSignatures, scVal) + } + + scValSignatures, _ := xdr.NewScVal(xdr.ScValTypeScvVec, xdr.ScVec(scSignatures)) + return scValSignatures +}