|
1 | 1 | import { type Abi, formatAbi, parseAbi } from "abitype";
|
2 |
| -import { getInstalledModules } from "../../extensions/modules/__generated__/IModularCore/read/getInstalledModules.js"; |
3 | 2 | import { download } from "../../storage/download.js";
|
4 |
| -import { extractIPFSUri } from "../../utils/bytecode/extractIPFS.js"; |
5 | 3 | import { getClientFetch } from "../../utils/fetch.js";
|
6 | 4 | import type { ThirdwebContract } from "../contract.js";
|
7 |
| -import { getBytecode } from "./get-bytecode.js"; |
8 | 5 |
|
9 | 6 | const ABI_RESOLUTION_CACHE = new WeakMap<ThirdwebContract<Abi>, Promise<Abi>>();
|
10 | 7 |
|
@@ -117,7 +114,11 @@ export async function resolveAbiFromBytecode(
|
117 | 114 | // biome-ignore lint/suspicious/noExplicitAny: library function that accepts any contract type
|
118 | 115 | contract: ThirdwebContract<any>,
|
119 | 116 | ): Promise<Abi> {
|
120 |
| - const bytecode = await getBytecode(contract); |
| 117 | + const [{ resolveImplementation }, { extractIPFSUri }] = await Promise.all([ |
| 118 | + import("../../utils/bytecode/resolveImplementation.js"), |
| 119 | + import("../../utils/bytecode/extractIPFS.js"), |
| 120 | + ]); |
| 121 | + const { bytecode } = await resolveImplementation(contract); |
121 | 122 | if (bytecode === "0x") {
|
122 | 123 | const { id, name } = contract.chain;
|
123 | 124 | throw new Error(
|
@@ -366,6 +367,9 @@ async function resolveModularModuleAddresses(
|
366 | 367 | contract: ThirdwebContract,
|
367 | 368 | ): Promise<string[]> {
|
368 | 369 | try {
|
| 370 | + const { getInstalledModules } = await import( |
| 371 | + "../../extensions/modules/__generated__/IModularCore/read/getInstalledModules.js" |
| 372 | + ); |
369 | 373 | const modules = await getInstalledModules({ contract });
|
370 | 374 | // if there are no plugins, return the root ABI
|
371 | 375 | if (!modules.length) {
|
@@ -434,14 +438,15 @@ function joinAbis(options: JoinAbisOptions): Abi {
|
434 | 438 | .filter((item) => item.type !== "constructor");
|
435 | 439 |
|
436 | 440 | if (options.rootAbi) {
|
437 |
| - mergedPlugins = [...(options.rootAbi || []), ...mergedPlugins].filter( |
438 |
| - Boolean, |
439 |
| - ); |
| 441 | + mergedPlugins = [...options.rootAbi, ...mergedPlugins] |
| 442 | + .filter((item) => item.type !== "fallback" && item.type !== "receive") |
| 443 | + .filter(Boolean); |
440 | 444 | }
|
441 | 445 |
|
442 | 446 | // unique by formatting every abi and then throwing them in a set
|
443 | 447 | // TODO: this may not be super efficient...
|
444 | 448 | const humanReadableAbi = [...new Set(formatAbi(mergedPlugins))];
|
| 449 | + |
445 | 450 | // finally parse it back out
|
446 | 451 | return parseAbi(humanReadableAbi);
|
447 | 452 | }
|
0 commit comments