Cli error cleanup 1.0 (#8834)
* Don't use move semantics if not needed (#8793) * SDK: Deboilerplate `TransportError` with thiserror * Enable interchange between `TransportError` and `ClientError` * SDK: Retval consistency between `Client` and `AsyncClient` traits * Client: Introduce/use `Result` type * Client: Remove unused `RpcResponseIn` type * Client: Rename `RpcResponse` to more appropriate `RpcResult` * Client: Death to `io::Result` return types * Client: Struct-ify `ClientError` * Client: Add optional `command` parameter to `ClientError` * RpcClient: Stop abusing `io::Error` (low-fruit) * ClientError: Use `thiserror`'s `Display` impl * Extend `RpcError`'s utility * RpcClient: Stop abusing `io::Error` (the rest) * CLI: Shim `main()` so we can `Display` format errors * claputils: format input validator errors with `Display` They are intended to be displayed to users * SDK: `thiserror` for hash and sig parse erros * Keygen: Shim main to format errors with `Display` * SDK: `thiserror` for `InstructionError` * CLI: `thiserror` for `CliError` * CLI: Format user messages with `Display` * Client: Tweak `Display` for `ClientError` * RpcClient: Improve messaging when TX cannot be confirmed * fu death io res retval * CLI/Keygen - fix shell return value on error * Tweak `InstructionError` `Display` messages as per review * Cleanup hackjob return code fix * Embrace that which you hate most * Too much... Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
@@ -256,7 +256,7 @@ mod tests {
|
||||
budget_instruction::payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 1);
|
||||
instructions[1].accounts = vec![]; // <!-- Attack! Prevent accounts from being passed into processor.
|
||||
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
assert_eq!(
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
@@ -276,7 +276,7 @@ mod tests {
|
||||
let budget_pubkey = budget_keypair.pubkey();
|
||||
let instructions =
|
||||
budget_instruction::payment(&alice_pubkey, &bob_pubkey, &budget_pubkey, 100);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
.unwrap();
|
||||
@@ -302,7 +302,7 @@ mod tests {
|
||||
None,
|
||||
1,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
.unwrap();
|
||||
@@ -315,7 +315,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let instruction =
|
||||
budget_instruction::apply_signature(&mallory_pubkey, &budget_pubkey, &bob_pubkey);
|
||||
let mut message = Message::new(vec![instruction]);
|
||||
let mut message = Message::new(&[instruction]);
|
||||
|
||||
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
|
||||
message.account_keys.insert(3, alice_pubkey);
|
||||
@@ -352,7 +352,7 @@ mod tests {
|
||||
None,
|
||||
1,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
.unwrap();
|
||||
@@ -365,7 +365,7 @@ mod tests {
|
||||
.unwrap();
|
||||
let instruction =
|
||||
budget_instruction::apply_timestamp(&mallory_pubkey, &budget_pubkey, &bob_pubkey, dt);
|
||||
let mut message = Message::new(vec![instruction]);
|
||||
let mut message = Message::new(&[instruction]);
|
||||
|
||||
// Attack! Part 2: Point the instruction to the expected, but unsigned, key.
|
||||
message.account_keys.insert(3, alice_pubkey);
|
||||
@@ -402,7 +402,7 @@ mod tests {
|
||||
None,
|
||||
1,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
.unwrap();
|
||||
@@ -472,7 +472,7 @@ mod tests {
|
||||
Some(alice_pubkey),
|
||||
1,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
.unwrap();
|
||||
@@ -550,7 +550,7 @@ mod tests {
|
||||
game_hash,
|
||||
41,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &budget_keypair], message)
|
||||
.unwrap();
|
||||
@@ -570,7 +570,7 @@ mod tests {
|
||||
|
||||
// Anyone can sign the message, but presumably it's Bob, since he's the
|
||||
// one claiming the payout.
|
||||
let message = Message::new_with_payer(vec![instruction], Some(&bob_pubkey));
|
||||
let message = Message::new_with_payer(&[instruction], Some(&bob_pubkey));
|
||||
bank_client.send_message(&[&bob_keypair], message).unwrap();
|
||||
|
||||
assert_eq!(bank_client.get_balance(&alice_pubkey).unwrap(), 0);
|
||||
|
@@ -603,7 +603,7 @@ mod test {
|
||||
);
|
||||
|
||||
client
|
||||
.send_message(&[owner, &new], Message::new(vec![instruction]))
|
||||
.send_message(&[owner, &new], Message::new(&[instruction]))
|
||||
.expect(&format!("{}:{}", line!(), file!()));
|
||||
new.pubkey()
|
||||
}
|
||||
|
@@ -32,11 +32,11 @@ pub fn create_genesis<T: Client>(from: &Keypair, client: &T, amount: u64) -> Key
|
||||
);
|
||||
|
||||
client
|
||||
.send_message(&[&from, &genesis], Message::new(vec![instruction]))
|
||||
.send_message(&[&from, &genesis], Message::new(&[instruction]))
|
||||
.unwrap();
|
||||
|
||||
let instruction = librapay_instruction::genesis(&genesis.pubkey(), amount);
|
||||
let message = Message::new_with_payer(vec![instruction], Some(&from.pubkey()));
|
||||
let message = Message::new_with_payer(&[instruction], Some(&from.pubkey()));
|
||||
client.send_message(&[from, &genesis], message).unwrap();
|
||||
|
||||
genesis
|
||||
|
@@ -93,7 +93,7 @@ mod tests {
|
||||
owner_pubkey,
|
||||
lamports,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client.send_message(&[payer_keypair, account_keypair], message)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ mod tests {
|
||||
&old_owner_keypair.pubkey(),
|
||||
new_owner_pubkey,
|
||||
);
|
||||
let message = Message::new_with_payer(vec![instruction], Some(&payer_keypair.pubkey()));
|
||||
let message = Message::new_with_payer(&[instruction], Some(&payer_keypair.pubkey()));
|
||||
bank_client.send_message(&[payer_keypair, old_owner_keypair], message)
|
||||
}
|
||||
|
||||
|
@@ -187,7 +187,7 @@ mod tests {
|
||||
date_instruction::create_account(&payer_keypair.pubkey(), &date_pubkey, 1);
|
||||
instructions.push(date_instruction::store(&date_pubkey, date));
|
||||
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client.send_message(&[payer_keypair, date_keypair], message)
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ mod tests {
|
||||
) -> Result<Signature> {
|
||||
let date_pubkey = date_keypair.pubkey();
|
||||
let instruction = date_instruction::store(&date_pubkey, date);
|
||||
let message = Message::new_with_payer(vec![instruction], Some(&payer_keypair.pubkey()));
|
||||
let message = Message::new_with_payer(&[instruction], Some(&payer_keypair.pubkey()));
|
||||
bank_client.send_message(&[payer_keypair, date_keypair], message)
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ mod tests {
|
||||
&date_pubkey,
|
||||
lamports,
|
||||
);
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
bank_client.send_message(&[payer_keypair, contract_keypair], message)
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ mod tests {
|
||||
) -> Result<Signature> {
|
||||
let instruction =
|
||||
vest_instruction::redeem_tokens(&contract_pubkey, &date_pubkey, &payee_pubkey);
|
||||
let message = Message::new_with_payer(vec![instruction], Some(&payer_keypair.pubkey()));
|
||||
let message = Message::new_with_payer(&[instruction], Some(&payer_keypair.pubkey()));
|
||||
bank_client.send_message(&[payer_keypair], message)
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ mod tests {
|
||||
);
|
||||
instructions[1].accounts = vec![]; // <!-- Attack! Prevent accounts from being passed into processor.
|
||||
|
||||
let message = Message::new(instructions);
|
||||
let message = Message::new(&instructions);
|
||||
assert_eq!(
|
||||
bank_client
|
||||
.send_message(&[&alice_keypair, &contract_keypair], message)
|
||||
|
Reference in New Issue
Block a user