Skip to content

Commit

Permalink
Merge branch 'execution-layer' of https://github.com/skalenetwork/ima…
Browse files Browse the repository at this point in the history
…-interfaces into feature/add-receiver-field-for-chain-to-chain-transfers
  • Loading branch information
yavrsky committed Dec 16, 2024
2 parents 29453cb + 6370654 commit 9e2b0f1
Show file tree
Hide file tree
Showing 39 changed files with 264 additions and 95 deletions.
4 changes: 3 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "solhint:all",
"rules": {
"compiler-version": ["error","^0.6.10"],
"foundry-test-functions": "off",

"compiler-version": ["error","^0.8.8"],
"state-visibility": "error",
"no-empty-blocks": "error",
"check-send-result": "error",
Expand Down
42 changes: 42 additions & 0 deletions contracts/DomainTypes.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: AGPL-3.0-only

/**
* DomainTypes.sol - SKALE Interchain Messaging Agent
* Copyright (C) 2024-Present SKALE Labs
* @author Dmytro Stebaiev
*
* SKALE IMA is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SKALE IMA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/
pragma solidity >=0.8.19 <0.9.0;


type SchainHash is bytes32;

using {
_schainHashEquals as ==,
_schainHashNotEquals as !=
} for SchainHash global;

// Operators are used by the library users
// slither-disable-start dead-code

function _schainHashEquals(SchainHash left, SchainHash right) pure returns (bool result) {
return SchainHash.unwrap(left) == SchainHash.unwrap(right);
}

function _schainHashNotEquals(SchainHash left, SchainHash right) pure returns (bool result) {
return SchainHash.unwrap(left) != SchainHash.unwrap(right);
}

// slither-disable-end dead-code
6 changes: 3 additions & 3 deletions contracts/IGasReimbursable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "./IMessageReceiver.sol";

Check warning on line 24 in contracts/IGasReimbursable.sol

View workflow job for this annotation

GitHub Actions / test

global import of path ./IMessageReceiver.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)

Check warning on line 24 in contracts/IGasReimbursable.sol

View workflow job for this annotation

GitHub Actions / test

global import of path ./IMessageReceiver.sol is not allowed. Specify names to import individually or bind all exports of the module into a name (import "path" as Name)


interface IGasReimbursable is IMessageReceiver {
function gasPayer(

Check warning on line 28 in contracts/IGasReimbursable.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0

Check warning on line 28 in contracts/IGasReimbursable.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0
bytes32 schainHash,
SchainHash schainHash,
address sender,
bytes calldata data
)
external
returns (address);
}
}
6 changes: 4 additions & 2 deletions contracts/IMessageListener.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import {SchainHash} from "./DomainTypes.sol";


interface IMessageListener {
Expand Down Expand Up @@ -52,7 +54,7 @@ interface IMessageListener {
) external;

function postOutgoingMessage(
bytes32 targetChainHash,
SchainHash targetChainHash,
address targetContract,
bytes memory data
) external;
Expand Down
10 changes: 5 additions & 5 deletions contracts/IMessageProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import { IMessageListener } from "./IMessageListener.sol";
import { IMessageListener, SchainHash } from "./IMessageListener.sol";


interface IMessageProxy is IMessageListener {
Expand All @@ -34,12 +34,12 @@ interface IMessageProxy is IMessageListener {
function removeExtraContract(string memory schainName, address extraContract) external;
function setVersion(string calldata newVersion) external;
function isContractRegistered(

Check warning on line 36 in contracts/IMessageProxy.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0

Check warning on line 36 in contracts/IMessageProxy.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0
bytes32 schainHash,
SchainHash schainHash,
address contractAddress
) external view returns (bool);
function getContractRegisteredLength(bytes32 schainHash) external view returns (uint256);
function getContractRegisteredLength(SchainHash schainHash) external view returns (uint256);

Check warning on line 40 in contracts/IMessageProxy.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0

Check warning on line 40 in contracts/IMessageProxy.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0
function getContractRegisteredRange(

Check warning on line 41 in contracts/IMessageProxy.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0

Check warning on line 41 in contracts/IMessageProxy.sol

View workflow job for this annotation

GitHub Actions / test

GC: Named return value is missing - Index 0
bytes32 schainHash,
SchainHash schainHash,
uint256 from,
uint256 to
)
Expand Down
8 changes: 5 additions & 3 deletions contracts/IMessageReceiver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import {SchainHash} from "./DomainTypes.sol";


interface IMessageReceiver {
function postMessage(
bytes32 schainHash,
SchainHash schainHash,
address sender,
bytes calldata data
)
external;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;


interface IERC721ReferenceMintAndMetadataMainnet {
function setSenderContractOnSchain(address newSenderContractOnSchain) external;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;


interface IERC721ReferenceMintAndMetadataSchain {
Expand All @@ -32,4 +32,4 @@ interface IERC721ReferenceMintAndMetadataSchain {
external
pure
returns (bytes memory data);
}
}
4 changes: 2 additions & 2 deletions contracts/mainnet/DepositBoxes/IDepositBoxERC1155.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "../IDepositBox.sol";

Expand Down Expand Up @@ -64,4 +64,4 @@ interface IDepositBoxERC1155 is IDepositBox {
external
view
returns (address[] memory);
}
}
14 changes: 7 additions & 7 deletions contracts/mainnet/DepositBoxes/IDepositBoxERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "../IDepositBox.sol";

Expand All @@ -45,9 +45,9 @@ interface IDepositBoxERC20 is IDepositBox {
function stopTrustingReceiver(string calldata schainName, address receiver) external;
function trustReceiver(string calldata schainName, address receiver) external;
function validateTransfer(uint transferId) external;
function isReceiverTrusted(bytes32 schainHash, address receiver) external view returns (bool);
function getArbitrageDuration(bytes32 schainHash) external view returns (uint256);
function getBigTransferThreshold(bytes32 schainHash, address token) external view returns (uint256);
function isReceiverTrusted(SchainHash schainHash, address receiver) external view returns (bool);
function getArbitrageDuration(SchainHash schainHash) external view returns (uint256);
function getBigTransferThreshold(SchainHash schainHash, address token) external view returns (uint256);
function getDelayedAmount(address receiver, address token) external view returns (uint256 value);
function getNextUnlockTimestamp(address receiver, address token) external view returns (uint256 unlockTimestamp);
function getSchainToERC20(string calldata schainName, address erc20OnMainnet) external view returns (bool);
Expand All @@ -60,7 +60,7 @@ interface IDepositBoxERC20 is IDepositBox {
external
view
returns (address[] memory);
function getTimeDelay(bytes32 schainHash) external view returns (uint256);
function getTimeDelay(SchainHash schainHash) external view returns (uint256);
function getTrustedReceiver(string calldata schainName, uint256 index) external view returns (address);
function getTrustedReceiversAmount(bytes32 schainHash) external view returns (uint256);
}
function getTrustedReceiversAmount(SchainHash schainHash) external view returns (uint256);
}
4 changes: 2 additions & 2 deletions contracts/mainnet/DepositBoxes/IDepositBoxERC721.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "../IDepositBox.sol";

Expand All @@ -44,4 +44,4 @@ interface IDepositBoxERC721 is IDepositBox {
external
view
returns (address[] memory);
}
}
4 changes: 2 additions & 2 deletions contracts/mainnet/DepositBoxes/IDepositBoxEth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "../IDepositBox.sol";

Expand All @@ -32,4 +32,4 @@ interface IDepositBoxEth is IDepositBox {
function getFunds(string calldata schainName, address payable receiver, uint amount) external;
function enableActiveEthTransfers(string calldata schainName) external;
function disableActiveEthTransfers(string calldata schainName) external;
}
}
27 changes: 16 additions & 11 deletions contracts/mainnet/ICommunityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "@skalenetwork/skale-manager-interfaces/IContractManager.sol";

Expand All @@ -35,17 +35,22 @@ interface ICommunityPool is ITwin {
ILinker linker,
IMessageProxyForMainnet messageProxyValue
) external;
function refundGasByUser(bytes32 schainHash, address payable node, address user, uint gas) external returns (uint);
function refundGasByUser(
SchainHash schainHash,
address payable node,
address user,
uint256 gas
) external returns (uint256);
function rechargeUserWallet(string calldata schainName, address user) external payable;
function withdrawFunds(string calldata schainName, uint amount) external;
function setMinTransactionGas(uint newMinTransactionGas) external;
function setMultiplier(uint newMultiplierNumerator, uint newMultiplierDivider) external;
function withdrawFunds(string calldata schainName, uint256 amount) external;
function setMinTransactionGas(uint256 newMinTransactionGas) external;
function setMultiplier(uint256 newMultiplierNumerator, uint256 newMultiplierDivider) external;
function refundGasBySchainWallet(
bytes32 schainHash,
SchainHash schainHash,
address payable node,
uint gas
uint256 gas
) external returns (bool);
function getBalance(address user, string calldata schainName) external view returns (uint);
function checkUserBalance(bytes32 schainHash, address receiver) external view returns (bool);
function getRecommendedRechargeAmount(bytes32 schainHash, address receiver) external view returns (uint256);
}
function getBalance(address user, string calldata schainName) external view returns (uint256);
function checkUserBalance(SchainHash schainHash, address receiver) external view returns (bool);
function getRecommendedRechargeAmount(SchainHash schainHash, address receiver) external view returns (uint256);
}
4 changes: 2 additions & 2 deletions contracts/mainnet/IDepositBox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "@skalenetwork/skale-manager-interfaces/IContractManager.sol";

Expand All @@ -39,4 +39,4 @@ interface IDepositBox is ITwin, IMessageReceiver, IGasReimbursable {
function enableWhitelist(string memory schainName) external;
function disableWhitelist(string memory schainName) external;
function isWhitelisted(string memory schainName) external view returns (bool);
}
}
6 changes: 3 additions & 3 deletions contracts/mainnet/ILinker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "./ITwin.sol";

Expand All @@ -30,7 +30,7 @@ interface ILinker is ITwin {
function connectSchain(string calldata schainName, address[] calldata schainContracts) external;
function kill(string calldata schainName) external;
function disconnectSchain(string calldata schainName) external;
function isNotKilled(bytes32 schainHash) external view returns (bool);
function isNotKilled(SchainHash schainHash) external view returns (bool);
function hasMainnetContract(address mainnetContract) external view returns (bool);
function hasSchain(string calldata schainName) external view returns (bool connected);
}
}
12 changes: 6 additions & 6 deletions contracts/mainnet/IMessageProxyForMainnet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "../IMessageProxy.sol";
import "./ICommunityPool.sol";
Expand All @@ -33,15 +33,15 @@ interface IMessageProxyForMainnet is IMessageProxy {
function addReimbursedContract(string memory schainName, address reimbursedContract) external;
function removeReimbursedContract(string memory schainName, address reimbursedContract) external;
function messageInProgress() external view returns (bool);
function isPaused(bytes32 schainHash) external view returns (bool);
function isReimbursedContract(bytes32 schainHash, address contractAddress) external view returns (bool);
function getReimbursedContractsLength(bytes32 schainHash) external view returns (uint256);
function isPaused(SchainHash schainHash) external view returns (bool);
function isReimbursedContract(SchainHash schainHash, address contractAddress) external view returns (bool);
function getReimbursedContractsLength(SchainHash schainHash) external view returns (uint256);
function getReimbursedContractsRange(
bytes32 schainHash,
SchainHash schainHash,
uint256 from,
uint256 to
)
external
view
returns (address[] memory contractsInRange);
}
}
10 changes: 6 additions & 4 deletions contracts/mainnet/ISkaleManagerClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
* along with SKALE IMA. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;
pragma solidity >=0.8.19 <0.9.0;

import "@skalenetwork/skale-manager-interfaces/IContractManager.sol";

import {SchainHash} from "../DomainTypes.sol";


interface ISkaleManagerClient {
function initialize(IContractManager newContractManagerOfSkaleManager) external;
function isSchainOwner(address sender, bytes32 schainHash) external view returns (bool);
function isAgentAuthorized(bytes32 schainHash, address sender) external view returns (bool);
}
function isSchainOwner(address sender, SchainHash schainHash) external view returns (bool);
function isAgentAuthorized(SchainHash schainHash, address sender) external view returns (bool);
}
Loading

0 comments on commit 9e2b0f1

Please sign in to comment.