Skip to content

Commit

Permalink
refactor: improve structure of fx bridge logic contract
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code committed Dec 31, 2024
1 parent 67b3ec3 commit b658aa5
Show file tree
Hide file tree
Showing 28 changed files with 918 additions and 1,344 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install abigen
- name: Install abigen # https://geth.ethereum.org/downloads
run: |
wget -q https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.12.0-e501b3b0.tar.gz
tar -zxvf geth-alltools-linux-amd64-1.12.0-e501b3b0.tar.gz
sudo mv geth-alltools-linux-amd64-1.12.0-e501b3b0/abigen /usr/local/bin
wget -q https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.14.12-293a300d.tar.gz
tar -zxvf geth-alltools-linux-amd64-1.14.12-293a300d.tar.gz
sudo mv geth-alltools-linux-amd64-1.14.12-293a300d/abigen /usr/local/bin
- name: Run abigen
run: make contract-abigen
- name: Check diff
Expand Down
4 changes: 2 additions & 2 deletions contract/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ for cmd in "${commands[@]}"; do
done

abigen_version=$(abigen --version | awk '{print $3}')
if ! [[ "$abigen_version" =~ ^1.12.0-stable.* ]]; then
echo "expected abigen version 1.12.0, but got $abigen_version, please upgrade abigen first" && exit 1
if ! [[ "$abigen_version" =~ ^1.14.12-stable.* ]]; then
echo "expected abigen version 1.14.12, but got $abigen_version, please upgrade abigen first" && exit 1
fi

project_dir="$(git rev-parse --show-toplevel)"
Expand Down
13 changes: 2 additions & 11 deletions contract/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,12 @@ func PackSubmitBatchCheckpoint(gravityID, methodName [32]byte, amounts []*big.In
)
}

func PackBridgeCallCheckpoint(gravityID, methodName [32]byte, sender, refund common.Address, tokens []common.Address, amounts []*big.Int, to common.Address, data, memo []byte, nonce, timeout, gasLimit, eventNonce *big.Int) ([]byte, error) {
func PackBridgeCallCheckpoint(gravityID, methodName [32]byte, nonce *big.Int, input *FxBridgeBaseBridgeCallData) ([]byte, error) {
return fxBridgeABI.Pack("bridgeCallCheckpoint",
gravityID,
methodName,
sender,
refund,
tokens,
amounts,
to,
data,
memo,
nonce,
timeout,
gasLimit,
eventNonce,
input,
)
}

Expand Down
30 changes: 15 additions & 15 deletions contract/icrosschain.sol.go

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

291 changes: 135 additions & 156 deletions contract/ifx_bridge_logic.sol.go

Large diffs are not rendered by default.

85 changes: 85 additions & 0 deletions solidity/contracts/bridge/FxBridgeBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

interface FxBridgeBase {
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;
}

struct OracleSignatures {
address[] oracles;
uint256[] powers;
bytes32[] r;
bytes32[] s;
uint8[] v;
}

struct BridgeCallData {
address sender;
address refund;
address[] tokens;
uint256[] amounts;
address to;
bytes data;
bytes memo;
uint256 timeout;
uint256 gasLimit;
uint256 eventNonce;
}

/* =============== 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 SubmitBridgeCallEvent(
address indexed _txOrigin,
uint256 _nonce,
uint256 _eventNonce,
bool _success,
bytes _cause
);
}
Loading

0 comments on commit b658aa5

Please sign in to comment.