diff --git a/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx index 6c6e59c..f3fddb8 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgExecuteContractForm.tsx @@ -99,10 +99,19 @@ const MsgExecuteContractForm = ({ } })(); + const msgContentUtf8Array = (() => { + try { + // The JsonEditor does not escape \n or remove whitespaces, so we need to parse + stringify + return toUtf8(JSON.stringify(JSON.parse(msgContent))); + } catch { + return Uint8Array.from([]); + } + })(); + const msgValue = MsgCodecs[MsgTypeUrls.Execute].fromPartial({ sender: fromAddress, contract: contractAddress, - msg: toUtf8(msgContent), + msg: msgContentUtf8Array, funds: [{ denom, amount: amountInAtomics }], }); diff --git a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx index b95d28e..ed9d02c 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContract2Form.tsx @@ -110,6 +110,15 @@ const MsgInstantiateContract2Form = ({ } })(); + const msgContentUtf8Array = (() => { + try { + // The JsonEditor does not escape \n or remove whitespaces, so we need to parse + stringify + return toUtf8(JSON.stringify(JSON.parse(msgContent))); + } catch { + return Uint8Array.from([]); + } + })(); + const msgValue = MsgCodecs[MsgTypeUrls.Instantiate2].fromPartial({ sender: fromAddress, codeId: codeId || 1, @@ -117,7 +126,7 @@ const MsgInstantiateContract2Form = ({ admin: adminAddress, fixMsg, salt: toUtf8(salt), - msg: toUtf8(msgContent), + msg: msgContentUtf8Array, funds: [{ denom, amount: amountInAtomics }], }); diff --git a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx index 5cb44ab..9b21e04 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgInstantiateContractForm.tsx @@ -108,12 +108,21 @@ const MsgInstantiateContractForm = ({ } })(); + const msgContentUtf8Array = (() => { + try { + // The JsonEditor does not escape \n or remove whitespaces, so we need to parse + stringify + return toUtf8(JSON.stringify(JSON.parse(msgContent))); + } catch { + return Uint8Array.from([]); + } + })(); + const msgValue = MsgCodecs[MsgTypeUrls.Instantiate].fromPartial({ sender: fromAddress, codeId: codeId || 1, label, admin: adminAddress, - msg: toUtf8(msgContent), + msg: msgContentUtf8Array, funds: [{ denom, amount: amountInAtomics }], }); diff --git a/components/forms/CreateTxForm/MsgForm/MsgMigrateContractForm.tsx b/components/forms/CreateTxForm/MsgForm/MsgMigrateContractForm.tsx index 09f6dc6..647db1d 100644 --- a/components/forms/CreateTxForm/MsgForm/MsgMigrateContractForm.tsx +++ b/components/forms/CreateTxForm/MsgForm/MsgMigrateContractForm.tsx @@ -50,11 +50,20 @@ const MsgMigrateContractForm = ({ return true; }; + const msgContentUtf8Array = (() => { + try { + // The JsonEditor does not escape \n or remove whitespaces, so we need to parse + stringify + return toUtf8(JSON.stringify(JSON.parse(msgContent))); + } catch { + return Uint8Array.from([]); + } + })(); + const msgValue = MsgCodecs[MsgTypeUrls.Migrate].fromPartial({ sender: fromAddress, contract: contractAddress, codeId: codeId || 1, - msg: toUtf8(msgContent), + msg: msgContentUtf8Array, }); const msg: MsgMigrateContractEncodeObject = { typeUrl: MsgTypeUrls.Migrate, value: msgValue };