Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Jan 17, 2024
1 parent b74e4a8 commit 6014c51
Show file tree
Hide file tree
Showing 17 changed files with 633 additions and 284 deletions.
6 changes: 6 additions & 0 deletions darc-protocol/contracts/protocol/MachineState.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions darc-protocol/contracts/protocol/MachineStateManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import "./Condition_Withdrawable.sol";
import "./Condition_TokenAndCash.sol";
import "./Condition_CreateTokenClass.sol";
import "./Condition_Program.sol";
import "./Condition_OperationLog.sol";


/**
Expand All @@ -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
{

/**
Expand Down Expand Up @@ -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;
Expand Down
150 changes: 75 additions & 75 deletions darc-protocol/contracts/protocol/Plugin/Condition_BatchOp.sol

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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
*/
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 6014c51

Please sign in to comment.