@@ -2,14 +2,23 @@ use std::str::FromStr;
2
2
3
3
use colored:: Colorize ;
4
4
use ore_api:: state:: proof_pda;
5
- use solana_program:: { pubkey :: Pubkey , native_token :: lamports_to_sol } ;
5
+ use solana_program:: { native_token :: lamports_to_sol , pubkey :: Pubkey } ;
6
6
use solana_sdk:: signature:: Signer ;
7
7
use spl_token:: amount_to_ui_amount;
8
- use tabled:: { Table , settings:: { Style , Remove , object:: { Rows , Columns } , Alignment } } ;
8
+ use tabled:: {
9
+ settings:: {
10
+ object:: { Columns , Rows } ,
11
+ Alignment , Remove , Style ,
12
+ } ,
13
+ Table ,
14
+ } ;
9
15
10
16
use crate :: {
11
17
args:: { AccountArgs , AccountCloseArgs , AccountCommand , ClaimArgs } ,
12
- utils:: { amount_u64_to_f64, ask_confirm, format_timestamp, get_proof, get_proof_with_authority, ComputeBudget , TableData , TableSectionTitle } ,
18
+ utils:: {
19
+ amount_u64_to_f64, ask_confirm, format_timestamp, get_proof, get_proof_with_authority,
20
+ ComputeBudget , TableData , TableSectionTitle ,
21
+ } ,
13
22
Miner ,
14
23
} ;
15
24
@@ -28,7 +37,7 @@ impl Miner {
28
37
// Parse account address
29
38
let signer = self . signer ( ) ;
30
39
let address = if let Some ( address) = & args. address {
31
- if let Ok ( address) = Pubkey :: from_str ( & address) {
40
+ if let Ok ( address) = Pubkey :: from_str ( address) {
32
41
address
33
42
} else {
34
43
println ! ( "Invalid address: {:?}" , address) ;
@@ -40,7 +49,7 @@ impl Miner {
40
49
signer. pubkey ( )
41
50
} ;
42
51
43
- // Aggregate data
52
+ // Aggregate data
44
53
let mut data = vec ! [ ] ;
45
54
self . get_account_data ( address, & mut data) . await ;
46
55
self . get_proof_data ( address, & mut data) . await ;
@@ -52,14 +61,14 @@ impl Miner {
52
61
table. with ( Style :: blank ( ) ) ;
53
62
table. section_title ( 0 , "Account" ) ;
54
63
table. section_title ( 3 , "Proof" ) ;
55
-
64
+
56
65
println ! ( "{table}\n " ) ;
57
66
}
58
67
59
68
async fn get_proof_account ( & self , args : AccountArgs ) {
60
69
// Parse account address
61
70
let proof_address = if let Some ( address) = & args. proof {
62
- if let Ok ( address) = Pubkey :: from_str ( & address) {
71
+ if let Ok ( address) = Pubkey :: from_str ( address) {
63
72
address
64
73
} else {
65
74
println ! ( "Invalid address: {:?}" , address) ;
@@ -69,8 +78,10 @@ impl Miner {
69
78
return ;
70
79
} ;
71
80
72
- // Aggregate data
73
- let proof = get_proof ( & self . rpc_client , proof_address) . await . expect ( "Failed to fetch proof account" ) ;
81
+ // Aggregate data
82
+ let proof = get_proof ( & self . rpc_client , proof_address)
83
+ . await
84
+ . expect ( "Failed to fetch proof account" ) ;
74
85
let mut data = vec ! [ ] ;
75
86
self . get_account_data ( proof. authority , & mut data) . await ;
76
87
self . get_proof_data ( proof. authority , & mut data) . await ;
@@ -82,7 +93,7 @@ impl Miner {
82
93
table. with ( Style :: blank ( ) ) ;
83
94
table. section_title ( 0 , "Account" ) ;
84
95
table. section_title ( 3 , "Proof" ) ;
85
-
96
+
86
97
println ! ( "{table}\n " ) ;
87
98
}
88
99
@@ -103,7 +114,11 @@ impl Miner {
103
114
} ;
104
115
105
116
// Get SOL balance
106
- let sol_balance = self . rpc_client . get_balance ( & authority) . await . expect ( "Failed to fetch SOL balance" ) ;
117
+ let sol_balance = self
118
+ . rpc_client
119
+ . get_balance ( & authority)
120
+ . await
121
+ . expect ( "Failed to fetch SOL balance" ) ;
107
122
108
123
// Aggregate data
109
124
data. push ( TableData {
@@ -138,10 +153,13 @@ impl Miner {
138
153
data. push ( TableData {
139
154
key : "Balance" . to_string ( ) ,
140
155
value : if proof. balance > 0 {
141
- format ! ( "{} ORE" , amount_u64_to_f64( proof. balance) ) . bold ( ) . yellow ( ) . to_string ( )
156
+ format ! ( "{} ORE" , amount_u64_to_f64( proof. balance) )
157
+ . bold ( )
158
+ . yellow ( )
159
+ . to_string ( )
142
160
} else {
143
161
format ! ( "{} ORE" , amount_u64_to_f64( proof. balance) )
144
- }
162
+ } ,
145
163
} ) ;
146
164
data. push ( TableData {
147
165
key : "Last hash" . to_string ( ) ,
@@ -157,7 +175,10 @@ impl Miner {
157
175
} ) ;
158
176
data. push ( TableData {
159
177
key : "Lifetime rewards" . to_string ( ) ,
160
- value : format ! ( "{} ORE" , amount_to_ui_amount( proof. total_rewards, ore_api:: consts:: TOKEN_DECIMALS ) ) ,
178
+ value : format ! (
179
+ "{} ORE" ,
180
+ amount_to_ui_amount( proof. total_rewards, ore_api:: consts:: TOKEN_DECIMALS )
181
+ ) ,
161
182
} ) ;
162
183
data. push ( TableData {
163
184
key : "Miner" . to_string ( ) ,
@@ -174,7 +195,9 @@ impl Miner {
174
195
async fn close ( & self , _args : AccountCloseArgs ) {
175
196
// Confirm proof exists
176
197
let signer = self . signer ( ) ;
177
- let proof = get_proof_with_authority ( & self . rpc_client , signer. pubkey ( ) ) . await . expect ( "Failed to fetch proof account" ) ;
198
+ let proof = get_proof_with_authority ( & self . rpc_client , signer. pubkey ( ) )
199
+ . await
200
+ . expect ( "Failed to fetch proof account" ) ;
178
201
179
202
// Confirm the user wants to close.
180
203
if !ask_confirm (
0 commit comments