Skip to content

Commit

Permalink
Merge branch 'solana-labs:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sjillen authored Dec 28, 2021
2 parents d07fdad + d9ad2e2 commit a4688ef
Show file tree
Hide file tree
Showing 32 changed files with 311 additions and 130 deletions.
4 changes: 2 additions & 2 deletions actions/cancelProposal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, Transaction, TransactionInstruction } from '@solana/web3.js'
import { Keypair, Transaction, TransactionInstruction } from '@solana/web3.js'

import { RpcContext } from '../models/core/api'
import { Proposal } from '@models/accounts'
Expand All @@ -11,7 +11,7 @@ export const cancelProposal = async (
proposal: ParsedAccount<Proposal> | undefined
) => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []
const signers: Keypair[] = []
const governanceAuthority = walletPubkey

withCancelProposal(
Expand Down
4 changes: 2 additions & 2 deletions actions/castVote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand All @@ -20,7 +20,7 @@ export async function castVote(
tokeOwnerRecord: PublicKey,
vote: Vote
) {
const signers: Account[] = []
const signers: Keypair[] = []
const instructions: TransactionInstruction[] = []

const governanceAuthority = walletPubkey
Expand Down
4 changes: 2 additions & 2 deletions actions/chat/postMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Account,
PublicKey,
Keypair,
Transaction,
TransactionInstruction,
} from '@solana/web3.js'
Expand All @@ -18,7 +18,7 @@ export async function postChatMessage(
body: ChatMessageBody,
replyTo?: PublicKey
) {
const signers: Account[] = []
const signers: Keypair[] = []
const instructions: TransactionInstruction[] = []

const governanceAuthority = walletPubkey
Expand Down
4 changes: 2 additions & 2 deletions actions/createProposal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand Down Expand Up @@ -32,7 +32,7 @@ export const createProposal = async (
isDraft: boolean
): Promise<PublicKey> => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []
const signers: Keypair[] = []
const governanceAuthority = walletPubkey
const signatory = walletPubkey
const payer = walletPubkey
Expand Down
4 changes: 2 additions & 2 deletions actions/createTreasuryAccount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand All @@ -20,7 +20,7 @@ export const createTreasuryAccount = async (
tokenOwnerRecord: PublicKey
): Promise<PublicKey> => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []
const signers: Keypair[] = []

const tokenAccount = await withCreateSplTokenAccount(
connection,
Expand Down
4 changes: 2 additions & 2 deletions actions/executeInstruction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, Transaction, TransactionInstruction } from '@solana/web3.js'
import { Keypair, Transaction, TransactionInstruction } from '@solana/web3.js'

import { Proposal, ProposalInstruction } from '../models/accounts'

Expand All @@ -12,7 +12,7 @@ export const executeInstruction = async (
proposal: ParsedAccount<Proposal>,
instruction: ParsedAccount<ProposalInstruction>
) => {
const signers: Account[] = []
const signers: Keypair[] = []
const instructions: TransactionInstruction[] = []

await withExecuteInstruction(
Expand Down
4 changes: 2 additions & 2 deletions actions/finalizeVotes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ParsedAccount } from '@models/core/accounts'
import { RpcContext } from '@models/core/api'
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand All @@ -15,7 +15,7 @@ export const finalizeVote = async (
realm: PublicKey,
proposal: ParsedAccount<Proposal>
) => {
const signers: Account[] = []
const signers: Keypair[] = []
const instructions: TransactionInstruction[] = []

withFinalizeVote(
Expand Down
4 changes: 2 additions & 2 deletions actions/flagInstructionError.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand All @@ -19,7 +19,7 @@ export const flagInstructionError = async (
) => {
const governanceAuthority = walletPubkey

const signers: Account[] = []
const signers: Keypair[] = []
const instructions: TransactionInstruction[] = []

withFlagInstructionError(
Expand Down
4 changes: 2 additions & 2 deletions actions/registerGovernance.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand All @@ -20,7 +20,7 @@ export const registerGovernance = async (
tokenOwnerRecord: PublicKey
): Promise<PublicKey> => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []
const signers: Keypair[] = []
let governanceAddress
const governanceAuthority = walletPubkey

Expand Down
4 changes: 2 additions & 2 deletions actions/relinquishVote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
Account,
Keypair,
PublicKey,
Transaction,
TransactionInstruction,
Expand All @@ -18,7 +18,7 @@ export const relinquishVote = async (
voteRecord: PublicKey,
instructions: TransactionInstruction[] = []
) => {
const signers: Account[] = []
const signers: Keypair[] = []

const governanceAuthority = walletPubkey
const beneficiary = walletPubkey
Expand Down
4 changes: 2 additions & 2 deletions actions/signOffProposal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, Transaction, TransactionInstruction } from '@solana/web3.js'
import { Keypair, Transaction, TransactionInstruction } from '@solana/web3.js'

import { RpcContext } from '../models/core/api'
import { SignatoryRecord } from '@models/accounts'
Expand All @@ -11,7 +11,7 @@ export const signOffProposal = async (
signatoryRecord: ParsedAccount<SignatoryRecord>
) => {
const instructions: TransactionInstruction[] = []
const signers: Account[] = []
const signers: Keypair[] = []

withSignOffProposal(
instructions,
Expand Down
33 changes: 29 additions & 4 deletions components/AssetsList/AssetsCompactWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,39 @@ import AssetOverview from './AssetOverview'
import useQueryContext from '@hooks/useQueryContext'
import { useRouter } from 'next/router'
import UpgradeProgram from './UpgradeProgram'
import useWalletStore from 'stores/useWalletStore'
const NEW_PROGRAM_VIEW = `/program/new`

const AssetsCompactWrapper = () => {
const router = useRouter()
const { symbol } = useRealm()
const {
symbol,
realm,
ownVoterWeight,
toManyCommunityOutstandingProposalsForUser,
toManyCouncilOutstandingProposalsForUse,
} = useRealm()
const connected = useWalletStore((s) => s.connected)
const { resetCompactViewState } = useAssetsStore()
const currentView = useAssetsStore((s) => s.compact.currentView)
const { fmtUrlWithCluster } = useQueryContext()
const goToNewAssetForm = () => {
router.push(fmtUrlWithCluster(`/dao/${symbol}${NEW_PROGRAM_VIEW}`))
}
const canCreateGovernance = realm
? ownVoterWeight.canCreateGovernance(realm)
: null

const addNewAssetTooltip = !connected
? 'Connect your wallet to create new asset'
: !canCreateGovernance
? "You don't have enough governance power to create a new asset"
: toManyCommunityOutstandingProposalsForUser
? 'You have too many community outstanding proposals. You need to finalize them before creating a new asset.'
: toManyCouncilOutstandingProposalsForUse
? 'You have too many council outstanding proposals. You need to finalize them before creating a new asset.'
: ''

useEffect(() => {
resetCompactViewState()
}, [symbol])
Expand All @@ -30,13 +52,16 @@ const AssetsCompactWrapper = () => {
<>
<h3 className="mb-4 flex items-center">
Assets
<Tooltip contentClassName="ml-auto" content={''}>
<Tooltip contentClassName="ml-auto" content={addNewAssetTooltip}>
<div
onClick={goToNewAssetForm}
className={`bg-bkg-2 default-transition
flex flex-col items-center justify-center
rounded-lg hover:bg-bkg-3 ml-auto
hover:cursor-pointer`}
rounded-lg hover:bg-bkg-3 ml-auto ${
addNewAssetTooltip
? 'cursor-not-allowed pointer-events-none opacity-60'
: 'cursor-pointer'
}`}
>
<div
className="bg-[rgba(255,255,255,0.06)] h-6 w-6 flex
Expand Down
20 changes: 9 additions & 11 deletions components/AssetsList/BaseGovernanceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
fmtPercentage,
getMintMinAmountAsDecimal,
getMintNaturalAmountFromDecimal,
getMintSupplyAsDecimal,
getMintSupplyFractionAsDecimalPercentage,
getMintSupplyPercentageAsDecimal,
parseMintNaturalAmountFromDecimal,
Expand Down Expand Up @@ -76,10 +75,14 @@ const BaseGovernanceForm = ({ formErrors, form, setForm, setFormErrors }) => {
// If the supply is small and 1% is below the minimum mint amount then coerce to the minimum value
const minTokenStep = Math.max(mintSupply1Percent, minTokenAmount)

const maxTokenAmount =
!realmMint?.supply?.isZero() && realmMint
? getMintSupplyAsDecimal(realmMint)
: undefined
const getSupplyPercent = () => {
const hasMinTokensPercentage =
!!minTokensPercentage && !isNaN(minTokensPercentage)
const percent = hasMinTokensPercentage
? fmtPercentage(minTokensPercentage)
: ''
return hasMinTokensPercentage && <div>{`${percent} of token supply`}</div>
}

useEffect(() => {
onMinTokensChange(form.minCommunityTokensToCreateProposal)
Expand All @@ -93,7 +96,6 @@ const BaseGovernanceForm = ({ formErrors, form, setForm, setFormErrors }) => {
type="number"
name="minCommunityTokensToCreateProposal"
min={minTokenAmount}
max={maxTokenAmount}
step={minTokenStep}
onBlur={validateMinMax}
onChange={(evt) =>
Expand All @@ -104,11 +106,7 @@ const BaseGovernanceForm = ({ formErrors, form, setForm, setFormErrors }) => {
}
error={formErrors['minCommunityTokensToCreateProposal']}
/>
{maxTokenAmount &&
!!minTokensPercentage &&
!isNaN(minTokensPercentage) && (
<div>{`${fmtPercentage(minTokensPercentage)} of token supply`}</div>
)}
{getSupplyPercent()}
<Input
label="min instruction hold up time (days)"
value={form.minInstructionHoldUpTime}
Expand Down
12 changes: 10 additions & 2 deletions components/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { FunctionComponent } from 'react'
import Loading from './Loading'
import Tooltip from './Tooltip'

interface ButtonProps {
className?: string
isLoading?: boolean
onClick?: () => void
disabled?: boolean
small?: boolean
tooltipMessage?: string
}

const Button: FunctionComponent<ButtonProps> = ({
Expand All @@ -15,6 +17,7 @@ const Button: FunctionComponent<ButtonProps> = ({
disabled,
isLoading,
small,
tooltipMessage = '',
...props
}) => {
return (
Expand All @@ -29,7 +32,9 @@ const Button: FunctionComponent<ButtonProps> = ({
{...props}
disabled={disabled}
>
{isLoading ? <Loading /> : children}
<Tooltip content={tooltipMessage}>
<div>{isLoading ? <Loading /> : children}</div>
</Tooltip>
</button>
)
}
Expand All @@ -43,6 +48,7 @@ export const SecondaryButton: FunctionComponent<ButtonProps> = ({
className,
isLoading,
small = false,
tooltipMessage = '',
...props
}) => {
return (
Expand All @@ -54,7 +60,9 @@ export const SecondaryButton: FunctionComponent<ButtonProps> = ({
} text-primary-light text-sm hover:border-primary-dark hover:text-primary-dark focus:outline-none disabled:border-fgd-3 disabled:text-fgd-3 disabled:cursor-not-allowed`}
{...props}
>
{isLoading ? <Loading /> : children}
<Tooltip content={tooltipMessage}>
<div>{isLoading ? <Loading /> : children}</div>
</Tooltip>
</button>
)
}
Expand Down
Loading

1 comment on commit a4688ef

@vercel
Copy link

@vercel vercel bot commented on a4688ef Dec 28, 2021

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.