-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cmd] Upgrade airdrop command to use new TransferScripts::batch_peer_…
…to_peer_v2 (#3264) * [cmd] Upgrade airdrop command to use new TransferScripts::batch_peer_to_peer_v2. * [cmd] Airdrop command support other Token check the users is accepted the token. * fixup
- Loading branch information
Showing
4 changed files
with
136 additions
and
24 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
43 changes: 43 additions & 0 deletions
43
vm/types/src/account_config/resources/auto_accept_token.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,43 @@ | ||
// Copyright (c) The Diem Core Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::token::token_code::TokenCode; | ||
use crate::{ | ||
account_config::constants::{ACCOUNT_MODULE_NAME, CORE_CODE_ADDRESS}, | ||
move_resource::MoveResource, | ||
}; | ||
use move_core_types::language_storage::{StructTag, TypeTag}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// The AutoAcceptToken resource held under an account. | ||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct AutoAcceptToken { | ||
enable: bool, | ||
} | ||
|
||
impl AutoAcceptToken { | ||
pub fn enable(&self) -> bool { | ||
self.enable | ||
} | ||
|
||
/// Get token code from Balance StructTag, return None if struct tag is not a valid Balance StructTag | ||
pub fn token_code(struct_tag: &StructTag) -> Option<TokenCode> { | ||
if struct_tag.address == CORE_CODE_ADDRESS | ||
&& struct_tag.module.as_str() == Self::MODULE_NAME | ||
&& struct_tag.name.as_str() == Self::STRUCT_NAME | ||
{ | ||
if let Some(TypeTag::Struct(token_tag)) = struct_tag.type_params.get(0) { | ||
Some(token_tag.clone().into()) | ||
} else { | ||
None | ||
} | ||
} else { | ||
None | ||
} | ||
} | ||
} | ||
|
||
impl MoveResource for AutoAcceptToken { | ||
const MODULE_NAME: &'static str = ACCOUNT_MODULE_NAME; | ||
const STRUCT_NAME: &'static str = "AutoAcceptToken"; | ||
} |
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