From 9f3da8f0c586e352ce6ea6e8b5cf5f9121861d80 Mon Sep 17 00:00:00 2001 From: madschristensen99 Date: Wed, 23 Apr 2025 11:56:03 -0400 Subject: [PATCH] Fix decryptAndCombine function to support all types of access control conditions --- rust/lit-actions/ext/js/02_litActionsSDK.js | 39 +++++++++++++++++---- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/rust/lit-actions/ext/js/02_litActionsSDK.js b/rust/lit-actions/ext/js/02_litActionsSDK.js index c169f63..3f0d4a6 100644 --- a/rust/lit-actions/ext/js/02_litActionsSDK.js +++ b/rust/lit-actions/ext/js/02_litActionsSDK.js @@ -257,22 +257,49 @@ function broadcastAndCollect({ name, value }) { /** * Decrypt and combine the provided - * @param {string} accessControlConditions The access control conditions - * @param {string} ciphertext The ciphertext to decrypt - * @param {string} dataToEncryptHash The hash of the data to - @ @param {string} authSig The auth signature - * @param {string} chain The chain + * @param {Object} params + * @param {Array=} params.accessControlConditions The access control conditions (optional) + * @param {Array=} params.evmContractConditions The EVM contract conditions (optional) + * @param {Array=} params.unifiedAccessControlConditions The unified access control conditions (optional) + * @param {string} params.ciphertext The ciphertext to decrypt + * @param {string} params.dataToEncryptHash The hash of the data to encrypt + * @param {Object|null} params.authSig The auth signature + * @param {string} params.chain The chain * @returns {string} The combined data */ function decryptAndCombine({ accessControlConditions, + evmContractConditions, + unifiedAccessControlConditions, ciphertext, dataToEncryptHash, authSig, chain, }) { + // Determine which type of conditions to use + let conditions; + if (accessControlConditions) { + conditions = accessControlConditions; + } else if (evmContractConditions) { + // Convert EVM contract conditions to unified format + conditions = evmContractConditions.map(condition => { + if (condition.operator) { + return condition; // Keep operator as is + } + return { + ...condition, + conditionType: "evmContract" + }; + }); + } else if (unifiedAccessControlConditions) { + conditions = unifiedAccessControlConditions; + } else { + throw new Error("No access control conditions provided"); + } + + // Call the Rust implementation with the appropriate conditions return ops.op_decrypt_and_combine( - accessControlConditions, + conditions, ciphertext, dataToEncryptHash, authSig,