clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Adding helpful language to tooltip for error "use of undeclared trait <trait>"

Open mefrem opened this issue 2 years ago • 1 comments

The Stacks blockchain is full of redundant SIP-009 trait references. I believe this is largely due to ignorance about mainnet trait references in Clarity contracts supported by Clarinet's add requirements feature.

I think we could encourage best practices of making already-published trait references by adding language to this error message in VS Code. For instance, adding *if your contract depends on a published trait reference, add that requirement to this project with clarinet requirements add <contract-reference> through the Clarinet CLI" or something. This would spare the developer of adding the relevant requirement to their project with another local contract.

Screenshot 2023-03-06 at 3 30 21 PM

Bonus: I wonder if there's not an opinionated tooltip that can be displayed if the impl-trait declaration includes the token <nft>, because the most common offenders of this redundant trait publication are contracts implementing SIP-009 NFTs, that would point the developer to these two steps, in the shell and then in the contract:

clarinet requirements add SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait
(impl-trait 'SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.nft-trait.nft-trait)

mefrem avatar Mar 06 '23 21:03 mefrem

Related https://github.com/hirosystems/clarinet/issues/796, https://github.com/hirosystems/clarinet/issues/600

lgalabru avatar Mar 08 '23 15:03 lgalabru