8000 Format code · jscriptcoder/DEX-Aggregator@3a7467c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a7467c

Browse files
committed
Format code
1 parent 12a4794 commit 3a7467c

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/components/AddToken/AddToken.svelte

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
<script lang="ts">
22
import type { ERC20Token, Token } from '../../libs/token/types'
33
import getConnectedWallet from '../../libs/utils/getConnectedWallet'
4+
import { errorToast, successToast } from '../NotificationToast'
5+
import notifyError from '../utils/notifyError'
46
57
export let value: Token
68
79
async function addToken() {
810
const { address, symbol, decimals, logoURI } = value as ERC20Token
911
10-
const wallet = await getConnectedWallet()
12+
try {
13+
const wallet = await getConnectedWallet()
1114
12-
const success = await wallet.watchAsset({
13-
type: 'ERC20',
14-
options: {
15-
address,
16-
symbol,
17-
decimals,
18-
image: logoURI,
19-
},
20-
})
15+
const success = await wallet.watchAsset({
16+
type: 'ERC20',
17+
options: {
18+
address,
19+
symbol,
20+
decimals,
21+
image: logoURI,
22+
},
23+
})
2124
22-
if (!success) {
23-
// TODO: inform user that the token was not added
25+
if (success) {
26+
successToast('Token added to your wallet.')
27+
} else {
28+
errorToast('Failed to add token to your wallet.')
29+
}
30+
} catch (err) {
31+
console.error(err)
32+
notifyError(err, 'Failed to add token to your wallet.')
2433
}
2534
}
2635
</script>

0 commit comments

Comments
 (0)
0