Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept xToken owner and upgrade to new messager #12

Merged
merged 6 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@
"ecb9a2d5bf63b21013524697f08bc7f6": {
"id": "ecb9a2d5bf63b21013524697f08bc7f6",
"solcVersion": "0.8.17",
"solcLongVersion": "0.8.17",
"solcLongVersion": "0.8.17+commit.8df45f5f",
"input": {
"language": "Solidity",
"sources": {
Expand Down Expand Up @@ -813,7 +813,7 @@
"inputs": [
{
"solcVersion": "0.8.17",
"solcLongVersion": "0.8.17",
"solcLongVersion": "0.8.17+commit.8df45f5f",
"id": "ecb9a2d5bf63b21013524697f08bc7f6",
"input": {
"language": "Solidity",
Expand Down Expand Up @@ -6456,4 +6456,4 @@
"buildInfoId": "ecb9a2d5bf63b21013524697f08bc7f6"
}
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"signer": "0x0f14341a7f464320319025540e8fe48ad0fe5aec",
"signature": "0x56c9f2b3a77279688cf079198351b49084858408240ece9d9d61548cd2d990f87f9e740c79eec4068f8fccab9eacff19b1200cad6bdbdee3654963a4c303567e1c"
},
{
"signer": "0x9F33a4809aA708d7a399fedBa514e0A0d15EfA85",
"signature": "0x591f7084ecfad8f70e9859e49358738fb2cc273d0192bcd29dbbc3305bae75742b09bdfc153d82481b6994ac26d9fc456166589c7c54bc070be2ad4da88269c21c"
},
{
"signer": "0x53405FB4d71591E33fe07bFbC90bD82E65720ad0",
"signature": "0xdda79a0cc93458c914e949a35855a1a5a1c17c5a3cf4f9b6e77f5876148e3b0d38919e07b1ad22b902d694e83aed4435201075dac4b1bfa532d34461953e19381b"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -1940,7 +1940,7 @@
"522074bb77d1035acef60d9b20c041da": {
"id": "522074bb77d1035acef60d9b20c041da",
"solcVersion": "0.8.17",
"solcLongVersion": "0.8.17",
"solcLongVersion": "0.8.17+commit.8df45f5f",
"input": {
"language": "Solidity",
"sources": {
Expand Down Expand Up @@ -2318,7 +2318,7 @@
"inputs": [
{
"solcVersion": "0.8.17",
"solcLongVersion": "0.8.17",
"solcLongVersion": "0.8.17+commit.8df45f5f",
"id": "522074bb77d1035acef60d9b20c041da",
"input": {
"language": "Solidity",
Expand Down Expand Up @@ -9747,4 +9747,4 @@
"buildInfoId": "522074bb77d1035acef60d9b20c041da"
}
}
}
}
2 changes: 1 addition & 1 deletion script/Proposal.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "./ring-dao/Config.s.sol";
import "./x-token/Config.s.sol";

contract Proposal is ConfigScript {}
2 changes: 1 addition & 1 deletion script/common/Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract contract Base is Script, Sphinx, SphinxConstants {
function configureSphinx() public override {
sphinxConfig.projectName = "RING-DAO";
sphinxConfig.testnets = ["darwinia_koi"];
// sphinxConfig.mainnets = ["ethereum", "darwinia", "crab", "arbitrum", "blast", "polygon", "moonbeam"];
sphinxConfig.mainnets = ["ethereum", "darwinia"];
}

function CREATE3() public returns (address create3) {
Expand Down
2 changes: 0 additions & 2 deletions script/ring-dao/Config.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
pragma solidity 0.8.17;

import {Base} from "../common/Base.sol";
import {TomlTools} from "../common/TomlTools.sol";
import {stdJson} from "forge-std/StdJson.sol";

import "@openzeppelin/contracts/access/IAccessControl.sol";

Expand Down
70 changes: 70 additions & 0 deletions script/x-token/Config.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import {Base} from "../common/Base.sol";

interface XTokenBase {
struct MessagerService {
address sendService;
address receiveService;
}

function setSendService(uint256 remoteChainId, address remoteBridge, address service) external;
function setReceiveService(uint256 remoteChainId, address remoteBridge, address service) external;
function messagers(uint256) external view returns (MessagerService memory);
}

interface IOwnership {
function dao() external view returns (address);
function pendingDao() external view returns (address);
function acceptOwnership() external;
}

contract ConfigScript is Base {
address backingAddress = 0x2B496f19A420C02490dB859fefeCCD71eDc2c046;
address issuingAddress = 0xDc0C760c0fB4672D06088515F6446a71Df0c64C1;
address oldMessagerOnDarwinia = 0x65Be094765731F394bc6d9DF53bDF3376F1Fc8B0;
address oldMessagerOnEthereum = 0x65Be094765731F394bc6d9DF53bDF3376F1Fc8B0;
address newMessagerOnDarwinia = 0x682294D1c00A9CA13290b53B7544b8F734D6501f;
address newMessagerOnEthereum = 0x02e5C0a36Fb0C83CCEBCD4D6177A7E223D6f0b7c;

uint256 ETHEREUM_CHAINID = 1;
uint256 DARWINIA_CHAINID = 46;

function run() public sphinx {
address dao = safeAddress();
if (block.chainid == DARWINIA_CHAINID) {
if (IOwnership(backingAddress).pendingDao() == dao) {
IOwnership(backingAddress).acceptOwnership();
}

if (IOwnership(newMessagerOnDarwinia).pendingDao() == dao) {
IOwnership(newMessagerOnDarwinia).acceptOwnership();
}

XTokenBase backing = XTokenBase(backingAddress);
require(backing.messagers(ETHEREUM_CHAINID).sendService == oldMessagerOnDarwinia, "!oldMessager");
require(backing.messagers(ETHEREUM_CHAINID).receiveService == oldMessagerOnDarwinia, "!oldMessager");
backing.setSendService(ETHEREUM_CHAINID, issuingAddress, newMessagerOnDarwinia);
backing.setReceiveService(ETHEREUM_CHAINID, issuingAddress, newMessagerOnDarwinia);
require(backing.messagers(ETHEREUM_CHAINID).sendService == newMessagerOnDarwinia, "!newMessager");
require(backing.messagers(ETHEREUM_CHAINID).receiveService == newMessagerOnDarwinia, "!newMessager");
} else if (block.chainid == ETHEREUM_CHAINID) {
if (IOwnership(issuingAddress).pendingDao() == dao) {
IOwnership(issuingAddress).acceptOwnership();
}

if (IOwnership(newMessagerOnEthereum).pendingDao() == dao) {
IOwnership(newMessagerOnEthereum).acceptOwnership();
}

XTokenBase issuing = XTokenBase(issuingAddress);
require(issuing.messagers(DARWINIA_CHAINID).sendService == oldMessagerOnEthereum, "!oldMessager");
require(issuing.messagers(DARWINIA_CHAINID).receiveService == oldMessagerOnEthereum, "!oldMessager");
issuing.setSendService(DARWINIA_CHAINID, backingAddress, newMessagerOnEthereum);
issuing.setReceiveService(DARWINIA_CHAINID, backingAddress, newMessagerOnEthereum);
require(issuing.messagers(DARWINIA_CHAINID).sendService == newMessagerOnEthereum, "!newMessager");
require(issuing.messagers(DARWINIA_CHAINID).receiveService == newMessagerOnEthereum, "!newMessager");
}
}
}
Loading