Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): Updated docs explaining Sandbox accounts #2235

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs/dev_docs/getting_started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Let's double check that the accounts have been registered with the sandbox using

#include_code get-accounts yarn-project/end-to-end/src/cli_docs_sandbox.test.ts bash

Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later.
You will see a that a number of accounts exist that we did not create. The Sandbox initialises itself with 3 default accounts. Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later.

```bash
export ADDRESS2=<Account address printed by the above command>
Expand Down Expand Up @@ -120,7 +120,7 @@ The `call` command calls a read-only method on a contract, one that will not gen
- `--contract-abi` - The abi of the contract we are calling.
- `--contract-address` - The address of the deployed contract

As you can see from the result, this address has a balance of 1000000, as expected.
As you can see from the result, this address has a balance of 1000000, as expected. When using the Sandbox, you are able to query the balance of any account that has been created in the system, even the accounts created by default. You may wonder why this is, as you haven't provided the private keys for these accounts. The Sandbox contains a component known as the AztecRPCServer. When an account is created, this component stores the provided encryption private key and is able to read the account's private state meaning that the Sandbox can report the balance of any of it's accounts. More information about the account model can be found [here](../../concepts/foundation/accounts/main.md).

## Sending a Transaction

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ export class AztecRPCServer implements AztecRPC {
const pubKey = this.keyStore.addAccount(privKey);
this.synchroniser.addAccount(pubKey, this.keyStore);
this.log.info(`Registered account ${completeAddress.address.toString()}`);
this.log.debug(`Registered ${completeAddress.toReadableString()}`);
this.log.debug(`Registered account\n ${completeAddress.toReadableString()}`);
} else {
this.log.info(`Account "${completeAddress.address.toString()}" already registered.`);
this.log.info(`Account:\n "${completeAddress.address.toString()}"\n already registered.`);
}
}

Expand All @@ -135,9 +135,9 @@ export class AztecRPCServer implements AztecRPC {
public async registerRecipient(recipient: CompleteAddress): Promise<void> {
const wasAdded = await this.db.addCompleteAddress(recipient);
if (wasAdded) {
this.log.info(`Added recipient: ${recipient.toReadableString()}`);
this.log.info(`Added recipient:\n ${recipient.toReadableString()}`);
} else {
this.log.info(`Recipient "${recipient.toReadableString()}" already registered.`);
this.log.info(`Recipient:\n "${recipient.toReadableString()}"\n already registered.`);
}
}

Expand Down
4 changes: 3 additions & 1 deletion yarn-project/aztec-sandbox/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ async function main() {
accountStrings.push(` Public Key: ${completeAddress.publicKey.toString()}\n\n`);
}
}
logger.info(`${splash}\n${github}\n\n`.concat(...accountStrings).concat(`Aztec Sandbox is now ready for use!`));
logger.info(
`${splash}\n${github}\n\n`.concat(...accountStrings).concat(`Aztec Sandbox v${version} is now ready for use!`),
);
}

main().catch(err => {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/circuits.js/src/types/complete_address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class CompleteAddress {
* @returns A readable string representation of the complete address.
*/
public toReadableString(): string {
return `Address: ${this.address.toString()}, Public Key: ${this.publicKey.toString()}, Partial Address: ${this.partialAddress.toString()}`;
return ` Address: ${this.address.toString()}\n Public Key: ${this.publicKey.toString()}\n Partial Address: ${this.partialAddress.toString()}\n`;
}

/**
Expand Down
20 changes: 14 additions & 6 deletions yarn-project/end-to-end/src/cli_docs_sandbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,21 @@ Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042e
% aztec-cli get-accounts
Accounts found:

Address: 0x20d3321707d53cebb168568e25c5c62a853ae1f0766d965e00d6f6c4eb05d599
Public key: 0x02d18745eadddd496be95274367ee2cbf0bf667b81373fb6bed715c18814a09022907c273ec1c469fcc678738bd8efc3e9053fe1acbb11fa32da0d6881a1370e
Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed
Address: 0x0c8a6673d7676cc80aaebe7fa7504cf51daa90ba906861bfad70a58a98bf5a7d
Public Key: 0x27c20118733174347b8082f578a7d8fb84b3ad38be293715eee8119ee5cd8a6d0d6b7d8124b37359663e75bcd2756f544a93b821a06f8e33fba68cc8029794d9
Partial Address: 0x1c6484e22441e5ca43bba53495d0cdc911da299150fde1191bcb330b64716ff9

Address: 0x175310d40cd3412477db1c2a2188efd586b63d6830115fbb46c592a6303dbf6c
Public key: 0x08aad54f32f1b6621ee5f25267166e160147cd355a2dfc129fa646a651dd29471d814ac749c2cda831fcca361c830ba56db4b4bd5951d4953c81865d0ae0cbe7
Partial address: 0x72bf7c9537875b0af267b4a8c497927e251f5988af6e30527feb16299042ed
Address: 0x226f8087792beff8d5009eb94e65d2a4a505b70baf4a9f28d33c8d620b0ba972
Public Key: 0x08145e8e8d46f51cda8d4c9cad81920236366abeafb8d387002bad879a3e87a81570b04ac829e4c007141d856d5a36d3b9c464e0f3c1c99cdbadaa6bb93f3257
Partial Address: 0x1833e53112953e6830a230cfc2895caed604f6395bbfafa730da26c5bf53c0a9

Address: 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b
Public Key: 0x13e6151ea8e7386a5e7c4c5221047bf73d0b1b7a2ad14d22b7f73e57c1fa00c614bc6da69da1b581b09ee6cdc195e5d58ae4dce01b63bbb744e58f03855a94dd
Partial Address: 0x30034aaf5d78821effa4827a132357110a49a4f37b6e384d884e233595bcf342

Address: 0x01b18c2044bbedd4a2e5f67cf6858370ccfb2b869b2000abe2f4ca12d9cc166e
Public Key: 0x240845f1179e3fbaa6ce587d44722b3452bbdaa11deb29553196b23534985d432b746bcf2f0e7046eb13f0ca0c4fedd027dc80b64384f50d6a14ad248faa941a
Partial Address: 0x03834845fc488d1454f195abe7d52b3393f6902eee080c90cd694c63572f7160
// docs:end:get-accounts
`;

Expand Down