Skip to content

Feature/gbi 1417 add fee collector address #378

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

Open
wants to merge 4 commits into
base: QA-Test
Choose a base branch
from
Open
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
1,356 changes: 1,356 additions & 0 deletions bridge/abi/BridgeV4.json

Large diffs are not rendered by default.

514 changes: 514 additions & 0 deletions bridge/contracts/Bridge/BridgeV4.sol

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions bridge/contracts/Bridge/IBridgeV4.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IBridgeV4 {

struct ClaimData {
address payable to;
uint256 amount;
bytes32 blockHash;
bytes32 transactionHash;
uint32 logIndex;
}

function version() external pure returns (string memory);

function getFeePercentage() external view returns(uint);

/**
* ERC-20 tokens approve and transferFrom pattern
* See https://eips.ethereum.org/EIPS/eip-20#transferfrom
*/
function receiveTokensTo(address tokenToUse, address to, uint256 amount) external;

/**
* Use network currency and cross it.
*/
function depositTo(address to) external payable;

/**
* ERC-777 tokensReceived hook allows to send tokens to a contract and notify it in a single transaction
* See https://eips.ethereum.org/EIPS/eip-777#motivation for details
*/
function tokensReceived (
address operator,
address from,
address to,
uint amount,
bytes calldata userData,
bytes calldata operatorData
) external;

/**
* Accepts the transaction from the other chain that was voted and sent by the Federation contract
*/
function acceptTransfer(
address _originalTokenAddress,
address payable _from,
address payable _to,
uint256 _amount,
bytes32 _blockHash,
bytes32 _transactionHash,
uint32 _logIndex
) external;

/**
* Claims the crossed transaction using the hash, this sends the funds to the address indicated in
*/
function claim(ClaimData calldata _claimData) external returns (uint256 receivedAmount);

function claimFallback(ClaimData calldata _claimData) external returns (uint256 receivedAmount);

function claimGasless(
ClaimData calldata _claimData,
address payable _relayer,
uint256 _fee,
uint256 _deadline,
uint8 _v,
bytes32 _r,
bytes32 _s
) external returns (uint256 receivedAmount);

function getTransactionDataHash(
address _to,
uint256 _amount,
bytes32 _blockHash,
bytes32 _transactionHash,
uint32 _logIndex
) external returns(bytes32);

event Cross(
address indexed _tokenAddress,
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _userData
);
event NewSideToken(
address indexed _newSideTokenAddress,
address indexed _originalTokenAddress,
string _newSymbol,
uint256 _granularity
);
event AcceptedCrossTransfer(
bytes32 indexed _transactionHash,
address indexed _originalTokenAddress,
address indexed _to,
address _from,
uint256 _amount,
bytes32 _blockHash,
uint256 _logIndex
);
event FeePercentageChanged(uint256 _amount);
event Claimed(
bytes32 indexed _transactionHash,
address indexed _originalTokenAddress,
address indexed _to,
address _sender,
uint256 _amount,
bytes32 _blockHash,
uint256 _logIndex,
address _reciever,
address _relayer,
uint256 _fee
);
}
10 changes: 5 additions & 5 deletions bridge/deploy/04_deploy_bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
const {deployments, network} = hre;
const {deployer} = await getNamedAccounts();
const {deploy, log} = deployments;
const BRIDGE_LAST_VERSION = 'v3'
const BRIDGE_LAST_VERSION = 'v4'

const bridgeProxyAddress = await address.getBridgeProxyAddress(hre);
if (bridgeProxyAddress) {
const Bridge = await deployments.getArtifact('BridgeV3');
const Bridge = await deployments.getArtifact('BridgeV4');
const bridge = new web3.eth.Contract(Bridge.abi, bridgeProxyAddress);
const currentBridgeVersion = bridge.methods.version().call();
const currentBridgeVersion = bridge.methods.version().send();
if (currentBridgeVersion === BRIDGE_LAST_VERSION) {
return;
}
}

const deployResult = await deploy('BridgeV3', {
const deployResult = await deploy('BridgeV4', {
from: deployer,
log: true,
});
Expand All @@ -35,4 +35,4 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
}
};
module.exports.id = 'deploy_bridge'; // id required to prevent reexecution
module.exports.tags = ['BridgeV3', 'Upgrade', 'DeployFromScratch', 'IntegrationTest'];
module.exports.tags = ['BridgeV4', 'Upgrade', 'DeployFromScratch', 'IntegrationTest'];
11 changes: 8 additions & 3 deletions bridge/deploy/05_deploy_bridgeProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,25 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
return;
}

const Bridge = await deployments.get('BridgeV3');
const Bridge = await deployments.get('BridgeV4');
const multiSigAddress = await address.getMultiSigAddress(hre);
const proxyAdminAddress = await address.getProxyAdminAddress(hre);
const sideTokenFactoryAddress = await address.getSideTokenFactoryAddress(hre);

const bridge = new web3.eth.Contract(Bridge.abi, Bridge.address);

const methodCall = bridge.methods.initialize(
multiSigAddress,
deployer,
deployer,
sideTokenFactoryAddress,
'r'
);
await methodCall.call({ from: deployer })
try {
await methodCall.send({ from: deployer })
} catch (error) {
throw error;
}

const constructorArguments = [
Bridge.address,
Expand Down Expand Up @@ -51,4 +56,4 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
};
module.exports.id = 'deploy_bridge_proxy'; // id required to prevent reexecution
module.exports.tags = ['BridgeProxy', 'DeployFromScratch', 'IntegrationTest'];
module.exports.dependencies = ['BridgeV3', 'MultiSigWallet', 'ProxyAdmin', 'SideTokenFactory'];
module.exports.dependencies = ['BridgeV4', 'MultiSigWallet', 'ProxyAdmin', 'SideTokenFactory'];
2 changes: 1 addition & 1 deletion bridge/deploy/06_deploy_federation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
if (federationProxyAddress) {
const Federation = await deployments.getArtifact('FederationV2');
const federation = new web3.eth.Contract(Federation.abi, federationProxyAddress);
const currentFederationVersion = federation.methods.version().call();
const currentFederationVersion = federation.methods.version().send();
if (currentFederationVersion === FEDERATION_LAST_VERSION) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions bridge/deploy/07_deploy_federationProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
bridgeProxyAddress,
multiSigAddress,
);
methodCall.call({from: deployer});
methodCall.send({from: deployer});

const constructorArguments = [
Federation.address,
Expand Down Expand Up @@ -82,4 +82,4 @@ function getFederationConf(deployer, network) {
members: [deployer],
required: 1,
};
}
}
2 changes: 1 addition & 1 deletion bridge/deploy/08_deploy_allowToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
if (allowTokensProxyAddress) {
const AllowTokens = await deployments.getArtifact('AllowTokens');
const allowTokens = new web3.eth.Contract(AllowTokens.abi, allowTokensProxyAddress);
const currentAllowTokensVersion = allowTokens.methods.version().call();
const currentAllowTokensVersion = allowTokens.methods.version().send();
if (currentAllowTokensVersion === ALLOW_TOKEN_LAST_VERSION) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion bridge/deploy/09_deploy_allowTokensProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
deployedJson.largeAmountConfirmations ?? '0',
typesInfo
);
methodCall.call({from: deployer});
methodCall.send({from: deployer});

const constructorArguments = [
AllowTokens.address,
Expand Down
2 changes: 1 addition & 1 deletion bridge/deploy/10_transfer_setTokens_allowTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = async function(hre) { // HardhatRuntimeEnvironment
const allowTokens = new web3.eth.Contract(AllowTokens.abi, AllowTokensProxy.address);
const multiSigAddress = await address.getMultiSigAddress(hre);

const owner = await allowTokens.methods.owner().call({from: deployer});
const owner = await allowTokens.methods.owner().send({from: deployer});
if (owner === multiSigAddress) {
return
}
Expand Down
3 changes: 1 addition & 2 deletions bridge/deploy/11_transfer_sideTokenFactoryToBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ module.exports = async function({getNamedAccounts, deployments}) { // HardhatRun
const SideTokenFactory = await deployments.get(sideTokenFactoryName);

const sideTokenFactoryContract = new web3.eth.Contract(SideTokenFactory.abi, SideTokenFactory.address);
const primary = await sideTokenFactoryContract.methods.primary().call({from: deployer});
const primary = await sideTokenFactoryContract.methods.primary().send({from: deployer});
if (primary === BridgeProxy.address) {
return
}

await execute(sideTokenFactoryName, {from: deployer, gasLimit: GAS_LIMIT}, 'transferPrimary', BridgeProxy.address);
log(`SideTokenFactory Transferred Primary to BridgeProxy`);
};
Expand Down
4 changes: 2 additions & 2 deletions bridge/deploy/12_transfer_federationToBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
return;
}

const Bridge = await deployments.getArtifact('BridgeV3');
const Bridge = await deployments.getArtifact('BridgeV4');
const MultiSigWallet = await deployments.getArtifact('MultiSigWallet');

const bridgeProxyAddress = await address.getBridgeProxyAddress(hre);
Expand All @@ -26,4 +26,4 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
};
module.exports.id = 'transfer_federation_to_bridge'; // id required to prevent reexecution
module.exports.tags = ['TransferFederationToBridge', 'DeployFromScratch', 'IntegrationTest'];
module.exports.dependencies = ['BridgeV3', 'BridgeProxy', 'FederationProxy', 'MultiSigWallet'];
module.exports.dependencies = ['BridgeV4', 'BridgeProxy', 'FederationProxy', 'MultiSigWallet'];
4 changes: 2 additions & 2 deletions bridge/deploy/13_transfer_allowTokensToBridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
return;
}

