@evvm/testnet-contracts 2.2.0 → 2.2.2

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.
Files changed (44) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +46 -521
  3. package/contracts/evvm/Evvm.sol +28 -31
  4. package/contracts/evvm/lib/ErrorsLib.sol +2 -1
  5. package/contracts/evvm/lib/EvvmStructs.sol +27 -1
  6. package/contracts/evvm/lib/SignatureUtils.sol +2 -5
  7. package/contracts/nameService/NameService.sol +118 -363
  8. package/contracts/nameService/lib/ErrorsLib.sol +1 -7
  9. package/contracts/nameService/lib/IdentityValidation.sol +182 -0
  10. package/contracts/nameService/lib/NameServiceStructs.sol +69 -0
  11. package/contracts/nameService/lib/SignatureUtils.sol +11 -4
  12. package/contracts/p2pSwap/P2PSwap.sol +41 -154
  13. package/contracts/p2pSwap/lib/P2PSwapStructs.sol +59 -0
  14. package/contracts/p2pSwap/lib/SignatureUtils.sol +1 -2
  15. package/contracts/staking/Estimator.sol +7 -6
  16. package/contracts/staking/Staking.sol +46 -146
  17. package/contracts/staking/lib/SignatureUtils.sol +1 -2
  18. package/contracts/staking/lib/StakingStructs.sol +94 -0
  19. package/contracts/treasury/Treasury.sol +18 -20
  20. package/contracts/treasuryTwoChains/TreasuryExternalChainStation.sol +88 -35
  21. package/contracts/treasuryTwoChains/TreasuryHostChainStation.sol +81 -47
  22. package/contracts/treasuryTwoChains/lib/ErrorsLib.sol +2 -0
  23. package/contracts/treasuryTwoChains/lib/ExternalChainStationStructs.sol +3 -14
  24. package/contracts/treasuryTwoChains/lib/HostChainStationStructs.sol +3 -7
  25. package/contracts/treasuryTwoChains/lib/SignatureUtils.sol +5 -7
  26. package/interfaces/IEstimator.sol +7 -50
  27. package/interfaces/IEvvm.sol +16 -90
  28. package/interfaces/INameService.sol +37 -88
  29. package/interfaces/IP2PSwap.sol +19 -15
  30. package/interfaces/IStaking.sol +20 -50
  31. package/interfaces/ITreasury.sol +1 -4
  32. package/interfaces/ITreasuryExternalChainStation.sol +11 -15
  33. package/interfaces/ITreasuryHostChainStation.sol +7 -10
  34. package/library/Erc191TestBuilder.sol +0 -1
  35. package/library/EvvmService.sol +14 -78
  36. package/library/primitives/IERC20.sol +79 -0
  37. package/library/utils/GovernanceUtils.sol +81 -0
  38. package/library/utils/{service/AsyncNonceService.sol → nonces/AsyncNonce.sol} +9 -11
  39. package/library/utils/nonces/SyncNonce.sol +27 -0
  40. package/library/utils/service/EvvmPayments.sol +77 -0
  41. package/library/utils/service/StakingServiceUtils.sol +15 -20
  42. package/package.json +11 -13
  43. package/library/utils/service/MakeServicePaymentOnEvvm.sol +0 -49
  44. package/library/utils/service/SyncNonceService.sol +0 -18
