Skip to content

Commit eea499b

Browse files
committed
undo changes to audio claim flow
1 parent 04d6153 commit eea499b

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

‎api/v1_claim_rewards.go‎

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ func fetchAttestations(
217217
hasAntiAbuseOracleAttestation bool,
218218
minVotes int,
219219
) ([]SenderAttestation, error) {
220+
220221
// Shuffle the validators
221222
shuffled := slices.Clone(allValidators)
222223
rand.Shuffle(len(shuffled), func(i, j int) {
@@ -354,7 +355,6 @@ func sendRewardClaimTransactions(
354355
transactionSender *spl.TransactionSender,
355356
rewardClaim RewardClaim,
356357
attestations []SenderAttestation,
357-
sourceTokenAccount *solana.PublicKey,
358358
) ([]solana.Signature, error) {
359359
// Transaction to send attestations in a separate transaction
360360
partialTx := solana.NewTransactionBuilder()
@@ -445,17 +445,14 @@ func sendRewardClaimTransactions(
445445
if err != nil {
446446
return nil, err
447447
}
448-
if sourceTokenAccount == nil {
449-
sourceTokenAccount = &state.TokenAccount
450-
}
451448
evaluateAttestationInstruction, err := reward_manager.NewEvaluateAttestationInstruction(
452449
rewardClaim.RewardID,
453450
rewardClaim.Specifier,
454451
common.HexToAddress(rewardClaim.RecipientEthAddress),
455-
rewardClaim.Amount*rewardClaim.TokenDecimals, // Convert to token wei
452+
rewardClaim.Amount*1e8, // Convert to wAUDIO wei
456453
common.HexToAddress(rewardClaim.ClaimAuthority),
457454
rewardManagerClient.GetProgramStateAccount(),
458-
*sourceTokenAccount,
455+
state.TokenAccount,
459456
rewardClaim.UserBank,
460457
feePayer.PublicKey(),
461458
)
@@ -555,7 +552,6 @@ func claimReward(
555552
transactionSender,
556553
rewardClaim,
557554
attestations,
558-
nil, // No ATA needed for AUDIO rewards
559555
)
560556
if err != nil {
561557
return nil, err
@@ -617,9 +613,8 @@ func getReward(rewardId string, rewardsList []rewards.Reward) (rewards.Reward, e
617613

618614
type RewardClaim struct {
619615
rewards.RewardClaim
620-
Handle string
621-
UserBank solana.PublicKey
622-
TokenDecimals uint64
616+
Handle string
617+
UserBank solana.PublicKey
623618
}
624619

625620
type ClaimResult struct {
@@ -716,9 +711,8 @@ func (app *ApiServer) v1ClaimRewards(c *fiber.Ctx) error {
716711
RecipientEthAddress: row.Wallet.String,
717712
ClaimAuthority: antiAbuseOracle.DelegateOwnerWallet,
718713
},
719-
Handle: row.Handle.String,
720-
UserBank: *bankAccount,
721-
TokenDecimals: 8, // wAUDIO wei
714+
Handle: row.Handle.String,
715+
UserBank: *bankAccount,
722716
}
723717

724718
validators := app.validators.GetNodes()

‎api/v1_coins_post_redeem.go‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func (app *ApiServer) v1CoinsPostRedeem(c *fiber.Ctx) error {
115115
if err != nil {
116116
return fmt.Errorf("failed to get init pubkey for reward manager state address: %w", err)
117117
}
118-
tokenSourcePubkey, err := solana.PublicKeyFromBase58(tokenSourceAddress)
119118
if err != nil {
120119
return fmt.Errorf("failed to init pubkey for token source address: %w", err)
121120
}
@@ -241,10 +240,9 @@ func (app *ApiServer) v1CoinsPostRedeem(c *fiber.Ctx) error {
241240
}
242241

243242
decoratedRewardClaim := RewardClaim{
244-
RewardClaim: rewardClaim,
245-
Handle: userHandle,
246-
UserBank: *bankAccount,
247-
TokenDecimals: uint64(coinDecimals),
243+
RewardClaim: rewardClaim,
244+
Handle: userHandle,
245+
UserBank: *bankAccount,
248246
}
249247

250248
claimMessage, err := rewardClaim.Compile()
@@ -305,7 +303,6 @@ func (app *ApiServer) v1CoinsPostRedeem(c *fiber.Ctx) error {
305303
app.transactionSender,
306304
decoratedRewardClaim,
307305
attestations,
308-
&tokenSourcePubkey,
309306
)
310307

311308
if err != nil {

0 commit comments

Comments
 (0)