Interact with contracts: upload, instantiate and call commands#79
Merged
Interact with contracts: upload, instantiate and call commands#79
Conversation
cmichi
reviewed
Oct 16, 2020
cmichi
reviewed
Oct 16, 2020
ascjones
commented
Feb 10, 2022
| parity-wasm = "0.42.2" | ||
| cargo_metadata = "0.14.1" | ||
| codec = { package = "parity-scale-codec", version = "2.3.1", features = ["derive"] } | ||
| scale = { package = "parity-scale-codec", version = "2.3.1", features = ["derive"] } |
Collaborator
Author
There was a problem hiding this comment.
Renamed because I have an embedded contract for testing purposes and ink! generates code with ::scale imports.
athei
reviewed
Feb 14, 2022
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
athei
approved these changes
Feb 14, 2022
Contributor
There was a problem hiding this comment.
I played around with it a bit and it is working as I imagined it. Some remarks:
Probably fix now
- Remove trailing new line from debug message. It looks awkward with the quote on the next line.
- Remove the decoding of the module error as long as this is buggy. It is massively confusing to see a wrong error there. Better to not decode.
Fix in follow up
- Add support for
remove_codeextrinsic.
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
…target chain differs
Collaborator
Author
cmichi
reviewed
Feb 16, 2022
| async-std = { version = "1.10.0", features = ["attributes", "tokio1"] } | ||
| ink_metadata = { version = "3.0.0-rc8", features = ["derive"] } | ||
| ink_env = "3.0.0-rc8" | ||
| scale-info = { version = "1.0.0", default-features = false, features = ["derive"] } |
Collaborator
There was a problem hiding this comment.
This will probably trigger a dependabot PR for an upgrade to 2.0.0.
Collaborator
Author
There was a problem hiding this comment.
I'll keep it as 1.0.0 for now since that is the same version as ink_metadata rc8 is using.
cmichi
approved these changes
Feb 16, 2022
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
upload,instantiateandcallcommands which allows interacting with contracts on live chains with a compatiblepallet-contracts.Upload
Instantiate
cargo contract instantiate \ --constructor new \ --args false \ --suri //Alice \ --code-hash 0xbc1b42256696c8a4187ec3ed79fc602789fc11287c4c30926f5e31ed8169574e \ --dry-runcargo contract instantiate \ --constructor new \ --args false \ --suri //Alice \ --code-hash 0xbc1b42256696c8a4187ec3ed79fc602789fc11287c4c30926f5e31ed8169574eInstantiate with code
Omitting
--code-hashwill callinstantiate_with_code:Call
cargo contract call \ --contract 5FQNUFjuSxjB1o67CneHXieB1Hy6xAj2A4h4dUVLCvNkgRmD \ --message flip \ --suri //Alice \ --dry-runcargo contract call \ --contract 5FQNUFjuSxjB1o67CneHXieB1Hy6xAj2A4h4dUVLCvNkgRmD \ --message flip \ --suri //Alicecargo contract call \ --contract 5FQNUFjuSxjB1o67CneHXieB1Hy6xAj2A4h4dUVLCvNkgRmD \ --message get \ --suri //Alice \ --dry-runDebug message
If the contract is build in debug mode then
Will result in...
Todo
Call0xprefix for hex encoded code hashpallet-contracts-primitivesandsp-rpcfromcrates.ioFollow ups
These will be promoted to their own issue, or into separate issues for following up once this is merged.
DispatchError::Moduleerrors, so that error details are displayed correctly across different chains DynamicDispatchError::Moduledetails paritytech/subxt#443--wait-for-finalization. so that success/events are not displayed until the block is finalized100CAN,1MCANsubstrate-contracts-nodeand unignore integration test: https://github.com/paritytech/cargo-contract/blob/60f65a2863be1266882bdd81861d836baeb06724/src/cmd/extrinsics/integration_tests.rs#L124