mirror of
https://github.com/AthanorLabs/atomic-swap.git
synced 2026-01-09 22:28:04 -05:00
fixes for stagenet swap and UI (#137)
This commit is contained in:
@@ -160,7 +160,7 @@ func NewBackend(cfg *Config) (Backend, error) {
|
|||||||
} else {
|
} else {
|
||||||
log.Debugf("instantiated backend with external sender")
|
log.Debugf("instantiated backend with external sender")
|
||||||
var err error
|
var err error
|
||||||
sender, err = txsender.NewExternalSender(cfg.Ctx, cfg.EthereumClient, cfg.SwapContractAddress)
|
sender, err = txsender.NewExternalSender(cfg.Ctx, cfg.Environment, cfg.EthereumClient, cfg.SwapContractAddress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ var (
|
|||||||
errTransactionTimeout = errors.New("timed out waiting for transaction to be signed")
|
errTransactionTimeout = errors.New("timed out waiting for transaction to be signed")
|
||||||
errNoSwapWithID = errors.New("no swap with given id")
|
errNoSwapWithID = errors.New("no swap with given id")
|
||||||
|
|
||||||
transactionTimeout = time.Minute * 2 // arbitrary, TODO vary this based on env
|
transactionTimeout = time.Minute * 2 // amount of time user has to sign message
|
||||||
)
|
)
|
||||||
|
|
||||||
// Transaction represents a transaction to be signed by the front-end
|
// Transaction represents a transaction to be signed by the front-end
|
||||||
@@ -52,13 +52,18 @@ type ExternalSender struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewExternalSender returns a new ExternalSender
|
// NewExternalSender returns a new ExternalSender
|
||||||
func NewExternalSender(ctx context.Context, ec *ethclient.Client,
|
func NewExternalSender(ctx context.Context, env common.Environment, ec *ethclient.Client,
|
||||||
contractAddr ethcommon.Address) (*ExternalSender, error) {
|
contractAddr ethcommon.Address) (*ExternalSender, error) {
|
||||||
abi, err := swapfactory.SwapFactoryMetaData.GetAbi()
|
abi, err := swapfactory.SwapFactoryMetaData.GetAbi()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch env {
|
||||||
|
case common.Mainnet, common.Stagenet:
|
||||||
|
transactionTimeout = time.Hour
|
||||||
|
}
|
||||||
|
|
||||||
return &ExternalSender{
|
return &ExternalSender{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
ec: ec,
|
ec: ec,
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ func (s *swapState) tryRefund() (ethcommon.Hash, error) {
|
|||||||
|
|
||||||
log.Debugf("tryRefund isReady=%v untilT0=%vs untilT1=%vs", isReady, untilT0.Seconds(), untilT1.Seconds())
|
log.Debugf("tryRefund isReady=%v untilT0=%vs untilT1=%vs", isReady, untilT0.Seconds(), untilT1.Seconds())
|
||||||
|
|
||||||
if (untilT0 > 0 || isReady) && untilT1 > 0 {
|
if (untilT0 > 0 && isReady) && untilT1 > 0 {
|
||||||
// we've passed t0 but aren't past t1 yet, so we need to wait until t1
|
// we've passed t0 but aren't past t1 yet, so we need to wait until t1
|
||||||
log.Infof("waiting until time %s to refund", s.t1)
|
log.Infof("waiting until time %s to refund", s.t1)
|
||||||
<-time.After(untilT1)
|
<-time.After(untilT1)
|
||||||
|
|||||||
@@ -194,8 +194,7 @@ func (s *wsServer) handleSigner(ctx context.Context, conn *websocket.Conn, offer
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
// TODO: check if conn closes or swap exited
|
// TODO: check if conn closes or swap exited
|
||||||
case <-time.After(time.Minute): // TODO: vary timeout based on env
|
case <-time.After(time.Hour): // TODO: vary timeout based on env
|
||||||
_ = conn.Close()
|
|
||||||
return fmt.Errorf("signer timed out")
|
return fmt.Errorf("signer timed out")
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
bash ./scripts/install-monero-linux.sh
|
bash ./scripts/install-monero-linux.sh
|
||||||
echo "starting monerod..."
|
echo "starting monerod..."
|
||||||
./monero-x86_64-linux-gnu-v0.17.3.2/monerod --detach --stagenet --rpc-bind-port 18081 &
|
nohup ./monero-x86_64-linux-gnu-v0.17.3.2/monerod --detach --stagenet --rpc-bind-port 18081 &
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
echo "starting monero-wallet-rpc on port 18083..."
|
echo "starting monero-wallet-rpc on port 18083..."
|
||||||
./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys --stagenet --trusted-daemon
|
nohup ./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18083 --disable-rpc-login --wallet-dir ./bob-test-keys --stagenet --trusted-daemon
|
||||||
|
|
||||||
echo "starting monero-wallet-rpc on port 18084..."
|
echo "starting monero-wallet-rpc on port 18084..."
|
||||||
./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys --stagenet --trusted-daemon
|
nohup ./monero-x86_64-linux-gnu-v0.17.3.2/monero-wallet-rpc --rpc-bind-port 18084 --disable-rpc-login --wallet-dir ./alice-test-keys --stagenet --trusted-daemon
|
||||||
|
|
||||||
# open Bob's wallet (must have funds)
|
# open Bob's wallet (must have funds)
|
||||||
sleep 5
|
sleep 5
|
||||||
@@ -19,4 +19,4 @@ curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"ope
|
|||||||
curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":get_accounts","params":{}}' -H 'Content-Type: application/json'
|
curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":get_accounts","params":{}}' -H 'Content-Type: application/json'
|
||||||
|
|
||||||
# start mining (if synced)
|
# start mining (if synced)
|
||||||
# curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":start_mining","params":{"threads_count":1,"do_background_mining":true,"ignore_battery":false}}' -H 'Content-Type: application/json'
|
# curl http://localhost:18083/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":start_mining","params":{"threads_count":1,"do_background_mining":true,"ignore_battery":false}}' -H 'Content-Type: application/json'
|
||||||
|
|||||||
@@ -22,6 +22,10 @@
|
|||||||
<LayoutGrid>
|
<LayoutGrid>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Cell spanDevices={{ desktop: 8, tablet: 6, phone: 12 }}>
|
<Cell spanDevices={{ desktop: 8, tablet: 6, phone: 12 }}>
|
||||||
|
<Cell spanDevices={{ desktop: 8, tablet: 6, phone: 12 }}>
|
||||||
|
<StatCard title="ETH-XMR Atomic Swap" content="Please ensure your Metamask is unlocked and set to the correct network before swapping. DO NOT REFRESH THE PAGE WHILE A SWAP IS HAPPENING!" />
|
||||||
|
</Cell>
|
||||||
|
<br />
|
||||||
<InnerGrid>
|
<InnerGrid>
|
||||||
<Cell spanDevices={{ desktop: 2, tablet: 4, phone: 12 }}>
|
<Cell spanDevices={{ desktop: 2, tablet: 4, phone: 12 }}>
|
||||||
<StatCard title="Peers" content={$peers.length.toString()} />
|
<StatCard title="Peers" content={$peers.length.toString()} />
|
||||||
@@ -34,7 +38,7 @@
|
|||||||
</Cell>
|
</Cell>
|
||||||
<Cell class="metamask">
|
<Cell class="metamask">
|
||||||
{#if $currentAccount}
|
{#if $currentAccount}
|
||||||
Account: {$currentAccount}
|
<StatCard title="Account" content={$currentAccount} />
|
||||||
{:else}
|
{:else}
|
||||||
<Button on:click={connectMetamask}>Connect Metamask</Button>
|
<Button on:click={connectMetamask}>Connect Metamask</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user