From 6014c516d4ef0c80d01703957896840bed578f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=AB=8B=E5=85=9A=20Lidang?= <6800565+lidangzzz@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:35:39 -0600 Subject: [PATCH] . --- .../contracts/protocol/MachineState.sol | 6 + .../protocol/MachineStateManager.sol | 3 + .../Plugin/ConditionExpressionFactory.sol | 10 +- .../protocol/Plugin/Condition_BatchOp.sol | 150 +++++----- .../Plugin/Condition_CreateTokenClass.sol | 28 +- .../Plugin/Condition_MachineState.sol | 88 +++--- .../Plugin/Condition_MembershipOp.sol | 12 +- .../protocol/Plugin/Condition_Operation.sol | 6 +- .../Plugin/Condition_OperationLog.sol | 266 ++++++++++++++++++ .../protocol/Plugin/Condition_Operator.sol | 56 ++-- .../Plugin/Condition_PluginAndVoting.sol | 66 ++--- .../protocol/Plugin/Condition_Program.sol | 16 +- .../Plugin/Condition_TokenAndCash.sol | 23 +- .../Plugin/Condition_Withdrawable.sol | 16 +- .../Plugin/EnumConditionExpression.sol.old | 62 ++-- .../Runtime/Executable/Executable.sol | 68 ++++- darc-specs/condition_expression.md | 41 ++- 17 files changed, 633 insertions(+), 284 deletions(-) create mode 100644 darc-protocol/contracts/protocol/Plugin/Condition_OperationLog.sol diff --git a/darc-protocol/contracts/protocol/MachineState.sol b/darc-protocol/contracts/protocol/MachineState.sol index 606b51c..d730ba3 100644 --- a/darc-protocol/contracts/protocol/MachineState.sol +++ b/darc-protocol/contracts/protocol/MachineState.sol @@ -164,6 +164,12 @@ struct MachineState { */ address[] operationLogMapAddressList; + /** + * The opearation log of all operators in the DARC protocol + * Any operation in the DARC protocol executed by any address will be recorded here + */ + OperationLog globalOperationLog; + /** * The machine state parameters of the DARC protocol */ diff --git a/darc-protocol/contracts/protocol/MachineStateManager.sol b/darc-protocol/contracts/protocol/MachineStateManager.sol index e4cb9ac..8493026 100644 --- a/darc-protocol/contracts/protocol/MachineStateManager.sol +++ b/darc-protocol/contracts/protocol/MachineStateManager.sol @@ -250,6 +250,9 @@ contract MachineStateManager { = currentMachineState.operationLogMap[currentMachineState.operationLogMapAddressList[i]]; } + // 4.4 copy the overall operation log from current machine state to sandbox + sandboxMachineState.globalOperationLog = currentMachineState.globalOperationLog; + // 5. Clone the machine state parameters sandboxMachineState.machineStateParameters = currentMachineState.machineStateParameters; diff --git a/darc-protocol/contracts/protocol/Plugin/ConditionExpressionFactory.sol b/darc-protocol/contracts/protocol/Plugin/ConditionExpressionFactory.sol index 77b077c..0e8547f 100644 --- a/darc-protocol/contracts/protocol/Plugin/ConditionExpressionFactory.sol +++ b/darc-protocol/contracts/protocol/Plugin/ConditionExpressionFactory.sol @@ -15,6 +15,7 @@ import "./Condition_Withdrawable.sol"; import "./Condition_TokenAndCash.sol"; import "./Condition_CreateTokenClass.sol"; import "./Condition_Program.sol"; +import "./Condition_OperationLog.sol"; /** @@ -25,7 +26,7 @@ import "./Condition_Program.sol"; contract ConditionExpressionFactory is Condition_Operator, Condition_MachineState, Condition_Operation, Condition_BatchOp, Condition_PluginAndVoting, Condition_MembershipOp, Condition_Withdrawable, Condition_TokenAndCash, - Condition_CreateTokenClass, Condition_Program + Condition_CreateTokenClass, Condition_Program, Condition_OperationLog { /** @@ -62,12 +63,13 @@ contract ConditionExpressionFactory is if (exp >= 431 && exp <= 460) { return withdrawableExpressionCheck(bIsBeforeOperation, operation, param, exp); } - if (exp >= 461 && exp <= 500) { return tokenAndCashExpressionCheck(bIsBeforeOperation, operation, param, exp);} + if (exp >= 461 && exp <= 500) { return tokenAndCashExpressionCheck(operation, param, exp);} - if (exp>=501 && exp <= 600) { return createTokenClassExpressionCheck(bIsBeforeOperation, operation, param, exp); } + if (exp>=501 && exp <= 600) { return createTokenClassExpressionCheck(operation, param, exp); } - if (exp>=601) { return programExpressionCheck(program, param, exp); } + if (exp>=601 && exp <= 700) { return programExpressionCheck(program, param, exp); } + if (exp >= 701) { return operationLogExpressionCheck(bIsBeforeOperation, operation, param, exp); } // default: return false; diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_BatchOp.sol b/darc-protocol/contracts/protocol/Plugin/Condition_BatchOp.sol index e463571..46a0a33 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_BatchOp.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_BatchOp.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; /** - * @title Condition of Operator + * @title Condition of Batch Operation * @author DARC Team * @notice All the condition expression functions related to Operator */ @@ -94,7 +94,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_211_BATCH_OP_SIZE_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_211_BATCH_OP_SIZE_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_211: The UINT_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_211: The UINT_2DARRAY[0] length is not 1"); @@ -103,7 +103,7 @@ contract Condition_BatchOp is MachineStateManager { return batchSize > param.UINT256_2DARRAY[0][0]; } - function ID_212_BATCH_OP_SIZE_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_212_BATCH_OP_SIZE_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_212: The UINT_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_212: The UINT_2DARRAY[0] length is not 1"); @@ -112,7 +112,7 @@ contract Condition_BatchOp is MachineStateManager { return batchSize < param.UINT256_2DARRAY[0][0]; } - function ID_213_BATCH_OP_SIZE_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_213_BATCH_OP_SIZE_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_213: The UINT_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_213: The UINT_2DARRAY[0] length is not 2"); @@ -121,7 +121,7 @@ contract Condition_BatchOp is MachineStateManager { return batchSize >= param.UINT256_2DARRAY[0][0] && batchSize <= param.UINT256_2DARRAY[0][1]; } - function ID_214_BATCH_OP_SIZE_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_214_BATCH_OP_SIZE_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_214: The UINT_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_214: The UINT_2DARRAY[0] length is not 1"); @@ -130,7 +130,7 @@ contract Condition_BatchOp is MachineStateManager { return batchSize == param.UINT256_2DARRAY[0][0]; } - function ID_215_BATCH_OP_EACH_TARGET_ADDRESSES_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_215_BATCH_OP_EACH_TARGET_ADDRESSES_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_215: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_215: The ADDRESS_2DARRAY[0] length is not 1"); @@ -142,7 +142,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_216_BATCH_OP_EACH_TARGET_ADDRESSES_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_216_BATCH_OP_EACH_TARGET_ADDRESSES_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_216: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length >= 1, "CE ID_216: The ADDRESS_2DARRAY[0] length is not greater than 1"); @@ -161,7 +161,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_217_BATCH_OP_EACH_TARGET_ADDRESSES_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_217_BATCH_OP_EACH_TARGET_ADDRESSES_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_217: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_217: The UINT256_2DARRAY[0] length is not 1"); @@ -190,7 +190,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_218_BATCH_OP_ANY_TARGET_ADDRESS_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_218_BATCH_OP_ANY_TARGET_ADDRESS_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_218: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_218: The ADDRESS_2DARRAY[0] length is not 1"); @@ -202,7 +202,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_219_BATCH_OP_ANY_TARGET_ADDRESS_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_219_BATCH_OP_ANY_TARGET_ADDRESS_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_219: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length >= 1, "CE ID_219: The ADDRESS_2DARRAY[0] length is not greater than 1"); @@ -218,7 +218,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_220_BATCH_OP_ANY_TARGET_ADDRESS_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_220_BATCH_OP_ANY_TARGET_ADDRESS_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_220: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_220: The UINT256_2DARRAY[0] length is not 1"); @@ -245,7 +245,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_221_BATCH_OP_EACH_TARGET_ADDRESS_TO_ITSELF(Operation memory op) internal pure returns (bool) + function ID_221_BATCH_OP_EACH_TARGET_ADDRESS_TO_ITSELF(Operation memory op) private pure returns (bool) { (address[] memory targetAddressList, bool bIsValid) = getAllTargetAddress(op); if (!bIsValid) return false; @@ -256,7 +256,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_222_BATCH_OP_ANY_TARGET_ADDRESS_TO_ITSELF(Operation memory op) internal pure returns (bool) + function ID_222_BATCH_OP_ANY_TARGET_ADDRESS_TO_ITSELF(Operation memory op) private pure returns (bool) { (address[] memory targetAddressList, bool bIsValid) = getAllTargetAddress(op); if (!bIsValid) return false; @@ -267,7 +267,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_223_BATCH_OP_EACH_SOURCE_ADDRESS_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_223_BATCH_OP_EACH_SOURCE_ADDRESS_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_223: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_223: The ADDRESS_2DARRAY[0] length is not 1"); @@ -279,7 +279,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_224_BATCH_OP_EACH_SOURCE_ADDRESS_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_224_BATCH_OP_EACH_SOURCE_ADDRESS_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_224: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length >= 1, "CE ID_224: The ADDRESS_2DARRAY[0] length is not greater than 1"); @@ -298,7 +298,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_225_BATCH_OP_EACH_SOURCE_ADDRESS_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_225_BATCH_OP_EACH_SOURCE_ADDRESS_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_225: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_225: The UINT256_2DARRAY[0] length is not 1"); @@ -327,7 +327,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_226_BATCH_OP_ANY_SOURCE_ADDRESS_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_226_BATCH_OP_ANY_SOURCE_ADDRESS_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_226: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_226: The ADDRESS_2DARRAY[0] length is not 1"); @@ -339,7 +339,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_227_BATCH_OP_ANY_SOURCE_ADDRESS_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_227_BATCH_OP_ANY_SOURCE_ADDRESS_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_227: The ADDRESS_2DARRAY length is not 1"); require(param.ADDRESS_2DARRAY[0].length >= 1, "CE ID_227: The ADDRESS_2DARRAY[0] length is not greater than 1"); @@ -355,7 +355,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_228_BATCH_OP_ANY_SOURCE_ADDRESS_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_228_BATCH_OP_ANY_SOURCE_ADDRESS_IN_MEMBER_ROLE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_228: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_228: The UINT256_2DARRAY[0] length is not 1"); @@ -382,7 +382,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_229_BATCH_OP_EACH_SOURCE_ADDRESS_FROM_ITSELF(Operation memory op) internal pure returns (bool) + function ID_229_BATCH_OP_EACH_SOURCE_ADDRESS_FROM_ITSELF(Operation memory op) private pure returns (bool) { (address[] memory sourceAddressList, bool bIsValid) = getAllSourceAddress(op); if (!bIsValid) return false; @@ -393,7 +393,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_230_BATCH_OP_ANY_SOURCE_ADDRESS_FROM_ITSELF(Operation memory op) internal pure returns (bool) + function ID_230_BATCH_OP_ANY_SOURCE_ADDRESS_FROM_ITSELF(Operation memory op) private pure returns (bool) { (address[] memory sourceAddressList, bool bIsValid) = getAllSourceAddress(op); if (!bIsValid) return false; @@ -404,7 +404,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_231_BATCH_OP_EACH_TOKEN_CLASS_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_231_BATCH_OP_EACH_TOKEN_CLASS_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_231: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_231: The UINT256_2DARRAY[0] length is not 1"); @@ -417,7 +417,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_232_BATCH_OP_EACH_TOKEN_CLASS_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_232_BATCH_OP_EACH_TOKEN_CLASS_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_232: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length >= 1, "CE ID_232: The UINT256_2DARRAY[0] length is not greater than 1"); @@ -436,7 +436,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_233_BATCH_OP_EACH_TOKEN_CLASS_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_233_BATCH_OP_EACH_TOKEN_CLASS_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_233: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_233: The UINT256_2DARRAY[0] length is not 2"); @@ -448,7 +448,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_234_BATCH_OP_EACH_TOKEN_CLASS_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_234_BATCH_OP_EACH_TOKEN_CLASS_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_234: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_234: The UINT256_2DARRAY[0] length is not 1"); @@ -460,7 +460,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_235_BATCH_OP_EACH_TOKEN_CLASS_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_235_BATCH_OP_EACH_TOKEN_CLASS_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_235: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_235: The UINT256_2DARRAY[0] length is not 1"); @@ -472,7 +472,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_236_BATCH_OP_TOTAL_TOKEN_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_236_BATCH_OP_TOTAL_TOKEN_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_236: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_236: The UINT256_2DARRAY[0] length is not 1"); @@ -485,7 +485,7 @@ contract Condition_BatchOp is MachineStateManager { return (totalAmount > param.UINT256_2DARRAY[0][0]); } - function ID_237_BATCH_OP_TOTAL_TOKEN_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_237_BATCH_OP_TOTAL_TOKEN_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_237: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_237: The UINT256_2DARRAY[0] length is not 1"); @@ -498,7 +498,7 @@ contract Condition_BatchOp is MachineStateManager { return (totalAmount < param.UINT256_2DARRAY[0][0]); } - function ID_238_BATCH_OP_TOTAL_TOKEN_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_238_BATCH_OP_TOTAL_TOKEN_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_238: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_238: The UINT256_2DARRAY[0] length is not 2"); @@ -511,7 +511,7 @@ contract Condition_BatchOp is MachineStateManager { return (totalAmount >= param.UINT256_2DARRAY[0][0] && totalAmount <= param.UINT256_2DARRAY[0][1]); } - function ID_239_BATCH_OP_TOTAL_TOKEN_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_239_BATCH_OP_TOTAL_TOKEN_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_239: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_239: The UINT256_2DARRAY[0] length is not 1"); @@ -524,7 +524,7 @@ contract Condition_BatchOp is MachineStateManager { return (totalAmount == param.UINT256_2DARRAY[0][0]); } - function ID_240_BATCH_OP_ANY_TOKEN_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_240_BATCH_OP_ANY_TOKEN_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_240: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_240: The UINT256_2DARRAY[0] length is not 1"); @@ -536,7 +536,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_241_BATCH_OP_ANY_TOKEN_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_241_BATCH_OP_ANY_TOKEN_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_241: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_241: The UINT256_2DARRAY[0] length is not 1"); @@ -548,7 +548,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_242_BATCH_OP_ANY_TOKEN_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_242_BATCH_OP_ANY_TOKEN_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_242: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_242: The UINT256_2DARRAY[0] length is not 2"); @@ -560,7 +560,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_243_BATCH_OP_ANY_TOKEN_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_243_BATCH_OP_ANY_TOKEN_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_243: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_243: The UINT256_2DARRAY[0] length is not 1"); @@ -572,7 +572,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_244_BATCH_OP_ANY_TOKEN_CLASS_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_244_BATCH_OP_ANY_TOKEN_CLASS_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_244: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_244: The UINT256_2DARRAY[0] length is not 1"); @@ -584,7 +584,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_245_BATCH_OP_ANY_TOKEN_CLASS_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_245_BATCH_OP_ANY_TOKEN_CLASS_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_245: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_245: The UINT256_2DARRAY[0] length is not 1"); @@ -596,7 +596,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_246_BATCH_OP_ANY_TOKEN_CLASS_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_246_BATCH_OP_ANY_TOKEN_CLASS_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_246: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_246: The UINT256_2DARRAY[0] length is not 2"); @@ -608,7 +608,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_247_BATCH_OP_ANY_TOKEN_CLASS_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_247_BATCH_OP_ANY_TOKEN_CLASS_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_247: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_247: The UINT256_2DARRAY[0] length is not 1"); @@ -620,7 +620,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_248_BATCH_OP_ANY_TOKEN_CLASS_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_248_BATCH_OP_ANY_TOKEN_CLASS_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_248: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length >= 1, "CE ID_248: The UINT256_2DARRAY[0] length is not greater than 1"); @@ -636,7 +636,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_249_BATCH_OP_EACH_SOURCE_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_249_BATCH_OP_EACH_SOURCE_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_249: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length >= 1, "CE ID_249: The UINT256_2DARRAY[0] length is not greater than 1"); @@ -675,7 +675,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_250_BATCH_OP_ANY_SOURCE_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_250_BATCH_OP_ANY_SOURCE_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_250: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length >= 1, "CE ID_250: The UINT256_2DARRAY[0] length is not greater than 1"); @@ -706,7 +706,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_251_BATCH_OP_EACH_TARGET_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_251_BATCH_OP_EACH_TARGET_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_251: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length >= 1, "CE ID_251: The UINT256_2DARRAY[0] length is not greater than 1"); @@ -745,7 +745,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_252_BATCH_OP_ANY_TARGET_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_252_BATCH_OP_ANY_TARGET_ADDRESS_IN_MEMBER_ROLE_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_252: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length >= 1, "CE ID_252: The UINT256_2DARRAY[0] length is not greater than 1"); @@ -776,7 +776,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_253_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_253_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_253: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_253: The UINT256_2DARRAY[0] length is not 1"); @@ -795,7 +795,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_254_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_254_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_254: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_254: The UINT256_2DARRAY[0] length is not 1"); @@ -814,7 +814,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_255_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_255_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_255: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_255: The UINT256_2DARRAY[0] length is not 2"); @@ -833,7 +833,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_256_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_256_BATCH_OP_EACH_TARGET_ADDRESS_WITHDRAWABLE_CASH_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_256: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_256: The UINT256_2DARRAY[0] length is not 1"); @@ -852,7 +852,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_257_BATCH_OP_ANY_TARGET_ADDRESS_WITHDRAWABLE_CASH_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_257_BATCH_OP_ANY_TARGET_ADDRESS_WITHDRAWABLE_CASH_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_257: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_257: The UINT256_2DARRAY[0] length is not 1"); @@ -871,7 +871,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_258_BATCH_OP_ANY_TARGET_ADDRESS_WITHDRAWABLE_CASH_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_258_BATCH_OP_ANY_TARGET_ADDRESS_WITHDRAWABLE_CASH_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_258: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_258: The UINT256_2DARRAY[0] length is not 1"); @@ -890,7 +890,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_259_BATCH_OP_ANY_TARGET_ADDRESS_WITHDRAWABLE_CASH_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_259_BATCH_OP_ANY_TARGET_ADDRESS_WITHDRAWABLE_CASH_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_259: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_259: The UINT256_2DARRAY[0] length is not 2"); @@ -909,7 +909,7 @@ contract Condition_BatchOp is MachineStateManager { return false; } - function ID_260_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_260_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_260: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_260: The UINT256_2DARRAY[0] length is not 1"); @@ -931,7 +931,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_261_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_261_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_261: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_261: The UINT256_2DARRAY[0] length is not 1"); @@ -953,7 +953,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_262_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_262_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_262: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_262: The UINT256_2DARRAY[0] length is not 2"); @@ -975,7 +975,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_263_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_263_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_263: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_263: The UINT256_2DARRAY[0] length is not 1"); @@ -997,7 +997,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_264_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_264_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_264: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_264: The UINT256_2DARRAY[0] length is not 1"); @@ -1019,7 +1019,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_265_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_265_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_265: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_265: The UINT256_2DARRAY[0] length is not 1"); @@ -1041,7 +1041,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_266_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_266_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_266: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_266: The UINT256_2DARRAY[0] length is not 2"); @@ -1063,7 +1063,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_267_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_267_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_267: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_267: The UINT256_2DARRAY[0] length is not 1"); @@ -1087,7 +1087,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_268_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_268_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_268: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_268: The UINT256_2DARRAY[0] length is not 1"); @@ -1111,7 +1111,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_269_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_269_BATCH_OP_EACH_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_269: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_269: The UINT256_2DARRAY[0] length is not 2"); @@ -1135,7 +1135,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_270_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_270_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_270: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_270: The UINT256_2DARRAY[0] length is not 1"); @@ -1157,7 +1157,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_271_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_271_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY[0].length == 1, "CE ID_271: The UINT256_2DARRAY[0] length is not 1"); require(param.UINT256_2DARRAY.length == 1, "CE ID_271: The UINT256_2DARRAY length is not 1"); @@ -1183,7 +1183,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_272_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_272_BATCH_OP_ANY_TARGET_ADDRESS_TOTAL_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY[0].length == 2, "CE ID_272: The UINT256_2DARRAY[0] length is not 2"); require(param.UINT256_2DARRAY.length == 1, "CE ID_272: The UINT256_2DARRAY length is not 1"); @@ -1209,7 +1209,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_273_BATCH_OP_EACH_TARGET_ADDRESS_OWNS_TOKEN_X_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_273_BATCH_OP_EACH_TARGET_ADDRESS_OWNS_TOKEN_X_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_273: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_273: The UINT256_2DARRAY[0] length is not 1"); @@ -1234,7 +1234,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_274_BATCH_OP_EACH_TARGET_ADDRESS_OWNS_TOKEN_X_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_274_BATCH_OP_EACH_TARGET_ADDRESS_OWNS_TOKEN_X_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_274: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_274: The UINT256_2DARRAY[0] length is not 1"); @@ -1259,7 +1259,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_275_BATCH_OP_EACH_TARGET_ADDRESS_OWNS_TOKEN_X_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_275_BATCH_OP_EACH_TARGET_ADDRESS_OWNS_TOKEN_X_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY[0].length == 3, "CE ID_275: The UINT256_2DARRAY[0] length is not 3"); require(param.UINT256_2DARRAY.length == 1, "CE ID_275: The UINT256_2DARRAY length is not 1"); @@ -1284,7 +1284,7 @@ contract Condition_BatchOp is MachineStateManager { return true; } - function ID_276_BATCH_OP_ANY_TARGET_ADDRESS_OWNS_TOKEN_X_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_276_BATCH_OP_ANY_TARGET_ADDRESS_OWNS_TOKEN_X_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY[0].length == 2, "CE ID_276: The UINT256_2DARRAY[0] length is not 2"); require(param.UINT256_2DARRAY.length == 1, "CE ID_276: The UINT256_2DARRAY length is not 1"); @@ -1312,7 +1312,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_277_BATCH_OP_ANY_TARGET_ADDRESS_OWNS_TOKEN_X_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_277_BATCH_OP_ANY_TARGET_ADDRESS_OWNS_TOKEN_X_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY[0].length == 2, "CE ID_277: The UINT256_2DARRAY[0] length is not 2"); require(param.UINT256_2DARRAY.length == 1, "CE ID_277: The UINT256_2DARRAY length is not 1"); @@ -1340,7 +1340,7 @@ contract Condition_BatchOp is MachineStateManager { } } - function ID_278_BATCH_OP_ANY_TARGET_ADDRESS_OWNS_TOKEN_X_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) + function ID_278_BATCH_OP_ANY_TARGET_ADDRESS_OWNS_TOKEN_X_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY[0].length == 3, "CE ID_278: The UINT256_2DARRAY[0] length is not 3"); require(param.UINT256_2DARRAY.length == 1, "CE ID_278: The UINT256_2DARRAY length is not 1"); @@ -1382,7 +1382,7 @@ contract Condition_BatchOp is MachineStateManager { * @return bool the flag to indicate if the operation is a batch operation * @return uint256 the batch size of the batch operation */ - function getBatchSize(Operation memory op) internal pure returns (bool, uint256) { + function getBatchSize(Operation memory op) private pure returns (bool, uint256) { bool bIsBatchOp = isBatchOp(op); uint256 batchSize = 0; if (!bIsBatchOp) return (false, batchSize); @@ -1417,7 +1417,7 @@ contract Condition_BatchOp is MachineStateManager { * @param op the operation to be checked * @return bool the flag to indicate if the operation is a batch operation */ - function isBatchOp(Operation memory op) internal pure returns (bool) { + function isBatchOp(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_MINT_TOKENS) return true; if (op.opcode == EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return true; if (op.opcode == EnumOpcode.BATCH_TRANSFER_TOKENS) return true; @@ -1448,7 +1448,7 @@ contract Condition_BatchOp is MachineStateManager { * @param op the operation to be checked * @return bool the flag to indicate if the operation is a token operation */ - function isTokenOp(Operation memory op) internal pure returns (bool) { + function isTokenOp(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_MINT_TOKENS) return true; if (op.opcode == EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; // batch create token classes is not a token operation if (op.opcode == EnumOpcode.BATCH_TRANSFER_TOKENS) return true; @@ -1468,7 +1468,7 @@ contract Condition_BatchOp is MachineStateManager { * @return address[] the target address list of the batch operation * @return bool the flag to indicate if the operation is a batch operation */ - function getAllTargetAddress(Operation memory op) pure internal returns (address[] memory, bool ) { + function getAllTargetAddress(Operation memory op) pure private returns (address[] memory, bool ) { if (!isBatchOp(op)) return (new address[](0), false); if (op.opcode == EnumOpcode.BATCH_TRANSFER_TOKENS_FROM_TO) { // ADDRESS_2DARRAY[0] is the source address list, ADDRESS_2DARRAY[1] is the target address list @@ -1486,7 +1486,7 @@ contract Condition_BatchOp is MachineStateManager { * @return address[] the source address list of the batch operation * @return bool the flag to indicate if the operation is a batch operation */ - function getAllSourceAddress(Operation memory op) pure internal returns (address[] memory, bool ) { + function getAllSourceAddress(Operation memory op) pure private returns (address[] memory, bool ) { if (op.opcode == EnumOpcode.BATCH_TRANSFER_TOKENS_FROM_TO) { // ADDRESS_2DARRAY[0] is the source address list, ADDRESS_2DARRAY[1] is the target address list return (op.param.ADDRESS_2DARRAY[0], true); @@ -1501,7 +1501,7 @@ contract Condition_BatchOp is MachineStateManager { * @return uint256[] the token amount list of the batch operation * @return bool the flag to indicate if the operation is a batch operation */ - function getTokenClassAndAmount(Operation memory op) pure internal returns (uint256[] memory, uint256[] memory, bool ) { + function getTokenClassAndAmount(Operation memory op) pure private returns (uint256[] memory, uint256[] memory, bool ) { if (!isTokenOp(op)) return (new uint256[](0), new uint256[](0), false); if (op.opcode == EnumOpcode.BATCH_MINT_TOKENS) { return (op.param.UINT256_2DARRAY[0], op.param.UINT256_2DARRAY[1], true); diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_CreateTokenClass.sol b/darc-protocol/contracts/protocol/Plugin/Condition_CreateTokenClass.sol index 3cce38d..9acd801 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_CreateTokenClass.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_CreateTokenClass.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; /** - * @title Condition of Operator + * @title Condition of Creation of Token Classes * @author DARC Team * @notice All the condition expression functions related to Operator */ @@ -14,12 +14,20 @@ import "../Utilities/OpcodeMap.sol"; import "../Plugin.sol"; contract Condition_CreateTokenClass is MachineStateManager { - function createTokenClassExpressionCheck(bool bIsBeforeOperation, Operation memory op, NodeParam memory param, uint256 id) internal view returns (bool) { + function createTokenClassExpressionCheck(Operation memory op, NodeParam memory param, uint256 id) internal view returns (bool) { + if (id == 501) { return ID_501_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_GREATER_THAN(op, param); } + if (id == 502) { return ID_502_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_LESS_THAN(op, param); } + if (id == 503) { return ID_503_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_IN_RANGE(op, param); } + if (id == 504) { return ID_504_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_EQUALS(op, param); } + if (id == 505) { return ID_505_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_GREATER_THAN(op, param); } + if (id == 506) { return ID_506_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_LESS_THAN(op, param); } + if (id == 507) { return ID_507_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_IN_RANGE(op, param); } + if (id == 508) { return ID_508_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_EQUALS(op, param); } return false; } - function ID_501_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_501_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_GREATER_THAN(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_501: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_501: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -29,7 +37,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_502_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_502_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_LESS_THAN(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_502: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_502: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -39,7 +47,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_503_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_503_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_IN_RANGE(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_503: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_503: The UINT256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -49,7 +57,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_504_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_504_CREATE_TOKEN_CLASSES_ANY_TOKEN_DIVIDEND_WEIGHT_EQUALS(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_504: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_504: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -59,7 +67,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_505_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_505_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_GREATER_THAN(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_505: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_505: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -69,7 +77,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_506_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_506_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_LESS_THAN(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_506: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_506: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -79,7 +87,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_507_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_507_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_IN_RANGE(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_507: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_507: The UINT256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; @@ -89,7 +97,7 @@ contract Condition_CreateTokenClass is MachineStateManager { return false; } - function ID_508_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_508_CREATE_TOKEN_CLASSES_ANY_VOTING_WEIGHT_EQUALS(Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_508: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_508: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CREATE_TOKEN_CLASSES) return false; diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_MachineState.sol b/darc-protocol/contracts/protocol/Plugin/Condition_MachineState.sol index 25dde68..2a163f7 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_MachineState.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_MachineState.sol @@ -72,109 +72,109 @@ contract Condition_MachineState is MachineStateManager { else return false; } - function ID_51_TIMESTAMP_GREATER_THAN(NodeParam memory param) internal view returns (bool) { + function ID_51_TIMESTAMP_GREATER_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_51: UINT256_2DARRAY is empty"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_51: UINT256_2DARRAY[0] is empty"); return block.timestamp > param.UINT256_2DARRAY[0][0]; } - function ID_52_TIMESTAMP_LESS_THAN(NodeParam memory param) internal view returns (bool) { + function ID_52_TIMESTAMP_LESS_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_52: UINT256_2DARRAY is empty"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_52: UINT256_2DARRAY[0] is empty"); return block.timestamp < param.UINT256_2DARRAY[0][0]; } - function ID_53_TIMESTAMP_IN_RANGE(NodeParam memory param) internal view returns (bool) { + function ID_53_TIMESTAMP_IN_RANGE(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_53: UINT256_2DARRAY is empty"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_53: UINT256_2DARRAY[0] must have 2 elements"); return block.timestamp >= param.UINT256_2DARRAY[0][0] && block.timestamp <= param.UINT256_2DARRAY[0][1]; } - function ID_54_DATE_YEAR_GREATER_THAN(NodeParam memory param) internal view returns (bool) { + function ID_54_DATE_YEAR_GREATER_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_54: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_54: UINT256_2DARRAY[0] must have 1 element"); (uint256 year, , , , , ) = getDateTime(block.timestamp); return year > param.UINT256_2DARRAY[0][0]; } - function ID_55_DATE_YEAR_LESS_THAN(NodeParam memory param) internal view returns (bool) { + function ID_55_DATE_YEAR_LESS_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_55: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_55: UINT256_2DARRAY[0] must have 1 element"); (uint256 year, , , , , ) = getDateTime(block.timestamp); return year < param.UINT256_2DARRAY[0][0]; } - function ID_56_DATE_YEAR_IN_RANGE(NodeParam memory param) internal view returns (bool) { + function ID_56_DATE_YEAR_IN_RANGE(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_56: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_56: UINT256_2DARRAY[0] must have 2 elements"); (uint256 year, , , , , ) = getDateTime(block.timestamp); return year >= param.UINT256_2DARRAY[0][0] && year <= param.UINT256_2DARRAY[0][1]; } - function ID_57_DATE_MONTH_GREATER_THAN(NodeParam memory param) internal view returns (bool) { + function ID_57_DATE_MONTH_GREATER_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_57: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_57: UINT256_2DARRAY[0] must have 1 element"); (, uint256 month, , , , ) = getDateTime(block.timestamp); return month > param.UINT256_2DARRAY[0][0]; } - function ID_58_DATE_MONTH_LESS_THAN(NodeParam memory param) internal view returns (bool) { + function ID_58_DATE_MONTH_LESS_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_58: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_58: UINT256_2DARRAY[0] must have 1 element"); (, uint256 month, , , , ) = getDateTime(block.timestamp); return month < param.UINT256_2DARRAY[0][0]; } - function ID_59_DATE_MONTH_IN_RANGE(NodeParam memory param) internal view returns (bool) { + function ID_59_DATE_MONTH_IN_RANGE(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_59: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_59: UINT256_2DARRAY[0] must have 2 elements"); (, uint256 month, , , , ) = getDateTime(block.timestamp); return month >= param.UINT256_2DARRAY[0][0] && month <= param.UINT256_2DARRAY[0][1]; } - function ID_60_DATE_DAY_GREATER_THAN(NodeParam memory param) internal view returns (bool) { + function ID_60_DATE_DAY_GREATER_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_60: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_60: UINT256_2DARRAY[0] must have 1 element"); (, , uint256 day, , , ) = getDateTime(block.timestamp); return day > param.UINT256_2DARRAY[0][0]; } - function ID_61_DATE_DAY_LESS_THAN(NodeParam memory param) internal view returns (bool) { + function ID_61_DATE_DAY_LESS_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_61: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_61: UINT256_2DARRAY[0] must have 1 element"); (, , uint256 day, , , ) = getDateTime(block.timestamp); return day < param.UINT256_2DARRAY[0][0]; } - function ID_62_DATE_DAY_IN_RANGE(NodeParam memory param) internal view returns (bool) { + function ID_62_DATE_DAY_IN_RANGE(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_62: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_62: UINT256_2DARRAY[0] must have 2 elements"); (, , uint256 day, , , ) = getDateTime(block.timestamp); return day >= param.UINT256_2DARRAY[0][0] && day <= param.UINT256_2DARRAY[0][1]; } - function ID_63_DATE_HOUR_GREATER_THAN(NodeParam memory param) internal view returns (bool) { + function ID_63_DATE_HOUR_GREATER_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_63: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_63: UINT256_2DARRAY[0] must have 1 element"); (, , , uint256 hour, , ) = getDateTime(block.timestamp); return hour > param.UINT256_2DARRAY[0][0]; } - function ID_64_DATE_HOUR_LESS_THAN(NodeParam memory param) internal view returns (bool) { + function ID_64_DATE_HOUR_LESS_THAN(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_64: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_64: UINT256_2DARRAY[0] must have 1 element"); (, , , uint256 hour, , ) = getDateTime(block.timestamp); return hour < param.UINT256_2DARRAY[0][0]; } - function ID_65_DATE_HOUR_IN_RANGE(NodeParam memory param) internal view returns (bool) { + function ID_65_DATE_HOUR_IN_RANGE(NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_65: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_65: UINT256_2DARRAY[0] must have 2 elements"); (, , , uint256 hour, , ) = getDateTime(block.timestamp); return hour >= param.UINT256_2DARRAY[0][0] && hour <= param.UINT256_2DARRAY[0][1]; } - function ID_66_ADDRESS_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_66_ADDRESS_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_66: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_66: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_66: UINT256_2DARRAY must have 1 element"); @@ -186,7 +186,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_67_ADDRESS_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_67_ADDRESS_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_67: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_67: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_67: UINT256_2DARRAY must have 1 element"); @@ -198,7 +198,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_68_ADDRESS_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_68_ADDRESS_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_68: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_68: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_68: UINT256_2DARRAY must have 1 element"); @@ -210,7 +210,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_69_ADDRESS_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_69_ADDRESS_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_69: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_69: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_69: UINT256_2DARRAY must have 1 element"); @@ -222,7 +222,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_70_ADDRESS_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_70_ADDRESS_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_70: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_70: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_70: UINT256_2DARRAY must have 1 element"); @@ -234,7 +234,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_71_ADDRESS_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_71_ADDRESS_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_71: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_71: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_71: UINT256_2DARRAY must have 1 element"); @@ -246,7 +246,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_72_ADDRESS_TOKEN_X_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_72_ADDRESS_TOKEN_X_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_72: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_72: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_72: UINT256_2DARRAY must have 1 element"); @@ -260,7 +260,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_73_ADDRESS_TOKEN_X_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_73_ADDRESS_TOKEN_X_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_73: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_73: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_73: UINT256_2DARRAY must have 1 element"); @@ -274,7 +274,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_74_ADDRESS_TOKEN_X_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_74_ADDRESS_TOKEN_X_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_74: ADDRESS_2DARRAY must have 1 element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_74: ADDRESS_2DARRAY[0] must have 1 element"); require(param.UINT256_2DARRAY.length == 1, "CE ID_74: UINT256_2DARRAY must have 1 element"); @@ -288,7 +288,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_75_TOTAL_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_75_TOTAL_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_75: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_75: UINT256_2DARRAY[0] must have 1 element"); if (bIsBeforeOp) { @@ -298,7 +298,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_76_TOTAL_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_76_TOTAL_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_76: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_76: UINT256_2DARRAY[0] must have 1 element"); if (bIsBeforeOp) { @@ -308,7 +308,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_77_TOTAL_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_77_TOTAL_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_77: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_77: UINT256_2DARRAY[0] must have 2 elements"); if (bIsBeforeOp) { @@ -318,7 +318,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_78_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_78_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_78: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_78: UINT256_2DARRAY[0] must have 1 element"); if (bIsBeforeOp) { @@ -328,7 +328,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_79_TOTAL_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_79_TOTAL_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_79: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_79: UINT256_2DARRAY[0] must have 1 element"); if (bIsBeforeOp) { @@ -338,7 +338,7 @@ contract Condition_MachineState is MachineStateManager { } } - function ID_80_TOTAL_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_80_TOTAL_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_80: UINT256_2DARRAY must have 1 element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_80: UINT256_2DARRAY[0] must have 2 elements"); if (bIsBeforeOp) { @@ -349,24 +349,24 @@ contract Condition_MachineState is MachineStateManager { } - function ID_81_TOTAL_CASH_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_81_TOTAL_CASH_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { // todo: need to implement return false; } - function ID_82_TOTAL_CASH_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_82_TOTAL_CASH_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { // todo: need to implement } - function ID_83_TOTAL_CASH_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_83_TOTAL_CASH_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { // todo: need to implement } - function ID_84_TOTAL_CASH_EQUALS(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_84_TOTAL_CASH_EQUALS(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { // todo: need to implement } - function ID_85_TOKEN_IN_LIST_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_85_TOKEN_IN_LIST_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_85: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_85: ADDRESS_2DARRAY[0] must have 1 element"); @@ -383,7 +383,7 @@ contract Condition_MachineState is MachineStateManager { return totalVotingWeight > param.UINT256_2DARRAY[1][0]; } - function ID_86_TOKEN_IN_LIST_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_86_TOKEN_IN_LIST_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_86: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_86: ADDRESS_2DARRAY[0] must have 1 element"); @@ -400,7 +400,7 @@ contract Condition_MachineState is MachineStateManager { return totalVotingWeight < param.UINT256_2DARRAY[1][0]; } - function ID_87_TOKEN_IN_LIST_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_87_TOKEN_IN_LIST_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_87: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 2, "CE ID_87: ADDRESS_2DARRAY[0] must have 2 elements"); @@ -417,7 +417,7 @@ contract Condition_MachineState is MachineStateManager { return totalVotingWeight >= param.UINT256_2DARRAY[1][0] && totalVotingWeight <= param.UINT256_2DARRAY[1][1]; } - function ID_88_TOKEN_IN_LIST_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_88_TOKEN_IN_LIST_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_88: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_88: ADDRESS_2DARRAY[0] must have 1 element"); @@ -434,7 +434,7 @@ contract Condition_MachineState is MachineStateManager { return totalDividendWeight > param.UINT256_2DARRAY[1][0]; } - function ID_89_TOKEN_IN_LIST_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_89_TOKEN_IN_LIST_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_89: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_89: ADDRESS_2DARRAY[0] must have 1 element"); @@ -451,7 +451,7 @@ contract Condition_MachineState is MachineStateManager { return totalDividendWeight < param.UINT256_2DARRAY[1][0]; } - function ID_90_TOKEN_IN_LIST_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_90_TOKEN_IN_LIST_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_90: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 2, "CE ID_90: ADDRESS_2DARRAY[0] must have 2 elements"); @@ -468,7 +468,7 @@ contract Condition_MachineState is MachineStateManager { return totalDividendWeight >= param.UINT256_2DARRAY[1][0] && totalDividendWeight <= param.UINT256_2DARRAY[1][1]; } - function ID_91_TOKEN_IN_LIST_AMOUNT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_91_TOKEN_IN_LIST_AMOUNT_GREATER_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_91: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_91: ADDRESS_2DARRAY[0] must have 1 element"); @@ -485,7 +485,7 @@ contract Condition_MachineState is MachineStateManager { return totalAmount > param.UINT256_2DARRAY[1][0]; } - function ID_92_TOKEN_IN_LIST_AMOUNT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_92_TOKEN_IN_LIST_AMOUNT_LESS_THAN(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_92: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_92: ADDRESS_2DARRAY[0] must have 1 element"); @@ -502,7 +502,7 @@ contract Condition_MachineState is MachineStateManager { return totalAmount < param.UINT256_2DARRAY[1][0]; } - function ID_93_TOKEN_IN_LIST_AMOUNT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_93_TOKEN_IN_LIST_AMOUNT_IN_RANGE(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_93: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 2, "CE ID_93: ADDRESS_2DARRAY[0] must have 2 elements"); @@ -519,7 +519,7 @@ contract Condition_MachineState is MachineStateManager { return totalAmount >= param.UINT256_2DARRAY[1][0] && totalAmount <= param.UINT256_2DARRAY[1][1]; } - function ID_94_TOKEN_IN_LIST_AMOUNT_EQUALS(bool bIsBeforeOp, NodeParam memory param) internal view returns (bool) { + function ID_94_TOKEN_IN_LIST_AMOUNT_EQUALS(bool bIsBeforeOp, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 2, "CE ID_94: ADDRESS_2DARRAY must have 2 element"); require(param.UINT256_2DARRAY[1].length == 1, "CE ID_94: ADDRESS_2DARRAY[0] must have 1 element"); diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_MembershipOp.sol b/darc-protocol/contracts/protocol/Plugin/Condition_MembershipOp.sol index 92a0596..6923ba2 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_MembershipOp.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_MembershipOp.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; /** - * @title Condition of Operator + * @title Condition of Membership-related Operations * @author DARC Team * @notice All the condition expression functions related to Operator */ @@ -30,7 +30,7 @@ contract Condition_MembershipOp is MachineStateManager { return false; } - function ID_401_CHANGE_MEMBER_ROLE_TO_ANY_ROLE_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_401_CHANGE_MEMBER_ROLE_TO_ANY_ROLE_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_401: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_401: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_CHANGE_MEMBER_ROLES) return false; @@ -40,7 +40,7 @@ contract Condition_MembershipOp is MachineStateManager { return false; } - function ID_402_CHANGE_MEMBER_ROLE_TO_ANY_ROLE_IN_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_402_CHANGE_MEMBER_ROLE_TO_ANY_ROLE_IN_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_402: The ADDRESS_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_CHANGE_MEMBER_ROLES) return false; for (uint256 i = 0; i < op.param.UINT256_2DARRAY[0].length; i++) { @@ -51,7 +51,7 @@ contract Condition_MembershipOp is MachineStateManager { return false; } - function ID_403_CHANGE_MEMBER_ROLE_TO_ANY_ROLE_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_403_CHANGE_MEMBER_ROLE_TO_ANY_ROLE_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_403: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_403: The UINT256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_CHANGE_MEMBER_ROLES) return false; @@ -61,7 +61,7 @@ contract Condition_MembershipOp is MachineStateManager { return false; } - function ID_406_CHANGE_MEMBER_NAME_TO_ANY_STRING_IN_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_406_CHANGE_MEMBER_NAME_TO_ANY_STRING_IN_LIST(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.STRING_ARRAY.length == 1, "CE ID_406: The STRING_ARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_CHANGE_MEMBER_NAMES) return false; for (uint256 i = 0; i < op.param.STRING_ARRAY.length; i++) { @@ -70,7 +70,7 @@ contract Condition_MembershipOp is MachineStateManager { return false; } - function ID_407_CHANGE_MEMBER_NAME_TO_ANY_STRING_CONTAINS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_407_CHANGE_MEMBER_NAME_TO_ANY_STRING_CONTAINS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { require(param.STRING_ARRAY.length == 1, "CE ID_407: The STRING_ARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_CHANGE_MEMBER_NAMES) return false; for (uint256 i = 0; i < op.param.STRING_ARRAY.length; i++) { diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_Operation.sol b/darc-protocol/contracts/protocol/Plugin/Condition_Operation.sol index df9d051..dbbd736 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_Operation.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_Operation.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; /** - * @title Condition of Machine State + * @title Condition of Operation * @author DARC Team * @notice All the condition expression functions related to Machine State */ @@ -23,7 +23,7 @@ contract Condition_Operation is MachineStateManager{ return false; } - function ID_151_OPERATION_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_151_OPERATION_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_151: The UINT_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_151: The UINT_2DARRAY[0] length is not 1"); @@ -31,7 +31,7 @@ contract Condition_Operation is MachineStateManager{ return false; } - function ID_152_OPERATION_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_152_OPERATION_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_152: The UINT_2DARRAY length is not 1"); for (uint256 i = 0; i < param.UINT256_2DARRAY[0].length; i++) { diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_OperationLog.sol b/darc-protocol/contracts/protocol/Plugin/Condition_OperationLog.sol new file mode 100644 index 0000000..eed23d0 --- /dev/null +++ b/darc-protocol/contracts/protocol/Plugin/Condition_OperationLog.sol @@ -0,0 +1,266 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.19; +/** + * @title Condition of Operation Log + * @author DARC Team + * @notice All the condition expression functions related to Operator + */ + + +import "../MachineState.sol"; +import "../MachineStateManager.sol"; +import "../Utilities/StringUtils.sol"; +import "../Utilities/OpcodeMap.sol"; +import "../Plugin.sol"; +import "../Utilities/OpcodeMap.sol"; + +contract Condition_OperationLog is MachineStateManager { + function operationLogExpressionCheck(bool bIsBeforeOperation, Operation memory op, NodeParam memory param, uint256 id) internal view returns (bool) { + if (id == 701) { return ID_701_OPERATION_BY_OPERATOR_SINCE_LAST_TIME_GREATER_THAN(bIsBeforeOperation, op, param); } + if (id == 702) { return ID_702_OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LESS_THAN(bIsBeforeOperation, op, param); } + if (id == 703) { return ID_703_OPERATION_BY_OPERATOR_SINCE_LAST_TIME_IN_RANGE(bIsBeforeOperation, op, param); } + if (id == 704) { return ID_704_OPERATION_GLOBAL_SINCE_LAST_TIME_GREATER_THAN(bIsBeforeOperation, op, param); } + if (id == 705) { return ID_705_OPERATION_GLOBAL_SINCE_LAST_TIME_LESS_THAN(bIsBeforeOperation, op, param); } + if (id == 706) { return ID_706_OPERATION_GLOBAL_SINCE_LAST_TIME_IN_RANGE(bIsBeforeOperation, op, param); } + if (id == 707) { return ID_707_OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_GREATER_THAN(bIsBeforeOperation, op, param); } + if (id == 708) { return ID_708_OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_LESS_THAN(bIsBeforeOperation, op, param); } + if (id == 709) { return ID_709_OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_IN_RANGE(bIsBeforeOperation, op, param); } + if (id == 710) { return ID_710_OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_GREATER_THAN(bIsBeforeOperation, op, param); } + if (id == 711) { return ID_711_OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_LESS_THAN(bIsBeforeOperation, op, param); } + if (id == 712) { return ID_712_OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_IN_RANGE(bIsBeforeOperation, op, param); } + return false; + } + + function ID_701_OPERATION_BY_OPERATOR_SINCE_LAST_TIME_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.UINT256_2DARRAY.length == 1, "CE ID_701: The UINT256_2DARRAY length is not 1"); + require(param.UINT256_2DARRAY[0].length == 1, "CE ID_701: The UINT256_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[op.operatorAddress].latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime > param.UINT256_2DARRAY[0][0]; + } + else { + // in after operation plugin condition check, check the sandbox machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[op.operatorAddress].latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime > param.UINT256_2DARRAY[0][0]; + } + } + + function ID_702_OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.UINT256_2DARRAY.length == 1, "CE ID_702: The UINT256_2DARRAY length is not 1"); + require(param.UINT256_2DARRAY[0].length == 1, "CE ID_702: The UINT256_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[op.operatorAddress].latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime < param.UINT256_2DARRAY[0][0]; + } + else { + // in after operation plugin condition check, check the sandbox machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[op.operatorAddress].latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime < param.UINT256_2DARRAY[0][0]; + } + } + + function ID_703_OPERATION_BY_OPERATOR_SINCE_LAST_TIME_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.UINT256_2DARRAY.length == 1, "CE ID_703: The UINT256_2DARRAY length is not 1"); + require(param.UINT256_2DARRAY[0].length == 2, "CE ID_703: The UINT256_2DARRAY[0] length is not 2"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[op.operatorAddress].latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime >= param.UINT256_2DARRAY[0][0] && elapsedTime <= param.UINT256_2DARRAY[0][1]; + } + else { + // in after operation plugin condition check, check the sandbox machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[op.operatorAddress].latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime >= param.UINT256_2DARRAY[0][0] && elapsedTime <= param.UINT256_2DARRAY[0][1]; + } + } + + function ID_704_OPERATION_GLOBAL_SINCE_LAST_TIME_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.UINT256_2DARRAY.length == 1, "CE ID_704: The UINT256_2DARRAY length is not 1"); + require(param.UINT256_2DARRAY[0].length == 1, "CE ID_704: The UINT256_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.globalOperationLog.latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime > param.UINT256_2DARRAY[0][0]; + } + else { + // in after operation plugin condition check, check the sandbox machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.globalOperationLog.latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime > param.UINT256_2DARRAY[0][0]; + } + } + + function ID_705_OPERATION_GLOBAL_SINCE_LAST_TIME_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.UINT256_2DARRAY.length == 1, "CE ID_705: The UINT256_2DARRAY length is not 1"); + require(param.UINT256_2DARRAY[0].length == 1, "CE ID_705: The UINT256_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.globalOperationLog.latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime < param.UINT256_2DARRAY[0][0]; + } + else { + // in after operation plugin condition check, check the sandbox machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.globalOperationLog.latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime < param.UINT256_2DARRAY[0][0]; + } + } + + function ID_706_OPERATION_GLOBAL_SINCE_LAST_TIME_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.UINT256_2DARRAY.length == 1, "CE ID_706: The UINT256_2DARRAY length is not 1"); + require(param.UINT256_2DARRAY[0].length == 2, "CE ID_706: The UINT256_2DARRAY[0] length is not 2"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.globalOperationLog.latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime >= param.UINT256_2DARRAY[0][0] && elapsedTime <= param.UINT256_2DARRAY[0][1]; + } + else { + // in after operation plugin condition check, check the sandbox machine state + uint256 elapsedTime = block.timestamp - sandboxMachineState.globalOperationLog.latestOperationTimestamp[getOpcodeID(op)]; + + return elapsedTime >= param.UINT256_2DARRAY[0][0] && elapsedTime <= param.UINT256_2DARRAY[0][1]; + } + } + + function ID_707_OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.ADDRESS_2DARRAY.length == 1, "CE ID_707: The ADDRESS_2DARRAY length is not 1"); + require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_707: The ADDRESS_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime > param.UINT256_2DARRAY[0][0]) { return true; } + } + return false; + } + else { + // in after operation plugin condition check, check the sandbox machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime > param.UINT256_2DARRAY[0][0]) { return true; } + } + return false; + } + } + + function ID_708_OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.ADDRESS_2DARRAY.length == 1, "CE ID_708: The ADDRESS_2DARRAY length is not 1"); + require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_708: The ADDRESS_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime < param.UINT256_2DARRAY[0][0]) { return true; } + } + return false; + } + else { + // in after operation plugin condition check, check the sandbox machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime < param.UINT256_2DARRAY[0][0]) { return true; } + } + return false; + } + } + + function ID_709_OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.ADDRESS_2DARRAY.length == 1, "CE ID_709: The ADDRESS_2DARRAY length is not 1"); + require(param.ADDRESS_2DARRAY[0].length == 2, "CE ID_709: The ADDRESS_2DARRAY[0] length is not 2"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime >= param.UINT256_2DARRAY[0][0] && elapsedTime <= param.UINT256_2DARRAY[0][1]) { return true; } + } + return false; + } + else { + // in after operation plugin condition check, check the sandbox machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime >= param.UINT256_2DARRAY[0][0] && elapsedTime <= param.UINT256_2DARRAY[0][1]) { return true; } + } + return false; + } + } + + function ID_710_OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.ADDRESS_2DARRAY.length == 1, "CE ID_710: The ADDRESS_2DARRAY length is not 1"); + require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_710: The ADDRESS_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime < param.UINT256_2DARRAY[0][0]) { return false; } + } + return true; + } + else { + // in after operation plugin condition check, check the sandbox machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime < param.UINT256_2DARRAY[0][0]) { return false; } + } + return true; + } + } + + function ID_711_OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.ADDRESS_2DARRAY.length == 1, "CE ID_711: The ADDRESS_2DARRAY length is not 1"); + require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_711: The ADDRESS_2DARRAY[0] length is not 1"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime > param.UINT256_2DARRAY[0][0]) { return false; } + } + return true; + } + else { + // in after operation plugin condition check, check the sandbox machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime > param.UINT256_2DARRAY[0][0]) { return false; } + } + return true; + } + } + + function ID_712_OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) private view returns (bool) { + require(param.ADDRESS_2DARRAY.length == 1, "CE ID_712: The ADDRESS_2DARRAY length is not 1"); + require(param.ADDRESS_2DARRAY[0].length == 2, "CE ID_712: The ADDRESS_2DARRAY[0] length is not 2"); + if (bIsBeforeOperation) { + // in before operation plugin condition check, just check current machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime < param.UINT256_2DARRAY[0][0] || elapsedTime > param.UINT256_2DARRAY[0][1]) { return false; } + } + return true; + } + else { + // in after operation plugin condition check, check the sandbox machine state + for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { + uint256 elapsedTime = block.timestamp - sandboxMachineState.operationLogMap[param.ADDRESS_2DARRAY[0][i]].latestOperationTimestamp[getOpcodeID(op)]; + if (elapsedTime < param.UINT256_2DARRAY[0][0] || elapsedTime > param.UINT256_2DARRAY[0][1]) { return false; } + } + return true; + } + } + + // ------------------ below are helper functions ------------------ + function getOpcodeID(Operation memory op) private pure returns (uint256) { + return OpcodeMap.opcodeVal(op.opcode); + } +} diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_Operator.sol b/darc-protocol/contracts/protocol/Plugin/Condition_Operator.sol index d522ab2..bd7e8e7 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_Operator.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_Operator.sol @@ -55,40 +55,40 @@ contract Condition_Operator is MachineStateManager { } } - function ID_1_OPERATOR_NAME_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_1_OPERATOR_NAME_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.STRING_ARRAY.length == 1, "CE ID_1: STRING_ARRAY must have one element"); if (bIsBeforeOperation) { return StringUtils.compareStrings(currentMachineState.memberInfoMap[operation.operatorAddress].name, param.STRING_ARRAY[0]); } else { return StringUtils.compareStrings(sandboxMachineState.memberInfoMap[operation.operatorAddress].name, param.STRING_ARRAY[0]); } } - function ID_2_OPERATOR_ROLE_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_2_OPERATOR_ROLE_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_2: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_2: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { return currentMachineState.memberInfoMap[operation.operatorAddress].role == param.UINT256_2DARRAY[0][0]; } else { return sandboxMachineState.memberInfoMap[operation.operatorAddress].role == param.UINT256_2DARRAY[0][0]; } } - function ID_3_OPERATOR_ADDRESS_EQUALS(Operation memory operation, NodeParam memory param) internal pure returns (bool) { + function ID_3_OPERATOR_ADDRESS_EQUALS(Operation memory operation, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_3: ADDRESS_2DARRAY must have one element"); require(param.ADDRESS_2DARRAY[0].length == 1, "CE ID_3: ADDRESS_2DARRAY[0] must have one element"); return operation.operatorAddress == param.ADDRESS_2DARRAY[0][0]; } - function ID_4_OPERATOR_ROLE_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_4_OPERATOR_ROLE_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_4: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_4: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { return currentMachineState.memberInfoMap[operation.operatorAddress].role > param.UINT256_2DARRAY[0][0]; } else { return sandboxMachineState.memberInfoMap[operation.operatorAddress].role > param.UINT256_2DARRAY[0][0]; } } - function ID_5_OPERATOR_ROLE_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_5_OPERATOR_ROLE_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_5: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_5: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { return currentMachineState.memberInfoMap[operation.operatorAddress].role < param.UINT256_2DARRAY[0][0]; } else { return sandboxMachineState.memberInfoMap[operation.operatorAddress].role < param.UINT256_2DARRAY[0][0]; } } - function ID_6_OPERATOR_ROLE_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_6_OPERATOR_ROLE_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_6: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_6: UINT256_2DARRAY[0] must have two elements"); require(param.UINT256_2DARRAY[0][0] <= param.UINT256_2DARRAY[0][1], "CE ID_6: UINT256_2DARRAY[0][0] must be less than or equal to UINT256_2DARRAY[0][1]"); @@ -96,7 +96,7 @@ contract Condition_Operator is MachineStateManager { } else { return sandboxMachineState.memberInfoMap[operation.operatorAddress].role >= param.UINT256_2DARRAY[0][0] && sandboxMachineState.memberInfoMap[operation.operatorAddress].role <= param.UINT256_2DARRAY[0][1]; } } - function ID_7_OPEERATOR_ROLE_IN_LIST(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_7_OPEERATOR_ROLE_IN_LIST(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_7: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length > 0, "CE ID_7: UINT256_2DARRAY[0] must have at least one element"); if (bIsBeforeOperation) { @@ -112,7 +112,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_8_OPERATOR_TOKEN_X_AMOUNT_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_8_OPERATOR_TOKEN_X_AMOUNT_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_8: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_8: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation){ @@ -128,7 +128,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_9_OPERATOR_TOKEN_X_AMOUNT_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_9_OPERATOR_TOKEN_X_AMOUNT_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_9: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_9: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -143,7 +143,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_10_OPERATOR_TOKEN_X_AMOUNT_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_10_OPERATOR_TOKEN_X_AMOUNT_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_10: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 3, "CE ID_10: UINT256_2DARRAY[0] must have three elements"); if (bIsBeforeOperation) { @@ -158,7 +158,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_11_OPERATOR_TOKEN_X_AMOUNT_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_11_OPERATOR_TOKEN_X_AMOUNT_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_11: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_11: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation){ @@ -174,7 +174,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_12_OPERATOR_TOKEN_X_PERCENTAGE_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_12_OPERATOR_TOKEN_X_PERCENTAGE_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_12: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_12: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation){ @@ -190,7 +190,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_13_OPERATOR_TOKEN_X_PERCENTAGE_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_13_OPERATOR_TOKEN_X_PERCENTAGE_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_13: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_13: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -200,7 +200,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_14_OPERATOR_TOKEN_X_PERCENTAGE_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_14_OPERATOR_TOKEN_X_PERCENTAGE_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_14: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_14: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -210,7 +210,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_15_OPERATOR_TOKEN_X_PERCENTAGE_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_15_OPERATOR_TOKEN_X_PERCENTAGE_EQUALS(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_15: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_15: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -220,7 +220,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_16_OPERATOR_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_16_OPERATOR_VOTING_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_16: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_16: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { @@ -230,7 +230,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_17_OPERATOR_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_17_OPERATOR_VOTING_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_17: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_17: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { @@ -240,7 +240,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_18_OPERATOR_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_18_OPERATOR_VOTING_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_18: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_18: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -250,7 +250,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_19_OPERATOR_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_19_OPERATOR_DIVIDEND_WEIGHT_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_19: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_19: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { @@ -260,7 +260,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_20_OPERATOR_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_20_OPERATOR_DIVIDEND_WEIGHT_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_20: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_20: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { @@ -270,7 +270,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_21_OPERATOR_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_21_OPERATOR_DIVIDEND_WEIGHT_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_21: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_21: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -280,7 +280,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_25_OPERATOR_WITHDRAWABLE_CASH_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_25_OPERATOR_WITHDRAWABLE_CASH_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_25: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_25: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { @@ -290,7 +290,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_26_OPERATOR_WITHDRAWABLE_CASH_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_26_OPERATOR_WITHDRAWABLE_CASH_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_26: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_26: UINT256_2DARRAY[0] must have one element"); if (bIsBeforeOperation) { @@ -300,7 +300,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_27_OPERATOR_WITHDRAWABLE_CASH_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_27_OPERATOR_WITHDRAWABLE_CASH_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_27: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_27: UINT256_2DARRAY[0] must have two elements"); if (bIsBeforeOperation) { @@ -310,7 +310,7 @@ contract Condition_Operator is MachineStateManager { } } - function ID_28_OPERATOR_WITHDRAWABLE_DIVIDENDS_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_28_OPERATOR_WITHDRAWABLE_DIVIDENDS_GREATER_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_28: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_28: UINT256_2DARRAY[0] must have one element"); uint256 withdrawableDividends = 0; @@ -322,7 +322,7 @@ contract Condition_Operator is MachineStateManager { return withdrawableDividends > param.UINT256_2DARRAY[0][0]; } - function ID_29_OPERATOR_WITHDRAWABLE_DIVIDENDS_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_29_OPERATOR_WITHDRAWABLE_DIVIDENDS_LESS_THAN(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_29: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_29: UINT256_2DARRAY[0] must have one element"); uint256 withdrawableDividends = 0; @@ -334,7 +334,7 @@ contract Condition_Operator is MachineStateManager { return withdrawableDividends < param.UINT256_2DARRAY[0][0]; } - function ID_30_OPERATOR_WITHDRAWABLE_DIVIDENDS_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal view returns (bool) { + function ID_30_OPERATOR_WITHDRAWABLE_DIVIDENDS_IN_RANGE(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private view returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_30: UINT256_2DARRAY must have one element"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_30: UINT256_2DARRAY[0] must have two elements"); uint256 withdrawableDividends = 0; @@ -346,7 +346,7 @@ contract Condition_Operator is MachineStateManager { return withdrawableDividends >= param.UINT256_2DARRAY[0][0] && withdrawableDividends <= param.UINT256_2DARRAY[0][1]; } - function ID_31_OPERATOR_ADDRESS_IN_LIST(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) internal pure returns (bool) { + function ID_31_OPERATOR_ADDRESS_IN_LIST(bool bIsBeforeOperation, Operation memory operation, NodeParam memory param) private pure returns (bool) { require(param.ADDRESS_2DARRAY.length == 1, "CE ID_31: ADDRESS_2DARRAY must have one element"); if (bIsBeforeOperation) { for (uint256 i = 0; i < param.ADDRESS_2DARRAY[0].length; i++) { diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_PluginAndVoting.sol b/darc-protocol/contracts/protocol/Plugin/Condition_PluginAndVoting.sol index 3e97e1a..905ff39 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_PluginAndVoting.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_PluginAndVoting.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.19; /** - * @title Condition of Operator + * @title Condition of Plugin-And-Voting-Rule-Related Operations * @author DARC Team * @notice All the condition expression functions related to Operator */ @@ -63,7 +63,7 @@ contract Condition_PluginAndVoting is MachineStateManager { // ---------------------- Plugin Condition ---------------------- - function ID_301_ENABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_301_ENABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_301: The UINT_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_ENABLE_PLUGINS) return false; @@ -78,7 +78,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_302_ENABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_302_ENABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_302: The UINT_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_ENABLE_PLUGINS) return false; @@ -93,7 +93,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_303_ENABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_303_ENABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_303: The UINT_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_ENABLE_PLUGINS) return false; @@ -110,7 +110,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_304_ENABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_304_ENABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_304: The UINT_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_ENABLE_PLUGINS) return false; @@ -127,7 +127,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_305_DISABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_305_DISABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_305: The UINT_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_DISABLE_PLUGINS) return false; @@ -142,7 +142,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_306_DISABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_306_DISABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_306: The UINT_256_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_DISABLE_PLUGINS) return false; @@ -157,7 +157,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_307_DISABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_307_DISABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_307: The UINT_256_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_DISABLE_PLUGINS) return false; @@ -174,7 +174,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_308_DISABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_308_DISABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_308: The UINT_256_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_DISABLE_PLUGINS) return false; @@ -191,7 +191,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_309_ENABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_309_ENABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_309: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_309: The UINT_256_2DARRAY[0] length is not 2"); @@ -205,7 +205,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_310_ENABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_310_ENABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_310: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_310: The UINT_256_2DARRAY[0] length is not 2"); @@ -219,7 +219,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_311_ENABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_311_ENABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_311: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_311: The UINT_256_2DARRAY[0] length is not 2"); @@ -234,7 +234,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_312_ENABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_312_ENABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_312: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_312: The UINT_256_2DARRAY[0] length is not 2"); @@ -249,7 +249,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_313_DISABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_313_DISABLE_ANY_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_313: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_313: The UINT_256_2DARRAY[0] length is not 2"); @@ -263,7 +263,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_314_DISABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_314_DISABLE_ANY_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_314: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_314: The UINT_256_2DARRAY[0] length is not 2"); @@ -277,7 +277,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_315_DISABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_315_DISABLE_EACH_BEFORE_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_315: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_315: The UINT_256_2DARRAY[0] length is not 2"); @@ -292,7 +292,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_316_DISABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) + function ID_316_DISABLE_EACH_AFTER_OP_PLUGIN_INDEX_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_316: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_316: The UINT_256_2DARRAY[0] length is not 2"); @@ -307,7 +307,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return true; } - function ID_317_ARE_ALL_PLUGINS_BEFORE_OPERATION(Operation memory op) internal pure returns (bool) + function ID_317_ARE_ALL_PLUGINS_BEFORE_OPERATION(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_ENABLE_PLUGINS || op.opcode == EnumOpcode.BATCH_DISABLE_PLUGINS) { for (uint256 i = 0; i < op.param.BOOL_ARRAY.length; i++) { @@ -324,7 +324,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_318_ARE_ALL_PLUGINS_AFTER_OPERATION(Operation memory op) internal pure returns (bool) + function ID_318_ARE_ALL_PLUGINS_AFTER_OPERATION(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_ENABLE_PLUGINS || op.opcode == EnumOpcode.BATCH_DISABLE_PLUGINS) { for (uint256 i = 0; i < op.param.BOOL_ARRAY.length; i++) { @@ -341,7 +341,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_319_IS_ANY_PLUGIN_BEFORE_OPERATION(Operation memory op) internal pure returns (bool) + function ID_319_IS_ANY_PLUGIN_BEFORE_OPERATION(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_ENABLE_PLUGINS || op.opcode == EnumOpcode.BATCH_DISABLE_PLUGINS) { for (uint256 i = 0; i < op.param.BOOL_ARRAY.length; i++) { @@ -358,7 +358,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_320_IS_ANY_PLUGIN_AFTER_OPERATION(Operation memory op) internal pure returns (bool) + function ID_320_IS_ANY_PLUGIN_AFTER_OPERATION(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_ENABLE_PLUGINS || op.opcode == EnumOpcode.BATCH_DISABLE_PLUGINS) { for (uint256 i = 0; i < op.param.BOOL_ARRAY.length; i++) { @@ -375,7 +375,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_321_ADD_PLUGIN_ANY_LEVEL_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_321_ADD_PLUGIN_ANY_LEVEL_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_321: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_321: The UINT_256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; @@ -385,7 +385,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_322_ADD_PLUGIN_ANY_LEVEL_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_322_ADD_PLUGIN_ANY_LEVEL_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_322: The UINT_256_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; for (uint256 index = 0; index < op.param.PLUGIN_ARRAY.length; index++) { @@ -396,7 +396,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_323_ADD_PLUGIN_ANY_LEVEL_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_323_ADD_PLUGIN_ANY_LEVEL_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_323: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_323: The UINT_256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; @@ -406,7 +406,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_324_ADD_PLUGIN_ANY_LEVEL_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_324_ADD_PLUGIN_ANY_LEVEL_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_324: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_324: The UINT_256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; @@ -416,7 +416,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_325_ADD_PLUGIN_ANY_LEVEL_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_325_ADD_PLUGIN_ANY_LEVEL_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_325: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_325: The UINT_256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; @@ -426,7 +426,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_326_ADD_PLUGIN_ANY_RETURN_TYPE_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_326_ADD_PLUGIN_ANY_RETURN_TYPE_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_326: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_326: The UINT_256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; @@ -441,7 +441,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_327_ADD_PLUGIN_ANY_VOTING_RULE_INDEX_IN_LIST(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_327_ADD_PLUGIN_ANY_VOTING_RULE_INDEX_IN_LIST(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_327: The UINT_256_2DARRAY length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_AND_ENABLE_PLUGINS && op.opcode != EnumOpcode.BATCH_ADD_PLUGINS) return false; for (uint256 index = 0; index < op.param.PLUGIN_ARRAY.length; index++) { @@ -455,7 +455,7 @@ contract Condition_PluginAndVoting is MachineStateManager { // ------------------------ Voting Conditions ------------------------ - function ID_371_ADD_ANY_VOTING_RULE_IS_ABSOLUTE_MAJORITY(Operation memory op) internal pure returns (bool) { + function ID_371_ADD_ANY_VOTING_RULE_IS_ABSOLUTE_MAJORITY(Operation memory op) private pure returns (bool) { if (op.opcode != EnumOpcode.BATCH_ADD_VOTING_RULES) return false; for (uint256 index = 0; index < op.param.VOTING_RULE_ARRAY.length; index++) { if (op.param.VOTING_RULE_ARRAY[index].bIsAbsoluteMajority == true) { return true; } @@ -463,7 +463,7 @@ contract Condition_PluginAndVoting is MachineStateManager { return false; } - function ID_372_ADD_ANY_VOTING_RULE_APPROVAL_PERCENTAGE_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_372_ADD_ANY_VOTING_RULE_APPROVAL_PERCENTAGE_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_372: The UINT_256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_372: The UINT_256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_ADD_VOTING_RULES) return false; @@ -472,7 +472,7 @@ contract Condition_PluginAndVoting is MachineStateManager { } } - function ID_373_ADD_ANY_VOTING_RULE_TOKEN_CLASS_CONTAINS(Operation memory op, NodeParam memory param) internal pure returns (bool) { + function ID_373_ADD_ANY_VOTING_RULE_TOKEN_CLASS_CONTAINS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_373: The STRING_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_373: The STRING_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_VOTING_RULES) return false; @@ -491,7 +491,7 @@ contract Condition_PluginAndVoting is MachineStateManager { * The function to get the plugin index list of the before operation plugins * @param op The operation to be checked */ - function getBeforeOpPluginIndexList(Operation memory op) internal pure returns (uint256[] memory) { + function getBeforeOpPluginIndexList(Operation memory op) private pure returns (uint256[] memory) { if (op.opcode == EnumOpcode.BATCH_ENABLE_PLUGINS || op.opcode == EnumOpcode.BATCH_DISABLE_PLUGINS) { uint256[] memory pluginIndexList = new uint256[](op.param.UINT256_2DARRAY[0].length); uint256 pt = 0; @@ -514,7 +514,7 @@ contract Condition_PluginAndVoting is MachineStateManager { * The function to get the plugin index list of the after operation plugins * @param op The operation to be checked */ - function getAfterOpPluginIndexList(Operation memory op) internal pure returns (uint256[] memory) { + function getAfterOpPluginIndexList(Operation memory op) private pure returns (uint256[] memory) { if (op.opcode == EnumOpcode.BATCH_ENABLE_PLUGINS || op.opcode == EnumOpcode.BATCH_DISABLE_PLUGINS) { uint256[] memory pluginIndexList = new uint256[](op.param.UINT256_2DARRAY[0].length); uint256 pt = 0; diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_Program.sol b/darc-protocol/contracts/protocol/Plugin/Condition_Program.sol index 2487533..04c0c8f 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_Program.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_Program.sol @@ -31,31 +31,31 @@ contract Condition_Program is MachineStateManager { return false; } - function ID_601_PROGRAM_OP_LENGTH_GREATER_THAN(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_601_PROGRAM_OP_LENGTH_GREATER_THAN(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_601: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_601: The UINT256_2DARRAY[0] length is not 1"); return program.operations.length > param.UINT256_2DARRAY[0][0]; } - function ID_602_PROGRAM_OP_LENGTH_LESS_THAN(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_602_PROGRAM_OP_LENGTH_LESS_THAN(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_602: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_602: The UINT256_2DARRAY[0] length is not 1"); return program.operations.length < param.UINT256_2DARRAY[0][0]; } - function ID_603_PRORGRAM_OP_LENGTH_EQUALS(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_603_PRORGRAM_OP_LENGTH_EQUALS(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_603: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_603: The UINT256_2DARRAY[0] length is not 1"); return program.operations.length == param.UINT256_2DARRAY[0][0]; } - function ID_604_PROGRAM_OP_LENGTH_IN_RANGE(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_604_PROGRAM_OP_LENGTH_IN_RANGE(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_604: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_604: The UINT256_2DARRAY[0] length is not 2"); return program.operations.length >= param.UINT256_2DARRAY[0][0] && program.operations.length <= param.UINT256_2DARRAY[0][1]; } - function ID_605_PROGRAM_CONTAINS_OP(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_605_PROGRAM_CONTAINS_OP(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_605: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_605: The UINT256_2DARRAY[0] length is not 1"); for (uint256 i = 0; i < program.operations.length; i++) { @@ -64,7 +64,7 @@ contract Condition_Program is MachineStateManager { return false; } - function ID_606_PROGRAM_CONTAINS_OP_IN_LIST(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_606_PROGRAM_CONTAINS_OP_IN_LIST(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_606: The UINT256_2DARRAY length is not 1"); for (uint256 i = 0; i < program.operations.length; i++) { for (uint256 j=0; j< param.UINT256_2DARRAY[0].length; j++) { @@ -74,7 +74,7 @@ contract Condition_Program is MachineStateManager { return false; } - function ID_607_PROGRAM_EVERY_OP_EQUALS(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_607_PROGRAM_EVERY_OP_EQUALS(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_607: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == program.operations.length, "CE ID_607: The UINT256_2DARRAY[0] length is not equal to program length"); for (uint256 i = 0; i < program.operations.length; i++) { @@ -83,7 +83,7 @@ contract Condition_Program is MachineStateManager { return true; } - function ID_608_PROGRAM_EVERY_OP_IN_LIST(Program memory program, NodeParam memory param) internal pure returns (bool) { + function ID_608_PROGRAM_EVERY_OP_IN_LIST(Program memory program, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_608: The UINT256_2DARRAY length is not 1"); for (uint256 i = 0; i < program.operations.length; i++) { bool bFound = false; diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_TokenAndCash.sol b/darc-protocol/contracts/protocol/Plugin/Condition_TokenAndCash.sol index 2158641..4b3b745 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_TokenAndCash.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_TokenAndCash.sol @@ -16,20 +16,19 @@ import "../Plugin.sol"; contract Condition_TokenAndCash is MachineStateManager { /** * The function to check the batch operation related condition expression - * @param bIsBeforeOperation The flag to indicate if the plugin is before operation plugin * @param op The operation to be checked * @param param The parameter list of the condition expression * @param id The id of the condition expression */ - function tokenAndCashExpressionCheck(bool bIsBeforeOperation, Operation memory op, NodeParam memory param, uint256 id) internal view returns (bool) { - if (id== 461) return ID_461_TOKEN_X_OP_ANY_PRICE_GREATER_THAN(bIsBeforeOperation, op, param); - if (id== 462) return ID_462_TOKEN_X_OP_ANY_PRICE_LESS_THAN(bIsBeforeOperation, op, param); - if (id== 463) return ID_463_TOKEN_X_OP_ANY_PRICE_IN_RANGE(bIsBeforeOperation, op, param); - if (id== 464) return ID_464_TOKEN_X_OP_ANY_PRICE_EQUALS(bIsBeforeOperation, op, param); + function tokenAndCashExpressionCheck(Operation memory op, NodeParam memory param, uint256 id) internal pure returns (bool) { + if (id== 461) return ID_461_TOKEN_X_OP_ANY_PRICE_GREATER_THAN(op, param); + if (id== 462) return ID_462_TOKEN_X_OP_ANY_PRICE_LESS_THAN(op, param); + if (id== 463) return ID_463_TOKEN_X_OP_ANY_PRICE_IN_RANGE(op, param); + if (id== 464) return ID_464_TOKEN_X_OP_ANY_PRICE_EQUALS(op, param); return false; } - function ID_461_TOKEN_X_OP_ANY_PRICE_GREATER_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_461_TOKEN_X_OP_ANY_PRICE_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_461: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_461: The UINT256_2DARRAY[0] length is not 1"); if (bIsTokenOperationWithCash(op) == false) return false; @@ -41,7 +40,7 @@ contract Condition_TokenAndCash is MachineStateManager { return false; } - function ID_462_TOKEN_X_OP_ANY_PRICE_LESS_THAN(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_462_TOKEN_X_OP_ANY_PRICE_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_462: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_462: The UINT256_2DARRAY[0] length is not 1"); if (bIsTokenOperationWithCash(op) == false) return false; @@ -53,7 +52,7 @@ contract Condition_TokenAndCash is MachineStateManager { return false; } - function ID_463_TOKEN_X_OP_ANY_PRICE_IN_RANGE(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_463_TOKEN_X_OP_ANY_PRICE_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_463: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 3, "CE ID_463: The UINT256_2DARRAY[0] length is not 1"); if (bIsTokenOperationWithCash(op) == false) return false; @@ -65,7 +64,7 @@ contract Condition_TokenAndCash is MachineStateManager { return false; } - function ID_464_TOKEN_X_OP_ANY_PRICE_EQUALS(bool bIsBeforeOperation, Operation memory op, NodeParam memory param) internal view returns (bool) { + function ID_464_TOKEN_X_OP_ANY_PRICE_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool) { require(param.UINT256_2DARRAY.length == 1, "CE ID_464: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_464: The UINT256_2DARRAY[0] length is not 1"); if (bIsTokenOperationWithCash(op) == false) return false; @@ -80,7 +79,7 @@ contract Condition_TokenAndCash is MachineStateManager { // -------------------------------- below are helper functions ---------------------------- - function bIsTokenOperationWithCash(Operation memory op) internal pure returns (bool) { + function bIsTokenOperationWithCash(Operation memory op) private pure returns (bool) { if (op.opcode == EnumOpcode.BATCH_PAY_TO_MINT_TOKENS || op.opcode == EnumOpcode.BATCH_PAY_TO_TRANSFER_TOKENS || op.opcode == EnumOpcode.BATCH_BURN_TOKENS_AND_REFUND @@ -88,7 +87,7 @@ contract Condition_TokenAndCash is MachineStateManager { return false; } - function getTokenClassAmountPriceList(Operation memory op) internal pure returns (uint256[] memory, uint256[] memory, uint256[] memory) { + function getTokenClassAmountPriceList(Operation memory op) private pure returns (uint256[] memory, uint256[] memory, uint256[] memory) { require(bIsTokenOperationWithCash(op), "CE ID_461: The operation is not token operation with cash(pay-to-mint, pay-to-transfer, burn-and-refund)"); if (op.opcode == EnumOpcode.BATCH_PAY_TO_MINT_TOKENS) { return (op.param.UINT256_2DARRAY[0], op.param.UINT256_2DARRAY[1], op.param.UINT256_2DARRAY[2]); diff --git a/darc-protocol/contracts/protocol/Plugin/Condition_Withdrawable.sol b/darc-protocol/contracts/protocol/Plugin/Condition_Withdrawable.sol index 7dfe214..e80fbe1 100644 --- a/darc-protocol/contracts/protocol/Plugin/Condition_Withdrawable.sol +++ b/darc-protocol/contracts/protocol/Plugin/Condition_Withdrawable.sol @@ -33,7 +33,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_431_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_431_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_431: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_431: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_WITHDRAWABLE_BALANCES) return false; @@ -43,7 +43,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_432_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_432_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_432: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_432: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_WITHDRAWABLE_BALANCES) return false; @@ -53,7 +53,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_433_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_433_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_433: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_433: The UINT256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_ADD_WITHDRAWABLE_BALANCES) return false; @@ -63,7 +63,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_434_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_434_ADD_WITHDRAWABLE_BALANCE_ANY_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_434: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_434: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_ADD_WITHDRAWABLE_BALANCES) return false; @@ -73,7 +73,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_435_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_435_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_GREATER_THAN(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_435: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_435: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_REDUCE_WITHDRAWABLE_BALANCES) return false; @@ -83,7 +83,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_436_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_436_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_LESS_THAN(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_436: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_436: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_REDUCE_WITHDRAWABLE_BALANCES) return false; @@ -93,7 +93,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_437_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_437_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_IN_RANGE(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_437: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 2, "CE ID_437: The UINT256_2DARRAY[0] length is not 2"); if (op.opcode != EnumOpcode.BATCH_REDUCE_WITHDRAWABLE_BALANCES) return false; @@ -103,7 +103,7 @@ contract Condition_Withdrawable is MachineStateManager { return false; } - function ID_438_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) internal pure returns (bool){ + function ID_438_REDUCE_WITHDRAWABLE_BALANCE_ANY_AMOUNT_EQUALS(Operation memory op, NodeParam memory param) private pure returns (bool){ require(param.UINT256_2DARRAY.length == 1, "CE ID_438: The UINT256_2DARRAY length is not 1"); require(param.UINT256_2DARRAY[0].length == 1, "CE ID_438: The UINT256_2DARRAY[0] length is not 1"); if (op.opcode != EnumOpcode.BATCH_REDUCE_WITHDRAWABLE_BALANCES) return false; diff --git a/darc-protocol/contracts/protocol/Plugin/EnumConditionExpression.sol.old b/darc-protocol/contracts/protocol/Plugin/EnumConditionExpression.sol.old index a88eb56..0bbd1c7 100644 --- a/darc-protocol/contracts/protocol/Plugin/EnumConditionExpression.sol.old +++ b/darc-protocol/contracts/protocol/Plugin/EnumConditionExpression.sol.old @@ -20,34 +20,34 @@ enum EnumConditionExpression{ OPERATOR_NAME_EQUALS, //ID: 1 params: string operatorName OPERATOR_ROLE_INDEX_EQUALS, //ID:2 params: uint256 operatorRoleIndex OPERATOR_ADDRESS_EQUALS, //ID:3 params: address operatorAddress - OPERATOR_ROLE_LARGER_THAN, // params: uint256 operatorRoleIndex + OPERATOR_ROLE_GREATER_THAN, // params: uint256 operatorRoleIndex OPERATOR_ROLE_LESS_THAN, // params: uint256 operatorRoleIndex OPERATOR_ROLE_IN_RANGE, // params: uint256 operatorRoleIndex OPERATOR_ROLE_IN_LIST, // params: uint256[] operatorRoleIndexArray - OPERATOR_TOKEN_X_AMOUNT_LARGER_THAN, // params: uint256 token class, uint256 amount + OPERATOR_TOKEN_X_AMOUNT_GREATER_THAN, // params: uint256 token class, uint256 amount OPERATOR_TOKEN_X_AMOUNT_LESS_THAN, // params: uint256 token class, uint256 amount OPERATOR_TOKEN_X_AMOUNT_IN_RANGE, // params: uint256 token class, uint256 amount OPERATOR_TOKEN_X_AMOUNT_EQUALS, // params: uint256 token class, uint256 amount - OPERATOR_TOKEN_X_PERCENTAGE_LARGER_THAN, // params: uint256 token class, uint256 percentage + OPERATOR_TOKEN_X_PERCENTAGE_GREATER_THAN, // params: uint256 token class, uint256 percentage OPERATOR_TOKEN_X_PERCENTAGE_LESS_THAN, // params: uint256 token class, uint256 percentage OPERATOR_TOKEN_X_PERCENTAGE_IN_RANGE, // params: uint256 token class, uint256 percentage OPERATOR_TOKEN_X_PERCENTAGE_EQUALS, // params: uint256 token class, uint256 percentage - OPERATOR_VOTING_WEIGHT_LARGER_THAN, // params: uint256 amount + OPERATOR_VOTING_WEIGHT_GREATER_THAN, // params: uint256 amount OPERATOR_VOTING_WEIGHT_LESS_THAN, // params: uint256 amount OPERATOR_VOTING_WEIGHT_IN_RANGE, // params: uint256 amount - OPERATOR_DIVIDEND_WEIGHT_LARGER_THAN, // params: uint256 amount + OPERATOR_DIVIDEND_WEIGHT_GREATER_THAN, // params: uint256 amount OPERATOR_DIVIDEND_WEIGHT_LESS_THAN, // params: uint256 amount OPERATOR_DIVIDEND_WEIGHT_IN_RANGE, // params: uint256 amount - OPERATOR_DIVIDEND_WITHDRAWABLE_LARGER_THAN, // params: uint256 amount + OPERATOR_DIVIDEND_WITHDRAWABLE_GREATER_THAN, // params: uint256 amount OPERATOR_DIVIDEND_WITHDRAWABLE_LESS_THAN, // params: uint256 amount OPERATOR_DIVIDEND_WITHDRAWABLE_IN_RANGE, // params: uint256 amount - OPERATOR_WITHDRAWABLE_CASH_LARGER_THAN, // params: uint256 amount + OPERATOR_WITHDRAWABLE_CASH_GREATER_THAN, // params: uint256 amount OPERATOR_WITHDRAWABLE_CASH_LESS_THAN, // params: uint256 amount OPERATOR_WITHDRAWABLE_CASH_IN_RANGE, // params: uint256 amount - OPERATOR_WITHDRAWABLE_DIVIDENDS_LARGER_THAN, // params: uint256 amount + OPERATOR_WITHDRAWABLE_DIVIDENDS_GREATER_THAN, // params: uint256 amount OPERATOR_WITHDRAWABLE_DIVIDENDS_LESS_THAN, // params: uint256 amount OPERATOR_WITHDRAWABLE_DIVIDENDS_IN_RANGE, // params: uint256 amount @@ -78,51 +78,51 @@ enum EnumConditionExpression{ /** * @notice Machine State related expressions */ - TIMESTAMP_LARGER_THAN, + TIMESTAMP_GREATER_THAN, TIMESTAMP_LESS_THAN, TIMESTAMP_IN_RANGE, - DATE_YEAR_LARGER_THAN, + DATE_YEAR_GREATER_THAN, DATE_YEAR_LESS_THAN, DATE_YEAR_IN_RANGE, - DATE_MONTH_LARGER_THAN, + DATE_MONTH_GREATER_THAN, DATE_MONTH_LESS_THAN, DATE_MONTH_IN_RANGE, - DATE_DAY_LARGER_THAN, + DATE_DAY_GREATER_THAN, DATE_DAY_LESS_THAN, DATE_DAY_IN_RANGE, - DATE_HOUR_LARGER_THAN, + DATE_HOUR_GREATER_THAN, DATE_HOUR_LESS_THAN, DATE_HOUR_IN_RANGE, - ADDRESS_VOTING_WEIGHT_LARGER_THAN, + ADDRESS_VOTING_WEIGHT_GREATER_THAN, ADDRESS_VOTING_WEIGHT_LESS_THAN, ADDRESS_VOTING_WEIGHT_IN_RANGE, - ADDRESS_DIVIDEND_WEIGHT_LARGER_THAN, + ADDRESS_DIVIDEND_WEIGHT_GREATER_THAN, ADDRESS_DIVIDEND_WEIGHT_LESS_THAN, ADDRESS_DIVIDEND_WEIGHT_IN_RANGE, - ADDRESS_TOKEN_X_LARGER_THAN, + ADDRESS_TOKEN_X_GREATER_THAN, ADDRESS_TOKEN_X_LESS_THAN, ADDRESS_TOKEN_X_IN_RANGE, - TOTAL_VOTING_WEIGHT_LARGER_THAN, + TOTAL_VOTING_WEIGHT_GREATER_THAN, TOTAL_VOTING_WEIGHT_LESS_THAN, TOTAL_VOTING_WEIGHT_IN_RANGE, - TOTAL_DIVIDEND_WEIGHT_LARGER_THAN, + TOTAL_DIVIDEND_WEIGHT_GREATER_THAN, TOTAL_DIVIDEND_WEIGHT_LESS_THAN, TOTAL_DIVIDEND_WEIGHT_IN_RANGE, - TOTAL_CASH_LARGER_THAN, + TOTAL_CASH_GREATER_THAN, TOTAL_CASH_LESS_THAN, TOTAL_CASH_IN_RANGE, TOTAL_CASH_EQUALS, - TOKEN_IN_list_VOTING_WEIGHT_LARGER_THAN, + TOKEN_IN_list_VOTING_WEIGHT_GREATER_THAN, TOKEN_IN_list_VOTING_WEIGHT_LESS_THAN, TOKEN_IN_list_VOTING_WEIGHT_IN_RANGE, - TOKEN_IN_list_DIVIDEND_WEIGHT_LARGER_THAN, + TOKEN_IN_list_DIVIDEND_WEIGHT_GREATER_THAN, TOKEN_IN_list_DIVIDEND_WEIGHT_LESS_THAN, TOKEN_IN_list_DIVIDEND_WEIGHT_IN_RANGE, - TOKEN_IN_list_AMOUNT_LARGER_THAN, + TOKEN_IN_list_AMOUNT_GREATER_THAN, TOKEN_IN_list_AMOUNT_LESS_THAN, TOKEN_IN_list_AMOUNT_IN_RANGE, TOKEN_IN_list_AMOUNT_EQUALS, @@ -177,13 +177,13 @@ enum EnumConditionExpression{ // General Operation and Operation Log related expressions OPERATION_EQUALS, OPERATION_IN_LIST, - OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LARGER_THAN, + OPERATION_BY_OPERATOR_SINCE_LAST_TIME_GREATER_THAN, OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LESS_THAN, OPERATION_BY_OPERATOR_SINCE_LAST_TIME_IN_RANGE, - OPERATION_EVERYONE_SINCE_LAST_TIME_LARGER_THAN, + OPERATION_EVERYONE_SINCE_LAST_TIME_GREATER_THAN, OPERATION_EVERYONE_SINCE_LAST_TIME_LESS_THAN, OPERATION_EVERYONE_SINCE_LAST_TIME_IN_RANGE, - OPERATION_BATCH_SIZE_LARGER_THAN, + OPERATION_BATCH_SIZE_GREATER_THAN, OPERATION_BATCH_SIZE_LESS_THAN, OPERATION_BATCH_SIZE_IN_RANGE, OPERATION_BATCH_SIZE_EQUALS, @@ -211,11 +211,11 @@ enum EnumConditionExpression{ // ---------------------------------------------------------- // Oracle and remote call related expressions ORACLE_CALL_UINT256_RESULT_EQUALS, - ORACLE_CALL_UINT256_RESULT_LARGER_THAN, + ORACLE_CALL_UINT256_RESULT_GREATER_THAN, ORACLE_CALL_UINT256_RESULT_LESS_THAN, ORACLE_CALL_UINT256_RESULT_IN_RANGE, ORACLE_CALL_UINT256_1_LESS_THAN_2, - ORACLE_CALL_UINT256_1_LARGER_THAN_2, + ORACLE_CALL_UINT256_1_GREATER_THAN_2, ORACLE_CALL_UINT256_1_EQUALS_2, ORACLE_CALL_STRING_RESULT_EQUALS, ORACLE_CALL_STRING_1_EQUALS_2, @@ -255,10 +255,10 @@ enum EnumConditionExpression{ MINT_TOKENS_TOTAL_AMOUNT_LEVEL_X_LESS_THAN, MINT_TOKENS_TOTAL_AMOUNT_LEVEL_X_IN_RANGE, MINT_TOKENS_TOTAL_AMOUNT_LEVEL_X_EQUALS, - MINT_TOKENS_TOTAL_VOTING_WEIGHT_LARGER_THAN, + MINT_TOKENS_TOTAL_VOTING_WEIGHT_GREATER_THAN, MINT_TOKENS_TOTAL_VOTING_WEIGHT_LESS_THAN, MINT_TOKENS_TOTAL_VOTING_WEIGHT_IN_RANGE, - MINT_TOKENS_TOTAL_DIVIDEND_WEIGHT_LARGER_THAN, + MINT_TOKENS_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN, MINT_TOKENS_TOTAL_DIVIDEND_WEIGHT_LESS_THAN, MINT_TOKENS_TOTAL_DIVIDEND_WEIGHT_IN_RANGE, MINT_TOKEN_EACH_BATCH_AMOUNT_MORE_THAN, @@ -307,10 +307,10 @@ enum EnumConditionExpression{ BURN_TOKENS_TOTAL_AMOUNT_LEVEL_X_LESS_THAN, BURN_TOKENS_TOTAL_AMOUNT_LEVEL_X_IN_RANGE, BURN_TOKENS_TOTAL_AMOUNT_LEVEL_X_EQUALS, - BURN_TOKENS_TOTAL_VOTING_WEIGHT_LARGER_THAN, + BURN_TOKENS_TOTAL_VOTING_WEIGHT_GREATER_THAN, BURN_TOKENS_TOTAL_VOTING_WEIGHT_LESS_THAN, BURN_TOKENS_TOTAL_VOTING_WEIGHT_IN_RANGE, - BURN_TOKENS_TOTAL_DIVIDEND_WEIGHT_LARGER_THAN, + BURN_TOKENS_TOTAL_DIVIDEND_WEIGHT_GREATER_THAN, BURN_TOKENS_TOTAL_DIVIDEND_WEIGHT_LESS_THAN, BURN_TOKENS_TOTAL_DIVIDEND_WEIGHT_IN_RANGE, BURN_TOKEN_EACH_BATCH_AMOUNT_MORE_THAN, diff --git a/darc-protocol/contracts/protocol/Runtime/Executable/Executable.sol b/darc-protocol/contracts/protocol/Runtime/Executable/Executable.sol index b3c54af..0d08f81 100644 --- a/darc-protocol/contracts/protocol/Runtime/Executable/Executable.sol +++ b/darc-protocol/contracts/protocol/Runtime/Executable/Executable.sol @@ -8,6 +8,7 @@ import "../VotingMachine/VotingMachine.sol"; // import openzeppelin upgradeable contracts safe math import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "./InstructionMachine.sol"; +import "../../Utilities/OpcodeMap.sol"; /** @@ -93,11 +94,76 @@ contract Executable is MachineStateManager, PluginSystem, VotingMachine, Instruc function executeProgram_Executable(Program memory program, bool bIsSandbox) internal { // 1. add each operation to the operation log - + updateOperationLog(bIsSandbox, program); + // 2. go through each operation for (uint256 i = 0; i < program.operations.length; i++) { // 2.1 execute the operation executeOperation(program.operations[i], bIsSandbox); } } + + /** + * @notice Update the user's operation log and global operation log before executing the operation + * @param bIsSandbox the flag of sandbox + * @param program the program to be executed + */ + function updateOperationLog(bool bIsSandbox, Program memory program) private { + if (bIsSandbox) { + // 1. search the operation log map to see if the program operator address is in the map + bool bIsInOperaionLopMapAddressList = false; + for (uint256 index; index < sandboxMachineState.operationLogMapAddressList.length;index++) { + if (sandboxMachineState.operationLogMapAddressList[index] == program.programOperatorAddress) { + bIsInOperaionLopMapAddressList = true; + break; + } + } + + // 2. if the program operator address is not in the map, add it to the map + if (!bIsInOperaionLopMapAddressList) { + sandboxMachineState.operationLogMapAddressList.push(program.programOperatorAddress); + } + + // 3. traverse each operation, update the user's operation log of current operator with the latest timestamp + for (uint256 index; index < program.operations.length;index++) { + uint256 opcodeVal = OpcodeMap.opcodeVal(program.operations[index].opcode); + sandboxMachineState.operationLogMap[program.programOperatorAddress].latestOperationTimestamp[opcodeVal] = block.timestamp; + } + + // 4. traverse each operation, update the global operation log with the latest timestamp + for (uint256 index; index < program.operations.length;index++) { + uint256 opcodeVal = OpcodeMap.opcodeVal(program.operations[index].opcode); + sandboxMachineState.globalOperationLog.latestOperationTimestamp[opcodeVal] = block.timestamp; + } + } + + else { + // 1. search the operation log map to see if the program operator address is in the map + bool bIsInOperaionLopMapAddressList = false; + for (uint256 index; index < currentMachineState.operationLogMapAddressList.length;index++) { + if (currentMachineState.operationLogMapAddressList[index] == program.programOperatorAddress) { + bIsInOperaionLopMapAddressList = true; + break; + } + } + + // 2. if the program operator address is not in the map, add it to the map + if (!bIsInOperaionLopMapAddressList) { + currentMachineState.operationLogMapAddressList.push(program.programOperatorAddress); + } + + // 3. traverse each operation, update the user's operation log of current operator with the latest timestamp + for (uint256 index; index < program.operations.length;index++) { + uint256 opcodeVal = OpcodeMap.opcodeVal(program.operations[index].opcode); + currentMachineState.operationLogMap[program.programOperatorAddress].latestOperationTimestamp[opcodeVal] = block.timestamp; + } + + // 4. traverse each operation, update the global operation log with the latest timestamp + for (uint256 index; index < program.operations.length;index++) { + uint256 opcodeVal = OpcodeMap.opcodeVal(program.operations[index].opcode); + currentMachineState.globalOperationLog.latestOperationTimestamp[opcodeVal] = block.timestamp; + } + } + + } } \ No newline at end of file diff --git a/darc-specs/condition_expression.md b/darc-specs/condition_expression.md index 7b0c9c2..fdeec04 100644 --- a/darc-specs/condition_expression.md +++ b/darc-specs/condition_expression.md @@ -185,12 +185,12 @@ For more details, please refer to [DARC Instruction Set Opcode Table(opcode.md)] | 148 | Placeholder148 | | | | 149 | Placeholder149 | | | | 150 | Placeholder150 | | | -| 151 | OPERATION_EQUALS | string operation, uint256 value || -| 152 | OPERATION_IN_LIST | string operation, uint256[] values || -| 153 | OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LARGER_THAN | string operation, address operator, uint256 timestamp | NOT READY, DO NOT USE -| 154 | OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LESS_THAN | string operation, address operator, uint256 timestamp | NOT READY, DO NOT USE -| 155 | OPERATION_BY_OPERATOR_SINCE_LAST_TIME_IN_RANGE | string operation, address operator, uint256 startTimestamp, uint256 endTimestamp | NOT READY, DO NOT USE -| 156 | OPERATION_EVERYONE_SINCE_LAST_TIME_LARGER_THAN | string operation, uint256 timestamp | NOT READY, DO NOT USE +| 151 | OPERATION_EQUALS | uint256 value || +| 152 | OPERATION_IN_LIST | uint256[] values || +| 153 | Placeholder153 | | | +| 154 | Placeholder154 | | | +| 155 | Placeholder155 | | | +| 156 | Placeholder156 | | | | 157 | Placeholder157 | | | | 158 | Placeholder158 | | | | 159 | Placeholder159 | | | @@ -199,7 +199,6 @@ For more details, please refer to [DARC Instruction Set Opcode Table(opcode.md)] | 162 | Placeholder162 | | | | 163 | Placeholder163 | | | | 164 | Placeholder164 | | | -| 165 | Placeholder165 | | | | 166 | Placeholder166 | | | | 167 | Placeholder167 | | | | 168 | Placeholder168 | | | @@ -216,11 +215,11 @@ For more details, please refer to [DARC Instruction Set Opcode Table(opcode.md)] | 179 | Placeholder179 | | | | 180 | Placeholder180 | | | | 181 | ORACLE_CALL_UINT256_RESULT_EQUALS | string oracle, string method, uint256[] args, uint256 expectedValue || -| 182 | ORACLE_CALL_UINT256_RESULT_LARGER_THAN | string oracle, string method, uint256[] args, uint256 minValue || +| 182 | ORACLE_CALL_UINT256_RESULT_GREATER_THAN | string oracle, string method, uint256[] args, uint256 minValue || | 183 | ORACLE_CALL_UINT256_RESULT_LESS_THAN | string oracle, string method, uint256[] args, uint256 maxValue || | 184 | ORACLE_CALL_UINT256_RESULT_IN_RANGE | string oracle, string method, uint256[] args, uint256 minValue, uint256 maxValue || | 185 | ORACLE_CALL_UINT256_1_LESS_THAN_2 | string oracle, string method, uint256[] args || -| 186 | ORACLE_CALL_UINT256_1_LARGER_THAN_2 | string oracle, string method, uint256[] args || +| 186 | ORACLE_CALL_UINT256_1_GREATER_THAN_2 | string oracle, string method, uint256[] args || | 187 | ORACLE_CALL_UINT256_1_EQUALS_2 | string oracle, string method, uint256[] args || | 188 | ORACLE_CALL_STRING_RESULT_EQUALS | string oracle, string method, string[] args, string expectedValue || | 189 | ORACLE_CALL_STRING_1_EQUALS_2 | string oracle, string method, string[] args || @@ -743,18 +742,18 @@ For more details, please refer to [DARC Instruction Set Opcode Table(opcode.md)] | 698 | Placeholder698 | | | | 699 | Placeholder699 | | | | 700 | Placeholder700 | | | -| 701 | Placeholder701 | | | -| 702 | Placeholder702 | | | -| 703 | Placeholder703 | | | -| 704 | Placeholder704 | | | -| 705 | Placeholder705 | | | -| 706 | Placeholder706 | | | -| 707 | Placeholder707 | | | -| 708 | Placeholder708 | | | -| 709 | Placeholder709 | | | -| 710 | Placeholder710 | | | -| 711 | Placeholder711 | | | -| 712 | Placeholder712 | | | +| 701 | OPERATION_BY_OPERATOR_SINCE_LAST_TIME_GREATER_THAN | address operator, uint256 timestamp || +| 702 | OPERATION_BY_OPERATOR_SINCE_LAST_TIME_LESS_THAN | address operator, uint256 timestamp || +| 703 | OPERATION_BY_OPERATOR_SINCE_LAST_TIME_IN_RANGE | address operator, uint256 startTimestamp, uint256 endTimestamp || +| 704 | OPERATION_GLOBAL_SINCE_LAST_TIME_GREATER_THAN | uint256 timestamp || +| 705 | OPERATION_GLOBAL_SINCE_LAST_TIME_LESS_THAN | uint256 timestamp || +| 706 | OPERATION_GLOBAL_SINCE_LAST_TIME_IN_RANGE | uint256 startTimestamp, uint256 endTimestamp || +| 707 | OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_GREATER_THAN | address[] addressList, uint256 timestamp || +| 708 | OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_LESS_THAN | address[] addressList, uint256 timestamp || +| 709 | OPERATION_BY_ANY_ADDRESS_IN_LIST_SINCE_LAST_TIME_IN_RANGE | address[] addressList, uint256 startTimestamp, uint256 endTimestamp || +| 710 | OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_GREATER_THAN | address[] addressList, uint256 timestamp || +| 711 | OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_LESS_THAN | address[] addressList, uint256 timestamp || +| 712 | OPERATION_BY_EACH_ADDRESS_IN_LIST_SINCE_LAST_TIME_IN_RANGE | address[] addressList, uint256 startTimestamp, uint256 endTimestamp || | 713 | Placeholder713 | | | | 714 | Placeholder714 | | | | 715 | Placeholder715 | | |