Skip to content

Commit 6f79e00

Browse files
authored
Show secret key only to payer (#129)
1 parent f6b0805 commit 6f79e00

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

components/instructions/instructionCard.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Keypair, PublicKey } from '@solana/web3.js';
22
import { ExternalLinkIcon } from '@heroicons/react/outline';
33
import {
44
AccountMetaData,
5-
InstructionExecutionStatus,
65
Proposal,
76
ProposalTransaction,
87
} from '@solana/spl-governance';
@@ -48,6 +47,7 @@ export default function InstructionCard({
4847
nftsGovernedTokenAccounts,
4948
governedTokenAccountsWithoutNfts,
5049
} = useGovernanceAssets();
50+
const wallet = useWalletStore((s) => s.current);
5151
const connection = useWalletStore((s) => s.connection);
5252
const tokenRecords = useWalletStore((s) => s.selectedRealm);
5353
const [descriptor, setDescriptor] = useState<InstructionDescriptor>();
@@ -149,6 +149,14 @@ export default function InstructionCard({
149149
return true;
150150
})();
151151

152+
// Say if the connected wallet is the payer of the open position instruction
153+
const isPayerOfOrcaWhirlpoolOpenPositionIx =
154+
isInstructionAboutOrcaWhirlpoolOpenPosition && wallet?.publicKey
155+
? proposalInstruction.account
156+
.getSingleInstruction()
157+
.accounts[0].pubkey.equals(wallet.publicKey)
158+
: false;
159+
152160
return (
153161
<div className="break-all">
154162
<h3 className="mb-4 flex">
@@ -199,10 +207,9 @@ export default function InstructionCard({
199207

200208
{
201209
// In the very particular case it is about Orca Whirlpool Open Position Instruction
202-
// We ask the users for the keypair of the position mint
210+
// We ask the users for the secret key of the position mint
203211
isInstructionAboutOrcaWhirlpoolOpenPosition &&
204-
proposalInstruction.account.executionStatus ===
205-
InstructionExecutionStatus.Success ? (
212+
isPayerOfOrcaWhirlpoolOpenPositionIx ? (
206213
<div className="flex flex-col mt-6 mb-8">
207214
<strong>
208215
Provide the <em>positionMint</em> secret key shown during the

0 commit comments

Comments
 (0)