diff --git a/pkg/capabilities/v2/chain-capabilities/aptos/client.pb.go b/pkg/capabilities/v2/chain-capabilities/aptos/client.pb.go new file mode 100644 index 0000000000..2e3b735ce8 --- /dev/null +++ b/pkg/capabilities/v2/chain-capabilities/aptos/client.pb.go @@ -0,0 +1,452 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.10 +// protoc v5.27.3 +// source: capabilities/blockchain/aptos/v1alpha/client.proto + +package aptos + +import ( + sdk "github.com/smartcontractkit/chainlink-protos/cre/go/sdk" + _ "github.com/smartcontractkit/chainlink-protos/cre/go/tools/generator" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// Transaction status for Aptos write report. +type TxStatus int32 + +const ( + TxStatus_TX_STATUS_UNKNOWN TxStatus = 0 + TxStatus_TX_STATUS_PENDING TxStatus = 1 + TxStatus_TX_STATUS_SUCCESS TxStatus = 2 + TxStatus_TX_STATUS_FAILED TxStatus = 3 +) + +// Enum value maps for TxStatus. +var ( + TxStatus_name = map[int32]string{ + 0: "TX_STATUS_UNKNOWN", + 1: "TX_STATUS_PENDING", + 2: "TX_STATUS_SUCCESS", + 3: "TX_STATUS_FAILED", + } + TxStatus_value = map[string]int32{ + "TX_STATUS_UNKNOWN": 0, + "TX_STATUS_PENDING": 1, + "TX_STATUS_SUCCESS": 2, + "TX_STATUS_FAILED": 3, + } +) + +func (x TxStatus) Enum() *TxStatus { + p := new(TxStatus) + *p = x + return p +} + +func (x TxStatus) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (TxStatus) Descriptor() protoreflect.EnumDescriptor { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_enumTypes[0].Descriptor() +} + +func (TxStatus) Type() protoreflect.EnumType { + return &file_capabilities_blockchain_aptos_v1alpha_client_proto_enumTypes[0] +} + +func (x TxStatus) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use TxStatus.Descriptor instead. +func (TxStatus) EnumDescriptor() ([]byte, []int) { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP(), []int{0} +} + +// Gas configuration for Aptos transactions. +type GasConfig struct { + state protoimpl.MessageState `protogen:"open.v1"` + MaxGasAmount uint64 `protobuf:"varint,1,opt,name=max_gas_amount,json=maxGasAmount,proto3" json:"max_gas_amount,omitempty"` + GasUnitPrice uint64 `protobuf:"varint,2,opt,name=gas_unit_price,json=gasUnitPrice,proto3" json:"gas_unit_price,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GasConfig) Reset() { + *x = GasConfig{} + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GasConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GasConfig) ProtoMessage() {} + +func (x *GasConfig) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[0] + 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 GasConfig.ProtoReflect.Descriptor instead. +func (*GasConfig) Descriptor() ([]byte, []int) { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP(), []int{0} +} + +func (x *GasConfig) GetMaxGasAmount() uint64 { + if x != nil { + return x.MaxGasAmount + } + return 0 +} + +func (x *GasConfig) GetGasUnitPrice() uint64 { + if x != nil { + return x.GasUnitPrice + } + return 0 +} + +// Request to write a signed report to the Aptos chain via the CRE forwarder. +type WriteReportRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Receiver []byte `protobuf:"bytes,1,opt,name=receiver,proto3" json:"receiver,omitempty"` // 32-byte Aptos account address (registry or receiver contract) + Report *sdk.ReportResponse `protobuf:"bytes,2,opt,name=report,proto3" json:"report,omitempty"` + GasConfig *GasConfig `protobuf:"bytes,3,opt,name=gas_config,json=gasConfig,proto3,oneof" json:"gas_config,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WriteReportRequest) Reset() { + *x = WriteReportRequest{} + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WriteReportRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteReportRequest) ProtoMessage() {} + +func (x *WriteReportRequest) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[1] + 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 WriteReportRequest.ProtoReflect.Descriptor instead. +func (*WriteReportRequest) Descriptor() ([]byte, []int) { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP(), []int{1} +} + +func (x *WriteReportRequest) GetReceiver() []byte { + if x != nil { + return x.Receiver + } + return nil +} + +func (x *WriteReportRequest) GetReport() *sdk.ReportResponse { + if x != nil { + return x.Report + } + return nil +} + +func (x *WriteReportRequest) GetGasConfig() *GasConfig { + if x != nil { + return x.GasConfig + } + return nil +} + +// Reply from writing a report to Aptos. +type WriteReportReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + TxStatus TxStatus `protobuf:"varint,1,opt,name=tx_status,json=txStatus,proto3,enum=capabilities.blockchain.aptos.v1alpha.TxStatus" json:"tx_status,omitempty"` + TxHash []byte `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3,oneof" json:"tx_hash,omitempty"` + ErrorMessage *string `protobuf:"bytes,3,opt,name=error_message,json=errorMessage,proto3,oneof" json:"error_message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WriteReportReply) Reset() { + *x = WriteReportReply{} + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WriteReportReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteReportReply) ProtoMessage() {} + +func (x *WriteReportReply) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[2] + 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 WriteReportReply.ProtoReflect.Descriptor instead. +func (*WriteReportReply) Descriptor() ([]byte, []int) { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP(), []int{2} +} + +func (x *WriteReportReply) GetTxStatus() TxStatus { + if x != nil { + return x.TxStatus + } + return TxStatus_TX_STATUS_UNKNOWN +} + +func (x *WriteReportReply) GetTxHash() []byte { + if x != nil { + return x.TxHash + } + return nil +} + +func (x *WriteReportReply) GetErrorMessage() string { + if x != nil && x.ErrorMessage != nil { + return *x.ErrorMessage + } + return "" +} + +// Request to execute a view (read-only) call on the Aptos chain. +// Maps to Aptos REST API POST /v1/view: function (e.g. "0x1::coin::name") and arguments. +type ViewRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Function string `protobuf:"bytes,1,opt,name=function,proto3" json:"function,omitempty"` // Fully qualified function, e.g. "0x1::coin::name" + Arguments [][]byte `protobuf:"bytes,2,rep,name=arguments,proto3" json:"arguments,omitempty"` // BCS- or JSON-encoded arguments; empty for no args + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ViewRequest) Reset() { + *x = ViewRequest{} + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ViewRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ViewRequest) ProtoMessage() {} + +func (x *ViewRequest) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[3] + 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 ViewRequest.ProtoReflect.Descriptor instead. +func (*ViewRequest) Descriptor() ([]byte, []int) { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP(), []int{3} +} + +func (x *ViewRequest) GetFunction() string { + if x != nil { + return x.Function + } + return "" +} + +func (x *ViewRequest) GetArguments() [][]byte { + if x != nil { + return x.Arguments + } + return nil +} + +// Reply from a view call. Data is the raw response (e.g. JSON array from Aptos view API). +type ViewReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ViewReply) Reset() { + *x = ViewReply{} + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ViewReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ViewReply) ProtoMessage() {} + +func (x *ViewReply) ProtoReflect() protoreflect.Message { + mi := &file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[4] + 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 ViewReply.ProtoReflect.Descriptor instead. +func (*ViewReply) Descriptor() ([]byte, []int) { + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP(), []int{4} +} + +func (x *ViewReply) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +var File_capabilities_blockchain_aptos_v1alpha_client_proto protoreflect.FileDescriptor + +const file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDesc = "" + + "\n" + + "2capabilities/blockchain/aptos/v1alpha/client.proto\x12%capabilities.blockchain.aptos.v1alpha\x1a\x15sdk/v1alpha/sdk.proto\x1a*tools/generator/v1alpha/cre_metadata.proto\"W\n" + + "\tGasConfig\x12$\n" + + "\x0emax_gas_amount\x18\x01 \x01(\x04R\fmaxGasAmount\x12$\n" + + "\x0egas_unit_price\x18\x02 \x01(\x04R\fgasUnitPrice\"\xca\x01\n" + + "\x12WriteReportRequest\x12\x1a\n" + + "\breceiver\x18\x01 \x01(\fR\breceiver\x123\n" + + "\x06report\x18\x02 \x01(\v2\x1b.sdk.v1alpha.ReportResponseR\x06report\x12T\n" + + "\n" + + "gas_config\x18\x03 \x01(\v20.capabilities.blockchain.aptos.v1alpha.GasConfigH\x00R\tgasConfig\x88\x01\x01B\r\n" + + "\v_gas_config\"\xc6\x01\n" + + "\x10WriteReportReply\x12L\n" + + "\ttx_status\x18\x01 \x01(\x0e2/.capabilities.blockchain.aptos.v1alpha.TxStatusR\btxStatus\x12\x1c\n" + + "\atx_hash\x18\x02 \x01(\fH\x00R\x06txHash\x88\x01\x01\x12(\n" + + "\rerror_message\x18\x03 \x01(\tH\x01R\ferrorMessage\x88\x01\x01B\n" + + "\n" + + "\b_tx_hashB\x10\n" + + "\x0e_error_message\"G\n" + + "\vViewRequest\x12\x1a\n" + + "\bfunction\x18\x01 \x01(\tR\bfunction\x12\x1c\n" + + "\targuments\x18\x02 \x03(\fR\targuments\"\x1f\n" + + "\tViewReply\x12\x12\n" + + "\x04data\x18\x01 \x01(\fR\x04data*e\n" + + "\bTxStatus\x12\x15\n" + + "\x11TX_STATUS_UNKNOWN\x10\x00\x12\x15\n" + + "\x11TX_STATUS_PENDING\x10\x01\x12\x15\n" + + "\x11TX_STATUS_SUCCESS\x10\x02\x12\x14\n" + + "\x10TX_STATUS_FAILED\x10\x032\xa4\x02\n" + + "\x06Client\x12\x81\x01\n" + + "\vWriteReport\x129.capabilities.blockchain.aptos.v1alpha.WriteReportRequest\x1a7.capabilities.blockchain.aptos.v1alpha.WriteReportReply\x12l\n" + + "\x04View\x122.capabilities.blockchain.aptos.v1alpha.ViewRequest\x1a0.capabilities.blockchain.aptos.v1alpha.ViewReply\x1a(\x82\xb5\x18$\b\x01\x12\vaptos@1.0.0\x1a\x13\n" + + "\rChainSelector\x12\x02\x12\x00b\x06proto3" + +var ( + file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescOnce sync.Once + file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescData []byte +) + +func file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescGZIP() []byte { + file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescOnce.Do(func() { + file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDesc), len(file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDesc))) + }) + return file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDescData +} + +var file_capabilities_blockchain_aptos_v1alpha_client_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_capabilities_blockchain_aptos_v1alpha_client_proto_goTypes = []any{ + (TxStatus)(0), // 0: capabilities.blockchain.aptos.v1alpha.TxStatus + (*GasConfig)(nil), // 1: capabilities.blockchain.aptos.v1alpha.GasConfig + (*WriteReportRequest)(nil), // 2: capabilities.blockchain.aptos.v1alpha.WriteReportRequest + (*WriteReportReply)(nil), // 3: capabilities.blockchain.aptos.v1alpha.WriteReportReply + (*ViewRequest)(nil), // 4: capabilities.blockchain.aptos.v1alpha.ViewRequest + (*ViewReply)(nil), // 5: capabilities.blockchain.aptos.v1alpha.ViewReply + (*sdk.ReportResponse)(nil), // 6: sdk.v1alpha.ReportResponse +} +var file_capabilities_blockchain_aptos_v1alpha_client_proto_depIdxs = []int32{ + 6, // 0: capabilities.blockchain.aptos.v1alpha.WriteReportRequest.report:type_name -> sdk.v1alpha.ReportResponse + 1, // 1: capabilities.blockchain.aptos.v1alpha.WriteReportRequest.gas_config:type_name -> capabilities.blockchain.aptos.v1alpha.GasConfig + 0, // 2: capabilities.blockchain.aptos.v1alpha.WriteReportReply.tx_status:type_name -> capabilities.blockchain.aptos.v1alpha.TxStatus + 2, // 3: capabilities.blockchain.aptos.v1alpha.Client.WriteReport:input_type -> capabilities.blockchain.aptos.v1alpha.WriteReportRequest + 4, // 4: capabilities.blockchain.aptos.v1alpha.Client.View:input_type -> capabilities.blockchain.aptos.v1alpha.ViewRequest + 3, // 5: capabilities.blockchain.aptos.v1alpha.Client.WriteReport:output_type -> capabilities.blockchain.aptos.v1alpha.WriteReportReply + 5, // 6: capabilities.blockchain.aptos.v1alpha.Client.View:output_type -> capabilities.blockchain.aptos.v1alpha.ViewReply + 5, // [5:7] is the sub-list for method output_type + 3, // [3:5] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_capabilities_blockchain_aptos_v1alpha_client_proto_init() } +func file_capabilities_blockchain_aptos_v1alpha_client_proto_init() { + if File_capabilities_blockchain_aptos_v1alpha_client_proto != nil { + return + } + file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[1].OneofWrappers = []any{} + file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes[2].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDesc), len(file_capabilities_blockchain_aptos_v1alpha_client_proto_rawDesc)), + NumEnums: 1, + NumMessages: 5, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_capabilities_blockchain_aptos_v1alpha_client_proto_goTypes, + DependencyIndexes: file_capabilities_blockchain_aptos_v1alpha_client_proto_depIdxs, + EnumInfos: file_capabilities_blockchain_aptos_v1alpha_client_proto_enumTypes, + MessageInfos: file_capabilities_blockchain_aptos_v1alpha_client_proto_msgTypes, + }.Build() + File_capabilities_blockchain_aptos_v1alpha_client_proto = out.File + file_capabilities_blockchain_aptos_v1alpha_client_proto_goTypes = nil + file_capabilities_blockchain_aptos_v1alpha_client_proto_depIdxs = nil +} diff --git a/pkg/capabilities/v2/chain-capabilities/aptos/generate.go b/pkg/capabilities/v2/chain-capabilities/aptos/generate.go new file mode 100644 index 0000000000..22f6184035 --- /dev/null +++ b/pkg/capabilities/v2/chain-capabilities/aptos/generate.go @@ -0,0 +1,6 @@ +// After changing the Aptos capability proto (e.g. adding the View RPC), run: +// go generate . +// from this directory so that client.pb.go and server/client_server_gen.go are regenerated +// (same codegen path as EVM/Solana; do not hand-edit the generated server). +//go:generate go run ../../gen --pkg=github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/chain-capabilities/aptos --file=capabilities/blockchain/aptos/v1alpha/client.proto +package aptos diff --git a/pkg/capabilities/v2/chain-capabilities/aptos/server/client_server_gen.go b/pkg/capabilities/v2/chain-capabilities/aptos/server/client_server_gen.go new file mode 100644 index 0000000000..ab62b781c5 --- /dev/null +++ b/pkg/capabilities/v2/chain-capabilities/aptos/server/client_server_gen.go @@ -0,0 +1,157 @@ +// Code generated by github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/protoc, DO NOT EDIT. + +package server + +import ( + "context" + "fmt" + "strconv" + "time" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities/v2/chain-capabilities/aptos" + "google.golang.org/protobuf/types/known/emptypb" + + "github.com/smartcontractkit/chainlink-common/pkg/capabilities" + caperrors "github.com/smartcontractkit/chainlink-common/pkg/capabilities/errors" + "github.com/smartcontractkit/chainlink-common/pkg/types/core" +) + +// Avoid unused imports if there is configuration type +var _ = emptypb.Empty{} + +type ClientCapability interface { + WriteReport(ctx context.Context, metadata capabilities.RequestMetadata, input *aptos.WriteReportRequest) (*capabilities.ResponseAndMetadata[*aptos.WriteReportReply], caperrors.Error) + + View(ctx context.Context, metadata capabilities.RequestMetadata, input *aptos.ViewRequest) (*capabilities.ResponseAndMetadata[*aptos.ViewReply], caperrors.Error) + + ChainSelector() uint64 + + Start(ctx context.Context) error + Close() error + HealthReport() map[string]error + Name() string + Description() string + Ready() error + Initialise(ctx context.Context, dependencies core.StandardCapabilitiesDependencies) error +} + +func NewClientServer(capability ClientCapability) *ClientServer { + stopCh := make(chan struct{}) + return &ClientServer{ + clientCapability: clientCapability{ClientCapability: capability, stopCh: stopCh}, + stopCh: stopCh, + } +} + +type ClientServer struct { + clientCapability + capabilityRegistry core.CapabilitiesRegistry + stopCh chan struct{} +} + +func (c *ClientServer) Initialise(ctx context.Context, dependencies core.StandardCapabilitiesDependencies) error { + if err := c.ClientCapability.Initialise(ctx, dependencies); err != nil { + return fmt.Errorf("error when initializing capability: %w", err) + } + + c.capabilityRegistry = dependencies.CapabilityRegistry + + if err := dependencies.CapabilityRegistry.Add(ctx, &clientCapability{ + ClientCapability: c.ClientCapability, + }); err != nil { + return fmt.Errorf("error when adding %s to the registry: %w", "aptos"+":ChainSelector:"+strconv.FormatUint(c.ChainSelector(), 10)+"@1.0.0", err) + } + + return nil +} + +func (c *ClientServer) Close() error { + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + if c.capabilityRegistry != nil { + if err := c.capabilityRegistry.Remove(ctx, "aptos"+":ChainSelector:"+strconv.FormatUint(c.ChainSelector(), 10)+"@1.0.0"); err != nil { + return err + } + } + + if c.stopCh != nil { + close(c.stopCh) + } + + return c.clientCapability.Close() +} + +func (c *ClientServer) Infos(ctx context.Context) ([]capabilities.CapabilityInfo, error) { + info, err := c.clientCapability.Info(ctx) + if err != nil { + return nil, err + } + return []capabilities.CapabilityInfo{info}, nil +} + +type clientCapability struct { + ClientCapability + stopCh chan struct{} +} + +func (c *clientCapability) Info(ctx context.Context) (capabilities.CapabilityInfo, error) { + // Maybe we do need to split it out, even if the user doesn't see it + return capabilities.NewCapabilityInfo("aptos"+":ChainSelector:"+strconv.FormatUint(c.ChainSelector(), 10)+"@1.0.0", capabilities.CapabilityTypeCombined, c.ClientCapability.Description()) +} + +var _ capabilities.ExecutableAndTriggerCapability = (*clientCapability)(nil) + +const ClientID = "aptos@1.0.0" + +func (c *clientCapability) RegisterTrigger(ctx context.Context, request capabilities.TriggerRegistrationRequest) (<-chan capabilities.TriggerResponse, error) { + return nil, fmt.Errorf("trigger %s not found", request.Method) +} + +func (c *clientCapability) UnregisterTrigger(ctx context.Context, request capabilities.TriggerRegistrationRequest) error { + return fmt.Errorf("trigger %s not found", request.Method) +} + +func (c *clientCapability) RegisterToWorkflow(ctx context.Context, request capabilities.RegisterToWorkflowRequest) error { + return nil +} + +func (c *clientCapability) UnregisterFromWorkflow(ctx context.Context, request capabilities.UnregisterFromWorkflowRequest) error { + return nil +} + +func (c *clientCapability) Execute(ctx context.Context, request capabilities.CapabilityRequest) (capabilities.CapabilityResponse, error) { + response := capabilities.CapabilityResponse{} + switch request.Method { + case "WriteReport": + input := &aptos.WriteReportRequest{} + config := &emptypb.Empty{} + wrapped := func(ctx context.Context, metadata capabilities.RequestMetadata, input *aptos.WriteReportRequest, _ *emptypb.Empty) (*aptos.WriteReportReply, capabilities.ResponseMetadata, error) { + output, err := c.ClientCapability.WriteReport(ctx, metadata, input) + if err != nil { + return nil, capabilities.ResponseMetadata{}, err + } + if output == nil { + return nil, capabilities.ResponseMetadata{}, fmt.Errorf("output and error is nil for method WriteReport(..) (if output is nil error must be present)") + } + return output.Response, output.ResponseMetadata, err + } + return capabilities.Execute(ctx, request, input, config, wrapped) + case "View": + input := &aptos.ViewRequest{} + config := &emptypb.Empty{} + wrapped := func(ctx context.Context, metadata capabilities.RequestMetadata, input *aptos.ViewRequest, _ *emptypb.Empty) (*aptos.ViewReply, capabilities.ResponseMetadata, error) { + output, err := c.ClientCapability.View(ctx, metadata, input) + if err != nil { + return nil, capabilities.ResponseMetadata{}, err + } + if output == nil { + return nil, capabilities.ResponseMetadata{}, fmt.Errorf("output and error is nil for method View(..) (if output is nil error must be present)") + } + return output.Response, output.ResponseMetadata, err + } + return capabilities.Execute(ctx, request, input, config, wrapped) + default: + return response, fmt.Errorf("method %s not found", request.Method) + } +} diff --git a/pkg/chains/aptos/aptos.pb.go b/pkg/chains/aptos/aptos.pb.go index a37b6c2daf..7bccb0c4c3 100644 --- a/pkg/chains/aptos/aptos.pb.go +++ b/pkg/chains/aptos/aptos.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.11 -// protoc v5.29.3 +// protoc-gen-go v1.36.10 +// protoc v5.27.3 // source: aptos.proto package aptos @@ -161,6 +161,86 @@ func (TransactionVariant) EnumDescriptor() ([]byte, []int) { return file_aptos_proto_rawDescGZIP(), []int{1} } +type LedgerVersionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LedgerVersionRequest) Reset() { + *x = LedgerVersionRequest{} + mi := &file_aptos_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LedgerVersionRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LedgerVersionRequest) ProtoMessage() {} + +func (x *LedgerVersionRequest) ProtoReflect() protoreflect.Message { + mi := &file_aptos_proto_msgTypes[0] + 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 LedgerVersionRequest.ProtoReflect.Descriptor instead. +func (*LedgerVersionRequest) Descriptor() ([]byte, []int) { + return file_aptos_proto_rawDescGZIP(), []int{0} +} + +type LedgerVersionReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + LedgerVersion uint64 `protobuf:"varint,1,opt,name=ledger_version,json=ledgerVersion,proto3" json:"ledger_version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *LedgerVersionReply) Reset() { + *x = LedgerVersionReply{} + mi := &file_aptos_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LedgerVersionReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LedgerVersionReply) ProtoMessage() {} + +func (x *LedgerVersionReply) ProtoReflect() protoreflect.Message { + mi := &file_aptos_proto_msgTypes[1] + 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 LedgerVersionReply.ProtoReflect.Descriptor instead. +func (*LedgerVersionReply) Descriptor() ([]byte, []int) { + return file_aptos_proto_rawDescGZIP(), []int{1} +} + +func (x *LedgerVersionReply) GetLedgerVersion() uint64 { + if x != nil { + return x.LedgerVersion + } + return 0 +} + type AccountAPTBalanceRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // 32-byte address @@ -170,7 +250,7 @@ type AccountAPTBalanceRequest struct { func (x *AccountAPTBalanceRequest) Reset() { *x = AccountAPTBalanceRequest{} - mi := &file_aptos_proto_msgTypes[0] + mi := &file_aptos_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -182,7 +262,7 @@ func (x *AccountAPTBalanceRequest) String() string { func (*AccountAPTBalanceRequest) ProtoMessage() {} func (x *AccountAPTBalanceRequest) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[0] + mi := &file_aptos_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -195,7 +275,7 @@ func (x *AccountAPTBalanceRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AccountAPTBalanceRequest.ProtoReflect.Descriptor instead. func (*AccountAPTBalanceRequest) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{0} + return file_aptos_proto_rawDescGZIP(), []int{2} } func (x *AccountAPTBalanceRequest) GetAddress() []byte { @@ -214,7 +294,7 @@ type AccountAPTBalanceReply struct { func (x *AccountAPTBalanceReply) Reset() { *x = AccountAPTBalanceReply{} - mi := &file_aptos_proto_msgTypes[1] + mi := &file_aptos_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -226,7 +306,7 @@ func (x *AccountAPTBalanceReply) String() string { func (*AccountAPTBalanceReply) ProtoMessage() {} func (x *AccountAPTBalanceReply) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[1] + mi := &file_aptos_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -239,7 +319,7 @@ func (x *AccountAPTBalanceReply) ProtoReflect() protoreflect.Message { // Deprecated: Use AccountAPTBalanceReply.ProtoReflect.Descriptor instead. func (*AccountAPTBalanceReply) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{1} + return file_aptos_proto_rawDescGZIP(), []int{3} } func (x *AccountAPTBalanceReply) GetValue() uint64 { @@ -249,16 +329,121 @@ func (x *AccountAPTBalanceReply) GetValue() uint64 { return 0 } +type AccountTransactionsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // 32-byte account address + Start *uint64 `protobuf:"varint,2,opt,name=start,proto3,oneof" json:"start,omitempty"` // optional start sequence + Limit *uint64 `protobuf:"varint,3,opt,name=limit,proto3,oneof" json:"limit,omitempty"` // optional page size + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AccountTransactionsRequest) Reset() { + *x = AccountTransactionsRequest{} + mi := &file_aptos_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AccountTransactionsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccountTransactionsRequest) ProtoMessage() {} + +func (x *AccountTransactionsRequest) ProtoReflect() protoreflect.Message { + mi := &file_aptos_proto_msgTypes[4] + 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 AccountTransactionsRequest.ProtoReflect.Descriptor instead. +func (*AccountTransactionsRequest) Descriptor() ([]byte, []int) { + return file_aptos_proto_rawDescGZIP(), []int{4} +} + +func (x *AccountTransactionsRequest) GetAddress() []byte { + if x != nil { + return x.Address + } + return nil +} + +func (x *AccountTransactionsRequest) GetStart() uint64 { + if x != nil && x.Start != nil { + return *x.Start + } + return 0 +} + +func (x *AccountTransactionsRequest) GetLimit() uint64 { + if x != nil && x.Limit != nil { + return *x.Limit + } + return 0 +} + +type AccountTransactionsReply struct { + state protoimpl.MessageState `protogen:"open.v1"` + Transactions []*Transaction `protobuf:"bytes,1,rep,name=transactions,proto3" json:"transactions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *AccountTransactionsReply) Reset() { + *x = AccountTransactionsReply{} + mi := &file_aptos_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *AccountTransactionsReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AccountTransactionsReply) ProtoMessage() {} + +func (x *AccountTransactionsReply) ProtoReflect() protoreflect.Message { + mi := &file_aptos_proto_msgTypes[5] + 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 AccountTransactionsReply.ProtoReflect.Descriptor instead. +func (*AccountTransactionsReply) Descriptor() ([]byte, []int) { + return file_aptos_proto_rawDescGZIP(), []int{5} +} + +func (x *AccountTransactionsReply) GetTransactions() []*Transaction { + if x != nil { + return x.Transactions + } + return nil +} + type ViewRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Payload *ViewPayload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + LedgerVersion *uint64 `protobuf:"varint,2,opt,name=ledger_version,json=ledgerVersion,proto3,oneof" json:"ledger_version,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ViewRequest) Reset() { *x = ViewRequest{} - mi := &file_aptos_proto_msgTypes[2] + mi := &file_aptos_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -270,7 +455,7 @@ func (x *ViewRequest) String() string { func (*ViewRequest) ProtoMessage() {} func (x *ViewRequest) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[2] + mi := &file_aptos_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -283,7 +468,7 @@ func (x *ViewRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ViewRequest.ProtoReflect.Descriptor instead. func (*ViewRequest) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{2} + return file_aptos_proto_rawDescGZIP(), []int{6} } func (x *ViewRequest) GetPayload() *ViewPayload { @@ -293,6 +478,13 @@ func (x *ViewRequest) GetPayload() *ViewPayload { return nil } +func (x *ViewRequest) GetLedgerVersion() uint64 { + if x != nil && x.LedgerVersion != nil { + return *x.LedgerVersion + } + return 0 +} + type ViewReply struct { state protoimpl.MessageState `protogen:"open.v1"` Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` @@ -302,7 +494,7 @@ type ViewReply struct { func (x *ViewReply) Reset() { *x = ViewReply{} - mi := &file_aptos_proto_msgTypes[3] + mi := &file_aptos_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -314,7 +506,7 @@ func (x *ViewReply) String() string { func (*ViewReply) ProtoMessage() {} func (x *ViewReply) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[3] + mi := &file_aptos_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -327,7 +519,7 @@ func (x *ViewReply) ProtoReflect() protoreflect.Message { // Deprecated: Use ViewReply.ProtoReflect.Descriptor instead. func (*ViewReply) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{3} + return file_aptos_proto_rawDescGZIP(), []int{7} } func (x *ViewReply) GetData() []byte { @@ -349,7 +541,7 @@ type ViewPayload struct { func (x *ViewPayload) Reset() { *x = ViewPayload{} - mi := &file_aptos_proto_msgTypes[4] + mi := &file_aptos_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -361,7 +553,7 @@ func (x *ViewPayload) String() string { func (*ViewPayload) ProtoMessage() {} func (x *ViewPayload) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[4] + mi := &file_aptos_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -374,7 +566,7 @@ func (x *ViewPayload) ProtoReflect() protoreflect.Message { // Deprecated: Use ViewPayload.ProtoReflect.Descriptor instead. func (*ViewPayload) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{4} + return file_aptos_proto_rawDescGZIP(), []int{8} } func (x *ViewPayload) GetModule() *ModuleID { @@ -415,7 +607,7 @@ type ModuleID struct { func (x *ModuleID) Reset() { *x = ModuleID{} - mi := &file_aptos_proto_msgTypes[5] + mi := &file_aptos_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -427,7 +619,7 @@ func (x *ModuleID) String() string { func (*ModuleID) ProtoMessage() {} func (x *ModuleID) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[5] + mi := &file_aptos_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -440,7 +632,7 @@ func (x *ModuleID) ProtoReflect() protoreflect.Message { // Deprecated: Use ModuleID.ProtoReflect.Descriptor instead. func (*ModuleID) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{5} + return file_aptos_proto_rawDescGZIP(), []int{9} } func (x *ModuleID) GetAddress() []byte { @@ -472,7 +664,7 @@ type TypeTag struct { func (x *TypeTag) Reset() { *x = TypeTag{} - mi := &file_aptos_proto_msgTypes[6] + mi := &file_aptos_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -484,7 +676,7 @@ func (x *TypeTag) String() string { func (*TypeTag) ProtoMessage() {} func (x *TypeTag) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[6] + mi := &file_aptos_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -497,7 +689,7 @@ func (x *TypeTag) ProtoReflect() protoreflect.Message { // Deprecated: Use TypeTag.ProtoReflect.Descriptor instead. func (*TypeTag) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{6} + return file_aptos_proto_rawDescGZIP(), []int{10} } func (x *TypeTag) GetType() TypeTagType { @@ -572,7 +764,7 @@ type VectorTag struct { func (x *VectorTag) Reset() { *x = VectorTag{} - mi := &file_aptos_proto_msgTypes[7] + mi := &file_aptos_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -584,7 +776,7 @@ func (x *VectorTag) String() string { func (*VectorTag) ProtoMessage() {} func (x *VectorTag) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[7] + mi := &file_aptos_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -597,7 +789,7 @@ func (x *VectorTag) ProtoReflect() protoreflect.Message { // Deprecated: Use VectorTag.ProtoReflect.Descriptor instead. func (*VectorTag) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{7} + return file_aptos_proto_rawDescGZIP(), []int{11} } func (x *VectorTag) GetElementType() *TypeTag { @@ -619,7 +811,7 @@ type StructTag struct { func (x *StructTag) Reset() { *x = StructTag{} - mi := &file_aptos_proto_msgTypes[8] + mi := &file_aptos_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -631,7 +823,7 @@ func (x *StructTag) String() string { func (*StructTag) ProtoMessage() {} func (x *StructTag) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[8] + mi := &file_aptos_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -644,7 +836,7 @@ func (x *StructTag) ProtoReflect() protoreflect.Message { // Deprecated: Use StructTag.ProtoReflect.Descriptor instead. func (*StructTag) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{8} + return file_aptos_proto_rawDescGZIP(), []int{12} } func (x *StructTag) GetAddress() []byte { @@ -684,7 +876,7 @@ type GenericTag struct { func (x *GenericTag) Reset() { *x = GenericTag{} - mi := &file_aptos_proto_msgTypes[9] + mi := &file_aptos_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -696,7 +888,7 @@ func (x *GenericTag) String() string { func (*GenericTag) ProtoMessage() {} func (x *GenericTag) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[9] + mi := &file_aptos_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -709,7 +901,7 @@ func (x *GenericTag) ProtoReflect() protoreflect.Message { // Deprecated: Use GenericTag.ProtoReflect.Descriptor instead. func (*GenericTag) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{9} + return file_aptos_proto_rawDescGZIP(), []int{13} } func (x *GenericTag) GetIndex() uint32 { @@ -732,7 +924,7 @@ type EventsByHandleRequest struct { func (x *EventsByHandleRequest) Reset() { *x = EventsByHandleRequest{} - mi := &file_aptos_proto_msgTypes[10] + mi := &file_aptos_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -744,7 +936,7 @@ func (x *EventsByHandleRequest) String() string { func (*EventsByHandleRequest) ProtoMessage() {} func (x *EventsByHandleRequest) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[10] + mi := &file_aptos_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -757,7 +949,7 @@ func (x *EventsByHandleRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EventsByHandleRequest.ProtoReflect.Descriptor instead. func (*EventsByHandleRequest) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{10} + return file_aptos_proto_rawDescGZIP(), []int{14} } func (x *EventsByHandleRequest) GetAccount() []byte { @@ -804,7 +996,7 @@ type EventsByHandleReply struct { func (x *EventsByHandleReply) Reset() { *x = EventsByHandleReply{} - mi := &file_aptos_proto_msgTypes[11] + mi := &file_aptos_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -816,7 +1008,7 @@ func (x *EventsByHandleReply) String() string { func (*EventsByHandleReply) ProtoMessage() {} func (x *EventsByHandleReply) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[11] + mi := &file_aptos_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -829,7 +1021,7 @@ func (x *EventsByHandleReply) ProtoReflect() protoreflect.Message { // Deprecated: Use EventsByHandleReply.ProtoReflect.Descriptor instead. func (*EventsByHandleReply) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{11} + return file_aptos_proto_rawDescGZIP(), []int{15} } func (x *EventsByHandleReply) GetEvents() []*Event { @@ -852,7 +1044,7 @@ type Event struct { func (x *Event) Reset() { *x = Event{} - mi := &file_aptos_proto_msgTypes[12] + mi := &file_aptos_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -864,7 +1056,7 @@ func (x *Event) String() string { func (*Event) ProtoMessage() {} func (x *Event) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[12] + mi := &file_aptos_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -877,7 +1069,7 @@ func (x *Event) ProtoReflect() protoreflect.Message { // Deprecated: Use Event.ProtoReflect.Descriptor instead. func (*Event) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{12} + return file_aptos_proto_rawDescGZIP(), []int{16} } func (x *Event) GetVersion() uint64 { @@ -925,7 +1117,7 @@ type GUID struct { func (x *GUID) Reset() { *x = GUID{} - mi := &file_aptos_proto_msgTypes[13] + mi := &file_aptos_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -937,7 +1129,7 @@ func (x *GUID) String() string { func (*GUID) ProtoMessage() {} func (x *GUID) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[13] + mi := &file_aptos_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -950,7 +1142,7 @@ func (x *GUID) ProtoReflect() protoreflect.Message { // Deprecated: Use GUID.ProtoReflect.Descriptor instead. func (*GUID) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{13} + return file_aptos_proto_rawDescGZIP(), []int{17} } func (x *GUID) GetCreationNumber() uint64 { @@ -976,7 +1168,7 @@ type TransactionByHashRequest struct { func (x *TransactionByHashRequest) Reset() { *x = TransactionByHashRequest{} - mi := &file_aptos_proto_msgTypes[14] + mi := &file_aptos_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -988,7 +1180,7 @@ func (x *TransactionByHashRequest) String() string { func (*TransactionByHashRequest) ProtoMessage() {} func (x *TransactionByHashRequest) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[14] + mi := &file_aptos_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1001,7 +1193,7 @@ func (x *TransactionByHashRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TransactionByHashRequest.ProtoReflect.Descriptor instead. func (*TransactionByHashRequest) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{14} + return file_aptos_proto_rawDescGZIP(), []int{18} } func (x *TransactionByHashRequest) GetHash() string { @@ -1020,7 +1212,7 @@ type TransactionByHashReply struct { func (x *TransactionByHashReply) Reset() { *x = TransactionByHashReply{} - mi := &file_aptos_proto_msgTypes[15] + mi := &file_aptos_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1032,7 +1224,7 @@ func (x *TransactionByHashReply) String() string { func (*TransactionByHashReply) ProtoMessage() {} func (x *TransactionByHashReply) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[15] + mi := &file_aptos_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1045,7 +1237,7 @@ func (x *TransactionByHashReply) ProtoReflect() protoreflect.Message { // Deprecated: Use TransactionByHashReply.ProtoReflect.Descriptor instead. func (*TransactionByHashReply) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{15} + return file_aptos_proto_rawDescGZIP(), []int{19} } func (x *TransactionByHashReply) GetTransaction() *Transaction { @@ -1068,7 +1260,7 @@ type Transaction struct { func (x *Transaction) Reset() { *x = Transaction{} - mi := &file_aptos_proto_msgTypes[16] + mi := &file_aptos_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1080,7 +1272,7 @@ func (x *Transaction) String() string { func (*Transaction) ProtoMessage() {} func (x *Transaction) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[16] + mi := &file_aptos_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1093,7 +1285,7 @@ func (x *Transaction) ProtoReflect() protoreflect.Message { // Deprecated: Use Transaction.ProtoReflect.Descriptor instead. func (*Transaction) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{16} + return file_aptos_proto_rawDescGZIP(), []int{20} } func (x *Transaction) GetType() TransactionVariant { @@ -1142,7 +1334,7 @@ type SubmitTransactionRequest struct { func (x *SubmitTransactionRequest) Reset() { *x = SubmitTransactionRequest{} - mi := &file_aptos_proto_msgTypes[17] + mi := &file_aptos_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1154,7 +1346,7 @@ func (x *SubmitTransactionRequest) String() string { func (*SubmitTransactionRequest) ProtoMessage() {} func (x *SubmitTransactionRequest) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[17] + mi := &file_aptos_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1167,7 +1359,7 @@ func (x *SubmitTransactionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SubmitTransactionRequest.ProtoReflect.Descriptor instead. func (*SubmitTransactionRequest) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{17} + return file_aptos_proto_rawDescGZIP(), []int{21} } func (x *SubmitTransactionRequest) GetReceiverModuleId() *ModuleID { @@ -1200,7 +1392,7 @@ type SubmitTransactionReply struct { func (x *SubmitTransactionReply) Reset() { *x = SubmitTransactionReply{} - mi := &file_aptos_proto_msgTypes[18] + mi := &file_aptos_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1212,7 +1404,7 @@ func (x *SubmitTransactionReply) String() string { func (*SubmitTransactionReply) ProtoMessage() {} func (x *SubmitTransactionReply) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[18] + mi := &file_aptos_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1225,7 +1417,7 @@ func (x *SubmitTransactionReply) ProtoReflect() protoreflect.Message { // Deprecated: Use SubmitTransactionReply.ProtoReflect.Descriptor instead. func (*SubmitTransactionReply) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{18} + return file_aptos_proto_rawDescGZIP(), []int{22} } func (x *SubmitTransactionReply) GetPendingTransaction() *PendingTransaction { @@ -1245,7 +1437,7 @@ type GasConfig struct { func (x *GasConfig) Reset() { *x = GasConfig{} - mi := &file_aptos_proto_msgTypes[19] + mi := &file_aptos_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1257,7 +1449,7 @@ func (x *GasConfig) String() string { func (*GasConfig) ProtoMessage() {} func (x *GasConfig) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[19] + mi := &file_aptos_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1270,7 +1462,7 @@ func (x *GasConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use GasConfig.ProtoReflect.Descriptor instead. func (*GasConfig) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{19} + return file_aptos_proto_rawDescGZIP(), []int{23} } func (x *GasConfig) GetMaxGasAmount() uint64 { @@ -1304,7 +1496,7 @@ type PendingTransaction struct { func (x *PendingTransaction) Reset() { *x = PendingTransaction{} - mi := &file_aptos_proto_msgTypes[20] + mi := &file_aptos_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1316,7 +1508,7 @@ func (x *PendingTransaction) String() string { func (*PendingTransaction) ProtoMessage() {} func (x *PendingTransaction) ProtoReflect() protoreflect.Message { - mi := &file_aptos_proto_msgTypes[20] + mi := &file_aptos_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1329,7 +1521,7 @@ func (x *PendingTransaction) ProtoReflect() protoreflect.Message { // Deprecated: Use PendingTransaction.ProtoReflect.Descriptor instead. func (*PendingTransaction) Descriptor() ([]byte, []int) { - return file_aptos_proto_rawDescGZIP(), []int{20} + return file_aptos_proto_rawDescGZIP(), []int{24} } func (x *PendingTransaction) GetHash() string { @@ -1400,13 +1592,26 @@ var File_aptos_proto protoreflect.FileDescriptor const file_aptos_proto_rawDesc = "" + "\n" + "\vaptos.proto\x12\n" + - "loop.aptos\"4\n" + + "loop.aptos\"\x16\n" + + "\x14LedgerVersionRequest\";\n" + + "\x12LedgerVersionReply\x12%\n" + + "\x0eledger_version\x18\x01 \x01(\x04R\rledgerVersion\"4\n" + "\x18AccountAPTBalanceRequest\x12\x18\n" + "\aaddress\x18\x01 \x01(\fR\aaddress\".\n" + "\x16AccountAPTBalanceReply\x12\x14\n" + - "\x05value\x18\x01 \x01(\x04R\x05value\"@\n" + + "\x05value\x18\x01 \x01(\x04R\x05value\"\x80\x01\n" + + "\x1aAccountTransactionsRequest\x12\x18\n" + + "\aaddress\x18\x01 \x01(\fR\aaddress\x12\x19\n" + + "\x05start\x18\x02 \x01(\x04H\x00R\x05start\x88\x01\x01\x12\x19\n" + + "\x05limit\x18\x03 \x01(\x04H\x01R\x05limit\x88\x01\x01B\b\n" + + "\x06_startB\b\n" + + "\x06_limit\"W\n" + + "\x18AccountTransactionsReply\x12;\n" + + "\ftransactions\x18\x01 \x03(\v2\x17.loop.aptos.TransactionR\ftransactions\"\x7f\n" + "\vViewRequest\x121\n" + - "\apayload\x18\x01 \x01(\v2\x17.loop.aptos.ViewPayloadR\apayload\"\x1f\n" + + "\apayload\x18\x01 \x01(\v2\x17.loop.aptos.ViewPayloadR\apayload\x12*\n" + + "\x0eledger_version\x18\x02 \x01(\x04H\x00R\rledgerVersion\x88\x01\x01B\x11\n" + + "\x0f_ledger_version\"\x1f\n" + "\tViewReply\x12\x12\n" + "\x04data\x18\x01 \x01(\fR\x04data\"\x9d\x01\n" + "\vViewPayload\x12,\n" + @@ -1515,9 +1720,11 @@ const file_aptos_proto_rawDesc = "" + "\"TRANSACTION_VARIANT_BLOCK_EPILOGUE\x10\x04\x12(\n" + "$TRANSACTION_VARIANT_STATE_CHECKPOINT\x10\x05\x12!\n" + "\x1dTRANSACTION_VARIANT_VALIDATOR\x10\x06\x12\x1f\n" + - "\x1bTRANSACTION_VARIANT_UNKNOWN\x10\a2\xb2\x03\n" + - "\x05Aptos\x12]\n" + - "\x11AccountAPTBalance\x12$.loop.aptos.AccountAPTBalanceRequest\x1a\".loop.aptos.AccountAPTBalanceReply\x126\n" + + "\x1bTRANSACTION_VARIANT_UNKNOWN\x10\a2\xea\x04\n" + + "\x05Aptos\x12Q\n" + + "\rLedgerVersion\x12 .loop.aptos.LedgerVersionRequest\x1a\x1e.loop.aptos.LedgerVersionReply\x12]\n" + + "\x11AccountAPTBalance\x12$.loop.aptos.AccountAPTBalanceRequest\x1a\".loop.aptos.AccountAPTBalanceReply\x12c\n" + + "\x13AccountTransactions\x12&.loop.aptos.AccountTransactionsRequest\x1a$.loop.aptos.AccountTransactionsReply\x126\n" + "\x04View\x12\x17.loop.aptos.ViewRequest\x1a\x15.loop.aptos.ViewReply\x12T\n" + "\x0eEventsByHandle\x12!.loop.aptos.EventsByHandleRequest\x1a\x1f.loop.aptos.EventsByHandleReply\x12]\n" + "\x11TransactionByHash\x12$.loop.aptos.TransactionByHashRequest\x1a\".loop.aptos.TransactionByHashReply\x12]\n" + @@ -1536,64 +1743,73 @@ func file_aptos_proto_rawDescGZIP() []byte { } var file_aptos_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_aptos_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_aptos_proto_msgTypes = make([]protoimpl.MessageInfo, 25) var file_aptos_proto_goTypes = []any{ - (TypeTagType)(0), // 0: loop.aptos.TypeTagType - (TransactionVariant)(0), // 1: loop.aptos.TransactionVariant - (*AccountAPTBalanceRequest)(nil), // 2: loop.aptos.AccountAPTBalanceRequest - (*AccountAPTBalanceReply)(nil), // 3: loop.aptos.AccountAPTBalanceReply - (*ViewRequest)(nil), // 4: loop.aptos.ViewRequest - (*ViewReply)(nil), // 5: loop.aptos.ViewReply - (*ViewPayload)(nil), // 6: loop.aptos.ViewPayload - (*ModuleID)(nil), // 7: loop.aptos.ModuleID - (*TypeTag)(nil), // 8: loop.aptos.TypeTag - (*VectorTag)(nil), // 9: loop.aptos.VectorTag - (*StructTag)(nil), // 10: loop.aptos.StructTag - (*GenericTag)(nil), // 11: loop.aptos.GenericTag - (*EventsByHandleRequest)(nil), // 12: loop.aptos.EventsByHandleRequest - (*EventsByHandleReply)(nil), // 13: loop.aptos.EventsByHandleReply - (*Event)(nil), // 14: loop.aptos.Event - (*GUID)(nil), // 15: loop.aptos.GUID - (*TransactionByHashRequest)(nil), // 16: loop.aptos.TransactionByHashRequest - (*TransactionByHashReply)(nil), // 17: loop.aptos.TransactionByHashReply - (*Transaction)(nil), // 18: loop.aptos.Transaction - (*SubmitTransactionRequest)(nil), // 19: loop.aptos.SubmitTransactionRequest - (*SubmitTransactionReply)(nil), // 20: loop.aptos.SubmitTransactionReply - (*GasConfig)(nil), // 21: loop.aptos.GasConfig - (*PendingTransaction)(nil), // 22: loop.aptos.PendingTransaction + (TypeTagType)(0), // 0: loop.aptos.TypeTagType + (TransactionVariant)(0), // 1: loop.aptos.TransactionVariant + (*LedgerVersionRequest)(nil), // 2: loop.aptos.LedgerVersionRequest + (*LedgerVersionReply)(nil), // 3: loop.aptos.LedgerVersionReply + (*AccountAPTBalanceRequest)(nil), // 4: loop.aptos.AccountAPTBalanceRequest + (*AccountAPTBalanceReply)(nil), // 5: loop.aptos.AccountAPTBalanceReply + (*AccountTransactionsRequest)(nil), // 6: loop.aptos.AccountTransactionsRequest + (*AccountTransactionsReply)(nil), // 7: loop.aptos.AccountTransactionsReply + (*ViewRequest)(nil), // 8: loop.aptos.ViewRequest + (*ViewReply)(nil), // 9: loop.aptos.ViewReply + (*ViewPayload)(nil), // 10: loop.aptos.ViewPayload + (*ModuleID)(nil), // 11: loop.aptos.ModuleID + (*TypeTag)(nil), // 12: loop.aptos.TypeTag + (*VectorTag)(nil), // 13: loop.aptos.VectorTag + (*StructTag)(nil), // 14: loop.aptos.StructTag + (*GenericTag)(nil), // 15: loop.aptos.GenericTag + (*EventsByHandleRequest)(nil), // 16: loop.aptos.EventsByHandleRequest + (*EventsByHandleReply)(nil), // 17: loop.aptos.EventsByHandleReply + (*Event)(nil), // 18: loop.aptos.Event + (*GUID)(nil), // 19: loop.aptos.GUID + (*TransactionByHashRequest)(nil), // 20: loop.aptos.TransactionByHashRequest + (*TransactionByHashReply)(nil), // 21: loop.aptos.TransactionByHashReply + (*Transaction)(nil), // 22: loop.aptos.Transaction + (*SubmitTransactionRequest)(nil), // 23: loop.aptos.SubmitTransactionRequest + (*SubmitTransactionReply)(nil), // 24: loop.aptos.SubmitTransactionReply + (*GasConfig)(nil), // 25: loop.aptos.GasConfig + (*PendingTransaction)(nil), // 26: loop.aptos.PendingTransaction } var file_aptos_proto_depIdxs = []int32{ - 6, // 0: loop.aptos.ViewRequest.payload:type_name -> loop.aptos.ViewPayload - 7, // 1: loop.aptos.ViewPayload.module:type_name -> loop.aptos.ModuleID - 8, // 2: loop.aptos.ViewPayload.arg_types:type_name -> loop.aptos.TypeTag - 0, // 3: loop.aptos.TypeTag.type:type_name -> loop.aptos.TypeTagType - 9, // 4: loop.aptos.TypeTag.vector:type_name -> loop.aptos.VectorTag - 10, // 5: loop.aptos.TypeTag.struct:type_name -> loop.aptos.StructTag - 11, // 6: loop.aptos.TypeTag.generic:type_name -> loop.aptos.GenericTag - 8, // 7: loop.aptos.VectorTag.element_type:type_name -> loop.aptos.TypeTag - 8, // 8: loop.aptos.StructTag.type_params:type_name -> loop.aptos.TypeTag - 14, // 9: loop.aptos.EventsByHandleReply.events:type_name -> loop.aptos.Event - 15, // 10: loop.aptos.Event.guid:type_name -> loop.aptos.GUID - 18, // 11: loop.aptos.TransactionByHashReply.transaction:type_name -> loop.aptos.Transaction - 1, // 12: loop.aptos.Transaction.type:type_name -> loop.aptos.TransactionVariant - 7, // 13: loop.aptos.SubmitTransactionRequest.receiver_module_id:type_name -> loop.aptos.ModuleID - 21, // 14: loop.aptos.SubmitTransactionRequest.gas_config:type_name -> loop.aptos.GasConfig - 22, // 15: loop.aptos.SubmitTransactionReply.pending_transaction:type_name -> loop.aptos.PendingTransaction - 2, // 16: loop.aptos.Aptos.AccountAPTBalance:input_type -> loop.aptos.AccountAPTBalanceRequest - 4, // 17: loop.aptos.Aptos.View:input_type -> loop.aptos.ViewRequest - 12, // 18: loop.aptos.Aptos.EventsByHandle:input_type -> loop.aptos.EventsByHandleRequest - 16, // 19: loop.aptos.Aptos.TransactionByHash:input_type -> loop.aptos.TransactionByHashRequest - 19, // 20: loop.aptos.Aptos.SubmitTransaction:input_type -> loop.aptos.SubmitTransactionRequest - 3, // 21: loop.aptos.Aptos.AccountAPTBalance:output_type -> loop.aptos.AccountAPTBalanceReply - 5, // 22: loop.aptos.Aptos.View:output_type -> loop.aptos.ViewReply - 13, // 23: loop.aptos.Aptos.EventsByHandle:output_type -> loop.aptos.EventsByHandleReply - 17, // 24: loop.aptos.Aptos.TransactionByHash:output_type -> loop.aptos.TransactionByHashReply - 20, // 25: loop.aptos.Aptos.SubmitTransaction:output_type -> loop.aptos.SubmitTransactionReply - 21, // [21:26] is the sub-list for method output_type - 16, // [16:21] is the sub-list for method input_type - 16, // [16:16] is the sub-list for extension type_name - 16, // [16:16] is the sub-list for extension extendee - 0, // [0:16] is the sub-list for field type_name + 22, // 0: loop.aptos.AccountTransactionsReply.transactions:type_name -> loop.aptos.Transaction + 10, // 1: loop.aptos.ViewRequest.payload:type_name -> loop.aptos.ViewPayload + 11, // 2: loop.aptos.ViewPayload.module:type_name -> loop.aptos.ModuleID + 12, // 3: loop.aptos.ViewPayload.arg_types:type_name -> loop.aptos.TypeTag + 0, // 4: loop.aptos.TypeTag.type:type_name -> loop.aptos.TypeTagType + 13, // 5: loop.aptos.TypeTag.vector:type_name -> loop.aptos.VectorTag + 14, // 6: loop.aptos.TypeTag.struct:type_name -> loop.aptos.StructTag + 15, // 7: loop.aptos.TypeTag.generic:type_name -> loop.aptos.GenericTag + 12, // 8: loop.aptos.VectorTag.element_type:type_name -> loop.aptos.TypeTag + 12, // 9: loop.aptos.StructTag.type_params:type_name -> loop.aptos.TypeTag + 18, // 10: loop.aptos.EventsByHandleReply.events:type_name -> loop.aptos.Event + 19, // 11: loop.aptos.Event.guid:type_name -> loop.aptos.GUID + 22, // 12: loop.aptos.TransactionByHashReply.transaction:type_name -> loop.aptos.Transaction + 1, // 13: loop.aptos.Transaction.type:type_name -> loop.aptos.TransactionVariant + 11, // 14: loop.aptos.SubmitTransactionRequest.receiver_module_id:type_name -> loop.aptos.ModuleID + 25, // 15: loop.aptos.SubmitTransactionRequest.gas_config:type_name -> loop.aptos.GasConfig + 26, // 16: loop.aptos.SubmitTransactionReply.pending_transaction:type_name -> loop.aptos.PendingTransaction + 2, // 17: loop.aptos.Aptos.LedgerVersion:input_type -> loop.aptos.LedgerVersionRequest + 4, // 18: loop.aptos.Aptos.AccountAPTBalance:input_type -> loop.aptos.AccountAPTBalanceRequest + 6, // 19: loop.aptos.Aptos.AccountTransactions:input_type -> loop.aptos.AccountTransactionsRequest + 8, // 20: loop.aptos.Aptos.View:input_type -> loop.aptos.ViewRequest + 16, // 21: loop.aptos.Aptos.EventsByHandle:input_type -> loop.aptos.EventsByHandleRequest + 20, // 22: loop.aptos.Aptos.TransactionByHash:input_type -> loop.aptos.TransactionByHashRequest + 23, // 23: loop.aptos.Aptos.SubmitTransaction:input_type -> loop.aptos.SubmitTransactionRequest + 3, // 24: loop.aptos.Aptos.LedgerVersion:output_type -> loop.aptos.LedgerVersionReply + 5, // 25: loop.aptos.Aptos.AccountAPTBalance:output_type -> loop.aptos.AccountAPTBalanceReply + 7, // 26: loop.aptos.Aptos.AccountTransactions:output_type -> loop.aptos.AccountTransactionsReply + 9, // 27: loop.aptos.Aptos.View:output_type -> loop.aptos.ViewReply + 17, // 28: loop.aptos.Aptos.EventsByHandle:output_type -> loop.aptos.EventsByHandleReply + 21, // 29: loop.aptos.Aptos.TransactionByHash:output_type -> loop.aptos.TransactionByHashReply + 24, // 30: loop.aptos.Aptos.SubmitTransaction:output_type -> loop.aptos.SubmitTransactionReply + 24, // [24:31] is the sub-list for method output_type + 17, // [17:24] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_aptos_proto_init() } @@ -1601,25 +1817,27 @@ func file_aptos_proto_init() { if File_aptos_proto != nil { return } - file_aptos_proto_msgTypes[6].OneofWrappers = []any{ + file_aptos_proto_msgTypes[4].OneofWrappers = []any{} + file_aptos_proto_msgTypes[6].OneofWrappers = []any{} + file_aptos_proto_msgTypes[10].OneofWrappers = []any{ (*TypeTag_Vector)(nil), (*TypeTag_Struct)(nil), (*TypeTag_Generic)(nil), } - file_aptos_proto_msgTypes[10].OneofWrappers = []any{} - file_aptos_proto_msgTypes[12].OneofWrappers = []any{} - file_aptos_proto_msgTypes[15].OneofWrappers = []any{} + file_aptos_proto_msgTypes[14].OneofWrappers = []any{} file_aptos_proto_msgTypes[16].OneofWrappers = []any{} - file_aptos_proto_msgTypes[17].OneofWrappers = []any{} - file_aptos_proto_msgTypes[18].OneofWrappers = []any{} + file_aptos_proto_msgTypes[19].OneofWrappers = []any{} file_aptos_proto_msgTypes[20].OneofWrappers = []any{} + file_aptos_proto_msgTypes[21].OneofWrappers = []any{} + file_aptos_proto_msgTypes[22].OneofWrappers = []any{} + file_aptos_proto_msgTypes[24].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_aptos_proto_rawDesc), len(file_aptos_proto_rawDesc)), NumEnums: 2, - NumMessages: 21, + NumMessages: 25, NumExtensions: 0, NumServices: 1, }, diff --git a/pkg/chains/aptos/aptos.proto b/pkg/chains/aptos/aptos.proto index 399d3c9751..661d6d4dc3 100644 --- a/pkg/chains/aptos/aptos.proto +++ b/pkg/chains/aptos/aptos.proto @@ -4,13 +4,23 @@ option go_package = "github.com/smartcontractkit/chainlink-common/pkg/chains/apt package loop.aptos; service Aptos { + rpc LedgerVersion(LedgerVersionRequest) returns (LedgerVersionReply); rpc AccountAPTBalance(AccountAPTBalanceRequest) returns (AccountAPTBalanceReply); + rpc AccountTransactions(AccountTransactionsRequest) returns (AccountTransactionsReply); rpc View(ViewRequest) returns (ViewReply); rpc EventsByHandle(EventsByHandleRequest) returns (EventsByHandleReply); rpc TransactionByHash(TransactionByHashRequest) returns (TransactionByHashReply); rpc SubmitTransaction(SubmitTransactionRequest) returns (SubmitTransactionReply); } +// ========== LedgerVersion ========== + +message LedgerVersionRequest {} + +message LedgerVersionReply { + uint64 ledger_version = 1; +} + // ========== AccountAPTBalance ========== message AccountAPTBalanceRequest { @@ -21,10 +31,23 @@ message AccountAPTBalanceReply { uint64 value = 1; } +// ========== AccountTransactions ========== + +message AccountTransactionsRequest { + bytes address = 1; // 32-byte account address + optional uint64 start = 2; // optional start sequence + optional uint64 limit = 3; // optional page size +} + +message AccountTransactionsReply { + repeated Transaction transactions = 1; +} + // ========== View ========== message ViewRequest { ViewPayload payload = 1; + optional uint64 ledger_version = 2; } message ViewReply { @@ -165,4 +188,4 @@ message PendingTransaction { uint64 expiration_timestamp_secs = 7; // Expiration timestamp in seconds bytes payload = 8; // Transaction payload as raw bytes bytes signature = 9; // Signature as raw bytes -} \ No newline at end of file +} diff --git a/pkg/chains/aptos/aptos_grpc.pb.go b/pkg/chains/aptos/aptos_grpc.pb.go index 83610596e0..06a8025baf 100644 --- a/pkg/chains/aptos/aptos_grpc.pb.go +++ b/pkg/chains/aptos/aptos_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v5.29.3 +// - protoc-gen-go-grpc v1.6.1 +// - protoc v5.27.3 // source: aptos.proto package aptos @@ -19,18 +19,22 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Aptos_AccountAPTBalance_FullMethodName = "/loop.aptos.Aptos/AccountAPTBalance" - Aptos_View_FullMethodName = "/loop.aptos.Aptos/View" - Aptos_EventsByHandle_FullMethodName = "/loop.aptos.Aptos/EventsByHandle" - Aptos_TransactionByHash_FullMethodName = "/loop.aptos.Aptos/TransactionByHash" - Aptos_SubmitTransaction_FullMethodName = "/loop.aptos.Aptos/SubmitTransaction" + Aptos_LedgerVersion_FullMethodName = "/loop.aptos.Aptos/LedgerVersion" + Aptos_AccountAPTBalance_FullMethodName = "/loop.aptos.Aptos/AccountAPTBalance" + Aptos_AccountTransactions_FullMethodName = "/loop.aptos.Aptos/AccountTransactions" + Aptos_View_FullMethodName = "/loop.aptos.Aptos/View" + Aptos_EventsByHandle_FullMethodName = "/loop.aptos.Aptos/EventsByHandle" + Aptos_TransactionByHash_FullMethodName = "/loop.aptos.Aptos/TransactionByHash" + Aptos_SubmitTransaction_FullMethodName = "/loop.aptos.Aptos/SubmitTransaction" ) // AptosClient is the client API for Aptos service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AptosClient interface { + LedgerVersion(ctx context.Context, in *LedgerVersionRequest, opts ...grpc.CallOption) (*LedgerVersionReply, error) AccountAPTBalance(ctx context.Context, in *AccountAPTBalanceRequest, opts ...grpc.CallOption) (*AccountAPTBalanceReply, error) + AccountTransactions(ctx context.Context, in *AccountTransactionsRequest, opts ...grpc.CallOption) (*AccountTransactionsReply, error) View(ctx context.Context, in *ViewRequest, opts ...grpc.CallOption) (*ViewReply, error) EventsByHandle(ctx context.Context, in *EventsByHandleRequest, opts ...grpc.CallOption) (*EventsByHandleReply, error) TransactionByHash(ctx context.Context, in *TransactionByHashRequest, opts ...grpc.CallOption) (*TransactionByHashReply, error) @@ -45,6 +49,16 @@ func NewAptosClient(cc grpc.ClientConnInterface) AptosClient { return &aptosClient{cc} } +func (c *aptosClient) LedgerVersion(ctx context.Context, in *LedgerVersionRequest, opts ...grpc.CallOption) (*LedgerVersionReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(LedgerVersionReply) + err := c.cc.Invoke(ctx, Aptos_LedgerVersion_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *aptosClient) AccountAPTBalance(ctx context.Context, in *AccountAPTBalanceRequest, opts ...grpc.CallOption) (*AccountAPTBalanceReply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AccountAPTBalanceReply) @@ -55,6 +69,16 @@ func (c *aptosClient) AccountAPTBalance(ctx context.Context, in *AccountAPTBalan return out, nil } +func (c *aptosClient) AccountTransactions(ctx context.Context, in *AccountTransactionsRequest, opts ...grpc.CallOption) (*AccountTransactionsReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AccountTransactionsReply) + err := c.cc.Invoke(ctx, Aptos_AccountTransactions_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *aptosClient) View(ctx context.Context, in *ViewRequest, opts ...grpc.CallOption) (*ViewReply, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ViewReply) @@ -99,7 +123,9 @@ func (c *aptosClient) SubmitTransaction(ctx context.Context, in *SubmitTransacti // All implementations must embed UnimplementedAptosServer // for forward compatibility. type AptosServer interface { + LedgerVersion(context.Context, *LedgerVersionRequest) (*LedgerVersionReply, error) AccountAPTBalance(context.Context, *AccountAPTBalanceRequest) (*AccountAPTBalanceReply, error) + AccountTransactions(context.Context, *AccountTransactionsRequest) (*AccountTransactionsReply, error) View(context.Context, *ViewRequest) (*ViewReply, error) EventsByHandle(context.Context, *EventsByHandleRequest) (*EventsByHandleReply, error) TransactionByHash(context.Context, *TransactionByHashRequest) (*TransactionByHashReply, error) @@ -114,20 +140,26 @@ type AptosServer interface { // pointer dereference when methods are called. type UnimplementedAptosServer struct{} +func (UnimplementedAptosServer) LedgerVersion(context.Context, *LedgerVersionRequest) (*LedgerVersionReply, error) { + return nil, status.Error(codes.Unimplemented, "method LedgerVersion not implemented") +} func (UnimplementedAptosServer) AccountAPTBalance(context.Context, *AccountAPTBalanceRequest) (*AccountAPTBalanceReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method AccountAPTBalance not implemented") + return nil, status.Error(codes.Unimplemented, "method AccountAPTBalance not implemented") +} +func (UnimplementedAptosServer) AccountTransactions(context.Context, *AccountTransactionsRequest) (*AccountTransactionsReply, error) { + return nil, status.Error(codes.Unimplemented, "method AccountTransactions not implemented") } func (UnimplementedAptosServer) View(context.Context, *ViewRequest) (*ViewReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method View not implemented") + return nil, status.Error(codes.Unimplemented, "method View not implemented") } func (UnimplementedAptosServer) EventsByHandle(context.Context, *EventsByHandleRequest) (*EventsByHandleReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method EventsByHandle not implemented") + return nil, status.Error(codes.Unimplemented, "method EventsByHandle not implemented") } func (UnimplementedAptosServer) TransactionByHash(context.Context, *TransactionByHashRequest) (*TransactionByHashReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method TransactionByHash not implemented") + return nil, status.Error(codes.Unimplemented, "method TransactionByHash not implemented") } func (UnimplementedAptosServer) SubmitTransaction(context.Context, *SubmitTransactionRequest) (*SubmitTransactionReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitTransaction not implemented") + return nil, status.Error(codes.Unimplemented, "method SubmitTransaction not implemented") } func (UnimplementedAptosServer) mustEmbedUnimplementedAptosServer() {} func (UnimplementedAptosServer) testEmbeddedByValue() {} @@ -140,7 +172,7 @@ type UnsafeAptosServer interface { } func RegisterAptosServer(s grpc.ServiceRegistrar, srv AptosServer) { - // If the following call pancis, it indicates UnimplementedAptosServer was + // If the following call panics, it indicates UnimplementedAptosServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. @@ -150,6 +182,24 @@ func RegisterAptosServer(s grpc.ServiceRegistrar, srv AptosServer) { s.RegisterService(&Aptos_ServiceDesc, srv) } +func _Aptos_LedgerVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(LedgerVersionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AptosServer).LedgerVersion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Aptos_LedgerVersion_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AptosServer).LedgerVersion(ctx, req.(*LedgerVersionRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Aptos_AccountAPTBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(AccountAPTBalanceRequest) if err := dec(in); err != nil { @@ -168,6 +218,24 @@ func _Aptos_AccountAPTBalance_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Aptos_AccountTransactions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AccountTransactionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AptosServer).AccountTransactions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Aptos_AccountTransactions_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AptosServer).AccountTransactions(ctx, req.(*AccountTransactionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Aptos_View_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ViewRequest) if err := dec(in); err != nil { @@ -247,10 +315,18 @@ var Aptos_ServiceDesc = grpc.ServiceDesc{ ServiceName: "loop.aptos.Aptos", HandlerType: (*AptosServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "LedgerVersion", + Handler: _Aptos_LedgerVersion_Handler, + }, { MethodName: "AccountAPTBalance", Handler: _Aptos_AccountAPTBalance_Handler, }, + { + MethodName: "AccountTransactions", + Handler: _Aptos_AccountTransactions_Handler, + }, { MethodName: "View", Handler: _Aptos_View_Handler, diff --git a/pkg/chains/aptos/proto_helpers.go b/pkg/chains/aptos/proto_helpers.go index 5ac4485781..b387a84b53 100644 --- a/pkg/chains/aptos/proto_helpers.go +++ b/pkg/chains/aptos/proto_helpers.go @@ -402,6 +402,67 @@ func ConvertGUIDFromProto(proto *GUID) (*typeaptos.GUID, error) { // ========== TransactionByHash Conversion ========== +func ConvertAccountTransactionsRequestToProto(req typeaptos.AccountTransactionsRequest) *AccountTransactionsRequest { + protoReq := &AccountTransactionsRequest{ + Address: req.Address[:], + } + if req.Start != nil { + protoReq.Start = req.Start + } + if req.Limit != nil { + protoReq.Limit = req.Limit + } + return protoReq +} + +func ConvertAccountTransactionsRequestFromProto(proto *AccountTransactionsRequest) (*typeaptos.AccountTransactionsRequest, error) { + if proto == nil { + return nil, fmt.Errorf("proto request is nil") + } + if len(proto.Address) != typeaptos.AccountAddressLength { + return nil, fmt.Errorf("invalid account address length: expected %d, got %d", typeaptos.AccountAddressLength, len(proto.Address)) + } + + var address typeaptos.AccountAddress + copy(address[:], proto.Address) + + return &typeaptos.AccountTransactionsRequest{ + Address: address, + Start: proto.Start, + Limit: proto.Limit, + }, nil +} + +func ConvertAccountTransactionsReplyToProto(reply *typeaptos.AccountTransactionsReply) *AccountTransactionsReply { + if reply == nil { + return nil + } + + txs := make([]*Transaction, 0, len(reply.Transactions)) + for _, tx := range reply.Transactions { + txs = append(txs, ConvertTransactionToProto(tx)) + } + return &AccountTransactionsReply{Transactions: txs} +} + +func ConvertAccountTransactionsReplyFromProto(proto *AccountTransactionsReply) (*typeaptos.AccountTransactionsReply, error) { + if proto == nil { + return nil, nil + } + + txs := make([]*typeaptos.Transaction, 0, len(proto.Transactions)) + for _, tx := range proto.Transactions { + decoded, err := ConvertTransactionFromProto(tx) + if err != nil { + return nil, err + } + if decoded != nil { + txs = append(txs, decoded) + } + } + return &typeaptos.AccountTransactionsReply{Transactions: txs}, nil +} + func ConvertTransactionByHashRequestToProto(req typeaptos.TransactionByHashRequest) *TransactionByHashRequest { return &TransactionByHashRequest{ Hash: req.Hash, diff --git a/pkg/loop/internal/relayer/aptos.go b/pkg/loop/internal/relayer/aptos.go index 3df657cf02..34fc3ba357 100644 --- a/pkg/loop/internal/relayer/aptos.go +++ b/pkg/loop/internal/relayer/aptos.go @@ -4,6 +4,9 @@ import ( "context" "fmt" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + aptospb "github.com/smartcontractkit/chainlink-common/pkg/chains/aptos" "github.com/smartcontractkit/chainlink-common/pkg/loop/internal/net" "github.com/smartcontractkit/chainlink-common/pkg/types" @@ -22,6 +25,14 @@ func NewAptosClient(client aptospb.AptosClient) *AptosClient { } } +func (ac *AptosClient) LedgerVersion(ctx context.Context) (uint64, error) { + reply, err := ac.grpcClient.LedgerVersion(ctx, &aptospb.LedgerVersionRequest{}) + if err != nil { + return 0, err + } + return reply.LedgerVersion, nil +} + func (ac *AptosClient) AccountAPTBalance(ctx context.Context, req aptos.AccountAPTBalanceRequest) (*aptos.AccountAPTBalanceReply, error) { reply, err := ac.grpcClient.AccountAPTBalance(ctx, &aptospb.AccountAPTBalanceRequest{ Address: req.Address[:], @@ -34,6 +45,16 @@ func (ac *AptosClient) AccountAPTBalance(ctx context.Context, req aptos.AccountA }, nil } +// AccountTransactions exposes Aptos account transaction listing for callers that need +// canonical tx hash derivation from transmitter account history. +func (ac *AptosClient) AccountTransactions(ctx context.Context, req aptos.AccountTransactionsRequest) (*aptos.AccountTransactionsReply, error) { + reply, err := ac.grpcClient.AccountTransactions(ctx, aptospb.ConvertAccountTransactionsRequestToProto(req)) + if err != nil { + return nil, err + } + return aptospb.ConvertAccountTransactionsReplyFromProto(reply) +} + func (ac *AptosClient) View(ctx context.Context, req aptos.ViewRequest) (*aptos.ViewReply, error) { // Convert Go types to proto types protoPayload, err := aptospb.ConvertViewPayloadToProto(req.Payload) @@ -44,6 +65,9 @@ func (ac *AptosClient) View(ctx context.Context, req aptos.ViewRequest) (*aptos. protoReq := &aptospb.ViewRequest{ Payload: protoPayload, } + if req.LedgerVersion != nil { + protoReq.LedgerVersion = req.LedgerVersion + } reply, err := ac.grpcClient.View(ctx, protoReq) if err != nil { @@ -108,6 +132,10 @@ type aptosServer struct { var _ aptospb.AptosServer = (*aptosServer)(nil) +type accountTransactionsReader interface { + AccountTransactions(ctx context.Context, req aptos.AccountTransactionsRequest) (*aptos.AccountTransactionsReply, error) +} + func newAptosServer(impl types.AptosService, b *net.BrokerExt) *aptosServer { return &aptosServer{impl: impl, BrokerExt: b.WithName("AptosServer")} } @@ -124,6 +152,30 @@ func (s *aptosServer) AccountAPTBalance(ctx context.Context, req *aptospb.Accoun }, nil } +func (s *aptosServer) LedgerVersion(ctx context.Context, _ *aptospb.LedgerVersionRequest) (*aptospb.LedgerVersionReply, error) { + ledgerVersion, err := s.impl.LedgerVersion(ctx) + if err != nil { + return nil, err + } + return &aptospb.LedgerVersionReply{LedgerVersion: ledgerVersion}, nil +} + +func (s *aptosServer) AccountTransactions(ctx context.Context, req *aptospb.AccountTransactionsRequest) (*aptospb.AccountTransactionsReply, error) { + impl, ok := s.impl.(accountTransactionsReader) + if !ok { + return nil, status.Error(codes.Unimplemented, "AccountTransactions not supported by aptos service") + } + goReq, err := aptospb.ConvertAccountTransactionsRequestFromProto(req) + if err != nil { + return nil, err + } + reply, err := impl.AccountTransactions(ctx, *goReq) + if err != nil { + return nil, err + } + return aptospb.ConvertAccountTransactionsReplyToProto(reply), nil +} + func (s *aptosServer) View(ctx context.Context, req *aptospb.ViewRequest) (*aptospb.ViewReply, error) { // Convert proto types to Go types goPayload, err := aptospb.ConvertViewPayloadFromProto(req.Payload) @@ -134,6 +186,10 @@ func (s *aptosServer) View(ctx context.Context, req *aptospb.ViewRequest) (*apto goReq := aptos.ViewRequest{ Payload: goPayload, } + if req.LedgerVersion != nil { + ledgerVersion := req.GetLedgerVersion() + goReq.LedgerVersion = &ledgerVersion + } reply, err := s.impl.View(ctx, goReq) if err != nil { diff --git a/pkg/loop/internal/relayerset/aptos.go b/pkg/loop/internal/relayerset/aptos.go index 8cbcbdac91..ca8f50450b 100644 --- a/pkg/loop/internal/relayerset/aptos.go +++ b/pkg/loop/internal/relayerset/aptos.go @@ -21,10 +21,18 @@ type aptosClient struct { var _ aptospb.AptosClient = (*aptosClient)(nil) +func (ac *aptosClient) LedgerVersion(ctx context.Context, in *aptospb.LedgerVersionRequest, opts ...grpc.CallOption) (*aptospb.LedgerVersionReply, error) { + return ac.client.LedgerVersion(appendRelayID(ctx, ac.relayID), in, opts...) +} + func (ac *aptosClient) AccountAPTBalance(ctx context.Context, in *aptospb.AccountAPTBalanceRequest, opts ...grpc.CallOption) (*aptospb.AccountAPTBalanceReply, error) { return ac.client.AccountAPTBalance(appendRelayID(ctx, ac.relayID), in, opts...) } +func (ac *aptosClient) AccountTransactions(ctx context.Context, in *aptospb.AccountTransactionsRequest, opts ...grpc.CallOption) (*aptospb.AccountTransactionsReply, error) { + return ac.client.AccountTransactions(appendRelayID(ctx, ac.relayID), in, opts...) +} + func (ac *aptosClient) View(ctx context.Context, in *aptospb.ViewRequest, opts ...grpc.CallOption) (*aptospb.ViewReply, error) { return ac.client.View(appendRelayID(ctx, ac.relayID), in, opts...) } @@ -48,6 +56,10 @@ type aptosServer struct { var _ aptospb.AptosServer = (*aptosServer)(nil) +type accountTransactionsReader interface { + AccountTransactions(ctx context.Context, req aptos.AccountTransactionsRequest) (*aptos.AccountTransactionsReply, error) +} + func (as *aptosServer) AccountAPTBalance(ctx context.Context, req *aptospb.AccountAPTBalanceRequest) (*aptospb.AccountAPTBalanceReply, error) { aptosService, err := as.parent.getAptosService(ctx) if err != nil { @@ -65,6 +77,39 @@ func (as *aptosServer) AccountAPTBalance(ctx context.Context, req *aptospb.Accou }, nil } +func (as *aptosServer) LedgerVersion(ctx context.Context, _ *aptospb.LedgerVersionRequest) (*aptospb.LedgerVersionReply, error) { + aptosService, err := as.parent.getAptosService(ctx) + if err != nil { + return nil, err + } + + ledgerVersion, err := aptosService.LedgerVersion(ctx) + if err != nil { + return nil, err + } + return &aptospb.LedgerVersionReply{LedgerVersion: ledgerVersion}, nil +} + +func (as *aptosServer) AccountTransactions(ctx context.Context, req *aptospb.AccountTransactionsRequest) (*aptospb.AccountTransactionsReply, error) { + aptosService, err := as.parent.getAptosService(ctx) + if err != nil { + return nil, err + } + client, ok := aptosService.(accountTransactionsReader) + if !ok { + return nil, fmt.Errorf("AccountTransactions not supported by aptos service") + } + goReq, err := aptospb.ConvertAccountTransactionsRequestFromProto(req) + if err != nil { + return nil, err + } + reply, err := client.AccountTransactions(ctx, *goReq) + if err != nil { + return nil, err + } + return aptospb.ConvertAccountTransactionsReplyToProto(reply), nil +} + func (as *aptosServer) View(ctx context.Context, req *aptospb.ViewRequest) (*aptospb.ViewReply, error) { aptosService, err := as.parent.getAptosService(ctx) if err != nil { @@ -80,6 +125,10 @@ func (as *aptosServer) View(ctx context.Context, req *aptospb.ViewRequest) (*apt goReq := aptos.ViewRequest{ Payload: goPayload, } + if req.LedgerVersion != nil { + ledgerVersion := req.GetLedgerVersion() + goReq.LedgerVersion = &ledgerVersion + } reply, err := aptosService.View(ctx, goReq) if err != nil { diff --git a/pkg/types/chains/aptos/aptos.go b/pkg/types/chains/aptos/aptos.go index 2c6b3c58b8..167629d290 100644 --- a/pkg/types/chains/aptos/aptos.go +++ b/pkg/types/chains/aptos/aptos.go @@ -10,6 +10,8 @@ type AccountAddress [AccountAddressLength]byte // Client wraps the Aptos RPC client methods used for reading on-chain state. type Client interface { + // LedgerVersion returns the latest committed ledger (transaction) version. + LedgerVersion(ctx context.Context) (uint64, error) // AccountAPTBalance returns the native APT coin balance (in octas) for the given account address. AccountAPTBalance(ctx context.Context, req AccountAPTBalanceRequest) (*AccountAPTBalanceReply, error) // View executes a Move view function (read-only) and returns the raw result. @@ -30,10 +32,23 @@ type AccountAPTBalanceReply struct { Value uint64 } +// ========== AccountTransactions ========== + +type AccountTransactionsRequest struct { + Address AccountAddress + Start *uint64 // optional, nil for provider default + Limit *uint64 // optional, nil for provider default +} + +type AccountTransactionsReply struct { + Transactions []*Transaction +} + // ========== View ========== type ViewRequest struct { - Payload *ViewPayload + Payload *ViewPayload + LedgerVersion *uint64 // optional, nil uses latest ledger version on the node } type ViewReply struct { diff --git a/pkg/types/mocks/aptos_service.go b/pkg/types/mocks/aptos_service.go index bfc9453dae..a45692369a 100644 --- a/pkg/types/mocks/aptos_service.go +++ b/pkg/types/mocks/aptos_service.go @@ -23,6 +23,62 @@ func (_m *AptosService) EXPECT() *AptosService_Expecter { return &AptosService_Expecter{mock: &_m.Mock} } +// LedgerVersion provides a mock function with given fields: ctx +func (_m *AptosService) LedgerVersion(ctx context.Context) (uint64, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for LedgerVersion") + } + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (uint64, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) uint64); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// AptosService_LedgerVersion_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LedgerVersion' +type AptosService_LedgerVersion_Call struct { + *mock.Call +} + +// LedgerVersion is a helper method to define mock.On call +// - ctx context.Context +func (_e *AptosService_Expecter) LedgerVersion(ctx interface{}) *AptosService_LedgerVersion_Call { + return &AptosService_LedgerVersion_Call{Call: _e.mock.On("LedgerVersion", ctx)} +} + +func (_c *AptosService_LedgerVersion_Call) Run(run func(ctx context.Context)) *AptosService_LedgerVersion_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *AptosService_LedgerVersion_Call) Return(_a0 uint64, _a1 error) *AptosService_LedgerVersion_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *AptosService_LedgerVersion_Call) RunAndReturn(run func(context.Context) (uint64, error)) *AptosService_LedgerVersion_Call { + _c.Call.Return(run) + return _c +} + // AccountAPTBalance provides a mock function with given fields: ctx, req func (_m *AptosService) AccountAPTBalance(ctx context.Context, req aptos.AccountAPTBalanceRequest) (*aptos.AccountAPTBalanceReply, error) { ret := _m.Called(ctx, req) diff --git a/pkg/types/relayer.go b/pkg/types/relayer.go index 39477fcc97..cef5b2a877 100644 --- a/pkg/types/relayer.go +++ b/pkg/types/relayer.go @@ -558,6 +558,10 @@ var _ AptosService = &UnimplementedAptosService{} // In the future, embedding this type may be required to implement AptosService (through use of an unexported method). type UnimplementedAptosService struct{} +func (ua *UnimplementedAptosService) LedgerVersion(ctx context.Context) (uint64, error) { + return 0, status.Errorf(codes.Unimplemented, "method LedgerVersion not implemented") +} + func (ua *UnimplementedAptosService) AccountAPTBalance(ctx context.Context, req aptos.AccountAPTBalanceRequest) (*aptos.AccountAPTBalanceReply, error) { return nil, status.Errorf(codes.Unimplemented, "method AccountAPTBalance not implemented") }