Hi guys I'm new to Rust and new to ink!, so please bear with me if I asked some silly questions.
My code is here. It comprises of an ERC20 contract and a main contract which contains some function that will change the state of the ERC20. Different from the delegator example which initialized add/subber/accumulator from codehash, my one will initialize the ERC20 by its accountID. I'm wondering whether ink-e2e allows me to test ERC20 approve/transfer from the main contract and methods in main contract that will trigger some methods in ERC20? I did following attempts in my code but failed.
When I run cargo test --features e2e-tests
I got the following errors:
error[E0599]: the function or associated item `new` exists for struct `Client<WithExtrinsicParams<ink_e2e::SubstrateConfig, BaseExtrinsicParams<ink_e2e::SubstrateConfig, PlainTip>>, DefaultEnvironment>`, but its trait bounds were not satisfied
--> lib.rs:99:9
|
99 | / #[ink_e2e::test(
100 | | additional_contracts = "erc20/Cargo.toml"
101 | | )]
| |__________^ function or associated item cannot be called on `Client<WithExtrinsicParams<ink_e2e::SubstrateConfig, BaseExtrinsicParams<ink_e2e::SubstrateConfig, PlainTip>>, DefaultEnvironment>` due to unsatisfied trait bounds
|
::: /Users/angie/.cargo/registry/src/github.com-1ecc6299db9ec823/ink_env-4.0.0-beta/src/types.rs:172:1
|
172 | pub enum DefaultEnvironment {}
| --------------------------- doesn't satisfy `DefaultEnvironment: ink_env::types::Environment`
|
::: /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/xts.rs:69:1
|
69 | pub struct Call<E: Environment, B> {
| ---------------------------------- doesn't satisfy `ink_e2e::xts::Call<DefaultEnvironment, _>: Encode`
|
= note: the following trait bounds were not satisfied:
`DefaultEnvironment: ink_env::types::Environment`
`ink_e2e::xts::Call<DefaultEnvironment, _>: Encode`
= note: this error originates in the attribute macro `ink_e2e::test` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DefaultEnvironment: ink_env::types::Environment` is not satisfied
--> lib.rs:99:9
|
99 | / #[ink_e2e::test(
100 | | additional_contracts = "erc20/Cargo.toml"
101 | | )]
| |__________^ the trait `ink_env::types::Environment` is not implemented for `DefaultEnvironment`
|
= help: the trait `ink_env::types::Environment` is implemented for `ink_env::types::DefaultEnvironment`
note: required by a bound in `Client`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/client.rs:249:8
|
249 | E: Environment,
| ^^^^^^^^^^^ required by this bound in `Client`
= note: this error originates in the attribute macro `ink_e2e::test` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> lib.rs:120:17
|
118 | let test_constructor = TestErcRef::new(
| --------------- arguments to this function are incorrect
119 | erc20_acc_id,
120 | ink_e2e::alice()
| ^^^^^^^^^^^^^^^^ expected struct `ink::ink_primitives::AccountId`, found struct `PairSigner`
|
= note: expected struct `ink::ink_primitives::AccountId`
found struct `PairSigner<_, ink_e2e::subxt::ext::sp_core::sr25519::Pair>`
note: associated function defined here
--> lib.rs:45:16
|
4 | #[ink::contract]
| ----------------
...
45 | pub fn new(
| ^^^
error[E0277]: the trait bound `Erc20Ref: ink::codegen::trait_def::call_builder::TraitCallBuilder` is not satisfied
--> lib.rs:133:43
|
133 | let approve = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ^^^^^^^^ the trait `ink::codegen::trait_def::call_builder::TraitCallBuilder` is not implemented for `Erc20Ref`
|
note: required by a bound in `build_message`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:93:10
|
93 | Ref: TraitCallBuilder + FromAccountId<ink_env::DefaultEnvironment>,
| ^^^^^^^^^^^^^^^^ required by this bound in `build_message`
error[E0277]: the trait bound `Erc20Ref: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>` is not satisfied
--> lib.rs:133:43
|
133 | let approve = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ^^^^^^^^ the trait `ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>` is not implemented for `Erc20Ref`
|
note: required by a bound in `build_message`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:93:29
|
93 | Ref: TraitCallBuilder + FromAccountId<ink_env::DefaultEnvironment>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `build_message`
error[E0308]: mismatched types
--> lib.rs:133:53
|
133 | let approve = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ------------------------- ^^^^^^^^^^^^^^^^^^^^ expected struct `ink_primitives::types::AccountId`, found struct `ink::ink_primitives::AccountId`
| |
| arguments to this function are incorrect
|
= note: perhaps two different versions of crate `ink_primitives` are being used?
note: function defined here
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:89:8
|
89 | pub fn build_message<Ref>(
| ^^^^^^^^^^^^^
error[E0599]: the method `call` exists for struct `MessageBuilder<ink_env::types::DefaultEnvironment, Erc20Ref>`, but its trait bounds were not satisfied
--> lib.rs:134:18
|
134 | .call(|contract| contract.approve(test_acc_id, 10_000));
| ^^^^ method cannot be called on `MessageBuilder<ink_env::types::DefaultEnvironment, Erc20Ref>` due to unsatisfied trait bounds
|
::: /Users/angie/Documents/CherryBooooooom/InteractWithErc20/erc20/lib.rs:13:5
|
13 | /// A simple ERC-20 contract.
| -----------------------------
| |
| doesn't satisfy `_: ink::codegen::trait_def::call_builder::TraitCallBuilder`
| doesn't satisfy `_: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>`
|
= note: the following trait bounds were not satisfied:
`Erc20Ref: ink::codegen::trait_def::call_builder::TraitCallBuilder`
`Erc20Ref: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>`
error[E0277]: the trait bound `Erc20Ref: ink::codegen::trait_def::call_builder::TraitCallBuilder` is not satisfied
--> lib.rs:142:44
|
142 | let transfer = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ^^^^^^^^ the trait `ink::codegen::trait_def::call_builder::TraitCallBuilder` is not implemented for `Erc20Ref`
|
note: required by a bound in `build_message`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:93:10
|
93 | Ref: TraitCallBuilder + FromAccountId<ink_env::DefaultEnvironment>,
| ^^^^^^^^^^^^^^^^ required by this bound in `build_message`
error[E0277]: the trait bound `Erc20Ref: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>` is not satisfied
--> lib.rs:142:44
|
142 | let transfer = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ^^^^^^^^ the trait `ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>` is not implemented for `Erc20Ref`
|
note: required by a bound in `build_message`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:93:29
|
93 | Ref: TraitCallBuilder + FromAccountId<ink_env::DefaultEnvironment>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `build_message`
error[E0308]: mismatched types
--> lib.rs:142:54
|
142 | let transfer = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ------------------------- ^^^^^^^^^^^^^^^^^^^^ expected struct `ink_primitives::types::AccountId`, found struct `ink::ink_primitives::AccountId`
| |
| arguments to this function are incorrect
|
= note: perhaps two different versions of crate `ink_primitives` are being used?
note: function defined here
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:89:8
|
89 | pub fn build_message<Ref>(
| ^^^^^^^^^^^^^
error[E0599]: the method `call` exists for struct `MessageBuilder<ink_env::types::DefaultEnvironment, Erc20Ref>`, but its trait bounds were not satisfied
--> lib.rs:143:18
|
143 | .call(|contract| contract.transfer(ink_e2e::bob(), 2_000));
| ^^^^ method cannot be called on `MessageBuilder<ink_env::types::DefaultEnvironment, Erc20Ref>` due to unsatisfied trait bounds
|
::: /Users/angie/Documents/CherryBooooooom/InteractWithErc20/erc20/lib.rs:13:5
|
13 | /// A simple ERC-20 contract.
| -----------------------------
| |
| doesn't satisfy `_: ink::codegen::trait_def::call_builder::TraitCallBuilder`
| doesn't satisfy `_: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>`
|
= note: the following trait bounds were not satisfied:
`Erc20Ref: ink::codegen::trait_def::call_builder::TraitCallBuilder`
`Erc20Ref: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>`
error[E0277]: the trait bound `Erc20Ref: ink::codegen::trait_def::call_builder::TraitCallBuilder` is not satisfied
--> lib.rs:150:46
|
150 | let balance_of = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ^^^^^^^^ the trait `ink::codegen::trait_def::call_builder::TraitCallBuilder` is not implemented for `Erc20Ref`
|
note: required by a bound in `build_message`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:93:10
|
93 | Ref: TraitCallBuilder + FromAccountId<ink_env::DefaultEnvironment>,
| ^^^^^^^^^^^^^^^^ required by this bound in `build_message`
error[E0277]: the trait bound `Erc20Ref: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>` is not satisfied
--> lib.rs:150:46
|
150 | let balance_of = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ^^^^^^^^ the trait `ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>` is not implemented for `Erc20Ref`
|
note: required by a bound in `build_message`
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:93:29
|
93 | Ref: TraitCallBuilder + FromAccountId<ink_env::DefaultEnvironment>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `build_message`
error[E0308]: mismatched types
--> lib.rs:150:56
|
150 | let balance_of = build_message::<Erc20Ref>(erc20_acc_id.clone())
| ------------------------- ^^^^^^^^^^^^^^^^^^^^ expected struct `ink_primitives::types::AccountId`, found struct `ink::ink_primitives::AccountId`
| |
| arguments to this function are incorrect
|
= note: perhaps two different versions of crate `ink_primitives` are being used?
note: function defined here
--> /Users/angie/.cargo/git/checkouts/ink-1add513eda8f5a89/fc543da/crates/e2e/src/builders.rs:89:8
|
89 | pub fn build_message<Ref>(
| ^^^^^^^^^^^^^
error[E0599]: the method `call` exists for struct `MessageBuilder<ink_env::types::DefaultEnvironment, Erc20Ref>`, but its trait bounds were not satisfied
--> lib.rs:151:14
|
151 | .call(|contract| contract.balance_of(ink_e2e::bob()));
| ^^^^ method cannot be called on `MessageBuilder<ink_env::types::DefaultEnvironment, Erc20Ref>` due to unsatisfied trait bounds
|
::: /Users/angie/Documents/CherryBooooooom/InteractWithErc20/erc20/lib.rs:13:5
|
13 | /// A simple ERC-20 contract.
| -----------------------------
| |
| doesn't satisfy `_: ink::codegen::trait_def::call_builder::TraitCallBuilder`
| doesn't satisfy `_: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>`
|
= note: the following trait bounds were not satisfied:
`Erc20Ref: ink::codegen::trait_def::call_builder::TraitCallBuilder`
`Erc20Ref: ink_env::call::create_builder::FromAccountId<ink_env::types::DefaultEnvironment>`
Some errors have detailed explanations: E0277, E0308, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `testerc` due to 15 previous errors
Could anyone help? Thanks!