-
-
Save larskuhtz/424c20f1a723a637dd43093d7c1d5ed6 to your computer and use it in GitHub Desktop.
jq config file for working with Kadena chainweb payloads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ############################################################################ # | |
# Base64 URL without padding | |
def base64dUrl: . | |
| gsub("(?<x>[-_])"; if .x == "-" then "+" else "/" end) | |
| "\(.)===" | |
| @base64d | |
; | |
def fromjson64: . | |
| base64dUrl | |
| fromjson | |
; | |
# ############################################################################ # | |
# Chainweb Debugging tools | |
def pWo: . | |
| .minerData = (.minerData | fromjson64) | |
| .coinbase = (.coinbase | fromjson64) | |
| .transactions = | |
[ .transactions[] | |
| | |
{ tx: (.[0] | fromjson64 | .cmd = (.cmd | fromjson)) | |
, result: (.[1] | fromjson64) | |
} | |
] | |
; | |
# ############################################################################ # | |
# RocksDb Paylaods | |
# | |
# keys: ["transactionsHash","minerData","transaction"] | |
# pk: "transactionsHash" | |
# | |
def blockTransactions2json: . | |
| .transactionsHash = .transactionHash | |
| del(.transactionHash) | |
| .minerData = (.minerData | fromjson64) | |
| .transaction = [.transaction[] | fromjson64] | |
; | |
def blockTransactionsCmd2json: . | |
| .transactionsHash = .transactionHash | |
| del(.transactionHash) | |
| .minerData = (.minerData | fromjson64) | |
| .transaction = [.transaction[] | fromjson64] | |
| .transaction = | |
[ .transaction[] | |
| .cmd = (.cmd | fromjson) | |
] | |
; | |
# | |
# keys: ["coinbaseOutput","outputs","outputsHash"] | |
# pk: "outputsHash" | |
# | |
def blockOutputs2json: . | |
| .coinbaseOutput = (.coinbaseOutput | fromjson64) | |
| .outputs = [.outputs[] | fromjson64] | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment