diff --git a/src/command/call.js b/src/command/call.js index e1d37d1..f9a7765 100644 --- a/src/command/call.js +++ b/src/command/call.js @@ -2,7 +2,7 @@ import AElf from 'aelf-sdk'; import inquirer from 'inquirer'; import chalk from 'chalk'; import BaseSubCommand from './baseSubCommand.js'; -import { callCommandUsages, callCommandParameters, callGlobalOptionValidatorDesc } from '../utils/constants.js'; +import { callCommandUsages, callCommandParameters, commonGlobalOptionValidatorDesc } from '../utils/constants.js'; import { getContractMethods, getContractInstance, @@ -38,7 +38,7 @@ class CallCommand extends BaseSubCommand { parameters = callCommandParameters, usage = callCommandUsages, options = [], - validatorDesc = callGlobalOptionValidatorDesc + validatorDesc = commonGlobalOptionValidatorDesc ) { super(name, parameters, description, options, usage, rc, validatorDesc); } diff --git a/src/command/send.js b/src/command/send.js index 02c4f62..ce543bb 100644 --- a/src/command/send.js +++ b/src/command/send.js @@ -1,3 +1,4 @@ +import { callCommandParameters, callCommandUsages, strictGlobalOptionValidatorDesc } from '../utils/constants.js'; import CallCommand from './call.js'; /** @@ -9,7 +10,15 @@ class SendCommand extends CallCommand { * @param {Registry} rc - The registry instance. */ constructor(rc) { - super(rc, 'send', 'Execute a method on a contract.'); + super( + rc, + 'send', + 'Execute a method on a contract.', + callCommandParameters, + callCommandUsages, + [], + strictGlobalOptionValidatorDesc + ); } /** diff --git a/src/utils/constants.js b/src/utils/constants.js index 8e71d9a..8304b45 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -381,21 +381,12 @@ const commonGlobalOptionValidatorDesc = { const strictGlobalOptionValidatorDesc = /**@type {CommonGlobalOptionValidatorDesc}*/ ({}); -// @ts-ignore -Object.entries(commonGlobalOptionValidatorDesc).forEach((/** @type {[CommonGlobalOptionKey, any]} */ [key, value]) => { - strictGlobalOptionValidatorDesc[key] = { - ...value - // required: true - }; -}); - -const callGlobalOptionValidatorDesc = /**@type {CommonGlobalOptionValidatorDesc}*/ ({}); // @ts-ignore Object.entries(commonGlobalOptionValidatorDesc).forEach((/** @type {[CommonGlobalOptionKey, any]} */ [key, value]) => { if (key === 'account' || key === 'password') { strictGlobalOptionValidatorDesc[key] = { ...value, - required: false + required: true }; } else { strictGlobalOptionValidatorDesc[key] = { @@ -464,7 +455,6 @@ export { callCommandParameters, commonGlobalOptionValidatorDesc, strictGlobalOptionValidatorDesc, - callGlobalOptionValidatorDesc, blkInfoCommandParameters, blkInfoCommandUsage, txResultCommandParameters,