Skip to content

Commit

Permalink
Merge pull request #2408 from fluidity-money/develop-disable-ethereum
Browse files Browse the repository at this point in the history
Remove Ethereum from the codebase
  • Loading branch information
af-afk authored Nov 22, 2023
2 parents bf2ebac + dcfc0fa commit ff6fb09
Show file tree
Hide file tree
Showing 32 changed files with 108 additions and 535 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type HighestRewardByNetworkBody = {
};

const useHighestRewardStatisticsByNetwork = async (network: string) => {
if (network !== "ethereum" && network !== "arbitrum") {
if (network !== "arbitrum") {
throw Error(`network ${network} not supported`);
}

Expand Down
43 changes: 18 additions & 25 deletions web/app.fluidity.money/app/queries/useUserActionsAggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,33 +111,26 @@ const queryAll: Queryable = {
}
`,
solana: gql`
query userActionsAggregateAll(
$offset: Int = 0,
$limit: Int = 12,
) {
solana: user_transactions_aggregate(
args: {
network_: "solana",
limit_: $limit,
offset_: $offset
query userActionsAggregateAll($offset: Int = 0, $limit: Int = 12) {
solana: user_transactions_aggregate(
args: { network_: "solana", limit_: $limit, offset_: $offset }
) {
value: amount
receiver: recipient_address
rewardHash: reward_hash
sender: sender_address
hash: transaction_hash
utility_amount
utility_name
winner: winning_address
reward: winning_amount
application
currency
timestamp: time
swap_in
type
}
) {
value: amount
receiver: recipient_address
rewardHash: reward_hash
sender: sender_address
hash: transaction_hash
utility_amount
utility_name
winner: winning_address
reward: winning_amount
application
currency
timestamp: time
swap_in
type
}
}
`,
};

Expand Down
2 changes: 1 addition & 1 deletion web/app.fluidity.money/app/queries/useUserRewards.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ beforeAll(() => {
describe("useUserRewards successfully runs", () => {
it("should return a valid response", async () => {
const response = await useUserRewardsByAddress(
"ethereum",
"arbitrum",
"0xeb6b882a295d316ac62c8cfcc81c3e37c084b7c5"
);
expect(response).toBeDefined();
Expand Down
2 changes: 0 additions & 2 deletions web/app.fluidity.money/app/queries/useUserRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const queryWinnersAllSolana = gql`
`;

const queryWinnersAll: { [network in Chain]: string } = {
ethereum: queryWinnersAll_,
arbitrum: queryWinnersAll_,
polygon_zk: queryWinnersAll_,
solana: queryWinnersAllSolana,
Expand Down Expand Up @@ -118,7 +117,6 @@ const queryWinnersByAddressSolana = gql`
`;

const queryWinnersByAddress: { [network in Chain]: string } = {
ethereum: queryWinnersByAddress_,
arbitrum: queryWinnersByAddress_,
polygon_zk: queryWinnersByAddress_,
solana: queryWinnersByAddressSolana,
Expand Down
255 changes: 21 additions & 234 deletions web/app.fluidity.money/app/queries/useUserTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,6 @@ import {
import { MintAddress } from "~/types/MintAddress";

const queryByAddress: Queryable = {
ethereum: gql`
query getTransactionsByAddress(
$tokens: [String!]
$address: String!
$offset: Int = 0
$filterHashes: [String!] = []
$limit: Int = 12
) {
ethereum {
transfers(
currency: { in: $tokens }
any: [{ sender: { is: $address } }, { receiver: { is: $address } }]
options: {
desc: "block.timestamp.unixtime"
limit: $limit
offset: $offset
}
) {
sender {
address
}
receiver {
address
}
amount
currency {
symbol
}
transaction(txHash: { notIn: $filterHashes }) {
hash
}
block {
timestamp {
unixtime
}
}
}
}
}
`,

arbitrum: gql`
query getTransactionsByAddress(
$address: String!
Expand Down Expand Up @@ -164,71 +123,6 @@ const queryByAddress: Queryable = {
};

const queryByTxHash: Queryable = {
ethereum: gql`
query getTransactionsByTxHash(
$transactions: [String!]
$filterHashes: [String!] = []
$tokens: [String!] = []
$limit: Int = 12
) {
ethereum {
transfers(
options: { desc: "block.timestamp.unixtime", limit: $limit }
txHash: { in: $transactions }
currency: { in: $tokens }
) {
sender {
address
}
receiver {
address
}
amount
currency {
symbol
}
transaction(txHash: { notIn: $filterHashes }) {
hash
}
block {
timestamp {
unixtime
}
}
}
}
}
`,

arbitrum: gql`
query getTransactionsByTxHash(
$transactions: [String!]
$filterHashes: [String!] = []
$limit: Int = 12
) {
transfers: user_actions(
where: {
network: { _eq: "arbitrum" }
_not: { transaction_hash: { _in: $filterHashes } }
transaction_hash: { _in: $transactions }
}
order_by: { time: desc }
limit: $limit
) {
sender_address
recipient_address
token_short_name
time
transaction_hash
amount
token_decimals
type
swap_in
application
}
}
`,

solana: gql`
query getTransactionsByTxHash(
$transactions: [String!]
Expand Down Expand Up @@ -289,45 +183,6 @@ const queryByTxHash: Queryable = {
};

const queryAll: Queryable = {
ethereum: gql`
query getTransactions(
$tokens: [String!]
$offset: Int = 0
$filterHashes: [String!] = []
$limit: Int = 12
) {
ethereum {
transfers(
currency: { in: $tokens }
options: {
desc: "block.timestamp.unixtime"
limit: $limit
offset: $offset
}
) {
sender {
address
}
receiver {
address
}
amount
currency {
symbol
}
transaction(txHash: { notIn: $filterHashes }) {
hash
}
block {
timestamp {
unixtime
}
}
}
}
}
`,

arbitrum: gql`
query getTransactions(
$offset: Int = 0
Expand Down Expand Up @@ -468,26 +323,6 @@ export type UserTransaction = {
application: string;
};

type BitqueryUserTransaction = {
sender: {
address: string;
};
receiver: { address: string };
block: { timestamp: { unixtime: number } };
transaction: { hash: string };
amount: number;
currency: { symbol: string };
};

type BitqueryUserTransactionRes = {
data?: {
[network: string]: {
transfers: BitqueryUserTransaction[];
};
};
errors?: unknown;
};

type HasuraUserTransaction = {
sender_address: string;
recipient_address: string;
Expand Down Expand Up @@ -541,21 +376,13 @@ const useUserTransactionsByAddress = async (
errors: `Failed to fetch GraphQL URL and headers for network ${network}`,
};

const result =
networkGqlBackend(network) === "hasura"
? parseHasuraUserTransactions(
await jsonPost<
UserTransactionsByAddressBody,
HasuraUserTransactionRes
>(url, body, headers)
)
: parseBitqueryUserTransactions(
await jsonPost<
UserTransactionsByAddressBody,
BitqueryUserTransactionRes
>(url, body, headers),
network
);
const result = parseHasuraUserTransactions(
await jsonPost<UserTransactionsByAddressBody, HasuraUserTransactionRes>(
url,
body,
headers
)
);

return result;
};
Expand Down Expand Up @@ -586,21 +413,13 @@ const useUserTransactionsByTxHash = async (
errors: `Failed to fetch GraphQL URL and headers for network ${network}`,
};

const result =
networkGqlBackend(network) === "hasura"
? parseHasuraUserTransactions(
await jsonPost<
UserTransactionsByTxHashBody,
HasuraUserTransactionRes
>(url, body, headers)
)
: parseBitqueryUserTransactions(
await jsonPost<
UserTransactionsByTxHashBody,
BitqueryUserTransactionRes
>(url, body, headers),
network
);
const result = parseHasuraUserTransactions(
await jsonPost<UserTransactionsByTxHashBody, HasuraUserTransactionRes>(
url,
body,
headers
)
);

return result;
};
Expand Down Expand Up @@ -638,23 +457,13 @@ const useUserTransactionsAll = async (
errors: `Failed to fetch GraphQL URL and headers for network ${network}`,
};

const result =
networkGqlBackend(network) === "hasura"
? parseHasuraUserTransactions(
await jsonPost<UserTransactionsAllBody, HasuraUserTransactionRes>(
url,
body,
headers
)
)
: parseBitqueryUserTransactions(
await jsonPost<UserTransactionsAllBody, BitqueryUserTransactionRes>(
url,
body,
headers
),
network
);
const result = parseHasuraUserTransactions(
await jsonPost<UserTransactionsAllBody, HasuraUserTransactionRes>(
url,
body,
headers
)
);

return result;
};
Expand Down Expand Up @@ -711,28 +520,6 @@ const parseHasuraUserTransactions = (
};
};

const parseBitqueryUserTransactions = (
result: BitqueryUserTransactionRes,
network: string
): UserTransactionsRes => {
if (!result.data || result.errors)
return {
errors: result.errors,
};

const transfers: BitqueryUserTransaction[] =
result.data[network]?.transfers ?? [];

return {
data: {
transfers: transfers.map((transfer) => ({
...transfer,
application: "none",
})),
},
};
};

export {
useUserTransactionsAll,
useUserTransactionsByAddress,
Expand Down
Loading

0 comments on commit ff6fb09

Please sign in to comment.