From 9ea64b3ca4e790cdb5998e28d159379df4d59c3b Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Fri, 10 Jun 2022 15:32:06 +0100 Subject: [PATCH 01/11] Add agent authorized check --- .../mainnet/MessageProxyForMainnet.sol | 1 + .../contracts/mainnet/SkaleManagerClient.sol | 5 + proxy/contracts/test/TestNodes.sol | 25 ++- proxy/contracts/test/TestSchainsInternal.sol | 31 ++- proxy/gas/calculateGas.ts | 47 ++-- proxy/package.json | 1 + proxy/test/DepositBoxERC1155.ts | 25 ++- proxy/test/DepositBoxERC20.ts | 27 ++- proxy/test/DepositBoxERC721.ts | 29 ++- proxy/test/DepositBoxERC721WithMetadata.ts | 29 ++- proxy/test/DepositBoxEth.ts | 39 +++- proxy/test/MessageProxy.ts | 211 ++++++++++++++++-- .../ERC721MintingFromSchainToMainnet.ts | 25 +-- proxy/test/utils/helper.ts | 11 + .../skale-manager-utils/contractManager.ts | 1 + proxy/test/utils/skale-manager-utils/nodes.ts | 36 +++ .../skale-manager-utils/schainsInternal.ts | 11 + proxy/yarn.lock | 7 + 18 files changed, 463 insertions(+), 98 deletions(-) create mode 100644 proxy/test/utils/skale-manager-utils/nodes.ts diff --git a/proxy/contracts/mainnet/MessageProxyForMainnet.sol b/proxy/contracts/mainnet/MessageProxyForMainnet.sol index e3cf29187..ec5eac130 100644 --- a/proxy/contracts/mainnet/MessageProxyForMainnet.sol +++ b/proxy/contracts/mainnet/MessageProxyForMainnet.sol @@ -218,6 +218,7 @@ contract MessageProxyForMainnet is SkaleManagerClient, MessageProxy, IMessagePro { uint256 gasTotal = gasleft(); bytes32 fromSchainHash = keccak256(abi.encodePacked(fromSchainName)); + require(isAgentAuthorized(fromSchainHash, msg.sender), "Agent is not authorized"); require(_checkSchainBalance(fromSchainHash), "Schain wallet has not enough funds"); require(connectedChains[fromSchainHash].inited, "Chain is not initialized"); require(messages.length <= MESSAGES_LENGTH, "Too many messages"); diff --git a/proxy/contracts/mainnet/SkaleManagerClient.sol b/proxy/contracts/mainnet/SkaleManagerClient.sol index b3dd002f7..facd91a5e 100644 --- a/proxy/contracts/mainnet/SkaleManagerClient.sol +++ b/proxy/contracts/mainnet/SkaleManagerClient.sol @@ -71,4 +71,9 @@ contract SkaleManagerClient is Initializable, AccessControlEnumerableUpgradeable address skaleChainsInternal = contractManagerOfSkaleManager.getContract("SchainsInternal"); return ISchainsInternal(skaleChainsInternal).isOwnerAddress(sender, schainHash); } + + function isAgentAuthorized(bytes32 schainHash, address sender) public view returns (bool) { + address skaleChainsInternal = contractManagerOfSkaleManager.getContract("SchainsInternal"); + return ISchainsInternal(skaleChainsInternal).isNodeAddressesInGroup(schainHash, sender); + } } diff --git a/proxy/contracts/test/TestNodes.sol b/proxy/contracts/test/TestNodes.sol index daeda8f0e..f1e6dc532 100644 --- a/proxy/contracts/test/TestNodes.sol +++ b/proxy/contracts/test/TestNodes.sol @@ -22,10 +22,13 @@ pragma solidity 0.8.6; +import "hardhat/console.sol"; + interface INodesTester { function createNode(address, Nodes.NodeCreationParams calldata params) external; function getNodeAddress(uint nodeIndex) external view returns (address); + function isNodeExist(address from, uint nodeIndex) external view returns (bool); } @@ -56,14 +59,21 @@ contract Nodes is INodesTester { string domainName; } + struct CreatedNodes { + mapping (uint => bool) isNodeExist; + uint numberOfNodes; + } + Node[] public nodes; + mapping (address => CreatedNodes) public nodeIndexes; + modifier checkNodeExists(uint nodeIndex) { _checkNodeIndex(nodeIndex); _; } - function createNode(address, NodeCreationParams calldata params) + function createNode(address from, NodeCreationParams calldata params) external override { nodes.push(Node({ @@ -78,6 +88,8 @@ contract Nodes is INodesTester { status: NodeStatus.Active, validatorId: 1337 })); + nodeIndexes[from].isNodeExist[nodes.length - 1] = true; + nodeIndexes[from].numberOfNodes++; } function getNodeAddress(uint nodeIndex) @@ -90,6 +102,17 @@ contract Nodes is INodesTester { return _publicKeyToAddress(nodes[nodeIndex].publicKey); } + function isNodeExist(address from, uint nodeIndex) + public + view + override + checkNodeExists(nodeIndex) + returns (bool) + { + console.log("Inside", nodeIndex); + return nodeIndexes[from].isNodeExist[nodeIndex]; + } + function _checkNodeIndex(uint nodeIndex) private view { require(nodeIndex < nodes.length, "Node with such index does not exist"); } diff --git a/proxy/contracts/test/TestSchainsInternal.sol b/proxy/contracts/test/TestSchainsInternal.sol index 27b12cd16..efbc9bfcd 100644 --- a/proxy/contracts/test/TestSchainsInternal.sol +++ b/proxy/contracts/test/TestSchainsInternal.sol @@ -39,6 +39,7 @@ interface ISchainsInternalTester { function isSchainExist(bytes32 schainHash) external view returns (bool); function getSchains() external view returns (bytes32[] memory); function getSchainName(bytes32 schainHash) external view returns (string memory); + function getNodesInGroup(bytes32 schainHash) external view returns (uint[] memory); } @@ -66,6 +67,8 @@ contract SchainsInternal is ISchainsInternalTester { bytes32[] public schainsAtSystem; + mapping (bytes32 => mapping (address => bool)) private _nodeAddressInSchain; + function addContractManager(address newContractManager) external override { contractManager = ContractManager(newContractManager); } @@ -89,17 +92,22 @@ contract SchainsInternal is ISchainsInternalTester { } function addNodesToSchainsGroups(bytes32 schainHash, uint[] memory nodes) external override { + Nodes nodesContract = Nodes(contractManager.getContract("Nodes")); schainsGroups[schainHash] = nodes; + for (uint i = 0; i < nodes.length; i++) { + address nodeAddress = nodesContract.getNodeAddress(nodes[i]); + _nodeAddressInSchain[schainHash][nodeAddress] = true; + } } function isNodeAddressesInGroup(bytes32 schainHash, address sender) external view override returns (bool) { - Nodes nodes = Nodes(contractManager.getContract("Nodes")); - for (uint i = 0; i < schainsGroups[schainHash].length; i++) { - if (nodes.getNodeAddress(schainsGroups[schainHash][i]) == sender) { - return true; - } - } - return true; + // Nodes nodes = Nodes(contractManager.getContract("Nodes")); + // for (uint i = 0; i < schainsGroups[schainHash].length; i++) { + // if (!nodes.isNodeExist(sender, schainsGroups[schainHash][i])) { + // return true; + // } + // } + return _nodeAddressInSchain[schainHash][sender]; } function isOwnerAddress(address from, bytes32 schainHash) external view override returns (bool) { @@ -122,4 +130,13 @@ contract SchainsInternal is ISchainsInternalTester { { return schains[schainHash].name; } + + function getNodesInGroup(bytes32 schainHash) + external + view + override + returns (uint[] memory) + { + return schainsGroups[schainHash]; + } } diff --git a/proxy/gas/calculateGas.ts b/proxy/gas/calculateGas.ts index 4a85deba4..b8200c053 100644 --- a/proxy/gas/calculateGas.ts +++ b/proxy/gas/calculateGas.ts @@ -86,11 +86,11 @@ import { deployTokenManagerERC1155 } from "../test/utils/deploy/schain/tokenMana import { deployMessageProxyForSchain } from "../test/utils/deploy/schain/messageProxyForSchain"; import { deployMessages } from "../test/utils/deploy/messages"; -import { randomString, stringValue } from "../test/utils/helper"; +import { randomString, stringValue, getPublicKey } from "../test/utils/helper"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber, BytesLike } from "ethers"; +import { BigNumber, BytesLike, Wallet } from "ethers"; import { assert, expect } from "chai"; import { deployCommunityLocker } from "../test/utils/deploy/schain/communityLocker"; @@ -101,6 +101,7 @@ describe("Gas calculation", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let schainOwner: SignerWithAddress; + let nodeAddress: Wallet; let imaLinker: Linker; let depositBoxEth: DepositBoxEth; @@ -165,10 +166,8 @@ describe("Gas calculation", () => { await schainsInternal.connect(deployer).addContractManager(contractManager.address); await wallets.connect(deployer).addContractManager(contractManager.address); - const nodePublicKey: [BytesLike, BytesLike] = [ - "0x1122334455667788990011223344556677889900112233445566778899001122", - "0x1122334455667788990011223344556677889900112233445566778899001122" - ]; + nodeAddress = Wallet.createRandom().connect(ethers.provider); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); // setup 16 nodes const nodeCreationParams = { @@ -176,26 +175,26 @@ describe("Gas calculation", () => { nonce: 1337, ip: "0x12345678", publicIp: "0x12345678", - publicKey: nodePublicKey, + publicKey: getPublicKey(nodeAddress), name: "GasCalculationNode", domainName: "gascalculationnode.com" }; - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); - await nodes.connect(deployer).createNode(deployer.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); + await nodes.connect(deployer).createNode(nodeAddress.address, nodeCreationParams); // initialize schain and data await schainsInternal.connect(deployer).initializeSchain(schainName, schainOwner.address, 12345678, 12345678); @@ -565,7 +564,7 @@ describe("Gas calculation", () => { }; async function postIncomingMessages(startingCounter: number, arrayOfMessages: any, action: string) { - const res = await (await messageProxyForMainnet.connect(deployer).postIncomingMessages( + const res = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, startingCounter, arrayOfMessages, diff --git a/proxy/package.json b/proxy/package.json index e325c93fc..345b37441 100644 --- a/proxy/package.json +++ b/proxy/package.json @@ -45,6 +45,7 @@ "@types/chai": "^4.2.12", "@types/chai-almost": "^1.0.1", "@types/chai-as-promised": "^7.1.3", + "@types/elliptic": "^6.4.14", "@types/minimist": "^1.2.0", "@types/mocha": "^8.2.2", "@types/sinon-chai": "^3.2.5", diff --git a/proxy/test/DepositBoxERC1155.ts b/proxy/test/DepositBoxERC1155.ts index c69a74d26..412de45f2 100644 --- a/proxy/test/DepositBoxERC1155.ts +++ b/proxy/test/DepositBoxERC1155.ts @@ -34,7 +34,7 @@ import { MessagesTester, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -47,7 +47,7 @@ import { deployDepositBoxERC1155 } from "./utils/deploy/mainnet/depositBoxERC115 import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -56,9 +56,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -75,6 +76,7 @@ describe("DepositBoxERC1155", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC1155: DepositBoxERC1155; let contractManager: ContractManager; @@ -97,6 +99,19 @@ describe("DepositBoxERC1155", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC1155.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -354,7 +369,7 @@ describe("DepositBoxERC1155", () => { // execution // to avoid `Incorrect sender` error const balanceBefore = await getBalance(deployer.address); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -410,7 +425,7 @@ describe("DepositBoxERC1155", () => { // execution // to avoid `Incorrect sender` error const balanceBefore = await getBalance(deployer.address); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); diff --git a/proxy/test/DepositBoxERC20.ts b/proxy/test/DepositBoxERC20.ts index b70a11408..38500cac7 100644 --- a/proxy/test/DepositBoxERC20.ts +++ b/proxy/test/DepositBoxERC20.ts @@ -36,7 +36,7 @@ import { ERC20OnChain, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -49,7 +49,7 @@ import { deployDepositBoxERC20 } from "./utils/deploy/mainnet/depositBoxERC20"; import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -60,9 +60,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -79,6 +80,7 @@ describe("DepositBoxERC20", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC20: DepositBoxERC20; let contractManager: ContractManager; @@ -101,6 +103,19 @@ describe("DepositBoxERC20", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC20.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -298,7 +313,7 @@ describe("DepositBoxERC20", () => { await depositBoxERC20.connect(user).depositERC20(schainName, erc20.address, amount); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress, messageWithNotMintedToken], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress, messageWithNotMintedToken], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Given address is not a contract"); @@ -309,13 +324,13 @@ describe("DepositBoxERC20", () => { } const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 2, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 2, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); await depositBoxERC20.connect(user).depositERC20(schainName, erc20.address, amount); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 3, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 3, [message], sign); expect(BigNumber.from(await depositBoxERC20.transferredAmount(schainHash, erc20.address)).toString()).to.be.equal(BigNumber.from(0).toString()); (await erc20.balanceOf(user.address)).toString().should.be.equal((amount * 2).toString()); diff --git a/proxy/test/DepositBoxERC721.ts b/proxy/test/DepositBoxERC721.ts index d96364d64..c87548911 100644 --- a/proxy/test/DepositBoxERC721.ts +++ b/proxy/test/DepositBoxERC721.ts @@ -34,7 +34,7 @@ import { MessagesTester, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -47,7 +47,7 @@ import { deployDepositBoxERC721 } from "./utils/deploy/mainnet/depositBoxERC721" import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -56,9 +56,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -75,6 +76,7 @@ describe("DepositBoxERC721", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC721: DepositBoxERC721; let contractManager: ContractManager; @@ -97,6 +99,19 @@ describe("DepositBoxERC721", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC721.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -276,7 +291,7 @@ describe("DepositBoxERC721", () => { await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -299,7 +314,7 @@ describe("DepositBoxERC721", () => { await erc721.connect(deployer).mint(deployer.address, tokenId); await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721.address, tokenId); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Given address is not a contract"); @@ -321,7 +336,7 @@ describe("DepositBoxERC721", () => { await erc721.connect(deployer).mint(deployer.address, tokenId); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Incorrect tokenId"); @@ -351,7 +366,7 @@ describe("DepositBoxERC721", () => { .depositERC721(schainName, erc721.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); diff --git a/proxy/test/DepositBoxERC721WithMetadata.ts b/proxy/test/DepositBoxERC721WithMetadata.ts index 3304f30fe..5728a1ddb 100644 --- a/proxy/test/DepositBoxERC721WithMetadata.ts +++ b/proxy/test/DepositBoxERC721WithMetadata.ts @@ -34,7 +34,7 @@ import { MessagesTester, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -47,7 +47,7 @@ import { deployDepositBoxERC721WithMetadata } from "./utils/deploy/mainnet/depos import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -56,9 +56,10 @@ import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber } from "ethers"; +import { BigNumber, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -75,6 +76,7 @@ describe("DepositBoxERC721WithMetadata", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxERC721WithMetadata: DepositBoxERC721WithMetadata; let contractManager: ContractManager; @@ -97,6 +99,19 @@ describe("DepositBoxERC721WithMetadata", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC721WithMetadata.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -282,7 +297,7 @@ describe("DepositBoxERC721WithMetadata", () => { await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721WithMetadata.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -308,7 +323,7 @@ describe("DepositBoxERC721WithMetadata", () => { await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); await erc721.connect(deployer).transferFrom(deployer.address, depositBoxERC721WithMetadata.address, tokenId); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Given address is not a contract"); @@ -332,7 +347,7 @@ describe("DepositBoxERC721WithMetadata", () => { await erc721.connect(deployer).mint(deployer.address, tokenId); await erc721.connect(deployer).setTokenURI(tokenId, tokenURI); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [messageWithWrongTokenAddress], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(stringFromHex(res.events[0].args?.message), "Incorrect tokenId"); @@ -364,7 +379,7 @@ describe("DepositBoxERC721WithMetadata", () => { .depositERC721(schainName, erc721.address, tokenId); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); diff --git a/proxy/test/DepositBoxEth.ts b/proxy/test/DepositBoxEth.ts index 66a5d4ef6..381faadf8 100644 --- a/proxy/test/DepositBoxEth.ts +++ b/proxy/test/DepositBoxEth.ts @@ -37,7 +37,7 @@ import { ERC20OnChain, CommunityPool } from "../typechain"; -import { randomString, stringFromHex, stringValue } from "./utils/helper"; +import { randomString, stringFromHex, stringValue, getPublicKey } from "./utils/helper"; import chai = require("chai"); import chaiAlmost = require("chai-almost"); @@ -53,7 +53,7 @@ import { deployDepositBoxERC1155 } from "./utils/deploy/mainnet/depositBoxERC115 import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessages } from "./utils/deploy/messages"; @@ -63,9 +63,10 @@ import { deployFallbackEthTester } from "./utils/deploy/test/fallbackEthTester"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber, ContractTransaction } from "ethers"; +import { BigNumber, ContractTransaction, Wallet } from "ethers"; import { assert, expect } from "chai"; +import { createNode } from "./utils/skale-manager-utils/nodes"; const BlsSignature: [BigNumber, BigNumber] = [ BigNumber.from("178325537405109593276798394634841698946852714038246117383766698579865918287"), @@ -105,6 +106,7 @@ describe("DepositBoxEth", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let nodeAddress: Wallet; let depositBoxEth: DepositBoxEth; let contractManager: ContractManager; @@ -127,6 +129,19 @@ describe("DepositBoxEth", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxEth.address); await messageProxy.registerExtraContract(schainName, communityPool.address); @@ -261,7 +276,7 @@ describe("DepositBoxEth", () => { .rechargeUserWallet(schainName, user.address, { value: wei }); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); // console.log(res.logs); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -306,7 +321,7 @@ describe("DepositBoxEth", () => { .connect(user) .rechargeUserWallet(schainName, user.address, { value: wei }); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -351,7 +366,7 @@ describe("DepositBoxEth", () => { // to avoid `Incorrect sender` error // await lockAndDataForMainnet.setContract("MessageProxy", deployer); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -400,7 +415,7 @@ describe("DepositBoxEth", () => { .connect(deployer) .deposit(schainName, { value: wei }); // execution - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); @@ -451,7 +466,7 @@ describe("DepositBoxEth", () => { expect(BigNumber.from(await depositBoxEth.transferredAmount(schainHash)).toString()).to.be.equal(BigNumber.from(wei).toString()); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -504,7 +519,7 @@ describe("DepositBoxEth", () => { expect(BigNumber.from(await depositBoxEth.transferredAmount(schainHash)).toString()).to.be.equal(BigNumber.from(wei).mul(2).toString()); const balanceBefore = await getBalance(deployer.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign); const balance = await getBalance(deployer.address); balance.should.not.be.lessThan(balanceBefore); balance.should.be.almost(balanceBefore); @@ -526,7 +541,7 @@ describe("DepositBoxEth", () => { const userBalanceBefore = await web3.eth.getBalance(user.address); - await messageProxy.connect(deployer).postIncomingMessages(schainName, 1, [message], sign); + await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 1, [message], sign); expect(BigNumber.from(await web3.eth.getBalance(user.address)).toString()).to.equal(BigNumber.from(userBalanceBefore).add(BigNumber.from(wei)).toString()); expect(BigNumber.from(await depositBoxEth.approveTransfers(user.address)).toString()).to.equal(BigNumber.from(wei).toString()); @@ -580,7 +595,7 @@ describe("DepositBoxEth", () => { expect(BigNumber.from(await depositBoxEth.transferredAmount(schainHash)).toString()).to.be.equal(BigNumber.from(wei).mul(2).toString()); - await reimbursed(await messageProxy.connect(deployer).postIncomingMessages(schainName, 0, [message], sign)); + await reimbursed(await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)); expect(BigNumber.from(await depositBoxEth.approveTransfers(fallbackEthTester.address)).toString()).to.equal(BigNumber.from(wei).toString()); @@ -599,7 +614,7 @@ describe("DepositBoxEth", () => { const userBalanceBefore = await web3.eth.getBalance(fallbackEthTester.address); - const res = await (await messageProxy.connect(deployer).postIncomingMessages(schainName, 1, [message], sign)).wait(); + const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 1, [message], sign)).wait(); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); diff --git a/proxy/test/MessageProxy.ts b/proxy/test/MessageProxy.ts index 77ce09758..9b6d9ce64 100644 --- a/proxy/test/MessageProxy.ts +++ b/proxy/test/MessageProxy.ts @@ -40,13 +40,13 @@ import { EtherbaseMock, SchainsInternal } from "../typechain/"; -import { randomString, stringToHex } from "./utils/helper"; +import { randomString, stringToHex, getPublicKey } from "./utils/helper"; import ABIReceiverMock = require("../artifacts/contracts/test/ReceiverMock.sol/ReceiverMock.json"); import { deployLinker } from "./utils/deploy/mainnet/linker"; import { deployMessageProxyForMainnet } from "./utils/deploy/mainnet/messageProxyForMainnet"; import { deployDepositBoxEth } from "./utils/deploy/mainnet/depositBoxEth"; import { deployContractManager } from "./utils/skale-manager-utils/contractManager"; -import { initializeSchain } from "./utils/skale-manager-utils/schainsInternal"; +import { initializeSchain, addNodesToSchain } from "./utils/skale-manager-utils/schainsInternal"; import { rechargeSchainWallet } from "./utils/skale-manager-utils/wallets"; import { setCommonPublicKey } from "./utils/skale-manager-utils/keyStorage"; import { deployMessageProxyCaller } from "./utils/deploy/test/messageProxyCaller"; @@ -59,6 +59,7 @@ import { assert, expect } from "chai"; import { MessageProxyForSchainTester } from "../typechain/MessageProxyForSchainTester"; import { deployMessageProxyForSchainTester } from "./utils/deploy/test/messageProxyForSchainTester"; import { deployCommunityPool } from "./utils/deploy/mainnet/communityPool"; +import { createNode } from "./utils/skale-manager-utils/nodes"; chai.should(); chai.use((chaiAsPromised)); @@ -69,6 +70,7 @@ describe("MessageProxy", () => { let client: SignerWithAddress; let customer: SignerWithAddress; let agent: SignerWithAddress; + let nodeAddress: Wallet; let keyStorage: KeyStorageMock; let messageProxyForSchain: MessageProxyForSchainTester; @@ -247,6 +249,19 @@ describe("MessageProxy", () => { it("should post incoming messages", async () => { const startingCounter = 0; await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.registerExtraContract(schainName, communityPool.address); @@ -276,7 +291,7 @@ describe("MessageProxy", () => { // chain should be inited: await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -287,7 +302,7 @@ describe("MessageProxy", () => { await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -298,7 +313,7 @@ describe("MessageProxy", () => { await communityPool.connect(client).rechargeUserWallet(schainName, client.address, {value: amountWei.toString()}); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -309,7 +324,106 @@ describe("MessageProxy", () => { await communityPool.connect(client).rechargeUserWallet(schainName, user.address, {value: amountWei.toString()}); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter + 2, + outgoingMessages, + sign + ); + const incomingMessagesCounter = BigNumber.from( + await messageProxyForMainnet.getIncomingMessagesCounter(schainName)); + incomingMessagesCounter.should.be.deep.equal(BigNumber.from(4)); + }); + + it("should not post incoming messages with incorrect address", async () => { + const startingCounter = 0; + await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); + await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); + await setCommonPublicKey(contractManager, schainName); + await messageProxyForMainnet.registerExtraContract(schainName, communityPool.address); + await depositBox.addSchainContract(schainName, deployer.address); + const minTransactionGas = await communityPool.minTransactionGas(); + const amountWei = minTransactionGas.mul(gasPrice); + + const message1 = { + destinationContract: depositBox.address, + sender: deployer.address, + data: await messages.encodeTransferEthMessage(client.address, 0), + }; + + const message2 = { + destinationContract: depositBox.address, + sender: deployer.address, + data: await messages.encodeTransferEthMessage(customer.address, 7), + }; + + const outgoingMessages = [message1, message2]; + const sign = { + blsSignature: BlsSignature, + counter: Counter, + hashA: HashA, + hashB: HashB, + }; + + // chain should be inited: + await messageProxyForMainnet + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter, + outgoingMessages, + sign + ).should.be.eventually.rejectedWith("Chain is not initialized"); + + await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); + + await messageProxyForMainnet + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter, + Array(11).fill(message1), + sign + ).should.be.eventually.rejectedWith("Too many messages"); + + await communityPool.connect(client).rechargeUserWallet(schainName, client.address, {value: amountWei.toString()}); + + await messageProxyForMainnet + .connect(user) + .postIncomingMessages( + schainName, + startingCounter, + outgoingMessages, + sign + ).should.be.eventually.rejectedWith("Agent is not authorized"); + + await messageProxyForMainnet + .connect(nodeAddress) + .postIncomingMessages( + schainName, + startingCounter, + outgoingMessages, + sign + ); + + await communityPool.connect(client).rechargeUserWallet(schainName, user.address, {value: amountWei.toString()}); + + await messageProxyForMainnet + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter + 2, @@ -346,6 +460,19 @@ describe("MessageProxy", () => { it("should get incoming messages counter", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); const startingCounter = 0; @@ -381,7 +508,7 @@ describe("MessageProxy", () => { incomingMessagesCounter0.should.be.deep.equal(BigNumber.from(0)); await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -395,6 +522,19 @@ describe("MessageProxy", () => { it("should get outgoing messages counter", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); @@ -430,7 +570,7 @@ describe("MessageProxy", () => { }; await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -460,6 +600,19 @@ describe("MessageProxy", () => { it("should check gas limit issue", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -490,7 +643,7 @@ describe("MessageProxy", () => { expect(a.toNumber()).be.equal(0); const res = await (await messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -506,6 +659,19 @@ describe("MessageProxy", () => { it("should slice revert message", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -537,7 +703,7 @@ describe("MessageProxy", () => { } await expect( messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -551,6 +717,19 @@ describe("MessageProxy", () => { it("should return panic error message", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const nodeCreationParams = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress), + name: "GasCalculationNode", + domainName: "gascalculationnode.com" + }; + await createNode(contractManager, nodeAddress.address, nodeCreationParams); + await addNodesToSchain(contractManager, schainName, [0]); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -583,7 +762,7 @@ describe("MessageProxy", () => { } await expect( messageProxyForMainnet - .connect(deployer) + .connect(nodeAddress) .postIncomingMessages( schainName, startingCounter, @@ -866,7 +1045,7 @@ describe("MessageProxy", () => { // } // // chain should be inited: - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // outgoingMessages, @@ -877,14 +1056,14 @@ describe("MessageProxy", () => { // (await messageProxyForSchain.getIncomingMessagesCounter(schainName)).toNumber().should.be.equal(0); - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // outgoingMessages, // fakeSign // ).should.be.eventually.rejectedWith("Signature is not verified"); - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter + 1, // outgoingMessages, @@ -894,7 +1073,7 @@ describe("MessageProxy", () => { // (await messageProxyForSchain.getIncomingMessagesCounter(schainName)).toNumber().should.be.equal(0); - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // [message1, message1, message1, message1, message1, message1, message1, message1, message1, message1, message1], @@ -911,7 +1090,7 @@ describe("MessageProxy", () => { // hashB: "0x2fa5d1482af89ecda5b40d8b7ffbbebf066bc0f9e78f61e7122d5fd952d58dd6" // }; - // await messageProxyForSchain.connect(deployer).postIncomingMessages( + // await messageProxyForSchain.connect(nodeAddress).postIncomingMessages( // schainName, // startingCounter, // outgoingMessages, diff --git a/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts b/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts index ec57298d6..d9b8fd3ba 100644 --- a/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts +++ b/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts @@ -84,11 +84,11 @@ import { deployTokenManagerERC721 } from "../utils/deploy/schain/tokenManagerERC import { deployMessageProxyForSchain } from "../utils/deploy/schain/messageProxyForSchain"; import { deployMessages } from "../utils/deploy/messages"; -import { randomString, stringValue } from "../utils/helper"; +import { randomString, stringValue, getPublicKey } from "../utils/helper"; import { ethers, web3 } from "hardhat"; import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; -import { BigNumber, BytesLike } from "ethers"; +import { BigNumber, BytesLike, Wallet } from "ethers"; import { assert, expect } from "chai"; import { deployCommunityLocker } from "../utils/deploy/schain/communityLocker"; @@ -99,6 +99,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let schainOwner: SignerWithAddress; + let nodeAddress: Wallet; let imaLinker: Linker; let communityPool: CommunityPool; @@ -149,10 +150,8 @@ describe("ERC721MintingFromSchainToMainnet", () => { await schainsInternal.connect(deployer).addContractManager(contractManager.address); await wallets.connect(deployer).addContractManager(contractManager.address); - const nodePublicKey: [BytesLike, BytesLike] = [ - "0x1122334455667788990011223344556677889900112233445566778899001122", - "0x1122334455667788990011223344556677889900112233445566778899001122" - ]; + nodeAddress = Wallet.createRandom().connect(ethers.provider); + await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); // setup 16 nodes const nodeCreationParams = { @@ -160,7 +159,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { nonce: 1337, ip: "0x12345678", publicIp: "0x12345678", - publicKey: nodePublicKey, + publicKey: getPublicKey(nodeAddress), name: "ExtensionChainNode", domainName: "gascalculationnode.com" }; @@ -352,7 +351,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { hashB: HashB, }; - await messageProxyForMainnet.connect(deployer).postIncomingMessages( + await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -361,7 +360,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"}); - const resPost = await (await messageProxyForMainnet.connect(deployer).postIncomingMessages( + const resPost = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -395,7 +394,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { hashB: HashB, }; - await messageProxyForMainnet.connect(deployer).postIncomingMessages( + await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -404,7 +403,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"}); - await expect(messageProxyForMainnet.connect(deployer).postIncomingMessages( + await expect(messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -436,7 +435,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { hashB: HashB, }; - await messageProxyForMainnet.connect(deployer).postIncomingMessages( + await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], @@ -445,7 +444,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { await wallets.connect(deployer).rechargeSchainWallet(stringValue(schainNameHash), {value: "1000000000000000000"}); - const resPost = await (await messageProxyForMainnet.connect(deployer).postIncomingMessages( + const resPost = await (await messageProxyForMainnet.connect(nodeAddress).postIncomingMessages( schainName, 0, [message], diff --git a/proxy/test/utils/helper.ts b/proxy/test/utils/helper.ts index 9ba199f6a..813dc856c 100644 --- a/proxy/test/utils/helper.ts +++ b/proxy/test/utils/helper.ts @@ -1,3 +1,9 @@ +import { Wallet, BytesLike, ethers } from "ethers"; + +import { ec } from "elliptic"; + +const secp256k1EC = new ec("secp256k1"); + // SPDX-License-Identifier: AGPL-3.0-only /** @@ -69,3 +75,8 @@ export function stringValue(value: string | null | undefined) { return ""; } } + +export function getPublicKey(wallet: Wallet): [BytesLike, BytesLike] { + const publicKey = secp256k1EC.keyFromPrivate(wallet.privateKey.slice(2)).getPublic(); + return [ethers.utils.hexlify(publicKey.getX().toBuffer()), ethers.utils.hexlify(publicKey.getY().toBuffer())] +} \ No newline at end of file diff --git a/proxy/test/utils/skale-manager-utils/contractManager.ts b/proxy/test/utils/skale-manager-utils/contractManager.ts index 0dc5a8ab9..8c142e87f 100644 --- a/proxy/test/utils/skale-manager-utils/contractManager.ts +++ b/proxy/test/utils/skale-manager-utils/contractManager.ts @@ -38,6 +38,7 @@ export async function deployContractManager(contractManagerAddress: string) { } if (await instance.getContract(nameSchainsInternal) === "0x0000000000000000000000000000000000000000") { const schainsInternalInstance = await (await ethers.getContractFactory(nameSchainsInternal)).deploy() as SchainsInternal; + await schainsInternalInstance.addContractManager(instance.address); await instance.setContractsAddress(nameSchainsInternal, schainsInternalInstance.address); } if (await instance.getContract(nameSkaleVerifier) === "0x0000000000000000000000000000000000000000") { diff --git a/proxy/test/utils/skale-manager-utils/nodes.ts b/proxy/test/utils/skale-manager-utils/nodes.ts new file mode 100644 index 000000000..fd2c7cfe3 --- /dev/null +++ b/proxy/test/utils/skale-manager-utils/nodes.ts @@ -0,0 +1,36 @@ +import { ethers } from "hardhat"; +import { ContractManager, Nodes } from "../../../typechain"; +import { BytesLike } from "ethers"; + +const nameNodes = "Nodes"; + +// const nodeCreationParams = { +// port: 1337, +// nonce: 1337, +// ip: "0x12345678", +// publicIp: "0x12345678", +// publicKey: getPublicKey(nodeAddress), +// name: "GasCalculationNode", +// domainName: "gascalculationnode.com" +// }; + +type NodeCreationParams = { + port: number; + nonce: number; + ip: string; + publicIp: string; + publicKey: [BytesLike, BytesLike]; + name: string; + domainName: string; +} + +export async function createNode( + contractManager: ContractManager, + from: string, + nodeCreationParams: NodeCreationParams +) { + const nodesFactory = await ethers.getContractFactory("Nodes"); + const nodesAddres = await contractManager.getContract("Nodes"); + const nodes = nodesFactory.attach(nodesAddres) as Nodes; + await nodes.createNode(from, nodeCreationParams); +} diff --git a/proxy/test/utils/skale-manager-utils/schainsInternal.ts b/proxy/test/utils/skale-manager-utils/schainsInternal.ts index e744926e2..d40fc927d 100644 --- a/proxy/test/utils/skale-manager-utils/schainsInternal.ts +++ b/proxy/test/utils/skale-manager-utils/schainsInternal.ts @@ -16,6 +16,17 @@ export async function initializeSchain( await schainsInternal.initializeSchain(schainName, owner, lifetime, deposit); } +export async function addNodesToSchain( + contractManager: ContractManager, + schainName: string, + nodes: number[] +) { + const schainsInternalFactory = await ethers.getContractFactory("SchainsInternal"); + const schainsInternalAddres = await contractManager.getContract("SchainsInternal"); + const schainsInternal = schainsInternalFactory.attach(schainsInternalAddres) as SchainsInternal; + await schainsInternal.addNodesToSchainsGroups(ethers.utils.id(schainName), nodes); +} + export async function isSchainActive( contractManager: ContractManager, schainName: string diff --git a/proxy/yarn.lock b/proxy/yarn.lock index 948d77ce8..f73e6a494 100644 --- a/proxy/yarn.lock +++ b/proxy/yarn.lock @@ -888,6 +888,13 @@ resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.22.tgz#47020d7e4cf19194d43b5202f35f75bd2ad35ce7" integrity sha512-tFfcE+DSTzWAgifkjik9AySNqIyNoYwmR+uecPwwD/XRNfvOjmC/FjCxpiUGDkDVDphPfCUecSQVFw+lN3M3kQ== +"@types/elliptic@^6.4.14": + version "6.4.14" + resolved "https://registry.yarnpkg.com/@types/elliptic/-/elliptic-6.4.14.tgz#7bbaad60567a588c1f08b10893453e6b9b4de48e" + integrity sha512-z4OBcDAU0GVwDTuwJzQCiL6188QvZMkvoERgcVjq0/mPM8jCfdwZ3x5zQEVoL9WCAru3aG5wl3Z5Ww5wBWn7ZQ== + dependencies: + "@types/bn.js" "*" + "@types/glob@^7.1.1": version "7.1.4" resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.4.tgz#ea59e21d2ee5c517914cb4bc8e4153b99e566672" From d1794c9ca6885533fda21d8730f996ef76342bc7 Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Sat, 11 Jun 2022 10:16:52 +0100 Subject: [PATCH 02/11] Add nodes init in test skale manager deploy --- .../deploySkaleManagerComponents.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/proxy/migrations/deploySkaleManagerComponents.ts b/proxy/migrations/deploySkaleManagerComponents.ts index e1cad246d..322dc3c9e 100644 --- a/proxy/migrations/deploySkaleManagerComponents.ts +++ b/proxy/migrations/deploySkaleManagerComponents.ts @@ -28,6 +28,8 @@ import { deployLibraries, getLinkedContractFactory } from "./tools/factory"; import { getAbi } from './tools/abi'; import { Manifest, hashBytecode } from "@openzeppelin/upgrades-core"; import { KeyStorageMock } from '../typechain/KeyStorageMock'; +import { Wallet } from 'ethers'; +import { getPublicKey, stringValue } from '../test/utils/helper'; export function getContractKeyInAbiFile(contract: string) { return contract.replace(/([a-z0-9])(?=[A-Z])/g, '$1_').toLowerCase(); @@ -128,8 +130,37 @@ async function main() { console.log("Set KeyStorage", keyStorage.address, "to ContractManager", contractManager.address, "\n"); await contractManager.setContractsAddress( "Nodes", nodes.address ); console.log("Set Nodes", nodes.address, "to ContractManager", contractManager.address, "\n"); + const nodeAddress1 = new Wallet(stringValue(process.env.PRIVATE_KEY_FOR_ETHEREUM)).connect(ethers.provider); + const nodeAddress2 = new Wallet(stringValue(process.env.PRIVATE_KEY_FOR_SCHAIN)).connect(ethers.provider); + await owner.sendTransaction({to: nodeAddress1.address, value: ethers.utils.parseEther("1")}); + await owner.sendTransaction({to: nodeAddress2.address, value: ethers.utils.parseEther("1")}); + + const nodeCreationParams1 = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress1), + name: "TestNode1", + domainName: "testnode1.com" + }; + const nodeCreationParams2 = { + port: 1337, + nonce: 1337, + ip: "0x12345678", + publicIp: "0x12345678", + publicKey: getPublicKey(nodeAddress1), + name: "TestNode2", + domainName: "testnode2.com" + }; + await nodes.connect(owner).createNode(nodeAddress1.address, nodeCreationParams1); + console.log("Create Node 0 with address", nodeAddress1.address, "\n"); + await nodes.connect(owner).createNode(nodeAddress2.address, nodeCreationParams2); + console.log("Create Node 1 with address", nodeAddress2.address, "\n"); await schainsInternal.initializeSchain( schainName, owner.address, 1, 1 ); console.log("Initialize Schain", schainName, "with address", owner.address, "\n"); + await schainsInternal.connect(owner).addNodesToSchainsGroups(stringValue(ethers.utils.id(schainName)), [0, 1]); + console.log("Add Nodes 0 and 1 to schain", schainName, "\n"); const BLSPublicKey = { x: { a: "8276253263131369565695687329790911140957927205765534740198480597854608202714", From 3d7168d61af8cf8410f5c2b9e981cf118553f73a Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Sat, 11 Jun 2022 11:08:46 +0100 Subject: [PATCH 03/11] Fix test deploy --- proxy/migrations/deploySkaleManagerComponents.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proxy/migrations/deploySkaleManagerComponents.ts b/proxy/migrations/deploySkaleManagerComponents.ts index 322dc3c9e..680e49e2f 100644 --- a/proxy/migrations/deploySkaleManagerComponents.ts +++ b/proxy/migrations/deploySkaleManagerComponents.ts @@ -116,6 +116,8 @@ async function main() { await schains.addContractManager( contractManager.address ); console.log("Add ContractManager address", contractManager.address, "as ContractManager to Contract Schains", schains.address, "\n"); + await schainsInternal.addContractManager( contractManager.address ); + console.log("Add ContractManager address", contractManager.address, "as ContractManager to Contract SchainsInternal", schainsInternal.address, "\n"); await wallets.addContractManager( contractManager.address ); console.log("Add ContractManager address", contractManager.address, "as ContractManager to Contract Wallets", wallets.address, "\n"); await contractManager.setContractsAddress( "Schains", schains.address ); From d1550f2ebb739bee32f4e54b867914a4402e702a Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Sun, 12 Jun 2022 22:50:58 +0100 Subject: [PATCH 04/11] Move interfaces to IMA repo --- proxy/.solhint.json | 2 +- proxy/contracts/MessageProxy.sol | 6 +- .../ERC721ReferenceMintAndMetadataMainnet.sol | 8 +- .../ERC721ReferenceMintAndMetadataSchain.sol | 16 +++- .../contracts/interfaces/IGasReimbursable.sol | 35 ++++++++ proxy/contracts/interfaces/IMessageProxy.sol | 83 +++++++++++++++++++ .../contracts/interfaces/IMessageReceiver.sol | 32 +++++++ .../interfaces/MessageProxyClient.sol | 6 +- .../interfaces/MessageReceiver.sol | 2 +- .../interfaces/MessageSender.sol | 0 .../DepositBoxes/IDepositBoxERC1155.sol | 57 +++++++++++++ .../mainnet/DepositBoxes/IDepositBoxERC20.sol | 45 ++++++++++ .../DepositBoxes/IDepositBoxERC721.sol | 45 ++++++++++ .../mainnet/DepositBoxes/IDepositBoxEth.sol | 34 ++++++++ .../interfaces/mainnet/ICommunityPool.sol | 49 +++++++++++ .../interfaces/mainnet/IDepositBox.sol | 42 ++++++++++ .../contracts/interfaces/mainnet/ILinker.sol | 36 ++++++++ .../mainnet/IMessageProxyForMainnet.sol | 32 +++++++ .../mainnet/ISkaleManagerClient.sol | 31 +++++++ proxy/contracts/interfaces/mainnet/ITwin.sol | 30 +++++++ .../interfaces/schain/ICommunityLocker.sol | 40 +++++++++ .../interfaces/schain/IKeyStorage.sol | 30 +++++++ .../schain/IMessageProxyForSchain.sol | 40 +++++++++ .../interfaces/schain/ITokenManager.sol | 32 +++++++ .../interfaces/schain/ITokenManagerLinker.sol | 36 ++++++++ .../TokenManagers/ITokenContractManager.sol | 37 +++++++++ .../TokenManagers/ITokenManagerERC1155.sol | 55 ++++++++++++ .../TokenManagers/ITokenManagerERC20.sol | 41 +++++++++ .../TokenManagers/ITokenManagerERC721.sol | 38 +++++++++ .../schain/TokenManagers/ITokenManagerEth.sol | 42 ++++++++++ .../schain/bls/IFieldOperations.sol | 42 ++++++++++ .../schain/tokens/IERC1155OnChain.sol | 38 +++++++++ .../schain/tokens/IERC20OnChain.sol | 27 ++++++ .../schain/tokens/IERC721OnChain.sol | 28 +++++++ .../interfaces/schain/tokens/IEthErc20.sol | 29 +++++++ proxy/contracts/mainnet/CommunityPool.sol | 2 +- proxy/contracts/mainnet/DepositBox.sol | 2 +- .../DepositBoxes/DepositBoxERC1155.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxERC20.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxERC721.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxEth.sol | 2 +- proxy/contracts/mainnet/Linker.sol | 2 +- .../mainnet/MessageProxyForMainnet.sol | 4 +- .../contracts/mainnet/SkaleManagerClient.sol | 4 +- proxy/contracts/mainnet/Twin.sol | 2 +- proxy/contracts/schain/CommunityLocker.sol | 2 +- proxy/contracts/schain/KeyStorage.sol | 2 +- .../schain/MessageProxyForSchain.sol | 2 +- proxy/contracts/schain/TokenManager.sol | 4 +- proxy/contracts/schain/TokenManagerLinker.sol | 2 +- .../TokenManagers/TokenManagerERC1155.sol | 2 +- .../TokenManagers/TokenManagerERC20.sol | 2 +- .../TokenManagers/TokenManagerERC721.sol | 2 +- .../schain/TokenManagers/TokenManagerEth.sol | 2 +- .../contracts/schain/bls/FieldOperations.sol | 2 +- .../schain/tokens/ERC1155OnChain.sol | 2 +- .../contracts/schain/tokens/ERC20OnChain.sol | 2 +- .../contracts/schain/tokens/ERC721OnChain.sol | 2 +- proxy/contracts/schain/tokens/EthErc20.sol | 2 +- proxy/contracts/test/FallbackEthTester.sol | 4 +- .../test/ReceiverGasLimitMainnetMock.sol | 2 +- .../test/ReceiverGasLimitSchainMock.sol | 2 +- proxy/contracts/test/ReceiverMock.sol | 2 +- .../test/TestCallReceiverContract.sol | 2 +- proxy/contracts/test/TestNodes.sol | 3 - proxy/interfaces/package.json | 11 +++ proxy/interfaces/publish_package.sh | 39 +++++++++ proxy/package.json | 1 - proxy/yarn.lock | 12 --- 69 files changed, 1215 insertions(+), 63 deletions(-) create mode 100644 proxy/contracts/interfaces/IGasReimbursable.sol create mode 100644 proxy/contracts/interfaces/IMessageProxy.sol create mode 100644 proxy/contracts/interfaces/IMessageReceiver.sol rename proxy/contracts/{extensions => }/interfaces/MessageProxyClient.sol (89%) rename proxy/contracts/{extensions => }/interfaces/MessageReceiver.sol (94%) rename proxy/contracts/{extensions => }/interfaces/MessageSender.sol (100%) create mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol create mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol create mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol create mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol create mode 100644 proxy/contracts/interfaces/mainnet/ICommunityPool.sol create mode 100644 proxy/contracts/interfaces/mainnet/IDepositBox.sol create mode 100644 proxy/contracts/interfaces/mainnet/ILinker.sol create mode 100644 proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol create mode 100644 proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol create mode 100644 proxy/contracts/interfaces/mainnet/ITwin.sol create mode 100644 proxy/contracts/interfaces/schain/ICommunityLocker.sol create mode 100644 proxy/contracts/interfaces/schain/IKeyStorage.sol create mode 100644 proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol create mode 100644 proxy/contracts/interfaces/schain/ITokenManager.sol create mode 100644 proxy/contracts/interfaces/schain/ITokenManagerLinker.sol create mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol create mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol create mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol create mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol create mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol create mode 100644 proxy/contracts/interfaces/schain/bls/IFieldOperations.sol create mode 100644 proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol create mode 100644 proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol create mode 100644 proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol create mode 100644 proxy/contracts/interfaces/schain/tokens/IEthErc20.sol create mode 100644 proxy/interfaces/package.json create mode 100755 proxy/interfaces/publish_package.sh diff --git a/proxy/.solhint.json b/proxy/.solhint.json index 3ebf80d25..4012a011f 100644 --- a/proxy/.solhint.json +++ b/proxy/.solhint.json @@ -5,7 +5,7 @@ "mark-callable-contracts": "off", "reason-string": "off", - "compiler-version": ["error","0.8.6"], + "compiler-version": ["error",">=0.6.10 <0.9.0"], "state-visibility": "error", "no-empty-blocks": "error", "check-send-result": "error", diff --git a/proxy/contracts/MessageProxy.sol b/proxy/contracts/MessageProxy.sol index 6efde8494..e81b50bf0 100644 --- a/proxy/contracts/MessageProxy.sol +++ b/proxy/contracts/MessageProxy.sol @@ -24,9 +24,9 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/IGasReimbursable.sol"; -import "@skalenetwork/ima-interfaces/IMessageProxy.sol"; -import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; +import "./interfaces/IGasReimbursable.sol"; +import "./interfaces/IMessageProxy.sol"; +import "./interfaces/IMessageReceiver.sol"; /** diff --git a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol index b3d3a25e7..3e620af11 100644 --- a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol +++ b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol @@ -21,10 +21,12 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/extensions/IERC721ReferenceMintAndMetadataMainnet.sol"; - import "../schain/tokens/ERC721OnChain.sol"; -import "./interfaces/MessageReceiver.sol"; +import "../interfaces/MessageReceiver.sol"; + +interface IERC721ReferenceMintAndMetadataMainnet { + function setSenderContractOnSchain(address newSenderContractOnSchain) external; +} // This contract runs on the main net and accepts deposits diff --git a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol index ae1fd91b3..e66860bdb 100644 --- a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol +++ b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol @@ -21,10 +21,20 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/extensions/IERC721ReferenceMintAndMetadataSchain.sol"; - import "../schain/tokens/ERC721OnChain.sol"; -import "./interfaces/MessageSender.sol"; +import "../interfaces/MessageSender.sol"; + +interface IERC721ReferenceMintAndMetadataSchain { + function sendTokenToMainnet(address receiver, uint256 tokenId) external; + function encodeParams( + address receiver, + uint256 tokenId, + string memory tokenURI + ) + external + pure + returns (bytes memory data); +} /** diff --git a/proxy/contracts/interfaces/IGasReimbursable.sol b/proxy/contracts/interfaces/IGasReimbursable.sol new file mode 100644 index 000000000..e6c8f197e --- /dev/null +++ b/proxy/contracts/interfaces/IGasReimbursable.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IGasReimbursable.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-Present SKALE Labs + * @author Artem Payvin + * + * 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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./IMessageReceiver.sol"; + + +interface IGasReimbursable is IMessageReceiver { + function gasPayer( + bytes32 schainHash, + address sender, + bytes calldata data + ) + external + returns (address); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/IMessageProxy.sol b/proxy/contracts/interfaces/IMessageProxy.sol new file mode 100644 index 000000000..83ba0e477 --- /dev/null +++ b/proxy/contracts/interfaces/IMessageProxy.sol @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IMessageProxy.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IMessageProxy { + + /** + * @dev Structure that describes message. Should contain sender of message, + * destination contract on schain that will receiver message, + * data that contains all needed info about token or ETH. + */ + struct Message { + address sender; + address destinationContract; + bytes data; + } + + /** + * @dev Structure that contains fields for bls signature. + */ + struct Signature { + uint256[2] blsSignature; + uint256 hashA; + uint256 hashB; + uint256 counter; + } + + function addConnectedChain(string calldata schainName) external; + function postIncomingMessages( + string calldata fromSchainName, + uint256 startingCounter, + Message[] calldata messages, + Signature calldata sign + ) external; + function setNewGasLimit(uint256 newGasLimit) external; + function registerExtraContractForAll(address extraContract) external; + function removeExtraContractForAll(address extraContract) external; + function removeConnectedChain(string memory schainName) external; + function postOutgoingMessage( + bytes32 targetChainHash, + address targetContract, + bytes memory data + ) external; + function registerExtraContract(string memory chainName, address extraContract) external; + function removeExtraContract(string memory schainName, address extraContract) external; + function setVersion(string calldata newVersion) external; + function isContractRegistered( + bytes32 schainHash, + address contractAddress + ) external view returns (bool); + function getContractRegisteredLength(bytes32 schainHash) external view returns (uint256); + function getContractRegisteredRange( + bytes32 schainHash, + uint256 from, + uint256 to + ) + external + view + returns (address[] memory); + function getOutgoingMessagesCounter(string calldata targetSchainName) external view returns (uint256); + function getIncomingMessagesCounter(string calldata fromSchainName) external view returns (uint256); + function isConnectedChain(string memory schainName) external view returns (bool); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/IMessageReceiver.sol b/proxy/contracts/interfaces/IMessageReceiver.sol new file mode 100644 index 000000000..ee9ed4f06 --- /dev/null +++ b/proxy/contracts/interfaces/IMessageReceiver.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IMessageReceiver.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IMessageReceiver { + function postMessage( + bytes32 schainHash, + address sender, + bytes calldata data + ) + external; +} \ No newline at end of file diff --git a/proxy/contracts/extensions/interfaces/MessageProxyClient.sol b/proxy/contracts/interfaces/MessageProxyClient.sol similarity index 89% rename from proxy/contracts/extensions/interfaces/MessageProxyClient.sol rename to proxy/contracts/interfaces/MessageProxyClient.sol index ba8ebd894..d998249f4 100644 --- a/proxy/contracts/extensions/interfaces/MessageProxyClient.sol +++ b/proxy/contracts/interfaces/MessageProxyClient.sol @@ -21,10 +21,10 @@ pragma solidity 0.8.6; -import "../../MessageProxy.sol"; +import "./IMessageProxy.sol"; abstract contract MessageProxyClient { - MessageProxy public messageProxy; + IMessageProxy public messageProxy; modifier onlyMessageProxy() { require(msg.sender == address(messageProxy), "Sender is not a message proxy"); @@ -32,6 +32,6 @@ abstract contract MessageProxyClient { } constructor(address newMessageProxyAddress) { - messageProxy = MessageProxy(newMessageProxyAddress); + messageProxy = IMessageProxy(newMessageProxyAddress); } } \ No newline at end of file diff --git a/proxy/contracts/extensions/interfaces/MessageReceiver.sol b/proxy/contracts/interfaces/MessageReceiver.sol similarity index 94% rename from proxy/contracts/extensions/interfaces/MessageReceiver.sol rename to proxy/contracts/interfaces/MessageReceiver.sol index 86d3dee18..2168b694b 100644 --- a/proxy/contracts/extensions/interfaces/MessageReceiver.sol +++ b/proxy/contracts/interfaces/MessageReceiver.sol @@ -21,7 +21,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; +import "./IMessageReceiver.sol"; import "./MessageProxyClient.sol"; diff --git a/proxy/contracts/extensions/interfaces/MessageSender.sol b/proxy/contracts/interfaces/MessageSender.sol similarity index 100% rename from proxy/contracts/extensions/interfaces/MessageSender.sol rename to proxy/contracts/interfaces/MessageSender.sol diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol new file mode 100644 index 000000000..ac3d0f95a --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IDepositBoxERC1155.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IDepositBox.sol"; + + +interface IDepositBoxERC1155 is IDepositBox { + function initializeAllTokensForSchain( + string calldata schainName, + address[] calldata tokens + ) external; + function depositERC1155(string calldata schainName, address erc1155OnMainnet, uint256 id, uint256 amount) external; + function depositERC1155Batch( + string calldata schainName, + address erc1155OnMainnet, + uint256[] calldata ids, + uint256[] calldata amounts + ) external; + function addERC1155TokenByOwner(string calldata schainName, address erc1155OnMainnet) external; + function getFunds( + string calldata schainName, + address erc1155OnMainnet, + address receiver, + uint256[] memory ids, + uint256[] memory amounts + ) external; + function getSchainToERC1155(string calldata schainName, address erc1155OnMainnet) external view returns (bool); + function getSchainToAllERC1155Length(string calldata schainName) external view returns (uint256); + function getSchainToAllERC1155( + string calldata schainName, + uint256 from, + uint256 to + ) + external + view + returns (address[] memory); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol new file mode 100644 index 000000000..45b3b5be6 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IDepositBoxERC20.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IDepositBox.sol"; + + +interface IDepositBoxERC20 is IDepositBox { + function initializeAllTokensForSchain( + string calldata schainName, + address[] calldata tokens + ) external; + function depositERC20(string calldata schainName, address erc20OnMainnet, uint256 amount) external; + function addERC20TokenByOwner(string calldata schainName, address erc20OnMainnet) external; + function getFunds(string calldata schainName, address erc20OnMainnet, address receiver, uint amount) external; + function getSchainToERC20(string calldata schainName, address erc20OnMainnet) external view returns (bool); + function getSchainToAllERC20Length(string calldata schainName) external view returns (uint256); + function getSchainToAllERC20( + string calldata schainName, + uint256 from, + uint256 to + ) + external + view + returns (address[] memory); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol new file mode 100644 index 000000000..762ed67be --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IDepositBoxERC721.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IDepositBox.sol"; + + +interface IDepositBoxERC721 is IDepositBox { + function initializeAllTokensForSchain( + string calldata schainName, + address[] calldata tokens + ) external; + function depositERC721(string calldata schainName, address erc721OnMainnet, uint256 tokenId) external; + function addERC721TokenByOwner(string calldata schainName, address erc721OnMainnet) external; + function getFunds(string calldata schainName, address erc721OnMainnet, address receiver, uint tokenId) external; + function getSchainToERC721(string calldata schainName, address erc721OnMainnet) external view returns (bool); + function getSchainToAllERC721Length(string calldata schainName) external view returns (uint256); + function getSchainToAllERC721( + string calldata schainName, + uint256 from, + uint256 to + ) + external + view + returns (address[] memory); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol new file mode 100644 index 000000000..866444d68 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IDepositBoxEth.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IDepositBox.sol"; + + +interface IDepositBoxEth is IDepositBox { + receive() external payable; + function deposit(string memory schainName) external payable; + function getMyEth() external; + function getFunds(string calldata schainName, address payable receiver, uint amount) external; + function enableActiveEthTransfers(string calldata schainName) external; + function disableActiveEthTransfers(string calldata schainName) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ICommunityPool.sol b/proxy/contracts/interfaces/mainnet/ICommunityPool.sol new file mode 100644 index 000000000..8ed639663 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/ICommunityPool.sol @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ICommunityPool.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "@skalenetwork/skale-manager-interfaces/IContractManager.sol"; + + +import "./ILinker.sol"; +import "./IMessageProxyForMainnet.sol"; +import "./ITwin.sol"; + + +interface ICommunityPool is ITwin { + function initialize( + IContractManager contractManagerOfSkaleManagerValue, + ILinker linker, + IMessageProxyForMainnet messageProxyValue + ) external; + function refundGasByUser(bytes32 schainHash, address payable node, address user, uint gas) external returns (uint); + function rechargeUserWallet(string calldata schainName, address user) external payable; + function withdrawFunds(string calldata schainName, uint amount) external; + function setMinTransactionGas(uint newMinTransactionGas) external; + function refundGasBySchainWallet( + bytes32 schainHash, + address payable node, + uint 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); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/IDepositBox.sol b/proxy/contracts/interfaces/mainnet/IDepositBox.sol new file mode 100644 index 000000000..dafcbd076 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/IDepositBox.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IDepositBox.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "@skalenetwork/skale-manager-interfaces/IContractManager.sol"; + +import "../IGasReimbursable.sol"; +import "../IMessageReceiver.sol"; +import "./ILinker.sol"; +import "./IMessageProxyForMainnet.sol"; +import "./ITwin.sol"; + + +interface IDepositBox is ITwin, IMessageReceiver, IGasReimbursable { + function initialize( + IContractManager contractManagerOfSkaleManagerValue, + ILinker newLinker, + IMessageProxyForMainnet messageProxyValue + ) external; + function enableWhitelist(string memory schainName) external; + function disableWhitelist(string memory schainName) external; + function isWhitelisted(string memory schainName) external view returns (bool); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ILinker.sol b/proxy/contracts/interfaces/mainnet/ILinker.sol new file mode 100644 index 000000000..8215b7784 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/ILinker.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ILinker.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./ITwin.sol"; + + +interface ILinker is ITwin { + function registerMainnetContract(address newMainnetContract) external; + function removeMainnetContract(address mainnetContract) external; + 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 hasMainnetContract(address mainnetContract) external view returns (bool); + function hasSchain(string calldata schainName) external view returns (bool connected); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol b/proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol new file mode 100644 index 000000000..640ce56c4 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IMessageProxyForMainnet.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IMessageProxy.sol"; +import "./ICommunityPool.sol"; + +interface IMessageProxyForMainnet is IMessageProxy { + function setCommunityPool(ICommunityPool newCommunityPoolAddress) external; + function setNewHeaderMessageGasCost(uint256 newHeaderMessageGasCost) external; + function setNewMessageGasCost(uint256 newMessageGasCost) external; + function messageInProgress() external view returns (bool); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol b/proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol new file mode 100644 index 000000000..fc0d05db2 --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ISkaleManagerClient.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "@skalenetwork/skale-manager-interfaces/IContractManager.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); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ITwin.sol b/proxy/contracts/interfaces/mainnet/ITwin.sol new file mode 100644 index 000000000..93665453d --- /dev/null +++ b/proxy/contracts/interfaces/mainnet/ITwin.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITwin.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./ISkaleManagerClient.sol"; + +interface ITwin is ISkaleManagerClient { + function addSchainContract(string calldata schainName, address contractReceiver) external; + function removeSchainContract(string calldata schainName) external; + function hasSchainContract(string calldata schainName) external view returns (bool); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/ICommunityLocker.sol b/proxy/contracts/interfaces/schain/ICommunityLocker.sol new file mode 100644 index 000000000..0b5089888 --- /dev/null +++ b/proxy/contracts/interfaces/schain/ICommunityLocker.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ICommunityLocker.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IMessageReceiver.sol"; + +import "./IMessageProxyForSchain.sol"; +import "./ITokenManagerLinker.sol"; + + +interface ICommunityLocker is IMessageReceiver { + function initialize( + string memory newSchainName, + IMessageProxyForSchain newMessageProxy, + ITokenManagerLinker newTokenManagerLinker, + address newCommunityPool + ) external; + function checkAllowedToSendMessage(address receiver) external; + function setTimeLimitPerMessage(uint newTimeLimitPerMessage) external; + function setGasPrice(uint gasPrice, uint timestamp, IMessageProxyForSchain.Signature memory signature) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/IKeyStorage.sol b/proxy/contracts/interfaces/schain/IKeyStorage.sol new file mode 100644 index 000000000..ac5d3105b --- /dev/null +++ b/proxy/contracts/interfaces/schain/IKeyStorage.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IKeyStorage.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./bls/IFieldOperations.sol"; + + +interface IKeyStorage { + function initialize() external; + function getBlsCommonPublicKey() external view returns (IFieldOperations.G2Point memory); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol b/proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol new file mode 100644 index 000000000..143b2c22b --- /dev/null +++ b/proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IMessageProxyForSchain.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IMessageProxy.sol"; +import "./IKeyStorage.sol"; + +interface IMessageProxyForSchain is IMessageProxy { + struct OutgoingMessageData { + bytes32 dstChainHash; // destination chain + uint256 msgCounter; // message counter + address srcContract; // origin + address dstContract; // receiver + bytes data; // payload + } + + function initialize(IKeyStorage blsKeyStorage, string memory schainName) external; + function verifyOutgoingMessageData(OutgoingMessageData memory message) external view returns (bool); + function verifySignature(bytes32 hashedMessage, Signature memory signature) external view returns (bool); + function messageInProgress() external view returns (bool); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/ITokenManager.sol b/proxy/contracts/interfaces/schain/ITokenManager.sol new file mode 100644 index 000000000..b0ee59b0b --- /dev/null +++ b/proxy/contracts/interfaces/schain/ITokenManager.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManager - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../IMessageReceiver.sol"; + + +interface ITokenManager is IMessageReceiver { + function enableAutomaticDeploy() external; + function addTokenManager(string calldata schainName, address newTokenManager) external; + function removeTokenManager(string calldata schainName) external; + function hasTokenManager(string calldata schainName) external view returns (bool); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/ITokenManagerLinker.sol b/proxy/contracts/interfaces/schain/ITokenManagerLinker.sol new file mode 100644 index 000000000..040b6751e --- /dev/null +++ b/proxy/contracts/interfaces/schain/ITokenManagerLinker.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManagerLinker - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./IMessageProxyForSchain.sol"; +import "./ITokenManager.sol"; + + +interface ITokenManagerLinker { + function initialize(IMessageProxyForSchain newMessageProxyAddress, address linker) external; + function registerTokenManager(ITokenManager newTokenManager) external; + function removeTokenManager(ITokenManager tokenManagerAddress) external; + function connectSchain(string calldata schainName) external; + function disconnectSchain(string calldata schainName) external; + function hasTokenManager(ITokenManager tokenManager) external view returns (bool); + function hasSchain(string calldata schainName) external view returns (bool connected); +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol new file mode 100644 index 000000000..1b7a15975 --- /dev/null +++ b/proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManagerERC20 - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../ICommunityLocker.sol"; +import "../IMessageProxyForSchain.sol"; +import "../ITokenManager.sol"; +import "../ITokenManagerLinker.sol"; + +interface ITokenContractManager is ITokenManager { + function initialize( + string memory newChainName, + IMessageProxyForSchain newMessageProxy, + ITokenManagerLinker newIMALinker, + ICommunityLocker newCommunityLocker, + address newDepositBox + ) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol new file mode 100644 index 000000000..7fc122660 --- /dev/null +++ b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManagerERC1155 - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./ITokenContractManager.sol"; + + +interface ITokenManagerERC1155 is ITokenContractManager { + function exitToMainERC1155( + address contractOnMainnet, + uint256 id, + uint256 amount + ) external; + function exitToMainERC1155Batch( + address contractOnMainnet, + uint256[] memory ids, + uint256[] memory amounts + ) external; + function transferToSchainERC1155( + string calldata targetSchainName, + address contractOnMainnet, + uint256 id, + uint256 amount + ) external; + function transferToSchainERC1155Batch( + string calldata targetSchainName, + address contractOnMainnet, + uint256[] memory ids, + uint256[] memory amounts + ) external; + function addERC1155TokenByOwner( + string calldata targetChainName, + address erc1155OnMainnet, + address erc1155OnSchain + ) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol new file mode 100644 index 000000000..945e134c6 --- /dev/null +++ b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManagerERC20 - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./ITokenContractManager.sol"; + +interface ITokenManagerERC20 is ITokenContractManager { + function exitToMainERC20( + address contractOnMainnet, + uint256 amount + ) external; + function transferToSchainERC20( + string calldata targetSchainName, + address contractOnMainnet, + uint256 amount + ) external; + function addERC20TokenByOwner( + string calldata targetChainName, + address erc20OnMainnet, + address erc20OnSchain + ) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol new file mode 100644 index 000000000..ba5299664 --- /dev/null +++ b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManagerERC721 - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "./ITokenContractManager.sol"; + +interface ITokenManagerERC721 is ITokenContractManager { + function exitToMainERC721(address contractOnMainnet, uint256 tokenId) external; + function transferToSchainERC721( + string calldata targetSchainName, + address contractOnMainnet, + uint256 tokenId + ) external; + function addERC721TokenByOwner( + string calldata targetChainName, + address erc721OnMainnet, + address erc721OnSchain + ) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol new file mode 100644 index 000000000..dce9c63d5 --- /dev/null +++ b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * ITokenManagerEth - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + +import "../tokens/IEthErc20.sol"; +import "../ICommunityLocker.sol"; +import "../IMessageProxyForSchain.sol"; +import "../ITokenManager.sol"; +import "../ITokenManagerLinker.sol"; + + +interface ITokenManagerEth is ITokenManager { + function initialize( + string memory newChainName, + IMessageProxyForSchain newMessageProxy, + ITokenManagerLinker newIMALinker, + ICommunityLocker newCommunityLocker, + address newDepositBox, + IEthErc20 ethErc20Address + ) external; + function setEthErc20Address(IEthErc20 newEthErc20Address) external; + function exitToMain(uint256 amount) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/bls/IFieldOperations.sol b/proxy/contracts/interfaces/schain/bls/IFieldOperations.sol new file mode 100644 index 000000000..7c1dca326 --- /dev/null +++ b/proxy/contracts/interfaces/schain/bls/IFieldOperations.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IFieldOperations.sol - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IFieldOperations { + + /** + * @dev Structure that represents the field element { a + ib } + */ + struct Fp2Point { + uint a; + uint b; + } + + /** + * @dev Structure that represents an element of G2 + */ + struct G2Point { + Fp2Point x; + Fp2Point y; + } +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol b/proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol new file mode 100644 index 000000000..2927793d4 --- /dev/null +++ b/proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IERC1155OnChain - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IERC1155OnChain { + function mint( + address account, + uint256 id, + uint256 amount, + bytes memory data + ) external; + function mintBatch( + address account, + uint256[] memory ids, + uint256[] memory amounts, + bytes memory data + ) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol b/proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol new file mode 100644 index 000000000..3b7e99108 --- /dev/null +++ b/proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IERC20OnChain - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IERC20OnChain { + function mint(address account, uint256 value) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol b/proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol new file mode 100644 index 000000000..d2a7e5aa9 --- /dev/null +++ b/proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IERC721OnChain - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IERC721OnChain { + function setTokenURI(uint256 tokenId, string calldata tokenUri) external returns (bool); + function mint(address account, uint256 tokenId) external; +} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IEthErc20.sol b/proxy/contracts/interfaces/schain/tokens/IEthErc20.sol new file mode 100644 index 000000000..aeb8236de --- /dev/null +++ b/proxy/contracts/interfaces/schain/tokens/IEthErc20.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: AGPL-3.0-only + +/** + * IEthErc20 - SKALE Interchain Messaging Agent + * Copyright (C) 2021-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 . + */ + +pragma solidity >=0.6.10 <0.9.0; + + +interface IEthErc20 { + function mint(address account, uint256 amount) external; + function forceBurn(address account, uint256 amount) external; + function initialize(address tokenManagerEthAddress) external; +} \ No newline at end of file diff --git a/proxy/contracts/mainnet/CommunityPool.sol b/proxy/contracts/mainnet/CommunityPool.sol index 153337635..6fbb982a9 100644 --- a/proxy/contracts/mainnet/CommunityPool.sol +++ b/proxy/contracts/mainnet/CommunityPool.sol @@ -23,8 +23,8 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; +import "../interfaces/mainnet/ICommunityPool.sol"; import "../Messages.sol"; import "./Twin.sol"; diff --git a/proxy/contracts/mainnet/DepositBox.sol b/proxy/contracts/mainnet/DepositBox.sol index 840d165a4..37d03b4d1 100644 --- a/proxy/contracts/mainnet/DepositBox.sol +++ b/proxy/contracts/mainnet/DepositBox.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/mainnet/IDepositBox.sol"; +import "../interfaces/mainnet/IDepositBox.sol"; import "./Twin.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol index 8de91f055..0ec21de68 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol @@ -25,7 +25,7 @@ import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155ReceiverUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol"; +import "../../interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol index 69a67a6b0..06cc29d3a 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; -import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol"; +import "../../interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol"; import "../../Messages.sol"; import "../DepositBox.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol index 9fea45a1e..3c3b29e13 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol @@ -23,8 +23,8 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; +import "../../interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol index 8968c1933..8af63af34 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; +import "../../interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/Linker.sol b/proxy/contracts/mainnet/Linker.sol index 665d5b1a1..ae763ade0 100644 --- a/proxy/contracts/mainnet/Linker.sol +++ b/proxy/contracts/mainnet/Linker.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/mainnet/ILinker.sol"; +import "../interfaces/mainnet/ILinker.sol"; import "../Messages.sol"; import "./MessageProxyForMainnet.sol"; diff --git a/proxy/contracts/mainnet/MessageProxyForMainnet.sol b/proxy/contracts/mainnet/MessageProxyForMainnet.sol index ec5eac130..011dde96c 100644 --- a/proxy/contracts/mainnet/MessageProxyForMainnet.sol +++ b/proxy/contracts/mainnet/MessageProxyForMainnet.sol @@ -24,9 +24,9 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; import "@skalenetwork/skale-manager-interfaces/ISchains.sol"; -import "@skalenetwork/ima-interfaces/mainnet/IMessageProxyForMainnet.sol"; -import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol"; +import "../interfaces/mainnet/IMessageProxyForMainnet.sol"; +import "../interfaces/mainnet/ICommunityPool.sol"; import "../MessageProxy.sol"; diff --git a/proxy/contracts/mainnet/SkaleManagerClient.sol b/proxy/contracts/mainnet/SkaleManagerClient.sol index facd91a5e..f9165c66a 100644 --- a/proxy/contracts/mainnet/SkaleManagerClient.sol +++ b/proxy/contracts/mainnet/SkaleManagerClient.sol @@ -25,7 +25,7 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@skalenetwork/skale-manager-interfaces/IContractManager.sol"; import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol"; -import "@skalenetwork/ima-interfaces/mainnet/ISkaleManagerClient.sol"; +import "../interfaces/mainnet/ISkaleManagerClient.sol"; /** @@ -72,7 +72,7 @@ contract SkaleManagerClient is Initializable, AccessControlEnumerableUpgradeable return ISchainsInternal(skaleChainsInternal).isOwnerAddress(sender, schainHash); } - function isAgentAuthorized(bytes32 schainHash, address sender) public view returns (bool) { + function isAgentAuthorized(bytes32 schainHash, address sender) public view override returns (bool) { address skaleChainsInternal = contractManagerOfSkaleManager.getContract("SchainsInternal"); return ISchainsInternal(skaleChainsInternal).isNodeAddressesInGroup(schainHash, sender); } diff --git a/proxy/contracts/mainnet/Twin.sol b/proxy/contracts/mainnet/Twin.sol index ba9857fa0..9f9f9a42e 100644 --- a/proxy/contracts/mainnet/Twin.sol +++ b/proxy/contracts/mainnet/Twin.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/mainnet/ITwin.sol"; +import "../interfaces/mainnet/ITwin.sol"; import "./MessageProxyForMainnet.sol"; import "./SkaleManagerClient.sol"; diff --git a/proxy/contracts/schain/CommunityLocker.sol b/proxy/contracts/schain/CommunityLocker.sol index 58ed57644..b7ebdaff8 100644 --- a/proxy/contracts/schain/CommunityLocker.sol +++ b/proxy/contracts/schain/CommunityLocker.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/ICommunityLocker.sol"; +import "../interfaces/schain/ICommunityLocker.sol"; import "../Messages.sol"; diff --git a/proxy/contracts/schain/KeyStorage.sol b/proxy/contracts/schain/KeyStorage.sol index 55277b907..1379850c3 100644 --- a/proxy/contracts/schain/KeyStorage.sol +++ b/proxy/contracts/schain/KeyStorage.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/IKeyStorage.sol"; +import "../interfaces/schain/IKeyStorage.sol"; import "./bls/FieldOperations.sol"; diff --git a/proxy/contracts/schain/MessageProxyForSchain.sol b/proxy/contracts/schain/MessageProxyForSchain.sol index bc34bf823..719644c68 100644 --- a/proxy/contracts/schain/MessageProxyForSchain.sol +++ b/proxy/contracts/schain/MessageProxyForSchain.sol @@ -22,8 +22,8 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/IMessageProxyForSchain.sol"; import "@skalenetwork/etherbase-interfaces/IEtherbaseUpgradeable.sol"; +import "../interfaces/schain/IMessageProxyForSchain.sol"; import "../MessageProxy.sol"; import "./bls/SkaleVerifier.sol"; diff --git a/proxy/contracts/schain/TokenManager.sol b/proxy/contracts/schain/TokenManager.sol index 0a5a76c82..9d92a707c 100644 --- a/proxy/contracts/schain/TokenManager.sol +++ b/proxy/contracts/schain/TokenManager.sol @@ -21,8 +21,8 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/schain/ITokenManager.sol"; -import "@skalenetwork/ima-interfaces/schain/ICommunityLocker.sol"; +import "../interfaces/schain/ITokenManager.sol"; +import "../interfaces/schain/ICommunityLocker.sol"; import "./MessageProxyForSchain.sol"; import "./TokenManagerLinker.sol"; diff --git a/proxy/contracts/schain/TokenManagerLinker.sol b/proxy/contracts/schain/TokenManagerLinker.sol index 563d99c03..fff49d5eb 100644 --- a/proxy/contracts/schain/TokenManagerLinker.sol +++ b/proxy/contracts/schain/TokenManagerLinker.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/ITokenManagerLinker.sol"; +import "../interfaces/schain/ITokenManagerLinker.sol"; import "../Messages.sol"; import "../MessageProxy.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol b/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol index 394812100..d31083ac5 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerERC1155.sol"; +import "../../interfaces/schain/TokenManagers/ITokenManagerERC1155.sol"; import "../../Messages.sol"; import "../tokens/ERC1155OnChain.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol b/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol index fa9a4463f..3cf34154d 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerERC20.sol"; +import "../../interfaces/schain/TokenManagers/ITokenManagerERC20.sol"; import "../../Messages.sol"; import "../tokens/ERC20OnChain.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol b/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol index eab1aaa0b..88b6dccf6 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerERC721.sol"; +import "../../interfaces/schain/TokenManagers/ITokenManagerERC721.sol"; import "../../Messages.sol"; import "../tokens/ERC721OnChain.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol b/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol index 37a749f8c..824d9d53d 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol @@ -21,7 +21,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerEth.sol"; +import "../../interfaces/schain/TokenManagers/ITokenManagerEth.sol"; import "../../Messages.sol"; import "../TokenManager.sol"; diff --git a/proxy/contracts/schain/bls/FieldOperations.sol b/proxy/contracts/schain/bls/FieldOperations.sol index e5905270a..32d567385 100644 --- a/proxy/contracts/schain/bls/FieldOperations.sol +++ b/proxy/contracts/schain/bls/FieldOperations.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/schain/bls/IFieldOperations.sol"; +import "../../interfaces/schain/bls/IFieldOperations.sol"; import "./Precompiled.sol"; diff --git a/proxy/contracts/schain/tokens/ERC1155OnChain.sol b/proxy/contracts/schain/tokens/ERC1155OnChain.sol index 0a0d914af..27e5fbad7 100644 --- a/proxy/contracts/schain/tokens/ERC1155OnChain.sol +++ b/proxy/contracts/schain/tokens/ERC1155OnChain.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/tokens/IERC1155OnChain.sol"; +import "../../interfaces/schain/tokens/IERC1155OnChain.sol"; /** diff --git a/proxy/contracts/schain/tokens/ERC20OnChain.sol b/proxy/contracts/schain/tokens/ERC20OnChain.sol index e20ed2a5d..e763490c5 100644 --- a/proxy/contracts/schain/tokens/ERC20OnChain.sol +++ b/proxy/contracts/schain/tokens/ERC20OnChain.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/tokens/IERC20OnChain.sol"; +import "../../interfaces/schain/tokens/IERC20OnChain.sol"; /** diff --git a/proxy/contracts/schain/tokens/ERC721OnChain.sol b/proxy/contracts/schain/tokens/ERC721OnChain.sol index 98a1ec32f..fbf82766e 100644 --- a/proxy/contracts/schain/tokens/ERC721OnChain.sol +++ b/proxy/contracts/schain/tokens/ERC721OnChain.sol @@ -25,7 +25,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/tokens/IERC721OnChain.sol"; +import "../../interfaces/schain/tokens/IERC721OnChain.sol"; /** diff --git a/proxy/contracts/schain/tokens/EthErc20.sol b/proxy/contracts/schain/tokens/EthErc20.sol index 6478fe430..99d5dc77e 100644 --- a/proxy/contracts/schain/tokens/EthErc20.sol +++ b/proxy/contracts/schain/tokens/EthErc20.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; -import "@skalenetwork/ima-interfaces/schain/tokens/IEthErc20.sol"; +import "../../interfaces/schain/tokens/IEthErc20.sol"; /** diff --git a/proxy/contracts/test/FallbackEthTester.sol b/proxy/contracts/test/FallbackEthTester.sol index 296b97a27..96f9c35f9 100644 --- a/proxy/contracts/test/FallbackEthTester.sol +++ b/proxy/contracts/test/FallbackEthTester.sol @@ -22,8 +22,8 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; -import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; +import "../interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; +import "../interfaces/mainnet/ICommunityPool.sol"; interface IFallbackEthTester { receive() external payable; diff --git a/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol b/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol index eed7d733e..943ca188d 100644 --- a/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol +++ b/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; +import "../interfaces/IMessageReceiver.sol"; contract ReceiverGasLimitMainnetMock is IMessageReceiver { diff --git a/proxy/contracts/test/ReceiverGasLimitSchainMock.sol b/proxy/contracts/test/ReceiverGasLimitSchainMock.sol index 65b8d6eb4..04b443a3d 100644 --- a/proxy/contracts/test/ReceiverGasLimitSchainMock.sol +++ b/proxy/contracts/test/ReceiverGasLimitSchainMock.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; +import "../interfaces/IMessageReceiver.sol"; contract ReceiverGasLimitSchainMock is IMessageReceiver { diff --git a/proxy/contracts/test/ReceiverMock.sol b/proxy/contracts/test/ReceiverMock.sol index 1c93bf76c..6b6798738 100644 --- a/proxy/contracts/test/ReceiverMock.sol +++ b/proxy/contracts/test/ReceiverMock.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; +import "../interfaces/IMessageReceiver.sol"; contract ReceiverMock is IMessageReceiver { diff --git a/proxy/contracts/test/TestCallReceiverContract.sol b/proxy/contracts/test/TestCallReceiverContract.sol index d8570351e..fb47f32e0 100644 --- a/proxy/contracts/test/TestCallReceiverContract.sol +++ b/proxy/contracts/test/TestCallReceiverContract.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; +import "../interfaces/IMessageReceiver.sol"; contract TestCallReceiverContract is IMessageReceiver { diff --git a/proxy/contracts/test/TestNodes.sol b/proxy/contracts/test/TestNodes.sol index f1e6dc532..34f085fe7 100644 --- a/proxy/contracts/test/TestNodes.sol +++ b/proxy/contracts/test/TestNodes.sol @@ -22,8 +22,6 @@ pragma solidity 0.8.6; -import "hardhat/console.sol"; - interface INodesTester { function createNode(address, Nodes.NodeCreationParams calldata params) external; @@ -109,7 +107,6 @@ contract Nodes is INodesTester { checkNodeExists(nodeIndex) returns (bool) { - console.log("Inside", nodeIndex); return nodeIndexes[from].isNodeExist[nodeIndex]; } diff --git a/proxy/interfaces/package.json b/proxy/interfaces/package.json new file mode 100644 index 000000000..4b5f5dc71 --- /dev/null +++ b/proxy/interfaces/package.json @@ -0,0 +1,11 @@ +{ + "name": "@skalenetwork/ima-interfaces", + "description": "Definitions of interfaces needed to integrate with IMA smart contracts", + "main": "index.js", + "repository": "git@github.com:skalenetwork/IMA.git", + "author": "Artem Payvin ", + "license": "AGPL-3.0", + "files": [ + "**/*.sol" + ] +} diff --git a/proxy/interfaces/publish_package.sh b/proxy/interfaces/publish_package.sh new file mode 100755 index 000000000..a44d62598 --- /dev/null +++ b/proxy/interfaces/publish_package.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +set -e + +USAGE_MSG='Usage: BRANCH=[BRANCH] publish_package.sh' +if [ -z "$BRANCH" ] +then + (>&2 echo 'You should provide branch') + echo "$USAGE_MSG" + exit 1 +fi + +SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" +ROOT_DIR=$(dirname $SCRIPT_DIR) +INTERFACES_DIR="$ROOT_DIR/contracts/interfaces" + +cd "$ROOT_DIR" + +BRANCH=$(echo $BRANCH | tr [:upper:] [:lower:] | tr -d [:space:]) +VERSION=$(BRANCH=$BRANCH $ROOT_DIR/predeployed/scripts/calculate_version.sh) + +TAG="" +if ! [[ $BRANCH == 'stable' ]] +then + TAG="--tag $BRANCH" +fi + +if [[ "$VERSION" == *-stable.0 ]] +then + VERSION=${VERSION%-stable.0} +fi + +echo "Using $VERSION as a new version" + +cp LICENSE "$INTERFACES_DIR" +cp README.md "$INTERFACES_DIR" +cp "$ROOT_DIR/interfaces/package.json" "$INTERFACES_DIR" + +yarn publish $INTERFACES_DIR --access public --new-version $VERSION --verbose --no-git-tag-version $TAG --ignore-scripts diff --git a/proxy/package.json b/proxy/package.json index 345b37441..e55f88909 100644 --- a/proxy/package.json +++ b/proxy/package.json @@ -25,7 +25,6 @@ "@openzeppelin/contracts-upgradeable": "^4.3.2", "@openzeppelin/hardhat-upgrades": "^1.9.0", "@skalenetwork/etherbase-interfaces": "^0.0.1-develop.20", - "@skalenetwork/ima-interfaces": "1.0.0-develop.16", "@skalenetwork/skale-manager-interfaces": "1.0.0-develop.1", "axios": "^0.21.4", "dotenv": "^10.0.0", diff --git a/proxy/yarn.lock b/proxy/yarn.lock index f73e6a494..57520e74b 100644 --- a/proxy/yarn.lock +++ b/proxy/yarn.lock @@ -757,23 +757,11 @@ resolved "https://registry.yarnpkg.com/@skalenetwork/etherbase-interfaces/-/etherbase-interfaces-0.0.1-develop.20.tgz#33f61e18d695fd47063aa39dce4df335d26b9528" integrity sha512-j3xnuQtOtjvjAoUMJgSUFxRa9/Egkg1RyA8r6PjcEb33VksE4LWLBy0PNFUFehLZv48595JROTcViGeXXwg5HQ== -"@skalenetwork/ima-interfaces@1.0.0-develop.16": - version "1.0.0-develop.16" - resolved "https://registry.yarnpkg.com/@skalenetwork/ima-interfaces/-/ima-interfaces-1.0.0-develop.16.tgz#9f79790c6e7eb960498f6930e978705f4ee60cc2" - integrity sha512-lsNonWKt3BLUlS7tk+w1Yp1o/07Bjj9Hr22zt0dzAqvRhCAB8ITBEeHlysXeQs60lE+bBqvmU/SRMdmMF/kliA== - dependencies: - "@skalenetwork/skale-manager-interfaces" "^0.1.2" - "@skalenetwork/skale-manager-interfaces@1.0.0-develop.1": version "1.0.0-develop.1" resolved "https://registry.yarnpkg.com/@skalenetwork/skale-manager-interfaces/-/skale-manager-interfaces-1.0.0-develop.1.tgz#8a2d06872dcdc235c041448efc454c0d5f1e55cf" integrity sha512-ZOSWEqvz76Ez5cuWE8n9+j/tnTVQg+t7vaZar/XME0hxnM1YwNFqy34nqjEC/SMhFXg/WnxdOVX9JWWXVZRlkQ== -"@skalenetwork/skale-manager-interfaces@^0.1.2": - version "0.1.2" - resolved "https://registry.yarnpkg.com/@skalenetwork/skale-manager-interfaces/-/skale-manager-interfaces-0.1.2.tgz#88e543c8cc298cd0cc9559892d746d2d74786da8" - integrity sha512-gapSQJahwWMlTB/xp/kMzB6k+9+Skx/N0fvEloiW4CUrkGkSa8+fj16YmUXX45p1hOc45W+JydiJPNgZtx32Dg== - "@solidity-parser/parser@^0.11.0": version "0.11.1" resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.11.1.tgz#fa840af64840c930f24a9c82c08d4a092a068add" From 18d75364c7cc07924b11d7e3b90cf90d5471eb54 Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Sun, 12 Jun 2022 22:57:09 +0100 Subject: [PATCH 05/11] Fix codacy' --- proxy/interfaces/publish_package.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/interfaces/publish_package.sh b/proxy/interfaces/publish_package.sh index a44d62598..8421e14e8 100755 --- a/proxy/interfaces/publish_package.sh +++ b/proxy/interfaces/publish_package.sh @@ -11,13 +11,13 @@ then fi SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -ROOT_DIR=$(dirname $SCRIPT_DIR) +ROOT_DIR="$(dirname $SCRIPT_DIR)" INTERFACES_DIR="$ROOT_DIR/contracts/interfaces" cd "$ROOT_DIR" -BRANCH=$(echo $BRANCH | tr [:upper:] [:lower:] | tr -d [:space:]) -VERSION=$(BRANCH=$BRANCH $ROOT_DIR/predeployed/scripts/calculate_version.sh) +BRANCH="$(echo $BRANCH | tr [:upper:] [:lower:] | tr -d [:space:])" +VERSION="$(BRANCH=$BRANCH $ROOT_DIR/predeployed/scripts/calculate_version.sh)" TAG="" if ! [[ $BRANCH == 'stable' ]] @@ -36,4 +36,4 @@ cp LICENSE "$INTERFACES_DIR" cp README.md "$INTERFACES_DIR" cp "$ROOT_DIR/interfaces/package.json" "$INTERFACES_DIR" -yarn publish $INTERFACES_DIR --access public --new-version $VERSION --verbose --no-git-tag-version $TAG --ignore-scripts +yarn publish "$INTERFACES_DIR" --access public --new-version "$VERSION" --verbose --no-git-tag-version "$TAG" --ignore-scripts From a78585d21152e777a1fd9cc7018a4874a82e0fef Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Sun, 12 Jun 2022 23:03:50 +0100 Subject: [PATCH 06/11] Fix codacy --- proxy/interfaces/publish_package.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/interfaces/publish_package.sh b/proxy/interfaces/publish_package.sh index 8421e14e8..9e6649bdf 100755 --- a/proxy/interfaces/publish_package.sh +++ b/proxy/interfaces/publish_package.sh @@ -11,13 +11,13 @@ then fi SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -ROOT_DIR="$(dirname $SCRIPT_DIR)" +ROOT_DIR="$(dirname "$SCRIPT_DIR")" INTERFACES_DIR="$ROOT_DIR/contracts/interfaces" cd "$ROOT_DIR" -BRANCH="$(echo $BRANCH | tr [:upper:] [:lower:] | tr -d [:space:])" -VERSION="$(BRANCH=$BRANCH $ROOT_DIR/predeployed/scripts/calculate_version.sh)" +BRANCH="$(echo "$BRANCH" | tr [:upper:] [:lower:] | tr -d [:space:])" +VERSION="$(BRANCH="$BRANCH" "$ROOT_DIR/predeployed/scripts/calculate_version.sh")" TAG="" if ! [[ $BRANCH == 'stable' ]] From 3e08e2ac32e69a3f792828537af42ec8e9c58ffa Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Mon, 13 Jun 2022 00:43:10 +0100 Subject: [PATCH 07/11] Fix eth distribution during test --- proxy/gas/calculateGas.ts | 14 ++++++++--- proxy/test/DepositBoxERC1155.ts | 13 +++++++--- proxy/test/DepositBoxERC20.ts | 13 +++++++--- proxy/test/DepositBoxERC721.ts | 13 +++++++--- proxy/test/DepositBoxERC721WithMetadata.ts | 13 +++++++--- proxy/test/DepositBoxEth.ts | 13 +++++++--- proxy/test/MessageProxy.ts | 25 ++++++++----------- .../ERC721MintingFromSchainToMainnet.ts | 9 ++++--- 8 files changed, 75 insertions(+), 38 deletions(-) diff --git a/proxy/gas/calculateGas.ts b/proxy/gas/calculateGas.ts index b8200c053..f621e9ac9 100644 --- a/proxy/gas/calculateGas.ts +++ b/proxy/gas/calculateGas.ts @@ -101,6 +101,7 @@ describe("Gas calculation", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let schainOwner: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let imaLinker: Linker; @@ -142,9 +143,17 @@ describe("Gas calculation", () => { const mainnetName = "Mainnet"; before(async () => { - [deployer, schainOwner, user] = await ethers.getSigners(); + [deployer, schainOwner, user, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); }) + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); + }); + beforeEach(async () => { // skale-manager mock preparation contractManager = await deployContractManager(contractManagerAddress); @@ -166,9 +175,6 @@ describe("Gas calculation", () => { await schainsInternal.connect(deployer).addContractManager(contractManager.address); await wallets.connect(deployer).addContractManager(contractManager.address); - nodeAddress = Wallet.createRandom().connect(ethers.provider); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); - // setup 16 nodes const nodeCreationParams = { port: 1337, diff --git a/proxy/test/DepositBoxERC1155.ts b/proxy/test/DepositBoxERC1155.ts index 412de45f2..10860cc29 100644 --- a/proxy/test/DepositBoxERC1155.ts +++ b/proxy/test/DepositBoxERC1155.ts @@ -76,6 +76,7 @@ describe("DepositBoxERC1155", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let depositBoxERC1155: DepositBoxERC1155; @@ -87,7 +88,15 @@ describe("DepositBoxERC1155", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -99,7 +108,6 @@ describe("DepositBoxERC1155", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -111,7 +119,6 @@ describe("DepositBoxERC1155", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC1155.address); await messageProxy.registerExtraContract(schainName, communityPool.address); diff --git a/proxy/test/DepositBoxERC20.ts b/proxy/test/DepositBoxERC20.ts index 38500cac7..67d35b8a4 100644 --- a/proxy/test/DepositBoxERC20.ts +++ b/proxy/test/DepositBoxERC20.ts @@ -80,6 +80,7 @@ describe("DepositBoxERC20", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let depositBoxERC20: DepositBoxERC20; @@ -91,7 +92,15 @@ describe("DepositBoxERC20", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -103,7 +112,6 @@ describe("DepositBoxERC20", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -115,7 +123,6 @@ describe("DepositBoxERC20", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC20.address); await messageProxy.registerExtraContract(schainName, communityPool.address); diff --git a/proxy/test/DepositBoxERC721.ts b/proxy/test/DepositBoxERC721.ts index c87548911..d7108957a 100644 --- a/proxy/test/DepositBoxERC721.ts +++ b/proxy/test/DepositBoxERC721.ts @@ -76,6 +76,7 @@ describe("DepositBoxERC721", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let depositBoxERC721: DepositBoxERC721; @@ -87,7 +88,15 @@ describe("DepositBoxERC721", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -99,7 +108,6 @@ describe("DepositBoxERC721", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -111,7 +119,6 @@ describe("DepositBoxERC721", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC721.address); await messageProxy.registerExtraContract(schainName, communityPool.address); diff --git a/proxy/test/DepositBoxERC721WithMetadata.ts b/proxy/test/DepositBoxERC721WithMetadata.ts index 5728a1ddb..98e80989b 100644 --- a/proxy/test/DepositBoxERC721WithMetadata.ts +++ b/proxy/test/DepositBoxERC721WithMetadata.ts @@ -76,6 +76,7 @@ describe("DepositBoxERC721WithMetadata", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let depositBoxERC721WithMetadata: DepositBoxERC721WithMetadata; @@ -87,7 +88,15 @@ describe("DepositBoxERC721WithMetadata", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -99,7 +108,6 @@ describe("DepositBoxERC721WithMetadata", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -111,7 +119,6 @@ describe("DepositBoxERC721WithMetadata", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxERC721WithMetadata.address); await messageProxy.registerExtraContract(schainName, communityPool.address); diff --git a/proxy/test/DepositBoxEth.ts b/proxy/test/DepositBoxEth.ts index 381faadf8..4d5322fa6 100644 --- a/proxy/test/DepositBoxEth.ts +++ b/proxy/test/DepositBoxEth.ts @@ -106,6 +106,7 @@ describe("DepositBoxEth", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let user2: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let depositBoxEth: DepositBoxEth; @@ -117,7 +118,15 @@ describe("DepositBoxEth", () => { const schainName = "Schain"; before(async () => { - [deployer, user, user2] = await ethers.getSigners(); + [deployer, user, user2, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); beforeEach(async () => { @@ -129,7 +138,6 @@ describe("DepositBoxEth", () => { await messageProxy.grantRole(await messageProxy.CHAIN_CONNECTOR_ROLE(), linker.address); await messageProxy.grantRole(await messageProxy.EXTRA_CONTRACT_REGISTRAR_ROLE(), deployer.address); await initializeSchain(contractManager, schainName, user.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -141,7 +149,6 @@ describe("DepositBoxEth", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, user2.address, "1000000000000000000"); await messageProxy.registerExtraContractForAll(depositBoxEth.address); await messageProxy.registerExtraContract(schainName, communityPool.address); diff --git a/proxy/test/MessageProxy.ts b/proxy/test/MessageProxy.ts index 9b6d9ce64..240eb29de 100644 --- a/proxy/test/MessageProxy.ts +++ b/proxy/test/MessageProxy.ts @@ -70,6 +70,7 @@ describe("MessageProxy", () => { let client: SignerWithAddress; let customer: SignerWithAddress; let agent: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let keyStorage: KeyStorageMock; @@ -97,7 +98,15 @@ describe("MessageProxy", () => { const Counter = 0; before(async () => { - [deployer, user, client, customer, agent] = await ethers.getSigners(); + [deployer, user, client, customer, agent, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); + }); + + after(async () => { + const balanceNode = await nodeAddress.getBalance(); + await nodeAddress.sendTransaction({to: richGuy.address, value: balanceNode.sub(ethers.utils.parseEther("1"))}); }); describe("MessageProxy for mainnet", async () => { @@ -249,7 +258,6 @@ describe("MessageProxy", () => { it("should post incoming messages", async () => { const startingCounter = 0; await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -261,7 +269,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.registerExtraContract(schainName, communityPool.address); @@ -339,7 +346,6 @@ describe("MessageProxy", () => { it("should not post incoming messages with incorrect address", async () => { const startingCounter = 0; await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -351,7 +357,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.registerExtraContract(schainName, communityPool.address); @@ -460,7 +465,6 @@ describe("MessageProxy", () => { it("should get incoming messages counter", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -472,7 +476,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); const startingCounter = 0; @@ -522,7 +525,6 @@ describe("MessageProxy", () => { it("should get outgoing messages counter", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -534,7 +536,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); @@ -600,7 +601,6 @@ describe("MessageProxy", () => { it("should check gas limit issue", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -612,7 +612,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -659,7 +658,6 @@ describe("MessageProxy", () => { it("should slice revert message", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -671,7 +669,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); @@ -717,7 +714,6 @@ describe("MessageProxy", () => { it("should return panic error message", async () => { await initializeSchain(contractManager, schainName, deployer.address, 1, 1); - nodeAddress = Wallet.createRandom().connect(ethers.provider); const nodeCreationParams = { port: 1337, nonce: 1337, @@ -729,7 +725,6 @@ describe("MessageProxy", () => { }; await createNode(contractManager, nodeAddress.address, nodeCreationParams); await addNodesToSchain(contractManager, schainName, [0]); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); await rechargeSchainWallet(contractManager, schainName, deployer.address, "1000000000000000000"); await setCommonPublicKey(contractManager, schainName); await messageProxyForMainnet.connect(deployer).addConnectedChain(schainName); diff --git a/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts b/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts index d9b8fd3ba..f83cbbf34 100644 --- a/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts +++ b/proxy/test/extensions/ERC721MintingFromSchainToMainnet.ts @@ -99,6 +99,7 @@ describe("ERC721MintingFromSchainToMainnet", () => { let deployer: SignerWithAddress; let user: SignerWithAddress; let schainOwner: SignerWithAddress; + let richGuy: SignerWithAddress; let nodeAddress: Wallet; let imaLinker: Linker; @@ -126,7 +127,10 @@ describe("ERC721MintingFromSchainToMainnet", () => { const contractManagerAddress = "0x0000000000000000000000000000000000000000"; before(async () => { - [deployer, schainOwner, user] = await ethers.getSigners(); + [deployer, schainOwner, user, richGuy] = await ethers.getSigners(); + nodeAddress = Wallet.createRandom().connect(ethers.provider); + const balanceRichGuy = await richGuy.getBalance(); + await richGuy.sendTransaction({to: nodeAddress.address, value: balanceRichGuy.sub(ethers.utils.parseEther("1"))}); }) beforeEach(async () => { @@ -150,9 +154,6 @@ describe("ERC721MintingFromSchainToMainnet", () => { await schainsInternal.connect(deployer).addContractManager(contractManager.address); await wallets.connect(deployer).addContractManager(contractManager.address); - nodeAddress = Wallet.createRandom().connect(ethers.provider); - await deployer.sendTransaction({to: nodeAddress.address, value: ethers.utils.parseEther("1")}); - // setup 16 nodes const nodeCreationParams = { port: 1337, From 6b26d199808286cd3e643354537a03e009ac9c56 Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Fri, 17 Jun 2022 07:06:21 +0100 Subject: [PATCH 08/11] Move interfaces back --- proxy/.solhint.json | 2 +- proxy/contracts/MessageProxy.sol | 6 +- .../ERC721ReferenceMintAndMetadataMainnet.sol | 2 +- .../ERC721ReferenceMintAndMetadataSchain.sol | 2 +- .../interfaces/MessageProxyClient.sol | 2 +- .../interfaces/MessageReceiver.sol | 2 +- .../interfaces/MessageSender.sol | 0 .../contracts/interfaces/IGasReimbursable.sol | 35 -------- proxy/contracts/interfaces/IMessageProxy.sol | 83 ------------------- .../contracts/interfaces/IMessageReceiver.sol | 32 ------- .../DepositBoxes/IDepositBoxERC1155.sol | 57 ------------- .../mainnet/DepositBoxes/IDepositBoxERC20.sol | 45 ---------- .../DepositBoxes/IDepositBoxERC721.sol | 45 ---------- .../mainnet/DepositBoxes/IDepositBoxEth.sol | 34 -------- .../interfaces/mainnet/ICommunityPool.sol | 49 ----------- .../interfaces/mainnet/IDepositBox.sol | 42 ---------- .../contracts/interfaces/mainnet/ILinker.sol | 36 -------- .../mainnet/IMessageProxyForMainnet.sol | 32 ------- .../mainnet/ISkaleManagerClient.sol | 31 ------- proxy/contracts/interfaces/mainnet/ITwin.sol | 30 ------- .../interfaces/schain/ICommunityLocker.sol | 40 --------- .../interfaces/schain/IKeyStorage.sol | 30 ------- .../schain/IMessageProxyForSchain.sol | 40 --------- .../interfaces/schain/ITokenManager.sol | 32 ------- .../interfaces/schain/ITokenManagerLinker.sol | 36 -------- .../TokenManagers/ITokenContractManager.sol | 37 --------- .../TokenManagers/ITokenManagerERC1155.sol | 55 ------------ .../TokenManagers/ITokenManagerERC20.sol | 41 --------- .../TokenManagers/ITokenManagerERC721.sol | 38 --------- .../schain/TokenManagers/ITokenManagerEth.sol | 42 ---------- .../schain/bls/IFieldOperations.sol | 42 ---------- .../schain/tokens/IERC1155OnChain.sol | 38 --------- .../schain/tokens/IERC20OnChain.sol | 27 ------ .../schain/tokens/IERC721OnChain.sol | 28 ------- .../interfaces/schain/tokens/IEthErc20.sol | 29 ------- proxy/contracts/mainnet/CommunityPool.sol | 2 +- proxy/contracts/mainnet/DepositBox.sol | 2 +- .../DepositBoxes/DepositBoxERC1155.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxERC20.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxERC721.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxEth.sol | 2 +- proxy/contracts/mainnet/Linker.sol | 2 +- .../mainnet/MessageProxyForMainnet.sol | 4 +- .../contracts/mainnet/SkaleManagerClient.sol | 2 +- proxy/contracts/mainnet/Twin.sol | 2 +- proxy/contracts/schain/CommunityLocker.sol | 2 +- proxy/contracts/schain/KeyStorage.sol | 2 +- .../schain/MessageProxyForSchain.sol | 2 +- proxy/contracts/schain/TokenManager.sol | 4 +- proxy/contracts/schain/TokenManagerLinker.sol | 2 +- .../TokenManagers/TokenManagerERC1155.sol | 2 +- .../TokenManagers/TokenManagerERC20.sol | 2 +- .../TokenManagers/TokenManagerERC721.sol | 2 +- .../schain/TokenManagers/TokenManagerEth.sol | 2 +- .../contracts/schain/bls/FieldOperations.sol | 2 +- .../schain/tokens/ERC1155OnChain.sol | 2 +- .../contracts/schain/tokens/ERC20OnChain.sol | 2 +- .../contracts/schain/tokens/ERC721OnChain.sol | 2 +- proxy/contracts/schain/tokens/EthErc20.sol | 2 +- proxy/contracts/test/FallbackEthTester.sol | 4 +- .../test/ReceiverGasLimitMainnetMock.sol | 2 +- .../test/ReceiverGasLimitSchainMock.sol | 2 +- proxy/contracts/test/ReceiverMock.sol | 2 +- .../test/TestCallReceiverContract.sol | 2 +- proxy/interfaces/package.json | 11 --- proxy/interfaces/publish_package.sh | 39 --------- proxy/package.json | 1 + proxy/yarn.lock | 12 +++ 68 files changed, 53 insertions(+), 1196 deletions(-) rename proxy/contracts/{ => extensions}/interfaces/MessageProxyClient.sol (95%) rename proxy/contracts/{ => extensions}/interfaces/MessageReceiver.sol (94%) rename proxy/contracts/{ => extensions}/interfaces/MessageSender.sol (100%) delete mode 100644 proxy/contracts/interfaces/IGasReimbursable.sol delete mode 100644 proxy/contracts/interfaces/IMessageProxy.sol delete mode 100644 proxy/contracts/interfaces/IMessageReceiver.sol delete mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol delete mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol delete mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol delete mode 100644 proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol delete mode 100644 proxy/contracts/interfaces/mainnet/ICommunityPool.sol delete mode 100644 proxy/contracts/interfaces/mainnet/IDepositBox.sol delete mode 100644 proxy/contracts/interfaces/mainnet/ILinker.sol delete mode 100644 proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol delete mode 100644 proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol delete mode 100644 proxy/contracts/interfaces/mainnet/ITwin.sol delete mode 100644 proxy/contracts/interfaces/schain/ICommunityLocker.sol delete mode 100644 proxy/contracts/interfaces/schain/IKeyStorage.sol delete mode 100644 proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol delete mode 100644 proxy/contracts/interfaces/schain/ITokenManager.sol delete mode 100644 proxy/contracts/interfaces/schain/ITokenManagerLinker.sol delete mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol delete mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol delete mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol delete mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol delete mode 100644 proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol delete mode 100644 proxy/contracts/interfaces/schain/bls/IFieldOperations.sol delete mode 100644 proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol delete mode 100644 proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol delete mode 100644 proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol delete mode 100644 proxy/contracts/interfaces/schain/tokens/IEthErc20.sol delete mode 100644 proxy/interfaces/package.json delete mode 100755 proxy/interfaces/publish_package.sh diff --git a/proxy/.solhint.json b/proxy/.solhint.json index 4012a011f..3ebf80d25 100644 --- a/proxy/.solhint.json +++ b/proxy/.solhint.json @@ -5,7 +5,7 @@ "mark-callable-contracts": "off", "reason-string": "off", - "compiler-version": ["error",">=0.6.10 <0.9.0"], + "compiler-version": ["error","0.8.6"], "state-visibility": "error", "no-empty-blocks": "error", "check-send-result": "error", diff --git a/proxy/contracts/MessageProxy.sol b/proxy/contracts/MessageProxy.sol index e81b50bf0..6efde8494 100644 --- a/proxy/contracts/MessageProxy.sol +++ b/proxy/contracts/MessageProxy.sol @@ -24,9 +24,9 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; -import "./interfaces/IGasReimbursable.sol"; -import "./interfaces/IMessageProxy.sol"; -import "./interfaces/IMessageReceiver.sol"; +import "@skalenetwork/ima-interfaces/IGasReimbursable.sol"; +import "@skalenetwork/ima-interfaces/IMessageProxy.sol"; +import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; /** diff --git a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol index 3e620af11..01ee7b617 100644 --- a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol +++ b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "../schain/tokens/ERC721OnChain.sol"; -import "../interfaces/MessageReceiver.sol"; +import "./interfaces/MessageReceiver.sol"; interface IERC721ReferenceMintAndMetadataMainnet { function setSenderContractOnSchain(address newSenderContractOnSchain) external; diff --git a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol index e66860bdb..6179f3a42 100644 --- a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol +++ b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "../schain/tokens/ERC721OnChain.sol"; -import "../interfaces/MessageSender.sol"; +import "./interfaces/MessageSender.sol"; interface IERC721ReferenceMintAndMetadataSchain { function sendTokenToMainnet(address receiver, uint256 tokenId) external; diff --git a/proxy/contracts/interfaces/MessageProxyClient.sol b/proxy/contracts/extensions/interfaces/MessageProxyClient.sol similarity index 95% rename from proxy/contracts/interfaces/MessageProxyClient.sol rename to proxy/contracts/extensions/interfaces/MessageProxyClient.sol index d998249f4..932004f15 100644 --- a/proxy/contracts/interfaces/MessageProxyClient.sol +++ b/proxy/contracts/extensions/interfaces/MessageProxyClient.sol @@ -21,7 +21,7 @@ pragma solidity 0.8.6; -import "./IMessageProxy.sol"; +import "@skalenetwork/ima-interfaces/IMessageProxy.sol"; abstract contract MessageProxyClient { IMessageProxy public messageProxy; diff --git a/proxy/contracts/interfaces/MessageReceiver.sol b/proxy/contracts/extensions/interfaces/MessageReceiver.sol similarity index 94% rename from proxy/contracts/interfaces/MessageReceiver.sol rename to proxy/contracts/extensions/interfaces/MessageReceiver.sol index 2168b694b..86d3dee18 100644 --- a/proxy/contracts/interfaces/MessageReceiver.sol +++ b/proxy/contracts/extensions/interfaces/MessageReceiver.sol @@ -21,7 +21,7 @@ pragma solidity 0.8.6; -import "./IMessageReceiver.sol"; +import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; import "./MessageProxyClient.sol"; diff --git a/proxy/contracts/interfaces/MessageSender.sol b/proxy/contracts/extensions/interfaces/MessageSender.sol similarity index 100% rename from proxy/contracts/interfaces/MessageSender.sol rename to proxy/contracts/extensions/interfaces/MessageSender.sol diff --git a/proxy/contracts/interfaces/IGasReimbursable.sol b/proxy/contracts/interfaces/IGasReimbursable.sol deleted file mode 100644 index e6c8f197e..000000000 --- a/proxy/contracts/interfaces/IGasReimbursable.sol +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IGasReimbursable.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-Present SKALE Labs - * @author Artem Payvin - * - * 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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./IMessageReceiver.sol"; - - -interface IGasReimbursable is IMessageReceiver { - function gasPayer( - bytes32 schainHash, - address sender, - bytes calldata data - ) - external - returns (address); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/IMessageProxy.sol b/proxy/contracts/interfaces/IMessageProxy.sol deleted file mode 100644 index 83ba0e477..000000000 --- a/proxy/contracts/interfaces/IMessageProxy.sol +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IMessageProxy.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IMessageProxy { - - /** - * @dev Structure that describes message. Should contain sender of message, - * destination contract on schain that will receiver message, - * data that contains all needed info about token or ETH. - */ - struct Message { - address sender; - address destinationContract; - bytes data; - } - - /** - * @dev Structure that contains fields for bls signature. - */ - struct Signature { - uint256[2] blsSignature; - uint256 hashA; - uint256 hashB; - uint256 counter; - } - - function addConnectedChain(string calldata schainName) external; - function postIncomingMessages( - string calldata fromSchainName, - uint256 startingCounter, - Message[] calldata messages, - Signature calldata sign - ) external; - function setNewGasLimit(uint256 newGasLimit) external; - function registerExtraContractForAll(address extraContract) external; - function removeExtraContractForAll(address extraContract) external; - function removeConnectedChain(string memory schainName) external; - function postOutgoingMessage( - bytes32 targetChainHash, - address targetContract, - bytes memory data - ) external; - function registerExtraContract(string memory chainName, address extraContract) external; - function removeExtraContract(string memory schainName, address extraContract) external; - function setVersion(string calldata newVersion) external; - function isContractRegistered( - bytes32 schainHash, - address contractAddress - ) external view returns (bool); - function getContractRegisteredLength(bytes32 schainHash) external view returns (uint256); - function getContractRegisteredRange( - bytes32 schainHash, - uint256 from, - uint256 to - ) - external - view - returns (address[] memory); - function getOutgoingMessagesCounter(string calldata targetSchainName) external view returns (uint256); - function getIncomingMessagesCounter(string calldata fromSchainName) external view returns (uint256); - function isConnectedChain(string memory schainName) external view returns (bool); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/IMessageReceiver.sol b/proxy/contracts/interfaces/IMessageReceiver.sol deleted file mode 100644 index ee9ed4f06..000000000 --- a/proxy/contracts/interfaces/IMessageReceiver.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IMessageReceiver.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IMessageReceiver { - function postMessage( - bytes32 schainHash, - address sender, - bytes calldata data - ) - external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol deleted file mode 100644 index ac3d0f95a..000000000 --- a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol +++ /dev/null @@ -1,57 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IDepositBoxERC1155.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IDepositBox.sol"; - - -interface IDepositBoxERC1155 is IDepositBox { - function initializeAllTokensForSchain( - string calldata schainName, - address[] calldata tokens - ) external; - function depositERC1155(string calldata schainName, address erc1155OnMainnet, uint256 id, uint256 amount) external; - function depositERC1155Batch( - string calldata schainName, - address erc1155OnMainnet, - uint256[] calldata ids, - uint256[] calldata amounts - ) external; - function addERC1155TokenByOwner(string calldata schainName, address erc1155OnMainnet) external; - function getFunds( - string calldata schainName, - address erc1155OnMainnet, - address receiver, - uint256[] memory ids, - uint256[] memory amounts - ) external; - function getSchainToERC1155(string calldata schainName, address erc1155OnMainnet) external view returns (bool); - function getSchainToAllERC1155Length(string calldata schainName) external view returns (uint256); - function getSchainToAllERC1155( - string calldata schainName, - uint256 from, - uint256 to - ) - external - view - returns (address[] memory); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol deleted file mode 100644 index 45b3b5be6..000000000 --- a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IDepositBoxERC20.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IDepositBox.sol"; - - -interface IDepositBoxERC20 is IDepositBox { - function initializeAllTokensForSchain( - string calldata schainName, - address[] calldata tokens - ) external; - function depositERC20(string calldata schainName, address erc20OnMainnet, uint256 amount) external; - function addERC20TokenByOwner(string calldata schainName, address erc20OnMainnet) external; - function getFunds(string calldata schainName, address erc20OnMainnet, address receiver, uint amount) external; - function getSchainToERC20(string calldata schainName, address erc20OnMainnet) external view returns (bool); - function getSchainToAllERC20Length(string calldata schainName) external view returns (uint256); - function getSchainToAllERC20( - string calldata schainName, - uint256 from, - uint256 to - ) - external - view - returns (address[] memory); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol deleted file mode 100644 index 762ed67be..000000000 --- a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IDepositBoxERC721.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IDepositBox.sol"; - - -interface IDepositBoxERC721 is IDepositBox { - function initializeAllTokensForSchain( - string calldata schainName, - address[] calldata tokens - ) external; - function depositERC721(string calldata schainName, address erc721OnMainnet, uint256 tokenId) external; - function addERC721TokenByOwner(string calldata schainName, address erc721OnMainnet) external; - function getFunds(string calldata schainName, address erc721OnMainnet, address receiver, uint tokenId) external; - function getSchainToERC721(string calldata schainName, address erc721OnMainnet) external view returns (bool); - function getSchainToAllERC721Length(string calldata schainName) external view returns (uint256); - function getSchainToAllERC721( - string calldata schainName, - uint256 from, - uint256 to - ) - external - view - returns (address[] memory); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol b/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol deleted file mode 100644 index 866444d68..000000000 --- a/proxy/contracts/interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IDepositBoxEth.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IDepositBox.sol"; - - -interface IDepositBoxEth is IDepositBox { - receive() external payable; - function deposit(string memory schainName) external payable; - function getMyEth() external; - function getFunds(string calldata schainName, address payable receiver, uint amount) external; - function enableActiveEthTransfers(string calldata schainName) external; - function disableActiveEthTransfers(string calldata schainName) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ICommunityPool.sol b/proxy/contracts/interfaces/mainnet/ICommunityPool.sol deleted file mode 100644 index 8ed639663..000000000 --- a/proxy/contracts/interfaces/mainnet/ICommunityPool.sol +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ICommunityPool.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "@skalenetwork/skale-manager-interfaces/IContractManager.sol"; - - -import "./ILinker.sol"; -import "./IMessageProxyForMainnet.sol"; -import "./ITwin.sol"; - - -interface ICommunityPool is ITwin { - function initialize( - IContractManager contractManagerOfSkaleManagerValue, - ILinker linker, - IMessageProxyForMainnet messageProxyValue - ) external; - function refundGasByUser(bytes32 schainHash, address payable node, address user, uint gas) external returns (uint); - function rechargeUserWallet(string calldata schainName, address user) external payable; - function withdrawFunds(string calldata schainName, uint amount) external; - function setMinTransactionGas(uint newMinTransactionGas) external; - function refundGasBySchainWallet( - bytes32 schainHash, - address payable node, - uint 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); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/IDepositBox.sol b/proxy/contracts/interfaces/mainnet/IDepositBox.sol deleted file mode 100644 index dafcbd076..000000000 --- a/proxy/contracts/interfaces/mainnet/IDepositBox.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IDepositBox.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "@skalenetwork/skale-manager-interfaces/IContractManager.sol"; - -import "../IGasReimbursable.sol"; -import "../IMessageReceiver.sol"; -import "./ILinker.sol"; -import "./IMessageProxyForMainnet.sol"; -import "./ITwin.sol"; - - -interface IDepositBox is ITwin, IMessageReceiver, IGasReimbursable { - function initialize( - IContractManager contractManagerOfSkaleManagerValue, - ILinker newLinker, - IMessageProxyForMainnet messageProxyValue - ) external; - function enableWhitelist(string memory schainName) external; - function disableWhitelist(string memory schainName) external; - function isWhitelisted(string memory schainName) external view returns (bool); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ILinker.sol b/proxy/contracts/interfaces/mainnet/ILinker.sol deleted file mode 100644 index 8215b7784..000000000 --- a/proxy/contracts/interfaces/mainnet/ILinker.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ILinker.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./ITwin.sol"; - - -interface ILinker is ITwin { - function registerMainnetContract(address newMainnetContract) external; - function removeMainnetContract(address mainnetContract) external; - 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 hasMainnetContract(address mainnetContract) external view returns (bool); - function hasSchain(string calldata schainName) external view returns (bool connected); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol b/proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol deleted file mode 100644 index 640ce56c4..000000000 --- a/proxy/contracts/interfaces/mainnet/IMessageProxyForMainnet.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IMessageProxyForMainnet.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IMessageProxy.sol"; -import "./ICommunityPool.sol"; - -interface IMessageProxyForMainnet is IMessageProxy { - function setCommunityPool(ICommunityPool newCommunityPoolAddress) external; - function setNewHeaderMessageGasCost(uint256 newHeaderMessageGasCost) external; - function setNewMessageGasCost(uint256 newMessageGasCost) external; - function messageInProgress() external view returns (bool); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol b/proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol deleted file mode 100644 index fc0d05db2..000000000 --- a/proxy/contracts/interfaces/mainnet/ISkaleManagerClient.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ISkaleManagerClient.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "@skalenetwork/skale-manager-interfaces/IContractManager.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); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/mainnet/ITwin.sol b/proxy/contracts/interfaces/mainnet/ITwin.sol deleted file mode 100644 index 93665453d..000000000 --- a/proxy/contracts/interfaces/mainnet/ITwin.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITwin.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./ISkaleManagerClient.sol"; - -interface ITwin is ISkaleManagerClient { - function addSchainContract(string calldata schainName, address contractReceiver) external; - function removeSchainContract(string calldata schainName) external; - function hasSchainContract(string calldata schainName) external view returns (bool); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/ICommunityLocker.sol b/proxy/contracts/interfaces/schain/ICommunityLocker.sol deleted file mode 100644 index 0b5089888..000000000 --- a/proxy/contracts/interfaces/schain/ICommunityLocker.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ICommunityLocker.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IMessageReceiver.sol"; - -import "./IMessageProxyForSchain.sol"; -import "./ITokenManagerLinker.sol"; - - -interface ICommunityLocker is IMessageReceiver { - function initialize( - string memory newSchainName, - IMessageProxyForSchain newMessageProxy, - ITokenManagerLinker newTokenManagerLinker, - address newCommunityPool - ) external; - function checkAllowedToSendMessage(address receiver) external; - function setTimeLimitPerMessage(uint newTimeLimitPerMessage) external; - function setGasPrice(uint gasPrice, uint timestamp, IMessageProxyForSchain.Signature memory signature) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/IKeyStorage.sol b/proxy/contracts/interfaces/schain/IKeyStorage.sol deleted file mode 100644 index ac5d3105b..000000000 --- a/proxy/contracts/interfaces/schain/IKeyStorage.sol +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IKeyStorage.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./bls/IFieldOperations.sol"; - - -interface IKeyStorage { - function initialize() external; - function getBlsCommonPublicKey() external view returns (IFieldOperations.G2Point memory); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol b/proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol deleted file mode 100644 index 143b2c22b..000000000 --- a/proxy/contracts/interfaces/schain/IMessageProxyForSchain.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IMessageProxyForSchain.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IMessageProxy.sol"; -import "./IKeyStorage.sol"; - -interface IMessageProxyForSchain is IMessageProxy { - struct OutgoingMessageData { - bytes32 dstChainHash; // destination chain - uint256 msgCounter; // message counter - address srcContract; // origin - address dstContract; // receiver - bytes data; // payload - } - - function initialize(IKeyStorage blsKeyStorage, string memory schainName) external; - function verifyOutgoingMessageData(OutgoingMessageData memory message) external view returns (bool); - function verifySignature(bytes32 hashedMessage, Signature memory signature) external view returns (bool); - function messageInProgress() external view returns (bool); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/ITokenManager.sol b/proxy/contracts/interfaces/schain/ITokenManager.sol deleted file mode 100644 index b0ee59b0b..000000000 --- a/proxy/contracts/interfaces/schain/ITokenManager.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManager - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../IMessageReceiver.sol"; - - -interface ITokenManager is IMessageReceiver { - function enableAutomaticDeploy() external; - function addTokenManager(string calldata schainName, address newTokenManager) external; - function removeTokenManager(string calldata schainName) external; - function hasTokenManager(string calldata schainName) external view returns (bool); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/ITokenManagerLinker.sol b/proxy/contracts/interfaces/schain/ITokenManagerLinker.sol deleted file mode 100644 index 040b6751e..000000000 --- a/proxy/contracts/interfaces/schain/ITokenManagerLinker.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManagerLinker - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./IMessageProxyForSchain.sol"; -import "./ITokenManager.sol"; - - -interface ITokenManagerLinker { - function initialize(IMessageProxyForSchain newMessageProxyAddress, address linker) external; - function registerTokenManager(ITokenManager newTokenManager) external; - function removeTokenManager(ITokenManager tokenManagerAddress) external; - function connectSchain(string calldata schainName) external; - function disconnectSchain(string calldata schainName) external; - function hasTokenManager(ITokenManager tokenManager) external view returns (bool); - function hasSchain(string calldata schainName) external view returns (bool connected); -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol deleted file mode 100644 index 1b7a15975..000000000 --- a/proxy/contracts/interfaces/schain/TokenManagers/ITokenContractManager.sol +++ /dev/null @@ -1,37 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManagerERC20 - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../ICommunityLocker.sol"; -import "../IMessageProxyForSchain.sol"; -import "../ITokenManager.sol"; -import "../ITokenManagerLinker.sol"; - -interface ITokenContractManager is ITokenManager { - function initialize( - string memory newChainName, - IMessageProxyForSchain newMessageProxy, - ITokenManagerLinker newIMALinker, - ICommunityLocker newCommunityLocker, - address newDepositBox - ) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol deleted file mode 100644 index 7fc122660..000000000 --- a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC1155.sol +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManagerERC1155 - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./ITokenContractManager.sol"; - - -interface ITokenManagerERC1155 is ITokenContractManager { - function exitToMainERC1155( - address contractOnMainnet, - uint256 id, - uint256 amount - ) external; - function exitToMainERC1155Batch( - address contractOnMainnet, - uint256[] memory ids, - uint256[] memory amounts - ) external; - function transferToSchainERC1155( - string calldata targetSchainName, - address contractOnMainnet, - uint256 id, - uint256 amount - ) external; - function transferToSchainERC1155Batch( - string calldata targetSchainName, - address contractOnMainnet, - uint256[] memory ids, - uint256[] memory amounts - ) external; - function addERC1155TokenByOwner( - string calldata targetChainName, - address erc1155OnMainnet, - address erc1155OnSchain - ) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol deleted file mode 100644 index 945e134c6..000000000 --- a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC20.sol +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManagerERC20 - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./ITokenContractManager.sol"; - -interface ITokenManagerERC20 is ITokenContractManager { - function exitToMainERC20( - address contractOnMainnet, - uint256 amount - ) external; - function transferToSchainERC20( - string calldata targetSchainName, - address contractOnMainnet, - uint256 amount - ) external; - function addERC20TokenByOwner( - string calldata targetChainName, - address erc20OnMainnet, - address erc20OnSchain - ) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol deleted file mode 100644 index ba5299664..000000000 --- a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerERC721.sol +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManagerERC721 - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "./ITokenContractManager.sol"; - -interface ITokenManagerERC721 is ITokenContractManager { - function exitToMainERC721(address contractOnMainnet, uint256 tokenId) external; - function transferToSchainERC721( - string calldata targetSchainName, - address contractOnMainnet, - uint256 tokenId - ) external; - function addERC721TokenByOwner( - string calldata targetChainName, - address erc721OnMainnet, - address erc721OnSchain - ) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol b/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol deleted file mode 100644 index dce9c63d5..000000000 --- a/proxy/contracts/interfaces/schain/TokenManagers/ITokenManagerEth.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * ITokenManagerEth - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - -import "../tokens/IEthErc20.sol"; -import "../ICommunityLocker.sol"; -import "../IMessageProxyForSchain.sol"; -import "../ITokenManager.sol"; -import "../ITokenManagerLinker.sol"; - - -interface ITokenManagerEth is ITokenManager { - function initialize( - string memory newChainName, - IMessageProxyForSchain newMessageProxy, - ITokenManagerLinker newIMALinker, - ICommunityLocker newCommunityLocker, - address newDepositBox, - IEthErc20 ethErc20Address - ) external; - function setEthErc20Address(IEthErc20 newEthErc20Address) external; - function exitToMain(uint256 amount) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/bls/IFieldOperations.sol b/proxy/contracts/interfaces/schain/bls/IFieldOperations.sol deleted file mode 100644 index 7c1dca326..000000000 --- a/proxy/contracts/interfaces/schain/bls/IFieldOperations.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IFieldOperations.sol - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IFieldOperations { - - /** - * @dev Structure that represents the field element { a + ib } - */ - struct Fp2Point { - uint a; - uint b; - } - - /** - * @dev Structure that represents an element of G2 - */ - struct G2Point { - Fp2Point x; - Fp2Point y; - } -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol b/proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol deleted file mode 100644 index 2927793d4..000000000 --- a/proxy/contracts/interfaces/schain/tokens/IERC1155OnChain.sol +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IERC1155OnChain - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IERC1155OnChain { - function mint( - address account, - uint256 id, - uint256 amount, - bytes memory data - ) external; - function mintBatch( - address account, - uint256[] memory ids, - uint256[] memory amounts, - bytes memory data - ) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol b/proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol deleted file mode 100644 index 3b7e99108..000000000 --- a/proxy/contracts/interfaces/schain/tokens/IERC20OnChain.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IERC20OnChain - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IERC20OnChain { - function mint(address account, uint256 value) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol b/proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol deleted file mode 100644 index d2a7e5aa9..000000000 --- a/proxy/contracts/interfaces/schain/tokens/IERC721OnChain.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IERC721OnChain - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IERC721OnChain { - function setTokenURI(uint256 tokenId, string calldata tokenUri) external returns (bool); - function mint(address account, uint256 tokenId) external; -} \ No newline at end of file diff --git a/proxy/contracts/interfaces/schain/tokens/IEthErc20.sol b/proxy/contracts/interfaces/schain/tokens/IEthErc20.sol deleted file mode 100644 index aeb8236de..000000000 --- a/proxy/contracts/interfaces/schain/tokens/IEthErc20.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-only - -/** - * IEthErc20 - SKALE Interchain Messaging Agent - * Copyright (C) 2021-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 . - */ - -pragma solidity >=0.6.10 <0.9.0; - - -interface IEthErc20 { - function mint(address account, uint256 amount) external; - function forceBurn(address account, uint256 amount) external; - function initialize(address tokenManagerEthAddress) external; -} \ No newline at end of file diff --git a/proxy/contracts/mainnet/CommunityPool.sol b/proxy/contracts/mainnet/CommunityPool.sol index 6fbb982a9..5808b265e 100644 --- a/proxy/contracts/mainnet/CommunityPool.sol +++ b/proxy/contracts/mainnet/CommunityPool.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; -import "../interfaces/mainnet/ICommunityPool.sol"; +import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; import "../Messages.sol"; import "./Twin.sol"; diff --git a/proxy/contracts/mainnet/DepositBox.sol b/proxy/contracts/mainnet/DepositBox.sol index 37d03b4d1..840d165a4 100644 --- a/proxy/contracts/mainnet/DepositBox.sol +++ b/proxy/contracts/mainnet/DepositBox.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "../interfaces/mainnet/IDepositBox.sol"; +import "@skalenetwork/ima-interfaces/mainnet/IDepositBox.sol"; import "./Twin.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol index 0ec21de68..8de91f055 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC1155.sol @@ -25,7 +25,7 @@ import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155ReceiverUpgradeable.sol"; -import "../../interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol"; +import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC1155.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol index 06cc29d3a..69a67a6b0 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC20.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; -import "../../interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol"; +import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC20.sol"; import "../../Messages.sol"; import "../DepositBox.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol index 3c3b29e13..29d1de65c 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; -import "../../interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol"; +import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol index 8af63af34..8968c1933 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxEth.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "../../interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; +import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/Linker.sol b/proxy/contracts/mainnet/Linker.sol index ae763ade0..665d5b1a1 100644 --- a/proxy/contracts/mainnet/Linker.sol +++ b/proxy/contracts/mainnet/Linker.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "../interfaces/mainnet/ILinker.sol"; +import "@skalenetwork/ima-interfaces/mainnet/ILinker.sol"; import "../Messages.sol"; import "./MessageProxyForMainnet.sol"; diff --git a/proxy/contracts/mainnet/MessageProxyForMainnet.sol b/proxy/contracts/mainnet/MessageProxyForMainnet.sol index 011dde96c..8f3358d0e 100644 --- a/proxy/contracts/mainnet/MessageProxyForMainnet.sol +++ b/proxy/contracts/mainnet/MessageProxyForMainnet.sol @@ -25,8 +25,8 @@ import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; import "@skalenetwork/skale-manager-interfaces/ISchains.sol"; import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol"; -import "../interfaces/mainnet/IMessageProxyForMainnet.sol"; -import "../interfaces/mainnet/ICommunityPool.sol"; +import "@skalenetwork/ima-interfaces/mainnet/IMessageProxyForMainnet.sol"; +import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; import "../MessageProxy.sol"; diff --git a/proxy/contracts/mainnet/SkaleManagerClient.sol b/proxy/contracts/mainnet/SkaleManagerClient.sol index f9165c66a..5c4c0c830 100644 --- a/proxy/contracts/mainnet/SkaleManagerClient.sol +++ b/proxy/contracts/mainnet/SkaleManagerClient.sol @@ -25,7 +25,7 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@skalenetwork/skale-manager-interfaces/IContractManager.sol"; import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol"; -import "../interfaces/mainnet/ISkaleManagerClient.sol"; +import "@skalenetwork/ima-interfaces/mainnet/ISkaleManagerClient.sol"; /** diff --git a/proxy/contracts/mainnet/Twin.sol b/proxy/contracts/mainnet/Twin.sol index 9f9f9a42e..ba9857fa0 100644 --- a/proxy/contracts/mainnet/Twin.sol +++ b/proxy/contracts/mainnet/Twin.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; -import "../interfaces/mainnet/ITwin.sol"; +import "@skalenetwork/ima-interfaces/mainnet/ITwin.sol"; import "./MessageProxyForMainnet.sol"; import "./SkaleManagerClient.sol"; diff --git a/proxy/contracts/schain/CommunityLocker.sol b/proxy/contracts/schain/CommunityLocker.sol index b7ebdaff8..58ed57644 100644 --- a/proxy/contracts/schain/CommunityLocker.sol +++ b/proxy/contracts/schain/CommunityLocker.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "../interfaces/schain/ICommunityLocker.sol"; +import "@skalenetwork/ima-interfaces/schain/ICommunityLocker.sol"; import "../Messages.sol"; diff --git a/proxy/contracts/schain/KeyStorage.sol b/proxy/contracts/schain/KeyStorage.sol index 1379850c3..55277b907 100644 --- a/proxy/contracts/schain/KeyStorage.sol +++ b/proxy/contracts/schain/KeyStorage.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "../interfaces/schain/IKeyStorage.sol"; +import "@skalenetwork/ima-interfaces/schain/IKeyStorage.sol"; import "./bls/FieldOperations.sol"; diff --git a/proxy/contracts/schain/MessageProxyForSchain.sol b/proxy/contracts/schain/MessageProxyForSchain.sol index 719644c68..69bcb2ac8 100644 --- a/proxy/contracts/schain/MessageProxyForSchain.sol +++ b/proxy/contracts/schain/MessageProxyForSchain.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@skalenetwork/etherbase-interfaces/IEtherbaseUpgradeable.sol"; -import "../interfaces/schain/IMessageProxyForSchain.sol"; +import "@skalenetwork/ima-interfaces/schain/IMessageProxyForSchain.sol"; import "../MessageProxy.sol"; import "./bls/SkaleVerifier.sol"; diff --git a/proxy/contracts/schain/TokenManager.sol b/proxy/contracts/schain/TokenManager.sol index 9d92a707c..0a5a76c82 100644 --- a/proxy/contracts/schain/TokenManager.sol +++ b/proxy/contracts/schain/TokenManager.sol @@ -21,8 +21,8 @@ pragma solidity 0.8.6; -import "../interfaces/schain/ITokenManager.sol"; -import "../interfaces/schain/ICommunityLocker.sol"; +import "@skalenetwork/ima-interfaces/schain/ITokenManager.sol"; +import "@skalenetwork/ima-interfaces/schain/ICommunityLocker.sol"; import "./MessageProxyForSchain.sol"; import "./TokenManagerLinker.sol"; diff --git a/proxy/contracts/schain/TokenManagerLinker.sol b/proxy/contracts/schain/TokenManagerLinker.sol index fff49d5eb..563d99c03 100644 --- a/proxy/contracts/schain/TokenManagerLinker.sol +++ b/proxy/contracts/schain/TokenManagerLinker.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "../interfaces/schain/ITokenManagerLinker.sol"; +import "@skalenetwork/ima-interfaces/schain/ITokenManagerLinker.sol"; import "../Messages.sol"; import "../MessageProxy.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol b/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol index d31083ac5..394812100 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerERC1155.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "../../interfaces/schain/TokenManagers/ITokenManagerERC1155.sol"; +import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerERC1155.sol"; import "../../Messages.sol"; import "../tokens/ERC1155OnChain.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol b/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol index 3cf34154d..fa9a4463f 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerERC20.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; -import "../../interfaces/schain/TokenManagers/ITokenManagerERC20.sol"; +import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerERC20.sol"; import "../../Messages.sol"; import "../tokens/ERC20OnChain.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol b/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol index 88b6dccf6..eab1aaa0b 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerERC721.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "../../interfaces/schain/TokenManagers/ITokenManagerERC721.sol"; +import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerERC721.sol"; import "../../Messages.sol"; import "../tokens/ERC721OnChain.sol"; diff --git a/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol b/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol index 824d9d53d..37a749f8c 100644 --- a/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol +++ b/proxy/contracts/schain/TokenManagers/TokenManagerEth.sol @@ -21,7 +21,7 @@ pragma solidity 0.8.6; -import "../../interfaces/schain/TokenManagers/ITokenManagerEth.sol"; +import "@skalenetwork/ima-interfaces/schain/TokenManagers/ITokenManagerEth.sol"; import "../../Messages.sol"; import "../TokenManager.sol"; diff --git a/proxy/contracts/schain/bls/FieldOperations.sol b/proxy/contracts/schain/bls/FieldOperations.sol index 32d567385..e5905270a 100644 --- a/proxy/contracts/schain/bls/FieldOperations.sol +++ b/proxy/contracts/schain/bls/FieldOperations.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "../../interfaces/schain/bls/IFieldOperations.sol"; +import "@skalenetwork/ima-interfaces/schain/bls/IFieldOperations.sol"; import "./Precompiled.sol"; diff --git a/proxy/contracts/schain/tokens/ERC1155OnChain.sol b/proxy/contracts/schain/tokens/ERC1155OnChain.sol index 27e5fbad7..0a0d914af 100644 --- a/proxy/contracts/schain/tokens/ERC1155OnChain.sol +++ b/proxy/contracts/schain/tokens/ERC1155OnChain.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "../../interfaces/schain/tokens/IERC1155OnChain.sol"; +import "@skalenetwork/ima-interfaces/schain/tokens/IERC1155OnChain.sol"; /** diff --git a/proxy/contracts/schain/tokens/ERC20OnChain.sol b/proxy/contracts/schain/tokens/ERC20OnChain.sol index e763490c5..e20ed2a5d 100644 --- a/proxy/contracts/schain/tokens/ERC20OnChain.sol +++ b/proxy/contracts/schain/tokens/ERC20OnChain.sol @@ -24,7 +24,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "../../interfaces/schain/tokens/IERC20OnChain.sol"; +import "@skalenetwork/ima-interfaces/schain/tokens/IERC20OnChain.sol"; /** diff --git a/proxy/contracts/schain/tokens/ERC721OnChain.sol b/proxy/contracts/schain/tokens/ERC721OnChain.sol index fbf82766e..98a1ec32f 100644 --- a/proxy/contracts/schain/tokens/ERC721OnChain.sol +++ b/proxy/contracts/schain/tokens/ERC721OnChain.sol @@ -25,7 +25,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; -import "../../interfaces/schain/tokens/IERC721OnChain.sol"; +import "@skalenetwork/ima-interfaces/schain/tokens/IERC721OnChain.sol"; /** diff --git a/proxy/contracts/schain/tokens/EthErc20.sol b/proxy/contracts/schain/tokens/EthErc20.sol index 99d5dc77e..6478fe430 100644 --- a/proxy/contracts/schain/tokens/EthErc20.sol +++ b/proxy/contracts/schain/tokens/EthErc20.sol @@ -23,7 +23,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol"; -import "../../interfaces/schain/tokens/IEthErc20.sol"; +import "@skalenetwork/ima-interfaces/schain/tokens/IEthErc20.sol"; /** diff --git a/proxy/contracts/test/FallbackEthTester.sol b/proxy/contracts/test/FallbackEthTester.sol index 96f9c35f9..296b97a27 100644 --- a/proxy/contracts/test/FallbackEthTester.sol +++ b/proxy/contracts/test/FallbackEthTester.sol @@ -22,8 +22,8 @@ pragma solidity 0.8.6; -import "../interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; -import "../interfaces/mainnet/ICommunityPool.sol"; +import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxEth.sol"; +import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; interface IFallbackEthTester { receive() external payable; diff --git a/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol b/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol index 943ca188d..eed7d733e 100644 --- a/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol +++ b/proxy/contracts/test/ReceiverGasLimitMainnetMock.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "../interfaces/IMessageReceiver.sol"; +import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; contract ReceiverGasLimitMainnetMock is IMessageReceiver { diff --git a/proxy/contracts/test/ReceiverGasLimitSchainMock.sol b/proxy/contracts/test/ReceiverGasLimitSchainMock.sol index 04b443a3d..65b8d6eb4 100644 --- a/proxy/contracts/test/ReceiverGasLimitSchainMock.sol +++ b/proxy/contracts/test/ReceiverGasLimitSchainMock.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "../interfaces/IMessageReceiver.sol"; +import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; contract ReceiverGasLimitSchainMock is IMessageReceiver { diff --git a/proxy/contracts/test/ReceiverMock.sol b/proxy/contracts/test/ReceiverMock.sol index 6b6798738..1c93bf76c 100644 --- a/proxy/contracts/test/ReceiverMock.sol +++ b/proxy/contracts/test/ReceiverMock.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "../interfaces/IMessageReceiver.sol"; +import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; contract ReceiverMock is IMessageReceiver { diff --git a/proxy/contracts/test/TestCallReceiverContract.sol b/proxy/contracts/test/TestCallReceiverContract.sol index fb47f32e0..d8570351e 100644 --- a/proxy/contracts/test/TestCallReceiverContract.sol +++ b/proxy/contracts/test/TestCallReceiverContract.sol @@ -22,7 +22,7 @@ pragma solidity 0.8.6; -import "../interfaces/IMessageReceiver.sol"; +import "@skalenetwork/ima-interfaces/IMessageReceiver.sol"; contract TestCallReceiverContract is IMessageReceiver { diff --git a/proxy/interfaces/package.json b/proxy/interfaces/package.json deleted file mode 100644 index 4b5f5dc71..000000000 --- a/proxy/interfaces/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@skalenetwork/ima-interfaces", - "description": "Definitions of interfaces needed to integrate with IMA smart contracts", - "main": "index.js", - "repository": "git@github.com:skalenetwork/IMA.git", - "author": "Artem Payvin ", - "license": "AGPL-3.0", - "files": [ - "**/*.sol" - ] -} diff --git a/proxy/interfaces/publish_package.sh b/proxy/interfaces/publish_package.sh deleted file mode 100755 index 9e6649bdf..000000000 --- a/proxy/interfaces/publish_package.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -set -e - -USAGE_MSG='Usage: BRANCH=[BRANCH] publish_package.sh' -if [ -z "$BRANCH" ] -then - (>&2 echo 'You should provide branch') - echo "$USAGE_MSG" - exit 1 -fi - -SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -ROOT_DIR="$(dirname "$SCRIPT_DIR")" -INTERFACES_DIR="$ROOT_DIR/contracts/interfaces" - -cd "$ROOT_DIR" - -BRANCH="$(echo "$BRANCH" | tr [:upper:] [:lower:] | tr -d [:space:])" -VERSION="$(BRANCH="$BRANCH" "$ROOT_DIR/predeployed/scripts/calculate_version.sh")" - -TAG="" -if ! [[ $BRANCH == 'stable' ]] -then - TAG="--tag $BRANCH" -fi - -if [[ "$VERSION" == *-stable.0 ]] -then - VERSION=${VERSION%-stable.0} -fi - -echo "Using $VERSION as a new version" - -cp LICENSE "$INTERFACES_DIR" -cp README.md "$INTERFACES_DIR" -cp "$ROOT_DIR/interfaces/package.json" "$INTERFACES_DIR" - -yarn publish "$INTERFACES_DIR" --access public --new-version "$VERSION" --verbose --no-git-tag-version "$TAG" --ignore-scripts diff --git a/proxy/package.json b/proxy/package.json index e55f88909..1359f5185 100644 --- a/proxy/package.json +++ b/proxy/package.json @@ -24,6 +24,7 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/contracts-upgradeable": "^4.3.2", "@openzeppelin/hardhat-upgrades": "^1.9.0", + "@skalenetwork/ima-interfaces": "1.0.0-fix-agent-authorized-interfaces.0", "@skalenetwork/etherbase-interfaces": "^0.0.1-develop.20", "@skalenetwork/skale-manager-interfaces": "1.0.0-develop.1", "axios": "^0.21.4", diff --git a/proxy/yarn.lock b/proxy/yarn.lock index 57520e74b..8a7755d61 100644 --- a/proxy/yarn.lock +++ b/proxy/yarn.lock @@ -757,11 +757,23 @@ resolved "https://registry.yarnpkg.com/@skalenetwork/etherbase-interfaces/-/etherbase-interfaces-0.0.1-develop.20.tgz#33f61e18d695fd47063aa39dce4df335d26b9528" integrity sha512-j3xnuQtOtjvjAoUMJgSUFxRa9/Egkg1RyA8r6PjcEb33VksE4LWLBy0PNFUFehLZv48595JROTcViGeXXwg5HQ== +"@skalenetwork/ima-interfaces@1.0.0-fix-agent-authorized-interfaces.0": + version "1.0.0-fix-agent-authorized-interfaces.0" + resolved "https://registry.yarnpkg.com/@skalenetwork/ima-interfaces/-/ima-interfaces-1.0.0-fix-agent-authorized-interfaces.0.tgz#2b08c82f2e0c102cb05bc1b0be7c9447a236122f" + integrity sha512-qmYwLDwaBFZe4JQtXbGSkVFQ6UeMHwb0OLiT4USq6xpPz69MLsVJPbQXLfrh/EAED2Kz/fG/CHUCDYPsoo1Now== + dependencies: + "@skalenetwork/skale-manager-interfaces" "^0.1.2" + "@skalenetwork/skale-manager-interfaces@1.0.0-develop.1": version "1.0.0-develop.1" resolved "https://registry.yarnpkg.com/@skalenetwork/skale-manager-interfaces/-/skale-manager-interfaces-1.0.0-develop.1.tgz#8a2d06872dcdc235c041448efc454c0d5f1e55cf" integrity sha512-ZOSWEqvz76Ez5cuWE8n9+j/tnTVQg+t7vaZar/XME0hxnM1YwNFqy34nqjEC/SMhFXg/WnxdOVX9JWWXVZRlkQ== +"@skalenetwork/skale-manager-interfaces@^0.1.2": + version "0.1.2" + resolved "https://registry.yarnpkg.com/@skalenetwork/skale-manager-interfaces/-/skale-manager-interfaces-0.1.2.tgz#88e543c8cc298cd0cc9559892d746d2d74786da8" + integrity sha512-gapSQJahwWMlTB/xp/kMzB6k+9+Skx/N0fvEloiW4CUrkGkSa8+fj16YmUXX45p1hOc45W+JydiJPNgZtx32Dg== + "@solidity-parser/parser@^0.11.0": version "0.11.1" resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.11.1.tgz#fa840af64840c930f24a9c82c08d4a092a068add" From b90f0a3e5e830b6ee3c1d4a8d00cf5ad95084028 Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Fri, 17 Jun 2022 07:16:37 +0100 Subject: [PATCH 09/11] Fix diff and clean --- .../ERC721ReferenceMintAndMetadataMainnet.sol | 6 ++---- .../ERC721ReferenceMintAndMetadataSchain.sol | 14 ++------------ .../extensions/interfaces/MessageProxyClient.sol | 6 +++--- proxy/contracts/mainnet/CommunityPool.sol | 2 +- .../mainnet/DepositBoxes/DepositBoxERC721.sol | 2 +- proxy/contracts/mainnet/MessageProxyForMainnet.sol | 2 +- proxy/contracts/schain/MessageProxyForSchain.sol | 2 +- proxy/package.json | 2 +- .../utils/skale-manager-utils/contractManager.ts | 7 ------- proxy/test/utils/skale-manager-utils/nodes.ts | 14 ++------------ .../utils/skale-manager-utils/schainsInternal.ts | 8 ++++---- 11 files changed, 18 insertions(+), 47 deletions(-) diff --git a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol index 01ee7b617..b3d3a25e7 100644 --- a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol +++ b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataMainnet.sol @@ -21,13 +21,11 @@ pragma solidity 0.8.6; +import "@skalenetwork/ima-interfaces/extensions/IERC721ReferenceMintAndMetadataMainnet.sol"; + import "../schain/tokens/ERC721OnChain.sol"; import "./interfaces/MessageReceiver.sol"; -interface IERC721ReferenceMintAndMetadataMainnet { - function setSenderContractOnSchain(address newSenderContractOnSchain) external; -} - // This contract runs on the main net and accepts deposits contract ERC721ReferenceMintAndMetadataMainnet is MessageReceiver, IERC721ReferenceMintAndMetadataMainnet { diff --git a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol index 6179f3a42..ae1fd91b3 100644 --- a/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol +++ b/proxy/contracts/extensions/ERC721ReferenceMintAndMetadataSchain.sol @@ -21,21 +21,11 @@ pragma solidity 0.8.6; +import "@skalenetwork/ima-interfaces/extensions/IERC721ReferenceMintAndMetadataSchain.sol"; + import "../schain/tokens/ERC721OnChain.sol"; import "./interfaces/MessageSender.sol"; -interface IERC721ReferenceMintAndMetadataSchain { - function sendTokenToMainnet(address receiver, uint256 tokenId) external; - function encodeParams( - address receiver, - uint256 tokenId, - string memory tokenURI - ) - external - pure - returns (bytes memory data); -} - /** * @title Token Manager diff --git a/proxy/contracts/extensions/interfaces/MessageProxyClient.sol b/proxy/contracts/extensions/interfaces/MessageProxyClient.sol index 932004f15..ba8ebd894 100644 --- a/proxy/contracts/extensions/interfaces/MessageProxyClient.sol +++ b/proxy/contracts/extensions/interfaces/MessageProxyClient.sol @@ -21,10 +21,10 @@ pragma solidity 0.8.6; -import "@skalenetwork/ima-interfaces/IMessageProxy.sol"; +import "../../MessageProxy.sol"; abstract contract MessageProxyClient { - IMessageProxy public messageProxy; + MessageProxy public messageProxy; modifier onlyMessageProxy() { require(msg.sender == address(messageProxy), "Sender is not a message proxy"); @@ -32,6 +32,6 @@ abstract contract MessageProxyClient { } constructor(address newMessageProxyAddress) { - messageProxy = IMessageProxy(newMessageProxyAddress); + messageProxy = MessageProxy(newMessageProxyAddress); } } \ No newline at end of file diff --git a/proxy/contracts/mainnet/CommunityPool.sol b/proxy/contracts/mainnet/CommunityPool.sol index 5808b265e..153337635 100644 --- a/proxy/contracts/mainnet/CommunityPool.sol +++ b/proxy/contracts/mainnet/CommunityPool.sol @@ -23,8 +23,8 @@ pragma solidity 0.8.6; -import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; +import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; import "../Messages.sol"; import "./Twin.sol"; diff --git a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol index 29d1de65c..9fea45a1e 100644 --- a/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol +++ b/proxy/contracts/mainnet/DepositBoxes/DepositBoxERC721.sol @@ -23,8 +23,8 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "@skalenetwork/ima-interfaces/mainnet/DepositBoxes/IDepositBoxERC721.sol"; +import "@openzeppelin/contracts-upgradeable/utils/structs/EnumerableSetUpgradeable.sol"; import "../DepositBox.sol"; import "../../Messages.sol"; diff --git a/proxy/contracts/mainnet/MessageProxyForMainnet.sol b/proxy/contracts/mainnet/MessageProxyForMainnet.sol index 8f3358d0e..ec5eac130 100644 --- a/proxy/contracts/mainnet/MessageProxyForMainnet.sol +++ b/proxy/contracts/mainnet/MessageProxyForMainnet.sol @@ -24,9 +24,9 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@skalenetwork/skale-manager-interfaces/IWallets.sol"; import "@skalenetwork/skale-manager-interfaces/ISchains.sol"; -import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol"; import "@skalenetwork/ima-interfaces/mainnet/IMessageProxyForMainnet.sol"; import "@skalenetwork/ima-interfaces/mainnet/ICommunityPool.sol"; +import "@skalenetwork/skale-manager-interfaces/ISchainsInternal.sol"; import "../MessageProxy.sol"; diff --git a/proxy/contracts/schain/MessageProxyForSchain.sol b/proxy/contracts/schain/MessageProxyForSchain.sol index 69bcb2ac8..bc34bf823 100644 --- a/proxy/contracts/schain/MessageProxyForSchain.sol +++ b/proxy/contracts/schain/MessageProxyForSchain.sol @@ -22,8 +22,8 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; -import "@skalenetwork/etherbase-interfaces/IEtherbaseUpgradeable.sol"; import "@skalenetwork/ima-interfaces/schain/IMessageProxyForSchain.sol"; +import "@skalenetwork/etherbase-interfaces/IEtherbaseUpgradeable.sol"; import "../MessageProxy.sol"; import "./bls/SkaleVerifier.sol"; diff --git a/proxy/package.json b/proxy/package.json index 1359f5185..249812c63 100644 --- a/proxy/package.json +++ b/proxy/package.json @@ -24,8 +24,8 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/contracts-upgradeable": "^4.3.2", "@openzeppelin/hardhat-upgrades": "^1.9.0", - "@skalenetwork/ima-interfaces": "1.0.0-fix-agent-authorized-interfaces.0", "@skalenetwork/etherbase-interfaces": "^0.0.1-develop.20", + "@skalenetwork/ima-interfaces": "1.0.0-fix-agent-authorized-interfaces.0", "@skalenetwork/skale-manager-interfaces": "1.0.0-develop.1", "axios": "^0.21.4", "dotenv": "^10.0.0", diff --git a/proxy/test/utils/skale-manager-utils/contractManager.ts b/proxy/test/utils/skale-manager-utils/contractManager.ts index 8c142e87f..45dc1d9cf 100644 --- a/proxy/test/utils/skale-manager-utils/contractManager.ts +++ b/proxy/test/utils/skale-manager-utils/contractManager.ts @@ -2,13 +2,6 @@ import { Wallet } from "@ethersproject/wallet"; import { ethers } from "hardhat"; import { ContractManager, KeyStorageMock, Nodes, Schains, SchainsInternal, SkaleVerifierMock, Wallets } from "../../../typechain"; -// const contractManager: ContractManagerContract = artifacts.require("./ContractManager"); -// const keyStorage: KeyStorageContract = artifacts.require("./KeyStorage"); -// const nodes: NodesContract = artifacts.require("./Nodes"); -// const schains: SchainsContract = artifacts.require("./Schains"); -// const schainsInternal: SchainsInternalContract = artifacts.require("./SchainsInternal"); -// const skaleVerifier: SkaleVerifierMockContract = artifacts.require("./SkaleVerifierMock"); -// const wallets: WalletsContract = artifacts.require("./Wallets"); const nameNodes = "Nodes"; const nameSchains = "Schains"; const nameSchainsInternal = "SchainsInternal"; diff --git a/proxy/test/utils/skale-manager-utils/nodes.ts b/proxy/test/utils/skale-manager-utils/nodes.ts index fd2c7cfe3..d0314a2f5 100644 --- a/proxy/test/utils/skale-manager-utils/nodes.ts +++ b/proxy/test/utils/skale-manager-utils/nodes.ts @@ -4,16 +4,6 @@ import { BytesLike } from "ethers"; const nameNodes = "Nodes"; -// const nodeCreationParams = { -// port: 1337, -// nonce: 1337, -// ip: "0x12345678", -// publicIp: "0x12345678", -// publicKey: getPublicKey(nodeAddress), -// name: "GasCalculationNode", -// domainName: "gascalculationnode.com" -// }; - type NodeCreationParams = { port: number; nonce: number; @@ -29,8 +19,8 @@ export async function createNode( from: string, nodeCreationParams: NodeCreationParams ) { - const nodesFactory = await ethers.getContractFactory("Nodes"); - const nodesAddres = await contractManager.getContract("Nodes"); + const nodesFactory = await ethers.getContractFactory(nameNodes); + const nodesAddres = await contractManager.getContract(nameNodes); const nodes = nodesFactory.attach(nodesAddres) as Nodes; await nodes.createNode(from, nodeCreationParams); } diff --git a/proxy/test/utils/skale-manager-utils/schainsInternal.ts b/proxy/test/utils/skale-manager-utils/schainsInternal.ts index d40fc927d..2ff58ba52 100644 --- a/proxy/test/utils/skale-manager-utils/schainsInternal.ts +++ b/proxy/test/utils/skale-manager-utils/schainsInternal.ts @@ -10,8 +10,8 @@ export async function initializeSchain( lifetime: number, deposit: number ) { - const schainsInternalFactory = await ethers.getContractFactory("SchainsInternal"); - const schainsInternalAddres = await contractManager.getContract("SchainsInternal"); + const schainsInternalFactory = await ethers.getContractFactory(nameSchainsInternal); + const schainsInternalAddres = await contractManager.getContract(nameSchainsInternal); const schainsInternal = schainsInternalFactory.attach(schainsInternalAddres) as SchainsInternal; await schainsInternal.initializeSchain(schainName, owner, lifetime, deposit); } @@ -21,8 +21,8 @@ export async function addNodesToSchain( schainName: string, nodes: number[] ) { - const schainsInternalFactory = await ethers.getContractFactory("SchainsInternal"); - const schainsInternalAddres = await contractManager.getContract("SchainsInternal"); + const schainsInternalFactory = await ethers.getContractFactory(nameSchainsInternal); + const schainsInternalAddres = await contractManager.getContract(nameSchainsInternal); const schainsInternal = schainsInternalFactory.attach(schainsInternalAddres) as SchainsInternal; await schainsInternal.addNodesToSchainsGroups(ethers.utils.id(schainName), nodes); } From bc0d211c3b546a7b9dd0af9bc2c71b12072c0944 Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Fri, 17 Jun 2022 07:19:28 +0100 Subject: [PATCH 10/11] Clean comments --- proxy/contracts/test/TestSchainsInternal.sol | 6 ------ proxy/test/DepositBoxEth.ts | 2 -- 2 files changed, 8 deletions(-) diff --git a/proxy/contracts/test/TestSchainsInternal.sol b/proxy/contracts/test/TestSchainsInternal.sol index efbc9bfcd..80960bfa2 100644 --- a/proxy/contracts/test/TestSchainsInternal.sol +++ b/proxy/contracts/test/TestSchainsInternal.sol @@ -101,12 +101,6 @@ contract SchainsInternal is ISchainsInternalTester { } function isNodeAddressesInGroup(bytes32 schainHash, address sender) external view override returns (bool) { - // Nodes nodes = Nodes(contractManager.getContract("Nodes")); - // for (uint i = 0; i < schainsGroups[schainHash].length; i++) { - // if (!nodes.isNodeExist(sender, schainsGroups[schainHash][i])) { - // return true; - // } - // } return _nodeAddressInSchain[schainHash][sender]; } diff --git a/proxy/test/DepositBoxEth.ts b/proxy/test/DepositBoxEth.ts index 4d5322fa6..c94071b76 100644 --- a/proxy/test/DepositBoxEth.ts +++ b/proxy/test/DepositBoxEth.ts @@ -192,7 +192,6 @@ describe("DepositBoxEth", () => { await depositBoxEth .connect(deployer) .deposit(schainName, { value: wei }); - // console.log("Gas for deposit:", tx.receipt.gasUsed); const lockAndDataBalance = await web3.eth.getBalance(depositBoxEth.address); // expectation @@ -284,7 +283,6 @@ describe("DepositBoxEth", () => { // execution const res = await (await messageProxy.connect(nodeAddress).postIncomingMessages(schainName, 0, [message], sign)).wait(); - // console.log(res.logs); if (res.events) { assert.equal(res.events[0].event, "PostMessageError"); assert.equal(res.events[0].args?.msgCounter.toString(), "0"); From ff15f79bb8fc4ad3b2f0e3ecc0e0d56ca1574185 Mon Sep 17 00:00:00 2001 From: Artem Payvin Date: Fri, 24 Jun 2022 10:32:06 +0100 Subject: [PATCH 11/11] Add version --- proxy/package.json | 2 +- proxy/yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proxy/package.json b/proxy/package.json index 249812c63..dd6b749c2 100644 --- a/proxy/package.json +++ b/proxy/package.json @@ -25,7 +25,7 @@ "@openzeppelin/contracts-upgradeable": "^4.3.2", "@openzeppelin/hardhat-upgrades": "^1.9.0", "@skalenetwork/etherbase-interfaces": "^0.0.1-develop.20", - "@skalenetwork/ima-interfaces": "1.0.0-fix-agent-authorized-interfaces.0", + "@skalenetwork/ima-interfaces": "1.0.0-develop.17", "@skalenetwork/skale-manager-interfaces": "1.0.0-develop.1", "axios": "^0.21.4", "dotenv": "^10.0.0", diff --git a/proxy/yarn.lock b/proxy/yarn.lock index 8a7755d61..56b239b1a 100644 --- a/proxy/yarn.lock +++ b/proxy/yarn.lock @@ -757,10 +757,10 @@ resolved "https://registry.yarnpkg.com/@skalenetwork/etherbase-interfaces/-/etherbase-interfaces-0.0.1-develop.20.tgz#33f61e18d695fd47063aa39dce4df335d26b9528" integrity sha512-j3xnuQtOtjvjAoUMJgSUFxRa9/Egkg1RyA8r6PjcEb33VksE4LWLBy0PNFUFehLZv48595JROTcViGeXXwg5HQ== -"@skalenetwork/ima-interfaces@1.0.0-fix-agent-authorized-interfaces.0": - version "1.0.0-fix-agent-authorized-interfaces.0" - resolved "https://registry.yarnpkg.com/@skalenetwork/ima-interfaces/-/ima-interfaces-1.0.0-fix-agent-authorized-interfaces.0.tgz#2b08c82f2e0c102cb05bc1b0be7c9447a236122f" - integrity sha512-qmYwLDwaBFZe4JQtXbGSkVFQ6UeMHwb0OLiT4USq6xpPz69MLsVJPbQXLfrh/EAED2Kz/fG/CHUCDYPsoo1Now== +"@skalenetwork/ima-interfaces@1.0.0-develop.17": + version "1.0.0-develop.17" + resolved "https://registry.yarnpkg.com/@skalenetwork/ima-interfaces/-/ima-interfaces-1.0.0-develop.17.tgz#e2650b43a056962e62127fe787577db96d9766d3" + integrity sha512-x1LEQF4dNklotJNCIRl4wfq9R6N8yeX0ZBe38yiBpKPgIX++R3pBF/gPl6HGK6l5xSp0bOQgzw59fzYdjnZP5A== dependencies: "@skalenetwork/skale-manager-interfaces" "^0.1.2"