Skip to content

Commit 7d74d30

Browse files
authored
[SDK] Resolve EIP7511 minimal proxy (#2362)
1 parent f3a0154 commit 7d74d30

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

.changeset/shy-nails-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/sdk": patch
3+
---
4+
5+
Resolve EIP7511 minimal proxy with Push0 opcode

packages/sdk/src/evm/common/feature-detection/extractMinimalProxyImplementationAddress.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,11 @@ export function extractMinimalProxyImplementationAddress(
3636
return `0x${implementationAddress}`;
3737
}
3838

39+
// EIP-7511 minimal proxy with PUSH0 opcode - https://eips.ethereum.org/EIPS/eip-7511
40+
if (bytecode.startsWith("0x365f5f375f5f365f73")) {
41+
const implementationAddress = bytecode.slice(20, 60);
42+
return `0x${implementationAddress}`;
43+
}
44+
3945
return undefined;
4046
}

packages/sdk/test/evm/feature-detection.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ describe("Feature Detection", async () => {
4343
);
4444
});
4545

46+
it("should extract implementation address for eip-7511 minimal proxy", async () => {
47+
// https://eips.ethereum.org/EIPS/eip-7511#specification
48+
const code =
49+
"0x365f5f375f5f365f73bebebebebebebebebebebebebebebebebebebebe5af43d5f5f3e5f3d91602a57fd5bf3";
50+
const implementationAddress =
51+
extractMinimalProxyImplementationAddress(code);
52+
expect(implementationAddress).to.equal(
53+
"0xbebebebebebebebebebebebebebebebebebebebe",
54+
);
55+
});
56+
4657
it("should extract implementation address for minimal proxy with receive", async () => {
4758
// https://github.com/0xSplits/splits-contracts/blob/c7b741926ec9746182d0d1e2c4c2046102e5d337/contracts/libraries/Clones.sol#L32
4859
const code =

0 commit comments

Comments
 (0)