From 0977a90ca3bd8258bfbfb65e7bda92dd1cc7688e Mon Sep 17 00:00:00 2001 From: PhilWindle <60546371+PhilWindle@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:22:05 +0100 Subject: [PATCH] feat: Added register-account command to cli (#2980) This PR adds the PXE's register-account command to the cli. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --- yarn-project/cli/src/index.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/yarn-project/cli/src/index.ts b/yarn-project/cli/src/index.ts index 04ebfed912a..baed053ad03 100644 --- a/yarn-project/cli/src/index.ts +++ b/yarn-project/cli/src/index.ts @@ -185,6 +185,30 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { log(`Partial address: ${partialAddress.toString()}`); }); + program + .command('register-account') + .description( + 'Registers an aztec account that can be used for sending transactions. Registers the account on the PXE. Uses a Schnorr single-key account which uses the same key for encryption and authentication (not secure for production usage).', + ) + .summary('Registers an aztec account that can be used for sending transactions.') + .addOption(createPrivateKeyOption('Private key for note encryption and transaction signing.', true)) + .requiredOption( + '-pa, --partial-address ', + 'The partially computed address of the account contract.', + parsePartialAddress, + ) + .addOption(pxeOption) + .action(async ({ rpcUrl, privateKey, partialAddress }) => { + const client = await createCompatibleClient(rpcUrl, debugLogger); + + const { address, publicKey } = await client.registerAccount(privateKey, partialAddress); + + log(`\nRegistered account:\n`); + log(`Address: ${address.toString()}`); + log(`Public key: ${publicKey.toString()}`); + log(`Partial address: ${partialAddress.toString()}`); + }); + program .command('deploy') .description('Deploys a compiled Aztec.nr contract to Aztec.')