Skip to content

Commit 21136c4

Browse files
authored
Do not display keypair input in open orca position (#128)
1 parent 79bea1e commit 21136c4

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

components/instructions/instructionCard.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Keypair, PublicKey } from '@solana/web3.js';
22
import { ExternalLinkIcon } from '@heroicons/react/outline';
33
import {
44
AccountMetaData,
5+
InstructionExecutionStatus,
56
Proposal,
67
ProposalTransaction,
78
} from '@solana/spl-governance';
@@ -199,7 +200,9 @@ export default function InstructionCard({
199200
{
200201
// In the very particular case it is about Orca Whirlpool Open Position Instruction
201202
// We ask the users for the keypair of the position mint
202-
isInstructionAboutOrcaWhirlpoolOpenPosition ? (
203+
isInstructionAboutOrcaWhirlpoolOpenPosition &&
204+
proposalInstruction.account.executionStatus ===
205+
InstructionExecutionStatus.Success ? (
203206
<div className="flex flex-col mt-6 mb-8">
204207
<strong>
205208
Provide the <em>positionMint</em> secret key shown during the

components/instructions/programs/orca.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,32 @@ export const ORCA_PROGRAM_INSTRUCTIONS = {
4949
'Metadata Update Auth',
5050
],
5151
getDataUI: async (
52-
_connection: Connection,
52+
connection: Connection,
5353
_data: Uint8Array,
54-
_accounts: AccountMetaData[],
54+
accounts: AccountMetaData[],
5555
) => {
56-
// No useful data to display. Do not use null to avoid having the bytes displayed
57-
return <></>;
56+
const whirlpoolAddress = accounts[6].pubkey;
57+
const whirlpoolClient = buildLocalWhirlpoolClient(connection);
58+
const whirlpool = (await whirlpoolClient.getPool(
59+
whirlpoolAddress,
60+
)) as WhirlpoolImpl;
61+
62+
if (!whirlpool) {
63+
throw new Error(
64+
`Cannot load whirlpool ${whirlpoolAddress.toBase58()} data`,
65+
);
66+
}
67+
68+
const tokenAName = getSplTokenNameByMint(whirlpool.tokenAInfo.mint);
69+
const tokenBName = getSplTokenNameByMint(whirlpool.tokenBInfo.mint);
70+
71+
return (
72+
<>
73+
<p>
74+
Whirlpool {tokenAName} - {tokenBName}
75+
</p>
76+
</>
77+
);
5878
},
5979
},
6080

0 commit comments

Comments
 (0)