forked from lidofinance/lido-l2
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathERC20BridgedPermit.sol
58 lines (49 loc) · 2.03 KB
/
ERC20BridgedPermit.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-FileCopyrightText: 2024 OpenZeppelin, Lido <[email protected]>
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.10;
import {ERC20Bridged} from "./ERC20Bridged.sol";
import {PermitExtension} from "./PermitExtension.sol";
import {Versioned} from "../utils/Versioned.sol";
/// @author kovalgek
contract ERC20BridgedPermit is ERC20Bridged, PermitExtension, Versioned {
/// @param name_ The name of the token
/// @param symbol_ The symbol of the token
/// @param version_ The current major version of the signing domain (aka token version)
/// @param decimals_ The decimals places of the token
/// @param bridge_ The bridge address which allowd to mint/burn tokens
constructor(
string memory name_,
string memory symbol_,
string memory version_,
uint8 decimals_,
address bridge_
)
ERC20Bridged(name_, symbol_, decimals_, bridge_)
PermitExtension(name_, version_)
{
}
/// @notice Initializes the contract from scratch.
/// @param name_ The name of the token
/// @param symbol_ The symbol of the token
/// @param version_ The version of the token
function initialize(string memory name_, string memory symbol_, string memory version_) external {
_initializeERC20Metadata(name_, symbol_);
_initialize_v2(name_, version_);
}
/// @notice A function to finalize upgrade to v2 (from v1).
function finalizeUpgrade_v2(string memory name_, string memory version_) external {
if (!_isMetadataInitialized()) {
revert ErrorMetadataNotInitialized();
}
_initialize_v2(name_, version_);
}
function _initialize_v2(string memory name_, string memory version_) internal {
_initializeContractVersionTo(2);
_initializeEIP5267Metadata(name_, version_);
}
/// @inheritdoc PermitExtension
function _permitAccepted(address owner_, address spender_, uint256 amount_) internal override {
_approve(owner_, spender_, amount_);
}
error ErrorMetadataNotInitialized();
}