Skip to content

Commit

Permalink
additional imports
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Sep 16, 2024
1 parent 15c5367 commit 1e6d113
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/cheatcodes/parse-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ If your JSON object has `hex numbers`, they will be encoded as bytes. The way to

### How to use StdJson

1. Import the library `import "../StdJson.sol";`
1. Import the library `import {stdJson} from "forge-std/StdJson.sol";`
2. Define its usage with `string`: `using stdJson for string;`
3. If you want to parse simple values (numbers, address, etc.) use the helper functions
4. If you want to parse entire JSON objects:
Expand Down
2 changes: 1 addition & 1 deletion src/cheatcodes/parse-toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ for (uint256 i = 0; i < fruitstall.apples.length; i++) {

### How to use StdToml

1. Import the library `import "../StdToml.sol";`
1. Import the library `import {stdToml} from "forge-std/StdToml.sol";`
2. Define its usage with `string`: `using stdToml for string;`
3. If you want to parse simple values (numbers, address, etc.) use the helper functions
4. If you want to parse entire TOML tables:
Expand Down
2 changes: 1 addition & 1 deletion src/config/vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ Add line to `.vscode/settings.json` file (solidity extension settings):
Now all contracts from the OpenZeppelin documentation can be used.

```javascript
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
```
2 changes: 1 addition & 1 deletion src/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Alternatively, you can use [Forge Std][forge-std] which comes bundled with `cons
you have to import it:

```solidity
import "forge-std/console.sol";
import {console} from "forge-std/console.sol";
```

### How do I run specific tests?
Expand Down
2 changes: 1 addition & 1 deletion src/forge/differential-ffi-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Finally, the test asserts that the both roots are exactly equal. If they are not
You may want to use differential testing against another Solidity implementation. In that case, `ffi` is not needed. Instead, the reference implementation is imported directly into the test.

```solidity
import "openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol";
import {MerkleProof} from "openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol";
//...
function testCompatibilityOpenZeppelinProver(bytes32[] memory _data, uint256 node) public {
vm.assume(_data.length > 1);
Expand Down
6 changes: 3 additions & 3 deletions src/forge/forge-std.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ deal(address(dai), alice, 10000e18);
To import the `Vm` interface or the `console` library individually:

```solidity
import "forge-std/Vm.sol";
import {Vm} from "forge-std/Vm.sol";
```

```solidity
import "forge-std/console.sol";
import {console} from "forge-std/console.sol";
```

**Note:** `console2.sol` contains patches to `console.sol` that allows Forge to decode traces for calls to the console, but it is not compatible with Hardhat.

```solidity
import "forge-std/console2.sol";
import {console2} from "forge-std/console2.sol";
```

### Standard libraries
Expand Down
2 changes: 1 addition & 1 deletion src/projects/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ remappings = [
Now we can import any of the contracts in `src/utils` of the solmate repository like so:

```solidity
import "@solmate-utils/LibString.sol";
import {LibString} from "@solmate-utils/LibString.sol";
```

### Updating dependencies
Expand Down
4 changes: 2 additions & 2 deletions src/reference/config/solidity-compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ A remapping _remaps_ Solidity imports to different directories. For example, the
with an import like

```solidity
import "@openzeppelin/contracts/utils/Context.sol";
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
```

becomes

```solidity
import "node_modules/@openzeppelin/openzeppelin-contracts/contracts/utils/Context.sol";
import {Context} from "node_modules/@openzeppelin/openzeppelin-contracts/contracts/utils/Context.sol";
```

##### `auto_detect_remappings`
Expand Down
2 changes: 1 addition & 1 deletion src/reference/forge-std/console-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- You can use it in calls and transactions. It also works with view and pure functions.
- It always works, regardless of the call or transaction failing or being successful.
- To use it you need import it:
- `import "forge-std/console.sol";`
- `import {console} from "forge-std/console.sol";`
- You can call console.log with up to 4 parameters in any order of following types:
- `uint`
- `string`
Expand Down
16 changes: 8 additions & 8 deletions src/tutorials/solidity-scripting.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,18 @@ Once that’s done, you should open up your preferred code editor and copy the c
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.10;
import "solmate/tokens/ERC721.sol";
import "openzeppelin-contracts/contracts/utils/Strings.sol";
import "openzeppelin-contracts/contracts/access/Ownable.sol";
import {ERC721} from "solmate/tokens/ERC721.sol";
import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
error MintPriceNotPaid();
error MaxSupply();
error NonExistentTokenURI();
error WithdrawTransfer();
contract NFT is ERC721, Ownable {
using Strings for uint256;
string public baseURI;
uint256 public currentTokenId;
uint256 public constant TOTAL_SUPPLY = 10_000;
Expand Down Expand Up @@ -163,8 +163,8 @@ The contents of `NFT.s.sol` should look like this:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/Script.sol";
import "../src/NFT.sol";
import {Script} from "forge-std/Script.sol";
import {NFT} from "../src/NFT.sol";
contract MyScript is Script {
function run() external {
Expand All @@ -188,8 +188,8 @@ pragma solidity ^0.8.13;
Remember even if it’s a script it still works like a smart contract, but is never deployed, so just like any other smart contract written in Solidity the `pragma version` has to be specified.

```solidity
import "forge-std/Script.sol";
import "../src/NFT.sol";
import {Script} from "forge-std/Script.sol";
import {NFT} from "../src/NFT.sol";
```

Just like we may import Forge Std to get testing utilities when writing tests, Forge Std also provides some scripting utilities that we import here.
Expand Down
18 changes: 9 additions & 9 deletions src/tutorials/solmate-nft.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ We are then going to rename the boilerplate contract in `src/Contract.sol` to `s
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.10;
import "solmate/tokens/ERC721.sol";
import "openzeppelin-contracts/contracts/utils/Strings.sol";
import {ERC721} from "solmate/tokens/ERC721.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
contract NFT is ERC721 {
uint256 public currentTokenId;
Expand Down Expand Up @@ -61,8 +61,8 @@ Compiler run failed
error[6275]: ParserError: Source "lib/openzeppelin-contracts/contracts/contracts/utils/Strings.sol" not found: File not found. Searched the following locations: "/PATH/TO/REPO".
--> src/NFT.sol:5:1:
|
5 | import "openzeppelin-contracts/contracts/utils/Strings.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5 | import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

this can be fixed by setting up the correct remapping. Create a file `remappings.txt` in your project and add the line
Expand Down Expand Up @@ -115,18 +115,18 @@ Let's extend our NFT by adding metadata to represent the content of our NFTs, as
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.10;
import "solmate/tokens/ERC721.sol";
import "openzeppelin-contracts/contracts/utils/Strings.sol";
import "openzeppelin-contracts/contracts/access/Ownable.sol";
import {ERC721} from "solmate/tokens/ERC721.sol";
import {Ownable} from "openzeppelin-contracts/contracts/access/Ownable.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
error MintPriceNotPaid();
error MaxSupply();
error NonExistentTokenURI();
error WithdrawTransfer();
contract NFT is ERC721, Ownable {
using Strings for uint256;
string public baseURI;
uint256 public currentTokenId;
uint256 public constant TOTAL_SUPPLY = 10_000;
Expand Down Expand Up @@ -196,7 +196,7 @@ Within your test folder rename the current `Contract.t.sol` test file to `NFT.t.
pragma solidity 0.8.10;
import {Test} from "forge-std/Test.sol";
import "../src/NFT.sol";
import {NFT} from "../src/NFT.sol";
contract NFTTest is Test {
using stdStorage for StdStorage;
Expand Down

0 comments on commit 1e6d113

Please sign in to comment.