Skip to content

Commit

Permalink
feat(contracts): update forge fmt config
Browse files Browse the repository at this point in the history
  • Loading branch information
owieth committed Aug 18, 2023
1 parent a752f2c commit f77ea74
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 116 deletions.
9 changes: 9 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ test = 'tests'
out = 'out'
libs = ['lib']

[fmt]
bracket_spacing = true
int_types = "long"
line_length = 120
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4

[rpc_endpoints]
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}"
goerli = "https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}"
Expand Down
8 changes: 4 additions & 4 deletions scripts/NFTIME.s.sol
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.18;

import {Script} from "@std/Script.sol";
import {NFTIME} from "../src/NFTIME.sol";
import {DateTime} from "../src/libraries/DateTime.sol";
import { Script } from "@std/Script.sol";
import { NFTIME } from "../src/NFTIME.sol";
import { DateTime } from "../src/libraries/DateTime.sol";

contract DeployScript is Script {
function setUp() public {}
function setUp() public { }

function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
Expand Down
41 changes: 23 additions & 18 deletions src/NFTIME.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {Ownable} from "@oz/access/Ownable.sol";
import {AccessControl} from "@oz/access/AccessControl.sol";
import {Counters} from "@oz/utils/Counters.sol";
import {ERC721} from "@oz/token/ERC721/ERC721.sol";
import {ERC721URIStorage} from "@oz/token/ERC721/extensions/ERC721URIStorage.sol";
import {ERC721Enumerable} from "@oz/token/ERC721/extensions/ERC721Enumerable.sol";
import {ERC721Pausable} from "@oz/token/ERC721/extensions/ERC721Pausable.sol";
import {ERC721Burnable} from "@oz/token/ERC721/extensions/ERC721Burnable.sol";
import {Base64} from "@oz/utils/Base64.sol";
import {Strings} from "@oz/utils/Strings.sol";

import {Date, DateTime} from "./libraries/DateTime.sol";
import {NFTIMEMetadata} from "./libraries/NFTIMEMetadata.sol";
import { Ownable } from "@oz/access/Ownable.sol";
import { AccessControl } from "@oz/access/AccessControl.sol";
import { Counters } from "@oz/utils/Counters.sol";
import { ERC721 } from "@oz/token/ERC721/ERC721.sol";
import { ERC721URIStorage } from "@oz/token/ERC721/extensions/ERC721URIStorage.sol";
import { ERC721Enumerable } from "@oz/token/ERC721/extensions/ERC721Enumerable.sol";
import { ERC721Pausable } from "@oz/token/ERC721/extensions/ERC721Pausable.sol";
import { ERC721Burnable } from "@oz/token/ERC721/extensions/ERC721Burnable.sol";
import { Base64 } from "@oz/utils/Base64.sol";
import { Strings } from "@oz/utils/Strings.sol";

import { Date, DateTime } from "./libraries/DateTime.sol";
import { NFTIMEMetadata } from "./libraries/NFTIMEMetadata.sol";

///
/// ███╗ ██╗███████╗████████╗██╗███╗ ███╗███████╗
Expand Down Expand Up @@ -113,7 +113,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E
//////////////////////////////////////////////////////////////*/

/// @dev The received ETH stays in this contract address
receive() external payable {}
receive() external payable { }

/// @notice Mint Regular NFTIME
/// @param _time Timestamp for Token
Expand Down Expand Up @@ -142,7 +142,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E

_isMinute ? s_mintedDays[_dateString] = true : s_mintedMinutes[_dateString] = true;

s_tokens[_newItemId] = TokenStruct({timestamp: _time, rarity: false, nftType: _type});
s_tokens[_newItemId] = TokenStruct({ timestamp: _time, rarity: false, nftType: _type });

return _newItemId;
}
Expand All @@ -160,7 +160,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E

_mint(msg.sender, _newItemId);

s_tokens[_newItemId] = TokenStruct({timestamp: 0, rarity: true, nftType: Type.Rarity});
s_tokens[_newItemId] = TokenStruct({ timestamp: 0, rarity: true, nftType: Type.Rarity });

_setTokenURI(_newItemId, _tokenUri);

Expand All @@ -169,7 +169,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E

