diff --git a/pkg/chains/stellar/proto_helpers.go b/pkg/chains/stellar/proto_helpers.go index eec57bb576..b470817c6e 100644 --- a/pkg/chains/stellar/proto_helpers.go +++ b/pkg/chains/stellar/proto_helpers.go @@ -222,3 +222,117 @@ func ConvertReadContractRequestFromProto(p *ReadContractRequest) (stellar.ReadCo LedgerSequence: p.GetLedgerSequence(), }, nil } + +// ConvertSubmitTransactionRequestToProto converts a domain SubmitTransactionRequest to its proto representation. +func ConvertSubmitTransactionRequestToProto(req stellar.SubmitTransactionRequest) (*SubmitTransactionRequest, error) { + return &SubmitTransactionRequest{ + Id: req.ID, + FromAddress: req.FromAddress, + OperationsXdr: req.OperationsXDR, + LedgerBoundsOffset: req.LedgerBoundsOffset, + }, nil +} + +// ConvertSubmitTransactionRequestFromProto converts a proto SubmitTransactionRequest to the domain type. +func ConvertSubmitTransactionRequestFromProto(p *SubmitTransactionRequest) (stellar.SubmitTransactionRequest, error) { + if p == nil { + return stellar.SubmitTransactionRequest{}, fmt.Errorf("submit transaction request is nil") + } + return stellar.SubmitTransactionRequest{ + ID: p.GetId(), + FromAddress: p.GetFromAddress(), + OperationsXDR: p.GetOperationsXdr(), + LedgerBoundsOffset: p.GetLedgerBoundsOffset(), + }, nil +} + +// ConvertSubmitTransactionResponseToProto converts a domain SubmitTransactionResponse to its proto representation. +func ConvertSubmitTransactionResponseToProto(resp *stellar.SubmitTransactionResponse) (*SubmitTransactionResponse, error) { + if resp == nil { + return nil, fmt.Errorf("submit transaction response is nil") + } + return &SubmitTransactionResponse{ + TxHash: resp.TxHash, + }, nil +} + +// ConvertSubmitTransactionResponseFromProto converts a proto SubmitTransactionResponse to the domain type. +func ConvertSubmitTransactionResponseFromProto(p *SubmitTransactionResponse) (*stellar.SubmitTransactionResponse, error) { + if p == nil { + return nil, fmt.Errorf("submit transaction response is nil") + } + return &stellar.SubmitTransactionResponse{ + TxHash: p.GetTxHash(), + }, nil +} + +// ConvertSimulateTransactionRequestToProto converts a domain SimulateTransactionRequest to its proto representation. +func ConvertSimulateTransactionRequestToProto(req stellar.SimulateTransactionRequest) (*SimulateTransactionRequest, error) { + return &SimulateTransactionRequest{ + FromAddress: req.FromAddress, + OperationsXdr: req.OperationsXDR, + LedgerBoundsOffset: req.LedgerBoundsOffset, + }, nil +} + +// ConvertSimulateTransactionRequestFromProto converts a proto SimulateTransactionRequest to the domain type. +func ConvertSimulateTransactionRequestFromProto(p *SimulateTransactionRequest) (stellar.SimulateTransactionRequest, error) { + if p == nil { + return stellar.SimulateTransactionRequest{}, fmt.Errorf("simulate transaction request is nil") + } + return stellar.SimulateTransactionRequest{ + FromAddress: p.GetFromAddress(), + OperationsXDR: p.GetOperationsXdr(), + LedgerBoundsOffset: p.GetLedgerBoundsOffset(), + }, nil +} + +// ConvertSimulateTransactionResponseToProto converts a domain SimulateTransactionResponse to its proto representation. +func ConvertSimulateTransactionResponseToProto(resp stellar.SimulateTransactionResponse) (*SimulateTransactionResponse, error) { + return &SimulateTransactionResponse{ + Error: resp.Error, + MinResourceFee: resp.MinResourceFee, + Results: resp.Results, + }, nil +} + +// ConvertSimulateTransactionResponseFromProto converts a proto SimulateTransactionResponse to the domain type. +func ConvertSimulateTransactionResponseFromProto(p *SimulateTransactionResponse) (stellar.SimulateTransactionResponse, error) { + if p == nil { + return stellar.SimulateTransactionResponse{}, fmt.Errorf("simulate transaction response is nil") + } + return stellar.SimulateTransactionResponse{ + Error: p.GetError(), + MinResourceFee: p.GetMinResourceFee(), + Results: p.GetResults(), + }, nil +} + +// ConvertTxResultToProto converts a domain TxResult to its proto representation. +func ConvertTxResultToProto(res stellar.TxResult) (*GetTransactionResultResponse, error) { + return &GetTransactionResultResponse{ + Id: res.ID, + Hash: res.Hash, + Status: res.Status, + Fee: res.Fee, + ResultXdr: res.ResultXDR, + ResultMetaXdr: res.ResultMetaXDR, + Error: res.Error, + }, nil +} + +// ConvertTxResultFromProto converts a proto GetTransactionResultResponse to the domain type. +func ConvertTxResultFromProto(p *GetTransactionResultResponse) (stellar.TxResult, error) { + if p == nil { + return stellar.TxResult{}, fmt.Errorf("transaction result response is nil") + } + return stellar.TxResult{ + ID: p.GetId(), + Hash: p.GetHash(), + Status: p.GetStatus(), + Fee: p.GetFee(), + ResultXDR: p.GetResultXdr(), + ResultMetaXDR: p.GetResultMetaXdr(), + Error: p.GetError(), + }, nil +} diff --git a/pkg/chains/stellar/stellar.pb.go b/pkg/chains/stellar/stellar.pb.go index 81f3165fe1..21fab89182 100644 --- a/pkg/chains/stellar/stellar.pb.go +++ b/pkg/chains/stellar/stellar.pb.go @@ -423,6 +423,550 @@ func (x *GetLatestLedgerResponse) GetLedgerMetadataXdr() []byte { return nil } +type SubmitTransactionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + FromAddress string `protobuf:"bytes,2,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` + OperationsXdr []string `protobuf:"bytes,3,rep,name=operations_xdr,json=operationsXdr,proto3" json:"operations_xdr,omitempty"` + LedgerBoundsOffset uint32 `protobuf:"varint,4,opt,name=ledger_bounds_offset,json=ledgerBoundsOffset,proto3" json:"ledger_bounds_offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubmitTransactionRequest) Reset() { + *x = SubmitTransactionRequest{} + mi := &file_stellar_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubmitTransactionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitTransactionRequest) ProtoMessage() {} + +func (x *SubmitTransactionRequest) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitTransactionRequest.ProtoReflect.Descriptor instead. +func (*SubmitTransactionRequest) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{6} +} + +func (x *SubmitTransactionRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *SubmitTransactionRequest) GetFromAddress() string { + if x != nil { + return x.FromAddress + } + return "" +} + +func (x *SubmitTransactionRequest) GetOperationsXdr() []string { + if x != nil { + return x.OperationsXdr + } + return nil +} + +func (x *SubmitTransactionRequest) GetLedgerBoundsOffset() uint32 { + if x != nil { + return x.LedgerBoundsOffset + } + return 0 +} + +type SubmitTransactionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxHash string `protobuf:"bytes,1,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubmitTransactionResponse) Reset() { + *x = SubmitTransactionResponse{} + mi := &file_stellar_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubmitTransactionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubmitTransactionResponse) ProtoMessage() {} + +func (x *SubmitTransactionResponse) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubmitTransactionResponse.ProtoReflect.Descriptor instead. +func (*SubmitTransactionResponse) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{7} +} + +func (x *SubmitTransactionResponse) GetTxHash() string { + if x != nil { + return x.TxHash + } + return "" +} + +type GetTransactionStatusRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TransactionId string `protobuf:"bytes,1,opt,name=transaction_id,json=transactionId,proto3" json:"transaction_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTransactionStatusRequest) Reset() { + *x = GetTransactionStatusRequest{} + mi := &file_stellar_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTransactionStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionStatusRequest) ProtoMessage() {} + +func (x *GetTransactionStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionStatusRequest.ProtoReflect.Descriptor instead. +func (*GetTransactionStatusRequest) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{8} +} + +func (x *GetTransactionStatusRequest) GetTransactionId() string { + if x != nil { + return x.TransactionId + } + return "" +} + +type GetTransactionStatusResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Status int32 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` // Maps to commontypes.TransactionStatus + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTransactionStatusResponse) Reset() { + *x = GetTransactionStatusResponse{} + mi := &file_stellar_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTransactionStatusResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionStatusResponse) ProtoMessage() {} + +func (x *GetTransactionStatusResponse) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionStatusResponse.ProtoReflect.Descriptor instead. +func (*GetTransactionStatusResponse) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{9} +} + +func (x *GetTransactionStatusResponse) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +type SimulateTransactionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` + OperationsXdr []string `protobuf:"bytes,2,rep,name=operations_xdr,json=operationsXdr,proto3" json:"operations_xdr,omitempty"` + LedgerBoundsOffset uint32 `protobuf:"varint,3,opt,name=ledger_bounds_offset,json=ledgerBoundsOffset,proto3" json:"ledger_bounds_offset,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SimulateTransactionRequest) Reset() { + *x = SimulateTransactionRequest{} + mi := &file_stellar_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SimulateTransactionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SimulateTransactionRequest) ProtoMessage() {} + +func (x *SimulateTransactionRequest) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SimulateTransactionRequest.ProtoReflect.Descriptor instead. +func (*SimulateTransactionRequest) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{10} +} + +func (x *SimulateTransactionRequest) GetFromAddress() string { + if x != nil { + return x.FromAddress + } + return "" +} + +func (x *SimulateTransactionRequest) GetOperationsXdr() []string { + if x != nil { + return x.OperationsXdr + } + return nil +} + +func (x *SimulateTransactionRequest) GetLedgerBoundsOffset() uint32 { + if x != nil { + return x.LedgerBoundsOffset + } + return 0 +} + +type SimulateTransactionResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + MinResourceFee int64 `protobuf:"varint,2,opt,name=min_resource_fee,json=minResourceFee,proto3" json:"min_resource_fee,omitempty"` + Results []string `protobuf:"bytes,3,rep,name=results,proto3" json:"results,omitempty"` // XDR-encoded results + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SimulateTransactionResponse) Reset() { + *x = SimulateTransactionResponse{} + mi := &file_stellar_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SimulateTransactionResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SimulateTransactionResponse) ProtoMessage() {} + +func (x *SimulateTransactionResponse) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SimulateTransactionResponse.ProtoReflect.Descriptor instead. +func (*SimulateTransactionResponse) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{11} +} + +func (x *SimulateTransactionResponse) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +func (x *SimulateTransactionResponse) GetMinResourceFee() int64 { + if x != nil { + return x.MinResourceFee + } + return 0 +} + +func (x *SimulateTransactionResponse) GetResults() []string { + if x != nil { + return x.Results + } + return nil +} + +type GetTransactionResultRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TransactionId string `protobuf:"bytes,1,opt,name=transaction_id,json=transactionId,proto3" json:"transaction_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTransactionResultRequest) Reset() { + *x = GetTransactionResultRequest{} + mi := &file_stellar_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTransactionResultRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionResultRequest) ProtoMessage() {} + +func (x *GetTransactionResultRequest) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionResultRequest.ProtoReflect.Descriptor instead. +func (*GetTransactionResultRequest) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{12} +} + +func (x *GetTransactionResultRequest) GetTransactionId() string { + if x != nil { + return x.TransactionId + } + return "" +} + +type GetTransactionResultResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + Status int32 `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty"` // Maps to commontypes.TransactionStatus + Fee int64 `protobuf:"varint,4,opt,name=fee,proto3" json:"fee,omitempty"` + ResultXdr string `protobuf:"bytes,5,opt,name=result_xdr,json=resultXdr,proto3" json:"result_xdr,omitempty"` + ResultMetaXdr string `protobuf:"bytes,6,opt,name=result_meta_xdr,json=resultMetaXdr,proto3" json:"result_meta_xdr,omitempty"` + Error string `protobuf:"bytes,7,opt,name=error,proto3" json:"error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTransactionResultResponse) Reset() { + *x = GetTransactionResultResponse{} + mi := &file_stellar_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTransactionResultResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionResultResponse) ProtoMessage() {} + +func (x *GetTransactionResultResponse) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionResultResponse.ProtoReflect.Descriptor instead. +func (*GetTransactionResultResponse) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{13} +} + +func (x *GetTransactionResultResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *GetTransactionResultResponse) GetHash() string { + if x != nil { + return x.Hash + } + return "" +} + +func (x *GetTransactionResultResponse) GetStatus() int32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *GetTransactionResultResponse) GetFee() int64 { + if x != nil { + return x.Fee + } + return 0 +} + +func (x *GetTransactionResultResponse) GetResultXdr() string { + if x != nil { + return x.ResultXdr + } + return "" +} + +func (x *GetTransactionResultResponse) GetResultMetaXdr() string { + if x != nil { + return x.ResultMetaXdr + } + return "" +} + +func (x *GetTransactionResultResponse) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +type GetTransactionFeeRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + TransactionId string `protobuf:"bytes,1,opt,name=transaction_id,json=transactionId,proto3" json:"transaction_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTransactionFeeRequest) Reset() { + *x = GetTransactionFeeRequest{} + mi := &file_stellar_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTransactionFeeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionFeeRequest) ProtoMessage() {} + +func (x *GetTransactionFeeRequest) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionFeeRequest.ProtoReflect.Descriptor instead. +func (*GetTransactionFeeRequest) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{14} +} + +func (x *GetTransactionFeeRequest) GetTransactionId() string { + if x != nil { + return x.TransactionId + } + return "" +} + +type GetTransactionFeeResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + Fee int64 `protobuf:"varint,1,opt,name=fee,proto3" json:"fee,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTransactionFeeResponse) Reset() { + *x = GetTransactionFeeResponse{} + mi := &file_stellar_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTransactionFeeResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTransactionFeeResponse) ProtoMessage() {} + +func (x *GetTransactionFeeResponse) ProtoReflect() protoreflect.Message { + mi := &file_stellar_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTransactionFeeResponse.ProtoReflect.Descriptor instead. +func (*GetTransactionFeeResponse) Descriptor() ([]byte, []int) { + return file_stellar_proto_rawDescGZIP(), []int{15} +} + +func (x *GetTransactionFeeResponse) GetFee() int64 { + if x != nil { + return x.Fee + } + return 0 +} + var File_stellar_proto protoreflect.FileDescriptor const file_stellar_proto_rawDesc = "" + @@ -456,11 +1000,50 @@ const file_stellar_proto_rawDesc = "" + "\bsequence\x18\x03 \x01(\rR\bsequence\x12*\n" + "\x11ledger_close_time\x18\x04 \x01(\x03R\x0fledgerCloseTime\x12*\n" + "\x11ledger_header_xdr\x18\x05 \x01(\fR\x0fledgerHeaderXdr\x12.\n" + - "\x13ledger_metadata_xdr\x18\x06 \x01(\fR\x11ledgerMetadataXdr2\x95\x02\n" + + "\x13ledger_metadata_xdr\x18\x06 \x01(\fR\x11ledgerMetadataXdr\"\xa6\x01\n" + + "\x18SubmitTransactionRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12!\n" + + "\ffrom_address\x18\x02 \x01(\tR\vfromAddress\x12%\n" + + "\x0eoperations_xdr\x18\x03 \x03(\tR\roperationsXdr\x120\n" + + "\x14ledger_bounds_offset\x18\x04 \x01(\rR\x12ledgerBoundsOffset\"4\n" + + "\x19SubmitTransactionResponse\x12\x17\n" + + "\atx_hash\x18\x01 \x01(\tR\x06txHash\"D\n" + + "\x1bGetTransactionStatusRequest\x12%\n" + + "\x0etransaction_id\x18\x01 \x01(\tR\rtransactionId\"6\n" + + "\x1cGetTransactionStatusResponse\x12\x16\n" + + "\x06status\x18\x01 \x01(\x05R\x06status\"\x98\x01\n" + + "\x1aSimulateTransactionRequest\x12!\n" + + "\ffrom_address\x18\x01 \x01(\tR\vfromAddress\x12%\n" + + "\x0eoperations_xdr\x18\x02 \x03(\tR\roperationsXdr\x120\n" + + "\x14ledger_bounds_offset\x18\x03 \x01(\rR\x12ledgerBoundsOffset\"w\n" + + "\x1bSimulateTransactionResponse\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error\x12(\n" + + "\x10min_resource_fee\x18\x02 \x01(\x03R\x0eminResourceFee\x12\x18\n" + + "\aresults\x18\x03 \x03(\tR\aresults\"D\n" + + "\x1bGetTransactionResultRequest\x12%\n" + + "\x0etransaction_id\x18\x01 \x01(\tR\rtransactionId\"\xc9\x01\n" + + "\x1cGetTransactionResultResponse\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + + "\x04hash\x18\x02 \x01(\tR\x04hash\x12\x16\n" + + "\x06status\x18\x03 \x01(\x05R\x06status\x12\x10\n" + + "\x03fee\x18\x04 \x01(\x03R\x03fee\x12\x1d\n" + + "\n" + + "result_xdr\x18\x05 \x01(\tR\tresultXdr\x12&\n" + + "\x0fresult_meta_xdr\x18\x06 \x01(\tR\rresultMetaXdr\x12\x14\n" + + "\x05error\x18\a \x01(\tR\x05error\"A\n" + + "\x18GetTransactionFeeRequest\x12%\n" + + "\x0etransaction_id\x18\x01 \x01(\tR\rtransactionId\"-\n" + + "\x19GetTransactionFeeResponse\x12\x10\n" + + "\x03fee\x18\x01 \x01(\x03R\x03fee2\xab\x06\n" + "\aStellar\x12a\n" + "\x10GetLedgerEntries\x12%.loop.stellar.GetLedgerEntriesRequest\x1a&.loop.stellar.GetLedgerEntriesResponse\x12P\n" + "\x0fGetLatestLedger\x12\x16.google.protobuf.Empty\x1a%.loop.stellar.GetLatestLedgerResponse\x12U\n" + - "\fReadContract\x12!.loop.stellar.ReadContractRequest\x1a\".loop.stellar.ReadContractResponseBAZ?github.com/smartcontractkit/chainlink-common/pkg/chains/stellarb\x06proto3" + "\fReadContract\x12!.loop.stellar.ReadContractRequest\x1a\".loop.stellar.ReadContractResponse\x12d\n" + + "\x11SubmitTransaction\x12&.loop.stellar.SubmitTransactionRequest\x1a'.loop.stellar.SubmitTransactionResponse\x12m\n" + + "\x14GetTransactionStatus\x12).loop.stellar.GetTransactionStatusRequest\x1a*.loop.stellar.GetTransactionStatusResponse\x12j\n" + + "\x13SimulateTransaction\x12(.loop.stellar.SimulateTransactionRequest\x1a).loop.stellar.SimulateTransactionResponse\x12m\n" + + "\x14GetTransactionResult\x12).loop.stellar.GetTransactionResultRequest\x1a*.loop.stellar.GetTransactionResultResponse\x12d\n" + + "\x11GetTransactionFee\x12&.loop.stellar.GetTransactionFeeRequest\x1a'.loop.stellar.GetTransactionFeeResponseBAZ?github.com/smartcontractkit/chainlink-common/pkg/chains/stellarb\x06proto3" var ( file_stellar_proto_rawDescOnce sync.Once @@ -474,31 +1057,51 @@ func file_stellar_proto_rawDescGZIP() []byte { return file_stellar_proto_rawDescData } -var file_stellar_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_stellar_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_stellar_proto_goTypes = []any{ - (*ReadContractRequest)(nil), // 0: loop.stellar.ReadContractRequest - (*ReadContractResponse)(nil), // 1: loop.stellar.ReadContractResponse - (*GetLedgerEntriesRequest)(nil), // 2: loop.stellar.GetLedgerEntriesRequest - (*LedgerEntryResult)(nil), // 3: loop.stellar.LedgerEntryResult - (*GetLedgerEntriesResponse)(nil), // 4: loop.stellar.GetLedgerEntriesResponse - (*GetLatestLedgerResponse)(nil), // 5: loop.stellar.GetLatestLedgerResponse - (*scval.ScVal)(nil), // 6: capabilities.blockchain.stellar.v1alpha.ScVal - (*emptypb.Empty)(nil), // 7: google.protobuf.Empty + (*ReadContractRequest)(nil), // 0: loop.stellar.ReadContractRequest + (*ReadContractResponse)(nil), // 1: loop.stellar.ReadContractResponse + (*GetLedgerEntriesRequest)(nil), // 2: loop.stellar.GetLedgerEntriesRequest + (*LedgerEntryResult)(nil), // 3: loop.stellar.LedgerEntryResult + (*GetLedgerEntriesResponse)(nil), // 4: loop.stellar.GetLedgerEntriesResponse + (*GetLatestLedgerResponse)(nil), // 5: loop.stellar.GetLatestLedgerResponse + (*SubmitTransactionRequest)(nil), // 6: loop.stellar.SubmitTransactionRequest + (*SubmitTransactionResponse)(nil), // 7: loop.stellar.SubmitTransactionResponse + (*GetTransactionStatusRequest)(nil), // 8: loop.stellar.GetTransactionStatusRequest + (*GetTransactionStatusResponse)(nil), // 9: loop.stellar.GetTransactionStatusResponse + (*SimulateTransactionRequest)(nil), // 10: loop.stellar.SimulateTransactionRequest + (*SimulateTransactionResponse)(nil), // 11: loop.stellar.SimulateTransactionResponse + (*GetTransactionResultRequest)(nil), // 12: loop.stellar.GetTransactionResultRequest + (*GetTransactionResultResponse)(nil), // 13: loop.stellar.GetTransactionResultResponse + (*GetTransactionFeeRequest)(nil), // 14: loop.stellar.GetTransactionFeeRequest + (*GetTransactionFeeResponse)(nil), // 15: loop.stellar.GetTransactionFeeResponse + (*scval.ScVal)(nil), // 16: capabilities.blockchain.stellar.v1alpha.ScVal + (*emptypb.Empty)(nil), // 17: google.protobuf.Empty } var file_stellar_proto_depIdxs = []int32{ - 6, // 0: loop.stellar.ReadContractRequest.args:type_name -> capabilities.blockchain.stellar.v1alpha.ScVal - 3, // 1: loop.stellar.GetLedgerEntriesResponse.entries:type_name -> loop.stellar.LedgerEntryResult - 2, // 2: loop.stellar.Stellar.GetLedgerEntries:input_type -> loop.stellar.GetLedgerEntriesRequest - 7, // 3: loop.stellar.Stellar.GetLatestLedger:input_type -> google.protobuf.Empty - 0, // 4: loop.stellar.Stellar.ReadContract:input_type -> loop.stellar.ReadContractRequest - 4, // 5: loop.stellar.Stellar.GetLedgerEntries:output_type -> loop.stellar.GetLedgerEntriesResponse - 5, // 6: loop.stellar.Stellar.GetLatestLedger:output_type -> loop.stellar.GetLatestLedgerResponse - 1, // 7: loop.stellar.Stellar.ReadContract:output_type -> loop.stellar.ReadContractResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 16, // 0: loop.stellar.ReadContractRequest.args:type_name -> capabilities.blockchain.stellar.v1alpha.ScVal + 3, // 1: loop.stellar.GetLedgerEntriesResponse.entries:type_name -> loop.stellar.LedgerEntryResult + 2, // 2: loop.stellar.Stellar.GetLedgerEntries:input_type -> loop.stellar.GetLedgerEntriesRequest + 17, // 3: loop.stellar.Stellar.GetLatestLedger:input_type -> google.protobuf.Empty + 0, // 4: loop.stellar.Stellar.ReadContract:input_type -> loop.stellar.ReadContractRequest + 6, // 5: loop.stellar.Stellar.SubmitTransaction:input_type -> loop.stellar.SubmitTransactionRequest + 8, // 6: loop.stellar.Stellar.GetTransactionStatus:input_type -> loop.stellar.GetTransactionStatusRequest + 10, // 7: loop.stellar.Stellar.SimulateTransaction:input_type -> loop.stellar.SimulateTransactionRequest + 12, // 8: loop.stellar.Stellar.GetTransactionResult:input_type -> loop.stellar.GetTransactionResultRequest + 14, // 9: loop.stellar.Stellar.GetTransactionFee:input_type -> loop.stellar.GetTransactionFeeRequest + 4, // 10: loop.stellar.Stellar.GetLedgerEntries:output_type -> loop.stellar.GetLedgerEntriesResponse + 5, // 11: loop.stellar.Stellar.GetLatestLedger:output_type -> loop.stellar.GetLatestLedgerResponse + 1, // 12: loop.stellar.Stellar.ReadContract:output_type -> loop.stellar.ReadContractResponse + 7, // 13: loop.stellar.Stellar.SubmitTransaction:output_type -> loop.stellar.SubmitTransactionResponse + 9, // 14: loop.stellar.Stellar.GetTransactionStatus:output_type -> loop.stellar.GetTransactionStatusResponse + 11, // 15: loop.stellar.Stellar.SimulateTransaction:output_type -> loop.stellar.SimulateTransactionResponse + 13, // 16: loop.stellar.Stellar.GetTransactionResult:output_type -> loop.stellar.GetTransactionResultResponse + 15, // 17: loop.stellar.Stellar.GetTransactionFee:output_type -> loop.stellar.GetTransactionFeeResponse + 10, // [10:18] is the sub-list for method output_type + 2, // [2:10] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_stellar_proto_init() } @@ -512,7 +1115,7 @@ func file_stellar_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_stellar_proto_rawDesc), len(file_stellar_proto_rawDesc)), NumEnums: 0, - NumMessages: 6, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/chains/stellar/stellar.proto b/pkg/chains/stellar/stellar.proto index 8142f1ec5d..4220d21f89 100644 --- a/pkg/chains/stellar/stellar.proto +++ b/pkg/chains/stellar/stellar.proto @@ -10,6 +10,11 @@ service Stellar { rpc GetLedgerEntries(GetLedgerEntriesRequest) returns (GetLedgerEntriesResponse); rpc GetLatestLedger(google.protobuf.Empty) returns (GetLatestLedgerResponse); rpc ReadContract(ReadContractRequest) returns (ReadContractResponse); + rpc SubmitTransaction(SubmitTransactionRequest) returns (SubmitTransactionResponse); + rpc GetTransactionStatus(GetTransactionStatusRequest) returns (GetTransactionStatusResponse); + rpc SimulateTransaction(SimulateTransactionRequest) returns (SimulateTransactionResponse); + rpc GetTransactionResult(GetTransactionResultRequest) returns (GetTransactionResultResponse); + rpc GetTransactionFee(GetTransactionFeeRequest) returns (GetTransactionFeeResponse); } // ReadContractRequest invokes a read-only (simulation) Soroban contract function. @@ -59,3 +64,56 @@ message GetLatestLedgerResponse { bytes ledger_header_xdr = 5; // LedgerHeader binary XDR bytes ledger_metadata_xdr = 6; // LedgerCloseMetaV2 binary XDR } + +message SubmitTransactionRequest { + string id = 1; + string from_address = 2; + repeated string operations_xdr = 3; + uint32 ledger_bounds_offset = 4; +} + +message SubmitTransactionResponse { + string tx_hash = 1; +} + +message GetTransactionStatusRequest { + string transaction_id = 1; +} + +message GetTransactionStatusResponse { + int32 status = 1; // Maps to commontypes.TransactionStatus +} + +message SimulateTransactionRequest { + string from_address = 1; + repeated string operations_xdr = 2; + uint32 ledger_bounds_offset = 3; +} + +message SimulateTransactionResponse { + string error = 1; + int64 min_resource_fee = 2; + repeated string results = 3; // XDR-encoded results +} + +message GetTransactionResultRequest { + string transaction_id = 1; +} + +message GetTransactionResultResponse { + string id = 1; + string hash = 2; + int32 status = 3; // Maps to commontypes.TransactionStatus + int64 fee = 4; + string result_xdr = 5; + string result_meta_xdr = 6; + string error = 7; +} + +message GetTransactionFeeRequest { + string transaction_id = 1; +} + +message GetTransactionFeeResponse { + int64 fee = 1; +} diff --git a/pkg/chains/stellar/stellar_grpc.pb.go b/pkg/chains/stellar/stellar_grpc.pb.go index 6c6da20432..0b9dc4a939 100644 --- a/pkg/chains/stellar/stellar_grpc.pb.go +++ b/pkg/chains/stellar/stellar_grpc.pb.go @@ -20,9 +20,14 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Stellar_GetLedgerEntries_FullMethodName = "/loop.stellar.Stellar/GetLedgerEntries" - Stellar_GetLatestLedger_FullMethodName = "/loop.stellar.Stellar/GetLatestLedger" - Stellar_ReadContract_FullMethodName = "/loop.stellar.Stellar/ReadContract" + Stellar_GetLedgerEntries_FullMethodName = "/loop.stellar.Stellar/GetLedgerEntries" + Stellar_GetLatestLedger_FullMethodName = "/loop.stellar.Stellar/GetLatestLedger" + Stellar_ReadContract_FullMethodName = "/loop.stellar.Stellar/ReadContract" + Stellar_SubmitTransaction_FullMethodName = "/loop.stellar.Stellar/SubmitTransaction" + Stellar_GetTransactionStatus_FullMethodName = "/loop.stellar.Stellar/GetTransactionStatus" + Stellar_SimulateTransaction_FullMethodName = "/loop.stellar.Stellar/SimulateTransaction" + Stellar_GetTransactionResult_FullMethodName = "/loop.stellar.Stellar/GetTransactionResult" + Stellar_GetTransactionFee_FullMethodName = "/loop.stellar.Stellar/GetTransactionFee" ) // StellarClient is the client API for Stellar service. @@ -32,6 +37,11 @@ type StellarClient interface { GetLedgerEntries(ctx context.Context, in *GetLedgerEntriesRequest, opts ...grpc.CallOption) (*GetLedgerEntriesResponse, error) GetLatestLedger(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*GetLatestLedgerResponse, error) ReadContract(ctx context.Context, in *ReadContractRequest, opts ...grpc.CallOption) (*ReadContractResponse, error) + SubmitTransaction(ctx context.Context, in *SubmitTransactionRequest, opts ...grpc.CallOption) (*SubmitTransactionResponse, error) + GetTransactionStatus(ctx context.Context, in *GetTransactionStatusRequest, opts ...grpc.CallOption) (*GetTransactionStatusResponse, error) + SimulateTransaction(ctx context.Context, in *SimulateTransactionRequest, opts ...grpc.CallOption) (*SimulateTransactionResponse, error) + GetTransactionResult(ctx context.Context, in *GetTransactionResultRequest, opts ...grpc.CallOption) (*GetTransactionResultResponse, error) + GetTransactionFee(ctx context.Context, in *GetTransactionFeeRequest, opts ...grpc.CallOption) (*GetTransactionFeeResponse, error) } type stellarClient struct { @@ -72,6 +82,56 @@ func (c *stellarClient) ReadContract(ctx context.Context, in *ReadContractReques return out, nil } +func (c *stellarClient) SubmitTransaction(ctx context.Context, in *SubmitTransactionRequest, opts ...grpc.CallOption) (*SubmitTransactionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SubmitTransactionResponse) + err := c.cc.Invoke(ctx, Stellar_SubmitTransaction_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *stellarClient) GetTransactionStatus(ctx context.Context, in *GetTransactionStatusRequest, opts ...grpc.CallOption) (*GetTransactionStatusResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetTransactionStatusResponse) + err := c.cc.Invoke(ctx, Stellar_GetTransactionStatus_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *stellarClient) SimulateTransaction(ctx context.Context, in *SimulateTransactionRequest, opts ...grpc.CallOption) (*SimulateTransactionResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(SimulateTransactionResponse) + err := c.cc.Invoke(ctx, Stellar_SimulateTransaction_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *stellarClient) GetTransactionResult(ctx context.Context, in *GetTransactionResultRequest, opts ...grpc.CallOption) (*GetTransactionResultResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetTransactionResultResponse) + err := c.cc.Invoke(ctx, Stellar_GetTransactionResult_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *stellarClient) GetTransactionFee(ctx context.Context, in *GetTransactionFeeRequest, opts ...grpc.CallOption) (*GetTransactionFeeResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetTransactionFeeResponse) + err := c.cc.Invoke(ctx, Stellar_GetTransactionFee_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // StellarServer is the server API for Stellar service. // All implementations must embed UnimplementedStellarServer // for forward compatibility. @@ -79,6 +139,11 @@ type StellarServer interface { GetLedgerEntries(context.Context, *GetLedgerEntriesRequest) (*GetLedgerEntriesResponse, error) GetLatestLedger(context.Context, *emptypb.Empty) (*GetLatestLedgerResponse, error) ReadContract(context.Context, *ReadContractRequest) (*ReadContractResponse, error) + SubmitTransaction(context.Context, *SubmitTransactionRequest) (*SubmitTransactionResponse, error) + GetTransactionStatus(context.Context, *GetTransactionStatusRequest) (*GetTransactionStatusResponse, error) + SimulateTransaction(context.Context, *SimulateTransactionRequest) (*SimulateTransactionResponse, error) + GetTransactionResult(context.Context, *GetTransactionResultRequest) (*GetTransactionResultResponse, error) + GetTransactionFee(context.Context, *GetTransactionFeeRequest) (*GetTransactionFeeResponse, error) mustEmbedUnimplementedStellarServer() } @@ -98,6 +163,21 @@ func (UnimplementedStellarServer) GetLatestLedger(context.Context, *emptypb.Empt func (UnimplementedStellarServer) ReadContract(context.Context, *ReadContractRequest) (*ReadContractResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ReadContract not implemented") } +func (UnimplementedStellarServer) SubmitTransaction(context.Context, *SubmitTransactionRequest) (*SubmitTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitTransaction not implemented") +} +func (UnimplementedStellarServer) GetTransactionStatus(context.Context, *GetTransactionStatusRequest) (*GetTransactionStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransactionStatus not implemented") +} +func (UnimplementedStellarServer) SimulateTransaction(context.Context, *SimulateTransactionRequest) (*SimulateTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SimulateTransaction not implemented") +} +func (UnimplementedStellarServer) GetTransactionResult(context.Context, *GetTransactionResultRequest) (*GetTransactionResultResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransactionResult not implemented") +} +func (UnimplementedStellarServer) GetTransactionFee(context.Context, *GetTransactionFeeRequest) (*GetTransactionFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransactionFee not implemented") +} func (UnimplementedStellarServer) mustEmbedUnimplementedStellarServer() {} func (UnimplementedStellarServer) testEmbeddedByValue() {} @@ -173,6 +253,96 @@ func _Stellar_ReadContract_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } +func _Stellar_SubmitTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SubmitTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StellarServer).SubmitTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Stellar_SubmitTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StellarServer).SubmitTransaction(ctx, req.(*SubmitTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Stellar_GetTransactionStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTransactionStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StellarServer).GetTransactionStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Stellar_GetTransactionStatus_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StellarServer).GetTransactionStatus(ctx, req.(*GetTransactionStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Stellar_SimulateTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SimulateTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StellarServer).SimulateTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Stellar_SimulateTransaction_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StellarServer).SimulateTransaction(ctx, req.(*SimulateTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Stellar_GetTransactionResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTransactionResultRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StellarServer).GetTransactionResult(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Stellar_GetTransactionResult_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StellarServer).GetTransactionResult(ctx, req.(*GetTransactionResultRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Stellar_GetTransactionFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTransactionFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StellarServer).GetTransactionFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Stellar_GetTransactionFee_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StellarServer).GetTransactionFee(ctx, req.(*GetTransactionFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Stellar_ServiceDesc is the grpc.ServiceDesc for Stellar service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -192,6 +362,26 @@ var Stellar_ServiceDesc = grpc.ServiceDesc{ MethodName: "ReadContract", Handler: _Stellar_ReadContract_Handler, }, + { + MethodName: "SubmitTransaction", + Handler: _Stellar_SubmitTransaction_Handler, + }, + { + MethodName: "GetTransactionStatus", + Handler: _Stellar_GetTransactionStatus_Handler, + }, + { + MethodName: "SimulateTransaction", + Handler: _Stellar_SimulateTransaction_Handler, + }, + { + MethodName: "GetTransactionResult", + Handler: _Stellar_GetTransactionResult_Handler, + }, + { + MethodName: "GetTransactionFee", + Handler: _Stellar_GetTransactionFee_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "stellar.proto", diff --git a/pkg/loop/internal/relayer/stellar.go b/pkg/loop/internal/relayer/stellar.go index cf860995b7..115eb3e5f4 100644 --- a/pkg/loop/internal/relayer/stellar.go +++ b/pkg/loop/internal/relayer/stellar.go @@ -3,6 +3,7 @@ package relayer import ( "context" "fmt" + "math/big" "google.golang.org/protobuf/types/known/emptypb" @@ -68,6 +69,69 @@ func (sc *StellarClient) ReadContract(ctx context.Context, req stellar.ReadContr }, nil } +func (sc *StellarClient) SubmitTransaction(ctx context.Context, req stellar.SubmitTransactionRequest) (*stellar.SubmitTransactionResponse, error) { + pReq, err := stelpb.ConvertSubmitTransactionRequestToProto(req) + if err != nil { + return nil, fmt.Errorf("invalid SubmitTransaction request: %w", err) + } + pResp, err := sc.grpcClient.SubmitTransaction(ctx, pReq) + if err != nil { + return nil, net.WrapRPCErr(err) + } + resp, err := stelpb.ConvertSubmitTransactionResponseFromProto(pResp) + if err != nil { + return nil, fmt.Errorf("invalid SubmitTransaction response: %w", err) + } + return resp, nil +} + +func (sc *StellarClient) GetTransactionStatus(ctx context.Context, transactionID string) (types.TransactionStatus, error) { + pReq := &stelpb.GetTransactionStatusRequest{TransactionId: transactionID} + pResp, err := sc.grpcClient.GetTransactionStatus(ctx, pReq) + if err != nil { + return 0, net.WrapRPCErr(err) + } + return types.TransactionStatus(pResp.GetStatus()), nil +} + +func (sc *StellarClient) SimulateTransaction(ctx context.Context, req stellar.SimulateTransactionRequest) (stellar.SimulateTransactionResponse, error) { + pReq, err := stelpb.ConvertSimulateTransactionRequestToProto(req) + if err != nil { + return stellar.SimulateTransactionResponse{}, fmt.Errorf("invalid SimulateTransaction request: %w", err) + } + pResp, err := sc.grpcClient.SimulateTransaction(ctx, pReq) + if err != nil { + return stellar.SimulateTransactionResponse{}, net.WrapRPCErr(err) + } + resp, err := stelpb.ConvertSimulateTransactionResponseFromProto(pResp) + if err != nil { + return stellar.SimulateTransactionResponse{}, fmt.Errorf("invalid SimulateTransaction response: %w", err) + } + return resp, nil +} + +func (sc *StellarClient) GetTransactionResult(ctx context.Context, transactionID string) (stellar.TxResult, error) { + pReq := &stelpb.GetTransactionResultRequest{TransactionId: transactionID} + pResp, err := sc.grpcClient.GetTransactionResult(ctx, pReq) + if err != nil { + return stellar.TxResult{}, net.WrapRPCErr(err) + } + resp, err := stelpb.ConvertTxResultFromProto(pResp) + if err != nil { + return stellar.TxResult{}, fmt.Errorf("invalid GetTransactionResult response: %w", err) + } + return resp, nil +} + +func (sc *StellarClient) GetTransactionFee(ctx context.Context, transactionID string) (*big.Int, error) { + pReq := &stelpb.GetTransactionFeeRequest{TransactionId: transactionID} + pResp, err := sc.grpcClient.GetTransactionFee(ctx, pReq) + if err != nil { + return nil, net.WrapRPCErr(err) + } + return big.NewInt(pResp.GetFee()), nil +} + // stellarServer wraps types.StellarService and exposes it as a stelpb.StellarServer gRPC endpoint. type stellarServer struct { stelpb.UnimplementedStellarServer @@ -126,3 +190,63 @@ func (s *stellarServer) ReadContract(ctx context.Context, req *stelpb.ReadContra Error: dResp.Error, }, nil } + +func (s *stellarServer) SubmitTransaction(ctx context.Context, req *stelpb.SubmitTransactionRequest) (*stelpb.SubmitTransactionResponse, error) { + dReq, err := stelpb.ConvertSubmitTransactionRequestFromProto(req) + if err != nil { + return nil, fmt.Errorf("invalid SubmitTransaction request: %w", err) + } + dResp, err := s.impl.SubmitTransaction(ctx, dReq) + if err != nil { + return nil, net.WrapRPCErr(err) + } + pResp, err := stelpb.ConvertSubmitTransactionResponseToProto(dResp) + if err != nil { + return nil, fmt.Errorf("invalid SubmitTransaction response: %w", err) + } + return pResp, nil +} + +func (s *stellarServer) GetTransactionStatus(ctx context.Context, req *stelpb.GetTransactionStatusRequest) (*stelpb.GetTransactionStatusResponse, error) { + status, err := s.impl.GetTransactionStatus(ctx, req.GetTransactionId()) + if err != nil { + return nil, net.WrapRPCErr(err) + } + return &stelpb.GetTransactionStatusResponse{Status: int32(status)}, nil +} + +func (s *stellarServer) SimulateTransaction(ctx context.Context, req *stelpb.SimulateTransactionRequest) (*stelpb.SimulateTransactionResponse, error) { + dReq, err := stelpb.ConvertSimulateTransactionRequestFromProto(req) + if err != nil { + return nil, fmt.Errorf("invalid SimulateTransaction request: %w", err) + } + dResp, err := s.impl.SimulateTransaction(ctx, dReq) + if err != nil { + return nil, net.WrapRPCErr(err) + } + pResp, err := stelpb.ConvertSimulateTransactionResponseToProto(dResp) + if err != nil { + return nil, fmt.Errorf("invalid SimulateTransaction response: %w", err) + } + return pResp, nil +} + +func (s *stellarServer) GetTransactionResult(ctx context.Context, req *stelpb.GetTransactionResultRequest) (*stelpb.GetTransactionResultResponse, error) { + dResp, err := s.impl.GetTransactionResult(ctx, req.GetTransactionId()) + if err != nil { + return nil, net.WrapRPCErr(err) + } + pResp, err := stelpb.ConvertTxResultToProto(dResp) + if err != nil { + return nil, fmt.Errorf("invalid GetTransactionResult response: %w", err) + } + return pResp, nil +} + +func (s *stellarServer) GetTransactionFee(ctx context.Context, req *stelpb.GetTransactionFeeRequest) (*stelpb.GetTransactionFeeResponse, error) { + fee, err := s.impl.GetTransactionFee(ctx, req.GetTransactionId()) + if err != nil { + return nil, net.WrapRPCErr(err) + } + return &stelpb.GetTransactionFeeResponse{Fee: fee.Int64()}, nil +} diff --git a/pkg/loop/internal/relayerset/stellar.go b/pkg/loop/internal/relayerset/stellar.go index a8a5a95177..66be0e19ea 100644 --- a/pkg/loop/internal/relayerset/stellar.go +++ b/pkg/loop/internal/relayerset/stellar.go @@ -33,6 +33,26 @@ func (sc *stellarClient) ReadContract(ctx context.Context, in *stelpb.ReadContra return sc.client.ReadContract(appendRelayID(ctx, sc.relayID), in, opts...) } +func (sc *stellarClient) SubmitTransaction(ctx context.Context, in *stelpb.SubmitTransactionRequest, opts ...grpc.CallOption) (*stelpb.SubmitTransactionResponse, error) { + return sc.client.SubmitTransaction(appendRelayID(ctx, sc.relayID), in, opts...) +} + +func (sc *stellarClient) GetTransactionStatus(ctx context.Context, in *stelpb.GetTransactionStatusRequest, opts ...grpc.CallOption) (*stelpb.GetTransactionStatusResponse, error) { + return sc.client.GetTransactionStatus(appendRelayID(ctx, sc.relayID), in, opts...) +} + +func (sc *stellarClient) SimulateTransaction(ctx context.Context, in *stelpb.SimulateTransactionRequest, opts ...grpc.CallOption) (*stelpb.SimulateTransactionResponse, error) { + return sc.client.SimulateTransaction(appendRelayID(ctx, sc.relayID), in, opts...) +} + +func (sc *stellarClient) GetTransactionResult(ctx context.Context, in *stelpb.GetTransactionResultRequest, opts ...grpc.CallOption) (*stelpb.GetTransactionResultResponse, error) { + return sc.client.GetTransactionResult(appendRelayID(ctx, sc.relayID), in, opts...) +} + +func (sc *stellarClient) GetTransactionFee(ctx context.Context, in *stelpb.GetTransactionFeeRequest, opts ...grpc.CallOption) (*stelpb.GetTransactionFeeResponse, error) { + return sc.client.GetTransactionFee(appendRelayID(ctx, sc.relayID), in, opts...) +} + // stellarServer implements stelpb.StellarServer by routing each RPC through the RelayerSet. type stellarServer struct { stelpb.UnimplementedStellarServer @@ -98,6 +118,86 @@ func (ss *stellarServer) ReadContract(ctx context.Context, req *stelpb.ReadContr }, nil } +func (ss *stellarServer) SubmitTransaction(ctx context.Context, req *stelpb.SubmitTransactionRequest) (*stelpb.SubmitTransactionResponse, error) { + svc, err := ss.parent.getStellarService(ctx) + if err != nil { + return nil, err + } + dReq, err := stelpb.ConvertSubmitTransactionRequestFromProto(req) + if err != nil { + return nil, fmt.Errorf("invalid SubmitTransaction request: %w", err) + } + dResp, err := svc.SubmitTransaction(ctx, dReq) + if err != nil { + return nil, net.WrapRPCErr(err) + } + pResp, err := stelpb.ConvertSubmitTransactionResponseToProto(dResp) + if err != nil { + return nil, fmt.Errorf("invalid SubmitTransaction response: %w", err) + } + return pResp, nil +} + +func (ss *stellarServer) GetTransactionStatus(ctx context.Context, req *stelpb.GetTransactionStatusRequest) (*stelpb.GetTransactionStatusResponse, error) { + svc, err := ss.parent.getStellarService(ctx) + if err != nil { + return nil, err + } + status, err := svc.GetTransactionStatus(ctx, req.GetTransactionId()) + if err != nil { + return nil, net.WrapRPCErr(err) + } + return &stelpb.GetTransactionStatusResponse{Status: int32(status)}, nil +} + +func (ss *stellarServer) SimulateTransaction(ctx context.Context, req *stelpb.SimulateTransactionRequest) (*stelpb.SimulateTransactionResponse, error) { + svc, err := ss.parent.getStellarService(ctx) + if err != nil { + return nil, err + } + dReq, err := stelpb.ConvertSimulateTransactionRequestFromProto(req) + if err != nil { + return nil, fmt.Errorf("invalid SimulateTransaction request: %w", err) + } + dResp, err := svc.SimulateTransaction(ctx, dReq) + if err != nil { + return nil, net.WrapRPCErr(err) + } + pResp, err := stelpb.ConvertSimulateTransactionResponseToProto(dResp) + if err != nil { + return nil, fmt.Errorf("invalid SimulateTransaction response: %w", err) + } + return pResp, nil +} + +func (ss *stellarServer) GetTransactionResult(ctx context.Context, req *stelpb.GetTransactionResultRequest) (*stelpb.GetTransactionResultResponse, error) { + svc, err := ss.parent.getStellarService(ctx) + if err != nil { + return nil, err + } + dResp, err := svc.GetTransactionResult(ctx, req.GetTransactionId()) + if err != nil { + return nil, net.WrapRPCErr(err) + } + pResp, err := stelpb.ConvertTxResultToProto(dResp) + if err != nil { + return nil, fmt.Errorf("invalid GetTransactionResult response: %w", err) + } + return pResp, nil +} + +func (ss *stellarServer) GetTransactionFee(ctx context.Context, req *stelpb.GetTransactionFeeRequest) (*stelpb.GetTransactionFeeResponse, error) { + svc, err := ss.parent.getStellarService(ctx) + if err != nil { + return nil, err + } + fee, err := svc.GetTransactionFee(ctx, req.GetTransactionId()) + if err != nil { + return nil, net.WrapRPCErr(err) + } + return &stelpb.GetTransactionFeeResponse{Fee: fee.Int64()}, nil +} + // getStellarService extracts the RelayID from context metadata and returns the StellarService // for the corresponding relayer. func (s *Server) getStellarService(ctx context.Context) (types.StellarService, error) { diff --git a/pkg/types/chains/stellar/stellar.go b/pkg/types/chains/stellar/stellar.go index c8a55d7fc9..35da0faf21 100644 --- a/pkg/types/chains/stellar/stellar.go +++ b/pkg/types/chains/stellar/stellar.go @@ -105,3 +105,41 @@ type RMNConfig struct { // Signers is the ordered list of RMN signers for this config. Signers []RMNSigner } + +// SubmitTransactionRequest represents a request to submit a transaction. +type SubmitTransactionRequest struct { + ID string + FromAddress string + OperationsXDR []string + LedgerBoundsOffset uint32 +} + +// SubmitTransactionResponse represents the response from submitting a transaction. +type SubmitTransactionResponse struct { + TxHash string +} + +// SimulateTransactionRequest represents a request to simulate a transaction. +type SimulateTransactionRequest struct { + FromAddress string + OperationsXDR []string + LedgerBoundsOffset uint32 +} + +// SimulateTransactionResponse represents the response from simulating a transaction. +type SimulateTransactionResponse struct { + Error string + MinResourceFee int64 + Results []string // XDR-encoded results +} + +// TxResult represents the full result of a transaction. +type TxResult struct { + ID string + Hash string + Status int32 // Maps to commontypes.TransactionStatus + Fee int64 // Total fee charged in stroops + ResultXDR string + ResultMetaXDR string + Error string +} diff --git a/pkg/types/mocks/stellar_service.go b/pkg/types/mocks/stellar_service.go index 078dc3dc35..0b2b8a348e 100644 --- a/pkg/types/mocks/stellar_service.go +++ b/pkg/types/mocks/stellar_service.go @@ -4,7 +4,9 @@ package mocks import ( context "context" + big "math/big" + types "github.com/smartcontractkit/chainlink-common/pkg/types" stellar "github.com/smartcontractkit/chainlink-common/pkg/types/chains/stellar" mock "github.com/stretchr/testify/mock" ) @@ -135,6 +137,179 @@ func (_c *StellarService_GetLedgerEntries_Call) RunAndReturn(run func(context.Co return _c } +// GetTransactionFee provides a mock function with given fields: ctx, transactionID +func (_m *StellarService) GetTransactionFee(ctx context.Context, transactionID string) (*big.Int, error) { + ret := _m.Called(ctx, transactionID) + + if len(ret) == 0 { + panic("no return value specified for GetTransactionFee") + } + + var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*big.Int, error)); ok { + return rf(ctx, transactionID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *big.Int); ok { + r0 = rf(ctx, transactionID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*big.Int) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, transactionID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StellarService_GetTransactionFee_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTransactionFee' +type StellarService_GetTransactionFee_Call struct { + *mock.Call +} + +// GetTransactionFee is a helper method to define mock.On call +// - ctx context.Context +// - transactionID string +func (_e *StellarService_Expecter) GetTransactionFee(ctx interface{}, transactionID interface{}) *StellarService_GetTransactionFee_Call { + return &StellarService_GetTransactionFee_Call{Call: _e.mock.On("GetTransactionFee", ctx, transactionID)} +} + +func (_c *StellarService_GetTransactionFee_Call) Run(run func(ctx context.Context, transactionID string)) *StellarService_GetTransactionFee_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *StellarService_GetTransactionFee_Call) Return(_a0 *big.Int, _a1 error) *StellarService_GetTransactionFee_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StellarService_GetTransactionFee_Call) RunAndReturn(run func(context.Context, string) (*big.Int, error)) *StellarService_GetTransactionFee_Call { + _c.Call.Return(run) + return _c +} + +// GetTransactionResult provides a mock function with given fields: ctx, transactionID +func (_m *StellarService) GetTransactionResult(ctx context.Context, transactionID string) (stellar.TxResult, error) { + ret := _m.Called(ctx, transactionID) + + if len(ret) == 0 { + panic("no return value specified for GetTransactionResult") + } + + var r0 stellar.TxResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (stellar.TxResult, error)); ok { + return rf(ctx, transactionID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) stellar.TxResult); ok { + r0 = rf(ctx, transactionID) + } else { + r0 = ret.Get(0).(stellar.TxResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, transactionID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StellarService_GetTransactionResult_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTransactionResult' +type StellarService_GetTransactionResult_Call struct { + *mock.Call +} + +// GetTransactionResult is a helper method to define mock.On call +// - ctx context.Context +// - transactionID string +func (_e *StellarService_Expecter) GetTransactionResult(ctx interface{}, transactionID interface{}) *StellarService_GetTransactionResult_Call { + return &StellarService_GetTransactionResult_Call{Call: _e.mock.On("GetTransactionResult", ctx, transactionID)} +} + +func (_c *StellarService_GetTransactionResult_Call) Run(run func(ctx context.Context, transactionID string)) *StellarService_GetTransactionResult_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *StellarService_GetTransactionResult_Call) Return(_a0 stellar.TxResult, _a1 error) *StellarService_GetTransactionResult_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StellarService_GetTransactionResult_Call) RunAndReturn(run func(context.Context, string) (stellar.TxResult, error)) *StellarService_GetTransactionResult_Call { + _c.Call.Return(run) + return _c +} + +// GetTransactionStatus provides a mock function with given fields: ctx, transactionID +func (_m *StellarService) GetTransactionStatus(ctx context.Context, transactionID string) (types.TransactionStatus, error) { + ret := _m.Called(ctx, transactionID) + + if len(ret) == 0 { + panic("no return value specified for GetTransactionStatus") + } + + var r0 types.TransactionStatus + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (types.TransactionStatus, error)); ok { + return rf(ctx, transactionID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) types.TransactionStatus); ok { + r0 = rf(ctx, transactionID) + } else { + r0 = ret.Get(0).(types.TransactionStatus) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, transactionID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StellarService_GetTransactionStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTransactionStatus' +type StellarService_GetTransactionStatus_Call struct { + *mock.Call +} + +// GetTransactionStatus is a helper method to define mock.On call +// - ctx context.Context +// - transactionID string +func (_e *StellarService_Expecter) GetTransactionStatus(ctx interface{}, transactionID interface{}) *StellarService_GetTransactionStatus_Call { + return &StellarService_GetTransactionStatus_Call{Call: _e.mock.On("GetTransactionStatus", ctx, transactionID)} +} + +func (_c *StellarService_GetTransactionStatus_Call) Run(run func(ctx context.Context, transactionID string)) *StellarService_GetTransactionStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *StellarService_GetTransactionStatus_Call) Return(_a0 types.TransactionStatus, _a1 error) *StellarService_GetTransactionStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StellarService_GetTransactionStatus_Call) RunAndReturn(run func(context.Context, string) (types.TransactionStatus, error)) *StellarService_GetTransactionStatus_Call { + _c.Call.Return(run) + return _c +} + // ReadContract provides a mock function with given fields: ctx, req func (_m *StellarService) ReadContract(ctx context.Context, req stellar.ReadContractRequest) (stellar.ReadContractResponse, error) { ret := _m.Called(ctx, req) @@ -192,6 +367,122 @@ func (_c *StellarService_ReadContract_Call) RunAndReturn(run func(context.Contex return _c } +// SimulateTransaction provides a mock function with given fields: ctx, req +func (_m *StellarService) SimulateTransaction(ctx context.Context, req stellar.SimulateTransactionRequest) (stellar.SimulateTransactionResponse, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for SimulateTransaction") + } + + var r0 stellar.SimulateTransactionResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, stellar.SimulateTransactionRequest) (stellar.SimulateTransactionResponse, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, stellar.SimulateTransactionRequest) stellar.SimulateTransactionResponse); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Get(0).(stellar.SimulateTransactionResponse) + } + + if rf, ok := ret.Get(1).(func(context.Context, stellar.SimulateTransactionRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StellarService_SimulateTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SimulateTransaction' +type StellarService_SimulateTransaction_Call struct { + *mock.Call +} + +// SimulateTransaction is a helper method to define mock.On call +// - ctx context.Context +// - req stellar.SimulateTransactionRequest +func (_e *StellarService_Expecter) SimulateTransaction(ctx interface{}, req interface{}) *StellarService_SimulateTransaction_Call { + return &StellarService_SimulateTransaction_Call{Call: _e.mock.On("SimulateTransaction", ctx, req)} +} + +func (_c *StellarService_SimulateTransaction_Call) Run(run func(ctx context.Context, req stellar.SimulateTransactionRequest)) *StellarService_SimulateTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(stellar.SimulateTransactionRequest)) + }) + return _c +} + +func (_c *StellarService_SimulateTransaction_Call) Return(_a0 stellar.SimulateTransactionResponse, _a1 error) *StellarService_SimulateTransaction_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StellarService_SimulateTransaction_Call) RunAndReturn(run func(context.Context, stellar.SimulateTransactionRequest) (stellar.SimulateTransactionResponse, error)) *StellarService_SimulateTransaction_Call { + _c.Call.Return(run) + return _c +} + +// SubmitTransaction provides a mock function with given fields: ctx, req +func (_m *StellarService) SubmitTransaction(ctx context.Context, req stellar.SubmitTransactionRequest) (*stellar.SubmitTransactionResponse, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for SubmitTransaction") + } + + var r0 *stellar.SubmitTransactionResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, stellar.SubmitTransactionRequest) (*stellar.SubmitTransactionResponse, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, stellar.SubmitTransactionRequest) *stellar.SubmitTransactionResponse); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*stellar.SubmitTransactionResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, stellar.SubmitTransactionRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// StellarService_SubmitTransaction_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubmitTransaction' +type StellarService_SubmitTransaction_Call struct { + *mock.Call +} + +// SubmitTransaction is a helper method to define mock.On call +// - ctx context.Context +// - req stellar.SubmitTransactionRequest +func (_e *StellarService_Expecter) SubmitTransaction(ctx interface{}, req interface{}) *StellarService_SubmitTransaction_Call { + return &StellarService_SubmitTransaction_Call{Call: _e.mock.On("SubmitTransaction", ctx, req)} +} + +func (_c *StellarService_SubmitTransaction_Call) Run(run func(ctx context.Context, req stellar.SubmitTransactionRequest)) *StellarService_SubmitTransaction_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(stellar.SubmitTransactionRequest)) + }) + return _c +} + +func (_c *StellarService_SubmitTransaction_Call) Return(_a0 *stellar.SubmitTransactionResponse, _a1 error) *StellarService_SubmitTransaction_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StellarService_SubmitTransaction_Call) RunAndReturn(run func(context.Context, stellar.SubmitTransactionRequest) (*stellar.SubmitTransactionResponse, error)) *StellarService_SubmitTransaction_Call { + _c.Call.Return(run) + return _c +} + // NewStellarService creates a new instance of StellarService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewStellarService(t interface { diff --git a/pkg/types/relayer.go b/pkg/types/relayer.go index dc5c0f459e..65232d52cb 100644 --- a/pkg/types/relayer.go +++ b/pkg/types/relayer.go @@ -273,6 +273,17 @@ type AptosService interface { // fetch ledger entries and get the latest ledger. type StellarService interface { stellar.Client + + // SubmitTransaction submits a transaction to the network. + SubmitTransaction(ctx context.Context, req stellar.SubmitTransactionRequest) (*stellar.SubmitTransactionResponse, error) + // GetTransactionStatus returns the current status of a transaction. + GetTransactionStatus(ctx context.Context, transactionID string) (TransactionStatus, error) + // SimulateTransaction performs a read-only simulation. + SimulateTransaction(ctx context.Context, req stellar.SimulateTransactionRequest) (stellar.SimulateTransactionResponse, error) + // GetTransactionResult returns the full result of a transaction. + GetTransactionResult(ctx context.Context, transactionID string) (stellar.TxResult, error) + // GetTransactionFee returns the fee charged for a transaction. + GetTransactionFee(ctx context.Context, transactionID string) (*big.Int, error) } // Relayer extends ChainService with providers for each product. @@ -660,3 +671,23 @@ func (u *UnimplementedStellarService) GetLedgerEntries(_ context.Context, _ stel func (u *UnimplementedStellarService) GetLatestLedger(_ context.Context) (stellar.GetLatestLedgerResponse, error) { return stellar.GetLatestLedgerResponse{}, status.Errorf(codes.Unimplemented, "method GetLatestLedger not implemented") } + +func (u *UnimplementedStellarService) SubmitTransaction(_ context.Context, _ stellar.SubmitTransactionRequest) (*stellar.SubmitTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitTransaction not implemented") +} + +func (u *UnimplementedStellarService) GetTransactionStatus(_ context.Context, _ string) (TransactionStatus, error) { + return 0, status.Errorf(codes.Unimplemented, "method GetTransactionStatus not implemented") +} + +func (u *UnimplementedStellarService) SimulateTransaction(_ context.Context, _ stellar.SimulateTransactionRequest) (stellar.SimulateTransactionResponse, error) { + return stellar.SimulateTransactionResponse{}, status.Errorf(codes.Unimplemented, "method SimulateTransaction not implemented") +} + +func (u *UnimplementedStellarService) GetTransactionResult(_ context.Context, _ string) (stellar.TxResult, error) { + return stellar.TxResult{}, status.Errorf(codes.Unimplemented, "method GetTransactionResult not implemented") +} + +func (u *UnimplementedStellarService) GetTransactionFee(_ context.Context, _ string) (*big.Int, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTransactionFee not implemented") +}