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

20240417 base58 shortnames; resolve IPFS metadata #145

Merged
merged 22 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e81a9b1
(deploy): update version number
benjaminbollen Apr 10, 2024
f853e96
(ERC1155): add total supply to mint paths; also name() and symbol()
benjaminbollen Apr 10, 2024
98b0a36
(Circles): update mint and burn for total supply
benjaminbollen Apr 12, 2024
7b78c74
(changelog): update changelog
benjaminbollen Apr 12, 2024
553a81c
(deploy): deployed version to chiado for testing
benjaminbollen Apr 12, 2024
2365942
Merge branch '20240410-totalsupply-name-erc1155' into feature-v0.3.4
benjaminbollen Apr 16, 2024
bbcf0ca
Merge branch '20240412-operate-flow-reentrency-guard' into feature-v0…
benjaminbollen Apr 16, 2024
4f2b439
Merge branch '20240412-consented-flow' into feature-v0.3.4
benjaminbollen Apr 16, 2024
288be7a
(circles): forge fmt
benjaminbollen Apr 16, 2024
4030508
(hub): merging all open 0.3.4 PRs and fixing total build size
benjaminbollen Apr 16, 2024
23778d8
(hub): assert that transient storage builds with solc, but not with f…
benjaminbollen Apr 17, 2024
5f174c5
Merge branch 'feature-v0.3.4' into 20240416-fitting-034-together
benjaminbollen Apr 17, 2024
cafe074
(hub): forge fmt
benjaminbollen Apr 17, 2024
727a45a
(hub, nameRegistry): impl IPFS uri for erc1155, with fallback to cons…
benjaminbollen Apr 17, 2024
783b4a5
(hub): make private values that can be read from verification constru…
benjaminbollen Apr 17, 2024
d82a290
(nameRegistry): refactor for better internal fcts; preparation to mak…
benjaminbollen Apr 18, 2024
d9b07ac
(test/names): cutting short effort to handle decoding base58 in tests
benjaminbollen Apr 30, 2024
53a796c
(NameRegistry): simplify to metadata digest storage, test short names
benjaminbollen Apr 30, 2024
b818894
(NameRegistry): test base58 conversion for short names
benjaminbollen Apr 30, 2024
76fc410
(NameRegistry): short names should always be padded to 12 characters
benjaminbollen May 2, 2024
4d92020
Merge branch 'develop' into 20240417-uri-with-ipfsv0
benjaminbollen May 3, 2024
b37a433
(test/names): remove unused base58 decoder
benjaminbollen May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## latest

- [PR141] consented flow with bi-directional trust, with opt-out to v1 protocol of uni-directional trust
- [PR138] storage-based reentrency guard for operateFlowMatrix
- [PR136] total supply, name and symbol for ERC1155 (out of specification)

## v0.3.3

- [PR132] bug fix in groupMint(); initial test coverage for group mint
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Chiado deployment
=================
Deployment Date: 2024-04-12 15:12:00
Version: 0.3.3-alpha
Git Commit: 7b78c749b91175265f2cf934fcc4f51a2085358d
Deployer Address: 0x7619F26728Ced663E50E578EB6ff42430931564c, Intitial nonce: 108
Compiler Version: v0.8.23+commit.f704f362

