From d75f3212423ac75b55e9bd289a04c88b6c7a6731 Mon Sep 17 00:00:00 2001 From: Tempe Techie <95053628+tempe-techie@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:33:01 +0200 Subject: [PATCH] manager check --- src/store/modules/user.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 6579fde..1ee90c4 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -195,8 +195,12 @@ export default { actions: { async checkIfAdmin({ commit, rootGetters }) { if (address.value) { + // check if user has any admin privileges - const minterIntfc = new ethers.utils.Interface(MinterAbi); + const minterIntfc = new ethers.utils.Interface([ + "function owner() public view returns (address)", + "function isManager(address) public view returns (bool)" + ]); const minterContract = new ethers.Contract(rootGetters["tld/getMinterAddress"], minterIntfc, signer.value); const minterAdmin = await minterContract.owner(); @@ -207,6 +211,17 @@ export default { commit("setIsMinterAdmin", false); } + if (minterAdmin != address.value) { + // check if current user is manager of the minter contract + const isManager = await minterContract.isManager(address.value); + + if (isManager) { + commit("setIsMinterAdmin", true); + } else { + commit("setIsMinterAdmin", false); + } + } + // check if user has any admin privileges const tldIntfc = new ethers.utils.Interface(TldAbi); const tldContract = new ethers.Contract(rootGetters["tld/getTldAddress"], tldIntfc, signer.value);