sdk: Add Borsh support for types and utilities (#15290)
* sdk: Add Borsh to Pubkey * Add serialization error for easier borsh integration * Add Borsh usage to banks-client and sdk * Rename SerializationError -> IOError * Add new errors to proto * Update Cargo lock * Update Cargo.lock based on CI * Clippy * Update ABI on bank * Address review feedback * Update sanity program instruction count test
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//! The `hash` module provides functions for creating SHA-256 hashes.
|
||||
|
||||
use crate::sanitize::Sanitize;
|
||||
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::{convert::TryFrom, fmt, mem, str::FromStr};
|
||||
use thiserror::Error;
|
||||
@@ -9,7 +10,20 @@ pub const HASH_BYTES: usize = 32;
|
||||
/// Maximum string length of a base58 encoded hash
|
||||
const MAX_BASE58_LEN: usize = 44;
|
||||
#[derive(
|
||||
Serialize, Deserialize, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash, AbiExample,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
BorshSerialize,
|
||||
BorshDeserialize,
|
||||
BorshSchema,
|
||||
Clone,
|
||||
Copy,
|
||||
Default,
|
||||
Eq,
|
||||
PartialEq,
|
||||
Ord,
|
||||
PartialOrd,
|
||||
Hash,
|
||||
AbiExample,
|
||||
)]
|
||||
#[repr(transparent)]
|
||||
pub struct Hash(pub [u8; HASH_BYTES]);
|
||||
|
Reference in New Issue
Block a user