diff --git a/bindings/rust/evmc-vm/src/lib.rs b/bindings/rust/evmc-vm/src/lib.rs index c9eb04a..017d8ff 100644 --- a/bindings/rust/evmc-vm/src/lib.rs +++ b/bindings/rust/evmc-vm/src/lib.rs @@ -18,13 +18,19 @@ impl ExecutionResult { _status_code: ffi::evmc_status_code, _gas_left: i64, _output: Option>, - _create_address: ffi::evmc_address, + _create_address: Option, ) -> Self { ExecutionResult { status_code: _status_code, gas_left: _gas_left, output: _output, - create_address: _create_address, + create_address: { + if let Some(_create_address) = _create_address { + _create_address + } else { + ffi::evmc_address { bytes: [0u8; 20] } + } + }, } } @@ -181,7 +187,7 @@ mod tests { ffi::evmc_status_code::EVMC_FAILURE, 420, None, - ffi::evmc_address { bytes: [0u8; 20] }, + Some(ffi::evmc_address { bytes: [0u8; 20] }), ); assert!(r.get_status_code() == ffi::evmc_status_code::EVMC_FAILURE); @@ -219,7 +225,7 @@ mod tests { ffi::evmc_status_code::EVMC_FAILURE, 420, Some(vec![0xc0, 0xff, 0xee, 0x71, 0x75]), - ffi::evmc_address { bytes: [0u8; 20] }, + Some(ffi::evmc_address { bytes: [0u8; 20] }), ); let f: *const ffi::evmc_result = r.into(); @@ -246,7 +252,7 @@ mod tests { ffi::evmc_status_code::EVMC_FAILURE, 420, None, - ffi::evmc_address { bytes: [0u8; 20] }, + Some(ffi::evmc_address { bytes: [0u8; 20] }), ); let f: *const ffi::evmc_result = r.into(); @@ -269,7 +275,7 @@ mod tests { ffi::evmc_status_code::EVMC_FAILURE, 420, Some(vec![0xc0, 0xff, 0xee, 0x71, 0x75]), - ffi::evmc_address { bytes: [0u8; 20] }, + Some(ffi::evmc_address { bytes: [0u8; 20] }), ); let f: ffi::evmc_result = r.into(); @@ -295,7 +301,7 @@ mod tests { ffi::evmc_status_code::EVMC_FAILURE, 420, None, - ffi::evmc_address { bytes: [0u8; 20] }, + Some(ffi::evmc_address { bytes: [0u8; 20] }), ); let f: ffi::evmc_result = r.into(); diff --git a/examples/example-rust-vm/src/lib.rs b/examples/example-rust-vm/src/lib.rs index b37590a..fd917d3 100644 --- a/examples/example-rust-vm/src/lib.rs +++ b/examples/example-rust-vm/src/lib.rs @@ -13,19 +13,13 @@ extern "C" fn execute( let is_create = unsafe { (*msg).kind == ffi::evmc_call_kind::EVMC_CREATE }; if is_create { - evmc_vm::ExecutionResult::new( - ffi::evmc_status_code::EVMC_FAILURE, - 0, - None, - ffi::evmc_address { bytes: [0u8; 20] }, - ) - .into() + evmc_vm::ExecutionResult::new(ffi::evmc_status_code::EVMC_FAILURE, 0, None, None).into() } else { evmc_vm::ExecutionResult::new( ffi::evmc_status_code::EVMC_SUCCESS, 66, Some(vec![0xc0, 0xff, 0xee]), - ffi::evmc_address { bytes: [0u8; 20] }, + None, ) .into() }