From 6a439529a13f20a74826876690f5f187d12c13b9 Mon Sep 17 00:00:00 2001 From: aakash-taneja Date: Fri, 12 Jul 2024 18:57:55 +0530 Subject: [PATCH 1/2] coreum support added --- src/methods/accessControl/validator.ts | 75 ++++++++++++++++++++------ 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/src/methods/accessControl/validator.ts b/src/methods/accessControl/validator.ts index cd94ef1..5e21a0d 100644 --- a/src/methods/accessControl/validator.ts +++ b/src/methods/accessControl/validator.ts @@ -70,6 +70,7 @@ const solidityType = [ const SupportedChains = { EVM: [], SOLANA: ["DEVNET", "TESTNET", "MAINNET"], + COREUM: ["Coreum_Devnet", "Coreum_Testnet", "Coreum_Mainnet"], }; const evmConditions = Joi.array() @@ -173,6 +174,48 @@ const solanaConditions = Joi.array() ) .unique((a, b) => a.id === b.id); +const coreumConditions = Joi.array() + .min(1) + .required() + .items( + Joi.object({ + id: Joi.number().min(1).required(), + contractAddress: Joi.when("standardContractType", { + is: Joi.equal(""), + then: Joi.string(), + otherwise: Joi.string().required(), + }), + denom: Joi.string(), + classid: Joi.string(), + standardContractType: Joi.string().allow(""), + chain: Joi.string() + .valid(...SupportedChains["COREUM"]) + .insensitive() + .required(), + method: Joi.when("standardContractType", { + is: Joi.equal(""), + then: Joi.string().required(), + otherwise: Joi.string().required(), + }), + parameters: Joi.when("standardContractType", { + is: Joi.equal(""), + then: Joi.array(), + otherwise: Joi.array().required(), + }), + returnValueTest: Joi.object({ + comparator: Joi.string() + .valid("==", ">=", "<=", "!=", ">", "<") + .required(), + value: Joi.alternatives( + Joi.number(), + Joi.string(), + Joi.array() + ).required(), + }).required(), + }) + ) + .unique((a, b) => a.id === b.id); + const updateConditionSchema = Joi.object({ chainType: Joi.string() .allow("", null) @@ -183,7 +226,11 @@ const updateConditionSchema = Joi.object({ conditions: Joi.when("chainType", { is: Joi.equal("EVM"), then: evmConditions, - otherwise: solanaConditions, + otherwise: Joi.when("chainType", { + is: Joi.equal("SOLANA"), + then: solanaConditions, + otherwise: coreumConditions, + }), }), decryptionType: Joi.string() .allow("", null) @@ -218,18 +265,15 @@ const accessConditionSchema = Joi.object({ conditions: Joi.when("chainType", { is: Joi.equal("EVM"), then: evmConditions, - otherwise: solanaConditions, + otherwise: Joi.when("chainType", { + is: Joi.equal("SOLANA"), + then: solanaConditions, + otherwise: coreumConditions, + }), }), - address: Joi.string() - .required(), - keyShards: Joi.array() - .min(5) - .max(5) - .required() - .items( - Joi.object()), - cid: Joi.string() - .required(), + address: Joi.string().required(), + keyShards: Joi.array().min(5).max(5).required().items(Joi.object()), + cid: Joi.string().required(), // TO aggregator next iteration: "1 or 2 and (3 xor 4)" aggregator: Joi.when("conditions.length", { is: Joi.number().greater(1), @@ -237,8 +281,5 @@ const accessConditionSchema = Joi.object({ .pattern(/( and | or )/i) .required(), }), -}) -export { - updateConditionSchema, - accessConditionSchema -}; +}); +export { updateConditionSchema, accessConditionSchema }; From 52891dcb486f7c34fd7bb7ac55ee7b1232a5accb Mon Sep 17 00:00:00 2001 From: ravish1729 Date: Fri, 12 Jul 2024 19:50:05 +0530 Subject: [PATCH 2/2] patch update --- package-lock.json | 4 ++-- package.json | 2 +- readme.MD | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 40c8822..3d8f6c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lighthouse-web3/kavach", - "version": "0.1.7", + "version": "0.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@lighthouse-web3/kavach", - "version": "0.1.7", + "version": "0.1.8", "license": "MIT", "dependencies": { "bls-eth-wasm": "^1.1.1", diff --git a/package.json b/package.json index 8942728..f8e7bad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lighthouse-web3/kavach", - "version": "0.1.7", + "version": "0.1.8", "description": "Encryption SDK: Build your trustless, decentralized and fault resistance Application using distributed key shades with threshold cryptography", "author": "xlassix", "main": "./dist/methods/index.js", diff --git a/readme.MD b/readme.MD index 519e515..c77d857 100644 --- a/readme.MD +++ b/readme.MD @@ -1,4 +1,4 @@ -# Kavach +# Kavach Kavach is an encryption SDK that allows you to build your trustless, decentralized and fault-tolerant Applications using distributed key shards with threshold cryptography