Skip to content

Commit 35a28eb

Browse files
authored
Initial claim rewards endpoint (#45)
Initial rewards claiming endpoint. Still lots of TODOs to fix. Tickets tracking most if not all of them... I think... Wanted to get it up for some ideas on how to organize/feedback on my golang
1 parent c1a36ef commit 35a28eb

4 files changed

Lines changed: 623 additions & 2 deletions

File tree

api/server.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ import (
1111
"bridgerton.audius.co/api/dbv1"
1212
"bridgerton.audius.co/config"
1313
"bridgerton.audius.co/trashid"
14+
"github.com/AudiusProject/audiusd/pkg/rewards"
1415
adapter "github.com/axiomhq/axiom-go/adapters/zap"
1516
"github.com/axiomhq/axiom-go/axiom"
17+
"github.com/ethereum/go-ethereum/crypto"
1618
"github.com/gofiber/contrib/fiberzap/v2"
1719
"github.com/gofiber/fiber/v2"
1820
"github.com/gofiber/fiber/v2/middleware/cors"
@@ -98,6 +100,11 @@ func NewApiServer(config config.Config) *ApiServer {
98100
panic(err)
99101
}
100102

103+
privateKey, err := crypto.HexToECDSA(config.DelegatePrivateKey)
104+
if err != nil {
105+
panic(err)
106+
}
107+
101108
app := &ApiServer{
102109
App: fiber.New(fiber.Config{
103110
JSONEncoder: json.Marshal,
@@ -110,6 +117,9 @@ func NewApiServer(config config.Config) *ApiServer {
110117
started: time.Now(),
111118
resolveHandleCache: resolveHandleCache,
112119
resolveWalletCache: resolveWalletCache,
120+
rewardAttester: *rewards.NewRewardAttester(privateKey, []rewards.Reward{}),
121+
solanaConfig: config.SolanaConfig,
122+
antiAbuseOracles: config.AntiAbuseOracles,
113123
}
114124

115125
app.Use(recover.New(recover.Config{
@@ -218,6 +228,9 @@ func NewApiServer(config config.Config) *ApiServer {
218228

219229
// Developer Apps
220230
g.Get("/developer_apps/:address", app.v1DeveloperApps)
231+
232+
// Rewards
233+
g.Get("/rewards/claim", app.v1ClaimRewards)
221234
}
222235

223236
app.Static("/", "./static")
@@ -242,6 +255,9 @@ type ApiServer struct {
242255
started time.Time
243256
resolveHandleCache otter.Cache[string, int32]
244257
resolveWalletCache otter.Cache[string, int32]
258+
rewardAttester rewards.RewardAttester
259+
solanaConfig config.SolanaConfig
260+
antiAbuseOracles []string
245261
}
246262

247263
func (app *ApiServer) home(c *fiber.Ctx) error {

0 commit comments

Comments
 (0)