Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed Dec 5, 2023
1 parent 9035e15 commit 5e24c0c
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 26 deletions.
15 changes: 15 additions & 0 deletions darc-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,18 @@ const myDeployedDARC_readOnly = new darcjs.DARC({
// Read information from the DARC
const memberList = await myDARC_readOnly.getMemberList();
```

### Test

Before running the test, you need to start a Hardhat Network in your neighbour folder `darc-protocol`

```bash
cd ../darc-protocol
npx hardhat node
```

Then, you can run the test in `darc-js` folder. Run below command in another terminal.

```bash
pnpm run test
```
98 changes: 80 additions & 18 deletions darc-js/src/darcBinary/DARC-test.json

Large diffs are not rendered by default.

30 changes: 29 additions & 1 deletion darc-protocol/contracts/protocol/Opcodes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ enum EnumOpcode {
* @param UINT256_2DARRAY[0] uint256[] tokenClassArray: the array of the token class index to mint tokens
* @param UINT256_2DARRAY[1] uint256[] amountArray: the array of the amount to mint tokens
* @param UINT256_2DARRAY[2] uint256[] priceArray: the price of each token class to mint
* @param UINT256_2DARRAY[3] uint256[1] dividendableFlag: the flag to indicate if the payment is dividendable. 1 for yes (pay for purchase), 0 for no (pay for investment)
* ID:20
*/
BATCH_PAY_TO_MINT_TOKENS,
Expand All @@ -197,6 +198,7 @@ enum EnumOpcode {
* @param UINT256_2DARRAY[0] uint256[] tokenClassArray: the array of the token class index to transfer token from
* @param UINT256_2DARRAY[1] uint256[] amountArray: the array of the amount of the token to transfer
* @param UINT256_2DARRAY[2] uint256[] priceArray: the price of each token class to transfer
* @ param UINT256_2DARRAY[3] uint256[1] dividendableFlag: the flag to indicate if the payment is dividendable. 1 for yes (pay for purchase), 0 for no (pay for investment)
* ID:21
*/
BATCH_PAY_TO_TRANSFER_TOKENS,
Expand Down Expand Up @@ -300,5 +302,31 @@ enum EnumOpcode {
* @notice Execute a program that has been voted and approved
* ID:33
*/
EXECUTE_PROGRAM
EXECUTE_PROGRAM,

/**
* @notice Emergency mode termination. Emergency agents cannot do anything after this operation
* ID:34
*/
END_EMERGENCY,

/**
* @notice Upgrade the contract to a new contract address
* @param ADDRESS_2DARRAY[0][0] The address of the new contract
* ID:35
*/
UPGRADE_TO_ADDRESS,

/**
* @notice Accepting current DARCs to be upgraded from the old contract address
* @param ADDRESS_2DARRAY[0][0] The address of the old contract
* ID:36
*/
CONFIRM_UPGRAED_FROM_ADDRESS,

/**
* @notice Upgrade the contract to the latest version
* ID:37
*/
UPGRADE_TO_THE_LATEST
}
5 changes: 0 additions & 5 deletions darc-protocol/contracts/protocol/Plugin/Plugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ struct VotingRule {
*/
uint256 executionPendingDurationInSeconds;

/**
* the forced stop during the voting duration is allowed or not
*/
bool isForcedStopAllowed;

/**
* the voting policy is enabled or not
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ contract VotingMachine is MachineStateManager {
require(votes.length == votingItems[latestVotingItemIndex].votingRuleIndices.length,
"the number of votes does not match the number of policies");

// set the boolean voted to true
voted[voter][latestVotingItemIndex] = true;

// update the voted status
bool bIsValid = false;
for (uint256 i = 0; i < votes.length; i++) {
Expand All @@ -194,8 +197,7 @@ contract VotingMachine is MachineStateManager {
}
}

// set the boolean voted to true
voted[voter][latestVotingItemIndex] = true;

}

/**
Expand Down

0 comments on commit 5e24c0c

Please sign in to comment.