Skip to content

Commit

Permalink
manager check
Browse files Browse the repository at this point in the history
  • Loading branch information
tempe-techie committed Oct 6, 2023
1 parent 0bf3bf8 commit d75f321
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/store/modules/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit d75f321

Please sign in to comment.