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

Extract metadata JSON. #688

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nathan-at-least
Copy link
Contributor

@nathan-at-least nathan-at-least commented Apr 19, 2023

This branch introduces a (hideous) shell script which generates a single JSON document with all of the ZIP header metadata.

It is a finicky unix pipeline parser and it introduces a strict requirement that metadata fields MUST be prefixed with exactly 2 spaces. There was only one ZIP that violated this: zip-1006.rst, so this PR updates that ZIP to match the format.

This metadata may be useful if served from https://zips.z.cash for building various infrastructure atop ZIPs.

jq examples

I am using the JSON output to perform various queries with jq. Some recipes follow:

Show all present metadata fields

$ jq 'reduce .[] as $acc ({}; $acc + .) | keys' zip-metadata.json 
[
  "Category",
  "Created",
  "Credits",
  "Discussions-To",
  "License",
  "Obsoletes",
  "Original-Authors",
  "Owners",
  "Pull-Request",
  "Status",
  "Title",
  "ZIP"
]

Finding all ZIPs without owners (they're all Reserved):

$ jq '.[] | select(.Owners? == null)' zip-metadata.json 
{
  "ZIP": "1",
  "Title": "Network Upgrade Policy and Scheduling",
  "Status": "Reserved",
  "Category": "Consensus Process",
  "Discussions-To": "<https://github.com/zcash/zips/issues/343>"
}
{
  "ZIP": "2",
  "Title": "Design Considerations for Network Upgrades",
  "Status": "Reserved",
  "Category": "Informational",
  "Discussions-To": "<https://github.com/zcash/zips/issues/362>"
}
{
  "ZIP": "312",
  "Title": "Shielded Multisignatures using FROST",
  "Status": "Reserved",
  "Category": "Standards / RPC / Wallet",
  "Discussions-To": "<https://github.com/zcash/zips/issues/382>"
}
{
  "ZIP": "402",
  "Title": "New Wallet Database Format",
  "Status": "Reserved",
  "Category": "Wallet",
  "Discussions-To": "<https://github.com/zcash/zips/issues/365>"
}
{
  "ZIP": "403",
  "Title": "Verification Behaviour of zcashd",
  "Status": "Reserved",
  "Category": "Informational",
  "Discussions-To": "<https://github.com/zcash/zips/issues/404>"
}

Listing all owners

$ jq --raw-output '[ .[] | .Owners? | select( . != null ) ] | flatten | .[]' zip-metadata.json | sed 's/ <.*$//; s/ (.*$//' | sort -u
...
Aditya Bharadwaj
Alfredo Garcia
Andrew Miller
aristarchus
Avichal Garg
Colleen Swanson
Daira Emma Hopwood
Daira Hopwood
Deirdre Connolly
Dimitris Apostolou
Eran Tromer
First Owner
Gordon Mohr
Greg Pfeil
Henry de Valence
Jack Grigg
James Todaro
J. Ayo Akinyele
Joseph Todaro
Josh Cincinnati
@kek
Kris Nuttycombe
@lex-node
Matt Luongo
@mistfpga
mistfpga
Nathan Wilcox
Pablo Kogan
Sean Bowe
Steven Smith
Taylor Hornby
teor
Vivek Arte
Ying Tong Lai
Zooko Wilcox

Finding ZIPs with a given author

$ jq '.[] | select(.Owners? | tostring | ascii_downcase | contains("nathan wilcox")) | { ZIP, Title }' zip-metadata.json 
{
  "ZIP": "316",
  "Title": "Unified Addresses and Unified Viewing Keys"
}
{
  "ZIP": "319",
  "Title": "Options for Shielded Pool Retirement"
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm -1 on checking this in manually. We can include this when we fix the automatic rendering. The bash script also looks a bit fragile; I'll have a look whether a Python program would be a better fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants