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

feat: add interface contract for FxBridgeLogic #264

Merged
merged 1 commit into from
Mar 11, 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
2,488 changes: 0 additions & 2,488 deletions contract/FxBridgeLogic.go

This file was deleted.

2,333 changes: 0 additions & 2,333 deletions contract/FxBridgeLogicBSC.go

This file was deleted.

2,502 changes: 0 additions & 2,502 deletions contract/FxBridgeLogicETH.go

This file was deleted.

1,994 changes: 1,994 additions & 0 deletions contract/IFxBridgeLogic.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contract/IStaking.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contract/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ echo "===> Compiling contracts"
[[ ! -d "$project_dir/contract/artifacts" ]] && mkdir -p "$project_dir/contract/artifacts"

# add core contracts
contracts=(WFXUpgradable FIP20Upgradable ICrossChain IStaking FxBridgeLogicETH FxBridgeLogicBSC FxBridgeLogic)
contracts=(WFXUpgradable FIP20Upgradable ICrossChain IStaking IFxBridgeLogic)
contracts_test=(CrossChainTest StakingTest)
# add 3rd party contracts
contracts+=(ERC1967Proxy)
Expand Down
203 changes: 203 additions & 0 deletions solidity/contracts/bridge/IFxBridgeLogic.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.0;

interface IFxBridgeLogic {
/* solhint-disable func-name-mixedcase */
function state_fxBridgeId() external view returns (bytes32);
function state_powerThreshold() external view returns (uint256);

function state_lastEventNonce() external view returns (uint256);
function state_lastOracleSetCheckpoint() external view returns (bytes32);
function state_lastOracleSetNonce() external view returns (uint256);
function state_lastBatchNonces(
address _erc20Address
) external view returns (uint256);

function bridgeTokens() external view returns (address[] memory);
function tokenStatus(
address _tokenAddr
) external view returns (TokenStatus memory);
function version() external view returns (string memory);
function state_lastRefundNonce(uint256 _nonce) external view returns (bool);
/* solhint-disable func-name-mixedcase */

struct TokenStatus {
bool isOriginated;
bool isActive;
bool isExist;
}

struct TransferInfo {
uint256 amount;
address destination;
uint256 fee;
address exchange;
uint256 minExchange;
}

struct BridgeToken {
address addr;
string name;
string symbol;
uint8 decimals;
}

function addBridgeToken(
address _tokenAddr,
bytes32 _channelIBC,
bool _isOriginated
) external returns (bool);

function pauseBridgeToken(address _tokenAddr) external returns (bool);

function activeBridgeToken(address _tokenAddr) external returns (bool);

function updateOracleSet(
address[] memory _newOracles,
uint256[] memory _newPowers,
uint256 _newOracleSetNonce,
address[] memory _currentOracles,
uint256[] memory _currentPowers,
uint256 _currentOracleSetNonce,
uint8[] memory _v,
bytes32[] memory _r,
bytes32[] memory _s
) external;

function sendToFx(
address _tokenContract,
bytes32 _destination,
bytes32 _targetIBC,
uint256 _amount
) external;

function bridgeCall(
string memory _dstChainId,
uint256 _gasLimit,
address _receiver,
address _to,
bytes calldata _message,
uint256 _value,
bytes memory _asset
) external;

function submitBatch(
address[] memory _currentOracles,
uint256[] memory _currentPowers,
uint8[] memory _v,
bytes32[] memory _r,
bytes32[] memory _s,
uint256[] memory _amounts,
address[] memory _destinations,
uint256[] memory _fees,
uint256[2] memory _nonceArray,
address _tokenContract,
uint256 _batchTimeout,
address _feeReceive
) external;

function refundBridgeToken(
address[] memory _currentOracles,
uint256[] memory _currentPowers,
uint8[] memory _v,
bytes32[] memory _r,
bytes32[] memory _s,
uint256[2] memory _nonceArray,
address _receiver,
address[] memory _tokens,
uint256[] memory _amounts,
uint256 _timeout
) external;

function transferOwner(
address _token,
address _newOwner
) external returns (bool);

/* =============== QUERY FUNCTIONS =============== */

function lastBatchNonce(
address _erc20Address
) external view returns (uint256);

function checkAssetStatus(address _tokenAddr) external view returns (bool);

/* ============== HELP FUNCTIONS =============== */

function makeCheckpoint(
address[] memory _oracles,
uint256[] memory _powers,
uint256 _oracleSetNonce,
bytes32 _fxBridgeId
) external pure returns (bytes32);

function checkOracleSignatures(
address[] memory _currentOracles,
uint256[] memory _currentPowers,
uint8[] memory _v,
bytes32[] memory _r,
bytes32[] memory _s,
bytes32 _theHash,
uint256 _powerThreshold
) external pure;

function pause() external;

function unpause() external;

function getBridgeTokenList() external view returns (BridgeToken[] memory);

function decodeType(
bytes memory _asset
) external pure returns (string memory, bytes memory);

/* =============== EVENTS =============== */

event TransactionBatchExecutedEvent(
uint256 indexed _batchNonce,
address indexed _token,
uint256 _eventNonce
);
event SendToFxEvent(
address indexed _tokenContract,
address indexed _sender,
bytes32 indexed _destination,
bytes32 _targetIBC,
uint256 _amount,
uint256 _eventNonce
);
event AddBridgeTokenEvent(
address indexed _tokenContract,
string _name,
string _symbol,
uint8 _decimals,
uint256 _eventNonce,
bytes32 _channelIBC
);
event OracleSetUpdatedEvent(
uint256 indexed _newOracleSetNonce,
uint256 _eventNonce,
address[] _oracles,
uint256[] _powers
);
event TransferOwnerEvent(address _token, address _newOwner);

event BridgeCallEvent(
address indexed _sender,
address indexed _receiver,
address indexed _to,
uint256 _eventNonce,
string _dstChainId,
uint256 _gasLimit,
uint256 _value,
bytes _message,
bytes _asset
);

event RefundTokenExecutedEvent(
address indexed _receiver,
uint256 indexed _refundNonce,
uint256 _eventNonce
);
}
Loading