Skip to content

Commit b0b71a2

Browse files
committed
Lint
1 parent cad3ad9 commit b0b71a2

File tree

2 files changed

+148
-149
lines changed

2 files changed

+148
-149
lines changed

Diff for: pages/stack/interop/tutorials/upgrade-to-superchain-erc20/lockbox.mdx

+106-106
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,28 @@ Some steps depend on whether you want to deploy on [supersim](/stack/interop/too
9595

9696
1. Specify these variables, which we use later:
9797

98-
<Tabs items={['Supersim', 'Devnets']}>
99-
<Tabs.Tab>
100-
Set these parameters for Supersim.
101-
102-
```sh
103-
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
104-
USER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
105-
URL_CHAIN_A=http://127.0.0.1:9545
106-
URL_CHAIN_B=http://127.0.0.1:9546
107-
```
108-
</Tabs.Tab>
109-
110-
<Tabs.Tab>
111-
For Devnet, specify in `PRIVATE_KEY` the private key you used for the setup script and then these parameters.
112-
113-
```sh
114-
USER_ADDRESS=`cast wallet address --private-key $PRIVATE_KEY`
115-
URL_CHAIN_A=https://interop-alpha-0.optimism.io
116-
URL_CHAIN_B=https://interop-alpha-1.optimism.io
117-
```
118-
</Tabs.Tab>
119-
</Tabs>
98+
<Tabs items={['Supersim', 'Devnets']}>
99+
<Tabs.Tab>
100+
Set these parameters for Supersim.
101+
102+
```sh
103+
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
104+
USER_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
105+
URL_CHAIN_A=http://127.0.0.1:9545
106+
URL_CHAIN_B=http://127.0.0.1:9546
107+
```
108+
</Tabs.Tab>
109+
110+
<Tabs.Tab>
111+
For Devnet, specify in `PRIVATE_KEY` the private key you used for the setup script and then these parameters.
112+
113+
```sh
114+
USER_ADDRESS=`cast wallet address --private-key $PRIVATE_KEY`
115+
URL_CHAIN_A=https://interop-alpha-0.optimism.io
116+
URL_CHAIN_B=https://interop-alpha-1.optimism.io
117+
```
118+
</Tabs.Tab>
119+
</Tabs>
120120

121121
2. Regardless of whether you use Supersim or Devnet, specify these variables.
122122

@@ -170,41 +170,41 @@ Some steps depend on whether you want to deploy on [supersim](/stack/interop/too
170170
```solidity filename="packages/contracts/scripts/LockboxDeployer.s.sol" file=<rootDir>/public/tutorials/LockboxDeployer.s.sol hash=534b543709be173d87508a53322d8c59
171171
```
172172

173-
<details>
174-
<summary>Explanation of the modified functions</summary>
173+
<details>
174+
<summary>Explanation of the modified functions</summary>
175175

176-
For the most part, this is the standard `SuperchainERC20Deployer.s.sol` that comes with the SuperchainERC20 starter kit.
177-
Some functions are modified, as explained below.
176+
For the most part, this is the standard `SuperchainERC20Deployer.s.sol` that comes with the SuperchainERC20 starter kit.
177+
Some functions are modified, as explained below.
178178

179-
```solidity file=<rootDir>/public/tutorials/LockboxDeployer.s.sol#L46-L52 hash=302d02c3895f109e5e64d265b0473e6a
180-
```
179+
```solidity file=<rootDir>/public/tutorials/LockboxDeployer.s.sol#L46-L52 hash=302d02c3895f109e5e64d265b0473e6a
180+
```
181181

182-
Get the majority of the configuration from the environment.
183-
Mostly of it is derived from the configuration of the original ERC-20 token.
182+
Get the majority of the configuration from the environment.
183+
Mostly of it is derived from the configuration of the original ERC-20 token.
184184

185-
Note that there is no `owner` here.
186-
This `SuperchainERC20` contract does not need an owner, because minting and burning are handled by the users themselves (by locking and unlocking the original tokens).
185+
Note that there is no `owner` here.
186+
This `SuperchainERC20` contract does not need an owner, because minting and burning are handled by the users themselves (by locking and unlocking the original tokens).
187187

188-
```solidity file=<rootDir>/public/tutorials/LockboxDeployer.s.sol#L54-L69 hash=c45855080dc554cece35ed87e2d68f68
189-
```
188+
```solidity file=<rootDir>/public/tutorials/LockboxDeployer.s.sol#L54-L69 hash=c45855080dc554cece35ed87e2d68f68
189+
```
190190

191-
"Manually" calculate the address that [`CREATE2`](https://www.evm.codes/?fork=cancun#f5) will give us.\
192-
If there is already a contract there, we have a problem.
193-
Otherwise, deploy `LockboxSuperchainERC20`.
191+
"Manually" calculate the address that [`CREATE2`](https://www.evm.codes/?fork=cancun#f5) will give us.\
192+
If there is already a contract there, we have a problem.
193+
Otherwise, deploy `LockboxSuperchainERC20`.
194194

195-
```solidity file=<rootDir>/public/tutorials/LockboxDeployer.s.sol#L80-L84 hash=5d1f71b16a6f02d52a79b1a9e7588f87
196-
```
195+
```solidity file=<rootDir>/public/tutorials/LockboxDeployer.s.sol#L80-L84 hash=5d1f71b16a6f02d52a79b1a9e7588f87
196+
```
197197

198-
I modified this salt function to include a timestamp (obtained using `vm.unixTime()` in the constructor).
199-
This is not necessary, but I consider it a developer experience improvement.
200-
During development you redeploy slightly modified code a lot of times.
201-
It is easier if you don't need to manually change the salt every time.
198+
I modified this salt function to include a timestamp (obtained using `vm.unixTime()` in the constructor).
199+
This is not necessary, but I consider it a developer experience improvement.
200+
During development you redeploy slightly modified code a lot of times.
201+
It is easier if you don't need to manually change the salt every time.
202202

203-
<Callout type="warning">
204-
Remove this before deploying to production.
205-
Otherwise, as new blockchains join the Interop cluster, you may not be able to deploy your contract at the same address.
206-
</Callout>
207-
</details>
203+
<Callout type="warning">
204+
Remove this before deploying to production.
205+
Otherwise, as new blockchains join the Interop cluster, you may not be able to deploy your contract at the same address.
206+
</Callout>
207+
</details>
208208

209209
### Create and deploy the new contract
210210

@@ -213,67 +213,67 @@ Some steps depend on whether you want to deploy on [supersim](/stack/interop/too
213213
```solidity filename="packages/contracts/src/LockboxSuperchainERC20.sol" file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol hash=d326f0e1c26904b844263274914951cf
214214
```
215215

216-
<details>
217-
<summary>Explanation</summary>
216+
<details>
217+
<summary>Explanation</summary>
218218

219-
```solidity file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol#L11-L12 hash=45d211a19533f9b0dee310743b25459f
220-
```
219+
```solidity file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol#L11-L12 hash=45d211a19533f9b0dee310743b25459f
220+
```
221221

222-
The lockbox contract needs to know the contract for which it is a lockbox.
223-
This requires not just the address, but also to know what chain has it.
222+
The lockbox contract needs to know the contract for which it is a lockbox.
223+
This requires not just the address, but also to know what chain has it.
224224

225-
```solidity file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol#L47-L57 hash=20f6aa15d113dcaf992875184173cb47
226-
```
225+
```solidity file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol#L47-L57 hash=20f6aa15d113dcaf992875184173cb47
226+
```
227227

228-
Users call this function to transfer original tokens to the contract and mint themselves an equivalent number of lockbox tokens.
229-
This function has several tests to make sure it can be called.
228+
Users call this function to transfer original tokens to the contract and mint themselves an equivalent number of lockbox tokens.
229+
This function has several tests to make sure it can be called.
230230

231-
* Check the chain ID.
232-
Locking and redeeming tokens can only be done on the original token's chain.
233-
* Use [`transferFrom`](https://ethereum.org/en/developers/tutorials/erc20-annotated-code/#transferFrom) to transfer the tokens to ourselves.
234-
This call typically reverts when it fails, but it can also return `false`.
235-
In that case, we revert.
236-
There are two reasons it may fail.
237-
* The user (in this case, the `LockboxSuperchainERC20` contract) does not have [the allowance](https://ethereum.org/en/developers/tutorials/erc20-annotated-code/#_approve) to spend that amount of tokens from the original owner (`msg.sender`).
238-
* The original owner (`msg.sender`) does not have enough tokens to transfer.
231+
* Check the chain ID.
232+
Locking and redeeming tokens can only be done on the original token's chain.
233+
* Use [`transferFrom`](https://ethereum.org/en/developers/tutorials/erc20-annotated-code/#transferFrom) to transfer the tokens to ourselves.
234+
This call typically reverts when it fails, but it can also return `false`.
235+
In that case, we revert.
236+
There are two reasons it may fail.
237+
* The user (in this case, the `LockboxSuperchainERC20` contract) does not have [the allowance](https://ethereum.org/en/developers/tutorials/erc20-annotated-code/#_approve) to spend that amount of tokens from the original owner (`msg.sender`).
238+
* The original owner (`msg.sender`) does not have enough tokens to transfer.
239239

240-
If the tests are successful, mint the requested amount for `msg.sender`.
240+
If the tests are successful, mint the requested amount for `msg.sender`.
241241

242-
```solidity file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol#L59-L67 hash=2e63a9cd1ac1114c3fb2110e28b60924
243-
```
242+
```solidity file=<rootDir>/public/tutorials/LockboxSuperchainERC20.sol#L59-L67 hash=2e63a9cd1ac1114c3fb2110e28b60924
243+
```
244244

245-
Users call this function to redeem their existing lockbox tokens and replace them with the original tokens.
246-
It also has multiple tests.
245+
Users call this function to redeem their existing lockbox tokens and replace them with the original tokens.
246+
It also has multiple tests.
247247

248-
* Again, check chain ID.
249-
* Try to `_burn` the amount of lockbox tokens.
250-
[The solady `_burn` function](https://github.com/Vectorized/solady/blob/main/src/tokens/ERC20.sol#L539-L542), the one we inherit from `SuperchainERC20`, reverts if the user does not have enough tokens to burn.
251-
* Transfer the amount of the original ERC-20 redeemed to
252-
the caller.
253-
This should never fail, because lockbox ERC-20 tokens are supposed to always be backed by an equal number of the original tokens.
254-
However, if it does fail for some reason, revert.
255-
</details>
248+
* Again, check chain ID.
249+
* Try to `_burn` the amount of lockbox tokens.
250+
[The solady `_burn` function](https://github.com/Vectorized/solady/blob/main/src/tokens/ERC20.sol#L539-L542), the one we inherit from `SuperchainERC20`, reverts if the user does not have enough tokens to burn.
251+
* Transfer the amount of the original ERC-20 redeemed to
252+
the caller.
253+
This should never fail, because lockbox ERC-20 tokens are supposed to always be backed by an equal number of the original tokens.
254+
However, if it does fail for some reason, revert.
255+
</details>
256256

257257
2. Actually deploy the contract.
258258

259-
<Tabs items={['Supersim', 'Devnets']}>
260-
<Tabs.Tab>
261-
```sh
262-
pnpm contracts:deploy:token
263-
```
264-
</Tabs.Tab>
259+
<Tabs items={['Supersim', 'Devnets']}>
260+
<Tabs.Tab>
261+
```sh
262+
pnpm contracts:deploy:token
263+
```
264+
</Tabs.Tab>
265265

266-
<Tabs.Tab>
267-
To deploy to the [development networks](/stack/interop/tools/devnet), follow the steps [in the tutorial](/stack/interop/tutorials/deploy-superchain-erc20#prepare-for-deployment) before you deploy the contract.
266+
<Tabs.Tab>
267+
To deploy to the [development networks](/stack/interop/tools/devnet), follow the steps [in the tutorial](/stack/interop/tutorials/deploy-superchain-erc20#prepare-for-deployment) before you deploy the contract.
268268

269-
Then, update `packages/contracts/.env` and deploy the token.
269+
Then, update `packages/contracts/.env` and deploy the token.
270270

271-
```sh
272-
echo DEPLOYER_PRIVATE_KEY=$PRIVATE_KEY > packages/contracts/.env
273-
pnpm contracts:deploy:token
274-
```
275-
</Tabs.Tab>
276-
</Tabs>
271+
```sh
272+
echo DEPLOYER_PRIVATE_KEY=$PRIVATE_KEY > packages/contracts/.env
273+
pnpm contracts:deploy:token
274+
```
275+
</Tabs.Tab>
276+
</Tabs>
277277

278278
3. Get the new token address and store it in an environment variable.
279279

@@ -322,18 +322,18 @@ Some steps depend on whether you want to deploy on [supersim](/stack/interop/too
322322

323323
6. Specify the configuration for another user.
324324

325-
<Tabs items={['Supersim', 'Devnets']}>
326-
<Tabs.Tab>
327-
```sh
328-
USER_ADDRESS_2=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
329-
PRIVATE_KEY_2=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
330-
```
331-
</Tabs.Tab>
332-
333-
<Tabs.Tab>
334-
Specify the private key (`PRIVATE_KEY_2`) and user address (`USER_ADDRESS_2`) of another user that has ETH on both devnets.
335-
</Tabs.Tab>
336-
</Tabs>
325+
<Tabs items={['Supersim', 'Devnets']}>
326+
<Tabs.Tab>
327+
```sh
328+
USER_ADDRESS_2=0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC
329+
PRIVATE_KEY_2=0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a
330+
```
331+
</Tabs.Tab>
332+
333+
<Tabs.Tab>
334+
Specify the private key (`PRIVATE_KEY_2`) and user address (`USER_ADDRESS_2`) of another user that has ETH on both devnets.
335+
</Tabs.Tab>
336+
</Tabs>
337337

338338
7. Transfer new tokens to the new user (on chain B) and see that they were actually transferred.
339339

0 commit comments

Comments
 (0)