Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Dec 21, 2023
1 parent 19072f6 commit 04d1a8f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 89 deletions.
4 changes: 2 additions & 2 deletions darc-docs/docs/DARC Protocol/OpCodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ By defining these operations through opcodes, the DARC protocol ensures consiste
| BATCH_PAY_TO_MINT_TOKENS | 20 | `addressArray`: address[]<br/>`tokenClassArray`: uint256[]<br/>`amountArray`: uint256[]<br/>`priceArray`: uint256[] | Batch Pay to Mint Tokens Operation |
| BATCH_PAY_TO_TRANSFER_TOKENS | 21 | `toAddressArray`: address[]<br/>`tokenClassArray`: uint256[]<br/>`amountArray`: uint256[]<br/>`priceArray`: uint256[] | Pay Some Cash to Transfer Tokens Operation |
| ADD_EMERGENCY | 22 | `addressArray`: address[] | Add an Array of Addresses as Emergency Agents |
| WITHDRAW_CASH_TO | 23 | `addressArray`: address[]<br/>`amountArray`: uint256[] | Withdraw Cash from the Contract's Cash Balance |
| RESERVED_ID_23 | 23 | `addressArray`: address[]<br/>`amountArray`: uint256[] | Withdraw Cash from the Contract's Cash Balance |
| CALL_EMERGENCY | 24 | `addressArray`: address[] | Call Emergency Agents to Handle Emergency Situations |
| CALL_CONTRACT_ABI | 25 | `contractAddress`: address<br/>`abi`: bytes | Call a Contract with the Given ABI |
| PAY_CASH | 26 | `amount`: uint256<br/>`paymentType`: uint256<br/>`dividendable`: uint256 | Pay Some Cash |
| OFFER_DIVIDENDS | 27 | N/A | Calculate Dividends and Offer to Token Holders |
| WITHDRAW_DIVIDENDS_TO | 28 | `addressArray`: address[]<br/>`amountArray`: uint256[] | Withdraw Dividends from the Withdrawable Dividends Balance |
| RESERVED_ID_28 | 28 | `addressArray`: address[]<br/>`amountArray`: uint256[] | Withdraw Dividends from the Withdrawable Dividends Balance |
| SET_APPROVAL_FOR_ALL_OPERATIONS | 29 | `address`: address | Set Approval for All Transfer Operations by Address |
| BATCH_BURN_TOKENS_AND_REFUND | 30 | `tokenClassArray`: uint256[] <br/> | Batch Burn Tokens and Refund |
| ADD_STORAGE_IPFS_HASH | 31 | `address`: string[] | Add Storage IPFS Hash |
Expand Down
55 changes: 0 additions & 55 deletions darc-protocol/contracts/protocol/CashOwnerListManager.sol

This file was deleted.

2 changes: 1 addition & 1 deletion darc-protocol/contracts/protocol/MachineStateManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ contract MachineStateManager {
false
));

// set dividend permyriad per transaction as 500
// set dividend permyriad per transaction as 5000, which is 50%
currentMachineState.machineStateParameters.dividendPermyriadPerTransaction = 5000;

