diff --git a/rust/tw_coin_registry/src/blockchain_type.rs b/rust/tw_coin_registry/src/blockchain_type.rs index e673d6ff476..357697cd83c 100644 --- a/rust/tw_coin_registry/src/blockchain_type.rs +++ b/rust/tw_coin_registry/src/blockchain_type.rs @@ -19,9 +19,10 @@ pub enum BlockchainType { NativeEvmos, NativeInjective, Ronin, - Unsupported, Thorchain, // end_of_blockchain_type - USED TO GENERATE CODE + #[serde(other)] + Unsupported, } impl BlockchainType { diff --git a/rust/wallet_core_rs/src/ffi/ethereum/abi.rs b/rust/wallet_core_rs/src/ffi/ethereum/abi.rs index 76b9906d0bc..84f64877781 100644 --- a/rust/wallet_core_rs/src/ffi/ethereum/abi.rs +++ b/rust/wallet_core_rs/src/ffi/ethereum/abi.rs @@ -20,9 +20,10 @@ use tw_misc::try_or_else; /// \return serialized `EthereumAbi::Proto::ContractCallDecodingOutput`. #[no_mangle] pub unsafe extern "C" fn tw_ethereum_abi_decode_contract_call( - coin: CoinType, + coin: u32, input: *const TWData, ) -> *mut TWData { + let coin = try_or_else!(CoinType::try_from(coin), std::ptr::null_mut); let input_data = try_or_else!(TWData::from_ptr_as_ref(input), std::ptr::null_mut); let evm_dispatcher = try_or_else!(evm_dispatcher(coin), std::ptr::null_mut); @@ -39,9 +40,10 @@ pub unsafe extern "C" fn tw_ethereum_abi_decode_contract_call( /// \return The serialized data of a `TW.EthereumAbi.Proto.ParamsDecodingOutput` proto object. #[no_mangle] pub unsafe extern "C" fn tw_ethereum_abi_decode_params( - coin: CoinType, + coin: u32, input: *const TWData, ) -> *mut TWData { + let coin = try_or_else!(CoinType::try_from(coin), std::ptr::null_mut); let input_data = try_or_else!(TWData::from_ptr_as_ref(input), std::ptr::null_mut); let evm_dispatcher = try_or_else!(evm_dispatcher(coin), std::ptr::null_mut); @@ -58,9 +60,10 @@ pub unsafe extern "C" fn tw_ethereum_abi_decode_params( /// \return function type signature as a Non-null string. #[no_mangle] pub unsafe extern "C" fn tw_ethereum_abi_function_get_signature( - coin: CoinType, + coin: u32, input: *const TWData, ) -> *mut TWString { + let coin = try_or_else!(CoinType::try_from(coin), std::ptr::null_mut); let input_data = try_or_else!(TWData::from_ptr_as_ref(input), || TWString::new() .into_ptr()); let evm_dispatcher = try_or_else!(evm_dispatcher(coin), || TWString::new().into_ptr()); @@ -78,9 +81,10 @@ pub unsafe extern "C" fn tw_ethereum_abi_function_get_signature( /// \return The serialized data of a `TW.EthereumAbi.Proto.FunctionEncodingOutput` proto object. #[no_mangle] pub unsafe extern "C" fn tw_ethereum_abi_encode_function( - coin: CoinType, + coin: u32, input: *const TWData, ) -> *mut TWData { + let coin = try_or_else!(CoinType::try_from(coin), std::ptr::null_mut); let input_data = try_or_else!(TWData::from_ptr_as_ref(input), std::ptr::null_mut); let evm_dispatcher = try_or_else!(evm_dispatcher(coin), std::ptr::null_mut); @@ -97,9 +101,10 @@ pub unsafe extern "C" fn tw_ethereum_abi_encode_function( /// \return The serialized data of a `TW.EthereumAbi.Proto.ValueDecodingOutput` proto object. #[no_mangle] pub unsafe extern "C" fn tw_ethereum_abi_decode_value( - coin: CoinType, + coin: u32, input: *const TWData, ) -> *mut TWData { + let coin = try_or_else!(CoinType::try_from(coin), std::ptr::null_mut); let input_data = try_or_else!(TWData::from_ptr_as_ref(input), std::ptr::null_mut); let evm_dispatcher = try_or_else!(evm_dispatcher(coin), std::ptr::null_mut); diff --git a/rust/wallet_core_rs/src/ffi/ethereum/rlp.rs b/rust/wallet_core_rs/src/ffi/ethereum/rlp.rs index 308228bd09b..f13470891c6 100644 --- a/rust/wallet_core_rs/src/ffi/ethereum/rlp.rs +++ b/rust/wallet_core_rs/src/ffi/ethereum/rlp.rs @@ -18,10 +18,8 @@ use tw_misc::try_or_else; /// \param input Non-null serialized `EthereumRlp::Proto::EncodingInput`. /// \return serialized `EthereumRlp::Proto::EncodingOutput`. #[no_mangle] -pub unsafe extern "C" fn tw_ethereum_rlp_encode( - coin: CoinType, - input: *const TWData, -) -> *mut TWData { +pub unsafe extern "C" fn tw_ethereum_rlp_encode(coin: u32, input: *const TWData) -> *mut TWData { + let coin = try_or_else!(CoinType::try_from(coin), std::ptr::null_mut); let input_data = try_or_else!(TWData::from_ptr_as_ref(input), std::ptr::null_mut); let evm_dispatcher = try_or_else!(evm_dispatcher(coin), std::ptr::null_mut); evm_dispatcher diff --git a/rust/wallet_core_rs/tests/ethereum_abi.rs b/rust/wallet_core_rs/tests/ethereum_abi.rs index 32adc18abbb..50f1dd09d7e 100644 --- a/rust/wallet_core_rs/tests/ethereum_abi.rs +++ b/rust/wallet_core_rs/tests/ethereum_abi.rs @@ -57,7 +57,7 @@ fn test_ethereum_abi_decode_contract_call() { let input_data = TWDataHelper::create(serialize(&input).unwrap()); let output_data = TWDataHelper::wrap(unsafe { - tw_ethereum_abi_decode_contract_call(CoinType::Ethereum, input_data.ptr()) + tw_ethereum_abi_decode_contract_call(CoinType::Ethereum as u32, input_data.ptr()) }) .to_vec() .expect("!tw_ethereum_abi_decode_contract_call returned nullptr"); @@ -97,7 +97,7 @@ fn test_ethereum_abi_decode_params() { let input_data = TWDataHelper::create(serialize(&input).unwrap()); let output_data = TWDataHelper::wrap(unsafe { - tw_ethereum_abi_decode_params(CoinType::Ethereum, input_data.ptr()) + tw_ethereum_abi_decode_params(CoinType::Ethereum as u32, input_data.ptr()) }) .to_vec() .expect("!tw_ethereum_abi_decode_params returned nullptr"); @@ -134,7 +134,7 @@ fn test_ethereum_abi_function_get_signature() { let input_data = TWDataHelper::create(serialize(&input).unwrap()); let actual = TWStringHelper::wrap(unsafe { - tw_ethereum_abi_function_get_signature(CoinType::Ethereum, input_data.ptr()) + tw_ethereum_abi_function_get_signature(CoinType::Ethereum as u32, input_data.ptr()) }) .to_string() .expect("!tw_ethereum_abi_function_get_signature returned nullptr"); @@ -155,7 +155,7 @@ fn test_ethereum_abi_encode_function() { let input_data = TWDataHelper::create(serialize(&input).unwrap()); let output_data = TWDataHelper::wrap(unsafe { - tw_ethereum_abi_encode_function(CoinType::Ethereum, input_data.ptr()) + tw_ethereum_abi_encode_function(CoinType::Ethereum as u32, input_data.ptr()) }) .to_vec() .expect("!tw_ethereum_abi_encode_function returned nullptr"); @@ -181,7 +181,7 @@ fn test_ethereum_abi_decode_value() { let input_data = TWDataHelper::create(serialize(&input).unwrap()); let output_data = TWDataHelper::wrap(unsafe { - tw_ethereum_abi_decode_value(CoinType::Ethereum, input_data.ptr()) + tw_ethereum_abi_decode_value(CoinType::Ethereum as u32, input_data.ptr()) }) .to_vec() .expect("!tw_ethereum_abi_decode_value returned nullptr"); diff --git a/rust/wallet_core_rs/tests/ethereum_rlp.rs b/rust/wallet_core_rs/tests/ethereum_rlp.rs index 4e689c79c8e..2326c482042 100644 --- a/rust/wallet_core_rs/tests/ethereum_rlp.rs +++ b/rust/wallet_core_rs/tests/ethereum_rlp.rs @@ -21,10 +21,11 @@ fn test_ethereum_rlp() { let input = RlpProto::EncodingInput { item: Some(item) }; let input_data = TWDataHelper::create(serialize(&input).unwrap()); - let output_data = - TWDataHelper::wrap(unsafe { tw_ethereum_rlp_encode(CoinType::Ethereum, input_data.ptr()) }) - .to_vec() - .expect("!tw_ethereum_rlp_encode returned nullptr"); + let output_data = TWDataHelper::wrap(unsafe { + tw_ethereum_rlp_encode(CoinType::Ethereum as u32, input_data.ptr()) + }) + .to_vec() + .expect("!tw_ethereum_rlp_encode returned nullptr"); let output: RlpProto::EncodingOutput = deserialize(&output_data).expect("!tw_ethereum_rlp_encode returned an invalid output");