1
1
import { useAccount } from "@/hooks/account" ;
2
2
import { useConnection } from "@/hooks/context" ;
3
- import { useToken } from "@/hooks/token" ;
4
3
import {
5
4
LayoutContainer ,
6
5
LayoutContent ,
@@ -18,14 +17,15 @@ import { useNavigate, useParams } from "react-router-dom";
18
17
import { Call , uint256 } from "starknet" ;
19
18
import { SendRecipient } from "@/components/modules/recipient" ;
20
19
import { SendAmount } from "./amount" ;
20
+ import { useToken } from "@cartridge/utils" ;
21
21
22
22
export function SendToken ( ) {
23
23
const { address : tokenAddress } = useParams < { address : string } > ( ) ;
24
24
const { address } = useAccount ( ) ;
25
25
const { parent } = useConnection ( ) ;
26
26
const [ validated , setValidated ] = useState ( false ) ;
27
27
const [ warning , setWarning ] = useState < string > ( ) ;
28
- const token = useToken ( { tokenAddress : tokenAddress ! } ) ;
28
+ const { token } = useToken ( tokenAddress ! ) ;
29
29
const navigate = useNavigate ( ) ;
30
30
31
31
const [ to , setTo ] = useState ( "" ) ;
@@ -44,15 +44,13 @@ export function SendToken() {
44
44
45
45
const onSubmit = useCallback (
46
46
async ( to : string , amount : number ) => {
47
- if ( ! token ) return ;
48
-
49
47
const formattedAmount = uint256 . bnToUint256 (
50
- BigInt ( amount * 10 ** token . meta . decimals ) ,
48
+ BigInt ( amount * 10 ** token . decimals ) ,
51
49
) ;
52
50
53
51
const calls : Call [ ] = [
54
52
{
55
- contractAddress : token . meta . address ,
53
+ contractAddress : token . address ,
56
54
entrypoint : "transfer" ,
57
55
calldata : [ to , formattedAmount ] ,
58
56
} ,
@@ -70,13 +68,13 @@ export function SendToken() {
70
68
return (
71
69
< LayoutContainer >
72
70
< LayoutHeader
73
- title = { `Send ${ token . meta . symbol } ` }
71
+ title = { `Send ${ token . symbol } ` }
74
72
description = { < CopyAddress address = { address } size = "sm" /> }
75
73
icon = {
76
74
< div className = "rounded-full size-11 bg-foreground-100 flex items-center justify-center" >
77
75
< img
78
76
className = "w-10 h-10"
79
- src = { token . meta . logoUrl ?? "/public/placeholder.svg" }
77
+ src = { token . icon ?? "/public/placeholder.svg" }
80
78
/>
81
79
</ div >
82
80
}
0 commit comments