Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix error serialization
  • Loading branch information
librelois committed Dec 10, 2021
commit c282f457c0bc99a10b762fb93dcf1174db0f086a
11 changes: 5 additions & 6 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub use overrides::{
use ethereum_types::{H160, H256};
use evm::ExitError;
pub use fc_rpc_core::types::TransactionMessage;
use jsonrpsee::types::{v2::ErrorCode, CallError, Error, JsonRawValue};
use jsonrpsee::types::{v2::ErrorCode, CallError, Error};
use pallet_evm::ExitReason;
use rustc_hex::ToHex;
use sha3::{Digest, Keccak256};
Expand Down Expand Up @@ -219,7 +219,7 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<()
code: ErrorCode::InternalError.code(),
message: format!("evm error: {:?}", e),
data: Some(
JsonRawValue::from_string("0x".to_string()).expect("fail to serialize data"),
jsonrpsee::types::to_json_raw_value(&"0x").expect("fail to serialize data"),
),
})
}
Expand All @@ -238,16 +238,15 @@ pub fn error_on_execution_failure(reason: &ExitReason, data: &[u8]) -> Result<()
code: ErrorCode::InternalError.code(),
message,
data: Some(
JsonRawValue::from_string(data.to_hex()).expect("fail to serialize data"),
jsonrpsee::types::to_json_raw_value::<String>(&data.to_hex())
.expect("fail to serialize data"),
),
})
}
ExitReason::Fatal(e) => Err(CallError::Custom {
code: ErrorCode::InternalError.code(),
message: format!("evm fatal: {:?}", e),
data: Some(
JsonRawValue::from_string("0x".to_string()).expect("fail to serialize data"),
),
data: Some(jsonrpsee::types::to_json_raw_value(&"0x").expect("fail to serialize data")),
}),
}
}
Expand Down