Skip to content

Commit

Permalink
Missing zero address check in (#62)
Browse files Browse the repository at this point in the history
* Missing zero address check in

Signed-off-by: Andres Aiello <[email protected]>

* test signed

Signed-off-by: Andres Aiello <[email protected]>

* test signed

Signed-off-by: Andres Aiello <[email protected]>

Signed-off-by: Andres Aiello <[email protected]>
  • Loading branch information
andresaiello authored Jan 25, 2023
1 parent 9336fe2 commit cfe525c
Show file tree
Hide file tree
Showing 64 changed files with 2,905 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ contract MultiChainSwapUniV2 is MultiChainSwap, ZetaInteractor, MultiChainSwapEr

IUniswapV2Router02 internal uniswapV2Router;

constructor(
address zetaConnector_,
address zetaToken_,
address uniswapV2Router_
) ZetaInteractor(zetaConnector_) {
constructor(address zetaConnector_, address zetaToken_, address uniswapV2Router_) ZetaInteractor(zetaConnector_) {
if (zetaToken_ == address(0) || uniswapV2Router_ == address(0)) revert ZetaCommonErrors.InvalidAddress();
zetaToken = zetaToken_;
uniswapV2RouterAddress = uniswapV2Router_;
uniswapV2Router = IUniswapV2Router02(uniswapV2Router_);
Expand Down Expand Up @@ -184,11 +181,9 @@ contract MultiChainSwapUniV2 is MultiChainSwap, ZetaInteractor, MultiChainSwapEr
);
}

function onZetaMessage(ZetaInterfaces.ZetaMessage calldata zetaMessage)
external
override
isValidMessageCall(zetaMessage)
{
function onZetaMessage(
ZetaInterfaces.ZetaMessage calldata zetaMessage
) external override isValidMessageCall(zetaMessage) {
(
bytes32 messageType,
address sourceTxOrigin,
Expand Down Expand Up @@ -268,11 +263,9 @@ contract MultiChainSwapUniV2 is MultiChainSwap, ZetaInteractor, MultiChainSwapEr
);
}

function onZetaRevert(ZetaInterfaces.ZetaRevert calldata zetaRevert)
external
override
isValidRevertCall(zetaRevert)
{
function onZetaRevert(
ZetaInterfaces.ZetaRevert calldata zetaRevert
) external override isValidRevertCall(zetaRevert) {
/**
* @dev: If something goes wrong we must swap to the source input token
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import "@zetachain/protocol-contracts/contracts/interfaces/ZetaInterfaces.sol";
import "../MultiChainSwap.sol";

contract MultiChainSwapZetaConnector is ZetaConnector {
address public zetaToken;
address public immutable zetaToken;

constructor(address zetaToken_) {
if (zetaToken_ == address(0)) revert ZetaCommonErrors.InvalidAddress();
zetaToken = zetaToken_;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ contract MultiChainValue is ZetaInteractor, MultiChainValueErrors {
mapping(uint256 => bool) public availableChainIds;

constructor(address connectorAddress_, address zetaToken_) ZetaInteractor(connectorAddress_) {
if (zetaToken_ == address(0)) revert ZetaCommonErrors.InvalidAddress();
zetaToken = zetaToken_;
}

Expand All @@ -36,11 +37,7 @@ contract MultiChainValue is ZetaInteractor, MultiChainValueErrors {
delete availableChainIds[destinationChainId];
}

function send(
uint256 destinationChainId,
bytes calldata destinationAddress,
uint256 zetaValueAndGas
) external {
function send(uint256 destinationChainId, bytes calldata destinationAddress, uint256 zetaValueAndGas) external {
if (!availableChainIds[destinationChainId]) revert InvalidDestinationChainId();
if (zetaValueAndGas == 0) revert InvalidZetaValueAndGas();

Expand Down
12 changes: 12 additions & 0 deletions packages/example-contracts/lib/shared/network.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ export type NetworkVariables = {
};

export const networkVariables: Record<NetworkName, NetworkVariables> = {
athens: {
chainId: 0,
connectorAddress: "",
crossChainId: 0,
crossChainName: ""
},
"bitcoin-test": {
chainId: 0,
connectorAddress: "",
crossChainId: 0,
crossChainName: ""
},
"bsc-localnet": {
chainId: 0,
connectorAddress: "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[
{
"inputs": [],
"name": "InvalidAddress",
"type": "error"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"inputs": [],
"name": "deposit",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
}
],
"name": "depositTo",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "wad",
"type": "uint256"
}
],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address payable",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "withdrawTo",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
Loading

0 comments on commit cfe525c

Please sign in to comment.