From 493405b3d882706c592bf42142e1072aba650dbd Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Tue, 15 Aug 2023 13:43:20 -0300 Subject: [PATCH] fix(cli): fixes in get-logs and deploy commands (#1572) - Fixes get-logs default `from` parameter (setting to zero caused an error) - Fixes arguments to deployer --- yarn-project/aztec-cli/src/index.ts | 10 +++++++--- yarn-project/foundation/src/abi/encoder.test.ts | 6 ++++-- yarn-project/foundation/src/abi/encoder.ts | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/yarn-project/aztec-cli/src/index.ts b/yarn-project/aztec-cli/src/index.ts index c14d23079b0..98c2d3f5fc8 100644 --- a/yarn-project/aztec-cli/src/index.ts +++ b/yarn-project/aztec-cli/src/index.ts @@ -166,8 +166,11 @@ async function main() { ); } + debugLogger(`Input arguments: ${options.args.map((x: any) => `"${x}"`).join(', ')}`); const args = encodeArgs(options.args, constructorAbi!.parameters); - const tx = deployer.deploy(args).send({ contractAddressSalt: salt }); + debugLogger(`Encoded arguments: ${args.join(', ')}`); + const tx = deployer.deploy(...args).send({ contractAddressSalt: salt }); + debugLogger(`Deploy tx sent with hash ${await tx.getTxHash()}`); const deployed = await tx.wait(); log(`\nContract deployed at ${deployed.contractAddress!.toString()}\n`); }); @@ -241,7 +244,7 @@ async function main() { .option('-u, --rpc-url ', 'URL of the Aztec RPC', AZTEC_RPC_HOST || 'http://localhost:8080') .action(async options => { const { from, limit } = options; - const fromBlock = from ? parseInt(from) : 0; + const fromBlock = from ? parseInt(from) : 1; const limitCount = limit ? parseInt(limit) : 100; const client = createAztecRpcClient(options.rpcUrl); @@ -475,6 +478,7 @@ async function main() { } main().catch(err => { - log(`Error thrown: ${err}`); + log(`Error in command execution`); + log(err); process.exit(1); }); diff --git a/yarn-project/foundation/src/abi/encoder.test.ts b/yarn-project/foundation/src/abi/encoder.test.ts index 4261f9b91c6..8922d1e7c94 100644 --- a/yarn-project/foundation/src/abi/encoder.test.ts +++ b/yarn-project/foundation/src/abi/encoder.test.ts @@ -49,7 +49,7 @@ describe('abi/encoder', () => { expect(() => encodeArguments(testFunctionAbi, args)).toThrowError('Cannot convert garbage to a BigInt'); }); - it.only('throws when passing object argument as field', () => { + it('throws when passing object argument as field', () => { const testFunctionAbi: FunctionAbi = { name: 'constructor', functionType: FunctionType.SECRET, @@ -73,6 +73,8 @@ describe('abi/encoder', () => { }, ]; - expect(() => encodeArguments(testFunctionAbi, args)).toThrowError('Argument cannot be serialised to a field'); + expect(() => encodeArguments(testFunctionAbi, args)).toThrowError( + 'Argument for owner cannot be serialised to a field', + ); }); }); diff --git a/yarn-project/foundation/src/abi/encoder.ts b/yarn-project/foundation/src/abi/encoder.ts index e7e3b684fa8..acf0a41aad1 100644 --- a/yarn-project/foundation/src/abi/encoder.ts +++ b/yarn-project/foundation/src/abi/encoder.ts @@ -32,7 +32,7 @@ class ArgumentEncoder { } else if (arg instanceof Fr) { this.flattened.push(arg); } else { - throw new Error('Argument cannot be serialised to a field'); + throw new Error(`Argument for ${name} cannot be serialised to a field`); } } else { throw new Error(`Invalid argument "${arg}" of type ${abiType.kind}`);