Skip to content

Commit

Permalink
Merge pull request #1461 from DA0-DA0/development
Browse files Browse the repository at this point in the history
Deploy fixes
  • Loading branch information
NoahSaso authored Nov 9, 2023
2 parents 6827f84 + d5f95b9 commit 41322be
Show file tree
Hide file tree
Showing 39 changed files with 446 additions and 262 deletions.
6 changes: 5 additions & 1 deletion packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"createAProposal": "Create a proposal",
"createAToken": "Create a token",
"createAccount": "Create account",
"createCrossChainAccount": "Create cross-chain account",
"createDAO": "Create DAO",
"createNftCollection": "Create NFT collection",
"createSubDao": "Create SubDAO",
Expand Down Expand Up @@ -397,8 +398,10 @@
"proposalNotFound": "Proposal not found.",
"relayerAlreadySetUp": "Relayer already set up.",
"relayerNotSetUp": "Relayer not set up.",
"selectAChainToContinue": "Select a chain to continue.",
"simulationFailedInvalidProposalActions": "Simulation failed. Verify your proposal actions are valid.",
"stakeInsufficient": "The DAO has {{amount}} ${{tokenSymbol}} staked, which is insufficient.",
"stargazeDaoNoCrossChainAccountsForPress": "This Stargaze DAO has no cross-chain accounts, and Press does not work on Stargaze. Create a cross-chain account for the DAO before setting up Press.",
"subDaoAlreadyExists": "SubDAO already exists.",
"tokenSwapContractNotChosen": "You must create a token swap or enter the address of an existing token swap before using this action.",
"tooFewChoices": "The proposal must have at least two choices.",
Expand Down Expand Up @@ -762,7 +765,7 @@
"createNftCollectionDescription_gov": "Create a new NFT collection controlled by the chain.",
"createNftCollectionDescription_wallet": "Create a new NFT collection controlled by you.",
"createPostDescription": "Create a post on the DAO's press.",
"createPressContract": "To publish content, you must first create a press contract.",
"createPressContract": "To set up Press, you must first create a smart contract to manage it.",
"createStep1": "Pick a DAO type and name it",
"createStep2": "Governance configuration",
"createStep3": "Voting configuration",
Expand Down Expand Up @@ -978,6 +981,7 @@
"searchMessages": "Search messages",
"searchNftsPlaceholder": "Find an NFT...",
"searchValidatorsPlaceholder": "Find a validator...",
"selectPressChain": "Each post will be minted as an NFT on this chain and then deposited into the DAO's treasury.",
"selfRelayDescription": "One or more messages in this proposal require self-relaying across chains since automatic relayers do not exist or are inactive right now.",
"setUpDiscordNotificationsTooltip": "Set up Discord notifications",
"signedInAs": "Signed in as {{name}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ const Component: ActionComponent<undefined, GovernanceVoteData> = (props) => {
: constSelector(undefined)
)

