stacks-network / stacks-network/stacks-core

Principal refinement types

Open
#7,136 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

clarity-new-type clarity-next-stretch
Dominant language
Rust
Stars
3.1k
Forks
762
Avg merge
4d 6h
Merged PRs (30d)
76

Description

Principal refinement types refine the native Principal type with optional traits.

Refined types of principals are declared to implement the specific traits, benefiting static analysis. They are similar to the Integer refinement types proposed in issue stacks-network/stacks-core#7129, the String refinement types proposed in stacks-network/stacks-core#7128, and the List type refined with an entry-type. They are suited to be used for the type aliases proposed in issue stacks-network/stacks-core#7130.

Example:

(define-trait can-sell
  ((sell (principal uint) 
         (response bool))))

(define-public (trade (market (principal can-sell)) 
                      (buyer principal) 
                      (price uint))
  (contract-call? market sell buyer price))

Related:
https://github.com/blockstack/stacks-blockchain/pull/1679

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Principal and traits documentation, then read related issues #1168, #7129, #7128, #7130 and pull request #1679 for the intended type-system direction. Done means Clarity supports principal types refined with optional traits and the example declaration and static-analysis use case are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
blockchain, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.