Skip to content

Commit

Permalink
feat: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
AbigailDeng committed Dec 3, 2024
2 parents 9247f33 + 4baa831 commit a697ef4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/command/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 10 additions & 1 deletion src/command/send.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { callCommandParameters, callCommandUsages, strictGlobalOptionValidatorDesc } from '../utils/constants.js';
import CallCommand from './call.js';

/**
Expand All @@ -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
);
}

/**
Expand Down
12 changes: 1 addition & 11 deletions src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down Expand Up @@ -464,7 +455,6 @@ export {
callCommandParameters,
commonGlobalOptionValidatorDesc,
strictGlobalOptionValidatorDesc,
callGlobalOptionValidatorDesc,
blkInfoCommandParameters,
blkInfoCommandUsage,
txResultCommandParameters,
Expand Down

0 comments on commit a697ef4

Please sign in to comment.