Skip to content

Commit

Permalink
chore: remove precompile fip20crosschain
Browse files Browse the repository at this point in the history
  • Loading branch information
nulnut authored and zakir-code committed Sep 23, 2024
1 parent c4d4a01 commit 56035ed
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 2,181 deletions.
204 changes: 2 additions & 202 deletions contract/FIP20Upgradable.go

Large diffs are not rendered by default.

23 changes: 1 addition & 22 deletions contract/ICrossChain.go

Large diffs are not rendered by default.

173 changes: 2 additions & 171 deletions contract/WFXUpgradable.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions contract/contract.go

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions solidity/contracts/bridge/ICrossChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

pragma solidity ^0.8.10;

import {IFIP20CrossChain} from "./IFIP20CrossChain.sol";
import {IBridgeCall} from "./IBridgeCall.sol";

// NOTE: if using an interface to invoke the precompiled contract
// need to use solidity version 0.8.10 and later.
interface ICrossChain is IFIP20CrossChain, IBridgeCall {
interface ICrossChain is IBridgeCall {
function crossChain(
address _token,
string memory _receipt,
Expand Down
16 changes: 0 additions & 16 deletions solidity/contracts/bridge/IFIP20CrossChain.sol

This file was deleted.

35 changes: 0 additions & 35 deletions solidity/contracts/fip20/FIP20Upgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import "@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable
import "@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol";

import "./IFIP20Upgradable.sol";
import "../bridge/IFIP20CrossChain.sol";

/* solhint-enable no-global-import */
/* solhint-disable custom-errors */
Expand Down Expand Up @@ -233,23 +232,6 @@ contract FIP20Upgradable is
_burn(account, amount);
}

// Deprecated: use pre-compiled contract crossChain
function transferCrossChain(
string memory recipient,
uint256 amount,
uint256 fee,
bytes32 target
) external override notContract returns (bool) {
_transferCrossChain(_msgSender(), recipient, amount, fee, target);

emit TransferCrossChain(_msgSender(), recipient, amount, fee, target);
return true;
}

function module() external view returns (address) {
return _module;
}

modifier notContract() {
require(!_isContract(_msgSender()), "caller cannot be contract");
_;
Expand Down Expand Up @@ -306,23 +288,6 @@ contract FIP20Upgradable is
_allowance[sender][spender] = amount;
}

function _transferCrossChain(
address sender,
string memory recipient,
uint256 amount,
uint256 fee,
bytes32 target
) internal {
require(sender != address(0), "transfer from the zero address");
require(bytes(recipient).length > 0, "invalid recipient");
require(target != bytes32(0), "invalid target");

_transfer(sender, _module, amount + fee);

IFIP20CrossChain(0x0000000000000000000000000000000000001004)
.fip20CrossChain(sender, recipient, amount, fee, target, "");
}

// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address) internal override onlyOwner {}

Expand Down
27 changes: 0 additions & 27 deletions solidity/contracts/fip20/IFIP20Upgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,21 +96,6 @@ interface IFIP20Upgradable {
*/
function burn(address from, uint256 amount) external;

/**
* @dev Cross chain moves `amount + fee` tokens from `sender` to `recipient`
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {TransferCrossChain} event.
*/
// Deprecated: use pre-compiled contract crossChain
function transferCrossChain(
string memory recipient,
uint256 amount,
uint256 fee,
bytes32 target
) external returns (bool);

/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
Expand All @@ -128,16 +113,4 @@ interface IFIP20Upgradable {
address indexed spender,
uint256 value
);

/**
* @dev Emitted when `amount + fee` tokens are cross chain moved from one account (`from`) to
* another (`to`) through (`target`).
*/
event TransferCrossChain(
address indexed from,
string recipient,
uint256 amount,
uint256 fee,
bytes32 target
);
}
46 changes: 0 additions & 46 deletions solidity/contracts/fip20/WFXUpgradable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol";

import "../bridge/IFIP20CrossChain.sol";

/* solhint-enable no-global-import */
/* solhint-disable custom-errors */

Expand Down Expand Up @@ -174,18 +172,6 @@ contract WFXUpgradable is
uint256 value
);

/**
* @dev Emitted when `amount + fee` tokens are cross chain moved from one account (`from`) to
* another (`to`) through (`target`).
*/
event TransferCrossChain(
address indexed from,
string recipient,
uint256 amount,
uint256 fee,
bytes32 target
);

function name() external view returns (string memory) {
return _name;
}
Expand Down Expand Up @@ -271,21 +257,6 @@ contract WFXUpgradable is
event Withdraw(address indexed from, address indexed to, uint256 value);
event Withdraw(address indexed from, uint256 value);

// Deprecated: use pre-compiled contract crossChain
function transferCrossChain(
string memory recipient,
uint256 amount,
uint256 fee,
bytes32 target
) external payable notContract returns (bool) {
if (msg.value > 0) {
deposit();
}
_transferCrossChain(_msgSender(), recipient, amount, fee, target);
emit TransferCrossChain(_msgSender(), recipient, amount, fee, target);
return true;
}

function module() external view returns (address) {
return _module;
}
Expand Down Expand Up @@ -346,23 +317,6 @@ contract WFXUpgradable is
_allowance[sender][spender] = amount;
}

function _transferCrossChain(
address sender,
string memory recipient,
uint256 amount,
uint256 fee,
bytes32 target
) internal {
require(sender != address(0), "transfer from the zero address");
require(bytes(recipient).length > 0, "invalid recipient");
require(target != bytes32(0), "invalid target");

_transfer(sender, _module, amount + fee);

IFIP20CrossChain(0x0000000000000000000000000000000000001004)
.fip20CrossChain(sender, recipient, amount, fee, target, "");
}

// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address) internal override onlyOwner {}

Expand Down
2 changes: 1 addition & 1 deletion tests/contract/CrossChainTest.go

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

Loading

0 comments on commit 56035ed

Please sign in to comment.