-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add get_icp_xdr_conversion_rate to mock cmc (#145)
Co-authored-by: Remco <[email protected]> Co-authored-by: Severin Siffert <[email protected]>
- Loading branch information
1 parent
1de0e55
commit 362c2a6
Showing
4 changed files
with
53 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,35 @@ | ||
use candid::CandidType; | ||
use cycles_ledger::endpoints::{CmcCreateCanisterArgs, CmcCreateCanisterError}; | ||
use ic_cdk::api::time; | ||
use serde::Deserialize; | ||
|
||
const NANOSECONDS_PER_SECOND: u64 = 1_000_000_000; | ||
|
||
#[derive(Debug, Deserialize, Eq, PartialEq, Default)] | ||
pub struct State { | ||
pub last_create_canister_args: Option<CmcCreateCanisterArgs>, | ||
pub fail_next_create_canister_with: Option<CmcCreateCanisterError>, | ||
} | ||
|
||
#[derive(CandidType, Deserialize, Default)] | ||
pub struct IcpXdrConversionRateResponse { | ||
pub certificate: Vec<u8>, | ||
pub data: IcpXdrConversionRate, | ||
pub hash_tree: Vec<u8>, | ||
} | ||
|
||
#[derive(CandidType, Deserialize)] | ||
pub struct IcpXdrConversionRate { | ||
pub xdr_permyriad_per_icp: u64, | ||
pub timestamp_seconds: u64, | ||
} | ||
|
||
impl Default for IcpXdrConversionRate { | ||
fn default() -> Self { | ||
Self { | ||
// mocked value | ||
xdr_permyriad_per_icp: 50_000, | ||
timestamp_seconds: time() / NANOSECONDS_PER_SECOND, | ||
} | ||
} | ||
} |
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