-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow P2P swaps of disabled tokens
- Loading branch information
Showing
22 changed files
with
229 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
14 changes: 14 additions & 0 deletions
14
backend/canisters/escrow/api/src/updates/c2c_set_token_enabled.rs
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,14 @@ | ||
use candid::CandidType; | ||
use serde::{Deserialize, Serialize}; | ||
use types::CanisterId; | ||
|
||
#[derive(CandidType, Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub ledger_canister_id: CanisterId, | ||
pub enabled: bool, | ||
} | ||
|
||
#[derive(CandidType, Serialize, Deserialize, Debug)] | ||
pub enum Response { | ||
Success, | ||
} |
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,3 +1,4 @@ | ||
pub mod c2c_set_token_enabled; | ||
pub mod cancel_swap; | ||
pub mod create_swap; | ||
pub mod notify_deposit; |
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,9 @@ | ||
use crate::read_state; | ||
|
||
pub fn caller_is_registry_canister() -> Result<(), String> { | ||
if read_state(|state| state.is_caller_registry_canister()) { | ||
Ok(()) | ||
} else { | ||
Err("Caller is not the registry canister".to_string()) | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
backend/canisters/escrow/impl/src/updates/c2c_set_token_enabled.rs
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,20 @@ | ||
use crate::guards::caller_is_registry_canister; | ||
use crate::{mutate_state, RuntimeState}; | ||
use canister_api_macros::update; | ||
use canister_tracing_macros::trace; | ||
use escrow_canister::c2c_set_token_enabled::{Response::*, *}; | ||
|
||
#[update(guard = "caller_is_registry_canister", msgpack = true)] | ||
#[trace] | ||
fn c2c_set_token_enabled(args: Args) -> Response { | ||
mutate_state(|state| c2c_set_token_enabled_impl(args, state)) | ||
} | ||
|
||
fn c2c_set_token_enabled_impl(args: Args, state: &mut RuntimeState) -> Response { | ||
if args.enabled { | ||
state.data.disabled_tokens.remove(&args.ledger_canister_id); | ||
} else { | ||
state.data.disabled_tokens.insert(args.ledger_canister_id); | ||
} | ||
Success | ||
} |
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,3 +1,4 @@ | ||
pub mod c2c_set_token_enabled; | ||
pub mod cancel_swap; | ||
pub mod create_swap; | ||
pub mod notify_deposit; | ||
|
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
Oops, something went wrong.