/// @notice Withdraw collected funds
function withdraw() external payable onlyRole(DEFAULT_ADMIN_ROLE) {
(bool success,) = payable(msg.sender).call{value: address(this).balance}("");
(bool success,) = payable(msg.sender).call{ value: address(this).balance }("");
if (!success) {
revert NFTIME__WithdrawError();
}
Expand Down Expand Up @@ -257,7 +257,12 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E
}

/// @dev See {ERC721-_beforeTokenTransfer}.
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize)
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
)
internal
override(ERC721, ERC721Enumerable, ERC721Pausable)
{
Expand Down
47 changes: 30 additions & 17 deletions src/V1/NFTIMEV1.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {Ownable} from "@oz/access/Ownable.sol";
import {AccessControl} from "@oz/access/AccessControl.sol";
import {Counters} from "@oz/utils/Counters.sol";
import {ERC721} from "@oz/token/ERC721/ERC721.sol";
import {ERC721URIStorage} from "@oz/token/ERC721/extensions/ERC721URIStorage.sol";
import {ERC721Enumerable} from "@oz/token/ERC721/extensions/ERC721Enumerable.sol";
import {ERC721Pausable} from "@oz/token/ERC721/extensions/ERC721Pausable.sol";
import {ERC721Burnable} from "@oz/token/ERC721/extensions/ERC721Burnable.sol";
import {Base64} from "@oz/utils/Base64.sol";
import {Strings} from "@oz/utils/Strings.sol";

import {Date, DateTime} from "./utils/DateTime.sol";
import {Renderer} from "./utils/Renderer.sol";
import { Ownable } from "@oz/access/Ownable.sol";
import { AccessControl } from "@oz/access/AccessControl.sol";
import { Counters } from "@oz/utils/Counters.sol";
import { ERC721 } from "@oz/token/ERC721/ERC721.sol";
import { ERC721URIStorage } from "@oz/token/ERC721/extensions/ERC721URIStorage.sol";
import { ERC721Enumerable } from "@oz/token/ERC721/extensions/ERC721Enumerable.sol";
import { ERC721Pausable } from "@oz/token/ERC721/extensions/ERC721Pausable.sol";
import { ERC721Burnable } from "@oz/token/ERC721/extensions/ERC721Burnable.sol";
import { Base64 } from "@oz/utils/Base64.sol";
import { Strings } from "@oz/utils/Strings.sol";

import { Date, DateTime } from "./utils/DateTime.sol";
import { Renderer } from "./utils/Renderer.sol";

/**
* c00l ,k0d. c0000000000000000d. c000000000000000d.
Expand Down Expand Up @@ -107,7 +107,11 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E

/// @dev Mint Rarity NFTIME
/// @param _tokenUri TokenURI to special rarity NFTIME
function rarityMint(string memory _tokenUri, string memory name, Date memory date)
function rarityMint(
string memory _tokenUri,
string memory name,
Date memory date
)
public
onlyRole(DEFAULT_ADMIN_ROLE)
whenNotPaused
Expand Down Expand Up @@ -158,7 +162,11 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E
/// @dev Render the JSON Metadata for a given rarity NFTIME.
/// @param _tokenId The id of the token to render.
/// @param _ipfsURI Custom ipfs uri.
function _rarityTokenURI(uint256 _tokenId, string memory _ipfsURI, string memory _name)
function _rarityTokenURI(
uint256 _tokenId,
string memory _ipfsURI,
string memory _name
)
public
view
returns (string memory)
Expand Down Expand Up @@ -254,7 +262,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E

/// @dev Withdraw collected Funds
function withdraw() public payable onlyRole(DEFAULT_ADMIN_ROLE) {
(bool success,) = payable(msg.sender).call{value: address(this).balance}("");
(bool success,) = payable(msg.sender).call{ value: address(this).balance }("");
require(success, "Unable to withdraw");
}

Expand All @@ -269,7 +277,12 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E
return super.tokenURI(_tokenId);
}

function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize)
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
)
internal
override(ERC721, ERC721Enumerable, ERC721Pausable)
{
Expand Down
10 changes: 5 additions & 5 deletions src/V1/utils/DateTime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract DateTime {
uint256 private constant SECONDS_PER_DAY = 24 * 60 * 60;
uint256 private constant SECONDS_PER_HOUR = 60 * 60;
uint256 private constant SECONDS_PER_MINUTE = 60;
int256 constant OFFSET19700101 = 2440588;
int256 constant OFFSET19700101 = 2_440_588;

function timestampToDateTime(uint256 _timestamp) public pure returns (Date memory) {
(uint256 year, string memory month, string memory day) = _daysToDate(_timestamp / SECONDS_PER_DAY);
Expand All @@ -46,10 +46,10 @@ contract DateTime {
function _daysToDate(uint256 _days) internal pure returns (uint256 year, string memory month, string memory day) {
int256 __days = int256(_days);

int256 L = __days + 68569 + OFFSET19700101;
int256 N = (4 * L) / 146097;
L = L - (146097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1461001;
int256 L = __days + 68_569 + OFFSET19700101;
int256 N = (4 * L) / 146_097;
L = L - (146_097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1_461_001;
L = L - (1461 * _year) / 4 + 31;
int256 _month = (80 * L) / 2447;
int256 _day = L - (2447 * _month) / 80;
Expand Down
12 changes: 10 additions & 2 deletions src/V1/utils/Renderer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ contract Renderer {
string memory width,
string memory transformX,
string memory transformY
) internal pure returns (string memory) {
)
internal
pure
returns (string memory)
{
return string.concat(
'<foreignObject x="',
transformX,
Expand All @@ -106,7 +110,11 @@ contract Renderer {
return svg.path(string.concat(svg.prop("fill", "none"), svg.prop("stroke", stroke), svg.prop("d", d)), "");
}

function getSVGClockPath(string memory d, uint256 rotation, uint256 product)
function getSVGClockPath(
string memory d,
uint256 rotation,
uint256 product
)
internal
pure
returns (string memory)
Expand Down
12 changes: 10 additions & 2 deletions src/V1/utils/SVG.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ library svg {
return el("linearGradient", _props, _children);
}

function gradientStop(uint256 offset, string memory stopColor, string memory _props)
function gradientStop(
uint256 offset,
string memory stopColor,
string memory _props
)
internal
pure
returns (string memory)
Expand All @@ -83,7 +87,11 @@ library svg {

/* COMMON */
// A generic element, can be used to construct any SVG (or HTML) element
function el(string memory _tag, string memory _props, string memory _children)
function el(
string memory _tag,
string memory _props,
string memory _children
)
internal
pure
returns (string memory)
Expand Down
29 changes: 17 additions & 12 deletions src/V2/NFTIMEV2.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import {Ownable} from "@oz/access/Ownable.sol";
import {AccessControl} from "@oz/access/AccessControl.sol";
import {Counters} from "@oz/utils/Counters.sol";
import {ERC721} from "@oz/token/ERC721/ERC721.sol";
import {ERC721URIStorage} from "@oz/token/ERC721/extensions/ERC721URIStorage.sol";
import {ERC721Enumerable} from "@oz/token/ERC721/extensions/ERC721Enumerable.sol";
import {ERC721Pausable} from "@oz/token/ERC721/extensions/ERC721Pausable.sol";
import {ERC721Burnable} from "@oz/token/ERC721/extensions/ERC721Burnable.sol";
import { Ownable } from "@oz/access/Ownable.sol";
import { AccessControl } from "@oz/access/AccessControl.sol";
import { Counters } from "@oz/utils/Counters.sol";
import { ERC721 } from "@oz/token/ERC721/ERC721.sol";
import { ERC721URIStorage } from "@oz/token/ERC721/extensions/ERC721URIStorage.sol";
import { ERC721Enumerable } from "@oz/token/ERC721/extensions/ERC721Enumerable.sol";
import { ERC721Pausable } from "@oz/token/ERC721/extensions/ERC721Pausable.sol";
import { ERC721Burnable } from "@oz/token/ERC721/extensions/ERC721Burnable.sol";

import {Date, DateTime} from "./libraries/DateTime.sol";
import { Date, DateTime } from "./libraries/DateTime.sol";

///
/// ███╗ ██╗███████╗████████╗██╗███╗ ███╗███████╗
Expand Down Expand Up @@ -99,7 +99,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E
//////////////////////////////////////////////////////////////*/

/// @dev The received ETH stays in this contract address
receive() external payable {}
receive() external payable { }

/// @dev Mint Regular NFTIME
/// @param _time Timestamp for minted NFTIME
Expand Down Expand Up @@ -149,7 +149,7 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E

/// @dev Withdraw collected Funds
function withdraw() external payable onlyRole(DEFAULT_ADMIN_ROLE) {
(bool success,) = payable(msg.sender).call{value: address(this).balance}("");
(bool success,) = payable(msg.sender).call{ value: address(this).balance }("");
if (!success) {
revert NFTIME__WithdrawError();
}
Expand Down Expand Up @@ -218,7 +218,12 @@ contract NFTIME is Ownable, AccessControl, ERC721URIStorage, ERC721Enumerable, E
/// @param to Recipient's Address
/// @param firstTokenId Token ID
/// @param batchSize Size of Batch
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize)
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
)
internal
override(ERC721, ERC721Enumerable, ERC721Pausable)
{
Expand Down
12 changes: 6 additions & 6 deletions src/V2/libraries/DateTime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pragma solidity ^0.8.18;

import {Strings} from "@oz/utils/Strings.sol";
import { Strings } from "@oz/utils/Strings.sol";

struct Date {
uint256 year;
Expand All @@ -22,7 +22,7 @@ library DateTime {
uint256 private constant SECONDS_PER_DAY = 24 * 60 * 60;
uint256 private constant SECONDS_PER_HOUR = 60 * 60;
uint256 private constant SECONDS_PER_MINUTE = 60;
int256 private constant OFFSET19700101 = 2440588;
int256 private constant OFFSET19700101 = 2_440_588;

string private constant WEEKDAY_MON = "MON";
string private constant WEEKDAY_TUE = "TUE";
Expand Down Expand Up @@ -68,10 +68,10 @@ library DateTime {
function _daysToDate(uint256 _days) internal pure returns (uint256 year, string memory month, string memory day) {
int256 __days = int256(_days);

int256 L = __days + 68569 + OFFSET19700101;
int256 N = (4 * L) / 146097;
L = L - (146097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1461001;
int256 L = __days + 68_569 + OFFSET19700101;
int256 N = (4 * L) / 146_097;
L = L - (146_097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1_461_001;
L = L - (1461 * _year) / 4 + 31;
int256 _month = (80 * L) / 2447;
int256 _day = L - (2447 * _month) / 80;
Expand Down
12 changes: 6 additions & 6 deletions src/libraries/DateTime.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

pragma solidity ^0.8.18;

import {Strings} from "@oz/utils/Strings.sol";
import { Strings } from "@oz/utils/Strings.sol";

/// @dev Struct for all necessary Date-Attributes
struct Date {
Expand Down Expand Up @@ -38,7 +38,7 @@ library DateTime {
uint256 private constant SECONDS_PER_DAY = 24 * 60 * 60;
uint256 private constant SECONDS_PER_HOUR = 60 * 60;
uint256 private constant SECONDS_PER_MINUTE = 60;
int256 private constant OFFSET19700101 = 2440588;
int256 private constant OFFSET19700101 = 2_440_588;

string private constant WEEKDAY_MON = "MON";
string private constant WEEKDAY_TUE = "TUE";
Expand Down Expand Up @@ -108,10 +108,10 @@ library DateTime {
function _daysToDate(uint256 _days) internal pure returns (uint256 year, string memory month, string memory day) {
int256 __days = int256(_days);

int256 L = __days + 68569 + OFFSET19700101;
int256 N = (4 * L) / 146097;
L = L - (146097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1461001;
int256 L = __days + 68_569 + OFFSET19700101;
int256 N = (4 * L) / 146_097;
L = L - (146_097 * N + 3) / 4;
int256 _year = (4000 * (L + 1)) / 1_461_001;
L = L - (1461 * _year) / 4 + 31;
int256 _month = (80 * L) / 2447;
int256 _day = L - (2447 * _month) / 80;
Expand Down
Loading

0 comments on commit f77ea74

Please sign in to comment.