Skip to content

Commit 06bf76d

Browse files
authored
Merge pull request #43 from AudiusProject/mjp-rewards-3
Fix error handler, move api/solana=>api/spl, add lookup table support, rewardmanagerstate support
2 parents 0943a61 + 4c4aab2 commit 06bf76d

16 files changed

Lines changed: 100 additions & 37 deletions

api/error_response.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package api
22

33
import (
4+
"errors"
45
"net/http"
56

67
"github.com/gofiber/fiber/v2"
@@ -22,6 +23,11 @@ func errorHandler(logger *zap.Logger) func(*fiber.Ctx, error) error {
2223
code = http.StatusNotFound
2324
}
2425

26+
var e *fiber.Error
27+
if errors.As(err, &e) {
28+
code = e.Code
29+
}
30+
2531
if code > 499 {
2632
logger.Error(err.Error(),
2733
zap.String("url", ctx.OriginalURL()))

api/spl/address_lookup_table.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package spl
2+
3+
import (
4+
bin "github.com/gagliardetto/binary"
5+
"github.com/gagliardetto/solana-go"
6+
)
7+
8+
type AddressLookupTableMeta struct {
9+
DeactivationSlot uint64
10+
LastExtendedSlot uint64
11+
LastExtendedSlotStartIndex uint8
12+
Authority []solana.PublicKey
13+
}
14+
15+
type AddressLookupTable struct {
16+
State uint32
17+
Meta AddressLookupTableMeta
18+
Addresses []solana.PublicKey
19+
}
20+
21+
func (inst *AddressLookupTable) UnmarshalWithDecoder(decoder *bin.Decoder) error {
22+
err := decoder.Decode(&inst.State)
23+
if err != nil {
24+
return err
25+
}
26+
err = decoder.Decode(&inst.Meta)
27+
if err != nil {
28+
return err
29+
}
30+
err = decoder.SetPosition(56)
31+
if err != nil {
32+
return err
33+
}
34+
for decoder.HasRemaining() {
35+
pub := &solana.PublicKey{}
36+
err = decoder.Decode(pub)
37+
if err != nil {
38+
return err
39+
}
40+
inst.Addresses = append(inst.Addresses, *pub)
41+
}
42+
return err
43+
}

api/solana/programs/reward_manager/ChangeManagerAccount.go renamed to api/spl/programs/reward_manager/ChangeManagerAccount.go

File renamed without changes.
File renamed without changes.

api/solana/programs/reward_manager/CreateSenderPublic.go renamed to api/spl/programs/reward_manager/CreateSenderPublic.go

File renamed without changes.
File renamed without changes.

api/solana/programs/reward_manager/DeleteSenderPublic.go renamed to api/spl/programs/reward_manager/DeleteSenderPublic.go

File renamed without changes.

api/solana/programs/reward_manager/EvaluateAttestations.go renamed to api/spl/programs/reward_manager/EvaluateAttestations.go

File renamed without changes.

api/solana/programs/reward_manager/EvaluateAttestations_test.go renamed to api/spl/programs/reward_manager/EvaluateAttestations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/hex"
55
"testing"
66

7-
"bridgerton.audius.co/api/solana/programs/reward_manager"
7+
"bridgerton.audius.co/api/spl/programs/reward_manager"
88
"github.com/gagliardetto/solana-go"
99
"github.com/stretchr/testify/require"
1010
)
File renamed without changes.

0 commit comments

Comments
 (0)