Skip to content

Commit c69c5a8

Browse files
authored
refactor: initializers and add token name and symbol to the parameters library (#36)
* refactor: initializers * style: remove unused import * fix: typo in workflow
1 parent 9640e3b commit c69c5a8

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
run: bunx --bun solhint --config .solhint.other.json 'script/**/*.sol'
6565
id: solhint-script
6666

67+
- name: Install Upgrades-core
68+
run: |
69+
bun install @openzeppelin/upgrades-core@latest
70+
6771
- name: Run Forge clean
6872
run: forge clean
6973
id: clean

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"dependencies": {
3+
"@openzeppelin/upgrades-core": "^1.44.1",
34
"solhint": "^5.0.5"
45
}
5-
}
6+
}

src/XanV1.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,22 @@ contract XanV1 is IXanV1, Initializable, ERC20Upgradeable, ERC20BurnableUpgradea
237237
lockedBalance = _getProposedUpgrades().lockedBalances[from];
238238
}
239239

240+
/// @notice Initializes the XanV1 contract and inherited contracts.
241+
/// @param initialMintRecipient The initial recipient of the minted tokens.
240242
// solhint-disable-next-line func-name-mixedcase
241243
function __XanV1_init(address initialMintRecipient) internal onlyInitializing {
244+
// Initialize inherited contracts
242245
__Context_init_unchained();
243-
__ERC20_init_unchained("Anoma Token", "Xan");
244-
__ERC20Burnable_init();
246+
__ERC20_init_unchained({name_: Parameters.NAME, symbol_: Parameters.SYMBOL});
247+
__ERC20Burnable_init_unchained();
245248
__UUPSUpgradeable_init_unchained();
246249

250+
// Initialize the XanV1 contract
247251
__XanV1_init_unchained(initialMintRecipient);
248252
}
249253

250-
/// @custom:oz-upgrades-unsafe-allow missing-initializer-call
254+
/// @notice Initializes the XanV1 contract.
255+
/// @param initialMintRecipient The initial recipient of the minted tokens.
251256
// solhint-disable-next-line func-name-mixedcase
252257
function __XanV1_init_unchained(address initialMintRecipient) internal onlyInitializing {
253258
_mint(initialMintRecipient, Parameters.SUPPLY);

src/drafts/XanV2.sol

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {XanV1} from "../XanV1.sol";
1010
contract XanV2 is IXanV2, XanV1 {
1111
/// @notice The [ERC-7201](https://eips.ethereum.org/EIPS/eip-7201) storage of the contract.
1212
/// @custom:storage-location erc7201:anoma.storage.Xan.v2
13-
/// @param proposedUpgrades The upgrade proposed from a current implementation.
13+
/// @param forwarder The forwarder being allowed to mint more tokens.
1414
struct XanV2Storage {
1515
address forwarder;
1616
}
@@ -28,6 +28,9 @@ contract XanV2 is IXanV2, XanV1 {
2828
_;
2929
}
3030

31+
/// @notice Initializes the proxy.
32+
/// @param initialMintRecipient The initial recipient of the minted tokens.
33+
/// @param xanV2Forwarder The XanV2 forwarder contract.
3134
/// @custom:oz-upgrades-validate-as-initializer
3235
// solhint-disable-next-line comprehensive-interface
3336
function initialize(address initialMintRecipient, address xanV2Forwarder) external reinitializer(2) {
@@ -39,6 +42,7 @@ contract XanV2 is IXanV2, XanV1 {
3942
/// @custom:oz-upgrades-validate-as-initializer
4043
// solhint-disable-next-line comprehensive-interface
4144
function initializeV2(address xanV2Forwarder) external reinitializer(2) {
45+
// Initialize the XanV2 contract
4246
__XanV2_init({xanV2Forwarder: xanV2Forwarder});
4347
}
4448

@@ -52,13 +56,16 @@ contract XanV2 is IXanV2, XanV1 {
5256
addr = _getXanV2Storage().forwarder;
5357
}
5458

59+
/// @notice Initializes the XanV2 contract and newly inherited contracts.
60+
/// @param xanV2Forwarder The XanV2 forwarder contract.
5561
/// @custom:oz-upgrades-unsafe-allow missing-initializer-call
5662
// solhint-disable-next-line func-name-mixedcase
5763
function __XanV2_init(address xanV2Forwarder) internal onlyInitializing {
5864
__XanV2_init_unchained({xanV2Forwarder: xanV2Forwarder});
5965
}
6066

61-
/// @custom:oz-upgrades-unsafe-allow missing-initializer-call
67+
/// @notice Initializes the XanV2 contract.
68+
/// @param xanV2Forwarder The XanV2 forwarder contract.
6269
// solhint-disable-next-line func-name-mixedcase
6370
function __XanV2_init_unchained(address xanV2Forwarder) internal onlyInitializing {
6471
_getXanV2Storage().forwarder = xanV2Forwarder;

src/libs/Parameters.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
pragma solidity ^0.8.30;
33

44
library Parameters {
5+
/// @notice The name of the token.
6+
string internal constant NAME = "Anoma";
7+
8+
/// @notice The symbol of the token.
9+
string internal constant SYMBOL = "XAN";
10+
511
/// @notice The total supply amounting to 1 bn (10^9) tokens with 18 decimals.
612
uint256 internal constant SUPPLY = 10 ** (9 + 18);
713

0 commit comments

Comments
 (0)