Skip to content

Commit

Permalink
fix: working old examples
Browse files Browse the repository at this point in the history
  • Loading branch information
idea404 committed Nov 10, 2023
1 parent 35fcc82 commit 4d64b25
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 11 additions & 2 deletions contracts/TwoUserMultisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,17 @@ contract TwoUserMultisig is IAccount, IERC1271 {
magic = bytes4(0);
}

address recoveredAddr1 = ECDSA.recover(_hash, signature1);
address recoveredAddr2 = ECDSA.recover(_hash, signature2);
(address recoveredAddr1, ECDSA.RecoverError error) = ECDSA.tryRecover(_hash, signature1);
if (error != ECDSA.RecoverError.NoError) {
magic = bytes4(0);
return magic;
}

(address recoveredAddr2, ECDSA.RecoverError error2) = ECDSA.tryRecover(_hash, signature2);
if (error2 != ECDSA.RecoverError.NoError) {
magic = bytes4(0);
return magic;
}

// Note, that we should abstain from using the require here in order to allow for fee estimation to work
if(recoveredAddr1 != owner1 || recoveredAddr2 != owner2) {
Expand Down
8 changes: 4 additions & 4 deletions test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("Account Abstraction Tests", function () {
ownerWallet2 = zks.Wallet.createRandom();
accountContract = await deployMultisig(firstRichWallet, factoryContract.address, ownerWallet1, ownerWallet2);
await fundAccount(firstRichWallet, accountContract.address);
await signMultiSigTx(firstRichWallet, accountContract.address, factoryContract.address, ownerWallet1, ownerWallet2);
// await signMultiSigTx(firstRichWallet, accountContract.address, factoryContract.address, ownerWallet1, ownerWallet2);
});

it("Should have a tx hash that starts from 0x", async function () {
Expand Down Expand Up @@ -77,10 +77,10 @@ describe("Account Abstraction Tests", function () {
})
).wait();
const balance = (await provider.getBalance(firstRichWallet.address)).toBigInt();
const difference = balanceBefore - balance;
const difference = balance - balanceBefore;
// expect to be slightly higher than 5
expect(difference / BigInt(10 ** 18) > 4.9).to.be.true;
expect(difference / BigInt(10 ** 18) < 5.1).to.be.true;
expect(difference / BigInt(10 ** 18) > 9.9).to.be.true;
expect(difference / BigInt(10 ** 18) < 10.1).to.be.true;
});
});
});
Expand Down

0 comments on commit 4d64b25

Please sign in to comment.