-
Notifications
You must be signed in to change notification settings - Fork 480
Add support for language level errors (LangError)
#1450
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
Changes from 25 commits
c62ea25
5e8cd1e
728c45c
810ea54
980f6a7
6181d9c
63fc94c
4280d37
474133a
e3f67ea
6a04bd1
5c9d250
a989be6
a9cae76
b3e0141
cf332b7
845b009
dc1b7a3
2ad4633
5421a0c
14b5875
a38a395
a4d653b
fc42d66
9705ff3
fc7f374
7869558
a668018
89d2cf5
68417b7
f2ef955
183dc11
26e1170
ae11633
1630b3d
2e7b5bc
87ca721
66dd9d1
517d408
1b6cacc
150e4d3
e59f53e
d68777e
4f2caad
f617a0c
105fe23
90cf477
3774d29
13d7a42
8929234
bb6c445
10c9e7d
57ddec7
077d15b
816f312
636e7c9
e2d8194
94449dd
f1137a7
2afef50
ed1aeec
ed60df8
8cea958
2488761
3670755
412c9ac
59bde0e
6eea67e
a78b042
96c9c42
f113dc2
f6b4c10
8b8eec8
6c24543
ce67e87
f5b5ae4
0fbbae1
894e898
fa9d57b
51dec24
cee90d7
b1cfc9f
1870988
476ed65
2ce3677
3410224
98aa04f
0164c01
3ed6521
a82346e
50c5f4e
d63cae1
55c4f3c
671377e
c7b8b07
ed6a6d6
1a74375
dff5ada
26e2e37
49d2ee4
5785eb0
7d57f8c
2b05e59
80a27a7
0212c90
12bc824
55b4e4f
1644343
f1211ba
9a1e41f
4057790
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -ex | ||
|
|
||
| F="${1:-pass}" | ||
| CROSS_CONTRACT_ADDR=$2 | ||
| FLIPPER_ADDR=$3 | ||
|
|
||
| SELECTOR="0x633aa551" | ||
| BAD_SELECTOR="0x00000000" | ||
|
|
||
| args=() | ||
| args+=( --contract ${CROSS_CONTRACT_ADDR} ) | ||
| args+=( --message call ) | ||
| args+=( --suri //Alice ) | ||
| args+=( --manifest-path ./examples/cross_chain_test/Cargo.toml ) | ||
| args+=( --verbose ) | ||
| args+=( --skip-confirm ) | ||
|
|
||
| case $F in | ||
| '--fail') | ||
| args+=( --args $FLIPPER_ADDR $BAD_SELECTOR ) ;; | ||
| *) | ||
| args+=( --args $FLIPPER_ADDR $SELECTOR ) ;; | ||
| esac | ||
|
|
||
| cargo contract call "${args[@]}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,3 +71,4 @@ pub use ink_macro::{ | |
| test, | ||
| trait_definition, | ||
| }; | ||
| pub use ink_primitives::LangError; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,3 +41,14 @@ pub use self::{ | |
| Hash, | ||
| }, | ||
| }; | ||
|
|
||
| /// An error that comes from the smart contracting language, but not necessarily the smart contract | ||
| /// itself nor the underlying execution environment. | ||
| #[non_exhaustive] | ||
| #[repr(u32)] | ||
| #[derive(Debug, Copy, Clone, PartialEq, Eq, ::scale::Encode, ::scale::Decode)] | ||
| #[cfg_attr(feature = "std", derive(::scale_info::TypeInfo))] | ||
| pub enum LangError { | ||
| /// Failed to read execution input for the dispatchable. | ||
| CouldNotReadInput = 1u32, | ||
| } | ||
|
Comment on lines
+54
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't we missing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kinda. I mentioned this in one of the
So tl;dr, we can't easily pull out
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Which extra error are you talking about specifically? But in general that is fine. We that we can add new errors to Another thing: Didn't we agree to move this enum to the metadata crate so it is unified across all languages? Or is this TODO.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We'd have
We re-export it in the metadata crate. See this conversation.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ha, now I understand why this is tricky because |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -ex | ||
|
|
||
| F="${1:-pass}" | ||
|
|
||
| cargo contract build --manifest-path examples/flipper/Cargo.toml --skip-linting | ||
ascjones marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cargo contract instantiate \ | ||
| --manifest-path examples/flipper/Cargo.toml \ | ||
| --suri //Alice --output-json \ | ||
| --constructor default \ | ||
| --salt $(date +%s) \ | ||
| --skip-confirm > /tmp/deployment-output.json | ||
|
|
||
| FLIPPER_ADDRESS=$(tail -n +2 /tmp/deployment-output.json | jq --raw-output .contract) | ||
| echo $FLIPPER_ADDRESS | ||
|
|
||
| cargo contract build --manifest-path examples/cross_chain_test/Cargo.toml --skip-linting | ||
| cargo contract instantiate \ | ||
| --manifest-path examples/cross_chain_test/Cargo.toml \ | ||
| --suri //Alice --output-json \ | ||
| --salt $(date +%s) \ | ||
| --skip-confirm > /tmp/deployment-output.json | ||
|
|
||
| CROSS_ADDRESS=$(tail -n +2 /tmp/deployment-output.json | jq --raw-output .contract) | ||
| echo $CROSS_ADDRESS | ||
|
|
||
| ./call-contract.sh $F $CROSS_ADDRESS $FLIPPER_ADDRESS | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Ignore build artifacts from the local tests sub-crate. | ||
| /target/ | ||
|
|
||
| # Ignore backup files creates by cargo fmt. | ||
| **/*.rs.bk | ||
|
|
||
| # Remove Cargo.lock when creating an executable, leave it for libraries | ||
| # More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock | ||
| Cargo.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [package] | ||
| name = "cross_chain_test" | ||
| version = "0.1.0" | ||
| authors = ["[your_name] <[your_email]>"] | ||
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
| ink = { path = "../../crates/ink", default-features = false } | ||
|
|
||
| scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } | ||
| scale-info = { version = "2", default-features = false, features = ["derive"], optional = true } | ||
|
|
||
| [lib] | ||
| name = "cross_chain_test" | ||
| path = "lib.rs" | ||
| crate-type = [ | ||
| # Used for normal contract Wasm blobs. | ||
| "cdylib", | ||
| ] | ||
|
|
||
| [features] | ||
| default = ["std"] | ||
| std = [ | ||
| "ink/std", | ||
| "scale/std", | ||
| "scale-info/std", | ||
| ] | ||
| ink-as-dependency = [] |
Uh oh!
There was an error while loading. Please reload this page.