From 502410e9dd541633888b13fb5eb579ecc54bc4ba Mon Sep 17 00:00:00 2001 From: Dummy Tester 123 Date: Sat, 20 Mar 2021 15:14:09 -0500 Subject: [PATCH 1/4] Bugfix for execute account construction --- packages/proposals/src/actions/execute.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/proposals/src/actions/execute.ts b/packages/proposals/src/actions/execute.ts index 77f277d..61bb618 100644 --- a/packages/proposals/src/actions/execute.ts +++ b/packages/proposals/src/actions/execute.ts @@ -78,18 +78,23 @@ function getAccountInfos( The addresses that do not require signatures follow the addresses that do, again with read-write accounts first and read-only accounts following. */ - const accountInfosInOrder = actualMessage.instructions[0].accounts.map( - a => actualMessage.accountKeys[a], - ); + 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 = - accountInfosInOrder.length - - requireSigsOnlyNotWritable - - requireNietherSigsNorWrite; - const readOnly = requireSigsOnlyNotWritable + requireNietherSigsNorWrite; + totalSize - requireSigsOnlyNotWritable - requireNietherSigsNorWrite; + // and adjust here... + const readOnly = + requireSigsOnlyNotWritable + + requireNietherSigsNorWrite - + (totalSize - accountInfosInOrder.length); let position = 0; @@ -125,5 +130,6 @@ function getAccountInfos( isSigner: false, }); } + return finalArray; } From 17a0100f4fd66dfa6ef9307b8d147599fc7dcb85 Mon Sep 17 00:00:00 2001 From: Dummy Tester 123 Date: Sat, 20 Mar 2021 16:07:33 -0500 Subject: [PATCH 2/4] Fix list pagination --- packages/proposals/src/views/home/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/proposals/src/views/home/index.tsx b/packages/proposals/src/views/home/index.tsx index f3158fb..a62bf52 100644 --- a/packages/proposals/src/views/home/index.tsx +++ b/packages/proposals/src/views/home/index.tsx @@ -11,11 +11,11 @@ export const HomeView = () => { const context = useProposals(); const [page, setPage] = useState(0); const listData = useMemo(() => { - const newListData: any[][] = [[]]; + const newListData: any[] = []; Object.keys(context.proposals).forEach(key => { const proposal = context.proposals[key]; - newListData[newListData.length - 1].push({ + newListData.push({ href: '#/proposal/' + key, title: proposal.info.state.name, proposal, @@ -27,8 +27,6 @@ export const HomeView = () => { proposal.info.state.descLink ), }); - if (newListData[newListData.length - 1].length == PAGE_SIZE) - newListData.push([]); }); return newListData; }, [context.proposals]); @@ -45,7 +43,7 @@ export const HomeView = () => { }, pageSize: PAGE_SIZE, }} - dataSource={listData[page]} + dataSource={listData} renderItem={item => ( From f68560ea35069bff9cb28d45ee43347983c35d5b Mon Sep 17 00:00:00 2001 From: Dummy Tester 123 Date: Sat, 20 Mar 2021 16:17:18 -0500 Subject: [PATCH 3/4] Fix footer. --- packages/proposals/src/components/Layout/index.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/proposals/src/components/Layout/index.tsx b/packages/proposals/src/components/Layout/index.tsx index 13fc6df..19bd840 100644 --- a/packages/proposals/src/components/Layout/index.tsx +++ b/packages/proposals/src/components/Layout/index.tsx @@ -45,11 +45,6 @@ export const AppLayout = React.memo((props: any) => { ( -
- {LABELS.FOOTER} -
- )} navTheme={theme} headerTheme={theme} theme={theme} @@ -126,6 +121,9 @@ export const AppLayout = React.memo((props: any) => { }} > {props.children} +
+ {LABELS.FOOTER} +
); From b8262223d36c5fdbdeb38e90c5a5c3db9bd27df6 Mon Sep 17 00:00:00 2001 From: Dummy Tester 123 Date: Sat, 20 Mar 2021 16:58:06 -0500 Subject: [PATCH 4/4] Have execute button show up when ready using a set interval trick. --- .../components/Proposal/InstructionCard.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/proposals/src/components/Proposal/InstructionCard.tsx b/packages/proposals/src/components/Proposal/InstructionCard.tsx index 9a41f58..8594470 100644 --- a/packages/proposals/src/components/Proposal/InstructionCard.tsx +++ b/packages/proposals/src/components/Proposal/InstructionCard.tsx @@ -9,7 +9,7 @@ import { import { ParsedAccount, contexts } from '@oyster/common'; import { Card, Spin } from 'antd'; import Meta from 'antd/lib/card/Meta'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { execute } from '../../actions/execute'; import { LABELS } from '../../constants'; import { @@ -96,7 +96,21 @@ function PlayStatusButton({ const wallet = useWallet(); const connection = useConnection(); const [currSlot, setCurrSlot] = useState(0); - connection.getSlot().then(setCurrSlot); + + const elapsedTime = currSlot - proposal.info.state.votingEndedAt.toNumber(); + const ineligibleToSee = elapsedTime < instruction.info.slot.toNumber(); + + useEffect(() => { + if (ineligibleToSee) { + const id = setInterval(() => { + connection.getSlot().then(setCurrSlot); + }, 400); + + return () => { + clearInterval(id); + }; + } + }, [ineligibleToSee, connection]); const run = async () => { setPlaying(Playstate.Playing); @@ -111,8 +125,7 @@ function PlayStatusButton({ }; if (proposal.info.state.status != TimelockStateStatus.Executing) return null; - const elapsedTime = currSlot - proposal.info.state.votingEndedAt.toNumber(); - if (elapsedTime < instruction.info.slot.toNumber()) return null; + if (ineligibleToSee) return null; if (playing === Playstate.Unplayed) return (