const address = getChainAddressForActionOptions(options, chainId)
const existingVotesLoading = loadableToLoadingData(
useRecoilValueLoadable(
proposalId
proposalId && address
? govProposalVoteSelector({
proposalId: Number(proposalId),
voter: getChainAddressForActionOptions(options, chainId),
voter: address,
chainId,
})
: constSelector(undefined)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const makeValidatorActionsAction: ActionMaker<ValidatorActionsData> = (

const getValidatorAddress = (chainId: string) =>
toValidatorAddress(
getChainAddressForActionOptions(options, chainId),
getChainAddressForActionOptions(options, chainId) || '',
getChainForChainId(chainId).bech32_prefix
)

Expand Down Expand Up @@ -181,8 +181,11 @@ export const makeValidatorActionsAction: ActionMaker<ValidatorActionsData> = (

const data = useDefaults()

// Check this is a stargate message.
if (!isDecodedStargateMsg(msg)) {
if (
!thisAddress ||
// Check this is a stargate message.
!isDecodedStargateMsg(msg)
) {
return { match: false }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export const makeManageWidgetsAction: ActionMaker<ManageWidgetsData> = ({
// V1 DAOs and V2-alpha DAOs use a value key of `addr`, the rest use `value`.
const valueKey =
context.info.coreVersion === ContractVersion.V1 ||
context.info.coreVersion === ContractVersion.V2Alpha
context.info.coreVersion === ContractVersion.V2Alpha ||
context.info.coreVersion === ContractVersion.NeutronV021
? 'addr'
: 'value'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export const makeManageStorageItemsAction: ActionMaker<
// V1 DAOs and V2-alpha DAOs use a value key of `addr`, V2-beta uses `value`.
const valueKey =
context.info.coreVersion === ContractVersion.V1 ||
context.info.coreVersion === ContractVersion.V2Alpha
context.info.coreVersion === ContractVersion.V2Alpha ||
context.info.coreVersion === ContractVersion.NeutronV021
? 'addr'
: 'value'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export const makeCreateNftCollectionAction: ActionMaker<
}

const creator = getChainAddressForActionOptions(options, chainId)
if (!creator) {
throw new Error(t('error.loadingData'))
}

return maybeMakePolytoneExecuteMessage(
currentChainId,
Expand Down
3 changes: 2 additions & 1 deletion packages/stateful/actions/core/nfts/ManageCw721/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ export const makeManageCw721Action: ActionMaker<ManageCw721Data> = ({
// V1 DAOs and V2-alpha DAOs use a value key of `addr`, V2-beta uses `value`.
const storageItemValueKey =
context.info.coreVersion === ContractVersion.V1 ||
context.info.coreVersion === ContractVersion.V2Alpha
context.info.coreVersion === ContractVersion.V2Alpha ||
context.info.coreVersion === ContractVersion.NeutronV021
? 'addr'
: 'value'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,19 @@ export const InstantiateNftCollection: ActionComponent = (props) => {
toast.error(t('error.loadingData'))
return
}

if (!walletAddress) {
toast.error(t('error.logInToContinue'))
return
}

if (!codeIds.Cw721Base) {
const minter = getChainAddressForActionOptions(options, chainId)
if (!codeIds.Cw721Base || !minter) {
toast.error(t('error.invalidChain'))
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setInstantiating(true)
try {
const minter = getChainAddressForActionOptions(options, chainId)
const signingCosmWasmClient = await getSigningCosmWasmClient()
const contractAddress = await instantiateSmartContract(
signingCosmWasmClient,
walletAddress,
Expand Down
3 changes: 2 additions & 1 deletion packages/stateful/actions/core/nfts/MintNft/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const Component: ActionComponent<undefined, MintNftData> = (props) => {
fieldName={props.fieldNamePrefix + 'chainId'}
onChange={(chainId) => {
// Update recipient to correct address.
const newAddress = getChainAddressForActionOptions(options, chainId)
const newAddress =
getChainAddressForActionOptions(options, chainId) || ''

setValue(
(props.fieldNamePrefix + 'mintMsg.owner') as 'mintMsg.owner',
Expand Down
10 changes: 6 additions & 4 deletions packages/stateful/actions/core/nfts/TransferNft/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -18,6 +17,7 @@ import {
import {
combineLoadingDataWithErrors,
decodePolytoneExecuteMsg,
encodeMessageAsBase64,
makeWasmMessage,
maybeMakePolytoneExecuteMessage,
objectMatchesStructure,
Expand Down Expand Up @@ -78,7 +78,7 @@ const useTransformToCosmos: UseTransformToCosmos<TransferNftData> = () => {
? {
send_nft: {
contract: recipient,
msg: toBase64(toUtf8(JSON.stringify(smartContractMsg))),
msg: encodeMessageAsBase64(smartContractMsg),
token_id: tokenId,
},
}
Expand Down Expand Up @@ -156,8 +156,10 @@ const useDecodedCosmosMsg: UseDecodedCosmosMsg<TransferNftData> = (
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
),
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const Component: ActionComponent = (props) => {
setValue((props.fieldNamePrefix + 'funds') as 'funds', [])
setValue(
(props.fieldNamePrefix + 'admin') as 'admin',
getChainAddressForActionOptions(options, chainId)
getChainAddressForActionOptions(options, chainId) || ''
)
}}
/>
Expand Down
19 changes: 9 additions & 10 deletions packages/stateful/actions/core/treasury/ManageStaking/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { coin, parseCoins } from '@cosmjs/amino'
import { useCallback } from 'react'
import { useFormContext } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
import { constSelector } from 'recoil'

import {
nativeDelegationInfoSelector,
Expand Down Expand Up @@ -189,8 +190,6 @@ const InnerComponent: ActionComponent = (props) => {
throw new Error(t('error.missingNativeToken'))
}

const address = getChainAddressForActionOptions(options, chainId)

// These need to be loaded via cached loadables to avoid displaying a loader
// when this data updates on a schedule. Manually trigger a suspense loader
// the first time when the initial data is still loading.
Expand All @@ -215,15 +214,15 @@ const InnerComponent: ActionComponent = (props) => {
),
}

const address = getChainAddressForActionOptions(options, chainId)
const loadingNativeDelegationInfo = useCachedLoading(
nativeDelegationInfoSelector({
chainId,
address,
}),
{
delegations: [],
unbondingDelegations: [],
}
address
? nativeDelegationInfoSelector({
chainId,
address,
})
: constSelector(undefined),
undefined
)

const loadingValidators = useCachedLoading(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ export const InstantiateTokenSwap: ActionComponent<
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setInstantiating(true)

try {
const instantiateMsg: InstantiateMsg = {
counterparty_one: {
Expand Down Expand Up @@ -110,6 +107,7 @@ export const InstantiateTokenSwap: ActionComponent<
},
}

const signingCosmWasmClient = await getSigningCosmWasmClient()
const contractAddress = await instantiateSmartContract(
signingCosmWasmClient,
walletAddress,
Expand Down
4 changes: 2 additions & 2 deletions packages/stateful/components/StargazeNftImportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export const InnerStargazeNftImportModal = ({
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setLoading(true)
try {
const signingCosmWasmClient = await getSigningCosmWasmClient()

const selectedNfts = nfts.data.filter((nft) =>
selected.includes(getIdForNft(nft))
)
Expand Down
4 changes: 2 additions & 2 deletions packages/stateful/components/WalletStakingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ export const WalletStakingModal = (props: WalletStakingModalProps) => {
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setLoading(true)
try {
const signingCosmWasmClient = await getSigningCosmWasmClient()

const microAmount = convertDenomToMicroDenomStringWithDecimals(
amount,
nativeToken.decimals
Expand Down
3 changes: 1 addition & 2 deletions packages/stateful/components/WalletTokenCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,9 @@ export const WalletTokenCard = (props: TokenCardInfo) => {
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setClaimLoading(true)
try {
const signingCosmWasmClient = await getSigningCosmWasmClient()
await signingCosmWasmClient.signAndBroadcast(
walletAddress,
(lazyInfo.loading ? [] : lazyInfo.data.stakingInfo!.stakes).map(
Expand Down
3 changes: 1 addition & 2 deletions packages/stateful/components/dao/DaoTokenDepositModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ export const DaoTokenDepositModal = ({
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setLoading(true)
try {
const microAmount = convertDenomToMicroDenomStringWithDecimals(
Expand All @@ -107,6 +105,7 @@ export const DaoTokenDepositModal = ({
)

if (token.type === 'native') {
const signingCosmWasmClient = await getSigningCosmWasmClient()
await signingCosmWasmClient.sendTokens(
address,
depositAddress,
Expand Down
3 changes: 1 addition & 2 deletions packages/stateful/components/pages/MeTransactionBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ export const MeTransactionBuilder = () => {
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setLoading(true)
setError('')
setTxHash('')

try {
const signingCosmWasmClient = await getSigningCosmWasmClient()
const encodeObjects = data.map((msg) =>
cwMsgToEncodeObject(msg, walletAddress)
)
Expand Down
3 changes: 1 addition & 2 deletions packages/stateful/hooks/useInstantiateAndExecute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ export const useInstantiateAndExecute = (
throw new Error(t('error.logInToContinue'))
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

// Get the checksum of the contract code.
const checksum = fromHex(codeDetailsLoadable.contents.checksum)
// Random salt.
Expand Down Expand Up @@ -118,6 +116,7 @@ export const useInstantiateAndExecute = (
),
]

const signingCosmWasmClient = await getSigningCosmWasmClient()
const response = (await signingCosmWasmClient.signAndBroadcast(
address,
messages.map((msg) => cwMsgToEncodeObject(msg, address)),
Expand Down
23 changes: 11 additions & 12 deletions packages/stateful/widgets/core.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { ChainId, Widget } from '@dao-dao/types'
import { Widget } from '@dao-dao/types'

import {
PressWidget,
RetroactiveCompensationWidget,
VestingPaymentsWidget,
WyndDepositWidget,
} from './widgets'

// Add widgets here.
export const getWidgets = (chainId: string): readonly Widget[] => [
// MintNftWidget,

VestingPaymentsWidget,
RetroactiveCompensationWidget,
PressWidget,

// WYND only available on Juno mainnet.
...(chainId === ChainId.JunoMainnet ? [WyndDepositWidget] : []),
]
export const getWidgets = (chainId: string): readonly Widget[] =>
[
// MintNftWidget,
VestingPaymentsWidget,
RetroactiveCompensationWidget,
PressWidget,
].filter(
(widget) =>
!widget.supportedChainIds || widget.supportedChainIds.includes(chainId)
)

export const getWidgetById = (chainId: string, id: string) =>
getWidgets(chainId).find((widget) => widget.id === id)
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ export const MintNftRenderer = ({
return
}

const signingCosmWasmClient = await getSigningCosmWasmClient()

setMinting(true)
try {
const signingCosmWasmClient = await getSigningCosmWasmClient()
await signingCosmWasmClient.execute(
walletAddress,
contract,
Expand Down
Loading

2 comments on commit 41322be

@vercel
Copy link

@vercel vercel bot commented on 41322be Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 41322be Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.