Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/e2e-scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 authored Sep 4, 2024
2 parents 5094735 + 0004bb6 commit 7b699f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
24 changes: 6 additions & 18 deletions docs/openapi/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,30 @@ package openapi

import (
"embed"
"html/template"
"net/http"

"github.com/gorilla/mux"
)

const (
apiFile = "openapi.swagger.yaml"
templateFile = "template.tpl"
apiFile = "openapi.swagger.yaml"
htmlFile = "openapi.html"
)

//go:embed openapi.swagger.yaml
var staticFS embed.FS

//go:embed template.tpl
var templateFS embed.FS
//go:embed openapi.html
var html []byte

func RegisterOpenAPIService(router *mux.Router) {
router.Handle("/"+apiFile, http.FileServer(http.FS(staticFS)))
router.HandleFunc("/", openAPIHandler())
}

func openAPIHandler() http.HandlerFunc {
tmpl, err := template.ParseFS(templateFS, templateFile)
if err != nil {
panic(err)
}

return func(w http.ResponseWriter, _ *http.Request) {
err := tmpl.Execute(w, struct {
URL string
}{
"/" + apiFile,
})
if err != nil {
http.Error(w, "Failed to render template", http.StatusInternalServerError)
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_, _ = w.Write(html)
}
}
2 changes: 1 addition & 1 deletion docs/openapi/template.tpl → docs/openapi/openapi.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script>
window.onload = function() {
window.ui = SwaggerUIBundle({
url: {{ .URL }},
url: "./openapi.swagger.yaml",
dom_id: "#swagger-ui",
deepLinking: true,
layout: "BaseLayout",
Expand Down
6 changes: 3 additions & 3 deletions x/crosschain/types/tx_body_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"fmt"
"math/big"

"github.com/btcsuite/btcd/btcec"
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
eth "github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"

Expand Down Expand Up @@ -136,7 +136,7 @@ func verifyOutboundBodyBTC(msg MsgAddOutboundTracker, txBytes []byte, tssBtc str
if len(vin.Witness) != 2 { // outTx is SegWit transaction for now
return fmt.Errorf("not a SegWit transaction")
}
pubKey, err := btcec.ParsePubKey(vin.Witness[1], btcec.S256())
pubKey, err := btcec.ParsePubKey(vin.Witness[1])
if err != nil {
return fmt.Errorf("failed to parse public key")
}
Expand Down

0 comments on commit 7b699f5

Please sign in to comment.