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: wire up issuer verification key #109

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ module github.com/blinklabs-io/snek
go 1.20

require (
github.com/blinklabs-io/gouroboros v0.57.0
github.com/fxamacker/cbor/v2 v2.5.0
github.com/blinklabs-io/gouroboros v0.58.0
github.com/gen2brain/beeep v0.0.0-20230602101333-f384c29b62dd
github.com/gin-gonic/gin v1.9.1
github.com/kelseyhightower/envconfig v1.4.0
Expand All @@ -28,6 +27,7 @@ require (
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/blinklabs-io/gouroboros v0.57.0 h1:k5Y706vvYAGM3bCtEhh6WRHGrvS3S6n1MT9vNLFAe/E=
github.com/blinklabs-io/gouroboros v0.57.0/go.mod h1:D5YJka8EyVmiXNMbRvjH23H9lNMLA4+qSlNNC/j7R0k=
github.com/blinklabs-io/gouroboros v0.58.0 h1:W1/fjntOfJ3Yn41/SjgxV4cS7XSuogCZYznygRXUj8Q=
github.com/blinklabs-io/gouroboros v0.58.0/go.mod h1:D5YJka8EyVmiXNMbRvjH23H9lNMLA4+qSlNNC/j7R0k=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
Expand Down
15 changes: 3 additions & 12 deletions input/chainsync/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
package chainsync

import (
"fmt"

"github.com/blinklabs-io/gouroboros/ledger"
"github.com/fxamacker/cbor/v2"
)

type BlockContext struct {
BlockNumber uint64 `json:"blockNumber"`
SlotNumber uint64 `json:"slotNumber"`
BlockNumber uint64 `json:"blockNumber"`
SlotNumber uint64 `json:"slotNumber"`
}

type BlockEvent struct {
Expand All @@ -50,16 +47,10 @@ func NewBlockHeaderContext(block ledger.BlockHeader) BlockContext {
}

func NewBlockEvent(block ledger.Block, includeCbor bool) BlockEvent {
keyCbor, err := cbor.Marshal(block.IssuerVkey())
if err != nil {
panic(err)
}
// iss := ledger.NewBlake2b256(block.IssuerVkey())
evt := BlockEvent{
BlockBodySize: block.BlockBodySize(),
BlockHash: block.Hash(),
IssuerVkey: fmt.Sprintf("%x", keyCbor),
// IssuerVkey: iss.String(),
IssuerVkey: block.IssuerVkey().Hash().String(),
}
if includeCbor {
evt.BlockCbor = block.Cbor()
Expand Down
10 changes: 5 additions & 5 deletions input/chainsync/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func NewTransactionContext(block ledger.Block, tx ledger.Transaction, index uint

func NewTransactionEvent(block ledger.Block, tx ledger.Transaction, includeCbor bool) TransactionEvent {
evt := TransactionEvent{
BlockHash: block.Hash(),
Inputs: tx.Inputs(),
Outputs: tx.Outputs(),
Fee: tx.Fee(),
TTL: tx.TTL(),
BlockHash: block.Hash(),
Inputs: tx.Inputs(),
Outputs: tx.Outputs(),
Fee: tx.Fee(),
TTL: tx.TTL(),
}
if includeCbor {
evt.TransactionCbor = tx.Cbor()
Expand Down
13 changes: 4 additions & 9 deletions output/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ func formatWebhook(e *event.Event, format string) []byte {
case "chainsync.block":
be := e.Payload.(chainsync.BlockEvent)
bc := e.Context.(chainsync.BlockContext)
// keyCbor, err := cbor.Marshal(be.IssuerVkey)
// if err != nil {
// panic(err)
// }
dme.Title = "New Cardano Block"
dmefs = append(dmefs, &DiscordMessageEmbedField{
Name: "Block Number",
Expand All @@ -135,11 +131,10 @@ func formatWebhook(e *event.Event, format string) []byte {
Name: "Block Hash",
Value: be.BlockHash,
})
// TODO: get the pool identifier from be.IssuerVkey
// dmefs = append(dmefs, &DiscordMessageEmbedField{
// Name: "Issuer Vkey",
// Value: fmt.Sprintf("%x", keyCbor),
// })
dmefs = append(dmefs, &DiscordMessageEmbedField{
Name: "Issuer Vkey",
Value: be.IssuerVkey,
})
// TODO: fix this URL for different networks
dme.URL = fmt.Sprintf("https://cexplorer.io/block/%s", be.BlockHash)
case "chainsync.rollback":
Expand Down
Loading