-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update FeeGrant API and test with Gas Station #41
Update FeeGrant API and test with Gas Station #41
Conversation
Deploying with Cloudflare Pages
|
pub trait FeeGranterAllowance { | ||
fn to_any(&self) -> Any; | ||
} | ||
|
||
impl FeeGranterAllowance for BasicAllowance { | ||
fn to_any(&self) -> Any { | ||
Any { | ||
type_url: feegrant::v1beta1::BasicAllowance::TYPE_URL.to_string(), | ||
value: self.clone().to_proto().encode_to_vec(), | ||
} | ||
} | ||
} | ||
|
||
impl FeeGranterAllowance for PeriodicAllowance { | ||
fn to_any(&self) -> Any { | ||
Any { | ||
type_url: feegrant::v1beta1::PeriodicAllowance::TYPE_URL.to_string(), | ||
value: feegrant::v1beta1::PeriodicAllowance { | ||
basic: self.basic.clone().map(|b| b.to_proto()), | ||
period: self.period.map(|p| prost_types::Duration { | ||
seconds: p.as_secs() as i64, | ||
nanos: 0, | ||
}), | ||
period_spend_limit: convert_coins(self.period_spend_limit.clone()), | ||
period_can_spend: convert_coins(self.period_can_spend.clone()), | ||
period_reset: self.period_reset.map(convert_stamp), | ||
} | ||
.encode_to_vec(), | ||
} | ||
} | ||
} | ||
|
||
impl FeeGranterAllowance for AllowedMsgAllowance { | ||
fn to_any(&self) -> Any { | ||
Any { | ||
type_url: feegrant::v1beta1::AllowedMsgAllowance::TYPE_URL.to_string(), | ||
value: feegrant::v1beta1::AllowedMsgAllowance { | ||
allowance: self.allowance.as_ref().map(|a| a.to_any()), | ||
allowed_messages: self.allowed_messages.clone(), | ||
} | ||
.encode_to_vec(), | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use Into<Any>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it's used in dyn
trait object and Into
is marked with Sized
, which makes it not object-safe
Is it just test-tube or Osmosis as a chain? |
base: &'a T, | ||
deps: cosmwasm_std::Deps<'a>, | ||
// We use a RefCell here to allow for the granter to be set after the FeeGranter is created | ||
granter: RefCell<Option<Addr>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be owned type. The struct can be mut
if the user wants to set the granter.
I.e. change fn granter(&self, ...)
to fn granter(&mut self, ...)
This change updates the fee-grant API to be usable. The previous version of the API encoded every single one of the messages improperly and was almost unusable.
It also creates a proof-of-concept abstract app for managing fee grants from an account. It is called "gas-station" and allows the Account to create grades of gas for different selections of gas tokens on the network, as well as different default expirations (TODO). Then, they can activate a gas pass for a user / contract, which will fee grant from the proxy on the account.
Check out the readme for it as to why it's better.
NOTE:
Checklist