diff --git a/src/client/index.ts b/src/client/index.ts index ac105d5b..bbb8a499 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -32,6 +32,8 @@ export { RpcClient } from "./clients/RpcClient"; export { type Adapter } from "./models/Adapter"; export { MsgExecuteContract } from "./models/MsgExecuteContract"; export { MsgInstantiateContract } from "./models/MsgInstantiateContract"; +export { MsgStoreCode } from "./models/MsgStoreCode"; +export { MsgMigrateContract } from "./models/MsgMigrateContract"; export { MsgExecuteContractInjective } from "./models/MsgExecuteContractInjective"; export { MsgIbcTransfer } from "./models/MsgIbcTransfer"; export { MsgOsmosisSinglePoolSwap } from "./models/MsgOsmosisSinglePoolSwap"; diff --git a/src/client/models/MsgMigrateContract.ts b/src/client/models/MsgMigrateContract.ts new file mode 100644 index 00000000..359bdf8e --- /dev/null +++ b/src/client/models/MsgMigrateContract.ts @@ -0,0 +1,39 @@ +import { PlainMessage } from "@bufbuild/protobuf"; +import { utf8 } from "cosmes/codec"; +import { CosmwasmWasmV1MsgMigrateContract as ProtoMsgMigrateContract } from "cosmes/protobufs"; + +import { DeepPrettify, Prettify } from "../../typeutils/prettify"; +import { Adapter } from "./Adapter"; + +type Data = Prettify< + DeepPrettify, "msg">> & { + msg: T; + } +>; + +export class MsgMigrateContract implements Adapter { + private readonly data: Data; + + constructor(data: Data) { + this.data = data; + } + + public toProto() { + return new ProtoMsgMigrateContract({ + ...this.data, + msg: utf8.decode(JSON.stringify(this.data.msg)), + }); + } + + public toAmino() { + return { + type: "wasm/MsgMigrateContract", + value: { + sender: this.data.sender, + code_id: this.data.codeId, + contract: this.data.contract, + msg: this.data.msg, + } + }; + } +} diff --git a/src/client/models/MsgStoreCode.ts b/src/client/models/MsgStoreCode.ts new file mode 100644 index 00000000..e1c47114 --- /dev/null +++ b/src/client/models/MsgStoreCode.ts @@ -0,0 +1,33 @@ +import { PlainMessage } from "@bufbuild/protobuf"; +import { base64 } from "cosmes/codec"; +import { CosmwasmWasmV1MsgStoreCode as ProtoMsgStoreCode } from "cosmes/protobufs"; + +import { DeepPrettify } from "../../typeutils/prettify"; +import { Adapter } from "./Adapter"; + +type Data = DeepPrettify>; + +export class MsgStoreCode implements Adapter { + private readonly data: Data; + + constructor(data: Data) { + this.data = data; + } + + public toProto() { + return new ProtoMsgStoreCode({ + ...this.data, + }); + } + + public toAmino() { + return { + type: "wasm/MsgStoreCode", + value: { + sender: this.data.sender, + wasm_byte_code: base64.encode(this.data.wasmByteCode), + instantiate_permission: this.data.instantiatePermission, + } + }; + } +}