@evvm/testnet-contracts 2.1.3 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +355 -55
- package/contracts/evvm/Evvm.sol +39 -38
- package/contracts/evvm/lib/ErrorsLib.sol +2 -1
- package/contracts/evvm/lib/EvvmStorage.sol +2 -0
- package/contracts/evvm/lib/EvvmStructs.sol +27 -1
- package/contracts/evvm/lib/SignatureUtils.sol +14 -17
- package/contracts/nameService/NameService.sol +124 -366
- package/contracts/nameService/lib/ErrorsLib.sol +2 -8
- package/contracts/nameService/lib/IdentityValidation.sol +182 -0
- package/contracts/nameService/lib/NameServiceStructs.sol +69 -0
- package/contracts/nameService/lib/SignatureUtils.sol +47 -41
- package/contracts/p2pSwap/P2PSwap.sol +54 -535
- package/contracts/p2pSwap/lib/P2PSwapStructs.sol +59 -0
- package/contracts/p2pSwap/lib/SignatureUtils.sol +16 -18
- package/contracts/staking/Estimator.sol +7 -6
- package/contracts/staking/Staking.sol +70 -159
- package/contracts/staking/lib/ErrorsLib.sol +0 -1
- package/contracts/staking/lib/SignatureUtils.sol +7 -36
- package/contracts/staking/lib/StakingStructs.sol +94 -0
- package/contracts/treasury/Treasury.sol +18 -20
- package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +88 -35
- package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +81 -47
- package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +2 -0
- package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +3 -14
- package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +3 -7
- package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +12 -14
- package/interfaces/IEstimator.sol +7 -50
- package/interfaces/IEvvm.sol +17 -91
- package/interfaces/INameService.sol +37 -88
- package/interfaces/IP2PSwap.sol +19 -15
- package/interfaces/IStaking.sol +20 -50
- package/interfaces/ITreasury.sol +1 -4
- package/interfaces/ITreasuryExternalChainStation.sol +11 -15
- package/interfaces/ITreasuryHostChainStation.sol +7 -10
- package/library/Erc191TestBuilder.sol +56 -57
- package/library/EvvmService.sol +40 -0
- package/library/primitives/IERC20.sol +79 -0
- package/library/primitives/Math.sol +415 -0
- package/library/primitives/SignatureRecover.sol +42 -0
- package/library/utils/AdvancedStrings.sol +89 -0
- package/library/utils/GovernanceUtils.sol +81 -0
- package/library/utils/SignatureUtil.sol +29 -0
- package/library/utils/nonces/AsyncNonce.sol +32 -0
- package/library/utils/nonces/SyncNonce.sol +27 -0
- package/library/utils/service/EvvmPayments.sol +77 -0
- package/library/utils/service/StakingServiceUtils.sol +32 -0
- package/package.json +11 -13
- package/contracts/evvm/EvvmLegacy.sol +0 -1553
- package/library/AdvancedStrings.sol +0 -77
- package/library/SignatureRecover.sol +0 -140
- package/library/StakingServiceHooks.sol +0 -116
package/interfaces/IStaking.sol
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
2
|
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface Staking {
|
|
5
|
+
library StakingStructs {
|
|
7
6
|
struct BoolTypeProposal {
|
|
8
7
|
bool flag;
|
|
9
8
|
uint256 timeToAccept;
|
|
@@ -15,18 +14,20 @@ interface Staking {
|
|
|
15
14
|
uint256 timestamp;
|
|
16
15
|
uint256 totalStaked;
|
|
17
16
|
}
|
|
17
|
+
}
|
|
18
18
|
|
|
19
|
+
interface IStaking {
|
|
19
20
|
error AddressIsNotAService();
|
|
20
21
|
error AddressMismatch();
|
|
21
22
|
error AddressMustWaitToFullUnstake();
|
|
22
23
|
error AddressMustWaitToStakeAgain();
|
|
24
|
+
error AsyncNonceAlreadyUsed();
|
|
23
25
|
error InvalidSignatureOnStaking();
|
|
24
26
|
error PresaleStakingDisabled();
|
|
25
27
|
error SenderIsNotAdmin();
|
|
26
28
|
error SenderIsNotGoldenFisher();
|
|
27
29
|
error ServiceDoesNotFulfillCorrectStakingAmount(uint256 requiredAmount);
|
|
28
30
|
error ServiceDoesNotStakeInSameTx();
|
|
29
|
-
error StakingNonceAlreadyUsed();
|
|
30
31
|
error UserIsNotPresaleStaker();
|
|
31
32
|
error UserPresaleStakerLimitExceeded();
|
|
32
33
|
|
|
@@ -40,57 +41,34 @@ interface Staking {
|
|
|
40
41
|
function cancelChangeAllowPresaleStaking() external;
|
|
41
42
|
function cancelChangeAllowPublicStaking() external;
|
|
42
43
|
function cancelSetSecondsToUnllockFullUnstaking() external;
|
|
43
|
-
function checkIfStakeNonceUsed(
|
|
44
|
-
address _account,
|
|
45
|
-
uint256 _nonce
|
|
46
|
-
) external view returns (bool);
|
|
47
44
|
function confirmChangeAllowPresaleStaking() external;
|
|
48
45
|
function confirmChangeAllowPublicStaking() external;
|
|
49
46
|
function confirmServiceStaking() external;
|
|
50
47
|
function confirmSetSecondsToUnllockFullUnstaking() external;
|
|
51
|
-
function getAddressHistory(
|
|
52
|
-
|
|
53
|
-
) external view returns (HistoryMetadata[] memory);
|
|
54
|
-
function getAddressHistoryByIndex(
|
|
55
|
-
address _account,
|
|
56
|
-
uint256 _index
|
|
57
|
-
) external view returns (HistoryMetadata memory);
|
|
58
|
-
function getAllDataOfAllowPublicStaking()
|
|
48
|
+
function getAddressHistory(address _account) external view returns (StakingStructs.HistoryMetadata[] memory);
|
|
49
|
+
function getAddressHistoryByIndex(address _account, uint256 _index)
|
|
59
50
|
external
|
|
60
51
|
view
|
|
61
|
-
returns (
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
view
|
|
65
|
-
returns (BoolTypeProposal memory);
|
|
52
|
+
returns (StakingStructs.HistoryMetadata memory);
|
|
53
|
+
function getAllDataOfAllowPublicStaking() external view returns (StakingStructs.BoolTypeProposal memory);
|
|
54
|
+
function getAllowPresaleStaking() external view returns (StakingStructs.BoolTypeProposal memory);
|
|
66
55
|
function getEstimatorAddress() external view returns (address);
|
|
67
56
|
function getEstimatorProposal() external view returns (address);
|
|
68
57
|
function getEvvmAddress() external view returns (address);
|
|
69
58
|
function getGoldenFisher() external view returns (address);
|
|
70
59
|
function getGoldenFisherProposal() external view returns (address);
|
|
60
|
+
function getIfUsedAsyncNonce(address user, uint256 nonce) external view returns (bool);
|
|
71
61
|
function getMateAddress() external pure returns (address);
|
|
72
62
|
function getOwner() external view returns (address);
|
|
73
|
-
function getPresaleStaker(
|
|
74
|
-
address _account
|
|
75
|
-
) external view returns (bool, uint256);
|
|
63
|
+
function getPresaleStaker(address _account) external view returns (bool, uint256);
|
|
76
64
|
function getPresaleStakerCount() external view returns (uint256);
|
|
77
65
|
function getSecondsToUnlockFullUnstaking() external view returns (uint256);
|
|
78
66
|
function getSecondsToUnlockStaking() external view returns (uint256);
|
|
79
|
-
function getSizeOfAddressHistory(
|
|
80
|
-
|
|
81
|
-
) external view returns (uint256);
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
) external view returns (uint256);
|
|
85
|
-
function getTimeToUserUnlockStakingTime(
|
|
86
|
-
address _account
|
|
87
|
-
) external view returns (uint256);
|
|
88
|
-
function getUserAmountStaked(
|
|
89
|
-
address _account
|
|
90
|
-
) external view returns (uint256);
|
|
91
|
-
function gimmeYiel(
|
|
92
|
-
address user
|
|
93
|
-
)
|
|
67
|
+
function getSizeOfAddressHistory(address _account) external view returns (uint256);
|
|
68
|
+
function getTimeToUserUnlockFullUnstakingTime(address _account) external view returns (uint256);
|
|
69
|
+
function getTimeToUserUnlockStakingTime(address _account) external view returns (uint256);
|
|
70
|
+
function getUserAmountStaked(address _account) external view returns (uint256);
|
|
71
|
+
function gimmeYiel(address user)
|
|
94
72
|
external
|
|
95
73
|
returns (
|
|
96
74
|
bytes32 epochAnswer,
|
|
@@ -99,17 +77,11 @@ interface Staking {
|
|
|
99
77
|
uint256 idToOverwriteUserHistory,
|
|
100
78
|
uint256 timestampToBeOverwritten
|
|
101
79
|
);
|
|
102
|
-
function goldenStaking(
|
|
103
|
-
bool isStaking,
|
|
104
|
-
uint256 amountOfStaking,
|
|
105
|
-
bytes memory signature_EVVM
|
|
106
|
-
) external;
|
|
80
|
+
function goldenStaking(bool isStaking, uint256 amountOfStaking, bytes memory signature_EVVM) external;
|
|
107
81
|
function prepareChangeAllowPresaleStaking() external;
|
|
108
82
|
function prepareChangeAllowPublicStaking() external;
|
|
109
83
|
function prepareServiceStaking(uint256 amountOfStaking) external;
|
|
110
|
-
function prepareSetSecondsToUnllockFullUnstaking(
|
|
111
|
-
uint256 _secondsToUnllockFullUnstaking
|
|
112
|
-
) external;
|
|
84
|
+
function prepareSetSecondsToUnllockFullUnstaking(uint256 _secondsToUnllockFullUnstaking) external;
|
|
113
85
|
function presaleStaking(
|
|
114
86
|
address user,
|
|
115
87
|
bool isStaking,
|
|
@@ -124,9 +96,7 @@ interface Staking {
|
|
|
124
96
|
function proposeAdmin(address _newAdmin) external;
|
|
125
97
|
function proposeEstimator(address _estimator) external;
|
|
126
98
|
function proposeGoldenFisher(address _goldenFisher) external;
|
|
127
|
-
function proposeSetSecondsToUnlockStaking(
|
|
128
|
-
uint256 _secondsToUnlockStaking
|
|
129
|
-
) external;
|
|
99
|
+
function proposeSetSecondsToUnlockStaking(uint256 _secondsToUnlockStaking) external;
|
|
130
100
|
function publicStaking(
|
|
131
101
|
address user,
|
|
132
102
|
bool isStaking,
|
package/interfaces/ITreasury.sol
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
2
|
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
-
|
|
4
3
|
pragma solidity ^0.8.0;
|
|
5
4
|
|
|
6
5
|
interface ITreasury {
|
|
@@ -10,8 +9,6 @@ interface ITreasury {
|
|
|
10
9
|
error PrincipalTokenIsNotWithdrawable();
|
|
11
10
|
|
|
12
11
|
function deposit(address token, uint256 amount) external payable;
|
|
13
|
-
|
|
14
|
-
function evvmAddress() external view returns (address);
|
|
15
|
-
|
|
12
|
+
function getEvvmAddress() external view returns (address);
|
|
16
13
|
function withdraw(address token, uint256 amount) external;
|
|
17
14
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
|
|
1
|
+
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
|
+
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
3
4
|
|
|
4
5
|
library ExternalChainStationStructs {
|
|
5
6
|
struct AddressTypeProposal {
|
|
@@ -16,13 +17,9 @@ library ExternalChainStationStructs {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
struct CrosschainConfig {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
address endpointAddress;
|
|
23
|
-
string hostChainStationChainName;
|
|
24
|
-
address gasServiceAddress;
|
|
25
|
-
address gatewayAddress;
|
|
20
|
+
HyperlaneConfig hyperlane;
|
|
21
|
+
LayerZeroConfig layerZero;
|
|
22
|
+
AxelarConfig axelar;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
struct HyperlaneConfig {
|
|
@@ -38,7 +35,7 @@ library ExternalChainStationStructs {
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
interface
|
|
38
|
+
interface ITreasuryExternalChainStation {
|
|
42
39
|
struct EnforcedOptionParam {
|
|
43
40
|
uint32 eid;
|
|
44
41
|
uint16 msgType;
|
|
@@ -74,6 +71,7 @@ interface TreasuryExternalChainStation {
|
|
|
74
71
|
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
|
|
75
72
|
error SafeERC20FailedOperation(address token);
|
|
76
73
|
error SenderNotAuthorized();
|
|
74
|
+
error WindowToChangeEvvmIDExpired();
|
|
77
75
|
|
|
78
76
|
event EnforcedOptionSet(EnforcedOptionParam[] _enforcedOptions);
|
|
79
77
|
event FisherBridgeSend(
|
|
@@ -87,8 +85,7 @@ interface TreasuryExternalChainStation {
|
|
|
87
85
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
88
86
|
event PeerSet(uint32 eid, bytes32 peer);
|
|
89
87
|
|
|
90
|
-
function _setHostChainAddress(address hostChainStationAddress, string memory hostChainStationAddressString)
|
|
91
|
-
external;
|
|
88
|
+
function _setHostChainAddress(address hostChainStationAddress, string memory hostChainStationAddressString) external;
|
|
92
89
|
function acceptAdmin() external;
|
|
93
90
|
function acceptFisherExecutor() external;
|
|
94
91
|
function acceptHostChainAddress() external;
|
|
@@ -98,9 +95,7 @@ interface TreasuryExternalChainStation {
|
|
|
98
95
|
view
|
|
99
96
|
returns (bytes memory);
|
|
100
97
|
function depositCoin(address toAddress, uint256 amount, bytes1 protocolToExecute) external payable;
|
|
101
|
-
function depositERC20(address toAddress, address token, uint256 amount, bytes1 protocolToExecute)
|
|
102
|
-
external
|
|
103
|
-
payable;
|
|
98
|
+
function depositERC20(address toAddress, address token, uint256 amount, bytes1 protocolToExecute) external payable;
|
|
104
99
|
function endpoint() external view returns (address);
|
|
105
100
|
function enforcedOptions(uint32 eid, uint16 msgType) external view returns (bytes memory enforcedOption);
|
|
106
101
|
function execute(bytes32 commandId, string memory sourceChain, string memory sourceAddress, bytes memory payload)
|
|
@@ -161,6 +156,7 @@ interface TreasuryExternalChainStation {
|
|
|
161
156
|
function renounceOwnership() external;
|
|
162
157
|
function setDelegate(address _delegate) external;
|
|
163
158
|
function setEnforcedOptions(EnforcedOptionParam[] memory _enforcedOptions) external;
|
|
159
|
+
function setEvvmID(uint256 newEvvmID) external;
|
|
164
160
|
function setPeer(uint32 _eid, bytes32 _peer) external;
|
|
165
161
|
function transferOwnership(address newOwner) external;
|
|
166
162
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
|
|
1
|
+
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
|
+
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
3
4
|
|
|
4
5
|
library HostChainStationStructs {
|
|
5
6
|
struct AddressTypeProposal {
|
|
@@ -16,13 +17,9 @@ library HostChainStationStructs {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
struct CrosschainConfig {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
address endpointAddress;
|
|
23
|
-
string externalChainStationChainName;
|
|
24
|
-
address gasServiceAddress;
|
|
25
|
-
address gatewayAddress;
|
|
20
|
+
HyperlaneConfig hyperlane;
|
|
21
|
+
LayerZeroConfig layerZero;
|
|
22
|
+
AxelarConfig axelar;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
struct HyperlaneConfig {
|
|
@@ -38,7 +35,7 @@ library HostChainStationStructs {
|
|
|
38
35
|
}
|
|
39
36
|
}
|
|
40
37
|
|
|
41
|
-
interface
|
|
38
|
+
interface ITreasuryHostChainStation {
|
|
42
39
|
struct EnforcedOptionParam {
|
|
43
40
|
uint32 eid;
|
|
44
41
|
uint16 msgType;
|
|
@@ -4,15 +4,14 @@
|
|
|
4
4
|
pragma solidity ^0.8.0;
|
|
5
5
|
/**
|
|
6
6
|
* @title Erc191TestBuilder
|
|
7
|
-
* @author
|
|
7
|
+
* @author jistro.eth
|
|
8
8
|
* @notice this library is used to build ERC191 messages for foundry test scripts
|
|
9
9
|
* more info in
|
|
10
10
|
* https://book.getfoundry.sh/cheatcodes/create-wallet
|
|
11
11
|
* https://book.getfoundry.sh/cheatcodes/sign
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {AdvancedStrings} from "./AdvancedStrings.sol";
|
|
14
|
+
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
16
15
|
|
|
17
16
|
library Erc191TestBuilder {
|
|
18
17
|
//-----------------------------------------------------------------------------------
|
|
@@ -30,7 +29,7 @@ library Erc191TestBuilder {
|
|
|
30
29
|
address _executor
|
|
31
30
|
) internal pure returns (bytes32 messageHash) {
|
|
32
31
|
string memory messageToSign = string.concat(
|
|
33
|
-
|
|
32
|
+
AdvancedStrings.uintToString(evvmID),
|
|
34
33
|
",",
|
|
35
34
|
"pay",
|
|
36
35
|
",",
|
|
@@ -40,11 +39,11 @@ library Erc191TestBuilder {
|
|
|
40
39
|
",",
|
|
41
40
|
AdvancedStrings.addressToString(_token),
|
|
42
41
|
",",
|
|
43
|
-
|
|
42
|
+
AdvancedStrings.uintToString(_amount),
|
|
44
43
|
",",
|
|
45
|
-
|
|
44
|
+
AdvancedStrings.uintToString(_priorityFee),
|
|
46
45
|
",",
|
|
47
|
-
|
|
46
|
+
AdvancedStrings.uintToString(_nonce),
|
|
48
47
|
",",
|
|
49
48
|
_priority_boolean ? "true" : "false",
|
|
50
49
|
",",
|
|
@@ -66,7 +65,7 @@ library Erc191TestBuilder {
|
|
|
66
65
|
return
|
|
67
66
|
buildHashForSign(
|
|
68
67
|
string.concat(
|
|
69
|
-
|
|
68
|
+
AdvancedStrings.uintToString(evvmID),
|
|
70
69
|
",",
|
|
71
70
|
"dispersePay",
|
|
72
71
|
",",
|
|
@@ -74,11 +73,11 @@ library Erc191TestBuilder {
|
|
|
74
73
|
",",
|
|
75
74
|
AdvancedStrings.addressToString(_token),
|
|
76
75
|
",",
|
|
77
|
-
|
|
76
|
+
AdvancedStrings.uintToString(_amount),
|
|
78
77
|
",",
|
|
79
|
-
|
|
78
|
+
AdvancedStrings.uintToString(_priorityFee),
|
|
80
79
|
",",
|
|
81
|
-
|
|
80
|
+
AdvancedStrings.uintToString(_nonce),
|
|
82
81
|
",",
|
|
83
82
|
_priority_boolean ? "true" : "false",
|
|
84
83
|
",",
|
|
@@ -99,13 +98,13 @@ library Erc191TestBuilder {
|
|
|
99
98
|
return
|
|
100
99
|
buildHashForSign(
|
|
101
100
|
string.concat(
|
|
102
|
-
|
|
101
|
+
AdvancedStrings.uintToString(evvmID),
|
|
103
102
|
",",
|
|
104
103
|
"preRegistrationUsername",
|
|
105
104
|
",",
|
|
106
105
|
AdvancedStrings.bytes32ToString(_hashUsername),
|
|
107
106
|
",",
|
|
108
|
-
|
|
107
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
109
108
|
)
|
|
110
109
|
);
|
|
111
110
|
}
|
|
@@ -119,15 +118,15 @@ library Erc191TestBuilder {
|
|
|
119
118
|
return
|
|
120
119
|
buildHashForSign(
|
|
121
120
|
string.concat(
|
|
122
|
-
|
|
121
|
+
AdvancedStrings.uintToString(evvmID),
|
|
123
122
|
",",
|
|
124
123
|
"registrationUsername",
|
|
125
124
|
",",
|
|
126
125
|
_username,
|
|
127
126
|
",",
|
|
128
|
-
|
|
127
|
+
AdvancedStrings.uintToString(_clowNumber),
|
|
129
128
|
",",
|
|
130
|
-
|
|
129
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
131
130
|
)
|
|
132
131
|
);
|
|
133
132
|
}
|
|
@@ -142,17 +141,17 @@ library Erc191TestBuilder {
|
|
|
142
141
|
return
|
|
143
142
|
buildHashForSign(
|
|
144
143
|
string.concat(
|
|
145
|
-
|
|
144
|
+
AdvancedStrings.uintToString(evvmID),
|
|
146
145
|
",",
|
|
147
146
|
"makeOffer",
|
|
148
147
|
",",
|
|
149
148
|
_username,
|
|
150
149
|
",",
|
|
151
|
-
|
|
150
|
+
AdvancedStrings.uintToString(_dateExpire),
|
|
152
151
|
",",
|
|
153
|
-
|
|
152
|
+
AdvancedStrings.uintToString(_amount),
|
|
154
153
|
",",
|
|
155
|
-
|
|
154
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
156
155
|
)
|
|
157
156
|
);
|
|
158
157
|
}
|
|
@@ -166,15 +165,15 @@ library Erc191TestBuilder {
|
|
|
166
165
|
return
|
|
167
166
|
buildHashForSign(
|
|
168
167
|
string.concat(
|
|
169
|
-
|
|
168
|
+
AdvancedStrings.uintToString(evvmID),
|
|
170
169
|
",",
|
|
171
170
|
"withdrawOffer",
|
|
172
171
|
",",
|
|
173
172
|
_username,
|
|
174
173
|
",",
|
|
175
|
-
|
|
174
|
+
AdvancedStrings.uintToString(_offerId),
|
|
176
175
|
",",
|
|
177
|
-
|
|
176
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
178
177
|
)
|
|
179
178
|
);
|
|
180
179
|
}
|
|
@@ -188,15 +187,15 @@ library Erc191TestBuilder {
|
|
|
188
187
|
return
|
|
189
188
|
buildHashForSign(
|
|
190
189
|
string.concat(
|
|
191
|
-
|
|
190
|
+
AdvancedStrings.uintToString(evvmID),
|
|
192
191
|
",",
|
|
193
192
|
"acceptOffer",
|
|
194
193
|
",",
|
|
195
194
|
_username,
|
|
196
195
|
",",
|
|
197
|
-
|
|
196
|
+
AdvancedStrings.uintToString(_offerId),
|
|
198
197
|
",",
|
|
199
|
-
|
|
198
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
200
199
|
)
|
|
201
200
|
);
|
|
202
201
|
}
|
|
@@ -209,13 +208,13 @@ library Erc191TestBuilder {
|
|
|
209
208
|
return
|
|
210
209
|
buildHashForSign(
|
|
211
210
|
string.concat(
|
|
212
|
-
|
|
211
|
+
AdvancedStrings.uintToString(evvmID),
|
|
213
212
|
",",
|
|
214
213
|
"renewUsername",
|
|
215
214
|
",",
|
|
216
215
|
_username,
|
|
217
216
|
",",
|
|
218
|
-
|
|
217
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
219
218
|
)
|
|
220
219
|
);
|
|
221
220
|
}
|
|
@@ -229,7 +228,7 @@ library Erc191TestBuilder {
|
|
|
229
228
|
return
|
|
230
229
|
buildHashForSign(
|
|
231
230
|
string.concat(
|
|
232
|
-
|
|
231
|
+
AdvancedStrings.uintToString(evvmID),
|
|
233
232
|
",",
|
|
234
233
|
"addCustomMetadata",
|
|
235
234
|
",",
|
|
@@ -237,7 +236,7 @@ library Erc191TestBuilder {
|
|
|
237
236
|
",",
|
|
238
237
|
_value,
|
|
239
238
|
",",
|
|
240
|
-
|
|
239
|
+
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
241
240
|
)
|
|
242
241
|
);
|
|
243
242
|
}
|
|
@@ -251,15 +250,15 @@ library Erc191TestBuilder {
|
|
|
251
250
|
return
|
|
252
251
|
buildHashForSign(
|
|
253
252
|
string.concat(
|
|
254
|
-
|
|
253
|
+
AdvancedStrings.uintToString(evvmID),
|
|
255
254
|
",",
|
|
256
255
|
"removeCustomMetadata",
|
|
257
256
|
",",
|
|
258
257
|
_username,
|
|
259
258
|
",",
|
|
260
|
-
|
|
259
|
+
AdvancedStrings.uintToString(_key),
|
|
261
260
|
",",
|
|
262
|
-
|
|
261
|
+
AdvancedStrings.uintToString(_nonce)
|
|
263
262
|
)
|
|
264
263
|
);
|
|
265
264
|
}
|
|
@@ -272,13 +271,13 @@ library Erc191TestBuilder {
|
|
|
272
271
|
return
|
|
273
272
|
buildHashForSign(
|
|
274
273
|
string.concat(
|
|
275
|
-
|
|
274
|
+
AdvancedStrings.uintToString(evvmID),
|
|
276
275
|
",",
|
|
277
276
|
"flushCustomMetadata",
|
|
278
277
|
",",
|
|
279
278
|
_username,
|
|
280
279
|
",",
|
|
281
|
-
|
|
280
|
+
AdvancedStrings.uintToString(_nonce)
|
|
282
281
|
)
|
|
283
282
|
);
|
|
284
283
|
}
|
|
@@ -291,13 +290,13 @@ library Erc191TestBuilder {
|
|
|
291
290
|
return
|
|
292
291
|
buildHashForSign(
|
|
293
292
|
string.concat(
|
|
294
|
-
|
|
293
|
+
AdvancedStrings.uintToString(evvmID),
|
|
295
294
|
",",
|
|
296
295
|
"flushUsername",
|
|
297
296
|
",",
|
|
298
297
|
_username,
|
|
299
298
|
",",
|
|
300
|
-
|
|
299
|
+
AdvancedStrings.uintToString(_nonce)
|
|
301
300
|
)
|
|
302
301
|
);
|
|
303
302
|
}
|
|
@@ -316,7 +315,7 @@ library Erc191TestBuilder {
|
|
|
316
315
|
return
|
|
317
316
|
buildHashForSign(
|
|
318
317
|
string.concat(
|
|
319
|
-
|
|
318
|
+
AdvancedStrings.uintToString(evvmID),
|
|
320
319
|
",",
|
|
321
320
|
"publicServiceStaking",
|
|
322
321
|
",",
|
|
@@ -324,9 +323,9 @@ library Erc191TestBuilder {
|
|
|
324
323
|
",",
|
|
325
324
|
_isStaking ? "true" : "false",
|
|
326
325
|
",",
|
|
327
|
-
|
|
326
|
+
AdvancedStrings.uintToString(_amountOfStaking),
|
|
328
327
|
",",
|
|
329
|
-
|
|
328
|
+
AdvancedStrings.uintToString(_nonce)
|
|
330
329
|
)
|
|
331
330
|
);
|
|
332
331
|
}
|
|
@@ -340,15 +339,15 @@ library Erc191TestBuilder {
|
|
|
340
339
|
return
|
|
341
340
|
buildHashForSign(
|
|
342
341
|
string.concat(
|
|
343
|
-
|
|
342
|
+
AdvancedStrings.uintToString(evvmID),
|
|
344
343
|
",",
|
|
345
344
|
"publicStaking",
|
|
346
345
|
",",
|
|
347
346
|
_isStaking ? "true" : "false",
|
|
348
347
|
",",
|
|
349
|
-
|
|
348
|
+
AdvancedStrings.uintToString(_amountOfStaking),
|
|
350
349
|
",",
|
|
351
|
-
|
|
350
|
+
AdvancedStrings.uintToString(_nonce)
|
|
352
351
|
)
|
|
353
352
|
);
|
|
354
353
|
}
|
|
@@ -362,15 +361,15 @@ library Erc191TestBuilder {
|
|
|
362
361
|
return
|
|
363
362
|
buildHashForSign(
|
|
364
363
|
string.concat(
|
|
365
|
-
|
|
364
|
+
AdvancedStrings.uintToString(evvmID),
|
|
366
365
|
",",
|
|
367
366
|
"presaleStaking",
|
|
368
367
|
",",
|
|
369
368
|
_isStaking ? "true" : "false",
|
|
370
369
|
",",
|
|
371
|
-
|
|
370
|
+
AdvancedStrings.uintToString(_amountOfStaking),
|
|
372
371
|
",",
|
|
373
|
-
|
|
372
|
+
AdvancedStrings.uintToString(_nonce)
|
|
374
373
|
)
|
|
375
374
|
);
|
|
376
375
|
}
|
|
@@ -390,19 +389,19 @@ library Erc191TestBuilder {
|
|
|
390
389
|
return
|
|
391
390
|
buildHashForSign(
|
|
392
391
|
string.concat(
|
|
393
|
-
|
|
392
|
+
AdvancedStrings.uintToString(evvmID),
|
|
394
393
|
",",
|
|
395
394
|
"makeOrder",
|
|
396
395
|
",",
|
|
397
|
-
|
|
396
|
+
AdvancedStrings.uintToString(_nonce),
|
|
398
397
|
",",
|
|
399
398
|
AdvancedStrings.addressToString(_tokenA),
|
|
400
399
|
",",
|
|
401
400
|
AdvancedStrings.addressToString(_tokenB),
|
|
402
401
|
",",
|
|
403
|
-
|
|
402
|
+
AdvancedStrings.uintToString(_amountA),
|
|
404
403
|
",",
|
|
405
|
-
|
|
404
|
+
AdvancedStrings.uintToString(_amountB)
|
|
406
405
|
)
|
|
407
406
|
);
|
|
408
407
|
}
|
|
@@ -417,17 +416,17 @@ library Erc191TestBuilder {
|
|
|
417
416
|
return
|
|
418
417
|
buildHashForSign(
|
|
419
418
|
string.concat(
|
|
420
|
-
|
|
419
|
+
AdvancedStrings.uintToString(evvmID),
|
|
421
420
|
",",
|
|
422
421
|
"cancelOrder",
|
|
423
422
|
",",
|
|
424
|
-
|
|
423
|
+
AdvancedStrings.uintToString(_nonce),
|
|
425
424
|
",",
|
|
426
425
|
AdvancedStrings.addressToString(_tokenA),
|
|
427
426
|
",",
|
|
428
427
|
AdvancedStrings.addressToString(_tokenB),
|
|
429
428
|
",",
|
|
430
|
-
|
|
429
|
+
AdvancedStrings.uintToString(_orderId)
|
|
431
430
|
)
|
|
432
431
|
);
|
|
433
432
|
}
|
|
@@ -442,17 +441,17 @@ library Erc191TestBuilder {
|
|
|
442
441
|
return
|
|
443
442
|
buildHashForSign(
|
|
444
443
|
string.concat(
|
|
445
|
-
|
|
444
|
+
AdvancedStrings.uintToString(evvmID),
|
|
446
445
|
",",
|
|
447
446
|
"dispatchOrder",
|
|
448
447
|
",",
|
|
449
|
-
|
|
448
|
+
AdvancedStrings.uintToString(_nonce),
|
|
450
449
|
",",
|
|
451
450
|
AdvancedStrings.addressToString(_tokenA),
|
|
452
451
|
",",
|
|
453
452
|
AdvancedStrings.addressToString(_tokenB),
|
|
454
453
|
",",
|
|
455
|
-
|
|
454
|
+
AdvancedStrings.uintToString(_orderId)
|
|
456
455
|
)
|
|
457
456
|
);
|
|
458
457
|
}
|
|
@@ -468,7 +467,7 @@ library Erc191TestBuilder {
|
|
|
468
467
|
keccak256(
|
|
469
468
|
abi.encodePacked(
|
|
470
469
|
"\x19Ethereum Signed Message:\n",
|
|
471
|
-
|
|
470
|
+
AdvancedStrings.uintToString(bytes(messageToSign).length),
|
|
472
471
|
messageToSign
|
|
473
472
|
)
|
|
474
473
|
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: EVVM-NONCOMMERCIAL-1.0
|
|
2
|
+
// Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
|
|
3
|
+
|
|
4
|
+
pragma solidity ^0.8.0;
|
|
5
|
+
|
|
6
|
+
import {EvvmStructs} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
|
|
7
|
+
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
8
|
+
import {AsyncNonce} from "@evvm/testnet-contracts/library/utils/nonces/AsyncNonce.sol";
|
|
9
|
+
import {StakingServiceUtils} from "@evvm/testnet-contracts/library/utils/service/StakingServiceUtils.sol";
|
|
10
|
+
import {EvvmPayments} from "@evvm/testnet-contracts/library/utils/service/EvvmPayments.sol";
|
|
11
|
+
|
|
12
|
+
abstract contract EvvmService is
|
|
13
|
+
AsyncNonce,
|
|
14
|
+
StakingServiceUtils,
|
|
15
|
+
EvvmPayments
|
|
16
|
+
{
|
|
17
|
+
error InvalidServiceSignature();
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
address evvmAddress,
|
|
21
|
+
address stakingAddress
|
|
22
|
+
) StakingServiceUtils(stakingAddress) EvvmPayments(evvmAddress) {}
|
|
23
|
+
|
|
24
|
+
function validateServiceSignature(
|
|
25
|
+
string memory functionName,
|
|
26
|
+
string memory inputs,
|
|
27
|
+
bytes memory signature,
|
|
28
|
+
address expectedSigner
|
|
29
|
+
) internal view virtual {
|
|
30
|
+
if (
|
|
31
|
+
!SignatureUtil.verifySignature(
|
|
32
|
+
evvm.getEvvmID(),
|
|
33
|
+
functionName,
|
|
34
|
+
inputs,
|
|
35
|
+
signature,
|
|
36
|
+
expectedSigner
|
|
37
|
+
)
|
|
38
|
+
) revert InvalidServiceSignature();
|
|
39
|
+
}
|
|
40
|
+
}
|