Skip to content

Commit

Permalink
use provider for permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
kevtechi committed Nov 10, 2024
1 parent d88e275 commit ca0b16e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export class BundlerService {

return hash;
} catch (e) {
if (!(await hasRole(tokenAddress, MINTER_ROLE, from, signer))) {
if (!(await hasRole(tokenAddress, MINTER_ROLE, from, this.provider))) {
throw new Error(
`Signer (${from}) does not have the MINTER_ROLE on token contract ${tokenAddress}`
);
Expand Down
6 changes: 3 additions & 3 deletions src/utils/crypto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ethers } from "ethers";
import { ethers, JsonRpcProvider } from "ethers";
import accessControlABI from "../abi/IAccessControlUpgradeable.abi.json" with { type: "json" };

export const MINTER_ROLE =
Expand All @@ -15,12 +15,12 @@ export async function hasRole(
tokenAddress: string,
role: string,
account: string,
signer: ethers.Signer
provider: JsonRpcProvider
): Promise<boolean> {
const tokenContract = new ethers.Contract(
tokenAddress,
accessControlABI,
signer
provider
);
return await tokenContract.getFunction("hasRole")(role, account);
}

0 comments on commit ca0b16e

Please sign in to comment.