layer_climb_core/signing/authz/
tx.rs

1use layer_climb_proto::authz::Grant;
2
3use crate::prelude::*;
4
5impl SigningClient {
6    pub async fn authz_grant_any(
7        &self,
8        granter: Address,
9        grantee: Address,
10        grant: Option<Grant>,
11        tx_builder: Option<TxBuilder<'_>>,
12    ) -> Result<layer_climb_proto::abci::TxResponse> {
13        let resp = tx_builder
14            .unwrap_or_else(|| self.tx_builder())
15            .broadcast([proto_into_any(
16                &self.authz_grant_any_msg(granter, grantee, grant)?,
17            )?])
18            .await?;
19
20        Ok(resp)
21    }
22
23    pub async fn authz_grant_send(
24        &self,
25        granter: Address,
26        grantee: Address,
27        spend_limit: Vec<layer_climb_proto::Coin>,
28        allow_list: Vec<Address>,
29        tx_builder: Option<TxBuilder<'_>>,
30    ) -> Result<layer_climb_proto::abci::TxResponse> {
31        let grant = Grant {
32            authorization: Some(proto_into_any(
33                &layer_climb_proto::bank::SendAuthorization {
34                    spend_limit,
35                    allow_list: allow_list.into_iter().map(|a| a.to_string()).collect(),
36                },
37            )?),
38            expiration: None,
39        };
40
41        self.authz_grant_any(granter, grantee, Some(grant), tx_builder)
42            .await
43    }
44}