1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
use crate::types::{Bytes, TargetId};
use codec::{Decode, Encode, Input};
use scale_info::TypeInfo;
use sp_core::{crypto::AccountId32, H160, H256, U256};
use sp_runtime::DispatchError;
use sp_std::prelude::*;
pub fn get_remote_bid_abi_descriptor() -> Vec<u8> {
b"WinnerSelected:Log(sfxId+:H256,winner+:Account20)".to_vec()
}
pub struct RemoteEVMBidLog {
pub sfx_id: H256,
pub winner: H160,
}
// Implement custom Scale decoding for RemoteEVMBidLog
impl Decode for RemoteEVMBidLog {
fn decode<I: Input>(input: &mut I) -> Result<Self, codec::Error> {
// Skip first byte
input.read_byte()?;
let sfx_id = H256::decode(input)?;
let winner = H160::decode(input)?;
Ok(RemoteEVMBidLog { sfx_id, winner })
}
}
// event Confirmation(
// bytes32 indexed id,
// address indexed target,
// uint256 indexed amount,
// address asset,
// address sender
// );
pub fn get_remote_confirmation_abi_descriptor() -> Vec<u8> {
b"Confirmation:Log(sfxId+:H256,target+:Account20,amount+:Value256,asset:Account20,sender:Account20)".to_vec()
}
pub struct RemoteEVMConfirmationLog {
pub sfx_id: H256,
pub target: H160,
pub amount: U256,
pub asset: H160,
pub sender: H160,
}
// Implement custom Scale decoding for RemoteEVMConfirmationLog
impl Decode for RemoteEVMConfirmationLog {
fn decode<I: Input>(input: &mut I) -> Result<Self, codec::Error> {
// Skip first byte
input.read_byte()?;
let sfx_id = H256::decode(input)?;
let target = H160::decode(input)?;
let amount = U256::decode(input)?;
let asset = H160::decode(input)?;
let sender = H160::decode(input)?;
Ok(RemoteEVMConfirmationLog {
sfx_id,
target,
amount,
asset,
sender,
})
}
}
// event TransferCommitApplied(bytes32 indexed sfxId, address indexed executor);
pub fn get_remote_transfer_commit_applied_abi_descriptor() -> Vec<u8> {
b"TransferCommitApplied:Log(sfxId+:H256,executor+:Account20)".to_vec()
}
pub struct RemoteEVMCommitLog {
pub sfx_id: H256,
pub executor: H160,
}
// Implement custom Scale decoding for RemoteEVMCommitLog
impl Decode for RemoteEVMCommitLog {
fn decode<I: Input>(input: &mut I) -> Result<Self, codec::Error> {
// Skip first byte
input.read_byte()?;
let sfx_id = H256::decode(input)?;
let executor = H160::decode(input)?;
Ok(RemoteEVMCommitLog { sfx_id, executor })
}
}
// emit OrderCreated(id, destination, asset, targetAccount, amount, rewardAsset, insurance, maxReward, nonce);
// event RemoteOrderIndexedCreated(bytes32 indexed id, uint32 indexed nonce, address indexed sender, bytes input);
// where input = abi.encode(destination, asset, targetAccount, amount, rewardAsset, insurance, maxReward)
pub fn get_remote_order_abi_descriptor() -> Vec<u8> {
b"RemoteOrderIndexed:Log(sfxId+:H256,nonce+:Value32,sender+:Account20,destination:Bytes4,asset:Bytes4,targetAccount:Account32,amount:Value256,rewardAsset:Account20,insurance:Value256,maxReward:Value256)".to_vec()
}
#[derive(Debug, Clone, Eq, PartialEq, Encode, TypeInfo)]
pub struct RemoteEVMOrderLog {
pub sfx_id: H256,
pub nonce: u32,
pub sender: H160,
pub destination: TargetId,
pub asset: u32,
pub target_account: AccountId32,
pub amount: U256,
pub reward_asset: H160,
pub insurance: U256,
pub max_reward: U256,
}
// Implement custom Scale decoding for RemoteEVMOrderLog
impl Decode for RemoteEVMOrderLog {
fn decode<I: Input>(input: &mut I) -> Result<Self, codec::Error> {
// Skip first byte
input.read_byte()?;
let sfx_id = H256::decode(input)?;
let nonce = u32::decode(input)?;
let sender = H160::decode(input)?;
let destination = TargetId::decode(input)?;
let asset = u32::decode(input)?;
let target_account = AccountId32::decode(input)?;
let amount = U256::decode(input)?;
let reward_asset = H160::decode(input)?;
let insurance = U256::decode(input)?;
let max_reward = U256::decode(input)?;
Ok(RemoteEVMOrderLog {
sfx_id,
nonce,
sender,
destination,
asset,
target_account,
amount,
reward_asset,
insurance,
max_reward,
})
}
}
pub fn get_instant_order_commit_abi_descriptor() -> Vec<u8> {
b"OrderCommitted:Log(sfxId+:H256,to+:Account20,amount:Value256,empty32Bytes:H256,signatureLength:Value32,signaturePart1:H256,signaturePart2:H256,signaturePart3:H256)".to_vec()
}
#[derive(Debug, Clone, Eq, PartialEq, Encode, TypeInfo)]
pub struct RemoteEVMInstantOrderCommitLog {
pub sfx_id: H256,
pub to: H160, // this must be set to the address of User on the remote evm
pub amount: U256,
pub signature: Bytes,
}
impl RemoteEVMInstantOrderCommitLog {
pub fn trim_signature(event_bytes: Vec<u8>) -> Result<Bytes, DispatchError> {
// Cut off and trim the bytes of SFX ID as well
let mut event_bytes = event_bytes;
// assert event_bytes length is correct and matches the length of the event 32 * 5 = 160
assert!(event_bytes.len() > 192);
// repeat the bytes of Amount on the last 32 bytes overriding last 32 bytes of signature
let amount_bytes = event_bytes[event_bytes.len() - 192..event_bytes.len() - 160].to_vec();
event_bytes.truncate(event_bytes.len() - 32);
event_bytes.extend_from_slice(&amount_bytes[..]);
// trim last 32 * 5 = 160 bytes out of data
Ok(event_bytes)
}
}
// Implement custom Scale decoding for RemoteEVMInstantOrderCommitLog
impl Decode for RemoteEVMInstantOrderCommitLog {
fn decode<I: Input>(input: &mut I) -> Result<Self, codec::Error> {
// Skip first byte
input.read_byte()?;
let sfx_id = H256::decode(input)?;
let to = H160::decode(input)?;
let amount = U256::decode(input)?;
let _empty_32_bytes = H256::decode(input)?;
let signature_length = u32::decode(input)?;
let signature_part_1 = H256::decode(input)?;
let signature_part_2 = H256::decode(input)?;
let signature_part_3 = H256::decode(input)?;
let mut signature = vec![];
signature.extend_from_slice(&signature_part_1[..]);
signature.extend_from_slice(&signature_part_2[..]);
signature.extend_from_slice(&signature_part_3[..1]);
// assert signature length is correct and matches the length of the signature 65
assert_eq!(signature_length, 65);
Ok(RemoteEVMInstantOrderCommitLog {
sfx_id,
to,
amount,
signature,
})
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{recode::recode_bytes_with_descriptor, Codec};
use frame_support::assert_ok;
use hex_literal::hex;
#[test]
fn test_remote_instant_commit_order_log_recodes_from_raw_rlp_event_bytes() {
// 🧮proof-calculated receipts root vs block receipts root: 0x7cf22a8b118f8ac7b23ae22af92c9580b362791b25aba105e34513c1404096cd 0x7cf22a8b118f8ac7b23ae22af92c9580b362791b25aba105e34513c1404096cd
// Proof generated
// {
// proof: [
// 'f8d1a013f4e094a48f767db2a4b041e2754899ac3cb98cfc0c3567ee117557b7ca9b14a0b97c3a374bb6265f16a54e0e56ac0d5ded98c02c687d36b0bb3704e576b10173a084d2c3e64b39142a387ab77398779f29d0d12fbfbd56250c23afb0eeff07cca3a0dd1bdfae88e83cd2139abaaad042fb942bb39eb83377334ed17dfc407f4ebfb3a0765deb5c64ff9e1f0d13024a383178239017ac0c0cb10d94974466c6a890561d808080a0b42b62d56e675514d7a65c84d126e7329fee8c32f736e81c8228a18595fc9c208080808080808080',
// 'f90211a0577f52ca97aca0a7f4751de42c8e2c90da59ae3f04f0d45f416429421e994120a048e5b59cfa22b444a94e0ed85701d0744a2f3251c8a47bc83cd3a9f5e883b4b3a0b33fcc09acb4368a6104c5cb53ace3ac90027a5f5b1acda4cf269e6f1c00b75fa0a4256b08b3e7e1be2b5e90fd86f5068ceb4465b2c9b554cc93dbe7cfc5fe31f8a0a69597bc3d185903ebcffcbec100cc597d27d1e67a3be674bdb58e3785100109a020cdaad17c24e2d5f1637f1a521ad45880fb810e05881677e546b0335194c5b4a09c5e1404ec211714e54289905ca13d61f4e8961cb732148a9a5cc61bb77ba8e0a07d6a13e376d1fba3f0781a616148384387df1b64813c02282c593083cb25afdaa00034928b893a5b9b788ce811a87e8b5a3c9d208d773364e9f482848f5075351da09347fd8eeaa1157aa9c46056c652ff1ce50cafcd0437dd6859473b4679743a83a0367d316122e7a57b0fb0c6d77d27902d89e3c77a55d15b98aa24cf65c154893aa0b6b0b712bcf8039693ea164760cda5edcb49943973f11417e1183beaa83c3004a07d1a208d5b22c4702c99267f194bdca44e3744301243c55b262fe801fbce7fada0950ac5664cfb6f605f5577e9a12f5f35af446d3702765fb0b53cf5cc583a2b55a0800b2f9850caeb3b84c9e72d4ff15a4604ecb0c08f4d078873758ae1ddd467f7a0d06602f91358bb55f6b1aa50065292bf780c91246514921d947d337c9a68fd3680',
// 'f9025220b9024e02f9024a01836fe439b9010000000000000000000000000400000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000200000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000002000000000000000000010000000000020000000000000000000000000000000000000000000000000000200000000000000000f9013ff9013c94842c115d11539c5af7f1dc171296f44f20ce7fdcf863a0839abeb554b654da2186e0f964e98da21e676b0c3177f2560b4c97671a2f7ea0a00909090909090909090909090909090909090909090909090909090909090909a0000000000000000000000000f61fa39fb137710b4383e0f1268bb1b09c6a7e8db8c0000000000000000000000000000000000000000000000000000000174876e80000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041d56e34aca5ad513434d73c9f5af25c72e3eb2dcd009696a49d9b3419c452250707ff4b564062c1982eb07fb540f1ed42279a7a467a591ded8e75a59969663e4f1c00000000000000000000000000000000000000000000000000000000000000'
// ],
// root: '7cf22a8b118f8ac7b23ae22af92c9580b362791b25aba105e34513c1404096cd',
// index: Uint8Array(1) [ 54 ],
// value: '02f9024a01836fe439b9010000000000000000000000000400000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000200000000000000000000000000000000000000000000000000000000000000010001000000000000000000000000000000002000000000000000000010000000000020000000000000000000000000000000000000000000000000000200000000000000000f9013ff9013c94842c115d11539c5af7f1dc171296f44f20ce7fdcf863a0839abeb554b654da2186e0f964e98da21e676b0c3177f2560b4c97671a2f7ea0a00909090909090909090909090909090909090909090909090909090909090909a0000000000000000000000000f61fa39fb137710b4383e0f1268bb1b09c6a7e8db8c0000000000000000000000000000000000000000000000000000000174876e80000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041d56e34aca5ad513434d73c9f5af25c72e3eb2dcd009696a49d9b3419c452250707ff4b564062c1982eb07fb540f1ed42279a7a467a591ded8e75a59969663e4f1c00000000000000000000000000000000000000000000000000000000000000',
// event: 'f9013c94842c115d11539c5af7f1dc171296f44f20ce7fdcf863a0839abeb554b654da2186e0f964e98da21e676b0c3177f2560b4c97671a2f7ea0a00909090909090909090909090909090909090909090909090909090909090909a0000000000000000000000000f61fa39fb137710b4383e0f1268bb1b09c6a7e8db8c0000000000000000000000000000000000000000000000000000000174876e80000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041d56e34aca5ad513434d73c9f5af25c72e3eb2dcd009696a49d9b3419c452250707ff4b564062c1982eb07fb540f1ed42279a7a467a591ded8e75a59969663e4f1c00000000000000000000000000000000000000000000000000000000000000'
// }
let encoded_event: Vec<u8> = hex!("f9013c94842c115d11539c5af7f1dc171296f44f20ce7fdcf863a0839abeb554b654da2186e0f964e98da21e676b0c3177f2560b4c97671a2f7ea0a00909090909090909090909090909090909090909090909090909090909090909a0000000000000000000000000f61fa39fb137710b4383e0f1268bb1b09c6a7e8db8c0000000000000000000000000000000000000000000000000000000174876e80000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041d56e34aca5ad513434d73c9f5af25c72e3eb2dcd009696a49d9b3419c452250707ff4b564062c1982eb07fb540f1ed42279a7a467a591ded8e75a59969663e4f1c00000000000000000000000000000000000000000000000000000000000000").into();
let recoded_message = recode_bytes_with_descriptor(
encoded_event.clone(),
get_instant_order_commit_abi_descriptor(),
Codec::Rlp,
Codec::Scale,
);
assert_ok!(recoded_message.clone());
let recoded_message = recoded_message.unwrap();
let decoded_remote_instant_commit_order_log =
RemoteEVMInstantOrderCommitLog::decode(&mut &recoded_message[..]);
assert_ok!(decoded_remote_instant_commit_order_log.clone());
const GWEI: u128 = 1_000_000_000u128;
assert_eq!(
decoded_remote_instant_commit_order_log,
Ok(RemoteEVMInstantOrderCommitLog {
sfx_id: hex!("0909090909090909090909090909090909090909090909090909090909090909").into(),
to: hex!("f61fa39fb137710b4383e0f1268bb1b09c6a7e8d").into(),
amount: U256::from(100 * GWEI), // 100gwei (gwei is 10^9 wei)
signature: hex!("d56e34aca5ad513434d73c9f5af25c72e3eb2dcd009696a49d9b3419c452250707ff4b564062c1982eb07fb540f1ed42279a7a467a591ded8e75a59969663e4f1c").to_vec(),
})
);
let _decoded_remote_instant_commit_order_log =
decoded_remote_instant_commit_order_log.unwrap();
// Trimming signature goes okey
let trimmed_signature =
RemoteEVMInstantOrderCommitLog::trim_signature(encoded_event.clone());
assert_ok!(trimmed_signature.clone());
let trimmed_signature = trimmed_signature.unwrap();
assert_ok!(crate::standard::get_sfx_transfer_asset_abi()
.validate_arguments_against_received(
&vec![
0u32.encode(), // empty asset id
hex!("000000000000000000000000f61fa39fb137710b4383e0f1268bb1b09c6a7e8d")
.to_vec(), // to
(100u128 * GWEI).encode(), // amount
],
trimmed_signature,
&Codec::Scale,
&Codec::Rlp,
));
}
#[test]
fn test_remote_order_log_recodes_from_raw_rlp_event_bytes() {
// Computed Root: 0x76435ece9646ad97cbaf7e8190af314df7f577b31f02f9c8ff12d3ea5a68b966
// 🧮proof-calculated receipts root vs block receipts root: 0x76435ece9646ad97cbaf7e8190af314df7f577b31f02f9c8ff12d3ea5a68b966 0x76435ece9646ad97cbaf7e8190af314df7f577b31f02f9c8ff12d3ea5a68b966
// {
// proof: [
// 'f8b1a0d573cf15a54d7ad0d0498169820a6dafd9633adec0f688d9d859d1741cdac5b6a03c3d817222f0515e057962c0db4bfd20674e227a3b3c43811b2f8f1357e127cea03fe55d8df8a0c96030c87b2f2caf2bc6f102b5546e097fda3f6eb8c89370ea6ca00e3ccf072c8ad2c828f4d859e0776b24cf345009c5cf3107413186a0617e5f7980808080a0e58215be848c1293dd381210359d84485553000a82b67410406d183b42adbbdd8080808080808080',
// 'f90211a086ff47818c4ed0f1d97d62c83605e662754d5c21d94e807c2142f7294eefda64a034960e2a1e3ec16b96816e81f842a51291989f5606c41aadba21b8069adaad64a057f37f57fecb0d336797db86604ea1d73a7933d5e6043c371729ca90989d5f8ca034754510b4bf1c613de0202a877a92be3e81ae1aacef713ac63d7fcdbeb84e05a099ec62a5e2b7bd634351e10bbdad33afbb3d9b52cb9b0a449fd38cec498624aba0f6b2fa50ec73e180a7c8b61cceacc8bfdf9214ef3df95abf4fa7b2e0ee38bb1aa0bc1b4735f691d698650aa757c1fac347e47b272dca9780293a091755f1eb49c4a0bb81253270782d099bd0cb4b5ab1fe9faad27c1657d6e55c7bce1129b0426011a03a2e7a799dc4f627368880fa7bfe6116ad913eaa04c1b200ecc5f4980ced9558a0649a03c1e451f6033a6b359f819c019ca9eb5fdb140bc5f01d9f369e2f1d69e8a04172cab94d1db98e819c0f5513d4944806a110862d9d8b67981cec1f5e1b3358a02e73b02f64e412bb54b38dc94bd232934438951d765abfa71df971606f9b6f74a0089c2c3e3b0c99a5f22d0c8c2e29c5e89835aa3d0848722eb1a52ef1cd0bae56a05b5a11c3bd83a7a0c764b11ccdf98de8ae91012637ab318f5ba980d303d199dba05fe9d9c59da9e5e95049f9baaa514da634b87daf0307d8de047399395b3ec606a002373b6677d1b3d1ebe4501df696607732e075a452e05f9b6aa8323fe7ee05d880',
// 'f902d420b902d002f902cc018354abeab9010000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000004000000000000000000000001000000000020000000000000000000800000000000000000000000000000000000000000000000004010000000000000000000000000000000000002000000000000000000000000000000000200000000000000400000000060000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000008f901c1f901be9496502ef03decd4aabd368cc46f5c2c22a645948cf884a07f1c6663f3b95396ee5e22d3f5fff2058cf091e620a0b1907eda0138b382c8b6a0e2da230e52caecf528190bb0f28767e3e02a2df185bcd070c3f019537e4d5844a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f85a57d965aecd289c625cae6161d0ab5141bc66b90120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e003030303000000000000000000000000000000000000000000000000000000000000e80300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000064'
// ],
// root: '76435ece9646ad97cbaf7e8190af314df7f577b31f02f9c8ff12d3ea5a68b966',
// index: Uint8Array(1) [ 40 ],
//
// value: '02f902cc018354abeab9010000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000004000000000000000000000001000000000020000000000000000000800000000000000000000000000000000000000000000000004010000000000000000000000000000000000002000000000000000000000000000000000200000000000000400000000060000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000008f901c1f901be9496502ef03decd4aabd368cc46f5c2c22a645948cf884a07f1c6663f3b95396ee5e22d3f5fff2058cf091e620a0b1907eda0138b382c8b6a0e2da230e52caecf528190bb0f28767e3e02a2df185bcd070c3f019537e4d5844a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f85a57d965aecd289c625cae6161d0ab5141bc66b90120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e003030303000000000000000000000000000000000000000000000000000000000000e80300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000064',
// event: 'f901be9496502ef03decd4aabd368cc46f5c2c22a645948cf884a07f1c6663f3b95396ee5e22d3f5fff2058cf091e620a0b1907eda0138b382c8b6a0e2da230e52caecf528190bb0f28767e3e02a2df185bcd070c3f019537e4d5844a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f85a57d965aecd289c625cae6161d0ab5141bc66b90120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e003030303000000000000000000000000000000000000000000000000000000000000e80300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000064'
let encoded_event: Vec<u8> = hex!("f901be9496502ef03decd4aabd368cc46f5c2c22a645948cf884a07f1c6663f3b95396ee5e22d3f5fff2058cf091e620a0b1907eda0138b382c8b6a0e2da230e52caecf528190bb0f28767e3e02a2df185bcd070c3f019537e4d5844a00000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000f85a57d965aecd289c625cae6161d0ab5141bc66b90120000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000e003030303000000000000000000000000000000000000000000000000000000000000e80300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000064").into();
let _remote_order_abi_descriptor = get_remote_order_abi_descriptor();
let recoded_message = recode_bytes_with_descriptor(
encoded_event.clone(),
get_remote_order_abi_descriptor(),
Codec::Rlp,
Codec::Scale,
)
.unwrap();
let decoded_remote_order_log =
RemoteEVMOrderLog::decode(&mut &recoded_message[..]).unwrap();
assert_eq!(
decoded_remote_order_log,
RemoteEVMOrderLog {
sfx_id: hex!("e2da230e52caecf528190bb0f28767e3e02a2df185bcd070c3f019537e4d5844")
.into(),
nonce: 0,
sender: hex!("f85a57d965aecd289c625cae6161d0ab5141bc66").into(),
destination: [3, 3, 3, 3],
asset: 65536000,
target_account: AccountId32::from([0u8; 32]),
amount: 100.into(),
max_reward: 100.into(),
insurance: 10.into(),
reward_asset: hex!("0000000000000000000000000000000000000000").into(),
}
)
}
}