From c270772c8e95276348d3060c65966ff136518d50 Mon Sep 17 00:00:00 2001 From: AbigailDeng Date: Fri, 1 Nov 2024 15:48:00 +0800 Subject: [PATCH] feat: password required --- package.json | 2 +- src/command/call.js | 4 ++-- src/command/send.js | 11 ++++++++++- src/utils/constants.js | 12 +----------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index e937d8b..79944f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aelf-command", - "version": "0.1.51-beta.0", + "version": "0.1.51-beta.1", "description": "A CLI tools for AElf", "main": "src/index.js", "type": "module", diff --git a/src/command/call.js b/src/command/call.js index 00e8843..8674501 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,