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

Use the aggregate transactions table for rendering the winners tab #2480

Merged
merged 6 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/types/user-actions/user-actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ type (

// AggregatedTransactionFromUserAction to create a partially aggregated transaction from a user action
func AggregatedTransactionFromUserAction(userAction UserAction) AggregatedUserTransaction {
var (
var (
senderAddress string
recipientAddress string
)
Expand Down Expand Up @@ -180,7 +180,7 @@ func AggregatedTransactionFromPendingWinner(pendingWinner winners.PendingWinner)
SenderAddress: senderAddress,
// the sender is the winner of a pending win
WinningAddress: senderAddress,
Type: "send",
Type: "send",
}

if pendingWinner.Utility == "FLUID" {
Expand Down
35 changes: 10 additions & 25 deletions web/app.fluidity.money/app/queries/useUserTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {
hasuraDateToUnix,
networkGqlBackend,
} from "~/util/api/graphql";
import BN from "bn.js";
import {
addDecimalToBn,
getTokenFromAddress,
Token,
} from "~/util/chainUtils/tokens";
Expand All @@ -21,7 +19,7 @@ const queryByAddress: Queryable = {
$limit: Int = 12
$tokens: [String!] = []
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "arbitrum" }
token_short_name: { _in: $tokens }
Expand Down Expand Up @@ -59,7 +57,7 @@ const queryByAddress: Queryable = {
$limit: Int = 12
$tokens: [String!] = []
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "solana" }
token_short_name: { _in: $tokens }
Expand All @@ -79,7 +77,6 @@ const queryByAddress: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand All @@ -97,7 +94,7 @@ const queryByAddress: Queryable = {
$limit: Int = 12
$tokens: [String!] = []
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "polygon_zk" }
token_short_name: { _in: $tokens }
Expand All @@ -117,7 +114,6 @@ const queryByAddress: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand All @@ -135,7 +131,7 @@ const queryByTxHash: Queryable = {
$filterHashes: [String!] = []
$limit: Int = 12
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "arbitrum" }
_not: { transaction_hash: { _in: $filterHashes } }
Expand All @@ -150,7 +146,6 @@ const queryByTxHash: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand All @@ -165,7 +160,7 @@ const queryByTxHash: Queryable = {
$filterHashes: [String!] = []
$limit: Int = 12
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "solana" }
_not: { transaction_hash: { _in: $filterHashes } }
Expand All @@ -180,7 +175,6 @@ const queryByTxHash: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand All @@ -196,7 +190,7 @@ const queryByTxHash: Queryable = {
$filterHashes: [String!] = []
$limit: Int = 12
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "polygon_zk" }
_not: { transaction_hash: { _in: $filterHashes } }
Expand All @@ -211,7 +205,6 @@ const queryByTxHash: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand All @@ -230,7 +223,7 @@ const queryAll: Queryable = {
$limit: Int = 12
$tokens: [String!] = []
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "arbitrum" }
_not: { transaction_hash: { _in: $filterHashes } }
Expand Down Expand Up @@ -263,7 +256,7 @@ const queryAll: Queryable = {
$limit: Int = 12
$tokens: [String!] = []
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "solana" }
_not: { transaction_hash: { _in: $filterHashes } }
Expand All @@ -279,7 +272,6 @@ const queryAll: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand All @@ -296,7 +288,7 @@ const queryAll: Queryable = {
$limit: Int = 12
$tokens: [String!] = []
) {
transfers: user_actions_lootbottles(
transfers: aggregated_user_transactions(
where: {
network: { _eq: "polygon_zk" }
_not: { transaction_hash: { _in: $filterHashes } }
Expand All @@ -312,7 +304,6 @@ const queryAll: Queryable = {
time
transaction_hash
amount
token_decimals
type
swap_in
application
Expand Down Expand Up @@ -375,7 +366,6 @@ type HasuraUserTransaction = {
sender_address: string;
recipient_address: string;
amount: number;
token_decimals: number;
token_short_name: string;
transaction_hash: string;
time: string;
Expand Down Expand Up @@ -552,12 +542,7 @@ const parseHasuraUserTransactions = (
return {
sender: { address: senderAddress },
receiver: { address: recipientAddress },
amount: Number(
addDecimalToBn(
new BN(String(transfer.amount)),
transfer.token_decimals
)
),
amount: transfer.amount,
currency: { symbol: "f" + transfer.token_short_name },
transaction: { hash: transfer.transaction_hash },
block: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export async function loader() {
},
].map(({ network, abi, getPrizePool }) => {
const infuraRpc = config.drivers[network][mainnetId].rpc.http;
console.log("infura rpc", infuraRpc);
const provider = new JsonRpcProvider(infuraRpc);

const rewardPoolAddr = config.contract.prize_pool[network as Chain];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type UserTransaction = {
value: number;
currency: string;
application: string;
lootboxCount: number;
rewardTier: number;
lootboxCount: number;
};

export type TransactionsLoaderData = {
Expand Down Expand Up @@ -208,8 +208,8 @@ export const loader: LoaderFunction = async ({ params, request }) => {
amount: value,
currency: { symbol: currency },
application,
lootboxCount,
rewardTier,
lootboxCount
} = transaction;

return {
Expand Down Expand Up @@ -292,8 +292,8 @@ export const loader: LoaderFunction = async ({ params, request }) => {
swapType,
utilityTokens: winner.utility,
application: tx.application,
lootboxCount: tx.lootboxCount,
rewardTier: tx.rewardTier,
lootboxCount: tx.lootboxCount,
};
});

Expand All @@ -316,4 +316,4 @@ export const loader: LoaderFunction = async ({ params, request }) => {
);
return new Error("Server could not fulfill request");
}
};
};
Loading