Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lidangzzz committed May 24, 2023
1 parent dab7f76 commit e57228b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ contract MoneyInstructions is MachineStateManager {
function op_OFFER_DIVIDENDS(Operation memory operation, bool bIsSandbox) internal {
if (bIsSandbox) {

// make sure that the dividend per myriad per transaction is less than 1000
require(sandboxMachineState.machineStateParameters.dividendPermyriadPerTransaction < 1000,
ErrorMsg.By(15));

// make sure that cycle counter is less than the threashold
require(sandboxMachineState.machineStateParameters.dividendCycleCounter <
sandboxMachineState.machineStateParameters.dividendCycleOfTransactions, ErrorMsg.By(16));

// 1. calculate the total amount of dividends to be offered
bool bIsValid = true;
uint256 totalDividends = 0;
Expand Down Expand Up @@ -238,9 +243,14 @@ contract MoneyInstructions is MachineStateManager {
sandboxMachineState.machineStateParameters.dividendCycleCounter = 0;
}
else {
// make sure that the dividend per myriad per transaction is less than 1000
require(currentMachineState.machineStateParameters.dividendPermyriadPerTransaction < 1000,
ErrorMsg.By(15));

// make sure that cycle counter is less than the threashold
require(currentMachineState.machineStateParameters.dividendCycleCounter <
currentMachineState.machineStateParameters.dividendCycleOfTransactions, ErrorMsg.By(16));

// 1. calculate the total amount of dividends to be offered
bool bIsValid = true;
uint256 totalDividends = 0;
Expand Down
3 changes: 3 additions & 0 deletions darc-protocol/contracts/Utilities/ErrorMsg.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ library ErrorMsg{
else if (val == 15) {
return "Invalid dividend permyriad per transaction. Should be less than 1000";
}
else if (val == 16) {
return "No enough number of transactions for dividends yet";
}
return "Unknown Error";
}
}
6 changes: 3 additions & 3 deletions darc-protocol/test/operationUnitTest/offer_dividends_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("offer_dividends_test", function () {
await darc.initialize();


// create a token class first
// create 3 token class first
await darc.entrance({
programOperatorAddress: programOperatorAddress,
operations: [{
Expand All @@ -49,8 +49,8 @@ describe("offer_dividends_test", function () {
PARAMETER_ARRAY: [],
PLUGIN_ARRAY: [],
UINT256_2DARRAY: [
[BigNumber.from(0), BigNumber.from(1)],
[BigNumber.from(10), BigNumber.from(1)],
[BigNumber.from(1), BigNumber.from(1)],
[BigNumber.from(1), BigNumber.from(10)],
[BigNumber.from(10), BigNumber.from(1)],
],
ADDRESS_2DARRAY: []
Expand Down

0 comments on commit e57228b

Please sign in to comment.