diff --git a/contracts/DriipSettlementDisputeByPayment.sol b/contracts/DriipSettlementDisputeByPayment.sol index ea2eeec9..aa0181ad 100644 --- a/contracts/DriipSettlementDisputeByPayment.sol +++ b/contracts/DriipSettlementDisputeByPayment.sol @@ -128,7 +128,7 @@ BalanceTrackable, FraudChallengable, Servable { payment.sender.nonce, payment.seals.operator.hash, PaymentTypesLib.PAYMENT_KIND() ); - // Cancel dependent null settlement challenge if existent + // Terminate dependent null settlement challenge proposal if existent nullSettlementChallengeState.terminateProposal(wallet, payment.currency); // Emit event diff --git a/contracts/DriipSettlementDisputeByTrade.sol b/contracts/DriipSettlementDisputeByTrade.sol index 559fd660..57a90c63 100644 --- a/contracts/DriipSettlementDisputeByTrade.sol +++ b/contracts/DriipSettlementDisputeByTrade.sol @@ -25,6 +25,7 @@ import {NahmiiTypesLib} from "./NahmiiTypesLib.sol"; import {TradeTypesLib} from "./TradeTypesLib.sol"; import {SettlementChallengeTypesLib} from "./SettlementChallengeTypesLib.sol"; import {DriipSettlementChallengeState} from "./DriipSettlementChallengeState.sol"; +import {NullSettlementChallengeState} from "./NullSettlementChallengeState.sol"; /** * @title DriipSettlementDisputeByTrade @@ -47,12 +48,15 @@ FraudChallengable, CancelOrdersChallengable, Servable { // Variables // ----------------------------------------------------------------------------------------------------------------- DriipSettlementChallengeState public driipSettlementChallengeState; + NullSettlementChallengeState public nullSettlementChallengeState; // // Events // ----------------------------------------------------------------------------------------------------------------- event SetDriipSettlementChallengeStateEvent(DriipSettlementChallengeState oldDriipSettlementChallengeState, DriipSettlementChallengeState newDriipSettlementChallengeState); + event SetNullSettlementChallengeStateEvent(NullSettlementChallengeState oldNullSettlementChallengeState, + NullSettlementChallengeState newNullSettlementChallengeState); event ChallengeByOrderEvent(uint256 nonce, TradeTypesLib.Order order, address challenger); event UnchallengeOrderCandidateByTradeEvent(uint256 nonce, TradeTypesLib.Order order, TradeTypesLib.Trade trade, address unchallenger); @@ -76,6 +80,17 @@ FraudChallengable, CancelOrdersChallengable, Servable { emit SetDriipSettlementChallengeStateEvent(oldDriipSettlementChallengeState, driipSettlementChallengeState); } + /// @notice Set the null settlement state contract + /// @param newNullSettlementChallengeState The (address of) NullSettlementChallengeState contract instance + function setNullSettlementChallengeState(NullSettlementChallengeState newNullSettlementChallengeState) public + onlyDeployer + notNullAddress(address(newNullSettlementChallengeState)) + { + NullSettlementChallengeState oldNullSettlementChallengeState = nullSettlementChallengeState; + nullSettlementChallengeState = newNullSettlementChallengeState; + emit SetNullSettlementChallengeStateEvent(oldNullSettlementChallengeState, nullSettlementChallengeState); + } + /// @notice Challenge the driip settlement by providing order candidate /// @param order The order candidate that challenges the challenged driip /// @param challenger The address of the challenger @@ -126,6 +141,9 @@ FraudChallengable, CancelOrdersChallengable, Servable { order.nonce, order.seals.operator.hash, TradeTypesLib.ORDER_KIND() ); + // Terminate dependent null settlement challenge proposal if existent + nullSettlementChallengeState.terminateProposal(order.wallet, currency); + // Emit event emit ChallengeByOrderEvent( driipSettlementChallengeState.proposalNonce(order.wallet, currency), order, challenger @@ -259,6 +277,9 @@ FraudChallengable, CancelOrdersChallengable, Servable { nonce, trade.seal.hash, TradeTypesLib.TRADE_KIND() ); + // Terminate dependent null settlement challenge proposal if existent + nullSettlementChallengeState.terminateProposal(wallet, currency); + // Emit event emit ChallengeByTradeEvent( wallet, driipSettlementChallengeState.proposalNonce(wallet, currency), trade, challenger diff --git a/migrations/5_bulk_of_contracts.js b/migrations/5_bulk_of_contracts.js index d85076a0..4fabecca 100644 --- a/migrations/5_bulk_of_contracts.js +++ b/migrations/5_bulk_of_contracts.js @@ -559,6 +559,7 @@ module.exports = (deployer, network, accounts) => { await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); await instance.setCancelOrdersChallenge(addressStorage.get('CancelOrdersChallenge')); await instance.setDriipSettlementChallengeState(addressStorage.get('DriipSettlementChallengeState')); + await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.CHALLENGE_BY_ORDER_ACTION.call()); await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.UNCHALLENGE_ORDER_CANDIDATE_BY_TRADE_ACTION.call()); @@ -853,17 +854,17 @@ module.exports = (deployer, network, accounts) => { } else if (network.startsWith('mainnet')) { addressStorage.set('BalanceTracker', '0xbc1bcc29edf605095bf4fe7a953b7c115ecc8cad'); - // await execDeploy(ctl, 'CancelOrdersChallenge', '', CancelOrdersChallenge); + await execDeploy(ctl, 'CancelOrdersChallenge', '', CancelOrdersChallenge); addressStorage.set('ClientFund', '0xcc8d82f6ba952966e63001c7b320eef2ae729099'); await execDeploy(ctl, 'CommunityVote', '', CommunityVote); await execDeploy(ctl, 'Configuration', '', Configuration); await execDeploy(ctl, 'DriipSettlementByPayment', '', DriipSettlementByPayment); - // await execDeploy(ctl, 'DriipSettlementByTrade', '', DriipSettlementByTrade); + await execDeploy(ctl, 'DriipSettlementByTrade', '', DriipSettlementByTrade); await execDeploy(ctl, 'DriipSettlementChallengeByPayment', '', DriipSettlementChallengeByPayment); - // await execDeploy(ctl, 'DriipSettlementChallengeByTrade', '', DriipSettlementChallengeByTrade); + await execDeploy(ctl, 'DriipSettlementChallengeByTrade', '', DriipSettlementChallengeByTrade); addressStorage.set('DriipSettlementChallengeState', '0x9b5b87ad686a55b59354f88a6a048c03b0495b62'); await execDeploy(ctl, 'DriipSettlementDisputeByPayment', '', DriipSettlementDisputeByPayment); - // await execDeploy(ctl, 'DriipSettlementDisputeByTrade', '', DriipSettlementDisputeByTrade); + await execDeploy(ctl, 'DriipSettlementDisputeByTrade', '', DriipSettlementDisputeByTrade); await execDeploy(ctl, 'DriipSettlementState', '', DriipSettlementState); await execDeploy(ctl, 'ERC20TransferController', '', ERC20TransferController); await execDeploy(ctl, 'ERC721TransferController', '', ERC721TransferController); @@ -879,10 +880,10 @@ module.exports = (deployer, network, accounts) => { // await execDeploy(ctl, 'FraudChallengeByTradeSucceedingPayment', '', FraudChallengeByTradeSucceedingPayment); await execDeploy(ctl, 'NullSettlement', '', NullSettlement); await execDeploy(ctl, 'NullSettlementChallengeByPayment', '', NullSettlementChallengeByPayment); - // await execDeploy(ctl, 'NullSettlementChallengeByTrade', '', NullSettlementChallengeByTrade); + await execDeploy(ctl, 'NullSettlementChallengeByTrade', '', NullSettlementChallengeByTrade); addressStorage.set('NullSettlementChallengeState', '0xb4379689bc570e5e2a415fcc700fd562cec0f123'); await execDeploy(ctl, 'NullSettlementDisputeByPayment', '', NullSettlementDisputeByPayment); - // await execDeploy(ctl, 'NullSettlementDisputeByTrade', '', NullSettlementDisputeByTrade); + await execDeploy(ctl, 'NullSettlementDisputeByTrade', '', NullSettlementDisputeByTrade); await execDeploy(ctl, 'NullSettlementState', '', NullSettlementState); await execDeploy(ctl, 'PartnerBenefactor', '', PartnerBenefactor); await execDeploy(ctl, 'PaymentHasher', '', PaymentHasher); @@ -917,8 +918,8 @@ module.exports = (deployer, network, accounts) => { // await instance.registerBeneficiary(addressStorage.get('PartnerFund')); await instance.registerService(addressStorage.get('DriipSettlementByPayment')); await instance.authorizeInitialService(addressStorage.get('DriipSettlementByPayment')); - // await instance.registerService(addressStorage.get('DriipSettlementByTrade')); - // await instance.authorizeInitialService(addressStorage.get('DriipSettlementByTrade')); + await instance.registerService(addressStorage.get('DriipSettlementByTrade')); + await instance.authorizeInitialService(addressStorage.get('DriipSettlementByTrade')); await instance.registerService(addressStorage.get('NullSettlement')); await instance.authorizeInitialService(addressStorage.get('NullSettlement')); // await instance.disableInitialServiceAuthorization(); @@ -968,14 +969,14 @@ module.exports = (deployer, network, accounts) => { await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByPayment'), await instance.DISQUALIFY_PROPOSAL_ACTION.call()); await instance.registerService(addressStorage.get('DriipSettlementByPayment')); await instance.enableServiceAction(addressStorage.get('DriipSettlementByPayment'), await instance.TERMINATE_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.INITIATE_PROPOSAL_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.DISQUALIFY_PROPOSAL_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.QUALIFY_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.INITIATE_PROPOSAL_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.DISQUALIFY_PROPOSAL_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.QUALIFY_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); instance = await DriipSettlementChallengeByPayment.at(addressStorage.get('DriipSettlementChallengeByPayment')); await instance.setValidator(addressStorage.get('Validator')); @@ -1009,18 +1010,19 @@ module.exports = (deployer, network, accounts) => { await instance.registerService(addressStorage.get('DriipSettlementChallengeByPayment')); await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByPayment'), await instance.CHALLENGE_BY_PAYMENT_ACTION.call()); - // instance = await DriipSettlementDisputeByTrade.at(addressStorage.get('DriipSettlementDisputeByTrade')); - // await instance.setConfiguration(addressStorage.get('Configuration')); - // await instance.setValidator(addressStorage.get('ValidatorV2')); - // await instance.setSecurityBond(addressStorage.get('SecurityBond')); - // await instance.setWalletLocker(addressStorage.get('WalletLocker')); - // await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); - // await instance.setCancelOrdersChallenge(addressStorage.get('CancelOrdersChallenge')); - // await instance.setDriipSettlementChallengeState(addressStorage.get('DriipSettlementChallengeState')); - // await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.CHALLENGE_BY_ORDER_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.UNCHALLENGE_ORDER_CANDIDATE_BY_TRADE_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.CHALLENGE_BY_TRADE_ACTION.call()); + instance = await DriipSettlementDisputeByTrade.at(addressStorage.get('DriipSettlementDisputeByTrade')); + await instance.setConfiguration(addressStorage.get('Configuration')); + await instance.setValidator(addressStorage.get('ValidatorV2')); + await instance.setSecurityBond(addressStorage.get('SecurityBond')); + await instance.setWalletLocker(addressStorage.get('WalletLocker')); + await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); + await instance.setCancelOrdersChallenge(addressStorage.get('CancelOrdersChallenge')); + await instance.setDriipSettlementChallengeState(addressStorage.get('DriipSettlementChallengeState')); + await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); + await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.CHALLENGE_BY_ORDER_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.UNCHALLENGE_ORDER_CANDIDATE_BY_TRADE_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.CHALLENGE_BY_TRADE_ACTION.call()); instance = await DriipSettlementState.at(addressStorage.get('DriipSettlementState')); await instance.setCommunityVote(addressStorage.get('CommunityVote')); @@ -1029,11 +1031,11 @@ module.exports = (deployer, network, accounts) => { await instance.enableServiceAction(addressStorage.get('DriipSettlementByPayment'), await instance.SET_SETTLEMENT_ROLE_DONE_ACTION.call()); await instance.enableServiceAction(addressStorage.get('DriipSettlementByPayment'), await instance.SET_MAX_NONCE_ACTION.call()); await instance.enableServiceAction(addressStorage.get('DriipSettlementByPayment'), await instance.SET_FEE_TOTAL_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.INIT_SETTLEMENT_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.SET_SETTLEMENT_ROLE_DONE_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.SET_MAX_NONCE_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.SET_FEE_TOTAL_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.INIT_SETTLEMENT_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.SET_SETTLEMENT_ROLE_DONE_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.SET_MAX_NONCE_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementByTrade'), await instance.SET_FEE_TOTAL_ACTION.call()); instance = await DriipSettlementByPayment.at(addressStorage.get('DriipSettlementByPayment')); await instance.setClientFund(addressStorage.get('ClientFund')); @@ -1047,17 +1049,17 @@ module.exports = (deployer, network, accounts) => { await instance.setRevenueFund(addressStorage.get('RevenueFund1')); // await instance.setPartnerBenefactor(addressStorage.get('PartnerBenefactor')); - // instance = await DriipSettlementByTrade.at(addressStorage.get('DriipSettlementByTrade')); - // await instance.setClientFund(addressStorage.get('ClientFund')); - // await instance.setValidator(addressStorage.get('ValidatorV2')); - // await instance.setCommunityVote(addressStorage.get('CommunityVote')); - // await instance.setConfiguration(addressStorage.get('Configuration')); - // await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); - // await instance.setWalletLocker(addressStorage.get('WalletLocker')); - // await instance.setDriipSettlementChallengeState(addressStorage.get('DriipSettlementChallengeState')); - // await instance.setDriipSettlementState(addressStorage.get('DriipSettlementState')); - // await instance.setRevenueFund(addressStorage.get('RevenueFund1')); - // await instance.setPartnerFund(addressStorage.get('PartnerFund')); + instance = await DriipSettlementByTrade.at(addressStorage.get('DriipSettlementByTrade')); + await instance.setClientFund(addressStorage.get('ClientFund')); + await instance.setValidator(addressStorage.get('ValidatorV2')); + await instance.setCommunityVote(addressStorage.get('CommunityVote')); + await instance.setConfiguration(addressStorage.get('Configuration')); + await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); + await instance.setWalletLocker(addressStorage.get('WalletLocker')); + await instance.setDriipSettlementChallengeState(addressStorage.get('DriipSettlementChallengeState')); + await instance.setDriipSettlementState(addressStorage.get('DriipSettlementState')); + await instance.setRevenueFund(addressStorage.get('RevenueFund1')); + // await instance.setPartnerBenefactor(addressStorage.get('PartnerBenefactor')); instance = await NullSettlementChallengeState.at(addressStorage.get('NullSettlementChallengeState')); await instance.setConfiguration(addressStorage.get('Configuration')); @@ -1073,15 +1075,15 @@ module.exports = (deployer, network, accounts) => { await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByPayment'), await instance.TERMINATE_PROPOSAL_ACTION.call()); await instance.registerService(addressStorage.get('DriipSettlementDisputeByPayment')); await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByPayment'), await instance.TERMINATE_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('NullSettlementChallengeByTrade')); - // await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.INITIATE_PROPOSAL_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('NullSettlementDisputeByTrade')); - // await instance.enableServiceAction(addressStorage.get('NullSettlementDisputeByTrade'), await instance.DISQUALIFY_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('NullSettlementChallengeByTrade')); + await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.INITIATE_PROPOSAL_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('NullSettlementDisputeByTrade')); + await instance.enableServiceAction(addressStorage.get('NullSettlementDisputeByTrade'), await instance.DISQUALIFY_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementChallengeByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementChallengeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.TERMINATE_PROPOSAL_ACTION.call()); instance = await NullSettlementChallengeByPayment.at(addressStorage.get('NullSettlementChallengeByPayment')); await instance.setConfiguration(addressStorage.get('Configuration')); @@ -1091,13 +1093,13 @@ module.exports = (deployer, network, accounts) => { await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); await instance.setDriipSettlementChallengeState(addressStorage.get('DriipSettlementChallengeState')); - // instance = await NullSettlementChallengeByTrade.at(addressStorage.get('NullSettlementChallengeByTrade')); - // await instance.setConfiguration(addressStorage.get('Configuration')); - // await instance.setBalanceTracker(addressStorage.get('BalanceTracker')); - // await instance.setWalletLocker(addressStorage.get('WalletLocker')); - // await instance.setNullSettlementDisputeByTrade(addressStorage.get('NullSettlementDisputeByTrade')); - // await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); - // await instance.setNullSettlementState(addressStorage.get('NullSettlementState')); + instance = await NullSettlementChallengeByTrade.at(addressStorage.get('NullSettlementChallengeByTrade')); + await instance.setConfiguration(addressStorage.get('Configuration')); + await instance.setBalanceTracker(addressStorage.get('BalanceTracker')); + await instance.setWalletLocker(addressStorage.get('WalletLocker')); + await instance.setNullSettlementDisputeByTrade(addressStorage.get('NullSettlementDisputeByTrade')); + await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); + await instance.setNullSettlementState(addressStorage.get('NullSettlementState')); instance = await NullSettlementDisputeByPayment.at(addressStorage.get('NullSettlementDisputeByPayment')); await instance.setConfiguration(addressStorage.get('Configuration')); @@ -1110,17 +1112,17 @@ module.exports = (deployer, network, accounts) => { await instance.registerService(addressStorage.get('NullSettlementChallengeByPayment')); await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByPayment'), await instance.CHALLENGE_BY_PAYMENT_ACTION.call()); - // instance = await NullSettlementDisputeByTrade.at(addressStorage.get('NullSettlementDisputeByTrade')); - // await instance.setConfiguration(addressStorage.get('Configuration')); - // await instance.setValidator(addressStorage.get('ValidatorV2')); - // await instance.setSecurityBond(addressStorage.get('SecurityBond')); - // await instance.setWalletLocker(addressStorage.get('WalletLocker')); - // await instance.setCancelOrdersChallenge(addressStorage.get('CancelOrdersChallenge')); - // await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); - // await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); - // await instance.registerService(addressStorage.get('NullSettlementChallengeByTrade')); - // await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.CHALLENGE_BY_ORDER_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.CHALLENGE_BY_TRADE_ACTION.call()); + instance = await NullSettlementDisputeByTrade.at(addressStorage.get('NullSettlementDisputeByTrade')); + await instance.setConfiguration(addressStorage.get('Configuration')); + await instance.setValidator(addressStorage.get('ValidatorV2')); + await instance.setSecurityBond(addressStorage.get('SecurityBond')); + await instance.setWalletLocker(addressStorage.get('WalletLocker')); + await instance.setCancelOrdersChallenge(addressStorage.get('CancelOrdersChallenge')); + await instance.setFraudChallenge(addressStorage.get('FraudChallenge')); + await instance.setNullSettlementChallengeState(addressStorage.get('NullSettlementChallengeState')); + await instance.registerService(addressStorage.get('NullSettlementChallengeByTrade')); + await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.CHALLENGE_BY_ORDER_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('NullSettlementChallengeByTrade'), await instance.CHALLENGE_BY_TRADE_ACTION.call()); instance = await NullSettlementState.at(addressStorage.get('NullSettlementState')); await instance.setCommunityVote(addressStorage.get('CommunityVote')); @@ -1243,12 +1245,12 @@ module.exports = (deployer, network, accounts) => { await instance.enableServiceAction(addressStorage.get('FraudChallengeByPayment'), await instance.REWARD_ACTION.call()); await instance.registerService(addressStorage.get('FraudChallengeBySuccessivePayments')); await instance.enableServiceAction(addressStorage.get('FraudChallengeBySuccessivePayments'), await instance.REWARD_ACTION.call()); - // await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.REWARD_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.DEPRIVE_ACTION.call()); - // await instance.registerService(addressStorage.get('NullSettlementDisputeByTrade')); - // await instance.enableServiceAction(addressStorage.get('NullSettlementDisputeByTrade'), await instance.REWARD_ACTION.call()); - // await instance.enableServiceAction(addressStorage.get('NullSettlementDisputeByTrade'), await instance.DEPRIVE_ACTION.call()); + await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); + await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.REWARD_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('DriipSettlementDisputeByTrade'), await instance.DEPRIVE_ACTION.call()); + await instance.registerService(addressStorage.get('NullSettlementDisputeByTrade')); + await instance.enableServiceAction(addressStorage.get('NullSettlementDisputeByTrade'), await instance.REWARD_ACTION.call()); + await instance.enableServiceAction(addressStorage.get('NullSettlementDisputeByTrade'), await instance.DEPRIVE_ACTION.call()); // await instance.registerService(addressStorage.get('FraudChallengeByTrade')); // await instance.enableServiceAction(addressStorage.get('FraudChallengeByTrade'), await instance.REWARD_ACTION.call()); // await instance.registerService(addressStorage.get('FraudChallengeByOrder')); @@ -1294,10 +1296,10 @@ module.exports = (deployer, network, accounts) => { await instance.authorizeInitialService(addressStorage.get('FraudChallengeByPayment')); await instance.registerService(addressStorage.get('FraudChallengeBySuccessivePayments')); await instance.authorizeInitialService(addressStorage.get('FraudChallengeBySuccessivePayments')); - // await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); - // await instance.authorizeInitialService(addressStorage.get('DriipSettlementDisputeByTrade')); - // await instance.registerService(addressStorage.get('NullSettlementDisputeByTrade')); - // await instance.authorizeInitialService(addressStorage.get('NullSettlementDisputeByTrade')); + await instance.registerService(addressStorage.get('DriipSettlementDisputeByTrade')); + await instance.authorizeInitialService(addressStorage.get('DriipSettlementDisputeByTrade')); + await instance.registerService(addressStorage.get('NullSettlementDisputeByTrade')); + await instance.authorizeInitialService(addressStorage.get('NullSettlementDisputeByTrade')); // await instance.registerService(addressStorage.get('FraudChallengeByPaymentSucceedingTrade')); // await instance.authorizeInitialService(addressStorage.get('FraudChallengeByPaymentSucceedingTrade')); // await instance.registerService(addressStorage.get('FraudChallengeBySuccessiveTrades')); diff --git a/test/scenarios/DriipSettlementDisputeByTrade.js b/test/scenarios/DriipSettlementDisputeByTrade.js index ef21fcad..dfdccb71 100644 --- a/test/scenarios/DriipSettlementDisputeByTrade.js +++ b/test/scenarios/DriipSettlementDisputeByTrade.js @@ -6,6 +6,7 @@ const mocks = require('../mocks'); const DriipSettlementDisputeByTrade = artifacts.require('DriipSettlementDisputeByTrade'); const SignerManager = artifacts.require('SignerManager'); const MockedDriipSettlementChallengeState = artifacts.require('MockedDriipSettlementChallengeState'); +const MockedNullSettlementChallengeState = artifacts.require('MockedNullSettlementChallengeState'); const MockedConfiguration = artifacts.require('MockedConfiguration'); const MockedFraudChallenge = artifacts.require('MockedFraudChallenge'); const MockedCancelOrdersChallenge = artifacts.require('MockedCancelOrdersChallenge'); @@ -26,6 +27,7 @@ module.exports = (glob) => { let web3SecurityBond, ethersSecurityBond; let web3WalletLocker, ethersWalletLocker; let web3DriipSettlementChallengeState, ethersDriipSettlementChallengeState; + let web3NullSettlementChallengeState, ethersNullSettlementChallengeState; let web3FraudChallenge, ethersFraudChallenge; let web3CancelOrdersChallenge, ethersCancelOrdersChallenge; let provider; @@ -37,6 +39,8 @@ module.exports = (glob) => { web3DriipSettlementChallengeState = await MockedDriipSettlementChallengeState.new(glob.owner); ethersDriipSettlementChallengeState = new Contract(web3DriipSettlementChallengeState.address, MockedDriipSettlementChallengeState.abi, glob.signer_owner); + web3NullSettlementChallengeState = await MockedNullSettlementChallengeState.new(glob.owner); + ethersNullSettlementChallengeState = new Contract(web3NullSettlementChallengeState.address, MockedNullSettlementChallengeState.abi, glob.signer_owner); web3Configuration = await MockedConfiguration.new(glob.owner); ethersConfiguration = new Contract(web3Configuration.address, MockedConfiguration.abi, glob.signer_owner); web3Validator = await MockedValidator.new(glob.owner, web3SignerManager.address); @@ -67,6 +71,8 @@ module.exports = (glob) => { await ethersDriipSettlementDisputeByTrade.setFraudChallenge(ethersFraudChallenge.address); await ethersDriipSettlementDisputeByTrade.setCancelOrdersChallenge(ethersCancelOrdersChallenge.address); await ethersDriipSettlementDisputeByTrade.setDriipSettlementChallengeState(ethersDriipSettlementChallengeState.address); + await ethersDriipSettlementDisputeByTrade.setNullSettlementChallengeState(ethersNullSettlementChallengeState.address); + }); describe('constructor', () => { @@ -322,6 +328,7 @@ module.exports = (glob) => { await web3FraudChallenge._reset(); await web3CancelOrdersChallenge._reset(); await web3DriipSettlementChallengeState._reset({gasLimit: 1e6}); + await web3NullSettlementChallengeState._reset({gasLimit: 1e6}); await web3SecurityBond._reset(); await web3WalletLocker._reset(); @@ -546,6 +553,15 @@ module.exports = (glob) => { (await ethersSecurityBond._fractionalRewardsCount()) ._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(order.wallet); + nscProposal.currency.ct.should.equal(order.placement.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -608,6 +624,15 @@ module.exports = (glob) => { (await ethersSecurityBond._fractionalRewardsCount()) ._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(order.wallet); + nscProposal.currency.ct.should.equal(order.placement.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -671,6 +696,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(order.placement.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(1000); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(order.wallet); + nscProposal.currency.ct.should.equal(order.placement.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -723,6 +757,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(order.placement.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(1000); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(order.wallet); + nscProposal.currency.ct.should.equal(order.placement.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); }); @@ -796,6 +839,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(order.placement.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(1000); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(order.wallet); + nscProposal.currency.ct.should.equal(order.placement.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -851,6 +903,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(order.placement.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(1000); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(order.wallet); + nscProposal.currency.ct.should.equal(order.placement.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(order.placement.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); }); @@ -1278,6 +1339,7 @@ module.exports = (glob) => { await web3FraudChallenge._reset(); await web3CancelOrdersChallenge._reset(); await web3DriipSettlementChallengeState._reset({gasLimit: 1e6}); + await web3NullSettlementChallengeState._reset({gasLimit: 1e6}); await web3SecurityBond._reset(); await web3WalletLocker._reset(); @@ -1539,6 +1601,15 @@ module.exports = (glob) => { (await ethersSecurityBond._fractionalRewardsCount()) ._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(trade.buyer.wallet); + nscProposal.currency.ct.should.equal(trade.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -1601,6 +1672,15 @@ module.exports = (glob) => { (await ethersSecurityBond._fractionalRewardsCount()) ._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(trade.buyer.wallet); + nscProposal.currency.ct.should.equal(trade.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -1663,6 +1743,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(trade.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(trade.buyer.wallet); + nscProposal.currency.ct.should.equal(trade.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -1714,6 +1803,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(trade.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(trade.buyer.wallet); + nscProposal.currency.ct.should.equal(trade.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); }); @@ -1786,6 +1884,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(trade.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(trade.buyer.wallet); + nscProposal.currency.ct.should.equal(trade.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); @@ -1840,6 +1947,15 @@ module.exports = (glob) => { progressiveReward.currency.ct.should.equal(trade.currencies.conjugate.ct); progressiveReward.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); progressiveReward.unlockTime._bn.should.eq.BN(0); + + (await ethersNullSettlementChallengeState._terminateProposalsCount()) + ._bn.should.eq.BN(1); + + const nscProposal = await ethersNullSettlementChallengeState._proposals(0); + nscProposal.wallet.should.equal(trade.buyer.wallet); + nscProposal.currency.ct.should.equal(trade.currencies.conjugate.ct); + nscProposal.currency.id._bn.should.eq.BN(trade.currencies.conjugate.id._bn); + nscProposal.terminated.should.be.true; }); }); });