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

chore(deps): update gouroboros to 0.55.0 #144

Merged
merged 1 commit into from
Oct 12, 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/blinklabs-io/tx-submit-api
go 1.20

require (
github.com/blinklabs-io/gouroboros v0.54.0
github.com/blinklabs-io/gouroboros v0.55.0
github.com/fxamacker/cbor/v2 v2.5.0
github.com/gin-contrib/zap v0.2.0
github.com/gin-gonic/gin v1.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/blinklabs-io/gouroboros v0.54.0 h1:ZRp+L7Xb2wRn3N02a7EQ8jpBfqL6FKjnpauJdCiHEqE=
github.com/blinklabs-io/gouroboros v0.54.0/go.mod h1:ID2Lq1XtYrBvmk/y+yQiX45sZiV8n+urOmT0s46d2+U=
github.com/blinklabs-io/gouroboros v0.55.0 h1:Sdjy8WwaeiVdnBys+xxYkUEWgNMN0QztlgOkFVzdNQU=
github.com/blinklabs-io/gouroboros v0.55.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.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk=
Expand Down
34 changes: 4 additions & 30 deletions internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import (
// @contact.url https://blinklabs.io
// @contact.email [email protected]

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func Start(cfg *config.Config) error {
// Disable gin debug and color output
gin.SetMode(gin.ReleaseMode)
Expand Down Expand Up @@ -321,13 +321,13 @@ func handleSubmitTx(c *gin.Context) {
oConn.Close()
}()
// Determine transaction type (era)
txType, err := determineTransactionType(txRawBytes)
txType, err := ledger.DetermineTransactionType(txRawBytes)
if err != nil {
c.JSON(400, "could not parse transaction to determine type")
return
}
// Submit the transaction
if err := oConn.LocalTxSubmission().Client.SubmitTx(txType, txRawBytes); err != nil {
if err := oConn.LocalTxSubmission().Client.SubmitTx(uint16(txType), txRawBytes); err != nil {
if c.GetHeader("Accept") == "application/cbor" {
txRejectErr := err.(localtxsubmission.TransactionRejectedError)
c.Data(400, "application/cbor", txRejectErr.ReasonCbor)
Expand All @@ -343,29 +343,3 @@ func handleSubmitTx(c *gin.Context) {
// Increment custom metric
_ = ginmetrics.GetMonitor().GetMetric("tx_submit_count").Inc(nil)
}

func determineTransactionType(data []byte) (uint16, error) {
// TODO: uncomment this once the following issue is resolved:
// https://github.com/blinklabs-io/gouroboros/issues/206
/*
if _, err := ledger.NewByronTransactionFromCbor(data); err == nil {
return ledger.TX_TYPE_BYRON, nil
}
*/
if _, err := ledger.NewShelleyTransactionFromCbor(data); err == nil {
return ledger.TX_TYPE_SHELLEY, nil
}
if _, err := ledger.NewAllegraTransactionFromCbor(data); err == nil {
return ledger.TX_TYPE_ALLEGRA, nil
}
if _, err := ledger.NewMaryTransactionFromCbor(data); err == nil {
return ledger.TX_TYPE_MARY, nil
}
if _, err := ledger.NewAlonzoTransactionFromCbor(data); err == nil {
return ledger.TX_TYPE_ALONZO, nil
}
if _, err := ledger.NewBabbageTransactionFromCbor(data); err == nil {
return ledger.TX_TYPE_BABBAGE, nil
}
return 0, fmt.Errorf("unknown transaction type")
}
Loading