Skip to content

Commit

Permalink
style: update error messages for unsupported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Dec 13, 2024
1 parent fca207d commit 949b10d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ node_modules/
!.yarn/sdks
!.yarn/versions

# ignore intellij local files
.idea/
2 changes: 1 addition & 1 deletion snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/message-signing-snap.git"
},
"source": {
"shasum": "WwjAlInXlGmhYmPE2iWLXj4UWwZecHhC0gIrwLqDLk0=",
"shasum": "SOtH39orNYpHZta/W/BcM5Fbsdruu88WVrsQiy/R8u8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
4 changes: 2 additions & 2 deletions src/utils/ERC1024.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ describe('errors:', () => {
'CyTDtSMUSxJ8wQ5Ht7fvko2frSuEEE9Srs5hZ/IODQ4=',
);
const encrypted = {
version: 'ed25519-xsalsa20-poly1305',
version: 'unsupported version',
};
expect(() => ERC1024.decrypt(encrypted as any, receiverSecret)).toThrow(
'Encryption type/version not supported.',
'Encryption type/version not supported (unsupported version).',
);
});

Expand Down
6 changes: 4 additions & 2 deletions src/utils/ERC1024.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const encrypt = (
} as Eip1024EncryptedData;
}
default:
throw new Error('Encryption type/version not supported');
throw new Error(`Encryption type/version not supported ${version}`);
}
};

Expand Down Expand Up @@ -88,7 +88,9 @@ const decrypt = (
return bytesToUtf8(decryptedMessage);
}
default:
throw new Error('Encryption type/version not supported.');
throw new Error(
`Encryption type/version not supported (${encryptedData.version}).`,
);
}
};

Expand Down

0 comments on commit 949b10d

Please sign in to comment.