const Bridge = await deployments.getArtifact('BridgeV3');
const Bridge = await deployments.getArtifact('BridgeV4');
const MultiSigWallet = await deployments.getArtifact('MultiSigWallet');

const multiSigAddress = await address.getMultiSigAddress(hre);
Expand All @@ -26,4 +26,4 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
};
module.exports.id = 'transfer_allow_tokens'; // id required to prevent reexecution
module.exports.tags = ['TransferAllowTokensToBridge', 'DeployFromScratch', 'IntegrationTest'];
module.exports.dependencies = ['BridgeV3', 'BridgeProxy', 'AllowTokensProxy', 'MultiSigWallet'];
module.exports.dependencies = ['BridgeV4', 'BridgeProxy', 'AllowTokensProxy', 'MultiSigWallet'];
4 changes: 2 additions & 2 deletions bridge/deploy/17_set_wrapped_currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
return;
}

const Bridge = await deployments.getArtifact('BridgeV3');
const Bridge = await deployments.getArtifact('BridgeV4');
const BridgeProxy = await deployments.get('BridgeProxy');
const MultiSigWallet = await deployments.getArtifact('MultiSigWallet');

Expand Down Expand Up @@ -48,5 +48,5 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment
module.exports.id = 'set_bridge_wrapped_currency'; // id required to prevent reexecution
module.exports.tags = ['BridgeSetWrappedCurrency', 'DeployFromScratch', 'IntegrationTest'];
module.exports.dependencies = [
'AllowTokensProxy', 'AllowTokens', 'BridgeV3', 'BridgeProxy', 'MultiSigWallet'
'AllowTokensProxy', 'AllowTokens', 'BridgeV4', 'BridgeProxy', 'MultiSigWallet'
];
2 changes: 1 addition & 1 deletion bridge/deploy/upgrades/01_upgrade_bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment

const proxyAdminContract = new web3.eth.Contract(proxyAdminArtifact.abi, proxyAdmin);
const methodCallUpdagradeBridgeDeployment = proxyAdminContract.methods.upgrade(bridgeProxy, bridgeDeployed.address);
await methodCallUpdagradeBridgeDeployment.call({ from: multiSig });
await methodCallUpdagradeBridgeDeployment.send({ from: multiSig });

const multiSigContract = new web3.eth.Contract(multiSigWalletArtifact.abi, multiSig);
await multiSigContract.methods.submitTransaction(
Expand Down
2 changes: 1 addition & 1 deletion bridge/deploy/upgrades/02_upgrade_federation.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = async function (hre) { // HardhatRuntimeEnvironment

const proxyAdminContract = new web3.eth.Contract(proxyAdminArtifact.abi, proxyAdmin);
const methodCallUpdagradeBridgeDeployment = proxyAdminContract.methods.upgrade(federationProxy, federationDeployed.address);
await methodCallUpdagradeBridgeDeployment.call({ from: multiSig });
await methodCallUpdagradeBridgeDeployment.send({ from: multiSig });

const multiSigContract = new web3.eth.Contract(multiSigWalletDeployment.abi, multiSig);
await multiSigContract.methods.submitTransaction(
Expand Down
1 change: 1 addition & 0 deletions bridge/deployments/alphanet/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
78
Loading
Loading