Skip to content

Commit 6144961

Browse files
authored
Merge pull request #144 from blinklabs-io/chore/deps-gouroboros
chore(deps): update gouroboros to 0.55.0
2 parents 05ddff8 + c9217c5 commit 6144961

File tree

3 files changed

+7
-33
lines changed

3 files changed

+7
-33
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/blinklabs-io/tx-submit-api
33
go 1.20
44

55
require (
6-
github.com/blinklabs-io/gouroboros v0.54.0
6+
github.com/blinklabs-io/gouroboros v0.55.0
77
github.com/fxamacker/cbor/v2 v2.5.0
88
github.com/gin-contrib/zap v0.2.0
99
github.com/gin-gonic/gin v1.9.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
4646
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
4747
github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
4848
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
49-
github.com/blinklabs-io/gouroboros v0.54.0 h1:ZRp+L7Xb2wRn3N02a7EQ8jpBfqL6FKjnpauJdCiHEqE=
50-
github.com/blinklabs-io/gouroboros v0.54.0/go.mod h1:ID2Lq1XtYrBvmk/y+yQiX45sZiV8n+urOmT0s46d2+U=
49+
github.com/blinklabs-io/gouroboros v0.55.0 h1:Sdjy8WwaeiVdnBys+xxYkUEWgNMN0QztlgOkFVzdNQU=
50+
github.com/blinklabs-io/gouroboros v0.55.0/go.mod h1:D5YJka8EyVmiXNMbRvjH23H9lNMLA4+qSlNNC/j7R0k=
5151
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
5252
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
5353
github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk=

internal/api/api.go

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ import (
4747
// @contact.url https://blinklabs.io
4848
// @contact.email [email protected]
4949

50-
// @license.name Apache 2.0
51-
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
50+
// @license.name Apache 2.0
51+
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
5252
func Start(cfg *config.Config) error {
5353
// Disable gin debug and color output
5454
gin.SetMode(gin.ReleaseMode)
@@ -321,13 +321,13 @@ func handleSubmitTx(c *gin.Context) {
321321
oConn.Close()
322322
}()
323323
// Determine transaction type (era)
324-
txType, err := determineTransactionType(txRawBytes)
324+
txType, err := ledger.DetermineTransactionType(txRawBytes)
325325
if err != nil {
326326
c.JSON(400, "could not parse transaction to determine type")
327327
return
328328
}
329329
// Submit the transaction
330-
if err := oConn.LocalTxSubmission().Client.SubmitTx(txType, txRawBytes); err != nil {
330+
if err := oConn.LocalTxSubmission().Client.SubmitTx(uint16(txType), txRawBytes); err != nil {
331331
if c.GetHeader("Accept") == "application/cbor" {
332332
txRejectErr := err.(localtxsubmission.TransactionRejectedError)
333333
c.Data(400, "application/cbor", txRejectErr.ReasonCbor)
@@ -343,29 +343,3 @@ func handleSubmitTx(c *gin.Context) {
343343
// Increment custom metric
344344
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_count").Inc(nil)
345345
}
346-
347-
func determineTransactionType(data []byte) (uint16, error) {
348-
// TODO: uncomment this once the following issue is resolved:
349-
// https://github.com/blinklabs-io/gouroboros/issues/206
350-
/*
351-
if _, err := ledger.NewByronTransactionFromCbor(data); err == nil {
352-
return ledger.TX_TYPE_BYRON, nil
353-
}
354-
*/
355-
if _, err := ledger.NewShelleyTransactionFromCbor(data); err == nil {
356-
return ledger.TX_TYPE_SHELLEY, nil
357-
}
358-
if _, err := ledger.NewAllegraTransactionFromCbor(data); err == nil {
359-
return ledger.TX_TYPE_ALLEGRA, nil
360-
}
361-
if _, err := ledger.NewMaryTransactionFromCbor(data); err == nil {
362-
return ledger.TX_TYPE_MARY, nil
363-
}
364-
if _, err := ledger.NewAlonzoTransactionFromCbor(data); err == nil {
365-
return ledger.TX_TYPE_ALONZO, nil
366-
}
367-
if _, err := ledger.NewBabbageTransactionFromCbor(data); err == nil {
368-
return ledger.TX_TYPE_BABBAGE, nil
369-
}
370-
return 0, fmt.Errorf("unknown transaction type")
371-
}

0 commit comments

Comments
 (0)