MCPcopy Create free account
hub / github.com/PolymathNetwork/polymath-core / matmAdd

Function matmAdd

CLI/commands/transfer_manager.js:604–634  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

602}
603
604async function matmAdd() {
605 let from = readlineSync.question('Enter the address from which transfers will be approved: ', {
606 limit: function (input) {
607 return web3.utils.isAddress(input);
608 },
609 limitMessage: "Must be a valid address"
610 });
611 let to = readlineSync.question('Enter the address to which transfers will be approved: ', {
612 limit: function (input) {
613 return web3.utils.isAddress(input);
614 },
615 limitMessage: "Must be a valid address"
616 });
617 if (!await getManualApproval(from, to)) {
618 let description = readlineSync.question('Enter the description for the manual approval: ', {
619 limit: function (input) {
620 return input != "" && getBinarySize(input) < 33
621 },
622 limitMessage: "Description is required"
623 });
624 let allowance = readlineSync.question('Enter the amount of tokens which will be approved: ');
625 let oneHourFromNow = Math.floor(Date.now() / 1000 + 3600);
626 let expiryTime = readlineSync.questionInt(`Enter the time (Unix Epoch time) until which the transfer is allowed (1 hour from now = ${oneHourFromNow}): `, { defaultInput: oneHourFromNow });
627 let addManualApprovalAction = currentTransferManager.methods.addManualApproval(from, to, web3.utils.toWei(allowance), expiryTime, web3.utils.fromAscii(description));
628 let addManualApprovalReceipt = await common.sendTransaction(addManualApprovalAction);
629 let addManualApprovalEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, addManualApprovalReceipt.logs, 'AddManualApproval');
630 console.log(chalk.green(`Manual approval has been added successfully!`));
631 } else {
632 console.log(chalk.red(`A manual approval already exists from ${from} to ${to}. Revoke it first if you want to add a new one or modify the existing one.`));
633 }
634}
635
636async function matmManage() {
637

Callers 1

Calls 2

getManualApprovalFunction · 0.85
getBinarySizeFunction · 0.85

Tested by

no test coverage detected