-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix NEP-141 tests ft_transfer_call impl
- Loading branch information
Showing
5 changed files
with
64 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,36 @@ | ||
use crate::*; | ||
use near_sdk::json_types::U128; | ||
use near_sdk::serde_json; | ||
use near_sdk::PromiseOrValue; | ||
|
||
#[near_bindgen] | ||
impl MockEvmContract { | ||
pub fn ft_transfer(&mut self, receiver_id: String, amount: U128, memo: Option<String>) { | ||
assert_eq!(receiver_id, "some_account.test"); | ||
#[allow(unused_variables)] | ||
#[payable] | ||
pub fn ft_transfer(&mut self, receiver_id: AccountId, amount: U128, memo: Option<String>) { | ||
use std::str::FromStr; | ||
assert_eq!( | ||
receiver_id, | ||
AccountId::from_str("some_account.test").unwrap() | ||
); | ||
assert_eq!(amount.0, 10); | ||
assert_eq!(memo, Some("some message".to_string())); | ||
} | ||
|
||
#[allow(unused_variables)] | ||
pub fn ft_on_transfer(&mut self, sender_id: AccountId, amount: U128, msg: String) -> String { | ||
serde_json::to_string(&0).expect("Failed to serialize message") | ||
} | ||
|
||
#[result_serializer(borsh)] | ||
#[allow(unused_variables)] | ||
#[payable] | ||
pub fn ft_transfer_call( | ||
&mut self, | ||
receiver_id: AccountId, | ||
amount: U128, | ||
memo: Option<String>, | ||
msg: String, | ||
) -> u64 { | ||
amount.0.try_into().unwrap() | ||
) -> PromiseOrValue<U128> { | ||
PromiseOrValue::Value(amount) | ||
} | ||
} |
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