diff --git a/examples/capi.c b/examples/capi.c index 32b3f4e..74caf16 100644 --- a/examples/capi.c +++ b/examples/capi.c @@ -5,19 +5,19 @@ struct evm_uint256be balance(struct evm_context* context, - const struct evm_uint160be* address) + const struct evm_address* address) { struct evm_uint256be ret = {.bytes = {1, 2, 3, 4}}; return ret; } -struct evm_uint160be address(struct evm_context* context) +struct evm_address address(struct evm_context* context) { - struct evm_uint160be ret = {.bytes = {1, 2, 3, 4}}; + struct evm_address ret = {.bytes = {1, 2, 3, 4}}; return ret; } -static void print_address(const struct evm_uint160be* address) +static void print_address(const struct evm_address* address) { int i = 0; for (i = 0; i < sizeof(address->bytes); ++i) @@ -25,7 +25,7 @@ static void print_address(const struct evm_uint160be* address) } static int account_exists(struct evm_context* context, - const struct evm_uint160be* address) { + const struct evm_address* address) { printf("EVM-C: EXISTS @"); print_address(address); printf("\n"); @@ -34,7 +34,7 @@ static int account_exists(struct evm_context* context, static void get_storage(struct evm_uint256be* result, struct evm_context* context, - const struct evm_uint160be* address, + const struct evm_address* address, const struct evm_uint256be* key) { printf("EVM-C: SLOAD @"); @@ -43,7 +43,7 @@ static void get_storage(struct evm_uint256be* result, } static void set_storage(struct evm_context* context, - const struct evm_uint160be* address, + const struct evm_address* address, const struct evm_uint256be* key, const struct evm_uint256be* value) { @@ -54,7 +54,7 @@ static void set_storage(struct evm_context* context, static void get_balance(struct evm_uint256be* result, struct evm_context* context, - const struct evm_uint160be* address) + const struct evm_address* address) { printf("EVM-C: BALANCE @"); print_address(address); @@ -64,7 +64,7 @@ static void get_balance(struct evm_uint256be* result, static size_t get_code(const uint8_t** code, struct evm_context* context, - const struct evm_uint160be* address) + const struct evm_address* address) { printf("EVM-C: CODE @"); print_address(address); @@ -73,8 +73,8 @@ static size_t get_code(const uint8_t** code, } static void selfdestruct(struct evm_context* context, - const struct evm_uint160be* address, - const struct evm_uint160be* beneficiary) + const struct evm_address* address, + const struct evm_address* beneficiary) { printf("EVM-C: SELFDESTRUCT "); print_address(address); @@ -105,7 +105,7 @@ static void get_block_hash(struct evm_uint256be* result, struct evm_context* con /// EVM log callback. /// /// @note The `evm_log` name is used to avoid conflict with `log()` C function. -static void evm_log(struct evm_context* context, const struct evm_uint160be* address, +static void evm_log(struct evm_context* context, const struct evm_address* address, const uint8_t* data, size_t data_size, const struct evm_uint256be topics[], size_t topics_count) { @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) { struct evm_uint256be code_hash = {.bytes = {1, 2, 3,}}; uint8_t const input[] = "Hello World!"; struct evm_uint256be value = {{1, 0,}}; - struct evm_uint160be addr = {{0, 1, 2,}}; + struct evm_address addr = {{0, 1, 2,}}; int64_t gas = 200000; struct evm_context ctx = {&ctx_fn_table}; diff --git a/include/evm.h b/include/evm.h index 24d30ad..924a8fb 100644 --- a/include/evm.h +++ b/include/evm.h @@ -49,7 +49,7 @@ struct evm_uint256be { /// Big-endian 160-bit hash suitable for keeping an Ethereum address. /// TODO: Rename to "address". -struct evm_uint160be { +struct evm_address { /// The 20 bytes of the hash. uint8_t bytes[20]; }; @@ -67,8 +67,8 @@ enum evm_flags { }; struct evm_message { - struct evm_uint160be address; - struct evm_uint160be sender; + struct evm_address address; + struct evm_address sender; struct evm_uint256be value; const uint8_t* input; size_t input_size; @@ -81,8 +81,8 @@ struct evm_message { struct evm_tx_context { struct evm_uint256be tx_gas_price; - struct evm_uint160be tx_origin; - struct evm_uint160be block_coinbase; + struct evm_address tx_origin; + struct evm_address block_coinbase; int64_t block_number; int64_t block_timestamp; int64_t block_gas_limit; @@ -196,7 +196,7 @@ struct evm_result { /// @param address The address of the account the query is about. /// @return 1 if exists, 0 otherwise. typedef int (*evm_account_exists_fn)(struct evm_context* context, - const struct evm_uint160be* address); + const struct evm_address* address); /// Get storage callback function. /// @@ -209,7 +209,7 @@ typedef int (*evm_account_exists_fn)(struct evm_context* context, /// @param key The index of the storage entry. typedef void (*evm_get_storage_fn)(struct evm_uint256be* result, struct evm_context* context, - const struct evm_uint160be* address, + const struct evm_address* address, const struct evm_uint256be* key); /// Set storage callback function. @@ -222,7 +222,7 @@ typedef void (*evm_get_storage_fn)(struct evm_uint256be* result, /// @param key The index of the storage entry. /// @param value The value to be stored. typedef void (*evm_set_storage_fn)(struct evm_context* context, - const struct evm_uint160be* address, + const struct evm_address* address, const struct evm_uint256be* key, const struct evm_uint256be* value); @@ -236,7 +236,7 @@ typedef void (*evm_set_storage_fn)(struct evm_context* context, /// @param address The address. typedef void (*evm_get_balance_fn)(struct evm_uint256be* result, struct evm_context* context, - const struct evm_uint160be* address); + const struct evm_address* address); /// Get code callback function. /// @@ -251,7 +251,7 @@ typedef void (*evm_get_balance_fn)(struct evm_uint256be* result, /// @return The size of the code. typedef size_t (*evm_get_code_fn)(const uint8_t** result_code, struct evm_context* context, - const struct evm_uint160be* address); + const struct evm_address* address); /// Selfdestruct callback function. /// @@ -262,8 +262,8 @@ typedef size_t (*evm_get_code_fn)(const uint8_t** result_code, /// @param beneficiary The address where the remaining ETH is going to be /// transferred. typedef void (*evm_selfdestruct_fn)(struct evm_context* context, - const struct evm_uint160be* address, - const struct evm_uint160be* beneficiary); + const struct evm_address* address, + const struct evm_address* beneficiary); /// Log callback function. /// @@ -278,7 +278,7 @@ typedef void (*evm_selfdestruct_fn)(struct evm_context* context, /// @param topics_count The number of the topics. Valid values are between /// 0 and 4 inclusively. typedef void (*evm_log_fn)(struct evm_context* context, - const struct evm_uint160be* address, + const struct evm_address* address, const uint8_t* data, size_t data_size, const struct evm_uint256be topics[],