Format msg properly for sending
This commit is contained in:
@@ -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 }],
|
||||
});
|
||||
|
||||
|
||||
@@ -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 }],
|
||||
});
|
||||
|
||||
|
||||
@@ -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 }],
|
||||
});
|
||||
|
||||
|
||||
@@ -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 };
|
||||
|
||||
Reference in New Issue
Block a user