Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions hub/components/EditWalletRules/AdvancedOptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Props
extends FormProps<{
depositExemptProposalCount: number;
minInstructionHoldupDays: number;
governanceSeed: string;
}> {
className?: string;
programVersion: number;
Expand Down Expand Up @@ -61,6 +62,25 @@ export function AdvancedOptions(props: Props) {
</div>
</div>
</ValueBlock>

<ValueBlock
title="Governance Seed"
description="A random seed used to force the governance wallet to a specific prefix."
>
<div className="relative">
<Input
className="w-full pr-24"
placeholder="# of days"
value={props.governanceSeed}
onChange={(e) => {
props.onGovernanceSeedChange?.(e.currentTarget.value);
}}
/>
<div className="absolute top-1/2 right-4 text-neutral-500 -translate-y-1/2">
Base58
</div>
</div>
</ValueBlock>
</SectionBlock>
);
}
3 changes: 3 additions & 0 deletions hub/components/EditWalletRules/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ interface Props
depositExemptProposalCount: number;
maxVoteDays: number;
minInstructionHoldupDays: number;
governanceSeed: string;
}> {
className?: string;
initialCommunityRules: CommunityRules;
Expand Down Expand Up @@ -147,13 +148,15 @@ function Form(props: Props & { title: string; description: string }) {
className="mt-2.5"
depositExemptProposalCount={props.depositExemptProposalCount}
minInstructionHoldupDays={props.minInstructionHoldupDays}
governanceSeed={props.governanceSeed}
programVersion={props.programVersion}
onDepositExemptProposalCountChange={
props.onDepositExemptProposalCountChange
}
onMinInstructionHoldupDaysChange={
props.onMinInstructionHoldupDaysChange
}
onGovernanceSeedChange={props.onGovernanceSeedChange}
/>
)}
</div>
Expand Down
2 changes: 2 additions & 0 deletions hub/components/EditWalletRules/Summary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface Props
minInstructionHoldupDays: number;
governanceAddress?: PublicKey;
walletAddress?: PublicKey;
governanceSeed: string;
}

function Summary(
Expand Down Expand Up @@ -151,6 +152,7 @@ export const NewWalletSummary = (
depositExemptProposalCount={props.depositExemptProposalCount}
baseVoteDays={props.baseVoteDays}
minInstructionHoldupDays={props.minInstructionHoldupDays}
governanceSeed={props.governanceSeed}
/>
</>
}
Expand Down
10 changes: 10 additions & 0 deletions hub/components/EditWalletRules/UpdatesList/NewRulesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ interface Props {
depositExemptProposalCount: number;
baseVoteDays: number;
minInstructionHoldupDays: number;
governanceSeed: string;
}

export function NewRulesList(props: Props) {
Expand Down Expand Up @@ -112,6 +113,15 @@ export function NewRulesList(props: Props) {
</div>
}
/>

<SummaryItem
label="Governance Seed"
value={
<div className="flex items-baseline">
<div>{props.governanceSeed}</div>
</div>
}
/>
</div>
</SectionBlock>
);
Expand Down
1 change: 1 addition & 0 deletions hub/components/EditWalletRules/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const getGovernanceRulesResp = IT.type({
minInstructionHoldupDays: IT.number,
version: IT.number,
walletAddress: PublicKey,
governanceSeed: IT.string,
}),
}),
});
5 changes: 5 additions & 0 deletions hub/components/NewWallet/NewWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function NewWalletWithDefaults({
maxVoteDays={rules.maxVoteDays}
minInstructionHoldupDays={rules.minInstructionHoldupDays}
programVersion={programVersion ?? 3}
governanceSeed={rules.governanceSeed}
onCommunityRulesChange={setRule('communityTokenRules')}
onCoolOffHoursChange={setRule('coolOffHours')}
onCouncilRulesChange={setRule('councilTokenRules')}
Expand All @@ -148,6 +149,9 @@ function NewWalletWithDefaults({
onMinInstructionHoldupDaysChange={setRule(
'minInstructionHoldupDays',
)}
onGovernanceSeedChange={
setRule('governanceSeed')
}
/>
<footer className="flex items-center justify-between">
<button
Expand Down Expand Up @@ -189,6 +193,7 @@ function NewWalletWithDefaults({
proposalDescription={proposalDescription}
proposalTitle={proposalTitle}
proposalVoteType={proposalVoteType}
governanceSeed={rules.governanceSeed}
onProposalDescriptionChange={setProposalDescription}
onProposalTitleChange={setProposalTitle}
onProposalVoteTypeChange={setProposalVoteType}
Expand Down
1 change: 1 addition & 0 deletions hub/components/NewWallet/useGovernanceDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const configs2defaults = (configs: GovernanceConfig[]) => {
maxVoteDays: 3,
depositExemptProposalCount: 10,
minInstructionHoldupDays: 0,
governanceSeed: "",
version: 3,
};
return x;
Expand Down
9 changes: 7 additions & 2 deletions hub/components/NewWallet/useNewWalletTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
withCreateGovernance,
withCreateNativeTreasury,
} from '@solana/spl-governance';
import { TransactionInstruction } from '@solana/web3.js';
import { PublicKey, TransactionInstruction } from '@solana/web3.js';

import { useCallback } from 'react';

Expand Down Expand Up @@ -70,13 +70,18 @@ const useNewWalletCallback = (
instructions.push(...preIx);
createNftTicketsIxs.push(...postIx);
}

let governedAccount = undefined;
if (rules.governanceSeed) {
governedAccount = new PublicKey(rules.governanceSeed);
}

const governanceAddress = await withCreateGovernance(
instructions,
realm.owner,
programVersion,
realm.pubkey,
undefined,
governedAccount,
config,
tokenOwnerRecord.pubkey,
wallet.publicKey,
Expand Down