Skip to content

Commit

Permalink
Remove need for program index
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass committed Apr 16, 2023
1 parent 2a526c9 commit f23e1f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/createProgramUpgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {programManagerProgramId} from './constants'
export const createProgramUpgrade = async ({
multisig,
programId,
programIndex,
buffer,
spill,
authority,
Expand All @@ -22,7 +21,6 @@ export const createProgramUpgrade = async ({
}: {
multisig: PublicKey
programId: PublicKey
programIndex: number
buffer: PublicKey
spill: PublicKey
authority: PublicKey
Expand All @@ -40,6 +38,17 @@ export const createProgramUpgrade = async ({
AnchorProvider.defaultOptions()
)
)
const programs = await program.account.managedProgram.all()
const programIndex = programs.find(
p => p.account.programAddress.toString() === programId.toString()
)?.account.managedProgramIndex

if (typeof programIndex === undefined) {
throw new Error(
`Program ${programId.toString()} not managed by this squad}`
)
}

const [programManagerPDA] = await getProgramManagerPDA(
multisig,
programManagerProgramId
Expand Down
4 changes: 1 addition & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ async function run(): Promise<void> {
const networkUrl: string = core.getInput('network-url')
const programMultisig: string = core.getInput('program-multisig')
const programId: string = core.getInput('program-id')
const programIndex: string = core.getInput('program-index')
const buffer: string = core.getInput('buffer')
const spillAddress: string = core.getInput('spill-address')
const authority: string = core.getInput('authority')
const name: string = core.getInput('name')
const keypair: string = core.getInput('keypair')
const idlBuffer: string = core.getInput('idl-buffer')
const authorityIndex: string = core.getInput('authority-index')

core.debug(`start: ${new Date().toLocaleString()}`)
core.debug(`networkUrl: ${networkUrl}`)
core.debug(`programMultisig: ${programMultisig}`)
core.debug(`programId: ${programId}`)
core.debug(`programIndex: ${programIndex}`)
core.debug(`buffer: ${buffer}`)
core.debug(`spillAddress: ${spillAddress}`)
core.debug(`authority: ${authority}`)
Expand All @@ -32,7 +31,6 @@ async function run(): Promise<void> {
await createProgramUpgrade({
multisig: publicKeyFrom(programMultisig, 'programMultisig'),
programId: publicKeyFrom(programId, 'programId'),
programIndex: parseInt(programIndex) ?? 1,
buffer: publicKeyFrom(buffer, 'buffer'),
spill: publicKeyFrom(spillAddress, 'spillAddress'),
authority: publicKeyFrom(authority, 'authority'),
Expand Down

0 comments on commit f23e1f2

Please sign in to comment.