-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
61 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use codec::{Decode, Encode, MaxEncodedLen}; | ||
use frame_support::RuntimeDebug; | ||
use scale_info::TypeInfo; | ||
#[cfg(feature = "std")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// [ISIN](https://en.wikipedia.org/wiki/International_Securities_Identification_Number) format. | ||
pub type Isin = [u8; 12]; | ||
|
||
/// A representation of an oracle price identifier | ||
#[derive( | ||
Encode, | ||
Decode, | ||
Clone, | ||
Copy, | ||
PartialOrd, | ||
Ord, | ||
PartialEq, | ||
Eq, | ||
TypeInfo, | ||
RuntimeDebug, | ||
MaxEncodedLen, | ||
)] | ||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] | ||
pub enum OracleKey { | ||
Isin(Isin), | ||
} | ||
|
||
#[cfg(feature = "runtime-benchmarks")] | ||
impl From<u32> for OracleKey { | ||
fn from(value: u32) -> Self { | ||
// Any u32 value always fits into 12 bytes | ||
let isin = Isin::try_from(&(value as u128).to_be_bytes()[0..12]).unwrap(); | ||
OracleKey::Isin(isin) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters