Skip to content

Commit

Permalink
Use spl-governance v3 sdk (solana-labs#969)
Browse files Browse the repository at this point in the history
* wip: update spl-gov v3 api

* wip: Update RealmConfig v3

* fix: NFT plugins for creation wizard

* chore: Rename GoverningTokenRole

* chore: Remove console.log
  • Loading branch information
SebastianBor authored Aug 19, 2022
1 parent c0710e5 commit c842f97
Show file tree
Hide file tree
Showing 41 changed files with 234 additions and 898 deletions.
4 changes: 2 additions & 2 deletions NftVotePlugin/NftProposalVoteState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const NftProposalVoteState = ({
const wallet = useWalletStore((s) => s.current)
const votingPower = useNftPluginStore((s) => s.state.votingPower)
const isNftPlugin =
config?.account.communityVoterWeightAddin &&
config?.account.communityTokenConfig.voterWeightAddin &&
nftPluginsPks.includes(
config?.account.communityVoterWeightAddin?.toBase58()
config?.account.communityTokenConfig.voterWeightAddin?.toBase58()
)

const ownVoteRecord = ownTokenRecord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useRealm from '@hooks/useRealm'
import { getTokenOwnerRecordAddress, Proposal } from '@solana/spl-governance'
import useWalletStore from '../../../stores/useWalletStore'
import { Option } from '@tools/core/option'
import { GoverningTokenType } from '@solana/spl-governance'
import { GoverningTokenRole } from '@solana/spl-governance'
import { fmtMintAmount } from '@tools/sdk/units'
import { getMintMetadata } from '@components/instructions/programs/splToken'
import useQueryContext from '@hooks/useQueryContext'
Expand Down Expand Up @@ -98,15 +98,15 @@ const LockPluginTokenBalanceCard = ({
{communityDepositVisible && (
<TokenDepositLock
mint={mint}
tokenType={GoverningTokenType.Community}
tokenType={GoverningTokenRole.Community}
councilVote={false}
/>
)}
{councilDepositVisible && (
<div className="mt-4">
<TokenDeposit
mint={councilMint}
tokenType={GoverningTokenType.Council}
tokenType={GoverningTokenRole.Council}
councilVote={true}
/>
</div>
Expand All @@ -128,7 +128,7 @@ const TokenDepositLock = ({
tokenType,
}: {
mint: MintInfo | undefined
tokenType: GoverningTokenType
tokenType: GoverningTokenRole
councilVote?: boolean
}) => {
const { realm, realmTokenAccount, councilTokenAccount } = useRealm()
Expand Down Expand Up @@ -157,19 +157,19 @@ const TokenDepositLock = ({
}

const depositTokenAccount =
tokenType === GoverningTokenType.Community
tokenType === GoverningTokenRole.Community
? realmTokenAccount
: councilTokenAccount

const depositMint =
tokenType === GoverningTokenType.Community
tokenType === GoverningTokenRole.Community
? realm?.account.communityMint
: realm?.account.config.councilMint

const tokenName = getMintMetadata(depositMint)?.name ?? realm?.account.name

const depositTokenName = `${tokenName} ${
tokenType === GoverningTokenType.Community ? '' : 'Council'
tokenType === GoverningTokenRole.Community ? '' : 'Council'
}`

const hasTokensInWallet =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ const WithDrawCommunityTokens = () => {
await withRelinquishVote(
instructions,
realmInfo!.programId,
getProgramVersionForRealm(realmInfo!),
realmInfo!.realmId,
proposal.account.governance,
proposal.pubkey,
ownTokenRecord!.pubkey,
Expand Down
272 changes: 0 additions & 272 deletions actions/createMultisigRealm.ts

This file was deleted.

11 changes: 7 additions & 4 deletions actions/createNFTRealm.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {
GoverningTokenConfigAccountArgs,
GoverningTokenType,
SetRealmAuthorityAction,
SYSTEM_PROGRAM_ID,
withCreateTokenOwnerRecord,
Expand Down Expand Up @@ -107,10 +109,11 @@ export default async function createNFTRealm({
transferCouncilMintAuthority,
councilWalletPks,

additionalRealmPlugins: [
new PublicKey(nftPluginsPks[0]),
new PublicKey(nftPluginsPks[0]),
],
communityTokenConfig: new GoverningTokenConfigAccountArgs({
voterWeightAddin: new PublicKey(nftPluginsPks[0]),
maxVoterWeightAddin: new PublicKey(nftPluginsPks[0]),
tokenType: GoverningTokenType.Liquid,
}),
})

console.log('NFT REALM realm public-key', realmPk.toBase58())
Expand Down
Loading

0 comments on commit c842f97

Please sign in to comment.