Skip to content

Commit

Permalink
src/auto.ts: Undo respecting followProxies for DiamondProxy
Browse files Browse the repository at this point in the history
Re-opens #132
  • Loading branch information
shazow committed Oct 1, 2024
1 parent 3dc8f52 commit fe8fa90
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,11 @@ export async function autoload(address: string, config: AutoloadConfig): Promise
};

if (result.proxies.length === 1 && result.proxies[0] instanceof DiamondProxyResolver) {
// TODO: Respect config.followProxies, see https://github.com/shazow/whatsabi/issues/132
onProgress("loadDiamondFacets", { address });
const diamondProxy = result.proxies[0] as DiamondProxyResolver;
if (config.followProxies) {
onProgress("loadDiamondFacets", { address });
const f = await diamondProxy.facets(provider, address);
Object.assign(facets, f);
} else {
result.followProxies = async function(selector?: string): Promise<AutoloadResult> {
if (selector) {
// Follow a single selector for DiamondProxy
onProgress("followProxies", { resolver: diamondProxy, address });
const resolved = await diamondProxy.resolve(provider, address, selector);
if (resolved !== undefined) return await autoload(resolved, config);
}
// Resolve all facets, unfortunately this requires doing the whole thing again with followProxy
// FIXME: Can we improve this codeflow easily?
// We could override the privider with a cached one here, but might be too magical and cause surprising bugs?
return await autoload(address, Object.assign({}, config, { followProxies: true }));
};
}
const f = await diamondProxy.facets(provider, address);
Object.assign(facets, f);

} else if (result.proxies.length > 0) {
result.followProxies = async function(selector?: string): Promise<AutoloadResult> {
Expand Down

0 comments on commit fe8fa90

Please sign in to comment.