Skip to content

Commit

Permalink
fix(cli): fixes in get-logs and deploy commands (#1572)
Browse files Browse the repository at this point in the history
- Fixes get-logs default `from` parameter (setting to zero caused an
error)
- Fixes arguments to deployer
  • Loading branch information
spalladino authored Aug 15, 2023
1 parent 35a81c3 commit 493405b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 7 additions & 3 deletions yarn-project/aztec-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
Expand Down Expand Up @@ -241,7 +244,7 @@ async function main() {
.option('-u, --rpc-url <string>', '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);
Expand Down Expand Up @@ -475,6 +478,7 @@ async function main() {
}

main().catch(err => {
log(`Error thrown: ${err}`);
log(`Error in command execution`);
log(err);
process.exit(1);
});
6 changes: 4 additions & 2 deletions yarn-project/foundation/src/abi/encoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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',
);
});
});
2 changes: 1 addition & 1 deletion yarn-project/foundation/src/abi/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down

0 comments on commit 493405b

Please sign in to comment.