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

Field events.docs in metadata starts with whitespace #1448

Closed
cmichi opened this issue Oct 24, 2022 · 2 comments
Closed

Field events.docs in metadata starts with whitespace #1448

cmichi opened this issue Oct 24, 2022 · 2 comments
Labels
A-ink_metadata [ink_metadata] Work item C-bug Something isn't working good first issue Good for newcomers

Comments

@cmichi
Copy link
Collaborator

cmichi commented Oct 24, 2022

Problem

The events.docs field in the metadata.json and *.contract file contains a whitespace at the beginning. We had this for other fields as well, please see the issue #920 for a description. We can't just remove every whitespace at the beginning, as for code blocks it would be valid.

We introduced a fix in #1385, but forgot about this field. We need to apply the same fix for docs under events. Please also make sure the tests cover this case as well with your PR.

As a reviewer please assign @SkymanOne.

Reproducer

(1) cargo contract new foo && cd foo/

(2) Add the following event inside #[ink::contract] mod foo { … }.

    /// Foo event
    #[ink(event)]
    pub struct FooEvent {
        /// Bar 
	value: bool,
    }

(3) Execute this:

$ cargo contract build --skip-linting
$ cat target/ink/metadata.json | jq .spec.events     
[
  {
    "args": [
      {
        "docs": [
          " Bar "
        ],
        "indexed": false,
        "label": "value",
        "type": {
          "displayName": [
            "bool"
          ],
          "type": 0
        }
      }
    ],
    "docs": [
      " Foo event"
    ],
    "label": "FooEvent"
  }
]

$ cat target/ink/foo.contract | jq .spec.events
[
  {
    "args": [
      {
        "docs": [
          " Bar "
        ],
        "indexed": false,
        "label": "value",
        "type": {
          "displayName": [
            "bool"
          ],
          "type": 0
        }
      }
    ],
    "docs": [
      " Foo event"
    ],
    "label": "FooEvent"
  }
]
@cmichi cmichi added C-bug Something isn't working good first issue Good for newcomers A-ink_metadata [ink_metadata] Work item labels Oct 24, 2022
@SkymanOne
Copy link
Contributor

@SkymanOne I see that you have solved almost similar issue, that is why I would like to ask you one thing. Assuming I have made changes for solving #1448 but I am not sure that my PR solved the issue, how to verify correctness of my code locally made changes in source code? How to "reload" ink WITH my changes, locally? I understand the problem of the issue and the goal but I am not sure how to apply my local changes for cargo contract build --skip-linting command which is a source of truth of correctness of my implementation.

Appreciate any hint.

After applying your changes to the ink!, go through reproduction steps that @cmichi described above. docs in spec.events should now not have leading white spaces for comments like /// Comment, but bear in mind that you don't want to remove all leading white space because they might be part of a code snippet or formatting.

@SkymanOne
Copy link
Contributor

Closed as solved in #1711

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ink_metadata [ink_metadata] Work item C-bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants