Skip to content

Commit

Permalink
Merge pull request #1297 from DA0-DA0/development
Browse files Browse the repository at this point in the history
Deploy recent fixes
  • Loading branch information
NoahSaso authored Jul 5, 2023
2 parents 84e5821 + 306be7e commit 11fb721
Show file tree
Hide file tree
Showing 108 changed files with 2,161 additions and 1,467 deletions.
1 change: 1 addition & 0 deletions apps/dapp/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NEXT_PUBLIC_LEGACY_URL_PREFIX=https://legacy.daodao.zone
NEXT_PUBLIC_SDA_URL_PREFIX=https://dao.testnet.daodao.zone
NEXT_PUBLIC_DAPP_URL_PREFIX=https://testnet.daodao.zone
NEXT_PUBLIC_DAO_DAO_DAO_ADDRESS=
NEXT_PUBLIC_WALLET_URL_PREFIX=https://testnet.mintscan.io/juno-testnet/account/

# https://dashboard.web3auth.io
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=BKloh0zJRJMSnZnro2qr6eDkT2echfshttYXPnCwb7BcAawwYJF9Df_xDoXGD4EE_l2tToFoByp890nl8HTGKMY
Expand Down
1 change: 1 addition & 0 deletions apps/dapp/.env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NEXT_PUBLIC_LEGACY_URL_PREFIX=https://legacy.daodao.zone
NEXT_PUBLIC_SDA_URL_PREFIX=https://dao.daodao.zone
NEXT_PUBLIC_DAPP_URL_PREFIX=https://daodao.zone
NEXT_PUBLIC_DAO_DAO_DAO_ADDRESS=juno10h0hc64jv006rr8qy0zhlu4jsxct8qwa0vtaleayh0ujz0zynf2s2r7v8q
NEXT_PUBLIC_WALLET_URL_PREFIX=https://mintscan.io/juno/account/

# https://dashboard.web3auth.io
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=BMGcq4QJkuTZoUZl3P_jk4X5uy3BsamFBzaFRmhwkRf16B3m4ZW--pP7Nbk8zlOt-u5SuXYbs2KigxnxxEz437k
Expand Down
1 change: 1 addition & 0 deletions apps/sda/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NEXT_PUBLIC_LEGACY_URL_PREFIX=https://legacy.daodao.zone
NEXT_PUBLIC_SDA_URL_PREFIX=https://dao.testnet.daodao.zone
NEXT_PUBLIC_DAPP_URL_PREFIX=https://testnet.daodao.zone
NEXT_PUBLIC_DAO_DAO_DAO_ADDRESS=
NEXT_PUBLIC_WALLET_URL_PREFIX=https://testnet.mintscan.io/juno-testnet/account/

# https://dashboard.web3auth.io
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=BKloh0zJRJMSnZnro2qr6eDkT2echfshttYXPnCwb7BcAawwYJF9Df_xDoXGD4EE_l2tToFoByp890nl8HTGKMY
Expand Down
1 change: 1 addition & 0 deletions apps/sda/.env.mainnet
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ NEXT_PUBLIC_LEGACY_URL_PREFIX=https://legacy.daodao.zone
NEXT_PUBLIC_SDA_URL_PREFIX=https://dao.daodao.zone
NEXT_PUBLIC_DAPP_URL_PREFIX=https://daodao.zone
NEXT_PUBLIC_DAO_DAO_DAO_ADDRESS=juno10h0hc64jv006rr8qy0zhlu4jsxct8qwa0vtaleayh0ujz0zynf2s2r7v8q
NEXT_PUBLIC_WALLET_URL_PREFIX=https://mintscan.io/juno/account/

