Skip to content

Commit

Permalink
fix: MsgInstantiateContract.Amino.admin can be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Lee committed Feb 13, 2022
1 parent df5dd3a commit 69a9673
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions terra_sdk/core/wasm/msgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,42 +139,6 @@ def from_proto(cls, proto: MsgMigrateCode_pb) -> MsgMigrateCode:
wasm_byte_code=proto.wasm_byte_code,
)


@attr.s
class MsgMigrateCode(Msg):
"""Upload a new smart contract WASM binary to the blockchain, replacing an existing code ID.
Can only be called once by creator of the contract, and is used for migrating from Col-4 to Col-5.
Args:
sender: address of sender
code_id: reference to the code on the blockchain
wasm_byte_code: base64-encoded string containing bytecode
"""

type = "wasm/MsgMigrateCode"
""""""

sender: AccAddress = attr.ib()
code_id: int = attr.ib(converter=int)
wasm_byte_code: str = attr.ib(converter=str)

def to_data(self) -> dict:
d = copy.deepcopy(self.__dict__)
d["sender"] = str(d["sender"])
d["code_id"] = str(d["code_id"])
d["wasm_byte_code"] = str(d["wasm_byte_code"])
return {"type": self.type, "value": dict_to_data(d)}

@classmethod
def from_data(cls, data: dict) -> MsgMigrateCode:
data = data["value"]
return cls(
sender=data["sender"],
code_id=data["code_id"],
wasm_byte_code=data["wasm_byte_code"],
)


@attr.s
class MsgInstantiateContract(Msg):
"""Creates a new instance of a smart contract from existing code on the blockchain.
Expand Down Expand Up @@ -203,9 +167,9 @@ def to_amino(self) -> dict:
"type": self.type_amino,
"value": {
"sender": self.sender,
"admin": self.admin if self.admin else None,
"admin": self.admin,
"code_id": str(self.code_id),
"init_msg": bytes(json.dumps(self.init_msg), "utf-8"),
"init_msg": self.init_msg,
"init_coins": self.init_coins.to_amino()
}
}
Expand Down

0 comments on commit 69a9673

Please sign in to comment.