diff --git a/packages/stateful/actions/core/nfts/TransferNft/index.tsx b/packages/stateful/actions/core/nfts/TransferNft/index.tsx index 0668eb1267..fa44614da9 100644 --- a/packages/stateful/actions/core/nfts/TransferNft/index.tsx +++ b/packages/stateful/actions/core/nfts/TransferNft/index.tsx @@ -1,4 +1,3 @@ -import { toBase64, toUtf8 } from '@cosmjs/encoding' import { useCallback } from 'react' import { useFormContext } from 'react-hook-form' import { constSelector, useRecoilValue } from 'recoil' @@ -18,6 +17,7 @@ import { import { combineLoadingDataWithErrors, decodePolytoneExecuteMsg, + encodeMessageAsBase64, makeWasmMessage, maybeMakePolytoneExecuteMessage, objectMatchesStructure, @@ -78,7 +78,7 @@ const useTransformToCosmos: UseTransformToCosmos = () => { ? { send_nft: { contract: recipient, - msg: toBase64(toUtf8(JSON.stringify(smartContractMsg))), + msg: encodeMessageAsBase64(smartContractMsg), token_id: tokenId, }, } @@ -156,8 +156,10 @@ const useDecodedCosmosMsg: UseDecodedCosmosMsg = ( recipient: msg.wasm.execute.msg.send_nft.contract, executeSmartContract: true, - smartContractMsg: parseEncodedMessage( - msg.wasm.execute.msg.send_nft.msg + smartContractMsg: JSON.stringify( + parseEncodedMessage(msg.wasm.execute.msg.send_nft.msg), + null, + 2 ), }, } diff --git a/packages/utils/contracts.ts b/packages/utils/contracts.ts index 28017b576c..4a3dc6214c 100644 --- a/packages/utils/contracts.ts +++ b/packages/utils/contracts.ts @@ -1,12 +1,11 @@ import { SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate' -import { toBase64, toUtf8 } from '@cosmjs/encoding' import { Coin, SigningStargateClient } from '@cosmjs/stargate' import { findAttribute, parseRawLog } from '@cosmjs/stargate/build/logs' import { ContractVersion } from '@dao-dao/types' import { CHAIN_GAS_MULTIPLIER } from './constants' -import { cwMsgToEncodeObject } from './messages' +import { cwMsgToEncodeObject, encodeMessageAsBase64 } from './messages' const CONTRACT_VERSIONS = Object.values(ContractVersion) @@ -55,7 +54,7 @@ export const instantiateSmartContract = async ( wasm: { instantiate: { code_id: codeId, - msg: toBase64(toUtf8(JSON.stringify(msg))), + msg: encodeMessageAsBase64(msg), funds: funds || [], label, // Replace empty string with undefined. diff --git a/packages/utils/messages/cw.ts b/packages/utils/messages/cw.ts index c97bf33a66..ceb545d8bf 100644 --- a/packages/utils/messages/cw.ts +++ b/packages/utils/messages/cw.ts @@ -15,7 +15,7 @@ import { import { getSupportedChainConfig } from '../chain' import { POLYTONE_TIMEOUT_SECONDS } from '../constants' import { objectMatchesStructure } from '../objectMatchesStructure' -import { parseEncodedMessage } from './encoding' +import { encodeMessageAsBase64, parseEncodedMessage } from './encoding' import { decodeStargateMessage } from './protobuf' type WasmMsgType = @@ -147,7 +147,7 @@ export const makeExecutableMintMessage = ( wasm: { execute: { contract_addr: contractAddress, - msg: toBase64(toUtf8(JSON.stringify(msg))), + msg: encodeMessageAsBase64(msg), funds: [], }, },