1
- import { IUser , IChallenge , TreeNode } from "../types" ;
2
1
import chalk from "chalk" ;
3
- import { calculatePoints } from "./helpers" ;
2
+ import { IChallenge , IUser , TreeNode } from "../types" ;
3
+ import { calculatePoints , calculateTotalGasUsed } from "./helpers" ;
4
4
5
5
export class ProgressView {
6
6
constructor (
@@ -18,6 +18,7 @@ export class ProgressView {
18
18
. filter ( c => c . challenge ) ;
19
19
20
20
const points = calculatePoints ( completedChallenges ) ;
21
+ const totalGasUsed = calculateTotalGasUsed ( completedChallenges ) ;
21
22
const completionRate = ( completedChallenges . length / this . challenges . filter ( c => c . enabled ) . length * 100 ) . toFixed ( 1 ) ;
22
23
23
24
// Create completed challenges node with all completed challenges as children
@@ -44,17 +45,17 @@ export class ProgressView {
44
45
label : "Progress" ,
45
46
name : "stats" ,
46
47
children : [ ...challengeNodes ] ,
47
- message : this . buildStatsMessage ( points , completionRate )
48
+ message : this . buildStatsMessage ( points , completionRate , totalGasUsed )
48
49
} ;
49
50
50
51
return statsNode ;
51
52
}
52
53
53
- private buildStatsMessage ( points : number , completionRate : string ) : string {
54
+ private buildStatsMessage ( points : number , completionRate : string , totalGasUsed : number ) : string {
54
55
const totalChallenges = this . challenges . filter ( c => c . enabled ) . length ;
55
56
const completedChallenges = this . userState . challenges . filter ( c => c . status === "success" ) . length ;
56
57
return `Address: ${ chalk . green ( this . userState . ens || this . userState . address ) }
57
- ${ chalk . yellow ( `Points Earned: ${ points . toLocaleString ( ) } ` ) }
58
+ ${ chalk . yellow ( `Points Earned: ${ points . toLocaleString ( ) } \n ${ chalk . cyan ( `Total Gas Used: ${ totalGasUsed . toLocaleString ( ) } ` ) } ` ) }
58
59
59
60
Challenges Completed: ${ chalk . blueBright ( `${ completedChallenges } /${ totalChallenges } (${ completionRate } %)` ) }
60
61
${ completedChallenges ? "Details:" : "" } `;
0 commit comments