Deployed Contracts:
Hub: 0xFFfbD3E62203B888bb8E09c1fcAcE58242674964
Migration: 0x9c7E2AfAc052743944d5d8F80Db90E1E14A663aE
NameRegistry: 0x0A1D308a39A6dF8972A972E586E4b4b3Dc73520f
ERC20Lift: 0xaA20efff0511175C091F156D095DD3b62951Be48
StandardTreasury: 0x97c28CCC374570C2b10f7569197919418D702F99
BaseGroupMintPolicy: 0x95fbD8D52c18b6AA453e9cB06851543f125DCedE
MastercopyDemurrageERC20: 0x44A47EC79B45A13e884328018320D90DE86Bb932
MastercopyInflationaryERC20: 0xb4A1012a0564a25dF5a8311d1B6DF47b098BdfdB
MastercopyStandardVault: 0x8E0115358DC2Dc984c0C1d9530BEE19616492177
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{"contractName":"Hub","deployedAddress":"0xFFfbD3E62203B888bb8E09c1fcAcE58242674964","sourcePath":"src/hub/Hub.sol:Hub","constructor-args":"0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0x0A1D308a39A6dF8972A972E586E4b4b3Dc73520f 0x9c7E2AfAc052743944d5d8F80Db90E1E14A663aE 0xaA20efff0511175C091F156D095DD3b62951Be48 0x97c28CCC374570C2b10f7569197919418D702F99 1675209600 31540000 https://fallback.aboutcircles.com/v1/circles/{id}.json","argumentsFile":"constructorArgs_Hub.txt"}
{"contractName":"Migration","deployedAddress":"0x9c7E2AfAc052743944d5d8F80Db90E1E14A663aE","sourcePath":"src/migration/Migration.sol:Migration","constructor-args":"0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0xFFfbD3E62203B888bb8E09c1fcAcE58242674964 1675209600","argumentsFile":"constructorArgs_Migration.txt"}
{"contractName":"NameRegistry","deployedAddress":"0x0A1D308a39A6dF8972A972E586E4b4b3Dc73520f","sourcePath":"src/names/NameRegistry.sol:NameRegistry","constructor-args":"0xFFfbD3E62203B888bb8E09c1fcAcE58242674964","argumentsFile":"constructorArgs_NameRegistry.txt"}
{"contractName":"ERC20Lift","deployedAddress":"0xaA20efff0511175C091F156D095DD3b62951Be48","sourcePath":"src/lift/ERC20Lift.sol:ERC20Lift","constructor-args":"0xFFfbD3E62203B888bb8E09c1fcAcE58242674964 0x0A1D308a39A6dF8972A972E586E4b4b3Dc73520f 0x44A47EC79B45A13e884328018320D90DE86Bb932 0xb4A1012a0564a25dF5a8311d1B6DF47b098BdfdB","argumentsFile":"constructorArgs_ERC20Lift.txt"}
{"contractName":"StandardTreasury","deployedAddress":"0x97c28CCC374570C2b10f7569197919418D702F99","sourcePath":"src/treasury/StandardTreasury.sol:StandardTreasury","constructor-args":"0xFFfbD3E62203B888bb8E09c1fcAcE58242674964 0x8E0115358DC2Dc984c0C1d9530BEE19616492177","argumentsFile":"constructorArgs_StandardTreasury.txt"}
{"contractName":"BaseGroupMintPolicy","deployedAddress":"0x95fbD8D52c18b6AA453e9cB06851543f125DCedE","sourcePath":"src/groups/BaseMintPolicy.sol:MintPolicy","constructor-args":"","argumentsFile":"constructorArgs_BaseGroupMintPolicy.txt"}
{"contractName":"MastercopyDemurrageERC20","deployedAddress":"0x44A47EC79B45A13e884328018320D90DE86Bb932","sourcePath":"src/lift/DemurrageCircles.sol:DemurrageCircles","constructor-args":"","argumentsFile":"constructorArgs_MastercopyDemurrageERC20.txt"}
{"contractName":"MastercopyInflationaryERC20","deployedAddress":"0xb4A1012a0564a25dF5a8311d1B6DF47b098BdfdB","sourcePath":"src/lift/InflationaryCircles.sol:InflationaryCircles","constructor-args":"","argumentsFile":"constructorArgs_MastercopyInflationaryERC20.txt"}
{"contractName":"MastercopyStandardVault","deployedAddress":"0x8E0115358DC2Dc984c0C1d9530BEE19616492177","sourcePath":"src/treasury/StandardVault.sol:StandardVault","constructor-args":"","argumentsFile":"constructorArgs_MastercopyStandardVault.txt"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0xFFfbD3E62203B888bb8E09c1fcAcE58242674964 0x0A1D308a39A6dF8972A972E586E4b4b3Dc73520f 0x44A47EC79B45A13e884328018320D90DE86Bb932 0xb4A1012a0564a25dF5a8311d1B6DF47b098BdfdB
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0x0A1D308a39A6dF8972A972E586E4b4b3Dc73520f 0x9c7E2AfAc052743944d5d8F80Db90E1E14A663aE 0xaA20efff0511175C091F156D095DD3b62951Be48 0x97c28CCC374570C2b10f7569197919418D702F99 1675209600 31540000 https://fallback.aboutcircles.com/v1/circles/{id}.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0xdbF22D4e8962Db3b2F1d9Ff55be728A887e47710 0xFFfbD3E62203B888bb8E09c1fcAcE58242674964 1675209600
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0xFFfbD3E62203B888bb8E09c1fcAcE58242674964
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0xFFfbD3E62203B888bb8E09c1fcAcE58242674964 0x8E0115358DC2Dc984c0C1d9530BEE19616492177
46 changes: 41 additions & 5 deletions src/circles/Circles.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.24;

import "../errors/Errors.sol";
import "../lib/Math64x64.sol";
import "./ERC1155.sol";

contract Circles is ERC1155 {
contract Circles is ERC1155, ICirclesErrors {
// Type declarations

/**
Expand Down Expand Up @@ -56,7 +57,7 @@ contract Circles is ERC1155 {
* and the status of the v1 Circles minting.
* @dev This is used to store the last mint time for each avatar.
*/
mapping(address => MintTime) public mintTimes;
mapping(address => MintTime) internal mintTimes;

// Events

Expand All @@ -74,8 +75,6 @@ contract Circles is ERC1155 {
DiscountedBalances(_inflation_day_zero)
{}

// External functions

// Public functions

/**
Expand Down Expand Up @@ -142,13 +141,50 @@ contract Circles is ERC1155 {
return;
}
// mint personal Circles to the human
_mint(_human, toTokenId(_human), issuance, "");
_mintAndUpdateTotalSupply(_human, toTokenId(_human), issuance, "");
// update the last mint time
mintTimes[_human].lastMintTime = uint96(block.timestamp);

emit PersonalMint(_human, issuance, startPeriod, endPeriod);
}

function _mintAndUpdateTotalSupply(address _account, uint256 _id, uint256 _value, bytes memory _data) internal {
_mint(_account, _id, _value, _data);

uint64 today = day(block.timestamp);
DiscountedBalance storage totalSupplyBalance = discountedTotalSupplies[_id];
uint256 newTotalSupply =
_calculateDiscountedBalance(totalSupplyBalance.balance, today - totalSupplyBalance.lastUpdatedDay) + _value;
if (newTotalSupply > MAX_VALUE) {
// DiscountedBalances: balance exceeds maximum value
revert CirclesERC1155AmountExceedsMaxUint190(_account, _id, newTotalSupply, 2);
}
totalSupplyBalance.balance = uint192(newTotalSupply);
totalSupplyBalance.lastUpdatedDay = today;
}

function _burnAndUpdateTotalSupply(address _account, uint256 _id, uint256 _value) internal {
// _update will discount the balance before subtracting the value
_burn(_account, _id, _value);

uint64 today = day(block.timestamp);
DiscountedBalance storage totalSupplyBalance = discountedTotalSupplies[_id];
uint256 discountedTotalSupply =
_calculateDiscountedBalance(totalSupplyBalance.balance, today - totalSupplyBalance.lastUpdatedDay);
if (discountedTotalSupply < _value) {
// Logically impossible to burn more than the total supply
// however if the total supply nears dust, the discounting of the balance
// and the total supply might differ on the least significant bits.
// There is no good way to handle this, so user should burn a few attoCRC less,
// or wait a day for the total supply to be discounted to zero automatically.
revert CirclesLogicAssertion(4);
}
unchecked {
totalSupplyBalance.balance = uint192(discountedTotalSupply - _value);
}
totalSupplyBalance.lastUpdatedDay = today;
}

// Private functions

/**
Expand Down
27 changes: 16 additions & 11 deletions src/circles/DiscountedBalances.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ contract DiscountedBalances is Demurrage {
* @dev stores the discounted balances of the accounts privately.
* Mapping from Circles identifiers to accounts to the discounted balance.
*/
mapping(uint256 => mapping(address => DiscountedBalance)) public discountedBalances;
mapping(uint256 => mapping(address => DiscountedBalance)) internal discountedBalances;

/**
* @dev stores the total supply for each Circles identifier
*/
mapping(uint256 => DiscountedBalance) internal discountedTotalSupplies;

// Constructor

Expand All @@ -36,17 +41,17 @@ contract DiscountedBalances is Demurrage {
return _calculateDiscountedBalance(discountedBalance.balance, _day - discountedBalance.lastUpdatedDay);
}

// Internal functions
/**
* @notice Total supply of a Circles identifier.
* @param _id Circles identifier for which to calculate the total supply
*/
function totalSupply(uint256 _id) public view returns (uint256) {
DiscountedBalance memory totalSupplyBalance = discountedTotalSupplies[_id];
uint64 today = day(block.timestamp);
return _calculateDiscountedBalance(totalSupplyBalance.balance, today - totalSupplyBalance.lastUpdatedDay);
}

// /**
// * @dev Calculate the inflationary balance of a discounted balance
// * @param _account Address of the account to calculate the balance of
// * @param _id Circles identifier for which to calculate the balance
// */
// function _inflationaryBalanceOf(address _account, uint256 _id) internal view returns (uint256) {
// DiscountedBalance memory discountedBalance = discountedBalances[_id][_account];
// return _calculateInflationaryBalance(discountedBalance.balance, discountedBalance.lastUpdatedDay);
// }
// Internal functions

/**
* @dev Update the balance of an account for a given Circles identifier
Expand Down
25 changes: 13 additions & 12 deletions src/circles/ERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,12 @@ abstract contract ERC1155 is DiscountedBalances, Context, ERC165, IERC1155, IERC
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
if (to == address(0)) {
revert ERC1155InvalidReceiver(address(0));
}
_updateWithAcceptanceCheck(address(0), to, ids, values, data);
}
// function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal {
// if (to == address(0)) {
// revert ERC1155InvalidReceiver(address(0));
// }
// _updateWithAcceptanceCheck(address(0), to, ids, values, data);
// }

/**
* @dev Destroys a `value` amount of tokens of type `id` from `from`
Expand Down Expand Up @@ -376,13 +376,14 @@ abstract contract ERC1155 is DiscountedBalances, Context, ERC165, IERC1155, IERC
* - `from` cannot be the zero address.
* - `from` must have at least `value` amount of tokens of type `id`.
* - `ids` and `values` must have the same length.
* //
*/
function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
if (from == address(0)) {
revert ERC1155InvalidSender(address(0));
}
_updateWithAcceptanceCheck(from, address(0), ids, values, "");
}
// function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal {
// if (from == address(0)) {
// revert ERC1155InvalidSender(address(0));
// }
// _updateWithAcceptanceCheck(from, address(0), ids, values, "");
// }

/**
* @dev Approve `operator` to operate on all of `owner` tokens
Expand Down
Loading
Loading