-
Notifications
You must be signed in to change notification settings - Fork 341
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
Support import alias in cosmwasm-schema
#1502
Comments
Thank you! Could you also share the code that generates the JSON Schema, i.e. uses the |
yes, absolutely. they are used in a struct which is used for IBC handling in different contracts. #[cw_serde]
pub enum RemoteTunnelPacketMsg {
/// A special case where the Factory is the only one who can call this
MintGovec {
wallet_addr: String,
},
GovecActions(GovecExecuteMsg),
StakeActions(StakeExecuteMsg),
ProposalActions {
prop_module_addr: String,
msg: ProposalExecuteMsg,
},
} #[cfg_attr(not(feature = "library"), entry_point)]
pub fn ibc_packet_receive(
deps: DepsMut,
_env: Env,
msg: IbcPacketReceiveMsg,
) -> Result<IbcReceiveResponse, ContractError> {
(|| {
let packet = msg.packet;
is_authorised_src(deps.as_ref(), packet.src, packet.dest)?;
let packet_msg: PacketMsg =
from_binary(&packet.data).map_err(|_| IbcError::InvalidPacketMsg)?;
let remote_ibc_msg: RemoteTunnelPacketMsg =
from_binary(&packet_msg.msg).map_err(|_| IbcError::InvalidInnerMsg)?;
match remote_ibc_msg {
RemoteTunnelPacketMsg::MintGovec { wallet_addr } => {
receive_mint_govec(deps, wallet_addr)
}
RemoteTunnelPacketMsg::GovecActions(msg) => {
receive_govec_actions(deps, packet_msg.sender, msg)
}
RemoteTunnelPacketMsg::StakeActions(msg) => {
receive_stake_actions(deps, packet_msg.sender, msg)
}
RemoteTunnelPacketMsg::ProposalActions {
prop_module_addr,
msg,
} => receive_proposal_actions(packet_msg.sender, prop_module_addr, msg),
}
})()
.or_else(|e| {
Ok(IbcReceiveResponse::new().set_ack(StdAck::fail(format!("IBC Packet Error: {}", e))))
})
} "RemoteTunnelPacketMsg": {
"description": "The IBC Packet Msg allowed dispatched by remote-tunnel",
"oneOf": [
{
"description": "A special case where the Factory is the only one who can call this",
"type": "object",
"required": [
"mint_govec"
],
"properties": {
"mint_govec": {
"type": "object",
"required": [
"wallet_addr"
],
"properties": {
"wallet_addr": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"govec_actions"
],
"properties": {
"govec_actions": {
"$ref": "#/definitions/GovecExecuteMsg"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"stake_actions"
],
"properties": {
"stake_actions": {
"$ref": "#/definitions/ExecuteMsg"
}
},
"additionalProperties": false
},
{
"type": "object",
"required": [
"proposal_actions"
],
"properties": {
"proposal_actions": {
"type": "object",
"required": [
"msg",
"prop_module_addr"
],
"properties": {
"msg": {
"$ref": "#/definitions/ExecuteMsg"
},
"prop_module_addr": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
]
} |
I took a look and I don't see an easy way to do this. |
This should help once it's merged: GREsau/schemars#178 GREsau/schemars#177 |
@aumetra could you have a look into this and ensure the new schema generator supports this request well? |
Yep, will add a test case. The new format is already using the internal |
Currently now
cosmwasm-schema
doesn't support import alias, it uses the same ref name for different aliases.Ex:
The text was updated successfully, but these errors were encountered: