@evvm/testnet-contracts 2.2.3 → 3.0.0
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 +145 -118
- package/README.md +162 -39
- package/contracts/core/Core.sol +1394 -0
- package/contracts/core/lib/CoreStorage.sol +171 -0
- package/contracts/nameService/NameService.sol +666 -586
- package/contracts/nameService/lib/IdentityValidation.sol +18 -3
- package/contracts/p2pSwap/P2PSwap.sol +439 -285
- package/contracts/staking/Estimator.sol +128 -40
- package/contracts/staking/Staking.sol +329 -322
- package/contracts/treasury/Treasury.sol +48 -37
- package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +585 -198
- package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +425 -174
- package/contracts/treasuryTwoChains/lib/PayloadUtils.sol +2 -4
- package/interfaces/{IEvvm.sol → ICore.sol} +67 -29
- package/interfaces/IEstimator.sol +1 -1
- package/interfaces/INameService.sol +58 -52
- package/interfaces/IP2PSwap.sol +18 -17
- package/interfaces/IStaking.sol +22 -17
- package/interfaces/ITreasury.sol +2 -1
- package/interfaces/ITreasuryExternalChainStation.sol +15 -9
- package/interfaces/ITreasuryHostChainStation.sol +14 -11
- package/interfaces/IUserValidator.sol +6 -0
- package/library/Erc191TestBuilder.sol +350 -297
- package/library/EvvmService.sol +38 -27
- package/library/errors/CoreError.sol +116 -0
- package/library/errors/CrossChainTreasuryError.sol +36 -0
- package/library/errors/NameServiceError.sol +79 -0
- package/library/errors/StakingError.sol +79 -0
- package/library/errors/TreasuryError.sol +33 -0
- package/library/primitives/SignatureRecover.sol +33 -0
- package/library/structs/CoreStructs.sol +146 -0
- package/library/structs/ExternalChainStationStructs.sol +92 -0
- package/library/structs/HostChainStationStructs.sol +77 -0
- package/library/structs/NameServiceStructs.sol +47 -0
- package/library/structs/P2PSwapStructs.sol +127 -0
- package/library/structs/StakingStructs.sol +67 -0
- package/library/utils/AdvancedStrings.sol +84 -5
- package/library/utils/CAUtils.sol +29 -0
- package/library/utils/SignatureUtil.sol +34 -0
- package/library/utils/governance/Admin.sol +66 -0
- package/library/utils/governance/ProposalStructs.sol +49 -0
- package/library/utils/service/CoreExecution.sol +177 -0
- package/library/utils/service/StakingServiceUtils.sol +30 -3
- package/library/utils/signature/CoreHashUtils.sol +73 -0
- package/library/utils/signature/NameServiceHashUtils.sol +156 -0
- package/library/utils/signature/P2PSwapHashUtils.sol +65 -0
- package/library/utils/signature/StakingHashUtils.sol +41 -0
- package/library/utils/signature/TreasuryCrossChainHashUtils.sol +40 -0
- package/package.json +2 -1
- package/contracts/evvm/Evvm.sol +0 -1327
- package/contracts/evvm/lib/ErrorsLib.sol +0 -18
- package/contracts/evvm/lib/EvvmStorage.sol +0 -62
- package/contracts/evvm/lib/EvvmStructs.sol +0 -90
- package/contracts/evvm/lib/SignatureUtils.sol +0 -120
- package/contracts/nameService/lib/ErrorsLib.sol +0 -21
- package/contracts/nameService/lib/NameServiceStructs.sol +0 -69
- package/contracts/nameService/lib/SignatureUtils.sol +0 -245
- package/contracts/p2pSwap/lib/P2PSwapStructs.sol +0 -59
- package/contracts/p2pSwap/lib/SignatureUtils.sol +0 -98
- package/contracts/staking/lib/ErrorsLib.sol +0 -22
- package/contracts/staking/lib/SignatureUtils.sol +0 -39
- package/contracts/staking/lib/StakingStructs.sol +0 -94
- package/contracts/treasury/lib/ErrorsLib.sol +0 -11
- package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +0 -48
- package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +0 -80
- package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +0 -87
- package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +0 -79
- package/library/utils/GovernanceUtils.sol +0 -81
- package/library/utils/nonces/AsyncNonce.sol +0 -32
- package/library/utils/nonces/SyncNonce.sol +0 -27
- package/library/utils/service/EvvmPayments.sol +0 -79
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
library ErrorsLib {
|
|
7
|
-
error InvalidSignature();
|
|
8
|
-
error SenderIsNotTheExecutor();
|
|
9
|
-
error UpdateBalanceFailed();
|
|
10
|
-
error SyncNonceMismatch();
|
|
11
|
-
error AsyncNonceAlreadyUsed();
|
|
12
|
-
error NotAnStaker();
|
|
13
|
-
error InsufficientBalance();
|
|
14
|
-
error InvalidAmount(uint256, uint256);
|
|
15
|
-
error NotAnCA();
|
|
16
|
-
error SenderIsNotTreasury();
|
|
17
|
-
error WindowToChangeEvvmIDExpired();
|
|
18
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
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 "./EvvmStructs.sol";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @title EvvmStorage
|
|
10
|
-
* @author Mate labs
|
|
11
|
-
* @dev Storage layout contract for EVVM proxy pattern implementation.
|
|
12
|
-
* This contract inherits all structures from EvvmStructs and
|
|
13
|
-
* defines the storage layout that will be used by the proxy pattern.
|
|
14
|
-
*
|
|
15
|
-
* @notice This contract should not be deployed directly, it's meant to be
|
|
16
|
-
* inherited by the implementation contracts to ensure they maintain
|
|
17
|
-
* the same storage layout.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
abstract contract EvvmStorage is EvvmStructs {
|
|
21
|
-
address constant ETH_ADDRESS = address(0);
|
|
22
|
-
bytes1 constant FLAG_IS_STAKER = 0x01;
|
|
23
|
-
uint256 constant TIME_TO_ACCEPT_PROPOSAL = 1 days;
|
|
24
|
-
uint256 constant TIME_TO_ACCEPT_IMPLEMENTATION = 30 days;
|
|
25
|
-
|
|
26
|
-
address nameServiceAddress;
|
|
27
|
-
|
|
28
|
-
address stakingContractAddress;
|
|
29
|
-
|
|
30
|
-
address treasuryAddress;
|
|
31
|
-
|
|
32
|
-
address whitelistTokenToBeAdded_address;
|
|
33
|
-
address whitelistTokenToBeAdded_pool;
|
|
34
|
-
uint256 whitelistTokenToBeAdded_dateToSet;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @dev The address of the implementation contract is stored
|
|
38
|
-
* separately because of the way the proxy pattern works,
|
|
39
|
-
* rather than in a struct.
|
|
40
|
-
*/
|
|
41
|
-
address currentImplementation;
|
|
42
|
-
address proposalImplementation;
|
|
43
|
-
uint256 timeToAcceptImplementation;
|
|
44
|
-
|
|
45
|
-
uint256 windowTimeToChangeEvvmID;
|
|
46
|
-
|
|
47
|
-
EvvmMetadata evvmMetadata;
|
|
48
|
-
|
|
49
|
-
AddressTypeProposal admin;
|
|
50
|
-
|
|
51
|
-
bytes1 breakerSetupNameServiceAddress;
|
|
52
|
-
|
|
53
|
-
mapping(address => bytes1) stakerList;
|
|
54
|
-
|
|
55
|
-
mapping(address user => mapping(address token => uint256 quantity)) balances;
|
|
56
|
-
|
|
57
|
-
mapping(address user => uint256 nonce) nextSyncUsedNonce;
|
|
58
|
-
|
|
59
|
-
mapping(address user => mapping(uint256 nonce => bool isUsed)) asyncUsedNonce;
|
|
60
|
-
|
|
61
|
-
mapping(address user => uint256 nonce) nextFisherDepositNonce;
|
|
62
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
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
|
-
/**
|
|
7
|
-
* @title EvvmStructs
|
|
8
|
-
* @dev Library of common structures used across EVVM and its services.
|
|
9
|
-
* This contract serves as a shared type system for the entire ecosystem,
|
|
10
|
-
* ensuring consistency in data structures between the core EVVM and
|
|
11
|
-
* external service contracts.
|
|
12
|
-
*
|
|
13
|
-
* @notice This contract should be inherited by both EVVM and service contracts
|
|
14
|
-
* that need to interact with these data structures.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
abstract contract EvvmStructs {
|
|
18
|
-
struct PayData {
|
|
19
|
-
address from;
|
|
20
|
-
address to_address;
|
|
21
|
-
string to_identity;
|
|
22
|
-
address token;
|
|
23
|
-
uint256 amount;
|
|
24
|
-
uint256 priorityFee;
|
|
25
|
-
uint256 nonce;
|
|
26
|
-
bool priorityFlag;
|
|
27
|
-
address executor;
|
|
28
|
-
bytes signature;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
struct DispersePayData {
|
|
32
|
-
address from;
|
|
33
|
-
DispersePayMetadata[] toData;
|
|
34
|
-
address token;
|
|
35
|
-
uint256 totalAmount;
|
|
36
|
-
uint256 priorityFee;
|
|
37
|
-
uint256 nonce;
|
|
38
|
-
bool priorityFlag;
|
|
39
|
-
address executor;
|
|
40
|
-
bytes signature;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
struct CaPayData {
|
|
44
|
-
address from;
|
|
45
|
-
address to;
|
|
46
|
-
address token;
|
|
47
|
-
uint256 amount;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
struct DisperseCaPayData{
|
|
51
|
-
address from;
|
|
52
|
-
DisperseCaPayMetadata[] toData;
|
|
53
|
-
address token;
|
|
54
|
-
uint256 amount;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
struct DispersePayMetadata {
|
|
58
|
-
uint256 amount;
|
|
59
|
-
address to_address;
|
|
60
|
-
string to_identity;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
struct DisperseCaPayMetadata {
|
|
64
|
-
uint256 amount;
|
|
65
|
-
address toAddress;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
struct EvvmMetadata {
|
|
69
|
-
string EvvmName;
|
|
70
|
-
uint256 EvvmID;
|
|
71
|
-
string principalTokenName;
|
|
72
|
-
string principalTokenSymbol;
|
|
73
|
-
address principalTokenAddress;
|
|
74
|
-
uint256 totalSupply;
|
|
75
|
-
uint256 eraTokens;
|
|
76
|
-
uint256 reward;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
struct AddressTypeProposal {
|
|
80
|
-
address current;
|
|
81
|
-
address proposal;
|
|
82
|
-
uint256 timeToAccept;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
struct UintTypeProposal {
|
|
86
|
-
uint256 current;
|
|
87
|
-
uint256 proposal;
|
|
88
|
-
uint256 timeToAccept;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
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;
|
|
4
|
-
|
|
5
|
-
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
6
|
-
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
7
|
-
|
|
8
|
-
library SignatureUtils {
|
|
9
|
-
/**
|
|
10
|
-
* @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
|
|
11
|
-
* verify messages, the next functions are used to verify the messages signed
|
|
12
|
-
* by the users
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* @notice This function is used to verify the message signed for the payment
|
|
17
|
-
* @param signer user who signed the message
|
|
18
|
-
* @param _receiverAddress address of the receiver
|
|
19
|
-
* @param _receiverIdentity identity of the receiver
|
|
20
|
-
*
|
|
21
|
-
* @notice if the _receiverAddress is 0x0 the function will use the _receiverIdentity
|
|
22
|
-
*
|
|
23
|
-
* @param _token address of the token to send
|
|
24
|
-
* @param _amount amount to send
|
|
25
|
-
* @param _priorityFee priorityFee to send to the staking holder
|
|
26
|
-
* @param _nonce nonce of the transaction
|
|
27
|
-
* @param _priorityFlag if the transaction is priority or not
|
|
28
|
-
* @param _executor the executor of the transaction
|
|
29
|
-
* @param signature signature of the user who wants to send the message
|
|
30
|
-
* @return true if the signature is valid
|
|
31
|
-
*/
|
|
32
|
-
function verifyMessageSignedForPay(
|
|
33
|
-
uint256 evvmID,
|
|
34
|
-
address signer,
|
|
35
|
-
address _receiverAddress,
|
|
36
|
-
string memory _receiverIdentity,
|
|
37
|
-
address _token,
|
|
38
|
-
uint256 _amount,
|
|
39
|
-
uint256 _priorityFee,
|
|
40
|
-
uint256 _nonce,
|
|
41
|
-
bool _priorityFlag,
|
|
42
|
-
address _executor,
|
|
43
|
-
bytes memory signature
|
|
44
|
-
) internal pure returns (bool) {
|
|
45
|
-
return
|
|
46
|
-
SignatureUtil.verifySignature(
|
|
47
|
-
evvmID,
|
|
48
|
-
"pay",
|
|
49
|
-
string.concat(
|
|
50
|
-
_receiverAddress == address(0)
|
|
51
|
-
? _receiverIdentity
|
|
52
|
-
: AdvancedStrings.addressToString(_receiverAddress),
|
|
53
|
-
",",
|
|
54
|
-
AdvancedStrings.addressToString(_token),
|
|
55
|
-
",",
|
|
56
|
-
AdvancedStrings.uintToString(_amount),
|
|
57
|
-
",",
|
|
58
|
-
AdvancedStrings.uintToString(_priorityFee),
|
|
59
|
-
",",
|
|
60
|
-
AdvancedStrings.uintToString(_nonce),
|
|
61
|
-
",",
|
|
62
|
-
_priorityFlag ? "true" : "false",
|
|
63
|
-
",",
|
|
64
|
-
AdvancedStrings.addressToString(_executor)
|
|
65
|
-
),
|
|
66
|
-
signature,
|
|
67
|
-
signer
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @notice This function is used to verify the message signed for the dispersePay
|
|
73
|
-
* @param signer user who signed the message
|
|
74
|
-
* @param hashList hash of the list of the transactions, the hash is calculated
|
|
75
|
-
* using sha256(abi.encode(toData))
|
|
76
|
-
* @param _token token address to send
|
|
77
|
-
* @param _amount amount to send
|
|
78
|
-
* @param _priorityFee priorityFee to send to the fisher who wants to send the message
|
|
79
|
-
* @param _nonce nonce of the transaction
|
|
80
|
-
* @param _priorityFlag if the transaction is priority or not
|
|
81
|
-
* @param _executor the executor of the transaction
|
|
82
|
-
* @param signature signature of the user who wants to send the message
|
|
83
|
-
* @return true if the signature is valid
|
|
84
|
-
*/
|
|
85
|
-
function verifyMessageSignedForDispersePay(
|
|
86
|
-
uint256 evvmID,
|
|
87
|
-
address signer,
|
|
88
|
-
bytes32 hashList,
|
|
89
|
-
address _token,
|
|
90
|
-
uint256 _amount,
|
|
91
|
-
uint256 _priorityFee,
|
|
92
|
-
uint256 _nonce,
|
|
93
|
-
bool _priorityFlag,
|
|
94
|
-
address _executor,
|
|
95
|
-
bytes memory signature
|
|
96
|
-
) internal pure returns (bool) {
|
|
97
|
-
return
|
|
98
|
-
SignatureUtil.verifySignature(
|
|
99
|
-
evvmID,
|
|
100
|
-
"dispersePay",
|
|
101
|
-
string.concat(
|
|
102
|
-
AdvancedStrings.bytes32ToString(hashList),
|
|
103
|
-
",",
|
|
104
|
-
AdvancedStrings.addressToString(_token),
|
|
105
|
-
",",
|
|
106
|
-
AdvancedStrings.uintToString(_amount),
|
|
107
|
-
",",
|
|
108
|
-
AdvancedStrings.uintToString(_priorityFee),
|
|
109
|
-
",",
|
|
110
|
-
AdvancedStrings.uintToString(_nonce),
|
|
111
|
-
",",
|
|
112
|
-
_priorityFlag ? "true" : "false",
|
|
113
|
-
",",
|
|
114
|
-
AdvancedStrings.addressToString(_executor)
|
|
115
|
-
),
|
|
116
|
-
signature,
|
|
117
|
-
signer
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
library ErrorsLib {
|
|
7
|
-
error SenderIsNotAdmin();
|
|
8
|
-
error UserIsNotOwnerOfIdentity();
|
|
9
|
-
error NonceAlreadyUsed();
|
|
10
|
-
error InvalidSignatureOnNameService();
|
|
11
|
-
error InvalidUsername();
|
|
12
|
-
error UsernameAlreadyRegistered();
|
|
13
|
-
error PreRegistrationNotValid();
|
|
14
|
-
error MakeOfferVerificationFailed();
|
|
15
|
-
error UserIsNotOwnerOfOffer();
|
|
16
|
-
error AcceptOfferVerificationFailed();
|
|
17
|
-
error RenewUsernameVerificationFailed();
|
|
18
|
-
error EmptyCustomMetadata();
|
|
19
|
-
error InvalidKey();
|
|
20
|
-
error FlushUsernameVerificationFailed();
|
|
21
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
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
|
-
abstract contract NameServiceStructs {
|
|
7
|
-
/**
|
|
8
|
-
* @dev Struct for managing address change proposals with time delay
|
|
9
|
-
* @param current Currently active address
|
|
10
|
-
* @param proposal Proposed new address waiting for approval
|
|
11
|
-
* @param timeToAccept Timestamp when the proposal can be accepted
|
|
12
|
-
*/
|
|
13
|
-
struct AddressTypeProposal {
|
|
14
|
-
address current;
|
|
15
|
-
address proposal;
|
|
16
|
-
uint256 timeToAccept;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @dev Struct for managing uint256 value proposals with time delay
|
|
21
|
-
* @param current Currently active value
|
|
22
|
-
* @param proposal Proposed new value waiting for approval
|
|
23
|
-
* @param timeToAccept Timestamp when the proposal can be accepted
|
|
24
|
-
*/
|
|
25
|
-
struct UintTypeProposal {
|
|
26
|
-
uint256 current;
|
|
27
|
-
uint256 proposal;
|
|
28
|
-
uint256 timeToAccept;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @dev Struct for managing boolean flag changes with time delay
|
|
33
|
-
* @param flag Current boolean state
|
|
34
|
-
* @param timeToAcceptChange Timestamp when the flag change can be executed
|
|
35
|
-
*/
|
|
36
|
-
struct BoolTypeProposal {
|
|
37
|
-
bool flag;
|
|
38
|
-
uint256 timeToAcceptChange;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @dev Core metadata for each registered identity/username
|
|
43
|
-
* @param owner Address that owns this identity
|
|
44
|
-
* @param expireDate Timestamp when the registration expires
|
|
45
|
-
* @param customMetadataMaxSlots Number of custom metadata entries stored
|
|
46
|
-
* @param offerMaxSlots Maximum number of offers that have been made
|
|
47
|
-
* @param flagNotAUsername Flag indicating if this is a pre-registration (0x01) or actual username (0x00)
|
|
48
|
-
*/
|
|
49
|
-
struct IdentityBaseMetadata {
|
|
50
|
-
address owner;
|
|
51
|
-
uint256 expireDate;
|
|
52
|
-
uint256 customMetadataMaxSlots;
|
|
53
|
-
uint256 offerMaxSlots;
|
|
54
|
-
bytes1 flagNotAUsername;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @dev Metadata for marketplace offers on usernames
|
|
60
|
-
* @param offerer Address making the offer
|
|
61
|
-
* @param expireDate Timestamp when the offer expires
|
|
62
|
-
* @param amount Amount offered in Principal Tokens (after 0.5% marketplace fee deduction)
|
|
63
|
-
*/
|
|
64
|
-
struct OfferMetadata {
|
|
65
|
-
address offerer;
|
|
66
|
-
uint256 expireDate;
|
|
67
|
-
uint256 amount;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,245 +0,0 @@
|
|
|
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;
|
|
4
|
-
|
|
5
|
-
import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
|
|
6
|
-
import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
|
|
7
|
-
|
|
8
|
-
library SignatureUtils {
|
|
9
|
-
/**
|
|
10
|
-
* @dev using EIP-191 (https://eips.ethereum.org/EIPS/eip-191) can be used to sign and
|
|
11
|
-
* verify messages, the next functions are used to verify the messages signed
|
|
12
|
-
* by the users
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
function verifyMessageSignedForPreRegistrationUsername(
|
|
16
|
-
uint256 evvmID,
|
|
17
|
-
address signer,
|
|
18
|
-
bytes32 _hashUsername,
|
|
19
|
-
uint256 _nameServiceNonce,
|
|
20
|
-
bytes memory signature
|
|
21
|
-
) internal pure returns (bool) {
|
|
22
|
-
return
|
|
23
|
-
SignatureUtil.verifySignature(
|
|
24
|
-
evvmID,
|
|
25
|
-
"preRegistrationUsername",
|
|
26
|
-
string.concat(
|
|
27
|
-
AdvancedStrings.bytes32ToString(_hashUsername),
|
|
28
|
-
",",
|
|
29
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
30
|
-
),
|
|
31
|
-
signature,
|
|
32
|
-
signer
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function verifyMessageSignedForRegistrationUsername(
|
|
37
|
-
uint256 evvmID,
|
|
38
|
-
address signer,
|
|
39
|
-
string memory _username,
|
|
40
|
-
uint256 _clowNumber,
|
|
41
|
-
uint256 _nameServiceNonce,
|
|
42
|
-
bytes memory signature
|
|
43
|
-
) internal pure returns (bool) {
|
|
44
|
-
return
|
|
45
|
-
SignatureUtil.verifySignature(
|
|
46
|
-
evvmID,
|
|
47
|
-
"registrationUsername",
|
|
48
|
-
string.concat(
|
|
49
|
-
_username,
|
|
50
|
-
",",
|
|
51
|
-
AdvancedStrings.uintToString(_clowNumber),
|
|
52
|
-
",",
|
|
53
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
54
|
-
),
|
|
55
|
-
signature,
|
|
56
|
-
signer
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function verifyMessageSignedForMakeOffer(
|
|
61
|
-
uint256 evvmID,
|
|
62
|
-
address signer,
|
|
63
|
-
string memory _username,
|
|
64
|
-
uint256 _dateExpire,
|
|
65
|
-
uint256 _amount,
|
|
66
|
-
uint256 _nameServiceNonce,
|
|
67
|
-
bytes memory signature
|
|
68
|
-
) internal pure returns (bool) {
|
|
69
|
-
return
|
|
70
|
-
SignatureUtil.verifySignature(
|
|
71
|
-
evvmID,
|
|
72
|
-
"makeOffer",
|
|
73
|
-
string.concat(
|
|
74
|
-
_username,
|
|
75
|
-
",",
|
|
76
|
-
AdvancedStrings.uintToString(_dateExpire),
|
|
77
|
-
",",
|
|
78
|
-
AdvancedStrings.uintToString(_amount),
|
|
79
|
-
",",
|
|
80
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
81
|
-
),
|
|
82
|
-
signature,
|
|
83
|
-
signer
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function verifyMessageSignedForWithdrawOffer(
|
|
88
|
-
uint256 evvmID,
|
|
89
|
-
address signer,
|
|
90
|
-
string memory _username,
|
|
91
|
-
uint256 _offerId,
|
|
92
|
-
uint256 _nameServiceNonce,
|
|
93
|
-
bytes memory signature
|
|
94
|
-
) internal pure returns (bool) {
|
|
95
|
-
return
|
|
96
|
-
SignatureUtil.verifySignature(
|
|
97
|
-
evvmID,
|
|
98
|
-
"withdrawOffer",
|
|
99
|
-
string.concat(
|
|
100
|
-
_username,
|
|
101
|
-
",",
|
|
102
|
-
AdvancedStrings.uintToString(_offerId),
|
|
103
|
-
",",
|
|
104
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
105
|
-
),
|
|
106
|
-
signature,
|
|
107
|
-
signer
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function verifyMessageSignedForAcceptOffer(
|
|
112
|
-
uint256 evvmID,
|
|
113
|
-
address signer,
|
|
114
|
-
string memory _username,
|
|
115
|
-
uint256 _offerId,
|
|
116
|
-
uint256 _nameServiceNonce,
|
|
117
|
-
bytes memory signature
|
|
118
|
-
) internal pure returns (bool) {
|
|
119
|
-
return
|
|
120
|
-
SignatureUtil.verifySignature(
|
|
121
|
-
evvmID,
|
|
122
|
-
"acceptOffer",
|
|
123
|
-
string.concat(
|
|
124
|
-
_username,
|
|
125
|
-
",",
|
|
126
|
-
AdvancedStrings.uintToString(_offerId),
|
|
127
|
-
",",
|
|
128
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
129
|
-
),
|
|
130
|
-
signature,
|
|
131
|
-
signer
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function verifyMessageSignedForRenewUsername(
|
|
136
|
-
uint256 evvmID,
|
|
137
|
-
address signer,
|
|
138
|
-
string memory _username,
|
|
139
|
-
uint256 _nameServiceNonce,
|
|
140
|
-
bytes memory signature
|
|
141
|
-
) internal pure returns (bool) {
|
|
142
|
-
return
|
|
143
|
-
SignatureUtil.verifySignature(
|
|
144
|
-
evvmID,
|
|
145
|
-
"renewUsername",
|
|
146
|
-
string.concat(
|
|
147
|
-
_username,
|
|
148
|
-
",",
|
|
149
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
150
|
-
),
|
|
151
|
-
signature,
|
|
152
|
-
signer
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function verifyMessageSignedForAddCustomMetadata(
|
|
157
|
-
uint256 evvmID,
|
|
158
|
-
address signer,
|
|
159
|
-
string memory _identity,
|
|
160
|
-
string memory _value,
|
|
161
|
-
uint256 _nameServiceNonce,
|
|
162
|
-
bytes memory signature
|
|
163
|
-
) internal pure returns (bool) {
|
|
164
|
-
return
|
|
165
|
-
SignatureUtil.verifySignature(
|
|
166
|
-
evvmID,
|
|
167
|
-
"addCustomMetadata",
|
|
168
|
-
string.concat(
|
|
169
|
-
_identity,
|
|
170
|
-
",",
|
|
171
|
-
_value,
|
|
172
|
-
",",
|
|
173
|
-
AdvancedStrings.uintToString(_nameServiceNonce)
|
|
174
|
-
),
|
|
175
|
-
signature,
|
|
176
|
-
signer
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function verifyMessageSignedForRemoveCustomMetadata(
|
|
181
|
-
uint256 evvmID,
|
|
182
|
-
address signer,
|
|
183
|
-
string memory _username,
|
|
184
|
-
uint256 _key,
|
|
185
|
-
uint256 _nonce,
|
|
186
|
-
bytes memory signature
|
|
187
|
-
) internal pure returns (bool) {
|
|
188
|
-
return
|
|
189
|
-
SignatureUtil.verifySignature(
|
|
190
|
-
evvmID,
|
|
191
|
-
"removeCustomMetadata",
|
|
192
|
-
string.concat(
|
|
193
|
-
_username,
|
|
194
|
-
",",
|
|
195
|
-
AdvancedStrings.uintToString(_key),
|
|
196
|
-
",",
|
|
197
|
-
AdvancedStrings.uintToString(_nonce)
|
|
198
|
-
),
|
|
199
|
-
signature,
|
|
200
|
-
signer
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function verifyMessageSignedForFlushCustomMetadata(
|
|
205
|
-
uint256 evvmID,
|
|
206
|
-
address signer,
|
|
207
|
-
string memory _identity,
|
|
208
|
-
uint256 _nonce,
|
|
209
|
-
bytes memory signature
|
|
210
|
-
) internal pure returns (bool) {
|
|
211
|
-
return
|
|
212
|
-
SignatureUtil.verifySignature(
|
|
213
|
-
evvmID,
|
|
214
|
-
"flushCustomMetadata",
|
|
215
|
-
string.concat(
|
|
216
|
-
_identity,
|
|
217
|
-
",",
|
|
218
|
-
AdvancedStrings.uintToString(_nonce)
|
|
219
|
-
),
|
|
220
|
-
signature,
|
|
221
|
-
signer
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function verifyMessageSignedForFlushUsername(
|
|
226
|
-
uint256 evvmID,
|
|
227
|
-
address signer,
|
|
228
|
-
string memory _username,
|
|
229
|
-
uint256 _nonce,
|
|
230
|
-
bytes memory signature
|
|
231
|
-
) internal pure returns (bool) {
|
|
232
|
-
return
|
|
233
|
-
SignatureUtil.verifySignature(
|
|
234
|
-
evvmID,
|
|
235
|
-
"flushUsername",
|
|
236
|
-
string.concat(
|
|
237
|
-
_username,
|
|
238
|
-
",",
|
|
239
|
-
AdvancedStrings.uintToString(_nonce)
|
|
240
|
-
),
|
|
241
|
-
signature,
|
|
242
|
-
signer
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
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
|
-
|
|
7
|
-
abstract contract P2PSwapStructs {
|
|
8
|
-
struct MarketInformation {
|
|
9
|
-
address tokenA;
|
|
10
|
-
address tokenB;
|
|
11
|
-
uint256 maxSlot;
|
|
12
|
-
uint256 ordersAvailable;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
struct Order {
|
|
16
|
-
address seller;
|
|
17
|
-
uint256 amountA;
|
|
18
|
-
uint256 amountB;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
struct OrderForGetter {
|
|
22
|
-
uint256 marketId;
|
|
23
|
-
uint256 orderId;
|
|
24
|
-
address seller;
|
|
25
|
-
uint256 amountA;
|
|
26
|
-
uint256 amountB;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
struct Percentage {
|
|
30
|
-
uint256 seller;
|
|
31
|
-
uint256 service;
|
|
32
|
-
uint256 mateStaker;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
struct MetadataMakeOrder {
|
|
36
|
-
uint256 nonce;
|
|
37
|
-
address tokenA;
|
|
38
|
-
address tokenB;
|
|
39
|
-
uint256 amountA;
|
|
40
|
-
uint256 amountB;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
struct MetadataCancelOrder {
|
|
44
|
-
uint256 nonce;
|
|
45
|
-
address tokenA;
|
|
46
|
-
address tokenB;
|
|
47
|
-
uint256 orderId;
|
|
48
|
-
bytes signature;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
struct MetadataDispatchOrder {
|
|
52
|
-
uint256 nonce;
|
|
53
|
-
address tokenA;
|
|
54
|
-
address tokenB;
|
|
55
|
-
uint256 orderId;
|
|
56
|
-
uint256 amountOfTokenBToFill;
|
|
57
|
-
bytes signature;
|
|
58
|
-
}
|
|
59
|
-
}
|