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

Safe subgraph queries #2746

Closed
wants to merge 5 commits into from
Closed

Safe subgraph queries #2746

wants to merge 5 commits into from

Conversation

adamgall
Copy link
Member

@adamgall adamgall commented Feb 26, 2025

Beginnings of implementation of Subgraph Query to determine whether or not an address is a Safe

@adamgall adamgall marked this pull request as draft February 26, 2025 06:17
Copy link

cloudflare-workers-and-pages bot commented Feb 26, 2025

Deploying decent-interface with  Cloudflare Pages  Cloudflare Pages

Latest commit: 03d6d07
Status: ✅  Deploy successful!
Preview URL: https://0e46adf1.decent-interface.pages.dev
Branch Preview URL: https://safe-subgraph-queries.decent-interface.pages.dev

View logs

Comment on lines 146 to 168
// TODO: uncomment this out once subgraph testing is completed and working
// try {
// type SafeClientCreationInfoResponse = {
// readonly created: string;
// readonly creator: string;
// readonly transactionHash: string;
// readonly factoryAddress: string;

// readonly masterCopy: string;
// readonly setupData: string;
// };

// const response: SafeClientCreationInfoResponse = await this._safeClientGet(
// safeAddress,
// '/transactions/creation',
// );

// return { ...response, singleton: response.masterCopy };
// } catch (error) {
// console.error('Error fetching getSafeCreationInfo from safe-client:', error);
// }

// TODO: this is what needs to be tested
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good place to start.

Find out where in the codebase is calling this getSafeCreationInfo function, to trigger it to run, and test that we can get the correct data from these subgraph graphql calls.

You can use the Playground to verify that data is actually there and available:

Check out the query in SafeQueries.ts to see the one we're using.

When I left off, the subgraph calls were returning strange "Message: Not Found" errors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not getting the error now. Seems to work for me, so I can search on mainnet on sepolia.

This DAO: 0xF222823699a84A6Dcd47A1A860554A5B9DAaaf47 should exist on Base though, but the query returns nothing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to figure out why, @DarksightKellar ?

…ppen in parallel, not in sequence. Much faster DAO searching now.
Comment on lines +31 to +55
// We're going to call getSafeCreationInfo for each resolved address
// If it throws, we don't have a Safe at that address
// If it doesn't throw, we add the resolved address and chainId to our list
const creationInfos = (
await Promise.all(
resolvedAddressesWithChainId.map(async resolved => {
try {
const safeAPI = getSafeAPI(getConfigByChainId(resolved.chainId));

setSafeResolvedAddressesWithPrefix(prevState => [...prevState, resolved]);
} catch (e) {
// Safe not found
continue;
}
}
// if this throws, we don't have a Safe
await safeAPI.getSafeCreationInfo(resolved.address);

// We actually only care about returning the resolved address and chainId
return resolved;
} catch (e) {
// Safe not found
return null;
}
}),
)
).filter(creationInfo => creationInfo !== null);

// We're left with a list of chains and addresses
// (all the same address) that have a Safe at that address.
setSafeResolvedAddressesWithPrefix(creationInfos);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here to make the DAO Searching do all network requests in parallel, not in sequence. Faster searching.

// add another layer of onchain fallback here
// use subgraph to get this data
const client = createDecentSubgraphClient(this.networkConfig);
const queryResult = await client.query<any>(SafeQuery, { safeAddress });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use the actual type from SafeQueries, not "any"

@adamgall
Copy link
Member Author

Closing this PR in favor of #2747

@adamgall adamgall closed this Feb 27, 2025
@adamgall adamgall deleted the safe-subgraph-queries branch February 27, 2025 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants