mirror of https://github.com/status-im/evmc.git
Add alias evmc_address for struct evmc_address
This commit is contained in:
parent
00e8b89712
commit
60cfde98af
|
@ -34,7 +34,7 @@ extern const struct evmc_host_interface evmc_go_host;
|
|||
static struct evmc_result execute_wrapper(struct evmc_instance* instance,
|
||||
int64_t context_index, enum evmc_revision rev,
|
||||
enum evmc_call_kind kind, uint32_t flags, int32_t depth, int64_t gas,
|
||||
const struct evmc_address* destination, const struct evmc_address* sender,
|
||||
const evmc_address* destination, const evmc_address* sender,
|
||||
const uint8_t* input_data, size_t input_size, const evmc_uint256be* value,
|
||||
const uint8_t* code, size_t code_size, const evmc_bytes32* create2_salt)
|
||||
{
|
||||
|
@ -70,8 +70,8 @@ import (
|
|||
const (
|
||||
_ = uint(common.HashLength - C.sizeof_evmc_bytes32) // The size of evmc_bytes32 equals the size of Hash.
|
||||
_ = uint(C.sizeof_evmc_bytes32 - common.HashLength)
|
||||
_ = uint(common.AddressLength - C.sizeof_struct_evmc_address) // The size of evmc_address equals the size of Address.
|
||||
_ = uint(C.sizeof_struct_evmc_address - common.AddressLength)
|
||||
_ = uint(common.AddressLength - C.sizeof_evmc_address) // The size of evmc_address equals the size of Address.
|
||||
_ = uint(C.sizeof_evmc_address - common.AddressLength)
|
||||
)
|
||||
|
||||
type Error int32
|
||||
|
@ -269,8 +269,8 @@ func evmcBytes32(in common.Hash) C.evmc_bytes32 {
|
|||
return out
|
||||
}
|
||||
|
||||
func evmcAddress(address common.Address) C.struct_evmc_address {
|
||||
r := C.struct_evmc_address{}
|
||||
func evmcAddress(address common.Address) C.evmc_address {
|
||||
r := C.evmc_address{}
|
||||
for i := 0; i < len(address); i++ {
|
||||
r.bytes[i] = C.uint8_t(address[i])
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ const struct evmc_host_interface evmc_go_host = {
|
|||
static inline void go_exported_functions_type_checks()
|
||||
{
|
||||
struct evmc_context* context = NULL;
|
||||
struct evmc_address* address = NULL;
|
||||
evmc_address* address = NULL;
|
||||
evmc_bytes32* bytes32 = NULL;
|
||||
evmc_uint256be* uint256be = NULL;
|
||||
uint8_t* data = NULL;
|
||||
|
|
|
@ -46,7 +46,7 @@ const (
|
|||
StorageDeleted StorageStatus = C.EVMC_STORAGE_DELETED
|
||||
)
|
||||
|
||||
func goAddress(in C.struct_evmc_address) common.Address {
|
||||
func goAddress(in C.evmc_address) common.Address {
|
||||
out := common.Address{}
|
||||
for i := 0; i < len(out); i++ {
|
||||
out[i] = byte(in.bytes[i])
|
||||
|
@ -88,14 +88,14 @@ type HostContext interface {
|
|||
}
|
||||
|
||||
//export accountExists
|
||||
func accountExists(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address) C.bool {
|
||||
func accountExists(pCtx unsafe.Pointer, pAddr *C.evmc_address) C.bool {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
return C.bool(ctx.AccountExists(goAddress(*pAddr)))
|
||||
}
|
||||
|
||||
//export getStorage
|
||||
func getStorage(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pKey *C.struct_evmc_bytes32) C.bool {
|
||||
func getStorage(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pKey *C.evmc_bytes32) C.bool {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
value, err := ctx.GetStorage(goAddress(*pAddr), goHash(*pKey))
|
||||
|
@ -107,7 +107,7 @@ func getStorage(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, pAddr *C.struct_ev
|
|||
}
|
||||
|
||||
//export setStorage
|
||||
func setStorage(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pKey *C.evmc_bytes32, pVal *C.evmc_bytes32) C.enum_evmc_storage_status {
|
||||
func setStorage(pCtx unsafe.Pointer, pAddr *C.evmc_address, pKey *C.evmc_bytes32, pVal *C.evmc_bytes32) C.enum_evmc_storage_status {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
status, err := ctx.SetStorage(goAddress(*pAddr), goHash(*pKey), goHash(*pVal))
|
||||
|
@ -118,7 +118,7 @@ func setStorage(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pKey *C.evmc_
|
|||
}
|
||||
|
||||
//export getBalance
|
||||
func getBalance(pResult *C.evmc_uint256be, pCtx unsafe.Pointer, pAddr *C.struct_evmc_address) C.bool {
|
||||
func getBalance(pResult *C.evmc_uint256be, pCtx unsafe.Pointer, pAddr *C.evmc_address) C.bool {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
balance, err := ctx.GetBalance(goAddress(*pAddr))
|
||||
|
@ -130,7 +130,7 @@ func getBalance(pResult *C.evmc_uint256be, pCtx unsafe.Pointer, pAddr *C.struct_
|
|||
}
|
||||
|
||||
//export getCodeSize
|
||||
func getCodeSize(pResult *C.size_t, pCtx unsafe.Pointer, pAddr *C.struct_evmc_address) C.bool {
|
||||
func getCodeSize(pResult *C.size_t, pCtx unsafe.Pointer, pAddr *C.evmc_address) C.bool {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
codeSize, err := ctx.GetCodeSize(goAddress(*pAddr))
|
||||
|
@ -142,7 +142,7 @@ func getCodeSize(pResult *C.size_t, pCtx unsafe.Pointer, pAddr *C.struct_evmc_ad
|
|||
}
|
||||
|
||||
//export getCodeHash
|
||||
func getCodeHash(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, pAddr *C.struct_evmc_address) C.bool {
|
||||
func getCodeHash(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, pAddr *C.evmc_address) C.bool {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
codeHash, err := ctx.GetCodeHash(goAddress(*pAddr))
|
||||
|
@ -154,7 +154,7 @@ func getCodeHash(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, pAddr *C.struct_e
|
|||
}
|
||||
|
||||
//export copyCode
|
||||
func copyCode(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, offset C.size_t, p *C.uint8_t, size C.size_t) C.size_t {
|
||||
func copyCode(pCtx unsafe.Pointer, pAddr *C.evmc_address, offset C.size_t, p *C.uint8_t, size C.size_t) C.size_t {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
code := ctx.GetCode(goAddress(*pAddr))
|
||||
|
@ -175,7 +175,7 @@ func copyCode(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, offset C.size_t
|
|||
}
|
||||
|
||||
//export selfdestruct
|
||||
func selfdestruct(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pBeneficiary *C.struct_evmc_address) {
|
||||
func selfdestruct(pCtx unsafe.Pointer, pAddr *C.evmc_address, pBeneficiary *C.evmc_address) {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
ctx.Selfdestruct(goAddress(*pAddr), goAddress(*pBeneficiary))
|
||||
|
@ -214,7 +214,7 @@ func getBlockHash(pResult *C.evmc_bytes32, pCtx unsafe.Pointer, number int64) C.
|
|||
}
|
||||
|
||||
//export emitLog
|
||||
func emitLog(pCtx unsafe.Pointer, pAddr *C.struct_evmc_address, pData unsafe.Pointer, dataSize C.size_t, pTopics unsafe.Pointer, topicsCount C.size_t) {
|
||||
func emitLog(pCtx unsafe.Pointer, pAddr *C.evmc_address, pData unsafe.Pointer, dataSize C.size_t, pTopics unsafe.Pointer, topicsCount C.size_t) {
|
||||
idx := int((*C.struct_extended_context)(pCtx).index)
|
||||
ctx := getHostContext(idx)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ int main()
|
|||
const size_t code_size = sizeof(code);
|
||||
const uint8_t input[] = "Hello World!";
|
||||
const evmc_uint256be value = {{1, 0}};
|
||||
const struct evmc_address addr = {{0, 1, 2}};
|
||||
const evmc_address addr = {{0, 1, 2}};
|
||||
const int64_t gas = 200000;
|
||||
struct evmc_context* ctx = example_host_create_context();
|
||||
struct evmc_message msg;
|
||||
|
|
|
@ -52,11 +52,11 @@ typedef struct evmc_bytes32
|
|||
typedef struct evmc_bytes32 evmc_uint256be;
|
||||
|
||||
/** Big-endian 160-bit hash suitable for keeping an Ethereum address. */
|
||||
struct evmc_address
|
||||
typedef struct evmc_address
|
||||
{
|
||||
/** The 20 bytes of the hash. */
|
||||
uint8_t bytes[20];
|
||||
};
|
||||
} evmc_address;
|
||||
|
||||
/** The kind of call-like instruction. */
|
||||
enum evmc_call_kind
|
||||
|
@ -97,10 +97,10 @@ struct evmc_message
|
|||
int64_t gas;
|
||||
|
||||
/** The destination of the message. */
|
||||
struct evmc_address destination;
|
||||
evmc_address destination;
|
||||
|
||||
/** The sender of the message. */
|
||||
struct evmc_address sender;
|
||||
evmc_address sender;
|
||||
|
||||
/**
|
||||
* The message input data.
|
||||
|
@ -134,8 +134,8 @@ struct evmc_message
|
|||
struct evmc_tx_context
|
||||
{
|
||||
evmc_uint256be tx_gas_price; /**< The transaction gas price. */
|
||||
struct evmc_address tx_origin; /**< The transaction origin account. */
|
||||
struct evmc_address block_coinbase; /**< The miner of the block. */
|
||||
evmc_address tx_origin; /**< The transaction origin account. */
|
||||
evmc_address block_coinbase; /**< The miner of the block. */
|
||||
int64_t block_number; /**< The block number. */
|
||||
int64_t block_timestamp; /**< The block timestamp. */
|
||||
int64_t block_gas_limit; /**< The block gas limit. */
|
||||
|
@ -380,7 +380,7 @@ struct evmc_result
|
|||
* This field has valid value only if the result describes successful
|
||||
* CREATE (evmc_result::status_code is ::EVMC_SUCCESS).
|
||||
*/
|
||||
struct evmc_address create_address;
|
||||
evmc_address create_address;
|
||||
|
||||
/**
|
||||
* Reserved data that MAY be used by a evmc_result object creator.
|
||||
|
@ -406,8 +406,7 @@ struct evmc_result
|
|||
* @param address The address of the account the query is about.
|
||||
* @return true if exists, false otherwise.
|
||||
*/
|
||||
typedef bool (*evmc_account_exists_fn)(struct evmc_context* context,
|
||||
const struct evmc_address* address);
|
||||
typedef bool (*evmc_account_exists_fn)(struct evmc_context* context, const evmc_address* address);
|
||||
|
||||
/**
|
||||
* Get storage callback function.
|
||||
|
@ -425,7 +424,7 @@ typedef bool (*evmc_account_exists_fn)(struct evmc_context* context,
|
|||
*/
|
||||
typedef bool (*evmc_get_storage_fn)(evmc_bytes32* result,
|
||||
struct evmc_context* context,
|
||||
const struct evmc_address* address,
|
||||
const evmc_address* address,
|
||||
const evmc_bytes32* key);
|
||||
|
||||
|
||||
|
@ -486,7 +485,7 @@ enum evmc_storage_status
|
|||
* @return The effect on the storage item. @see ::evmc_storage_status.
|
||||
*/
|
||||
typedef enum evmc_storage_status (*evmc_set_storage_fn)(struct evmc_context* context,
|
||||
const struct evmc_address* address,
|
||||
const evmc_address* address,
|
||||
const evmc_bytes32* key,
|
||||
const evmc_bytes32* value);
|
||||
|
||||
|
@ -507,7 +506,7 @@ typedef enum evmc_storage_status (*evmc_set_storage_fn)(struct evmc_context* con
|
|||
*/
|
||||
typedef bool (*evmc_get_balance_fn)(evmc_uint256be* result,
|
||||
struct evmc_context* context,
|
||||
const struct evmc_address* address);
|
||||
const evmc_address* address);
|
||||
|
||||
/**
|
||||
* Get code size callback function.
|
||||
|
@ -527,7 +526,7 @@ typedef bool (*evmc_get_balance_fn)(evmc_uint256be* result,
|
|||
*/
|
||||
typedef bool (*evmc_get_code_size_fn)(size_t* result,
|
||||
struct evmc_context* context,
|
||||
const struct evmc_address* address);
|
||||
const evmc_address* address);
|
||||
|
||||
/**
|
||||
* Get code size callback function.
|
||||
|
@ -548,7 +547,7 @@ typedef bool (*evmc_get_code_size_fn)(size_t* result,
|
|||
*/
|
||||
typedef bool (*evmc_get_code_hash_fn)(evmc_bytes32* result,
|
||||
struct evmc_context* context,
|
||||
const struct evmc_address* address);
|
||||
const evmc_address* address);
|
||||
|
||||
/**
|
||||
* Copy code callback function.
|
||||
|
@ -569,7 +568,7 @@ typedef bool (*evmc_get_code_hash_fn)(evmc_bytes32* result,
|
|||
* @return The number of bytes copied to the buffer by the Client.
|
||||
*/
|
||||
typedef size_t (*evmc_copy_code_fn)(struct evmc_context* context,
|
||||
const struct evmc_address* address,
|
||||
const evmc_address* address,
|
||||
size_t code_offset,
|
||||
uint8_t* buffer_data,
|
||||
size_t buffer_size);
|
||||
|
@ -587,8 +586,8 @@ typedef size_t (*evmc_copy_code_fn)(struct evmc_context* context,
|
|||
* transferred.
|
||||
*/
|
||||
typedef void (*evmc_selfdestruct_fn)(struct evmc_context* context,
|
||||
const struct evmc_address* address,
|
||||
const struct evmc_address* beneficiary);
|
||||
const evmc_address* address,
|
||||
const evmc_address* beneficiary);
|
||||
|
||||
/**
|
||||
* Log callback function.
|
||||
|
@ -605,7 +604,7 @@ typedef void (*evmc_selfdestruct_fn)(struct evmc_context* context,
|
|||
* 0 and 4 inclusively.
|
||||
*/
|
||||
typedef void (*evmc_emit_log_fn)(struct evmc_context* context,
|
||||
const struct evmc_address* address,
|
||||
const evmc_address* address,
|
||||
const uint8_t* data,
|
||||
size_t data_size,
|
||||
const evmc_bytes32 topics[],
|
||||
|
|
Loading…
Reference in New Issue