diff --git a/yarn-project/cli/src/cmds/pxe/index.ts b/yarn-project/cli/src/cmds/pxe/index.ts index fb86c3ae2a1e..b9a69eca05c8 100644 --- a/yarn-project/cli/src/cmds/pxe/index.ts +++ b/yarn-project/cli/src/cmds/pxe/index.ts @@ -68,8 +68,8 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL '', "A compiled Aztec.nr contract's artifact in JSON format or name of a contract artifact exported by @aztec/noir-contracts.js", ) - .option('--initialize ', 'The contract initializer function to call', 'constructor') - .option('--no-initialize') + .option('--init ', 'The contract initializer function to call', 'constructor') + .option('--no-init', 'Leave the contract uninitialized') .option('-a, --args ', 'Contract constructor arguments', []) .addOption(pxeOption) .option( @@ -88,10 +88,8 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL // `options.wait` is default true. Passing `--no-wait` will set it to false. // https://github.com/tj/commander.js#other-option-types-negatable-boolean-and-booleanvalue .option('--no-wait', 'Skip waiting for the contract to be deployed. Print the hash of deployment transaction') - .option('--class-registration', 'Register the contract class. Only has to be done once') - .option('--no-class-registration', 'Skip registering the contract class') - .option('--public-deployment', 'Deploy the public bytecode of contract') - .option('--no-public-deployment', "Skip deploying the contract's public bytecode"); + .option('--no-class-registration', "Don't register this contract class") + .option('--no-public-deployment', "Don't emit this contract's public bytecode"); addOptions(deployCommand, FeeOpts.getOptions()).action(async (artifactPath, opts) => { const { deploy } = await import('./deploy.js'); const { @@ -103,7 +101,7 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL wait, privateKey, classRegistration, - initialize, + init, publicDeployment, universal, } = opts; @@ -115,10 +113,10 @@ export function injectCommands(program: Command, log: LogFn, debugLogger: DebugL rawArgs, salt, privateKey, - typeof initialize === 'string' ? initialize : undefined, + typeof init === 'string' ? init : undefined, !publicDeployment, !classRegistration, - typeof initialize === 'string' ? false : initialize, + typeof init === 'string' ? false : init, universal, wait, FeeOpts.fromCli(opts, log), diff --git a/yarn-project/cli/src/utils/commands.test.ts b/yarn-project/cli/src/utils/commands.test.ts new file mode 100644 index 000000000000..7b925b0a0077 --- /dev/null +++ b/yarn-project/cli/src/utils/commands.test.ts @@ -0,0 +1,19 @@ +import { Fr } from '@aztec/circuits.js'; + +import { parseFieldFromHexString } from './commands.js'; + +describe('parseFieldFromHexString', () => { + it.each<[string, Fr]>([ + ['0', Fr.ZERO], + ['0x0', Fr.ZERO], + ['0x1', new Fr(1)], + ['0x00', Fr.ZERO], + ['fa', new Fr(0xfa)], + ['123', new Fr(0x0123)], + ['0xff', new Fr(255)], + ['0x0000000000000000000000000000000000000000000000000000000000000003', new Fr(3)], + ['0x00000000000000000000000000000000000000000000000000000000000000003', new Fr(3)], + ])('parses the field %s correctly', (str, expected) => { + expect(parseFieldFromHexString(str)).toEqual(expected); + }); +}); diff --git a/yarn-project/cli/src/utils/commands.ts b/yarn-project/cli/src/utils/commands.ts index d51c79f4fcb7..3c26ae127b2c 100644 --- a/yarn-project/cli/src/utils/commands.ts +++ b/yarn-project/cli/src/utils/commands.ts @@ -138,9 +138,16 @@ export function parseFieldFromHexString(str: string): Fr { // pad it so that we may read it as a buffer. // Buffer needs _exactly_ two hex characters per byte const padded = hex.length % 2 === 1 ? '0' + hex : hex; + let buf = Buffer.from(padded, 'hex'); + if (buf.length > Fr.SIZE_IN_BYTES) { + buf = buf.subarray(buf.length - Fr.SIZE_IN_BYTES); + } + + const fr = Buffer.alloc(Fr.SIZE_IN_BYTES, 0); + fr.set(buf, Fr.SIZE_IN_BYTES - buf.length); // finally, turn it into an integer - return Fr.fromBuffer(Buffer.from(padded, 'hex')); + return Fr.fromBuffer(fr); } /**