mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 06:51:07 +00:00
Add low level traits to retrieve name, symbol, decimals and allowance in pallet-assets (#9757)
* Add ERC20 compatible trait to retrieve name, symbol, decimals and allowance * delegate instead of spender * Remove erc20 trait and divide it into lower level traits * add import * approvals and metadata depend on fungibles Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -794,3 +794,37 @@ fn assets_from_genesis_should_exist() {
|
||||
assert_eq!(Assets::total_supply(999), 100);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn querying_name_symbol_and_decimals_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
use frame_support::traits::tokens::fungibles::metadata::Inspect;
|
||||
assert_ok!(Assets::force_create(Origin::root(), 0, 1, true, 1));
|
||||
assert_ok!(Assets::force_set_metadata(
|
||||
Origin::root(),
|
||||
0,
|
||||
vec![0u8; 10],
|
||||
vec![1u8; 10],
|
||||
12,
|
||||
false
|
||||
));
|
||||
assert_eq!(Assets::name(0), vec![0u8; 10]);
|
||||
assert_eq!(Assets::symbol(0), vec![1u8; 10]);
|
||||
assert_eq!(Assets::decimals(0), 12);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn querying_allowance_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
use frame_support::traits::tokens::fungibles::approvals::{Inspect, Mutate};
|
||||
assert_ok!(Assets::force_create(Origin::root(), 0, 1, true, 1));
|
||||
assert_ok!(Assets::mint(Origin::signed(1), 0, 1, 100));
|
||||
Balances::make_free_balance_be(&1, 1);
|
||||
assert_ok!(Assets::approve(0, &1, &2, 50));
|
||||
assert_eq!(Assets::allowance(0, &1, &2), 50);
|
||||
// Transfer asset 0, from owner 1 and delegate 2 to destination 3
|
||||
assert_ok!(Assets::transfer_from(0, &1, &2, &3, 50));
|
||||
assert_eq!(Assets::allowance(0, &1, &2), 0);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user