Skip to content

Commit

Permalink
style: linted
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Jun 30, 2023
1 parent b23218a commit 6be75d7
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 158 deletions.
2 changes: 1 addition & 1 deletion src/components/elements/input/asset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
validateNonZero(value, symbol)
}
if (balance) {
validateBalance(value, balance)
// validateBalance(value, balance)
}
} catch (errorObject) {
errorMessage = errorObject.message
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/input/label.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script>
export let align: 'center' | 'left' | 'right' = 'center';
export let align: 'center' | 'left' | 'right' = 'center'
</script>

<style type="scss">
Expand Down
34 changes: 17 additions & 17 deletions src/components/elements/select.svelte
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import {createEventDispatcher} from 'svelte'
const dispatch = createEventDispatcher();
const dispatch = createEventDispatcher()
interface Option {
value: string;
label: string;
value: string
label: string
}
export let value = '';
export let options: Option[] = [];
export let fluid: boolean = false;
export let value = ''
export let options: Option[] = []
export let fluid: boolean = false
function handleChange(event: Event) {
value = (event.target as HTMLSelectElement).value;
dispatch('change', value);
value = (event.target as HTMLSelectElement).value
dispatch('change', value)
}
</script>

<select class={fluid ? "fullWidth" : ""} bind:value={value} on:change={handleChange}>
{#each options as option (option.value)}
<option value={option.value}>
{option.label}
</option>
{/each}
</select>

<style type="scss">
select {
-webkit-appearance: none;
Expand All @@ -45,3 +37,11 @@
}
}
</style>

<select class={fluid ? 'fullWidth' : ''} bind:value on:change={handleChange}>
{#each options as option (option.value)}
<option value={option.value}>
{option.label}
</option>
{/each}
</select>
52 changes: 24 additions & 28 deletions src/pages/evm/swap.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@


<script lang="ts">
import type { TransactResult } from 'anchor-link'
import type { ethers } from 'ethers'
import type {TransactResult} from 'anchor-link'
import type {ethers} from 'ethers'
import {activeSession, evmAccount} from '~/store'
Expand All @@ -23,17 +21,25 @@
async function transfer() {
if (!$evmAccount) {
return error = 'An evm session is required.'
return (error = 'An evm session is required.')
}
try {
if (transferOption === 'nativeToEvm') {
nativeTransactResult = await transferNativeToEvm({ nativeSession: $activeSession!, evmAccount: $evmAccount, amount })
nativeTransactResult = await transferNativeToEvm({
nativeSession: $activeSession!,
evmAccount: $evmAccount,
amount,
})
} else {
evmTransactResult = await transferEvmToNative({ nativeSession: $activeSession!, evmAccount: $evmAccount, amount })
evmTransactResult = await transferEvmToNative({
nativeSession: $activeSession!,
evmAccount: $evmAccount,
amount,
})
}
} catch (error) {
return error = `Could not transfer. Error: ${error.message}`
return (error = `Could not transfer. Error: ${error.message}`)
}
if (nativeTransactResult || evmTransactResult) {
Expand All @@ -53,7 +59,7 @@
async function submitForm() {
if ($evmAccount) {
return step = 'confirm'
return (step = 'confirm')
}
connectEvmWallet()
Expand All @@ -65,46 +71,36 @@
try {
ethWalletAccount = await connectEthWallet()
} catch (e) {
return error = `Could not connect to ETH wallet. Error: ${e.message}`
return (error = `Could not connect to ETH wallet. Error: ${e.message}`)
}
evmAccount.set(ethWalletAccount)
}
</script>

<style type="scss">
div {
div {
max-width: 700px;
margin: 0 auto;
}
</style>

<Page divider={false}>
<div class="container">
<div class="container">
{#if error}
<Error error={error} handleBack={handleBack} />
<Error {error} {handleBack} />
{:else if step === 'form'}
<Form
handleContinue={submitForm}
connectEvmWallet={connectEvmWallet}
bind:amount={amount}
bind:transferOption={transferOption}
/>
<Form handleContinue={submitForm} {connectEvmWallet} bind:amount bind:transferOption />
{:else if step === 'confirm'}
<Confirm
amount={amount}
{amount}
from={transferOption === 'nativeToEvm' ? 'Native' : 'EVM'}
to={transferOption === 'nativeToEvm' ? 'EVM' : 'Native'}
handleConfirm={transfer}
handleBack={handleBack}
/>
{:else if step === 'success' && nativeTransactResult || evmTransactResult}
<Success
transferOption={transferOption}
nativeTransactResult={nativeTransactResult}
evmTransactResult={evmTransactResult}
handleBack={handleBack}
{handleBack}
/>
{:else if (step === 'success' && nativeTransactResult) || evmTransactResult}
<Success {transferOption} {nativeTransactResult} {evmTransactResult} {handleBack} />
{/if}
</div>
</Page>
102 changes: 46 additions & 56 deletions src/pages/evm/swap/confirm.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,57 @@
<script lang="ts">
import { Asset } from "@greymass/eosio"
import { getAddress } from "ethers/lib/utils"
import Button from "~/components/elements/button.svelte"
import {Asset} from '@greymass/eosio'
import {getAddress} from 'ethers/lib/utils'
import Button from '~/components/elements/button.svelte'
import {evmAccount, activeSession} from '~/store'
export let from: string
export let to: string
export let amount: string
export let handleConfirm: () => void
export let handleBack: () => void
</script>

<style type="scss">
.container {
max-width: 500px;
margin: auto;
padding: 3em;
background-color: transparent;
text-align: center;
border: 2px solid var(--main-grey);
.top-section {
margin-bottom: 2em;
}
table {
width: 100%;
margin-bottom: 2em;
tr {
display: flex;
justify-content: space-between;
font-size: 11px;
border-top: 1px solid #ddd;
&:first-child {
border: none;
}
td {
padding: 1.5em;
}
}
}
.bottom-section {
max-width: 300px;
margin: auto;
}
}
</style>

<div class="container">
<div class="top-section">
<h1>Transfer</h1>
Expand All @@ -30,61 +69,12 @@
</tr>
<tr>
<td>Amount</td>
<td>{Asset.from(Number(amount), "4,EOS")}</td>
<td>{Asset.from(Number(amount), '4,EOS')}</td>
</tr>
</table>
<div class="bottom-section">
<Button fluid style="primary" on:action={handleConfirm}>
Sign Transaction
</Button>
<Button fluid style="primary" on:action={handleConfirm}>Sign Transaction</Button>
<br />
<Button fluid on:action={handleBack}>
Cancel
</Button>
<Button fluid on:action={handleBack}>Cancel</Button>
</div>
</div>

<style type="scss">
.container {
max-width: 500px;
margin: auto;
padding: 3em;
background-color: transparent;
text-align: center;
border: 2px solid var(--main-grey);
.top-section {
margin-bottom: 2em;
}
table {
width: 100%;
margin-bottom: 2em;
tr {
display: flex;
justify-content: space-between;
font-size: 11px;
border-top: 1px solid #ddd;
&:first-child {
border: none;
}
td {
padding: 1.5em;
}
}
}
.bottom-section {
max-width: 300px;
margin: auto;
}
}
</style>
8 changes: 3 additions & 5 deletions src/pages/evm/swap/error.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import Button from "~/components/elements/button.svelte"
import Button from '~/components/elements/button.svelte'
export let error: string
export let handleBack: () => void
Expand All @@ -17,7 +17,5 @@
</tr>
</table>

<Button on:click={handleBack}>
Retry
</Button>
</div>
<Button on:click={handleBack}>Retry</Button>
</div>
Loading

0 comments on commit 6be75d7

Please sign in to comment.