Skip to content

Commit 33d8107

Browse files
committed
Throw if program address is not found
1 parent 7b83f73 commit 33d8107

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/nodes-from-anchor/src/v01/InstructionAccountNode.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
import { getBase58Codec } from '@solana/codecs';
3131

3232
import { hex } from '../utils';
33-
import { IdlV01InstructionAccount, IdlV01InstructionAccountItem, IdlV01Seed, IdlV01SeedAccount } from './idl';
33+
import { IdlV01InstructionAccount, IdlV01InstructionAccountItem, IdlV01Seed } from './idl';
3434

3535
export function instructionAccountNodesFromAnchorV01(
3636
allAccounts: AccountNode[],
@@ -135,13 +135,12 @@ export function instructionAccountNodeFromAnchorV01(
135135
break;
136136
}
137137
case 'account': {
138-
const accNode = parentIdl.find(acc => acc.name == (idl.pda?.program as IdlV01SeedAccount).path);
139-
if (accNode) {
140-
programId = (accNode as IdlV01InstructionAccount).address;
141-
} else {
142-
programId = '';
138+
const programPath = idl.pda.program.path;
139+
const programNode = parentIdl.find(acc => acc.name == programPath);
140+
if (!(programNode && 'address' in programNode)) {
141+
throw new CodamaError(CODAMA_ERROR__ANCHOR__PROGRAM_ID_KIND_UNIMPLEMENTED, { kind });
143142
}
144-
143+
programId = programNode.address;
145144
break;
146145
}
147146
default: {

0 commit comments

Comments
 (0)