Skip to content

Commit 2027c61

Browse files
authored
Merge pull request #26 from axieinfinity/release/v0.2.0
feat: add ERC1155Common, support launchpad/presale and adapt OZ v5.
2 parents fa36abc + c8d186c commit 2027c61

34 files changed

+500
-259
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ on:
77
- dev
88
- "feature/*"
99
- "features/*"
10+
- "feature/*"
11+
- "features/*"
1012
pull_request:
1113
branches:
1214
- main
1315
- dev
1416
- "feature/*"
1517
- "features/*"
18+
- "feature/*"
19+
- "features/*"
1620

1721
env:
1822
FOUNDRY_PROFILE: ci
@@ -24,6 +28,7 @@ jobs:
2428

2529
name: Foundry project
2630
runs-on: ubuntu-latest
31+
runs-on: ubuntu-latest
2732
steps:
2833
- uses: actions/checkout@v4.1.1
2934
with:
@@ -36,7 +41,7 @@ jobs:
3641

3742
- name: Install dependencies
3843
run: |
39-
forge install
44+
forge soldeer update
4045
id: install
4146

4247
- name: Run Forge build

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ artifacts/
1313
typechain-types/
1414
.idea
1515
.env
16+
17+
dependencies

.gitmodules

Lines changed: 0 additions & 12 deletions
This file was deleted.

foundry.toml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,36 @@ extra_output = ["devdoc", "userdoc", "storagelayout"]
1111
fs_permissions = [{ access = "read-write", path = "./" }]
1212

1313
[fmt]
14-
tab_width = 2
1514
line_length = 120
15+
tab_width = 2
1616
bracket_spacing = true
17+
multiline_func_header = 'params_first'
18+
single_line_statement_blocks = 'single'
19+
sort_imports = true
20+
number_underscore = "thousands"
21+
wrap_comments = true
22+
23+
[dependencies]
24+
"openzeppelin" = { version = "5.0.2", url = "https://github.com/OpenZeppelin/openzeppelin-contracts/archive/refs/tags/v5.0.2.zip" }
25+
"openzeppelin-upgradeable" = { version = "5.0.2", url = "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/archive/refs/tags/v5.0.2.zip" }
26+
forge-std = { version = "1.9.3", url = "https://github.com/foundry-rs/forge-std/archive/refs/tags/v1.9.3.zip" }
27+
28+
[soldeer]
29+
# whether soldeer manages remappings
30+
remappings_generate = false
31+
32+
# whether soldeer re-generates all remappings when installing, updating or uninstalling deps
33+
remappings_regenerate = false
34+
35+
# whether to suffix the remapping with the version: `name-a.b.c`
36+
remappings_version = true
37+
38+
# a prefix to add to the remappings ("@" would give `@name`)
39+
remappings_prefix = "@"
40+
41+
# where to store the remappings ("txt" for `remappings.txt` or "config" for `foundry.toml`)
42+
# ignored when `soldeer.toml` is used as config (uses `remappings.txt`)
43+
remappings_location = "txt"
44+
45+
# whether to install sub-dependencies or not. If true this wil install the dependencies of dependencies 1 level down.
46+
recursive_deps = true

lib/forge-std

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/openzeppelin-contracts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 0 additions & 1 deletion
This file was deleted.

remappings.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
forge-std/=lib/forge-std/src/
2-
ds-test/=lib/forge-std/lib/ds-test/src/
3-
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
4-
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts
1+
forge-std/=dependencies/forge-std-1.9.3/src/
2+
@openzeppelin/contracts/=dependencies/openzeppelin-5.0.2/contracts/
3+
@openzeppelin/contracts-upgradeable/=dependencies/openzeppelin-upgradeable-5.0.2/contracts/

soldeer.lock

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[[dependencies]]
2+
name = "contract-template"
3+
version = "0.1.0"
4+
source = "https://github.com/axieinfinity/contract-template/archive/refs/tags/release-v0.1.0.zip"
5+
checksum = "56676e92b8825974abab8e381a98d0cc55da7057a18b3d325a13def760fa69d3"
6+
integrity = "9fda9db2e8c24bb37378b1a14f41e1338967d101282bcdc0df9e98d7cf0edcda"
7+
8+
[[dependencies]]
9+
name = "forge-std"
10+
version = "1.9.3"
11+
source = "https://github.com/foundry-rs/forge-std/archive/refs/tags/v1.9.3.zip"
12+
checksum = "cc61148ae1a47f2415956a95ada670501b10ebd7f65cc00eda6ea7025770f42b"
13+
integrity = "d53734fbd7201cd9e44de730ae045ed8958dd2c7b9493c30b322f6e6c21ca8b2"
14+
15+
[[dependencies]]
16+
name = "openzeppelin"
17+
version = "5.0.2"
18+
source = "https://github.com/OpenZeppelin/openzeppelin-contracts/archive/refs/tags/v5.0.2.zip"
19+
checksum = "ca49e0776066328da0087977864dfaef0d5e54a0ea9859236a7cd9ad02abb9e5"
20+
integrity = "6f8fc028520b958667ef1e96460c64140f42fef60ff02bc63110780c557b7c7e"
21+
22+
[[dependencies]]
23+
name = "openzeppelin-upgradeable"
24+
version = "5.0.2"
25+
source = "https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/archive/refs/tags/v5.0.2.zip"
26+
checksum = "4790d4f592cb46c868916ea50613997df1e28fd42b4d32e0999f0a4b9d1a7cf8"
27+
integrity = "085dfc37ec3b96f0ea95ae99d8c044b0b407eab88a78d7cb552284bccf1130ba"

src/ERC1155Common.sol

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// Compatible with OpenZeppelin Contracts ^5.0.0
33
pragma solidity ^0.8.20;
44

5+
import { AccessControlEnumerable } from "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";
56
import { IERC165 } from "@openzeppelin/contracts/interfaces/IERC165.sol";
6-
import { AccessControlEnumerable } from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
77
import { ERC1155 } from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
88

9+
import { IERC1155Common } from "./interfaces/IERC1155Common.sol";
910
import { ERC1155Burnable } from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";
1011
import { ERC1155Pausable } from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol";
1112
import { ERC1155Supply } from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
1213
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
13-
import { IERC1155Common } from "./interfaces/IERC1155Common.sol";
1414

1515
contract ERC1155Common is
1616
ERC1155,
@@ -44,7 +44,9 @@ contract ERC1155Common is
4444
* Requirements:
4545
* - the caller must have the `URI_SETTER_ROLE`.
4646
*/
47-
function setURI(string memory newURI) external onlyRole(URI_SETTER_ROLE) {
47+
function setURI(
48+
string memory newURI
49+
) external onlyRole(URI_SETTER_ROLE) {
4850
_setURI(newURI);
4951
}
5052

@@ -72,11 +74,12 @@ contract ERC1155Common is
7274
}
7375

7476
/// @inheritdoc IERC1155Common
75-
function mintBatch(address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data)
76-
public
77-
virtual
78-
onlyRole(MINTER_ROLE)
79-
{
77+
function mintBatch(
78+
address to,
79+
uint256[] calldata ids,
80+
uint256[] calldata amounts,
81+
bytes calldata data
82+
) public virtual onlyRole(MINTER_ROLE) {
8083
_mintBatch(to, ids, amounts, data);
8184
}
8285

@@ -85,11 +88,12 @@ contract ERC1155Common is
8588
* Requirements:
8689
* - the caller must have the `MINTER_ROLE`.
8790
*/
88-
function bulkMint(uint256 id, address[] calldata tos, uint256[] calldata amounts, bytes[] calldata datas)
89-
public
90-
virtual
91-
onlyRole(MINTER_ROLE)
92-
{
91+
function bulkMint(
92+
uint256 id,
93+
address[] calldata tos,
94+
uint256[] calldata amounts,
95+
bytes[] calldata datas
96+
) public virtual onlyRole(MINTER_ROLE) {
9397
uint256 length = tos.length;
9498
require(length != 0 && length == amounts.length && length == datas.length, "ERC1155: invalid array lengths");
9599

@@ -101,7 +105,9 @@ contract ERC1155Common is
101105
/**
102106
* @dev See {ERC1155-uri}.
103107
*/
104-
function uri(uint256 tokenId) public view virtual override returns (string memory) {
108+
function uri(
109+
uint256 tokenId
110+
) public view virtual override returns (string memory) {
105111
string memory uri_ = super.uri(tokenId);
106112
return string.concat(uri_, tokenId.toString());
107113
}
@@ -119,27 +125,21 @@ contract ERC1155Common is
119125
/**
120126
* @dev See {ERC165-supportsInterface}.
121127
*/
122-
function supportsInterface(bytes4 interfaceId)
123-
public
124-
view
125-
virtual
126-
override(IERC165, ERC1155, AccessControlEnumerable)
127-
returns (bool)
128-
{
128+
function supportsInterface(
129+
bytes4 interfaceId
130+
) public view virtual override(IERC165, ERC1155, AccessControlEnumerable) returns (bool) {
129131
return interfaceId == type(IERC1155Common).interfaceId || super.supportsInterface(interfaceId);
130132
}
131133

132134
/**
133-
* @dev See {ERC1155-_beforeTokenTransfer}.
135+
* @dev See {ERC1155-_update}.
134136
*/
135-
function _beforeTokenTransfer(
136-
address operator,
137+
function _update(
137138
address from,
138139
address to,
139140
uint256[] memory ids,
140-
uint256[] memory amounts,
141-
bytes memory data
142-
) internal virtual override(ERC1155, ERC1155Pausable, ERC1155Supply) {
143-
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
141+
uint256[] memory values
142+
) internal virtual override(ERC1155, ERC1155Supply, ERC1155Pausable) {
143+
super._update(from, to, ids, values);
144144
}
145145
}

0 commit comments

Comments
 (0)