(hasGlobalDailyRestriction, hasGlobalCustomRestriction)
| 1667 | } |
| 1668 | |
| 1669 | async function changeDefaultRestrictions(hasGlobalDailyRestriction, hasGlobalCustomRestriction) { |
| 1670 | let options = []; |
| 1671 | if (!hasGlobalDailyRestriction) { |
| 1672 | options.push('Add global daily restriction'); |
| 1673 | } else { |
| 1674 | options.push('Modify global daily restriction', 'Remove global daily restriction'); |
| 1675 | } |
| 1676 | |
| 1677 | if (!hasGlobalCustomRestriction) { |
| 1678 | options.push('Add global custom restriction'); |
| 1679 | } else { |
| 1680 | options.push('Modify global custom restriction', 'Remove global custom restriction'); |
| 1681 | } |
| 1682 | |
| 1683 | let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'RETURN' }); |
| 1684 | let optionSelected = index !== -1 ? options[index] : 'RETURN'; |
| 1685 | console.log('Selected:', optionSelected, '\n'); |
| 1686 | switch (optionSelected) { |
| 1687 | case 'Add global daily restriction': |
| 1688 | let globalDailyRestrictoToAdd = inputRestrictionData(true); |
| 1689 | let addGlobalDailyRestrictionAction = currentTransferManager.methods.addDefaultDailyRestriction( |
| 1690 | globalDailyRestrictoToAdd.allowedTokens, |
| 1691 | globalDailyRestrictoToAdd.startTime, |
| 1692 | globalDailyRestrictoToAdd.endTime, |
| 1693 | globalDailyRestrictoToAdd.restrictionType |
| 1694 | ); |
| 1695 | let addGlobalDailyRestrictionReceipt = await common.sendTransaction(addGlobalDailyRestrictionAction); |
| 1696 | let addGlobalDailyRestrictionEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, addGlobalDailyRestrictionReceipt.logs, 'AddDefaultDailyRestriction'); |
| 1697 | console.log(chalk.green(`Global daily restriction has been added successfully!`)); |
| 1698 | break; |
| 1699 | case 'Modify global daily restriction': |
| 1700 | let globalDailyRestrictoToModify = inputRestrictionData(true); |
| 1701 | let modifyGlobalDailyRestrictionAction = currentTransferManager.methods.modifyDefaultDailyRestriction( |
| 1702 | globalDailyRestrictoToModify.allowedTokens, |
| 1703 | globalDailyRestrictoToModify.startTime, |
| 1704 | globalDailyRestrictoToModify.endTime, |
| 1705 | globalDailyRestrictoToModify.restrictionType |
| 1706 | ); |
| 1707 | let modifyGlobalDailyRestrictionReceipt = await common.sendTransaction(modifyGlobalDailyRestrictionAction); |
| 1708 | let modifyGlobalDailyRestrictionEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyGlobalDailyRestrictionReceipt.logs, 'ModifyDefaultDailyRestriction'); |
| 1709 | console.log(chalk.green(`Global daily restriction has been modified successfully!`)); |
| 1710 | break; |
| 1711 | case 'Remove global daily restriction': |
| 1712 | let removeGlobalDailyRestrictionAction = currentTransferManager.methods.removeDefaultDailyRestriction(); |
| 1713 | let removeGlobalDailyRestrictionReceipt = await common.sendTransaction(removeGlobalDailyRestrictionAction); |
| 1714 | let removeGlobalDailyRestrictionEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, removeGlobalDailyRestrictionReceipt.logs, 'DefaultDailyRestrictionRemoved'); |
| 1715 | console.log(chalk.green(`Global daily restriction has been removed successfully!`)); |
| 1716 | break; |
| 1717 | case 'Add global custom restriction': |
| 1718 | let globalCustomRestrictoToAdd = inputRestrictionData(false); |
| 1719 | let addGlobalCustomRestrictionAction = currentTransferManager.methods.addDefaultRestriction( |
| 1720 | globalCustomRestrictoToAdd.allowedTokens, |
| 1721 | globalCustomRestrictoToAdd.startTime, |
| 1722 | globalCustomRestrictoToAdd.rollingPeriodInDays, |
| 1723 | globalCustomRestrictoToAdd.endTime, |
| 1724 | globalCustomRestrictoToAdd.restrictionType |
| 1725 | ); |
| 1726 | let addGlobalCustomRestrictionReceipt = await common.sendTransaction(addGlobalCustomRestrictionAction); |
no test coverage detected