Skip to content

Commit

Permalink
support ETH property query for RPC, add getway list query response an…
Browse files Browse the repository at this point in the history
…d rpc interface(fix #8)
  • Loading branch information
Fred0327 committed Oct 24, 2023
1 parent ec298cc commit 5b27b5a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions types/src/tx_type/change_pubkey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub enum ChangePubKeyAuthData {
eth_signature: PackedEthSignature,
},
EthCreate2 {
#[serde(flatten)]
data: Create2Data,
},
}
Expand Down Expand Up @@ -316,4 +317,47 @@ mod test {

assert_eq!(bytes, expected_bytes);
}

#[test]
fn test_change_pubkey_eth_sign_msg() {
let pubkey_hash =
PubKeyHash::from_hex("0xdbd9c8235e4fc9d5b9b7bb201f1133e8a28c0edd").unwrap();
let nonce = Nonce(0);
let account_id = 2.into();
let key: H256 = [5; 32].into();
let signer = EthSigner::from(key);

Check failure on line 328 in types/src/tx_type/change_pubkey.rs

View workflow job for this annotation

GitHub Actions / cargo test

failed to resolve: use of undeclared type `EthSigner`
let eth_sign_msg = ChangePubKey::get_eth_sign_msg(&pubkey_hash, nonce, account_id);

Check failure on line 329 in types/src/tx_type/change_pubkey.rs

View workflow job for this annotation

GitHub Actions / cargo test

no function or associated item named `get_eth_sign_msg` found for struct `change_pubkey::ChangePubKey` in the current scope
let eth_signature = signer.sign_message(eth_sign_msg.as_bytes()).unwrap();
assert_eq!(eth_signature.as_hex(), "0xefd0d9c6beb00310535bb51ee58745adb547e7d875d5823892365a6450caf6c559a6a4bfd83bf336ac59cf83e97948dbf607bf2aecd24f6829c3deac20ecdb601b");
}

#[test]
fn test_change_pubkey_create2() {
let s = r#"
{
"ethAuthType":"EthCreate2",
"chainId":2,
"account":"0x4504d5BE8634e3896d42784A5aB89fc41C3d4511",
"accountId":22,
"subAccountId":0,
"fee":"0",
"nonce":0,
"ts":1698128102,
"type":"ChangePubKey",
"newPkHash":"0x179d3888ad53fb3ce5e01f548c2e7c50dea076a6",
"feeToken":17,
"ethAuthData":{
"type":"EthCreate2",
"creatorAddress":"0x6E253C951A40fAf4032faFbEc19262Cd1531A5F5",
"saltArg":"0x0000000000000000000000000000000000000000000000000000000000000000",
"codeHash":"0x4f063cd4b2e3a885f61fefb0988cc12487182c4f09ff5de374103f5812f33fe7"
},
"signature":{
"pubKey":"0b3e7d5328193b9cda3d5372cece28be209b4c7c136e734c6261c4fda965e710",
"signature":"2f28abf960060dab8d829af5e243b35e2d41545c3354eef4f897a44bca73c629b60d997e343c4a0dd95e68f879c1e09c17fccb93906d458b1a75b7910d89a303"
}
}"#;
let tx: Result<ChangePubKey, _> = serde_json::from_str(s);
assert!(tx.is_ok())
}
}

0 comments on commit 5b27b5a

Please sign in to comment.