-
Notifications
You must be signed in to change notification settings - Fork 7
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
Safe subgraph queries #2746
Conversation
Release/v0.7.2
…r not an address is a Safe
Deploying decent-interface with
|
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 |
// 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
// 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); |
There was a problem hiding this comment.
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 }); |
There was a problem hiding this comment.
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"
Closing this PR in favor of #2747 |
Beginnings of implementation of Subgraph Query to determine whether or not an address is a Safe