Skip to content

Commit

Permalink
Transpile 84df2bc
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Mar 2, 2023
1 parent cb0c144 commit 6753832
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 15 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 4.8.2

- `ERC721Consecutive`: Fixed a bug when `_mintConsecutive` is used for batches of size 1 that could lead to balance overflow. Refer to the breaking changes section in the changelog for a note on the behavior of `ERC721._beforeTokenTransfer`.

### Breaking changes

- `ERC721`: The internal function `_beforeTokenTransfer` no longer updates balances, which it previously did when `batchSize` was greater than 1. This change has no consequence unless a custom ERC721 extension is explicitly invoking `_beforeTokenTransfer`. Balance updates in extensions must now be done explicitly using `__unsafe_increaseBalance`, with a name that indicates that there is an invariant that has to be manually verified.

## 4.8.1 (2023-01-13)

* `ERC4626`: Use staticcall instead of call when fetching underlying ERC-20 decimals. ([#3943](https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3943))
Expand Down
140 changes: 140 additions & 0 deletions contracts/mocks/WithInit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
pragma solidity >=0.7 <0.9;
pragma experimental ABIEncoderV2;

import "../access/AccessControlUpgradeable.sol";

contract AccessControlUpgradeableWithInit is AccessControlUpgradeable {
constructor() payable initializer {
__AccessControl_init();
}
}
import "../utils/ContextUpgradeable.sol";

contract ContextUpgradeableWithInit is ContextUpgradeable {
constructor() payable initializer {
__Context_init();
}
}
import "../utils/introspection/ERC165Upgradeable.sol";

contract ERC165UpgradeableWithInit is ERC165Upgradeable {
constructor() payable initializer {
__ERC165_init();
}
}
import "./AccessControlMockUpgradeable.sol";

contract AccessControlMockUpgradeableWithInit is AccessControlMockUpgradeable {
Expand All @@ -21,6 +42,13 @@ contract TimelockControllerUpgradeableWithInit is TimelockControllerUpgradeable
__TimelockController_init(minDelay, proposers, executors, admin);
}
}
import "../utils/cryptography/EIP712Upgradeable.sol";

contract EIP712UpgradeableWithInit is EIP712Upgradeable {
constructor(string memory name, string memory version) payable initializer {
__EIP712_init(name, version);
}
}
import "./wizard/MyGovernor3Upgradeable.sol";

contract MyGovernorUpgradeableWithInit is MyGovernorUpgradeable {
Expand Down Expand Up @@ -126,13 +154,27 @@ contract ERC1271MaliciousMockUpgradeableWithInit is ERC1271MaliciousMockUpgradea
__ERC1271MaliciousMock_init();
}
}
import "../access/OwnableUpgradeable.sol";

contract OwnableUpgradeableWithInit is OwnableUpgradeable {
constructor() payable initializer {
__Ownable_init();
}
}
import "../utils/escrow/EscrowUpgradeable.sol";

contract EscrowUpgradeableWithInit is EscrowUpgradeable {
constructor() payable initializer {
__Escrow_init();
}
}
import "../utils/MulticallUpgradeable.sol";

contract MulticallUpgradeableWithInit is MulticallUpgradeable {
constructor() payable initializer {
__Multicall_init();
}
}
import "./MulticallTokenMockUpgradeable.sol";

contract MulticallTokenMockUpgradeableWithInit is MulticallTokenMockUpgradeable {
Expand All @@ -159,6 +201,20 @@ contract ERC20PresetMinterPauserUpgradeableWithInit is ERC20PresetMinterPauserUp
__ERC20PresetMinterPauser_init(name, symbol);
}
}
import "../access/AccessControlEnumerableUpgradeable.sol";

contract AccessControlEnumerableUpgradeableWithInit is AccessControlEnumerableUpgradeable {
constructor() payable initializer {
__AccessControlEnumerable_init();
}
}
import "../security/PausableUpgradeable.sol";

contract PausableUpgradeableWithInit is PausableUpgradeable {
constructor() payable initializer {
__Pausable_init();
}
}
import "../token/ERC777/ERC777Upgradeable.sol";

contract ERC777UpgradeableWithInit is ERC777Upgradeable {
Expand Down Expand Up @@ -337,6 +393,13 @@ contract ERC1155BurnableMockUpgradeableWithInit is ERC1155BurnableMockUpgradeabl
__ERC1155BurnableMock_init(uri);
}
}
import "../utils/introspection/ERC165StorageUpgradeable.sol";

