Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- Add `managed` access control option for use with AccessManager. ([#298](https://github.com/OpenZeppelin/contracts-wizard/pull/298))

## 0.4.0 (2023-10-05)

### Breaking changes
Expand Down
11 changes: 11 additions & 0 deletions packages/core/src/custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ testCustom('access control roles', {
access: 'roles',
});

testCustom('access control managed', {
access: 'managed',
});

testCustom('upgradeable uups with access control disabled', {
// API should override access to true since it is required for UUPS
access: false,
Expand All @@ -69,6 +73,13 @@ testAPIEquivalence('custom API full upgradeable', {
upgradeable: 'uups',
});

testAPIEquivalence('custom API full upgradeable with managed', {
name: 'CustomContract',
access: 'managed',
pausable: true,
upgradeable: 'uups',
});

test('custom API assert defaults', async t => {
t.is(custom.print(custom.defaults), custom.print());
});
Expand Down
14 changes: 14 additions & 0 deletions packages/core/src/custom.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ Generated by [AVA](https://avajs.dev).
}␊
`

## access control managed

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
pragma solidity ^0.8.20;␊
import "@openzeppelin/contracts/access/manager/AccessManaged.sol";␊
contract MyContract is AccessManaged {␊
constructor(address initialAuthority) AccessManaged(initialAuthority) {}␊
}␊
`

## upgradeable uups with access control disabled

> Snapshot 1
Expand Down
Binary file modified packages/core/src/custom.test.ts.snap
Binary file not shown.
17 changes: 17 additions & 0 deletions packages/core/src/erc1155.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ testERC1155('basic + roles', {
access: 'roles',
});

testERC1155('basic + managed', {
access: 'managed',
});

testERC1155('no updatable uri', {
updatableUri: false,
});
Expand All @@ -55,6 +59,11 @@ testERC1155('mintable + roles', {
access: 'roles',
});

testERC1155('mintable + managed', {
mintable: true,
access: 'managed',
});

testERC1155('supply tracking', {
supply: true,
});
Expand All @@ -75,6 +84,14 @@ testERC1155('full upgradeable uups', {
upgradeable: 'uups',
});

testERC1155('full upgradeable transparent with managed', {
mintable: true,
access: 'managed',
burnable: true,
pausable: true,
upgradeable: 'uups',
});

testAPIEquivalence('API default');

testAPIEquivalence('API basic', { name: 'CustomToken', uri: 'https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/' });
Expand Down
129 changes: 129 additions & 0 deletions packages/core/src/erc1155.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ Generated by [AVA](https://avajs.dev).
}␊
`

## basic + managed

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
pragma solidity ^0.8.20;␊
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import "@openzeppelin/contracts/access/manager/AccessManaged.sol";␊
contract MyToken is ERC1155, AccessManaged {␊
constructor(address initialAuthority)␊
ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
AccessManaged(initialAuthority)␊
{}␊
function setURI(string memory newuri) public restricted {␊
_setURI(newuri);␊
}␊
}␊
`

## no updatable uri

> Snapshot 1
Expand Down Expand Up @@ -229,6 +251,42 @@ Generated by [AVA](https://avajs.dev).
}␊
`

## mintable + managed

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
pragma solidity ^0.8.20;␊
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import "@openzeppelin/contracts/access/manager/AccessManaged.sol";␊
contract MyToken is ERC1155, AccessManaged {␊
constructor(address initialAuthority)␊
ERC1155("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/")␊
AccessManaged(initialAuthority)␊
{}␊
function setURI(string memory newuri) public restricted {␊
_setURI(newuri);␊
}␊
function mint(address account, uint256 id, uint256 amount, bytes memory data)␊
public␊
restricted␊
{␊
_mint(account, id, amount, data);␊
}␊
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
public␊
restricted␊
{␊
_mintBatch(to, ids, amounts, data);␊
}␊
}␊
`

## supply tracking

> Snapshot 1
Expand Down Expand Up @@ -434,3 +492,74 @@ Generated by [AVA](https://avajs.dev).
}␊
}␊
`

## full upgradeable transparent with managed

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
pragma solidity ^0.8.20;␊
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
contract MyToken is Initializable, ERC1155Upgradeable, AccessManagedUpgradeable, ERC1155PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable {␊
/// @custom:oz-upgrades-unsafe-allow constructor␊
constructor() {␊
_disableInitializers();␊
}␊
function initialize(address initialAuthority) initializer public {␊
__ERC1155_init("https://gateway.pinata.cloud/ipfs/QmcP9hxrnC1T5ATPmq2saFeAM1ypFX9BnAswCdHB9JCjLA/");␊
__AccessManaged_init(initialAuthority);␊
__ERC1155Pausable_init();␊
__ERC1155Burnable_init();␊
__UUPSUpgradeable_init();␊
}␊
function setURI(string memory newuri) public restricted {␊
_setURI(newuri);␊
}␊
function pause() public restricted {␊
_pause();␊
}␊
function unpause() public restricted {␊
_unpause();␊
}␊
function mint(address account, uint256 id, uint256 amount, bytes memory data)␊
public␊
restricted␊
{␊
_mint(account, id, amount, data);␊
}␊
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)␊
public␊
restricted␊
{␊
_mintBatch(to, ids, amounts, data);␊
}␊
function _authorizeUpgrade(address newImplementation)␊
internal␊
restricted␊
override␊
{}␊
// The following functions are overrides required by Solidity.␊
function _update(address from, address to, uint256[] memory ids, uint256[] memory values)␊
internal␊
override(ERC1155Upgradeable, ERC1155PausableUpgradeable)␊
{␊
super._update(from, to, ids, values);␊
}␊
}␊
`
Binary file modified packages/core/src/erc1155.test.ts.snap
Binary file not shown.
17 changes: 17 additions & 0 deletions packages/core/src/erc20.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ testERC20('erc20 pausable with roles', {
access: 'roles',
});

testERC20('erc20 pausable with managed', {
pausable: true,
access: 'managed',
});

testERC20('erc20 burnable pausable', {
burnable: true,
pausable: true,
Expand Down Expand Up @@ -103,6 +108,18 @@ testERC20('erc20 full upgradeable uups', {
upgradeable: 'uups',
});

testERC20('erc20 full upgradeable uups managed', {
premint: '2000',
access: 'managed',
burnable: true,
mintable: true,
pausable: true,
permit: true,
votes: true,
flashmint: true,
upgradeable: 'uups',
});

testAPIEquivalence('erc20 API default');

testAPIEquivalence('erc20 API basic', { name: 'CustomToken', symbol: 'CTK' });
Expand Down
112 changes: 112 additions & 0 deletions packages/core/src/erc20.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,44 @@ Generated by [AVA](https://avajs.dev).
}␊
`

## erc20 pausable with managed

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
pragma solidity ^0.8.20;␊
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";␊
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Pausable.sol";␊
import "@openzeppelin/contracts/access/manager/AccessManaged.sol";␊
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";␊
contract MyToken is ERC20, ERC20Pausable, AccessManaged, ERC20Permit {␊
constructor(address initialAuthority)␊
ERC20("MyToken", "MTK")␊
AccessManaged(initialAuthority)␊
ERC20Permit("MyToken")␊
{}␊
function pause() public restricted {␊
_pause();␊
}␊
function unpause() public restricted {␊
_unpause();␊
}␊
// The following functions are overrides required by Solidity.␊
function _update(address from, address to, uint256 value)␊
internal␊
override(ERC20, ERC20Pausable)␊
{␊
super._update(from, to, value);␊
}␊
}␊
`

## erc20 burnable pausable

> Snapshot 1
Expand Down Expand Up @@ -460,3 +498,77 @@ Generated by [AVA](https://avajs.dev).
}␊
}␊
`

## erc20 full upgradeable uups managed

> Snapshot 1

`// SPDX-License-Identifier: MIT␊
pragma solidity ^0.8.20;␊
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20VotesUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20FlashMintUpgradeable.sol";␊
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
contract MyToken is Initializable, ERC20Upgradeable, ERC20BurnableUpgradeable, ERC20PausableUpgradeable, AccessManagedUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable, ERC20FlashMintUpgradeable, UUPSUpgradeable {␊
/// @custom:oz-upgrades-unsafe-allow constructor␊
constructor() {␊
_disableInitializers();␊
}␊
function initialize(address initialAuthority) initializer public {␊
__ERC20_init("MyToken", "MTK");␊
__ERC20Burnable_init();␊
__ERC20Pausable_init();␊
__AccessManaged_init(initialAuthority);␊
__ERC20Permit_init("MyToken");␊
__ERC20Votes_init();␊
__ERC20FlashMint_init();␊
__UUPSUpgradeable_init();␊
_mint(msg.sender, 2000 * 10 ** decimals());␊
}␊
function pause() public restricted {␊
_pause();␊
}␊
function unpause() public restricted {␊
_unpause();␊
}␊
function mint(address to, uint256 amount) public restricted {␊
_mint(to, amount);␊
}␊
function _authorizeUpgrade(address newImplementation)␊
internal␊
restricted␊
override␊
{}␊
// The following functions are overrides required by Solidity.␊
function _update(address from, address to, uint256 value)␊
internal␊
override(ERC20Upgradeable, ERC20PausableUpgradeable, ERC20VotesUpgradeable)␊
{␊
super._update(from, to, value);␊
}␊
function nonces(address owner)␊
public␊
view␊
override(ERC20PermitUpgradeable, NoncesUpgradeable)␊
returns (uint256)␊
{␊
return super.nonces(owner);␊
}␊
}␊
`
Binary file modified packages/core/src/erc20.test.ts.snap
Binary file not shown.
Loading