This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Refactor pallet-cosmos-x-wasm-types
- Loading branch information
Showing
8 changed files
with
299 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This file is part of Horizon. | ||
|
||
// Copyright (C) 2023 Haderech Pte. Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
pub mod msg_execute_contract; | ||
pub mod msg_instantiate_contract2; | ||
pub mod msg_migrate_contract; | ||
pub mod msg_store_code; | ||
pub mod msg_update_admin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This file is part of Horizon. | ||
|
||
// Copyright (C) 2023 Haderech Pte. Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use alloc::{string::String, vec, vec::Vec}; | ||
use cosmos_sdk_proto::{cosmwasm::wasm, prost::Message, Any}; | ||
use pallet_cosmos_types::{coin::Coin, tx_msgs::Msg}; | ||
use pallet_cosmos_x_auth_migrations::legacytx::stdsign::LegacyMsg; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct MsgExecuteContract { | ||
pub contract: String, | ||
pub funds: Vec<Coin>, | ||
pub msg: Vec<u8>, | ||
pub sender: String, | ||
} | ||
|
||
impl TryFrom<&Any> for MsgExecuteContract { | ||
type Error = (); | ||
|
||
fn try_from(any: &Any) -> Result<Self, Self::Error> { | ||
let msg = wasm::v1::MsgExecuteContract::decode(&mut &*any.value).map_err(|_| ())?; | ||
Ok(Self { | ||
contract: msg.contract, | ||
funds: msg.funds.iter().map(Into::into).collect(), | ||
msg: msg.msg, | ||
sender: msg.sender, | ||
}) | ||
} | ||
} | ||
|
||
impl LegacyMsg for MsgExecuteContract { | ||
const AMINO_NAME: &'static str = "wasm/MsgExecuteContract"; | ||
} | ||
|
||
impl Msg for MsgExecuteContract { | ||
fn get_signers(self) -> Vec<String> { | ||
vec![self.sender.clone()] | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
frame/cosmos/x/wasm/types/src/tx/msg_instantiate_contract2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// This file is part of Horizon. | ||
|
||
// Copyright (C) 2023 Haderech Pte. Ltd. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use alloc::{string::String, vec, vec::Vec}; | ||
use cosmos_sdk_proto::{cosmwasm::wasm, prost::Message, Any}; | ||
use pallet_cosmos_types::{coin::Coin, tx_msgs::Msg}; | ||
use pallet_cosmos_x_auth_migrations::legacytx::stdsign::LegacyMsg; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] | ||
pub struct MsgInstantiateContract2 { | ||
pub admin: String, | ||
pub code_id: u64, | ||
pub fix_msg: bool, | ||
pub funds: Vec<Coin>, | ||
pub label: String, | ||
pub msg: Vec<u8>, | ||
pub salt: Vec<u8>, | ||
pub sender: String, | ||
} | ||
|
||
impl TryFrom<&Any> for MsgInstantiateContract2 { | ||
type Error = (); | ||
|
||
fn try_from(any: &Any) -> Result<Self, Self::Error> { | ||
let msg = wasm::v1::MsgInstantiateContract2::decode(&mut &*any.value).map_err(|_| ())?; | ||
Ok(Self { | ||
admin: msg.admin, | ||
code_id: msg.code_id, | ||
fix_msg: msg.fix_msg, | ||
funds: msg.funds.iter().map(Into::into).collect(), | ||
label: msg.label, | ||
msg: msg.msg, | ||
salt: msg.salt, | ||
sender: msg.sender, | ||
}) | ||
} | ||
} | ||
|
||
impl LegacyMsg for MsgInstantiateContract2 { | ||
const AMINO_NAME: &'static str = "wasm/MsgInstantiateContract2"; | ||
} | ||
|
||
impl Msg for MsgInstantiateContract2 { | ||
fn get_signers(self) -> Vec<String> { | ||
vec![self.sender.clone()] | ||
} | ||
} |
Oops, something went wrong.