contract ERC165StorageUpgradeableWithInit is ERC165StorageUpgradeable {
constructor() payable initializer {
__ERC165Storage_init();
}
}
import "./ERC165StorageMockUpgradeable.sol";

contract ERC165StorageMockUpgradeableWithInit is ERC165StorageMockUpgradeable {
Expand Down Expand Up @@ -479,6 +542,13 @@ contract ERC165InterfacesSupportedUpgradeableWithInit is ERC165InterfacesSupport
__ERC165InterfacesSupported_init(interfaceIds);
}
}
import "../token/common/ERC2981Upgradeable.sol";

contract ERC2981UpgradeableWithInit is ERC2981Upgradeable {
constructor() payable initializer {
__ERC2981_init();
}
}
import "./ERC721RoyaltyMockUpgradeable.sol";

contract ERC721RoyaltyMockUpgradeableWithInit is ERC721RoyaltyMockUpgradeable {
Expand All @@ -500,6 +570,13 @@ contract StringsMockUpgradeableWithInit is StringsMockUpgradeable {
__StringsMock_init();
}
}
import "../proxy/ERC1967/ERC1967UpgradeUpgradeable.sol";

contract ERC1967UpgradeUpgradeableWithInit is ERC1967UpgradeUpgradeable {
constructor() payable initializer {
__ERC1967Upgrade_init();
}
}
import "./UUPS/UUPSUpgradeableMockUpgradeable.sol";

contract UUPSUpgradeableMockUpgradeableWithInit is UUPSUpgradeableMockUpgradeable {
Expand Down Expand Up @@ -882,6 +959,20 @@ contract ReentrancyMockUpgradeableWithInit is ReentrancyMockUpgradeable {
__ReentrancyMock_init();
}
}
import "../security/ReentrancyGuardUpgradeable.sol";

contract ReentrancyGuardUpgradeableWithInit is ReentrancyGuardUpgradeable {
constructor() payable initializer {
__ReentrancyGuard_init();
}
}
import "../crosschain/polygon/CrossChainEnabledPolygonChildUpgradeable.sol";

contract CrossChainEnabledPolygonChildUpgradeableWithInit is CrossChainEnabledPolygonChildUpgradeable {
constructor(address fxChild) CrossChainEnabledPolygonChildUpgradeable(fxChild) payable initializer {

}
}
import "./crosschain/receiversUpgradeable.sol";

contract CrossChainEnabledAMBMockUpgradeableWithInit is CrossChainEnabledAMBMockUpgradeable {
Expand Down Expand Up @@ -924,6 +1015,27 @@ contract CrossChainEnabledAMBUpgradeableWithInit is CrossChainEnabledAMBUpgradea

}
}
import "../crosschain/arbitrum/CrossChainEnabledArbitrumL1Upgradeable.sol";

contract CrossChainEnabledArbitrumL1UpgradeableWithInit is CrossChainEnabledArbitrumL1Upgradeable {
constructor(address bridge) CrossChainEnabledArbitrumL1Upgradeable(bridge) payable initializer {

}
}
import "../crosschain/arbitrum/CrossChainEnabledArbitrumL2Upgradeable.sol";

contract CrossChainEnabledArbitrumL2UpgradeableWithInit is CrossChainEnabledArbitrumL2Upgradeable {
constructor() payable initializer {
__CrossChainEnabledArbitrumL2_init();
}
}
import "../crosschain/optimism/CrossChainEnabledOptimismUpgradeable.sol";

contract CrossChainEnabledOptimismUpgradeableWithInit is CrossChainEnabledOptimismUpgradeable {
constructor(address messenger) CrossChainEnabledOptimismUpgradeable(messenger) payable initializer {

}
}
import "./AccessControlCrossChainMockUpgradeable.sol";

contract AccessControlCrossChainMockUpgradeableWithInit is AccessControlCrossChainMockUpgradeable {
Expand All @@ -933,6 +1045,13 @@ contract AccessControlCrossChainMockUpgradeableWithInit is AccessControlCrossCha
}
import "./crosschain/bridgesUpgradeable.sol";

contract BaseRelayMockUpgradeableWithInit is BaseRelayMockUpgradeable {
constructor() payable initializer {
__BaseRelayMock_init();
}
}
import "./crosschain/bridgesUpgradeable.sol";

