Skip to content

Commit

Permalink
Merge pull request #24 from lighthouse-web3/staging-aakash
Browse files Browse the repository at this point in the history
Coreum Support
  • Loading branch information
ravish1729 authored Jul 12, 2024
2 parents aa57781 + 52891dc commit ec3d0d7
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 21 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion readme.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Kavach <img src="https://img.shields.io/badge/BETA-v0.1.7-green"/>
# Kavach <img src="https://img.shields.io/badge/BETA-v0.1.8-green"/>

Kavach is an encryption SDK that allows you to build your trustless, decentralized and fault-tolerant Applications using distributed key shards with threshold cryptography

Expand Down
75 changes: 58 additions & 17 deletions src/methods/accessControl/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const solidityType = [
const SupportedChains = {
EVM: [],
SOLANA: ["DEVNET", "TESTNET", "MAINNET"],
COREUM: ["Coreum_Devnet", "Coreum_Testnet", "Coreum_Mainnet"],
};

const evmConditions = Joi.array()
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -218,27 +265,21 @@ 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),
then: Joi.string()
.pattern(/( and | or )/i)
.required(),
}),
})
export {
updateConditionSchema,
accessConditionSchema
};
});
export { updateConditionSchema, accessConditionSchema };

0 comments on commit ec3d0d7

Please sign in to comment.