Skip to content

Commit

Permalink
General repo cleanup and commenting (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
mshrieve authored Sep 8, 2022
1 parent e51f398 commit 8f093bc
Show file tree
Hide file tree
Showing 45 changed files with 158 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cache/
out/
broadcast/
node_modules
.env

.DS_Store

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ No one remembers where bibos came from, but one things for sure - they are imple
### Install

Install [Foundry](https://github.com/gakonst/foundry/).
Run `[bash]foundryup` to update to nightly builds.
Run `foundryup` to update to nightly builds.

This project uses [pnpm](https://pnpm.io/) for maximum javascript acceleration.

Expand All @@ -29,7 +29,7 @@ For submodules:
forge update
```

For some scripts, you might need `jq` JSON utility. To install run `[bash]brew install jq`.
For some scripts, you might need `jq` JSON utility. To install on MacOS, run `brew install jq`.

---

Expand All @@ -41,8 +41,8 @@ pnpm test

---

### Bibos Local Deployment + Inspector
### Bibos Local Inspector

1. Run `anvil` in one terminal instance.
2. Run `pnpm run deploy-anvil` in another. This deploys all the libraries, and Bibos.
3. Run `pnpm run dev`, for the frontend. Navigate to `localhost:3000` in your browser.
```[bash]
pnpm dev
```
7 changes: 3 additions & 4 deletions deployment/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# deploy bibos to anvil

# anvil rpc
RPC_URL=http://127.0.0.1:8545
# // anvil account 9
Expand All @@ -20,10 +22,7 @@ get_return_value() {
SCRIPT_OUTPUT="$(forge script --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast --json src/scripts/deploy_bibos.sol:deploy_bibos)"
BIBOS_ADDRESS="$(get_return_value "bibos" "$SCRIPT_OUTPUT")"

# # erase deployments.json
echo "{}" > $DEPLOYMENTS_PATH

# # save the bibos address in deployments.json
# save the bibos address in deployments.json
write_deployment_address "Bibos" $BIBOS_ADDRESS

echo "$SCRIPT_OUTPUT"
7 changes: 1 addition & 6 deletions deployment/scripts.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#!/bin/bash

# anvil rpc
RPC_URL=http://127.0.0.1:8545
# // anvil account 9
PRIVATE_KEY=0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6
PUBLIC_KEY=0xa0ee7a142d267c1f36714e4a8f75612f20a79720

# scripts to help interact with bibos

# forge script --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast --json src/scripts/deploy_bibos.sol:deploy_bibos
# cast send --private-key $PRIVATE_KEY --rpc-url $RPC_URL $BIBOS_ADDRESS "withdraw(address)" "$TO"
Expand Down
2 changes: 2 additions & 0 deletions deployment/verify_contracts.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# verify bibos contracts with external library addresses

forge verify-contract --chain-id 1 --compiler-version "0.8.13+commit.abaa5c0e" \
--libraries "src/libraries/Cheeks.sol:Cheeks:0x5a56533924d6694c617172592cfa7d8c63de4b4f" \
--libraries "src/libraries/Data.sol:Data:0x62897c2906035e70470d0b0a37bf31fdadf7bf67" \
Expand Down
2 changes: 1 addition & 1 deletion lib/forge-std
2 changes: 1 addition & 1 deletion lib/solmate
3 changes: 3 additions & 0 deletions src/Bibos.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ pragma solidity 0.8.13;

import {ERC721} from "solmate/tokens/ERC721.sol";
import {Owned} from "solmate/auth/Owned.sol";

import {Render} from "libraries/Render.sol";

error InsufficentValue();
error MintedOut();
error InvalidTokenId();
error AmountNotAvailable();

/// @title Bibos
/// @author Bumblebee Systems
contract Bibos is ERC721, Owned {
/*//////////////////////////////////////////////////////////////
STATE
Expand Down
2 changes: 2 additions & 0 deletions src/dev/PaletteUncompressed.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

/// @title PaletteUncompressed
/// @author Bumblebee Systems
library PaletteUncompressed {
function lightest(uint256 _value) internal pure returns (string memory) {
string[64] memory lightestValues = [
Expand Down
2 changes: 2 additions & 0 deletions src/dev/PaletteUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity >=0.8.0;
import {Util} from "libraries/Util.sol";
import {PaletteUncompressed} from "dev/PaletteUncompressed.sol";

/// @title PaletteUtil
/// @author Bumblebee Systems
library PaletteUtil {
uint256 constant length = 64;

Expand Down
2 changes: 2 additions & 0 deletions src/dev/PointsUncompressed.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

/// @title PointsUncompressed
/// @author Bumblebee Systems
library PointsUncompressed {
uint256 constant length = 64;

Expand Down
2 changes: 2 additions & 0 deletions src/dev/PointsUtil.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pragma solidity >=0.8.0;
import {Util} from "libraries/Util.sol";
import {PointsUncompressed} from "dev/PointsUncompressed.sol";

/// @title PointsUtil
/// @author Bumblebee Systems
library PointsUtil {
uint256 constant length = 64;

Expand Down
2 changes: 2 additions & 0 deletions src/dev/TimesUncompressed.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

/// @title TimesUncompressed
/// @author Bumblebee Systems
library TimesUncompressed {
uint256 constant length = 64;

Expand Down
4 changes: 3 additions & 1 deletion src/dev/TimesUtil.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Util} from "src/libraries/Util.sol";
import {Util} from "libraries/Util.sol";
import {TimesUncompressed} from "dev/TimesUncompressed.sol";

/// @title TimesUtil
/// @author Bumblebee Systems
library TimesUtil {
uint256 constant length = 64;

Expand Down
2 changes: 2 additions & 0 deletions src/dev/Util.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

/// @title TimesUtil
/// @author Bumblebee Systems
library Util {
/// @notice will revert if any characters are not in [0-9]
function hexStringToUint256(string memory _value) internal pure returns (uint256 result) {
Expand Down
6 changes: 4 additions & 2 deletions src/libraries/Background.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Palette} from "./Palette.sol";
import {SVG} from "./SVG.sol";
import {Palette} from "libraries/Palette.sol";
import {SVG} from "libraries/SVG.sol";

/// @title Background
/// @author Bumblebee Systems
library Background {
/*//////////////////////////////////////////////////////////////
RENDER
Expand Down
18 changes: 10 additions & 8 deletions src/libraries/Body.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Palette, DensityType, PolarityType} from "./Palette.sol";
import {Traits} from "./Traits.sol";
import {Data} from "./Data.sol";
import {Util} from "./Util.sol";
import {SVG} from "./SVG.sol";
import {Palette, DensityType, PolarityType} from "libraries/Palette.sol";
import {Traits} from "libraries/Traits.sol";
import {Data} from "libraries/Data.sol";
import {Util} from "libraries/Util.sol";
import {SVG} from "libraries/SVG.sol";

/// @title Body
/// @author Bumblebee Systems
library Body {
uint256 constant circlesCount = 7;
uint256 constant CIRCLE_COUNT = 7;

/*//////////////////////////////////////////////////////////////
RENDER
Expand All @@ -24,7 +26,7 @@ library Body {

string memory bodyGroupChildren = _bodyBackground(backgroundFill);

for (uint8 index = 0; index < circlesCount; ++index) {
for (uint8 index = 0; index < CIRCLE_COUNT; ++index) {
bodyGroupChildren = string.concat(
bodyGroupChildren,
_bodyCircle(_seed, index, _tokenId, radii[index], mixBlendMode)
Expand All @@ -51,7 +53,7 @@ library Body {
) internal pure returns (string memory) {
uint256 bodySeed = uint256(keccak256(abi.encodePacked(_seed, "body", _index)));
string memory bodyFill1 = Palette.bodyFill(_seed, _index, _tokenId);
string memory bodyFill2 = Palette.bodyFill(_seed, _index + circlesCount, _tokenId);
string memory bodyFill2 = Palette.bodyFill(_seed, _index + CIRCLE_COUNT, _tokenId);
string memory dur = Data.shortTimes(bodySeed /= Data.length);
string[2] memory coords = (_index == 0) ? ["150", "150"] : Data.bodyPoints(bodySeed /= 2);
bool reverse = bodySeed % 2 == 0;
Expand Down
8 changes: 5 additions & 3 deletions src/libraries/Cheeks.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Util} from "./Util.sol";
import {SVG} from "./SVG.sol";
import {Traits} from "./Traits.sol";
import {Util} from "libraries/Util.sol";
import {SVG} from "libraries/SVG.sol";
import {Traits} from "libraries/Traits.sol";

enum CheekType {
NONE,
Expand All @@ -12,6 +12,8 @@ enum CheekType {
BIG
}

/// @title Cheeks
/// @author Bumblebee Systems
library Cheeks {
/*//////////////////////////////////////////////////////////////
RENDER
Expand Down
4 changes: 3 additions & 1 deletion src/libraries/Data.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Util} from "src/libraries/Util.sol";
import {Util} from "libraries/Util.sol";

/// @title Data
/// @author Bumblebee Systems
library Data {
/*//////////////////////////////////////////////////////////////
POINTS
Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Eyes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ enum EyeType {
OPALINE
}

/// @title Eyes
/// @author Bumblebee Systems
library Eyes {
string constant fill = "black";

Expand Down
2 changes: 2 additions & 0 deletions src/libraries/Eyes2.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

/// @title Eyes2
/// @author Bumblebee Systems
library Eyes2 {
function opaline(string memory _fill) external pure returns (string memory) {
return
Expand Down
12 changes: 7 additions & 5 deletions src/libraries/Face.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {SVG} from "./SVG.sol";
import {Eyes} from "./Eyes.sol";
import {Mouth} from "./Mouth.sol";
import {Cheeks} from "./Cheeks.sol";
import {Data} from "./Data.sol";
import {SVG} from "libraries/SVG.sol";
import {Eyes} from "libraries/Eyes.sol";
import {Mouth} from "libraries/Mouth.sol";
import {Cheeks} from "libraries/Cheeks.sol";
import {Data} from "libraries/Data.sol";

/// @title Face
/// @author Bumblebee Systems
library Face {
/*//////////////////////////////////////////////////////////////
RENDER
Expand Down
10 changes: 6 additions & 4 deletions src/libraries/Glints.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
pragma solidity >=0.8.0;

import {Traits} from "libraries/Traits.sol";
import {Palette} from "./Palette.sol";
import {Data} from "./Data.sol";
import {Util} from "./Util.sol";
import {SVG} from "./SVG.sol";
import {Palette} from "libraries/Palette.sol";
import {Data} from "libraries/Data.sol";
import {Util} from "libraries/Util.sol";
import {SVG} from "libraries/SVG.sol";

/// @title Glints
/// @author Bumblebee Systems
library Glints {
/*//////////////////////////////////////////////////////////////
RENDER
Expand Down
6 changes: 4 additions & 2 deletions src/libraries/Metadata.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

import {Base64} from "./Base64.sol";
import {Util} from "./Util.sol";
import {Base64} from "libraries/Base64.sol";
import {Util} from "libraries/Util.sol";

/// @title Metadata
/// @author Bumblebee Systems
library Metadata {
string constant JSON_BASE64_HEADER = "data:application/json;base64,";
string constant SVG_XML_BASE64_HEADER = "data:image/svg+xml;base64,";
Expand Down
16 changes: 9 additions & 7 deletions src/libraries/Motes.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Palette} from "./Palette.sol";
import {Data} from "./Data.sol";
import {Util} from "./Util.sol";
import {SVG} from "./SVG.sol";
import {Traits} from "./Traits.sol";
import {Palette} from "libraries/Palette.sol";
import {Data} from "libraries/Data.sol";
import {Util} from "libraries/Util.sol";
import {SVG} from "libraries/SVG.sol";
import {Traits} from "libraries/Traits.sol";

enum MoteType {
NONE,
Expand All @@ -15,8 +15,10 @@ enum MoteType {
GLISTENING
}

/// @title Motes
/// @author Bumblebee Systems
library Motes {
uint256 constant GLINT_COUNT = 20;
uint256 constant MOTE_COUNT = 20;

/*//////////////////////////////////////////////////////////////
RENDER
Expand All @@ -28,7 +30,7 @@ library Motes {
MoteType moteType = Traits.moteType(_seed);
if (moteType == MoteType.NONE) return "";

for (uint8 i = 0; i < GLINT_COUNT; i++) {
for (uint8 i = 0; i < MOTE_COUNT; i++) {
uint256 moteSeed = uint256(keccak256(abi.encodePacked(_seed, "mote", i)));

string memory dur = Data.longTimes(moteSeed /= Data.length);
Expand Down
6 changes: 4 additions & 2 deletions src/libraries/Mouth.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.0;

import {Palette} from "./Palette.sol";
import {Traits} from "./Traits.sol";
import {Palette} from "libraries/Palette.sol";
import {Traits} from "libraries/Traits.sol";

enum MouthType {
SMILE,
Expand All @@ -19,6 +19,8 @@ enum MouthType {
BLEP
}

/// @title Mouth
/// @author Bumblebee Systems
library Mouth {
string constant fill = "black";

Expand Down
Loading

0 comments on commit 8f093bc

Please sign in to comment.