Skip to content

Commit

Permalink
feat: add log if gateway respond failure
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Nov 18, 2024
1 parent a223bd9 commit 90e0828
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/sdk/reencrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export const reencryptRequest =
throw new Error("Gateway didn't response correctly");
}

if (json.status === 'failure') {
throw new Error("The reencryption didn't succeed");
}

const client = new_client(kmsSignatures, userAddress, 'default');

try {
Expand All @@ -88,7 +92,10 @@ export const reencryptRequest =
// Duplicate payloadForRequest and replace ciphertext_handle with ciphertext_digest.
const { ciphertext_handle, ...p } = payloadForRequest;
// TODO check all ciphertext digests are all the same
const payloadForVerification = { ...p, ciphertext_digest: json.response[0].ciphertext_digest };
const payloadForVerification = {
...p,
ciphertext_digest: json.response[0].ciphertext_digest,
};

const decryption = process_reencryption_resp_from_js(
client,
Expand Down

0 comments on commit 90e0828

Please sign in to comment.