Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Aug 23, 2023
1 parent a53ec72 commit ee12135
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
26 changes: 25 additions & 1 deletion docs/docs/dev_docs/contracts/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,33 @@ await aztecRpc.registerRecipient(completeAddress);
</TabItem>
</Tabs>

At this point we only allow emitting note spending info through encrypted events.
In the future we will allow emitting arbitrary information.
(If you currently emit arbitrary information, AztecRPC server will fail to process it and it will not be queryable.)



### Unencrypted Events
Unencrypted events are events which can be read by anyone.
They can be emitted by both public and private functions.
It's important for a developer to consider whether it's acceptable for the unencrypted event to be emitted from private functions as it might pose a significant privacy leak.

Once emitted, unencrypted events are stored in AztecNode and can be queried by anyone:
<Tabs groupId="events">
<TabItem value="cli" label="Aztec CLI">

```bash
aztec-cli get-logs --from 5 --limit 1
```

</TabItem>
<TabItem value="js" label="Aztec.js">

#include_code logs /yarn-project/end-to-end/src/e2e_public_token_contract.test.ts typescript

</TabItem>
</Tabs>

### Constraining events
### Costs

Explain L1 cost to emit an event.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/getting_started/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ View result: [
Finally, we can use the CLI's `get-logs` command to retrieve unencrypted logs emitted by the contract:

```
% aztec-cli get-logs 5 1
% aztec-cli get-logs --from 5 --limit 1
Logs found:
Coins transferred
Expand Down
4 changes: 4 additions & 0 deletions yarn-project/end-to-end/src/e2e_public_token_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ describe('e2e_public_token_contract', () => {
};

const expectLogsFromLastBlockToBe = async (logMessages: string[]) => {
// docs:start:logs

const l2BlockNum = await aztecRpcServer.getBlockNumber();
const unencryptedLogs = await aztecRpcServer.getUnencryptedLogs(l2BlockNum, 1);

// docs:end:logs
const unrolledLogs = L2BlockL2Logs.unrollLogs(unencryptedLogs);
const asciiLogs = unrolledLogs.map(log => log.toString('ascii'));

Expand Down

0 comments on commit ee12135

Please sign in to comment.