frame_support/traits/tokens/fungibles/approvals.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Inspect and Mutate traits for Asset approvals
19//!
20//! See the [`crate::traits::fungibles`] doc for more information about fungibles traits.
21
22use crate::dispatch::DispatchResult;
23pub trait Inspect<AccountId>: super::Inspect<AccountId> {
24 // Check the amount approved by an owner to be spent by a delegate
25 fn allowance(asset: Self::AssetId, owner: &AccountId, delegate: &AccountId) -> Self::Balance;
26}
27
28pub trait Mutate<AccountId>: Inspect<AccountId> {
29 // Approve a delegate account to spend an amount of tokens owned by an owner
30 fn approve(
31 asset: Self::AssetId,
32 owner: &AccountId,
33 delegate: &AccountId,
34 amount: Self::Balance,
35 ) -> DispatchResult;
36
37 // Transfer from a delegate account an amount approved by the owner of the asset
38 fn transfer_from(
39 asset: Self::AssetId,
40 owner: &AccountId,
41 delegate: &AccountId,
42 dest: &AccountId,
43 amount: Self::Balance,
44 ) -> DispatchResult;
45}