From 0d0f8c8763af7fe1d012e627da5eb2a5bcc2047f Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Fri, 23 Apr 2021 11:17:46 +0100 Subject: [PATCH 01/16] feat: use only program id for governance pda --- packages/proposals/src/actions/registerProgramGovernance.ts | 3 --- packages/proposals/src/models/createEmptyTimelockConfig.ts | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/proposals/src/actions/registerProgramGovernance.ts index 1a45a11..5acb0fd 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/proposals/src/actions/registerProgramGovernance.ts @@ -119,9 +119,6 @@ export const registerProgramGovernance = async ( const [timelockConfigKey] = await PublicKey.findProgramAddress( [ Buffer.from(GOVERNANCE_AUTHORITY_SEED), - PROGRAM_IDS.timelock.programId.toBuffer(), - uninitializedTimelockConfig.governanceMint.toBuffer(), - councilMintSeed, uninitializedTimelockConfig.program.toBuffer(), ], PROGRAM_IDS.timelock.programId, diff --git a/packages/proposals/src/models/createEmptyTimelockConfig.ts b/packages/proposals/src/models/createEmptyTimelockConfig.ts index 29d594a..fdc688e 100644 --- a/packages/proposals/src/models/createEmptyTimelockConfig.ts +++ b/packages/proposals/src/models/createEmptyTimelockConfig.ts @@ -38,7 +38,7 @@ export const createEmptyTimelockConfigInstruction = ( { pubkey: programAccount, isSigner: false, isWritable: false }, { pubkey: programDataAccount, isSigner: false, isWritable: true }, { pubkey: programUpgradeAuthority, isSigner: true, isWritable: false }, - { pubkey: governanceMint, isSigner: false, isWritable: false }, + { pubkey: payer, isSigner: true, isWritable: false }, { pubkey: PROGRAM_IDS.system, isSigner: false, isWritable: false }, { @@ -48,10 +48,6 @@ export const createEmptyTimelockConfigInstruction = ( }, ]; - if (councilMint) { - keys.push({ pubkey: councilMint, isSigner: false, isWritable: false }); - } - return new TransactionInstruction({ keys, programId: PROGRAM_IDS.timelock.programId, From 90546db0e5cedf55f9fc7650cfafb4302b7a04bf Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Fri, 23 Apr 2021 23:06:28 +0100 Subject: [PATCH 02/16] fix: use button for execute action --- .../src/components/Proposal/InstructionCard.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/proposals/src/components/Proposal/InstructionCard.tsx index 1e8ba7d..f97eed4 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/InstructionCard.tsx @@ -7,7 +7,7 @@ import { RedoOutlined, } from '@ant-design/icons'; import { ParsedAccount, contexts } from '@oyster/common'; -import { Card } from 'antd'; +import { Card, Button } from 'antd'; import Meta from 'antd/lib/card/Meta'; import React, { useEffect, useState } from 'react'; import { execute } from '../../actions/execute'; @@ -139,17 +139,17 @@ function PlayStatusButton({ if (playing === Playstate.Unplayed) return ( - + ); else if (playing === Playstate.Playing) return ; else if (playing === Playstate.Error) return ( - + ); else return ; } From 61f4be3cbdc6a505592cdc51eadb45f73580e150 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Fri, 23 Apr 2021 23:06:56 +0100 Subject: [PATCH 03/16] chore: lint errors --- .../src/actions/registerProgramGovernance.ts | 4 -- .../components/Proposal/VoterBubbleGraph.tsx | 42 ++++++++++--------- .../proposals/src/views/proposal/index.tsx | 2 + 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/proposals/src/actions/registerProgramGovernance.ts index 5acb0fd..d2dee74 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/proposals/src/actions/registerProgramGovernance.ts @@ -112,10 +112,6 @@ export const registerProgramGovernance = async ( ); } - const councilMintSeed = uninitializedTimelockConfig.councilMint - ? uninitializedTimelockConfig.councilMint.toBuffer() - : Buffer.from(''); - const [timelockConfigKey] = await PublicKey.findProgramAddress( [ Buffer.from(GOVERNANCE_AUTHORITY_SEED), diff --git a/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx b/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx index 2d7fee0..4dc236e 100644 --- a/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx +++ b/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx @@ -14,10 +14,6 @@ const MAX_BUBBLE_AMOUNT = 50; export function VoterBubbleGraph(props: IVoterBubbleGraph) { const { data, width, height, endpoint } = props; - const subdomain = endpoint - .replace('http://', '') - .replace('https://', '') - .split('.')[0]; // For some reason giving this a type causes an issue where setRef // cant be used with ref={} prop...not sure why. SetStateAction nonsense. @@ -31,24 +27,30 @@ export function VoterBubbleGraph(props: IVoterBubbleGraph) { d.name.slice(d.name.length - 3, d.name.length), })); //console.log('Data', limitedData); - const format = d3.format(',d'); - const color = d3 - .scaleOrdinal() - .domain([VoteType.Undecided, VoteType.Yes, VoteType.No]) - .range(['grey', 'green', 'red']); - - const pack = (data: Array) => { - return d3 - .pack() - .size([width - 2, height - 2]) - .padding(3)( - //@ts-ignore - d3.hierarchy({ children: data }).sum(d => (d.value ? d.value : 0)), - ); - }; useEffect(() => { if (ref) { + const subdomain = endpoint + .replace('http://', '') + .replace('https://', '') + .split('.')[0]; + + const format = d3.format(',d'); + const color = d3 + .scaleOrdinal() + .domain([VoteType.Undecided, VoteType.Yes, VoteType.No]) + .range(['grey', 'green', 'red']); + + const pack = (data: Array) => { + return d3 + .pack() + .size([width - 2, height - 2]) + .padding(3)( + //@ts-ignore + d3.hierarchy({ children: data }).sum(d => (d.value ? d.value : 0)), + ); + }; + ref.innerHTML = ''; const root = pack(limitedData); // console.log('Re-rendered'); @@ -127,7 +129,7 @@ export function VoterBubbleGraph(props: IVoterBubbleGraph) { }${format(d.value)}`, ); } - }, [ref, limitedData, height, width]); + }, [ref, limitedData, height, width, endpoint]); return (
b.value - a.value, ); + return data; } From 50326a22986ae3b4fa88475ac4179d4475a7f8fa Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Fri, 23 Apr 2021 23:21:49 +0100 Subject: [PATCH 04/16] chore: fix lint issues --- packages/proposals/src/components/Layout/index.tsx | 11 ++++++----- packages/proposals/src/views/home/index.tsx | 2 +- packages/proposals/src/views/proposals/index.tsx | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/proposals/src/components/Layout/index.tsx b/packages/proposals/src/components/Layout/index.tsx index b3ede8c..9501d59 100644 --- a/packages/proposals/src/components/Layout/index.tsx +++ b/packages/proposals/src/components/Layout/index.tsx @@ -30,11 +30,12 @@ export const AppLayout = React.memo((props: any) => { ); }); - const breadcrumbItems = [ - - Home - , - ].concat(extraBreadcrumbItems); + + // const breadcrumbItems = [ + // + // Home + // , + // ].concat(extraBreadcrumbItems); // TODO: add breadcrumb diff --git a/packages/proposals/src/views/home/index.tsx b/packages/proposals/src/views/home/index.tsx index c57086f..1f0d591 100644 --- a/packages/proposals/src/views/home/index.tsx +++ b/packages/proposals/src/views/home/index.tsx @@ -56,7 +56,7 @@ export const HomeView = () => { }); }); return newListData; - }, [configs, proposals]); + }, [configs, proposals, states]); return ( <> diff --git a/packages/proposals/src/views/proposals/index.tsx b/packages/proposals/src/views/proposals/index.tsx index cd221fb..2b7d06c 100644 --- a/packages/proposals/src/views/proposals/index.tsx +++ b/packages/proposals/src/views/proposals/index.tsx @@ -45,7 +45,7 @@ export const ProposalsView = () => { }); }); return newListData; - }, [proposals]); + }, [proposals, id, mint, states]); return ( Date: Sat, 24 Apr 2021 09:21:05 +0100 Subject: [PATCH 05/16] chore: suppress lint warnings --- .../src/components/Background/useCannon.tsx | 42 +++++++++---------- .../proposals/src/components/Layout/index.tsx | 38 ++++++++--------- packages/proposals/src/contexts/proposals.tsx | 6 +-- .../proposals/src/views/governance/index.tsx | 2 +- .../proposals/src/views/proposal/index.tsx | 9 ++-- 5 files changed, 47 insertions(+), 50 deletions(-) diff --git a/packages/proposals/src/components/Background/useCannon.tsx b/packages/proposals/src/components/Background/useCannon.tsx index 1821fe6..8cab58b 100644 --- a/packages/proposals/src/components/Background/useCannon.tsx +++ b/packages/proposals/src/components/Background/useCannon.tsx @@ -1,53 +1,49 @@ -import * as CANNON from 'cannon' -import React, { useState, useEffect, useContext, useRef } from 'react' -import { useFrame } from 'react-three-fiber' +import * as CANNON from 'cannon'; +import React, { useState, useEffect, useContext, useRef } from 'react'; +import { useFrame } from 'react-three-fiber'; // Cannon-world context provider -export const CannonContext = React.createContext( - null, -); +export const CannonContext = React.createContext(null); export function Provider({ children = null as any }) { // Set up physics const [world] = useState(() => new CANNON.World()); useEffect(() => { - world.broadphase = new CANNON.NaiveBroadphase() - world.solver.iterations = 10 - world.gravity.set(0, 0, -25) + world.broadphase = new CANNON.NaiveBroadphase(); + world.solver.iterations = 10; + world.gravity.set(0, 0, -25); }, [world]); // Run world stepper every frame useFrame(() => world.step(1 / 60)); // Distribute world via context - return ( - - ); + return ; } // Custom hook to maintain a world physics body export function useCannon({ ...props }, fn: any, deps = []) { - const ref = useRef() + const ref = useRef(); // Get cannon world object - const world = useContext(CannonContext) + const world = useContext(CannonContext); // Instanciate a physics body - const [body] = useState(() => new CANNON.Body(props)) + const [body] = useState(() => new CANNON.Body(props)); useEffect(() => { // Call function so the user can add shapes - fn(body) + fn(body); // Add body to world on mount - world.addBody(body) + world.addBody(body); // Remove body on unmount - return () => world.removeBody(body) - }, deps) + return () => world.removeBody(body); + }, deps); //eslint-disable-line useFrame(() => { if (ref.current) { // Transport cannon physics into the referenced threejs object - ref.current.position.copy(body.position) - ref.current.quaternion.copy(body.quaternion) + ref.current.position.copy(body.position); + ref.current.quaternion.copy(body.quaternion); } - }) + }); - return ref + return ref; } diff --git a/packages/proposals/src/components/Layout/index.tsx b/packages/proposals/src/components/Layout/index.tsx index 9501d59..f6b9baa 100644 --- a/packages/proposals/src/components/Layout/index.tsx +++ b/packages/proposals/src/components/Layout/index.tsx @@ -1,7 +1,7 @@ import React from 'react'; import './../../App.less'; -import { Breadcrumb, Layout } from 'antd'; -import { Link, useLocation } from 'react-router-dom'; +import { Layout } from 'antd'; +import { Link } from 'react-router-dom'; import { LABELS } from '../../constants'; import { components } from '@oyster/common'; @@ -11,25 +11,25 @@ import Logo from './dark-horizontal-combined-rainbow.inline.svg'; const { AppBar } = components; export const AppLayout = React.memo((props: any) => { - const location = useLocation(); + // const location = useLocation(); - const breadcrumbNameMap: any = { - '/governance': 'Governance', - '/apps/1': 'Application1', - '/apps/2': 'Application2', - '/apps/1/detail': 'Detail', - '/apps/2/detail': 'Detail', - }; + // const breadcrumbNameMap: any = { + // '/governance': 'Governance', + // '/apps/1': 'Application1', + // '/apps/2': 'Application2', + // '/apps/1/detail': 'Detail', + // '/apps/2/detail': 'Detail', + // }; - const pathSnippets = location.pathname.split('/').filter(i => i); - const extraBreadcrumbItems = pathSnippets.map((_, index) => { - const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; - return ( - - {breadcrumbNameMap[url]} - - ); - }); + //const pathSnippets = location.pathname.split('/').filter(i => i); + // const extraBreadcrumbItems = pathSnippets.map((_, index) => { + // const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; + // return ( + // + // {breadcrumbNameMap[url]} + // + // ); + // }); // const breadcrumbItems = [ // diff --git a/packages/proposals/src/contexts/proposals.tsx b/packages/proposals/src/contexts/proposals.tsx index badf957..2488d48 100644 --- a/packages/proposals/src/contexts/proposals.tsx +++ b/packages/proposals/src/contexts/proposals.tsx @@ -81,9 +81,9 @@ function useSetupProposalsCache({ setStates: React.Dispatch>; setConfigs: React.Dispatch>; }) { - const PROGRAM_IDS = utils.programIds(); - useEffect(() => { + const PROGRAM_IDS = utils.programIds(); + const query = async () => { const programAccounts = await connection.getProgramAccounts( PROGRAM_IDS.timelock.programId, @@ -187,7 +187,7 @@ function useSetupProposalsCache({ return () => { connection.removeProgramAccountChangeListener(subID); }; - }, [connection, PROGRAM_IDS.timelock.programId.toBase58()]); + }, [connection]); //eslint-disable-line } export const useProposals = () => { const context = useContext(ProposalsContext); diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/proposals/src/views/governance/index.tsx index fecaee1..13ad421 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/proposals/src/views/governance/index.tsx @@ -133,7 +133,7 @@ export const GovernanceDashboard = () => { })), ); }); - }, [configs.length, myTokenAccts.join(',')]); + }, [configs.length, myTokenAccts.join(',')]); //eslint-disable-line return ; }; diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/proposals/src/views/proposal/index.tsx index 468818a..8028397 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/proposals/src/views/proposal/index.tsx @@ -1,4 +1,4 @@ -import { Card, Col, Grid, Row, Spin, Statistic, Tabs } from 'antd'; +import { Card, Col, Row, Spin, Statistic, Tabs } from 'antd'; import React, { useMemo, useState } from 'react'; import { LABELS } from '../../constants'; import { ParsedAccount, TokenIcon } from '@oyster/common'; @@ -30,11 +30,12 @@ import { VoterBubbleGraph } from '../../components/Proposal/VoterBubbleGraph'; import { VoterTable } from '../../components/Proposal/VoterTable'; const { TabPane } = Tabs; +// eslint-disable-next-line export const urlRegex = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/; const { useMint } = contexts.Accounts; const { useConnectionConfig } = contexts.Connection; const { useAccountByMint } = hooks; -const { useBreakpoint } = Grid; +//const { useBreakpoint } = Grid; export enum VoteType { Undecided = 'Undecided', @@ -134,7 +135,7 @@ function useLoadGist({ setLoading(false); }); } - }, [loading]); + }, [loading]); //eslint-disable-line } interface PartialGovernanceRecord { info: { yesCount: BN; noCount: BN; undecidedCount: BN }; @@ -244,7 +245,7 @@ function InnerProposalView({ const [msg, setMsg] = useState(''); const [width, setWidth] = useState(); const [height, setHeight] = useState(); - const breakpoint = useBreakpoint(); + // const breakpoint = useBreakpoint(); useLoadGist({ loading, From 9464d80d2c9ac1fe4309f099ed9f4bb4914022cb Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 11:09:23 +0100 Subject: [PATCH 06/16] fix: show instruction program id and data --- packages/proposals/src/actions/execute.ts | 72 +------------------ .../components/Proposal/InstructionCard.tsx | 19 ++++- packages/proposals/src/constants/labels.ts | 5 +- packages/proposals/src/utils/transactions.ts | 69 ++++++++++++++++++ .../proposals/src/views/governance/index.tsx | 2 +- .../src/views/governance/register.tsx | 2 +- 6 files changed, 93 insertions(+), 76 deletions(-) create mode 100644 packages/proposals/src/utils/transactions.ts diff --git a/packages/proposals/src/actions/execute.ts b/packages/proposals/src/actions/execute.ts index e48a180..3a83b5d 100644 --- a/packages/proposals/src/actions/execute.ts +++ b/packages/proposals/src/actions/execute.ts @@ -2,7 +2,6 @@ import { Account, Connection, Message, - PublicKey, TransactionInstruction, } from '@solana/web3.js'; import { contexts, utils, ParsedAccount } from '@oyster/common'; @@ -14,6 +13,7 @@ import { } from '../models/timelock'; import { executeInstruction } from '../models/execute'; import { LABELS } from '../constants'; +import { getMessageAccountInfos } from '../utils/transactions'; const { sendTransaction } = contexts.Connection; const { notify } = utils; @@ -27,7 +27,7 @@ export const execute = async ( let signers: Account[] = []; let instructions: TransactionInstruction[] = []; const actualMessage = decodeBufferIntoMessage(transaction.info.instruction); - const accountInfos = getAccountInfos(actualMessage); + const accountInfos = getMessageAccountInfos(actualMessage); instructions.push( executeInstruction( @@ -69,71 +69,3 @@ export const execute = async ( function decodeBufferIntoMessage(instruction: number[]): Message { return Message.from(instruction); } - -function getAccountInfos( - actualMessage: Message, -): { pubkey: PublicKey; isSigner: boolean; isWritable: boolean }[] { - console.log(actualMessage); - // From Solana docs: - /* - - The addresses that require signatures appear at the beginning of the account address array, - with addresses requesting write access first and read-only accounts following. - The addresses that do not require signatures follow the addresses that do, - again with read-write accounts first and read-only accounts following. - */ - const { programIdIndex, accounts } = actualMessage.instructions[0]; - const accountInfosInOrder = accounts.map(a => actualMessage.accountKeys[a]); - // If programIdIndex isnt in accountInfos, there's an off-by-one issue that happens here - // where one account that should be writable isnt, so we take care of here... - const totalSize = - accountInfosInOrder.length + (accounts.includes(programIdIndex) ? 0 : 1); - const requireSigsOnlyNotWritable = - actualMessage.header.numReadonlySignedAccounts; - const requireNietherSigsNorWrite = - actualMessage.header.numReadonlyUnsignedAccounts; - const writableOnly = - totalSize - requireSigsOnlyNotWritable - requireNietherSigsNorWrite; - // and adjust here... - const readOnly = - requireSigsOnlyNotWritable + - requireNietherSigsNorWrite - - (totalSize - accountInfosInOrder.length); - - let position = 0; - - let finalArray: { - pubkey: PublicKey; - isSigner: boolean; - isWritable: boolean; - }[] = []; - for (let i = 0; i < writableOnly; i++) { - finalArray.push({ - pubkey: accountInfosInOrder[position], - isWritable: true, - isSigner: false, // We force signer to false because you realistically as executor wont - // have any of these keys present unless it happens to be your own - // WE dont care about required signers or not - }); - position++; - } - - for (let i = 0; i < readOnly; i++) { - finalArray.push({ - pubkey: accountInfosInOrder[position], - isWritable: false, - isSigner: false, - }); - position++; - } - - for (; position < accountInfosInOrder.length; position++) { - finalArray.push({ - pubkey: accountInfosInOrder[position], - isWritable: false, - isSigner: false, - }); - } - - return finalArray; -} diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/proposals/src/components/Proposal/InstructionCard.tsx index f97eed4..7c026c7 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/InstructionCard.tsx @@ -7,9 +7,10 @@ import { RedoOutlined, } from '@ant-design/icons'; import { ParsedAccount, contexts } from '@oyster/common'; +import { Message } from '@solana/web3.js'; import { Card, Button } from 'antd'; import Meta from 'antd/lib/card/Meta'; -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useMemo, useState } from 'react'; import { execute } from '../../actions/execute'; import { LABELS } from '../../constants'; import { @@ -18,6 +19,7 @@ import { TimelockStateStatus, TimelockTransaction, } from '../../models/timelock'; + import './style.less'; const { useWallet } = contexts.Wallet; @@ -44,13 +46,24 @@ export function InstructionCard({ const [playing, setPlaying] = useState( instruction.info.executed === 1 ? Playstate.Played : Playstate.Unplayed, ); + + const instructionDetails = useMemo(() => { + const message = Message.from(instruction.info.instruction); + + return { + instructionProgramID: + message.accountKeys[message.instructions[0].programIdIndex], + instructionData: message.instructions[0].data, + }; + }, [instruction]); + const contentList: Record = { info: ( -

Instruction: TODO

+

{`${LABELS.INSTRUCTION}: ${instructionDetails.instructionData}`}

{LABELS.DELAY}: {instruction.info.slot.toNumber()}

diff --git a/packages/proposals/src/constants/labels.ts b/packages/proposals/src/constants/labels.ts index 81fc4cd..8054d73 100644 --- a/packages/proposals/src/constants/labels.ts +++ b/packages/proposals/src/constants/labels.ts @@ -99,7 +99,10 @@ export const LABELS = { TOKENS_REFUNDED: 'Your voting tokens have been refunded', REGISTER_GOVERNANCE: 'Register', - PROGRAM: 'Program ID', + + PROGRAM_ID: 'Program ID', + INSTRUCTION: 'Instruction', + GOVERNANCE: 'Governance Token Holders', COUNCIL: 'The Council', GOVERNANCE_MINT: 'Governance Mint ID', diff --git a/packages/proposals/src/utils/transactions.ts b/packages/proposals/src/utils/transactions.ts new file mode 100644 index 0000000..3c10584 --- /dev/null +++ b/packages/proposals/src/utils/transactions.ts @@ -0,0 +1,69 @@ +import { Message, PublicKey } from '@solana/web3.js'; + +export function getMessageAccountInfos( + actualMessage: Message, +): { pubkey: PublicKey; isSigner: boolean; isWritable: boolean }[] { + console.log(actualMessage); + // From Solana docs: + /* + + The addresses that require signatures appear at the beginning of the account address array, + with addresses requesting write access first and read-only accounts following. + The addresses that do not require signatures follow the addresses that do, + again with read-write accounts first and read-only accounts following. + */ + const { programIdIndex, accounts } = actualMessage.instructions[0]; + const accountInfosInOrder = accounts.map(a => actualMessage.accountKeys[a]); + // If programIdIndex isnt in accountInfos, there's an off-by-one issue that happens here + // where one account that should be writable isnt, so we take care of here... + const totalSize = + accountInfosInOrder.length + (accounts.includes(programIdIndex) ? 0 : 1); + const requireSigsOnlyNotWritable = + actualMessage.header.numReadonlySignedAccounts; + const requireNietherSigsNorWrite = + actualMessage.header.numReadonlyUnsignedAccounts; + const writableOnly = + totalSize - requireSigsOnlyNotWritable - requireNietherSigsNorWrite; + // and adjust here... + const readOnly = + requireSigsOnlyNotWritable + + requireNietherSigsNorWrite - + (totalSize - accountInfosInOrder.length); + + let position = 0; + + let finalArray: { + pubkey: PublicKey; + isSigner: boolean; + isWritable: boolean; + }[] = []; + for (let i = 0; i < writableOnly; i++) { + finalArray.push({ + pubkey: accountInfosInOrder[position], + isWritable: true, + isSigner: false, // We force signer to false because you realistically as executor wont + // have any of these keys present unless it happens to be your own + // WE dont care about required signers or not + }); + position++; + } + + for (let i = 0; i < readOnly; i++) { + finalArray.push({ + pubkey: accountInfosInOrder[position], + isWritable: false, + isSigner: false, + }); + position++; + } + + for (; position < accountInfosInOrder.length; position++) { + finalArray.push({ + pubkey: accountInfosInOrder[position], + isWritable: false, + isSigner: false, + }); + } + + return finalArray; +} diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/proposals/src/views/governance/index.tsx index 13ad421..bb3fee5 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/proposals/src/views/governance/index.tsx @@ -75,7 +75,7 @@ const columns = [ render: (key: PublicKey) => {key?.toBase58()}, }, { - title: LABELS.PROGRAM, + title: LABELS.PROGRAM_ID, dataIndex: 'program', key: 'program', render: (key: PublicKey) => {key.toBase58()}, diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/proposals/src/views/governance/register.tsx index f78e8c9..b49df29 100644 --- a/packages/proposals/src/views/governance/register.tsx +++ b/packages/proposals/src/views/governance/register.tsx @@ -158,7 +158,7 @@ export function NewForm({ From c19e7fe2190d0e8011d47fefc8c23b1d8fc25b31 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 12:12:44 +0100 Subject: [PATCH 07/16] chore: rename state structs to Governance --- .../addCustomSingleSignerTransaction.ts | 14 +-- packages/proposals/src/actions/addSigner.ts | 8 +- .../proposals/src/actions/createProposal.ts | 18 ++-- .../src/actions/depositSourceTokensAndVote.ts | 12 +-- packages/proposals/src/actions/execute.ts | 8 +- .../proposals/src/actions/mintSourceTokens.ts | 4 +- .../src/actions/registerProgramGovernance.ts | 9 +- .../proposals/src/actions/removeSigner.ts | 4 +- packages/proposals/src/actions/sign.ts | 8 +- .../src/actions/withdrawVotingTokens.ts | 12 +-- .../src/components/Proposal/AddSigners.tsx | 6 +- .../components/Proposal/InstructionCard.tsx | 18 ++-- .../components/Proposal/MintSourceTokens.tsx | 4 +- .../Proposal/NewInstructionCard.tsx | 12 +-- .../src/components/Proposal/SignButton.tsx | 6 +- .../src/components/Proposal/StateBadge.tsx | 12 +-- .../src/components/Proposal/Vote.tsx | 16 ++-- .../src/components/Proposal/WithdrawVote.tsx | 24 ++--- packages/proposals/src/contexts/proposals.tsx | 88 +++++++++---------- .../addCustomSingleSignerTransaction.ts | 10 +-- packages/proposals/src/models/addSigner.ts | 4 +- .../createEmptyGovernanceVotingRecord.ts | 4 +- .../src/models/createEmptyTimelockConfig.ts | 4 +- .../src/models/depositSourceTokens.ts | 4 +- packages/proposals/src/models/execute.ts | 4 +- .../src/models/initTimelockConfig.ts | 4 +- .../proposals/src/models/initTimelockSet.ts | 4 +- packages/proposals/src/models/removeSigner.ts | 4 +- packages/proposals/src/models/sign.ts | 4 +- packages/proposals/src/models/timelock.ts | 73 ++++++++------- packages/proposals/src/models/vote.ts | 4 +- .../src/models/withdrawVotingTokens.ts | 4 +- packages/proposals/src/utils/serialize.ts | 4 +- .../proposals/src/views/dashboard/index.tsx | 4 +- .../proposals/src/views/governance/index.tsx | 8 +- .../src/views/governance/register.tsx | 10 +-- packages/proposals/src/views/home/index.tsx | 6 +- .../proposals/src/views/proposal/index.tsx | 24 ++--- 38 files changed, 227 insertions(+), 239 deletions(-) diff --git a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts b/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts index 4be6682..0729c57 100644 --- a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts +++ b/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts @@ -8,9 +8,9 @@ import { import { contexts, utils, models, ParsedAccount } from '@oyster/common'; import { GOVERNANCE_AUTHORITY_SEED, - CustomSingleSignerTimelockTransactionLayout, - TimelockSet, - TimelockState, + CustomSingleSignerTransactionLayout, + Proposal, + ProposalState, } from '../models/timelock'; import { addCustomSingleSignerTransactionInstruction } from '../models/addCustomSingleSignerTransaction'; @@ -21,8 +21,8 @@ const { approve } = models; export const addCustomSingleSignerTransaction = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, sigAccount: PublicKey, slot: string, instruction: string, @@ -34,7 +34,7 @@ export const addCustomSingleSignerTransaction = async ( let instructions: TransactionInstruction[] = []; const rentExempt = await connection.getMinimumBalanceForRentExemption( - CustomSingleSignerTimelockTransactionLayout.span, + CustomSingleSignerTransactionLayout.span, ); const txnKey = new Account(); @@ -43,7 +43,7 @@ export const addCustomSingleSignerTransaction = async ( fromPubkey: wallet.publicKey, newAccountPubkey: txnKey.publicKey, lamports: rentExempt, - space: CustomSingleSignerTimelockTransactionLayout.span, + space: CustomSingleSignerTransactionLayout.span, programId: PROGRAM_IDS.timelock.programId, }); diff --git a/packages/proposals/src/actions/addSigner.ts b/packages/proposals/src/actions/addSigner.ts index f03b39a..301c2f7 100644 --- a/packages/proposals/src/actions/addSigner.ts +++ b/packages/proposals/src/actions/addSigner.ts @@ -14,8 +14,8 @@ import { import { GOVERNANCE_AUTHORITY_SEED, - TimelockSet, - TimelockState, + Proposal, + ProposalState, } from '../models/timelock'; import { AccountLayout } from '@solana/spl-token'; import { addSignerInstruction } from '../models/addSigner'; @@ -27,8 +27,8 @@ const { approve } = models; export const addSigner = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, adminAccount: PublicKey, newSignatoryAccountOwner: PublicKey, ) => { diff --git a/packages/proposals/src/actions/createProposal.ts b/packages/proposals/src/actions/createProposal.ts index 2998bbb..0ef7bef 100644 --- a/packages/proposals/src/actions/createProposal.ts +++ b/packages/proposals/src/actions/createProposal.ts @@ -11,9 +11,9 @@ import { AccountLayout, MintLayout } from '@solana/spl-token'; import { initTimelockSetInstruction } from '../models/initTimelockSet'; import { GOVERNANCE_AUTHORITY_SEED, - TimelockConfig, - TimelockSetLayout, - TimelockStateLayout, + Governance, + ProposalLayout, + ProposalStateLayout, } from '../models/timelock'; const { cache } = contexts.Accounts; @@ -27,7 +27,7 @@ export const createProposal = async ( name: string, description: string, useGovernance: boolean, - timelockConfig: ParsedAccount, + timelockConfig: ParsedAccount, ): Promise => { const PROGRAM_IDS = utils.programIds(); @@ -83,11 +83,11 @@ export const createProposal = async ( let createTimelockAccountsInstructions: TransactionInstruction[] = []; const timelockRentExempt = await connection.getMinimumBalanceForRentExemption( - TimelockSetLayout.span, + ProposalLayout.span, ); const timelockStateRentExempt = await connection.getMinimumBalanceForRentExemption( - TimelockStateLayout.span, + ProposalStateLayout.span, ); const timelockStateKey = new Account(); @@ -96,7 +96,7 @@ export const createProposal = async ( fromPubkey: wallet.publicKey, newAccountPubkey: timelockStateKey.publicKey, lamports: timelockStateRentExempt, - space: TimelockStateLayout.span, + space: ProposalStateLayout.span, programId: PROGRAM_IDS.timelock.programId, }); signers.push(timelockStateKey); @@ -109,7 +109,7 @@ export const createProposal = async ( fromPubkey: wallet.publicKey, newAccountPubkey: timelockSetKey.publicKey, lamports: timelockRentExempt, - space: TimelockSetLayout.span, + space: ProposalLayout.span, programId: PROGRAM_IDS.timelock.programId, }); signers.push(timelockSetKey); @@ -199,7 +199,7 @@ async function getAssociatedAccountsAndInstructions( wallet: any, accountRentExempt: number, mintRentExempt: number, - timelockConfig: ParsedAccount, + timelockConfig: ParsedAccount, useGovernance: boolean, sourceMintDecimals: number, newProposalKey: Account, diff --git a/packages/proposals/src/actions/depositSourceTokensAndVote.ts b/packages/proposals/src/actions/depositSourceTokensAndVote.ts index 29cc5db..8763f1d 100644 --- a/packages/proposals/src/actions/depositSourceTokensAndVote.ts +++ b/packages/proposals/src/actions/depositSourceTokensAndVote.ts @@ -14,9 +14,9 @@ import { import { GOVERNANCE_AUTHORITY_SEED, - TimelockConfig, - TimelockSet, - TimelockState, + Governance, + Proposal, + ProposalState, } from '../models/timelock'; import { AccountLayout } from '@solana/spl-token'; @@ -35,13 +35,13 @@ const { approve } = models; export const depositSourceTokensAndVote = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, + proposal: ParsedAccount, existingVoteAccount: PublicKey | undefined, existingYesVoteAccount: PublicKey | undefined, existingNoVoteAccount: PublicKey | undefined, sourceAccount: PublicKey, - timelockConfig: ParsedAccount, - state: ParsedAccount, + timelockConfig: ParsedAccount, + state: ParsedAccount, yesVotingTokenAmount: number, noVotingTokenAmount: number, ) => { diff --git a/packages/proposals/src/actions/execute.ts b/packages/proposals/src/actions/execute.ts index 3a83b5d..b3b4078 100644 --- a/packages/proposals/src/actions/execute.ts +++ b/packages/proposals/src/actions/execute.ts @@ -7,8 +7,8 @@ import { import { contexts, utils, ParsedAccount } from '@oyster/common'; import { - TimelockSet, - TimelockState, + Proposal, + ProposalState, TimelockTransaction, } from '../models/timelock'; import { executeInstruction } from '../models/execute'; @@ -20,8 +20,8 @@ const { notify } = utils; export const execute = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, transaction: ParsedAccount, ) => { let signers: Account[] = []; diff --git a/packages/proposals/src/actions/mintSourceTokens.ts b/packages/proposals/src/actions/mintSourceTokens.ts index 3c724b1..814feab 100644 --- a/packages/proposals/src/actions/mintSourceTokens.ts +++ b/packages/proposals/src/actions/mintSourceTokens.ts @@ -6,7 +6,7 @@ import { } from '@solana/web3.js'; import { contexts, utils, ParsedAccount, actions } from '@oyster/common'; -import { TimelockConfig } from '../models/timelock'; +import { Governance } from '../models/timelock'; import { AccountLayout, Token } from '@solana/spl-token'; import { LABELS } from '../constants'; const { createTokenAccount } = actions; @@ -20,7 +20,7 @@ export interface SourceEntryInterface { export const mintSourceTokens = async ( connection: Connection, wallet: any, - timelockConfig: ParsedAccount, + timelockConfig: ParsedAccount, useGovernance: boolean, entries: SourceEntryInterface[], setSavePerc: (num: number) => void, diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/proposals/src/actions/registerProgramGovernance.ts index d2dee74..55751a8 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/proposals/src/actions/registerProgramGovernance.ts @@ -10,8 +10,8 @@ import { AccountLayout, MintLayout, Token } from '@solana/spl-token'; import { GOVERNANCE_AUTHORITY_SEED, ExecutionType, - TimelockConfig, - TimelockType, + Governance, + GovernanceType, VotingEntryRule, } from '../models/timelock'; import { initTimelockConfigInstruction } from '../models/initTimelockConfig'; @@ -25,7 +25,7 @@ const { notify } = utils; export const registerProgramGovernance = async ( connection: Connection, wallet: any, - uninitializedTimelockConfig: Partial, + uninitializedTimelockConfig: Partial, useCouncil: boolean, ): Promise => { const PROGRAM_IDS = utils.programIds(); @@ -144,8 +144,7 @@ export const registerProgramGovernance = async ( uninitializedTimelockConfig.voteThreshold!, uninitializedTimelockConfig.executionType || ExecutionType.Independent, - uninitializedTimelockConfig.timelockType || - TimelockType.CustomSingleSignerV1, + uninitializedTimelockConfig.timelockType || GovernanceType.Governance, uninitializedTimelockConfig.votingEntryRule || VotingEntryRule.Anytime, uninitializedTimelockConfig.minimumSlotWaitingPeriod || new BN(0), uninitializedTimelockConfig.timeLimit || new BN(0), diff --git a/packages/proposals/src/actions/removeSigner.ts b/packages/proposals/src/actions/removeSigner.ts index 02ba946..32b80fa 100644 --- a/packages/proposals/src/actions/removeSigner.ts +++ b/packages/proposals/src/actions/removeSigner.ts @@ -6,7 +6,7 @@ import { } from '@solana/web3.js'; import { contexts, utils, models, ParsedAccount } from '@oyster/common'; -import { GOVERNANCE_AUTHORITY_SEED, TimelockSet } from '../models/timelock'; +import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/timelock'; import { removeSignerInstruction } from '../models/removeSigner'; const { sendTransaction } = contexts.Connection; const { notify } = utils; @@ -15,7 +15,7 @@ const { approve } = models; export const removeSigner = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, + proposal: ParsedAccount, adminAccount: PublicKey, sigAccount: PublicKey, ) => { diff --git a/packages/proposals/src/actions/sign.ts b/packages/proposals/src/actions/sign.ts index 02d34a3..4637eb5 100644 --- a/packages/proposals/src/actions/sign.ts +++ b/packages/proposals/src/actions/sign.ts @@ -8,8 +8,8 @@ import { contexts, utils, models, ParsedAccount } from '@oyster/common'; import { GOVERNANCE_AUTHORITY_SEED, - TimelockSet, - TimelockState, + Proposal, + ProposalState, } from '../models/timelock'; import { signInstruction } from '../models/sign'; @@ -20,8 +20,8 @@ const { approve } = models; export const sign = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, sigAccount: PublicKey, ) => { const PROGRAM_IDS = utils.programIds(); diff --git a/packages/proposals/src/actions/withdrawVotingTokens.ts b/packages/proposals/src/actions/withdrawVotingTokens.ts index 424ba34..7461090 100644 --- a/packages/proposals/src/actions/withdrawVotingTokens.ts +++ b/packages/proposals/src/actions/withdrawVotingTokens.ts @@ -14,9 +14,9 @@ import { import { GOVERNANCE_AUTHORITY_SEED, - TimelockSet, - TimelockState, - TimelockStateStatus, + Proposal, + ProposalState, + ProposalStateStatus, } from '../models/timelock'; import { AccountLayout } from '@solana/spl-token'; import { withdrawVotingTokensInstruction } from '../models/withdrawVotingTokens'; @@ -29,8 +29,8 @@ const { approve } = models; export const withdrawVotingTokens = async ( connection: Connection, wallet: any, - proposal: ParsedAccount, - state: ParsedAccount, + proposal: ParsedAccount, + state: ParsedAccount, existingVoteAccount: PublicKey | undefined, existingYesVoteAccount: PublicKey | undefined, existingNoVoteAccount: PublicKey | undefined, @@ -150,7 +150,7 @@ export const withdrawVotingTokens = async ( ); const [msg, completedMsg] = - state.info.status === TimelockStateStatus.Voting + state.info.status === ProposalStateStatus.Voting ? [LABELS.WITHDRAWING_YOUR_VOTE, LABELS.VOTE_WITHDRAWN] : [LABELS.REFUNDING_YOUR_TOKENS, LABELS.TOKENS_REFUNDED]; diff --git a/packages/proposals/src/components/Proposal/AddSigners.tsx b/packages/proposals/src/components/Proposal/AddSigners.tsx index fe27065..eb55bb3 100644 --- a/packages/proposals/src/components/Proposal/AddSigners.tsx +++ b/packages/proposals/src/components/Proposal/AddSigners.tsx @@ -1,7 +1,7 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Modal, Input, Form, Progress } from 'antd'; import React, { useState } from 'react'; -import { TimelockSet, TimelockState } from '../../models/timelock'; +import { Proposal, ProposalState } from '../../models/timelock'; import { utils, contexts, hooks } from '@oyster/common'; import { addSigner } from '../../actions/addSigner'; import { PublicKey } from '@solana/web3.js'; @@ -22,8 +22,8 @@ export default function AddSigners({ proposal, state, }: { - proposal: ParsedAccount; - state: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/proposals/src/components/Proposal/InstructionCard.tsx index 7c026c7..8ca4561 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/InstructionCard.tsx @@ -14,9 +14,9 @@ import React, { useEffect, useMemo, useState } from 'react'; import { execute } from '../../actions/execute'; import { LABELS } from '../../constants'; import { - TimelockSet, - TimelockState, - TimelockStateStatus, + Proposal, + ProposalState, + ProposalStateStatus, TimelockTransaction, } from '../../models/timelock'; @@ -38,8 +38,8 @@ export function InstructionCard({ position, }: { instruction: ParsedAccount; - proposal: ParsedAccount; - state: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; position: number; }) { const [tabKey, setTabKey] = useState('info'); @@ -106,8 +106,8 @@ function PlayStatusButton({ setPlaying, instruction, }: { - proposal: ParsedAccount; - state: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; instruction: ParsedAccount; playing: Playstate; setPlaying: React.Dispatch>; @@ -144,8 +144,8 @@ function PlayStatusButton({ }; if ( - state.info.status !== TimelockStateStatus.Executing && - state.info.status !== TimelockStateStatus.Completed + state.info.status !== ProposalStateStatus.Executing && + state.info.status !== ProposalStateStatus.Completed ) return null; if (ineligibleToSee) return null; diff --git a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx b/packages/proposals/src/components/Proposal/MintSourceTokens.tsx index 3e538be..8666aa7 100644 --- a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx +++ b/packages/proposals/src/components/Proposal/MintSourceTokens.tsx @@ -1,7 +1,7 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Modal, Input, Form, Progress, InputNumber, Radio } from 'antd'; import React, { useState } from 'react'; -import { TimelockConfig } from '../../models/timelock'; +import { Governance } from '../../models/timelock'; import { utils, contexts } from '@oyster/common'; import { PublicKey } from '@solana/web3.js'; import { LABELS } from '../../constants'; @@ -25,7 +25,7 @@ export default function MintSourceTokens({ timelockConfig, useGovernance, }: { - timelockConfig: ParsedAccount; + timelockConfig: ParsedAccount; useGovernance: boolean; }) { const PROGRAM_IDS = utils.programIds(); diff --git a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx b/packages/proposals/src/components/Proposal/NewInstructionCard.tsx index af8fc55..9f2c012 100644 --- a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/NewInstructionCard.tsx @@ -3,9 +3,9 @@ import { Card } from 'antd'; import { Form, Input } from 'antd'; import { INSTRUCTION_LIMIT, - TimelockConfig, - TimelockSet, - TimelockState, + Governance, + Proposal, + ProposalState, } from '../../models/timelock'; import { contexts, ParsedAccount, hooks, utils } from '@oyster/common'; import { addCustomSingleSignerTransaction } from '../../actions/addCustomSingleSignerTransaction'; @@ -28,9 +28,9 @@ export function NewInstructionCard({ position, config, }: { - proposal: ParsedAccount; - state: ParsedAccount; - config: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; + config: ParsedAccount; position: number; }) { const [form] = Form.useForm(); diff --git a/packages/proposals/src/components/Proposal/SignButton.tsx b/packages/proposals/src/components/Proposal/SignButton.tsx index 0e9ba8d..a01ce2c 100644 --- a/packages/proposals/src/components/Proposal/SignButton.tsx +++ b/packages/proposals/src/components/Proposal/SignButton.tsx @@ -3,7 +3,7 @@ import { ParsedAccount, hooks, contexts, utils } from '@oyster/common'; import { Button, Modal } from 'antd'; import React from 'react'; import { sign } from '../../actions/sign'; -import { TimelockSet, TimelockState } from '../../models/timelock'; +import { Proposal, ProposalState } from '../../models/timelock'; const { confirm } = Modal; const { useWallet } = contexts.Wallet; @@ -15,8 +15,8 @@ export default function SignButton({ proposal, state, }: { - proposal: ParsedAccount; - state: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); diff --git a/packages/proposals/src/components/Proposal/StateBadge.tsx b/packages/proposals/src/components/Proposal/StateBadge.tsx index 16098eb..39600e0 100644 --- a/packages/proposals/src/components/Proposal/StateBadge.tsx +++ b/packages/proposals/src/components/Proposal/StateBadge.tsx @@ -3,15 +3,15 @@ import { Badge, Tag } from 'antd'; import React from 'react'; import { STATE_COLOR, - TimelockState, - TimelockStateStatus, + ProposalState, + ProposalStateStatus, } from '../../models/timelock'; export function StateBadgeRibbon({ state, children, }: { - state: ParsedAccount; + state: ParsedAccount; children?: any; }) { const status = state.info.status; @@ -19,19 +19,19 @@ export function StateBadgeRibbon({ return ( {children} ); } -export function StateBadge({ state }: { state: ParsedAccount }) { +export function StateBadge({ state }: { state: ParsedAccount }) { const status = state.info.status; let color = STATE_COLOR[status]; return ( - {TimelockStateStatus[status]} + {ProposalStateStatus[status]} ); } diff --git a/packages/proposals/src/components/Proposal/Vote.tsx b/packages/proposals/src/components/Proposal/Vote.tsx index 630eb0e..4b6e349 100644 --- a/packages/proposals/src/components/Proposal/Vote.tsx +++ b/packages/proposals/src/components/Proposal/Vote.tsx @@ -2,10 +2,10 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Col, Modal, Row } from 'antd'; import React from 'react'; import { - TimelockConfig, - TimelockSet, - TimelockState, - TimelockStateStatus, + Governance, + Proposal, + ProposalState, + ProposalStateStatus, } from '../../models/timelock'; import { LABELS } from '../../constants'; import { depositSourceTokensAndVote } from '../../actions/depositSourceTokensAndVote'; @@ -25,9 +25,9 @@ export function Vote({ timelockConfig, yeahVote, }: { - proposal: ParsedAccount; - state: ParsedAccount; - timelockConfig: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; + timelockConfig: ParsedAccount; yeahVote: boolean; }) { const wallet = useWallet(); @@ -42,7 +42,7 @@ export function Vote({ const eligibleToView = userTokenAccount && userTokenAccount.info.amount.toNumber() > 0 && - state.info.status === TimelockStateStatus.Voting; + state.info.status === ProposalStateStatus.Voting; const [btnLabel, title, msg, icon] = yeahVote ? [ diff --git a/packages/proposals/src/components/Proposal/WithdrawVote.tsx b/packages/proposals/src/components/Proposal/WithdrawVote.tsx index ddf1597..7cb464e 100644 --- a/packages/proposals/src/components/Proposal/WithdrawVote.tsx +++ b/packages/proposals/src/components/Proposal/WithdrawVote.tsx @@ -2,10 +2,10 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Col, Modal, Row } from 'antd'; import React from 'react'; import { - TimelockConfig, - TimelockSet, - TimelockState, - TimelockStateStatus, + Governance, + Proposal, + ProposalState, + ProposalStateStatus, } from '../../models/timelock'; import { LABELS } from '../../constants'; import { withdrawVotingTokens } from '../../actions/withdrawVotingTokens'; @@ -21,9 +21,9 @@ export function WithdrawVote({ proposal, state, }: { - proposal: ParsedAccount; - state: ParsedAccount; - timelockConfig: ParsedAccount; + proposal: ParsedAccount; + state: ParsedAccount; + timelockConfig: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); @@ -41,13 +41,13 @@ export function WithdrawVote({ const eligibleToView = votingTokens > 0 && - (state.info.status === TimelockStateStatus.Voting || - state.info.status === TimelockStateStatus.Completed || - state.info.status === TimelockStateStatus.Executing || - state.info.status === TimelockStateStatus.Defeated); + (state.info.status === ProposalStateStatus.Voting || + state.info.status === ProposalStateStatus.Completed || + state.info.status === ProposalStateStatus.Executing || + state.info.status === ProposalStateStatus.Defeated); const [btnLabel, title, msg, action] = - state.info.status === TimelockStateStatus.Voting + state.info.status === ProposalStateStatus.Voting ? [ LABELS.WITHDRAW_VOTE, LABELS.WITHDRAW_YOUR_VOTE_QUESTION, diff --git a/packages/proposals/src/contexts/proposals.tsx b/packages/proposals/src/contexts/proposals.tsx index 2488d48..a08274b 100644 --- a/packages/proposals/src/contexts/proposals.tsx +++ b/packages/proposals/src/contexts/proposals.tsx @@ -14,26 +14,26 @@ import { cache, } from '@oyster/common'; import { - CustomSingleSignerTimelockTransactionLayout, - CustomSingleSignerTimelockTransactionParser, - TimelockConfig, - TimelockConfigLayout, - TimelockConfigParser, - TimelockSet, - TimelockState, - TimelockSetLayout, + CustomSingleSignerTransactionLayout, + CustomSingleSignerTransactionParser, + Governance, + GovernanceLayout, + GovernanceParser, + Proposal, + ProposalState, + ProposalLayout, TimelockSetParser, TimelockTransaction, - TimelockStateParser, - TimelockStateLayout, - CustomSingleSignerTimelockTransaction, + ProposalStateParser, + ProposalStateLayout, + CustomSingleSignerTransaction, } from '../models/timelock'; export interface ProposalsContextState { - proposals: Record>; + proposals: Record>; transactions: Record>; - states: Record>; - configs: Record>; + states: Record>; + configs: Record>; } export const ProposalsContext = React.createContext( @@ -91,39 +91,35 @@ function useSetupProposalsCache({ return programAccounts; }; Promise.all([query()]).then((all: PublicKeyAndAccount[][]) => { - const newProposals: Record> = {}; + const newProposals: Record> = {}; const newTransactions: Record< string, ParsedAccount > = {}; - const newStates: Record> = {}; - const newConfigs: Record> = {}; + const newStates: Record> = {}; + const newConfigs: Record> = {}; all[0].forEach(a => { let cached; switch (a.account.data.length) { - case TimelockSetLayout.span: + case ProposalLayout.span: cache.add(a.pubkey, a.account, TimelockSetParser); - cached = cache.get(a.pubkey) as ParsedAccount; + cached = cache.get(a.pubkey) as ParsedAccount; newProposals[a.pubkey.toBase58()] = cached; break; - case CustomSingleSignerTimelockTransactionLayout.span: - cache.add( - a.pubkey, - a.account, - CustomSingleSignerTimelockTransactionParser, - ); + case CustomSingleSignerTransactionLayout.span: + cache.add(a.pubkey, a.account, CustomSingleSignerTransactionParser); cached = cache.get(a.pubkey) as ParsedAccount; newTransactions[a.pubkey.toBase58()] = cached; break; - case TimelockConfigLayout.span: - cache.add(a.pubkey, a.account, TimelockConfigParser); - cached = cache.get(a.pubkey) as ParsedAccount; + case GovernanceLayout.span: + cache.add(a.pubkey, a.account, GovernanceParser); + cached = cache.get(a.pubkey) as ParsedAccount; newConfigs[a.pubkey.toBase58()] = cached; break; - case TimelockStateLayout.span: - cache.add(a.pubkey, a.account, TimelockStateParser); - cached = cache.get(a.pubkey) as ParsedAccount; + case ProposalStateLayout.span: + cache.add(a.pubkey, a.account, ProposalStateParser); + cached = cache.get(a.pubkey) as ParsedAccount; newStates[a.pubkey.toBase58()] = cached; break; } @@ -138,39 +134,35 @@ function useSetupProposalsCache({ PROGRAM_IDS.timelock.programId, async (info: KeyedAccountInfo) => { [ - [TimelockSetLayout.span, TimelockSetParser, setProposals], + [ProposalLayout.span, TimelockSetParser, setProposals], [ - CustomSingleSignerTimelockTransactionLayout.span, - CustomSingleSignerTimelockTransactionParser, + CustomSingleSignerTransactionLayout.span, + CustomSingleSignerTransactionParser, setTransactions, ], - [TimelockStateLayout.span, TimelockStateParser, setStates], - [TimelockConfigLayout.span, TimelockConfigParser, setConfigs], + [ProposalStateLayout.span, ProposalStateParser, setStates], + [GovernanceLayout.span, GovernanceParser, setConfigs], ].forEach(arr => { const [span, parser, setter] = arr; if (info.accountInfo.data.length === span) { cache.add(info.accountId, info.accountInfo, parser); let cached: any; switch (info.accountInfo.data.length) { - case TimelockSetLayout.span: - cached = cache.get( - info.accountId, - ) as ParsedAccount; + case ProposalLayout.span: + cached = cache.get(info.accountId) as ParsedAccount; break; - case CustomSingleSignerTimelockTransactionLayout.span: + case CustomSingleSignerTransactionLayout.span: cached = cache.get( info.accountId, - ) as ParsedAccount; + ) as ParsedAccount; break; - case TimelockConfigLayout.span: - cached = cache.get( - info.accountId, - ) as ParsedAccount; + case GovernanceLayout.span: + cached = cache.get(info.accountId) as ParsedAccount; break; - case TimelockStateLayout.span: + case ProposalStateLayout.span: cached = cache.get( info.accountId, - ) as ParsedAccount; + ) as ParsedAccount; break; } setter((obj: any) => ({ diff --git a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts b/packages/proposals/src/models/addCustomSingleSignerTransaction.ts index e15890f..385ee09 100644 --- a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts +++ b/packages/proposals/src/models/addCustomSingleSignerTransaction.ts @@ -5,8 +5,8 @@ import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; import { INSTRUCTION_LIMIT, - TimelockInstruction, - TRANSACTION_SLOTS, + GovernanceInstruction, + MAX_TRANSACTIONS, } from './timelock'; import BN from 'bn.js'; @@ -53,9 +53,9 @@ export const addCustomSingleSignerTransactionInstruction = ( ); } - if (position > TRANSACTION_SLOTS) { + if (position > MAX_TRANSACTIONS) { throw new Error( - 'Position is more than ' + TRANSACTION_SLOTS + ' which is not allowed.', + 'Position is more than ' + MAX_TRANSACTIONS + ' which is not allowed.', ); } @@ -75,7 +75,7 @@ export const addCustomSingleSignerTransactionInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.AddCustomSingleSignerTransaction, + instruction: GovernanceInstruction.AddCustomSingleSignerTransaction, slot: new BN(slot), instructions: instructionAsBytes, position: position, diff --git a/packages/proposals/src/models/addSigner.ts b/packages/proposals/src/models/addSigner.ts index 244354e..03cd045 100644 --- a/packages/proposals/src/models/addSigner.ts +++ b/packages/proposals/src/models/addSigner.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; /// [Requires Admin token] /// Adds a signatory to the Timelock which means that this timelock can't leave Draft state until yet another signatory burns @@ -35,7 +35,7 @@ export const addSignerInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.AddSigner, + instruction: GovernanceInstruction.AddSigner, }, data, ); diff --git a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts b/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts index 9326817..b8c1d6e 100644 --- a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts +++ b/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; /// 0. `[]` Governance voting record key. Needs to be set with pubkey set to PDA with seeds of the /// program account key, proposal key, your voting account key. @@ -24,7 +24,7 @@ export const createEmptyGovernanceVotingRecordInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.CreateGovernanceVotingRecord, + instruction: GovernanceInstruction.CreateGovernanceVotingRecord, }, data, ); diff --git a/packages/proposals/src/models/createEmptyTimelockConfig.ts b/packages/proposals/src/models/createEmptyTimelockConfig.ts index fdc688e..1d3f702 100644 --- a/packages/proposals/src/models/createEmptyTimelockConfig.ts +++ b/packages/proposals/src/models/createEmptyTimelockConfig.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; /// 0. `[]` Timelock config key. Needs to be set with pubkey set to PDA with seeds of the /// program account key, governance mint key, council mint key, and timelock program account key. @@ -28,7 +28,7 @@ export const createEmptyTimelockConfigInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.CreateEmptyTimelockConfig, + instruction: GovernanceInstruction.CreateEmptyGovernance, }, data, ); diff --git a/packages/proposals/src/models/depositSourceTokens.ts b/packages/proposals/src/models/depositSourceTokens.ts index 371d8e6..dd9c4c6 100644 --- a/packages/proposals/src/models/depositSourceTokens.ts +++ b/packages/proposals/src/models/depositSourceTokens.ts @@ -3,7 +3,7 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; import BN from 'bn.js'; /// [Requires tokens of the Governance mint or Council mint depending on type of TimelockSet] @@ -42,7 +42,7 @@ export const depositSourceTokensInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.DepositGovernanceTokens, + instruction: GovernanceInstruction.DepositGovernanceTokens, votingTokenAmount: new BN(votingTokenAmount), }, data, diff --git a/packages/proposals/src/models/execute.ts b/packages/proposals/src/models/execute.ts index 5a56361..39321e0 100644 --- a/packages/proposals/src/models/execute.ts +++ b/packages/proposals/src/models/execute.ts @@ -5,7 +5,7 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; /// Executes a command in the timelock set. /// @@ -35,7 +35,7 @@ export const executeInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.Execute, + instruction: GovernanceInstruction.Execute, numberOfExtraAccounts: accountInfos.length, }, data, diff --git a/packages/proposals/src/models/initTimelockConfig.ts b/packages/proposals/src/models/initTimelockConfig.ts index eead19f..7c0da23 100644 --- a/packages/proposals/src/models/initTimelockConfig.ts +++ b/packages/proposals/src/models/initTimelockConfig.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { CONFIG_NAME_LENGTH, TimelockInstruction } from './timelock'; +import { CONFIG_NAME_LENGTH, GovernanceInstruction } from './timelock'; import BN from 'bn.js'; import * as Layout from '../utils/layout'; @@ -49,7 +49,7 @@ export const initTimelockConfigInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.InitTimelockConfig, + instruction: GovernanceInstruction.InitGovernance, voteThreshold, executionType, timelockType, diff --git a/packages/proposals/src/models/initTimelockSet.ts b/packages/proposals/src/models/initTimelockSet.ts index 8feda01..c77abbb 100644 --- a/packages/proposals/src/models/initTimelockSet.ts +++ b/packages/proposals/src/models/initTimelockSet.ts @@ -5,7 +5,7 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { DESC_SIZE, NAME_SIZE, TimelockInstruction } from './timelock'; +import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './timelock'; /// Initializes a new empty Timelocked set of Instructions that will be executed at various slots in the future in draft mode. /// Grants Admin token to caller. @@ -80,7 +80,7 @@ export const initTimelockSetInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.InitTimelockSet, + instruction: GovernanceInstruction.InitProposal, descLink: descAsBytes, name: nameAsBytes, }, diff --git a/packages/proposals/src/models/removeSigner.ts b/packages/proposals/src/models/removeSigner.ts index 6dec5a7..3f8d5bc 100644 --- a/packages/proposals/src/models/removeSigner.ts +++ b/packages/proposals/src/models/removeSigner.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; /// [Requires Admin token] /// Removes a signer from the set. @@ -31,7 +31,7 @@ export const removeSignerInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.RemoveSigner, + instruction: GovernanceInstruction.RemoveSigner, }, data, ); diff --git a/packages/proposals/src/models/sign.ts b/packages/proposals/src/models/sign.ts index 54048e9..b559303 100644 --- a/packages/proposals/src/models/sign.ts +++ b/packages/proposals/src/models/sign.ts @@ -5,7 +5,7 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; /// [Requires Signatory token] /// Burns signatory token, indicating you approve of moving this Timelock set from Draft state to Voting state. @@ -35,7 +35,7 @@ export const signInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.Sign, + instruction: GovernanceInstruction.Sign, }, data, ); diff --git a/packages/proposals/src/models/timelock.ts b/packages/proposals/src/models/timelock.ts index 19996fe..97995ea 100644 --- a/packages/proposals/src/models/timelock.ts +++ b/packages/proposals/src/models/timelock.ts @@ -8,25 +8,25 @@ export const DESC_SIZE = 200; export const NAME_SIZE = 32; export const CONFIG_NAME_LENGTH = 32; export const INSTRUCTION_LIMIT = 450; -export const TRANSACTION_SLOTS = 5; +export const MAX_TRANSACTIONS = 5; export const TEMP_FILE_TXN_SIZE = 1000; /// Seed for proposal authority export const GOVERNANCE_AUTHORITY_SEED = 'governance'; -export enum TimelockInstruction { - InitTimelockSet = 1, +export enum GovernanceInstruction { + InitProposal = 1, AddSigner = 2, RemoveSigner = 3, AddCustomSingleSignerTransaction = 4, Sign = 8, Vote = 9, - InitTimelockConfig = 10, + InitGovernance = 10, Execute = 11, DepositGovernanceTokens = 12, WithdrawVotingTokens = 13, - CreateEmptyTimelockConfig = 14, + CreateEmptyGovernance = 14, CreateGovernanceVotingRecord = 15, } @@ -58,7 +58,7 @@ export const GovernanceVotingRecordLayout: typeof BufferLayout.Structure = Buffe ], ); -export interface TimelockConfig { +export interface Governance { /// Account type accountType: GovernanceAccountType; /// Vote threshold @@ -66,7 +66,7 @@ export interface TimelockConfig { /// Execution type executionType: ExecutionType; /// Timelock Type - timelockType: TimelockType; + timelockType: GovernanceType; /// Voting entry rule votingEntryRule: VotingEntryRule; /// Minimum slot time-distance from creation of proposal for an instruction to be placed @@ -94,7 +94,7 @@ export enum GovernanceAccountType { CustomSingleSignerTransaction = 5, } -export const TimelockConfigLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const GovernanceLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ BufferLayout.u8('accountType'), BufferLayout.u8('voteThreshold'), @@ -121,11 +121,11 @@ export enum ExecutionType { Independent = 0, } -export enum TimelockType { - CustomSingleSignerV1 = 0, +export enum GovernanceType { + Governance = 0, } -export enum TimelockStateStatus { +export enum ProposalStateStatus { /// Draft Draft = 0, /// Taking votes @@ -145,19 +145,19 @@ export enum TimelockStateStatus { } export const STATE_COLOR: Record = { - [TimelockStateStatus.Draft]: 'orange', - [TimelockStateStatus.Voting]: 'blue', - [TimelockStateStatus.Executing]: 'green', - [TimelockStateStatus.Completed]: 'purple', - [TimelockStateStatus.Deleted]: 'gray', - [TimelockStateStatus.Defeated]: 'red', + [ProposalStateStatus.Draft]: 'orange', + [ProposalStateStatus.Voting]: 'blue', + [ProposalStateStatus.Executing]: 'green', + [ProposalStateStatus.Completed]: 'purple', + [ProposalStateStatus.Deleted]: 'gray', + [ProposalStateStatus.Defeated]: 'red', }; -export interface TimelockState { +export interface ProposalState { /// Account type accountType: GovernanceAccountType; timelockSet: PublicKey; - status: TimelockStateStatus; + status: ProposalStateStatus; totalSigningTokensMinted: BN; timelockTransactions: PublicKey[]; name: string; @@ -171,12 +171,12 @@ export interface TimelockState { usedTxnSlots: number; } -const timelockTxns = []; -for (let i = 0; i < TRANSACTION_SLOTS; i++) { - timelockTxns.push(Layout.publicKey('timelockTxn' + i.toString())); +const proposalTxns = []; +for (let i = 0; i < MAX_TRANSACTIONS; i++) { + proposalTxns.push(Layout.publicKey('timelockTxn' + i.toString())); } -export const TimelockSetLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const ProposalLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ BufferLayout.u8('accountType'), Layout.publicKey('config'), @@ -198,7 +198,7 @@ export const TimelockSetLayout: typeof BufferLayout.Structure = BufferLayout.str ], ); -export const TimelockStateLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const ProposalStateLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ BufferLayout.u8('accountType'), Layout.publicKey('timelockSet'), @@ -213,12 +213,12 @@ export const TimelockStateLayout: typeof BufferLayout.Structure = BufferLayout.s Layout.uint64('deletedAt'), BufferLayout.u8('executions'), BufferLayout.u8('usedTxnSlots'), - ...timelockTxns, + ...proposalTxns, BufferLayout.seq(BufferLayout.u8(), 300, 'padding'), ], ); -export interface TimelockSet { +export interface Proposal { /// Account type accountType: GovernanceAccountType; @@ -270,7 +270,7 @@ export interface TimelockSet { noVotingDump: PublicKey; } -export const CustomSingleSignerTimelockTransactionLayout: typeof BufferLayout.Structure = BufferLayout.struct( +export const CustomSingleSignerTransactionLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ BufferLayout.u8('accountType'), Layout.uint64('slot'), @@ -293,15 +293,14 @@ export interface TimelockTransaction { instructionEndIndex: number; } -export interface CustomSingleSignerTimelockTransaction - extends TimelockTransaction {} +export interface CustomSingleSignerTransaction extends TimelockTransaction {} export const TimelockSetParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = TimelockSetLayout.decode(buffer); + const data = ProposalLayout.decode(buffer); const details = { pubkey: pubKey, account: { @@ -354,15 +353,15 @@ export const GovernanceVotingRecordParser = ( return details; }; -export const TimelockStateParser = ( +export const ProposalStateParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = TimelockStateLayout.decode(buffer); + const data = ProposalStateLayout.decode(buffer); const timelockTxns = []; - for (let i = 0; i < TRANSACTION_SLOTS; i++) { + for (let i = 0; i < MAX_TRANSACTIONS; i++) { timelockTxns.push(data['timelockTxn' + i.toString()]); } @@ -392,12 +391,12 @@ export const TimelockStateParser = ( return details; }; -export const CustomSingleSignerTimelockTransactionParser = ( +export const CustomSingleSignerTransactionParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = CustomSingleSignerTimelockTransactionLayout.decode(buffer); + const data = CustomSingleSignerTransactionLayout.decode(buffer); const details = { pubkey: pubKey, @@ -417,12 +416,12 @@ export const CustomSingleSignerTimelockTransactionParser = ( return details; }; -export const TimelockConfigParser = ( +export const GovernanceParser = ( pubKey: PublicKey, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); - const data = TimelockConfigLayout.decode(buffer); + const data = GovernanceLayout.decode(buffer); const details = { pubkey: pubKey, diff --git a/packages/proposals/src/models/vote.ts b/packages/proposals/src/models/vote.ts index 3bbd3ec..adf47a8 100644 --- a/packages/proposals/src/models/vote.ts +++ b/packages/proposals/src/models/vote.ts @@ -7,7 +7,7 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; import BN from 'bn.js'; /// [Requires Voting tokens] @@ -60,7 +60,7 @@ export const voteInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.Vote, + instruction: GovernanceInstruction.Vote, yesVotingTokenAmount: new BN(yesVotingTokenAmount), noVotingTokenAmount: new BN(noVotingTokenAmount), }, diff --git a/packages/proposals/src/models/withdrawVotingTokens.ts b/packages/proposals/src/models/withdrawVotingTokens.ts index f488e5d..b18ade8 100644 --- a/packages/proposals/src/models/withdrawVotingTokens.ts +++ b/packages/proposals/src/models/withdrawVotingTokens.ts @@ -3,7 +3,7 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { TimelockInstruction } from './timelock'; +import { GovernanceInstruction } from './timelock'; import BN from 'bn.js'; /// 0. `[writable]` Governance voting record account. See Vote docs for more detail. @@ -51,7 +51,7 @@ export const withdrawVotingTokensInstruction = ( dataLayout.encode( { - instruction: TimelockInstruction.WithdrawVotingTokens, + instruction: GovernanceInstruction.WithdrawVotingTokens, votingTokenAmount: new BN(votingTokenAmount), }, data, diff --git a/packages/proposals/src/utils/serialize.ts b/packages/proposals/src/utils/serialize.ts index 8017f84..73f0c56 100644 --- a/packages/proposals/src/utils/serialize.ts +++ b/packages/proposals/src/utils/serialize.ts @@ -6,7 +6,7 @@ import { PublicKey, Message, } from '@solana/web3.js'; -import { GOVERNANCE_AUTHORITY_SEED, TimelockSet } from '../models/timelock'; +import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/timelock'; export async function serializeInstruction({ connection, instr, @@ -14,7 +14,7 @@ export async function serializeInstruction({ }: { connection: Connection; instr: TransactionInstruction; - proposal: ParsedAccount; + proposal: ParsedAccount; }): Promise<{ base64: string; byteArray: Uint8Array }> { const PROGRAM_IDS = utils.programIds(); let instructionTransaction = new Transaction(); diff --git a/packages/proposals/src/views/dashboard/index.tsx b/packages/proposals/src/views/dashboard/index.tsx index 5bd00dc..6b39f22 100644 --- a/packages/proposals/src/views/dashboard/index.tsx +++ b/packages/proposals/src/views/dashboard/index.tsx @@ -4,7 +4,7 @@ import { GUTTER } from '../../constants'; import { contexts, hooks, ParsedAccount } from '@oyster/common'; import './style.less'; import { useProposals } from '../../contexts/proposals'; -import { TimelockSet } from '../../models/timelock'; +import { Proposal } from '../../models/timelock'; import { Connection } from '@solana/web3.js'; import { WalletAdapter } from '@solana/wallet-base'; const { useWallet } = contexts.Wallet; @@ -38,7 +38,7 @@ function InnerDummyView({ }: { connection: Connection; wallet: WalletAdapter; - proposal: ParsedAccount; + proposal: ParsedAccount; }) { const sigAccount = useAccountByMint(proposal.info.signatoryMint); if (!sigAccount) return ; diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/proposals/src/views/governance/index.tsx index bb3fee5..42811c7 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/proposals/src/views/governance/index.tsx @@ -11,8 +11,8 @@ import { } from '@oyster/common'; import { ExecutionType, - TimelockConfig, - TimelockType, + Governance, + GovernanceType, VotingEntryRule, } from '../../models/timelock'; import { PublicKey } from '@solana/web3.js'; @@ -42,7 +42,7 @@ const columns = [ title: LABELS.PROPOSAL_TYPE, dataIndex: 'timelockType', key: 'timelockType', - render: (number: number) => {TimelockType[number]}, + render: (number: number) => {GovernanceType[number]}, }, { title: LABELS.VOTING_ENTRY_RULES, @@ -85,7 +85,7 @@ const columns = [ title: LABELS.ACTIONS, dataIndex: 'config', key: 'config', - render: (config: ParsedAccount) => ( + render: (config: ParsedAccount) => ( <> {config.info.councilMint && ( diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/proposals/src/views/governance/register.tsx index b49df29..acfee71 100644 --- a/packages/proposals/src/views/governance/register.tsx +++ b/packages/proposals/src/views/governance/register.tsx @@ -5,7 +5,7 @@ import { PublicKey } from '@solana/web3.js'; import { CONFIG_NAME_LENGTH, ExecutionType, - TimelockType, + GovernanceType, VotingEntryRule, } from '../../models/timelock'; import { LABELS } from '../../constants'; @@ -68,7 +68,7 @@ export function NewForm({ const wallet = useWallet(); const connection = useConnection(); const onFinish = async (values: { - timelockType: TimelockType; + timelockType: GovernanceType; executionType: ExecutionType; voteThreshold: number; votingEntryRule: VotingEntryRule; @@ -218,12 +218,10 @@ export function NewForm({ name="timelockType" label={LABELS.PROPOSAL_TYPE} rules={[{ required: true }]} - initialValue={TimelockType.CustomSingleSignerV1} + initialValue={GovernanceType.Governance} > { const history = useHistory(); @@ -26,8 +26,8 @@ export const HomeView = () => { if (proposal.info.config.toBase58() === configKey) { acc.active = acc.active + - (state.info.status === TimelockStateStatus.Voting || - state.info.status === TimelockStateStatus.Draft + (state.info.status === ProposalStateStatus.Voting || + state.info.status === ProposalStateStatus.Draft ? 1 : 0); diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/proposals/src/views/proposal/index.tsx index 8028397..94044b5 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/proposals/src/views/proposal/index.tsx @@ -4,10 +4,10 @@ import { LABELS } from '../../constants'; import { ParsedAccount, TokenIcon } from '@oyster/common'; import { INSTRUCTION_LIMIT, - TimelockConfig, - TimelockSet, - TimelockState, - TimelockStateStatus, + Governance, + Proposal, + ProposalState, + ProposalStateStatus, TimelockTransaction, } from '../../models/timelock'; import { useParams } from 'react-router-dom'; @@ -102,7 +102,7 @@ function useLoadGist({ setFailed: (b: boolean) => void; setContent: (b: string) => void; isGist: boolean; - timelockState: ParsedAccount; + timelockState: ParsedAccount; }) { useMemo(() => { if (loading) { @@ -217,9 +217,9 @@ function InnerProposalView({ votingDisplayData, endpoint, }: { - proposal: ParsedAccount; - timelockConfig: ParsedAccount; - timelockState: ParsedAccount; + proposal: ParsedAccount; + timelockConfig: ParsedAccount; + timelockState: ParsedAccount; sigMint: MintInfo; votingMint: MintInfo; yesVotingMint: MintInfo; @@ -277,12 +277,12 @@ function InnerProposalView({
{adminAccount && adminAccount.info.amount.toNumber() === 1 && - timelockState.info.status === TimelockStateStatus.Draft && ( + timelockState.info.status === ProposalStateStatus.Draft && ( )} {sigAccount && sigAccount.info.amount.toNumber() === 1 && - timelockState.info.status === TimelockStateStatus.Draft && ( + timelockState.info.status === ProposalStateStatus.Draft && ( )} ))} {instructionsForProposal.length < INSTRUCTION_LIMIT && - timelockState.info.status === TimelockStateStatus.Draft && ( + timelockState.info.status === ProposalStateStatus.Draft && (
, + timelockConfig: ParsedAccount, sourceMint: MintInfo, ): number { return timelockConfig.info.voteThreshold === 100 From 5c994fe9c546a9dbb0809f09b82a930b4ab37c3b Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 12:19:10 +0100 Subject: [PATCH 08/16] chore: rename instructions to Governance --- .../src/actions/addCustomSingleSignerTransaction.ts | 2 +- packages/proposals/src/actions/addSigner.ts | 2 +- packages/proposals/src/actions/createProposal.ts | 6 +++--- .../src/actions/depositSourceTokensAndVote.ts | 2 +- packages/proposals/src/actions/execute.ts | 2 +- packages/proposals/src/actions/mintSourceTokens.ts | 2 +- .../proposals/src/actions/registerProgramGovernance.ts | 10 +++++----- packages/proposals/src/actions/removeSigner.ts | 2 +- packages/proposals/src/actions/sign.ts | 2 +- packages/proposals/src/actions/withdrawVotingTokens.ts | 2 +- .../proposals/src/components/Proposal/AddSigners.tsx | 2 +- .../src/components/Proposal/InstructionCard.tsx | 2 +- .../src/components/Proposal/MintSourceTokens.tsx | 2 +- .../src/components/Proposal/NewInstructionCard.tsx | 2 +- .../proposals/src/components/Proposal/SignButton.tsx | 2 +- .../proposals/src/components/Proposal/StateBadge.tsx | 2 +- packages/proposals/src/components/Proposal/Vote.tsx | 2 +- .../proposals/src/components/Proposal/WithdrawVote.tsx | 2 +- packages/proposals/src/contexts/proposals.tsx | 2 +- packages/proposals/src/hooks/useVotingRecords.ts | 2 +- .../src/models/addCustomSingleSignerTransaction.ts | 2 +- packages/proposals/src/models/addSigner.ts | 2 +- ...EmptyTimelockConfig.ts => createEmptyGovernance.ts} | 4 ++-- .../src/models/createEmptyGovernanceVotingRecord.ts | 2 +- packages/proposals/src/models/depositSourceTokens.ts | 2 +- packages/proposals/src/models/execute.ts | 2 +- .../src/models/{timelock.ts => governance.ts} | 0 .../{initTimelockConfig.ts => initGovernance.ts} | 4 ++-- .../src/models/{initTimelockSet.ts => initProposal.ts} | 4 ++-- packages/proposals/src/models/removeSigner.ts | 2 +- packages/proposals/src/models/sign.ts | 2 +- packages/proposals/src/models/vote.ts | 2 +- packages/proposals/src/models/withdrawVotingTokens.ts | 2 +- packages/proposals/src/utils/lookups.ts | 2 +- packages/proposals/src/utils/serialize.ts | 2 +- packages/proposals/src/views/dashboard/index.tsx | 2 +- packages/proposals/src/views/governance/index.tsx | 2 +- packages/proposals/src/views/governance/register.tsx | 2 +- packages/proposals/src/views/home/index.tsx | 2 +- packages/proposals/src/views/proposal/index.tsx | 2 +- packages/proposals/src/views/proposal/new.tsx | 2 +- 41 files changed, 49 insertions(+), 49 deletions(-) rename packages/proposals/src/models/{createEmptyTimelockConfig.ts => createEmptyGovernance.ts} (94%) rename packages/proposals/src/models/{timelock.ts => governance.ts} (100%) rename packages/proposals/src/models/{initTimelockConfig.ts => initGovernance.ts} (95%) rename packages/proposals/src/models/{initTimelockSet.ts => initProposal.ts} (97%) diff --git a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts b/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts index 0729c57..3756805 100644 --- a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts +++ b/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts @@ -11,7 +11,7 @@ import { CustomSingleSignerTransactionLayout, Proposal, ProposalState, -} from '../models/timelock'; +} from '../models/governance'; import { addCustomSingleSignerTransactionInstruction } from '../models/addCustomSingleSignerTransaction'; const { sendTransaction } = contexts.Connection; diff --git a/packages/proposals/src/actions/addSigner.ts b/packages/proposals/src/actions/addSigner.ts index 301c2f7..9e1eb38 100644 --- a/packages/proposals/src/actions/addSigner.ts +++ b/packages/proposals/src/actions/addSigner.ts @@ -16,7 +16,7 @@ import { GOVERNANCE_AUTHORITY_SEED, Proposal, ProposalState, -} from '../models/timelock'; +} from '../models/governance'; import { AccountLayout } from '@solana/spl-token'; import { addSignerInstruction } from '../models/addSigner'; const { createTokenAccount } = actions; diff --git a/packages/proposals/src/actions/createProposal.ts b/packages/proposals/src/actions/createProposal.ts index 0ef7bef..a39cd00 100644 --- a/packages/proposals/src/actions/createProposal.ts +++ b/packages/proposals/src/actions/createProposal.ts @@ -8,13 +8,13 @@ import { import { contexts, utils, actions, ParsedAccount } from '@oyster/common'; import { AccountLayout, MintLayout } from '@solana/spl-token'; -import { initTimelockSetInstruction } from '../models/initTimelockSet'; +import { initProposalInstruction } from '../models/initProposal'; import { GOVERNANCE_AUTHORITY_SEED, Governance, ProposalLayout, ProposalStateLayout, -} from '../models/timelock'; +} from '../models/governance'; const { cache } = contexts.Accounts; const { sendTransactions } = contexts.Connection; @@ -117,7 +117,7 @@ export const createProposal = async ( createTimelockAccountsInstructions.push(uninitializedTimelockSetInstruction); instructions.push( - initTimelockSetInstruction( + initProposalInstruction( timelockStateKey.publicKey, timelockSetKey.publicKey, timelockConfig.pubkey, diff --git a/packages/proposals/src/actions/depositSourceTokensAndVote.ts b/packages/proposals/src/actions/depositSourceTokensAndVote.ts index 8763f1d..6fa2170 100644 --- a/packages/proposals/src/actions/depositSourceTokensAndVote.ts +++ b/packages/proposals/src/actions/depositSourceTokensAndVote.ts @@ -17,7 +17,7 @@ import { Governance, Proposal, ProposalState, -} from '../models/timelock'; +} from '../models/governance'; import { AccountLayout } from '@solana/spl-token'; diff --git a/packages/proposals/src/actions/execute.ts b/packages/proposals/src/actions/execute.ts index b3b4078..2ccbdf1 100644 --- a/packages/proposals/src/actions/execute.ts +++ b/packages/proposals/src/actions/execute.ts @@ -10,7 +10,7 @@ import { Proposal, ProposalState, TimelockTransaction, -} from '../models/timelock'; +} from '../models/governance'; import { executeInstruction } from '../models/execute'; import { LABELS } from '../constants'; import { getMessageAccountInfos } from '../utils/transactions'; diff --git a/packages/proposals/src/actions/mintSourceTokens.ts b/packages/proposals/src/actions/mintSourceTokens.ts index 814feab..a5ffe11 100644 --- a/packages/proposals/src/actions/mintSourceTokens.ts +++ b/packages/proposals/src/actions/mintSourceTokens.ts @@ -6,7 +6,7 @@ import { } from '@solana/web3.js'; import { contexts, utils, ParsedAccount, actions } from '@oyster/common'; -import { Governance } from '../models/timelock'; +import { Governance } from '../models/governance'; import { AccountLayout, Token } from '@solana/spl-token'; import { LABELS } from '../constants'; const { createTokenAccount } = actions; diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/proposals/src/actions/registerProgramGovernance.ts index 55751a8..6e99191 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/proposals/src/actions/registerProgramGovernance.ts @@ -13,10 +13,10 @@ import { Governance, GovernanceType, VotingEntryRule, -} from '../models/timelock'; -import { initTimelockConfigInstruction } from '../models/initTimelockConfig'; +} from '../models/governance'; +import { initGovernanceInstruction } from '../models/initGovernance'; import BN from 'bn.js'; -import { createEmptyTimelockConfigInstruction } from '../models/createEmptyTimelockConfig'; +import { createEmptyGovernanceInstruction } from '../models/createEmptyGovernance'; const { sendTransactions } = contexts.Connection; const { createMint, createTokenAccount } = actions; @@ -126,7 +126,7 @@ export const registerProgramGovernance = async ( ); instructions.push( - createEmptyTimelockConfigInstruction( + createEmptyGovernanceInstruction( timelockConfigKey, uninitializedTimelockConfig.program, programDataAccount, @@ -137,7 +137,7 @@ export const registerProgramGovernance = async ( ), ); instructions.push( - initTimelockConfigInstruction( + initGovernanceInstruction( timelockConfigKey, uninitializedTimelockConfig.program, uninitializedTimelockConfig.governanceMint, diff --git a/packages/proposals/src/actions/removeSigner.ts b/packages/proposals/src/actions/removeSigner.ts index 32b80fa..61cead8 100644 --- a/packages/proposals/src/actions/removeSigner.ts +++ b/packages/proposals/src/actions/removeSigner.ts @@ -6,7 +6,7 @@ import { } from '@solana/web3.js'; import { contexts, utils, models, ParsedAccount } from '@oyster/common'; -import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/timelock'; +import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/governance'; import { removeSignerInstruction } from '../models/removeSigner'; const { sendTransaction } = contexts.Connection; const { notify } = utils; diff --git a/packages/proposals/src/actions/sign.ts b/packages/proposals/src/actions/sign.ts index 4637eb5..deedd14 100644 --- a/packages/proposals/src/actions/sign.ts +++ b/packages/proposals/src/actions/sign.ts @@ -10,7 +10,7 @@ import { GOVERNANCE_AUTHORITY_SEED, Proposal, ProposalState, -} from '../models/timelock'; +} from '../models/governance'; import { signInstruction } from '../models/sign'; const { sendTransaction } = contexts.Connection; diff --git a/packages/proposals/src/actions/withdrawVotingTokens.ts b/packages/proposals/src/actions/withdrawVotingTokens.ts index 7461090..a9dc0ea 100644 --- a/packages/proposals/src/actions/withdrawVotingTokens.ts +++ b/packages/proposals/src/actions/withdrawVotingTokens.ts @@ -17,7 +17,7 @@ import { Proposal, ProposalState, ProposalStateStatus, -} from '../models/timelock'; +} from '../models/governance'; import { AccountLayout } from '@solana/spl-token'; import { withdrawVotingTokensInstruction } from '../models/withdrawVotingTokens'; import { LABELS } from '../constants'; diff --git a/packages/proposals/src/components/Proposal/AddSigners.tsx b/packages/proposals/src/components/Proposal/AddSigners.tsx index eb55bb3..33f3f20 100644 --- a/packages/proposals/src/components/Proposal/AddSigners.tsx +++ b/packages/proposals/src/components/Proposal/AddSigners.tsx @@ -1,7 +1,7 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Modal, Input, Form, Progress } from 'antd'; import React, { useState } from 'react'; -import { Proposal, ProposalState } from '../../models/timelock'; +import { Proposal, ProposalState } from '../../models/governance'; import { utils, contexts, hooks } from '@oyster/common'; import { addSigner } from '../../actions/addSigner'; import { PublicKey } from '@solana/web3.js'; diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/proposals/src/components/Proposal/InstructionCard.tsx index 8ca4561..3c34a69 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/InstructionCard.tsx @@ -18,7 +18,7 @@ import { ProposalState, ProposalStateStatus, TimelockTransaction, -} from '../../models/timelock'; +} from '../../models/governance'; import './style.less'; diff --git a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx b/packages/proposals/src/components/Proposal/MintSourceTokens.tsx index 8666aa7..ec2aa8a 100644 --- a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx +++ b/packages/proposals/src/components/Proposal/MintSourceTokens.tsx @@ -1,7 +1,7 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Modal, Input, Form, Progress, InputNumber, Radio } from 'antd'; import React, { useState } from 'react'; -import { Governance } from '../../models/timelock'; +import { Governance } from '../../models/governance'; import { utils, contexts } from '@oyster/common'; import { PublicKey } from '@solana/web3.js'; import { LABELS } from '../../constants'; diff --git a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx b/packages/proposals/src/components/Proposal/NewInstructionCard.tsx index 9f2c012..f57d238 100644 --- a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/NewInstructionCard.tsx @@ -6,7 +6,7 @@ import { Governance, Proposal, ProposalState, -} from '../../models/timelock'; +} from '../../models/governance'; import { contexts, ParsedAccount, hooks, utils } from '@oyster/common'; import { addCustomSingleSignerTransaction } from '../../actions/addCustomSingleSignerTransaction'; import { SaveOutlined } from '@ant-design/icons'; diff --git a/packages/proposals/src/components/Proposal/SignButton.tsx b/packages/proposals/src/components/Proposal/SignButton.tsx index a01ce2c..2d74b84 100644 --- a/packages/proposals/src/components/Proposal/SignButton.tsx +++ b/packages/proposals/src/components/Proposal/SignButton.tsx @@ -3,7 +3,7 @@ import { ParsedAccount, hooks, contexts, utils } from '@oyster/common'; import { Button, Modal } from 'antd'; import React from 'react'; import { sign } from '../../actions/sign'; -import { Proposal, ProposalState } from '../../models/timelock'; +import { Proposal, ProposalState } from '../../models/governance'; const { confirm } = Modal; const { useWallet } = contexts.Wallet; diff --git a/packages/proposals/src/components/Proposal/StateBadge.tsx b/packages/proposals/src/components/Proposal/StateBadge.tsx index 39600e0..9666210 100644 --- a/packages/proposals/src/components/Proposal/StateBadge.tsx +++ b/packages/proposals/src/components/Proposal/StateBadge.tsx @@ -5,7 +5,7 @@ import { STATE_COLOR, ProposalState, ProposalStateStatus, -} from '../../models/timelock'; +} from '../../models/governance'; export function StateBadgeRibbon({ state, diff --git a/packages/proposals/src/components/Proposal/Vote.tsx b/packages/proposals/src/components/Proposal/Vote.tsx index 4b6e349..ba7fffe 100644 --- a/packages/proposals/src/components/Proposal/Vote.tsx +++ b/packages/proposals/src/components/Proposal/Vote.tsx @@ -6,7 +6,7 @@ import { Proposal, ProposalState, ProposalStateStatus, -} from '../../models/timelock'; +} from '../../models/governance'; import { LABELS } from '../../constants'; import { depositSourceTokensAndVote } from '../../actions/depositSourceTokensAndVote'; import { contexts, hooks } from '@oyster/common'; diff --git a/packages/proposals/src/components/Proposal/WithdrawVote.tsx b/packages/proposals/src/components/Proposal/WithdrawVote.tsx index 7cb464e..ec6f15c 100644 --- a/packages/proposals/src/components/Proposal/WithdrawVote.tsx +++ b/packages/proposals/src/components/Proposal/WithdrawVote.tsx @@ -6,7 +6,7 @@ import { Proposal, ProposalState, ProposalStateStatus, -} from '../../models/timelock'; +} from '../../models/governance'; import { LABELS } from '../../constants'; import { withdrawVotingTokens } from '../../actions/withdrawVotingTokens'; import { contexts, hooks } from '@oyster/common'; diff --git a/packages/proposals/src/contexts/proposals.tsx b/packages/proposals/src/contexts/proposals.tsx index a08274b..3c15144 100644 --- a/packages/proposals/src/contexts/proposals.tsx +++ b/packages/proposals/src/contexts/proposals.tsx @@ -27,7 +27,7 @@ import { ProposalStateParser, ProposalStateLayout, CustomSingleSignerTransaction, -} from '../models/timelock'; +} from '../models/governance'; export interface ProposalsContextState { proposals: Record>; diff --git a/packages/proposals/src/hooks/useVotingRecords.ts b/packages/proposals/src/hooks/useVotingRecords.ts index a9b814d..c535929 100644 --- a/packages/proposals/src/hooks/useVotingRecords.ts +++ b/packages/proposals/src/hooks/useVotingRecords.ts @@ -11,7 +11,7 @@ import { GovernanceVotingRecord, GovernanceVotingRecordLayout, GovernanceVotingRecordParser, -} from '../models/timelock'; +} from '../models/governance'; import { getGovernanceVotingRecords } from '../utils/lookups'; export function useVotingRecords(proposal: PublicKey) { diff --git a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts b/packages/proposals/src/models/addCustomSingleSignerTransaction.ts index 385ee09..3c1c237 100644 --- a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts +++ b/packages/proposals/src/models/addCustomSingleSignerTransaction.ts @@ -7,7 +7,7 @@ import { INSTRUCTION_LIMIT, GovernanceInstruction, MAX_TRANSACTIONS, -} from './timelock'; +} from './governance'; import BN from 'bn.js'; /// [Requires Signatory token] diff --git a/packages/proposals/src/models/addSigner.ts b/packages/proposals/src/models/addSigner.ts index 03cd045..a365350 100644 --- a/packages/proposals/src/models/addSigner.ts +++ b/packages/proposals/src/models/addSigner.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// [Requires Admin token] /// Adds a signatory to the Timelock which means that this timelock can't leave Draft state until yet another signatory burns diff --git a/packages/proposals/src/models/createEmptyTimelockConfig.ts b/packages/proposals/src/models/createEmptyGovernance.ts similarity index 94% rename from packages/proposals/src/models/createEmptyTimelockConfig.ts rename to packages/proposals/src/models/createEmptyGovernance.ts index 1d3f702..a38816c 100644 --- a/packages/proposals/src/models/createEmptyTimelockConfig.ts +++ b/packages/proposals/src/models/createEmptyGovernance.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// 0. `[]` Timelock config key. Needs to be set with pubkey set to PDA with seeds of the /// program account key, governance mint key, council mint key, and timelock program account key. @@ -11,7 +11,7 @@ import { GovernanceInstruction } from './timelock'; /// 4. `[]` Timelock program pub key. /// 5. `[]` System account. /// 6. `[]` Council mint [optional] to tie this config to [Optional] -export const createEmptyTimelockConfigInstruction = ( +export const createEmptyGovernanceInstruction = ( timelockConfigAccount: PublicKey, programAccount: PublicKey, programDataAccount: PublicKey, diff --git a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts b/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts index b8c1d6e..694aa55 100644 --- a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts +++ b/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// 0. `[]` Governance voting record key. Needs to be set with pubkey set to PDA with seeds of the /// program account key, proposal key, your voting account key. diff --git a/packages/proposals/src/models/depositSourceTokens.ts b/packages/proposals/src/models/depositSourceTokens.ts index dd9c4c6..cfbb027 100644 --- a/packages/proposals/src/models/depositSourceTokens.ts +++ b/packages/proposals/src/models/depositSourceTokens.ts @@ -3,7 +3,7 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; /// [Requires tokens of the Governance mint or Council mint depending on type of TimelockSet] diff --git a/packages/proposals/src/models/execute.ts b/packages/proposals/src/models/execute.ts index 39321e0..2692176 100644 --- a/packages/proposals/src/models/execute.ts +++ b/packages/proposals/src/models/execute.ts @@ -5,7 +5,7 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// Executes a command in the timelock set. /// diff --git a/packages/proposals/src/models/timelock.ts b/packages/proposals/src/models/governance.ts similarity index 100% rename from packages/proposals/src/models/timelock.ts rename to packages/proposals/src/models/governance.ts diff --git a/packages/proposals/src/models/initTimelockConfig.ts b/packages/proposals/src/models/initGovernance.ts similarity index 95% rename from packages/proposals/src/models/initTimelockConfig.ts rename to packages/proposals/src/models/initGovernance.ts index 7c0da23..37fd8b8 100644 --- a/packages/proposals/src/models/initTimelockConfig.ts +++ b/packages/proposals/src/models/initGovernance.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { CONFIG_NAME_LENGTH, GovernanceInstruction } from './timelock'; +import { CONFIG_NAME_LENGTH, GovernanceInstruction } from './governance'; import BN from 'bn.js'; import * as Layout from '../utils/layout'; @@ -10,7 +10,7 @@ import * as Layout from '../utils/layout'; /// 1. `[]` Program account that this config uses /// 2. `[]` Governance mint that this config uses /// 3. `[]` Council mint that this config uses [Optional] -export const initTimelockConfigInstruction = ( +export const initGovernanceInstruction = ( timelockConfigAccount: PublicKey, programAccount: PublicKey, governanceMint: PublicKey, diff --git a/packages/proposals/src/models/initTimelockSet.ts b/packages/proposals/src/models/initProposal.ts similarity index 97% rename from packages/proposals/src/models/initTimelockSet.ts rename to packages/proposals/src/models/initProposal.ts index c77abbb..e8ad6c4 100644 --- a/packages/proposals/src/models/initTimelockSet.ts +++ b/packages/proposals/src/models/initProposal.ts @@ -5,7 +5,7 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './timelock'; +import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './governance'; /// Initializes a new empty Timelocked set of Instructions that will be executed at various slots in the future in draft mode. /// Grants Admin token to caller. @@ -30,7 +30,7 @@ import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './timelock'; /// 17. `[]` Timelock minting authority /// 18. '[]` Token program id /// 19. `[]` Rent sysvar -export const initTimelockSetInstruction = ( +export const initProposalInstruction = ( timelockStateAccount: PublicKey, timelockSetAccount: PublicKey, timelockConfigAccount: PublicKey, diff --git a/packages/proposals/src/models/removeSigner.ts b/packages/proposals/src/models/removeSigner.ts index 3f8d5bc..b17dc41 100644 --- a/packages/proposals/src/models/removeSigner.ts +++ b/packages/proposals/src/models/removeSigner.ts @@ -1,7 +1,7 @@ import { PublicKey, TransactionInstruction } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// [Requires Admin token] /// Removes a signer from the set. diff --git a/packages/proposals/src/models/sign.ts b/packages/proposals/src/models/sign.ts index b559303..ded6b73 100644 --- a/packages/proposals/src/models/sign.ts +++ b/packages/proposals/src/models/sign.ts @@ -5,7 +5,7 @@ import { } from '@solana/web3.js'; import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; /// [Requires Signatory token] /// Burns signatory token, indicating you approve of moving this Timelock set from Draft state to Voting state. diff --git a/packages/proposals/src/models/vote.ts b/packages/proposals/src/models/vote.ts index adf47a8..b38b969 100644 --- a/packages/proposals/src/models/vote.ts +++ b/packages/proposals/src/models/vote.ts @@ -7,7 +7,7 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; /// [Requires Voting tokens] diff --git a/packages/proposals/src/models/withdrawVotingTokens.ts b/packages/proposals/src/models/withdrawVotingTokens.ts index b18ade8..c987d37 100644 --- a/packages/proposals/src/models/withdrawVotingTokens.ts +++ b/packages/proposals/src/models/withdrawVotingTokens.ts @@ -3,7 +3,7 @@ import { utils } from '@oyster/common'; import * as Layout from '../utils/layout'; import * as BufferLayout from 'buffer-layout'; -import { GovernanceInstruction } from './timelock'; +import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; /// 0. `[writable]` Governance voting record account. See Vote docs for more detail. diff --git a/packages/proposals/src/utils/lookups.ts b/packages/proposals/src/utils/lookups.ts index d590767..3df419c 100644 --- a/packages/proposals/src/utils/lookups.ts +++ b/packages/proposals/src/utils/lookups.ts @@ -5,7 +5,7 @@ import { GovernanceVotingRecord, GovernanceVotingRecordLayout, GovernanceVotingRecordParser, -} from '../models/timelock'; +} from '../models/governance'; const MAX_LOOKUPS = 5000; export async function getGovernanceVotingRecords( diff --git a/packages/proposals/src/utils/serialize.ts b/packages/proposals/src/utils/serialize.ts index 73f0c56..a4d8db1 100644 --- a/packages/proposals/src/utils/serialize.ts +++ b/packages/proposals/src/utils/serialize.ts @@ -6,7 +6,7 @@ import { PublicKey, Message, } from '@solana/web3.js'; -import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/timelock'; +import { GOVERNANCE_AUTHORITY_SEED, Proposal } from '../models/governance'; export async function serializeInstruction({ connection, instr, diff --git a/packages/proposals/src/views/dashboard/index.tsx b/packages/proposals/src/views/dashboard/index.tsx index 6b39f22..e55a8e8 100644 --- a/packages/proposals/src/views/dashboard/index.tsx +++ b/packages/proposals/src/views/dashboard/index.tsx @@ -4,7 +4,7 @@ import { GUTTER } from '../../constants'; import { contexts, hooks, ParsedAccount } from '@oyster/common'; import './style.less'; import { useProposals } from '../../contexts/proposals'; -import { Proposal } from '../../models/timelock'; +import { Proposal } from '../../models/governance'; import { Connection } from '@solana/web3.js'; import { WalletAdapter } from '@solana/wallet-base'; const { useWallet } = contexts.Wallet; diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/proposals/src/views/governance/index.tsx index 42811c7..0eacdd9 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/proposals/src/views/governance/index.tsx @@ -14,7 +14,7 @@ import { Governance, GovernanceType, VotingEntryRule, -} from '../../models/timelock'; +} from '../../models/governance'; import { PublicKey } from '@solana/web3.js'; import { Table } from 'antd'; import MintSourceTokens from '../../components/Proposal/MintSourceTokens'; diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/proposals/src/views/governance/register.tsx index acfee71..5d28707 100644 --- a/packages/proposals/src/views/governance/register.tsx +++ b/packages/proposals/src/views/governance/register.tsx @@ -7,7 +7,7 @@ import { ExecutionType, GovernanceType, VotingEntryRule, -} from '../../models/timelock'; +} from '../../models/governance'; import { LABELS } from '../../constants'; import { contexts, utils, tryParseKey } from '@oyster/common'; import { registerProgramGovernance } from '../../actions/registerProgramGovernance'; diff --git a/packages/proposals/src/views/home/index.tsx b/packages/proposals/src/views/home/index.tsx index b5ca655..153ddd1 100644 --- a/packages/proposals/src/views/home/index.tsx +++ b/packages/proposals/src/views/home/index.tsx @@ -6,7 +6,7 @@ import { TokenIcon, useWallet } from '@oyster/common'; import { Background } from './../../components/Background'; import { useHistory } from 'react-router-dom'; import { RegisterGovernanceMenuItem } from '../governance/register'; -import { ProposalStateStatus } from '../../models/timelock'; +import { ProposalStateStatus } from '../../models/governance'; export const HomeView = () => { const history = useHistory(); diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/proposals/src/views/proposal/index.tsx index 94044b5..4ca1f05 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/proposals/src/views/proposal/index.tsx @@ -9,7 +9,7 @@ import { ProposalState, ProposalStateStatus, TimelockTransaction, -} from '../../models/timelock'; +} from '../../models/governance'; import { useParams } from 'react-router-dom'; import ReactMarkdown from 'react-markdown'; import { useProposals } from '../../contexts/proposals'; diff --git a/packages/proposals/src/views/proposal/new.tsx b/packages/proposals/src/views/proposal/new.tsx index 8da7ca9..c1711c0 100644 --- a/packages/proposals/src/views/proposal/new.tsx +++ b/packages/proposals/src/views/proposal/new.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { Button, ButtonProps, Modal, Radio } from 'antd'; import { Form, Input, Select } from 'antd'; import { Account } from '@solana/web3.js'; -import { DESC_SIZE, NAME_SIZE } from '../../models/timelock'; +import { DESC_SIZE, NAME_SIZE } from '../../models/governance'; import { LABELS } from '../../constants'; import { contexts, utils } from '@oyster/common'; import { createProposal } from '../../actions/createProposal'; From 05992a5ea71c36dd77b3095fc26b825bf7a3acf4 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 12:57:30 +0100 Subject: [PATCH 09/16] chore: rename instructions and actions to Governance --- .../addCustomSingleSignerTransaction.ts | 4 +- packages/proposals/src/actions/addSigner.ts | 2 +- .../proposals/src/actions/createProposal.ts | 76 +++++++++---------- .../src/actions/depositSourceTokensAndVote.ts | 10 +-- packages/proposals/src/actions/execute.ts | 4 +- .../proposals/src/actions/mintSourceTokens.ts | 10 +-- .../src/actions/registerProgramGovernance.ts | 62 +++++++-------- .../proposals/src/actions/removeSigner.ts | 2 +- packages/proposals/src/actions/sign.ts | 2 +- .../src/actions/withdrawVotingTokens.ts | 6 +- .../components/Proposal/InstructionCard.tsx | 6 +- .../components/Proposal/MintSourceTokens.tsx | 12 +-- .../src/components/Proposal/Vote.tsx | 6 +- .../src/components/Proposal/WithdrawVote.tsx | 2 - packages/proposals/src/contexts/proposals.tsx | 20 ++--- .../proposals/src/hooks/useVotingRecords.ts | 4 +- .../addCustomSingleSignerTransaction.ts | 30 ++++---- packages/proposals/src/models/addSigner.ts | 18 ++--- .../src/models/createEmptyGovernance.ts | 20 ++--- .../createEmptyGovernanceVotingRecord.ts | 6 +- .../src/models/depositSourceTokens.ts | 18 ++--- packages/proposals/src/models/execute.ts | 25 +++--- packages/proposals/src/models/governance.ts | 8 +- .../proposals/src/models/initGovernance.ts | 20 ++--- packages/proposals/src/models/initProposal.ts | 24 +++--- packages/proposals/src/models/removeSigner.ts | 15 ++-- packages/proposals/src/models/sign.ts | 22 +++--- packages/proposals/src/models/vote.ts | 28 +++---- .../src/models/withdrawVotingTokens.ts | 25 +++--- packages/proposals/src/utils/lookups.ts | 2 +- packages/proposals/src/utils/serialize.ts | 2 +- .../proposals/src/views/governance/index.tsx | 4 +- .../proposals/src/views/proposal/index.tsx | 18 ++--- 33 files changed, 257 insertions(+), 256 deletions(-) diff --git a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts b/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts index 3756805..5fd87ec 100644 --- a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts +++ b/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts @@ -44,12 +44,12 @@ export const addCustomSingleSignerTransaction = async ( newAccountPubkey: txnKey.publicKey, lamports: rentExempt, space: CustomSingleSignerTransactionLayout.span, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, }); const [authority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); signers.push(txnKey); diff --git a/packages/proposals/src/actions/addSigner.ts b/packages/proposals/src/actions/addSigner.ts index 9e1eb38..9263bd3 100644 --- a/packages/proposals/src/actions/addSigner.ts +++ b/packages/proposals/src/actions/addSigner.ts @@ -52,7 +52,7 @@ export const addSigner = async ( const [mintAuthority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); const transferAuthority = approve( diff --git a/packages/proposals/src/actions/createProposal.ts b/packages/proposals/src/actions/createProposal.ts index a39cd00..3438c67 100644 --- a/packages/proposals/src/actions/createProposal.ts +++ b/packages/proposals/src/actions/createProposal.ts @@ -27,7 +27,7 @@ export const createProposal = async ( name: string, description: string, useGovernance: boolean, - timelockConfig: ParsedAccount, + governance: ParsedAccount, ): Promise => { const PROGRAM_IDS = utils.programIds(); @@ -45,12 +45,12 @@ export const createProposal = async ( await cache.queryMint( connection, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint!, + ? governance.info.governanceMint + : governance.info.councilMint!, ) ).decimals; - const timelockSetKey = new Account(); + const proposalKey = new Account(); const { sigMint, @@ -73,54 +73,54 @@ export const createProposal = async ( wallet, accountRentExempt, mintRentExempt, - timelockConfig, + governance, useGovernance, sourceMintDecimals, - timelockSetKey, + proposalKey, ); - let createTimelockAccountsSigners: Account[] = []; - let createTimelockAccountsInstructions: TransactionInstruction[] = []; + let createGovernanceAccountsSigners: Account[] = []; + let createGovernanceAccountsInstructions: TransactionInstruction[] = []; - const timelockRentExempt = await connection.getMinimumBalanceForRentExemption( + const proposalRentExempt = await connection.getMinimumBalanceForRentExemption( ProposalLayout.span, ); - const timelockStateRentExempt = await connection.getMinimumBalanceForRentExemption( + const proposalStateRentExempt = await connection.getMinimumBalanceForRentExemption( ProposalStateLayout.span, ); - const timelockStateKey = new Account(); + const proposalStateKey = new Account(); - const uninitializedTimelockStateInstruction = SystemProgram.createAccount({ + const uninitializedProposalStateInstruction = SystemProgram.createAccount({ fromPubkey: wallet.publicKey, - newAccountPubkey: timelockStateKey.publicKey, - lamports: timelockStateRentExempt, + newAccountPubkey: proposalStateKey.publicKey, + lamports: proposalStateRentExempt, space: ProposalStateLayout.span, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, }); - signers.push(timelockStateKey); - createTimelockAccountsSigners.push(timelockStateKey); - createTimelockAccountsInstructions.push( - uninitializedTimelockStateInstruction, + signers.push(proposalStateKey); + createGovernanceAccountsSigners.push(proposalStateKey); + createGovernanceAccountsInstructions.push( + uninitializedProposalStateInstruction, ); - const uninitializedTimelockSetInstruction = SystemProgram.createAccount({ + const uninitializedProposalInstruction = SystemProgram.createAccount({ fromPubkey: wallet.publicKey, - newAccountPubkey: timelockSetKey.publicKey, - lamports: timelockRentExempt, + newAccountPubkey: proposalKey.publicKey, + lamports: proposalRentExempt, space: ProposalLayout.span, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, }); - signers.push(timelockSetKey); - createTimelockAccountsSigners.push(timelockSetKey); - createTimelockAccountsInstructions.push(uninitializedTimelockSetInstruction); + signers.push(proposalKey); + createGovernanceAccountsSigners.push(proposalKey); + createGovernanceAccountsInstructions.push(uninitializedProposalInstruction); instructions.push( initProposalInstruction( - timelockStateKey.publicKey, - timelockSetKey.publicKey, - timelockConfig.pubkey, + proposalStateKey.publicKey, + proposalKey.publicKey, + governance.pubkey, sigMint, adminMint, voteMint, @@ -135,8 +135,8 @@ export const createProposal = async ( noVoteDumpAccount, sourceHoldingAccount, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint!, + ? governance.info.governanceMint + : governance.info.councilMint!, authority, description, name, @@ -155,10 +155,10 @@ export const createProposal = async ( wallet, [ ...associatedInstructions, - createTimelockAccountsInstructions, + createGovernanceAccountsInstructions, instructions, ], - [...associatedSigners, createTimelockAccountsSigners, signers], + [...associatedSigners, createGovernanceAccountsSigners, signers], true, true, ); @@ -169,7 +169,7 @@ export const createProposal = async ( description: `Transaction - ${tx}`, }); - return timelockSetKey; + return proposalKey; } catch (ex) { console.error(ex); throw new Error(); @@ -199,7 +199,7 @@ async function getAssociatedAccountsAndInstructions( wallet: any, accountRentExempt: number, mintRentExempt: number, - timelockConfig: ParsedAccount, + governance: ParsedAccount, useGovernance: boolean, sourceMintDecimals: number, newProposalKey: Account, @@ -211,7 +211,7 @@ async function getAssociatedAccountsAndInstructions( Buffer.from(GOVERNANCE_AUTHORITY_SEED), newProposalKey.publicKey.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); let mintSigners: Account[] = []; @@ -346,8 +346,8 @@ async function getAssociatedAccountsAndInstructions( wallet.publicKey, accountRentExempt, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint!, + ? governance.info.governanceMint + : governance.info.councilMint!, authority, holdingSigners, ); diff --git a/packages/proposals/src/actions/depositSourceTokensAndVote.ts b/packages/proposals/src/actions/depositSourceTokensAndVote.ts index 6fa2170..608d431 100644 --- a/packages/proposals/src/actions/depositSourceTokensAndVote.ts +++ b/packages/proposals/src/actions/depositSourceTokensAndVote.ts @@ -40,7 +40,7 @@ export const depositSourceTokensAndVote = async ( existingYesVoteAccount: PublicKey | undefined, existingNoVoteAccount: PublicKey | undefined, sourceAccount: PublicKey, - timelockConfig: ParsedAccount, + governance: ParsedAccount, state: ParsedAccount, yesVotingTokenAmount: number, noVotingTokenAmount: number, @@ -72,11 +72,11 @@ export const depositSourceTokensAndVote = async ( const [governanceVotingRecord] = await PublicKey.findProgramAddress( [ Buffer.from(GOVERNANCE_AUTHORITY_SEED), - PROGRAM_IDS.timelock.programId.toBuffer(), + PROGRAM_IDS.governance.programId.toBuffer(), proposal.pubkey.toBuffer(), existingVoteAccount.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); if (needToCreateGovAccountToo) { @@ -114,7 +114,7 @@ export const depositSourceTokensAndVote = async ( const [mintAuthority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); const depositAuthority = approve( @@ -166,7 +166,7 @@ export const depositSourceTokensAndVote = async ( proposal.info.noVotingMint, proposal.info.sourceMint, proposal.pubkey, - timelockConfig.pubkey, + governance.pubkey, voteAuthority.publicKey, mintAuthority, yesVotingTokenAmount, diff --git a/packages/proposals/src/actions/execute.ts b/packages/proposals/src/actions/execute.ts index 2ccbdf1..e08b04b 100644 --- a/packages/proposals/src/actions/execute.ts +++ b/packages/proposals/src/actions/execute.ts @@ -9,7 +9,7 @@ import { contexts, utils, ParsedAccount } from '@oyster/common'; import { Proposal, ProposalState, - TimelockTransaction, + GovernanceTransaction, } from '../models/governance'; import { executeInstruction } from '../models/execute'; import { LABELS } from '../constants'; @@ -22,7 +22,7 @@ export const execute = async ( wallet: any, proposal: ParsedAccount, state: ParsedAccount, - transaction: ParsedAccount, + transaction: ParsedAccount, ) => { let signers: Account[] = []; let instructions: TransactionInstruction[] = []; diff --git a/packages/proposals/src/actions/mintSourceTokens.ts b/packages/proposals/src/actions/mintSourceTokens.ts index a5ffe11..e207d3b 100644 --- a/packages/proposals/src/actions/mintSourceTokens.ts +++ b/packages/proposals/src/actions/mintSourceTokens.ts @@ -20,7 +20,7 @@ export interface SourceEntryInterface { export const mintSourceTokens = async ( connection: Connection, wallet: any, - timelockConfig: ParsedAccount, + governance: ParsedAccount, useGovernance: boolean, entries: SourceEntryInterface[], setSavePerc: (num: number) => void, @@ -44,8 +44,8 @@ export const mintSourceTokens = async ( wallet.publicKey, accountRentExempt, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint!, + ? governance.info.governanceMint + : governance.info.councilMint!, e.owner, signers, ); @@ -54,8 +54,8 @@ export const mintSourceTokens = async ( Token.createMintToInstruction( PROGRAM_IDS.token, useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint!, + ? governance.info.governanceMint + : governance.info.councilMint!, e.sourceAccount, wallet.publicKey, [], diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/proposals/src/actions/registerProgramGovernance.ts index 6e99191..dc3d572 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/proposals/src/actions/registerProgramGovernance.ts @@ -25,7 +25,7 @@ const { notify } = utils; export const registerProgramGovernance = async ( connection: Connection, wallet: any, - uninitializedTimelockConfig: Partial, + uninitializedGovernance: Partial, useCouncil: boolean, ): Promise => { const PROGRAM_IDS = utils.programIds(); @@ -41,13 +41,13 @@ export const registerProgramGovernance = async ( AccountLayout.span, ); - if (!uninitializedTimelockConfig.program) - uninitializedTimelockConfig.program = new Account().publicKey; // Random generation if none given + if (!uninitializedGovernance.program) + uninitializedGovernance.program = new Account().publicKey; // Random generation if none given - if (!uninitializedTimelockConfig.councilMint && useCouncil) { + if (!uninitializedGovernance.councilMint && useCouncil) { // Initialize the mint, an account for the admin, and give them one council token // to start their lives with. - uninitializedTimelockConfig.councilMint = createMint( + uninitializedGovernance.councilMint = createMint( mintInstructions, wallet.publicKey, mintRentExempt, @@ -61,7 +61,7 @@ export const registerProgramGovernance = async ( mintInstructions, wallet.publicKey, accountRentExempt, - uninitializedTimelockConfig.councilMint, + uninitializedGovernance.councilMint, wallet.publicKey, mintSigners, ); @@ -69,7 +69,7 @@ export const registerProgramGovernance = async ( mintInstructions.push( Token.createMintToInstruction( PROGRAM_IDS.token, - uninitializedTimelockConfig.councilMint, + uninitializedGovernance.councilMint, adminsCouncilToken, wallet.publicKey, [], @@ -78,10 +78,10 @@ export const registerProgramGovernance = async ( ); } - if (!uninitializedTimelockConfig.governanceMint) { + if (!uninitializedGovernance.governanceMint) { // Initialize the mint, an account for the admin, and give them one governance token // to start their lives with. - uninitializedTimelockConfig.governanceMint = createMint( + uninitializedGovernance.governanceMint = createMint( mintInstructions, wallet.publicKey, mintRentExempt, @@ -95,7 +95,7 @@ export const registerProgramGovernance = async ( mintInstructions, wallet.publicKey, accountRentExempt, - uninitializedTimelockConfig.governanceMint, + uninitializedGovernance.governanceMint, wallet.publicKey, mintSigners, ); @@ -103,7 +103,7 @@ export const registerProgramGovernance = async ( mintInstructions.push( Token.createMintToInstruction( PROGRAM_IDS.token, - uninitializedTimelockConfig.governanceMint, + uninitializedGovernance.governanceMint, adminsGovernanceToken, wallet.publicKey, [], @@ -112,44 +112,44 @@ export const registerProgramGovernance = async ( ); } - const [timelockConfigKey] = await PublicKey.findProgramAddress( + const [governanceKey] = await PublicKey.findProgramAddress( [ Buffer.from(GOVERNANCE_AUTHORITY_SEED), - uninitializedTimelockConfig.program.toBuffer(), + uninitializedGovernance.program.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); const [programDataAccount] = await PublicKey.findProgramAddress( - [uninitializedTimelockConfig.program.toBuffer()], + [uninitializedGovernance.program.toBuffer()], PROGRAM_IDS.bpf_upgrade_loader, ); instructions.push( createEmptyGovernanceInstruction( - timelockConfigKey, - uninitializedTimelockConfig.program, + governanceKey, + uninitializedGovernance.program, programDataAccount, wallet.publicKey, - uninitializedTimelockConfig.governanceMint, + uninitializedGovernance.governanceMint, wallet.publicKey, - uninitializedTimelockConfig.councilMint, + uninitializedGovernance.councilMint, ), ); instructions.push( initGovernanceInstruction( - timelockConfigKey, - uninitializedTimelockConfig.program, - uninitializedTimelockConfig.governanceMint, + governanceKey, + uninitializedGovernance.program, + uninitializedGovernance.governanceMint, - uninitializedTimelockConfig.voteThreshold!, - uninitializedTimelockConfig.executionType || ExecutionType.Independent, - uninitializedTimelockConfig.timelockType || GovernanceType.Governance, - uninitializedTimelockConfig.votingEntryRule || VotingEntryRule.Anytime, - uninitializedTimelockConfig.minimumSlotWaitingPeriod || new BN(0), - uninitializedTimelockConfig.timeLimit || new BN(0), - uninitializedTimelockConfig.name || '', - uninitializedTimelockConfig.councilMint, + uninitializedGovernance.voteThreshold!, + uninitializedGovernance.executionType || ExecutionType.Independent, + uninitializedGovernance.timelockType || GovernanceType.Governance, + uninitializedGovernance.votingEntryRule || VotingEntryRule.Anytime, + uninitializedGovernance.minimumSlotWaitingPeriod || new BN(0), + uninitializedGovernance.timeLimit || new BN(0), + uninitializedGovernance.name || '', + uninitializedGovernance.councilMint, ), ); @@ -177,7 +177,7 @@ export const registerProgramGovernance = async ( description: `Transaction - ${tx}`, }); - return timelockConfigKey; + return governanceKey; } catch (ex) { console.error(ex); throw new Error(); diff --git a/packages/proposals/src/actions/removeSigner.ts b/packages/proposals/src/actions/removeSigner.ts index 61cead8..9dd2747 100644 --- a/packages/proposals/src/actions/removeSigner.ts +++ b/packages/proposals/src/actions/removeSigner.ts @@ -26,7 +26,7 @@ export const removeSigner = async ( const [mintAuthority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); const transferAuthority = approve( diff --git a/packages/proposals/src/actions/sign.ts b/packages/proposals/src/actions/sign.ts index deedd14..725deed 100644 --- a/packages/proposals/src/actions/sign.ts +++ b/packages/proposals/src/actions/sign.ts @@ -31,7 +31,7 @@ export const sign = async ( const [mintAuthority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); const transferAuthority = approve( diff --git a/packages/proposals/src/actions/withdrawVotingTokens.ts b/packages/proposals/src/actions/withdrawVotingTokens.ts index a9dc0ea..0cc584e 100644 --- a/packages/proposals/src/actions/withdrawVotingTokens.ts +++ b/packages/proposals/src/actions/withdrawVotingTokens.ts @@ -81,7 +81,7 @@ export const withdrawVotingTokens = async ( const [mintAuthority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); // We dont know in this scope how much is in each account so we just ask for all in each. @@ -119,11 +119,11 @@ export const withdrawVotingTokens = async ( const [governanceVotingRecord] = await PublicKey.findProgramAddress( [ Buffer.from(GOVERNANCE_AUTHORITY_SEED), - PROGRAM_IDS.timelock.programId.toBuffer(), + PROGRAM_IDS.governance.programId.toBuffer(), proposal.pubkey.toBuffer(), existingVoteAccount.toBuffer(), ], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); signers.push(transferAuthority); diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/proposals/src/components/Proposal/InstructionCard.tsx index 3c34a69..a1c4f80 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/InstructionCard.tsx @@ -17,7 +17,7 @@ import { Proposal, ProposalState, ProposalStateStatus, - TimelockTransaction, + GovernanceTransaction, } from '../../models/governance'; import './style.less'; @@ -37,7 +37,7 @@ export function InstructionCard({ state, position, }: { - instruction: ParsedAccount; + instruction: ParsedAccount; proposal: ParsedAccount; state: ParsedAccount; position: number; @@ -108,7 +108,7 @@ function PlayStatusButton({ }: { proposal: ParsedAccount; state: ParsedAccount; - instruction: ParsedAccount; + instruction: ParsedAccount; playing: Playstate; setPlaying: React.Dispatch>; }) { diff --git a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx b/packages/proposals/src/components/Proposal/MintSourceTokens.tsx index ec2aa8a..291f1d6 100644 --- a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx +++ b/packages/proposals/src/components/Proposal/MintSourceTokens.tsx @@ -22,18 +22,18 @@ const layout = { }; export default function MintSourceTokens({ - timelockConfig, + governance, useGovernance, }: { - timelockConfig: ParsedAccount; + governance: ParsedAccount; useGovernance: boolean; }) { const PROGRAM_IDS = utils.programIds(); const wallet = useWallet(); const connection = useConnection(); const mintKey = useGovernance - ? timelockConfig.info.governanceMint - : timelockConfig.info.councilMint!; + ? governance.info.governanceMint + : governance.info.councilMint!; const mint = useMint(mintKey); const [saving, setSaving] = useState(false); @@ -108,7 +108,7 @@ export default function MintSourceTokens({ try { if (sourceHolders[i].owner) { const tokenAccounts = await connection.getTokenAccountsByOwner( - sourceHolders[i].owner || PROGRAM_IDS.timelock, + sourceHolders[i].owner || PROGRAM_IDS.governance, { programId: PROGRAM_IDS.token, }, @@ -130,7 +130,7 @@ export default function MintSourceTokens({ await mintSourceTokens( connection, wallet.wallet, - timelockConfig, + governance, useGovernance, sourceHoldersToRun, setSavePerc, diff --git a/packages/proposals/src/components/Proposal/Vote.tsx b/packages/proposals/src/components/Proposal/Vote.tsx index ba7fffe..76806cd 100644 --- a/packages/proposals/src/components/Proposal/Vote.tsx +++ b/packages/proposals/src/components/Proposal/Vote.tsx @@ -22,12 +22,12 @@ const { confirm } = Modal; export function Vote({ proposal, state, - timelockConfig, + governance, yeahVote, }: { proposal: ParsedAccount; state: ParsedAccount; - timelockConfig: ParsedAccount; + governance: ParsedAccount; yeahVote: boolean; }) { const wallet = useWallet(); @@ -90,7 +90,7 @@ export function Vote({ yesVoteAccount?.pubkey, noVoteAccount?.pubkey, userTokenAccount.pubkey, - timelockConfig, + governance, state, yesTokenAmount, noTokenAmount, diff --git a/packages/proposals/src/components/Proposal/WithdrawVote.tsx b/packages/proposals/src/components/Proposal/WithdrawVote.tsx index ec6f15c..7ec3c2f 100644 --- a/packages/proposals/src/components/Proposal/WithdrawVote.tsx +++ b/packages/proposals/src/components/Proposal/WithdrawVote.tsx @@ -2,7 +2,6 @@ import { ParsedAccount } from '@oyster/common'; import { Button, Col, Modal, Row } from 'antd'; import React from 'react'; import { - Governance, Proposal, ProposalState, ProposalStateStatus, @@ -23,7 +22,6 @@ export function WithdrawVote({ }: { proposal: ParsedAccount; state: ParsedAccount; - timelockConfig: ParsedAccount; }) { const wallet = useWallet(); const connection = useConnection(); diff --git a/packages/proposals/src/contexts/proposals.tsx b/packages/proposals/src/contexts/proposals.tsx index 3c15144..0fd7796 100644 --- a/packages/proposals/src/contexts/proposals.tsx +++ b/packages/proposals/src/contexts/proposals.tsx @@ -22,8 +22,8 @@ import { Proposal, ProposalState, ProposalLayout, - TimelockSetParser, - TimelockTransaction, + ProposalParser, + GovernanceTransaction, ProposalStateParser, ProposalStateLayout, CustomSingleSignerTransaction, @@ -31,7 +31,7 @@ import { export interface ProposalsContextState { proposals: Record>; - transactions: Record>; + transactions: Record>; states: Record>; configs: Record>; } @@ -86,7 +86,7 @@ function useSetupProposalsCache({ const query = async () => { const programAccounts = await connection.getProgramAccounts( - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); return programAccounts; }; @@ -94,7 +94,7 @@ function useSetupProposalsCache({ const newProposals: Record> = {}; const newTransactions: Record< string, - ParsedAccount + ParsedAccount > = {}; const newStates: Record> = {}; const newConfigs: Record> = {}; @@ -103,13 +103,15 @@ function useSetupProposalsCache({ let cached; switch (a.account.data.length) { case ProposalLayout.span: - cache.add(a.pubkey, a.account, TimelockSetParser); + cache.add(a.pubkey, a.account, ProposalParser); cached = cache.get(a.pubkey) as ParsedAccount; newProposals[a.pubkey.toBase58()] = cached; break; case CustomSingleSignerTransactionLayout.span: cache.add(a.pubkey, a.account, CustomSingleSignerTransactionParser); - cached = cache.get(a.pubkey) as ParsedAccount; + cached = cache.get( + a.pubkey, + ) as ParsedAccount; newTransactions[a.pubkey.toBase58()] = cached; break; case GovernanceLayout.span: @@ -131,10 +133,10 @@ function useSetupProposalsCache({ setConfigs(newConfigs); }); const subID = connection.onProgramAccountChange( - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, async (info: KeyedAccountInfo) => { [ - [ProposalLayout.span, TimelockSetParser, setProposals], + [ProposalLayout.span, ProposalParser, setProposals], [ CustomSingleSignerTransactionLayout.span, CustomSingleSignerTransactionParser, diff --git a/packages/proposals/src/hooks/useVotingRecords.ts b/packages/proposals/src/hooks/useVotingRecords.ts index c535929..23c64ed 100644 --- a/packages/proposals/src/hooks/useVotingRecords.ts +++ b/packages/proposals/src/hooks/useVotingRecords.ts @@ -31,9 +31,9 @@ export function useVotingRecords(proposal: PublicKey) { const records = await getGovernanceVotingRecords(proposal, endpoint); setVotingRecords(records); - const { timelock } = utils.programIds(); + const { governance } = utils.programIds(); - return connection.onProgramAccountChange(timelock.programId, info => { + return connection.onProgramAccountChange(governance.programId, info => { if ( info.accountInfo.data.length === GovernanceVotingRecordLayout.span ) { diff --git a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts b/packages/proposals/src/models/addCustomSingleSignerTransaction.ts index 3c1c237..b75c125 100644 --- a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts +++ b/packages/proposals/src/models/addCustomSingleSignerTransaction.ts @@ -11,26 +11,26 @@ import { import BN from 'bn.js'; /// [Requires Signatory token] -/// Adds a Transaction to the Timelock Set. Max of 10 of any Transaction type. More than 10 will throw error. +/// Adds a Transaction to the Proposal. Max of 10 of any Transaction type. More than 10 will throw error. /// Creates a PDA using your authority to be used to later execute the instruction. /// This transaction needs to contain authority to execute the program. /// -/// 0. `[writable]` Uninitialized Timelock Transaction account. -/// 1. `[writable]` Timelock set account. +/// 0. `[writable]` Uninitialized Proposal Transaction account. +/// 1. `[writable]` Proposal account. /// 2. `[writable]` Signatory account /// 3. `[writable]` Signatory validation account. -/// 4. `[]` Timelock Set account. -/// 5. `[]` Timelock Config account. +/// 4. `[]` Proposal account. +/// 5. `[]` Governance account. /// 6. `[]` Transfer authority -/// 7. `[]` Timelock mint authority +/// 7. `[]` Governance mint authority /// 8. `[]` Token program account. export const addCustomSingleSignerTransactionInstruction = ( - timelockTransactionAccount: PublicKey, - timelockStateAccount: PublicKey, + proposalTransactionAccount: PublicKey, + proposalStateAccount: PublicKey, signatoryAccount: PublicKey, signatoryValidationAccount: PublicKey, - timelockSetAccount: PublicKey, - timelockConfigAccount: PublicKey, + proposalAccount: PublicKey, + governanceAccount: PublicKey, transferAuthority: PublicKey, authority: PublicKey, slot: string, @@ -85,12 +85,12 @@ export const addCustomSingleSignerTransactionInstruction = ( ); const keys = [ - { pubkey: timelockTransactionAccount, isSigner: true, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalTransactionAccount, isSigner: true, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: signatoryAccount, isSigner: false, isWritable: true }, { pubkey: signatoryValidationAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: timelockConfigAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: governanceAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: authority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -98,7 +98,7 @@ export const addCustomSingleSignerTransactionInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/addSigner.ts b/packages/proposals/src/models/addSigner.ts index a365350..e785c8d 100644 --- a/packages/proposals/src/models/addSigner.ts +++ b/packages/proposals/src/models/addSigner.ts @@ -4,7 +4,7 @@ import * as BufferLayout from 'buffer-layout'; import { GovernanceInstruction } from './governance'; /// [Requires Admin token] -/// Adds a signatory to the Timelock which means that this timelock can't leave Draft state until yet another signatory burns +/// Adds a signatory to the Proposal which means that this Proposal can't leave Draft state until yet another signatory burns /// their signatory token indicating they are satisfied with the instruction queue. They'll receive an signatory token /// as a result of this call that they can burn later. /// @@ -12,18 +12,18 @@ import { GovernanceInstruction } from './governance'; /// 1. `[writable]` Initialized Signatory mint account. /// 2. `[writable]` Admin account. /// 3. `[writable]` Admin validation account. -/// 4. `[writable]` Timelock set account. -/// 5. `[]` Timelock set account. +/// 4. `[writable]` Proposal account. +/// 5. `[]` Proposal account. /// 6. `[]` Transfer authority -/// 7. `[]` Timelock program mint authority +/// 7. `[]` Governance program mint authority /// 8. '[]` Token program id. export const addSignerInstruction = ( signatoryAccount: PublicKey, signatoryMintAccount: PublicKey, adminAccount: PublicKey, adminValidationAccount: PublicKey, - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, ): TransactionInstruction => { @@ -45,15 +45,15 @@ export const addSignerInstruction = ( { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, { pubkey: adminAccount, isSigner: false, isWritable: true }, { pubkey: adminValidationAccount, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/createEmptyGovernance.ts b/packages/proposals/src/models/createEmptyGovernance.ts index a38816c..a46a193 100644 --- a/packages/proposals/src/models/createEmptyGovernance.ts +++ b/packages/proposals/src/models/createEmptyGovernance.ts @@ -3,16 +3,16 @@ import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; import { GovernanceInstruction } from './governance'; -/// 0. `[]` Timelock config key. Needs to be set with pubkey set to PDA with seeds of the -/// program account key, governance mint key, council mint key, and timelock program account key. -/// 1. `[]` Program account to tie this config to. -/// 2. `[]` Governance mint to tie this config to -/// 3. `[]` Payer -/// 4. `[]` Timelock program pub key. +/// 0. `[]` Governance account. The account pubkey needs to be set to PDA with the following seeds: +/// 1) 'governance' const prefix, 2) Governed Program account key +/// 1. `[]` Account of the Program governed by this Governance account +/// 2. `[writable]` Program Data account of the Program governed by this Governance account +/// 3. `[signer]` Current Upgrade Authority account of the Program governed by this Governance account +/// 4. `[signer]` Payer /// 5. `[]` System account. -/// 6. `[]` Council mint [optional] to tie this config to [Optional] +/// 6. `[]` bpf_upgrade_loader account. export const createEmptyGovernanceInstruction = ( - timelockConfigAccount: PublicKey, + governanceAccount: PublicKey, programAccount: PublicKey, programDataAccount: PublicKey, programUpgradeAuthority: PublicKey, @@ -34,7 +34,7 @@ export const createEmptyGovernanceInstruction = ( ); const keys = [ - { pubkey: timelockConfigAccount, isSigner: false, isWritable: false }, + { pubkey: governanceAccount, isSigner: false, isWritable: false }, { pubkey: programAccount, isSigner: false, isWritable: false }, { pubkey: programDataAccount, isSigner: false, isWritable: true }, { pubkey: programUpgradeAuthority, isSigner: true, isWritable: false }, @@ -50,7 +50,7 @@ export const createEmptyGovernanceInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts b/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts index 694aa55..4a3a813 100644 --- a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts +++ b/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts @@ -8,7 +8,7 @@ import { GovernanceInstruction } from './governance'; /// 1. `[]` Proposal key /// 2. `[]` Your voting account /// 3. `[]` Payer -/// 4. `[]` Timelock program pub key. +/// 4. `[]` Governance program pub key /// 5. `[]` System account. export const createEmptyGovernanceVotingRecordInstruction = ( governanceRecordAccount: PublicKey, @@ -35,7 +35,7 @@ export const createEmptyGovernanceVotingRecordInstruction = ( { pubkey: votingAccount, isSigner: false, isWritable: false }, { pubkey: payer, isSigner: true, isWritable: false }, { - pubkey: PROGRAM_IDS.timelock.programId, + pubkey: PROGRAM_IDS.governance.programId, isSigner: false, isWritable: false, }, @@ -43,7 +43,7 @@ export const createEmptyGovernanceVotingRecordInstruction = ( ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/depositSourceTokens.ts b/packages/proposals/src/models/depositSourceTokens.ts index cfbb027..4ccef75 100644 --- a/packages/proposals/src/models/depositSourceTokens.ts +++ b/packages/proposals/src/models/depositSourceTokens.ts @@ -6,19 +6,19 @@ import * as BufferLayout from 'buffer-layout'; import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; -/// [Requires tokens of the Governance mint or Council mint depending on type of TimelockSet] -/// Deposits voting tokens to be used during the voting process in a timelock. +/// [Requires tokens of the Governance mint or Council mint depending on type of Proposal] +/// Deposits voting tokens to be used during the voting process in a Proposal. /// These tokens are removed from your account and can be returned by withdrawing -/// them from the timelock (but then you will miss the vote.) +/// them from the Proposal (but then you will miss the vote.) /// /// 0. `[writable]` Governance voting record account. See Vote docs for more detail. /// 1. `[writable]` Initialized Voting account to hold your received voting tokens. /// 2. `[writable]` User token account to deposit tokens from. -/// 3. `[writable]` Source holding account for timelock that will accept the tokens in escrow. +/// 3. `[writable]` Source holding account for Proposal that will accept the tokens in escrow. /// 4. `[writable]` Voting mint account. -/// 5. `[]` Timelock set account. +/// 5. `[]` Proposal account. /// 6. `[]` Transfer authority -/// 7. `[]` Timelock program mint authority +/// 7. `[]` Governance program mint authority (pda with seed of Proposal key) /// 8. `[]` Token program account. export const depositSourceTokensInstruction = ( governanceVotingRecord: PublicKey, @@ -26,7 +26,7 @@ export const depositSourceTokensInstruction = ( sourceAccount: PublicKey, sourceHoldingAccount: PublicKey, votingMint: PublicKey, - timelockSetAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, votingTokenAmount: number, @@ -54,7 +54,7 @@ export const depositSourceTokensInstruction = ( { pubkey: sourceAccount, isSigner: false, isWritable: true }, { pubkey: sourceHoldingAccount, isSigner: false, isWritable: true }, { pubkey: votingMint, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -62,7 +62,7 @@ export const depositSourceTokensInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/execute.ts b/packages/proposals/src/models/execute.ts index 2692176..8863120 100644 --- a/packages/proposals/src/models/execute.ts +++ b/packages/proposals/src/models/execute.ts @@ -7,21 +7,22 @@ import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; import { GovernanceInstruction } from './governance'; -/// Executes a command in the timelock set. +/// Executes a command in the Proposal /// /// 0. `[writable]` Transaction account you wish to execute. -/// 1. `[writable]` Timelock state account. +/// 1. `[writable]` Proposal state account. /// 2. `[]` Program being invoked account -/// 3. `[]` Timelock set account. -/// 4. `[]` Timelock config -/// 5. `[]` Clock sysvar. +/// 3. `[]` Proposal account. +/// 4. `[]` Governance account +/// 5. `[]` Governance program account pub key. +/// 6. `[]` Clock sysvar. /// 7+ Any extra accounts that are part of the instruction, in order export const executeInstruction = ( transactionAccount: PublicKey, - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, programBeingInvokedAccount: PublicKey, - timelockConfig: PublicKey, + governance: PublicKey, accountInfos: { pubkey: PublicKey; isWritable: boolean; isSigner: boolean }[], ): TransactionInstruction => { const PROGRAM_IDS = utils.programIds(); @@ -44,16 +45,16 @@ export const executeInstruction = ( const keys = [ // just a note this were all set to writable true...come back and check on this { pubkey: transactionAccount, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: programBeingInvokedAccount, isSigner: false, isWritable: false }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: timelockConfig, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: governance, isSigner: false, isWritable: false }, { pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false }, ...accountInfos, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/governance.ts b/packages/proposals/src/models/governance.ts index 97995ea..913d46a 100644 --- a/packages/proposals/src/models/governance.ts +++ b/packages/proposals/src/models/governance.ts @@ -65,7 +65,7 @@ export interface Governance { voteThreshold: number; /// Execution type executionType: ExecutionType; - /// Timelock Type + /// Governance Type timelockType: GovernanceType; /// Voting entry rule votingEntryRule: VotingEntryRule; @@ -281,7 +281,7 @@ export const CustomSingleSignerTransactionLayout: typeof BufferLayout.Structure ], ); -export interface TimelockTransaction { +export interface GovernanceTransaction { /// Account type accountType: GovernanceAccountType; @@ -293,9 +293,9 @@ export interface TimelockTransaction { instructionEndIndex: number; } -export interface CustomSingleSignerTransaction extends TimelockTransaction {} +export interface CustomSingleSignerTransaction extends GovernanceTransaction {} -export const TimelockSetParser = ( +export const ProposalParser = ( pubKey: PublicKey, info: AccountInfo, ) => { diff --git a/packages/proposals/src/models/initGovernance.ts b/packages/proposals/src/models/initGovernance.ts index 37fd8b8..275d2ea 100644 --- a/packages/proposals/src/models/initGovernance.ts +++ b/packages/proposals/src/models/initGovernance.ts @@ -5,18 +5,18 @@ import { CONFIG_NAME_LENGTH, GovernanceInstruction } from './governance'; import BN from 'bn.js'; import * as Layout from '../utils/layout'; -/// 0. `[writable]` Timelock config key. Needs to be set with pubkey set to PDA with seeds of the -/// program account key, governance mint key, council mint key, timelock program account key. -/// 1. `[]` Program account that this config uses -/// 2. `[]` Governance mint that this config uses -/// 3. `[]` Council mint that this config uses [Optional] +/// 0. `[writable]` Governance account. The account pubkey needs to be set to PDA with the following seeds: +/// 1) 'governance' const prefix, 2) Governed Program account key +/// 1. `[]` Account of the Program governed by this Governance account +/// 2. `[]` Governance mint that this Governance uses +/// 3. `[]` Council mint that this Governance uses [Optional] export const initGovernanceInstruction = ( - timelockConfigAccount: PublicKey, + governanceAccount: PublicKey, programAccount: PublicKey, governanceMint: PublicKey, voteThreshold: number, executionType: number, - timelockType: number, + governanceType: number, votingEntryRule: number, minimumSlotWaitingPeriod: BN, timeLimit: BN, @@ -52,7 +52,7 @@ export const initGovernanceInstruction = ( instruction: GovernanceInstruction.InitGovernance, voteThreshold, executionType, - timelockType, + timelockType: governanceType, votingEntryRule, minimumSlotWaitingPeriod, timeLimit, @@ -62,7 +62,7 @@ export const initGovernanceInstruction = ( ); const keys = [ - { pubkey: timelockConfigAccount, isSigner: false, isWritable: true }, + { pubkey: governanceAccount, isSigner: false, isWritable: true }, { pubkey: programAccount, isSigner: false, isWritable: false }, { pubkey: governanceMint, isSigner: false, isWritable: false }, ]; @@ -73,7 +73,7 @@ export const initGovernanceInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/initProposal.ts b/packages/proposals/src/models/initProposal.ts index e8ad6c4..262a2d8 100644 --- a/packages/proposals/src/models/initProposal.ts +++ b/packages/proposals/src/models/initProposal.ts @@ -7,12 +7,12 @@ import { utils } from '@oyster/common'; import * as BufferLayout from 'buffer-layout'; import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './governance'; -/// Initializes a new empty Timelocked set of Instructions that will be executed at various slots in the future in draft mode. +/// Initializes a new empty Proposal for Instructions that will be executed at various slots in the future in draft mode. /// Grants Admin token to caller. /// -/// 0. `[writable]` Uninitialized Timelock state account . -/// 1. `[writable]` Uninitialized Timelock set account . -/// 2. `[writable]` Initialized Timelock config account. +/// 0. `[writable]` Uninitialized Proposal state account . +/// 1. `[writable]` Uninitialized Proposal account . +/// 2. `[writable]` Initialized Governance account. /// 3. `[writable]` Initialized Signatory Mint account /// 4. `[writable]` Initialized Admin Mint account /// 5. `[writable]` Initialized Voting Mint account @@ -27,13 +27,13 @@ import { DESC_SIZE, NAME_SIZE, GovernanceInstruction } from './governance'; /// 14. `[writable]` Initialized No voting dump account /// 15. `[writable]` Initialized source holding account /// 16. `[]` Source mint -/// 17. `[]` Timelock minting authority +/// 17. `[]` Governance minting authority (pda with seed of Proposal key) /// 18. '[]` Token program id /// 19. `[]` Rent sysvar export const initProposalInstruction = ( - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, - timelockConfigAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, + governanceAccount: PublicKey, signatoryMintAccount: PublicKey, adminMintAccount: PublicKey, votingMintAccount: PublicKey, @@ -88,9 +88,9 @@ export const initProposalInstruction = ( ); const keys = [ - { pubkey: timelockStateAccount, isSigner: true, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: true, isWritable: true }, - { pubkey: timelockConfigAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: true, isWritable: true }, + { pubkey: proposalAccount, isSigner: true, isWritable: true }, + { pubkey: governanceAccount, isSigner: false, isWritable: true }, { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, { pubkey: adminMintAccount, isSigner: false, isWritable: true }, { pubkey: votingMintAccount, isSigner: false, isWritable: true }, @@ -115,7 +115,7 @@ export const initProposalInstruction = ( ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/removeSigner.ts b/packages/proposals/src/models/removeSigner.ts index b17dc41..72afff6 100644 --- a/packages/proposals/src/models/removeSigner.ts +++ b/packages/proposals/src/models/removeSigner.ts @@ -10,16 +10,17 @@ import { GovernanceInstruction } from './governance'; /// 1. `[writable]` Signatory mint account. /// 2. `[writable]` Admin account. /// 3. `[writable]` Admin validation account. -/// 4. `[]` Timelock set account. -/// 5. `[]` Transfer authority -/// 6. `[]` Timelock program mint authority -/// 7. '[]` Token program id. +/// 4. `[writable]` Proposal state account. +/// 5. `[]` Proposal account. +/// 6. `[]` Transfer authority +/// 7. `[]` Governance program mint authority (pda of seed with Proposal key) +/// 8. '[]` Token program id. export const removeSignerInstruction = ( signatoryAccount: PublicKey, signatoryMintAccount: PublicKey, adminAccount: PublicKey, adminValidationAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, ): TransactionInstruction => { @@ -41,14 +42,14 @@ export const removeSignerInstruction = ( { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, { pubkey: adminAccount, isSigner: false, isWritable: true }, { pubkey: adminValidationAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: true }, + { pubkey: proposalAccount, isSigner: false, isWritable: true }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/sign.ts b/packages/proposals/src/models/sign.ts index ded6b73..be28b58 100644 --- a/packages/proposals/src/models/sign.ts +++ b/packages/proposals/src/models/sign.ts @@ -8,22 +8,22 @@ import * as BufferLayout from 'buffer-layout'; import { GovernanceInstruction } from './governance'; /// [Requires Signatory token] -/// Burns signatory token, indicating you approve of moving this Timelock set from Draft state to Voting state. +/// Burns signatory token, indicating you approve of moving this Proposal from Draft state to Voting state. /// The last Signatory token to be burned moves the state to Voting. /// -/// 0. `[writable]` Timelock state account pub key. +/// 0. `[writable]` Proposal state account pub key. /// 1. `[writable]` Signatory account /// 2. `[writable]` Signatory mint account. -/// 3. `[]` Timelock set account pub key. +/// 3. `[]` Proposal account pub key. /// 4. `[]` Transfer authority -/// 5. `[]` Timelock mint authority -/// 6. `[]` Token program account. -/// 7. `[]` Clock sysvar. +/// 5. `[]` Governance mint authority (pda of seed Proposal key) +/// 7. `[]` Token program account. +/// 8. `[]` Clock sysvar. export const signInstruction = ( - timelockStateAccount: PublicKey, + proposalStateAccount: PublicKey, signatoryAccount: PublicKey, signatoryMintAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, ): TransactionInstruction => { @@ -41,10 +41,10 @@ export const signInstruction = ( ); const keys = [ - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: signatoryAccount, isSigner: false, isWritable: true }, { pubkey: signatoryMintAccount, isSigner: false, isWritable: true }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -52,7 +52,7 @@ export const signInstruction = ( ]; return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/vote.ts b/packages/proposals/src/models/vote.ts index b38b969..beed2d9 100644 --- a/packages/proposals/src/models/vote.ts +++ b/packages/proposals/src/models/vote.ts @@ -11,13 +11,13 @@ import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; /// [Requires Voting tokens] -/// Burns voting tokens, indicating you approve and/or disapprove of running this set of transactions. If you tip the vote threshold, -/// then the transactions can begin to be run at their time slots when people click execute. +/// Burns voting tokens, indicating you approve and/or disapprove of running this set of transactions. If you tip the consensus, +/// then the transactions can begin to be run at their time slots when people click execute. You are then given yes and/or no tokens. /// /// 0. `[writable]` Governance voting record account. /// Can be uninitialized or initialized(if already used once in this proposal) -/// Must have address with PDA having seed tuple [timelock acct key, proposal key, your voting account key] -/// 1. `[writable]` Timelock state account. +/// Must have address with PDA having seed tuple [Governance acct key, proposal key, your voting account key] +/// 1. `[writable]` Proposal state account. /// 2. `[writable]` Your Voting account. /// 3. `[writable]` Your Yes-Voting account. /// 4. `[writable]` Your No-Voting account. @@ -25,15 +25,15 @@ import BN from 'bn.js'; /// 6. `[writable]` Yes Voting mint account. /// 7. `[writable]` No Voting mint account. /// 8. `[]` Source mint account -/// 9. `[]` Timelock set account. -/// 10. `[]` Timelock config account. +/// 9. `[]` Proposal account. +/// 10. `[]` Governance account. /// 12. `[]` Transfer authority -/// 13. `[]` Timelock program mint authority +/// 13. `[]` Governance program mint authority (pda of seed Proposal key) /// 14. `[]` Token program account. /// 15. `[]` Clock sysvar. export const voteInstruction = ( governanceVotingRecord: PublicKey, - timelockStateAccount: PublicKey, + proposalStateAccount: PublicKey, votingAccount: PublicKey, yesVotingAccount: PublicKey, noVotingAccount: PublicKey, @@ -41,8 +41,8 @@ export const voteInstruction = ( yesVotingMint: PublicKey, noVotingMint: PublicKey, sourceMint: PublicKey, - timelockSetAccount: PublicKey, - timelockConfig: PublicKey, + proposalAccount: PublicKey, + governance: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, yesVotingTokenAmount: number, @@ -69,7 +69,7 @@ export const voteInstruction = ( const keys = [ { pubkey: governanceVotingRecord, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: true }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: true }, { pubkey: votingAccount, isSigner: false, isWritable: true }, { pubkey: yesVotingAccount, isSigner: false, isWritable: true }, { pubkey: noVotingAccount, isSigner: false, isWritable: true }, @@ -77,8 +77,8 @@ export const voteInstruction = ( { pubkey: yesVotingMint, isSigner: false, isWritable: true }, { pubkey: noVotingMint, isSigner: false, isWritable: true }, { pubkey: sourceMint, isSigner: false, isWritable: false }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, - { pubkey: timelockConfig, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, + { pubkey: governance, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -87,7 +87,7 @@ export const voteInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/models/withdrawVotingTokens.ts b/packages/proposals/src/models/withdrawVotingTokens.ts index c987d37..6ed8a37 100644 --- a/packages/proposals/src/models/withdrawVotingTokens.ts +++ b/packages/proposals/src/models/withdrawVotingTokens.ts @@ -6,21 +6,24 @@ import * as BufferLayout from 'buffer-layout'; import { GovernanceInstruction } from './governance'; import BN from 'bn.js'; +/// [Requires voting tokens] +/// Withdraws voting tokens. +/// /// 0. `[writable]` Governance voting record account. See Vote docs for more detail. /// 1. `[writable]` Initialized Voting account from which to remove your voting tokens. /// 2. `[writable]` Initialized Yes Voting account from which to remove your voting tokens. /// 3. `[writable]` Initialized No Voting account from which to remove your voting tokens. /// 4. `[writable]` User token account that you wish your actual tokens to be returned to. -/// 5. `[writable]` Source holding account owned by the timelock that will has the actual tokens in escrow. -/// 6. `[writable]` Initialized Yes Voting dump account owned by timelock set to which to send your voting tokens. -/// 7. `[writable]` Initialized No Voting dump account owned by timelock set to which to send your voting tokens. +/// 5. `[writable]` Source holding account owned by the Governance that will has the actual tokens in escrow. +/// 6. `[writable]` Initialized Yes Voting dump account owned by Proposal to which to send your voting tokens. +/// 7. `[writable]` Initialized No Voting dump account owned by Proposal to which to send your voting tokens. /// 8. `[writable]` Voting mint account. /// 9. `[writable]` Yes Voting mint account. /// 10. `[writable]` No Voting mint account. -/// 11. `[]` Timelock state account. -/// 12. `[]` Timelock set account. +/// 11. `[]` Proposal state account. +/// 12. `[]` Proposal account. /// 13. `[]` Transfer authority -/// 14. `[]` Timelock program mint authority +/// 14. `[]` Governance program mint authority (pda of seed Proposal key) /// 15. `[]` Token program account. export const withdrawVotingTokensInstruction = ( governanceVotingRecord: PublicKey, @@ -34,8 +37,8 @@ export const withdrawVotingTokensInstruction = ( votingMint: PublicKey, yesVotingMint: PublicKey, noVotingMint: PublicKey, - timelockStateAccount: PublicKey, - timelockSetAccount: PublicKey, + proposalStateAccount: PublicKey, + proposalAccount: PublicKey, transferAuthority: PublicKey, mintAuthority: PublicKey, votingTokenAmount: number, @@ -69,8 +72,8 @@ export const withdrawVotingTokensInstruction = ( { pubkey: votingMint, isSigner: false, isWritable: true }, { pubkey: yesVotingMint, isSigner: false, isWritable: true }, { pubkey: noVotingMint, isSigner: false, isWritable: true }, - { pubkey: timelockStateAccount, isSigner: false, isWritable: false }, - { pubkey: timelockSetAccount, isSigner: false, isWritable: false }, + { pubkey: proposalStateAccount, isSigner: false, isWritable: false }, + { pubkey: proposalAccount, isSigner: false, isWritable: false }, { pubkey: transferAuthority, isSigner: true, isWritable: false }, { pubkey: mintAuthority, isSigner: false, isWritable: false }, { pubkey: PROGRAM_IDS.token, isSigner: false, isWritable: false }, @@ -78,7 +81,7 @@ export const withdrawVotingTokensInstruction = ( return new TransactionInstruction({ keys, - programId: PROGRAM_IDS.timelock.programId, + programId: PROGRAM_IDS.governance.programId, data, }); }; diff --git a/packages/proposals/src/utils/lookups.ts b/packages/proposals/src/utils/lookups.ts index 3df419c..3374961 100644 --- a/packages/proposals/src/utils/lookups.ts +++ b/packages/proposals/src/utils/lookups.ts @@ -25,7 +25,7 @@ export async function getGovernanceVotingRecords( id: 1, method: 'getProgramAccounts', params: [ - PROGRAM_IDS.timelock.programId.toBase58(), + PROGRAM_IDS.governance.programId.toBase58(), { commitment: 'single', filters: [ diff --git a/packages/proposals/src/utils/serialize.ts b/packages/proposals/src/utils/serialize.ts index a4d8db1..9fefc8c 100644 --- a/packages/proposals/src/utils/serialize.ts +++ b/packages/proposals/src/utils/serialize.ts @@ -24,7 +24,7 @@ export async function serializeInstruction({ ).blockhash; const [authority] = await PublicKey.findProgramAddress( [Buffer.from(GOVERNANCE_AUTHORITY_SEED), proposal.pubkey.toBuffer()], - PROGRAM_IDS.timelock.programId, + PROGRAM_IDS.governance.programId, ); instructionTransaction.setSigners(authority); const msg: Message = instructionTransaction.compileMessage(); diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/proposals/src/views/governance/index.tsx index 0eacdd9..dcd18a9 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/proposals/src/views/governance/index.tsx @@ -87,9 +87,9 @@ const columns = [ key: 'config', render: (config: ParsedAccount) => ( <> - + {config.info.councilMint && ( - + )} ), diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/proposals/src/views/proposal/index.tsx index 4ca1f05..9c8e51f 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/proposals/src/views/proposal/index.tsx @@ -8,7 +8,7 @@ import { Proposal, ProposalState, ProposalStateStatus, - TimelockTransaction, + GovernanceTransaction, } from '../../models/governance'; import { useParams } from 'react-router-dom'; import ReactMarkdown from 'react-markdown'; @@ -225,14 +225,14 @@ function InnerProposalView({ yesVotingMint: MintInfo; noVotingMint: MintInfo; sourceMint: MintInfo; - instructions: Record>; + instructions: Record>; votingDisplayData: Array; endpoint: string; }) { const sigAccount = useAccountByMint(proposal.info.signatoryMint); const adminAccount = useAccountByMint(proposal.info.adminMint); - const instructionsForProposal: ParsedAccount[] = timelockState.info.timelockTransactions + const instructionsForProposal: ParsedAccount[] = timelockState.info.timelockTransactions .map(k => instructions[k.toBase58()]) .filter(k => k); const isUrl = !!timelockState.info.descLink.match(urlRegex); @@ -286,25 +286,21 @@ function InnerProposalView({ )} - + Date: Sat, 24 Apr 2021 13:06:55 +0100 Subject: [PATCH 10/16] chore: rename params to Governance --- .../src/views/governance/register.tsx | 8 +- .../proposals/src/views/proposal/index.tsx | 83 +++++++++---------- packages/proposals/src/views/proposal/new.tsx | 4 +- 3 files changed, 47 insertions(+), 48 deletions(-) diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/proposals/src/views/governance/register.tsx index 5d28707..933ab8d 100644 --- a/packages/proposals/src/views/governance/register.tsx +++ b/packages/proposals/src/views/governance/register.tsx @@ -68,7 +68,7 @@ export function NewForm({ const wallet = useWallet(); const connection = useConnection(); const onFinish = async (values: { - timelockType: GovernanceType; + governanceType: GovernanceType; executionType: ExecutionType; voteThreshold: number; votingEntryRule: VotingEntryRule; @@ -119,8 +119,8 @@ export function NewForm({ return; } - const uninitializedConfig = { - timelockType: values.timelockType, + const uninitializedGovernance = { + timelockType: values.governanceType, executionType: values.executionType, voteThreshold: values.voteThreshold, votingEntryRule: values.votingEntryRule, @@ -140,7 +140,7 @@ export function NewForm({ const newConfig = await registerProgramGovernance( connection, wallet.wallet, - uninitializedConfig, + uninitializedGovernance, councilVisible, ); handleOk(newConfig); diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/proposals/src/views/proposal/index.tsx index 9c8e51f..29682c5 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/proposals/src/views/proposal/index.tsx @@ -47,8 +47,8 @@ export const ProposalView = () => { const context = useProposals(); const { id } = useParams<{ id: string }>(); const proposal = context.proposals[id]; - const timelockConfig = context.configs[proposal?.info.config.toBase58()]; - const timelockState = context.states[proposal?.info.state.toBase58()]; + const governance = context.configs[proposal?.info.config.toBase58()]; + const proposalState = context.states[proposal?.info.state.toBase58()]; const { endpoint } = useConnectionConfig(); const sigMint = useMint(proposal?.info.signatoryMint); const votingMint = useMint(proposal?.info.votingMint); @@ -69,8 +69,8 @@ export const ProposalView = () => { noVotingMint ? ( void; @@ -102,11 +102,11 @@ function useLoadGist({ setFailed: (b: boolean) => void; setContent: (b: string) => void; isGist: boolean; - timelockState: ParsedAccount; + proposalState: ParsedAccount; }) { useMemo(() => { if (loading) { - let toFetch = timelockState.info.descLink; + let toFetch = proposalState.info.descLink; const pieces = toFetch.match(urlRegex); if (isGist && pieces) { const justIdWithoutUser = pieces[1].split('/')[2]; @@ -206,20 +206,20 @@ function voterDisplayData( function InnerProposalView({ proposal, - timelockState, + proposalState, sigMint, votingMint, yesVotingMint, noVotingMint, instructions, - timelockConfig, + governance, sourceMint, votingDisplayData, endpoint, }: { proposal: ParsedAccount; - timelockConfig: ParsedAccount; - timelockState: ParsedAccount; + governance: ParsedAccount; + proposalState: ParsedAccount; sigMint: MintInfo; votingMint: MintInfo; yesVotingMint: MintInfo; @@ -232,14 +232,14 @@ function InnerProposalView({ const sigAccount = useAccountByMint(proposal.info.signatoryMint); const adminAccount = useAccountByMint(proposal.info.adminMint); - const instructionsForProposal: ParsedAccount[] = timelockState.info.timelockTransactions + const instructionsForProposal: ParsedAccount[] = proposalState.info.timelockTransactions .map(k => instructions[k.toBase58()]) .filter(k => k); - const isUrl = !!timelockState.info.descLink.match(urlRegex); + const isUrl = !!proposalState.info.descLink.match(urlRegex); const isGist = - !!timelockState.info.descLink.match(/gist/i) && - !!timelockState.info.descLink.match(/github/i); - const [content, setContent] = useState(timelockState.info.descLink); + !!proposalState.info.descLink.match(/gist/i) && + !!proposalState.info.descLink.match(/github/i); + const [content, setContent] = useState(proposalState.info.descLink); const [loading, setLoading] = useState(isUrl); const [failed, setFailed] = useState(false); const [msg, setMsg] = useState(''); @@ -254,7 +254,7 @@ function InnerProposalView({ setMsg, setContent, isGist, - timelockState, + proposalState: proposalState, }); return ( @@ -268,8 +268,8 @@ function InnerProposalView({ size={60} /> -

{timelockState.info.name}

- +

{proposalState.info.name}

+ @@ -277,32 +277,32 @@ function InnerProposalView({
{adminAccount && adminAccount.info.amount.toNumber() === 1 && - timelockState.info.status === ProposalStateStatus.Draft && ( - + proposalState.info.status === ProposalStateStatus.Draft && ( + )} {sigAccount && sigAccount.info.amount.toNumber() === 1 && - timelockState.info.status === ProposalStateStatus.Draft && ( - + proposalState.info.status === ProposalStateStatus.Draft && ( + )} - +
@@ -366,10 +366,10 @@ function InnerProposalView({ @@ -387,7 +387,7 @@ function InnerProposalView({ @@ -408,7 +408,7 @@ function InnerProposalView({

{LABELS.DESCRIPTION}:{' '} @@ -435,17 +435,17 @@ function InnerProposalView({ proposal={proposal} position={position + 1} instruction={instruction} - state={timelockState} + state={proposalState} /> ))} {instructionsForProposal.length < INSTRUCTION_LIMIT && - timelockState.info.status === ProposalStateStatus.Draft && ( + proposalState.info.status === ProposalStateStatus.Draft && (

@@ -461,13 +461,12 @@ function InnerProposalView({ } function getVotesRequired( - timelockConfig: ParsedAccount, + governance: ParsedAccount, sourceMint: MintInfo, ): number { - return timelockConfig.info.voteThreshold === 100 + return governance.info.voteThreshold === 100 ? sourceMint.supply.toNumber() : Math.ceil( - (timelockConfig.info.voteThreshold / 100) * - sourceMint.supply.toNumber(), + (governance.info.voteThreshold / 100) * sourceMint.supply.toNumber(), ); } diff --git a/packages/proposals/src/views/proposal/new.tsx b/packages/proposals/src/views/proposal/new.tsx index c1711c0..21d8ec0 100644 --- a/packages/proposals/src/views/proposal/new.tsx +++ b/packages/proposals/src/views/proposal/new.tsx @@ -74,9 +74,9 @@ export function NewForm({ name: string; proposalMintType: string; description: string; - timelockConfigKey: string; + governanceKey: string; }) => { - const config = context.configs[values.timelockConfigKey]; + const config = context.configs[values.governanceKey]; if ( values.proposalMintType === ProposalMintType.Council && From 4f9798abd9c3e294553b3505a8a3761679974cb5 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 13:07:21 +0100 Subject: [PATCH 11/16] chore: update governance ids --- packages/common/src/utils/ids.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/common/src/utils/ids.ts b/packages/common/src/utils/ids.ts index 10ea905..b71c749 100644 --- a/packages/common/src/utils/ids.ts +++ b/packages/common/src/utils/ids.ts @@ -34,7 +34,7 @@ let WORMHOLE_BRIDGE: { wrappedMaster: string; }; -let TIMELOCK: { +let GOVERNANCE: { programId: PublicKey; }; @@ -112,7 +112,7 @@ export const PROGRAM_IDS = [ { name: 'localnet', timelock: () => ({ - programId: new PublicKey('3KEiR9eX7isb8xeFzTzbLZij8tKH6YFYUbMyjBp8ygDK'), + programId: new PublicKey('2uWrXQ3tMurqTLe3Dmue6DzasUGV9UPqK7AK7HzS7v3D'), }), wormhole: () => ({ pubkey: new PublicKey('WormT3McKhFJ2RkiGpdw9GKvNCrB2aB54gb2uV9MfQC'), @@ -143,7 +143,7 @@ export const setProgramIds = (envName: string) => { SWAP_PROGRAM_LAYOUT = swap.current.layout; SWAP_PROGRAM_LEGACY_IDS = swap.legacy; - TIMELOCK = instance.timelock(); + GOVERNANCE = instance.timelock(); if (envName === 'mainnet-beta') { LENDING_PROGRAM_ID = new PublicKey( @@ -160,7 +160,7 @@ export const programIds = () => { swapLayout: SWAP_PROGRAM_LAYOUT, lending: LENDING_PROGRAM_ID, wormhole: WORMHOLE_BRIDGE, - timelock: TIMELOCK, + governance: GOVERNANCE, associatedToken: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, bpf_upgrade_loader: BPF_UPGRADE_LOADER_ID, system: SYSTEM, From 6394bf7a884d29bff29f922891c85044a4de6c96 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 13:24:28 +0100 Subject: [PATCH 12/16] chore: rename timelockType --- packages/proposals/src/actions/registerProgramGovernance.ts | 2 +- packages/proposals/src/models/governance.ts | 6 +++--- packages/proposals/src/models/initGovernance.ts | 4 ++-- packages/proposals/src/views/governance/index.tsx | 4 ++-- packages/proposals/src/views/governance/register.tsx | 4 ++-- packages/proposals/src/views/proposal/new.tsx | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/proposals/src/actions/registerProgramGovernance.ts index dc3d572..828770c 100644 --- a/packages/proposals/src/actions/registerProgramGovernance.ts +++ b/packages/proposals/src/actions/registerProgramGovernance.ts @@ -144,7 +144,7 @@ export const registerProgramGovernance = async ( uninitializedGovernance.voteThreshold!, uninitializedGovernance.executionType || ExecutionType.Independent, - uninitializedGovernance.timelockType || GovernanceType.Governance, + uninitializedGovernance.governanceType || GovernanceType.Governance, uninitializedGovernance.votingEntryRule || VotingEntryRule.Anytime, uninitializedGovernance.minimumSlotWaitingPeriod || new BN(0), uninitializedGovernance.timeLimit || new BN(0), diff --git a/packages/proposals/src/models/governance.ts b/packages/proposals/src/models/governance.ts index 913d46a..246aad7 100644 --- a/packages/proposals/src/models/governance.ts +++ b/packages/proposals/src/models/governance.ts @@ -66,7 +66,7 @@ export interface Governance { /// Execution type executionType: ExecutionType; /// Governance Type - timelockType: GovernanceType; + governanceType: GovernanceType; /// Voting entry rule votingEntryRule: VotingEntryRule; /// Minimum slot time-distance from creation of proposal for an instruction to be placed @@ -99,7 +99,7 @@ export const GovernanceLayout: typeof BufferLayout.Structure = BufferLayout.stru BufferLayout.u8('accountType'), BufferLayout.u8('voteThreshold'), BufferLayout.u8('executionType'), - BufferLayout.u8('timelockType'), + BufferLayout.u8('governanceType'), BufferLayout.u8('votingEntryRule'), Layout.uint64('minimumSlotWaitingPeriod'), Layout.publicKey('governanceMint'), @@ -432,7 +432,7 @@ export const GovernanceParser = ( accountType: data.accountType, voteThreshold: data.voteThreshold, executionType: data.executionType, - timelockType: data.timelockType, + governanceType: data.governanceType, votingEntryRule: data.votingEntryRule, minimumSlotWaitingPeriod: data.minimumSlotWaitingPeriod, governanceMint: data.governanceMint, diff --git a/packages/proposals/src/models/initGovernance.ts b/packages/proposals/src/models/initGovernance.ts index 275d2ea..f6f33d5 100644 --- a/packages/proposals/src/models/initGovernance.ts +++ b/packages/proposals/src/models/initGovernance.ts @@ -33,7 +33,7 @@ export const initGovernanceInstruction = ( BufferLayout.u8('instruction'), BufferLayout.u8('voteThreshold'), BufferLayout.u8('executionType'), - BufferLayout.u8('timelockType'), + BufferLayout.u8('governanceType'), BufferLayout.u8('votingEntryRule'), Layout.uint64('minimumSlotWaitingPeriod'), Layout.uint64('timeLimit'), @@ -52,7 +52,7 @@ export const initGovernanceInstruction = ( instruction: GovernanceInstruction.InitGovernance, voteThreshold, executionType, - timelockType: governanceType, + governanceType, votingEntryRule, minimumSlotWaitingPeriod, timeLimit, diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/proposals/src/views/governance/index.tsx index dcd18a9..7882914 100644 --- a/packages/proposals/src/views/governance/index.tsx +++ b/packages/proposals/src/views/governance/index.tsx @@ -40,8 +40,8 @@ const columns = [ }, { title: LABELS.PROPOSAL_TYPE, - dataIndex: 'timelockType', - key: 'timelockType', + dataIndex: 'governanceType', + key: 'governanceType', render: (number: number) => {GovernanceType[number]}, }, { diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/proposals/src/views/governance/register.tsx index 933ab8d..f7a5eaa 100644 --- a/packages/proposals/src/views/governance/register.tsx +++ b/packages/proposals/src/views/governance/register.tsx @@ -120,7 +120,7 @@ export function NewForm({ } const uninitializedGovernance = { - timelockType: values.governanceType, + governanceType: values.governanceType, executionType: values.executionType, voteThreshold: values.voteThreshold, votingEntryRule: values.votingEntryRule, @@ -215,7 +215,7 @@ export function NewForm({ From 10ae7359da7cf5f8e027f826b70d206bc0ecd02c Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 13:24:47 +0100 Subject: [PATCH 13/16] chore: disable render tracking --- packages/proposals/src/wdyr.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/proposals/src/wdyr.ts b/packages/proposals/src/wdyr.ts index 83c7d54..cbe0b1c 100644 --- a/packages/proposals/src/wdyr.ts +++ b/packages/proposals/src/wdyr.ts @@ -3,6 +3,6 @@ import React from 'react'; if (process.env.NODE_ENV === 'development') { const whyDidYouRender = require('@welldone-software/why-did-you-render'); whyDidYouRender(React, { - trackAllPureComponents: true, + trackAllPureComponents: false, }); } From 43e2c9060cb3b5fd8e85a0f25d1565f10c5f6df6 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 13:29:08 +0100 Subject: [PATCH 14/16] chore: rename timelock props to governance --- packages/proposals/src/models/governance.ts | 20 +++++++++---------- .../proposals/src/views/proposal/index.tsx | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/proposals/src/models/governance.ts b/packages/proposals/src/models/governance.ts index 246aad7..3f32591 100644 --- a/packages/proposals/src/models/governance.ts +++ b/packages/proposals/src/models/governance.ts @@ -156,10 +156,10 @@ export const STATE_COLOR: Record = { export interface ProposalState { /// Account type accountType: GovernanceAccountType; - timelockSet: PublicKey; + proposal: PublicKey; status: ProposalStateStatus; totalSigningTokensMinted: BN; - timelockTransactions: PublicKey[]; + proposalTransactions: PublicKey[]; name: string; descLink: string; votingEndedAt: BN; @@ -173,7 +173,7 @@ export interface ProposalState { const proposalTxns = []; for (let i = 0; i < MAX_TRANSACTIONS; i++) { - proposalTxns.push(Layout.publicKey('timelockTxn' + i.toString())); + proposalTxns.push(Layout.publicKey('proposalTxn' + i.toString())); } export const ProposalLayout: typeof BufferLayout.Structure = BufferLayout.struct( @@ -201,8 +201,8 @@ export const ProposalLayout: typeof BufferLayout.Structure = BufferLayout.struct export const ProposalStateLayout: typeof BufferLayout.Structure = BufferLayout.struct( [ BufferLayout.u8('accountType'), - Layout.publicKey('timelockSet'), - BufferLayout.u8('timelockStateStatus'), + Layout.publicKey('proposal'), + BufferLayout.u8('proposalStateStatus'), Layout.uint64('totalSigningTokensMinted'), BufferLayout.seq(BufferLayout.u8(), DESC_SIZE, 'descLink'), BufferLayout.seq(BufferLayout.u8(), NAME_SIZE, 'name'), @@ -360,9 +360,9 @@ export const ProposalStateParser = ( const buffer = Buffer.from(info.data); const data = ProposalStateLayout.decode(buffer); - const timelockTxns = []; + const proposalTxns = []; for (let i = 0; i < MAX_TRANSACTIONS; i++) { - timelockTxns.push(data['timelockTxn' + i.toString()]); + proposalTxns.push(data['proposalTxn' + i.toString()]); } const details = { @@ -372,12 +372,12 @@ export const ProposalStateParser = ( }, info: { accountType: data.accountType, - timelockSet: data.timelockSet, - status: data.timelockStateStatus, + proposal: data.proposal, + status: data.proposalStateStatus, totalSigningTokensMinted: data.totalSigningTokensMinted, descLink: utils.fromUTF8Array(data.descLink).replaceAll('\u0000', ''), name: utils.fromUTF8Array(data.name).replaceAll('\u0000', ''), - timelockTransactions: timelockTxns, + proposalTransactions: proposalTxns, votingEndedAt: data.votingEndedAt, votingBeganAt: data.votingBeganAt, createdAt: data.createdAt, diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/proposals/src/views/proposal/index.tsx index 29682c5..710ebfe 100644 --- a/packages/proposals/src/views/proposal/index.tsx +++ b/packages/proposals/src/views/proposal/index.tsx @@ -232,7 +232,7 @@ function InnerProposalView({ const sigAccount = useAccountByMint(proposal.info.signatoryMint); const adminAccount = useAccountByMint(proposal.info.adminMint); - const instructionsForProposal: ParsedAccount[] = proposalState.info.timelockTransactions + const instructionsForProposal: ParsedAccount[] = proposalState.info.proposalTransactions .map(k => instructions[k.toBase58()]) .filter(k => k); const isUrl = !!proposalState.info.descLink.match(urlRegex); From eb786f2fc353be2f49498d85687a300246949878 Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 13:34:41 +0100 Subject: [PATCH 15/16] chore: rename program ids to governance --- .vscode/settings.json | 2 +- packages/common/src/utils/ids.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 02e42b3..41d54e6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,6 @@ "typescript.enablePromptUseWorkspaceTsdk": true, "prettier.prettierPath": ".vscode/pnpify/prettier/index.js", "cSpell.words": [ - "Timelock" + ] } diff --git a/packages/common/src/utils/ids.ts b/packages/common/src/utils/ids.ts index b71c749..fe24dc6 100644 --- a/packages/common/src/utils/ids.ts +++ b/packages/common/src/utils/ids.ts @@ -54,7 +54,7 @@ export const ENABLE_FEES_INPUT = false; export const PROGRAM_IDS = [ { name: 'mainnet-beta', - timelock: () => ({ + governance: () => ({ programId: new PublicKey('9iAeqqppjn7g1Jn8o2cQCqU5aQVV3h4q9bbWdKRbeC2w'), }), wormhole: () => ({ @@ -75,7 +75,7 @@ export const PROGRAM_IDS = [ }, { name: 'testnet', - timelock: () => ({ + governance: () => ({ programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'), }), wormhole: () => ({ @@ -93,7 +93,7 @@ export const PROGRAM_IDS = [ }, { name: 'devnet', - timelock: () => ({ + governance: () => ({ programId: new PublicKey('DCVPuhaGNMLh73FRWFroH4o3ERUhBKMRWfBgJV94VqRk'), }), wormhole: () => ({ @@ -111,7 +111,7 @@ export const PROGRAM_IDS = [ }, { name: 'localnet', - timelock: () => ({ + governance: () => ({ programId: new PublicKey('2uWrXQ3tMurqTLe3Dmue6DzasUGV9UPqK7AK7HzS7v3D'), }), wormhole: () => ({ @@ -143,7 +143,7 @@ export const setProgramIds = (envName: string) => { SWAP_PROGRAM_LAYOUT = swap.current.layout; SWAP_PROGRAM_LEGACY_IDS = swap.legacy; - GOVERNANCE = instance.timelock(); + GOVERNANCE = instance.governance(); if (envName === 'mainnet-beta') { LENDING_PROGRAM_ID = new PublicKey( From 3b5e84b8b72f17e3cbb121e391918f52f45052fb Mon Sep 17 00:00:00 2001 From: "Sebastian.Bor" Date: Sat, 24 Apr 2021 13:46:36 +0100 Subject: [PATCH 16/16] chore: rename proposals to governance --- packages/{proposals => governance}/.env | 0 packages/{proposals => governance}/.env.production | 0 packages/{proposals => governance}/craco.config.js | 2 +- packages/{proposals => governance}/package.json | 6 +++--- .../{proposals => governance}/public/index.html | 0 packages/{proposals => governance}/public/logo.ico | Bin .../{proposals => governance}/public/manifest.json | 0 .../{proposals => governance}/public/robots.txt | 0 .../{proposals => governance}/public/splash.svg | 0 packages/{proposals => governance}/src/App.less | 0 packages/{proposals => governance}/src/App.tsx | 0 .../src/actions/addCustomSingleSignerTransaction.ts | 0 .../src/actions/addSigner.ts | 0 .../src/actions/createProposal.ts | 0 .../src/actions/depositSourceTokensAndVote.ts | 0 .../src/actions/execute.ts | 0 .../src/actions/mintSourceTokens.ts | 0 .../src/actions/registerProgramGovernance.ts | 0 .../src/actions/removeSigner.ts | 0 .../{proposals => governance}/src/actions/sign.ts | 0 .../src/actions/withdrawVotingTokens.ts | 0 .../{proposals => governance}/src/ant-custom.less | 0 .../src/components/Background/index.tsx | 0 .../src/components/Background/styles.less | 0 .../src/components/Background/useCannon.tsx | 0 .../dark-horizontal-combined-rainbow.inline.svg | 0 .../src/components/Layout/index.tsx | 0 .../src/components/Proposal/AddSigners.tsx | 0 .../src/components/Proposal/InstructionCard.tsx | 0 .../src/components/Proposal/MintSourceTokens.tsx | 0 .../src/components/Proposal/NewInstructionCard.tsx | 0 .../src/components/Proposal/SignButton.tsx | 0 .../src/components/Proposal/StateBadge.tsx | 0 .../src/components/Proposal/Vote.tsx | 0 .../src/components/Proposal/VoterBubbleGraph.tsx | 0 .../src/components/Proposal/VoterTable.tsx | 0 .../src/components/Proposal/WithdrawVote.tsx | 0 .../src/components/Proposal/style.less | 0 .../src/constants/index.tsx | 0 .../src/constants/labels.ts | 0 .../src/constants/style.tsx | 0 .../src/contexts/proposals.tsx | 0 .../src/hooks/useVotingRecords.ts | 0 packages/{proposals => governance}/src/index.tsx | 0 .../{proposals => governance}/src/manifest.json | 4 ++-- .../src/models/addCustomSingleSignerTransaction.ts | 0 .../src/models/addSigner.ts | 0 .../src/models/createEmptyGovernance.ts | 0 .../src/models/createEmptyGovernanceVotingRecord.ts | 0 .../src/models/depositSourceTokens.ts | 0 .../{proposals => governance}/src/models/execute.ts | 0 .../src/models/governance.ts | 0 .../src/models/initGovernance.ts | 0 .../src/models/initProposal.ts | 0 .../src/models/removeSigner.ts | 0 .../{proposals => governance}/src/models/sign.ts | 0 .../{proposals => governance}/src/models/vote.ts | 0 .../src/models/withdrawVotingTokens.ts | 0 .../src/react-app-env.d.ts | 0 packages/{proposals => governance}/src/routes.tsx | 0 .../{proposals => governance}/src/serviceWorker.ts | 0 .../{proposals => governance}/src/setupTests.ts | 0 .../src/types/buffer-layout.d.ts | 0 .../src/types/sol-wallet-adapter.d.ts | 0 .../{proposals => governance}/src/utils/layout.ts | 0 .../{proposals => governance}/src/utils/lookups.ts | 0 .../src/utils/serialize.ts | 0 .../src/utils/transactions.ts | 0 .../src/views/dashboard/index.tsx | 0 .../src/views/dashboard/style.less | 0 .../src/views/governance/index.tsx | 0 .../src/views/governance/register.tsx | 0 .../src/views/home/index.tsx | 0 .../src/views/home/style.less | 0 .../{proposals => governance}/src/views/index.tsx | 0 .../src/views/proposal/index.tsx | 0 .../src/views/proposal/new.tsx | 0 .../src/views/proposal/style.less | 0 .../src/views/proposals/index.tsx | 0 .../src/views/proposals/style.less | 0 packages/{proposals => governance}/src/wdyr.ts | 0 packages/{proposals => governance}/tsconfig.json | 0 .../types/buffer-layout.d.ts | 0 83 files changed, 6 insertions(+), 6 deletions(-) rename packages/{proposals => governance}/.env (100%) rename packages/{proposals => governance}/.env.production (100%) rename packages/{proposals => governance}/craco.config.js (95%) rename packages/{proposals => governance}/package.json (93%) rename packages/{proposals => governance}/public/index.html (100%) rename packages/{proposals => governance}/public/logo.ico (100%) rename packages/{proposals => governance}/public/manifest.json (100%) rename packages/{proposals => governance}/public/robots.txt (100%) rename packages/{proposals => governance}/public/splash.svg (100%) rename packages/{proposals => governance}/src/App.less (100%) rename packages/{proposals => governance}/src/App.tsx (100%) rename packages/{proposals => governance}/src/actions/addCustomSingleSignerTransaction.ts (100%) rename packages/{proposals => governance}/src/actions/addSigner.ts (100%) rename packages/{proposals => governance}/src/actions/createProposal.ts (100%) rename packages/{proposals => governance}/src/actions/depositSourceTokensAndVote.ts (100%) rename packages/{proposals => governance}/src/actions/execute.ts (100%) rename packages/{proposals => governance}/src/actions/mintSourceTokens.ts (100%) rename packages/{proposals => governance}/src/actions/registerProgramGovernance.ts (100%) rename packages/{proposals => governance}/src/actions/removeSigner.ts (100%) rename packages/{proposals => governance}/src/actions/sign.ts (100%) rename packages/{proposals => governance}/src/actions/withdrawVotingTokens.ts (100%) rename packages/{proposals => governance}/src/ant-custom.less (100%) rename packages/{proposals => governance}/src/components/Background/index.tsx (100%) rename packages/{proposals => governance}/src/components/Background/styles.less (100%) rename packages/{proposals => governance}/src/components/Background/useCannon.tsx (100%) rename packages/{proposals => governance}/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg (100%) rename packages/{proposals => governance}/src/components/Layout/index.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/AddSigners.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/InstructionCard.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/MintSourceTokens.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/NewInstructionCard.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/SignButton.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/StateBadge.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/Vote.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/VoterBubbleGraph.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/VoterTable.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/WithdrawVote.tsx (100%) rename packages/{proposals => governance}/src/components/Proposal/style.less (100%) rename packages/{proposals => governance}/src/constants/index.tsx (100%) rename packages/{proposals => governance}/src/constants/labels.ts (100%) rename packages/{proposals => governance}/src/constants/style.tsx (100%) rename packages/{proposals => governance}/src/contexts/proposals.tsx (100%) rename packages/{proposals => governance}/src/hooks/useVotingRecords.ts (100%) rename packages/{proposals => governance}/src/index.tsx (100%) rename packages/{proposals => governance}/src/manifest.json (84%) rename packages/{proposals => governance}/src/models/addCustomSingleSignerTransaction.ts (100%) rename packages/{proposals => governance}/src/models/addSigner.ts (100%) rename packages/{proposals => governance}/src/models/createEmptyGovernance.ts (100%) rename packages/{proposals => governance}/src/models/createEmptyGovernanceVotingRecord.ts (100%) rename packages/{proposals => governance}/src/models/depositSourceTokens.ts (100%) rename packages/{proposals => governance}/src/models/execute.ts (100%) rename packages/{proposals => governance}/src/models/governance.ts (100%) rename packages/{proposals => governance}/src/models/initGovernance.ts (100%) rename packages/{proposals => governance}/src/models/initProposal.ts (100%) rename packages/{proposals => governance}/src/models/removeSigner.ts (100%) rename packages/{proposals => governance}/src/models/sign.ts (100%) rename packages/{proposals => governance}/src/models/vote.ts (100%) rename packages/{proposals => governance}/src/models/withdrawVotingTokens.ts (100%) rename packages/{proposals => governance}/src/react-app-env.d.ts (100%) rename packages/{proposals => governance}/src/routes.tsx (100%) rename packages/{proposals => governance}/src/serviceWorker.ts (100%) rename packages/{proposals => governance}/src/setupTests.ts (100%) rename packages/{proposals => governance}/src/types/buffer-layout.d.ts (100%) rename packages/{proposals => governance}/src/types/sol-wallet-adapter.d.ts (100%) rename packages/{proposals => governance}/src/utils/layout.ts (100%) rename packages/{proposals => governance}/src/utils/lookups.ts (100%) rename packages/{proposals => governance}/src/utils/serialize.ts (100%) rename packages/{proposals => governance}/src/utils/transactions.ts (100%) rename packages/{proposals => governance}/src/views/dashboard/index.tsx (100%) rename packages/{proposals => governance}/src/views/dashboard/style.less (100%) rename packages/{proposals => governance}/src/views/governance/index.tsx (100%) rename packages/{proposals => governance}/src/views/governance/register.tsx (100%) rename packages/{proposals => governance}/src/views/home/index.tsx (100%) rename packages/{proposals => governance}/src/views/home/style.less (100%) rename packages/{proposals => governance}/src/views/index.tsx (100%) rename packages/{proposals => governance}/src/views/proposal/index.tsx (100%) rename packages/{proposals => governance}/src/views/proposal/new.tsx (100%) rename packages/{proposals => governance}/src/views/proposal/style.less (100%) rename packages/{proposals => governance}/src/views/proposals/index.tsx (100%) rename packages/{proposals => governance}/src/views/proposals/style.less (100%) rename packages/{proposals => governance}/src/wdyr.ts (100%) rename packages/{proposals => governance}/tsconfig.json (100%) rename packages/{proposals => governance}/types/buffer-layout.d.ts (100%) diff --git a/packages/proposals/.env b/packages/governance/.env similarity index 100% rename from packages/proposals/.env rename to packages/governance/.env diff --git a/packages/proposals/.env.production b/packages/governance/.env.production similarity index 100% rename from packages/proposals/.env.production rename to packages/governance/.env.production diff --git a/packages/proposals/craco.config.js b/packages/governance/craco.config.js similarity index 95% rename from packages/proposals/craco.config.js rename to packages/governance/craco.config.js index bd78054..1ce0585 100644 --- a/packages/proposals/craco.config.js +++ b/packages/governance/craco.config.js @@ -10,7 +10,7 @@ module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { paths.appBuild = webpackConfig.output.path = path.resolve( - './../../build/proposals', + './../../build/governance', ); return webpackConfig; }, diff --git a/packages/proposals/package.json b/packages/governance/package.json similarity index 93% rename from packages/proposals/package.json rename to packages/governance/package.json index 45d4046..d8564fd 100644 --- a/packages/proposals/package.json +++ b/packages/governance/package.json @@ -1,5 +1,5 @@ { - "name": "proposals", + "name": "governance", "version": "0.0.1", "dependencies": { "@ant-design/icons": "^4.4.0", @@ -60,8 +60,8 @@ "localnet:down": "solana-localnet down", "localnet:logs": "solana-localnet logs -f", "predeploy": "git pull --ff-only && yarn && yarn build", - "deploy": "gh-pages -d ../../build/proposals --repo https://github.com/solana-labs/oyster-gov", - "deploy:ar": "arweave deploy-dir ../../build/proposals --key-file ", + "deploy": "gh-pages -d ../../build/governance --repo https://github.com/solana-labs/oyster-gov", + "deploy:ar": "arweave deploy-dir ../../build/governance --key-file ", "format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\"" }, "eslintConfig": { diff --git a/packages/proposals/public/index.html b/packages/governance/public/index.html similarity index 100% rename from packages/proposals/public/index.html rename to packages/governance/public/index.html diff --git a/packages/proposals/public/logo.ico b/packages/governance/public/logo.ico similarity index 100% rename from packages/proposals/public/logo.ico rename to packages/governance/public/logo.ico diff --git a/packages/proposals/public/manifest.json b/packages/governance/public/manifest.json similarity index 100% rename from packages/proposals/public/manifest.json rename to packages/governance/public/manifest.json diff --git a/packages/proposals/public/robots.txt b/packages/governance/public/robots.txt similarity index 100% rename from packages/proposals/public/robots.txt rename to packages/governance/public/robots.txt diff --git a/packages/proposals/public/splash.svg b/packages/governance/public/splash.svg similarity index 100% rename from packages/proposals/public/splash.svg rename to packages/governance/public/splash.svg diff --git a/packages/proposals/src/App.less b/packages/governance/src/App.less similarity index 100% rename from packages/proposals/src/App.less rename to packages/governance/src/App.less diff --git a/packages/proposals/src/App.tsx b/packages/governance/src/App.tsx similarity index 100% rename from packages/proposals/src/App.tsx rename to packages/governance/src/App.tsx diff --git a/packages/proposals/src/actions/addCustomSingleSignerTransaction.ts b/packages/governance/src/actions/addCustomSingleSignerTransaction.ts similarity index 100% rename from packages/proposals/src/actions/addCustomSingleSignerTransaction.ts rename to packages/governance/src/actions/addCustomSingleSignerTransaction.ts diff --git a/packages/proposals/src/actions/addSigner.ts b/packages/governance/src/actions/addSigner.ts similarity index 100% rename from packages/proposals/src/actions/addSigner.ts rename to packages/governance/src/actions/addSigner.ts diff --git a/packages/proposals/src/actions/createProposal.ts b/packages/governance/src/actions/createProposal.ts similarity index 100% rename from packages/proposals/src/actions/createProposal.ts rename to packages/governance/src/actions/createProposal.ts diff --git a/packages/proposals/src/actions/depositSourceTokensAndVote.ts b/packages/governance/src/actions/depositSourceTokensAndVote.ts similarity index 100% rename from packages/proposals/src/actions/depositSourceTokensAndVote.ts rename to packages/governance/src/actions/depositSourceTokensAndVote.ts diff --git a/packages/proposals/src/actions/execute.ts b/packages/governance/src/actions/execute.ts similarity index 100% rename from packages/proposals/src/actions/execute.ts rename to packages/governance/src/actions/execute.ts diff --git a/packages/proposals/src/actions/mintSourceTokens.ts b/packages/governance/src/actions/mintSourceTokens.ts similarity index 100% rename from packages/proposals/src/actions/mintSourceTokens.ts rename to packages/governance/src/actions/mintSourceTokens.ts diff --git a/packages/proposals/src/actions/registerProgramGovernance.ts b/packages/governance/src/actions/registerProgramGovernance.ts similarity index 100% rename from packages/proposals/src/actions/registerProgramGovernance.ts rename to packages/governance/src/actions/registerProgramGovernance.ts diff --git a/packages/proposals/src/actions/removeSigner.ts b/packages/governance/src/actions/removeSigner.ts similarity index 100% rename from packages/proposals/src/actions/removeSigner.ts rename to packages/governance/src/actions/removeSigner.ts diff --git a/packages/proposals/src/actions/sign.ts b/packages/governance/src/actions/sign.ts similarity index 100% rename from packages/proposals/src/actions/sign.ts rename to packages/governance/src/actions/sign.ts diff --git a/packages/proposals/src/actions/withdrawVotingTokens.ts b/packages/governance/src/actions/withdrawVotingTokens.ts similarity index 100% rename from packages/proposals/src/actions/withdrawVotingTokens.ts rename to packages/governance/src/actions/withdrawVotingTokens.ts diff --git a/packages/proposals/src/ant-custom.less b/packages/governance/src/ant-custom.less similarity index 100% rename from packages/proposals/src/ant-custom.less rename to packages/governance/src/ant-custom.less diff --git a/packages/proposals/src/components/Background/index.tsx b/packages/governance/src/components/Background/index.tsx similarity index 100% rename from packages/proposals/src/components/Background/index.tsx rename to packages/governance/src/components/Background/index.tsx diff --git a/packages/proposals/src/components/Background/styles.less b/packages/governance/src/components/Background/styles.less similarity index 100% rename from packages/proposals/src/components/Background/styles.less rename to packages/governance/src/components/Background/styles.less diff --git a/packages/proposals/src/components/Background/useCannon.tsx b/packages/governance/src/components/Background/useCannon.tsx similarity index 100% rename from packages/proposals/src/components/Background/useCannon.tsx rename to packages/governance/src/components/Background/useCannon.tsx diff --git a/packages/proposals/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg b/packages/governance/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg similarity index 100% rename from packages/proposals/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg rename to packages/governance/src/components/Layout/dark-horizontal-combined-rainbow.inline.svg diff --git a/packages/proposals/src/components/Layout/index.tsx b/packages/governance/src/components/Layout/index.tsx similarity index 100% rename from packages/proposals/src/components/Layout/index.tsx rename to packages/governance/src/components/Layout/index.tsx diff --git a/packages/proposals/src/components/Proposal/AddSigners.tsx b/packages/governance/src/components/Proposal/AddSigners.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/AddSigners.tsx rename to packages/governance/src/components/Proposal/AddSigners.tsx diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/governance/src/components/Proposal/InstructionCard.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/InstructionCard.tsx rename to packages/governance/src/components/Proposal/InstructionCard.tsx diff --git a/packages/proposals/src/components/Proposal/MintSourceTokens.tsx b/packages/governance/src/components/Proposal/MintSourceTokens.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/MintSourceTokens.tsx rename to packages/governance/src/components/Proposal/MintSourceTokens.tsx diff --git a/packages/proposals/src/components/Proposal/NewInstructionCard.tsx b/packages/governance/src/components/Proposal/NewInstructionCard.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/NewInstructionCard.tsx rename to packages/governance/src/components/Proposal/NewInstructionCard.tsx diff --git a/packages/proposals/src/components/Proposal/SignButton.tsx b/packages/governance/src/components/Proposal/SignButton.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/SignButton.tsx rename to packages/governance/src/components/Proposal/SignButton.tsx diff --git a/packages/proposals/src/components/Proposal/StateBadge.tsx b/packages/governance/src/components/Proposal/StateBadge.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/StateBadge.tsx rename to packages/governance/src/components/Proposal/StateBadge.tsx diff --git a/packages/proposals/src/components/Proposal/Vote.tsx b/packages/governance/src/components/Proposal/Vote.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/Vote.tsx rename to packages/governance/src/components/Proposal/Vote.tsx diff --git a/packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx b/packages/governance/src/components/Proposal/VoterBubbleGraph.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/VoterBubbleGraph.tsx rename to packages/governance/src/components/Proposal/VoterBubbleGraph.tsx diff --git a/packages/proposals/src/components/Proposal/VoterTable.tsx b/packages/governance/src/components/Proposal/VoterTable.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/VoterTable.tsx rename to packages/governance/src/components/Proposal/VoterTable.tsx diff --git a/packages/proposals/src/components/Proposal/WithdrawVote.tsx b/packages/governance/src/components/Proposal/WithdrawVote.tsx similarity index 100% rename from packages/proposals/src/components/Proposal/WithdrawVote.tsx rename to packages/governance/src/components/Proposal/WithdrawVote.tsx diff --git a/packages/proposals/src/components/Proposal/style.less b/packages/governance/src/components/Proposal/style.less similarity index 100% rename from packages/proposals/src/components/Proposal/style.less rename to packages/governance/src/components/Proposal/style.less diff --git a/packages/proposals/src/constants/index.tsx b/packages/governance/src/constants/index.tsx similarity index 100% rename from packages/proposals/src/constants/index.tsx rename to packages/governance/src/constants/index.tsx diff --git a/packages/proposals/src/constants/labels.ts b/packages/governance/src/constants/labels.ts similarity index 100% rename from packages/proposals/src/constants/labels.ts rename to packages/governance/src/constants/labels.ts diff --git a/packages/proposals/src/constants/style.tsx b/packages/governance/src/constants/style.tsx similarity index 100% rename from packages/proposals/src/constants/style.tsx rename to packages/governance/src/constants/style.tsx diff --git a/packages/proposals/src/contexts/proposals.tsx b/packages/governance/src/contexts/proposals.tsx similarity index 100% rename from packages/proposals/src/contexts/proposals.tsx rename to packages/governance/src/contexts/proposals.tsx diff --git a/packages/proposals/src/hooks/useVotingRecords.ts b/packages/governance/src/hooks/useVotingRecords.ts similarity index 100% rename from packages/proposals/src/hooks/useVotingRecords.ts rename to packages/governance/src/hooks/useVotingRecords.ts diff --git a/packages/proposals/src/index.tsx b/packages/governance/src/index.tsx similarity index 100% rename from packages/proposals/src/index.tsx rename to packages/governance/src/index.tsx diff --git a/packages/proposals/src/manifest.json b/packages/governance/src/manifest.json similarity index 84% rename from packages/proposals/src/manifest.json rename to packages/governance/src/manifest.json index adc115d..87bc3cd 100644 --- a/packages/proposals/src/manifest.json +++ b/packages/governance/src/manifest.json @@ -1,6 +1,6 @@ { - "name": "Oyster Proposals", - "short_name": "Oyster Proposals", + "name": "Oyster Governance", + "short_name": "Oyster Governance", "display": "standalone", "start_url": "./", "theme_color": "#002140", diff --git a/packages/proposals/src/models/addCustomSingleSignerTransaction.ts b/packages/governance/src/models/addCustomSingleSignerTransaction.ts similarity index 100% rename from packages/proposals/src/models/addCustomSingleSignerTransaction.ts rename to packages/governance/src/models/addCustomSingleSignerTransaction.ts diff --git a/packages/proposals/src/models/addSigner.ts b/packages/governance/src/models/addSigner.ts similarity index 100% rename from packages/proposals/src/models/addSigner.ts rename to packages/governance/src/models/addSigner.ts diff --git a/packages/proposals/src/models/createEmptyGovernance.ts b/packages/governance/src/models/createEmptyGovernance.ts similarity index 100% rename from packages/proposals/src/models/createEmptyGovernance.ts rename to packages/governance/src/models/createEmptyGovernance.ts diff --git a/packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts b/packages/governance/src/models/createEmptyGovernanceVotingRecord.ts similarity index 100% rename from packages/proposals/src/models/createEmptyGovernanceVotingRecord.ts rename to packages/governance/src/models/createEmptyGovernanceVotingRecord.ts diff --git a/packages/proposals/src/models/depositSourceTokens.ts b/packages/governance/src/models/depositSourceTokens.ts similarity index 100% rename from packages/proposals/src/models/depositSourceTokens.ts rename to packages/governance/src/models/depositSourceTokens.ts diff --git a/packages/proposals/src/models/execute.ts b/packages/governance/src/models/execute.ts similarity index 100% rename from packages/proposals/src/models/execute.ts rename to packages/governance/src/models/execute.ts diff --git a/packages/proposals/src/models/governance.ts b/packages/governance/src/models/governance.ts similarity index 100% rename from packages/proposals/src/models/governance.ts rename to packages/governance/src/models/governance.ts diff --git a/packages/proposals/src/models/initGovernance.ts b/packages/governance/src/models/initGovernance.ts similarity index 100% rename from packages/proposals/src/models/initGovernance.ts rename to packages/governance/src/models/initGovernance.ts diff --git a/packages/proposals/src/models/initProposal.ts b/packages/governance/src/models/initProposal.ts similarity index 100% rename from packages/proposals/src/models/initProposal.ts rename to packages/governance/src/models/initProposal.ts diff --git a/packages/proposals/src/models/removeSigner.ts b/packages/governance/src/models/removeSigner.ts similarity index 100% rename from packages/proposals/src/models/removeSigner.ts rename to packages/governance/src/models/removeSigner.ts diff --git a/packages/proposals/src/models/sign.ts b/packages/governance/src/models/sign.ts similarity index 100% rename from packages/proposals/src/models/sign.ts rename to packages/governance/src/models/sign.ts diff --git a/packages/proposals/src/models/vote.ts b/packages/governance/src/models/vote.ts similarity index 100% rename from packages/proposals/src/models/vote.ts rename to packages/governance/src/models/vote.ts diff --git a/packages/proposals/src/models/withdrawVotingTokens.ts b/packages/governance/src/models/withdrawVotingTokens.ts similarity index 100% rename from packages/proposals/src/models/withdrawVotingTokens.ts rename to packages/governance/src/models/withdrawVotingTokens.ts diff --git a/packages/proposals/src/react-app-env.d.ts b/packages/governance/src/react-app-env.d.ts similarity index 100% rename from packages/proposals/src/react-app-env.d.ts rename to packages/governance/src/react-app-env.d.ts diff --git a/packages/proposals/src/routes.tsx b/packages/governance/src/routes.tsx similarity index 100% rename from packages/proposals/src/routes.tsx rename to packages/governance/src/routes.tsx diff --git a/packages/proposals/src/serviceWorker.ts b/packages/governance/src/serviceWorker.ts similarity index 100% rename from packages/proposals/src/serviceWorker.ts rename to packages/governance/src/serviceWorker.ts diff --git a/packages/proposals/src/setupTests.ts b/packages/governance/src/setupTests.ts similarity index 100% rename from packages/proposals/src/setupTests.ts rename to packages/governance/src/setupTests.ts diff --git a/packages/proposals/src/types/buffer-layout.d.ts b/packages/governance/src/types/buffer-layout.d.ts similarity index 100% rename from packages/proposals/src/types/buffer-layout.d.ts rename to packages/governance/src/types/buffer-layout.d.ts diff --git a/packages/proposals/src/types/sol-wallet-adapter.d.ts b/packages/governance/src/types/sol-wallet-adapter.d.ts similarity index 100% rename from packages/proposals/src/types/sol-wallet-adapter.d.ts rename to packages/governance/src/types/sol-wallet-adapter.d.ts diff --git a/packages/proposals/src/utils/layout.ts b/packages/governance/src/utils/layout.ts similarity index 100% rename from packages/proposals/src/utils/layout.ts rename to packages/governance/src/utils/layout.ts diff --git a/packages/proposals/src/utils/lookups.ts b/packages/governance/src/utils/lookups.ts similarity index 100% rename from packages/proposals/src/utils/lookups.ts rename to packages/governance/src/utils/lookups.ts diff --git a/packages/proposals/src/utils/serialize.ts b/packages/governance/src/utils/serialize.ts similarity index 100% rename from packages/proposals/src/utils/serialize.ts rename to packages/governance/src/utils/serialize.ts diff --git a/packages/proposals/src/utils/transactions.ts b/packages/governance/src/utils/transactions.ts similarity index 100% rename from packages/proposals/src/utils/transactions.ts rename to packages/governance/src/utils/transactions.ts diff --git a/packages/proposals/src/views/dashboard/index.tsx b/packages/governance/src/views/dashboard/index.tsx similarity index 100% rename from packages/proposals/src/views/dashboard/index.tsx rename to packages/governance/src/views/dashboard/index.tsx diff --git a/packages/proposals/src/views/dashboard/style.less b/packages/governance/src/views/dashboard/style.less similarity index 100% rename from packages/proposals/src/views/dashboard/style.less rename to packages/governance/src/views/dashboard/style.less diff --git a/packages/proposals/src/views/governance/index.tsx b/packages/governance/src/views/governance/index.tsx similarity index 100% rename from packages/proposals/src/views/governance/index.tsx rename to packages/governance/src/views/governance/index.tsx diff --git a/packages/proposals/src/views/governance/register.tsx b/packages/governance/src/views/governance/register.tsx similarity index 100% rename from packages/proposals/src/views/governance/register.tsx rename to packages/governance/src/views/governance/register.tsx diff --git a/packages/proposals/src/views/home/index.tsx b/packages/governance/src/views/home/index.tsx similarity index 100% rename from packages/proposals/src/views/home/index.tsx rename to packages/governance/src/views/home/index.tsx diff --git a/packages/proposals/src/views/home/style.less b/packages/governance/src/views/home/style.less similarity index 100% rename from packages/proposals/src/views/home/style.less rename to packages/governance/src/views/home/style.less diff --git a/packages/proposals/src/views/index.tsx b/packages/governance/src/views/index.tsx similarity index 100% rename from packages/proposals/src/views/index.tsx rename to packages/governance/src/views/index.tsx diff --git a/packages/proposals/src/views/proposal/index.tsx b/packages/governance/src/views/proposal/index.tsx similarity index 100% rename from packages/proposals/src/views/proposal/index.tsx rename to packages/governance/src/views/proposal/index.tsx diff --git a/packages/proposals/src/views/proposal/new.tsx b/packages/governance/src/views/proposal/new.tsx similarity index 100% rename from packages/proposals/src/views/proposal/new.tsx rename to packages/governance/src/views/proposal/new.tsx diff --git a/packages/proposals/src/views/proposal/style.less b/packages/governance/src/views/proposal/style.less similarity index 100% rename from packages/proposals/src/views/proposal/style.less rename to packages/governance/src/views/proposal/style.less diff --git a/packages/proposals/src/views/proposals/index.tsx b/packages/governance/src/views/proposals/index.tsx similarity index 100% rename from packages/proposals/src/views/proposals/index.tsx rename to packages/governance/src/views/proposals/index.tsx diff --git a/packages/proposals/src/views/proposals/style.less b/packages/governance/src/views/proposals/style.less similarity index 100% rename from packages/proposals/src/views/proposals/style.less rename to packages/governance/src/views/proposals/style.less diff --git a/packages/proposals/src/wdyr.ts b/packages/governance/src/wdyr.ts similarity index 100% rename from packages/proposals/src/wdyr.ts rename to packages/governance/src/wdyr.ts diff --git a/packages/proposals/tsconfig.json b/packages/governance/tsconfig.json similarity index 100% rename from packages/proposals/tsconfig.json rename to packages/governance/tsconfig.json diff --git a/packages/proposals/types/buffer-layout.d.ts b/packages/governance/types/buffer-layout.d.ts similarity index 100% rename from packages/proposals/types/buffer-layout.d.ts rename to packages/governance/types/buffer-layout.d.ts