nym_pool_contract_common/
msg.rs

1// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::{Allowance, TransferRecipient};
5use cosmwasm_schema::cw_serde;
6use cosmwasm_std::Coin;
7use std::collections::HashMap;
8
9#[cfg(feature = "schema")]
10use crate::types::{
11    AvailableTokensResponse, GrantResponse, GranterResponse, GrantersPagedResponse,
12    GrantsPagedResponse, LockedTokensPagedResponse, LockedTokensResponse,
13    TotalLockedTokensResponse,
14};
15
16#[cw_serde]
17pub struct InstantiateMsg {
18    pub pool_denomination: String,
19
20    /// Initial map of grants to be created at instantiation
21    pub grants: HashMap<String, Allowance>,
22}
23
24#[cw_serde]
25pub enum ExecuteMsg {
26    /// Change the admin
27    UpdateAdmin {
28        admin: String,
29        // flag to determine whether old admin should be removed from the granter set
30        // and new one should be included instead
31        // the reason it's provided as an option is to make it possible to skip this field
32        // when creating transaction directly with nyxd
33        update_granter_set: Option<bool>,
34    },
35
36    /// Attempt to grant new allowance to the specified grantee
37    GrantAllowance {
38        grantee: String,
39        allowance: Box<Allowance>,
40    },
41
42    /// Attempt to revoke previously granted allowance
43    RevokeAllowance { grantee: String },
44
45    /// Attempt to use allowance
46    UseAllowance { recipients: Vec<TransferRecipient> },
47
48    /// Attempt to withdraw the specified amount into the grantee's account
49    WithdrawAllowance { amount: Coin },
50
51    /// Attempt to lock part of existing allowance for future use
52    LockAllowance { amount: Coin },
53
54    /// Attempt to unlock previously locked allowance
55    UnlockAllowance { amount: Coin },
56
57    /// Attempt to use part of the locked allowance
58    UseLockedAllowance { recipients: Vec<TransferRecipient> },
59
60    /// Attempt to withdraw the specified amount of locked tokens into the grantee's account
61    WithdrawLockedAllowance { amount: Coin },
62
63    /// Attempt to add a new account to the permitted set of grant granters
64    AddNewGranter { granter: String },
65
66    /// Revoke the provided account from the permitted set of granters
67    RevokeGranter { granter: String },
68
69    /// Attempt to remove expired grant from the storage and unlock (if any) locked tokens
70    RemoveExpiredGrant { grantee: String },
71}
72
73#[cw_serde]
74#[cfg_attr(feature = "schema", derive(cosmwasm_schema::QueryResponses))]
75pub enum QueryMsg {
76    #[cfg_attr(feature = "schema", returns(cw_controllers::AdminResponse))]
77    Admin {},
78
79    #[cfg_attr(feature = "schema", returns(AvailableTokensResponse))]
80    GetAvailableTokens {},
81
82    #[cfg_attr(feature = "schema", returns(TotalLockedTokensResponse))]
83    GetTotalLockedTokens {},
84
85    #[cfg_attr(feature = "schema", returns(LockedTokensResponse))]
86    GetLockedTokens { grantee: String },
87
88    #[cfg_attr(feature = "schema", returns(GrantResponse))]
89    GetGrant { grantee: String },
90
91    #[cfg_attr(feature = "schema", returns(GranterResponse))]
92    GetGranter { granter: String },
93
94    #[cfg_attr(feature = "schema", returns(LockedTokensPagedResponse))]
95    GetLockedTokensPaged {
96        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
97        limit: Option<u32>,
98
99        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
100        start_after: Option<String>,
101    },
102
103    #[cfg_attr(feature = "schema", returns(GrantersPagedResponse))]
104    GetGrantersPaged {
105        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
106        limit: Option<u32>,
107
108        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
109        start_after: Option<String>,
110    },
111
112    #[cfg_attr(feature = "schema", returns(GrantsPagedResponse))]
113    GetGrantsPaged {
114        /// Controls the maximum number of entries returned by the query. Note that too large values will be overwritten by a saner default.
115        limit: Option<u32>,
116
117        /// Pagination control for the values returned by the query. Note that the provided value itself will **not** be used for the response.
118        start_after: Option<String>,
119    },
120}
121
122#[cw_serde]
123pub struct MigrateMsg {
124    //
125}