import { PlainMessage } from "@bufbuild/protobuf"; import { utf8 } from "cosmes/codec"; import { CosmwasmWasmV1MsgInstantiateContract as ProtoMsgInstantiateContract } from "cosmes/protobufs"; import { DeepPrettify, Prettify } from "../../typeutils/prettify"; import { Adapter } from "./Adapter"; type Data = Prettify< DeepPrettify, "msg">> & { msg: T; } >; export class MsgInstantiateContract implements Adapter { private readonly data: Data; constructor(data: Data) { this.data = data; } public toProto() { return new ProtoMsgInstantiateContract({ ...this.data, msg: utf8.decode(JSON.stringify(this.data.msg)), }); } public toAmino() { return { type: "wasm/MsgInstantiateContract", value: { sender: this.data.sender, admin: this.data.admin, code_id: this.data.codeId.toString(), label: this.data.label, msg: this.data.msg, funds: this.data.funds, }, }; } }