@zemyth/raise-sdk 0.1.7 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ import { PublicKey, Keypair, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, SYS
10
10
  import {
11
11
  getProjectPDA,
12
12
  getEscrowPDA,
13
+ getEscrowTokenAccountPDA,
13
14
  getMilestonePDA,
14
15
  getInvestmentPDA,
15
16
  getVotePDA,
@@ -379,8 +380,10 @@ export async function approveProject(
379
380
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
380
381
  const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
381
382
  const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
383
+ const escrowPda = getEscrowPDA(args.projectId, program.programId);
384
+ const escrowTokenAccountPda = getEscrowTokenAccountPDA(projectPda, program.programId);
382
385
 
383
- // Request 400k CUs - this instruction creates 10 accounts + 7 CPIs + 5 events
386
+ // Request 400k CUs - this instruction creates 11 accounts + 7 CPIs + 5 events
384
387
  const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
385
388
  units: 400_000,
386
389
  });
@@ -401,6 +404,8 @@ export async function approveProject(
401
404
  futureRoundTokenVault: futureRoundTokenVaultPda,
402
405
  futureRoundVault: futureRoundVaultPda,
403
406
  usdcMint: args.usdcMint,
407
+ escrowPda,
408
+ escrowTokenAccount: escrowTokenAccountPda,
404
409
  authority: adminPubkey,
405
410
  payer: adminPubkey,
406
411
  })
@@ -584,11 +589,14 @@ export async function claimMilestoneFunds(
584
589
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
585
590
 
586
591
  // For non-final milestones, derive next milestone PDA if not provided
592
+ const isFinal = args.nextMilestoneDeadline.eq(new BN(0));
587
593
  const nextMilestonePda = args.nextMilestonePda ??
588
- (args.nextMilestoneDeadline.gt(new BN(0))
594
+ (!isFinal
589
595
  ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId)
590
596
  : null);
591
597
 
598
+ // Pass null for optional next_milestone on final milestone —
599
+ // Anchor's resolveOptionals converts null → programId sentinel for Option<Account> = None
592
600
  return getMethods(program)
593
601
  .claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline })
594
602
  .accountsPartial({
@@ -601,7 +609,7 @@ export async function claimMilestoneFunds(
601
609
  tokenVault: tokenVaultPda,
602
610
  tokenomics: tokenomicsPda,
603
611
  lpUsdcVault: lpUsdcVaultPda,
604
- nextMilestone: nextMilestonePda,
612
+ nextMilestone: nextMilestonePda, // null for final → Anchor uses programId sentinel
605
613
  systemProgram: SystemProgram.programId,
606
614
  tokenProgram: TOKEN_PROGRAM_ID,
607
615
  })
package/src/pdas/index.ts CHANGED
@@ -57,6 +57,24 @@ export function getEscrowPDA(projectId: BN | number | string, programId: PublicK
57
57
  return pda;
58
58
  }
59
59
 
60
+ /**
61
+ * Derive Escrow Token Account PDA from project PDA
62
+ *
63
+ * This is the USDC token account owned by the escrow PDA,
64
+ * created during approveProject.
65
+ *
66
+ * @param projectPda - Project account PDA
67
+ * @param programId - Raise program ID
68
+ * @returns Escrow token account PDA
69
+ */
70
+ export function getEscrowTokenAccountPDA(projectPda: PublicKey, programId: PublicKey): PublicKey {
71
+ const [pda] = PublicKey.findProgramAddressSync(
72
+ [Buffer.from(SEEDS.ESCROW_TOKEN), projectPda.toBuffer()],
73
+ programId
74
+ );
75
+ return pda;
76
+ }
77
+
60
78
  /**
61
79
  * Derive Milestone PDA from project PDA and milestone index
62
80
  *