Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

type annotations needed in substrate frotier rpc pallet

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading