diff --git a/interfaces/services/virtual_machine.proto b/interfaces/services/virtual_machine.proto index 7e66ad5e..f16e62bb 100644 --- a/interfaces/services/virtual_machine.proto +++ b/interfaces/services/virtual_machine.proto @@ -18,6 +18,7 @@ service VirtualMachine { // called by ConsensusContext rpc ProcessTransactionSet (ProcessTransactionSetInput) returns (ProcessTransactionSetOutput); // Transactions Streaming + rpc CallSystemContract (CallSystemContractInput) returns (CallSystemContractOutput); // called by PublicApi rpc ProcessQuery (ProcessQueryInput) returns (ProcessQueryOutput); @@ -59,4 +60,17 @@ message TransactionSetPreOrderInput { // returns error string if one of the transactions does not pass pre order checks message TransactionSetPreOrderOutput { repeated protocol.TransactionStatus pre_order_results = 1; +} + +message CallSystemContractInput { + primitives.block_height block_height = 1; + primitives.timestamp_nano block_timestamp = 2; + primitives.contract_name contract_name = 3; + primitives.method_name method_name = 4; + protocol.ArgumentArray input_argument_array = 5; +} + +message CallSystemContractOutput { + protocol.ArgumentArray output_argument_array = 1; + protocol.ExecutionResult call_result = 2; } \ No newline at end of file diff --git a/types/go/services/virtual_machine.mb.go b/types/go/services/virtual_machine.mb.go index 1703e482..eac3852e 100644 --- a/types/go/services/virtual_machine.mb.go +++ b/types/go/services/virtual_machine.mb.go @@ -15,6 +15,7 @@ import ( type VirtualMachine interface { handlers.ContractSdkCallHandler ProcessTransactionSet(ctx context.Context, input *ProcessTransactionSetInput) (*ProcessTransactionSetOutput, error) + CallSystemContract(ctx context.Context, input *CallSystemContractInput) (*CallSystemContractOutput, error) ProcessQuery(ctx context.Context, input *ProcessQueryInput) (*ProcessQueryOutput, error) TransactionSetPreOrder(ctx context.Context, input *TransactionSetPreOrderInput) (*TransactionSetPreOrderOutput, error) } @@ -213,5 +214,73 @@ func (x *TransactionSetPreOrderOutput) StringPreOrderResults() (res string) { return } +///////////////////////////////////////////////////////////////////////////// +// message CallSystemContractInput (non serializable) + +type CallSystemContractInput struct { + BlockHeight primitives.BlockHeight + BlockTimestamp primitives.TimestampNano + ContractName primitives.ContractName + MethodName primitives.MethodName + InputArgumentArray *protocol.ArgumentArray +} + +func (x *CallSystemContractInput) String() string { + if x == nil { + return "" + } + return fmt.Sprintf("{BlockHeight:%s,BlockTimestamp:%s,ContractName:%s,MethodName:%s,InputArgumentArray:%s,}", x.StringBlockHeight(), x.StringBlockTimestamp(), x.StringContractName(), x.StringMethodName(), x.StringInputArgumentArray()) +} + +func (x *CallSystemContractInput) StringBlockHeight() (res string) { + res = fmt.Sprintf("%s", x.BlockHeight) + return +} + +func (x *CallSystemContractInput) StringBlockTimestamp() (res string) { + res = fmt.Sprintf("%s", x.BlockTimestamp) + return +} + +func (x *CallSystemContractInput) StringContractName() (res string) { + res = fmt.Sprintf("%s", x.ContractName) + return +} + +func (x *CallSystemContractInput) StringMethodName() (res string) { + res = fmt.Sprintf("%s", x.MethodName) + return +} + +func (x *CallSystemContractInput) StringInputArgumentArray() (res string) { + res = x.InputArgumentArray.String() + return +} + +///////////////////////////////////////////////////////////////////////////// +// message CallSystemContractOutput (non serializable) + +type CallSystemContractOutput struct { + OutputArgumentArray *protocol.ArgumentArray + CallResult protocol.ExecutionResult +} + +func (x *CallSystemContractOutput) String() string { + if x == nil { + return "" + } + return fmt.Sprintf("{OutputArgumentArray:%s,CallResult:%s,}", x.StringOutputArgumentArray(), x.StringCallResult()) +} + +func (x *CallSystemContractOutput) StringOutputArgumentArray() (res string) { + res = x.OutputArgumentArray.String() + return +} + +func (x *CallSystemContractOutput) StringCallResult() (res string) { + res = fmt.Sprintf("%x", x.CallResult) + return +} + ///////////////////////////////////////////////////////////////////////////// // enums diff --git a/types/go/services/virtual_machine_mock.mb.go b/types/go/services/virtual_machine_mock.mb.go index 7b75952c..3f6a8ec9 100644 --- a/types/go/services/virtual_machine_mock.mb.go +++ b/types/go/services/virtual_machine_mock.mb.go @@ -24,6 +24,15 @@ func (s *MockVirtualMachine) ProcessTransactionSet(ctx context.Context, input *P } } +func (s *MockVirtualMachine) CallSystemContract(ctx context.Context, input *CallSystemContractInput) (*CallSystemContractOutput, error) { + ret := s.Called(ctx, input) + if out := ret.Get(0); out != nil { + return out.(*CallSystemContractOutput), ret.Error(1) + } else { + return nil, ret.Error(1) + } +} + func (s *MockVirtualMachine) ProcessQuery(ctx context.Context, input *ProcessQueryInput) (*ProcessQueryOutput, error) { ret := s.Called(ctx, input) if out := ret.Get(0); out != nil {