2

I have a chain similar to mentioned in this question, where I'm trying to deploy ink! smart contracts. I'm setting my Environment like this:

use ink::env::{Environment, DefaultEnvironment};
use fp_account::AccountId20;

pub struct EthereumEnvironment;

impl Environment for EthereumEnvironment {
    const MAX_EVENT_TOPICS: usize = <DefaultEnvironment as Environment>::MAX_EVENT_TOPICS;
    type AccountId = AccountId20;
    type Balance = <DefaultEnvironment as Environment>::Balance;
    type Hash = <DefaultEnvironment as Environment>::Hash;
    type Timestamp = <DefaultEnvironment as Environment>::Timestamp;
    type BlockNumber = <DefaultEnvironment as Environment>::BlockNumber;
    type ChainExtension = ink::env::NoChainExtension;
}

However, I'm getting some compile-time errors similar to this:

error[E0277]: the trait bound `AccountId20: AsMut<[u8]>` is not satisfied
   --> lib.rs:14:22
    |
14  |     type AccountId = AccountId20;
    |                      ^^^^^^^^^^^ the trait `AsMut<[u8]>` is not implemented for `AccountId20`
    |
note: required by a bound in `ink::ink_env::Environment::AccountId`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ink_env-4.3.0/src/types.rs:136:11
    |
128 |     type AccountId: 'static
    |          --------- required by a bound in this associated type
...
136 |         + AsMut<[u8]>;
    |           ^^^^^^^^^^^ required by this bound in `Environment::AccountId`
error[E0277]: the trait bound `AccountId20: scale_encode::EncodeAsType` is not satisfied
   --> lib.rs:14:22
    |
14  |     type AccountId = AccountId20;
    |                      ^^^^^^^^^^^ the trait `scale_encode::EncodeAsType` is not implemented for `AccountId20`
    |
    = help: the following other types implement trait `scale_encode::EncodeAsType`:
              &'a T
              ()
              (A, B)
              (A, B, C)
              (A, B, C, D)
              (A, B, C, D, E)
              (A, B, C, D, E, F)
              (A, B, C, D, E, F, G)
            and 69 others
    = note: required for `<EthereumEnvironment as ink::ink_env::Environment>::AccountId` to implement `ink::ink_env::types::CodecAsType`
note: required by a bound in `ink::ink_env::Environment::AccountId`
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ink_env-4.3.0/src/types.rs:130:11
    |
128 |     type AccountId: 'static
    |          --------- required by a bound in this associated type
129 |         + scale::Codec
130 |         + CodecAsType
    |           ^^^^^^^^^^^ required by this bound in `Environment::AccountId`
error[E0277]: the trait bound `AccountId20: StorageLayout` is not satisfied
  
   |
19 | #[cfg_attr(feature = "std", derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout))]
   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StorageLayout` is not implemented for `AccountId20`
   |
   = help: the following other types implement trait `StorageLayout`:
             ()
             (A, B)
             (A, B, C)
             (A, B, C, D)
             (A, B, C, D, E)
             (A, B, C, D, E, F)
             (A, B, C, D, E, F, G)
             (A, B, C, D, E, F, G, H)
           and 65 others
   = note: this error originates in the derive macro `ink::storage::traits::StorageLayout` (in Nightly builds, run with -Z macro-backtrace for more info)

Any help in this regard will be highly appreciated. Thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.