program log pubkey as base58 (#12901)
This commit is contained in:
@ -540,11 +540,9 @@ static uint64_t sol_invoke(
|
||||
*
|
||||
* @param key The public key to print
|
||||
*/
|
||||
static void sol_log_key(const SolPubkey *key) {
|
||||
for (int j = 0; j < sizeof(*key); j++) {
|
||||
sol_log_64(0, 0, 0, j, key->x[j]);
|
||||
}
|
||||
}
|
||||
void sol_log_pubkey(
|
||||
const SolPubkey *pubkey
|
||||
);
|
||||
|
||||
/**
|
||||
* Prints the hexadecimal representation of an array
|
||||
@ -564,7 +562,7 @@ static void sol_log_array(const uint8_t *array, int len) {
|
||||
*/
|
||||
static void sol_log_params(const SolParameters *params) {
|
||||
sol_log("- Program identifier:");
|
||||
sol_log_key(params->program_id);
|
||||
sol_log_pubkey(params->program_id);
|
||||
|
||||
sol_log("- Number of KeyedAccounts");
|
||||
sol_log_64(0, 0, 0, 0, params->ka_num);
|
||||
@ -574,13 +572,13 @@ static void sol_log_params(const SolParameters *params) {
|
||||
sol_log(" - Is writable");
|
||||
sol_log_64(0, 0, 0, 0, params->ka[i].is_writable);
|
||||
sol_log(" - Key");
|
||||
sol_log_key(params->ka[i].key);
|
||||
sol_log_pubkey(params->ka[i].key);
|
||||
sol_log(" - Lamports");
|
||||
sol_log_64(0, 0, 0, 0, *params->ka[i].lamports);
|
||||
sol_log(" - data");
|
||||
sol_log_array(params->ka[i].data, params->ka[i].data_len);
|
||||
sol_log(" - Owner");
|
||||
sol_log_key(params->ka[i].owner);
|
||||
sol_log_pubkey(params->ka[i].owner);
|
||||
sol_log(" - Executable");
|
||||
sol_log_64(0, 0, 0, 0, params->ka[i].executable);
|
||||
sol_log(" - Rent Epoch");
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#![cfg(feature = "program")]
|
||||
|
||||
use crate::{account_info::AccountInfo, pubkey::Pubkey};
|
||||
use crate::account_info::AccountInfo;
|
||||
|
||||
/// Prints a string
|
||||
/// There are two forms and are fast
|
||||
@ -63,18 +63,6 @@ pub fn sol_log_slice(slice: &[u8]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Prints a pubkey
|
||||
pub trait Log {
|
||||
fn log(&self);
|
||||
}
|
||||
impl Log for Pubkey {
|
||||
fn log(&self) {
|
||||
for (i, k) in self.to_bytes().iter().enumerate() {
|
||||
info!(0, 0, 0, i, *k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Prints the hexadecimal representation of the program's input parameters
|
||||
///
|
||||
/// @param ka - A pointer to an array of `AccountInfo` to print
|
||||
|
@ -202,9 +202,16 @@ impl Pubkey {
|
||||
pub fn to_bytes(self) -> [u8; 32] {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
// TODO localalize this
|
||||
/// Log a `Pubkey` from a program
|
||||
#[cfg(feature = "program")]
|
||||
pub fn log(&self) {
|
||||
extern "C" {
|
||||
fn sol_log_pubkey(pubkey_addr: *const u8);
|
||||
};
|
||||
unsafe { sol_log_pubkey(self.as_ref() as *const _ as *const u8) };
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<[u8]> for Pubkey {
|
||||
fn as_ref(&self) -> &[u8] {
|
||||
|
Reference in New Issue
Block a user