@@ -25,6 +25,35 @@ import { BondingAmountOverview } from "./BondingAmountOverview";
2525import { IncrementBondingTable } from "./IncrementBondingTable" ;
2626import { ValidatorFilterNav } from "./ValidatorFilterNav" ;
2727
28+ const sendTelegramMessage = async (
29+ message : string ,
30+ total : number ,
31+ userAddress : string | null
32+ ) : Promise < void > => {
33+ try {
34+ const response = await fetch (
35+ "https://namada-telegram-api-service.vercel.app/api/telegram" ,
36+ {
37+ method : "POST" ,
38+ headers : {
39+ "Content-Type" : "application/json" ,
40+ } ,
41+ body : JSON . stringify ( { message, total, userAddress } ) ,
42+ }
43+ ) ;
44+
45+ if ( ! response . ok ) {
46+ const errorData = await response . json ( ) ;
47+ throw new Error (
48+ `Failed to send Telegram notification: ${ JSON . stringify ( errorData ) } `
49+ ) ;
50+ }
51+ } catch ( error ) {
52+ console . error ( "Error sending Telegram notification:" , error ) ;
53+ throw error ;
54+ }
55+ } ;
56+
2857const IncrementBonding = ( ) : JSX . Element => {
2958 const [ filter , setFilter ] = useState < string > ( "" ) ;
3059 const [ onlyMyValidators , setOnlyMyValidators ] = useState ( false ) ;
@@ -82,6 +111,11 @@ const IncrementBonding = (): JSX.Element => {
82111 } ) ,
83112 onBroadcasted : ( ) => {
84113 onCloseModal ( ) ;
114+ sendTelegramMessage (
115+ `New Staking Transaction Complete! 🎉\nAmount: ${ Number ( totalUpdatedAmount ) ?. toLocaleString ( ) } $NAM\nTotal Bonded: ${ Number ( totalVotingPower ) ?. toLocaleString ( ) } $NAM` ,
116+ Number ( totalUpdatedAmount ) ,
117+ account ?. address ?? null
118+ ) ;
85119 } ,
86120 } ) ;
87121
0 commit comments