// set the dividend cycle of transactions as 1
Expand Down
12 changes: 4 additions & 8 deletions darc-protocol/contracts/protocol/Opcodes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,10 @@ enum EnumOpcode {
ADD_EMERGENCY,

/**
* @notice withdraw cash from the contract's cash balance
* @param address[] addressArray: the array of the address to withdraw cash to
* @param uint256[] amountArray: the array of the amount of cash to withdraw
* @notice Reserved ID 23 DO NOT USE
* ID:23
*/
WITHDRAW_CASH_TO,
RESERVED_ID_23,

/**
* @notice Call emergency agents to handle emergency situations
Expand Down Expand Up @@ -255,12 +253,10 @@ enum EnumOpcode {
OFFER_DIVIDENDS,

/**
* @notice Withdraw dividends from the withdrawable dividends balance
* @param address[] addressArray: the array of the address to withdraw dividends to
* @param uint256[] amountArray: the array of the amount of dividends to withdraw
* @notice Reserved ID 28 DO NOT USE
* ID:28
*/
WITHDRAW_DIVIDENDS_TO,
RESERVED_ID_28,

/**
* @notice Set the approval for all transfer operations by address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract ConditionExpressionFactory is

// check the condition expression node
if (exp == EnumConditionExpression.OPERATION_NAME_EQUALS) {
return exp_OPERATION_NAME_EUQALS(operation, param);
return exp_OPERATION_NAME_EQUALS(operation, param);
}
else if (exp == EnumConditionExpression.OPERATOR_NAME_EQUALS) {
return false;//exp_OPERATOR_NAME_EQUALS(bIsBeforeOperation, operation, paramList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract OperatorExpressionFunctions is MachineStateManager {
* The first parameter is the opcode ID (in uint256) of the condition node
* This is function to check if the opcode of the current/sandbox machine state is equal to the opcode of the condition node
*/
function exp_OPERATION_NAME_EUQALS(Operation memory operation, NodeParam memory param) internal pure returns (bool) {
function exp_OPERATION_NAME_EQUALS(Operation memory operation, NodeParam memory param) internal pure returns (bool) {
//get the uint256 value of the first parameter
uint256 paramOpcodeID = param.UINT256_ARRAY[0];
// compare
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ OfferDividendsInstructions
}

// opcode id == 23
else if (operation.opcode == EnumOpcode.WITHDRAW_CASH_TO) {
op_WITHDRAW_CASH_TO(operation, bIsSandbox);
else if (operation.opcode == EnumOpcode.RESERVED_ID_23) {
revert("Reserved opcode id 23 is not implemented.");
}

// opcode id == 24
Expand All @@ -180,8 +180,8 @@ OfferDividendsInstructions
}

// opcode id == 28
else if (operation.opcode == EnumOpcode.WITHDRAW_DIVIDENDS_TO) {
op_WITHDRAW_DIVIDENDS_TO(operation, bIsSandbox);
else if (operation.opcode == EnumOpcode.RESERVED_ID_28) {
revert("Reserved opcode id 28 is not implemented.");
}

// opcode id == 29
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,6 @@ contract MoneyInstructions is MachineStateManager {
}
}

/**
* The function to withdraw cash from the DARC
* @param operation The operation to be executed
* @param bIsSandbox The boolean flag that indicates if the operation is executed in sandbox
*/
function op_WITHDRAW_CASH_TO(Operation memory operation, bool bIsSandbox) internal {

}

/**
* @notice Pay cash to the DARC
* @param operation the operation to be executed
Expand Down Expand Up @@ -302,8 +293,4 @@ contract MoneyInstructions is MachineStateManager {
// todo
}

function op_WITHDRAW_DIVIDENDS_TO(Operation memory operation, bool bIsSandbox) internal {
// todo
}

}
8 changes: 4 additions & 4 deletions darc-protocol/contracts/protocol/Utilities/OpcodeMap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ library OpcodeMap{
if (opcode == EnumOpcode.BATCH_PAY_TO_MINT_TOKENS) return 20;
if (opcode == EnumOpcode.BATCH_PAY_TO_TRANSFER_TOKENS) return 21;
if (opcode == EnumOpcode.CALL_EMERGENCY) return 22;
if (opcode == EnumOpcode.WITHDRAW_CASH_TO) return 23;
if (opcode == EnumOpcode.RESERVED_ID_23) return 23;
if (opcode == EnumOpcode.CALL_EMERGENCY) return 24;
if (opcode == EnumOpcode.CALL_CONTRACT_ABI) return 25;
if (opcode == EnumOpcode.PAY_CASH) return 26;
if (opcode == EnumOpcode.OFFER_DIVIDENDS) return 27;
if (opcode == EnumOpcode.WITHDRAW_DIVIDENDS_TO) return 28;
if (opcode == EnumOpcode.RESERVED_ID_28) return 28;
if (opcode == EnumOpcode.SET_APPROVAL_FOR_ALL_OPERATIONS) return 29;
if (opcode == EnumOpcode.BATCH_BURN_TOKENS_AND_REFUND) return 30;
if (opcode == EnumOpcode.ADD_STORAGE_IPFS_HASH) return 31;
Expand Down Expand Up @@ -79,12 +79,12 @@ library OpcodeMap{
if (opcode == EnumOpcode.BATCH_PAY_TO_MINT_TOKENS) return "BATCH_PAY_TO_MINT_TOKENS";
if (opcode == EnumOpcode.BATCH_PAY_TO_TRANSFER_TOKENS) return "BATCH_PAY_TO_TRANSFER_TOKENS";
if (opcode == EnumOpcode.CALL_EMERGENCY) return "CALL_EMERGENCY";
if (opcode == EnumOpcode.WITHDRAW_CASH_TO) return "WITHDRAW_CASH_TO";
if (opcode == EnumOpcode.RESERVED_ID_23) return "RESERVED_ID_23";
if (opcode == EnumOpcode.CALL_EMERGENCY) return "CALL_EMERGENCY";
if (opcode == EnumOpcode.CALL_CONTRACT_ABI) return "CALL_CONTRACT_ABI";
if (opcode == EnumOpcode.PAY_CASH) return "PAY_CASH";
if (opcode == EnumOpcode.OFFER_DIVIDENDS) return "OFFER_DIVIDENDS";
if (opcode == EnumOpcode.WITHDRAW_DIVIDENDS_TO) return "WITHDRAW_DIVIDENDS_TO";
if (opcode == EnumOpcode.RESERVED_ID_28) return "RESERVED_ID_28";
if (opcode == EnumOpcode.SET_APPROVAL_FOR_ALL_OPERATIONS) return "SET_APPROVAL_FOR_ALL_OPERATIONS";
if (opcode == EnumOpcode.BATCH_BURN_TOKENS_AND_REFUND) return "BATCH_BURN_TOKENS_AND_REFUND";
if (opcode == EnumOpcode.ADD_STORAGE_IPFS_HASH) return "ADD_STORAGE_IPFS_HASH";
Expand Down

0 comments on commit 04d1a8f

Please sign in to comment.