I’m using susbtrate 2.0.1 and trying to integrate frontier implementation into the runtime, this implementation was working fine with substrate 2.0.0 but now having some syntax errors.
Frontier Dependencies
frontier-consensus = { default-features = false,git = 'https://github.com/PureStake/frontier.git', branch = 'substrate-v2' }
frontier-rpc = { default-features = false, git = 'https://github.com/PureStake/frontier.git', branch = 'substrate-v2' }
frontier-rpc-primitives = { default-features = false, git = 'https://github.com/PureStake/frontier.git', branch = 'substrate-v2' }
Below is the error :
error[E0283]: type annotations needed
--> /Users/dev/Applications/.cargo/git/checkouts/frontier-6f1ff17f29a883b0/c5fe2a6/rpc/src/eth.rs:299:56
|
299 | Ok(U256::from(self.client.info().best_number.clone().unique_saturated_into()))
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: multiple `impl`s satisfying `U256: From<_>` found in the following crates: `core`, `primitive_types`:
- impl From<&'static str> for U256;
- impl From<U128> for U256;
- impl From<[u8; _]> for U256;
- impl From<i128> for U256;
and 15 more
help: try using a fully qualified path to specify the expected types
|
299 | Ok(U256::from(<<<B as BlockT>::Header as HeaderT>::Number as UniqueSaturatedInto<T>>::unique_saturated_into(self.client.info().best_number.clone())))
type annotations needed
--> /Users/dev/Applications/.cargo/git/checkouts/frontier-6f1ff17f29a883b0/c5fe2a6/rpc/src/eth_pubsub.rs:88:46
|
88 | self.client.info().best_number.clone().unique_saturated_into() as u32
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: type must be known at this point
help: try using a fully qualified path to specify the expected types
|
88 | <<<B as BlockT>::Header as HeaderT>::Number as UniqueSaturatedInto<T>>::unique_saturated_into(self.client.info().best_number.clone()) as u32
On this line of code having this error :
fn block_number(&self) -> Result<U256> {
Ok(U256::from(self.client.info().best_number.clone().unique_saturated_into()))
}
native_number = Some(
self.client.info().best_number.clone().unique_saturated_into() as u32
);
>Solution :
The compiler can not deduce U256 from which type (u32?u64?…?) within this context.
You need to write it explicitly.
BTW, you could use saturated_into instead unique_saturated_into, which supports turbo fish style.
Example:
U256::from(self.client.info().best_number.clone().saturated_into::<u32>());
If you want unique_saturated_into anyway:
let bn: u32 = self.client.info().best_number.clone().unique_saturated_into();
U256::from(bn);