-
Notifications
You must be signed in to change notification settings - Fork 121
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
Make cargo contract work with AccountId20
and EthereumSignature
#1186
Conversation
To add a little more detail, these are the kinds of compile errors I'm down to.
As far as I can tell, |
Without having had a chance to dig further, when this sort of error crops up, my first thought is "are there dupe versions of crates in the tree which make it that |
|
What specifically do you need these types for? I assume that's for submitting transactions and queries. Then yes, we can just introduce generic notion of accounts and make them configurable either via env vars or additional command args |
@xermicus Yes that is my exact goal. As a first step, I'm trying to just make it work with It seems like you think this should be reasonably achievable. Is that right? This PR is my best attempt and it doesn't compile. I would be very grateful if you could try to build it and take a look.
@SkymanOne This is for signing and submitting transactions. So that means for instantiating contracts, and calling them. It sounds like you have some confidence about how to introduce this generic account type. Could you please either take a look at my attempt or give it a try? I would be very grateful. I've tried my best and feel pretty close, but I'm not sure how to make this compile. |
This should be configured within the contract using the Environment trait. Since the environment config is written to metadata it can be read there by cargo contract. |
@jsdw I also thought that maybe the dependencies were crossed and I was using 2 different types. Here's what I've done so far. Ask cargo tree about what depends on my $ cargo tree -i account
account v0.1.1 (/home/joshy/ProgrammingProjects/cargo-contract/crates/account)
├── cargo-contract v3.0.1 (/home/joshy/ProgrammingProjects/cargo-contract/crates/cargo-contract)
└── contract-transcode v3.0.1 (/home/joshy/ProgrammingProjects/cargo-contract/crates/transcode)
└── cargo-contract v3.0.1 (/home/joshy/ProgrammingProjects/cargo-contract/crates/cargo-contract) Write a test in // Sanity check to make sure that I'm not accidentally using two different AccountId20 types.
// Until this crate actually compiles, you have to comment out pretty much all of this file to make the test build.
#[test]
fn make_sure_that_account_id_20_types_are_the_same_type() {
let a = contract_transcode::AccountId20::default();
let b = account::AccountId20::default();
assert_eq!(a, b, "If this compiles at all, they are the same type. (I guess it should pass too.)")
} Indeed the test compiles and passes. These results combined with the fact that I double and triple checked all the imports yesterday make me pretty sure they are the same type. So I just don't get what the compiler is trying to tell me. |
Until now we have only targeted a single node configuration, the recent What we want is to be able to target different node configurations. I see a couple of different approaches:
|
I am in favour of the latter. Since it is more agile and easier for developers to add support for their chains to |
Related issue #1168 |
I understand that a proper generic design might take more than a week or two. So I would be happy to help with that in whatever time frame makes sense. For immediate use at PBA, I hope to get this branch working an use it as a fork. Could any of you take a look at my work here, and help me understand the compile issue I'm facing. And whether my work is close to complete? |
This reverts commit 3c3dc6f.
Attempt to get it to compile
Closing this, since this PR itself does not attempt to implement the generic solution of being able to target different configurations/versions of |
This PR is my latest attempt to make cargo contract work with the
AccountId20
andEthereumSignature
types. Currently cargo contract assumes that the chain will use theAccountId32
type, but actually Substrate is generic over this type.This PR replaces #1183, and is a much more systematic approach. I've understood the main parts of this repo's design as well as subxt's. However, this code is still not quite compiling. I would would really appreciate some guidance from someone who understands this stuff. (Maybe @ascjones or @athei or @jsdw ?
Motivation:
This is for the Polkadot Blockchain Academy's contract pow chain. This chain will host both evm contracts and pallet-contracts. We are planning to make it use
AccountId20
andEthereumSignature
just like Moonbeam does so that users only have a single notion of account. I've got this working in Polkadot-Blockchain-Academy/Academy-PoW#26 and even Polkadot js is supporting it :) The last concern is that cargo contracts cannot interact with the chain. And we would really like to include cargo contract as a central part of the lesson.