Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken Multisig Example #1197

Closed
bernardoaraujor opened this issue Mar 22, 2022 · 11 comments · Fixed by #1198 or #1202
Closed

Broken Multisig Example #1197

bernardoaraujor opened this issue Mar 22, 2022 · 11 comments · Fixed by #1198 or #1202
Labels
A-examples [examples] Work item C-bug Something isn't working

Comments

@bernardoaraujor
Copy link

these comments on the multisig example propose the following code to generate a transaction to add new owners:

      // address of an existing `Multisig` contract
        let wallet_id: AccountId = [7u8; 32].into();
       
        // first create the transaction that adds `alice` through `add_owner`
        let alice: AccountId = [1u8; 32].into();
        let mut call = CallData::new(Selector::new([166, 229, 27, 154])); // add_owner
        call.push_arg(&alice);
        let transaction = Transaction {
            callee: wallet_id,
            selector: call.selector().to_bytes(),
            input: call.params().to_owned(),
            transferred_value: 0,
            gas_limit: 0
        };
        
        // submit the transaction for confirmation
        let mut submit = CallParams::<Env, _, _>::eval(
            wallet_id,
            Selector::new([86, 244, 13, 223]) // submit_transaction
        );
        let (id, _): (u32, ConfirmationStatus)  = submit.push_arg(&transaction)
            .fire()
            .expect("submit_transaction won't panic.");

However I'm running into the following compilation error:

error[E0107]: this struct takes 4 generic arguments but 3 generic arguments were supplied
   --> lib.rs:296:30
    |
296 |             let mut submit = CallParams::<Env, _, _>::eval(
    |                              ^^^^^^^^^^   ---  -  - supplied 3 generic arguments
    |                              |
    |                              expected 4 generic arguments
    |
note: struct defined here, with 4 generic parameters: `E`, `CallType`, `Args`, `R`
   --> /home/bear/.cargo/registry/src/github.com-1ecc6299db9ec823/ink_env-3.0.0/src/call/call_builder.rs:36:12
    |
36  | pub struct CallParams<E, CallType, Args, R>
    |            ^^^^^^^^^^ -  --------  ----  -
help: add missing generic argument
    |
296 |             let mut submit = CallParams::<Env, _, _, R>::eval(
    |                                                    +++

@bernardoaraujor bernardoaraujor added C-bug Something isn't working B-invalid This doesn't seem right A-examples [examples] Work item labels Mar 22, 2022
@cmichi
Copy link
Collaborator

cmichi commented Mar 23, 2022

@bernardoaraujor Are you using the latest stable 3.0 release? There were some changes to the CallBuilder API there and if you have the 3.0.0-rc9 dependencies in your Cargo.toml you might be using the stable release under the hood without noticing.

@bernardoaraujor
Copy link
Author

@bernardoaraujor Are you using the latest stable 3.0 release? There were some changes to the CallBuilder API there and if you have the 3.0.0-rc9 dependencies in your Cargo.toml you might be using the stable release under the hood without noticing.

doing the following on Cargo.toml wasn't enough, the error message stays the same:

-ink_prelude = { version = "3.0.0-rc9", default-features = false }
-ink_primitives = { version = "3.0.0-rc9", default-features = false }
-ink_prelude = { version = "3.0.0-rc9", default-features = false }
-ink_primitives = { version = "3.0.0-rc9", default-features = false }
-ink_metadata = { version = "3.0.0-rc9", default-features = false, features = ["derive"], optional = true }
-ink_env = { version = "3.0.0-rc9", default-features = false }
-ink_storage = { version = "3.0.0-rc9", default-features = false }
-ink_lang = { version = "3.0.0-rc9", default-features = false }
+ink_prelude = { version = "3.0.0", default-features = false }
+ink_primitives = { version = "3.0.0", default-features = false }
+ink_metadata = { version = "3.0.0", default-features = false, features = ["derive"], optional = true }
+ink_env = { version = "3.0.0", default-features = false }
+ink_storage = { version = "3.0.0", default-features = false }
+ink_lang = { version = "3.0.0", default-features = false }

@HCastano
Copy link
Contributor

@bernardoaraujor did you make sure to also run cargo update after making that change? Your Lockfile might still be pointing to the RC9 release

@bernardoaraujor
Copy link
Author

@bernardoaraujor did you make sure to also run cargo update after making that change? Your Lockfile might still be pointing to the RC9 release

yes, also when manually looking at Cargo.lock:

[[package]]
name = "ink_allocator"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "ff4500f3c3655740e36670f790c8c30c4bde9d2c86be8c71ceb80fb8d3cba1d9"
dependencies = [
 "cfg-if",
]

[[package]]
name = "ink_engine"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "9787c69c6dec595c01d4113676d99cde9b97a423ea7fde5a3aad56c41e59431a"
dependencies = [
 "blake2",
 "derive_more",
 "parity-scale-codec",
 "rand",
 "secp256k1",
 "sha2",
 "sha3",
]

[[package]]
name = "ink_env"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "e1e5c207a3a4dbad722f2be1a981511944efe9ea6970454aae54098f99149ec0"
dependencies = [
 "arrayref",
 "blake2",
 "cfg-if",
 "derive_more",
 "ink_allocator",
 "ink_engine",
 "ink_metadata",
 "ink_prelude",
 "ink_primitives",
 "num-traits",
 "parity-scale-codec",
 "paste",
 "rand",
 "rlibc",
 "scale-info",
 "secp256k1",
 "sha2",
 "sha3",
 "static_assertions",
]

[[package]]
name = "ink_eth_compatibility"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "224fae62b21dd2baa12682f308659c0907cacccf66d21bd2425db30d567cd40a"
dependencies = [
 "ink_env",
 "libsecp256k1",
]

[[package]]
name = "ink_lang"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "21d9fbc1628dc1cdeba5d81b99cc8cfc4015d0f1926a561abc85eea3d237e23a"
dependencies = [
 "derive_more",
 "ink_env",
 "ink_eth_compatibility",
 "ink_lang_macro",
 "ink_prelude",
 "ink_primitives",
 "ink_storage",
 "parity-scale-codec",
]

[[package]]
name = "ink_lang_codegen"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "0d4d9fd69d0b7028c5ca0823fcb92393322de54a1373c53bc5897f00c8f7dbd1"
dependencies = [
 "blake2",
 "derive_more",
 "either",
 "heck",
 "impl-serde",
 "ink_lang_ir",
 "itertools",
 "parity-scale-codec",
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "ink_lang_ir"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "db7709e3543a35c804b7bde70a875a4c1a842dd8f461d02dbc04ce302342714a"
dependencies = [
 "blake2",
 "either",
 "itertools",
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "ink_lang_macro"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "4cc314eb213969799a930abf4026a493c90e6e1f7801a1fa0ffaeb31c22af316"
dependencies = [
 "ink_lang_codegen",
 "ink_lang_ir",
 "ink_primitives",
 "parity-scale-codec",
 "proc-macro2",
 "syn",
]

[[package]]
name = "ink_metadata"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "bc45b35402543837a828b12dcca8b806676bd41f9c32538487816515336a2526"
dependencies = [
 "derive_more",
 "impl-serde",
 "ink_prelude",
 "ink_primitives",
 "scale-info",
 "serde",
]

[[package]]
name = "ink_prelude"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "b9a1556937918ca7a13bcc699ceb06da600b5ee67dd1eb5d611fb44c6ee5bed4"
dependencies = [
 "cfg-if",
]

[[package]]
name = "ink_primitives"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "5f2abfc9cdcccb447d730a8b79399b4cc8cd2d02281cf411ffb52b00f29d925d"
dependencies = [
 "cfg-if",
 "ink_prelude",
 "parity-scale-codec",
 "scale-info",
]

[[package]]
name = "ink_storage"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "6341bea8ec05beff2497ff21a6d2df1833a6f00b015de70fcaed695bbe098219"
dependencies = [
 "array-init",
 "cfg-if",
 "derive_more",
 "ink_env",
 "ink_metadata",
 "ink_prelude",
 "ink_primitives",
 "ink_storage_derive",
 "parity-scale-codec",
 "scale-info",
]

[[package]]
name = "ink_storage_derive"
version = "3.0.0"
source = "registry+/~https://github.com/rust-lang/crates.io-index"
checksum = "5b0fc08b2f36ee4613605567b97883099c6d1824108a1a0a41aabccd8a768971"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "synstructure",
]

but the following remains there:

error[E0107]: this struct takes 4 generic arguments but 3 generic arguments were supplied
   --> lib.rs:351:30
    |
351 |             let mut submit = CallParams::<Env, _, _>::eval(
    |                              ^^^^^^^^^^   ---  -  - supplied 3 generic arguments
    |                              |
    |                              expected 4 generic arguments
    |
note: struct defined here, with 4 generic parameters: `E`, `CallType`, `Args`, `R`

@xgreenx
Copy link
Collaborator

xgreenx commented Mar 23, 2022

I think the problem is that documentation in multisig example is outdated=) It really provides 3 arguments when it should be 4 arguments=)
The comment:
image

The code of ink:
image

@bernardoaraujor
Copy link
Author

bernardoaraujor commented Mar 23, 2022

I agree with @xgreenx

it is also not clear to me how to extract the right codes to use on Selector for CallData and CallParams.
where do those codes come from?

@HCastano HCastano changed the title brtoken multisig example Broken Multisig Example Mar 24, 2022
@HCastano
Copy link
Contributor

HCastano commented Mar 24, 2022

Yeah you guys are are right. I've opened #1198.

@HCastano HCastano removed the B-invalid This doesn't seem right label Mar 24, 2022
@bernardoaraujor
Copy link
Author

@HCastano thanks, that cleared out the original issue.
But now I'm stuck here:

error[E0432]: unresolved import `ink_env::test`
  --> /home/bear/develop/sbp-contract/multisig/lib.rs:46:82
   |
46 |     use ink_env::{DefaultEnvironment as Env, call::{CallParams, Selector, Call}, test::CallData};
   |                                                                                  ^^^^ could not find `test` in `ink_env`

@cmichi
Copy link
Collaborator

cmichi commented Mar 25, 2022

@bernardoaraujor Could you push your branch to that repo? What is the command you're executing to get this error?

I suspect that you might have ink-experimental-engine somewhere in there, but we removed it with one of the recent release candidate.

@bernardoaraujor
Copy link
Author

bernardoaraujor commented Mar 25, 2022

here is what the error is coming from (pushed to main branch on origin)

@HCastano
Copy link
Contributor

@bernardoaraujor Yeah this was on us again, sorry. Can you take a look at #1202 and see if that finally resolves your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-examples [examples] Work item C-bug Something isn't working
Projects
None yet
4 participants