Skip to content

Commit

Permalink
remove hook gas limit; add schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
epanchee committed Sep 5, 2024
1 parent 713c22e commit cf18004
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 16 deletions.
15 changes: 6 additions & 9 deletions contracts/tokenomics/staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use osmosis_std::types::osmosis::tokenfactory::v1beta1::{
};

use astroport::staking::{
Config, ExecuteMsg, InstantiateMsg, QueryMsg, StakingResponse, TrackerData, HOOK_GAS_LIMIT,
Config, ExecuteMsg, InstantiateMsg, QueryMsg, StakingResponse, TrackerData,
};

use crate::error::ContractError;
Expand Down Expand Up @@ -130,14 +130,11 @@ pub fn execute(
contract_address,
msg,
} => execute_enter(deps, env, info).map(|(resp, minted_coins)| {
resp.add_submessage(
SubMsg::new(WasmMsg::Execute {
contract_addr: contract_address.clone(),
msg,
funds: vec![minted_coins],
})
.with_gas_limit(HOOK_GAS_LIMIT),
)
resp.add_message(WasmMsg::Execute {
contract_addr: contract_address.clone(),
msg,
funds: vec![minted_coins],
})
.add_attributes([
("action", "enter_with_hook"),
("next_contract", &contract_address),
Expand Down
4 changes: 0 additions & 4 deletions packages/astroport/src/staking.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::{Binary, Uint128};

/// Enforces gas limit for contracts used in ExecuteMsg::EnterWithHook.
pub const HOOK_GAS_LIMIT: u64 = 1_000_000;

/// This structure describes the parameters used for creating a contract.
#[cw_serde]
pub struct InstantiateMsg {
Expand All @@ -25,7 +22,6 @@ pub enum ExecuteMsg {
Enter { receiver: Option<String> },
/// Deposits ASTRO in exchange for xASTRO
/// and passes **all resulting xASTRO** to defined contract along with an executable message.
/// Note that the next message will be executed with limited gas (see HOOK_GAS_LIMIT).
EnterWithHook {
contract_address: String,
msg: Binary,
Expand Down
37 changes: 35 additions & 2 deletions schemas/astroport-staking/astroport-staking.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"contract_name": "astroport-staking",
"contract_version": "2.1.0",
"contract_version": "2.2.0",
"idl_version": "1.0.0",
"instantiate": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand All @@ -27,6 +27,7 @@
"type": "string"
},
"tracking_code_id": {
"description": "The Code ID of contract used to track the TokenFactory token balances",
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down Expand Up @@ -61,6 +62,32 @@
},
"additionalProperties": false
},
{
"description": "Deposits ASTRO in exchange for xASTRO and passes **all resulting xASTRO** to defined contract along with an executable message.",
"type": "object",
"required": [
"enter_with_hook"
],
"properties": {
"enter_with_hook": {
"type": "object",
"required": [
"contract_address",
"msg"
],
"properties": {
"contract_address": {
"type": "string"
},
"msg": {
"$ref": "#/definitions/Binary"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Burns xASTRO in exchange for ASTRO",
"type": "object",
Expand All @@ -75,7 +102,13 @@
},
"additionalProperties": false
}
]
],
"definitions": {
"Binary": {
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
"type": "string"
}
}
},
"query": {
"$schema": "http://json-schema.org/draft-07/schema#",
Expand Down
34 changes: 33 additions & 1 deletion schemas/astroport-staking/raw/execute.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@
},
"additionalProperties": false
},
{
"description": "Deposits ASTRO in exchange for xASTRO and passes **all resulting xASTRO** to defined contract along with an executable message.",
"type": "object",
"required": [
"enter_with_hook"
],
"properties": {
"enter_with_hook": {
"type": "object",
"required": [
"contract_address",
"msg"
],
"properties": {
"contract_address": {
"type": "string"
},
"msg": {
"$ref": "#/definitions/Binary"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"description": "Burns xASTRO in exchange for ASTRO",
"type": "object",
Expand All @@ -39,5 +65,11 @@
},
"additionalProperties": false
}
]
],
"definitions": {
"Binary": {
"description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>. See also <https://github.com/CosmWasm/cosmwasm/blob/main/docs/MESSAGE_TYPES.md>.",
"type": "string"
}
}
}
1 change: 1 addition & 0 deletions schemas/astroport-staking/raw/instantiate.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"type": "string"
},
"tracking_code_id": {
"description": "The Code ID of contract used to track the TokenFactory token balances",
"type": "integer",
"format": "uint64",
"minimum": 0.0
Expand Down

0 comments on commit cf18004

Please sign in to comment.