mirror of
https://github.com/AthanorLabs/atomic-swap.git
synced 2026-01-09 14:18:03 -05:00
remove hardhat dependency from ethereum/ dir (#196)
This commit is contained in:
7
.github/workflows/unit-tests.yml
vendored
7
.github/workflows/unit-tests.yml
vendored
@@ -11,7 +11,6 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.18.x]
|
||||
node-version: [16.x]
|
||||
platform: [ubuntu-22.04]
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
@@ -49,9 +48,3 @@ jobs:
|
||||
|
||||
- name: Run coverage
|
||||
run: bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
- name: Run Hardhat tests
|
||||
run: |
|
||||
cd ethereum
|
||||
npm install --save-dev hardhat
|
||||
npx hardhat test
|
||||
|
||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -31,4 +31,9 @@ swaptester
|
||||
node.key
|
||||
xmrmaker.key
|
||||
xmrtaker.key
|
||||
cmd/daemon/*.key
|
||||
cmd/daemon/*.key
|
||||
tests/*.log
|
||||
|
||||
# Ethereum contract compilation artifacts
|
||||
ethereum/abi/
|
||||
ethereum/bin/
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"path"
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
@@ -32,9 +32,9 @@ func getOrDeploySwapFactory(
|
||||
chainID *big.Int,
|
||||
privkey *ecdsa.PrivateKey,
|
||||
ec *ethclient.Client,
|
||||
) (*swapfactory.SwapFactory, ethcommon.Address, error) {
|
||||
) (*contracts.SwapFactory, ethcommon.Address, error) {
|
||||
var (
|
||||
sf *swapfactory.SwapFactory
|
||||
sf *contracts.SwapFactory
|
||||
)
|
||||
|
||||
if env != common.Mainnet && (address == ethcommon.Address{}) {
|
||||
@@ -47,14 +47,14 @@ func getOrDeploySwapFactory(
|
||||
return nil, ethcommon.Address{}, fmt.Errorf("failed to make transactor: %w", err)
|
||||
}
|
||||
|
||||
// deploy SwapFactory.sol
|
||||
// deploy contracts.sol
|
||||
var tx *ethtypes.Transaction
|
||||
address, tx, sf, err = deploySwapFactory(ec, txOpts)
|
||||
if err != nil {
|
||||
return nil, ethcommon.Address{}, fmt.Errorf("failed to deploy swap factory: %w; please check your chain ID", err)
|
||||
}
|
||||
|
||||
log.Infof("deployed SwapFactory.sol: address=%s tx hash=%s", address, tx.Hash())
|
||||
log.Infof("deployed contracts.sol: address=%s tx hash=%s", address, tx.Hash())
|
||||
|
||||
// store the contract address on disk
|
||||
fp := path.Join(dataDir, "contractaddress")
|
||||
@@ -67,7 +67,7 @@ func getOrDeploySwapFactory(
|
||||
if err != nil {
|
||||
return nil, ethcommon.Address{}, err
|
||||
}
|
||||
log.Infof("loaded SwapFactory.sol from address %s", address)
|
||||
log.Infof("loaded contracts.sol from address %s", address)
|
||||
|
||||
err = checkContractCode(ctx, ec, address)
|
||||
if err != nil {
|
||||
@@ -84,7 +84,7 @@ func checkContractCode(ctx context.Context, ec *ethclient.Client, contractAddr e
|
||||
return err
|
||||
}
|
||||
|
||||
expectedCode := ethcommon.FromHex(swapfactory.SwapFactoryMetaData.Bin)
|
||||
expectedCode := ethcommon.FromHex(contracts.SwapFactoryMetaData.Bin)
|
||||
if !bytes.Contains(expectedCode, code) {
|
||||
return errInvalidSwapContract
|
||||
}
|
||||
@@ -92,10 +92,10 @@ func checkContractCode(ctx context.Context, ec *ethclient.Client, contractAddr e
|
||||
return nil
|
||||
}
|
||||
|
||||
func getSwapFactory(client *ethclient.Client, addr ethcommon.Address) (*swapfactory.SwapFactory, error) {
|
||||
return swapfactory.NewSwapFactory(addr, client)
|
||||
func getSwapFactory(client *ethclient.Client, addr ethcommon.Address) (*contracts.SwapFactory, error) {
|
||||
return contracts.NewSwapFactory(addr, client)
|
||||
}
|
||||
|
||||
func deploySwapFactory(client *ethclient.Client, txOpts *bind.TransactOpts) (ethcommon.Address, *ethtypes.Transaction, *swapfactory.SwapFactory, error) { //nolint:lll
|
||||
return swapfactory.DeploySwapFactory(txOpts, client)
|
||||
func deploySwapFactory(client *ethclient.Client, txOpts *bind.TransactOpts) (ethcommon.Address, *ethtypes.Transaction, *contracts.SwapFactory, error) { //nolint:lll
|
||||
return contracts.DeploySwapFactory(txOpts, client)
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/cliutil"
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrmaker"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrtaker"
|
||||
recovery "github.com/athanorlabs/atomic-swap/recover"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -110,8 +110,8 @@ func main() {
|
||||
// Recoverer is implemented by a backend which is able to recover swap funds
|
||||
type Recoverer interface {
|
||||
WalletFromSharedSecret(secret *mcrypto.PrivateKeyInfo) (mcrypto.Address, error)
|
||||
RecoverFromXMRMakerSecretAndContract(b backend.Backend, dataDir string, xmrmakerSecret, contractAddr string, swapID [32]byte, swap swapfactory.SwapFactorySwap) (*xmrmaker.RecoveryResult, error) //nolint:lll
|
||||
RecoverFromXMRTakerSecretAndContract(b backend.Backend, dataDir string, xmrtakerSecret string, swapID [32]byte, swap swapfactory.SwapFactorySwap) (*xmrtaker.RecoveryResult, error) //nolint:lll
|
||||
RecoverFromXMRMakerSecretAndContract(b backend.Backend, dataDir string, xmrmakerSecret, contractAddr string, swapID [32]byte, swap contracts.SwapFactorySwap) (*xmrmaker.RecoveryResult, error) //nolint:lll
|
||||
RecoverFromXMRTakerSecretAndContract(b backend.Backend, dataDir string, xmrtakerSecret string, swapID [32]byte, swap contracts.SwapFactorySwap) (*xmrtaker.RecoveryResult, error) //nolint:lll
|
||||
}
|
||||
|
||||
type instance struct {
|
||||
@@ -284,7 +284,7 @@ func createBackend(ctx context.Context, c *cli.Context, env common.Environment,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
contract, err := swapfactory.NewSwapFactory(contractAddr, ec)
|
||||
contract, err := contracts.NewSwapFactory(contractAddr, ec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrmaker"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrtaker"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
"github.com/athanorlabs/atomic-swap/tests"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -65,14 +65,14 @@ func (r *mockRecoverer) WalletFromSharedSecret(_ *mcrypto.PrivateKeyInfo) (mcryp
|
||||
}
|
||||
|
||||
func (r *mockRecoverer) RecoverFromXMRMakerSecretAndContract(b backend.Backend, _ string, xmrmakerSecret,
|
||||
contractAddr string, swapID [32]byte, _ swapfactory.SwapFactorySwap) (*xmrmaker.RecoveryResult, error) {
|
||||
contractAddr string, swapID [32]byte, _ contracts.SwapFactorySwap) (*xmrmaker.RecoveryResult, error) {
|
||||
return &xmrmaker.RecoveryResult{
|
||||
Claimed: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *mockRecoverer) RecoverFromXMRTakerSecretAndContract(b backend.Backend, _ string, xmrtakerSecret string,
|
||||
swapID [32]byte, _ swapfactory.SwapFactorySwap) (*xmrtaker.RecoveryResult, error) {
|
||||
swapID [32]byte, _ contracts.SwapFactorySwap) (*xmrtaker.RecoveryResult, error) {
|
||||
return &xmrtaker.RecoveryResult{
|
||||
Claimed: true,
|
||||
}, nil
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Hardhat Project for Swap contract
|
||||
|
||||
Run `npm install` first.
|
||||
|
||||
|
||||
A default Hardhat project comes with a sample contract, a test for that contract, a sample script that deploys that contract, and an example of a task implementation, which simply lists the available accounts.
|
||||
|
||||
Try running some of the following tasks:
|
||||
|
||||
```shell
|
||||
npx hardhat accounts
|
||||
npx hardhat compile
|
||||
npx hardhat clean
|
||||
npx hardhat test
|
||||
npx hardhat node
|
||||
node scripts/sample-script.js
|
||||
npx hardhat help
|
||||
```
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -38,7 +38,7 @@ var ERC20MockMetaData = &bind.MetaData{
|
||||
// Deprecated: Use ERC20MockMetaData.ABI instead.
|
||||
var ERC20MockABI = ERC20MockMetaData.ABI
|
||||
|
||||
// ERC20MockBin is the compiled bytecode used for deploying new contracts.
|
||||
// ERC20MockBin is the compiled bytecode used for deploying new ethereum.
|
||||
// Deprecated: Use ERC20MockMetaData.Bin instead.
|
||||
var ERC20MockBin = ERC20MockMetaData.Bin
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,31 +0,0 @@
|
||||
require("@nomiclabs/hardhat-waffle");
|
||||
require("@nomiclabs/hardhat-web3");
|
||||
require("hardhat-gas-reporter");
|
||||
|
||||
// This is a sample Hardhat task. To learn how to create your own go to
|
||||
// https://hardhat.org/guides/create-task.html
|
||||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
|
||||
const accounts = await hre.ethers.getSigners();
|
||||
|
||||
for (const account of accounts) {
|
||||
console.log(account.address);
|
||||
}
|
||||
});
|
||||
|
||||
// You need to export an object to set up your config
|
||||
// Go to https://hardhat.org/config/ to learn more
|
||||
|
||||
/**
|
||||
* @type import('hardhat/config').HardhatUserConfig
|
||||
*/
|
||||
module.exports = {
|
||||
solidity: "0.8.5",
|
||||
networks: {
|
||||
hardhat: {
|
||||
gas: "auto"
|
||||
}
|
||||
},
|
||||
gasReporter: {
|
||||
enabled: false
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
16731
ethereum/package-lock.json
generated
16731
ethereum/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "atomic-swap",
|
||||
"devDependencies": {
|
||||
"@nomiclabs/hardhat-ethers": "^2.0.2",
|
||||
"@nomiclabs/hardhat-waffle": "^2.0.1",
|
||||
"@nomiclabs/hardhat-web3": "^2.0.0",
|
||||
"chai": "^4.3.4",
|
||||
"ethereum-waffle": "^3.4.0",
|
||||
"ethers": "^5.5.1",
|
||||
"hardhat": "^2.8.0",
|
||||
"hardhat-gas-reporter": "^1.0.4",
|
||||
"web3": "^1.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"noble-ed25519": "^1.2.6",
|
||||
"noble-secp256k1": "^1.2.14",
|
||||
"rewire": "^5.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
async function main() {
|
||||
const SwapFactory = await ethers.getContractFactory("SwapFactory");
|
||||
const contract = await SwapFactory.deploy();
|
||||
|
||||
console.log("SwapFactory deployed to:", contract.address);
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => process.exit(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
// Code generated - DO NOT EDIT.
|
||||
// This file is a generated binding and any manual changes will be lost.
|
||||
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -51,7 +51,7 @@ var SwapFactoryMetaData = &bind.MetaData{
|
||||
// Deprecated: Use SwapFactoryMetaData.ABI instead.
|
||||
var SwapFactoryABI = SwapFactoryMetaData.ABI
|
||||
|
||||
// SwapFactoryBin is the compiled bytecode used for deploying new contracts.
|
||||
// SwapFactoryBin is the compiled bytecode used for deploying new ethereum.
|
||||
// Deprecated: Use SwapFactoryMetaData.Bin instead.
|
||||
var SwapFactoryBin = SwapFactoryMetaData.Bin
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,38 +0,0 @@
|
||||
const { expect } = require("chai");
|
||||
|
||||
const arrayify = ethers.utils.arrayify;
|
||||
|
||||
function KeyPair(s, pubKey_x, pubKey_y) {
|
||||
this.s = s;
|
||||
this.pubKey_x = pubKey_x;
|
||||
this.pubKey_y = pubKey_y;
|
||||
}
|
||||
|
||||
describe("Secp256k1", function () {
|
||||
const test_vecs = [
|
||||
new KeyPair('0xD30519BCAE8D180DBFCC94FE0B8383DC310185B0BE97B4365083EBCECCD75759',
|
||||
'0x3AF1E1EFA4D1E1AD5CB9E3967E98E901DAFCD37C44CF0BFB6C216997F5EE51DF',
|
||||
'0xE4ACAC3E6F139E0C7DB2BD736824F51392BDA176965A1C59EB9C3C5FF9E85D7A'),
|
||||
new KeyPair('0xebb2c082fd7727890a28ac82f6bdf97bad8de9f5d7c9028692de1a255cad3e0f',
|
||||
'0x779dd197a5df977ed2cf6cb31d82d43328b790dc6b3b7d4437a427bd5847dfcd',
|
||||
'0xe94b724a555b6d017bb7607c3e3281daf5b1699d6ef4124975c9237b917d426f'),
|
||||
];
|
||||
|
||||
let swap;
|
||||
beforeEach(async function () {
|
||||
const Secp256k1 = await ethers.getContractFactory("Secp256k1");
|
||||
secp256k1 = await Secp256k1.deploy();
|
||||
});
|
||||
|
||||
it("Should verify commitment correctly with test vecs", async function () {
|
||||
test_vecs.forEach(async function (kp, i) {
|
||||
const qKeccak = ethers.utils.solidityKeccak256(
|
||||
["uint256", "uint256"],
|
||||
[kp.pubKey_x, kp.pubKey_y]);
|
||||
|
||||
console.log('Testing %s of %s test vectors...', i + 1, test_vecs.length);
|
||||
let ok = await secp256k1.mulVerify(arrayify(kp.s), arrayify(qKeccak));
|
||||
expect(ok).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package swapfactory
|
||||
package contracts
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@@ -178,7 +178,7 @@ func (m *SendKeysMessage) Type() Type {
|
||||
return SendKeysType
|
||||
}
|
||||
|
||||
// ContractSwap is the same as swapfactory.SwapFactorySwap
|
||||
// ContractSwap is the same as contracts.SwapFactorySwap
|
||||
type ContractSwap struct {
|
||||
Owner ethcommon.Address
|
||||
Claimer ethcommon.Address
|
||||
|
||||
@@ -16,12 +16,12 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/ethereum/block"
|
||||
"github.com/athanorlabs/atomic-swap/monero"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/txsender"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
)
|
||||
@@ -40,7 +40,7 @@ type Backend interface {
|
||||
|
||||
// create a new transaction sender, called per-swap
|
||||
NewTxSender(asset ethcommon.Address,
|
||||
erc20Contract *swapfactory.IERC20) (txsender.Sender, error)
|
||||
erc20Contract *contracts.IERC20) (txsender.Sender, error)
|
||||
|
||||
// ethclient methods
|
||||
BalanceAt(ctx context.Context, account ethcommon.Address, blockNumber *big.Int) (*big.Int, error)
|
||||
@@ -56,7 +56,7 @@ type Backend interface {
|
||||
|
||||
// helpers
|
||||
WaitForReceipt(ctx context.Context, txHash ethcommon.Hash) (*ethtypes.Receipt, error)
|
||||
NewSwapFactory(addr ethcommon.Address) (*swapfactory.SwapFactory, error)
|
||||
NewSwapFactory(addr ethcommon.Address) (*contracts.SwapFactory, error)
|
||||
|
||||
// getters
|
||||
Ctx() context.Context
|
||||
@@ -66,7 +66,7 @@ type Backend interface {
|
||||
TxOpts() (*bind.TransactOpts, error)
|
||||
SwapManager() swap.Manager
|
||||
EthAddress() ethcommon.Address
|
||||
Contract() *swapfactory.SwapFactory
|
||||
Contract() *contracts.SwapFactory
|
||||
ContractAddr() ethcommon.Address
|
||||
Net() net.MessageSender
|
||||
SwapTimeout() time.Duration
|
||||
@@ -81,7 +81,7 @@ type Backend interface {
|
||||
SetXMRDepositAddress(mcrypto.Address, types.Hash)
|
||||
ClearXMRDepositAddress(types.Hash)
|
||||
SetBaseXMRDepositAddress(mcrypto.Address)
|
||||
SetContract(*swapfactory.SwapFactory)
|
||||
SetContract(*contracts.SwapFactory)
|
||||
SetContractAddress(ethcommon.Address)
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ type backend struct {
|
||||
txOpts *txsender.TxOpts
|
||||
|
||||
// swap contract
|
||||
contract *swapfactory.SwapFactory
|
||||
contract *contracts.SwapFactory
|
||||
contractAddr ethcommon.Address
|
||||
swapTimeout time.Duration
|
||||
|
||||
@@ -132,7 +132,7 @@ type Config struct {
|
||||
GasPrice *big.Int
|
||||
GasLimit uint64
|
||||
|
||||
SwapContract *swapfactory.SwapFactory
|
||||
SwapContract *contracts.SwapFactory
|
||||
SwapContractAddress ethcommon.Address
|
||||
|
||||
SwapManager swap.Manager
|
||||
@@ -205,7 +205,7 @@ func NewBackend(cfg *Config) (Backend, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (b *backend) NewTxSender(asset ethcommon.Address, erc20Contract *swapfactory.IERC20) (txsender.Sender, error) {
|
||||
func (b *backend) NewTxSender(asset ethcommon.Address, erc20Contract *contracts.IERC20) (txsender.Sender, error) {
|
||||
if b.ethPrivKey == nil {
|
||||
return txsender.NewExternalSender(b.ctx, b.env, b.ethClient, b.contractAddr, asset)
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func (b *backend) ChainID() *big.Int {
|
||||
return b.chainID
|
||||
}
|
||||
|
||||
func (b *backend) Contract() *swapfactory.SwapFactory {
|
||||
func (b *backend) Contract() *contracts.SwapFactory {
|
||||
return b.contract
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ func (b *backend) BalanceAt(ctx context.Context, account ethcommon.Address, bloc
|
||||
|
||||
func (b *backend) ERC20BalanceAt(ctx context.Context, token ethcommon.Address, account ethcommon.Address,
|
||||
blockNumber *big.Int) (*big.Int, error) {
|
||||
tokenContract, err := swapfactory.NewIERC20(token, b.ethClient)
|
||||
tokenContract, err := contracts.NewIERC20(token, b.ethClient)
|
||||
if err != nil {
|
||||
return big.NewInt(0), err
|
||||
}
|
||||
@@ -288,7 +288,7 @@ func (b *backend) ERC20BalanceAt(ctx context.Context, token ethcommon.Address, a
|
||||
|
||||
func (b *backend) ERC20Info(ctx context.Context, token ethcommon.Address) (name string, symbol string,
|
||||
decimals uint8, err error) {
|
||||
tokenContract, err := swapfactory.NewIERC20(token, b.ethClient)
|
||||
tokenContract, err := contracts.NewIERC20(token, b.ethClient)
|
||||
if err != nil {
|
||||
return "", "", 18, err
|
||||
}
|
||||
@@ -380,8 +380,8 @@ func (b *backend) LatestBlockTimestamp(ctx context.Context) (time.Time, error) {
|
||||
return time.Unix(int64(hdr.Time), 0), nil
|
||||
}
|
||||
|
||||
func (b *backend) NewSwapFactory(addr ethcommon.Address) (*swapfactory.SwapFactory, error) {
|
||||
return swapfactory.NewSwapFactory(addr, b.ethClient)
|
||||
func (b *backend) NewSwapFactory(addr ethcommon.Address) (*contracts.SwapFactory, error) {
|
||||
return contracts.NewSwapFactory(addr, b.ethClient)
|
||||
}
|
||||
|
||||
func (b *backend) SetEthAddress(addr ethcommon.Address) {
|
||||
@@ -413,7 +413,7 @@ func (b *backend) ClearXMRDepositAddress(id types.Hash) {
|
||||
// address they will be using.
|
||||
// the contract bytecode is validated in the calling code, but this should never be called
|
||||
// for unvalidated contracts.
|
||||
func (b *backend) SetContract(contract *swapfactory.SwapFactory) {
|
||||
func (b *backend) SetContract(contract *contracts.SwapFactory) {
|
||||
b.contract = contract
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/ethereum/block"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
@@ -50,7 +50,7 @@ type ExternalSender struct {
|
||||
// NewExternalSender returns a new ExternalSender
|
||||
func NewExternalSender(ctx context.Context, env common.Environment, ec *ethclient.Client,
|
||||
contractAddr ethcommon.Address, erc20Addr ethcommon.Address) (*ExternalSender, error) {
|
||||
abi, err := swapfactory.SwapFactoryMetaData.GetAbi()
|
||||
abi, err := contracts.SwapFactoryMetaData.GetAbi()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func NewExternalSender(ctx context.Context, env common.Environment, ec *ethclien
|
||||
}
|
||||
|
||||
// SetContract ...
|
||||
func (s *ExternalSender) SetContract(_ *swapfactory.SwapFactory) {}
|
||||
func (s *ExternalSender) SetContract(_ *contracts.SwapFactory) {}
|
||||
|
||||
// SetContractAddress ...
|
||||
func (s *ExternalSender) SetContractAddress(addr ethcommon.Address) {
|
||||
@@ -136,7 +136,7 @@ func (s *ExternalSender) NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte,
|
||||
}
|
||||
|
||||
// SetReady prompts the external sender to sign a set_ready transaction
|
||||
func (s *ExternalSender) SetReady(_swap swapfactory.SwapFactorySwap) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
func (s *ExternalSender) SetReady(_swap contracts.SwapFactorySwap) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
input, err := s.abi.Pack("set_ready", _swap)
|
||||
if err != nil {
|
||||
return ethcommon.Hash{}, nil, err
|
||||
@@ -146,7 +146,7 @@ func (s *ExternalSender) SetReady(_swap swapfactory.SwapFactorySwap) (ethcommon.
|
||||
}
|
||||
|
||||
// Claim prompts the external sender to sign a claim transaction
|
||||
func (s *ExternalSender) Claim(_swap swapfactory.SwapFactorySwap,
|
||||
func (s *ExternalSender) Claim(_swap contracts.SwapFactorySwap,
|
||||
_s [32]byte) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
input, err := s.abi.Pack("claim", _swap, _s)
|
||||
if err != nil {
|
||||
@@ -157,7 +157,7 @@ func (s *ExternalSender) Claim(_swap swapfactory.SwapFactorySwap,
|
||||
}
|
||||
|
||||
// Refund prompts the external sender to sign a refund transaction
|
||||
func (s *ExternalSender) Refund(_swap swapfactory.SwapFactorySwap,
|
||||
func (s *ExternalSender) Refund(_swap contracts.SwapFactorySwap,
|
||||
_s [32]byte) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
input, err := s.abi.Pack("refund", _swap, _s)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"math/big"
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/ethereum/block"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
@@ -16,31 +16,31 @@ import (
|
||||
|
||||
// Sender signs and submits transactions to the chain
|
||||
type Sender interface {
|
||||
SetContract(*swapfactory.SwapFactory)
|
||||
SetContract(*contracts.SwapFactory)
|
||||
SetContractAddress(ethcommon.Address)
|
||||
Approve(spender ethcommon.Address,
|
||||
amount *big.Int) (ethcommon.Hash, *ethtypes.Receipt, error) // for ERC20 swaps
|
||||
NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer ethcommon.Address,
|
||||
_timeoutDuration *big.Int, _nonce *big.Int, _ethAsset types.EthAsset,
|
||||
amount *big.Int) (ethcommon.Hash, *ethtypes.Receipt, error)
|
||||
SetReady(_swap swapfactory.SwapFactorySwap) (ethcommon.Hash, *ethtypes.Receipt, error)
|
||||
Claim(_swap swapfactory.SwapFactorySwap,
|
||||
SetReady(_swap contracts.SwapFactorySwap) (ethcommon.Hash, *ethtypes.Receipt, error)
|
||||
Claim(_swap contracts.SwapFactorySwap,
|
||||
_s [32]byte) (ethcommon.Hash, *ethtypes.Receipt, error)
|
||||
Refund(_swap swapfactory.SwapFactorySwap,
|
||||
Refund(_swap contracts.SwapFactorySwap,
|
||||
_s [32]byte) (ethcommon.Hash, *ethtypes.Receipt, error)
|
||||
}
|
||||
|
||||
type privateKeySender struct {
|
||||
ctx context.Context
|
||||
ec *ethclient.Client
|
||||
contract *swapfactory.SwapFactory
|
||||
erc20Contract *swapfactory.IERC20
|
||||
contract *contracts.SwapFactory
|
||||
erc20Contract *contracts.IERC20
|
||||
txOpts *TxOpts
|
||||
}
|
||||
|
||||
// NewSenderWithPrivateKey returns a new *privateKeySender
|
||||
func NewSenderWithPrivateKey(ctx context.Context, ec *ethclient.Client, contract *swapfactory.SwapFactory,
|
||||
erc20Contract *swapfactory.IERC20, txOpts *TxOpts) Sender {
|
||||
func NewSenderWithPrivateKey(ctx context.Context, ec *ethclient.Client, contract *contracts.SwapFactory,
|
||||
erc20Contract *contracts.IERC20, txOpts *TxOpts) Sender {
|
||||
return &privateKeySender{
|
||||
ctx: ctx,
|
||||
ec: ec,
|
||||
@@ -49,7 +49,7 @@ func NewSenderWithPrivateKey(ctx context.Context, ec *ethclient.Client, contract
|
||||
}
|
||||
}
|
||||
|
||||
func (s *privateKeySender) SetContract(contract *swapfactory.SwapFactory) {
|
||||
func (s *privateKeySender) SetContract(contract *contracts.SwapFactory) {
|
||||
s.contract = contract
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func (s *privateKeySender) NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte
|
||||
return tx.Hash(), receipt, nil
|
||||
}
|
||||
|
||||
func (s *privateKeySender) SetReady(_swap swapfactory.SwapFactorySwap) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
func (s *privateKeySender) SetReady(_swap contracts.SwapFactorySwap) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
s.txOpts.Lock()
|
||||
defer s.txOpts.Unlock()
|
||||
txOpts := s.txOpts.Inner()
|
||||
@@ -124,7 +124,7 @@ func (s *privateKeySender) SetReady(_swap swapfactory.SwapFactorySwap) (ethcommo
|
||||
return tx.Hash(), receipt, nil
|
||||
}
|
||||
|
||||
func (s *privateKeySender) Claim(_swap swapfactory.SwapFactorySwap,
|
||||
func (s *privateKeySender) Claim(_swap contracts.SwapFactorySwap,
|
||||
_s [32]byte) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
s.txOpts.Lock()
|
||||
defer s.txOpts.Unlock()
|
||||
@@ -145,7 +145,7 @@ func (s *privateKeySender) Claim(_swap swapfactory.SwapFactorySwap,
|
||||
return tx.Hash(), receipt, nil
|
||||
}
|
||||
|
||||
func (s *privateKeySender) Refund(_swap swapfactory.SwapFactorySwap,
|
||||
func (s *privateKeySender) Refund(_swap contracts.SwapFactorySwap,
|
||||
_s [32]byte) (ethcommon.Hash, *ethtypes.Receipt, error) {
|
||||
s.txOpts.Lock()
|
||||
defer s.txOpts.Unlock()
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
)
|
||||
|
||||
// GetSwapInfoFilepath returns an info file path with the current timestamp.
|
||||
@@ -22,8 +22,8 @@ func GetSwapRecoveryFilepath(dataDir string) string {
|
||||
return path.Join(dataDir, fmt.Sprintf("recovery-%s.txt", t))
|
||||
}
|
||||
|
||||
// ConvertContractSwapToMsg converts a swapfactory.SwapFactorySwap to a *message.ContractSwap
|
||||
func ConvertContractSwapToMsg(swap swapfactory.SwapFactorySwap) *message.ContractSwap {
|
||||
// ConvertContractSwapToMsg converts a contracts.SwapFactorySwap to a *message.ContractSwap
|
||||
func ConvertContractSwapToMsg(swap contracts.SwapFactorySwap) *message.ContractSwap {
|
||||
return &message.ContractSwap{
|
||||
Owner: swap.Owner,
|
||||
Claimer: swap.Claimer,
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
)
|
||||
|
||||
// InfoFileContents represents the contents of the swap info file used in case
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
type InfoFileContents struct {
|
||||
ContractAddress string
|
||||
ContractSwapID [32]byte
|
||||
ContractSwap swapfactory.SwapFactorySwap
|
||||
ContractSwap contracts.SwapFactorySwap
|
||||
PrivateKeyInfo *mcrypto.PrivateKeyInfo
|
||||
SharedSwapPrivateKey *mcrypto.PrivateKeyInfo
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func WriteContractAddressToFile(infofile, addr string) error {
|
||||
}
|
||||
|
||||
// WriteContractSwapToFile writes the given Swap contract struct to the given file
|
||||
func WriteContractSwapToFile(infofile string, swapID [32]byte, swap swapfactory.SwapFactorySwap) error {
|
||||
func WriteContractSwapToFile(infofile string, swapID [32]byte, swap contracts.SwapFactorySwap) error {
|
||||
file, contents, err := setupFile(infofile)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
)
|
||||
|
||||
// HandleProtocolMessage is called by the network to handle an incoming message.
|
||||
@@ -280,7 +280,7 @@ func (s *swapState) handleRefund(txHash string) (mcrypto.Address, error) {
|
||||
return "", errClaimTxHasNoLogs
|
||||
}
|
||||
|
||||
sa, err := swapfactory.GetSecretFromLog(receipt.Logs[0], "Refunded")
|
||||
sa, err := contracts.GetSecretFromLog(receipt.Logs[0], "Refunded")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ import (
|
||||
common "github.com/athanorlabs/atomic-swap/common"
|
||||
types "github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
net "github.com/athanorlabs/atomic-swap/net"
|
||||
message "github.com/athanorlabs/atomic-swap/net/message"
|
||||
swap "github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
txsender "github.com/athanorlabs/atomic-swap/protocol/txsender"
|
||||
swapfactory "github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
ethereum "github.com/ethereum/go-ethereum"
|
||||
bind "github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
common0 "github.com/ethereum/go-ethereum/common"
|
||||
@@ -135,10 +135,10 @@ func (mr *MockBackendMockRecorder) CodeAt(arg0, arg1, arg2 interface{}) *gomock.
|
||||
}
|
||||
|
||||
// Contract mocks base method.
|
||||
func (m *MockBackend) Contract() *swapfactory.SwapFactory {
|
||||
func (m *MockBackend) Contract() *contracts.SwapFactory {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Contract")
|
||||
ret0, _ := ret[0].(*swapfactory.SwapFactory)
|
||||
ret0, _ := ret[0].(*contracts.SwapFactory)
|
||||
return ret0
|
||||
}
|
||||
|
||||
@@ -437,10 +437,10 @@ func (mr *MockBackendMockRecorder) Net() *gomock.Call {
|
||||
}
|
||||
|
||||
// NewSwapFactory mocks base method.
|
||||
func (m *MockBackend) NewSwapFactory(arg0 common0.Address) (*swapfactory.SwapFactory, error) {
|
||||
func (m *MockBackend) NewSwapFactory(arg0 common0.Address) (*contracts.SwapFactory, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NewSwapFactory", arg0)
|
||||
ret0, _ := ret[0].(*swapfactory.SwapFactory)
|
||||
ret0, _ := ret[0].(*contracts.SwapFactory)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
@@ -452,7 +452,7 @@ func (mr *MockBackendMockRecorder) NewSwapFactory(arg0 interface{}) *gomock.Call
|
||||
}
|
||||
|
||||
// NewTxSender mocks base method.
|
||||
func (m *MockBackend) NewTxSender(arg0 common0.Address, arg1 *swapfactory.IERC20) (txsender.Sender, error) {
|
||||
func (m *MockBackend) NewTxSender(arg0 common0.Address, arg1 *contracts.IERC20) (txsender.Sender, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "NewTxSender", arg0, arg1)
|
||||
ret0, _ := ret[0].(txsender.Sender)
|
||||
@@ -521,7 +521,7 @@ func (mr *MockBackendMockRecorder) SetBaseXMRDepositAddress(arg0 interface{}) *g
|
||||
}
|
||||
|
||||
// SetContract mocks base method.
|
||||
func (m *MockBackend) SetContract(arg0 *swapfactory.SwapFactory) {
|
||||
func (m *MockBackend) SetContract(arg0 *contracts.SwapFactory) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetContract", arg0)
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
"github.com/athanorlabs/atomic-swap/dleq"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
)
|
||||
|
||||
type recoveryState struct {
|
||||
@@ -22,7 +22,7 @@ type recoveryState struct {
|
||||
// which has methods to either claim ether or reclaim monero from an initiated swap.
|
||||
func NewRecoveryState(b backend.Backend, dataDir string, secret *mcrypto.PrivateSpendKey,
|
||||
contractAddr ethcommon.Address,
|
||||
contractSwapID [32]byte, contractSwap swapfactory.SwapFactorySwap) (*recoveryState, error) {
|
||||
contractSwapID [32]byte, contractSwap contracts.SwapFactorySwap) (*recoveryState, error) {
|
||||
kp, err := secret.AsPrivateKeyPair()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
"github.com/athanorlabs/atomic-swap/crypto/secp256k1"
|
||||
"github.com/athanorlabs/atomic-swap/dleq"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/monero"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
@@ -28,7 +29,6 @@ import (
|
||||
pswap "github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/txsender"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrmaker/offers"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
)
|
||||
|
||||
const revertSwapCompleted = "swap is already completed"
|
||||
@@ -57,7 +57,7 @@ type swapState struct {
|
||||
|
||||
// swap contract and timeouts in it; set once contract is deployed
|
||||
contractSwapID [32]byte
|
||||
contractSwap swapfactory.SwapFactorySwap
|
||||
contractSwap contracts.SwapFactorySwap
|
||||
t0, t1 time.Time
|
||||
|
||||
// XMRTaker's keys for this session
|
||||
@@ -99,7 +99,7 @@ func newSwapState(
|
||||
|
||||
var sender txsender.Sender
|
||||
if offer.EthAsset != types.EthAssetETH {
|
||||
erc20Contract, err := swapfactory.NewIERC20(offer.EthAsset.Address(), b.EthClient())
|
||||
erc20Contract, err := contracts.NewIERC20(offer.EthAsset.Address(), b.EthClient())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -326,7 +326,7 @@ func (s *swapState) filterForRefund() (*mcrypto.PrivateSpendKey, error) {
|
||||
)
|
||||
|
||||
for _, log := range logs {
|
||||
matches, err := swapfactory.CheckIfLogIDMatches(log, refundedEvent, s.contractSwapID) //nolint:govet
|
||||
matches, err := contracts.CheckIfLogIDMatches(log, refundedEvent, s.contractSwapID) //nolint:govet
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -342,7 +342,7 @@ func (s *swapState) filterForRefund() (*mcrypto.PrivateSpendKey, error) {
|
||||
return nil, errNoRefundLogsFound
|
||||
}
|
||||
|
||||
sa, err := swapfactory.GetSecretFromLog(&foundLog, refundedEvent)
|
||||
sa, err := contracts.GetSecretFromLog(&foundLog, refundedEvent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get secret from log: %w", err)
|
||||
}
|
||||
@@ -356,11 +356,11 @@ func (s *swapState) tryClaim() (ethcommon.Hash, error) {
|
||||
return ethcommon.Hash{}, err
|
||||
}
|
||||
switch stage {
|
||||
case swapfactory.StageInvalid:
|
||||
case contracts.StageInvalid:
|
||||
return ethcommon.Hash{}, errClaimInvalid
|
||||
case swapfactory.StageCompleted:
|
||||
case contracts.StageCompleted:
|
||||
return ethcommon.Hash{}, errClaimSwapComplete
|
||||
case swapfactory.StagePending, swapfactory.StageReady:
|
||||
case contracts.StagePending, contracts.StageReady:
|
||||
// do nothing
|
||||
default:
|
||||
panic("Unhandled stage value")
|
||||
@@ -381,7 +381,7 @@ func (s *swapState) tryClaim() (ethcommon.Hash, error) {
|
||||
return ethcommon.Hash{}, errClaimPastTime
|
||||
}
|
||||
|
||||
if ts.Before(s.t0) && stage != swapfactory.StageReady {
|
||||
if ts.Before(s.t0) && stage != contracts.StageReady {
|
||||
// TODO: t0 could be 24 hours from now. Don't we want to poll the stage periodically? (#163)
|
||||
// we need to wait until t0 to claim
|
||||
log.Infof("waiting until time %s to claim, time now=%s", s.t0, time.Now())
|
||||
@@ -486,7 +486,7 @@ func (s *swapState) checkContract(txHash ethcommon.Hash) error {
|
||||
return errCannotFindNewLog
|
||||
}
|
||||
|
||||
var event *swapfactory.SwapFactoryNew
|
||||
var event *contracts.SwapFactoryNew
|
||||
for _, log := range receipt.Logs {
|
||||
event, err = s.Contract().ParseNew(*log)
|
||||
if err == nil {
|
||||
|
||||
@@ -11,13 +11,13 @@ import (
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/monero"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
pswap "github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
"github.com/athanorlabs/atomic-swap/tests"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
@@ -61,7 +61,7 @@ func newTestXMRMaker(t *testing.T) *Instance {
|
||||
txOpts, err := bind.NewKeyedTransactorWithChainID(pk, chainID)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, tx, contract, err := swapfactory.DeploySwapFactory(txOpts, ec)
|
||||
_, tx, contract, err := contracts.DeploySwapFactory(txOpts, ec)
|
||||
require.NoError(t, err)
|
||||
|
||||
addr, err := bind.WaitDeployed(context.Background(), ec, tx)
|
||||
@@ -155,13 +155,13 @@ func newSwap(t *testing.T, ss *swapState, claimKey, refundKey types.Hash, amount
|
||||
receipt := tests.MineTransaction(t, ss, tx)
|
||||
|
||||
require.Equal(t, 1, len(receipt.Logs))
|
||||
ss.contractSwapID, err = swapfactory.GetIDFromLog(receipt.Logs[0])
|
||||
ss.contractSwapID, err = contracts.GetIDFromLog(receipt.Logs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
t0, t1, err := swapfactory.GetTimeoutsFromLog(receipt.Logs[0])
|
||||
t0, t1, err := contracts.GetTimeoutsFromLog(receipt.Logs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
ss.contractSwap = swapfactory.SwapFactorySwap{
|
||||
ss.contractSwap = contracts.SwapFactorySwap{
|
||||
Owner: ethAddr,
|
||||
Claimer: ethAddr,
|
||||
PubKeyClaim: claimKey,
|
||||
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
@@ -17,7 +17,7 @@ func checkContractCode(ctx context.Context, b backend.Backend, contractAddr ethc
|
||||
return err
|
||||
}
|
||||
|
||||
expectedCode := ethcommon.FromHex(swapfactory.SwapFactoryMetaData.Bin)
|
||||
expectedCode := ethcommon.FromHex(contracts.SwapFactoryMetaData.Bin)
|
||||
if !bytes.Contains(expectedCode, code) {
|
||||
return errInvalidSwapContract
|
||||
}
|
||||
@@ -25,8 +25,8 @@ func checkContractCode(ctx context.Context, b backend.Backend, contractAddr ethc
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertContractSwap(msg *message.ContractSwap) swapfactory.SwapFactorySwap {
|
||||
return swapfactory.SwapFactorySwap{
|
||||
func convertContractSwap(msg *message.ContractSwap) contracts.SwapFactorySwap {
|
||||
return contracts.SwapFactorySwap{
|
||||
Owner: msg.Owner,
|
||||
Claimer: msg.Claimer,
|
||||
PubKeyClaim: msg.PubKeyClaim,
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/tests"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
@@ -26,7 +26,7 @@ func TestCheckContractCode(t *testing.T) {
|
||||
txOpts, err := bind.NewKeyedTransactorWithChainID(pk, chainID)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, tx, _, err := swapfactory.DeploySwapFactory(txOpts, ec)
|
||||
_, tx, _, err := contracts.DeploySwapFactory(txOpts, ec)
|
||||
require.NoError(t, err)
|
||||
|
||||
addr, err := bind.WaitDeployed(ctx, ec, tx)
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/monero"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/fatih/color" //nolint:misspell
|
||||
@@ -387,7 +387,7 @@ func (s *swapState) handleNotifyClaimed(txHash string) (mcrypto.Address, error)
|
||||
|
||||
log.Infof("counterparty claimed ETH; tx hash=%s", txHash)
|
||||
|
||||
skB, err := swapfactory.GetSecretFromLog(receipt.Logs[0], "Claimed")
|
||||
skB, err := contracts.GetSecretFromLog(receipt.Logs[0], "Claimed")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to get secret from log: %w", err)
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
"github.com/athanorlabs/atomic-swap/dleq"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
pswap "github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
)
|
||||
|
||||
var claimedTopic = common.GetTopic(common.ClaimedEventSignature)
|
||||
@@ -28,7 +28,7 @@ type recoveryState struct {
|
||||
// NewRecoveryState returns a new *xmrmaker.recoveryState,
|
||||
// which has methods to either claim ether or reclaim monero from an initiated swap.
|
||||
func NewRecoveryState(b backend.Backend, dataDir string, secret *mcrypto.PrivateSpendKey,
|
||||
contractSwapID [32]byte, contractSwap swapfactory.SwapFactorySwap) (*recoveryState, error) {
|
||||
contractSwapID [32]byte, contractSwap contracts.SwapFactorySwap) (*recoveryState, error) {
|
||||
kp, err := secret.AsPrivateKeyPair()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -139,7 +139,7 @@ func (s *swapState) filterForClaim() (*mcrypto.PrivateSpendKey, error) {
|
||||
)
|
||||
|
||||
for _, log := range logs {
|
||||
matches, err := swapfactory.CheckIfLogIDMatches(log, claimedEvent, s.contractSwapID) //nolint:govet
|
||||
matches, err := contracts.CheckIfLogIDMatches(log, claimedEvent, s.contractSwapID) //nolint:govet
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (s *swapState) filterForClaim() (*mcrypto.PrivateSpendKey, error) {
|
||||
return nil, errNoClaimLogsFound
|
||||
}
|
||||
|
||||
sa, err := swapfactory.GetSecretFromLog(&foundLog, claimedEvent)
|
||||
sa, err := contracts.GetSecretFromLog(&foundLog, claimedEvent)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get secret from log: %w", err)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
"github.com/athanorlabs/atomic-swap/crypto/secp256k1"
|
||||
"github.com/athanorlabs/atomic-swap/dleq"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/monero"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
@@ -22,7 +23,6 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
pswap "github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/txsender"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/fatih/color" //nolint:misspell
|
||||
@@ -63,7 +63,7 @@ type swapState struct {
|
||||
|
||||
// swap contract and timeouts in it; set once contract is deployed
|
||||
contractSwapID [32]byte
|
||||
contractSwap swapfactory.SwapFactorySwap
|
||||
contractSwap contracts.SwapFactorySwap
|
||||
t0, t1 time.Time
|
||||
|
||||
// next expected network message
|
||||
@@ -103,7 +103,7 @@ func newSwapState(b backend.Backend, offerID types.Hash, infofile string, transf
|
||||
|
||||
var sender txsender.Sender
|
||||
if ethAsset != types.EthAssetETH {
|
||||
erc20Contract, err := swapfactory.NewIERC20(ethAsset.Address(), b.EthClient()) //nolint:govet
|
||||
erc20Contract, err := contracts.NewIERC20(ethAsset.Address(), b.EthClient()) //nolint:govet
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -348,16 +348,16 @@ func (s *swapState) tryRefund() (ethcommon.Hash, error) {
|
||||
return ethcommon.Hash{}, err
|
||||
}
|
||||
switch stage {
|
||||
case swapfactory.StageInvalid:
|
||||
case contracts.StageInvalid:
|
||||
return ethcommon.Hash{}, errRefundInvalid
|
||||
case swapfactory.StageCompleted:
|
||||
case contracts.StageCompleted:
|
||||
return ethcommon.Hash{}, errRefundSwapCompleted
|
||||
case swapfactory.StagePending, swapfactory.StageReady:
|
||||
case contracts.StagePending, contracts.StageReady:
|
||||
// do nothing
|
||||
default:
|
||||
panic("Unhandled stage value")
|
||||
}
|
||||
isReady := stage == swapfactory.StageReady
|
||||
isReady := stage == contracts.StageReady
|
||||
|
||||
ts, err := s.LatestBlockTimestamp(s.ctx)
|
||||
if err != nil {
|
||||
@@ -455,7 +455,7 @@ func (s *swapState) lockETH(amount common.EtherAmount) (ethcommon.Hash, error) {
|
||||
|
||||
// check that the approval is required
|
||||
// TODO: separate to its own function and create unit tests
|
||||
token, err := swapfactory.NewIERC20(s.ethAsset.Address(), s.EthClient())
|
||||
token, err := contracts.NewIERC20(s.ethAsset.Address(), s.EthClient())
|
||||
if err != nil {
|
||||
log.Errorf("failed to instantiate IERC20: %s", s.ethAsset)
|
||||
return ethcommon.Hash{}, err
|
||||
@@ -496,7 +496,7 @@ func (s *swapState) lockETH(amount common.EtherAmount) (ethcommon.Hash, error) {
|
||||
}
|
||||
|
||||
for _, rLog := range receipt.Logs {
|
||||
s.contractSwapID, err = swapfactory.GetIDFromLog(rLog)
|
||||
s.contractSwapID, err = contracts.GetIDFromLog(rLog)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
@@ -508,7 +508,7 @@ func (s *swapState) lockETH(amount common.EtherAmount) (ethcommon.Hash, error) {
|
||||
var t0 *big.Int
|
||||
var t1 *big.Int
|
||||
for _, log := range receipt.Logs {
|
||||
t0, t1, err = swapfactory.GetTimeoutsFromLog(log)
|
||||
t0, t1, err = contracts.GetTimeoutsFromLog(log)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
@@ -519,7 +519,7 @@ func (s *swapState) lockETH(amount common.EtherAmount) (ethcommon.Hash, error) {
|
||||
|
||||
s.setTimeouts(t0, t1)
|
||||
|
||||
s.contractSwap = swapfactory.SwapFactorySwap{
|
||||
s.contractSwap = contracts.SwapFactorySwap{
|
||||
Owner: s.EthAddress(),
|
||||
Claimer: s.xmrmakerAddress,
|
||||
PubKeyClaim: cmtXMRMaker,
|
||||
@@ -546,8 +546,8 @@ func (s *swapState) ready() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if stage != swapfactory.StagePending {
|
||||
return fmt.Errorf("can not set contract to ready when swap stage is %s", swapfactory.StageToString(stage))
|
||||
if stage != contracts.StagePending {
|
||||
return fmt.Errorf("can not set contract to ready when swap stage is %s", contracts.StageToString(stage))
|
||||
}
|
||||
_, _, err = s.sender.SetReady(s.contractSwap)
|
||||
if err != nil {
|
||||
|
||||
@@ -13,12 +13,12 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/net"
|
||||
"github.com/athanorlabs/atomic-swap/net/message"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
pswap "github.com/athanorlabs/atomic-swap/protocol/swap"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
"github.com/athanorlabs/atomic-swap/tests"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
@@ -55,7 +55,7 @@ func newBackend(t *testing.T) backend.Backend {
|
||||
txOpts, err := bind.NewKeyedTransactorWithChainID(pk, chainID)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, tx, contract, err := swapfactory.DeploySwapFactory(txOpts, ec)
|
||||
_, tx, contract, err := contracts.DeploySwapFactory(txOpts, ec)
|
||||
require.NoError(t, err)
|
||||
|
||||
addr, err := bind.WaitDeployed(ctx, ec, tx)
|
||||
@@ -86,7 +86,7 @@ func newXMRMakerBackend(t *testing.T) backend.Backend {
|
||||
|
||||
txOpts, err := bind.NewKeyedTransactorWithChainID(pk, chainID)
|
||||
require.NoError(t, err)
|
||||
addr, _, contract, err := swapfactory.DeploySwapFactory(txOpts, ec)
|
||||
addr, _, contract, err := contracts.DeploySwapFactory(txOpts, ec)
|
||||
require.NoError(t, err)
|
||||
|
||||
bcfg := &backend.Config{
|
||||
@@ -191,7 +191,7 @@ func TestSwapState_HandleProtocolMessage_SendKeysMessage_Refund(t *testing.T) {
|
||||
// check swap is marked completed
|
||||
stage, err := s.Contract().Swaps(nil, s.contractSwapID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, swapfactory.StageCompleted, stage)
|
||||
require.Equal(t, contracts.StageCompleted, stage)
|
||||
}
|
||||
|
||||
func TestSwapState_NotifyXMRLock(t *testing.T) {
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
"github.com/athanorlabs/atomic-swap/monero"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrmaker"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/xmrtaker"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
@@ -91,7 +91,7 @@ func (r *recoverer) WalletFromSharedSecret(pk *mcrypto.PrivateKeyInfo) (mcrypto.
|
||||
// RecoverFromXMRMakerSecretAndContract recovers funds by either claiming ether or reclaiming locked monero.
|
||||
func (r *recoverer) RecoverFromXMRMakerSecretAndContract(b backend.Backend, dataDir string,
|
||||
xmrmakerSecret, contractAddr string, swapID [32]byte,
|
||||
swap swapfactory.SwapFactorySwap) (*xmrmaker.RecoveryResult, error) {
|
||||
swap contracts.SwapFactorySwap) (*xmrmaker.RecoveryResult, error) {
|
||||
bs, err := hex.DecodeString(xmrmakerSecret)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode XMRMaker's secret: %w", err)
|
||||
@@ -113,7 +113,7 @@ func (r *recoverer) RecoverFromXMRMakerSecretAndContract(b backend.Backend, data
|
||||
|
||||
// RecoverFromXMRTakerSecretAndContract recovers funds by either claiming locked monero or refunding ether.
|
||||
func (r *recoverer) RecoverFromXMRTakerSecretAndContract(b backend.Backend, dataDir string,
|
||||
xmrtakerSecret string, swapID [32]byte, swap swapfactory.SwapFactorySwap) (*xmrtaker.RecoveryResult, error) {
|
||||
xmrtakerSecret string, swapID [32]byte, swap contracts.SwapFactorySwap) (*xmrtaker.RecoveryResult, error) {
|
||||
as, err := hex.DecodeString(xmrtakerSecret)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode XMRTaker's secret: %w", err)
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"github.com/athanorlabs/atomic-swap/common"
|
||||
"github.com/athanorlabs/atomic-swap/common/types"
|
||||
mcrypto "github.com/athanorlabs/atomic-swap/crypto/monero"
|
||||
contracts "github.com/athanorlabs/atomic-swap/ethereum"
|
||||
pcommon "github.com/athanorlabs/atomic-swap/protocol"
|
||||
"github.com/athanorlabs/atomic-swap/protocol/backend"
|
||||
"github.com/athanorlabs/atomic-swap/swapfactory"
|
||||
"github.com/athanorlabs/atomic-swap/tests"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
@@ -35,9 +35,9 @@ func newSwap(
|
||||
setReady bool,
|
||||
) (
|
||||
ethcommon.Address,
|
||||
*swapfactory.SwapFactory,
|
||||
*contracts.SwapFactory,
|
||||
[32]byte,
|
||||
swapfactory.SwapFactorySwap,
|
||||
contracts.SwapFactorySwap,
|
||||
) {
|
||||
tm := big.NewInt(defaultTimeout)
|
||||
|
||||
@@ -47,7 +47,7 @@ func newSwap(
|
||||
txOpts, err := bind.NewKeyedTransactorWithChainID(pk, chainID)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, tx, contract, err := swapfactory.DeploySwapFactory(txOpts, ec)
|
||||
_, tx, contract, err := contracts.DeploySwapFactory(txOpts, ec)
|
||||
require.NoError(t, err)
|
||||
|
||||
addr, err := bind.WaitDeployed(context.Background(), ec, tx)
|
||||
@@ -63,13 +63,13 @@ func newSwap(
|
||||
receipt := tests.MineTransaction(t, ec, tx)
|
||||
|
||||
require.Equal(t, 1, len(receipt.Logs))
|
||||
swapID, err := swapfactory.GetIDFromLog(receipt.Logs[0])
|
||||
swapID, err := contracts.GetIDFromLog(receipt.Logs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
t0, t1, err := swapfactory.GetTimeoutsFromLog(receipt.Logs[0])
|
||||
t0, t1, err := contracts.GetTimeoutsFromLog(receipt.Logs[0])
|
||||
require.NoError(t, err)
|
||||
|
||||
swap := swapfactory.SwapFactorySwap{
|
||||
swap := contracts.SwapFactorySwap{
|
||||
Owner: txOpts.From,
|
||||
Claimer: xmrmakerAddress,
|
||||
PubKeyClaim: claimKey,
|
||||
@@ -92,7 +92,7 @@ func newSwap(
|
||||
func newBackend(
|
||||
t *testing.T,
|
||||
addr ethcommon.Address,
|
||||
contract *swapfactory.SwapFactory,
|
||||
contract *contracts.SwapFactory,
|
||||
privkey *ecdsa.PrivateKey,
|
||||
) backend.Backend {
|
||||
pk := privkey
|
||||
|
||||
@@ -16,9 +16,9 @@ fi
|
||||
"${ABIGEN}" \
|
||||
--abi ethereum/abi/SwapFactory.abi \
|
||||
--bin ethereum/bin/SwapFactory.bin \
|
||||
--pkg swapfactory \
|
||||
--pkg contracts \
|
||||
--type SwapFactory \
|
||||
--out swapfactory/swap_factory.go
|
||||
--out ethereum/swap_factory.go
|
||||
|
||||
"${SOLC_BIN}" --abi ethereum/contracts/ERC20Mock.sol -o ethereum/abi/ --overwrite
|
||||
"${SOLC_BIN}" --bin ethereum/contracts/ERC20Mock.sol -o ethereum/bin/ --overwrite
|
||||
@@ -26,13 +26,13 @@ fi
|
||||
"${ABIGEN}" \
|
||||
--abi ethereum/abi/ERC20Mock.abi \
|
||||
--bin ethereum/bin/ERC20Mock.bin \
|
||||
--pkg swapfactory \
|
||||
--pkg contracts \
|
||||
--type ERC20Mock \
|
||||
--out swapfactory/erc20_mock.go
|
||||
--out ethereum/erc20_mock.go
|
||||
|
||||
"${SOLC_BIN}" --abi ethereum/contracts/IERC20Metadata.sol -o ethereum/abi/ --overwrite
|
||||
"${ABIGEN}" \
|
||||
--abi ethereum/abi/IERC20Metadata.abi \
|
||||
--pkg swapfactory \
|
||||
--pkg contracts \
|
||||
--type IERC20 \
|
||||
--out swapfactory/ierc20.go
|
||||
--out ethereum/ierc20.go
|
||||
|
||||
@@ -39,7 +39,7 @@ sleep 3 # Alice's swapd is a bootnode for Bob and Charlie's swapd
|
||||
|
||||
start-swapd bob \
|
||||
--dev-xmrmaker \
|
||||
--bootnodes /ip4/127.0.0.1/tcp/9933/p2p/12D3KooWAYn1T8Lu122Pav4zAogjpeU61usLTNZpLRNh9gCqY6X2 \
|
||||
--bootnodes /ip4/127.0.0.1/tcp/9933/p2p/12D3KooWAAxG7eTEHr2uBVw3BDMxYsxyqfKvj3qqqpRGtTfuzTuH \
|
||||
--wallet-file test-wallet \
|
||||
--deploy
|
||||
|
||||
@@ -48,7 +48,7 @@ start-swapd charlie \
|
||||
--ethereum-privkey "${CHARLIE_ETH_KEY}" \
|
||||
--libp2p-port 9955 \
|
||||
--rpc-port 5003 \
|
||||
--bootnodes /ip4/127.0.0.1/tcp/9933/p2p/12D3KooWAYn1T8Lu122Pav4zAogjpeU61usLTNZpLRNh9gCqY6X2 \
|
||||
--bootnodes /ip4/127.0.0.1/tcp/9933/p2p/12D3KooWAAxG7eTEHr2uBVw3BDMxYsxyqfKvj3qqqpRGtTfuzTuH \
|
||||
--deploy
|
||||
|
||||
sleep 3 # Time for Bob and Charlie's swapd to be fully up
|
||||
|
||||
@@ -1 +1 @@
|
||||
b0d2d5dac3cc02d8db12e4a9703d6175cd4e9531027268b0566f50b85ca2e9410add5985d336d208fcb66c429f3abab7ae4d42f94714b54ea6fb8558d3a72df9
|
||||
d97f10b75b1d5772fa07468f20329b13489b2bf9165e57ae0fe777630830ee9405462a30fedaaa5ebe0f30d8a8c4dc8f141876cd3fc1c8b95a898ec64bc70668
|
||||
@@ -33,12 +33,12 @@ var testPackages = []struct {
|
||||
numKeys int
|
||||
}{
|
||||
{"cmd/swapd", 2},
|
||||
{"ethereum", 16},
|
||||
{"ethereum/block", 2},
|
||||
{"protocol/backend", 2},
|
||||
{"protocol/xmrmaker", 2},
|
||||
{"protocol/xmrtaker", 2},
|
||||
{"recover", 2},
|
||||
{"swapfactory", 16},
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -383,11 +383,13 @@ func TestRefund_XMRMakerCancels_untilAfterT1(t *testing.T) {
|
||||
// funds, but XMRMaker goes offline until past isReady==true and t0, but comes online before t1. When
|
||||
// XMRMaker comes back online, he should claim the ETH, causing XMRTaker to also claim the XMR.
|
||||
func TestRefund_XMRMakerCancels_afterIsReady(t *testing.T) {
|
||||
// Skipping test as it can't guarantee that the refund will happen before the swap completes
|
||||
// successfully: // https://github.com/athanorlabs/atomic-swap/issues/144
|
||||
t.Skip()
|
||||
testRefundXMRMakerCancels(t, 30, types.CompletedSuccess)
|
||||
}
|
||||
|
||||
func testRefundXMRMakerCancels(t *testing.T, swapTimeout uint64, expectedExitStatus types.Status) {
|
||||
t.Skip("wtf")
|
||||
func testRefundXMRMakerCancels(t *testing.T, swapTimeout uint64, expectedExitStatus types.Status) { //nolint:unused
|
||||
if os.Getenv(generateBlocksEnv) != falseStr {
|
||||
generateBlocks(64)
|
||||
}
|
||||
@@ -459,7 +461,6 @@ func testRefundXMRMakerCancels(t *testing.T, swapTimeout uint64, expectedExitSta
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(providers))
|
||||
require.GreaterOrEqual(t, len(providers[0]), 2)
|
||||
|
||||
takerStatusCh, err := awsc.TakeOfferAndSubscribe(providers[0][0], offerID, 0.05)
|
||||
require.NoError(t, err)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user