Skip to content
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
5 changes: 1 addition & 4 deletions api/solana_wallet_middleware.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package api

import (
"context"
"crypto/ed25519"

"github.com/gofiber/fiber/v2"
"github.com/mr-tron/base58"
"go.uber.org/zap"
)

// SolanaWalletCtxKey is the context key used to pass a verified Solana wallet
// from the HTTP middleware to the database layer.
const SolanaWalletCtxKey = "solanaWallet"

// solanaWalletMiddleware verifies Solana wallet signatures from request headers.
Expand Down Expand Up @@ -52,6 +49,6 @@ func (app *ApiServer) solanaWalletMiddleware(c *fiber.Ctx) error {
}

app.logger.Debug("solanaWalletMiddleware: verified", zap.String("wallet", wallet))
c.SetUserContext(context.WithValue(c.UserContext(), SolanaWalletCtxKey, wallet))
c.Locals(SolanaWalletCtxKey, wallet)
return c.Next()
}
2 changes: 1 addition & 1 deletion api/solana_wallet_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestSolanaWalletMiddleware(t *testing.T) {
var capturedWallet string
testApp := fiber.New()
testApp.Get("/", app.solanaWalletMiddleware, func(c *fiber.Ctx) error {
if w, ok := c.UserContext().Value(SolanaWalletCtxKey).(string); ok {
if w, ok := c.Context().Value(SolanaWalletCtxKey).(string); ok {
capturedWallet = w
}
return c.SendStatus(fiber.StatusOK)
Expand Down
Loading