Skip to content
This repository has been archived by the owner on Feb 9, 2025. It is now read-only.

Commit

Permalink
add spill account field in the upgrade form (#2107)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xShuk authored Feb 5, 2024
1 parent e3cd3a9 commit 2d49a04
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions components/AssetsList/UpgradeProgram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { validateInstruction } from 'utils/instructionTools'
import * as yup from 'yup'
import { createUpgradeInstruction } from '@tools/sdk/bpfUpgradeableLoader/createUpgradeInstruction'
import { debounce } from '@utils/debounce'
import { isFormValid } from '@utils/formValidation'
import { isFormValid, validatePubkey } from '@utils/formValidation'
import ProgramUpgradeInfo from 'pages/dao/[symbol]/proposal/components/instructions/bpfUpgradeableLoader/ProgramUpgradeInfo'
import { getProgramName } from '@components/instructions/programs/names'
import useCreateProposal from '@hooks/useCreateProposal'
Expand All @@ -49,6 +49,7 @@ const UpgradeProgram = ({ program }: { program: AssetAccount }) => {
const [form, setForm] = useState<UpgradeProgramCompactForm>({
governedAccount: program,
programId: programId?.toString(),
bufferSpillAddress: wallet?.publicKey ? wallet.publicKey.toBase58() : '',
bufferAddress: '',
description: '',
title: '',
Expand Down Expand Up @@ -87,6 +88,12 @@ const UpgradeProgram = ({ program }: { program: AssetAccount }) => {
})
}
}),
bufferSpillAddress: yup
.string()
.required("Spill account is required")
.test('is-spill-account-valid', 'Invalid Spill Account', function (val: string) {
return val ? validatePubkey(val) : true
}),
governedAccount: yup
.object()
.nullable()
Expand All @@ -105,7 +112,7 @@ const UpgradeProgram = ({ program }: { program: AssetAccount }) => {
form.governedAccount.pubkey,
new PublicKey(form.bufferAddress),
form.governedAccount.extensions.program!.authority,
wallet!.publicKey
new PublicKey(form.bufferSpillAddress!)
)
serializedInstruction = serializeInstructionToBase64(upgradeIx)
}
Expand Down Expand Up @@ -188,6 +195,19 @@ const UpgradeProgram = ({ program }: { program: AssetAccount }) => {
noMaxWidth={true}
error={formErrors['bufferAddress']}
/>
<Input
label="Spill account"
value={form.bufferSpillAddress}
type="text"
onChange={(evt) =>
handleSetForm({
value: evt.target.value,
propertyName: 'bufferSpillAddress',
})
}
noMaxWidth={true}
error={formErrors['bufferSpillAddress']}
/>
<ProgramUpgradeInfo
authority={form.governedAccount?.extensions.program?.authority}
/>
Expand Down

0 comments on commit 2d49a04

Please sign in to comment.