@@ -1,5 +1,6 @@
1
- // SPDX-License-Identifier: UNLICENSED
2
- pragma solidity ^0.8.4;
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
- uint32 hostChainStationDomainId;
20
- address mailboxAddress;
21
- uint32 hostChainStationEid;
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 TreasuryExternalChainStation {
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: UNLICENSED
2
- pragma solidity ^0.8.4;
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
- uint32 externalChainStationDomainId;
20
- address mailboxAddress;
21
- uint32 externalChainStationEid;
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 TreasuryHostChainStation {
38
+ interface ITreasuryHostChainStation {
42
39
  struct EnforcedOptionParam {
43
40
  uint32 eid;
44
41
  uint16 msgType;
@@ -11,7 +11,6 @@ pragma solidity ^0.8.0;
11
11
  * https://book.getfoundry.sh/cheatcodes/sign
12
12
  */
13
13
 
14
-
15
14
  import {AdvancedStrings} from "@evvm/testnet-contracts/library/utils/AdvancedStrings.sol";
16
15
 
17
16
  library Erc191TestBuilder {
@@ -3,21 +3,23 @@
3
3
 
4
4
  pragma solidity ^0.8.0;
5
5
 
6
- import {IEvvm} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
7
- import {IStaking} from "@evvm/testnet-contracts/interfaces/IStaking.sol";
6
+ import {EvvmStructs} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
8
7
  import {SignatureUtil} from "@evvm/testnet-contracts/library/utils/SignatureUtil.sol";
9
- import {AsyncNonceService} from "@evvm/testnet-contracts/library/utils/service/AsyncNonceService.sol";
10
-
11
- abstract contract EvvmService is AsyncNonceService {
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
+ {
12
17
  error InvalidServiceSignature();
13
18
 
14
- IEvvm evvm;
15
- IStaking staking;
16
-
17
- constructor(address evvmAddress, address stakingAddress) {
18
- evvm = IEvvm(evvmAddress);
19
- staking = IStaking(stakingAddress);
20
- }
19
+ constructor(
20
+ address evvmAddress,
21
+ address stakingAddress
22
+ ) StakingServiceUtils(stakingAddress) EvvmPayments(evvmAddress) {}
21
23
 
22
24
  function validateServiceSignature(
23
25
  string memory functionName,
@@ -35,70 +37,4 @@ abstract contract EvvmService is AsyncNonceService {
35
37
  )
36
38
  ) revert InvalidServiceSignature();
37
39
  }
38
-
39
- function requestPay(
40
- address from,
41
- address token,
42
- uint256 amount,
43
- uint256 priorityFee,
44
- uint256 nonce,
45
- bool priorityFlag,
46
- bytes memory signature
47
- ) internal virtual {
48
- evvm.pay(
49
- from,
50
- address(this),
51
- "",
52
- token,
53
- amount,
54
- priorityFee,
55
- nonce,
56
- priorityFlag,
57
- address(this),
58
- signature
59
- );
60
- }
61
-
62
- function makeCaPay(
63
- address to,
64
- address token,
65
- uint256 amount
66
- ) internal virtual {
67
- evvm.caPay(to, token, amount);
68
- }
69
-
70
- function _makeStakeService(uint256 amountToStake) internal {
71
- staking.prepareServiceStaking(amountToStake);
72
- evvm.caPay(
73
- address(staking),
74
- getPrincipalTokenAddress(),
75
- staking.priceOfStaking() * amountToStake
76
- );
77
- staking.confirmServiceStaking();
78
- }
79
-
80
- function _makeUnstakeService(uint256 amountToUnstake) internal {
81
- staking.serviceUnstaking(amountToUnstake);
82
- }
83
-
84
- function _changeEvvmAddress(address newEvvmAddress) internal {
85
- evvm = IEvvm(newEvvmAddress);
86
- }
87
-
88
- function _changeStakingAddress(address newStakingAddress) internal {
89
- staking = IStaking(newStakingAddress);
90
- }
91
-
92
- function getPrincipalTokenAddress()
93
- internal
94
- pure
95
- virtual
96
- returns (address)
97
- {
98
- return address(1);
99
- }
100
-
101
- function getEtherAddress() internal pure virtual returns (address) {
102
- return address(0);
103
- }
104
40
  }
@@ -0,0 +1,79 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
3
+
4
+ pragma solidity ^0.8.20;
5
+
6
+ /**
7
+ * @dev Interface of the ERC20 standard as defined in the EIP.
8
+ */
9
+ interface IERC20 {
10
+ /**
11
+ * @dev Emitted when `value` tokens are moved from one account (`from`) to
12
+ * another (`to`).
13
+ *
14
+ * Note that `value` may be zero.
15
+ */
16
+ event Transfer(address indexed from, address indexed to, uint256 value);
17
+
18
+ /**
19
+ * @dev Emitted when the allowance of a `spender` for an `owner` is set by
20
+ * a call to {approve}. `value` is the new allowance.
21
+ */
22
+ event Approval(address indexed owner, address indexed spender, uint256 value);
23
+
24
+ /**
25
+ * @dev Returns the value of tokens in existence.
26
+ */
27
+ function totalSupply() external view returns (uint256);
28
+
29
+ /**
30
+ * @dev Returns the value of tokens owned by `account`.
31
+ */
32
+ function balanceOf(address account) external view returns (uint256);
33
+
34
+ /**
35
+ * @dev Moves a `value` amount of tokens from the caller's account to `to`.
36
+ *
37
+ * Returns a boolean value indicating whether the operation succeeded.
38
+ *
39
+ * Emits a {Transfer} event.
40
+ */
41
+ function transfer(address to, uint256 value) external returns (bool);
42
+
43
+ /**
44
+ * @dev Returns the remaining number of tokens that `spender` will be
45
+ * allowed to spend on behalf of `owner` through {transferFrom}. This is
46
+ * zero by default.
47
+ *
48
+ * This value changes when {approve} or {transferFrom} are called.
49
+ */
50
+ function allowance(address owner, address spender) external view returns (uint256);
51
+
52
+ /**
53
+ * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
54
+ * caller's tokens.
55
+ *
56
+ * Returns a boolean value indicating whether the operation succeeded.
57
+ *
58
+ * IMPORTANT: Beware that changing an allowance with this method brings the risk
59
+ * that someone may use both the old and the new allowance by unfortunate
60
+ * transaction ordering. One possible solution to mitigate this race
61
+ * condition is to first reduce the spender's allowance to 0 and set the
62
+ * desired value afterwards:
63
+ * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
64
+ *
65
+ * Emits an {Approval} event.
66
+ */
67
+ function approve(address spender, uint256 value) external returns (bool);
68
+
69
+ /**
70
+ * @dev Moves a `value` amount of tokens from `from` to `to` using the
71
+ * allowance mechanism. `value` is then deducted from the caller's
72
+ * allowance.
73
+ *
74
+ * Returns a boolean value indicating whether the operation succeeded.
75
+ *
76
+ * Emits a {Transfer} event.
77
+ */
78
+ function transferFrom(address from, address to, uint256 value) external returns (bool);
79
+ }
@@ -0,0 +1,81 @@
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 ProposalStructs {
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
+ /**
43
+ * @title AdminControlled
44
+ * @notice Base contract for admin-controlled contracts with time-delayed governance
45
+ */
46
+ abstract contract AdminControlled {
47
+ ProposalStructs.AddressTypeProposal public admin;
48
+
49
+ event AdminProposed(address indexed newAdmin, uint256 timeToAccept);
50
+ event AdminAccepted(address indexed newAdmin);
51
+
52
+ error SenderIsNotAdmin();
53
+ error ProposalNotReady();
54
+
55
+ modifier onlyAdmin() {
56
+ if (msg.sender != admin.current) revert SenderIsNotAdmin();
57
+ _;
58
+ }
59
+
60
+ /**
61
+ * @notice Proposes a new admin with time delay
62
+ * @param newAdmin Address of proposed admin
63
+ * @param delay Time delay before proposal can be accepted
64
+ */
65
+ function proposeAdmin(address newAdmin, uint256 delay) external onlyAdmin {
66
+ admin.proposal = newAdmin;
67
+ admin.timeToAccept = block.timestamp + delay;
68
+ emit AdminProposed(newAdmin, admin.timeToAccept);
69
+ }
70
+
71
+ /**
72
+ * @notice Accepts the admin proposal after time delay
73
+ */
74
+ function acceptAdminProposal() external onlyAdmin {
75
+ if (block.timestamp < admin.timeToAccept) revert ProposalNotReady();
76
+ admin.current = admin.proposal;
77
+ admin.proposal = address(0);
78
+ admin.timeToAccept = 0;
79
+ emit AdminAccepted(admin.current);
80
+ }
81
+ }
@@ -3,32 +3,30 @@
3
3
 
4
4
  pragma solidity ^0.8.0;
5
5
 
6
- abstract contract AsyncNonceService {
7
-
8
- error ServiceAsyncNonceAlreadyUsed();
6
+ abstract contract AsyncNonce {
7
+ error AsyncNonceAlreadyUsed();
9
8
 
10
9
  mapping(address user => mapping(uint256 nonce => bool availability))
11
- private asyncServiceNonce;
10
+ private asyncNonce;
12
11
 
13
- function markAsyncServiceNonceAsUsed(
12
+ function markAsyncNonceAsUsed(
14
13
  address user,
15
14
  uint256 nonce
16
15
  ) internal virtual {
17
- asyncServiceNonce[user][nonce] = true;
16
+ asyncNonce[user][nonce] = true;
18
17
  }
19
18
 
20
- function verifyAsyncServiceNonce(
19
+ function verifyAsyncNonce(
21
20
  address user,
22
21
  uint256 nonce
23
22
  ) internal view virtual {
24
- if (asyncServiceNonce[user][nonce])
25
- revert ServiceAsyncNonceAlreadyUsed();
23
+ if (asyncNonce[user][nonce]) revert AsyncNonceAlreadyUsed();
26
24
  }
27
25
 
28
- function isAsyncServiceNonceAvailable(
26
+ function getIfUsedAsyncNonce(
29
27
  address user,
30
28
  uint256 nonce
31
29
  ) public view virtual returns (bool) {
32
- return asyncServiceNonce[user][nonce];
30
+ return asyncNonce[user][nonce];
33
31
  }
34
32
  }
@@ -0,0 +1,27 @@
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 SyncNonce {
7
+ error SyncNonceMismatch();
8
+
9
+ mapping(address user => uint256 nonce) private syncNonce;
10
+
11
+ function incrementSyncNonce(address user) internal virtual {
12
+ syncNonce[user]++;
13
+ }
14
+
15
+ function verifySyncNonce(
16
+ address user,
17
+ uint256 nonce
18
+ ) internal view virtual {
19
+ if (syncNonce[user] != nonce) revert SyncNonceMismatch();
20
+ }
21
+
22
+ function getNextCurrentSyncNonce(
23
+ address user
24
+ ) public view virtual returns (uint256) {
25
+ return syncNonce[user];
26
+ }
27
+ }
@@ -0,0 +1,77 @@
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 {IEvvm, EvvmStructs} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
7
+
8
+ abstract contract EvvmPayments {
9
+ IEvvm internal evvm;
10
+
11
+ constructor(address evvmAddress) {}
12
+
13
+ function requestPay(
14
+ address from,
15
+ address token,
16
+ uint256 amount,
17
+ uint256 priorityFee,
18
+ uint256 nonce,
19
+ bool priorityFlag,
20
+ bytes memory signature
21
+ ) internal virtual {
22
+ evvm.pay(
23
+ from,
24
+ address(this),
25
+ "",
26
+ token,
27
+ amount,
28
+ priorityFee,
29
+ nonce,
30
+ priorityFlag,
31
+ address(this),
32
+ signature
33
+ );
34
+ }
35
+
36
+ function requestDispersePay(
37
+ EvvmStructs.DispersePayMetadata[] memory toData,
38
+ address token,
39
+ uint256 amount,
40
+ uint256 priorityFee,
41
+ uint256 nonce,
42
+ bool priorityFlag,
43
+ bytes memory signature
44
+ ) internal virtual {
45
+ evvm.dispersePay(
46
+ address(this),
47
+ toData,
48
+ token,
49
+ amount,
50
+ priorityFee,
51
+ nonce,
52
+ priorityFlag,
53
+ address(this),
54
+ signature
55
+ );
56
+ }
57
+
58
+ function makeCaPay(
59
+ address to,
60
+ address token,
61
+ uint256 amount
62
+ ) internal virtual {
63
+ evvm.caPay(to, token, amount);
64
+ }
65
+
66
+ function makeDisperseCaPay(
67
+ EvvmStructs.DisperseCaPayMetadata[] memory toData,
68
+ address token,
69
+ uint256 amount
70
+ ) internal virtual {
71
+ evvm.disperseCaPay(toData, token, amount);
72
+ }
73
+
74
+ function _changeEvvmAddress(address newEvvmAddress) internal virtual {
75
+ evvm = IEvvm(newEvvmAddress);
76
+ }
77
+ }
@@ -2,36 +2,31 @@
2
2
  // Full license terms available at: https://www.evvm.info/docs/EVVMNoncommercialLicense
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- import {IEvvm} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
6
5
  import {IStaking} from "@evvm/testnet-contracts/interfaces/IStaking.sol";
6
+ import {IEvvm} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
7
7
 
8
8
  abstract contract StakingServiceUtils {
9
- address stakingHookAddress;
10
- address evvmHookAddress;
11
- constructor(address _stakingAddress) {
12
- stakingHookAddress = _stakingAddress;
13
- evvmHookAddress = IStaking(stakingHookAddress).getEvvmAddress();
9
+ IStaking internal staking;
10
+
11
+ constructor(address stakingAddress) {
12
+ staking = IStaking(stakingAddress);
14
13
  }
14
+
15
15
  function _makeStakeService(uint256 amountToStake) internal {
16
- IStaking(stakingHookAddress).prepareServiceStaking(amountToStake);
17
- IEvvm(evvmHookAddress).caPay(
18
- address(stakingHookAddress),
19
- 0x0000000000000000000000000000000000000001,
20
- IStaking(stakingHookAddress).priceOfStaking() * amountToStake
16
+ staking.prepareServiceStaking(amountToStake);
17
+ IEvvm(staking.getEvvmAddress()).caPay(
18
+ address(staking),
19
+ IEvvm(staking.getEvvmAddress()).getPrincipalTokenAddress(),
20
+ staking.priceOfStaking() * amountToStake
21
21
  );
22
- IStaking(stakingHookAddress).confirmServiceStaking();
22
+ staking.confirmServiceStaking();
23
23
  }
24
24
 
25
25
  function _makeUnstakeService(uint256 amountToUnstake) internal {
26
- IStaking(stakingHookAddress).serviceUnstaking(amountToUnstake);
27
- }
28
-
29
- function _changeStakingAddress(address newStakingAddress) internal {
30
- stakingHookAddress = newStakingAddress;
31
- evvmHookAddress = IStaking(stakingHookAddress).getEvvmAddress();
26
+ staking.serviceUnstaking(amountToUnstake);
32
27
  }
33
28
 
34
- function _changeEvvmHookAddress(address newEvvmAddress) internal {
35
- evvmHookAddress = newEvvmAddress;
29
+ function _changeStakingAddress(address newStakingAddress) internal virtual {
30
+ staking = IStaking(newStakingAddress);
36
31
  }
37
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evvm/testnet-contracts",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "type": "module",
5
5
  "description": "EVVM Testnet Contracts - Smart contracts and tools for scalable, modular, and cross-chain EVM virtualization",
6
6
  "files": [
@@ -36,18 +36,17 @@
36
36
  "access": "public"
37
37
  },
38
38
  "scripts": {
39
- "build": "npm run copy-files",
39
+ "publish-package": "bun run copy-files && bun publish && bun run clean",
40
+ "prepare-publish": "bun run copy-files && bun run pack",
41
+ "build": "bun run copy-files",
40
42
  "copy-files": "cp -r src/contracts . && cp -r src/interfaces . && cp -r src/library .",
41
43
  "clean": "rm -rf contracts interfaces library",
42
- "prepare-publish": "npm run copy-files && npm pack",
43
- "publish-package": "npm run copy-files && npm publish && npm run clean",
44
- "compile": "forge build",
45
- "test": "forge test",
46
- "deploy:anvil": "make deployLocalTestnet",
47
- "deploy:sepolia": "make deployTestnet NETWORK=eth",
48
- "deploy:arbitrum": "make deployTestnet NETWORK=arb",
49
- "wizard": "tsx scripts/evvm-init.ts",
50
- "wizard:deploy": "tsx scripts/evvm-init.ts --deploy"
44
+ "evvm": "bun run cli/index.ts",
45
+ "buildCli": "bun build cli/index.ts --compile --outfile evvm",
46
+ "build-all": "bun run build-linux && bun run build-windows && bun run build-macos",
47
+ "build-linux": "bun build cli/index.ts --compile --outfile .executables/evvm-linux-x64 && bun build cli/index.ts --compile --outfile .executables/evvm-linux-arm64 && bun build cli/index.ts --compile --outfile .executables/evvm-linux-x64-musl && bun build cli/index.ts --compile --outfile .executables/evvm-linux-arm64-musl",
48
+ "build-windows": "bun build cli/index.ts --compile --outfile .executables/evvm-windows-x64.exe",
49
+ "build-macos": "bun build cli/index.ts --compile --outfile .executables/evvm-darwin-x64 && bun build cli/index.ts --compile --outfile .executables/evvm-darwin-arm64"
51
50
  },
52
51
  "peerDependencies": {
53
52
  "@openzeppelin/contracts": "^5.0.0"
@@ -58,13 +57,12 @@
58
57
  "dotenv": "^16.4.5",
59
58
  "execa": "^8.0.1",
60
59
  "prompts": "^2.4.2",
61
- "viem": "^2.39.0"
60
+ "viem": "^2.43.3"
62
61
  },
63
62
  "devDependencies": {
64
63
  "@types/node": "^20.11.0",
65
64
  "@types/prompts": "^2.4.9",
66
65
  "forge-std": "^1.0.0",
67
- "tsx": "^4.7.0",
68
66
  "typescript": "^5.3.0"
69
67
  }
70
68
  }
@@ -1,49 +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 {IEvvm} from "@evvm/testnet-contracts/interfaces/IEvvm.sol";
7
-
8
- abstract contract MakeServicePaymentOnEvvm {
9
- IEvvm public evvm;
10
-
11
- constructor(address evvmAddress) {
12
- evvm = IEvvm(evvmAddress);
13
- }
14
-
15
- function makePay(
16
- address from,
17
- address token,
18
- uint256 amount,
19
- uint256 priorityFee,
20
- uint256 nonce,
21
- bool priorityFlag,
22
- bytes memory signature
23
- ) internal virtual {
24
- evvm.pay(
25
- from,
26
- address(this),
27
- "",
28
- token,
29
- amount,
30
- priorityFee,
31
- nonce,
32
- priorityFlag,
33
- address(this),
34
- signature
35
- );
36
- }
37
-
38
- function makeCaPay(
39
- address to,
40
- address token,
41
- uint256 amount
42
- ) internal virtual {
43
- evvm.caPay(to, token, amount);
44
- }
45
-
46
- function _changeEvvmAddress(address newEvvmAddress) internal {
47
- evvm = IEvvm(newEvvmAddress);
48
- }
49
- }