contract EthCashier is Ownable {
TokenCashier public tokenCashier;
WrappedEther public wrappedEther;
constructor(address _tokenCashier, address _wrappedEther) public {
tokenCashier = TokenCashier(_tokenCashier);
wrappedEther = WrappedEther(_wrappedEther);
}
function deposit() public payable {
depositTo(msg.sender);
}
function depositTo(address _to) public payable {
wrappedEther.deposit.value(msg.value)();
require(wrappedEther.approve(address(tokenCashier), msg.value), "approve failure");
tokenCashier.depositTo(address(wrappedEther), _to, msg.value);
}
function upgrade(address _newTokenCashier) public onlyOwner {
tokenCashier = TokenCashier(_newTokenCashier);
}
}
This contract is a wrap of token cashier and the weth. It enables user to deposit Ether via tube (token cashier) to IoTeX, without an extra manual step to exchange to WEth.
As implemented in function depositTo, the deposited ether will be exchanged to WEth in the function first, and then deposit to token cashier.
The front-end side, we need to distinguish ether from the other tokens. If user choosing ether, we should call this contract EthCashier; otherwise, we call the TokenCashier.
Test contract on Kovan: 0xe958ed5d5d29e0910cf53b6d161d9295a93c2ab7
This contract is a wrap of token cashier and the weth. It enables user to deposit Ether via tube (token cashier) to IoTeX, without an extra manual step to exchange to WEth. As implemented in function depositTo, the deposited ether will be exchanged to WEth in the function first, and then deposit to token cashier.
The front-end side, we need to distinguish ether from the other tokens. If user choosing ether, we should call this contract EthCashier; otherwise, we call the TokenCashier.
Test contract on Kovan: 0xe958ed5d5d29e0910cf53b6d161d9295a93c2ab7
ABI: