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

feat: add Cl.prettyPrint #1551

Merged
merged 3 commits into from
Sep 20, 2023
Merged

feat: add Cl.prettyPrint #1551

merged 3 commits into from
Sep 20, 2023

Conversation

hugocaillard
Copy link
Contributor

@hugocaillard hugocaillard commented Sep 20, 2023

This PR was published to npm with the version 6.8.2-pr.12aa132.0
e.g. npm install @stacks/[email protected] --save-exact

Description

Cl.prettyPrint allows to format a clarity value into

Example

const value = Cl.tuple({
  id: Cl.uint(1),
  messageAscii: Cl.stringAscii('hello world'),
  someMessageUtf8: Cl.some(Cl.stringUtf8('hello world')),
  items: Cl.some(
    Cl.list([
      Cl.ok(
        Cl.tuple({
          id: Cl.uint(1),
          owner: Cl.some(Cl.standardPrincipal(addr)),
        })
      ),
      Cl.ok(
        Cl.tuple({
          id: Cl.uint(2),
          owner: Cl.none(),
        })
      ),
    ])
  ),
});



const result = Cl.prettyPrint(value, 2);

/*
{
  id: u1,
  messageAscii: "hello world",
  someMessageUtf8: (some u"hello world"),
  items: (some (list
    (ok {
      id: u1,
      owner: (some 'ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG)
    })
    (ok {
      id: u2,
      owner: none
    })
  ))
}
*/

Checklist

  • Unit tested updated code paths
  • Tagged @janniks for review

@vercel
Copy link

vercel bot commented Sep 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stacksjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 20, 2023 2:57pm

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #1551 (12aa132) into main (04b96d1) will increase coverage by 0.14%.
The diff coverage is 93.47%.

@@            Coverage Diff             @@
##             main    #1551      +/-   ##
==========================================
+ Coverage   66.18%   66.32%   +0.14%     
==========================================
  Files         118      119       +1     
  Lines        8640     8686      +46     
  Branches     1908     1929      +21     
==========================================
+ Hits         5718     5761      +43     
- Misses       2685     2688       +3     
  Partials      237      237              
Files Changed Coverage Δ
packages/transactions/src/clarity/prettyPrint.ts 93.33% <93.33%> (ø)
packages/transactions/src/cl.ts 100.00% <100.00%> (ø)

Copy link
Collaborator

@janniks janniks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So good ✨

Copy link
Collaborator

@janniks janniks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's goo!

@hugocaillard
Copy link
Contributor Author

Thanks @janniks!

@janniks janniks merged commit ae25ad9 into main Sep 20, 2023
7 checks passed
@janniks janniks deleted the feat/add-cl-pretty-print branch September 20, 2023 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants