Skip to content

Commit

Permalink
feat: proxy slot utils
Browse files Browse the repository at this point in the history
  • Loading branch information
seinmyung25 committed Dec 29, 2023
1 parent 38f022c commit f5cfee1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion helper/eco-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,21 @@ export class ProxyFactory extends AsyncConstructor {
const inst = await logic.attach(proxy) as EcoProxiedInstance<CT>;

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<CT extends BaseContract>(logic:CT) {
const slotData = await ethers.provider.getStorage(logic, this.IMPLEMENTATION_SLOT)
return ethers.getAddress("0x" + slotData.slice(-40));
}

async getAdminAddress<CT extends BaseContract>(logic:CT) {
const slotData = await ethers.provider.getStorage(logic, this.ADMIN_SLOT)
return ethers.getAddress("0x" + slotData.slice(-40));
}
}

async function test() {
Expand Down

0 comments on commit f5cfee1

Please sign in to comment.