Skip to content
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

Closed

Conversation

adairrr
Copy link
Contributor

@adairrr adairrr commented Aug 15, 2023

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

  • CI is green.
  • Changelog updated.

@github-actions github-actions bot added the sdk label Aug 15, 2023
@cloudflare-pages
Copy link

cloudflare-pages bot commented Aug 15, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: f69b598
Status: ✅  Deploy successful!
Preview URL: https://0159a5d7.abstract-docs.pages.dev
Branch Preview URL: https://adair-abs-56-rename-grant-fe.abstract-docs.pages.dev

View logs

@adairrr adairrr changed the title Redo fee-grant api Update FeeGrant API and test with Gas Station Aug 16, 2023
@adairrr adairrr mentioned this pull request Aug 17, 2023
1 task
Comment on lines +305 to +348
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(),
}
}
}
Copy link
Contributor Author

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>

Copy link
Collaborator

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

@CyberHoward
Copy link
Contributor

Osmosis test tube does not support contracts fee-granting. This sucks and we need to find a way around it. However, you can test out the app yourself here: https://console.abstract.money/junotestnet/account/0/modules/abstract:gas-station?activeTab=interactions

Is it just test-tube or Osmosis as a chain?
@adairrr

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>>,
Copy link
Contributor

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 was referenced Nov 15, 2023
@CyberHoward
Copy link
Contributor

close in favor of #147 and #148

@CyberHoward CyberHoward deleted the adair/abs-56-rename-grant-feature-to-fee_grant-and-feegrant branch December 7, 2023 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants