Skip to content

Commit ba012bd

Browse files
authored
Made admin field optional in MsgInstantiateContract (#115)
1 parent a25f81f commit ba012bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cosmos-sdk-rs/src/cosmwasm.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub struct MsgInstantiateContract {
137137
pub sender: AccountId,
138138

139139
/// Admin is an optional address that can execute migrations
140-
pub admin: AccountId,
140+
pub admin: Option<AccountId>,
141141

142142
/// CodeID is the reference to the stored WASM code
143143
pub code_id: u64,
@@ -174,9 +174,14 @@ impl TryFrom<proto::cosmwasm::wasm::v1beta1::MsgInstantiateContract> for MsgInst
174174
} else {
175175
Some(proto.label)
176176
};
177+
let admin = if proto.admin.is_empty() {
178+
None
179+
} else {
180+
Some(proto.admin.parse())
181+
};
177182
Ok(MsgInstantiateContract {
178183
sender: proto.sender.parse()?,
179-
admin: proto.admin.parse()?,
184+
admin: admin.transpose()?,
180185
code_id: proto.code_id,
181186
label,
182187
init_msg: proto.init_msg,
@@ -193,7 +198,7 @@ impl From<MsgInstantiateContract> for proto::cosmwasm::wasm::v1beta1::MsgInstant
193198
fn from(msg: MsgInstantiateContract) -> proto::cosmwasm::wasm::v1beta1::MsgInstantiateContract {
194199
proto::cosmwasm::wasm::v1beta1::MsgInstantiateContract {
195200
sender: msg.sender.to_string(),
196-
admin: msg.admin.to_string(),
201+
admin: msg.admin.map(|admin| admin.to_string()).unwrap_or_default(),
197202
code_id: msg.code_id,
198203
label: msg.label.unwrap_or_default(),
199204
init_msg: msg.init_msg,

0 commit comments

Comments
 (0)