@@ -5,12 +5,14 @@ import {CustomElement, InjectAppend, InjectionMode} from '../injectors';
55import { FloatElement } from '../custom' ;
66import { fetchListingTime } from './helpers' ;
77import '../common/ui/steam-button' ;
8+ import { ProveTradesToken } from '../../bridge/handlers/prove_trades_token' ;
9+ import { ClientSend } from '../../bridge/client' ;
810
911@CustomElement ( )
1012@InjectAppend ( '.tradehistoryrow .tradehistory_content' , InjectionMode . CONTINUOUS )
1113export class TradeProof extends FloatElement {
1214 @state ( )
13- private proofNumber : number | undefined ;
15+ private message : string | undefined ;
1416
1517 @state ( )
1618 private isProcessing = false ;
@@ -20,12 +22,12 @@ export class TradeProof extends FloatElement {
2022 }
2123
2224 render ( ) {
23- return this . proofNumber
24- ? html ` < span > Proof: ${ this . proofNumber } </ span > `
25+ return this . message
26+ ? html ` < span > ${ this . message } </ span > `
2527 : html `
2628 < csfloat-steam-button
2729 @click ="${ this . onClick } "
28- .text ="${ this . isProcessing ? 'Computing Proof ...' : 'CSFloat Proof ' } "
30+ .text ="${ this . isProcessing ? 'Proving ...' : 'Prove Trade on CSFloat ' } "
2931 >
3032 </ csfloat-steam-button >
3133 ` ;
@@ -34,14 +36,17 @@ export class TradeProof extends FloatElement {
3436 private async onClick ( ) {
3537 this . isProcessing = true ;
3638
37- const index = $J ( '.tradehistoryrow' ) . index ( $J ( this ) . parent ( ) . parent ( ) ) ;
39+ const token = document
40+ . getElementById ( 'application_config' )
41+ ?. getAttribute ( 'data-loyalty_webapi_token' )
42+ ?. replace ( '"' , '' )
43+ . replace ( '"' , '' ) ;
44+
3845 try {
39- this . proofNumber = await fetchListingTime ( index ) ;
40- } catch ( e ) {
41- alert (
42- "Failed to parse time, make sure you're on an english version of the page by appending ?l=english to the url"
43- ) ;
46+ const resp = await ClientSend ( ProveTradesToken , { token} ) ;
47+ this . message = resp . message ;
48+ } catch ( e : any ) {
49+ alert ( e . toString ( ) ) ;
4450 }
45- this . isProcessing = false ;
4651 }
4752}
0 commit comments