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): fix portals tutorial formatting #2929

Merged
merged 9 commits into from
Oct 23, 2023
5 changes: 3 additions & 2 deletions docs/docs/dev_docs/tutorials/token_portal/minting_on_aztec.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ In our `token-bridge` nargo project in `aztec-contracts`, under `src` there is a

```rust
mod util;
#include_code token_bridge_imports /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr rust raw
#include_code token_bridge_imports /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr raw
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo good spot!

use crate::token_interface::Token;
use crate::util::{get_mint_public_content_hash, get_mint_private_content_hash, get_withdraw_content_hash};
#include_code token_bridge_storage_and_constructor /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr rust raw
#include_code token_bridge_storage_and_constructor /yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr raw
```

This imports Aztec-related dependencies and our two helper files `token_interface.nr` and `util.nr`.
(The code above will give errors right now - this is because we haven't implemented util and token_interface yet.)

Expand Down
32 changes: 17 additions & 15 deletions docs/docs/dev_docs/tutorials/token_portal/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ However if you’d rather skip this part, our dev-rels repo contains the starter
- [docker](https://docs.docker.com/)
- [Aztec sandbox](https://docs.aztec.network/dev_docs/getting_started/sandbox) - you should have this running before starting the tutorial

```sh
```bash
/bin/sh -c "$(curl -fsSL 'https://sandbox.aztec.network')"
```

- Nargo

```sh
```bash
curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | sh
noirup -v #include_noir_version
```
Expand All @@ -36,7 +36,7 @@ noirup -v #include_noir_version

Our root project will house everything ✨

```sh
```bash
mkdir aztec-token-bridge
```

Expand All @@ -46,7 +46,7 @@ Now inside `aztec-token-bridge` create a new directory called `aztec-contracts`

Inside `aztec-contracts`, create a nargo contract project by running

```sh
```bash
mkdir aztec-contracts
cd aztec-contracts
nargo new --contract token_bridge
Expand Down Expand Up @@ -87,26 +87,28 @@ aztec-contracts

# Create a JS hardhat project

In the root dir `aztec-token-bridge`, create a new directory called `l1-contracts` and run `npx hardhat init` inside of it. Keep hitting enter so you get the default setup (Javascript project)
In the root dir `aztec-token-bridge`, create a new directory called `l1-contracts` and run `yarn init -yp &&
npx hardhat init` inside of it. Keep hitting enter so you get the default setup (Javascript project)

```sh
```bash
mkdir l1-contracts
cd l1-contracts
yarn init -yp
npx hardhat init
```

Once you have a hardhat project set up, delete the existing contracts and create a `TokenPortal.sol`:
Once you have a hardhat project set up, delete the existing contracts, tests, and scripts, and create a `TokenPortal.sol`:

```sh
cd contracts
rm *.sol
```bash
rm -rf contracts test scripts
mkdir contracts && cd contracts
touch TokenPortal.sol
```

Now add dependencies that are required. These include interfaces to Aztec Inbox, Outbox and Registry smart contracts, OpenZeppelin contracts, and NomicFoundation.

```sh
yarn add @aztec/l1-contracts @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @types/chai @types/mocha @typechain/ethers-v5 @typechain/hardhat chai hardhat-gas-reporter solidity-coverage ts-node typechain typescript @openzeppelin/contracts
```bash
yarn add @aztec/foundation @aztec/l1-contracts @openzeppelin/contracts && yarn add @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan @types/chai @types/mocha @typechain/ethers-v5 @typechain/hardhat chai hardhat-gas-reporter solidity-coverage ts-node typechain typescript --dev
catmcgee marked this conversation as resolved.
Show resolved Hide resolved

```

Expand Down Expand Up @@ -136,7 +138,7 @@ We will use `viem` in this tutorial and `jest` for testing.

Inside the root directory, run

```sh
```bash
mkdir src && cd src && yarn init -yp
yarn add @aztec/aztec.js @aztec/noir-contracts @aztec/types @aztec/foundation @aztec/l1-artifacts viem "@types/node@^20.8.2"
yarn add -D jest @jest/globals ts-jest
Expand Down Expand Up @@ -236,13 +238,13 @@ Then create a jest config file: `jest.config.json`

You will also need to install some dependencies:

```sh
```bash
yarn add --dev typescript @types/jest ts-jest
```

Finally, we will create a test file. Run this in the `src` directory.:

```sh
```bash
mkdir test && cd test
touch cross_chain_messaging.test.ts
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this step we will write a Typescript test to interact with the sandbox and ca

Go to the `src/test` directory in your root dir and create a new file called `cross_chain_messaging.test.ts`:

```sh
```bash
cd src/test
touch cross_chain_messaging.test.ts
```
Expand Down Expand Up @@ -60,11 +60,11 @@ const [PortalERC20Abi, PortalERC20Bytecode] =
const [TokenPortalAbi, TokenPortalBytecode] =
getL1ContractABIAndBytecode("TokenPortal");

#include_code deployL1Contract /yarn-project/ethereum/src/deploy_l1_contracts.ts typescript raw
#include_code deployL1Contract /yarn-project/ethereum/src/deploy_l1_contracts.ts raw

#include_code deployAndInitializeTokenAndBridgeContracts /yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts typescript raw
#include_code deployAndInitializeTokenAndBridgeContracts /yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts raw

#include_code delay /yarn-project/end-to-end/src/fixtures/utils.ts typescript raw
#include_code delay /yarn-project/end-to-end/src/fixtures/utils.ts raw
```

This code
Expand Down Expand Up @@ -165,7 +165,7 @@ This fetches the wallets from the sandbox and deploys our cross chain harness on

```bash
cd packages/src
yarn test
DEBUG='aztec:canary_uniswap' yarn test
```

### Error handling
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/dev_docs/tutorials/uniswap/l1_portal.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IRegistry} from "@aztec/l1-contracts/src/core/interfaces/messagebridge/IRegistry.sol";
import {DataStructures} from "@aztec/l1-contracts/src/core/libraries/DataStructures.sol";
import {Hash} from "@aztec/l1-contracts/src/core/libraries/Hash.sol";
```

#include_code setup l1-contracts/test/portals/UniswapPortal.sol solidity raw
#include_code setup l1-contracts/test/portals/UniswapPortal.sol raw
```

In this set up we defined the `initialize()` function and a struct (`LocalSwapVars`) to manage assets being swapped.

Expand Down
16 changes: 8 additions & 8 deletions docs/docs/dev_docs/tutorials/uniswap/typescript_glue_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In this step, we We will now write a Typescript to interact with the sandbox and

In the root folder, go to `src` dir we created in [the token bridge tutorial](../token_portal/setup.md).

```sh
```bash
cd src/test
touch uniswap.test.ts
```
Expand All @@ -22,14 +22,14 @@ We will write two tests:

To compile the Solidity contracts, run this:

```sh
```bash
cd l1-contracts
npx hardhat compile
```

and the Aztec.nr contracts:

```sh
```bash
cd aztec-contracts
aztec-cli compile --typescript ../../src/test/fixtures uniswap
```
Expand Down Expand Up @@ -59,7 +59,7 @@ export FORK_URL=<YOUR_RPC_URL e.g. https://mainnet.infura.io/v3/API_KEY>

Now rerun the sandbox:

```sh
```bash
/bin/sh -c "$(curl -fsSL 'https://sandbox.aztec.network')"
```

Expand Down Expand Up @@ -114,9 +114,9 @@ const MNEMONIC = "test test test test test test test test test test test junk";
const hdAccount = mnemonicToAccount(MNEMONIC);
const expectedForkBlockNumber = 17514288;

#include_code uniswap_l1_l2_test_setup_const yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts typescript raw
#include_code uniswap_setup yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts typescript raw
#include_code uniswap_l1_l2_test_beforeAll yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts typescript raw
#include_code uniswap_l1_l2_test_setup_const yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts raw
#include_code uniswap_setup yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts raw
#include_code uniswap_l1_l2_test_beforeAll yarn-project/end-to-end/src/shared/uniswap_l1_l2.ts raw
```

## Private flow test
Expand All @@ -131,7 +131,7 @@ const expectedForkBlockNumber = 17514288;

Make sure your sandbox is running.

```sh
```bash
cd ~/.aztec && docker-compose up
```

Expand Down
44 changes: 22 additions & 22 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const sidebars = {

{
type: "html",
value: '<span class="sidebar-divider" />',
value: '<span clasuns="sidebar-divider" />',
},

// SPECIFICATION
Expand Down Expand Up @@ -245,7 +245,7 @@ const sidebars = {
],
},
{
label: "Build Uniswap with Portals",
label: "Build a Uniswap Integration with Portals",
catmcgee marked this conversation as resolved.
Show resolved Hide resolved
type: "category",
link: {
type: "doc",
Expand Down Expand Up @@ -312,27 +312,27 @@ const sidebars = {
},
"dev_docs/contracts/common_errors",
{
label: "Resources",
type: "category",
items: [
//"dev_docs/contracts/resources/style_guide",
{
label: "Common Patterns",
type: "category",
// link: {
// type: "doc",
// id: "dev_docs/contracts/resources/common_patterns/main",
// },
items: [
label: "Resources",
type: "category",
items: [
//"dev_docs/contracts/resources/style_guide",
{
label: "Common Patterns",
type: "category",
// link: {
// type: "doc",
// id: "dev_docs/contracts/resources/common_patterns/main",
// },
items: [
"dev_docs/contracts/resources/common_patterns/authwit",
// "dev_docs/contracts/resources/common_patterns/sending_tokens_to_user",
// "dev_docs/contracts/resources/common_patterns/sending_tokens_to_contract",
// "dev_docs/contracts/resources/common_patterns/access_control",
// "dev_docs/contracts/resources/common_patterns/interacting_with_l1",
],
},
],
},
// "dev_docs/contracts/resources/common_patterns/sending_tokens_to_user",
// "dev_docs/contracts/resources/common_patterns/sending_tokens_to_contract",
// "dev_docs/contracts/resources/common_patterns/access_control",
// "dev_docs/contracts/resources/common_patterns/interacting_with_l1",
],
},
],
},
// {
// label: "Security Considerations",
// type: "category",
Expand Down
Loading