Unverified Commit d99ea915 authored by Andrew Jones's avatar Andrew Jones Committed by GitHub
Browse files

[metadata] update to scale-info 0.3, removes string interning (#467)

* WIP

* WIP

* Iterating on InkProject types

* Extract InkProject to its own file

* More iteration on contract metadata

* Compiles...ship it

* Fmt

* Add optional fields and doc test

* Add custom serializer impls for compiler/lang

* Fmt

* Clippy

* Update to scale-info 0.3

* Use &'static str instead of compact string (scale-info 0.3)

* Reexport Url and Version

* Fix missing semicolon

* Fix up metadata exports and codegen

* Serialize hash as byte string

* Remove spec nesting

* Remove name from contract spec

* Add name to storage struct

* Flatten SourceCompiler

* Implement ToTokens for Extension metadata

Allows converting an instance into code that can construct that instance. For use from `cargo-contract`.

* User and Version

* Fix up builder ToTokens and other errs/warns

* Fmt

* Url wrapper

* Comment and Version/Url intos

* Fmt

* Fix U

* Promote extension to module dir

* Moved InkProjectExtension to cargo-contract

* Fix doc gen

* Fix json tests

* Use pretty assertions and fix layout json tests

* Remove storage name from layout (ink specific)

* StorageLayout -> Layout

* Remove redundant contract_ident_lit

* Remove redundant dependencies

* Use Self instead of InkProject
parent 5a944ca2
Pipeline #100563 passed with stages
in 10 minutes and 47 seconds
......@@ -13,7 +13,7 @@
// limitations under the License.
use super::*;
use assert_json_diff::assert_json_eq;
use pretty_assertions::assert_eq;
use scale_info::{
IntoCompact,
Registry,
......@@ -34,10 +34,10 @@ fn spec_constructor_selector_must_serialize_to_hex() {
let json = serde_json::to_value(&cs.into_compact(&mut registry)).unwrap();
// then
assert_json_eq!(
assert_eq!(
json,
json!({
"name": 1,
"name": "foo",
"selector": "0x075bcd15",
"args": [],
"docs": []
......@@ -48,7 +48,7 @@ fn spec_constructor_selector_must_serialize_to_hex() {
#[test]
fn spec_contract_json() {
// given
let contract: ContractSpec = ContractSpec::new("incrementer")
let contract: ContractSpec = ContractSpec::new()
.constructors(vec![
ConstructorSpec::new("new")
.selector([94u8, 189u8, 136u8, 214u8])
......@@ -97,30 +97,30 @@ fn spec_contract_json() {
let json = serde_json::to_value(&contract.into_compact(&mut registry)).unwrap();
// then
assert_json_eq!(
assert_eq!(
json,
json!({
"constructors": [
{
"args": [
{
"name": 3,
"name": "init_value",
"type": {
"displayName": [
4
"i32"
],
"id": 1
}
}
],
"docs": [],
"name": 2,
"name": "new",
"selector": "0x5ebd88d6"
},
{
"args": [],
"docs": [],
"name": 5,
"name": "default",
"selector": "0x0222ff18"
}
],
......@@ -130,10 +130,10 @@ fn spec_contract_json() {
{
"args": [
{
"name": 7,
"name": "by",
"type": {
"displayName": [
4
"i32"
],
"id": 1
}
......@@ -141,7 +141,7 @@ fn spec_contract_json() {
],
"docs": [],
"mutates": true,
"name": 6,
"name": "inc",
"returnType": null,
"selector": "0xe7d0590f"
},
......@@ -149,17 +149,16 @@ fn spec_contract_json() {
"args": [],
"docs": [],
"mutates": false,
"name": 8,
"name": "get",
"returnType": {
"displayName": [
4
"i32"
],
"id": 1
},
"selector": "0x25444afe"
}
],
"name": 1
})
)
}
......@@ -21,7 +21,7 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
ink_prelude = { version = "2.1.0", path = "../prelude/", default-features = false }
tiny-keccak = { version = "2.0", features = ["keccak"] }
scale = { package = "parity-scale-codec", version = "1.3", default-features = false, features = ["derive", "full"] }
scale-info = { version = "0.2", default-features = false, features = ["derive"], optional = true }
scale-info = { version = "0.3", default-features = false, features = ["derive"], optional = true }
[dev-dependencies]
criterion = "0.3.1"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment