fixes for stagenet swap and UI (#137)

This commit is contained in:
noot
2022-06-23 16:15:20 -04:00
committed by GitHub
parent 7ae4dcbbbe
commit 68f17665af
6 changed files with 19 additions and 11 deletions

View File

@@ -160,7 +160,7 @@ func NewBackend(cfg *Config) (Backend, error) {
} else {
log.Debugf("instantiated backend with external sender")
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 {
return nil, err
}

View File

@@ -22,7 +22,7 @@ var (
errTransactionTimeout = errors.New("timed out waiting for transaction to be signed")
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
@@ -52,13 +52,18 @@ type ExternalSender struct {
}
// 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) {
abi, err := swapfactory.SwapFactoryMetaData.GetAbi()
if err != nil {
return nil, err
}
switch env {
case common.Mainnet, common.Stagenet:
transactionTimeout = time.Hour
}
return &ExternalSender{
ctx: ctx,
ec: ec,

View File

@@ -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())
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
log.Infof("waiting until time %s to refund", s.t1)
<-time.After(untilT1)

View File

@@ -194,8 +194,7 @@ func (s *wsServer) handleSigner(ctx context.Context, conn *websocket.Conn, offer
for {
select {
// TODO: check if conn closes or swap exited
case <-time.After(time.Minute): // TODO: vary timeout based on env
_ = conn.Close()
case <-time.After(time.Hour): // TODO: vary timeout based on env
return fmt.Errorf("signer timed out")
case <-ctx.Done():
return nil

View File

@@ -2,14 +2,14 @@
bash ./scripts/install-monero-linux.sh
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
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..."
./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)
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'
# 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'

View File

@@ -22,6 +22,10 @@
<LayoutGrid>
<Spacer />
<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>
<Cell spanDevices={{ desktop: 2, tablet: 4, phone: 12 }}>
<StatCard title="Peers" content={$peers.length.toString()} />
@@ -34,7 +38,7 @@
</Cell>
<Cell class="metamask">
{#if $currentAccount}
Account: {$currentAccount}
<StatCard title="Account" content={$currentAccount} />
{:else}
<Button on:click={connectMetamask}>Connect Metamask</Button>
{/if}