diff --git a/packages/helium-vote-service/src/index.ts b/packages/helium-vote-service/src/index.ts index 65166355f..a957545ef 100644 --- a/packages/helium-vote-service/src/index.ts +++ b/packages/helium-vote-service/src/index.ts @@ -559,22 +559,28 @@ server.post<{ .instruction(); instructions.push(countIx); if (vote.delegatedPosition) { - const delegatedCountIx = await heliumSubDaosProgram.methods - .trackVoteV0() - .accounts({ - payer: pdaWallet, - delegatedPosition: new PublicKey(vote.delegatedPosition), - registrar: HNT_REGISTRAR, - position: positionKey(new PublicKey(vote.asset))[0], - proposal, - mint: new PublicKey(vote.asset), - marker: voteMarkerKey( - new PublicKey(vote.asset), - proposal - )[0], - }) - .instruction(); - instructions.push(delegatedCountIx); + const delegatedPosition = + await provider.connection.getAccountInfo( + new PublicKey(vote.delegatedPosition) + ); + if (delegatedPosition) { + const delegatedCountIx = await heliumSubDaosProgram.methods + .trackVoteV0() + .accounts({ + payer: pdaWallet, + delegatedPosition: new PublicKey(vote.delegatedPosition), + registrar: HNT_REGISTRAR, + position: positionKey(new PublicKey(vote.asset))[0], + proposal, + mint: new PublicKey(vote.asset), + marker: voteMarkerKey( + new PublicKey(vote.asset), + proposal + )[0], + }) + .instruction(); + instructions.push(delegatedCountIx); + } } return instructions; })