From f5cfee163de4a069feaa2625a2a1ba08330a2d71 Mon Sep 17 00:00:00 2001 From: seinmyung25 Date: Fri, 29 Dec 2023 16:48:48 +0900 Subject: [PATCH] feat: proxy slot utils --- helper/eco-proxy.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/helper/eco-proxy.ts b/helper/eco-proxy.ts index 7a6b5d9..eef3c86 100644 --- a/helper/eco-proxy.ts +++ b/helper/eco-proxy.ts @@ -40,11 +40,21 @@ export class ProxyFactory extends AsyncConstructor { const inst = await logic.attach(proxy) as EcoProxiedInstance; inst.ecoProxy = proxy; - inst.ecoProxyAdmin = this.proxyAdminFactory.attach(await ethers.provider.getStorage(proxy, this.ADMIN_SLOT)) as EcoProxyAdmin; + inst.ecoProxyAdmin = this.proxyAdminFactory.attach(await this.getAdminAddress(proxy)) as EcoProxyAdmin; inst.ecoLogic = logic; return inst; } + + async getImplAddress(logic:CT) { + const slotData = await ethers.provider.getStorage(logic, this.IMPLEMENTATION_SLOT) + return ethers.getAddress("0x" + slotData.slice(-40)); + } + + async getAdminAddress(logic:CT) { + const slotData = await ethers.provider.getStorage(logic, this.ADMIN_SLOT) + return ethers.getAddress("0x" + slotData.slice(-40)); + } } async function test() {