File tree Expand file tree Collapse file tree 1 file changed +21
-12
lines changed Expand file tree Collapse file tree 1 file changed +21
-12
lines changed Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import type { ERC20Token , Token } from ' ../../libs/token/types'
3
3
import getConnectedWallet from ' ../../libs/utils/getConnectedWallet'
4
+ import { errorToast , successToast } from ' ../NotificationToast'
5
+ import notifyError from ' ../utils/notifyError'
4
6
5
7
export let value: Token
6
8
7
9
async function addToken() {
8
10
const { address, symbol, decimals, logoURI } = value as ERC20Token
9
11
10
- const wallet = await getConnectedWallet ()
12
+ try {
13
+ const wallet = await getConnectedWallet ()
11
14
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
+ })
21
24
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.' )
24
33
}
25
34
}
26
35
</script >
You can’t perform that action at this time.
0 commit comments