Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansonhkg committed Apr 4, 2023
1 parent 94deb7b commit 58d507c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/pkp-ethers/src/lib/handler.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ethers } from 'ethers';
import {
SignTypedDataVersion,
recoverTypedSignature,
recoverPersonalSignature,
} from '@metamask/eth-sig-util';

import {
Expand All @@ -22,11 +23,12 @@ const pkpEthersWallet = new PKPEthersWallet({

await pkpEthersWallet.init();

testThese([
await testThese([
{ name: 'signTypedData', fn: shouldSignTypedData },
{ name: 'signTypedDataV1', fn: shouldSignTypedDataV1 },
{ name: 'signTypedDataV3', fn: shouldSignTypedDataV3 },
{ name: 'signTypedDataV4', fn: shouldSignTypedDataV4 },
{ name: 'signTransaction', fn: shouldSignTransaction },
{ name: 'sendTransaction', fn: shouldSendTransaction },
]);

Expand Down Expand Up @@ -374,16 +376,11 @@ async function shouldSignTransaction() {

log.blue('signature', signature);

// verify signature
const recoveredAddr = recoverTransaction(signature);

log.blue('recoveredAddr', recoveredAddr);

if (recoveredAddr.toLowerCase() !== LITCONFIG.PKP_ADDRESS.toLowerCase()) {
if (signature === '' || signature === null || signature === undefined) {
return {
status: 500,
message:
'failed to sign transaction - recovered address does not match PKP address',
'failed to sign transaction - signature is empty, null or undefined',
};
}

Expand Down

0 comments on commit 58d507c

Please sign in to comment.