Skip to content

Commit 08cc489

Browse files
committed
[SDK] Update implementation addr extraction logic (#6093)
TOOL-3258 <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces support for EIP-7702 by adding functionality to extract the implementation address from a specific bytecode pattern. It includes a new utility function and a corresponding test case. ### Detailed summary - Added EIP-7702 support in `extractMinimalProxyImplementationAddress.ts` to extract the implementation address from bytecode. - Implemented a check for bytecode length and prefix. - Added a test case in `extractMinimalProxyImplementationAddress.test.ts` to validate the new functionality. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent f03ded3 commit 08cc489

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
7702 delegation designator

packages/thirdweb/src/utils/bytecode/extractMinimalProxyImplementationAddress.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ describe("extractMinimalProxyImplementationAddress", () => {
5151
expect(result).toBe("0xbebebebebebebebebebebebebebebebebebebebe");
5252
});
5353

54+
it("should extract address from EIP-7702 delegation designator", () => {
55+
const bytecode = "0xef0100bebebebebebebebebebebebebebebebebebebebe";
56+
const result = extractMinimalProxyImplementationAddress(bytecode);
57+
expect(result).toBe("0xbebebebebebebebebebebebebebebebebebebebe");
58+
});
59+
5460
it("should return undefined for non-matching bytecode", () => {
5561
const bytecode =
5662
"0x60806040526000805534801561001457600080fd5b50610150806100246000396000f3fe";

packages/thirdweb/src/utils/bytecode/extractMinimalProxyImplementationAddress.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,11 @@ export function extractMinimalProxyImplementationAddress(
5454
return `0x${implementationAddress}`;
5555
}
5656

57+
// EIP-7702 - https://eips.ethereum.org/EIPS/eip-7702#abstract
58+
if (bytecode.length === 48 && bytecode.startsWith("0xef0100")) {
59+
const implementationAddress = bytecode.slice(8, 48);
60+
return `0x${implementationAddress}`;
61+
}
62+
5763
return undefined;
5864
}

0 commit comments

Comments
 (0)