From a17f95d4145a8f40add421292a5f685f125a733f Mon Sep 17 00:00:00 2001 From: Dmitry Holodov Date: Sun, 9 Apr 2023 03:08:17 -0500 Subject: [PATCH] SwapFactory to SwapCreator rename, upgrade to solc 0.8.19 (#372) --- .github/workflows/unit-tests.yml | 1 + cmd/swapd/contract.go | 48 +- cmd/swapd/contract_test.go | 14 +- cmd/swapd/main.go | 38 +- cmd/swapd/main_test.go | 30 +- codecov.yml | 2 +- common/config.go | 16 +- common/consts.go | 2 +- daemon/swap_daemon.go | 20 +- daemon/swap_daemon_test.go | 24 +- db/recovery_db.go | 4 +- db/recovery_db_test.go | 10 +- db/types.go | 10 +- docs/developing.md | 23 +- docs/local.md | 4 +- docs/stagenet.md | 2 +- ethereum/aggregator_v3_interface.go | 8 +- ethereum/block/testdata/generate-bindings.sh | 2 +- ethereum/block/ut_contract_test.go | 10 +- ...ract.go => check_swap_creator_contract.go} | 46 +- ...go => check_swap_creator_contract_test.go} | 69 +-- .../{SwapFactory.sol => SwapCreator.sol} | 2 +- ethereum/deploy_util.go | 14 +- ethereum/erc20_mock.go | 10 +- ethereum/erc20_mock_test.go | 8 +- ethereum/extethclient/eth_wallet_client.go | 2 +- ethereum/ierc20.go | 8 +- ethereum/{swap_factory.go => swap_creator.go} | 428 +++++++++--------- ...ory_marshal.go => swap_creator_marshal.go} | 12 +- ...l_test.go => swap_creator_marshal_test.go} | 12 +- ...p_factory_test.go => swap_creator_test.go} | 71 +-- ethereum/utils.go | 18 +- ethereum/watcher/watcher.go | 16 +- net/host.go | 2 +- net/host_test.go | 8 +- net/message/message.go | 2 +- net/message/relay_message.go | 10 +- net/relay_test.go | 4 +- protocol/backend/backend.go | 54 +-- protocol/swap/types.go | 2 +- protocol/swap/types_test.go | 2 +- protocol/txsender/external_sender.go | 10 +- protocol/txsender/sender.go | 20 +- protocol/xmrmaker/checks.go | 6 +- protocol/xmrmaker/claim.go | 10 +- protocol/xmrmaker/claim_test.go | 10 +- protocol/xmrmaker/event_test.go | 2 +- protocol/xmrmaker/instance_test.go | 26 +- protocol/xmrmaker/message_handler.go | 4 +- protocol/xmrmaker/swap_state.go | 24 +- protocol/xmrmaker/swap_state_ongoing_test.go | 8 +- protocol/xmrmaker/swap_state_test.go | 18 +- protocol/xmrtaker/claim.go | 2 +- protocol/xmrtaker/event_test.go | 2 +- protocol/xmrtaker/instance_test.go | 4 +- protocol/xmrtaker/message_handler.go | 2 +- protocol/xmrtaker/swap_state.go | 18 +- protocol/xmrtaker/swap_state_ongoing_test.go | 4 +- protocol/xmrtaker/swap_state_test.go | 26 +- relayer/claim_request.go | 20 +- relayer/claim_request_test.go | 26 +- relayer/forwarder.go | 28 +- relayer/submit_transaction.go | 6 +- relayer/validate.go | 24 +- relayer/validate_test.go | 54 +-- rpc/server.go | 4 + scripts/generate-bindings.sh | 2 +- scripts/run-integration-tests.sh | 12 +- 68 files changed, 736 insertions(+), 704 deletions(-) rename ethereum/{check_swap_factory_contract.go => check_swap_creator_contract.go} (93%) rename ethereum/{check_swap_factory_contract_test.go => check_swap_creator_contract_test.go} (64%) rename ethereum/contracts/{SwapFactory.sol => SwapCreator.sol} (99%) rename ethereum/{swap_factory.go => swap_creator.go} (78%) rename ethereum/{swap_factory_marshal.go => swap_creator_marshal.go} (82%) rename ethereum/{swap_factory_marshal_test.go => swap_creator_marshal_test.go} (87%) rename ethereum/{swap_factory_test.go => swap_creator_test.go} (89%) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index d83655c8..1d871390 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -59,6 +59,7 @@ jobs: - name: Run unit tests env: ETH_MAINNET_ENDPOINT: ${{ secrets.ETH_MAINNET_ENDPOINT }} + ETH_SEPOLIA_ENDPOINT: ${{ secrets.ETH_SEPOLIA_ENDPOINT }} run: ./scripts/run-unit-tests.sh - name: Upload code coverage diff --git a/cmd/swapd/contract.go b/cmd/swapd/contract.go index 945d41c8..053ac1d2 100644 --- a/cmd/swapd/contract.go +++ b/cmd/swapd/contract.go @@ -30,87 +30,87 @@ var ( ) type contractAddresses struct { - SwapFactory ethcommon.Address `json:"swapFactory" validate:"required"` - Forwarder ethcommon.Address `json:"forwarder" validate:"required"` + SwapCreatorAddr ethcommon.Address `json:"swapCreatorAddr" validate:"required"` + ForwarderAddr ethcommon.Address `json:"forwarderAddr" validate:"required"` } -func getOrDeploySwapFactory( +func getOrDeploySwapCreator( ctx context.Context, - address ethcommon.Address, + swapCreatorAddr ethcommon.Address, env common.Environment, dataDir string, ec extethclient.EthClient, - forwarderAddress ethcommon.Address, + forwarderAddr ethcommon.Address, ) (ethcommon.Address, error) { var err error - if env != common.Mainnet && (address == ethcommon.Address{}) { + if env != common.Mainnet && (swapCreatorAddr == ethcommon.Address{}) { // we're on a development or testnet environment and we have no deployed contract, // so let's deploy one - address, _, err = deploySwapFactory(ctx, ec.Raw(), ec.PrivateKey(), forwarderAddress, dataDir) + swapCreatorAddr, _, err = deploySwapCreator(ctx, ec.Raw(), ec.PrivateKey(), forwarderAddr, dataDir) if err != nil { - return ethcommon.Address{}, fmt.Errorf("failed to deploy swap factory: %w", err) + return ethcommon.Address{}, fmt.Errorf("failed to deploy swap creator: %w", err) } } else { // otherwise, load the contract from the given address // and check that its bytecode is valid (ie. matches the // bytecode of this repo's swap contract) - _, err = contracts.CheckSwapFactoryContractCode(ctx, ec.Raw(), address) + _, err = contracts.CheckSwapCreatorContractCode(ctx, ec.Raw(), swapCreatorAddr) if err != nil { return ethcommon.Address{}, err } } - return address, nil + return swapCreatorAddr, nil } -func deploySwapFactory( +func deploySwapCreator( ctx context.Context, ec *ethclient.Client, privkey *ecdsa.PrivateKey, - forwarderAddress ethcommon.Address, + forwarderAddr ethcommon.Address, dataDir string, -) (ethcommon.Address, *contracts.SwapFactory, error) { +) (ethcommon.Address, *contracts.SwapCreator, error) { if privkey == nil { return ethcommon.Address{}, nil, errNoEthereumPrivateKey } - if (forwarderAddress == ethcommon.Address{}) { + if (forwarderAddr == ethcommon.Address{}) { // deploy forwarder contract as well var err error - forwarderAddress, err = contracts.DeployGSNForwarderWithKey(ctx, ec, privkey) + forwarderAddr, err = contracts.DeployGSNForwarderWithKey(ctx, ec, privkey) if err != nil { return ethcommon.Address{}, nil, err } } else { - if err := contracts.CheckForwarderContractCode(ctx, ec, forwarderAddress); err != nil { + if err := contracts.CheckForwarderContractCode(ctx, ec, forwarderAddr); err != nil { return ethcommon.Address{}, nil, err } } - swapFactoryAddress, sf, err := contracts.DeploySwapFactoryWithKey(ctx, ec, privkey, forwarderAddress) + swapCreatorAddr, sf, err := contracts.DeploySwapCreatorWithKey(ctx, ec, privkey, forwarderAddr) if err != nil { return ethcommon.Address{}, nil, err } - // store the contract address on disk - err = writeContractAddressToFile( + // store the contract addresses on disk + err = writeContractAddressesToFile( path.Join(dataDir, contractAddressesFile), &contractAddresses{ - SwapFactory: swapFactoryAddress, - Forwarder: forwarderAddress, + SwapCreatorAddr: swapCreatorAddr, + ForwarderAddr: forwarderAddr, }, ) if err != nil { return ethcommon.Address{}, nil, fmt.Errorf("failed to write contract address to file: %w", err) } - return swapFactoryAddress, sf, nil + return swapCreatorAddr, sf, nil } -// writeContractAddressToFile writes the contract address to the given file -func writeContractAddressToFile(filePath string, addresses *contractAddresses) error { +// writeContractAddressesToFile writes the contract addresses to the given file +func writeContractAddressesToFile(filePath string, addresses *contractAddresses) error { jsonData, err := vjson.MarshalIndentStruct(addresses, "", " ") if err != nil { return err diff --git a/cmd/swapd/contract_test.go b/cmd/swapd/contract_test.go index 8a683be6..165ca8ee 100644 --- a/cmd/swapd/contract_test.go +++ b/cmd/swapd/contract_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetOrDeploySwapFactory_DeployNoForwarder(t *testing.T) { +func TestGetOrDeploySwapCreator_DeployNoForwarder(t *testing.T) { pk := tests.GetTakerTestKey(t) ec := extethclient.CreateTestClient(t, pk) tmpDir := t.TempDir() @@ -24,7 +24,7 @@ func TestGetOrDeploySwapFactory_DeployNoForwarder(t *testing.T) { forwarder, err := contracts.DeployGSNForwarderWithKey(context.Background(), ec.Raw(), pk) require.NoError(t, err) - _, err = getOrDeploySwapFactory( + _, err = getOrDeploySwapCreator( context.Background(), ethcommon.Address{}, common.Development, @@ -35,12 +35,12 @@ func TestGetOrDeploySwapFactory_DeployNoForwarder(t *testing.T) { require.NoError(t, err) } -func TestGetOrDeploySwapFactory_DeployForwarderAlso(t *testing.T) { +func TestGetOrDeploySwapCreator_DeployForwarderAlso(t *testing.T) { pk := tests.GetTakerTestKey(t) ec := extethclient.CreateTestClient(t, pk) tmpDir := t.TempDir() - _, err := getOrDeploySwapFactory( + _, err := getOrDeploySwapCreator( context.Background(), ethcommon.Address{}, common.Development, @@ -51,7 +51,7 @@ func TestGetOrDeploySwapFactory_DeployForwarderAlso(t *testing.T) { require.NoError(t, err) } -func TestGetOrDeploySwapFactory_Get(t *testing.T) { +func TestGetOrDeploySwapCreator_Get(t *testing.T) { pk := tests.GetTakerTestKey(t) ec := extethclient.CreateTestClient(t, pk) tmpDir := t.TempDir() @@ -61,7 +61,7 @@ func TestGetOrDeploySwapFactory_Get(t *testing.T) { t.Log(forwarder) // deploy and get address - address, err := getOrDeploySwapFactory( + address, err := getOrDeploySwapCreator( context.Background(), ethcommon.Address{}, common.Development, @@ -71,7 +71,7 @@ func TestGetOrDeploySwapFactory_Get(t *testing.T) { ) require.NoError(t, err) - addr2, err := getOrDeploySwapFactory( + addr2, err := getOrDeploySwapCreator( context.Background(), address, common.Development, diff --git a/cmd/swapd/main.go b/cmd/swapd/main.go index 05a37b4f..c85cf334 100644 --- a/cmd/swapd/main.go +++ b/cmd/swapd/main.go @@ -151,7 +151,7 @@ func cliApp() *cli.App { }, &cli.StringFlag{ Name: flagContractAddress, - Usage: "Address of instance of SwapFactory.sol already deployed on-chain; required if running on mainnet", + Usage: "Address of instance of SwapCreator.sol already deployed on-chain; required if running on mainnet", }, &cli.StringSliceFlag{ Name: flagBootnodes, @@ -362,17 +362,17 @@ func getEnvConfig(c *cli.Context, devXMRMaker bool, devXMRTaker bool) (*common.C return nil, errFlagsMutuallyExclusive(flagDeploy, flagContractAddress) } // Zero out the contract address, we'll set its final value after deploying - conf.SwapFactoryAddress = ethcommon.Address{} + conf.SwapCreatorAddr = ethcommon.Address{} } else { contractAddrStr := c.String(flagContractAddress) if contractAddrStr != "" { if !ethcommon.IsHexAddress(contractAddrStr) { return nil, fmt.Errorf("%q requires a valid ethereum address", flagContractAddress) } - conf.SwapFactoryAddress = ethcommon.HexToAddress(contractAddrStr) + conf.SwapCreatorAddr = ethcommon.HexToAddress(contractAddrStr) } - if conf.SwapFactoryAddress == (ethcommon.Address{}) { + if conf.SwapCreatorAddr == (ethcommon.Address{}) { return nil, fmt.Errorf("flag %q or %q is required for env=%s", flagDeploy, flagContractAddress, env) } } @@ -380,42 +380,44 @@ func getEnvConfig(c *cli.Context, devXMRMaker bool, devXMRTaker bool) (*common.C return conf, nil } -// validateOrDeployContracts validates or deploys the swap factory. The SwapFactoryAddress field +// validateOrDeployContracts validates or deploys the swap creator. The SwapCreatorAddr field // of envConf should be all zeros if deploying and its value will be replaced by the new deployed // contract. func validateOrDeployContracts(c *cli.Context, envConf *common.Config, ec extethclient.EthClient) error { deploy := c.Bool(flagDeploy) - if deploy && envConf.SwapFactoryAddress != (ethcommon.Address{}) { + if deploy && envConf.SwapCreatorAddr != (ethcommon.Address{}) { panic("contract address should have been zeroed when envConf was initialized") } - // forwarderAddress is set only if we're deploying the swap contract, and the --forwarder-address - // flag is set. otherwise, if we're deploying and the flag isn't set, we also deploy the forwarder. - var forwarderAddress ethcommon.Address - forwarderAddressStr := c.String(flagForwarderAddress) - if deploy && forwarderAddressStr != "" { - if !ethcommon.IsHexAddress(forwarderAddressStr) { + // forwarderAddr is set only if we're deploying the swap creator contract + // and the --forwarder-address flag is set. Otherwise, if we're deploying + // and this flag isn't set, we deploy both the forwarder and the swap + // creator contracts. + var forwarderAddr ethcommon.Address + forwarderAddrStr := c.String(flagForwarderAddress) + if deploy && forwarderAddrStr != "" { + if !ethcommon.IsHexAddress(forwarderAddrStr) { return fmt.Errorf("%q requires a valid ethereum address", flagForwarderAddress) } - forwarderAddress = ethcommon.HexToAddress(forwarderAddressStr) - } else if !deploy && forwarderAddressStr != "" { + forwarderAddr = ethcommon.HexToAddress(forwarderAddrStr) + } else if !deploy && forwarderAddrStr != "" { return fmt.Errorf("using flag %q requires the %q flag", flagForwarderAddress, flagDeploy) } - contractAddr, err := getOrDeploySwapFactory( + swapCreatorAddr, err := getOrDeploySwapCreator( c.Context, - envConf.SwapFactoryAddress, + envConf.SwapCreatorAddr, envConf.Env, envConf.DataDir, ec, - forwarderAddress, + forwarderAddr, ) if err != nil { return err } - envConf.SwapFactoryAddress = contractAddr + envConf.SwapCreatorAddr = swapCreatorAddr return nil } diff --git a/cmd/swapd/main_test.go b/cmd/swapd/main_test.go index 4c84fb82..ac799878 100644 --- a/cmd/swapd/main_test.go +++ b/cmd/swapd/main_test.go @@ -96,19 +96,19 @@ func TestDaemon_DevXMRTaker(t *testing.T) { require.NoError(t, err) m := make(map[string]string) require.NoError(t, json.Unmarshal(data, &m)) - swapFactoryAddr, ok := m["swapFactory"] + swapCreatorAddr, ok := m["swapCreatorAddr"] require.True(t, ok) - forwarderAddr, ok := m["forwarder"] + forwarderAddr, ok := m["forwarderAddr"] require.True(t, ok) ec, _ := tests.NewEthClient(t) ecCtx := context.Background() discoveredForwarderAddr, err := - contracts.CheckSwapFactoryContractCode(ecCtx, ec, ethcommon.HexToAddress(swapFactoryAddr)) + contracts.CheckSwapCreatorContractCode(ecCtx, ec, ethcommon.HexToAddress(swapCreatorAddr)) require.NoError(t, err) require.Equal(t, strings.ToLower(discoveredForwarderAddr.Hex()), forwarderAddr) - // something is seriously wrong if this next check fails, as CheckSwapFactoryContractCode + // something is seriously wrong if this next check fails, as CheckSwapCreatorContractCode // should have already validated the forwarder bytecode err = contracts.CheckForwarderContractCode(ecCtx, ec, ethcommon.HexToAddress(forwarderAddr)) require.NoError(t, err) @@ -120,7 +120,7 @@ func TestDaemon_DevXMRMaker(t *testing.T) { ec, _ := tests.NewEthClient(t) // We tested --deploy with the taker, so test passing the contract address here - swapFactoryAddr, _, err := deploySwapFactory(context.Background(), ec, key, ethcommon.Address{}, t.TempDir()) + swapCreatorAddr, _, err := deploySwapCreator(context.Background(), ec, key, ethcommon.Address{}, t.TempDir()) require.NoError(t, err) flags := []string{ @@ -128,7 +128,7 @@ func TestDaemon_DevXMRMaker(t *testing.T) { fmt.Sprintf("--%s", flagDevXMRMaker), fmt.Sprintf("--%s=dev", flagEnv), fmt.Sprintf("--%s=debug", flagLogLevel), - fmt.Sprintf("--%s=%s", flagContractAddress, swapFactoryAddr), + fmt.Sprintf("--%s=%s", flagContractAddress, swapCreatorAddr), fmt.Sprintf("--%s=%s", flagDataDir, t.TempDir()), fmt.Sprintf("--%s=%d", flagRPCPort, rpcPort), fmt.Sprintf("--%s=0", flagLibp2pPort), @@ -157,9 +157,9 @@ func TestDaemon_BadFlags(t *testing.T) { ec, _ := tests.NewEthClient(t) ctx, _ := newTestContext(t) - swapFactoryAddr, swapFactory, err := deploySwapFactory(ctx, ec, key, ethcommon.Address{}, t.TempDir()) + swapCreatorAddr, swapCreator, err := deploySwapCreator(ctx, ec, key, ethcommon.Address{}, t.TempDir()) require.NoError(t, err) - forwarderAddr, err := swapFactory.TrustedForwarder(nil) + forwarderAddr, err := swapCreator.TrustedForwarder(nil) require.NoError(t, err) baseFlags := []string{ @@ -184,10 +184,10 @@ func TestDaemon_BadFlags(t *testing.T) { expectErr: `flag "deploy" or "contract-address" is required for env=dev`, }, { - description: "deploy SwapFactory with invalid forwarder", + description: "deploy SwapCreator with invalid forwarder", extraFlags: []string{ fmt.Sprintf("--%s", flagDeploy), - fmt.Sprintf("--%s=%s", flagForwarderAddress, swapFactoryAddr), // passing wrong contract + fmt.Sprintf("--%s=%s", flagForwarderAddress, swapCreatorAddr), // passing wrong contract }, expectErr: "does not contain correct Forwarder code", }, @@ -204,19 +204,19 @@ func TestDaemon_BadFlags(t *testing.T) { extraFlags: []string{ fmt.Sprintf("--%s=%s", flagForwarderAddress, forwarderAddr), // next flag is needed, or we fail on a different error first - fmt.Sprintf("--%s=%s", flagContractAddress, swapFactoryAddr), + fmt.Sprintf("--%s=%s", flagContractAddress, swapCreatorAddr), }, expectErr: fmt.Sprintf(`using flag "%s" requires the "%s" flag`, flagForwarderAddress, flagDeploy), }, { - description: "pass invalid SwapFactory contract", + description: "pass invalid SwapCreator contract", extraFlags: []string{ fmt.Sprintf("--%s=%s", flagContractAddress, forwarderAddr), // passing wrong contract }, - expectErr: "does not contain correct SwapFactory code", + expectErr: "does not contain correct SwapCreator code", }, { - description: "pass SwapFactory contract an invalid address (wrong length)", + description: "pass SwapCreator contract an invalid address (wrong length)", extraFlags: []string{ fmt.Sprintf("--%s=%s", flagContractAddress, "0xFFFF"), // too short }, @@ -226,7 +226,7 @@ func TestDaemon_BadFlags(t *testing.T) { // this one also happens when people accidentally confuse swapd with swapcli description: "forgot to prefix the flag name with dashes", extraFlags: []string{ - flagContractAddress, swapFactoryAddr.String(), + flagContractAddress, swapCreatorAddr.String(), }, expectErr: fmt.Sprintf("unknown command %q", flagContractAddress), }, diff --git a/codecov.yml b/codecov.yml index a0a56d34..af8e861f 100644 --- a/codecov.yml +++ b/codecov.yml @@ -13,7 +13,7 @@ coverage: # Don't calculate code coverage percentages on generated abigen files # or our profiling code ignore: - - ethereum/swap_factory.go + - ethereum/swap_creator.go - ethereum/aggregator_v3_interface.go - ethereum/erc20_mock.go - ethereum/ierc20.go diff --git a/common/config.go b/common/config.go index 60677b86..c0c3e696 100644 --- a/common/config.go +++ b/common/config.go @@ -33,12 +33,12 @@ type MoneroNode struct { // Config contains constants that are defaults for various environments type Config struct { - Env Environment - DataDir string - MoneroNodes []*MoneroNode - SwapFactoryAddress ethcommon.Address - ForwarderContractAddress ethcommon.Address - Bootnodes []string + Env Environment + DataDir string + MoneroNodes []*MoneroNode + SwapCreatorAddr ethcommon.Address + ForwarderAddr ethcommon.Address + Bootnodes []string } // MainnetConfig is the mainnet ethereum and monero configuration @@ -86,8 +86,8 @@ func StagenetConfig() *Config { Port: 38081, }, }, - SwapFactoryAddress: ethcommon.HexToAddress("0x531BAAceB7939C04ef0DE517557a2f84F5545EFB"), - ForwarderContractAddress: ethcommon.HexToAddress("0x8730e444bB1501C23BC3E170405a8EbAFD138000"), + SwapCreatorAddr: ethcommon.HexToAddress("0x2C3b31E4379ab5B1B0Cb12B37D2B268FEf44d7f0"), + ForwarderAddr: ethcommon.HexToAddress("0xF45e206B38f5901daBf9758fcC2CFce6aEe5B134"), Bootnodes: []string{ "/ip4/134.122.115.208/tcp/9900/p2p/12D3KooWDqCzbjexHEa8Rut7bzxHFpRMZyDRW1L6TGkL1KY24JH5", "/ip4/143.198.123.27/tcp/9900/p2p/12D3KooWSc4yFkPWBFmPToTMbhChH3FAgGH96DNzSg5fio1pQYoN", diff --git a/common/consts.go b/common/consts.go index c4284f06..68baada4 100644 --- a/common/consts.go +++ b/common/consts.go @@ -25,7 +25,7 @@ const ( TimeFmtNSecs = "2006-01-02-15:04:05.999999999" ) -// SwapFactory.sol event signatures +// SwapCreator.sol event signatures const ( ReadyEventSignature = "Ready(bytes32)" ClaimedEventSignature = "Claimed(bytes32,bytes32)" diff --git a/daemon/swap_daemon.go b/daemon/swap_daemon.go index e5f60ebf..b9d8c049 100644 --- a/daemon/swap_daemon.go +++ b/daemon/swap_daemon.go @@ -54,8 +54,8 @@ func RunSwapDaemon(ctx context.Context, conf *SwapdConfig) (err error) { conf.Libp2pKeyfile = path.Join(conf.EnvConf.DataDir, common.DefaultLibp2pKeyFileName) } - if conf.EnvConf.SwapFactoryAddress == (ethcommon.Address{}) { - panic("swap factory address not specified") + if conf.EnvConf.SwapCreatorAddr == (ethcommon.Address{}) { + panic("swap creator address not specified") } ec := conf.EthereumClient @@ -105,14 +105,14 @@ func RunSwapDaemon(ctx context.Context, conf *SwapdConfig) (err error) { }() swapBackend, err := backend.NewBackend(&backend.Config{ - Ctx: ctx, - MoneroClient: conf.MoneroClient, - EthereumClient: conf.EthereumClient, - Environment: conf.EnvConf.Env, - SwapFactoryAddress: conf.EnvConf.SwapFactoryAddress, - SwapManager: sm, - RecoveryDB: sdb.RecoveryDB(), - Net: host, + Ctx: ctx, + MoneroClient: conf.MoneroClient, + EthereumClient: conf.EthereumClient, + Environment: conf.EnvConf.Env, + SwapCreatorAddr: conf.EnvConf.SwapCreatorAddr, + SwapManager: sm, + RecoveryDB: sdb.RecoveryDB(), + Net: host, }) if err != nil { return fmt.Errorf("failed to make backend: %w", err) diff --git a/daemon/swap_daemon_test.go b/daemon/swap_daemon_test.go index 2c487b5b..fe8bf6eb 100644 --- a/daemon/swap_daemon_test.go +++ b/daemon/swap_daemon_test.go @@ -62,11 +62,11 @@ func init() { _ = logging.SetLogLevel("xmrtaker", level) } -var _swapFactoryAddress *ethcommon.Address +var _swapCreatorAddr *ethcommon.Address -func getSwapFactoryAddress(t *testing.T, ec *ethclient.Client) ethcommon.Address { - if _swapFactoryAddress != nil { - return *_swapFactoryAddress +func getSwapCreatorAddress(t *testing.T, ec *ethclient.Client) ethcommon.Address { + if _swapCreatorAddr != nil { + return *_swapCreatorAddr } ctx := context.Background() @@ -75,11 +75,11 @@ func getSwapFactoryAddress(t *testing.T, ec *ethclient.Client) ethcommon.Address forwarderAddr, err := contracts.DeployGSNForwarderWithKey(ctx, ec, ethKey) require.NoError(t, err) - swapFactoryAddr, _, err := contracts.DeploySwapFactoryWithKey(ctx, ec, ethKey, forwarderAddr) + swapCreatorAddr, _, err := contracts.DeploySwapCreatorWithKey(ctx, ec, ethKey, forwarderAddr) require.NoError(t, err) - _swapFactoryAddress = &swapFactoryAddr - return swapFactoryAddr + _swapCreatorAddr = &swapCreatorAddr + return swapCreatorAddr } func privKeyToAddr(privKey *ecdsa.PrivateKey) ethcommon.Address { @@ -161,7 +161,7 @@ func createTestConf(t *testing.T, ethKey *ecdsa.PrivateKey) *SwapdConfig { envConf := new(common.Config) *envConf = *common.ConfigDefaultsForEnv(common.Development) envConf.DataDir = t.TempDir() - envConf.SwapFactoryAddress = getSwapFactoryAddress(t, ec.Raw()) + envConf.SwapCreatorAddr = getSwapCreatorAddress(t, ec.Raw()) return &SwapdConfig{ EnvConf: envConf, @@ -227,7 +227,7 @@ func TestRunSwapDaemon_SwapBobHasNoEth_AliceRelaysClaim(t *testing.T) { aliceConf := createTestConf(t, tests.GetTakerTestKey(t)) - timeout := 5 * time.Minute + timeout := 7 * time.Minute ctx := launchDaemons(t, timeout, bobConf, aliceConf) bc, err := wsclient.NewWsClient(ctx, fmt.Sprintf("ws://127.0.0.1:%d/ws", bobConf.RPCPort)) @@ -320,7 +320,7 @@ func TestRunSwapDaemon_NoRelayersAvailable_Refund(t *testing.T) { aliceConf := createTestConf(t, aliceEthKey) minimumFundAlice(t, aliceConf.EthereumClient, providesAmt) - timeout := 7 * time.Minute + timeout := 8 * time.Minute ctx := launchDaemons(t, timeout, bobConf, aliceConf) bc, err := wsclient.NewWsClient(ctx, fmt.Sprintf("ws://127.0.0.1:%d/ws", bobConf.RPCPort)) @@ -405,7 +405,7 @@ func TestRunSwapDaemon_CharlieRelays(t *testing.T) { charlieStartBal, err := charlieConf.EthereumClient.Balance(context.Background()) require.NoError(t, err) - timeout := 5 * time.Minute + timeout := 7 * time.Minute ctx := launchDaemons(t, timeout, bobConf, aliceConf, charlieConf) bc, err := wsclient.NewWsClient(ctx, fmt.Sprintf("ws://127.0.0.1:%d/ws", bobConf.RPCPort)) @@ -510,7 +510,7 @@ func TestRunSwapDaemon_CharlieIsBroke_AliceRelays(t *testing.T) { charlieConf := createTestConf(t, charlieEthKey) charlieConf.IsRelayer = true - timeout := 5 * time.Minute + timeout := 7 * time.Minute ctx := launchDaemons(t, timeout, bobConf, aliceConf, charlieConf) bc, err := wsclient.NewWsClient(ctx, fmt.Sprintf("ws://127.0.0.1:%d/ws", bobConf.RPCPort)) diff --git a/db/recovery_db.go b/db/recovery_db.go index 34173af7..b4910fb5 100644 --- a/db/recovery_db.go +++ b/db/recovery_db.go @@ -74,7 +74,7 @@ func (db *RecoveryDB) GetSwapRelayerInfo(id types.Hash) (*types.OfferExtra, erro } // PutContractSwapInfo stores the given contract swap ID (which is not the same as the daemon -// swap ID, but is instead a hash of the `SwapFactorySwap` structure) +// swap ID, but is instead a hash of the `SwapCreatorSwap` structure) // and contract swap structure for the given swap ID. func (db *RecoveryDB) PutContractSwapInfo(id types.Hash, info *EthereumSwapInfo) error { val, err := vjson.MarshalStruct(info) @@ -91,7 +91,7 @@ func (db *RecoveryDB) PutContractSwapInfo(id types.Hash, info *EthereumSwapInfo) return db.db.Flush() } -// GetContractSwapInfo returns the contract swap ID (a hash of the `SwapFactorySwap` structure) and +// GetContractSwapInfo returns the contract swap ID (a hash of the `SwapCreatorSwap` structure) and // and contract swap structure for the given swap ID. func (db *RecoveryDB) GetContractSwapInfo(id types.Hash) (*EthereumSwapInfo, error) { key := getRecoveryDBKey(id, contractSwapInfoPrefix) diff --git a/db/recovery_db_test.go b/db/recovery_db_test.go index 21dcf8a5..e95cfd04 100644 --- a/db/recovery_db_test.go +++ b/db/recovery_db_test.go @@ -37,7 +37,7 @@ func TestRecoveryDB_ContractSwapInfo(t *testing.T) { si := &EthereumSwapInfo{ StartNumber: big.NewInt(12345), SwapID: types.Hash{1, 2, 3, 4}, - Swap: &contracts.SwapFactorySwap{ + Swap: &contracts.SwapCreatorSwap{ Owner: ethcommon.HexToAddress("0xda9dfa130df4de4673b89022ee50ff26f6ea73cf"), Claimer: ethcommon.HexToAddress("0xbe0eb53f46cd790cd13851d5eff43d12404d33e8"), PubKeyClaim: ethcommon.HexToHash("0x5ab9467e70d4e98567991f0179d1f82a3096ed7973f7aff9ea50f649cafa88b9"), @@ -48,7 +48,7 @@ func TestRecoveryDB_ContractSwapInfo(t *testing.T) { Value: big.NewInt(9876), Nonce: big.NewInt(1234), }, - ContractAddress: ethcommon.HexToAddress("0xd2b5d6252d0645e4cf4bb547e82a485f527befb7"), + SwapCreatorAddr: ethcommon.HexToAddress("0xd2b5d6252d0645e4cf4bb547e82a485f527befb7"), } expectedStr := `{ @@ -65,7 +65,7 @@ func TestRecoveryDB_ContractSwapInfo(t *testing.T) { "value": 9876, "nonce": 1234 }, - "contractAddress": "0xd2b5d6252d0645e4cf4bb547e82a485f527befb7" + "swapCreatorAddr": "0xd2b5d6252d0645e4cf4bb547e82a485f527befb7" }` jsonData, err := vjson.MarshalStruct(si) require.NoError(t, err) @@ -151,7 +151,7 @@ func TestRecoveryDB_DeleteSwap(t *testing.T) { si := &EthereumSwapInfo{ StartNumber: big.NewInt(12345), SwapID: types.Hash{1, 2, 3, 4}, - Swap: &contracts.SwapFactorySwap{ + Swap: &contracts.SwapCreatorSwap{ Owner: ethcommon.HexToAddress("0xda9dfa130df4de4673b89022ee50ff26f6ea73cf"), Claimer: ethcommon.HexToAddress("0xbe0eb53f46cd790cd13851d5eff43d12404d33e8"), PubKeyClaim: ethcommon.HexToHash("0x5ab9467e70d4e98567991f0179d1f82a3096ed7973f7aff9ea50f649cafa88b9"), @@ -162,7 +162,7 @@ func TestRecoveryDB_DeleteSwap(t *testing.T) { Value: big.NewInt(9876), Nonce: big.NewInt(1234), }, - ContractAddress: ethcommon.HexToAddress("0xd2b5d6252d0645e4cf4bb547e82a485f527befb7"), + SwapCreatorAddr: ethcommon.HexToAddress("0xd2b5d6252d0645e4cf4bb547e82a485f527befb7"), } info := &types.OfferExtra{ diff --git a/db/types.go b/db/types.go index aeb41281..de3a737c 100644 --- a/db/types.go +++ b/db/types.go @@ -20,12 +20,12 @@ type EthereumSwapInfo struct { // SwapID is the swap ID used by the swap contract; not the same as the // swap/offer ID used by swapd. It's the hash of the ABI encoded - // `contracts.SwapFactorySwap` struct. + // `contracts.SwapCreatorSwap` struct. SwapID types.Hash `json:"swapID" validate:"required"` - // Swap is the `Swap` structure inside SwapFactory.sol. - Swap *contracts.SwapFactorySwap `json:"swap" validate:"required"` + // Swap is the `Swap` structure inside SwapCreator.sol. + Swap *contracts.SwapCreatorSwap `json:"swap" validate:"required"` - // ContractAddress is the address of the contract on which the swap was created. - ContractAddress ethcommon.Address `json:"contractAddress" validate:"required"` + // SwapCreatorAddr is the address of the contract on which the swap was created. + SwapCreatorAddr ethcommon.Address `json:"swapCreatorAddr" validate:"required"` } diff --git a/docs/developing.md b/docs/developing.md index 3ddd31b7..2831bba2 100644 --- a/docs/developing.md +++ b/docs/developing.md @@ -12,19 +12,28 @@ You can use the script `scripts/setup-env.sh` to quickly set up local monerod-te ganache instances. If you need to later kill `ganache`, `monerod`, `monero-wallet-rpc`, or `swapd` instances, you can use `scripts/cleanup-test-processes.sh`. -## Deploying or using deployed SwapFactory.sol +## Deploying or using deployed SwapCreator.sol -The swap program uses a "factory" contract for the Ethereum side to reduce gas costs from deploying a new contract for each swap. The contract can be found in [here](../ethereum/contracts/SwapFactory.sol). For each new swap, the eth-holding party will call `NewSwap` on the factory contract, initiating a swap instance inside the contract. +The swap program uses a "creator" contract for the Ethereum side to reduce gas +costs from deploying a new contract for each swap. The contract can be found in +[here](../ethereum/contracts/SwapCreator.sol). For each new swap, the +eth-holding party will call `NewSwap` on the creator contract, initiating a swap +instance inside the contract. -If you're developing on a local network, running a `swapd` instance with the `--dev-xmrtaker` flag will automatically deploy an instance of `SwapFactory.sol` for you. You should see the following log shortly after starting `./swapd --dev-xmrtaker`: +If you're developing on a local network, running a `swapd` instance with the +`--dev-xmrtaker` flag will automatically deploy an instance of `SwapCreator.sol` +for you. You should see the following log shortly after starting +`./swapd --dev-xmrtaker`: ```bash -# 2022-01-26T18:39:04.600-0500 INFO cmd daemon/contract.go:35 deployed SwapFactory.sol: address=0x3F2aF34E4250de94242Ac2B8A38550fd4503696d tx hash=0x638caf280178b3cfe06854b8a76a4ce355d38c5d81187836f0733cad1287b657 +# 2022-01-26T18:39:04.600-0500 INFO cmd daemon/contract.go:35 deployed SwapCreator.sol: address=0x3F2aF34E4250de94242Ac2B8A38550fd4503696d tx hash=0x638caf280178b3cfe06854b8a76a4ce355d38c5d81187836f0733cad1287b657 ``` -If you wish to use an instance of `SwapFactory.sol` that's already deployed on-chain, you can use the `--contract-address` flag to specify the address. For example: +If you wish to use an instance of `SwapCreator.sol` that's already deployed +on-chain, you can use the `--contract-address` flag to specify the address. For +example: ```bash $ ./swapd --dev-xmrtaker --contract-address 0x3F2aF34E4250de94242Ac2B8A38550fd4503696d -# 2022-01-26T18:56:31.627-0500 INFO cmd daemon/contract.go:42 loaded SwapFactory.sol from address 0x3F2aF34E4250de94242Ac2B8A38550fd4503696d +# 2022-01-26T18:56:31.627-0500 INFO cmd daemon/contract.go:42 loaded SwapCreator.sol from address 0x3F2aF34E4250de94242Ac2B8A38550fd4503696d ``` ## Compiling contract bindings @@ -33,7 +42,7 @@ If you update the `Swap.sol` contract for some reason, you will need to re-gener for the contract. **Note:** you do *not* need to do this to try out the swap; only if you want to edit the contract for development purposes. -Download solc v0.8.17: https://github.com/ethereum/solidity/releases/tag/v0.8.17 +Download solc v0.8.19: https://github.com/ethereum/solidity/releases/tag/v0.8.19 If `solc` with the needed version is not in your path (or not first in your path), set the `SOLC_BIN` environment variable to the correct version: diff --git a/docs/local.md b/docs/local.md index 54d09422..d5c006a0 100644 --- a/docs/local.md +++ b/docs/local.md @@ -91,7 +91,7 @@ Now get the ethereum contract address that Alice deployed to. This can be pulled the file ..., or if you have `jq` installed (available via `sudo apt install jq`), you can set a variable like this: ```bash -CONTRACT_ADDR=$(jq -r .swapFactory "${TMPDIR-/tmp}"/xmrtaker-*/contract-addresses.json) +CONTRACT_ADDR=$(jq -r .swapCreatorAddr "${TMPDIR-/tmp}"/xmrtaker-*/contract-addresses.json) ``` Now start Bob's swapd instance: @@ -220,4 +220,4 @@ To query information for a past swap using its ID, you can run: ./bin/swapcli past --offer-id ``` -For both of these commands, if no `--offer-id` is passed, all ongoing or past swaps will be returned. \ No newline at end of file +For both of these commands, if no `--offer-id` is passed, all ongoing or past swaps will be returned. diff --git a/docs/stagenet.md b/docs/stagenet.md index 3c22abff..64d94445 100644 --- a/docs/stagenet.md +++ b/docs/stagenet.md @@ -179,7 +179,7 @@ You can also try the swap on another Ethereum or EVM-compatible testnet. However To connect to a different Ethereum network, follow [Setup](#setup) steps 4-7 but with your desired network. Then, start `swapd` with your specified private key file, endpoint, and chain ID. Common chain IDs can be found [here](https://besu.hyperledger.org/en/stable/Concepts/NetworkID-And-ChainID/). -> Note: The `--deploy` flag to `swapd` creates a new instance of `SwapFactory.sol` to the +> Note: The `--deploy` flag to `swapd` creates a new instance of `SwapCreator.sol` to the network. You need to have funds in your account to deploy the contract. To use a contract deployed with `--deploy` in subsequent `swapd` instances, use the flag `--contract-addr=ADDRESS`. When using `stagenet`, a deployed contract already exists and diff --git a/ethereum/aggregator_v3_interface.go b/ethereum/aggregator_v3_interface.go index 4784ed63..5b7a6ef1 100644 --- a/ethereum/aggregator_v3_interface.go +++ b/ethereum/aggregator_v3_interface.go @@ -1,6 +1,3 @@ -// Copyright 2023 Athanor Labs (ON) -// SPDX-License-Identifier: LGPL-3.0-only - // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. @@ -29,6 +26,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) // AggregatorV3InterfaceMetaData contains all meta data concerning the AggregatorV3Interface contract. @@ -137,11 +135,11 @@ func NewAggregatorV3InterfaceFilterer(address common.Address, filterer bind.Cont // bindAggregatorV3Interface binds a generic wrapper to an already deployed contract. func bindAggregatorV3Interface(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(AggregatorV3InterfaceABI)) + parsed, err := AggregatorV3InterfaceMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/ethereum/block/testdata/generate-bindings.sh b/ethereum/block/testdata/generate-bindings.sh index b984f267..12b9aaed 100755 --- a/ethereum/block/testdata/generate-bindings.sh +++ b/ethereum/block/testdata/generate-bindings.sh @@ -14,7 +14,7 @@ fi "${SOLC_BIN}" --abi UTContract.sol -o . --overwrite "${SOLC_BIN}" --bin UTContract.sol -o . --overwrite -# Use abigen 1.10.17-stable to match how we compile the SwapFactory contract +# Use abigen 1.10.17-stable to match how we compile the SwapCreator contract "${ABIGEN}" --abi UTContract.abi --bin UTContract.bin --pkg block --type UTContract --out ../ut_contract_test.go rm -f UTContract.abi UTContract.bin diff --git a/ethereum/block/ut_contract_test.go b/ethereum/block/ut_contract_test.go index cc7386d8..cf334467 100644 --- a/ethereum/block/ut_contract_test.go +++ b/ethereum/block/ut_contract_test.go @@ -1,6 +1,3 @@ -// Copyright 2023 Athanor Labs (ON) -// SPDX-License-Identifier: LGPL-3.0-only - // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. @@ -29,12 +26,13 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) // UTContractMetaData contains all meta data concerning the UTContract contract. var UTContractMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_stamp\",\"type\":\"uint256\"}],\"name\":\"checkStamp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x608060405234801561001057600080fd5b506101da806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d5f7a03a14610030575b600080fd5b61004a600480360381019061004591906100d4565b61004c565b005b8042111561008f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161008690610184565b60405180910390fd5b8060008190555050565b600080fd5b6000819050919050565b6100b18161009e565b81146100bc57600080fd5b50565b6000813590506100ce816100a8565b92915050565b6000602082840312156100ea576100e9610099565b5b60006100f8848285016100bf565b91505092915050565b600082825260208201905092915050565b7f626c6f636b2e74696d657374616d7020776173206e6f74206c6573732074686160008201527f6e207374616d7000000000000000000000000000000000000000000000000000602082015250565b600061016e602783610101565b915061017982610112565b604082019050919050565b6000602082019050818103600083015261019d81610161565b905091905056fea26469706673582212203a38c90eb8e83a68408aca6e96e7fab891b951de030c24bcc8a3a67dbb87c7d764736f6c63430008110033", + Bin: "0x608060405234801561001057600080fd5b506101da806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063d5f7a03a14610030575b600080fd5b61004a600480360381019061004591906100d4565b61004c565b005b8042111561008f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161008690610184565b60405180910390fd5b8060008190555050565b600080fd5b6000819050919050565b6100b18161009e565b81146100bc57600080fd5b50565b6000813590506100ce816100a8565b92915050565b6000602082840312156100ea576100e9610099565b5b60006100f8848285016100bf565b91505092915050565b600082825260208201905092915050565b7f626c6f636b2e74696d657374616d7020776173206e6f74206c6573732074686160008201527f6e207374616d7000000000000000000000000000000000000000000000000000602082015250565b600061016e602783610101565b915061017982610112565b604082019050919050565b6000602082019050818103600083015261019d81610161565b905091905056fea2646970667358221220e3debdc387582462e246390796d566e062d5965fb0bd8de5af573ad815d24b0564736f6c63430008130033", } // UTContractABI is the input ABI used to generate the binding from. @@ -159,11 +157,11 @@ func NewUTContractFilterer(address common.Address, filterer bind.ContractFiltere // bindUTContract binds a generic wrapper to an already deployed contract. func bindUTContract(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(UTContractABI)) + parsed, err := UTContractMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/ethereum/check_swap_factory_contract.go b/ethereum/check_swap_creator_contract.go similarity index 93% rename from ethereum/check_swap_factory_contract.go rename to ethereum/check_swap_creator_contract.go index 27e7e16f..f0b20ce2 100644 --- a/ethereum/check_swap_factory_contract.go +++ b/ethereum/check_swap_creator_contract.go @@ -15,30 +15,30 @@ import ( "github.com/athanorlabs/go-relayer/impls/gsnforwarder" ) -// expectedSwapFactoryBytecodeHex is generated by deploying an instance of SwapFactory.sol +// expectedSwapCreatorBytecodeHex is generated by deploying an instance of SwapCreator.sol // with the trustedForwarder address set to all zeros and reading back the bytecode. See -// the unit test TestExpectedSwapFactoryBytecodeHex if you need to update this value. +// the unit test TestExpectedSwapCreatorBytecodeHex if you need to update this value. const ( - expectedSwapFactoryBytecodeHex = "6080604052600436106100865760003560e01c806373e4771c1161005957806373e4771c14610145578063b32d1b4f1461016e578063c41e46cf146101ab578063eb84e7f2146101db578063fcaf229c1461021857610086565b80631e6c5acc1461008b57806356c022bb146100b4578063572b6c05146100df5780635cb969161461011c575b600080fd5b34801561009757600080fd5b506100b260048036038101906100ad91906116b6565b610241565b005b3480156100c057600080fd5b506100c96105b4565b6040516100d69190611707565b60405180910390f35b3480156100eb57600080fd5b5061010660048036038101906101019190611722565b6105d8565b604051610113919061176a565b60405180910390f35b34801561012857600080fd5b50610143600480360381019061013e91906116b6565b610630565b005b34801561015157600080fd5b5061016c60048036038101906101679190611785565b610756565b005b34801561017a57600080fd5b50610195600480360381019061019091906117db565b610a1e565b6040516101a2919061176a565b60405180910390f35b6101c560048036038101906101c0919061181b565b610b23565b6040516101d291906118e0565b60405180910390f35b3480156101e757600080fd5b5061020260048036038101906101fd91906118fb565b610e90565b60405161020f919061199f565b60405180910390f35b34801561022457600080fd5b5061023f600480360381019061023a91906119ba565b610eb0565b005b6000826040516020016102549190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff1690506003808111156102a3576102a2611928565b5b8160038111156102b6576102b5611928565b5b141580156102e95750600060038111156102d3576102d2611928565b5b8160038111156102e6576102e5611928565b5b14155b610328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031f90611b54565b60405180910390fd5b836000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039190611be6565b60405180910390fd5b8360a00151421015806103e157508360800151421080156103e05750600260038111156103ca576103c9611928565b5b8160038111156103dd576103dc611928565b5b14155b5b610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041790611c78565b60405180910390fd5b61042e83856060015161103f565b82827e7c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561049157610490611928565b5b0217905550600073ffffffffffffffffffffffffffffffffffffffff168460c0015173ffffffffffffffffffffffffffffffffffffffff160361052257836000015173ffffffffffffffffffffffffffffffffffffffff166108fc8560e001519081150290604051600060405180830381858888f1935050505015801561051c573d6000803e3d6000fd5b506105ae565b8360c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85600001518660e001516040518363ffffffff1660e01b8152600401610569929190611d06565b6020604051808303816000875af1158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac9190611d5b565b505b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b61063a8282611092565b600073ffffffffffffffffffffffffffffffffffffffff168260c0015173ffffffffffffffffffffffffffffffffffffffff16036106c657816020015173ffffffffffffffffffffffffffffffffffffffff166108fc8360e001519081150290604051600060405180830381858888f193505050501580156106c0573d6000803e3d6000fd5b50610752565b8160c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83602001518460e001516040518363ffffffff1660e01b815260040161070d929190611d06565b6020604051808303816000875af115801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190611d5b565b505b5050565b61075f336105d8565b61079e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079590611dfa565b60405180910390fd5b826020015173ffffffffffffffffffffffffffffffffffffffff166107c1611360565b73ffffffffffffffffffffffffffffffffffffffff1614610817576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080e90611e8c565b60405180910390fd5b6108218383611092565b600073ffffffffffffffffffffffffffffffffffffffff168360c0015173ffffffffffffffffffffffffffffffffffffffff16036108ff57826020015173ffffffffffffffffffffffffffffffffffffffff166108fc828560e001516108879190611edb565b9081150290604051600060405180830381858888f193505050501580156108b2573d6000803e3d6000fd5b503273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156108f9573d6000803e3d6000fd5b50610a19565b8260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8460200151838660e001516109349190611edb565b6040518363ffffffff1660e01b8152600401610951929190611d06565b6020604051808303816000875af1158015610970573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109949190611d5b565b508260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb32836040518363ffffffff1660e01b81526004016109d4929190611f0f565b6020604051808303816000875af11580156109f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a179190611d5b565b505b505050565b60008060016000601b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179860001b7ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414180610a7a57610a79611f38565b5b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798890960001b60405160008152602001604052604051610abd9493929190611ff7565b6020604051602081039080840390855afa158015610adf573d6000803e3d6000fd5b5050506020604051035190508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161491505092915050565b6000610b2d61139a565b33816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050898160400181815250508881606001818152505087816020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508642610bbd919061203c565b816080018181525050858742610bd3919061203c565b610bdd919061203c565b8160a0018181525050848160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160e0018181525050600073ffffffffffffffffffffffffffffffffffffffff168160c0015173ffffffffffffffffffffffffffffffffffffffff1603610cab57348160e0015114610ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9d906120e2565b60405180910390fd5b610d35565b8060c0015173ffffffffffffffffffffffffffffffffffffffff166323b872dd33308460e001516040518463ffffffff1660e01b8152600401610cf093929190612102565b6020604051808303816000875af1158015610d0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d339190611d5b565b505b8281610100018181525050600081604051602001610d539190611adb565b60405160208183030381529060405280519060200120905060006003811115610d7f57610d7e611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610db157610db0611928565b5b14610df1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de890612185565b60405180910390fd5b7f91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56818c8c85608001518660a001518760c001518860e00151604051610e3c97969594939291906121a5565b60405180910390a1600160008083815260200190815260200160002060006101000a81548160ff02191690836003811115610e7a57610e79611928565b5b0217905550809250505098975050505050505050565b60006020528060005260406000206000915054906101000a900460ff1681565b600081604051602001610ec39190611adb565b60405160208183030381529060405280519060200120905060016003811115610eef57610eee611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610f2157610f20611928565b5b14610f61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5890612260565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614610fd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fca906122f2565b60405180910390fd5b600260008083815260200190815260200160002060006101000a81548160ff0219169083600381111561100957611008611928565b5b0217905550807f5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f60405160405180910390a25050565b61104f8260001c8260001c610a1e565b61108e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108590612384565b60405180910390fd5b5050565b6000826040516020016110a59190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff169050600060038111156110f5576110f4611928565b5b81600381111561110857611107611928565b5b03611148576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113f906123f0565b60405180910390fd5b60038081111561115b5761115a611928565b5b81600381111561116e5761116d611928565b5b036111ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a590611b54565b60405180910390fd5b836020015173ffffffffffffffffffffffffffffffffffffffff166111d1611360565b73ffffffffffffffffffffffffffffffffffffffff1614611227576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121e9061245c565b60405180910390fd5b83608001514210158061125e57506002600381111561124957611248611928565b5b81600381111561125c5761125b611928565b5b145b61129d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611294906124c8565b60405180910390fd5b8360a0015142106112e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112da90612534565b60405180910390fd5b6112f183856040015161103f565b82827f38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561135557611354611928565b5b021790555050505050565b600061136b336105d8565b1561137f57601436033560601c905061138e565b611387611392565b905061138f565b5b90565b600033905090565b604051806101200160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008019168152602001600080191681526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081525090565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61148b82611442565b810181811067ffffffffffffffff821117156114aa576114a9611453565b5b80604052505050565b60006114bd61142e565b90506114c98282611482565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006114f9826114ce565b9050919050565b611509816114ee565b811461151457600080fd5b50565b60008135905061152681611500565b92915050565b6000819050919050565b61153f8161152c565b811461154a57600080fd5b50565b60008135905061155c81611536565b92915050565b6000819050919050565b61157581611562565b811461158057600080fd5b50565b6000813590506115928161156c565b92915050565b60006115a3826114ce565b9050919050565b6115b381611598565b81146115be57600080fd5b50565b6000813590506115d0816115aa565b92915050565b600061012082840312156115ed576115ec61143d565b5b6115f86101206114b3565b9050600061160884828501611517565b600083015250602061161c84828501611517565b60208301525060406116308482850161154d565b60408301525060606116448482850161154d565b606083015250608061165884828501611583565b60808301525060a061166c84828501611583565b60a08301525060c0611680848285016115c1565b60c08301525060e061169484828501611583565b60e0830152506101006116a984828501611583565b6101008301525092915050565b60008061014083850312156116ce576116cd611438565b5b60006116dc858286016115d6565b9250506101206116ee8582860161154d565b9150509250929050565b61170181611598565b82525050565b600060208201905061171c60008301846116f8565b92915050565b60006020828403121561173857611737611438565b5b6000611746848285016115c1565b91505092915050565b60008115159050919050565b6117648161174f565b82525050565b600060208201905061177f600083018461175b565b92915050565b6000806000610160848603121561179f5761179e611438565b5b60006117ad868287016115d6565b9350506101206117bf8682870161154d565b9250506101406117d186828701611583565b9150509250925092565b600080604083850312156117f2576117f1611438565b5b600061180085828601611583565b925050602061181185828601611583565b9150509250929050565b600080600080600080600080610100898b03121561183c5761183b611438565b5b600061184a8b828c0161154d565b985050602061185b8b828c0161154d565b975050604061186c8b828c01611517565b965050606061187d8b828c01611583565b955050608061188e8b828c01611583565b94505060a061189f8b828c016115c1565b93505060c06118b08b828c01611583565b92505060e06118c18b828c01611583565b9150509295985092959890939650565b6118da8161152c565b82525050565b60006020820190506118f560008301846118d1565b92915050565b60006020828403121561191157611910611438565b5b600061191f8482850161154d565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061196857611967611928565b5b50565b600081905061197982611957565b919050565b60006119898261196b565b9050919050565b6119998161197e565b82525050565b60006020820190506119b46000830184611990565b92915050565b600061012082840312156119d1576119d0611438565b5b60006119df848285016115d6565b91505092915050565b6119f1816114ee565b82525050565b611a008161152c565b82525050565b611a0f81611562565b82525050565b611a1e81611598565b82525050565b61012082016000820151611a3b60008501826119e8565b506020820151611a4e60208501826119e8565b506040820151611a6160408501826119f7565b506060820151611a7460608501826119f7565b506080820151611a876080850182611a06565b5060a0820151611a9a60a0850182611a06565b5060c0820151611aad60c0850182611a15565b5060e0820151611ac060e0850182611a06565b50610100820151611ad5610100850182611a06565b50505050565b600061012082019050611af16000830184611a24565b92915050565b600082825260208201905092915050565b7f7377617020697320616c726561647920636f6d706c6574656400000000000000600082015250565b6000611b3e601983611af7565b9150611b4982611b08565b602082019050919050565b60006020820190508181036000830152611b6d81611b31565b9050919050565b7f726566756e64206d7573742062652063616c6c6564206279207468652073776160008201527f70206f776e657200000000000000000000000000000000000000000000000000602082015250565b6000611bd0602783611af7565b9150611bdb82611b74565b604082019050919050565b60006020820190508181036000830152611bff81611bc3565b9050919050565b7f697427732074686520636f756e74657270617274792773207475726e2c20756e60008201527f61626c6520746f20726566756e642c2074727920616761696e206c6174657200602082015250565b6000611c62603f83611af7565b9150611c6d82611c06565b604082019050919050565b60006020820190508181036000830152611c9181611c55565b9050919050565b6000819050919050565b6000611cbd611cb8611cb3846114ce565b611c98565b6114ce565b9050919050565b6000611ccf82611ca2565b9050919050565b6000611ce182611cc4565b9050919050565b611cf181611cd6565b82525050565b611d0081611562565b82525050565b6000604082019050611d1b6000830185611ce8565b611d286020830184611cf7565b9392505050565b611d388161174f565b8114611d4357600080fd5b50565b600081519050611d5581611d2f565b92915050565b600060208284031215611d7157611d70611438565b5b6000611d7f84828501611d46565b91505092915050565b7f636c61696d52656c617965722063616e206f6e6c792062652063616c6c65642060008201527f62792061207472757374656420666f7277617264657200000000000000000000602082015250565b6000611de4603683611af7565b9150611def82611d88565b604082019050919050565b60006020820190508181036000830152611e1381611dd7565b9050919050565b7f7369676e6572206f66207468652072656c61796564207472616e73616374696f60008201527f6e206d7573742062652074686520636c61696d65720000000000000000000000602082015250565b6000611e76603583611af7565b9150611e8182611e1a565b604082019050919050565b60006020820190508181036000830152611ea581611e69565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611ee682611562565b9150611ef183611562565b9250828203905081811115611f0957611f08611eac565b5b92915050565b6000604082019050611f2460008301856116f8565b611f316020830184611cf7565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000819050919050565b60008160001b9050919050565b6000611f99611f94611f8f84611f67565b611f71565b61152c565b9050919050565b611fa981611f7e565b82525050565b6000819050919050565b600060ff82169050919050565b6000611fe1611fdc611fd784611faf565b611c98565b611fb9565b9050919050565b611ff181611fc6565b82525050565b600060808201905061200c6000830187611fa0565b6120196020830186611fe8565b61202660408301856118d1565b61203360608301846118d1565b95945050505050565b600061204782611562565b915061205283611562565b925082820190508082111561206a57612069611eac565b5b92915050565b7f76616c7565206e6f742073616d652061732045544820616d6f756e742073656e60008201527f7400000000000000000000000000000000000000000000000000000000000000602082015250565b60006120cc602183611af7565b91506120d782612070565b604082019050919050565b600060208201905081810360008301526120fb816120bf565b9050919050565b600060608201905061211760008301866116f8565b61212460208301856116f8565b6121316040830184611cf7565b949350505050565b7f7377617020616c72656164792065786973747300000000000000000000000000600082015250565b600061216f601383611af7565b915061217a82612139565b602082019050919050565b6000602082019050818103600083015261219e81612162565b9050919050565b600060e0820190506121ba600083018a6118d1565b6121c760208301896118d1565b6121d460408301886118d1565b6121e16060830187611cf7565b6121ee6080830186611cf7565b6121fb60a08301856116f8565b61220860c0830184611cf7565b98975050505050505050565b7f73776170206973206e6f7420696e2050454e44494e4720737461746500000000600082015250565b600061224a601c83611af7565b915061225582612214565b602082019050919050565b600060208201905081810360008301526122798161223d565b9050919050565b7f6f6e6c79207468652073776170206f776e65722063616e2063616c6c2073657460008201527f5265616479000000000000000000000000000000000000000000000000000000602082015250565b60006122dc602583611af7565b91506122e782612280565b604082019050919050565b6000602082019050818103600083015261230b816122cf565b9050919050565b7f70726f76696465642073656372657420646f6573206e6f74206d61746368207460008201527f6865206578706563746564207075626c6963206b657900000000000000000000602082015250565b600061236e603683611af7565b915061237982612312565b604082019050919050565b6000602082019050818103600083015261239d81612361565b9050919050565b7f696e76616c696420737761700000000000000000000000000000000000000000600082015250565b60006123da600c83611af7565b91506123e5826123a4565b602082019050919050565b60006020820190508181036000830152612409816123cd565b9050919050565b7f6f6e6c7920636c61696d65722063616e20636c61696d21000000000000000000600082015250565b6000612446601783611af7565b915061245182612410565b602082019050919050565b6000602082019050818103600083015261247581612439565b9050919050565b7f746f6f206561726c7920746f20636c61696d2100000000000000000000000000600082015250565b60006124b2601383611af7565b91506124bd8261247c565b602082019050919050565b600060208201905081810360008301526124e1816124a5565b9050919050565b7f746f6f206c61746520746f20636c61696d210000000000000000000000000000600082015250565b600061251e601283611af7565b9150612529826124e8565b602082019050919050565b6000602082019050818103600083015261254d81612511565b905091905056fea2646970667358221220877bd1d22a1b04aafd8f019ea84a948de577de61f0af77b51f0a6bb85511218564736f6c63430008110033" //nolint:lll + expectedSwapCreatorBytecodeHex = "6080604052600436106100865760003560e01c806373e4771c1161005957806373e4771c14610145578063b32d1b4f1461016e578063c41e46cf146101ab578063eb84e7f2146101db578063fcaf229c1461021857610086565b80631e6c5acc1461008b57806356c022bb146100b4578063572b6c05146100df5780635cb969161461011c575b600080fd5b34801561009757600080fd5b506100b260048036038101906100ad91906116b6565b610241565b005b3480156100c057600080fd5b506100c96105b4565b6040516100d69190611707565b60405180910390f35b3480156100eb57600080fd5b5061010660048036038101906101019190611722565b6105d8565b604051610113919061176a565b60405180910390f35b34801561012857600080fd5b50610143600480360381019061013e91906116b6565b610630565b005b34801561015157600080fd5b5061016c60048036038101906101679190611785565b610756565b005b34801561017a57600080fd5b50610195600480360381019061019091906117db565b610a1e565b6040516101a2919061176a565b60405180910390f35b6101c560048036038101906101c0919061181b565b610b23565b6040516101d291906118e0565b60405180910390f35b3480156101e757600080fd5b5061020260048036038101906101fd91906118fb565b610e90565b60405161020f919061199f565b60405180910390f35b34801561022457600080fd5b5061023f600480360381019061023a91906119ba565b610eb0565b005b6000826040516020016102549190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff1690506003808111156102a3576102a2611928565b5b8160038111156102b6576102b5611928565b5b141580156102e95750600060038111156102d3576102d2611928565b5b8160038111156102e6576102e5611928565b5b14155b610328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031f90611b54565b60405180910390fd5b836000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039190611be6565b60405180910390fd5b8360a00151421015806103e157508360800151421080156103e05750600260038111156103ca576103c9611928565b5b8160038111156103dd576103dc611928565b5b14155b5b610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041790611c78565b60405180910390fd5b61042e83856060015161103f565b82827e7c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561049157610490611928565b5b0217905550600073ffffffffffffffffffffffffffffffffffffffff168460c0015173ffffffffffffffffffffffffffffffffffffffff160361052257836000015173ffffffffffffffffffffffffffffffffffffffff166108fc8560e001519081150290604051600060405180830381858888f1935050505015801561051c573d6000803e3d6000fd5b506105ae565b8360c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85600001518660e001516040518363ffffffff1660e01b8152600401610569929190611d06565b6020604051808303816000875af1158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac9190611d5b565b505b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b61063a8282611092565b600073ffffffffffffffffffffffffffffffffffffffff168260c0015173ffffffffffffffffffffffffffffffffffffffff16036106c657816020015173ffffffffffffffffffffffffffffffffffffffff166108fc8360e001519081150290604051600060405180830381858888f193505050501580156106c0573d6000803e3d6000fd5b50610752565b8160c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83602001518460e001516040518363ffffffff1660e01b815260040161070d929190611d06565b6020604051808303816000875af115801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190611d5b565b505b5050565b61075f336105d8565b61079e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079590611dfa565b60405180910390fd5b826020015173ffffffffffffffffffffffffffffffffffffffff166107c1611360565b73ffffffffffffffffffffffffffffffffffffffff1614610817576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080e90611e8c565b60405180910390fd5b6108218383611092565b600073ffffffffffffffffffffffffffffffffffffffff168360c0015173ffffffffffffffffffffffffffffffffffffffff16036108ff57826020015173ffffffffffffffffffffffffffffffffffffffff166108fc828560e001516108879190611edb565b9081150290604051600060405180830381858888f193505050501580156108b2573d6000803e3d6000fd5b503273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156108f9573d6000803e3d6000fd5b50610a19565b8260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8460200151838660e001516109349190611edb565b6040518363ffffffff1660e01b8152600401610951929190611d06565b6020604051808303816000875af1158015610970573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109949190611d5b565b508260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb32836040518363ffffffff1660e01b81526004016109d4929190611f0f565b6020604051808303816000875af11580156109f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a179190611d5b565b505b505050565b60008060016000601b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179860001b7ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414180610a7a57610a79611f38565b5b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798890960001b60405160008152602001604052604051610abd9493929190611ff7565b6020604051602081039080840390855afa158015610adf573d6000803e3d6000fd5b5050506020604051035190508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161491505092915050565b6000610b2d61139a565b33816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050898160400181815250508881606001818152505087816020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508642610bbd919061203c565b816080018181525050858742610bd3919061203c565b610bdd919061203c565b8160a0018181525050848160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160e0018181525050600073ffffffffffffffffffffffffffffffffffffffff168160c0015173ffffffffffffffffffffffffffffffffffffffff1603610cab57348160e0015114610ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9d906120e2565b60405180910390fd5b610d35565b8060c0015173ffffffffffffffffffffffffffffffffffffffff166323b872dd33308460e001516040518463ffffffff1660e01b8152600401610cf093929190612102565b6020604051808303816000875af1158015610d0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d339190611d5b565b505b8281610100018181525050600081604051602001610d539190611adb565b60405160208183030381529060405280519060200120905060006003811115610d7f57610d7e611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610db157610db0611928565b5b14610df1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de890612185565b60405180910390fd5b7f91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56818c8c85608001518660a001518760c001518860e00151604051610e3c97969594939291906121a5565b60405180910390a1600160008083815260200190815260200160002060006101000a81548160ff02191690836003811115610e7a57610e79611928565b5b0217905550809250505098975050505050505050565b60006020528060005260406000206000915054906101000a900460ff1681565b600081604051602001610ec39190611adb565b60405160208183030381529060405280519060200120905060016003811115610eef57610eee611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610f2157610f20611928565b5b14610f61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5890612260565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614610fd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fca906122f2565b60405180910390fd5b600260008083815260200190815260200160002060006101000a81548160ff0219169083600381111561100957611008611928565b5b0217905550807f5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f60405160405180910390a25050565b61104f8260001c8260001c610a1e565b61108e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108590612384565b60405180910390fd5b5050565b6000826040516020016110a59190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff169050600060038111156110f5576110f4611928565b5b81600381111561110857611107611928565b5b03611148576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113f906123f0565b60405180910390fd5b60038081111561115b5761115a611928565b5b81600381111561116e5761116d611928565b5b036111ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a590611b54565b60405180910390fd5b836020015173ffffffffffffffffffffffffffffffffffffffff166111d1611360565b73ffffffffffffffffffffffffffffffffffffffff1614611227576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121e9061245c565b60405180910390fd5b83608001514210158061125e57506002600381111561124957611248611928565b5b81600381111561125c5761125b611928565b5b145b61129d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611294906124c8565b60405180910390fd5b8360a0015142106112e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112da90612534565b60405180910390fd5b6112f183856040015161103f565b82827f38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561135557611354611928565b5b021790555050505050565b600061136b336105d8565b1561137f57601436033560601c905061138e565b611387611392565b905061138f565b5b90565b600033905090565b604051806101200160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008019168152602001600080191681526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081525090565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61148b82611442565b810181811067ffffffffffffffff821117156114aa576114a9611453565b5b80604052505050565b60006114bd61142e565b90506114c98282611482565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006114f9826114ce565b9050919050565b611509816114ee565b811461151457600080fd5b50565b60008135905061152681611500565b92915050565b6000819050919050565b61153f8161152c565b811461154a57600080fd5b50565b60008135905061155c81611536565b92915050565b6000819050919050565b61157581611562565b811461158057600080fd5b50565b6000813590506115928161156c565b92915050565b60006115a3826114ce565b9050919050565b6115b381611598565b81146115be57600080fd5b50565b6000813590506115d0816115aa565b92915050565b600061012082840312156115ed576115ec61143d565b5b6115f86101206114b3565b9050600061160884828501611517565b600083015250602061161c84828501611517565b60208301525060406116308482850161154d565b60408301525060606116448482850161154d565b606083015250608061165884828501611583565b60808301525060a061166c84828501611583565b60a08301525060c0611680848285016115c1565b60c08301525060e061169484828501611583565b60e0830152506101006116a984828501611583565b6101008301525092915050565b60008061014083850312156116ce576116cd611438565b5b60006116dc858286016115d6565b9250506101206116ee8582860161154d565b9150509250929050565b61170181611598565b82525050565b600060208201905061171c60008301846116f8565b92915050565b60006020828403121561173857611737611438565b5b6000611746848285016115c1565b91505092915050565b60008115159050919050565b6117648161174f565b82525050565b600060208201905061177f600083018461175b565b92915050565b6000806000610160848603121561179f5761179e611438565b5b60006117ad868287016115d6565b9350506101206117bf8682870161154d565b9250506101406117d186828701611583565b9150509250925092565b600080604083850312156117f2576117f1611438565b5b600061180085828601611583565b925050602061181185828601611583565b9150509250929050565b600080600080600080600080610100898b03121561183c5761183b611438565b5b600061184a8b828c0161154d565b985050602061185b8b828c0161154d565b975050604061186c8b828c01611517565b965050606061187d8b828c01611583565b955050608061188e8b828c01611583565b94505060a061189f8b828c016115c1565b93505060c06118b08b828c01611583565b92505060e06118c18b828c01611583565b9150509295985092959890939650565b6118da8161152c565b82525050565b60006020820190506118f560008301846118d1565b92915050565b60006020828403121561191157611910611438565b5b600061191f8482850161154d565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061196857611967611928565b5b50565b600081905061197982611957565b919050565b60006119898261196b565b9050919050565b6119998161197e565b82525050565b60006020820190506119b46000830184611990565b92915050565b600061012082840312156119d1576119d0611438565b5b60006119df848285016115d6565b91505092915050565b6119f1816114ee565b82525050565b611a008161152c565b82525050565b611a0f81611562565b82525050565b611a1e81611598565b82525050565b61012082016000820151611a3b60008501826119e8565b506020820151611a4e60208501826119e8565b506040820151611a6160408501826119f7565b506060820151611a7460608501826119f7565b506080820151611a876080850182611a06565b5060a0820151611a9a60a0850182611a06565b5060c0820151611aad60c0850182611a15565b5060e0820151611ac060e0850182611a06565b50610100820151611ad5610100850182611a06565b50505050565b600061012082019050611af16000830184611a24565b92915050565b600082825260208201905092915050565b7f7377617020697320616c726561647920636f6d706c6574656400000000000000600082015250565b6000611b3e601983611af7565b9150611b4982611b08565b602082019050919050565b60006020820190508181036000830152611b6d81611b31565b9050919050565b7f726566756e64206d7573742062652063616c6c6564206279207468652073776160008201527f70206f776e657200000000000000000000000000000000000000000000000000602082015250565b6000611bd0602783611af7565b9150611bdb82611b74565b604082019050919050565b60006020820190508181036000830152611bff81611bc3565b9050919050565b7f697427732074686520636f756e74657270617274792773207475726e2c20756e60008201527f61626c6520746f20726566756e642c2074727920616761696e206c6174657200602082015250565b6000611c62603f83611af7565b9150611c6d82611c06565b604082019050919050565b60006020820190508181036000830152611c9181611c55565b9050919050565b6000819050919050565b6000611cbd611cb8611cb3846114ce565b611c98565b6114ce565b9050919050565b6000611ccf82611ca2565b9050919050565b6000611ce182611cc4565b9050919050565b611cf181611cd6565b82525050565b611d0081611562565b82525050565b6000604082019050611d1b6000830185611ce8565b611d286020830184611cf7565b9392505050565b611d388161174f565b8114611d4357600080fd5b50565b600081519050611d5581611d2f565b92915050565b600060208284031215611d7157611d70611438565b5b6000611d7f84828501611d46565b91505092915050565b7f636c61696d52656c617965722063616e206f6e6c792062652063616c6c65642060008201527f62792061207472757374656420666f7277617264657200000000000000000000602082015250565b6000611de4603683611af7565b9150611def82611d88565b604082019050919050565b60006020820190508181036000830152611e1381611dd7565b9050919050565b7f7369676e6572206f66207468652072656c61796564207472616e73616374696f60008201527f6e206d7573742062652074686520636c61696d65720000000000000000000000602082015250565b6000611e76603583611af7565b9150611e8182611e1a565b604082019050919050565b60006020820190508181036000830152611ea581611e69565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611ee682611562565b9150611ef183611562565b9250828203905081811115611f0957611f08611eac565b5b92915050565b6000604082019050611f2460008301856116f8565b611f316020830184611cf7565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000819050919050565b60008160001b9050919050565b6000611f99611f94611f8f84611f67565b611f71565b61152c565b9050919050565b611fa981611f7e565b82525050565b6000819050919050565b600060ff82169050919050565b6000611fe1611fdc611fd784611faf565b611c98565b611fb9565b9050919050565b611ff181611fc6565b82525050565b600060808201905061200c6000830187611fa0565b6120196020830186611fe8565b61202660408301856118d1565b61203360608301846118d1565b95945050505050565b600061204782611562565b915061205283611562565b925082820190508082111561206a57612069611eac565b5b92915050565b7f76616c7565206e6f742073616d652061732045544820616d6f756e742073656e60008201527f7400000000000000000000000000000000000000000000000000000000000000602082015250565b60006120cc602183611af7565b91506120d782612070565b604082019050919050565b600060208201905081810360008301526120fb816120bf565b9050919050565b600060608201905061211760008301866116f8565b61212460208301856116f8565b6121316040830184611cf7565b949350505050565b7f7377617020616c72656164792065786973747300000000000000000000000000600082015250565b600061216f601383611af7565b915061217a82612139565b602082019050919050565b6000602082019050818103600083015261219e81612162565b9050919050565b600060e0820190506121ba600083018a6118d1565b6121c760208301896118d1565b6121d460408301886118d1565b6121e16060830187611cf7565b6121ee6080830186611cf7565b6121fb60a08301856116f8565b61220860c0830184611cf7565b98975050505050505050565b7f73776170206973206e6f7420696e2050454e44494e4720737461746500000000600082015250565b600061224a601c83611af7565b915061225582612214565b602082019050919050565b600060208201905081810360008301526122798161223d565b9050919050565b7f6f6e6c79207468652073776170206f776e65722063616e2063616c6c2073657460008201527f5265616479000000000000000000000000000000000000000000000000000000602082015250565b60006122dc602583611af7565b91506122e782612280565b604082019050919050565b6000602082019050818103600083015261230b816122cf565b9050919050565b7f70726f76696465642073656372657420646f6573206e6f74206d61746368207460008201527f6865206578706563746564207075626c6963206b657900000000000000000000602082015250565b600061236e603683611af7565b915061237982612312565b604082019050919050565b6000602082019050818103600083015261239d81612361565b9050919050565b7f696e76616c696420737761700000000000000000000000000000000000000000600082015250565b60006123da600c83611af7565b91506123e5826123a4565b602082019050919050565b60006020820190508181036000830152612409816123cd565b9050919050565b7f6f6e6c7920636c61696d65722063616e20636c61696d21000000000000000000600082015250565b6000612446601783611af7565b915061245182612410565b602082019050919050565b6000602082019050818103600083015261247581612439565b9050919050565b7f746f6f206561726c7920746f20636c61696d2100000000000000000000000000600082015250565b60006124b2601383611af7565b91506124bd8261247c565b602082019050919050565b600060208201905081810360008301526124e1816124a5565b9050919050565b7f746f6f206c61746520746f20636c61696d210000000000000000000000000000600082015250565b600061251e601283611af7565b9150612529826124e8565b602082019050919050565b6000602082019050818103600083015261254d81612511565b905091905056fea26469706673582212209e214a8c453f496d821757ac5151c078e6562fa384824ab19add396f716eb16264736f6c63430008130033" //nolint:lll ethAddrByteLen = len(ethcommon.Address{}) // 20 bytes ) -// forwarderAddressIndices is a slice of the start indices where the trusted forwarder +// forwarderAddrIndices is a slice of the start indices where the trusted forwarder // address is compiled into the deployed contract byte code. When verifying the bytecode // of a deployed contract, we need special treatment for these identical 20-byte address -// blocks. See TestForwarderAddressIndexes to update the values. -var forwarderAddressIndices = []int{1474, 1512} +// blocks. See TestForwarderAddrIndexes to update the values. +var forwarderAddrIndices = []int{1474, 1512} var ( - errInvalidSwapContract = errors.New("given contract address does not contain correct SwapFactory code") - errInvalidForwarderContract = errors.New("given contract address does not contain correct Forwarder code") + errInvalidSwapCreatorContract = errors.New("given contract address does not contain correct SwapCreator code") + errInvalidForwarderContract = errors.New("given contract address does not contain correct Forwarder code") ) -// CheckSwapFactoryContractCode checks that the bytecode at the given address matches the -// SwapFactory.sol contract. The trusted forwarder address that the contract was deployed +// CheckSwapCreatorContractCode checks that the bytecode at the given address matches the +// SwapCreator.sol contract. The trusted forwarder address that the contract was deployed // with is parsed out from the byte code and returned. -func CheckSwapFactoryContractCode( +func CheckSwapCreatorContractCode( ctx context.Context, ec *ethclient.Client, contractAddr ethcommon.Address, @@ -48,26 +48,26 @@ func CheckSwapFactoryContractCode( return ethcommon.Address{}, err } - expectedCode := ethcommon.FromHex(expectedSwapFactoryBytecodeHex) + expectedCode := ethcommon.FromHex(expectedSwapCreatorBytecodeHex) if len(code) != len(expectedCode) { - return ethcommon.Address{}, fmt.Errorf("length mismatch: %w", errInvalidSwapContract) + return ethcommon.Address{}, fmt.Errorf("length mismatch: %w", errInvalidSwapCreatorContract) } allZeroAddr := ethcommon.Address{} // we fill this in with the trusted forwarder that the contract was deployed with - var forwarderAddress ethcommon.Address + var forwarderAddr ethcommon.Address - for i, addrIndex := range forwarderAddressIndices { + for i, addrIndex := range forwarderAddrIndices { curAddr := code[addrIndex : addrIndex+ethAddrByteLen] if i == 0 { // initialise the trusted forwarder address on the first index - copy(forwarderAddress[:], curAddr) + copy(forwarderAddr[:], curAddr) } else { // check that any remaining forwarder addresses match the one we found at the first index - if !bytes.Equal(curAddr, forwarderAddress[:]) { - return ethcommon.Address{}, errInvalidSwapContract + if !bytes.Equal(curAddr, forwarderAddr[:]) { + return ethcommon.Address{}, errInvalidSwapCreatorContract } } @@ -81,20 +81,20 @@ func CheckSwapFactoryContractCode( // Now that the trusted forwarder addresses have been zeroed out, the read-in contract code should // match the expected code. if !bytes.Equal(expectedCode, code) { - return ethcommon.Address{}, errInvalidSwapContract + return ethcommon.Address{}, errInvalidSwapCreatorContract } - if (forwarderAddress == ethcommon.Address{}) { - return forwarderAddress, nil + if (forwarderAddr == ethcommon.Address{}) { + return forwarderAddr, nil } - err = CheckForwarderContractCode(ctx, ec, forwarderAddress) + err = CheckForwarderContractCode(ctx, ec, forwarderAddr) if err != nil { return ethcommon.Address{}, err } // return the trusted forwarder address that was parsed from the deployed contract byte code - return forwarderAddress, nil + return forwarderAddr, nil } // CheckForwarderContractCode checks that the trusted forwarder contract used by diff --git a/ethereum/check_swap_factory_contract_test.go b/ethereum/check_swap_creator_contract_test.go similarity index 64% rename from ethereum/check_swap_factory_contract_test.go rename to ethereum/check_swap_creator_contract_test.go index 9fdeae1f..42f3603b 100644 --- a/ethereum/check_swap_factory_contract_test.go +++ b/ethereum/check_swap_creator_contract_test.go @@ -20,7 +20,7 @@ import ( "github.com/stretchr/testify/require" ) -// deployContract is a test helper that deploys the SwapFactory contract and returns the +// deployContract is a test helper that deploys the SwapCreator contract and returns the // deployed address func deployContract( t *testing.T, @@ -29,7 +29,7 @@ func deployContract( trustedForwarder ethcommon.Address, ) ethcommon.Address { ctx := context.Background() - contractAddr, _, err := DeploySwapFactoryWithKey(ctx, ec, pk, trustedForwarder) + contractAddr, _, err := DeploySwapCreatorWithKey(ctx, ec, pk, trustedForwarder) require.NoError(t, err) return contractAddr } @@ -40,7 +40,7 @@ func deployForwarder(t *testing.T, ec *ethclient.Client, pk *ecdsa.PrivateKey) e return addr } -// getContractCode is a test helper that deploys the swap factory contract to read back +// getContractCode is a test helper that deploys the swap creator contract to read back // and return the finalised byte code post deployment. func getContractCode(t *testing.T, trustedForwarder ethcommon.Address) []byte { ec, _ := tests.NewEthClient(t) @@ -59,20 +59,20 @@ func TestCheckForwarderContractCode(t *testing.T) { require.NoError(t, err) } -// This test will fail if the compiled SwapFactory contract is updated, but the -// expectedSwapFactoryBytecodeHex constant is not updated. Use this test to update the +// This test will fail if the compiled SwapCreator contract is updated, but the +// expectedSwapCreatorBytecodeHex constant is not updated. Use this test to update the // constant. -func TestExpectedSwapFactoryBytecodeHex(t *testing.T) { +func TestExpectedSwapCreatorBytecodeHex(t *testing.T) { allZeroTrustedForwarder := ethcommon.Address{} codeHex := ethcommon.Bytes2Hex(getContractCode(t, allZeroTrustedForwarder)) - require.Equal(t, expectedSwapFactoryBytecodeHex, codeHex, - "update the expectedSwapFactoryBytecodeHex constant with the actual value to fix this test") + require.Equal(t, expectedSwapCreatorBytecodeHex, codeHex, + "update the expectedSwapCreatorBytecodeHex constant with the actual value to fix this test") } -// This test will fail if the compiled SwapFactory contract is updated, but the -// forwarderAddressIndexes slice of trusted forwarder locations is not updated. Use this -// test to update the slice. -func TestForwarderAddressIndexes(t *testing.T) { +// This test will fail if the compiled SwapCreator contract is updated, but the +// forwarderAddrIndexes slice of trusted forwarder locations is not updated. Use +// this test to update the slice. +func TestForwarderAddrIndexes(t *testing.T) { ec, _ := tests.NewEthClient(t) pk := tests.GetMakerTestKey(t) trustedForwarder := deployForwarder(t, ec, pk) @@ -86,65 +86,68 @@ func TestForwarderAddressIndexes(t *testing.T) { } } - t.Logf("forwarderAddressIndexes: %v", addressLocations) - require.EqualValues(t, forwarderAddressIndices, addressLocations, - "update forwarderAddressIndexes with above logged indexes to fix this test") + t.Logf("forwarderAddrIndexes: %v", addressLocations) + require.EqualValues(t, forwarderAddrIndices, addressLocations, + "update forwarderAddrIndexes with above logged indexes to fix this test") } -// Ensure that we correctly verify the SwapFactory contract when initialised with +// Ensure that we correctly verify the SwapCreator contract when initialised with // different trusted forwarder addresses. -func TestCheckSwapFactoryContractCode(t *testing.T) { +func TestCheckSwapCreatorContractCode(t *testing.T) { ec, _ := tests.NewEthClient(t) pk := tests.GetMakerTestKey(t) - trustedForwarderAddresses := []string{ + trustedForwarderAddrs := []string{ deployForwarder(t, ec, pk).Hex(), deployForwarder(t, ec, pk).Hex(), deployForwarder(t, ec, pk).Hex(), } - for _, addrHex := range trustedForwarderAddresses { + for _, addrHex := range trustedForwarderAddrs { tfAddr := ethcommon.HexToAddress(addrHex) contractAddr := deployContract(t, ec, pk, tfAddr) - parsedTFAddr, err := CheckSwapFactoryContractCode(context.Background(), ec, contractAddr) + parsedTFAddr, err := CheckSwapCreatorContractCode(context.Background(), ec, contractAddr) require.NoError(t, err) require.Equal(t, addrHex, parsedTFAddr.Hex()) } } // Tests that we fail when the wrong contract byte code is found -func TestCheckSwapFactoryContractCode_fail(t *testing.T) { +func TestCheckSwapCreatorContractCode_fail(t *testing.T) { ec, _ := tests.NewEthClient(t) pk := tests.GetMakerTestKey(t) - // Deploy a forwarder contract and then try to verify it as SwapFactory contract + // Deploy a forwarder contract and then try to verify it as SwapCreator contract contractAddr := deployForwarder(t, ec, pk) - _, err := CheckSwapFactoryContractCode(context.Background(), ec, contractAddr) - require.ErrorIs(t, err, errInvalidSwapContract) + _, err := CheckSwapCreatorContractCode(context.Background(), ec, contractAddr) + require.ErrorIs(t, err, errInvalidSwapCreatorContract) } func TestSepoliaContract(t *testing.T) { - // comment out the next line to test the default sepolia contract - t.Skip("requires access to non-vetted external sepolia node") - const sepoliaEndpoint = "https://rpc.sepolia.org/" + // TODO: CI's ETH_SEPOLIA_ENDPOINT is giving 404 errors + endpoint := "" // os.Getenv("ETH_SEPOLIA_ENDPOINT") + if endpoint == "" { + endpoint = "https://rpc.sepolia.org/" + } + // temporarily place a funded sepolia private key below to deploy the test contract const sepoliaKey = "" ctx := context.Background() - ec, err := ethclient.Dial(sepoliaEndpoint) + ec, err := ethclient.Dial(endpoint) require.NoError(t, err) defer ec.Close() - parsedTFAddr, err := CheckSwapFactoryContractCode(ctx, ec, common.StagenetConfig().SwapFactoryAddress) - if errors.Is(err, errInvalidSwapContract) && sepoliaKey != "" { + parsedTFAddr, err := CheckSwapCreatorContractCode(ctx, ec, common.StagenetConfig().SwapCreatorAddr) + if errors.Is(err, errInvalidSwapCreatorContract) && sepoliaKey != "" { pk, err := ethcrypto.HexToECDSA(sepoliaKey) //nolint:govet // shadow declaration of err require.NoError(t, err) forwarderAddr := deployForwarder(t, ec, pk) - sfAddr, _, err := DeploySwapFactoryWithKey(context.Background(), ec, pk, forwarderAddr) + sfAddr, _, err := DeploySwapCreatorWithKey(context.Background(), ec, pk, forwarderAddr) require.NoError(t, err) - t.Logf("New Sepolia SwapFactory deployed with TrustedForwarder=%s", forwarderAddr) + t.Logf("New Sepolia SwapCreator deployed with TrustedForwarder=%s", forwarderAddr) t.Fatalf("Update common.StagenetConfig.ContractAddress with %s", sfAddr.Hex()) } else { require.NoError(t, err) - t.Logf("Sepolia SwapFactory deployed with TrustedForwarder=%s", parsedTFAddr.Hex()) + t.Logf("Sepolia SwapCreator deployed with TrustedForwarder=%s", parsedTFAddr.Hex()) } } diff --git a/ethereum/contracts/SwapFactory.sol b/ethereum/contracts/SwapCreator.sol similarity index 99% rename from ethereum/contracts/SwapFactory.sol rename to ethereum/contracts/SwapCreator.sol index 0ba05252..e8a57025 100644 --- a/ethereum/contracts/SwapFactory.sol +++ b/ethereum/contracts/SwapCreator.sol @@ -5,7 +5,7 @@ import {ERC2771Context} from "./ERC2771Context.sol"; import {IERC20} from "./IERC20.sol"; import {Secp256k1} from "./Secp256k1.sol"; -contract SwapFactory is ERC2771Context, Secp256k1 { +contract SwapCreator is ERC2771Context, Secp256k1 { // Swap state is PENDING when the swap is first created and funded // Alice sets Stage to READY when she sees the funds locked on the other chain. // this prevents Bob from withdrawing funds without locking funds on the other chain first diff --git a/ethereum/deploy_util.go b/ethereum/deploy_util.go index afa3eaad..c7edb562 100644 --- a/ethereum/deploy_util.go +++ b/ethereum/deploy_util.go @@ -20,14 +20,14 @@ import ( var log = logging.Logger("contracts") -// DeploySwapFactoryWithKey deploys the SwapFactory contract using the passed privKey to +// DeploySwapCreatorWithKey deploys the SwapCreator contract using the passed privKey to // pay for the gas. -func DeploySwapFactoryWithKey( +func DeploySwapCreatorWithKey( ctx context.Context, ec *ethclient.Client, privKey *ecdsa.PrivateKey, forwarderAddr ethcommon.Address, -) (ethcommon.Address, *SwapFactory, error) { +) (ethcommon.Address, *SwapCreator, error) { txOpts, err := newTXOpts(ctx, ec, privKey) if err != nil { @@ -36,13 +36,13 @@ func DeploySwapFactoryWithKey( if (forwarderAddr != ethcommon.Address{}) { if err = registerDomainSeparatorIfNeeded(ctx, ec, privKey, forwarderAddr); err != nil { - return ethcommon.Address{}, nil, fmt.Errorf("failed to deploy swap factory: %w", err) + return ethcommon.Address{}, nil, fmt.Errorf("failed to deploy swap creator: %w", err) } } - address, tx, sf, err := DeploySwapFactory(txOpts, ec, forwarderAddr) + address, tx, sf, err := DeploySwapCreator(txOpts, ec, forwarderAddr) if err != nil { - return ethcommon.Address{}, nil, fmt.Errorf("failed to deploy swap factory: %w", err) + return ethcommon.Address{}, nil, fmt.Errorf("failed to deploy swap creator: %w", err) } _, err = block.WaitForReceipt(ctx, ec, tx.Hash()) @@ -50,7 +50,7 @@ func DeploySwapFactoryWithKey( return ethcommon.Address{}, nil, err } - log.Infof("deployed SwapFactory.sol: address=%s tx hash=%s", address, tx.Hash()) + log.Infof("deployed SwapCreator.sol: address=%s tx hash=%s", address, tx.Hash()) return address, sf, nil } diff --git a/ethereum/erc20_mock.go b/ethereum/erc20_mock.go index ef129595..136c77f4 100644 --- a/ethereum/erc20_mock.go +++ b/ethereum/erc20_mock.go @@ -1,6 +1,3 @@ -// Copyright 2023 Athanor Labs (ON) -// SPDX-License-Identifier: LGPL-3.0-only - // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. @@ -29,12 +26,13 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) // ERC20MockMetaData contains all meta data concerning the ERC20Mock contract. var ERC20MockMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol\",\"type\":\"string\"},{\"internalType\":\"address\",\"name\":\"initialAccount\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"initialBalance\",\"type\":\"uint256\"}],\"stateMutability\":\"payable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"approveInternal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transferInternal\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]", - Bin: "0x6080604052604051620020f4380380620020f4833981810160405281019062000029919062000417565b838381600390816200003c919062000708565b5080600490816200004e919062000708565b5050506200006382826200006d60201b60201c565b505050506200090a565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603620000df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000d69062000850565b60405180910390fd5b620000f360008383620001da60201b60201c565b8060026000828254620001079190620008a1565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051620001ba9190620008ed565b60405180910390a3620001d660008383620001df60201b60201c565b5050565b505050565b505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200024d8262000202565b810181811067ffffffffffffffff821117156200026f576200026e62000213565b5b80604052505050565b600062000284620001e4565b905062000292828262000242565b919050565b600067ffffffffffffffff821115620002b557620002b462000213565b5b620002c08262000202565b9050602081019050919050565b60005b83811015620002ed578082015181840152602081019050620002d0565b60008484015250505050565b6000620003106200030a8462000297565b62000278565b9050828152602081018484840111156200032f576200032e620001fd565b5b6200033c848285620002cd565b509392505050565b600082601f8301126200035c576200035b620001f8565b5b81516200036e848260208601620002f9565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003a48262000377565b9050919050565b620003b68162000397565b8114620003c257600080fd5b50565b600081519050620003d681620003ab565b92915050565b6000819050919050565b620003f181620003dc565b8114620003fd57600080fd5b50565b6000815190506200041181620003e6565b92915050565b60008060008060808587031215620004345762000433620001ee565b5b600085015167ffffffffffffffff811115620004555762000454620001f3565b5b620004638782880162000344565b945050602085015167ffffffffffffffff811115620004875762000486620001f3565b5b620004958782880162000344565b9350506040620004a887828801620003c5565b9250506060620004bb8782880162000400565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200051a57607f821691505b60208210810362000530576200052f620004d2565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026200059a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200055b565b620005a686836200055b565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620005e9620005e3620005dd84620003dc565b620005be565b620003dc565b9050919050565b6000819050919050565b6200060583620005c8565b6200061d6200061482620005f0565b84845462000568565b825550505050565b600090565b6200063462000625565b62000641818484620005fa565b505050565b5b8181101562000669576200065d6000826200062a565b60018101905062000647565b5050565b601f821115620006b857620006828162000536565b6200068d846200054b565b810160208510156200069d578190505b620006b5620006ac856200054b565b83018262000646565b50505b505050565b600082821c905092915050565b6000620006dd60001984600802620006bd565b1980831691505092915050565b6000620006f88383620006ca565b9150826002028217905092915050565b6200071382620004c7565b67ffffffffffffffff8111156200072f576200072e62000213565b5b6200073b825462000501565b620007488282856200066d565b600060209050601f8311600181146200078057600084156200076b578287015190505b620007778582620006ea565b865550620007e7565b601f198416620007908662000536565b60005b82811015620007ba5784890151825560018201915060208501945060208101905062000793565b86831015620007da5784890151620007d6601f891682620006ca565b8355505b6001600288020188555050505b505050505050565b600082825260208201905092915050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600062000838601f83620007ef565b9150620008458262000800565b602082019050919050565b600060208201905081810360008301526200086b8162000829565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000620008ae82620003dc565b9150620008bb83620003dc565b9250828201905080821115620008d657620008d562000872565b5b92915050565b620008e781620003dc565b82525050565b6000602082019050620009046000830184620008dc565b92915050565b6117da806200091a6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f19116100975780639dc29fac116100665780639dc29fac14610286578063a457c2d7146102a2578063a9059cbb146102d2578063dd62ed3e14610302576100f5565b806340c10f191461020057806356189cb41461021c57806370a082311461023857806395d89b4114610268576100f5565b8063222f5be0116100d3578063222f5be01461016657806323b872dd14610182578063313ce567146101b257806339509351146101d0576100f5565b806306fdde03146100fa578063095ea7b31461011857806318160ddd14610148575b600080fd5b610102610332565b60405161010f9190610f27565b60405180910390f35b610132600480360381019061012d9190610fe2565b6103c4565b60405161013f919061103d565b60405180910390f35b6101506103e7565b60405161015d9190611067565b60405180910390f35b610180600480360381019061017b9190611082565b6103f1565b005b61019c60048036038101906101979190611082565b610401565b6040516101a9919061103d565b60405180910390f35b6101ba610430565b6040516101c791906110f1565b60405180910390f35b6101ea60048036038101906101e59190610fe2565b610439565b6040516101f7919061103d565b60405180910390f35b61021a60048036038101906102159190610fe2565b610470565b005b61023660048036038101906102319190611082565b61047e565b005b610252600480360381019061024d919061110c565b61048e565b60405161025f9190611067565b60405180910390f35b6102706104d6565b60405161027d9190610f27565b60405180910390f35b6102a0600480360381019061029b9190610fe2565b610568565b005b6102bc60048036038101906102b79190610fe2565b610576565b6040516102c9919061103d565b60405180910390f35b6102ec60048036038101906102e79190610fe2565b6105ed565b6040516102f9919061103d565b60405180910390f35b61031c60048036038101906103179190611139565b610610565b6040516103299190611067565b60405180910390f35b606060038054610341906111a8565b80601f016020809104026020016040519081016040528092919081815260200182805461036d906111a8565b80156103ba5780601f1061038f576101008083540402835291602001916103ba565b820191906000526020600020905b81548152906001019060200180831161039d57829003601f168201915b5050505050905090565b6000806103cf610697565b90506103dc81858561069f565b600191505092915050565b6000600254905090565b6103fc838383610868565b505050565b60008061040c610697565b9050610419858285610ade565b610424858585610868565b60019150509392505050565b60006012905090565b600080610444610697565b90506104658185856104568589610610565b6104609190611208565b61069f565b600191505092915050565b61047a8282610b6a565b5050565b61048983838361069f565b505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546104e5906111a8565b80601f0160208091040260200160405190810160405280929190818152602001828054610511906111a8565b801561055e5780601f106105335761010080835404028352916020019161055e565b820191906000526020600020905b81548152906001019060200180831161054157829003601f168201915b5050505050905090565b6105728282610cc0565b5050565b600080610581610697565b9050600061058f8286610610565b9050838110156105d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cb906112ae565b60405180910390fd5b6105e1828686840361069f565b60019250505092915050565b6000806105f8610697565b9050610605818585610868565b600191505092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361070e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070590611340565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361077d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610774906113d2565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161085b9190611067565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ce90611464565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610946576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093d906114f6565b60405180910390fd5b610951838383610e8d565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156109d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ce90611588565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610ac59190611067565b60405180910390a3610ad8848484610e92565b50505050565b6000610aea8484610610565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610b645781811015610b56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4d906115f4565b60405180910390fd5b610b63848484840361069f565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610bd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd090611660565b60405180910390fd5b610be560008383610e8d565b8060026000828254610bf79190611208565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610ca89190611067565b60405180910390a3610cbc60008383610e92565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d26906116f2565b60405180910390fd5b610d3b82600083610e8d565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610dc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db890611784565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282540392505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610e749190611067565b60405180910390a3610e8883600084610e92565b505050565b505050565b505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610ed1578082015181840152602081019050610eb6565b60008484015250505050565b6000601f19601f8301169050919050565b6000610ef982610e97565b610f038185610ea2565b9350610f13818560208601610eb3565b610f1c81610edd565b840191505092915050565b60006020820190508181036000830152610f418184610eee565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f7982610f4e565b9050919050565b610f8981610f6e565b8114610f9457600080fd5b50565b600081359050610fa681610f80565b92915050565b6000819050919050565b610fbf81610fac565b8114610fca57600080fd5b50565b600081359050610fdc81610fb6565b92915050565b60008060408385031215610ff957610ff8610f49565b5b600061100785828601610f97565b925050602061101885828601610fcd565b9150509250929050565b60008115159050919050565b61103781611022565b82525050565b6000602082019050611052600083018461102e565b92915050565b61106181610fac565b82525050565b600060208201905061107c6000830184611058565b92915050565b60008060006060848603121561109b5761109a610f49565b5b60006110a986828701610f97565b93505060206110ba86828701610f97565b92505060406110cb86828701610fcd565b9150509250925092565b600060ff82169050919050565b6110eb816110d5565b82525050565b600060208201905061110660008301846110e2565b92915050565b60006020828403121561112257611121610f49565b5b600061113084828501610f97565b91505092915050565b600080604083850312156111505761114f610f49565b5b600061115e85828601610f97565b925050602061116f85828601610f97565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806111c057607f821691505b6020821081036111d3576111d2611179565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061121382610fac565b915061121e83610fac565b9250828201905080821115611236576112356111d9565b5b92915050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000611298602583610ea2565b91506112a38261123c565b604082019050919050565b600060208201905081810360008301526112c78161128b565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061132a602483610ea2565b9150611335826112ce565b604082019050919050565b600060208201905081810360008301526113598161131d565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006113bc602283610ea2565b91506113c782611360565b604082019050919050565b600060208201905081810360008301526113eb816113af565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b600061144e602583610ea2565b9150611459826113f2565b604082019050919050565b6000602082019050818103600083015261147d81611441565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006114e0602383610ea2565b91506114eb82611484565b604082019050919050565b6000602082019050818103600083015261150f816114d3565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000611572602683610ea2565b915061157d82611516565b604082019050919050565b600060208201905081810360008301526115a181611565565b9050919050565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b60006115de601d83610ea2565b91506115e9826115a8565b602082019050919050565b6000602082019050818103600083015261160d816115d1565b9050919050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600061164a601f83610ea2565b915061165582611614565b602082019050919050565b600060208201905081810360008301526116798161163d565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b60006116dc602183610ea2565b91506116e782611680565b604082019050919050565b6000602082019050818103600083015261170b816116cf565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b600061176e602283610ea2565b915061177982611712565b604082019050919050565b6000602082019050818103600083015261179d81611761565b905091905056fea2646970667358221220b9927c0e6cb6fcc5601de2bb6a346d05bc04193af7313cc6ba7eaf0ddb8798c464736f6c63430008110033", + Bin: "0x6080604052604051620020f4380380620020f4833981810160405281019062000029919062000417565b838381600390816200003c919062000708565b5080600490816200004e919062000708565b5050506200006382826200006d60201b60201c565b505050506200090a565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603620000df576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401620000d69062000850565b60405180910390fd5b620000f360008383620001da60201b60201c565b8060026000828254620001079190620008a1565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051620001ba9190620008ed565b60405180910390a3620001d660008383620001df60201b60201c565b5050565b505050565b505050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6200024d8262000202565b810181811067ffffffffffffffff821117156200026f576200026e62000213565b5b80604052505050565b600062000284620001e4565b905062000292828262000242565b919050565b600067ffffffffffffffff821115620002b557620002b462000213565b5b620002c08262000202565b9050602081019050919050565b60005b83811015620002ed578082015181840152602081019050620002d0565b60008484015250505050565b6000620003106200030a8462000297565b62000278565b9050828152602081018484840111156200032f576200032e620001fd565b5b6200033c848285620002cd565b509392505050565b600082601f8301126200035c576200035b620001f8565b5b81516200036e848260208601620002f9565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003a48262000377565b9050919050565b620003b68162000397565b8114620003c257600080fd5b50565b600081519050620003d681620003ab565b92915050565b6000819050919050565b620003f181620003dc565b8114620003fd57600080fd5b50565b6000815190506200041181620003e6565b92915050565b60008060008060808587031215620004345762000433620001ee565b5b600085015167ffffffffffffffff811115620004555762000454620001f3565b5b620004638782880162000344565b945050602085015167ffffffffffffffff811115620004875762000486620001f3565b5b620004958782880162000344565b9350506040620004a887828801620003c5565b9250506060620004bb8782880162000400565b91505092959194509250565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200051a57607f821691505b60208210810362000530576200052f620004d2565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026200059a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200055b565b620005a686836200055b565b95508019841693508086168417925050509392505050565b6000819050919050565b6000620005e9620005e3620005dd84620003dc565b620005be565b620003dc565b9050919050565b6000819050919050565b6200060583620005c8565b6200061d6200061482620005f0565b84845462000568565b825550505050565b600090565b6200063462000625565b62000641818484620005fa565b505050565b5b8181101562000669576200065d6000826200062a565b60018101905062000647565b5050565b601f821115620006b857620006828162000536565b6200068d846200054b565b810160208510156200069d578190505b620006b5620006ac856200054b565b83018262000646565b50505b505050565b600082821c905092915050565b6000620006dd60001984600802620006bd565b1980831691505092915050565b6000620006f88383620006ca565b9150826002028217905092915050565b6200071382620004c7565b67ffffffffffffffff8111156200072f576200072e62000213565b5b6200073b825462000501565b620007488282856200066d565b600060209050601f8311600181146200078057600084156200076b578287015190505b620007778582620006ea565b865550620007e7565b601f198416620007908662000536565b60005b82811015620007ba5784890151825560018201915060208501945060208101905062000793565b86831015620007da5784890151620007d6601f891682620006ca565b8355505b6001600288020188555050505b505050505050565b600082825260208201905092915050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600062000838601f83620007ef565b9150620008458262000800565b602082019050919050565b600060208201905081810360008301526200086b8162000829565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000620008ae82620003dc565b9150620008bb83620003dc565b9250828201905080821115620008d657620008d562000872565b5b92915050565b620008e781620003dc565b82525050565b6000602082019050620009046000830184620008dc565b92915050565b6117da806200091a6000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c806340c10f19116100975780639dc29fac116100665780639dc29fac14610286578063a457c2d7146102a2578063a9059cbb146102d2578063dd62ed3e14610302576100f5565b806340c10f191461020057806356189cb41461021c57806370a082311461023857806395d89b4114610268576100f5565b8063222f5be0116100d3578063222f5be01461016657806323b872dd14610182578063313ce567146101b257806339509351146101d0576100f5565b806306fdde03146100fa578063095ea7b31461011857806318160ddd14610148575b600080fd5b610102610332565b60405161010f9190610f27565b60405180910390f35b610132600480360381019061012d9190610fe2565b6103c4565b60405161013f919061103d565b60405180910390f35b6101506103e7565b60405161015d9190611067565b60405180910390f35b610180600480360381019061017b9190611082565b6103f1565b005b61019c60048036038101906101979190611082565b610401565b6040516101a9919061103d565b60405180910390f35b6101ba610430565b6040516101c791906110f1565b60405180910390f35b6101ea60048036038101906101e59190610fe2565b610439565b6040516101f7919061103d565b60405180910390f35b61021a60048036038101906102159190610fe2565b610470565b005b61023660048036038101906102319190611082565b61047e565b005b610252600480360381019061024d919061110c565b61048e565b60405161025f9190611067565b60405180910390f35b6102706104d6565b60405161027d9190610f27565b60405180910390f35b6102a0600480360381019061029b9190610fe2565b610568565b005b6102bc60048036038101906102b79190610fe2565b610576565b6040516102c9919061103d565b60405180910390f35b6102ec60048036038101906102e79190610fe2565b6105ed565b6040516102f9919061103d565b60405180910390f35b61031c60048036038101906103179190611139565b610610565b6040516103299190611067565b60405180910390f35b606060038054610341906111a8565b80601f016020809104026020016040519081016040528092919081815260200182805461036d906111a8565b80156103ba5780601f1061038f576101008083540402835291602001916103ba565b820191906000526020600020905b81548152906001019060200180831161039d57829003601f168201915b5050505050905090565b6000806103cf610697565b90506103dc81858561069f565b600191505092915050565b6000600254905090565b6103fc838383610868565b505050565b60008061040c610697565b9050610419858285610ade565b610424858585610868565b60019150509392505050565b60006012905090565b600080610444610697565b90506104658185856104568589610610565b6104609190611208565b61069f565b600191505092915050565b61047a8282610b6a565b5050565b61048983838361069f565b505050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6060600480546104e5906111a8565b80601f0160208091040260200160405190810160405280929190818152602001828054610511906111a8565b801561055e5780601f106105335761010080835404028352916020019161055e565b820191906000526020600020905b81548152906001019060200180831161054157829003601f168201915b5050505050905090565b6105728282610cc0565b5050565b600080610581610697565b9050600061058f8286610610565b9050838110156105d4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105cb906112ae565b60405180910390fd5b6105e1828686840361069f565b60019250505092915050565b6000806105f8610697565b9050610605818585610868565b600191505092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361070e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161070590611340565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361077d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610774906113d2565b60405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258360405161085b9190611067565b60405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ce90611464565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610946576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161093d906114f6565b60405180910390fd5b610951838383610e8d565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156109d7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ce90611588565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610ac59190611067565b60405180910390a3610ad8848484610e92565b50505050565b6000610aea8484610610565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610b645781811015610b56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b4d906115f4565b60405180910390fd5b610b63848484840361069f565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610bd9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd090611660565b60405180910390fd5b610be560008383610e8d565b8060026000828254610bf79190611208565b92505081905550806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610ca89190611067565b60405180910390a3610cbc60008383610e92565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d2f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d26906116f2565b60405180910390fd5b610d3b82600083610e8d565b60008060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610dc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db890611784565b60405180910390fd5b8181036000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555081600260008282540392505081905550600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610e749190611067565b60405180910390a3610e8883600084610e92565b505050565b505050565b505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610ed1578082015181840152602081019050610eb6565b60008484015250505050565b6000601f19601f8301169050919050565b6000610ef982610e97565b610f038185610ea2565b9350610f13818560208601610eb3565b610f1c81610edd565b840191505092915050565b60006020820190508181036000830152610f418184610eee565b905092915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610f7982610f4e565b9050919050565b610f8981610f6e565b8114610f9457600080fd5b50565b600081359050610fa681610f80565b92915050565b6000819050919050565b610fbf81610fac565b8114610fca57600080fd5b50565b600081359050610fdc81610fb6565b92915050565b60008060408385031215610ff957610ff8610f49565b5b600061100785828601610f97565b925050602061101885828601610fcd565b9150509250929050565b60008115159050919050565b61103781611022565b82525050565b6000602082019050611052600083018461102e565b92915050565b61106181610fac565b82525050565b600060208201905061107c6000830184611058565b92915050565b60008060006060848603121561109b5761109a610f49565b5b60006110a986828701610f97565b93505060206110ba86828701610f97565b92505060406110cb86828701610fcd565b9150509250925092565b600060ff82169050919050565b6110eb816110d5565b82525050565b600060208201905061110660008301846110e2565b92915050565b60006020828403121561112257611121610f49565b5b600061113084828501610f97565b91505092915050565b600080604083850312156111505761114f610f49565b5b600061115e85828601610f97565b925050602061116f85828601610f97565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806111c057607f821691505b6020821081036111d3576111d2611179565b5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061121382610fac565b915061121e83610fac565b9250828201905080821115611236576112356111d9565b5b92915050565b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f7760008201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b6000611298602583610ea2565b91506112a38261123c565b604082019050919050565b600060208201905081810360008301526112c78161128b565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061132a602483610ea2565b9150611335826112ce565b604082019050919050565b600060208201905081810360008301526113598161131d565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f20616464726560008201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b60006113bc602283610ea2565b91506113c782611360565b604082019050919050565b600060208201905081810360008301526113eb816113af565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f20616460008201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b600061144e602583610ea2565b9150611459826113f2565b604082019050919050565b6000602082019050818103600083015261147d81611441565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f206164647260008201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b60006114e0602383610ea2565b91506114eb82611484565b604082019050919050565b6000602082019050818103600083015261150f816114d3565b9050919050565b7f45524332303a207472616e7366657220616d6f756e742065786365656473206260008201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b6000611572602683610ea2565b915061157d82611516565b604082019050919050565b600060208201905081810360008301526115a181611565565b9050919050565b7f45524332303a20696e73756666696369656e7420616c6c6f77616e6365000000600082015250565b60006115de601d83610ea2565b91506115e9826115a8565b602082019050919050565b6000602082019050818103600083015261160d816115d1565b9050919050565b7f45524332303a206d696e7420746f20746865207a65726f206164647265737300600082015250565b600061164a601f83610ea2565b915061165582611614565b602082019050919050565b600060208201905081810360008301526116798161163d565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f2061646472657360008201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b60006116dc602183610ea2565b91506116e782611680565b604082019050919050565b6000602082019050818103600083015261170b816116cf565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e60008201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b600061176e602283610ea2565b915061177982611712565b604082019050919050565b6000602082019050818103600083015261179d81611761565b905091905056fea2646970667358221220af9e01ce81a57fddb609151c618fc94dec5e4a2921f9625373b205f1b2b92fc764736f6c63430008130033", } // ERC20MockABI is the input ABI used to generate the binding from. @@ -159,11 +157,11 @@ func NewERC20MockFilterer(address common.Address, filterer bind.ContractFilterer // bindERC20Mock binds a generic wrapper to an already deployed contract. func bindERC20Mock(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(ERC20MockABI)) + parsed, err := ERC20MockMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/ethereum/erc20_mock_test.go b/ethereum/erc20_mock_test.go index 0c2f5b28..ac7e3195 100644 --- a/ethereum/erc20_mock_test.go +++ b/ethereum/erc20_mock_test.go @@ -15,7 +15,7 @@ import ( "github.com/athanorlabs/atomic-swap/ethereum/block" ) -func TestSwapFactory_NewSwap_ERC20(t *testing.T) { +func TestSwapCreator_NewSwap_ERC20(t *testing.T) { auth, conn, pkA := setupXMRTakerAuth(t) pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) @@ -30,7 +30,7 @@ func TestSwapFactory_NewSwap_ERC20(t *testing.T) { testNewSwap(t, erc20Addr) } -func TestSwapFactory_Claim_ERC20(t *testing.T) { +func TestSwapCreator_Claim_ERC20(t *testing.T) { auth, conn, pkA := setupXMRTakerAuth(t) pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) @@ -48,7 +48,7 @@ func TestSwapFactory_Claim_ERC20(t *testing.T) { testClaim(t, erc20Addr, 2, big.NewInt(99), erc20Contract) } -func TestSwapFactory_RefundBeforeT0_ERC20(t *testing.T) { +func TestSwapCreator_RefundBeforeT0_ERC20(t *testing.T) { auth, conn, pkA := setupXMRTakerAuth(t) pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) @@ -62,7 +62,7 @@ func TestSwapFactory_RefundBeforeT0_ERC20(t *testing.T) { testRefundBeforeT0(t, erc20Addr, 2) } -func TestSwapFactory_RefundAfterT1_ERC20(t *testing.T) { +func TestSwapCreator_RefundAfterT1_ERC20(t *testing.T) { auth, conn, pkA := setupXMRTakerAuth(t) pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) diff --git a/ethereum/extethclient/eth_wallet_client.go b/ethereum/extethclient/eth_wallet_client.go index 5635b29f..5eee9ed8 100644 --- a/ethereum/extethclient/eth_wallet_client.go +++ b/ethereum/extethclient/eth_wallet_client.go @@ -138,7 +138,7 @@ func (c *ethClient) Balance(ctx context.Context) (*big.Int, error) { return bal, nil } -// SuggestedGasPrice returns the underlying eth client's suggested gas price +// SuggestGasPrice returns the underlying eth client's suggested gas price // unless the user specified a fixed gas price to use, in which case the user // supplied value is returned. func (c *ethClient) SuggestGasPrice(ctx context.Context) (*big.Int, error) { diff --git a/ethereum/ierc20.go b/ethereum/ierc20.go index 2f6e9ea3..85afeaa6 100644 --- a/ethereum/ierc20.go +++ b/ethereum/ierc20.go @@ -1,6 +1,3 @@ -// Copyright 2023 Athanor Labs (ON) -// SPDX-License-Identifier: LGPL-3.0-only - // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. @@ -29,6 +26,7 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) // IERC20MetaData contains all meta data concerning the IERC20 contract. @@ -137,11 +135,11 @@ func NewIERC20Filterer(address common.Address, filterer bind.ContractFilterer) ( // bindIERC20 binds a generic wrapper to an already deployed contract. func bindIERC20(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(IERC20ABI)) + parsed, err := IERC20MetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil } // Call invokes the (constant) contract method with params as input values and diff --git a/ethereum/swap_factory.go b/ethereum/swap_creator.go similarity index 78% rename from ethereum/swap_factory.go rename to ethereum/swap_creator.go index fd1e7a06..5ae16280 100644 --- a/ethereum/swap_factory.go +++ b/ethereum/swap_creator.go @@ -1,6 +1,3 @@ -// Copyright 2023 Athanor Labs (ON) -// SPDX-License-Identifier: LGPL-3.0-only - // Code generated - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. @@ -29,10 +26,11 @@ var ( _ = common.Big1 _ = types.BloomLookup _ = event.NewSubscription + _ = abi.ConvertType ) -// SwapFactorySwap is an auto generated low-level Go binding around an user-defined struct. -type SwapFactorySwap struct { +// SwapCreatorSwap is an auto generated low-level Go binding around an user-defined struct. +type SwapCreatorSwap struct { Owner common.Address Claimer common.Address PubKeyClaim [32]byte @@ -44,23 +42,23 @@ type SwapFactorySwap struct { Nonce *big.Int } -// SwapFactoryMetaData contains all meta data concerning the SwapFactory contract. -var SwapFactoryMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"trustedForwarder\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"Claimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"claimKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"refundKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"New\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"}],\"name\":\"Ready\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"Refunded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_trustedForwarder\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapFactory.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapFactory.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"claimRelayer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forwarder\",\"type\":\"address\"}],\"name\":\"isTrustedForwarder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"scalar\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"qKeccak\",\"type\":\"uint256\"}],\"name\":\"mulVerify\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"addresspayable\",\"name\":\"_claimer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_timeoutDuration0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timeoutDuration1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_nonce\",\"type\":\"uint256\"}],\"name\":\"newSwap\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapFactory.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapFactory.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"}],\"name\":\"setReady\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"swaps\",\"outputs\":[{\"internalType\":\"enumSwapFactory.Stage\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x60a06040523480156200001157600080fd5b50604051620026bd380380620026bd8339818101604052810190620000379190620000de565b808073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050505062000110565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000a68262000079565b9050919050565b620000b88162000099565b8114620000c457600080fd5b50565b600081519050620000d881620000ad565b92915050565b600060208284031215620000f757620000f662000074565b5b60006200010784828501620000c7565b91505092915050565b60805161258a62000133600039600081816105b601526105dc015261258a6000f3fe6080604052600436106100865760003560e01c806373e4771c1161005957806373e4771c14610145578063b32d1b4f1461016e578063c41e46cf146101ab578063eb84e7f2146101db578063fcaf229c1461021857610086565b80631e6c5acc1461008b57806356c022bb146100b4578063572b6c05146100df5780635cb969161461011c575b600080fd5b34801561009757600080fd5b506100b260048036038101906100ad91906116b6565b610241565b005b3480156100c057600080fd5b506100c96105b4565b6040516100d69190611707565b60405180910390f35b3480156100eb57600080fd5b5061010660048036038101906101019190611722565b6105d8565b604051610113919061176a565b60405180910390f35b34801561012857600080fd5b50610143600480360381019061013e91906116b6565b610630565b005b34801561015157600080fd5b5061016c60048036038101906101679190611785565b610756565b005b34801561017a57600080fd5b50610195600480360381019061019091906117db565b610a1e565b6040516101a2919061176a565b60405180910390f35b6101c560048036038101906101c0919061181b565b610b23565b6040516101d291906118e0565b60405180910390f35b3480156101e757600080fd5b5061020260048036038101906101fd91906118fb565b610e90565b60405161020f919061199f565b60405180910390f35b34801561022457600080fd5b5061023f600480360381019061023a91906119ba565b610eb0565b005b6000826040516020016102549190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff1690506003808111156102a3576102a2611928565b5b8160038111156102b6576102b5611928565b5b141580156102e95750600060038111156102d3576102d2611928565b5b8160038111156102e6576102e5611928565b5b14155b610328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031f90611b54565b60405180910390fd5b836000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039190611be6565b60405180910390fd5b8360a00151421015806103e157508360800151421080156103e05750600260038111156103ca576103c9611928565b5b8160038111156103dd576103dc611928565b5b14155b5b610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041790611c78565b60405180910390fd5b61042e83856060015161103f565b82827e7c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561049157610490611928565b5b0217905550600073ffffffffffffffffffffffffffffffffffffffff168460c0015173ffffffffffffffffffffffffffffffffffffffff160361052257836000015173ffffffffffffffffffffffffffffffffffffffff166108fc8560e001519081150290604051600060405180830381858888f1935050505015801561051c573d6000803e3d6000fd5b506105ae565b8360c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85600001518660e001516040518363ffffffff1660e01b8152600401610569929190611d06565b6020604051808303816000875af1158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac9190611d5b565b505b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b61063a8282611092565b600073ffffffffffffffffffffffffffffffffffffffff168260c0015173ffffffffffffffffffffffffffffffffffffffff16036106c657816020015173ffffffffffffffffffffffffffffffffffffffff166108fc8360e001519081150290604051600060405180830381858888f193505050501580156106c0573d6000803e3d6000fd5b50610752565b8160c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83602001518460e001516040518363ffffffff1660e01b815260040161070d929190611d06565b6020604051808303816000875af115801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190611d5b565b505b5050565b61075f336105d8565b61079e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079590611dfa565b60405180910390fd5b826020015173ffffffffffffffffffffffffffffffffffffffff166107c1611360565b73ffffffffffffffffffffffffffffffffffffffff1614610817576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080e90611e8c565b60405180910390fd5b6108218383611092565b600073ffffffffffffffffffffffffffffffffffffffff168360c0015173ffffffffffffffffffffffffffffffffffffffff16036108ff57826020015173ffffffffffffffffffffffffffffffffffffffff166108fc828560e001516108879190611edb565b9081150290604051600060405180830381858888f193505050501580156108b2573d6000803e3d6000fd5b503273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156108f9573d6000803e3d6000fd5b50610a19565b8260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8460200151838660e001516109349190611edb565b6040518363ffffffff1660e01b8152600401610951929190611d06565b6020604051808303816000875af1158015610970573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109949190611d5b565b508260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb32836040518363ffffffff1660e01b81526004016109d4929190611f0f565b6020604051808303816000875af11580156109f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a179190611d5b565b505b505050565b60008060016000601b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179860001b7ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414180610a7a57610a79611f38565b5b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798890960001b60405160008152602001604052604051610abd9493929190611ff7565b6020604051602081039080840390855afa158015610adf573d6000803e3d6000fd5b5050506020604051035190508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161491505092915050565b6000610b2d61139a565b33816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050898160400181815250508881606001818152505087816020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508642610bbd919061203c565b816080018181525050858742610bd3919061203c565b610bdd919061203c565b8160a0018181525050848160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160e0018181525050600073ffffffffffffffffffffffffffffffffffffffff168160c0015173ffffffffffffffffffffffffffffffffffffffff1603610cab57348160e0015114610ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9d906120e2565b60405180910390fd5b610d35565b8060c0015173ffffffffffffffffffffffffffffffffffffffff166323b872dd33308460e001516040518463ffffffff1660e01b8152600401610cf093929190612102565b6020604051808303816000875af1158015610d0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d339190611d5b565b505b8281610100018181525050600081604051602001610d539190611adb565b60405160208183030381529060405280519060200120905060006003811115610d7f57610d7e611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610db157610db0611928565b5b14610df1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de890612185565b60405180910390fd5b7f91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56818c8c85608001518660a001518760c001518860e00151604051610e3c97969594939291906121a5565b60405180910390a1600160008083815260200190815260200160002060006101000a81548160ff02191690836003811115610e7a57610e79611928565b5b0217905550809250505098975050505050505050565b60006020528060005260406000206000915054906101000a900460ff1681565b600081604051602001610ec39190611adb565b60405160208183030381529060405280519060200120905060016003811115610eef57610eee611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610f2157610f20611928565b5b14610f61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5890612260565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614610fd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fca906122f2565b60405180910390fd5b600260008083815260200190815260200160002060006101000a81548160ff0219169083600381111561100957611008611928565b5b0217905550807f5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f60405160405180910390a25050565b61104f8260001c8260001c610a1e565b61108e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108590612384565b60405180910390fd5b5050565b6000826040516020016110a59190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff169050600060038111156110f5576110f4611928565b5b81600381111561110857611107611928565b5b03611148576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113f906123f0565b60405180910390fd5b60038081111561115b5761115a611928565b5b81600381111561116e5761116d611928565b5b036111ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a590611b54565b60405180910390fd5b836020015173ffffffffffffffffffffffffffffffffffffffff166111d1611360565b73ffffffffffffffffffffffffffffffffffffffff1614611227576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121e9061245c565b60405180910390fd5b83608001514210158061125e57506002600381111561124957611248611928565b5b81600381111561125c5761125b611928565b5b145b61129d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611294906124c8565b60405180910390fd5b8360a0015142106112e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112da90612534565b60405180910390fd5b6112f183856040015161103f565b82827f38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561135557611354611928565b5b021790555050505050565b600061136b336105d8565b1561137f57601436033560601c905061138e565b611387611392565b905061138f565b5b90565b600033905090565b604051806101200160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008019168152602001600080191681526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081525090565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61148b82611442565b810181811067ffffffffffffffff821117156114aa576114a9611453565b5b80604052505050565b60006114bd61142e565b90506114c98282611482565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006114f9826114ce565b9050919050565b611509816114ee565b811461151457600080fd5b50565b60008135905061152681611500565b92915050565b6000819050919050565b61153f8161152c565b811461154a57600080fd5b50565b60008135905061155c81611536565b92915050565b6000819050919050565b61157581611562565b811461158057600080fd5b50565b6000813590506115928161156c565b92915050565b60006115a3826114ce565b9050919050565b6115b381611598565b81146115be57600080fd5b50565b6000813590506115d0816115aa565b92915050565b600061012082840312156115ed576115ec61143d565b5b6115f86101206114b3565b9050600061160884828501611517565b600083015250602061161c84828501611517565b60208301525060406116308482850161154d565b60408301525060606116448482850161154d565b606083015250608061165884828501611583565b60808301525060a061166c84828501611583565b60a08301525060c0611680848285016115c1565b60c08301525060e061169484828501611583565b60e0830152506101006116a984828501611583565b6101008301525092915050565b60008061014083850312156116ce576116cd611438565b5b60006116dc858286016115d6565b9250506101206116ee8582860161154d565b9150509250929050565b61170181611598565b82525050565b600060208201905061171c60008301846116f8565b92915050565b60006020828403121561173857611737611438565b5b6000611746848285016115c1565b91505092915050565b60008115159050919050565b6117648161174f565b82525050565b600060208201905061177f600083018461175b565b92915050565b6000806000610160848603121561179f5761179e611438565b5b60006117ad868287016115d6565b9350506101206117bf8682870161154d565b9250506101406117d186828701611583565b9150509250925092565b600080604083850312156117f2576117f1611438565b5b600061180085828601611583565b925050602061181185828601611583565b9150509250929050565b600080600080600080600080610100898b03121561183c5761183b611438565b5b600061184a8b828c0161154d565b985050602061185b8b828c0161154d565b975050604061186c8b828c01611517565b965050606061187d8b828c01611583565b955050608061188e8b828c01611583565b94505060a061189f8b828c016115c1565b93505060c06118b08b828c01611583565b92505060e06118c18b828c01611583565b9150509295985092959890939650565b6118da8161152c565b82525050565b60006020820190506118f560008301846118d1565b92915050565b60006020828403121561191157611910611438565b5b600061191f8482850161154d565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061196857611967611928565b5b50565b600081905061197982611957565b919050565b60006119898261196b565b9050919050565b6119998161197e565b82525050565b60006020820190506119b46000830184611990565b92915050565b600061012082840312156119d1576119d0611438565b5b60006119df848285016115d6565b91505092915050565b6119f1816114ee565b82525050565b611a008161152c565b82525050565b611a0f81611562565b82525050565b611a1e81611598565b82525050565b61012082016000820151611a3b60008501826119e8565b506020820151611a4e60208501826119e8565b506040820151611a6160408501826119f7565b506060820151611a7460608501826119f7565b506080820151611a876080850182611a06565b5060a0820151611a9a60a0850182611a06565b5060c0820151611aad60c0850182611a15565b5060e0820151611ac060e0850182611a06565b50610100820151611ad5610100850182611a06565b50505050565b600061012082019050611af16000830184611a24565b92915050565b600082825260208201905092915050565b7f7377617020697320616c726561647920636f6d706c6574656400000000000000600082015250565b6000611b3e601983611af7565b9150611b4982611b08565b602082019050919050565b60006020820190508181036000830152611b6d81611b31565b9050919050565b7f726566756e64206d7573742062652063616c6c6564206279207468652073776160008201527f70206f776e657200000000000000000000000000000000000000000000000000602082015250565b6000611bd0602783611af7565b9150611bdb82611b74565b604082019050919050565b60006020820190508181036000830152611bff81611bc3565b9050919050565b7f697427732074686520636f756e74657270617274792773207475726e2c20756e60008201527f61626c6520746f20726566756e642c2074727920616761696e206c6174657200602082015250565b6000611c62603f83611af7565b9150611c6d82611c06565b604082019050919050565b60006020820190508181036000830152611c9181611c55565b9050919050565b6000819050919050565b6000611cbd611cb8611cb3846114ce565b611c98565b6114ce565b9050919050565b6000611ccf82611ca2565b9050919050565b6000611ce182611cc4565b9050919050565b611cf181611cd6565b82525050565b611d0081611562565b82525050565b6000604082019050611d1b6000830185611ce8565b611d286020830184611cf7565b9392505050565b611d388161174f565b8114611d4357600080fd5b50565b600081519050611d5581611d2f565b92915050565b600060208284031215611d7157611d70611438565b5b6000611d7f84828501611d46565b91505092915050565b7f636c61696d52656c617965722063616e206f6e6c792062652063616c6c65642060008201527f62792061207472757374656420666f7277617264657200000000000000000000602082015250565b6000611de4603683611af7565b9150611def82611d88565b604082019050919050565b60006020820190508181036000830152611e1381611dd7565b9050919050565b7f7369676e6572206f66207468652072656c61796564207472616e73616374696f60008201527f6e206d7573742062652074686520636c61696d65720000000000000000000000602082015250565b6000611e76603583611af7565b9150611e8182611e1a565b604082019050919050565b60006020820190508181036000830152611ea581611e69565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611ee682611562565b9150611ef183611562565b9250828203905081811115611f0957611f08611eac565b5b92915050565b6000604082019050611f2460008301856116f8565b611f316020830184611cf7565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000819050919050565b60008160001b9050919050565b6000611f99611f94611f8f84611f67565b611f71565b61152c565b9050919050565b611fa981611f7e565b82525050565b6000819050919050565b600060ff82169050919050565b6000611fe1611fdc611fd784611faf565b611c98565b611fb9565b9050919050565b611ff181611fc6565b82525050565b600060808201905061200c6000830187611fa0565b6120196020830186611fe8565b61202660408301856118d1565b61203360608301846118d1565b95945050505050565b600061204782611562565b915061205283611562565b925082820190508082111561206a57612069611eac565b5b92915050565b7f76616c7565206e6f742073616d652061732045544820616d6f756e742073656e60008201527f7400000000000000000000000000000000000000000000000000000000000000602082015250565b60006120cc602183611af7565b91506120d782612070565b604082019050919050565b600060208201905081810360008301526120fb816120bf565b9050919050565b600060608201905061211760008301866116f8565b61212460208301856116f8565b6121316040830184611cf7565b949350505050565b7f7377617020616c72656164792065786973747300000000000000000000000000600082015250565b600061216f601383611af7565b915061217a82612139565b602082019050919050565b6000602082019050818103600083015261219e81612162565b9050919050565b600060e0820190506121ba600083018a6118d1565b6121c760208301896118d1565b6121d460408301886118d1565b6121e16060830187611cf7565b6121ee6080830186611cf7565b6121fb60a08301856116f8565b61220860c0830184611cf7565b98975050505050505050565b7f73776170206973206e6f7420696e2050454e44494e4720737461746500000000600082015250565b600061224a601c83611af7565b915061225582612214565b602082019050919050565b600060208201905081810360008301526122798161223d565b9050919050565b7f6f6e6c79207468652073776170206f776e65722063616e2063616c6c2073657460008201527f5265616479000000000000000000000000000000000000000000000000000000602082015250565b60006122dc602583611af7565b91506122e782612280565b604082019050919050565b6000602082019050818103600083015261230b816122cf565b9050919050565b7f70726f76696465642073656372657420646f6573206e6f74206d61746368207460008201527f6865206578706563746564207075626c6963206b657900000000000000000000602082015250565b600061236e603683611af7565b915061237982612312565b604082019050919050565b6000602082019050818103600083015261239d81612361565b9050919050565b7f696e76616c696420737761700000000000000000000000000000000000000000600082015250565b60006123da600c83611af7565b91506123e5826123a4565b602082019050919050565b60006020820190508181036000830152612409816123cd565b9050919050565b7f6f6e6c7920636c61696d65722063616e20636c61696d21000000000000000000600082015250565b6000612446601783611af7565b915061245182612410565b602082019050919050565b6000602082019050818103600083015261247581612439565b9050919050565b7f746f6f206561726c7920746f20636c61696d2100000000000000000000000000600082015250565b60006124b2601383611af7565b91506124bd8261247c565b602082019050919050565b600060208201905081810360008301526124e1816124a5565b9050919050565b7f746f6f206c61746520746f20636c61696d210000000000000000000000000000600082015250565b600061251e601283611af7565b9150612529826124e8565b602082019050919050565b6000602082019050818103600083015261254d81612511565b905091905056fea2646970667358221220877bd1d22a1b04aafd8f019ea84a948de577de61f0af77b51f0a6bb85511218564736f6c63430008110033", +// SwapCreatorMetaData contains all meta data concerning the SwapCreator contract. +var SwapCreatorMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"trustedForwarder\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"Claimed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"claimKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"refundKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"New\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"}],\"name\":\"Ready\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"swapID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"Refunded\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"_trustedForwarder\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapCreator.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"claim\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapCreator.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"fee\",\"type\":\"uint256\"}],\"name\":\"claimRelayer\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"forwarder\",\"type\":\"address\"}],\"name\":\"isTrustedForwarder\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"scalar\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"qKeccak\",\"type\":\"uint256\"}],\"name\":\"mulVerify\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"_pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"_pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"addresspayable\",\"name\":\"_claimer\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_timeoutDuration0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_timeoutDuration1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"_asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_nonce\",\"type\":\"uint256\"}],\"name\":\"newSwap\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapCreator.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"_s\",\"type\":\"bytes32\"}],\"name\":\"refund\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"addresspayable\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"claimer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyClaim\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"pubKeyRefund\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"timeout0\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"timeout1\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"asset\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"}],\"internalType\":\"structSwapCreator.Swap\",\"name\":\"_swap\",\"type\":\"tuple\"}],\"name\":\"setReady\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"swaps\",\"outputs\":[{\"internalType\":\"enumSwapCreator.Stage\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + Bin: "0x60a06040523480156200001157600080fd5b50604051620026bd380380620026bd8339818101604052810190620000379190620000de565b808073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff1681525050505062000110565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620000a68262000079565b9050919050565b620000b88162000099565b8114620000c457600080fd5b50565b600081519050620000d881620000ad565b92915050565b600060208284031215620000f757620000f662000074565b5b60006200010784828501620000c7565b91505092915050565b60805161258a62000133600039600081816105b601526105dc015261258a6000f3fe6080604052600436106100865760003560e01c806373e4771c1161005957806373e4771c14610145578063b32d1b4f1461016e578063c41e46cf146101ab578063eb84e7f2146101db578063fcaf229c1461021857610086565b80631e6c5acc1461008b57806356c022bb146100b4578063572b6c05146100df5780635cb969161461011c575b600080fd5b34801561009757600080fd5b506100b260048036038101906100ad91906116b6565b610241565b005b3480156100c057600080fd5b506100c96105b4565b6040516100d69190611707565b60405180910390f35b3480156100eb57600080fd5b5061010660048036038101906101019190611722565b6105d8565b604051610113919061176a565b60405180910390f35b34801561012857600080fd5b50610143600480360381019061013e91906116b6565b610630565b005b34801561015157600080fd5b5061016c60048036038101906101679190611785565b610756565b005b34801561017a57600080fd5b50610195600480360381019061019091906117db565b610a1e565b6040516101a2919061176a565b60405180910390f35b6101c560048036038101906101c0919061181b565b610b23565b6040516101d291906118e0565b60405180910390f35b3480156101e757600080fd5b5061020260048036038101906101fd91906118fb565b610e90565b60405161020f919061199f565b60405180910390f35b34801561022457600080fd5b5061023f600480360381019061023a91906119ba565b610eb0565b005b6000826040516020016102549190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff1690506003808111156102a3576102a2611928565b5b8160038111156102b6576102b5611928565b5b141580156102e95750600060038111156102d3576102d2611928565b5b8160038111156102e6576102e5611928565b5b14155b610328576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161031f90611b54565b60405180910390fd5b836000015173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461039a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161039190611be6565b60405180910390fd5b8360a00151421015806103e157508360800151421080156103e05750600260038111156103ca576103c9611928565b5b8160038111156103dd576103dc611928565b5b14155b5b610420576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161041790611c78565b60405180910390fd5b61042e83856060015161103f565b82827e7c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561049157610490611928565b5b0217905550600073ffffffffffffffffffffffffffffffffffffffff168460c0015173ffffffffffffffffffffffffffffffffffffffff160361052257836000015173ffffffffffffffffffffffffffffffffffffffff166108fc8560e001519081150290604051600060405180830381858888f1935050505015801561051c573d6000803e3d6000fd5b506105ae565b8360c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85600001518660e001516040518363ffffffff1660e01b8152600401610569929190611d06565b6020604051808303816000875af1158015610588573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ac9190611d5b565b505b50505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b61063a8282611092565b600073ffffffffffffffffffffffffffffffffffffffff168260c0015173ffffffffffffffffffffffffffffffffffffffff16036106c657816020015173ffffffffffffffffffffffffffffffffffffffff166108fc8360e001519081150290604051600060405180830381858888f193505050501580156106c0573d6000803e3d6000fd5b50610752565b8160c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb83602001518460e001516040518363ffffffff1660e01b815260040161070d929190611d06565b6020604051808303816000875af115801561072c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107509190611d5b565b505b5050565b61075f336105d8565b61079e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161079590611dfa565b60405180910390fd5b826020015173ffffffffffffffffffffffffffffffffffffffff166107c1611360565b73ffffffffffffffffffffffffffffffffffffffff1614610817576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161080e90611e8c565b60405180910390fd5b6108218383611092565b600073ffffffffffffffffffffffffffffffffffffffff168360c0015173ffffffffffffffffffffffffffffffffffffffff16036108ff57826020015173ffffffffffffffffffffffffffffffffffffffff166108fc828560e001516108879190611edb565b9081150290604051600060405180830381858888f193505050501580156108b2573d6000803e3d6000fd5b503273ffffffffffffffffffffffffffffffffffffffff166108fc829081150290604051600060405180830381858888f193505050501580156108f9573d6000803e3d6000fd5b50610a19565b8260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb8460200151838660e001516109349190611edb565b6040518363ffffffff1660e01b8152600401610951929190611d06565b6020604051808303816000875af1158015610970573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109949190611d5b565b508260c0015173ffffffffffffffffffffffffffffffffffffffff1663a9059cbb32836040518363ffffffff1660e01b81526004016109d4929190611f0f565b6020604051808303816000875af11580156109f3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a179190611d5b565b505b505050565b60008060016000601b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179860001b7ffffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036414180610a7a57610a79611f38565b5b7f79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798890960001b60405160008152602001604052604051610abd9493929190611ff7565b6020604051602081039080840390855afa158015610adf573d6000803e3d6000fd5b5050506020604051035190508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161491505092915050565b6000610b2d61139a565b33816000019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050898160400181815250508881606001818152505087816020019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250508642610bbd919061203c565b816080018181525050858742610bd3919061203c565b610bdd919061203c565b8160a0018181525050848160c0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050838160e0018181525050600073ffffffffffffffffffffffffffffffffffffffff168160c0015173ffffffffffffffffffffffffffffffffffffffff1603610cab57348160e0015114610ca6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c9d906120e2565b60405180910390fd5b610d35565b8060c0015173ffffffffffffffffffffffffffffffffffffffff166323b872dd33308460e001516040518463ffffffff1660e01b8152600401610cf093929190612102565b6020604051808303816000875af1158015610d0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d339190611d5b565b505b8281610100018181525050600081604051602001610d539190611adb565b60405160208183030381529060405280519060200120905060006003811115610d7f57610d7e611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610db157610db0611928565b5b14610df1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de890612185565b60405180910390fd5b7f91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56818c8c85608001518660a001518760c001518860e00151604051610e3c97969594939291906121a5565b60405180910390a1600160008083815260200190815260200160002060006101000a81548160ff02191690836003811115610e7a57610e79611928565b5b0217905550809250505098975050505050505050565b60006020528060005260406000206000915054906101000a900460ff1681565b600081604051602001610ec39190611adb565b60405160208183030381529060405280519060200120905060016003811115610eef57610eee611928565b5b60008083815260200190815260200160002060009054906101000a900460ff166003811115610f2157610f20611928565b5b14610f61576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f5890612260565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff16826000015173ffffffffffffffffffffffffffffffffffffffff1614610fd3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fca906122f2565b60405180910390fd5b600260008083815260200190815260200160002060006101000a81548160ff0219169083600381111561100957611008611928565b5b0217905550807f5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f60405160405180910390a25050565b61104f8260001c8260001c610a1e565b61108e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108590612384565b60405180910390fd5b5050565b6000826040516020016110a59190611adb565b604051602081830303815290604052805190602001209050600080600083815260200190815260200160002060009054906101000a900460ff169050600060038111156110f5576110f4611928565b5b81600381111561110857611107611928565b5b03611148576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161113f906123f0565b60405180910390fd5b60038081111561115b5761115a611928565b5b81600381111561116e5761116d611928565b5b036111ae576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111a590611b54565b60405180910390fd5b836020015173ffffffffffffffffffffffffffffffffffffffff166111d1611360565b73ffffffffffffffffffffffffffffffffffffffff1614611227576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161121e9061245c565b60405180910390fd5b83608001514210158061125e57506002600381111561124957611248611928565b5b81600381111561125c5761125b611928565b5b145b61129d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611294906124c8565b60405180910390fd5b8360a0015142106112e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112da90612534565b60405180910390fd5b6112f183856040015161103f565b82827f38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee60405160405180910390a3600360008084815260200190815260200160002060006101000a81548160ff0219169083600381111561135557611354611928565b5b021790555050505050565b600061136b336105d8565b1561137f57601436033560601c905061138e565b611387611392565b905061138f565b5b90565b600033905090565b604051806101200160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008019168152602001600080191681526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001600081525090565b6000604051905090565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61148b82611442565b810181811067ffffffffffffffff821117156114aa576114a9611453565b5b80604052505050565b60006114bd61142e565b90506114c98282611482565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006114f9826114ce565b9050919050565b611509816114ee565b811461151457600080fd5b50565b60008135905061152681611500565b92915050565b6000819050919050565b61153f8161152c565b811461154a57600080fd5b50565b60008135905061155c81611536565b92915050565b6000819050919050565b61157581611562565b811461158057600080fd5b50565b6000813590506115928161156c565b92915050565b60006115a3826114ce565b9050919050565b6115b381611598565b81146115be57600080fd5b50565b6000813590506115d0816115aa565b92915050565b600061012082840312156115ed576115ec61143d565b5b6115f86101206114b3565b9050600061160884828501611517565b600083015250602061161c84828501611517565b60208301525060406116308482850161154d565b60408301525060606116448482850161154d565b606083015250608061165884828501611583565b60808301525060a061166c84828501611583565b60a08301525060c0611680848285016115c1565b60c08301525060e061169484828501611583565b60e0830152506101006116a984828501611583565b6101008301525092915050565b60008061014083850312156116ce576116cd611438565b5b60006116dc858286016115d6565b9250506101206116ee8582860161154d565b9150509250929050565b61170181611598565b82525050565b600060208201905061171c60008301846116f8565b92915050565b60006020828403121561173857611737611438565b5b6000611746848285016115c1565b91505092915050565b60008115159050919050565b6117648161174f565b82525050565b600060208201905061177f600083018461175b565b92915050565b6000806000610160848603121561179f5761179e611438565b5b60006117ad868287016115d6565b9350506101206117bf8682870161154d565b9250506101406117d186828701611583565b9150509250925092565b600080604083850312156117f2576117f1611438565b5b600061180085828601611583565b925050602061181185828601611583565b9150509250929050565b600080600080600080600080610100898b03121561183c5761183b611438565b5b600061184a8b828c0161154d565b985050602061185b8b828c0161154d565b975050604061186c8b828c01611517565b965050606061187d8b828c01611583565b955050608061188e8b828c01611583565b94505060a061189f8b828c016115c1565b93505060c06118b08b828c01611583565b92505060e06118c18b828c01611583565b9150509295985092959890939650565b6118da8161152c565b82525050565b60006020820190506118f560008301846118d1565b92915050565b60006020828403121561191157611910611438565b5b600061191f8482850161154d565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b6004811061196857611967611928565b5b50565b600081905061197982611957565b919050565b60006119898261196b565b9050919050565b6119998161197e565b82525050565b60006020820190506119b46000830184611990565b92915050565b600061012082840312156119d1576119d0611438565b5b60006119df848285016115d6565b91505092915050565b6119f1816114ee565b82525050565b611a008161152c565b82525050565b611a0f81611562565b82525050565b611a1e81611598565b82525050565b61012082016000820151611a3b60008501826119e8565b506020820151611a4e60208501826119e8565b506040820151611a6160408501826119f7565b506060820151611a7460608501826119f7565b506080820151611a876080850182611a06565b5060a0820151611a9a60a0850182611a06565b5060c0820151611aad60c0850182611a15565b5060e0820151611ac060e0850182611a06565b50610100820151611ad5610100850182611a06565b50505050565b600061012082019050611af16000830184611a24565b92915050565b600082825260208201905092915050565b7f7377617020697320616c726561647920636f6d706c6574656400000000000000600082015250565b6000611b3e601983611af7565b9150611b4982611b08565b602082019050919050565b60006020820190508181036000830152611b6d81611b31565b9050919050565b7f726566756e64206d7573742062652063616c6c6564206279207468652073776160008201527f70206f776e657200000000000000000000000000000000000000000000000000602082015250565b6000611bd0602783611af7565b9150611bdb82611b74565b604082019050919050565b60006020820190508181036000830152611bff81611bc3565b9050919050565b7f697427732074686520636f756e74657270617274792773207475726e2c20756e60008201527f61626c6520746f20726566756e642c2074727920616761696e206c6174657200602082015250565b6000611c62603f83611af7565b9150611c6d82611c06565b604082019050919050565b60006020820190508181036000830152611c9181611c55565b9050919050565b6000819050919050565b6000611cbd611cb8611cb3846114ce565b611c98565b6114ce565b9050919050565b6000611ccf82611ca2565b9050919050565b6000611ce182611cc4565b9050919050565b611cf181611cd6565b82525050565b611d0081611562565b82525050565b6000604082019050611d1b6000830185611ce8565b611d286020830184611cf7565b9392505050565b611d388161174f565b8114611d4357600080fd5b50565b600081519050611d5581611d2f565b92915050565b600060208284031215611d7157611d70611438565b5b6000611d7f84828501611d46565b91505092915050565b7f636c61696d52656c617965722063616e206f6e6c792062652063616c6c65642060008201527f62792061207472757374656420666f7277617264657200000000000000000000602082015250565b6000611de4603683611af7565b9150611def82611d88565b604082019050919050565b60006020820190508181036000830152611e1381611dd7565b9050919050565b7f7369676e6572206f66207468652072656c61796564207472616e73616374696f60008201527f6e206d7573742062652074686520636c61696d65720000000000000000000000602082015250565b6000611e76603583611af7565b9150611e8182611e1a565b604082019050919050565b60006020820190508181036000830152611ea581611e69565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000611ee682611562565b9150611ef183611562565b9250828203905081811115611f0957611f08611eac565b5b92915050565b6000604082019050611f2460008301856116f8565b611f316020830184611cf7565b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000819050919050565b60008160001b9050919050565b6000611f99611f94611f8f84611f67565b611f71565b61152c565b9050919050565b611fa981611f7e565b82525050565b6000819050919050565b600060ff82169050919050565b6000611fe1611fdc611fd784611faf565b611c98565b611fb9565b9050919050565b611ff181611fc6565b82525050565b600060808201905061200c6000830187611fa0565b6120196020830186611fe8565b61202660408301856118d1565b61203360608301846118d1565b95945050505050565b600061204782611562565b915061205283611562565b925082820190508082111561206a57612069611eac565b5b92915050565b7f76616c7565206e6f742073616d652061732045544820616d6f756e742073656e60008201527f7400000000000000000000000000000000000000000000000000000000000000602082015250565b60006120cc602183611af7565b91506120d782612070565b604082019050919050565b600060208201905081810360008301526120fb816120bf565b9050919050565b600060608201905061211760008301866116f8565b61212460208301856116f8565b6121316040830184611cf7565b949350505050565b7f7377617020616c72656164792065786973747300000000000000000000000000600082015250565b600061216f601383611af7565b915061217a82612139565b602082019050919050565b6000602082019050818103600083015261219e81612162565b9050919050565b600060e0820190506121ba600083018a6118d1565b6121c760208301896118d1565b6121d460408301886118d1565b6121e16060830187611cf7565b6121ee6080830186611cf7565b6121fb60a08301856116f8565b61220860c0830184611cf7565b98975050505050505050565b7f73776170206973206e6f7420696e2050454e44494e4720737461746500000000600082015250565b600061224a601c83611af7565b915061225582612214565b602082019050919050565b600060208201905081810360008301526122798161223d565b9050919050565b7f6f6e6c79207468652073776170206f776e65722063616e2063616c6c2073657460008201527f5265616479000000000000000000000000000000000000000000000000000000602082015250565b60006122dc602583611af7565b91506122e782612280565b604082019050919050565b6000602082019050818103600083015261230b816122cf565b9050919050565b7f70726f76696465642073656372657420646f6573206e6f74206d61746368207460008201527f6865206578706563746564207075626c6963206b657900000000000000000000602082015250565b600061236e603683611af7565b915061237982612312565b604082019050919050565b6000602082019050818103600083015261239d81612361565b9050919050565b7f696e76616c696420737761700000000000000000000000000000000000000000600082015250565b60006123da600c83611af7565b91506123e5826123a4565b602082019050919050565b60006020820190508181036000830152612409816123cd565b9050919050565b7f6f6e6c7920636c61696d65722063616e20636c61696d21000000000000000000600082015250565b6000612446601783611af7565b915061245182612410565b602082019050919050565b6000602082019050818103600083015261247581612439565b9050919050565b7f746f6f206561726c7920746f20636c61696d2100000000000000000000000000600082015250565b60006124b2601383611af7565b91506124bd8261247c565b602082019050919050565b600060208201905081810360008301526124e1816124a5565b9050919050565b7f746f6f206c61746520746f20636c61696d210000000000000000000000000000600082015250565b600061251e601283611af7565b9150612529826124e8565b602082019050919050565b6000602082019050818103600083015261254d81612511565b905091905056fea26469706673582212209e214a8c453f496d821757ac5151c078e6562fa384824ab19add396f716eb16264736f6c63430008130033", } -// SwapFactoryABI is the input ABI used to generate the binding from. -// Deprecated: Use SwapFactoryMetaData.ABI instead. -var SwapFactoryABI = SwapFactoryMetaData.ABI +// SwapCreatorABI is the input ABI used to generate the binding from. +// Deprecated: Use SwapCreatorMetaData.ABI instead. +var SwapCreatorABI = SwapCreatorMetaData.ABI -// SwapFactoryBin is the compiled bytecode used for deploying new contracts. -// Deprecated: Use SwapFactoryMetaData.Bin instead. -var SwapFactoryBin = SwapFactoryMetaData.Bin +// SwapCreatorBin is the compiled bytecode used for deploying new contracts. +// Deprecated: Use SwapCreatorMetaData.Bin instead. +var SwapCreatorBin = SwapCreatorMetaData.Bin -// DeploySwapFactory deploys a new Ethereum contract, binding an instance of SwapFactory to it. -func DeploySwapFactory(auth *bind.TransactOpts, backend bind.ContractBackend, trustedForwarder common.Address) (common.Address, *types.Transaction, *SwapFactory, error) { - parsed, err := SwapFactoryMetaData.GetAbi() +// DeploySwapCreator deploys a new Ethereum contract, binding an instance of SwapCreator to it. +func DeploySwapCreator(auth *bind.TransactOpts, backend bind.ContractBackend, trustedForwarder common.Address) (common.Address, *types.Transaction, *SwapCreator, error) { + parsed, err := SwapCreatorMetaData.GetAbi() if err != nil { return common.Address{}, nil, nil, err } @@ -68,161 +66,161 @@ func DeploySwapFactory(auth *bind.TransactOpts, backend bind.ContractBackend, tr return common.Address{}, nil, nil, errors.New("GetABI returned nil") } - address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(SwapFactoryBin), backend, trustedForwarder) + address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(SwapCreatorBin), backend, trustedForwarder) if err != nil { return common.Address{}, nil, nil, err } - return address, tx, &SwapFactory{SwapFactoryCaller: SwapFactoryCaller{contract: contract}, SwapFactoryTransactor: SwapFactoryTransactor{contract: contract}, SwapFactoryFilterer: SwapFactoryFilterer{contract: contract}}, nil + return address, tx, &SwapCreator{SwapCreatorCaller: SwapCreatorCaller{contract: contract}, SwapCreatorTransactor: SwapCreatorTransactor{contract: contract}, SwapCreatorFilterer: SwapCreatorFilterer{contract: contract}}, nil } -// SwapFactory is an auto generated Go binding around an Ethereum contract. -type SwapFactory struct { - SwapFactoryCaller // Read-only binding to the contract - SwapFactoryTransactor // Write-only binding to the contract - SwapFactoryFilterer // Log filterer for contract events +// SwapCreator is an auto generated Go binding around an Ethereum contract. +type SwapCreator struct { + SwapCreatorCaller // Read-only binding to the contract + SwapCreatorTransactor // Write-only binding to the contract + SwapCreatorFilterer // Log filterer for contract events } -// SwapFactoryCaller is an auto generated read-only Go binding around an Ethereum contract. -type SwapFactoryCaller struct { +// SwapCreatorCaller is an auto generated read-only Go binding around an Ethereum contract. +type SwapCreatorCaller struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// SwapFactoryTransactor is an auto generated write-only Go binding around an Ethereum contract. -type SwapFactoryTransactor struct { +// SwapCreatorTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SwapCreatorTransactor struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// SwapFactoryFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type SwapFactoryFilterer struct { +// SwapCreatorFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SwapCreatorFilterer struct { contract *bind.BoundContract // Generic contract wrapper for the low level calls } -// SwapFactorySession is an auto generated Go binding around an Ethereum contract, +// SwapCreatorSession is an auto generated Go binding around an Ethereum contract, // with pre-set call and transact options. -type SwapFactorySession struct { - Contract *SwapFactory // Generic contract binding to set the session for +type SwapCreatorSession struct { + Contract *SwapCreator // 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 } -// SwapFactoryCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// SwapCreatorCallerSession is an auto generated read-only Go binding around an Ethereum contract, // with pre-set call options. -type SwapFactoryCallerSession struct { - Contract *SwapFactoryCaller // Generic contract caller binding to set the session for +type SwapCreatorCallerSession struct { + Contract *SwapCreatorCaller // Generic contract caller binding to set the session for CallOpts bind.CallOpts // Call options to use throughout this session } -// SwapFactoryTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// SwapCreatorTransactorSession is an auto generated write-only Go binding around an Ethereum contract, // with pre-set transact options. -type SwapFactoryTransactorSession struct { - Contract *SwapFactoryTransactor // Generic contract transactor binding to set the session for +type SwapCreatorTransactorSession struct { + Contract *SwapCreatorTransactor // Generic contract transactor binding to set the session for TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session } -// SwapFactoryRaw is an auto generated low-level Go binding around an Ethereum contract. -type SwapFactoryRaw struct { - Contract *SwapFactory // Generic contract binding to access the raw methods on +// SwapCreatorRaw is an auto generated low-level Go binding around an Ethereum contract. +type SwapCreatorRaw struct { + Contract *SwapCreator // Generic contract binding to access the raw methods on } -// SwapFactoryCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type SwapFactoryCallerRaw struct { - Contract *SwapFactoryCaller // Generic read-only contract binding to access the raw methods on +// SwapCreatorCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SwapCreatorCallerRaw struct { + Contract *SwapCreatorCaller // Generic read-only contract binding to access the raw methods on } -// SwapFactoryTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type SwapFactoryTransactorRaw struct { - Contract *SwapFactoryTransactor // Generic write-only contract binding to access the raw methods on +// SwapCreatorTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SwapCreatorTransactorRaw struct { + Contract *SwapCreatorTransactor // Generic write-only contract binding to access the raw methods on } -// NewSwapFactory creates a new instance of SwapFactory, bound to a specific deployed contract. -func NewSwapFactory(address common.Address, backend bind.ContractBackend) (*SwapFactory, error) { - contract, err := bindSwapFactory(address, backend, backend, backend) +// NewSwapCreator creates a new instance of SwapCreator, bound to a specific deployed contract. +func NewSwapCreator(address common.Address, backend bind.ContractBackend) (*SwapCreator, error) { + contract, err := bindSwapCreator(address, backend, backend, backend) if err != nil { return nil, err } - return &SwapFactory{SwapFactoryCaller: SwapFactoryCaller{contract: contract}, SwapFactoryTransactor: SwapFactoryTransactor{contract: contract}, SwapFactoryFilterer: SwapFactoryFilterer{contract: contract}}, nil + return &SwapCreator{SwapCreatorCaller: SwapCreatorCaller{contract: contract}, SwapCreatorTransactor: SwapCreatorTransactor{contract: contract}, SwapCreatorFilterer: SwapCreatorFilterer{contract: contract}}, nil } -// NewSwapFactoryCaller creates a new read-only instance of SwapFactory, bound to a specific deployed contract. -func NewSwapFactoryCaller(address common.Address, caller bind.ContractCaller) (*SwapFactoryCaller, error) { - contract, err := bindSwapFactory(address, caller, nil, nil) +// NewSwapCreatorCaller creates a new read-only instance of SwapCreator, bound to a specific deployed contract. +func NewSwapCreatorCaller(address common.Address, caller bind.ContractCaller) (*SwapCreatorCaller, error) { + contract, err := bindSwapCreator(address, caller, nil, nil) if err != nil { return nil, err } - return &SwapFactoryCaller{contract: contract}, nil + return &SwapCreatorCaller{contract: contract}, nil } -// NewSwapFactoryTransactor creates a new write-only instance of SwapFactory, bound to a specific deployed contract. -func NewSwapFactoryTransactor(address common.Address, transactor bind.ContractTransactor) (*SwapFactoryTransactor, error) { - contract, err := bindSwapFactory(address, nil, transactor, nil) +// NewSwapCreatorTransactor creates a new write-only instance of SwapCreator, bound to a specific deployed contract. +func NewSwapCreatorTransactor(address common.Address, transactor bind.ContractTransactor) (*SwapCreatorTransactor, error) { + contract, err := bindSwapCreator(address, nil, transactor, nil) if err != nil { return nil, err } - return &SwapFactoryTransactor{contract: contract}, nil + return &SwapCreatorTransactor{contract: contract}, nil } -// NewSwapFactoryFilterer creates a new log filterer instance of SwapFactory, bound to a specific deployed contract. -func NewSwapFactoryFilterer(address common.Address, filterer bind.ContractFilterer) (*SwapFactoryFilterer, error) { - contract, err := bindSwapFactory(address, nil, nil, filterer) +// NewSwapCreatorFilterer creates a new log filterer instance of SwapCreator, bound to a specific deployed contract. +func NewSwapCreatorFilterer(address common.Address, filterer bind.ContractFilterer) (*SwapCreatorFilterer, error) { + contract, err := bindSwapCreator(address, nil, nil, filterer) if err != nil { return nil, err } - return &SwapFactoryFilterer{contract: contract}, nil + return &SwapCreatorFilterer{contract: contract}, nil } -// bindSwapFactory binds a generic wrapper to an already deployed contract. -func bindSwapFactory(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(SwapFactoryABI)) +// bindSwapCreator binds a generic wrapper to an already deployed contract. +func bindSwapCreator(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := SwapCreatorMetaData.GetAbi() if err != nil { return nil, err } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil + 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 (_SwapFactory *SwapFactoryRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _SwapFactory.Contract.SwapFactoryCaller.contract.Call(opts, result, method, params...) +func (_SwapCreator *SwapCreatorRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SwapCreator.Contract.SwapCreatorCaller.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 (_SwapFactory *SwapFactoryRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwapFactory.Contract.SwapFactoryTransactor.contract.Transfer(opts) +func (_SwapCreator *SwapCreatorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwapCreator.Contract.SwapCreatorTransactor.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_SwapFactory *SwapFactoryRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _SwapFactory.Contract.SwapFactoryTransactor.contract.Transact(opts, method, params...) +func (_SwapCreator *SwapCreatorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SwapCreator.Contract.SwapCreatorTransactor.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 (_SwapFactory *SwapFactoryCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _SwapFactory.Contract.contract.Call(opts, result, method, params...) +func (_SwapCreator *SwapCreatorCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SwapCreator.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 (_SwapFactory *SwapFactoryTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwapFactory.Contract.contract.Transfer(opts) +func (_SwapCreator *SwapCreatorTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwapCreator.Contract.contract.Transfer(opts) } // Transact invokes the (paid) contract method with params as input values. -func (_SwapFactory *SwapFactoryTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _SwapFactory.Contract.contract.Transact(opts, method, params...) +func (_SwapCreator *SwapCreatorTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SwapCreator.Contract.contract.Transact(opts, method, params...) } // TrustedForwarder is a free data retrieval call binding the contract method 0x56c022bb. // // Solidity: function _trustedForwarder() view returns(address) -func (_SwapFactory *SwapFactoryCaller) TrustedForwarder(opts *bind.CallOpts) (common.Address, error) { +func (_SwapCreator *SwapCreatorCaller) TrustedForwarder(opts *bind.CallOpts) (common.Address, error) { var out []interface{} - err := _SwapFactory.contract.Call(opts, &out, "_trustedForwarder") + err := _SwapCreator.contract.Call(opts, &out, "_trustedForwarder") if err != nil { return *new(common.Address), err @@ -237,23 +235,23 @@ func (_SwapFactory *SwapFactoryCaller) TrustedForwarder(opts *bind.CallOpts) (co // TrustedForwarder is a free data retrieval call binding the contract method 0x56c022bb. // // Solidity: function _trustedForwarder() view returns(address) -func (_SwapFactory *SwapFactorySession) TrustedForwarder() (common.Address, error) { - return _SwapFactory.Contract.TrustedForwarder(&_SwapFactory.CallOpts) +func (_SwapCreator *SwapCreatorSession) TrustedForwarder() (common.Address, error) { + return _SwapCreator.Contract.TrustedForwarder(&_SwapCreator.CallOpts) } // TrustedForwarder is a free data retrieval call binding the contract method 0x56c022bb. // // Solidity: function _trustedForwarder() view returns(address) -func (_SwapFactory *SwapFactoryCallerSession) TrustedForwarder() (common.Address, error) { - return _SwapFactory.Contract.TrustedForwarder(&_SwapFactory.CallOpts) +func (_SwapCreator *SwapCreatorCallerSession) TrustedForwarder() (common.Address, error) { + return _SwapCreator.Contract.TrustedForwarder(&_SwapCreator.CallOpts) } // IsTrustedForwarder is a free data retrieval call binding the contract method 0x572b6c05. // // Solidity: function isTrustedForwarder(address forwarder) view returns(bool) -func (_SwapFactory *SwapFactoryCaller) IsTrustedForwarder(opts *bind.CallOpts, forwarder common.Address) (bool, error) { +func (_SwapCreator *SwapCreatorCaller) IsTrustedForwarder(opts *bind.CallOpts, forwarder common.Address) (bool, error) { var out []interface{} - err := _SwapFactory.contract.Call(opts, &out, "isTrustedForwarder", forwarder) + err := _SwapCreator.contract.Call(opts, &out, "isTrustedForwarder", forwarder) if err != nil { return *new(bool), err @@ -268,23 +266,23 @@ func (_SwapFactory *SwapFactoryCaller) IsTrustedForwarder(opts *bind.CallOpts, f // IsTrustedForwarder is a free data retrieval call binding the contract method 0x572b6c05. // // Solidity: function isTrustedForwarder(address forwarder) view returns(bool) -func (_SwapFactory *SwapFactorySession) IsTrustedForwarder(forwarder common.Address) (bool, error) { - return _SwapFactory.Contract.IsTrustedForwarder(&_SwapFactory.CallOpts, forwarder) +func (_SwapCreator *SwapCreatorSession) IsTrustedForwarder(forwarder common.Address) (bool, error) { + return _SwapCreator.Contract.IsTrustedForwarder(&_SwapCreator.CallOpts, forwarder) } // IsTrustedForwarder is a free data retrieval call binding the contract method 0x572b6c05. // // Solidity: function isTrustedForwarder(address forwarder) view returns(bool) -func (_SwapFactory *SwapFactoryCallerSession) IsTrustedForwarder(forwarder common.Address) (bool, error) { - return _SwapFactory.Contract.IsTrustedForwarder(&_SwapFactory.CallOpts, forwarder) +func (_SwapCreator *SwapCreatorCallerSession) IsTrustedForwarder(forwarder common.Address) (bool, error) { + return _SwapCreator.Contract.IsTrustedForwarder(&_SwapCreator.CallOpts, forwarder) } // MulVerify is a free data retrieval call binding the contract method 0xb32d1b4f. // // Solidity: function mulVerify(uint256 scalar, uint256 qKeccak) pure returns(bool) -func (_SwapFactory *SwapFactoryCaller) MulVerify(opts *bind.CallOpts, scalar *big.Int, qKeccak *big.Int) (bool, error) { +func (_SwapCreator *SwapCreatorCaller) MulVerify(opts *bind.CallOpts, scalar *big.Int, qKeccak *big.Int) (bool, error) { var out []interface{} - err := _SwapFactory.contract.Call(opts, &out, "mulVerify", scalar, qKeccak) + err := _SwapCreator.contract.Call(opts, &out, "mulVerify", scalar, qKeccak) if err != nil { return *new(bool), err @@ -299,23 +297,23 @@ func (_SwapFactory *SwapFactoryCaller) MulVerify(opts *bind.CallOpts, scalar *bi // MulVerify is a free data retrieval call binding the contract method 0xb32d1b4f. // // Solidity: function mulVerify(uint256 scalar, uint256 qKeccak) pure returns(bool) -func (_SwapFactory *SwapFactorySession) MulVerify(scalar *big.Int, qKeccak *big.Int) (bool, error) { - return _SwapFactory.Contract.MulVerify(&_SwapFactory.CallOpts, scalar, qKeccak) +func (_SwapCreator *SwapCreatorSession) MulVerify(scalar *big.Int, qKeccak *big.Int) (bool, error) { + return _SwapCreator.Contract.MulVerify(&_SwapCreator.CallOpts, scalar, qKeccak) } // MulVerify is a free data retrieval call binding the contract method 0xb32d1b4f. // // Solidity: function mulVerify(uint256 scalar, uint256 qKeccak) pure returns(bool) -func (_SwapFactory *SwapFactoryCallerSession) MulVerify(scalar *big.Int, qKeccak *big.Int) (bool, error) { - return _SwapFactory.Contract.MulVerify(&_SwapFactory.CallOpts, scalar, qKeccak) +func (_SwapCreator *SwapCreatorCallerSession) MulVerify(scalar *big.Int, qKeccak *big.Int) (bool, error) { + return _SwapCreator.Contract.MulVerify(&_SwapCreator.CallOpts, scalar, qKeccak) } // Swaps is a free data retrieval call binding the contract method 0xeb84e7f2. // // Solidity: function swaps(bytes32 ) view returns(uint8) -func (_SwapFactory *SwapFactoryCaller) Swaps(opts *bind.CallOpts, arg0 [32]byte) (uint8, error) { +func (_SwapCreator *SwapCreatorCaller) Swaps(opts *bind.CallOpts, arg0 [32]byte) (uint8, error) { var out []interface{} - err := _SwapFactory.contract.Call(opts, &out, "swaps", arg0) + err := _SwapCreator.contract.Call(opts, &out, "swaps", arg0) if err != nil { return *new(uint8), err @@ -330,125 +328,125 @@ func (_SwapFactory *SwapFactoryCaller) Swaps(opts *bind.CallOpts, arg0 [32]byte) // Swaps is a free data retrieval call binding the contract method 0xeb84e7f2. // // Solidity: function swaps(bytes32 ) view returns(uint8) -func (_SwapFactory *SwapFactorySession) Swaps(arg0 [32]byte) (uint8, error) { - return _SwapFactory.Contract.Swaps(&_SwapFactory.CallOpts, arg0) +func (_SwapCreator *SwapCreatorSession) Swaps(arg0 [32]byte) (uint8, error) { + return _SwapCreator.Contract.Swaps(&_SwapCreator.CallOpts, arg0) } // Swaps is a free data retrieval call binding the contract method 0xeb84e7f2. // // Solidity: function swaps(bytes32 ) view returns(uint8) -func (_SwapFactory *SwapFactoryCallerSession) Swaps(arg0 [32]byte) (uint8, error) { - return _SwapFactory.Contract.Swaps(&_SwapFactory.CallOpts, arg0) +func (_SwapCreator *SwapCreatorCallerSession) Swaps(arg0 [32]byte) (uint8, error) { + return _SwapCreator.Contract.Swaps(&_SwapCreator.CallOpts, arg0) } // Claim is a paid mutator transaction binding the contract method 0x5cb96916. // // Solidity: function claim((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s) returns() -func (_SwapFactory *SwapFactoryTransactor) Claim(opts *bind.TransactOpts, _swap SwapFactorySwap, _s [32]byte) (*types.Transaction, error) { - return _SwapFactory.contract.Transact(opts, "claim", _swap, _s) +func (_SwapCreator *SwapCreatorTransactor) Claim(opts *bind.TransactOpts, _swap SwapCreatorSwap, _s [32]byte) (*types.Transaction, error) { + return _SwapCreator.contract.Transact(opts, "claim", _swap, _s) } // Claim is a paid mutator transaction binding the contract method 0x5cb96916. // // Solidity: function claim((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s) returns() -func (_SwapFactory *SwapFactorySession) Claim(_swap SwapFactorySwap, _s [32]byte) (*types.Transaction, error) { - return _SwapFactory.Contract.Claim(&_SwapFactory.TransactOpts, _swap, _s) +func (_SwapCreator *SwapCreatorSession) Claim(_swap SwapCreatorSwap, _s [32]byte) (*types.Transaction, error) { + return _SwapCreator.Contract.Claim(&_SwapCreator.TransactOpts, _swap, _s) } // Claim is a paid mutator transaction binding the contract method 0x5cb96916. // // Solidity: function claim((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s) returns() -func (_SwapFactory *SwapFactoryTransactorSession) Claim(_swap SwapFactorySwap, _s [32]byte) (*types.Transaction, error) { - return _SwapFactory.Contract.Claim(&_SwapFactory.TransactOpts, _swap, _s) +func (_SwapCreator *SwapCreatorTransactorSession) Claim(_swap SwapCreatorSwap, _s [32]byte) (*types.Transaction, error) { + return _SwapCreator.Contract.Claim(&_SwapCreator.TransactOpts, _swap, _s) } // ClaimRelayer is a paid mutator transaction binding the contract method 0x73e4771c. // // Solidity: function claimRelayer((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s, uint256 fee) returns() -func (_SwapFactory *SwapFactoryTransactor) ClaimRelayer(opts *bind.TransactOpts, _swap SwapFactorySwap, _s [32]byte, fee *big.Int) (*types.Transaction, error) { - return _SwapFactory.contract.Transact(opts, "claimRelayer", _swap, _s, fee) +func (_SwapCreator *SwapCreatorTransactor) ClaimRelayer(opts *bind.TransactOpts, _swap SwapCreatorSwap, _s [32]byte, fee *big.Int) (*types.Transaction, error) { + return _SwapCreator.contract.Transact(opts, "claimRelayer", _swap, _s, fee) } // ClaimRelayer is a paid mutator transaction binding the contract method 0x73e4771c. // // Solidity: function claimRelayer((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s, uint256 fee) returns() -func (_SwapFactory *SwapFactorySession) ClaimRelayer(_swap SwapFactorySwap, _s [32]byte, fee *big.Int) (*types.Transaction, error) { - return _SwapFactory.Contract.ClaimRelayer(&_SwapFactory.TransactOpts, _swap, _s, fee) +func (_SwapCreator *SwapCreatorSession) ClaimRelayer(_swap SwapCreatorSwap, _s [32]byte, fee *big.Int) (*types.Transaction, error) { + return _SwapCreator.Contract.ClaimRelayer(&_SwapCreator.TransactOpts, _swap, _s, fee) } // ClaimRelayer is a paid mutator transaction binding the contract method 0x73e4771c. // // Solidity: function claimRelayer((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s, uint256 fee) returns() -func (_SwapFactory *SwapFactoryTransactorSession) ClaimRelayer(_swap SwapFactorySwap, _s [32]byte, fee *big.Int) (*types.Transaction, error) { - return _SwapFactory.Contract.ClaimRelayer(&_SwapFactory.TransactOpts, _swap, _s, fee) +func (_SwapCreator *SwapCreatorTransactorSession) ClaimRelayer(_swap SwapCreatorSwap, _s [32]byte, fee *big.Int) (*types.Transaction, error) { + return _SwapCreator.Contract.ClaimRelayer(&_SwapCreator.TransactOpts, _swap, _s, fee) } // NewSwap is a paid mutator transaction binding the contract method 0xc41e46cf. // // Solidity: function newSwap(bytes32 _pubKeyClaim, bytes32 _pubKeyRefund, address _claimer, uint256 _timeoutDuration0, uint256 _timeoutDuration1, address _asset, uint256 _value, uint256 _nonce) payable returns(bytes32) -func (_SwapFactory *SwapFactoryTransactor) NewSwap(opts *bind.TransactOpts, _pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer common.Address, _timeoutDuration0 *big.Int, _timeoutDuration1 *big.Int, _asset common.Address, _value *big.Int, _nonce *big.Int) (*types.Transaction, error) { - return _SwapFactory.contract.Transact(opts, "newSwap", _pubKeyClaim, _pubKeyRefund, _claimer, _timeoutDuration0, _timeoutDuration1, _asset, _value, _nonce) +func (_SwapCreator *SwapCreatorTransactor) NewSwap(opts *bind.TransactOpts, _pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer common.Address, _timeoutDuration0 *big.Int, _timeoutDuration1 *big.Int, _asset common.Address, _value *big.Int, _nonce *big.Int) (*types.Transaction, error) { + return _SwapCreator.contract.Transact(opts, "newSwap", _pubKeyClaim, _pubKeyRefund, _claimer, _timeoutDuration0, _timeoutDuration1, _asset, _value, _nonce) } // NewSwap is a paid mutator transaction binding the contract method 0xc41e46cf. // // Solidity: function newSwap(bytes32 _pubKeyClaim, bytes32 _pubKeyRefund, address _claimer, uint256 _timeoutDuration0, uint256 _timeoutDuration1, address _asset, uint256 _value, uint256 _nonce) payable returns(bytes32) -func (_SwapFactory *SwapFactorySession) NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer common.Address, _timeoutDuration0 *big.Int, _timeoutDuration1 *big.Int, _asset common.Address, _value *big.Int, _nonce *big.Int) (*types.Transaction, error) { - return _SwapFactory.Contract.NewSwap(&_SwapFactory.TransactOpts, _pubKeyClaim, _pubKeyRefund, _claimer, _timeoutDuration0, _timeoutDuration1, _asset, _value, _nonce) +func (_SwapCreator *SwapCreatorSession) NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer common.Address, _timeoutDuration0 *big.Int, _timeoutDuration1 *big.Int, _asset common.Address, _value *big.Int, _nonce *big.Int) (*types.Transaction, error) { + return _SwapCreator.Contract.NewSwap(&_SwapCreator.TransactOpts, _pubKeyClaim, _pubKeyRefund, _claimer, _timeoutDuration0, _timeoutDuration1, _asset, _value, _nonce) } // NewSwap is a paid mutator transaction binding the contract method 0xc41e46cf. // // Solidity: function newSwap(bytes32 _pubKeyClaim, bytes32 _pubKeyRefund, address _claimer, uint256 _timeoutDuration0, uint256 _timeoutDuration1, address _asset, uint256 _value, uint256 _nonce) payable returns(bytes32) -func (_SwapFactory *SwapFactoryTransactorSession) NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer common.Address, _timeoutDuration0 *big.Int, _timeoutDuration1 *big.Int, _asset common.Address, _value *big.Int, _nonce *big.Int) (*types.Transaction, error) { - return _SwapFactory.Contract.NewSwap(&_SwapFactory.TransactOpts, _pubKeyClaim, _pubKeyRefund, _claimer, _timeoutDuration0, _timeoutDuration1, _asset, _value, _nonce) +func (_SwapCreator *SwapCreatorTransactorSession) NewSwap(_pubKeyClaim [32]byte, _pubKeyRefund [32]byte, _claimer common.Address, _timeoutDuration0 *big.Int, _timeoutDuration1 *big.Int, _asset common.Address, _value *big.Int, _nonce *big.Int) (*types.Transaction, error) { + return _SwapCreator.Contract.NewSwap(&_SwapCreator.TransactOpts, _pubKeyClaim, _pubKeyRefund, _claimer, _timeoutDuration0, _timeoutDuration1, _asset, _value, _nonce) } // Refund is a paid mutator transaction binding the contract method 0x1e6c5acc. // // Solidity: function refund((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s) returns() -func (_SwapFactory *SwapFactoryTransactor) Refund(opts *bind.TransactOpts, _swap SwapFactorySwap, _s [32]byte) (*types.Transaction, error) { - return _SwapFactory.contract.Transact(opts, "refund", _swap, _s) +func (_SwapCreator *SwapCreatorTransactor) Refund(opts *bind.TransactOpts, _swap SwapCreatorSwap, _s [32]byte) (*types.Transaction, error) { + return _SwapCreator.contract.Transact(opts, "refund", _swap, _s) } // Refund is a paid mutator transaction binding the contract method 0x1e6c5acc. // // Solidity: function refund((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s) returns() -func (_SwapFactory *SwapFactorySession) Refund(_swap SwapFactorySwap, _s [32]byte) (*types.Transaction, error) { - return _SwapFactory.Contract.Refund(&_SwapFactory.TransactOpts, _swap, _s) +func (_SwapCreator *SwapCreatorSession) Refund(_swap SwapCreatorSwap, _s [32]byte) (*types.Transaction, error) { + return _SwapCreator.Contract.Refund(&_SwapCreator.TransactOpts, _swap, _s) } // Refund is a paid mutator transaction binding the contract method 0x1e6c5acc. // // Solidity: function refund((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap, bytes32 _s) returns() -func (_SwapFactory *SwapFactoryTransactorSession) Refund(_swap SwapFactorySwap, _s [32]byte) (*types.Transaction, error) { - return _SwapFactory.Contract.Refund(&_SwapFactory.TransactOpts, _swap, _s) +func (_SwapCreator *SwapCreatorTransactorSession) Refund(_swap SwapCreatorSwap, _s [32]byte) (*types.Transaction, error) { + return _SwapCreator.Contract.Refund(&_SwapCreator.TransactOpts, _swap, _s) } // SetReady is a paid mutator transaction binding the contract method 0xfcaf229c. // // Solidity: function setReady((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap) returns() -func (_SwapFactory *SwapFactoryTransactor) SetReady(opts *bind.TransactOpts, _swap SwapFactorySwap) (*types.Transaction, error) { - return _SwapFactory.contract.Transact(opts, "setReady", _swap) +func (_SwapCreator *SwapCreatorTransactor) SetReady(opts *bind.TransactOpts, _swap SwapCreatorSwap) (*types.Transaction, error) { + return _SwapCreator.contract.Transact(opts, "setReady", _swap) } // SetReady is a paid mutator transaction binding the contract method 0xfcaf229c. // // Solidity: function setReady((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap) returns() -func (_SwapFactory *SwapFactorySession) SetReady(_swap SwapFactorySwap) (*types.Transaction, error) { - return _SwapFactory.Contract.SetReady(&_SwapFactory.TransactOpts, _swap) +func (_SwapCreator *SwapCreatorSession) SetReady(_swap SwapCreatorSwap) (*types.Transaction, error) { + return _SwapCreator.Contract.SetReady(&_SwapCreator.TransactOpts, _swap) } // SetReady is a paid mutator transaction binding the contract method 0xfcaf229c. // // Solidity: function setReady((address,address,bytes32,bytes32,uint256,uint256,address,uint256,uint256) _swap) returns() -func (_SwapFactory *SwapFactoryTransactorSession) SetReady(_swap SwapFactorySwap) (*types.Transaction, error) { - return _SwapFactory.Contract.SetReady(&_SwapFactory.TransactOpts, _swap) +func (_SwapCreator *SwapCreatorTransactorSession) SetReady(_swap SwapCreatorSwap) (*types.Transaction, error) { + return _SwapCreator.Contract.SetReady(&_SwapCreator.TransactOpts, _swap) } -// SwapFactoryClaimedIterator is returned from FilterClaimed and is used to iterate over the raw logs and unpacked data for Claimed events raised by the SwapFactory contract. -type SwapFactoryClaimedIterator struct { - Event *SwapFactoryClaimed // Event containing the contract specifics and raw log +// SwapCreatorClaimedIterator is returned from FilterClaimed and is used to iterate over the raw logs and unpacked data for Claimed events raised by the SwapCreator contract. +type SwapCreatorClaimedIterator struct { + Event *SwapCreatorClaimed // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -462,7 +460,7 @@ type SwapFactoryClaimedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *SwapFactoryClaimedIterator) Next() bool { +func (it *SwapCreatorClaimedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -471,7 +469,7 @@ func (it *SwapFactoryClaimedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(SwapFactoryClaimed) + it.Event = new(SwapCreatorClaimed) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -486,7 +484,7 @@ func (it *SwapFactoryClaimedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(SwapFactoryClaimed) + it.Event = new(SwapCreatorClaimed) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -502,19 +500,19 @@ func (it *SwapFactoryClaimedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *SwapFactoryClaimedIterator) Error() error { +func (it *SwapCreatorClaimedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *SwapFactoryClaimedIterator) Close() error { +func (it *SwapCreatorClaimedIterator) Close() error { it.sub.Unsubscribe() return nil } -// SwapFactoryClaimed represents a Claimed event raised by the SwapFactory contract. -type SwapFactoryClaimed struct { +// SwapCreatorClaimed represents a Claimed event raised by the SwapCreator contract. +type SwapCreatorClaimed struct { SwapID [32]byte S [32]byte Raw types.Log // Blockchain specific contextual infos @@ -523,7 +521,7 @@ type SwapFactoryClaimed struct { // FilterClaimed is a free log retrieval operation binding the contract event 0x38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee. // // Solidity: event Claimed(bytes32 indexed swapID, bytes32 indexed s) -func (_SwapFactory *SwapFactoryFilterer) FilterClaimed(opts *bind.FilterOpts, swapID [][32]byte, s [][32]byte) (*SwapFactoryClaimedIterator, error) { +func (_SwapCreator *SwapCreatorFilterer) FilterClaimed(opts *bind.FilterOpts, swapID [][32]byte, s [][32]byte) (*SwapCreatorClaimedIterator, error) { var swapIDRule []interface{} for _, swapIDItem := range swapID { @@ -534,17 +532,17 @@ func (_SwapFactory *SwapFactoryFilterer) FilterClaimed(opts *bind.FilterOpts, sw sRule = append(sRule, sItem) } - logs, sub, err := _SwapFactory.contract.FilterLogs(opts, "Claimed", swapIDRule, sRule) + logs, sub, err := _SwapCreator.contract.FilterLogs(opts, "Claimed", swapIDRule, sRule) if err != nil { return nil, err } - return &SwapFactoryClaimedIterator{contract: _SwapFactory.contract, event: "Claimed", logs: logs, sub: sub}, nil + return &SwapCreatorClaimedIterator{contract: _SwapCreator.contract, event: "Claimed", logs: logs, sub: sub}, nil } // WatchClaimed is a free log subscription operation binding the contract event 0x38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee. // // Solidity: event Claimed(bytes32 indexed swapID, bytes32 indexed s) -func (_SwapFactory *SwapFactoryFilterer) WatchClaimed(opts *bind.WatchOpts, sink chan<- *SwapFactoryClaimed, swapID [][32]byte, s [][32]byte) (event.Subscription, error) { +func (_SwapCreator *SwapCreatorFilterer) WatchClaimed(opts *bind.WatchOpts, sink chan<- *SwapCreatorClaimed, swapID [][32]byte, s [][32]byte) (event.Subscription, error) { var swapIDRule []interface{} for _, swapIDItem := range swapID { @@ -555,7 +553,7 @@ func (_SwapFactory *SwapFactoryFilterer) WatchClaimed(opts *bind.WatchOpts, sink sRule = append(sRule, sItem) } - logs, sub, err := _SwapFactory.contract.WatchLogs(opts, "Claimed", swapIDRule, sRule) + logs, sub, err := _SwapCreator.contract.WatchLogs(opts, "Claimed", swapIDRule, sRule) if err != nil { return nil, err } @@ -565,8 +563,8 @@ func (_SwapFactory *SwapFactoryFilterer) WatchClaimed(opts *bind.WatchOpts, sink select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(SwapFactoryClaimed) - if err := _SwapFactory.contract.UnpackLog(event, "Claimed", log); err != nil { + event := new(SwapCreatorClaimed) + if err := _SwapCreator.contract.UnpackLog(event, "Claimed", log); err != nil { return err } event.Raw = log @@ -590,18 +588,18 @@ func (_SwapFactory *SwapFactoryFilterer) WatchClaimed(opts *bind.WatchOpts, sink // ParseClaimed is a log parse operation binding the contract event 0x38d6042dbdae8e73a7f6afbabd3fbe0873f9f5ed3cd71294591c3908c2e65fee. // // Solidity: event Claimed(bytes32 indexed swapID, bytes32 indexed s) -func (_SwapFactory *SwapFactoryFilterer) ParseClaimed(log types.Log) (*SwapFactoryClaimed, error) { - event := new(SwapFactoryClaimed) - if err := _SwapFactory.contract.UnpackLog(event, "Claimed", log); err != nil { +func (_SwapCreator *SwapCreatorFilterer) ParseClaimed(log types.Log) (*SwapCreatorClaimed, error) { + event := new(SwapCreatorClaimed) + if err := _SwapCreator.contract.UnpackLog(event, "Claimed", log); err != nil { return nil, err } event.Raw = log return event, nil } -// SwapFactoryNewIterator is returned from FilterNew and is used to iterate over the raw logs and unpacked data for New events raised by the SwapFactory contract. -type SwapFactoryNewIterator struct { - Event *SwapFactoryNew // Event containing the contract specifics and raw log +// SwapCreatorNewIterator is returned from FilterNew and is used to iterate over the raw logs and unpacked data for New events raised by the SwapCreator contract. +type SwapCreatorNewIterator struct { + Event *SwapCreatorNew // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -615,7 +613,7 @@ type SwapFactoryNewIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *SwapFactoryNewIterator) Next() bool { +func (it *SwapCreatorNewIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -624,7 +622,7 @@ func (it *SwapFactoryNewIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(SwapFactoryNew) + it.Event = new(SwapCreatorNew) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -639,7 +637,7 @@ func (it *SwapFactoryNewIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(SwapFactoryNew) + it.Event = new(SwapCreatorNew) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -655,19 +653,19 @@ func (it *SwapFactoryNewIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *SwapFactoryNewIterator) Error() error { +func (it *SwapCreatorNewIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *SwapFactoryNewIterator) Close() error { +func (it *SwapCreatorNewIterator) Close() error { it.sub.Unsubscribe() return nil } -// SwapFactoryNew represents a New event raised by the SwapFactory contract. -type SwapFactoryNew struct { +// SwapCreatorNew represents a New event raised by the SwapCreator contract. +type SwapCreatorNew struct { SwapID [32]byte ClaimKey [32]byte RefundKey [32]byte @@ -681,21 +679,21 @@ type SwapFactoryNew struct { // FilterNew is a free log retrieval operation binding the contract event 0x91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56. // // Solidity: event New(bytes32 swapID, bytes32 claimKey, bytes32 refundKey, uint256 timeout0, uint256 timeout1, address asset, uint256 value) -func (_SwapFactory *SwapFactoryFilterer) FilterNew(opts *bind.FilterOpts) (*SwapFactoryNewIterator, error) { +func (_SwapCreator *SwapCreatorFilterer) FilterNew(opts *bind.FilterOpts) (*SwapCreatorNewIterator, error) { - logs, sub, err := _SwapFactory.contract.FilterLogs(opts, "New") + logs, sub, err := _SwapCreator.contract.FilterLogs(opts, "New") if err != nil { return nil, err } - return &SwapFactoryNewIterator{contract: _SwapFactory.contract, event: "New", logs: logs, sub: sub}, nil + return &SwapCreatorNewIterator{contract: _SwapCreator.contract, event: "New", logs: logs, sub: sub}, nil } // WatchNew is a free log subscription operation binding the contract event 0x91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56. // // Solidity: event New(bytes32 swapID, bytes32 claimKey, bytes32 refundKey, uint256 timeout0, uint256 timeout1, address asset, uint256 value) -func (_SwapFactory *SwapFactoryFilterer) WatchNew(opts *bind.WatchOpts, sink chan<- *SwapFactoryNew) (event.Subscription, error) { +func (_SwapCreator *SwapCreatorFilterer) WatchNew(opts *bind.WatchOpts, sink chan<- *SwapCreatorNew) (event.Subscription, error) { - logs, sub, err := _SwapFactory.contract.WatchLogs(opts, "New") + logs, sub, err := _SwapCreator.contract.WatchLogs(opts, "New") if err != nil { return nil, err } @@ -705,8 +703,8 @@ func (_SwapFactory *SwapFactoryFilterer) WatchNew(opts *bind.WatchOpts, sink cha select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(SwapFactoryNew) - if err := _SwapFactory.contract.UnpackLog(event, "New", log); err != nil { + event := new(SwapCreatorNew) + if err := _SwapCreator.contract.UnpackLog(event, "New", log); err != nil { return err } event.Raw = log @@ -730,18 +728,18 @@ func (_SwapFactory *SwapFactoryFilterer) WatchNew(opts *bind.WatchOpts, sink cha // ParseNew is a log parse operation binding the contract event 0x91446ce035ac29998b5473504609a5ef5e961005daba4630a1684b63be848f56. // // Solidity: event New(bytes32 swapID, bytes32 claimKey, bytes32 refundKey, uint256 timeout0, uint256 timeout1, address asset, uint256 value) -func (_SwapFactory *SwapFactoryFilterer) ParseNew(log types.Log) (*SwapFactoryNew, error) { - event := new(SwapFactoryNew) - if err := _SwapFactory.contract.UnpackLog(event, "New", log); err != nil { +func (_SwapCreator *SwapCreatorFilterer) ParseNew(log types.Log) (*SwapCreatorNew, error) { + event := new(SwapCreatorNew) + if err := _SwapCreator.contract.UnpackLog(event, "New", log); err != nil { return nil, err } event.Raw = log return event, nil } -// SwapFactoryReadyIterator is returned from FilterReady and is used to iterate over the raw logs and unpacked data for Ready events raised by the SwapFactory contract. -type SwapFactoryReadyIterator struct { - Event *SwapFactoryReady // Event containing the contract specifics and raw log +// SwapCreatorReadyIterator is returned from FilterReady and is used to iterate over the raw logs and unpacked data for Ready events raised by the SwapCreator contract. +type SwapCreatorReadyIterator struct { + Event *SwapCreatorReady // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -755,7 +753,7 @@ type SwapFactoryReadyIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *SwapFactoryReadyIterator) Next() bool { +func (it *SwapCreatorReadyIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -764,7 +762,7 @@ func (it *SwapFactoryReadyIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(SwapFactoryReady) + it.Event = new(SwapCreatorReady) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -779,7 +777,7 @@ func (it *SwapFactoryReadyIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(SwapFactoryReady) + it.Event = new(SwapCreatorReady) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -795,19 +793,19 @@ func (it *SwapFactoryReadyIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *SwapFactoryReadyIterator) Error() error { +func (it *SwapCreatorReadyIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *SwapFactoryReadyIterator) Close() error { +func (it *SwapCreatorReadyIterator) Close() error { it.sub.Unsubscribe() return nil } -// SwapFactoryReady represents a Ready event raised by the SwapFactory contract. -type SwapFactoryReady struct { +// SwapCreatorReady represents a Ready event raised by the SwapCreator contract. +type SwapCreatorReady struct { SwapID [32]byte Raw types.Log // Blockchain specific contextual infos } @@ -815,31 +813,31 @@ type SwapFactoryReady struct { // FilterReady is a free log retrieval operation binding the contract event 0x5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f. // // Solidity: event Ready(bytes32 indexed swapID) -func (_SwapFactory *SwapFactoryFilterer) FilterReady(opts *bind.FilterOpts, swapID [][32]byte) (*SwapFactoryReadyIterator, error) { +func (_SwapCreator *SwapCreatorFilterer) FilterReady(opts *bind.FilterOpts, swapID [][32]byte) (*SwapCreatorReadyIterator, error) { var swapIDRule []interface{} for _, swapIDItem := range swapID { swapIDRule = append(swapIDRule, swapIDItem) } - logs, sub, err := _SwapFactory.contract.FilterLogs(opts, "Ready", swapIDRule) + logs, sub, err := _SwapCreator.contract.FilterLogs(opts, "Ready", swapIDRule) if err != nil { return nil, err } - return &SwapFactoryReadyIterator{contract: _SwapFactory.contract, event: "Ready", logs: logs, sub: sub}, nil + return &SwapCreatorReadyIterator{contract: _SwapCreator.contract, event: "Ready", logs: logs, sub: sub}, nil } // WatchReady is a free log subscription operation binding the contract event 0x5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f. // // Solidity: event Ready(bytes32 indexed swapID) -func (_SwapFactory *SwapFactoryFilterer) WatchReady(opts *bind.WatchOpts, sink chan<- *SwapFactoryReady, swapID [][32]byte) (event.Subscription, error) { +func (_SwapCreator *SwapCreatorFilterer) WatchReady(opts *bind.WatchOpts, sink chan<- *SwapCreatorReady, swapID [][32]byte) (event.Subscription, error) { var swapIDRule []interface{} for _, swapIDItem := range swapID { swapIDRule = append(swapIDRule, swapIDItem) } - logs, sub, err := _SwapFactory.contract.WatchLogs(opts, "Ready", swapIDRule) + logs, sub, err := _SwapCreator.contract.WatchLogs(opts, "Ready", swapIDRule) if err != nil { return nil, err } @@ -849,8 +847,8 @@ func (_SwapFactory *SwapFactoryFilterer) WatchReady(opts *bind.WatchOpts, sink c select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(SwapFactoryReady) - if err := _SwapFactory.contract.UnpackLog(event, "Ready", log); err != nil { + event := new(SwapCreatorReady) + if err := _SwapCreator.contract.UnpackLog(event, "Ready", log); err != nil { return err } event.Raw = log @@ -874,18 +872,18 @@ func (_SwapFactory *SwapFactoryFilterer) WatchReady(opts *bind.WatchOpts, sink c // ParseReady is a log parse operation binding the contract event 0x5fc23b25552757626e08b316cc2387ad1bc70ee1594af7204db4ce0c39f5d15f. // // Solidity: event Ready(bytes32 indexed swapID) -func (_SwapFactory *SwapFactoryFilterer) ParseReady(log types.Log) (*SwapFactoryReady, error) { - event := new(SwapFactoryReady) - if err := _SwapFactory.contract.UnpackLog(event, "Ready", log); err != nil { +func (_SwapCreator *SwapCreatorFilterer) ParseReady(log types.Log) (*SwapCreatorReady, error) { + event := new(SwapCreatorReady) + if err := _SwapCreator.contract.UnpackLog(event, "Ready", log); err != nil { return nil, err } event.Raw = log return event, nil } -// SwapFactoryRefundedIterator is returned from FilterRefunded and is used to iterate over the raw logs and unpacked data for Refunded events raised by the SwapFactory contract. -type SwapFactoryRefundedIterator struct { - Event *SwapFactoryRefunded // Event containing the contract specifics and raw log +// SwapCreatorRefundedIterator is returned from FilterRefunded and is used to iterate over the raw logs and unpacked data for Refunded events raised by the SwapCreator contract. +type SwapCreatorRefundedIterator struct { + Event *SwapCreatorRefunded // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -899,7 +897,7 @@ type SwapFactoryRefundedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *SwapFactoryRefundedIterator) Next() bool { +func (it *SwapCreatorRefundedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -908,7 +906,7 @@ func (it *SwapFactoryRefundedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(SwapFactoryRefunded) + it.Event = new(SwapCreatorRefunded) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -923,7 +921,7 @@ func (it *SwapFactoryRefundedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(SwapFactoryRefunded) + it.Event = new(SwapCreatorRefunded) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -939,19 +937,19 @@ func (it *SwapFactoryRefundedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *SwapFactoryRefundedIterator) Error() error { +func (it *SwapCreatorRefundedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *SwapFactoryRefundedIterator) Close() error { +func (it *SwapCreatorRefundedIterator) Close() error { it.sub.Unsubscribe() return nil } -// SwapFactoryRefunded represents a Refunded event raised by the SwapFactory contract. -type SwapFactoryRefunded struct { +// SwapCreatorRefunded represents a Refunded event raised by the SwapCreator contract. +type SwapCreatorRefunded struct { SwapID [32]byte S [32]byte Raw types.Log // Blockchain specific contextual infos @@ -960,7 +958,7 @@ type SwapFactoryRefunded struct { // FilterRefunded is a free log retrieval operation binding the contract event 0x007c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f. // // Solidity: event Refunded(bytes32 indexed swapID, bytes32 indexed s) -func (_SwapFactory *SwapFactoryFilterer) FilterRefunded(opts *bind.FilterOpts, swapID [][32]byte, s [][32]byte) (*SwapFactoryRefundedIterator, error) { +func (_SwapCreator *SwapCreatorFilterer) FilterRefunded(opts *bind.FilterOpts, swapID [][32]byte, s [][32]byte) (*SwapCreatorRefundedIterator, error) { var swapIDRule []interface{} for _, swapIDItem := range swapID { @@ -971,17 +969,17 @@ func (_SwapFactory *SwapFactoryFilterer) FilterRefunded(opts *bind.FilterOpts, s sRule = append(sRule, sItem) } - logs, sub, err := _SwapFactory.contract.FilterLogs(opts, "Refunded", swapIDRule, sRule) + logs, sub, err := _SwapCreator.contract.FilterLogs(opts, "Refunded", swapIDRule, sRule) if err != nil { return nil, err } - return &SwapFactoryRefundedIterator{contract: _SwapFactory.contract, event: "Refunded", logs: logs, sub: sub}, nil + return &SwapCreatorRefundedIterator{contract: _SwapCreator.contract, event: "Refunded", logs: logs, sub: sub}, nil } // WatchRefunded is a free log subscription operation binding the contract event 0x007c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f. // // Solidity: event Refunded(bytes32 indexed swapID, bytes32 indexed s) -func (_SwapFactory *SwapFactoryFilterer) WatchRefunded(opts *bind.WatchOpts, sink chan<- *SwapFactoryRefunded, swapID [][32]byte, s [][32]byte) (event.Subscription, error) { +func (_SwapCreator *SwapCreatorFilterer) WatchRefunded(opts *bind.WatchOpts, sink chan<- *SwapCreatorRefunded, swapID [][32]byte, s [][32]byte) (event.Subscription, error) { var swapIDRule []interface{} for _, swapIDItem := range swapID { @@ -992,7 +990,7 @@ func (_SwapFactory *SwapFactoryFilterer) WatchRefunded(opts *bind.WatchOpts, sin sRule = append(sRule, sItem) } - logs, sub, err := _SwapFactory.contract.WatchLogs(opts, "Refunded", swapIDRule, sRule) + logs, sub, err := _SwapCreator.contract.WatchLogs(opts, "Refunded", swapIDRule, sRule) if err != nil { return nil, err } @@ -1002,8 +1000,8 @@ func (_SwapFactory *SwapFactoryFilterer) WatchRefunded(opts *bind.WatchOpts, sin select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(SwapFactoryRefunded) - if err := _SwapFactory.contract.UnpackLog(event, "Refunded", log); err != nil { + event := new(SwapCreatorRefunded) + if err := _SwapCreator.contract.UnpackLog(event, "Refunded", log); err != nil { return err } event.Raw = log @@ -1027,9 +1025,9 @@ func (_SwapFactory *SwapFactoryFilterer) WatchRefunded(opts *bind.WatchOpts, sin // ParseRefunded is a log parse operation binding the contract event 0x007c875846b687732a7579c19bb1dade66cd14e9f4f809565e2b2b5e76c72b4f. // // Solidity: event Refunded(bytes32 indexed swapID, bytes32 indexed s) -func (_SwapFactory *SwapFactoryFilterer) ParseRefunded(log types.Log) (*SwapFactoryRefunded, error) { - event := new(SwapFactoryRefunded) - if err := _SwapFactory.contract.UnpackLog(event, "Refunded", log); err != nil { +func (_SwapCreator *SwapCreatorFilterer) ParseRefunded(log types.Log) (*SwapCreatorRefunded, error) { + event := new(SwapCreatorRefunded) + if err := _SwapCreator.contract.UnpackLog(event, "Refunded", log); err != nil { return nil, err } event.Raw = log diff --git a/ethereum/swap_factory_marshal.go b/ethereum/swap_creator_marshal.go similarity index 82% rename from ethereum/swap_factory_marshal.go rename to ethereum/swap_creator_marshal.go index 41dadd51..6c9ea6be 100644 --- a/ethereum/swap_factory_marshal.go +++ b/ethereum/swap_creator_marshal.go @@ -12,7 +12,7 @@ import ( "github.com/athanorlabs/atomic-swap/common/vjson" ) -// swap is the same as the auto-generated SwapFactorySwap type, but with some type +// swap is the same as the auto-generated SwapCreatorSwap type, but with some type // adjustments and annotations for JSON marshalling. type swap struct { Owner common.Address `json:"owner" validate:"required"` @@ -26,8 +26,8 @@ type swap struct { Nonce *big.Int `json:"nonce" validate:"required"` } -// MarshalJSON provides JSON marshalling for SwapFactorySwap -func (sfs *SwapFactorySwap) MarshalJSON() ([]byte, error) { +// MarshalJSON provides JSON marshalling for SwapCreatorSwap +func (sfs *SwapCreatorSwap) MarshalJSON() ([]byte, error) { return vjson.MarshalStruct(&swap{ Owner: sfs.Owner, Claimer: sfs.Claimer, @@ -41,13 +41,13 @@ func (sfs *SwapFactorySwap) MarshalJSON() ([]byte, error) { }) } -// UnmarshalJSON provides JSON unmarshalling for SwapFactorySwap -func (sfs *SwapFactorySwap) UnmarshalJSON(data []byte) error { +// UnmarshalJSON provides JSON unmarshalling for SwapCreatorSwap +func (sfs *SwapCreatorSwap) UnmarshalJSON(data []byte) error { s := &swap{} if err := vjson.UnmarshalStruct(data, s); err != nil { return err } - *sfs = SwapFactorySwap{ + *sfs = SwapCreatorSwap{ Owner: s.Owner, Claimer: s.Claimer, PubKeyClaim: s.PubKeyClaim, diff --git a/ethereum/swap_factory_marshal_test.go b/ethereum/swap_creator_marshal_test.go similarity index 87% rename from ethereum/swap_factory_marshal_test.go rename to ethereum/swap_creator_marshal_test.go index 392f7862..3615c94f 100644 --- a/ethereum/swap_factory_marshal_test.go +++ b/ethereum/swap_creator_marshal_test.go @@ -17,8 +17,8 @@ import ( "github.com/athanorlabs/atomic-swap/common/vjson" ) -func TestSwapFactorySwap_JSON(t *testing.T) { - sf := &SwapFactorySwap{ +func TestSwapCreatorSwap_JSON(t *testing.T) { + sf := &SwapCreatorSwap{ Owner: ethcommon.HexToAddress("0xda9dfa130df4de4673b89022ee50ff26f6ea73cf"), Claimer: ethcommon.HexToAddress("0xbe0eb53f46cd790cd13851d5eff43d12404d33e8"), PubKeyClaim: ethcommon.HexToHash("0x5ab9467e70d4e98567991f0179d1f82a3096ed7973f7aff9ea50f649cafa88b9"), @@ -44,7 +44,7 @@ func TestSwapFactorySwap_JSON(t *testing.T) { require.NoError(t, err) require.JSONEq(t, expectedJSON, string(jsonData)) - sf2 := &SwapFactorySwap{} + sf2 := &SwapCreatorSwap{} err = json.Unmarshal(jsonData, sf2) require.NoError(t, err) require.EqualValues(t, sf, sf2) @@ -52,8 +52,8 @@ func TestSwapFactorySwap_JSON(t *testing.T) { // Ensure that our serializable swap type has the same number of fields as the original // generated type. -func TestSwapFactorySwap_JSON_fieldCountEqual(t *testing.T) { +func TestSwapCreatorSwap_JSON_fieldCountEqual(t *testing.T) { numSwapFields := reflect.TypeOf(swap{}).NumField() - numSwapFactorySwapFields := reflect.TypeOf(SwapFactorySwap{}).NumField() - require.Equal(t, numSwapFactorySwapFields, numSwapFields) + numSwapCreatorSwapFields := reflect.TypeOf(SwapCreatorSwap{}).NumField() + require.Equal(t, numSwapCreatorSwapFields, numSwapFields) } diff --git a/ethereum/swap_factory_test.go b/ethereum/swap_creator_test.go similarity index 89% rename from ethereum/swap_factory_test.go rename to ethereum/swap_creator_test.go index 5da456aa..2acf37ad 100644 --- a/ethereum/swap_factory_test.go +++ b/ethereum/swap_creator_test.go @@ -44,7 +44,7 @@ func setupXMRTakerAuth(t *testing.T) (*bind.TransactOpts, *ethclient.Client, *ec func testNewSwap(t *testing.T, asset ethcommon.Address) { auth, conn, _ := setupXMRTakerAuth(t) - address, tx, contract, err := DeploySwapFactory(auth, conn, ethcommon.Address{}) + address, tx, contract, err := DeploySwapCreator(auth, conn, ethcommon.Address{}) require.NoError(t, err) require.NotEqual(t, ethcommon.Address{}, address) require.NotNil(t, tx) @@ -52,7 +52,7 @@ func testNewSwap(t *testing.T, asset ethcommon.Address) { receipt, err := block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) owner := auth.From claimer := common.EthereumPrivateKeyToAddress(tests.GetMakerTestKey(t)) @@ -106,7 +106,7 @@ func testNewSwap(t *testing.T, asset ethcommon.Address) { require.NoError(t, err) // validate that off-chain swapID calculation matches the on-chain value - swap := SwapFactorySwap{ + swap := SwapCreatorSwap{ Owner: owner, Claimer: claimer, PubKeyClaim: pubKeyClaim, @@ -122,11 +122,11 @@ func testNewSwap(t *testing.T, asset ethcommon.Address) { require.Equal(t, types.Hash(swapID).Hex(), swap.SwapID().Hex()) } -func TestSwapFactory_NewSwap(t *testing.T) { +func TestSwapCreator_NewSwap(t *testing.T) { testNewSwap(t, ethAssetAddress) } -func TestSwapFactory_Claim_vec(t *testing.T) { +func TestSwapCreator_Claim_vec(t *testing.T) { secret, err := hex.DecodeString("D30519BCAE8D180DBFCC94FE0B8383DC310185B0BE97B4365083EBCECCD75759") require.NoError(t, err) pubX, err := hex.DecodeString("3AF1E1EFA4D1E1AD5CB9E3967E98E901DAFCD37C44CF0BFB6C216997F5EE51DF") @@ -147,11 +147,11 @@ func TestSwapFactory_Claim_vec(t *testing.T) { pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) - _, tx, contract, err := DeploySwapFactory(auth, conn, ethcommon.Address{}) + _, tx, contract, err := DeploySwapCreator(auth, conn, ethcommon.Address{}) require.NoError(t, err) receipt, err := block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) nonce := big.NewInt(0) tx, err = contract.NewSwap(auth, cmt, [32]byte{}, addr, defaultTimeoutDuration, @@ -168,7 +168,7 @@ func TestSwapFactory_Claim_vec(t *testing.T) { t0, t1, err := GetTimeoutsFromLog(receipt.Logs[0]) require.NoError(t, err) - swap := SwapFactorySwap{ + swap := SwapCreatorSwap{ Owner: addr, Claimer: addr, PubKeyClaim: cmt, @@ -211,19 +211,24 @@ func testClaim(t *testing.T, asset ethcommon.Address, newLogIndex int, value *bi cmt := res.Secp256k1PublicKey().Keccak256() // deploy swap contract with claim key hash - auth, conn, pkA := setupXMRTakerAuth(t) + authOrig, conn, pkA := setupXMRTakerAuth(t) pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) - swapFactoryAddress, tx, contract, err := DeploySwapFactory(auth, conn, ethcommon.Address{}) + // TODO: Rewrite this code to avoid the awkward use of txOpts. Code was using + // same TxOpts for multiple transactions and we needed a quick fix to get + // CI working. + txOpts := *authOrig + swapCreatorAddr, tx, contract, err := DeploySwapCreator(&txOpts, conn, ethcommon.Address{}) require.NoError(t, err) receipt, err := block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) if asset != ethAssetAddress { require.NotNil(t, erc20Contract) - tx, err = erc20Contract.Approve(auth, swapFactoryAddress, value) + txOpts = *authOrig + tx, err = erc20Contract.Approve(&txOpts, swapCreatorAddr, value) require.NoError(t, err) receipt, err = block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) @@ -231,17 +236,17 @@ func testClaim(t *testing.T, asset ethcommon.Address, newLogIndex int, value *bi } nonce := big.NewInt(0) + txOpts = *authOrig if asset == ethAssetAddress { - auth.Value = value + txOpts.Value = value } - tx, err = contract.NewSwap(auth, cmt, [32]byte{}, addr, + tx, err = contract.NewSwap(&txOpts, cmt, [32]byte{}, addr, defaultTimeoutDuration, defaultTimeoutDuration, asset, value, nonce) require.NoError(t, err) receipt, err = block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) t.Logf("gas cost to call new_swap: %d", receipt.GasUsed) - auth.Value = big.NewInt(0) require.Equal(t, newLogIndex+1, len(receipt.Logs)) id, err := GetIDFromLog(receipt.Logs[newLogIndex]) @@ -250,7 +255,7 @@ func testClaim(t *testing.T, asset ethcommon.Address, newLogIndex int, value *bi t0, t1, err := GetTimeoutsFromLog(receipt.Logs[newLogIndex]) require.NoError(t, err) - swap := SwapFactorySwap{ + swap := SwapCreatorSwap{ Owner: addr, Claimer: addr, PubKeyClaim: cmt, @@ -263,7 +268,8 @@ func testClaim(t *testing.T, asset ethcommon.Address, newLogIndex int, value *bi } // set contract to Ready - tx, err = contract.SetReady(auth, swap) + txOpts = *authOrig + tx, err = contract.SetReady(&txOpts, swap) require.NoError(t, err) receipt, err = block.WaitForReceipt(context.Background(), conn, tx.Hash()) t.Logf("gas cost to call SetReady: %d", receipt.GasUsed) @@ -273,7 +279,8 @@ func testClaim(t *testing.T, asset ethcommon.Address, newLogIndex int, value *bi var s [32]byte secret := proof.Secret() copy(s[:], secret[:]) - tx, err = contract.Claim(auth, swap, s) + txOpts = *authOrig + tx, err = contract.Claim(&txOpts, swap, s) require.NoError(t, err) receipt, err = block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) @@ -284,7 +291,7 @@ func testClaim(t *testing.T, asset ethcommon.Address, newLogIndex int, value *bi require.Equal(t, StageCompleted, stage) } -func TestSwapFactory_Claim_random(t *testing.T) { +func TestSwapCreator_Claim_random(t *testing.T) { testClaim(t, ethAssetAddress, 0, big.NewInt(0), nil) } @@ -304,11 +311,11 @@ func testRefundBeforeT0(t *testing.T, asset ethcommon.Address, newLogIndex int) pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) - _, tx, contract, err := DeploySwapFactory(auth, conn, ethcommon.Address{}) + _, tx, contract, err := DeploySwapCreator(auth, conn, ethcommon.Address{}) require.NoError(t, err) receipt, err := block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) nonce := big.NewInt(0) tx, err = contract.NewSwap(auth, [32]byte{}, cmt, addr, defaultTimeoutDuration, defaultTimeoutDuration, @@ -325,7 +332,7 @@ func testRefundBeforeT0(t *testing.T, asset ethcommon.Address, newLogIndex int) t0, t1, err := GetTimeoutsFromLog(receipt.Logs[newLogIndex]) require.NoError(t, err) - swap := SwapFactorySwap{ + swap := SwapCreatorSwap{ Owner: addr, Claimer: addr, PubKeyClaim: [32]byte{}, @@ -352,7 +359,7 @@ func testRefundBeforeT0(t *testing.T, asset ethcommon.Address, newLogIndex int) require.Equal(t, StageCompleted, stage) } -func TestSwapFactory_Refund_beforeT0(t *testing.T) { +func TestSwapCreator_Refund_beforeT0(t *testing.T) { testRefundBeforeT0(t, ethAssetAddress, 0) } @@ -372,11 +379,11 @@ func testRefundAfterT1(t *testing.T, asset ethcommon.Address, newLogIndex int) { pub := pkA.Public().(*ecdsa.PublicKey) addr := crypto.PubkeyToAddress(*pub) - _, tx, contract, err := DeploySwapFactory(auth, conn, ethcommon.Address{}) + _, tx, contract, err := DeploySwapCreator(auth, conn, ethcommon.Address{}) require.NoError(t, err) receipt, err := block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) nonce := big.NewInt(0) timeout := big.NewInt(1) // T1 expires before we get the receipt for new_swap TX @@ -396,7 +403,7 @@ func testRefundAfterT1(t *testing.T, asset ethcommon.Address, newLogIndex int) { <-time.After(time.Until(time.Unix(t1.Int64()+1, 0))) - swap := SwapFactorySwap{ + swap := SwapCreatorSwap{ Owner: addr, Claimer: addr, PubKeyClaim: [32]byte{}, @@ -428,11 +435,11 @@ func testRefundAfterT1(t *testing.T, asset ethcommon.Address, newLogIndex int) { require.Equal(t, StageCompleted, stage) } -func TestSwapFactory_Refund_afterT1(t *testing.T) { +func TestSwapCreator_Refund_afterT1(t *testing.T) { testRefundAfterT1(t, ethAssetAddress, 0) } -func TestSwapFactory_MultipleSwaps(t *testing.T) { +func TestSwapCreator_MultipleSwaps(t *testing.T) { // test case where contract has multiple swaps happening at once conn, chainID := tests.NewEthClient(t) @@ -440,11 +447,11 @@ func TestSwapFactory_MultipleSwaps(t *testing.T) { auth, err := bind.NewKeyedTransactorWithChainID(pkContractCreator, chainID) require.NoError(t, err) - _, tx, contract, err := DeploySwapFactory(auth, conn, ethcommon.Address{}) + _, tx, contract, err := DeploySwapCreator(auth, conn, ethcommon.Address{}) require.NoError(t, err) receipt, err := block.WaitForReceipt(context.Background(), conn, tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) const numSwaps = 16 type swapCase struct { @@ -452,7 +459,7 @@ func TestSwapFactory_MultipleSwaps(t *testing.T) { walletKey *ecdsa.PrivateKey id [32]byte secret [32]byte - swap SwapFactorySwap + swap SwapCreatorSwap } getAuth := func(sc *swapCase) *bind.TransactOpts { @@ -481,7 +488,7 @@ func TestSwapFactory_MultipleSwaps(t *testing.T) { sc.walletKey = tests.GetTestKeyByIndex(t, i) addrSwap := crypto.PubkeyToAddress(*sc.walletKey.Public().(*ecdsa.PublicKey)) - sc.swap = SwapFactorySwap{ + sc.swap = SwapCreatorSwap{ Owner: addrSwap, Claimer: addrSwap, PubKeyClaim: res.Secp256k1PublicKey().Keccak256(), diff --git a/ethereum/utils.go b/ethereum/utils.go index 37060c5d..d1df58d2 100644 --- a/ethereum/utils.go +++ b/ethereum/utils.go @@ -21,7 +21,7 @@ import ( ) // Swap stage values that match the names and indexes of the Stage enum in -// the SwapFactory contract +// the SwapCreator contract const ( StageInvalid byte = iota StagePending @@ -30,10 +30,10 @@ const ( ) var ( - // SwapFactoryParsedABI is the parsed SwapFactory ABI. We can skip the error check, + // SwapCreatorParsedABI is the parsed SwapCreator ABI. We can skip the error check, // as it can only fail if abigen generates JSON bindings that golang can't parse, in // which case it will be nil we'll see panics when vetting the binaries. - SwapFactoryParsedABI, _ = SwapFactoryMetaData.GetAbi() + SwapCreatorParsedABI, _ = SwapCreatorMetaData.GetAbi() claimedTopic = common.GetTopic(common.ClaimedEventSignature) refundedTopic = common.GetTopic(common.RefundedEventSignature) @@ -57,7 +57,7 @@ func StageToString(stage byte) string { // SwapID calculates and returns the same hashed swap identifier that newSwap // emits and that is used to track the on-chain stage of a swap. -func (sfs *SwapFactorySwap) SwapID() types.Hash { +func (sfs *SwapCreatorSwap) SwapID() types.Hash { uint256Ty, err := abi.NewType("uint256", "", nil) if err != nil { panic(fmt.Sprintf("failed to create uint256 type: %s", err)) @@ -116,7 +116,7 @@ func (sfs *SwapFactorySwap) SwapID() types.Hash { ) if err != nil { // As long as none of the *big.Int fields are nil, this cannot fail. - // When receiving SwapFactorySwap objects from the database or peers in + // When receiving SwapCreatorSwap objects from the database or peers in // JSON, all *big.Int values are pre-validated to be non-nil. panic(fmt.Sprintf("failed to pack arguments: %s", err)) } @@ -130,7 +130,7 @@ func GetSecretFromLog(log *ethtypes.Log, eventTopic [32]byte) (*mcrypto.PrivateS return nil, errors.New("invalid event, must be one of Claimed or Refunded") } - // abiSF, err := abi.JSON(strings.NewReader(SwapFactoryMetaData.ABI)) + // abiSF, err := abi.JSON(strings.NewReader(SwapCreatorMetaData.ABI)) // if err != nil { // return nil, err // } @@ -164,7 +164,7 @@ func CheckIfLogIDMatches(log ethtypes.Log, eventTopic, id [32]byte) (bool, error return false, errors.New("invalid event, must be one of Claimed or Refunded") } - // abi, err := abi.JSON(strings.NewReader(SwapFactoryMetaData.ABI)) + // abi, err := abi.JSON(strings.NewReader(SwapCreatorMetaData.ABI)) // if err != nil { // return false, err // } @@ -189,7 +189,7 @@ func CheckIfLogIDMatches(log ethtypes.Log, eventTopic, id [32]byte) (bool, error // GetIDFromLog returns the swap ID from a New log. func GetIDFromLog(log *ethtypes.Log) ([32]byte, error) { - abi := SwapFactoryParsedABI + abi := SwapCreatorParsedABI const event = "New" if log.Topics[0] != abi.Events[event].ID { @@ -213,7 +213,7 @@ func GetIDFromLog(log *ethtypes.Log) ([32]byte, error) { // GetTimeoutsFromLog returns the timeouts from a New event. func GetTimeoutsFromLog(log *ethtypes.Log) (*big.Int, *big.Int, error) { - abi := SwapFactoryParsedABI + abi := SwapCreatorParsedABI const event = "New" if log.Topics[0] != abi.Events[event].ID { diff --git a/ethereum/watcher/watcher.go b/ethereum/watcher/watcher.go index c782fe39..33ace245 100644 --- a/ethereum/watcher/watcher.go +++ b/ethereum/watcher/watcher.go @@ -6,6 +6,7 @@ package watcher import ( "context" + "errors" "math/big" "time" @@ -13,14 +14,18 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" + ethrpc "github.com/ethereum/go-ethereum/rpc" logging "github.com/ipfs/go-log" ) -var ( - log = logging.Logger("ethereum/watcher") +const ( checkForBlocksTimeout = time.Second ) +var ( + log = logging.Logger("ethereum/watcher") +) + // EventFilter filters the chain for specific events (logs). // When it finds a desired log, it puts it into its outbound channel. type EventFilter struct { @@ -70,6 +75,9 @@ func (f *EventFilter) Start() error { currHeader, err := f.ec.HeaderByNumber(f.ctx, nil) if err != nil { log.Errorf("failed to get header in event watcher: %s", err) + if errors.Is(err, ethrpc.ErrClientQuit) { + return // non-recoverable error + } continue } @@ -85,7 +93,9 @@ func (f *EventFilter) Start() error { continue } - log.Debugf("filtered for logs from block %s to block %s", f.filterQuery.FromBlock, currHeader.Number) + // If you think we are missing log events, uncomment to debug: + // log.Debugf("filtered for logs from block %s to block %s", + // f.filterQuery.FromBlock, currHeader.Number) for _, l := range logs { if l.Topics[0] != f.topic { diff --git a/net/host.go b/net/host.go index 57aa5a6c..50582303 100644 --- a/net/host.go +++ b/net/host.go @@ -26,7 +26,7 @@ import ( const ( // ProtocolID is the base atomic swap network protocol ID prefix. The full ID // includes the chain ID at the end. - ProtocolID = "/atomic-swap/0.2" + ProtocolID = "/atomic-swap/0.3" maxMessageSize = 1 << 17 maxRelayMessageSize = 2048 ) diff --git a/net/host_test.go b/net/host_test.go index de04536c..b6cb51a6 100644 --- a/net/host_test.go +++ b/net/host_test.go @@ -79,8 +79,14 @@ func (s *mockSwapState) Exit() error { func basicTestConfig(t *testing.T) *Config { // t.TempDir() is unique on every call. Don't reuse this config with multiple hosts. tmpDir := t.TempDir() + + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(func() { + cancel() + }) + return &Config{ - Ctx: context.Background(), + Ctx: ctx, DataDir: tmpDir, Port: 0, // OS randomized libp2p port KeyFile: path.Join(tmpDir, "node.key"), diff --git a/net/message/message.go b/net/message/message.go index d0604a71..7cb63ec4 100644 --- a/net/message/message.go +++ b/net/message/message.go @@ -158,7 +158,7 @@ type NotifyETHLocked struct { Address ethcommon.Address `json:"address" validate:"required"` TxHash types.Hash `json:"txHash" validate:"required"` ContractSwapID types.Hash `json:"contractSwapID" validate:"required"` - ContractSwap *contracts.SwapFactorySwap `json:"contractSwap" validate:"required"` + ContractSwap *contracts.SwapCreatorSwap `json:"contractSwap" validate:"required"` } // String ... diff --git a/net/message/relay_message.go b/net/message/relay_message.go index d980dbb0..212bbc12 100644 --- a/net/message/relay_message.go +++ b/net/message/relay_message.go @@ -18,11 +18,11 @@ type RelayClaimRequest struct { // OfferID is non-nil, if the request is from a maker to the taker of an // active swap. It is nil, if the request is being sent to a relay node, // because it advertised in the DHT. - OfferID *types.Hash `json:"offerID"` - SwapFactoryAddress ethcommon.Address `json:"swapFactoryAddress" validate:"required"` - Swap *contracts.SwapFactorySwap `json:"swap" validate:"required"` - Secret []byte `json:"secret" validate:"required,len=32"` - Signature []byte `json:"signature" validate:"required,len=65"` + OfferID *types.Hash `json:"offerID"` + SwapCreatorAddr ethcommon.Address `json:"swapCreatorAddr" validate:"required"` + Swap *contracts.SwapCreatorSwap `json:"swap" validate:"required"` + Secret []byte `json:"secret" validate:"required,len=32"` + Signature []byte `json:"signature" validate:"required,len=65"` } // RelayClaimResponse implements common.Message for our p2p relay claim responses diff --git a/net/relay_test.go b/net/relay_test.go index c44f40bd..96973003 100644 --- a/net/relay_test.go +++ b/net/relay_test.go @@ -60,8 +60,8 @@ func createTestClaimRequest() *message.RelayClaimRequest { sig := [65]byte{0x1} req := &message.RelayClaimRequest{ - SwapFactoryAddress: ethcommon.Address{0x1}, - Swap: &contracts.SwapFactorySwap{ + SwapCreatorAddr: ethcommon.Address{0x1}, + Swap: &contracts.SwapCreatorSwap{ Owner: ethcommon.Address{0x1}, Claimer: ethcommon.Address{0x1}, PubKeyClaim: [32]byte{0x1}, diff --git a/protocol/backend/backend.go b/protocol/backend/backend.go index 0a856474..79d6f934 100644 --- a/protocol/backend/backend.go +++ b/protocol/backend/backend.go @@ -64,15 +64,15 @@ type Backend interface { NewTxSender(asset ethcommon.Address, erc20Contract *contracts.IERC20) (txsender.Sender, error) // helpers - NewSwapFactory(addr ethcommon.Address) (*contracts.SwapFactory, error) + NewSwapCreator(addr ethcommon.Address) (*contracts.SwapCreator, error) HandleRelayClaimRequest(request *message.RelayClaimRequest) (*message.RelayClaimResponse, error) // getters Ctx() context.Context Env() common.Environment SwapManager() swap.Manager - Contract() *contracts.SwapFactory - ContractAddr() ethcommon.Address + SwapCreator() *contracts.SwapCreator + SwapCreatorAddr() ethcommon.Address SwapTimeout() time.Duration XMRDepositAddress(offerID *types.Hash) *mcrypto.Address @@ -101,9 +101,9 @@ type backend struct { perSwapXMRDepositAddr map[types.Hash]*mcrypto.Address // swap contract - contract *contracts.SwapFactory - contractAddr ethcommon.Address - swapTimeout time.Duration + swapCreator *contracts.SwapCreator + swapCreatorAddr ethcommon.Address + swapTimeout time.Duration // network interface NetSender @@ -111,23 +111,23 @@ type backend struct { // Config is the config for the Backend type Config struct { - Ctx context.Context - MoneroClient monero.WalletClient - EthereumClient extethclient.EthClient - Environment common.Environment - SwapFactoryAddress ethcommon.Address - SwapManager swap.Manager - RecoveryDB RecoveryDB - Net NetSender + Ctx context.Context + MoneroClient monero.WalletClient + EthereumClient extethclient.EthClient + Environment common.Environment + SwapCreatorAddr ethcommon.Address + SwapManager swap.Manager + RecoveryDB RecoveryDB + Net NetSender } // NewBackend returns a new Backend func NewBackend(cfg *Config) (Backend, error) { - if (cfg.SwapFactoryAddress == ethcommon.Address{}) { + if (cfg.SwapCreatorAddr == ethcommon.Address{}) { return nil, errNilSwapContractOrAddress } - swapFactory, err := contracts.NewSwapFactory(cfg.SwapFactoryAddress, cfg.EthereumClient.Raw()) + swapCreator, err := contracts.NewSwapCreator(cfg.SwapCreatorAddr, cfg.EthereumClient.Raw()) if err != nil { return nil, err } @@ -137,8 +137,8 @@ func NewBackend(cfg *Config) (Backend, error) { env: cfg.Environment, moneroWallet: cfg.MoneroClient, ethClient: cfg.EthereumClient, - contract: swapFactory, - contractAddr: cfg.SwapFactoryAddress, + swapCreator: swapCreator, + swapCreatorAddr: cfg.SwapCreatorAddr, swapManager: cfg.SwapManager, swapTimeout: common.SwapTimeoutFromEnv(cfg.Environment), NetSender: cfg.Net, @@ -157,22 +157,22 @@ func (b *backend) ETHClient() extethclient.EthClient { func (b *backend) NewTxSender(asset ethcommon.Address, erc20Contract *contracts.IERC20) (txsender.Sender, error) { if !b.ethClient.HasPrivateKey() { - return txsender.NewExternalSender(b.ctx, b.env, b.ethClient.Raw(), b.contractAddr, asset) + return txsender.NewExternalSender(b.ctx, b.env, b.ethClient.Raw(), b.swapCreatorAddr, asset) } - return txsender.NewSenderWithPrivateKey(b.ctx, b.ETHClient(), b.contract, erc20Contract), nil + return txsender.NewSenderWithPrivateKey(b.ctx, b.ETHClient(), b.swapCreator, erc20Contract), nil } func (b *backend) RecoveryDB() RecoveryDB { return b.recoveryDB } -func (b *backend) Contract() *contracts.SwapFactory { - return b.contract +func (b *backend) SwapCreator() *contracts.SwapCreator { + return b.swapCreator } -func (b *backend) ContractAddr() ethcommon.Address { - return b.contractAddr +func (b *backend) SwapCreatorAddr() ethcommon.Address { + return b.swapCreatorAddr } func (b *backend) Ctx() context.Context { @@ -197,8 +197,8 @@ func (b *backend) SetSwapTimeout(timeout time.Duration) { b.swapTimeout = timeout } -func (b *backend) NewSwapFactory(addr ethcommon.Address) (*contracts.SwapFactory, error) { - return contracts.NewSwapFactory(addr, b.ethClient.Raw()) +func (b *backend) NewSwapCreator(addr ethcommon.Address) (*contracts.SwapCreator, error) { + return contracts.NewSwapCreator(addr, b.ethClient.Raw()) } // XMRDepositAddress returns the per-swap override deposit address, if a @@ -258,6 +258,6 @@ func (b *backend) HandleRelayClaimRequest(request *message.RelayClaimRequest) (* b.Ctx(), request, b.ETHClient(), - b.ContractAddr(), + b.SwapCreatorAddr(), ) } diff --git a/protocol/swap/types.go b/protocol/swap/types.go index 548a4aca..36d64e9f 100644 --- a/protocol/swap/types.go +++ b/protocol/swap/types.go @@ -20,7 +20,7 @@ import ( var ( // CurInfoVersion is the latest supported version of a serialised Info struct - CurInfoVersion, _ = semver.NewVersion("0.2.0") + CurInfoVersion, _ = semver.NewVersion("0.3.0") errInfoVersionMissing = errors.New("required 'version' field missing in swap Info") ) diff --git a/protocol/swap/types_test.go b/protocol/swap/types_test.go index 7bf80141..abca3fc5 100644 --- a/protocol/swap/types_test.go +++ b/protocol/swap/types_test.go @@ -42,7 +42,7 @@ func Test_InfoMarshal(t *testing.T) { require.NoError(t, err) expectedJSON := `{ - "version": "0.2.0", + "version": "0.3.0", "peerID": "12D3KooWQQRJuKTZ35eiHGNPGDpQqjpJSdaxEMJRxi6NWFrrvQVi", "offerID": "0x0102030405060708091011121314151617181920212223242526272829303132", "provides": "XMR", diff --git a/protocol/txsender/external_sender.go b/protocol/txsender/external_sender.go index 316babe9..189af140 100644 --- a/protocol/txsender/external_sender.go +++ b/protocol/txsender/external_sender.go @@ -68,7 +68,7 @@ func NewExternalSender( return &ExternalSender{ ctx: ctx, ec: ec, - abi: contracts.SwapFactoryParsedABI, + abi: contracts.SwapCreatorParsedABI, contractAddr: contractAddr, erc20Addr: erc20Addr, out: make(chan *Transaction), @@ -77,7 +77,7 @@ func NewExternalSender( } // SetContract ... -func (s *ExternalSender) SetContract(_ *contracts.SwapFactory) {} +func (s *ExternalSender) SetContract(_ *contracts.SwapCreator) {} // SetContractAddress ... func (s *ExternalSender) SetContractAddress(addr ethcommon.Address) { @@ -150,7 +150,7 @@ func (s *ExternalSender) NewSwap( } // SetReady prompts the external sender to sign a set_ready transaction -func (s *ExternalSender) SetReady(swap *contracts.SwapFactorySwap) (*ethtypes.Receipt, error) { +func (s *ExternalSender) SetReady(swap *contracts.SwapCreatorSwap) (*ethtypes.Receipt, error) { input, err := s.abi.Pack("set_ready", swap) if err != nil { return nil, err @@ -161,7 +161,7 @@ func (s *ExternalSender) SetReady(swap *contracts.SwapFactorySwap) (*ethtypes.Re // Claim prompts the external sender to sign a claim transaction func (s *ExternalSender) Claim( - swap *contracts.SwapFactorySwap, + swap *contracts.SwapCreatorSwap, secret [32]byte, ) (*ethtypes.Receipt, error) { input, err := s.abi.Pack("claim", swap, secret) @@ -174,7 +174,7 @@ func (s *ExternalSender) Claim( // Refund prompts the external sender to sign a refund transaction func (s *ExternalSender) Refund( - swap *contracts.SwapFactorySwap, + swap *contracts.SwapCreatorSwap, secret [32]byte, ) (*ethtypes.Receipt, error) { input, err := s.abi.Pack("refund", swap, secret) diff --git a/protocol/txsender/sender.go b/protocol/txsender/sender.go index 0a4a1507..7f3e3dcf 100644 --- a/protocol/txsender/sender.go +++ b/protocol/txsender/sender.go @@ -24,7 +24,7 @@ import ( // Sender signs and submits transactions to the chain type Sender interface { - SetContract(*contracts.SwapFactory) + SetContract(*contracts.SwapCreator) SetContractAddress(ethcommon.Address) Approve(spender ethcommon.Address, amount *big.Int) (*ethtypes.Receipt, error) // for ERC20 swaps NewSwap( @@ -36,15 +36,15 @@ type Sender interface { ethAsset types.EthAsset, amount *big.Int, ) (*ethtypes.Receipt, error) - SetReady(swap *contracts.SwapFactorySwap) (*ethtypes.Receipt, error) - Claim(swap *contracts.SwapFactorySwap, secret [32]byte) (*ethtypes.Receipt, error) - Refund(swap *contracts.SwapFactorySwap, secret [32]byte) (*ethtypes.Receipt, error) + SetReady(swap *contracts.SwapCreatorSwap) (*ethtypes.Receipt, error) + Claim(swap *contracts.SwapCreatorSwap, secret [32]byte) (*ethtypes.Receipt, error) + Refund(swap *contracts.SwapCreatorSwap, secret [32]byte) (*ethtypes.Receipt, error) } type privateKeySender struct { ctx context.Context ethClient extethclient.EthClient - swapContract *contracts.SwapFactory + swapContract *contracts.SwapCreator erc20Contract *contracts.IERC20 } @@ -52,7 +52,7 @@ type privateKeySender struct { func NewSenderWithPrivateKey( ctx context.Context, ethClient extethclient.EthClient, - swapContract *contracts.SwapFactory, + swapContract *contracts.SwapCreator, erc20Contract *contracts.IERC20, ) Sender { return &privateKeySender{ @@ -63,7 +63,7 @@ func NewSenderWithPrivateKey( } } -func (s *privateKeySender) SetContract(contract *contracts.SwapFactory) { +func (s *privateKeySender) SetContract(contract *contracts.SwapCreator) { s.swapContract = contract } @@ -132,7 +132,7 @@ func (s *privateKeySender) NewSwap( return receipt, nil } -func (s *privateKeySender) SetReady(swap *contracts.SwapFactorySwap) (*ethtypes.Receipt, error) { +func (s *privateKeySender) SetReady(swap *contracts.SwapCreatorSwap) (*ethtypes.Receipt, error) { s.ethClient.Lock() defer s.ethClient.Unlock() txOpts, err := s.ethClient.TxOpts(s.ctx) @@ -156,7 +156,7 @@ func (s *privateKeySender) SetReady(swap *contracts.SwapFactorySwap) (*ethtypes. } func (s *privateKeySender) Claim( - swap *contracts.SwapFactorySwap, + swap *contracts.SwapCreatorSwap, secret [32]byte, ) (*ethtypes.Receipt, error) { s.ethClient.Lock() @@ -182,7 +182,7 @@ func (s *privateKeySender) Claim( } func (s *privateKeySender) Refund( - swap *contracts.SwapFactorySwap, + swap *contracts.SwapCreatorSwap, secret [32]byte, ) (*ethtypes.Receipt, error) { s.ethClient.Lock() diff --git a/protocol/xmrmaker/checks.go b/protocol/xmrmaker/checks.go index 1d0c0b2d..a2b9f417 100644 --- a/protocol/xmrmaker/checks.go +++ b/protocol/xmrmaker/checks.go @@ -26,7 +26,7 @@ func (s *swapState) checkContract(txHash ethcommon.Hash) error { return fmt.Errorf("failed to get newSwap transaction %s by hash: %w", txHash, err) } - if tx.To() == nil || *(tx.To()) != s.contractAddr { + if tx.To() == nil || *(tx.To()) != s.swapCreatorAddr { return errInvalidETHLockedTransaction } @@ -45,9 +45,9 @@ func (s *swapState) checkContract(txHash ethcommon.Hash) error { return errCannotFindNewLog } - var event *contracts.SwapFactoryNew + var event *contracts.SwapCreatorNew for _, log := range receipt.Logs { - event, err = s.Contract().ParseNew(*log) + event, err = s.SwapCreator().ParseNew(*log) if err == nil { break } diff --git a/protocol/xmrmaker/claim.go b/protocol/xmrmaker/claim.go index 683f1dbe..5ea6b1fe 100644 --- a/protocol/xmrmaker/claim.go +++ b/protocol/xmrmaker/claim.go @@ -117,7 +117,7 @@ func (s *swapState) relayClaimWithXMRTaker(request *message.RelayClaimRequest) ( s.ctx, s.ETHClient().Raw(), response.TxHash, - s.contractAddr, + s.swapCreatorAddr, s.contractSwapID, s.getSecret(), ) @@ -159,7 +159,7 @@ func (s *swapState) claimWithAdvertisedRelayers(request *message.RelayClaimReque s.ctx, s.ETHClient().Raw(), resp.TxHash, - s.contractAddr, + s.swapCreatorAddr, s.contractSwapID, s.getSecret(), ) @@ -183,7 +183,7 @@ func (s *swapState) claimWithAdvertisedRelayers(request *message.RelayClaimReque // operations more generally. Note that the receipt returned is for a // transaction created by the remote relayer, not by us. func (s *swapState) claimWithRelay() (*ethtypes.Receipt, error) { - forwarderAddress, err := s.Contract().TrustedForwarder(&bind.CallOpts{Context: s.ctx}) + forwarderAddr, err := s.SwapCreator().TrustedForwarder(&bind.CallOpts{Context: s.ctx}) if err != nil { return nil, err } @@ -194,8 +194,8 @@ func (s *swapState) claimWithRelay() (*ethtypes.Receipt, error) { s.ctx, s.ETHClient().PrivateKey(), s.ETHClient().Raw(), - s.contractAddr, - forwarderAddress, + s.swapCreatorAddr, + forwarderAddr, s.contractSwap, &secret, ) diff --git a/protocol/xmrmaker/claim_test.go b/protocol/xmrmaker/claim_test.go index 7b916cfc..7102e691 100644 --- a/protocol/xmrmaker/claim_test.go +++ b/protocol/xmrmaker/claim_test.go @@ -84,7 +84,7 @@ func testSwapStateClaimRelayer(t *testing.T, sk *ecdsa.PrivateKey, asset types.E addr := crypto.PubkeyToAddress(*pub) // deploy forwarder - forwarderAddress, tx, forwarderContract, err := gsnforwarder.DeployForwarder(txOpts, ec.Raw()) + forwarderAddr, tx, forwarderContract, err := gsnforwarder.DeployForwarder(txOpts, ec.Raw()) require.NoError(t, err) receipt, err := block.WaitForReceipt(ctx, ec.Raw(), tx.Hash()) require.NoError(t, err) @@ -97,11 +97,11 @@ func testSwapStateClaimRelayer(t *testing.T, sk *ecdsa.PrivateKey, asset types.E t.Logf("gas cost to call RegisterDomainSeparator: %d", receipt.GasUsed) // deploy swap contract with claim key hash - contractAddr, tx, contract, err := contracts.DeploySwapFactory(txOpts, ec.Raw(), forwarderAddress) + contractAddr, tx, contract, err := contracts.DeploySwapCreator(txOpts, ec.Raw(), forwarderAddr) require.NoError(t, err) receipt, err = block.WaitForReceipt(ctx, ec.Raw(), tx.Hash()) require.NoError(t, err) - t.Logf("gas cost to deploy SwapFactory.sol: %d", receipt.GasUsed) + t.Logf("gas cost to deploy SwapCreator.sol: %d", receipt.GasUsed) if asset != types.EthAssetETH { token, err := contracts.NewIERC20(asset.Address(), ec.Raw()) //nolint:govet @@ -141,7 +141,7 @@ func testSwapStateClaimRelayer(t *testing.T, sk *ecdsa.PrivateKey, asset types.E t0, t1, err := contracts.GetTimeoutsFromLog(receipt.Logs[logIndex]) require.NoError(t, err) - swap := &contracts.SwapFactorySwap{ + swap := &contracts.SwapCreatorSwap{ Owner: addr, Claimer: addr, PubKeyClaim: cmt, @@ -168,7 +168,7 @@ func testSwapStateClaimRelayer(t *testing.T, sk *ecdsa.PrivateKey, asset types.E sk, ec.Raw(), contractAddr, - forwarderAddress, + forwarderAddr, swap, &secret, ) diff --git a/protocol/xmrmaker/event_test.go b/protocol/xmrmaker/event_test.go index 063ee15c..8446484d 100644 --- a/protocol/xmrmaker/event_test.go +++ b/protocol/xmrmaker/event_test.go @@ -26,7 +26,7 @@ func TestSwapState_handleEvent_EventContractReady(t *testing.T) { txOpts, err := s.ETHClient().TxOpts(s.ctx) require.NoError(t, err) - tx, err := s.Contract().SetReady(txOpts, *s.contractSwap) + tx, err := s.SwapCreator().SetReady(txOpts, *s.contractSwap) require.NoError(t, err) tests.MineTransaction(t, s.ETHClient().Raw(), tx) diff --git a/protocol/xmrmaker/instance_test.go b/protocol/xmrmaker/instance_test.go index 72556406..fcb4f2eb 100644 --- a/protocol/xmrmaker/instance_test.go +++ b/protocol/xmrmaker/instance_test.go @@ -88,8 +88,8 @@ func newBackendAndNet(t *testing.T) (backend.Backend, *mockNet) { txOpts, err := bind.NewKeyedTransactorWithChainID(pk, chainID) require.NoError(t, err) - var forwarderAddress ethcommon.Address - _, tx, _, err := contracts.DeploySwapFactory(txOpts, ec, forwarderAddress) + var forwarderAddr ethcommon.Address + _, tx, _, err := contracts.DeploySwapCreator(txOpts, ec, forwarderAddr) require.NoError(t, err) ctx, cancel := context.WithCancel(context.Background()) @@ -115,14 +115,14 @@ func newBackendAndNet(t *testing.T) (backend.Backend, *mockNet) { net := new(mockNet) bcfg := &backend.Config{ - Ctx: ctx, - MoneroClient: monero.CreateWalletClient(t), - EthereumClient: extendedEC, - Environment: common.Development, - SwapFactoryAddress: addr, - SwapManager: newSwapManager(t), - Net: net, - RecoveryDB: rdb, + Ctx: ctx, + MoneroClient: monero.CreateWalletClient(t), + EthereumClient: extendedEC, + Environment: common.Development, + SwapCreatorAddr: addr, + SwapManager: newSwapManager(t), + Net: net, + RecoveryDB: rdb, } b, err := backend.NewBackend(bcfg) @@ -168,7 +168,7 @@ func TestInstance_createOngoingSwap(t *testing.T) { rdb := inst.backend.RecoveryDB().(*backend.MockRecoveryDB) ec := inst.backend.ETHClient() - contract := inst.backend.Contract() + contract := inst.backend.SwapCreator() contractSwap, contractSwapID, _ := newTestSwap( t, ec, contract, [32]byte{}, [32]byte{}, big.NewInt(100), time.Minute*10, ) @@ -204,9 +204,9 @@ func TestInstance_createOngoingSwap(t *testing.T) { rdb.EXPECT().GetCounterpartySwapPrivateKey(s.OfferID).Return(nil, errors.New("some error")) rdb.EXPECT().GetContractSwapInfo(s.OfferID).Return(&db.EthereumSwapInfo{ StartNumber: big.NewInt(1), - ContractAddress: inst.backend.ContractAddr(), + SwapCreatorAddr: inst.backend.SwapCreatorAddr(), SwapID: contractSwapID, - Swap: &contracts.SwapFactorySwap{ + Swap: &contracts.SwapCreatorSwap{ Timeout0: big.NewInt(1), Timeout1: big.NewInt(2), }, diff --git a/protocol/xmrmaker/message_handler.go b/protocol/xmrmaker/message_handler.go index 97918b55..944e4954 100644 --- a/protocol/xmrmaker/message_handler.go +++ b/protocol/xmrmaker/message_handler.go @@ -117,7 +117,7 @@ func (s *swapState) handleNotifyETHLocked(msg *message.NotifyETHLocked) error { // note: this function verifies the forwarder code as well, even if we aren't using a relayer, // in which case it's not relevant to us and we don't need to verify it. // doesn't hurt though I suppose. - _, err = contracts.CheckSwapFactoryContractCode(s.ctx, s.Backend.ETHClient().Raw(), contractAddr) + _, err = contracts.CheckSwapCreatorContractCode(s.ctx, s.Backend.ETHClient().Raw(), contractAddr) if err != nil { return err } @@ -130,7 +130,7 @@ func (s *swapState) handleNotifyETHLocked(msg *message.NotifyETHLocked) error { StartNumber: receipt.BlockNumber, SwapID: s.contractSwapID, Swap: s.contractSwap, - ContractAddress: contractAddr, + SwapCreatorAddr: contractAddr, } if err = s.Backend.RecoveryDB().PutContractSwapInfo(s.OfferID(), ethInfo); err != nil { diff --git a/protocol/xmrmaker/swap_state.go b/protocol/xmrmaker/swap_state.go index 4d4135b6..fb4365eb 100644 --- a/protocol/xmrmaker/swap_state.go +++ b/protocol/xmrmaker/swap_state.go @@ -63,11 +63,11 @@ type swapState struct { pubkeys *mcrypto.PublicKeyPair // swap contract and timeouts in it - contract *contracts.SwapFactory - contractAddr ethcommon.Address - contractSwapID [32]byte - contractSwap *contracts.SwapFactorySwap - t0, t1 time.Time + contract *contracts.SwapCreator + swapCreatorAddr ethcommon.Address + contractSwapID [32]byte + contractSwap *contracts.SwapCreatorSwap + t0, t1 time.Time // XMRTaker's keys for this session xmrtakerPublicSpendKey *mcrypto.PublicKey @@ -182,7 +182,7 @@ func checkIfAlreadyClaimed( ) (bool, error) { // check if swap actually completed and we didn't realize for some reason // this could happen if we restart from an ongoing swap - contract, err := contracts.NewSwapFactory(ethSwapInfo.ContractAddress, b.ETHClient().Raw()) + contract, err := contracts.NewSwapCreator(ethSwapInfo.SwapCreatorAddr, b.ETHClient().Raw()) if err != nil { return false, err } @@ -206,7 +206,7 @@ func checkIfAlreadyClaimed( filterQuery := ethereum.FilterQuery{ FromBlock: ethSwapInfo.StartNumber, - Addresses: []ethcommon.Address{ethSwapInfo.ContractAddress}, + Addresses: []ethcommon.Address{ethSwapInfo.SwapCreatorAddr}, } claimedTopic := common.GetTopic(common.ClaimedEventSignature) @@ -309,7 +309,7 @@ func newSwapStateFromOngoing( return nil, err } - err = s.setContract(ethSwapInfo.ContractAddress) + err = s.setContract(ethSwapInfo.SwapCreatorAddr) if err != nil { return nil, err } @@ -361,7 +361,7 @@ func newSwapState( readyWatcher := watcher.NewEventFilter( ctx, b.ETHClient().Raw(), - b.ContractAddr(), + b.SwapCreatorAddr(), ethStartNumber, readyTopic, logReadyCh, @@ -370,7 +370,7 @@ func newSwapState( refundedWatcher := watcher.NewEventFilter( ctx, b.ETHClient().Raw(), - b.ContractAddr(), + b.SwapCreatorAddr(), ethStartNumber, refundedTopic, logRefundedCh, @@ -624,10 +624,10 @@ func (s *swapState) setXMRTakerKeys( // setContract sets the contract in which XMRTaker has locked her ETH. func (s *swapState) setContract(address ethcommon.Address) error { - s.contractAddr = address + s.swapCreatorAddr = address var err error - s.contract, err = s.NewSwapFactory(address) + s.contract, err = s.NewSwapCreator(address) if err != nil { return err } diff --git a/protocol/xmrmaker/swap_state_ongoing_test.go b/protocol/xmrmaker/swap_state_ongoing_test.go index 9441665a..b42a8756 100644 --- a/protocol/xmrmaker/swap_state_ongoing_test.go +++ b/protocol/xmrmaker/swap_state_ongoing_test.go @@ -32,7 +32,7 @@ func TestSwapStateOngoing_ClaimFunds(t *testing.T) { txOpts, err := swapState.ETHClient().TxOpts(swapState.Backend.Ctx()) require.NoError(t, err) - tx, err := swapState.Contract().SetReady(txOpts, *swapState.contractSwap) + tx, err := swapState.SwapCreator().SetReady(txOpts, *swapState.contractSwap) require.NoError(t, err) tests.MineTransaction(t, swapState.ETHClient().Raw(), tx) @@ -40,7 +40,7 @@ func TestSwapStateOngoing_ClaimFunds(t *testing.T) { StartNumber: big.NewInt(int64(startNum)), SwapID: swapState.contractSwapID, Swap: swapState.contractSwap, - ContractAddress: swapState.Backend.ContractAddr(), + SwapCreatorAddr: swapState.Backend.SwapCreatorAddr(), } swapState.info.Status = types.XMRLocked @@ -101,7 +101,7 @@ func TestSwapStateOngoing_Refund(t *testing.T) { ctx := s.Backend.Ctx() txOpts, err := s.ETHClient().TxOpts(ctx) require.NoError(t, err) - tx, err := s.Contract().Refund(txOpts, *s.contractSwap, sc) + tx, err := s.SwapCreator().Refund(txOpts, *s.contractSwap, sc) require.NoError(t, err) receipt, err := block.WaitForReceipt(ctx, s.ETHClient().Raw(), tx.Hash()) require.NoError(t, err) @@ -111,7 +111,7 @@ func TestSwapStateOngoing_Refund(t *testing.T) { StartNumber: big.NewInt(int64(startNum)), SwapID: s.contractSwapID, Swap: s.contractSwap, - ContractAddress: s.Backend.ContractAddr(), + SwapCreatorAddr: s.Backend.SwapCreatorAddr(), } s.info.Status = types.XMRLocked diff --git a/protocol/xmrmaker/swap_state_test.go b/protocol/xmrmaker/swap_state_test.go index c766ae6b..ae1b5a80 100644 --- a/protocol/xmrmaker/swap_state_test.go +++ b/protocol/xmrmaker/swap_state_test.go @@ -75,11 +75,11 @@ func newTestXMRTakerSendKeysMessage(t *testing.T) (*message.SendKeysMessage, *pc func newTestSwap( t *testing.T, ec extethclient.EthClient, - contract *contracts.SwapFactory, + contract *contracts.SwapCreator, claimKey, refundKey types.Hash, amount *big.Int, timeout time.Duration, -) (*contracts.SwapFactorySwap, [32]byte, ethcommon.Hash) { +) (*contracts.SwapCreatorSwap, [32]byte, ethcommon.Hash) { tm := big.NewInt(int64(timeout.Seconds())) txOpts, err := ec.TxOpts(context.Background()) require.NoError(t, err) @@ -100,7 +100,7 @@ func newTestSwap( t0, t1, err := contracts.GetTimeoutsFromLog(receipt.Logs[0]) require.NoError(t, err) - contractSwap := &contracts.SwapFactorySwap{ + contractSwap := &contracts.SwapCreatorSwap{ Owner: ethAddr, Claimer: ethAddr, PubKeyClaim: claimKey, @@ -128,7 +128,7 @@ func newSwap( } contractSwap, contractSwapID, txHash := newTestSwap( - t, ss.ETHClient(), ss.Contract(), claimKey, refundKey, amount, timeout, + t, ss.ETHClient(), ss.SwapCreator(), claimKey, refundKey, amount, timeout, ) ss.contractSwapID = contractSwapID @@ -153,7 +153,7 @@ func TestSwapState_ClaimFunds(t *testing.T) { txOpts, err := swapState.ETHClient().TxOpts(swapState.ctx) require.NoError(t, err) - tx, err := swapState.Contract().SetReady(txOpts, *swapState.contractSwap) + tx, err := swapState.SwapCreator().SetReady(txOpts, *swapState.contractSwap) require.NoError(t, err) tests.MineTransaction(t, swapState.ETHClient().Raw(), tx) @@ -201,7 +201,7 @@ func TestSwapState_HandleProtocolMessage_NotifyETHLocked_ok(t *testing.T) { duration := common.SwapTimeoutFromEnv(common.Development) hash := newSwap(t, s, s.secp256k1Pub.Keccak256(), s.xmrtakerSecp256K1PublicKey.Keccak256(), desiredAmount.BigInt(), duration) - addr := s.ContractAddr() + addr := s.SwapCreatorAddr() msg = &message.NotifyETHLocked{ Address: addr, @@ -235,7 +235,7 @@ func TestSwapState_HandleProtocolMessage_NotifyETHLocked_timeout(t *testing.T) { require.NoError(t, err) _ = newSwap(t, s, s.secp256k1Pub.Keccak256(), s.xmrtakerSecp256K1PublicKey.Keccak256(), desiredAmount.BigInt(), duration) - addr := s.ContractAddr() + addr := s.SwapCreatorAddr() err = s.setContract(addr) require.NoError(t, err) @@ -287,7 +287,7 @@ func TestSwapState_handleRefund(t *testing.T) { txOpts, err := s.ETHClient().TxOpts(s.ctx) require.NoError(t, err) - tx, err := s.Contract().Refund(txOpts, *s.contractSwap, sc) + tx, err := s.SwapCreator().Refund(txOpts, *s.contractSwap, sc) require.NoError(t, err) receipt, err := block.WaitForReceipt(s.Backend.Ctx(), s.ETHClient().Raw(), tx.Hash()) require.NoError(t, err) @@ -342,7 +342,7 @@ func TestSwapState_Exit_Reclaim(t *testing.T) { txOpts, err := s.ETHClient().TxOpts(s.ctx) require.NoError(t, err) - tx, err := s.Contract().Refund(txOpts, *s.contractSwap, sc) + tx, err := s.SwapCreator().Refund(txOpts, *s.contractSwap, sc) require.NoError(t, err) receipt := tests.MineTransaction(t, s.ETHClient().Raw(), tx) diff --git a/protocol/xmrtaker/claim.go b/protocol/xmrtaker/claim.go index 67f06e85..dc1139ce 100644 --- a/protocol/xmrtaker/claim.go +++ b/protocol/xmrtaker/claim.go @@ -38,7 +38,7 @@ func (s *swapState) tryClaim() error { func (s *swapState) filterForClaim() (*mcrypto.PrivateSpendKey, error) { logs, err := s.ETHClient().Raw().FilterLogs(s.ctx, eth.FilterQuery{ - Addresses: []ethcommon.Address{s.ContractAddr()}, + Addresses: []ethcommon.Address{s.SwapCreatorAddr()}, Topics: [][]ethcommon.Hash{{claimedTopic}}, }) if err != nil { diff --git a/protocol/xmrtaker/event_test.go b/protocol/xmrtaker/event_test.go index 2ec5c8a0..00c7e1d5 100644 --- a/protocol/xmrtaker/event_test.go +++ b/protocol/xmrtaker/event_test.go @@ -44,7 +44,7 @@ func lockXMRAndCheckForReadyLog(t *testing.T, s *swapState, xmrAddr *mcrypto.Add readyWatcher := watcher.NewEventFilter( s.Backend.Ctx(), s.Backend.ETHClient().Raw(), - s.Backend.ContractAddr(), + s.Backend.SwapCreatorAddr(), ethHeader.Number, readyTopic, logReadyCh, diff --git a/protocol/xmrtaker/instance_test.go b/protocol/xmrtaker/instance_test.go index 0fe12a9f..e015c60c 100644 --- a/protocol/xmrtaker/instance_test.go +++ b/protocol/xmrtaker/instance_test.go @@ -66,8 +66,8 @@ func TestInstance_createOngoingSwap(t *testing.T) { rdb.EXPECT().GetCounterpartySwapPrivateKey(s.OfferID).Return(nil, errors.New("some error")) rdb.EXPECT().GetContractSwapInfo(s.OfferID).Return(&db.EthereumSwapInfo{ StartNumber: big.NewInt(1), - ContractAddress: inst.backend.ContractAddr(), - Swap: &contracts.SwapFactorySwap{ + SwapCreatorAddr: inst.backend.SwapCreatorAddr(), + Swap: &contracts.SwapCreatorSwap{ Timeout0: big.NewInt(1), Timeout1: big.NewInt(2), }, diff --git a/protocol/xmrtaker/message_handler.go b/protocol/xmrtaker/message_handler.go index 5b3a2c17..df902e14 100644 --- a/protocol/xmrtaker/message_handler.go +++ b/protocol/xmrtaker/message_handler.go @@ -136,7 +136,7 @@ func (s *swapState) handleSendKeysMessage(msg *message.SendKeysMessage) (common. go s.checkForXMRLock() out := &message.NotifyETHLocked{ - Address: s.ContractAddr(), + Address: s.SwapCreatorAddr(), TxHash: receipt.TxHash, ContractSwapID: s.contractSwapID, ContractSwap: s.contractSwap, diff --git a/protocol/xmrtaker/swap_state.go b/protocol/xmrtaker/swap_state.go index 91942edc..51c05f9b 100644 --- a/protocol/xmrtaker/swap_state.go +++ b/protocol/xmrtaker/swap_state.go @@ -73,7 +73,7 @@ type swapState struct { // swap contract and timeouts in it; set once contract is deployed contractSwapID [32]byte - contractSwap *contracts.SwapFactorySwap + contractSwap *contracts.SwapCreatorSwap t0, t1 time.Time // tracks the state of the swap @@ -182,8 +182,8 @@ func newSwapStateFromOngoing( return nil, err } - if b.ContractAddr() != ethSwapInfo.ContractAddress { - return nil, errContractAddrMismatch(ethSwapInfo.ContractAddress.String()) + if b.SwapCreatorAddr() != ethSwapInfo.SwapCreatorAddr { + return nil, errContractAddrMismatch(ethSwapInfo.SwapCreatorAddr.String()) } s.setTimeouts(ethSwapInfo.Swap.Timeout0, ethSwapInfo.Swap.Timeout1) @@ -244,7 +244,7 @@ func newSwapState( claimedWatcher := watcher.NewEventFilter( ctx, b.ETHClient().Raw(), - b.ContractAddr(), + b.SwapCreatorAddr(), ethStartNumber, claimedTopic, logClaimedCh, @@ -420,7 +420,7 @@ func (s *swapState) exit() error { } func (s *swapState) tryRefund() (*ethtypes.Receipt, error) { - stage, err := s.Contract().Swaps(s.ETHClient().CallOpts(s.ctx), s.contractSwapID) + stage, err := s.SwapCreator().Swaps(s.ETHClient().CallOpts(s.ctx), s.contractSwapID) if err != nil { return nil, err } @@ -561,7 +561,7 @@ func (s *swapState) approveToken() error { } log.Info("approving token for use by the swap contract...") - _, err = s.sender.Approve(s.ContractAddr(), balance) + _, err = s.sender.Approve(s.SwapCreatorAddr(), balance) if err != nil { return fmt.Errorf("failed to approve token: %w", err) } @@ -639,7 +639,7 @@ func (s *swapState) lockAsset() (*ethtypes.Receipt, error) { s.fundsLocked = true s.setTimeouts(t0, t1) - s.contractSwap = &contracts.SwapFactorySwap{ + s.contractSwap = &contracts.SwapCreatorSwap{ Owner: s.ETHClient().Address(), Claimer: s.xmrmakerAddress, PubKeyClaim: cmtXMRMaker, @@ -655,7 +655,7 @@ func (s *swapState) lockAsset() (*ethtypes.Receipt, error) { StartNumber: receipt.BlockNumber, SwapID: s.contractSwapID, Swap: s.contractSwap, - ContractAddress: s.Backend.ContractAddr(), + SwapCreatorAddr: s.Backend.SwapCreatorAddr(), } if err := s.Backend.RecoveryDB().PutContractSwapInfo(s.OfferID(), ethInfo); err != nil { @@ -670,7 +670,7 @@ func (s *swapState) lockAsset() (*ethtypes.Receipt, error) { // call Claim(). Ready() should only be called once XMRTaker sees XMRMaker lock his XMR. // If time t_0 has passed, there is no point of calling Ready(). func (s *swapState) ready() error { - stage, err := s.Contract().Swaps(s.ETHClient().CallOpts(s.ctx), s.contractSwapID) + stage, err := s.SwapCreator().Swaps(s.ETHClient().CallOpts(s.ctx), s.contractSwapID) if err != nil { return err } diff --git a/protocol/xmrtaker/swap_state_ongoing_test.go b/protocol/xmrtaker/swap_state_ongoing_test.go index 22e8faf0..bcf03588 100644 --- a/protocol/xmrtaker/swap_state_ongoing_test.go +++ b/protocol/xmrtaker/swap_state_ongoing_test.go @@ -62,7 +62,7 @@ func TestSwapStateOngoing_handleEvent_EventXMRLocked(t *testing.T) { StartNumber: big.NewInt(int64(startNum)), SwapID: s.contractSwapID, Swap: s.contractSwap, - ContractAddress: s.Backend.ContractAddr(), + SwapCreatorAddr: s.Backend.SwapCreatorAddr(), } ss, err := newSwapStateFromOngoing( @@ -89,7 +89,7 @@ func TestSwapStateOngoing_handleEvent_EventETHClaimed(t *testing.T) { StartNumber: big.NewInt(int64(startNum)), SwapID: s.contractSwapID, Swap: s.contractSwap, - ContractAddress: s.Backend.ContractAddr(), + SwapCreatorAddr: s.Backend.SwapCreatorAddr(), } ss, err := newSwapStateFromOngoing( diff --git a/protocol/xmrtaker/swap_state_test.go b/protocol/xmrtaker/swap_state_test.go index 7f73f66a..27ac4517 100644 --- a/protocol/xmrtaker/swap_state_test.go +++ b/protocol/xmrtaker/swap_state_test.go @@ -90,8 +90,8 @@ func newBackendAndNet(t *testing.T) (backend.Backend, *mockNet) { txOpts, err := bind.NewKeyedTransactorWithChainID(pk, ec.ChainID()) require.NoError(t, err) - var forwarderAddress ethcommon.Address - _, tx, _, err := contracts.DeploySwapFactory(txOpts, ec.Raw(), forwarderAddress) + var forwarderAddr ethcommon.Address + _, tx, _, err := contracts.DeploySwapCreator(txOpts, ec.Raw(), forwarderAddr) require.NoError(t, err) addr, err := bind.WaitDeployed(ctx, ec.Raw(), tx) @@ -108,14 +108,14 @@ func newBackendAndNet(t *testing.T) (backend.Backend, *mockNet) { net := new(mockNet) bcfg := &backend.Config{ - Ctx: context.Background(), - MoneroClient: monero.CreateWalletClient(t), - EthereumClient: ec, - Environment: common.Development, - SwapManager: newSwapManager(t), - SwapFactoryAddress: addr, - Net: net, - RecoveryDB: rdb, + Ctx: ctx, + MoneroClient: monero.CreateWalletClient(t), + EthereumClient: ec, + Environment: common.Development, + SwapManager: newSwapManager(t), + SwapCreatorAddr: addr, + Net: net, + RecoveryDB: rdb, } b, err := backend.NewBackend(bcfg) @@ -241,7 +241,7 @@ func TestSwapState_HandleProtocolMessage_SendKeysMessage_Refund(t *testing.T) { } // check swap is marked completed - stage, err := s.Contract().Swaps(nil, s.contractSwapID) + stage, err := s.SwapCreator().Swaps(nil, s.contractSwapID) require.NoError(t, err) require.Equal(t, contracts.StageCompleted, stage) } @@ -329,7 +329,7 @@ func TestSwapState_NotifyXMRLock_Refund(t *testing.T) { } // check balance of contract is 0 - balance, err := s.ETHClient().Raw().BalanceAt(context.Background(), s.ContractAddr(), nil) + balance, err := s.ETHClient().Raw().BalanceAt(context.Background(), s.SwapCreatorAddr(), nil) require.NoError(t, err) require.Equal(t, uint64(0), balance.Uint64()) } @@ -429,7 +429,7 @@ func TestSwapState_ApproveToken(t *testing.T) { s, contract := newTestSwapStateWithERC20(t, initialBalance) err := s.approveToken() require.NoError(t, err) - allowance, err := contract.Allowance(&bind.CallOpts{}, s.ETHClient().Address(), s.ContractAddr()) + allowance, err := contract.Allowance(&bind.CallOpts{}, s.ETHClient().Address(), s.SwapCreatorAddr()) require.NoError(t, err) require.Equal(t, initialBalance, allowance) } diff --git a/relayer/claim_request.go b/relayer/claim_request.go index 188b0a65..4374124d 100644 --- a/relayer/claim_request.go +++ b/relayer/claim_request.go @@ -37,9 +37,9 @@ func CreateRelayClaimRequest( ctx context.Context, claimerEthKey *ecdsa.PrivateKey, ec *ethclient.Client, - swapFactoryAddress ethcommon.Address, - forwarderAddress ethcommon.Address, - swap *contracts.SwapFactorySwap, + swapCreatorAddr ethcommon.Address, + forwarderAddr ethcommon.Address, + swap *contracts.SwapCreatorSwap, secret *[32]byte, ) (*message.RelayClaimRequest, error) { @@ -47,8 +47,8 @@ func CreateRelayClaimRequest( ctx, claimerEthKey, ec, - swapFactoryAddress, - forwarderAddress, + swapCreatorAddr, + forwarderAddr, swap, secret, ) @@ -57,10 +57,10 @@ func CreateRelayClaimRequest( } return &message.RelayClaimRequest{ - OfferID: nil, // set elsewhere if sending to counterparty - SwapFactoryAddress: swapFactoryAddress, - Swap: swap, - Secret: secret[:], - Signature: signature, + OfferID: nil, // set elsewhere if sending to counterparty + SwapCreatorAddr: swapCreatorAddr, + Swap: swap, + Secret: secret[:], + Signature: signature, }, nil } diff --git a/relayer/claim_request_test.go b/relayer/claim_request_test.go index 3f6f7676..8e43c5cb 100644 --- a/relayer/claim_request_test.go +++ b/relayer/claim_request_test.go @@ -22,28 +22,28 @@ import ( // Speed up tests a little by giving deployContracts(...) a package-level cache. // These variables should not be accessed by other functions. -var _forwarderAddress *ethcommon.Address -var _swapFactoryAddress *ethcommon.Address +var _forwarderAddr *ethcommon.Address +var _swapCreatorAddr *ethcommon.Address -// deployContracts deploys and returns the swapFactory and forwarder addresses. +// deployContracts deploys and returns the swapCreator and forwarder addresses. func deployContracts(t *testing.T, ec *ethclient.Client, key *ecdsa.PrivateKey) (ethcommon.Address, ethcommon.Address) { ctx := context.Background() - if _forwarderAddress == nil || _swapFactoryAddress == nil { + if _forwarderAddr == nil || _swapCreatorAddr == nil { forwarderAddr, err := contracts.DeployGSNForwarderWithKey(ctx, ec, key) require.NoError(t, err) - _forwarderAddress = &forwarderAddr + _forwarderAddr = &forwarderAddr - swapFactoryAddr, _, err := contracts.DeploySwapFactoryWithKey(ctx, ec, key, forwarderAddr) + swapCreatorAddr, _, err := contracts.DeploySwapCreatorWithKey(ctx, ec, key, forwarderAddr) require.NoError(t, err) - _swapFactoryAddress = &swapFactoryAddr + _swapCreatorAddr = &swapCreatorAddr } - return *_swapFactoryAddress, *_forwarderAddress + return *_swapCreatorAddr, *_forwarderAddr } -func createTestSwap(claimer ethcommon.Address) *contracts.SwapFactorySwap { - return &contracts.SwapFactorySwap{ +func createTestSwap(claimer ethcommon.Address) *contracts.SwapCreatorSwap { + return &contracts.SwapCreatorSwap{ Owner: ethcommon.Address{0x1}, Claimer: claimer, PubKeyClaim: [32]byte{0x1}, @@ -62,16 +62,16 @@ func TestCreateRelayClaimRequest(t *testing.T) { claimer := crypto.PubkeyToAddress(*ethKey.Public().(*ecdsa.PublicKey)) ec, _ := tests.NewEthClient(t) secret := [32]byte{0x1} - swapFactoryAddr, forwarderAddr := deployContracts(t, ec, ethKey) + swapCreatorAddr, forwarderAddr := deployContracts(t, ec, ethKey) // success path swap := createTestSwap(claimer) - req, err := CreateRelayClaimRequest(ctx, ethKey, ec, swapFactoryAddr, forwarderAddr, swap, &secret) + req, err := CreateRelayClaimRequest(ctx, ethKey, ec, swapCreatorAddr, forwarderAddr, swap, &secret) require.NoError(t, err) require.NotNil(t, req) // change the ethkey to not match the claimer address to trigger the error path ethKey = tests.GetTakerTestKey(t) - _, err = CreateRelayClaimRequest(ctx, ethKey, ec, swapFactoryAddr, forwarderAddr, swap, &secret) + _, err = CreateRelayClaimRequest(ctx, ethKey, ec, swapCreatorAddr, forwarderAddr, swap, &secret) require.ErrorContains(t, err, "signing key does not match claimer") } diff --git a/relayer/forwarder.go b/relayer/forwarder.go index c6553007..a548d5cb 100644 --- a/relayer/forwarder.go +++ b/relayer/forwarder.go @@ -23,9 +23,9 @@ func createForwarderSignature( ctx context.Context, claimerEthKey *ecdsa.PrivateKey, ec *ethclient.Client, - swapFactoryAddress ethcommon.Address, - forwarderAddress ethcommon.Address, - swap *contracts.SwapFactorySwap, + swapCreatorAddr ethcommon.Address, + forwarderAddr ethcommon.Address, + swap *contracts.SwapCreatorSwap, secret *[32]byte, ) ([]byte, error) { @@ -33,7 +33,7 @@ func createForwarderSignature( return nil, fmt.Errorf("signing key does not match claimer %s", swap.Claimer) } - forwarder, domainSeparator, err := getForwarderAndDomainSeparator(ctx, ec, forwarderAddress) + forwarder, domainSeparator, err := getForwarderAndDomainSeparator(ctx, ec, forwarderAddr) if err != nil { return nil, err } @@ -45,7 +45,7 @@ func createForwarderSignature( forwarderReq, err := createForwarderRequest( nonce, - swapFactoryAddress, + swapCreatorAddr, swap, secret, ) @@ -69,8 +69,8 @@ func createForwarderSignature( // createForwarderRequest creates the forwarder request, which we sign the digest of. func createForwarderRequest( nonce *big.Int, - swapFactoryAddress ethcommon.Address, - swap *contracts.SwapFactorySwap, + swapCreatorAddr ethcommon.Address, + swap *contracts.SwapCreatorSwap, secret *[32]byte, ) (*gsnforwarder.IForwarderForwardRequest, error) { @@ -81,7 +81,7 @@ func createForwarderRequest( req := &gsnforwarder.IForwarderForwardRequest{ From: swap.Claimer, - To: swapFactoryAddress, + To: swapCreatorAddr, Value: big.NewInt(0), Gas: big.NewInt(relayedClaimGas), Nonce: nonce, @@ -93,28 +93,28 @@ func createForwarderRequest( } // getClaimRelayerTxCalldata returns the call data to be used when invoking the -// claimRelayer method on the SwapFactory contract. -func getClaimRelayerTxCalldata(feeWei *big.Int, swap *contracts.SwapFactorySwap, secret *[32]byte) ([]byte, error) { - return contracts.SwapFactoryParsedABI.Pack("claimRelayer", *swap, *secret, feeWei) +// claimRelayer method on the SwapCreator contract. +func getClaimRelayerTxCalldata(feeWei *big.Int, swap *contracts.SwapCreatorSwap, secret *[32]byte) ([]byte, error) { + return contracts.SwapCreatorParsedABI.Pack("claimRelayer", *swap, *secret, feeWei) } func getForwarderAndDomainSeparator( ctx context.Context, ec *ethclient.Client, - forwarderAddress ethcommon.Address, + forwarderAddr ethcommon.Address, ) (*gsnforwarder.Forwarder, *[32]byte, error) { chainID, err := ec.ChainID(ctx) if err != nil { return nil, nil, err } - forwarder, err := gsnforwarder.NewForwarder(forwarderAddress, ec) + forwarder, err := gsnforwarder.NewForwarder(forwarderAddr, ec) if err != nil { return nil, nil, err } domainSeparator, err := rcommon.GetEIP712DomainSeparator(gsnforwarder.DefaultName, - gsnforwarder.DefaultVersion, chainID, forwarderAddress) + gsnforwarder.DefaultVersion, chainID, forwarderAddr) if err != nil { return nil, nil, fmt.Errorf("failed to get EIP712 domain separator: %w", err) } diff --git a/relayer/submit_transaction.go b/relayer/submit_transaction.go index b7128b30..0e6378e9 100644 --- a/relayer/submit_transaction.go +++ b/relayer/submit_transaction.go @@ -33,12 +33,12 @@ func ValidateAndSendTransaction( return nil, err } - reqSwapFactory, err := contracts.NewSwapFactory(req.SwapFactoryAddress, ec.Raw()) + reqSwapCreator, err := contracts.NewSwapCreator(req.SwapCreatorAddr, ec.Raw()) if err != nil { return nil, err } - reqForwarderAddr, err := reqSwapFactory.TrustedForwarder(&bind.CallOpts{Context: ctx}) + reqForwarderAddr, err := reqSwapCreator.TrustedForwarder(&bind.CallOpts{Context: ctx}) if err != nil { return nil, err } @@ -56,7 +56,7 @@ func ValidateAndSendTransaction( // The size of request.Secret was vetted when it was deserialized secret := (*[32]byte)(req.Secret) - forwarderReq, err := createForwarderRequest(nonce, req.SwapFactoryAddress, req.Swap, secret) + forwarderReq, err := createForwarderRequest(nonce, req.SwapCreatorAddr, req.Swap, secret) if err != nil { return nil, err } diff --git a/relayer/validate.go b/relayer/validate.go index 61dcc8d7..99c7a168 100644 --- a/relayer/validate.go +++ b/relayer/validate.go @@ -33,7 +33,7 @@ func validateClaimRequest( } // validateClaimValues validates the non-signature aspects of the claim request: -// 1. the claim request's swap factory and forwarder contract bytecode matches ours +// 1. the claim request's swap creator and forwarder contract bytecode matches ours // 2. the swap is for ETH and not an ERC20 token // 3. the swap value is strictly greater than the relayer fee // 4. TODO: Validate that the swap exists and is in a claimable state? @@ -41,19 +41,19 @@ func validateClaimValues( ctx context.Context, request *message.RelayClaimRequest, ec *ethclient.Client, - ourSwapFactoryAddr ethcommon.Address, + ourSwapCreatorAddr ethcommon.Address, ) error { isTakerRelay := request.OfferID != nil - // Validate the deployed SwapFactory contract, if it is not at the same address - // as our own. The CheckSwapFactoryContractCode method validates both the - // SwapFactory bytecode and the Forwarder bytecode. - if request.SwapFactoryAddress != ourSwapFactoryAddr { + // Validate the deployed SwapCreator contract, if it is not at the same address + // as our own. The CheckSwapCreatorContractCode method validates both the + // SwapCreator bytecode and the Forwarder bytecode. + if request.SwapCreatorAddr != ourSwapCreatorAddr { if isTakerRelay { - return fmt.Errorf("taker claim swap factory mismatch found=%s expected=%s", - request.SwapFactoryAddress, ourSwapFactoryAddr) + return fmt.Errorf("taker claim swap creator mismatch found=%s expected=%s", + request.SwapCreatorAddr, ourSwapCreatorAddr) } - _, err := contracts.CheckSwapFactoryContractCode(ctx, ec, request.SwapFactoryAddress) + _, err := contracts.CheckSwapCreatorContractCode(ctx, ec, request.SwapCreatorAddr) if err != nil { return err } @@ -85,12 +85,12 @@ func validateClaimSignature( From: ethcommon.Address{0xFF}, // can be any value but zero, which will validate all signatures } - swapFactory, err := contracts.NewSwapFactory(request.SwapFactoryAddress, ec) + swapCreator, err := contracts.NewSwapCreator(request.SwapCreatorAddr, ec) if err != nil { return err } - forwarderAddr, err := swapFactory.TrustedForwarder(&bind.CallOpts{Context: ctx}) + forwarderAddr, err := swapCreator.TrustedForwarder(&bind.CallOpts{Context: ctx}) if err != nil { return err } @@ -109,7 +109,7 @@ func validateClaimSignature( forwarderRequest, err := createForwarderRequest( nonce, - request.SwapFactoryAddress, + request.SwapCreatorAddr, request.Swap, secret, ) diff --git a/relayer/validate_test.go b/relayer/validate_test.go index 08ab633e..1304fefa 100644 --- a/relayer/validate_test.go +++ b/relayer/validate_test.go @@ -24,7 +24,7 @@ func TestValidateRelayerFee(t *testing.T) { ctx := context.Background() ec, _ := tests.NewEthClient(t) key := tests.GetTakerTestKey(t) - swapFactoryAddr, _ := deployContracts(t, ec, key) + swapCreatorAddr, _ := deployContracts(t, ec, key) type testCase struct { description string @@ -50,7 +50,7 @@ func TestValidateRelayerFee(t *testing.T) { } for _, tc := range testCases { - swap := &contracts.SwapFactorySwap{ + swap := &contracts.SwapCreatorSwap{ Owner: ethcommon.Address{}, Claimer: ethcommon.Address{}, PubKeyClaim: [32]byte{}, @@ -63,12 +63,12 @@ func TestValidateRelayerFee(t *testing.T) { } request := &message.RelayClaimRequest{ - SwapFactoryAddress: swapFactoryAddr, - Swap: swap, - Secret: make([]byte, 32), + SwapCreatorAddr: swapCreatorAddr, + Swap: swap, + Secret: make([]byte, 32), } - err := validateClaimValues(ctx, request, ec, swapFactoryAddr) + err := validateClaimValues(ctx, request, ec, swapCreatorAddr) if tc.expectErr != "" { require.ErrorContains(t, err, tc.expectErr, tc.description) } else { @@ -82,18 +82,18 @@ func TestValidateRelayerFee(t *testing.T) { // the taker who is being asked to claim. func Test_validateClaimValues_takerClaim_contractAddressNotEqualFail(t *testing.T) { offerID := types.Hash{0x1} // non-nil offer ID passed to indicate taker claim - swapFactoryAddrInClaim := ethcommon.Address{0x1} // address in claim - swapFactoryAddrOurs := ethcommon.Address{0x2} // passed to validateClaimValues + swapCreatorAddrInClaim := ethcommon.Address{0x1} // address in claim + swapCreatorAddrOurs := ethcommon.Address{0x2} // passed to validateClaimValues request := &message.RelayClaimRequest{ - OfferID: &offerID, - SwapFactoryAddress: swapFactoryAddrInClaim, - Secret: make([]byte, 32), - Swap: new(contracts.SwapFactorySwap), // test fails before we validate this + OfferID: &offerID, + SwapCreatorAddr: swapCreatorAddrInClaim, + Secret: make([]byte, 32), + Swap: new(contracts.SwapCreatorSwap), // test fails before we validate this } - err := validateClaimValues(context.Background(), request, nil, swapFactoryAddrOurs) - require.ErrorContains(t, err, "taker claim swap factory mismatch") + err := validateClaimValues(context.Background(), request, nil, swapCreatorAddrOurs) + require.ErrorContains(t, err, "taker claim swap creator mismatch") } // When validating a claim made to a DHT advertised relayer, the contacts can have @@ -102,17 +102,17 @@ func Test_validateClaimValues_takerClaim_contractAddressNotEqualFail(t *testing. func Test_validateClaimValues_dhtClaim_contractAddressNotEqual(t *testing.T) { ec, _ := tests.NewEthClient(t) key := tests.GetTakerTestKey(t) - swapFactoryAddr, forwarderAddr := deployContracts(t, ec, key) + swapCreatorAddr, forwarderAddr := deployContracts(t, ec, key) request := &message.RelayClaimRequest{ - OfferID: nil, // DHT relayer claim - SwapFactoryAddress: forwarderAddr, // not a valid swap factory contract - Secret: make([]byte, 32), - Swap: new(contracts.SwapFactorySwap), // test fails before we validate this + OfferID: nil, // DHT relayer claim + SwapCreatorAddr: forwarderAddr, // not a valid swap creator contract + Secret: make([]byte, 32), + Swap: new(contracts.SwapCreatorSwap), // test fails before we validate this } - err := validateClaimValues(context.Background(), request, ec, swapFactoryAddr) - require.ErrorContains(t, err, "contract address does not contain correct SwapFactory code") + err := validateClaimValues(context.Background(), request, ec, swapCreatorAddr) + require.ErrorContains(t, err, "contract address does not contain correct SwapCreator code") } func Test_validateSignature(t *testing.T) { @@ -121,10 +121,10 @@ func Test_validateSignature(t *testing.T) { claimer := crypto.PubkeyToAddress(*ethKey.Public().(*ecdsa.PublicKey)) ec, _ := tests.NewEthClient(t) secret := [32]byte{0x1} - swapFactoryAddr, forwarderAddr := deployContracts(t, ec, ethKey) + swapCreatorAddr, forwarderAddr := deployContracts(t, ec, ethKey) swap := createTestSwap(claimer) - req, err := CreateRelayClaimRequest(ctx, ethKey, ec, swapFactoryAddr, forwarderAddr, swap, &secret) + req, err := CreateRelayClaimRequest(ctx, ethKey, ec, swapCreatorAddr, forwarderAddr, swap, &secret) require.NoError(t, err) // success path @@ -143,19 +143,19 @@ func Test_validateClaimRequest(t *testing.T) { claimer := crypto.PubkeyToAddress(*ethKey.Public().(*ecdsa.PublicKey)) ec, _ := tests.NewEthClient(t) secret := [32]byte{0x1} - swapFactoryAddr, forwarderAddr := deployContracts(t, ec, ethKey) + swapCreatorAddr, forwarderAddr := deployContracts(t, ec, ethKey) swap := createTestSwap(claimer) - req, err := CreateRelayClaimRequest(ctx, ethKey, ec, swapFactoryAddr, forwarderAddr, swap, &secret) + req, err := CreateRelayClaimRequest(ctx, ethKey, ec, swapCreatorAddr, forwarderAddr, swap, &secret) require.NoError(t, err) // success path - err = validateClaimRequest(ctx, req, ec, swapFactoryAddr) + err = validateClaimRequest(ctx, req, ec, swapCreatorAddr) require.NoError(t, err) // test failure path by passing a non-eth asset asset := ethcommon.Address{0x1} req.Swap.Asset = asset - err = validateClaimRequest(ctx, req, ec, swapFactoryAddr) + err = validateClaimRequest(ctx, req, ec, swapCreatorAddr) require.ErrorContains(t, err, fmt.Sprintf("relaying for ETH Asset %s is not supported", types.EthAsset(asset))) } diff --git a/rpc/server.go b/rpc/server.go index 0ab5938e..9decbf55 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -120,6 +120,10 @@ func (s *Server) WsURL() string { // Start starts the JSON-RPC and Websocket server. func (s *Server) Start() error { + if s.ctx.Err() != nil { + return s.ctx.Err() + } + log.Infof("Starting RPC server on %s", s.HttpURL()) log.Infof("Starting websockets server on %s", s.WsURL()) diff --git a/scripts/generate-bindings.sh b/scripts/generate-bindings.sh index b4a85cd3..2916b416 100755 --- a/scripts/generate-bindings.sh +++ b/scripts/generate-bindings.sh @@ -27,7 +27,7 @@ compile-contract() { --out "ethereum/${go_file_name}.go" } -compile-contract SwapFactory SwapFactory swap_factory +compile-contract SwapCreator SwapCreator swap_creator compile-contract ERC20Mock ERC20Mock erc20_mock compile-contract IERC20Metadata IERC20 ierc20 compile-contract AggregatorV3Interface AggregatorV3Interface aggregator_v3_interface diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index 96925245..e1eae365 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -106,9 +106,9 @@ start-daemons() { exit 1 fi - SWAP_FACTORY_ADDR="$(jq -r .swapFactory "${CONTRACT_ADDR_FILE}")" - FORWARDER_ADDR="$(jq -r .forwarder "${CONTRACT_ADDR_FILE}")" - if [[ -z "${SWAP_FACTORY_ADDR}" ]] || [[ -z "${FORWARDER_ADDR}" ]]; then + SWAP_CREATOR_ADDR="$(jq -r .swapCreatorAddr "${CONTRACT_ADDR_FILE}")" + FORWARDER_ADDR="$(jq -r .forwarderAddr "${CONTRACT_ADDR_FILE}")" + if [[ -z "${SWAP_CREATOR_ADDR}" ]] || [[ -z "${FORWARDER_ADDR}" ]]; then echo "Failed to get Alice's deployed contract addresses" stop-daemons exit 1 @@ -120,14 +120,14 @@ start-daemons() { "--data-dir=${SWAP_TEST_DATA_DIR}/bob" \ --libp2p-port=9944 \ "--bootnodes=${ALICE_MULTIADDR}" \ - "--contract-address=${SWAP_FACTORY_ADDR}" + "--contract-address=${SWAP_CREATOR_ADDR}" start-swapd charlie "${CHARLIE_RPC_PORT}" \ "--log-level=${LOG_LEVEL}" \ --data-dir "${SWAP_TEST_DATA_DIR}/charlie" \ --libp2p-port=9955 \ "--bootnodes=${ALICE_MULTIADDR}" \ - "--contract-address=${SWAP_FACTORY_ADDR}" \ + "--contract-address=${SWAP_CREATOR_ADDR}" \ "--relayer" } @@ -143,7 +143,7 @@ stop-daemons() { echo "running integration tests..." create-eth-keys start-daemons -TESTS=integration CONTRACT_ADDR=${SWAP_FACTORY_ADDR} go test ./tests -v -count=1 -timeout=30m +TESTS=integration CONTRACT_ADDR=${SWAP_CREATOR_ADDR} go test ./tests -v -count=1 -timeout=30m OK="${?}" KEEP_TEST_DATA="${OK}" stop-daemons