diff --git a/yarn-project/cli/src/encoding.ts b/yarn-project/cli/src/encoding.ts index 50a088cc4c5..a118c3b12b1 100644 --- a/yarn-project/cli/src/encoding.ts +++ b/yarn-project/cli/src/encoding.ts @@ -91,7 +91,9 @@ function encodeArg(arg: string, abiType: ABIType, name: string): any { export function encodeArgs(args: any[], params: ABIParameter[]) { if (args.length !== params.length) { throw new Error( - `Invalid number of args provided. Expected: ${params.length}, received: ${args.length}\nReceived args: ${args}`, + `Invalid args provided.\nExpected args: [${params + .map(param => param.name + ': ' + param.type.kind) + .join(', ')}]\nReceived args: ${args.join(', ')}`, ); } return args.map((arg: any, index) => { diff --git a/yarn-project/cli/src/index.ts b/yarn-project/cli/src/index.ts index 71e61409f65..fe38efd4508 100644 --- a/yarn-project/cli/src/index.ts +++ b/yarn-project/cli/src/index.ts @@ -172,11 +172,6 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { const constructor = getAbiFunction(contractAbi, 'constructor'); if (!constructor) throw new Error(`Constructor not found in contract ABI`); - if (constructor.parameters.length !== options.args.length) { - throw new Error( - `Invalid number of args passed (expected ${constructor.parameters.length} but got ${options.args.length})`, - ); - } debugLogger(`Input arguments: ${options.args.map((x: any) => `"${x}"`).join(', ')}`); const args = encodeArgs(options.args, constructorAbi!.parameters); @@ -376,13 +371,6 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { log, ); - const fnAbi = getAbiFunction(contractAbi, functionName); - if (fnAbi.parameters.length !== options.args.length) { - throw Error( - `Invalid number of args passed. Expected ${fnAbi.parameters.length}; Received: ${options.args.length}`, - ); - } - const privateKey = GrumpkinScalar.fromString(stripLeadingHex(options.privateKey)); const client = await createCompatibleClient(options.rpcUrl, debugLogger); diff --git a/yarn-project/cli/src/test/utils.test.ts b/yarn-project/cli/src/test/utils.test.ts index b37ec4fd7dd..3d34a48a217 100644 --- a/yarn-project/cli/src/test/utils.test.ts +++ b/yarn-project/cli/src/test/utils.test.ts @@ -74,9 +74,7 @@ describe('CLI Utils', () => { it('Errors on invalid inputs', () => { // invalid number of args const args1 = [field.toString(), 'false']; - expect(() => encodeArgs(args1, mockContractAbi.functions[1].parameters)).toThrow( - 'Invalid number of args provided. Expected: 5, received: 2', - ); + expect(() => encodeArgs(args1, mockContractAbi.functions[1].parameters)).toThrow('Invalid args provided'); // invalid array length const invalidArray = fieldArray.concat([Fr.random().toString()]);