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

deploy #62

Merged
merged 2 commits into from
Mar 3, 2025
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
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
NEXT_PUBLIC_GRAPH_KEY=
NEXT_PUBLIC_URL=
NEXT_PUBLIC_URL=
NEXT_PUBLIC_SEQUENCE_KEY=
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"deploy": "bun run pages:build && wrangler pages deploy"
},
"dependencies": {
"0xsequence": "^2.2.14",
"@farcaster/frame-sdk": "^0.0.16",
"@farcaster/frame-wagmi-connector": "^0.0.14",
"@hookform/resolvers": "^3.10.0",
Expand Down
2 changes: 0 additions & 2 deletions src/app/dao/[chainid]/[daoid]/dao-home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export default function DaoHome() {
daoid: params.daoid,
});

console.log("params", params);

if (!isLoaded || isDaoLoading) {
return (
<div className="h-full w-full flex items-center justify-center">
Expand Down
2 changes: 0 additions & 2 deletions src/components/app/DaoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { DaoListCard } from "./DaoListCard";
export const DaoList = () => {
const { address, chain } = useAccount();

console.log("DaoList chain", chain);

const { daos, isLoading, isFetched } = useDaosForAddress({
chainid: toHex(chain?.id || "0"),
address,
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/useDao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export const useDao = ({
);
}

console.log("useDao chainid daoid", chainid, daoid);

const { data, ...rest } = useQuery<{ dao: DaoItem }>({
queryKey: [`get-dao-${chainid}-${daoid}`],
enabled: Boolean(chainid && daoid),
Expand Down
58 changes: 40 additions & 18 deletions src/hooks/useDaoTokenBalances.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useQuery } from "@tanstack/react-query";

import { SequenceIndexer } from "@0xsequence/indexer";
import { TokenBalance } from "@/lib/types";
import { getGnosisUrl } from "@/lib/endpoints";

import { getAddress } from "viem";
import { getTokenIndexerUrl } from "@/lib/endpoints";

export const useDaoTokenBalances = ({
chainid,
Expand All @@ -12,7 +10,7 @@ export const useDaoTokenBalances = ({
chainid?: string;
safeAddress?: string;
}) => {
const gnosisUrl = getGnosisUrl({
const url = getTokenIndexerUrl({
chainid: chainid || "",
});

Expand All @@ -21,22 +19,46 @@ export const useDaoTokenBalances = ({
`get-dao-token-balances${chainid}-${safeAddress}`,
{ chainid, safeAddress },
],
enabled: Boolean(chainid && safeAddress),
enabled: Boolean(chainid && safeAddress && url),
queryFn: async (): Promise<{
tokens: TokenBalance[];
}> => {
let balances = [] as TokenBalance[];
try {
const res = await fetch(
`${gnosisUrl}/safes/${getAddress(safeAddress || "")}/balances/?exclude_spam=true`
);

balances = await res.json();
} catch (err) {
console.log("token fetch error", err);
}

return { tokens: balances };
const key = process.env.NEXT_PUBLIC_SEQUENCE_KEY;

const indexer = new SequenceIndexer(url, key);

const tokenBalances = await indexer.getTokenBalances({
accountAddress: safeAddress,
includeMetadata: true,
includeCollectionTokens: false,
metadataOptions: { verifiedOnly: true },
});

const balance = await indexer.getEtherBalance({
accountAddress: safeAddress,
});

const transformedTokenBalances = tokenBalances.balances.map(
(tokenBal) => {
return {
token: {
decimals: tokenBal.contractInfo?.decimals,
symbol: tokenBal.contractInfo?.symbol,
name: tokenBal.contractInfo?.name,
logoUri: tokenBal.contractInfo?.logoURI,
},
tokenAddress: tokenBal.contractAddress,
balance: tokenBal.balance,
};
}
);

const nativeBalance = {
tokenAddress: null,
balance: balance.balance.balanceWei,
};

return { tokens: [nativeBalance, ...transformedTokenBalances] };
},
});

Expand Down
29 changes: 16 additions & 13 deletions src/lib/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const getGraphUrl = ({
graphKey: string;
subgraphKey: string;
}): string => {
console.log("getGraphUrl chainid", chainid);
const subgraphHash = SUBGRAPH_IDS[subgraphKey][chainid];
if (!subgraphHash) {
console.log("invalid chainid or subgraphkey");
Expand Down Expand Up @@ -35,20 +34,24 @@ const SUBGRAPH_IDS: KeychainList = {
},
};

export const getGnosisUrl = ({ chainid }: { chainid: string }): string => {
const gnosisUrl = GNOSIS_API[chainid];
if (!gnosisUrl) {
export const getTokenIndexerUrl = ({
chainid,
}: {
chainid: string;
}): string => {
const url = SEQUENCE_API[chainid];
if (!url) {
console.log("invalid chainid");
}
return gnosisUrl;
return url;
};

const GNOSIS_API: KEYCHAIN = {
"0x1": "https://safe-transaction-mainnet.safe.global/api/v1",
"0x64": "https://safe-transaction-gnosis-chain.safe.global/api/v1",
"0x89": "https://safe-transaction-polygon.safe.global/api/v1",
"0xa": "https://safe-transaction-optimism.safe.global/api/v1",
"0xa4b1": "https://safe-transaction-arbitrum.safe.global/api/v1",
"0xaa36a7": "https://safe-transaction-sepolia.safe.global/api/v1",
"0x2105": "https://safe-transaction-base.safe.global/api/v1",
const SEQUENCE_API: KEYCHAIN = {
"0x1": "https://mainnet-indexer.sequence.app",
"0x64": "https://gnosis-indexer.sequence.app",
"0x89": "https://polygon-indexer.sequence.app",
"0xa": "https://optimism-indexer.sequence.app",
"0xa4b1": "https://arbitrum-indexer.sequence.app",
"0xaa36a7": "https://sepolia-indexer.sequence.app",
"0x2105": "https://base-indexer.sequence.app",
};
12 changes: 5 additions & 7 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,13 @@ export type WaitForReceipt = {
};

export type TokenInfo = {
decimals: number;
symbol: string;
name: string;
logoUri: string | null;
decimals?: number;
symbol?: string;
name?: string;
logoUri?: string | null;
};
export type TokenBalance = {
token: TokenInfo | null;
token?: TokenInfo | null;
tokenAddress: string | null;
balance: string;
ethValue: string;
timestamp: string;
};