Skip to content

Commit

Permalink
Merge pull request #152 from zama-ai/betterError
Browse files Browse the repository at this point in the history
Better error
  • Loading branch information
jatZama authored Dec 14, 2024
2 parents 67ecdfd + 3344021 commit f40b193
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fhevmjs",
"version": "0.6.0",
"version": "0.6.1",
"description": "fhEVM SDK for blockchain using TFHE",
"main": "lib/node.js",
"types": "lib/node/node.d.ts",
Expand Down Expand Up @@ -52,9 +52,9 @@
"fetch-mock": "^11.1.3",
"keccak": "^3.0.4",
"node-tfhe": "^0.9.1",
"node-tkms": "0.9.0-rc36",
"node-tkms": "^0.9.0",
"tfhe": "^0.9.1",
"tkms": "0.9.0-rc36",
"tkms": "^0.9.0",
"wasm-feature-detect": "^1.8.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type FhevmInstance = {
createEIP712: (
publicKey: string,
contractAddress: string,
userAddress?: string,
delegatedAccount?: string,
) => EIP712;
reencrypt: (
handle: bigint,
Expand Down
8 changes: 6 additions & 2 deletions src/sdk/reencrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ export const reencryptRequest =
const acl = new ethers.Contract(aclContractAddress, aclABI, provider);
const userAllowed = await acl.persistAllowed(handle, userAddress);
const contractAllowed = await acl.persistAllowed(handle, contractAddress);
const isAllowed = userAllowed && contractAllowed;
if (!isAllowed) {
if (!userAllowed) {
throw new Error('User is not authorized to reencrypt this handle!');
}
if (!contractAllowed) {
throw new Error(
'dApp contract is not authorized to reencrypt this handle!',
);
}
if (userAddress === contractAddress) {
throw new Error(
'userAddress should not be equal to contractAddress when requesting reencryption!',
Expand Down

0 comments on commit f40b193

Please sign in to comment.