Loading...
Searching...
No Matches
contract_manager.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
22#include "absl/status/statusor.h"
23#include "eEVM/opcode.h"
24#include "eEVM/simple/simpleglobalstate.h"
26#include "proto/contract/func_params.pb.h"
27
28namespace resdb {
29namespace contract {
30
32 public:
34
35 public:
36 Address DeployContract(const Address& owner_address,
37 const DeployInfo& deploy_info);
38
39 absl::StatusOr<eevm::AccountState> GetContract(const Address& address);
40
41 absl::StatusOr<std::string> ExecContract(const Address& caller_address,
42 const Address& contract_address,
43 const Params& func_param);
44
45 private:
46 std::string GetFuncAddress(const Address& contract_address,
47 const std::string& func_name);
48 void SetFuncAddress(const Address& contract_address, const FuncInfo& func);
49
50 absl::StatusOr<std::vector<uint8_t>> Execute(
51 const Address& owner_address, const Address& contract_address,
52 const std::vector<uint8_t>& func_para);
53
54 private:
55 std::unique_ptr<eevm::SimpleGlobalState> gs_;
56 std::map<Address, std::map<std::string, std::string>> func_address_;
57};
58
59} // namespace contract
60} // namespace resdb
Address DeployContract(const Address &owner_address, const DeployInfo &deploy_info)
absl::StatusOr< eevm::AccountState > GetContract(const Address &address)
absl::StatusOr< std::string > ExecContract(const Address &caller_address, const Address &contract_address, const Params &func_param)
eevm::Address Address
Definition utils.h:27