contract BridgeAMBMockUpgradeableWithInit is BridgeAMBMockUpgradeable {
constructor() payable initializer {
__BridgeAMBMock_init();
Expand Down Expand Up @@ -1001,6 +1120,13 @@ contract ERC2771ContextMockUpgradeableWithInit is ERC2771ContextMockUpgradeable

}
}
import "../metatx/ERC2771ContextUpgradeable.sol";

contract ERC2771ContextUpgradeableWithInit is ERC2771ContextUpgradeable {
constructor(address trustedForwarder) ERC2771ContextUpgradeable(trustedForwarder) payable initializer {

}
}
import "./ERC20CappedMockUpgradeable.sol";

contract ERC20CappedMockUpgradeableWithInit is ERC20CappedMockUpgradeable {
Expand Down Expand Up @@ -1058,6 +1184,13 @@ contract ConditionalEscrowMockUpgradeableWithInit is ConditionalEscrowMockUpgrad
__ConditionalEscrowMock_init();
}
}
import "../security/PullPaymentUpgradeable.sol";

contract PullPaymentUpgradeableWithInit is PullPaymentUpgradeable {
constructor() payable initializer {
__PullPayment_init();
}
}
import "./PullPaymentMockUpgradeable.sol";

contract PullPaymentMockUpgradeableWithInit is PullPaymentMockUpgradeable {
Expand All @@ -1072,6 +1205,13 @@ contract OwnableMockUpgradeableWithInit is OwnableMockUpgradeable {
__OwnableMock_init();
}
}
import "../access/Ownable2StepUpgradeable.sol";

contract Ownable2StepUpgradeableWithInit is Ownable2StepUpgradeable {
constructor() payable initializer {
__Ownable2Step_init();
}
}
import "./Ownable2StepMockUpgradeable.sol";

contract Ownable2StepMockUpgradeableWithInit is Ownable2StepMockUpgradeable {
Expand Down
25 changes: 14 additions & 11 deletions contracts/token/ERC721/ERC721Upgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -472,18 +472,9 @@ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeab
function _beforeTokenTransfer(
address from,
address to,
uint256, /* firstTokenId */
uint256 firstTokenId,
uint256 batchSize
) internal virtual {
if (batchSize > 1) {
if (from != address(0)) {
_balances[from] -= batchSize;
}
if (to != address(0)) {
_balances[to] += batchSize;
}
}
}
) internal virtual {}

/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
Expand All @@ -506,6 +497,18 @@ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeab
uint256 batchSize
) internal virtual {}

/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}

/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ abstract contract ERC721ConsecutiveUpgradeable is Initializable, IERC2309Upgrade
// push an ownership checkpoint & emit event
uint96 last = first + batchSize - 1;
_sequentialOwnership.push(last, uint160(to));

// The invariant required by this function is preserved because the new sequentialOwnership checkpoint
// is attributing ownership of `batchSize` new tokens to account `to`.
__unsafe_increaseBalance(to, batchSize);

emit ConsecutiveTransfer(first, last, address(0), to);

// hook after
Expand Down
4 changes: 4 additions & 0 deletions contracts/utils/introspection/ERC165CheckerUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ library ERC165CheckerUpgradeable {
* @dev Assumes that account contains a contract that supports ERC165, otherwise
* the behavior of this method is undefined. This precondition can be checked
* with {supportsERC165}.
*
* Some precompiled contracts will falsely indicate support for a given interface, so caution
* should be exercised when using this function.
*
* Interface identification is specified in ERC-165.
*/
function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
Expand Down
Binary file removed docs/modules/ROOT/images/tally-admin.png
Binary file not shown.
Binary file added docs/modules/ROOT/images/tally-exec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/modules/ROOT/images/tally-vote.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
* xref:crosschain.adoc[Crosschain]
* xref:utilities.adoc[Utilities]
* xref:subgraphs::index.adoc[Subgraphs]
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/governance.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ image::tally-vote.png[Voting in Tally]

=== Execute the Proposal

Once the voting period is over, if quorum was reached (enough voting power participated) and the majority voted in favor, the proposal is considered successful and can proceed to be executed. This can also be done in Tally in the "Administration Panel" section of a project.
Once the voting period is over, if quorum was reached (enough voting power participated) and the majority voted in favor, the proposal is considered successful and can proceed to be executed. Once a proposal passes, it can be queued and executed from the same place you voted.

image::tally-admin.png[Administration Panel in Tally]
image::tally-exec.png[Administration Panel in Tally]

We will see now how to do this manually using Ethers.js.

Expand Down
Loading

0 comments on commit 6753832

Please sign in to comment.