# https://dashboard.web3auth.io
NEXT_PUBLIC_WEB3AUTH_CLIENT_ID=BMGcq4QJkuTZoUZl3P_jk4X5uy3BsamFBzaFRmhwkRf16B3m4ZW--pP7Nbk8zlOt-u5SuXYbs2KigxnxxEz437k
Expand Down
17 changes: 7 additions & 10 deletions packages/i18n/locales/dog/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,18 @@
"useExistingToken": "us an existin tokken",
"withDecodedModuleMessages": "wif dekodded modul messajez"
},
"daoCreationAdapter": {
"DaoProposalSingle": {
"advancedWarning": "deez iz advancd fitchurz. threshhold n kwurum kan interact in counterintuitev wayz. if u configure dem wifout fullie understanding how dey werk, u kan lock yer da0, makin it impossibul 4 puppozalz 2 passs."
"daoCreator": {
"MembershipBased": {
"description": "smol organizashon wif a few membberz hoo are likely 2 stick aroun. membberz can b addd n remoovd by a voat ov existin membberz",
"membership": "by invitashon",
"name": "membarship da0 (mullteesig)",
"supplies": "none"
},
"DaoVotingCw20Staked": {
"TokenBased": {
"description": "fluud organizashon wif manie memberz hoo can joinn n leev az dey wish. memberz can alter der goobernanz powa n particippashon by exchangin tokenz.",
"membership": "bi steakin tokkenz",
"name": "tokken-based da0",
"supplies": "tokkenz"
},
"DaoVotingCw4": {
"description": "smol organizashon wif a few membberz hoo are likely 2 stick aroun. membberz can b addd n remoovd by a voat ov existin membberz",
"membership": "by invitashon",
"name": "membarship da0 (mullteesig)",
"supplies": "none"
}
},
"depositRefundPolicy": {
Expand Down
27 changes: 17 additions & 10 deletions packages/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"continue": "Continue",
"continueEditing": "Continue editing",
"copy": "Copy",
"copyAddress": "Copy address",
"copyAddressToClipboard": "Copy address to clipboard",
"copyDaoAddress": "Copy DAO address",
"copyToClipboard": "Copy to clipboard",
Expand Down Expand Up @@ -175,24 +176,24 @@
"withdrawAvailableBalance": "Withdraw available balance",
"withdrawFiat": "Withdraw fiat"
},
"daoCreationAdapter": {
"DaoVotingCw20Staked": {
"description": "Fluid organization with many members who can join and leave as they wish. Members can alter their governance power and participation by exchanging tokens.",
"membership": "By staking tokens",
"name": "Token-based DAO",
"supplies": "Tokens"
},
"DaoVotingCw4": {
"daoCreator": {
"MembershipBased": {
"description": "Small organization with a few members who are likely to stick around. Members can be added and removed by a vote of existing members.",
"membership": "By invitation",
"name": "Membership DAO (Multisig)",
"supplies": "None"
},
"DaoVotingCw721Staked": {
"NftBased": {
"description": "Fluid organization with many members who can join and leave as they wish. Members can alter their governance power and participation by exchanging non-fungible tokens.",
"membership": "By staking NFTs",
"name": "Non-Fungible Token (NFT)-based DAO",
"supplies": "Non-Fungible Tokens"
},
"TokenBased": {
"description": "Fluid organization with many members who can join and leave as they wish. Members can alter their governance power and participation by exchanging tokens.",
"membership": "By staking tokens",
"name": "Token-based DAO",
"supplies": "Tokens"
}
},
"depositRefundPolicy": {
Expand Down Expand Up @@ -272,6 +273,7 @@
"errorOccurredOnPage": "An error occurred on this page.",
"failedParsingCoreVersion": "Failed to determine core version.",
"failedToFindGovernanceProposal": "Failed to find governance proposal with ID {{id}}.",
"failedToGetFactoryTokenInfo": "Failed to get factory token info. Please enter a valid factory denom.",
"failedToGetTokenInfo": "Failed to get token info. Please enter a valid {{tokenType}} contract address.",
"failedToLoadMembersDescription": "Members failed to load. Check your internet connection or try again later.",
"failedToLoadMembersTitle": "Failed to load members.",
Expand All @@ -292,6 +294,7 @@
"logInToCreate": "Log in to create a DAO.",
"logInToFollow": "Log in to follow a DAO.",
"missingGovernanceTokenAddress": "Missing governance token address.",
"missingGovernanceTokenDenom": "Missing governance token denom.",
"mustBeMemberToCreateCompensationCycle": "You must be a member of the DAO to create a compensation cycle.",
"mustBeMemberToCreatePost": "You must be a member of the DAO to create a post.",
"mustBeMemberToCreateProposal": "You must be a member of the DAO to create a proposal.",
Expand Down Expand Up @@ -459,6 +462,7 @@
"multipleChoiceOptionTitlePlaceholder": "Give your choice a title",
"multipleChoiceTitle": "Multiple choice proposals",
"name": "Name",
"nativeOrFactoryToken": "Native or factory token",
"nftCollectionAddress": "NFT collection address",
"nftMintInstructions": "Create a unique token ID for the NFT and enter the address of the initial owner below.",
"nftUploadMetadataInstructions": "Input the NFT's metadata, and then press 'Upload' to store it on IPFS.",
Expand Down Expand Up @@ -854,6 +858,8 @@
"token_one": "token",
"token_other": "tokens",
"tokens": "tokens",
"tokensWillBeSentToTreasury_dao": "These tokens will be sent to the DAO's treasury.",
"tokensWillBeSentToTreasury_wallet": "These tokens will be sent to your wallet.",
"tokensWillBeSplitAmongContributors": "{{tokens}} will be split among contributors.",
"tos": "DAO DAO TOOLING IS PROVIDED \"AS IS\", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. No developer or entity involved in creating the DAO DAO UI or smart contracts will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of DAO DAO tooling, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.",
"totalHoldings": "Total holdings",
Expand Down Expand Up @@ -885,7 +891,7 @@
"upgradeToV2Explanation": "This upgrades your DAO's contracts to the latest audited version. Below you may register any SubDAOs that were created while this DAO was using v1. SubDAOs can use any version, but v2 is recommended.",
"validatorActionsDescription": "Make transactions related to running a validator.",
"verifyAddressMatches": "Verify that the following address matches the 'Send To' address in the widget below.",
"verifyingGovernanceToken": "Verifying CW20 token...",
"verifyingGovernanceToken": "Verifying governance token...",
"vestingIsCancellableByOther": "This vesting payment can be cancelled by the following address after it's created.",
"vestingIsCancellableByOwner_dao": "This vesting payment can be cancelled by the DAO after it's created.",
"vestingIsCancellableByOwner_wallet": "You will be able to cancel this vesting payment after it's created.",
Expand Down Expand Up @@ -1067,6 +1073,7 @@
"executeSmartContract": "Execute Smart Contract",
"existingToken": "Existing token",
"expires": "Expires",
"factoryToken": "Factory token",
"featuredDaos": "Featured DAOs",
"feeShare": "Fee share",
"fiatOnOffRamp": "Fiat on/off ramp",
Expand Down
64 changes: 48 additions & 16 deletions packages/state/recoil/selectors/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { ChainInfoID } from '@noahsaso/cosmodal'
import { ProposalStatus } from 'cosmjs-types/cosmos/gov/v1beta1/gov'
import { cosmos, juno } from 'interchain-rpc'
import { Metadata } from 'interchain-rpc/types/codegen/cosmos/bank/v1beta1/bank'
import { DelegationDelegatorReward } from 'interchain-rpc/types/codegen/cosmos/distribution/v1beta1/distribution'
import {
Proposal as GovProposal,
Expand All @@ -19,6 +20,7 @@ import {
UnbondingDelegation as RpcUnbondingDelegation,
Validator as RpcValidator,
} from 'interchain-rpc/types/codegen/cosmos/staking/v1beta1/staking'
import { osmosis } from 'juno-network'
import Long from 'long'
import { selector, selectorFamily, waitForAll } from 'recoil'

Expand Down Expand Up @@ -61,10 +63,10 @@ export const stargateClientForChainSelector = selectorFamily<
string | undefined
>({
key: 'stargateClientForChain',
get: (chainId) => async () =>
await stargateClientRouter.connect(
chainId ? getRpcForChainId(chainId) : getRpcForChainId(CHAIN_ID)
),
get:
(chainId: string = CHAIN_ID) =>
async () =>
await stargateClientRouter.connect(getRpcForChainId(chainId)),
dangerouslyAllowMutability: true,
})

Expand All @@ -73,23 +75,23 @@ export const cosmWasmClientForChainSelector = selectorFamily<
string | undefined
>({
key: 'cosmWasmClientForChain',
get: (chainId) => async () =>
await cosmWasmClientRouter.connect(
chainId ? getRpcForChainId(chainId) : getRpcForChainId(CHAIN_ID)
),
get:
(chainId = CHAIN_ID) =>
async () =>
await cosmWasmClientRouter.connect(getRpcForChainId(chainId)),
dangerouslyAllowMutability: true,
})

export const cosmosRpcClientForChainSelector = selectorFamily({
key: 'cosmosRpcClientForChain',
get: (chainId?: string) => async () =>
(
await cosmos.ClientFactory.createRPCQueryClient({
rpcEndpoint: chainId
? getRpcForChainId(chainId)
: getRpcForChainId(CHAIN_ID),
})
).cosmos,
get:
(chainId: string = CHAIN_ID) =>
async () =>
(
await cosmos.ClientFactory.createRPCQueryClient({
rpcEndpoint: getRpcForChainId(chainId),
})
).cosmos,
dangerouslyAllowMutability: true,
})

Expand All @@ -104,6 +106,19 @@ export const junoRpcClientSelector = selector({
dangerouslyAllowMutability: true,
})

export const osmosisRpcClientForChainSelector = selectorFamily({
key: 'osmosisRpcClientForChain',
get:
(chainId: string = CHAIN_ID) =>
async () =>
(
await osmosis.ClientFactory.createRPCQueryClient({
rpcEndpoint: getRpcForChainId(chainId),
})
).osmosis,
dangerouslyAllowMutability: true,
})

export const blockHeightSelector = selectorFamily<number, WithChainId<{}>>({
key: 'blockHeight',
get:
Expand Down Expand Up @@ -662,3 +677,20 @@ export const validatorSlashesSelector = selectorFamily<
})
)) ?? [],
})

export const denomMetadataSelector = selectorFamily<
Metadata,
WithChainId<{ denom: string }>
>({
key: 'denomMetadata',
get:
({ denom, chainId }) =>
async ({ get }) => {
const client = get(cosmosRpcClientForChainSelector(chainId))
return (
await client.bank.v1beta1.denomMetadata({
denom,
})
).metadata
},
})
3 changes: 2 additions & 1 deletion packages/state/recoil/selectors/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const queryContractIndexerSelector = selectorFamily<

export const queryGenericIndexerSelector = selectorFamily<
any,
Omit<QueryIndexerParams, 'type'>
Omit<QueryIndexerParams, 'type' | 'address'>
>({
key: 'queryGenericIndexer',
get:
Expand All @@ -75,6 +75,7 @@ export const queryGenericIndexerSelector = selectorFamily<
get(
queryIndexerSelector({
type: IndexerFormulaType.Generic,
address: '_',
...params,
})
),
Expand Down
87 changes: 36 additions & 51 deletions packages/state/recoil/selectors/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import {
CHAIN_BECH32_PREFIX,
getFallbackImage,
isValidContractAddress,
isValidTokenFactoryDenom,
isValidWalletAddress,
nativeTokenDecimals,
nativeTokenLabel,
nativeTokenLogoURI,
} from '@dao-dao/utils'

import { nativeBalanceSelector, nativeBalancesSelector } from './chain'
import {
Cw20BaseSelectors,
Cw20StakeSelectors,
DaoCoreV2Selectors,
} from './contracts'
denomMetadataSelector,
nativeBalanceSelector,
nativeBalancesSelector,
} from './chain'
import { Cw20BaseSelectors, DaoCoreV2Selectors } from './contracts'
import { walletCw20BalancesSelector } from './wallet'
import { wyndUsdPriceSelector } from './wynd'

Expand All @@ -41,7 +42,14 @@ export const genericTokenSelector = selectorFamily<
chainId,
params: [],
})
: constSelector({
: // Native factory tokens.
isValidTokenFactoryDenom(denomOrAddress, CHAIN_BECH32_PREFIX)
? factoryTokenInfoSelector({
denom: denomOrAddress,
chainId,
})
: // Native IBC tokens.
constSelector({
decimals: nativeTokenDecimals(denomOrAddress) ?? 0,
symbol: nativeTokenLabel(denomOrAddress),
})
Expand Down Expand Up @@ -172,54 +180,31 @@ export const genericTokenBalanceSelector = selectorFamily<
},
})

// Returns a list of DAOs that use the given cw20 token as their governance
// token with the staked balance of the given wallet address for each.
export const cw20TokenDaosWithStakedBalanceSelector = selectorFamily<
export const factoryTokenInfoSelector = selectorFamily<
{
coreAddress: string
stakingContractAddress: string
stakedBalance: number
}[],
WithChainId<{
cw20Address: string
walletAddress: string
}>
symbol: string
decimals: number
},
WithChainId<{ denom: string }>
>({
key: 'cw20TokenDaosWithStakedBalance',
key: 'factoryTokenInfo',
get:
({ cw20Address, walletAddress, chainId }) =>
({ get }) => {
const daos = get(
Cw20BaseSelectors.daosWithVotingAndStakingContractSelector({
contractAddress: cw20Address,
chainId,
})
)

const daosWalletStakedTokens = get(
waitForAll(
daos.map(({ stakingContractAddress }) =>
Cw20StakeSelectors.stakedValueSelector({
contractAddress: stakingContractAddress,
params: [
{
address: walletAddress,
},
],
})
)
)
)

const daosWithBalances = daos
.map(({ coreAddress, stakingContractAddress }, index) => ({
coreAddress,
stakingContractAddress,
stakedBalance: Number(daosWalletStakedTokens[index].value),
}))
// Sort descending by staked tokens.
.sort((a, b) => b.stakedBalance - a.stakedBalance)
(params) =>
async ({ get }) => {
const { base, denomUnits, symbol } = get(denomMetadataSelector(params))

// `display` field not yet updated to point to the correct denom unit, so
// use the first one with nonzero decimals if it exists, and the first
// otherwise.
const displayDenom =
denomUnits.find((unit) => unit.exponent > 0) || denomUnits[0]
if (!displayDenom) {
throw new Error('No denom unit found for token factory denom')
}

return daosWithBalances
return {
symbol: symbol || base,
decimals: displayDenom.exponent,
}
},
})
Loading

2 comments on commit 11fb721

@vercel
Copy link

@vercel vercel bot commented on 11fb721 Jul 5, 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 11fb721 Jul 5, 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.