git.delta.rocks / unique-network / refs/commits / e6258963f053

difftreelog

chore add selector to error message

Grigoriy Simonov2022-08-12parent: #9097925.patch.diff
in: master

2 files changed

modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -261,7 +261,8 @@
 	let (selector, mut reader) = AbiReader::new_call(input)?;
 	let call = C::parse(selector, &mut reader)?;
 	if call.is_none() {
-		return Err("Function not found".into());
+		let selector = u32::from_be_bytes(selector);
+		return Err(format!("unrecognized selector: 0x{selector:0<8x}").into());
 	}
 	let call = call.unwrap();
 
modifiedtests/src/evmCoder.test.tsdiffbeforeafterboth
27 sources: {27 sources: {
28 ['Test.sol']: {28 ['Test.sol']: {
29 content: 29 content:
30 `30 `
31 // SPDX-License-Identifier: MIT31 // SPDX-License-Identifier: MIT
32 pragma solidity ^0.8.0;32 pragma solidity ^0.8.0;
33 interface ITest {33 interface ITest {
34 function ztestzzzzzzz() external returns (uint256 n);34 function ztestzzzzzzz() external returns (uint256 n);
35 }35 }
36 contract Test {36 contract Test {
37 event Result(bool, uint256);37 event Result(bool, uint256);
38 function test1() public {38 function test1() public {
39 try39 try
40 ITest(${collectionAddress}).ztestzzzzzzz()40 ITest(${collectionAddress}).ztestzzzzzzz()
41 returns (uint256 n) {41 returns (uint256 n) {
42 // enters42 // enters
43 emit Result(true, n); // => [true, BigNumber { value: "43648854190028290368124427828690944273759144372138548774646036134290060795932" }]43 emit Result(true, n); // => [true, BigNumber { value: "43648854190028290368124427828690944273759144372138548774646036134290060795932" }]
44 } catch {44 } catch {
45 emit Result(false, 0);45 emit Result(false, 0);
46 }46 }
47 }47 }
48 function test2() public {48 function test2() public {
49 try49 try
50 ITest(${contractAddress}).ztestzzzzzzz()50 ITest(${contractAddress}).ztestzzzzzzz()
51 returns (uint256 n) {51 returns (uint256 n) {
52 emit Result(true, n);52 emit Result(true, n);
53 } catch {53 } catch {
54 // enters54 // enters
55 emit Result(false, 0); // => [ false, BigNumber { value: "0" } ]55 emit Result(false, 0); // => [ false, BigNumber { value: "0" } ]
56 }56 }
57 }
57 }58 function test3() public {
59 ITest(${collectionAddress}).ztestzzzzzzz();
60 }
58 }61 }
59 `,62 `,
60 },63 },
61 },64 },
62 settings: {65 settings: {
106 '1': '0',109 '1': '0',
107 });110 });
108 }111 }
112 {
113 await expect(testContract.methods.test3().call())
114 .to.be.rejectedWith(/unrecognized selector: 0xd9f02b36$/g);
115 }
109 });116 });
110});117});