Skip to content

Commit

Permalink
feat: check that sender is correct
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Maldonado <[email protected]>
  • Loading branch information
md0x committed Jul 19, 2024
1 parent 69b24fb commit 79fd454
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ const provider = getProvider();
const { ovalConfigs, ovalConfigsShared } = env;

// Initialize unlocker wallets for each Oval instance.
const walletManager = WalletManager.getInstance(provider);
walletManager.initialize(ovalConfigs, ovalConfigsShared);
const walletManager = WalletManager.getInstance();
walletManager.initialize(provider, ovalConfigs, ovalConfigsShared);

// Initialize Oval discovery
const ovalDiscovery = OvalDiscovery.getInstance();
Expand Down
8 changes: 8 additions & 0 deletions src/lib/walletManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { env } from "./env";
import { retrieveGckmsKey } from "./gckms";
import { isMochaTest } from "./helpers";
import { OvalConfigs, OvalConfigsShared } from "./types";
import { PermissionProxy__factory } from "../contract-types";

type WalletConfig = {
unlockerKey?: string;
Expand Down Expand Up @@ -120,6 +121,13 @@ export class WalletManager {
const wallet = await this.createWallet(config);
if (wallet) {
const walletPubKey = await wallet.getAddress();

// Check if the wallet is a sender in the PermissionProxy contract.
const isSender = await PermissionProxy__factory.connect(env.permissionProxyAddress, this.provider!).senders(wallet.address);
if (!isSender) {
throw new Error(`Wallet ${wallet.address} is not a sender in the PermissionProxy contract.`);
}

this.sharedWallets.set(walletPubKey, wallet);
}
}
Expand Down

0 comments on commit 79fd454

Please sign in to comment.