diff --git a/contracts/WIOTXUnwrapper.sol b/contracts/WIOTXUnwrapper.sol new file mode 100644 index 0000000..df90f0b --- /dev/null +++ b/contracts/WIOTXUnwrapper.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +pragma solidity >= 0.8.0; + +interface IWIOTX { + function withdraw(uint256) external; +} + +contract WIOTXUnwrapper { + address public wiotx; + + constructor(address _wiotx) { + wiotx = _wiotx; + } + + receive() external payable { + } + + function onReceive(address _sender, IWIOTX _token, uint256 _amount, bytes calldata _payload) external { + require(address(_token) == wiotx, "WIOTXUnwrapper: invalid token"); + address recipient = _sender; + if (_payload.length == 32) { + (recipient) = abi.decode(_payload, (address)); + } + _token.withdraw(_amount); + payable(recipient).transfer(_amount); + } +} diff --git a/witness-service/configs/witness-config-ethereum-payload.yaml b/witness-service/configs/witness-config-ethereum-payload.yaml index ff46cac..ea6cd96 100644 --- a/witness-service/configs/witness-config-ethereum-payload.yaml +++ b/witness-service/configs/witness-config-ethereum-payload.yaml @@ -88,3 +88,6 @@ cashiers: # USDa - token2: "0xeaa38983d3370e35fb42229f89e816e28035a74b" token1: "0xBB76063476A79F73624386795f4CcA855954C891" + # W-IOTX + - token2: "io15qr5fzpxsnp7garl4m7k355rafzqn8grrm0grz" + token1: "0x6fB3e0A217407EFFf7Ca062D46c26E5d60a14d69" diff --git a/witness-service/relayer/service.go b/witness-service/relayer/service.go index 27c2c2e..5c0357a 100644 --- a/witness-service/relayer/service.go +++ b/witness-service/relayer/service.go @@ -581,7 +581,7 @@ func (s *Service) submitTransfers() error { if err := s.submitTransfer(transfer, validator); err != nil { util.Alert("failed to submit transfer" + err.Error()) } - time.Sleep(2 * time.Second) + time.Sleep(5 * time.Second) } } return nil diff --git a/witness-service/relayer/transfervalidatoronethereum.go b/witness-service/relayer/transfervalidatoronethereum.go index efdf9a0..74bd23f 100644 --- a/witness-service/relayer/transfervalidatoronethereum.go +++ b/witness-service/relayer/transfervalidatoronethereum.go @@ -11,6 +11,7 @@ import ( "crypto/ecdsa" "log" "math/big" + "strings" "sync" "time" @@ -382,7 +383,7 @@ func (tv *transferValidatorOnEthereum) Check(transfer *Transfer) (StatusOnChainT switch errors.Cause(err) { case ethereum.NotFound: if transfer.nonce <= nonce { - if transfer.updateTime.Add(5 * time.Minute).Before(time.Now()) { + if transfer.updateTime.Add(10 * time.Minute).Before(time.Now()) { return StatusOnChainNonceOverwritten, nil } return StatusOnChainNotConfirmed, nil @@ -397,7 +398,7 @@ func (tv *transferValidatorOnEthereum) Check(transfer *Transfer) (StatusOnChainT default: return StatusOnChainUnknown, err } - if transfer.updateTime.After(time.Now().Add(-10 * time.Minute)) { + if transfer.updateTime.After(time.Now().Add(-20 * time.Minute)) { return StatusOnChainNotConfirmed, nil } // no matter what the receipt status is, mark the validation as failure @@ -465,6 +466,9 @@ func (tv *transferValidatorOnEthereum) submit(transfer *Transfer, witnesses []*W case ethereum.NotFound: return common.Hash{}, common.Address{}, 0, nil, errors.Wrap(errNoncritical, err.Error()) default: + if strings.Contains(err.Error(), "could not replace existing tx") { + return common.Hash{}, common.Address{}, 0, nil, errors.Wrap(errNoncritical, err.Error()) + } return common.Hash{}, common.Address{}, 0, nil, err } }