Skip to content

Commit 59bd629

Browse files
authored
Merge pull request #109 from blinklabs-io/feat/issuer-vkey
feat: wire up issuer verification key
2 parents f0ca659 + b4592a3 commit 59bd629

File tree

5 files changed

+16
-30
lines changed

5 files changed

+16
-30
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ module github.com/blinklabs-io/snek
33
go 1.20
44

55
require (
6-
github.com/blinklabs-io/gouroboros v0.57.0
7-
github.com/fxamacker/cbor/v2 v2.5.0
6+
github.com/blinklabs-io/gouroboros v0.58.0
87
github.com/gen2brain/beeep v0.0.0-20230602101333-f384c29b62dd
98
github.com/gin-gonic/gin v1.9.1
109
github.com/kelseyhightower/envconfig v1.4.0
@@ -28,6 +27,7 @@ require (
2827
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
2928
github.com/chenzhuoyu/iasm v0.9.0 // indirect
3029
github.com/davecgh/go-spew v1.1.1 // indirect
30+
github.com/fxamacker/cbor/v2 v2.5.0 // indirect
3131
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
3232
github.com/gin-contrib/sse v0.1.0 // indirect
3333
github.com/go-openapi/jsonpointer v0.20.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB
44
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
55
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
66
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
7-
github.com/blinklabs-io/gouroboros v0.57.0 h1:k5Y706vvYAGM3bCtEhh6WRHGrvS3S6n1MT9vNLFAe/E=
8-
github.com/blinklabs-io/gouroboros v0.57.0/go.mod h1:D5YJka8EyVmiXNMbRvjH23H9lNMLA4+qSlNNC/j7R0k=
7+
github.com/blinklabs-io/gouroboros v0.58.0 h1:W1/fjntOfJ3Yn41/SjgxV4cS7XSuogCZYznygRXUj8Q=
8+
github.com/blinklabs-io/gouroboros v0.58.0/go.mod h1:D5YJka8EyVmiXNMbRvjH23H9lNMLA4+qSlNNC/j7R0k=
99
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
1010
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
1111
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=

input/chainsync/block.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
package chainsync
1616

1717
import (
18-
"fmt"
19-
2018
"github.com/blinklabs-io/gouroboros/ledger"
21-
"github.com/fxamacker/cbor/v2"
2219
)
2320

2421
type BlockContext struct {
25-
BlockNumber uint64 `json:"blockNumber"`
26-
SlotNumber uint64 `json:"slotNumber"`
22+
BlockNumber uint64 `json:"blockNumber"`
23+
SlotNumber uint64 `json:"slotNumber"`
2724
}
2825

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

5249
func NewBlockEvent(block ledger.Block, includeCbor bool) BlockEvent {
53-
keyCbor, err := cbor.Marshal(block.IssuerVkey())
54-
if err != nil {
55-
panic(err)
56-
}
57-
// iss := ledger.NewBlake2b256(block.IssuerVkey())
5850
evt := BlockEvent{
5951
BlockBodySize: block.BlockBodySize(),
6052
BlockHash: block.Hash(),
61-
IssuerVkey: fmt.Sprintf("%x", keyCbor),
62-
// IssuerVkey: iss.String(),
53+
IssuerVkey: block.IssuerVkey().Hash().String(),
6354
}
6455
if includeCbor {
6556
evt.BlockCbor = block.Cbor()

input/chainsync/tx.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ func NewTransactionContext(block ledger.Block, tx ledger.Transaction, index uint
4848

4949
func NewTransactionEvent(block ledger.Block, tx ledger.Transaction, includeCbor bool) TransactionEvent {
5050
evt := TransactionEvent{
51-
BlockHash: block.Hash(),
52-
Inputs: tx.Inputs(),
53-
Outputs: tx.Outputs(),
54-
Fee: tx.Fee(),
55-
TTL: tx.TTL(),
51+
BlockHash: block.Hash(),
52+
Inputs: tx.Inputs(),
53+
Outputs: tx.Outputs(),
54+
Fee: tx.Fee(),
55+
TTL: tx.TTL(),
5656
}
5757
if includeCbor {
5858
evt.TransactionCbor = tx.Cbor()

output/webhook/webhook.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ func formatWebhook(e *event.Event, format string) []byte {
118118
case "chainsync.block":
119119
be := e.Payload.(chainsync.BlockEvent)
120120
bc := e.Context.(chainsync.BlockContext)
121-
// keyCbor, err := cbor.Marshal(be.IssuerVkey)
122-
// if err != nil {
123-
// panic(err)
124-
// }
125121
dme.Title = "New Cardano Block"
126122
dmefs = append(dmefs, &DiscordMessageEmbedField{
127123
Name: "Block Number",
@@ -135,11 +131,10 @@ func formatWebhook(e *event.Event, format string) []byte {
135131
Name: "Block Hash",
136132
Value: be.BlockHash,
137133
})
138-
// TODO: get the pool identifier from be.IssuerVkey
139-
// dmefs = append(dmefs, &DiscordMessageEmbedField{
140-
// Name: "Issuer Vkey",
141-
// Value: fmt.Sprintf("%x", keyCbor),
142-
// })
134+
dmefs = append(dmefs, &DiscordMessageEmbedField{
135+
Name: "Issuer Vkey",
136+
Value: be.IssuerVkey,
137+
})
143138
// TODO: fix this URL for different networks
144139
dme.URL = fmt.Sprintf("https://cexplorer.io/block/%s", be.BlockHash)
145140
case "chainsync.rollback":

0 commit comments

Comments
 (0)