Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the locations of the accounts for testing a Mint #2442

Merged
merged 8 commits into from
Dec 11, 2023
Merged
9 changes: 8 additions & 1 deletion cmd/connector-common-winners-timescale/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
package main

import (
"github.com/fluidity-money/fluidity-app/lib/databases/postgres/solana"
database "github.com/fluidity-money/fluidity-app/lib/databases/timescale/winners"
queue "github.com/fluidity-money/fluidity-app/lib/queues/winners"
)

func main() {
queue.WinnersAll(database.InsertWinner)
go queue.WinnersEthereum(database.InsertWinner)

queue.WinnersSolana(func(winner queue.Winner) {
winningSignature := solana.GetIntermediateWinner(winner.TransactionHash)
winner.SendTransactionHash = winningSignature
database.InsertWinner(winner)
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

-- migrate:up

CREATE TABLE solana_intermediate_winners (
af-afk marked this conversation as resolved.
Show resolved Hide resolved
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
winning_signature VARCHAR NOT NULL,
payout_signature VARCHAR NOT NULL
af-afk marked this conversation as resolved.
Show resolved Hide resolved
);

-- migrate:down

DROP TABLE solana_intermediate_winners;
57 changes: 57 additions & 0 deletions lib/databases/postgres/solana/intermediate-winners.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2022 Fluidity Money. All rights reserved. Use of this
// source code is governed by a GPL-style license that can be found in the
// LICENSE.md file.

package solana

import (
"fmt"

"github.com/fluidity-money/fluidity-app/lib/log"
"github.com/fluidity-money/fluidity-app/lib/postgres"
)

// GetIntermediateWinner using a payout transaction signature
func GetIntermediateWinner(payoutSignature string) (winningSignature string) {
databaseClient := postgres.Client()

statementText := fmt.Sprintf(
`SELECT winning_signature
FROM %s
WHERE payout_signature = $;`,
af-afk marked this conversation as resolved.
Show resolved Hide resolved

TableIntermediateWinners,
)

row := databaseClient.QueryRow(statementText, payoutSignature)

if err := row.Err(); err != nil {
log.Fatal(func(k *log.Log) {
k.Context = Context

k.Format(
"Failed to query for an intermediate winner with payout sig %v",
payoutSignature,
)

k.Payload = err
})
}

err := row.Scan(&winningSignature)

if err != nil {
log.Fatal(func(k *log.Log) {
k.Context = Context

k.Format(
"Failed to scan the intermediate winners table for payout signature %v",
payoutSignature,
)

k.Payload = err
})
}

return winningSignature
}
5 changes: 5 additions & 0 deletions lib/databases/postgres/solana/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ const (

// TableMintLimits is used to store each token's per user mint limit
TableMintLimits = `solana_mint_limits`

// TableIntermediateWinners to use to track winners that were
// paid out and need to be linked in the winners database to the
// winning transaction
TableIntermediateWinners = `solana_intermediate_winners`
)
Loading