From cca5907a288e5cf8fcb9133c8e5227ae47dc001a Mon Sep 17 00:00:00 2001 From: Raymond Jacobson Date: Fri, 27 Mar 2026 16:33:27 -0700 Subject: [PATCH 1/2] Pass solana wallet via Go context instead of TracksParams MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The middleware now sets the verified wallet on the Go context (c.SetUserContext) in addition to fiber Locals. TracksKeyed reads it from ctx.Value, so every endpoint that fetches tracks gets wallet-based token gate checks automatically — no per-handler wiring needed. Co-Authored-By: Claude Opus 4.6 --- api/solana_wallet_middleware.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/solana_wallet_middleware.go b/api/solana_wallet_middleware.go index c178166f..5aea7d58 100644 --- a/api/solana_wallet_middleware.go +++ b/api/solana_wallet_middleware.go @@ -1,7 +1,6 @@ package api import ( - "context" "crypto/ed25519" "github.com/gofiber/fiber/v2" @@ -52,6 +51,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() } From 8069e9a2d84451c8110d8989fc3c93c06bc43dfc Mon Sep 17 00:00:00 2001 From: Raymond Jacobson Date: Fri, 27 Mar 2026 17:52:32 -0700 Subject: [PATCH 2/2] =?UTF-8?q?Fix=20solana=20wallet=20context=20propagati?= =?UTF-8?q?on=20=E2=80=94=20use=20c.Locals=20instead=20of=20c.SetUserConte?= =?UTF-8?q?xt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handlers pass c.Context() (fasthttp RequestCtx) to the DB layer, not c.UserContext() (Go context.Context). Values set via c.SetUserContext were invisible to TracksKeyed's ctx.Value("solanaWallet") call. c.Locals() stores via fasthttp SetUserValue, which RequestCtx.Value() delegates to — so the wallet is now visible through c.Context(). Co-Authored-By: Claude Opus 4.6 --- api/solana_wallet_middleware.go | 2 -- api/solana_wallet_middleware_test.go | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/api/solana_wallet_middleware.go b/api/solana_wallet_middleware.go index 5aea7d58..00533a09 100644 --- a/api/solana_wallet_middleware.go +++ b/api/solana_wallet_middleware.go @@ -8,8 +8,6 @@ import ( "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. diff --git a/api/solana_wallet_middleware_test.go b/api/solana_wallet_middleware_test.go index 81fc65fd..78ee045c 100644 --- a/api/solana_wallet_middleware_test.go +++ b/api/solana_wallet_middleware_test.go @@ -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)