From 8b2e1457ccb3932e48a3dda4552c11cc88994bfc Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 2 Nov 2023 11:45:20 -0400 Subject: [PATCH 1/4] Fix coin formatting large numbers. --- .../treasury/CommunityPoolDeposit/index.tsx | 17 +++++++++-------- .../core/treasury/ManageStaking/index.tsx | 12 +++++++----- .../actions/core/treasury/Spend/index.tsx | 9 +++++---- .../actions/core/treasury/WyndSwap/index.tsx | 9 +++++---- .../token_swap/PerformTokenSwap/index.tsx | 6 +++--- .../components/SelfRelayExecuteModal.tsx | 12 +++++++++--- .../stateful/components/WalletStakingModal.tsx | 6 +++--- .../components/dao/DaoTokenDepositModal.tsx | 6 +++--- .../components/gov/GovProposalStatusAndInfo.tsx | 4 ++-- .../common/hooks/makeUsePublishProposal.ts | 5 ++++- .../common/hooks/makeUsePublishProposal.ts | 5 ++++- .../actions/Mint/index.tsx | 14 ++++++++------ .../components/StakingModal.tsx | 3 ++- .../DaoVotingTokenStaked/actions/Mint/index.tsx | 14 ++++++++------ .../components/StakingModal.tsx | 3 ++- .../actions/ManageVesting/index.tsx | 6 +++--- .../widgets/WyndDeposit/WyndDepositRenderer.tsx | 2 +- packages/utils/conversion.ts | 6 ++++++ 18 files changed, 84 insertions(+), 55 deletions(-) diff --git a/packages/stateful/actions/core/treasury/CommunityPoolDeposit/index.tsx b/packages/stateful/actions/core/treasury/CommunityPoolDeposit/index.tsx index b21cb1eca..9f111d7ff 100644 --- a/packages/stateful/actions/core/treasury/CommunityPoolDeposit/index.tsx +++ b/packages/stateful/actions/core/treasury/CommunityPoolDeposit/index.tsx @@ -1,4 +1,4 @@ -import { coins } from '@cosmjs/amino' +import { coins } from '@cosmjs/stargate' import { useCallback } from 'react' import { useFormContext } from 'react-hook-form' import { constSelector, useRecoilValue } from 'recoil' @@ -15,7 +15,7 @@ import { UseTransformToCosmos, } from '@dao-dao/types/actions' import { - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, decodePolytoneExecuteMsg, isDecodedStargateMsg, @@ -105,11 +105,6 @@ export const makeCommunityPoolDepositAction: ActionMaker< throw new Error(`Unknown token: ${denom}`) } - const microAmount = convertDenomToMicroDenomWithDecimals( - amount, - token.decimals - ) - return maybeMakePolytoneExecuteMessage( currentChainId, chainId, @@ -118,7 +113,13 @@ export const makeCommunityPoolDepositAction: ActionMaker< typeUrl: MsgFundCommunityPool.typeUrl, value: MsgFundCommunityPool.fromPartial({ depositor: address, - amount: coins(microAmount, denom), + amount: coins( + convertDenomToMicroDenomStringWithDecimals( + amount, + token.decimals + ), + denom + ), }), }, }) diff --git a/packages/stateful/actions/core/treasury/ManageStaking/index.tsx b/packages/stateful/actions/core/treasury/ManageStaking/index.tsx index 22450da81..9ccbe93d5 100644 --- a/packages/stateful/actions/core/treasury/ManageStaking/index.tsx +++ b/packages/stateful/actions/core/treasury/ManageStaking/index.tsx @@ -204,11 +204,13 @@ const InnerComponent: ActionComponent = (props) => { : { loading: false, data: coin( - balances.data.find( - ({ token: { chainId, denomOrAddress } }) => - chainId === nativeToken.chainId && - denomOrAddress === nativeToken.denomOrAddress - )?.balance ?? 0, + BigInt( + balances.data.find( + ({ token: { chainId, denomOrAddress } }) => + chainId === nativeToken.chainId && + denomOrAddress === nativeToken.denomOrAddress + )?.balance ?? 0 + ).toString(), nativeToken.denomOrAddress ), } diff --git a/packages/stateful/actions/core/treasury/Spend/index.tsx b/packages/stateful/actions/core/treasury/Spend/index.tsx index 5138479e3..650a4e8f9 100644 --- a/packages/stateful/actions/core/treasury/Spend/index.tsx +++ b/packages/stateful/actions/core/treasury/Spend/index.tsx @@ -21,7 +21,7 @@ import { UseTransformToCosmos, } from '@dao-dao/types/actions' import { - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, decodePolytoneExecuteMsg, getChainForChainId, @@ -155,9 +155,10 @@ const useTransformToCosmos: UseTransformToCosmos = () => { throw new Error(`Unknown token: ${denom}`) } - const amount = BigInt( - convertDenomToMicroDenomWithDecimals(_amount, token.decimals) - ).toString() + const amount = convertDenomToMicroDenomStringWithDecimals( + _amount, + token.decimals + ) let msg: CosmosMsgForEmpty | undefined if (toChainId !== fromChainId) { diff --git a/packages/stateful/actions/core/treasury/WyndSwap/index.tsx b/packages/stateful/actions/core/treasury/WyndSwap/index.tsx index 9785af90f..c29080f41 100644 --- a/packages/stateful/actions/core/treasury/WyndSwap/index.tsx +++ b/packages/stateful/actions/core/treasury/WyndSwap/index.tsx @@ -41,6 +41,7 @@ import { ExecuteSwapOperationsMsg } from '@dao-dao/types/contracts/WyndexMultiHo import { DAO_DAO_DAO_ADDRESS, WYND_MULTI_HOP_CONTRACT, + convertDenomToMicroDenomStringWithDecimals, convertDenomToMicroDenomWithDecimals, convertMicroDenomToDenomWithDecimals, encodeMessageAsBase64, @@ -525,16 +526,16 @@ const useTransformToCosmos: UseTransformToCosmos = () => { return } - const inAmount = convertDenomToMicroDenomWithDecimals( + const inAmount = convertDenomToMicroDenomStringWithDecimals( tokenInAmount, tokenIn.decimals - ).toString() + ) const minOutAmount = _minOutAmount !== undefined - ? convertDenomToMicroDenomWithDecimals( + ? convertDenomToMicroDenomStringWithDecimals( _minOutAmount, tokenOut.decimals - ).toString() + ) : undefined const msg: ExecuteSwapOperationsMsg = { diff --git a/packages/stateful/actions/core/treasury/token_swap/PerformTokenSwap/index.tsx b/packages/stateful/actions/core/treasury/token_swap/PerformTokenSwap/index.tsx index 1d275f89b..594b4e495 100644 --- a/packages/stateful/actions/core/treasury/token_swap/PerformTokenSwap/index.tsx +++ b/packages/stateful/actions/core/treasury/token_swap/PerformTokenSwap/index.tsx @@ -18,7 +18,7 @@ import { UseTransformToCosmos, } from '@dao-dao/types/actions' import { - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, encodeMessageAsBase64, makeWasmMessage, objectMatchesStructure, @@ -141,10 +141,10 @@ const useTransformToCosmos: UseTransformToCosmos = () => { } // Convert amount to micro amount. - const amount = convertDenomToMicroDenomWithDecimals( + const amount = convertDenomToMicroDenomStringWithDecimals( selfParty.amount, selfParty.decimals - ).toString() + ) return selfParty.type === 'cw20' ? makeWasmMessage({ diff --git a/packages/stateful/components/SelfRelayExecuteModal.tsx b/packages/stateful/components/SelfRelayExecuteModal.tsx index 9c7c639eb..fb566035e 100644 --- a/packages/stateful/components/SelfRelayExecuteModal.tsx +++ b/packages/stateful/components/SelfRelayExecuteModal.tsx @@ -403,7 +403,10 @@ export const SelfRelayExecuteModal = ({ { bank: { send: { - amount: coins(fundsNeeded, relayer.feeToken.denom), + amount: coins( + BigInt(fundsNeeded).toString(), + relayer.feeToken.denom + ), to_address: relayer.relayerAddress, }, }, @@ -472,7 +475,10 @@ export const SelfRelayExecuteModal = ({ grant: { authorization: SendAuthorization.toProtoMsg( SendAuthorization.fromPartial({ - spendLimit: coins(newBalance, relayer.feeToken.denom), + spendLimit: coins( + BigInt(newBalance).toString(), + relayer.feeToken.denom + ), }) ), expiration: { @@ -837,7 +843,7 @@ export const SelfRelayExecuteModal = ({ await client.sign.sendTokens( relayerAddress, wallet.address, - coins(remainingTokensAfterFee, feeDenom), + coins(BigInt(remainingTokensAfterFee).toString(), feeDenom), fee ) diff --git a/packages/stateful/components/WalletStakingModal.tsx b/packages/stateful/components/WalletStakingModal.tsx index b0fc8b9b9..200a3aff4 100644 --- a/packages/stateful/components/WalletStakingModal.tsx +++ b/packages/stateful/components/WalletStakingModal.tsx @@ -19,7 +19,7 @@ import { } from '@dao-dao/stateless' import { CHAIN_GAS_MULTIPLIER, - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, cwMsgToEncodeObject, processError, @@ -110,10 +110,10 @@ export const WalletStakingModal = (props: WalletStakingModalProps) => { setLoading(true) try { - const microAmount = convertDenomToMicroDenomWithDecimals( + const microAmount = convertDenomToMicroDenomStringWithDecimals( amount, nativeToken.decimals - ).toString() + ) if (mode === StakingMode.Stake) { await signingCosmWasmClient.signAndBroadcast( diff --git a/packages/stateful/components/dao/DaoTokenDepositModal.tsx b/packages/stateful/components/dao/DaoTokenDepositModal.tsx index a576245c3..c345db4f2 100644 --- a/packages/stateful/components/dao/DaoTokenDepositModal.tsx +++ b/packages/stateful/components/dao/DaoTokenDepositModal.tsx @@ -17,7 +17,7 @@ import { } from '@dao-dao/stateless' import { CHAIN_GAS_MULTIPLIER, - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, processError, } from '@dao-dao/utils' @@ -101,10 +101,10 @@ export const DaoTokenDepositModal = ({ setLoading(true) try { - const microAmount = convertDenomToMicroDenomWithDecimals( + const microAmount = convertDenomToMicroDenomStringWithDecimals( amount, token.decimals - ).toString() + ) if (token.type === 'native') { await signingCosmWasmClient.sendTokens( diff --git a/packages/stateful/components/gov/GovProposalStatusAndInfo.tsx b/packages/stateful/components/gov/GovProposalStatusAndInfo.tsx index a5e066028..90860d44d 100644 --- a/packages/stateful/components/gov/GovProposalStatusAndInfo.tsx +++ b/packages/stateful/components/gov/GovProposalStatusAndInfo.tsx @@ -46,7 +46,7 @@ import { } from '@dao-dao/types' import { CHAIN_GAS_MULTIPLIER, - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, formatPercentOf100, getGovPath, @@ -297,7 +297,7 @@ const InnerProposalStatusAndInfo = ({ proposalId: Long.fromString(proposalId.toString()), depositor: walletAddress, amount: coins( - convertDenomToMicroDenomWithDecimals( + convertDenomToMicroDenomStringWithDecimals( depositValue, depositToken.decimals ), diff --git a/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/common/hooks/makeUsePublishProposal.ts b/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/common/hooks/makeUsePublishProposal.ts index e9bb72f65..acfd358f7 100644 --- a/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/common/hooks/makeUsePublishProposal.ts +++ b/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/common/hooks/makeUsePublishProposal.ts @@ -291,7 +291,10 @@ export const makeUsePublishProposal = // Native token deposit if exists. const proposeFunds = requiredProposalDeposit && depositInfoNativeTokenDenom - ? coins(requiredProposalDeposit, depositInfoNativeTokenDenom) + ? coins( + BigInt(requiredProposalDeposit).toString(), + depositInfoNativeTokenDenom + ) : undefined // Recreate form data with just the expected fields to remove any fields diff --git a/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/common/hooks/makeUsePublishProposal.ts b/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/common/hooks/makeUsePublishProposal.ts index 09c705882..969702f6f 100644 --- a/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/common/hooks/makeUsePublishProposal.ts +++ b/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/common/hooks/makeUsePublishProposal.ts @@ -273,7 +273,10 @@ export const makeUsePublishProposal = // Native token deposit if exists. const proposeFunds = requiredProposalDeposit && depositInfoNativeTokenDenom - ? coins(requiredProposalDeposit, depositInfoNativeTokenDenom) + ? coins( + BigInt(requiredProposalDeposit).toString(), + depositInfoNativeTokenDenom + ) : undefined // Recreate form data with just the expected fields to remove any fields diff --git a/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/actions/Mint/index.tsx b/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/actions/Mint/index.tsx index bfdb59b39..dc09ed749 100644 --- a/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/actions/Mint/index.tsx +++ b/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/actions/Mint/index.tsx @@ -12,7 +12,7 @@ import { UseTransformToCosmos, } from '@dao-dao/types/actions' import { - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, isDecodedStargateMsg, makeStargateMessage, @@ -37,16 +37,18 @@ const useTransformToCosmos: UseTransformToCosmos = () => { return useCallback( (data: MintData) => { - const amount = convertDenomToMicroDenomWithDecimals( - data.amount, - governanceTokenInfo.decimals - ) return makeStargateMessage({ stargate: { typeUrl: MsgMint.typeUrl, value: { sender: address, - amount: coin(amount, governanceTokenAddress), + amount: coin( + convertDenomToMicroDenomStringWithDecimals( + data.amount, + governanceTokenInfo.decimals + ), + governanceTokenAddress + ), } as MsgMint, }, }) diff --git a/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/components/StakingModal.tsx b/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/components/StakingModal.tsx index 6cf362c00..b25581dcb 100644 --- a/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/components/StakingModal.tsx +++ b/packages/stateful/voting-module-adapter/adapters/DaoVotingNativeStaked/components/StakingModal.tsx @@ -17,6 +17,7 @@ import { import { BaseStakingModalProps } from '@dao-dao/types' import { CHAIN_GAS_MULTIPLIER, + convertDenomToMicroDenomStringWithDecimals, convertDenomToMicroDenomWithDecimals, convertMicroDenomToDenomWithDecimals, processError, @@ -117,7 +118,7 @@ const InnerStakingModal = ({ CHAIN_GAS_MULTIPLIER, undefined, coins( - convertDenomToMicroDenomWithDecimals( + convertDenomToMicroDenomStringWithDecimals( amount, governanceToken.decimals ), diff --git a/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/actions/Mint/index.tsx b/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/actions/Mint/index.tsx index fa40576cb..cdf71f4af 100644 --- a/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/actions/Mint/index.tsx +++ b/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/actions/Mint/index.tsx @@ -18,7 +18,7 @@ import { UseTransformToCosmos, } from '@dao-dao/types/actions' import { - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertMicroDenomToDenomWithDecimals, isDecodedStargateMsg, makeStargateMessage, @@ -44,16 +44,18 @@ const useTransformToCosmos: UseTransformToCosmos = () => { return useCallback( (data: MintData) => { - const amount = convertDenomToMicroDenomWithDecimals( - data.amount, - governanceTokenInfo.decimals - ) return makeStargateMessage({ stargate: { typeUrl: MsgMint.typeUrl, value: { sender: address, - amount: coin(amount, governanceTokenAddress), + amount: coin( + convertDenomToMicroDenomStringWithDecimals( + data.amount, + governanceTokenInfo.decimals + ), + governanceTokenAddress + ), } as MsgMint, }, }) diff --git a/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/components/StakingModal.tsx b/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/components/StakingModal.tsx index fd81e6582..06a3e8c67 100644 --- a/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/components/StakingModal.tsx +++ b/packages/stateful/voting-module-adapter/adapters/DaoVotingTokenStaked/components/StakingModal.tsx @@ -17,6 +17,7 @@ import { import { BaseStakingModalProps } from '@dao-dao/types' import { CHAIN_GAS_MULTIPLIER, + convertDenomToMicroDenomStringWithDecimals, convertDenomToMicroDenomWithDecimals, convertMicroDenomToDenomWithDecimals, processError, @@ -117,7 +118,7 @@ const InnerStakingModal = ({ CHAIN_GAS_MULTIPLIER, undefined, coins( - convertDenomToMicroDenomWithDecimals( + convertDenomToMicroDenomStringWithDecimals( amount, governanceToken.decimals ), diff --git a/packages/stateful/widgets/widgets/VestingPayments/actions/ManageVesting/index.tsx b/packages/stateful/widgets/widgets/VestingPayments/actions/ManageVesting/index.tsx index ea1e63b33..030e0002b 100644 --- a/packages/stateful/widgets/widgets/VestingPayments/actions/ManageVesting/index.tsx +++ b/packages/stateful/widgets/widgets/VestingPayments/actions/ManageVesting/index.tsx @@ -35,7 +35,7 @@ import { } from '@dao-dao/types/contracts/CwPayrollFactory' import { InstantiateMsg as VestingInstantiateMsg } from '@dao-dao/types/contracts/CwVesting' import { - convertDenomToMicroDenomWithDecimals, + convertDenomToMicroDenomStringWithDecimals, convertDurationWithUnitsToSeconds, convertMicroDenomToDenomWithDecimals, convertSecondsToDurationWithUnits, @@ -518,10 +518,10 @@ export const makeManageVestingActionMaker = ({ throw new Error(`Unknown token: ${begin.denomOrAddress}`) } - const amount = convertDenomToMicroDenomWithDecimals( + const amount = convertDenomToMicroDenomStringWithDecimals( begin.amount, token.decimals - ).toString() + ) const instantiateMsg: VestingInstantiateMsg = { denom: diff --git a/packages/stateful/widgets/widgets/WyndDeposit/WyndDepositRenderer.tsx b/packages/stateful/widgets/widgets/WyndDeposit/WyndDepositRenderer.tsx index f0556397d..83ac39a83 100644 --- a/packages/stateful/widgets/widgets/WyndDeposit/WyndDepositRenderer.tsx +++ b/packages/stateful/widgets/widgets/WyndDeposit/WyndDepositRenderer.tsx @@ -309,7 +309,7 @@ export const WyndDepositRenderer = ({ msg, CHAIN_GAS_MULTIPLIER, undefined, - coins(requiredInput, token.denomOrAddress) + coins(BigInt(requiredInput).toString(), token.denomOrAddress) ) } else { // Cw20 diff --git a/packages/utils/conversion.ts b/packages/utils/conversion.ts index 4448e25cb..66b970e14 100644 --- a/packages/utils/conversion.ts +++ b/packages/utils/conversion.ts @@ -38,6 +38,12 @@ export function convertDenomToMicroDenomWithDecimals( return isNaN(amount) ? 0 : amount } +// Using BigInt.toString() ensures the value is not abbreviated. The +// Number.toString() function abbreviates large numbers like 1e20. +export const convertDenomToMicroDenomStringWithDecimals = ( + ...params: Parameters +) => BigInt(convertDenomToMicroDenomWithDecimals(...params)).toString() + export function convertFromMicroDenom(denom: string) { return denom?.substring(1).toUpperCase() } From 198326add61736ea9566b9450cf0b3fead08fa27 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 2 Nov 2023 11:49:16 -0400 Subject: [PATCH 2/4] Trim DAO name on creation. --- .../actions/core/dao_governance/UpgradeV1ToV2/index.tsx | 4 +++- packages/stateful/components/dao/CreateDaoForm.tsx | 2 +- packages/stateful/creators/MembershipBased/mutate.ts | 2 +- packages/stateful/creators/NftBased/mutate.ts | 2 +- packages/stateful/creators/TokenBased/mutate.ts | 2 +- .../DaoProposalMultiple/daoCreation/getInstantiateInfo.ts | 4 ++-- .../DaoProposalSingle/daoCreation/getInstantiateInfo.ts | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/stateful/actions/core/dao_governance/UpgradeV1ToV2/index.tsx b/packages/stateful/actions/core/dao_governance/UpgradeV1ToV2/index.tsx index 00c798bd1..350f026f3 100644 --- a/packages/stateful/actions/core/dao_governance/UpgradeV1ToV2/index.tsx +++ b/packages/stateful/actions/core/dao_governance/UpgradeV1ToV2/index.tsx @@ -283,7 +283,9 @@ export const makeUpgradeV1ToV2Action: ActionMaker = ({ info: { admin: { core_module: {} }, code_id: codeIds.DaoPreProposeSingle, - label: `DAO_${name}_pre-propose-${DaoProposalSingleAdapter.id}`, + label: `DAO_${name.trim()}_pre-propose-${ + DaoProposalSingleAdapter.id + }`, msg: Buffer.from( JSON.stringify({ deposit_info: depositInfo diff --git a/packages/stateful/components/dao/CreateDaoForm.tsx b/packages/stateful/components/dao/CreateDaoForm.tsx index 3ee7201b6..e0d3b771b 100644 --- a/packages/stateful/components/dao/CreateDaoForm.tsx +++ b/packages/stateful/components/dao/CreateDaoForm.tsx @@ -333,7 +333,7 @@ export const InnerCreateDaoForm = ({ automatically_add_cw721s: true, description, image_url: imageUrl ?? null, - name, + name: name.trim(), proposal_modules_instantiate_info: proposalModuleInstantiateInfos, // Placeholder. Should be replaced by creator's mutate function. voting_module_instantiate_info: { diff --git a/packages/stateful/creators/MembershipBased/mutate.ts b/packages/stateful/creators/MembershipBased/mutate.ts index c1f12ac3d..f7ecd4be6 100644 --- a/packages/stateful/creators/MembershipBased/mutate.ts +++ b/packages/stateful/creators/MembershipBased/mutate.ts @@ -50,7 +50,7 @@ export const mutate: DaoCreatorMutate = ( msg.voting_module_instantiate_info = { admin: { core_module: {} }, code_id: codeIds.DaoVotingCw4, - label: `DAO_${name}_${MembershipBasedCreatorId}`, + label: `DAO_${name.trim()}_${MembershipBasedCreatorId}`, msg: Buffer.from( JSON.stringify(votingModuleAdapterInstantiateMsg), 'utf8' diff --git a/packages/stateful/creators/NftBased/mutate.ts b/packages/stateful/creators/NftBased/mutate.ts index 2f332afc1..e22fc304f 100644 --- a/packages/stateful/creators/NftBased/mutate.ts +++ b/packages/stateful/creators/NftBased/mutate.ts @@ -40,7 +40,7 @@ export const mutate: DaoCreatorMutate = ( msg.voting_module_instantiate_info = { admin: { core_module: {} }, code_id: codeIds.DaoVotingCw721Staked, - label: `DAO_${daoName}_${NftBasedCreatorId}`, + label: `DAO_${daoName.trim()}_${NftBasedCreatorId}`, msg: Buffer.from( JSON.stringify(votingModuleAdapterInstantiateMsg), 'utf8' diff --git a/packages/stateful/creators/TokenBased/mutate.ts b/packages/stateful/creators/TokenBased/mutate.ts index f1506fd89..6d99f72aa 100644 --- a/packages/stateful/creators/TokenBased/mutate.ts +++ b/packages/stateful/creators/TokenBased/mutate.ts @@ -129,7 +129,7 @@ export const mutate: DaoCreatorMutate = ( msg.voting_module_instantiate_info = { admin: { core_module: {} }, code_id: codeIds.DaoVotingTokenStaked, - label: `DAO_${daoName}_${TokenBasedCreatorId}`, + label: `DAO_${daoName.trim()}_${TokenBasedCreatorId}`, msg: Buffer.from( JSON.stringify(votingModuleAdapterInstantiateMsg), 'utf8' diff --git a/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/daoCreation/getInstantiateInfo.ts b/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/daoCreation/getInstantiateInfo.ts index a8961c3bd..5ebbb4872 100644 --- a/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/daoCreation/getInstantiateInfo.ts +++ b/packages/stateful/proposal-module-adapter/adapters/DaoProposalMultiple/daoCreation/getInstantiateInfo.ts @@ -87,7 +87,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo = ( info: { admin: { core_module: {} }, code_id: codeIds.DaoPreProposeMultiple, - label: `DAO_${name}_pre-propose-${DaoProposalMultipleAdapterId}`, + label: `DAO_${name.trim()}_pre-propose-${DaoProposalMultipleAdapterId}`, msg: Buffer.from( JSON.stringify(preProposeMultipleInstantiateMsg), 'utf8' @@ -112,7 +112,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo = ( return { admin: { core_module: {} }, code_id: codeIds.DaoProposalMultiple, - label: `DAO_${name}_${DaoProposalMultipleAdapterId}`, + label: `DAO_${name.trim()}_${DaoProposalMultipleAdapterId}`, msg: Buffer.from(JSON.stringify(msg), 'utf8').toString('base64'), // TODO(neutron-2.3.0): add back in here and in instantiate schema. ...(chainId !== ChainId.NeutronMainnet && { diff --git a/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/daoCreation/getInstantiateInfo.ts b/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/daoCreation/getInstantiateInfo.ts index db63e06a6..4fa5deaff 100644 --- a/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/daoCreation/getInstantiateInfo.ts +++ b/packages/stateful/proposal-module-adapter/adapters/DaoProposalSingle/daoCreation/getInstantiateInfo.ts @@ -88,7 +88,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo< info: { admin: { core_module: {} }, code_id: codeIds.DaoPreProposeSingle, - label: `DAO_${name}_pre-propose-${DaoProposalSingleAdapterId}`, + label: `DAO_${name.trim()}_pre-propose-${DaoProposalSingleAdapterId}`, msg: Buffer.from( JSON.stringify(preProposeSingleInstantiateMsg), 'utf8' @@ -115,7 +115,7 @@ export const getInstantiateInfo: DaoCreationGetInstantiateInfo< return { admin: { core_module: {} }, code_id: codeIds.DaoProposalSingle, - label: `DAO_${name}_${DaoProposalSingleAdapterId}`, + label: `DAO_${name.trim()}_${DaoProposalSingleAdapterId}`, msg: Buffer.from(JSON.stringify(msg), 'utf8').toString('base64'), // TODO(neutron-2.3.0): add back in here and in instantiate schema. ...(chainId !== ChainId.NeutronMainnet && { From ae72d3c54867caa82fb6696300515356b28ce49e Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 2 Nov 2023 11:59:51 -0400 Subject: [PATCH 3/4] Fixed Me page crash if any chain doesn't load its tokens. --- packages/stateful/components/pages/MeBalances.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/stateful/components/pages/MeBalances.tsx b/packages/stateful/components/pages/MeBalances.tsx index dfadf415b..887e3b059 100644 --- a/packages/stateful/components/pages/MeBalances.tsx +++ b/packages/stateful/components/pages/MeBalances.tsx @@ -1,4 +1,4 @@ -import { waitForAll, waitForAllSettled } from 'recoil' +import { waitForAllSettled } from 'recoil' import { MeBalances as StatelessMeBalances, @@ -28,7 +28,7 @@ export const MeBalances = () => { const tokensWithoutLazyInfo = useCachedLoading( walletAddress - ? waitForAll( + ? waitForAllSettled( getSupportedChains().map(({ chain }) => walletTokenCardInfosSelector({ chainId: chain.chain_id, @@ -45,7 +45,9 @@ export const MeBalances = () => { const flattenedTokensWithoutLazyInfo = tokensWithoutLazyInfo.loading ? [] - : tokensWithoutLazyInfo.data.flat() + : tokensWithoutLazyInfo.data.flatMap((loadable) => + loadable.state === 'hasValue' ? loadable.contents : [] + ) // Load separately so they cache separately. const tokenLazyInfos = useCachedLoading( @@ -64,7 +66,9 @@ export const MeBalances = () => { ) const tokens: LoadingData = - tokensWithoutLazyInfo.loading || tokenLazyInfos.loading + tokensWithoutLazyInfo.loading || + tokenLazyInfos.loading || + flattenedTokensWithoutLazyInfo.length !== tokenLazyInfos.data.length ? { loading: true, } From f07dd2ecefc1bbe2f4410644e206585514857e51 Mon Sep 17 00:00:00 2001 From: Noah Saso Date: Thu, 2 Nov 2023 18:07:16 -0400 Subject: [PATCH 4/4] Fix non-unique keys. --- packages/stateless/pages/MeBalances.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/stateless/pages/MeBalances.tsx b/packages/stateless/pages/MeBalances.tsx index d825b61c8..60b104918 100644 --- a/packages/stateless/pages/MeBalances.tsx +++ b/packages/stateless/pages/MeBalances.tsx @@ -127,7 +127,7 @@ export const MeBalances = ({
{visibleBalances.map((props, index) => ( @@ -159,7 +159,7 @@ export const MeBalances = ({
{hiddenBalances.map((props, index) => (