gbuiltin_proxy/
lib.rs

1// This file is part of Gear.
2
3// Copyright (C) 2021-2025 Gear Technologies Inc.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Types used to communicate with proxy built-in.
20
21#![no_std]
22
23use gprimitives::ActorId;
24use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
25use scale_info::TypeInfo;
26
27/// Request that can be handled by the proxy builtin.
28///
29/// Currently all proxies aren't required to send announcement,
30/// i.e. no delays for the delegate actions.
31#[derive(Debug, Clone, Copy, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen)]
32pub enum Request {
33    /// Add proxy request.
34    ///
35    /// Requests to add `delegate` as a delegate for the actions
36    /// defined by `proxy_type` to be done on behalf of the request
37    /// sender.
38    #[codec(index = 0)]
39    AddProxy {
40        delegate: ActorId,
41        proxy_type: ProxyType,
42    },
43    /// Remove proxy request.
44    ///
45    /// Request sender asks to remove `delegate` with set of allowed actions
46    /// defined in `proxy_type` from his list of proxies.
47    #[codec(index = 1)]
48    RemoveProxy {
49        delegate: ActorId,
50        proxy_type: ProxyType,
51    },
52}
53
54/// Proxy type.
55///
56/// The mirror enum for the one defined in vara-runtime crate.
57#[derive(Debug, Clone, Copy, Eq, PartialEq, Encode, Decode, TypeInfo, MaxEncodedLen)]
58pub enum ProxyType {
59    Any,
60    NonTransfer,
61    Governance,
62    Staking,
63    IdentityJudgement,
64    CancelProxy,
65}