@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.
@@ -11,6 +11,7 @@ var SEEDS = {
11
11
  INVESTMENT: "investment",
12
12
  VOTE: "vote",
13
13
  ESCROW: "escrow",
14
+ ESCROW_TOKEN: "escrow_token",
14
15
  PIVOT: "pivot",
15
16
  TGE_ESCROW: "tge_escrow",
16
17
  ADMIN_CONFIG: "admin-config",
@@ -47,6 +48,13 @@ function getEscrowPDA(projectId, programId) {
47
48
  );
48
49
  return pda;
49
50
  }
51
+ function getEscrowTokenAccountPDA(projectPda, programId) {
52
+ const [pda] = PublicKey.findProgramAddressSync(
53
+ [Buffer.from(SEEDS.ESCROW_TOKEN), projectPda.toBuffer()],
54
+ programId
55
+ );
56
+ return pda;
57
+ }
50
58
  function getMilestonePDA(projectPda, milestoneIndex, programId) {
51
59
  const [pda] = PublicKey.findProgramAddressSync(
52
60
  [
@@ -459,6 +467,8 @@ async function approveProject(program, args, admin) {
459
467
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
460
468
  const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
461
469
  const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
470
+ const escrowPda = getEscrowPDA(args.projectId, program.programId);
471
+ const escrowTokenAccountPda = getEscrowTokenAccountPDA(projectPda, program.programId);
462
472
  const computeBudgetIx = ComputeBudgetProgram.setComputeUnitLimit({
463
473
  units: 4e5
464
474
  });
@@ -476,6 +486,8 @@ async function approveProject(program, args, admin) {
476
486
  futureRoundTokenVault: futureRoundTokenVaultPda,
477
487
  futureRoundVault: futureRoundVaultPda,
478
488
  usdcMint: args.usdcMint,
489
+ escrowPda,
490
+ escrowTokenAccount: escrowTokenAccountPda,
479
491
  authority: adminPubkey,
480
492
  payer: adminPubkey
481
493
  }).preInstructions([computeBudgetIx]);
@@ -549,7 +561,8 @@ async function claimMilestoneFunds(program, args, founder) {
549
561
  const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
550
562
  const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
551
563
  const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
552
- const nextMilestonePda = args.nextMilestonePda ?? (args.nextMilestoneDeadline.gt(new BN(0)) ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
564
+ const isFinal = args.nextMilestoneDeadline.eq(new BN(0));
565
+ const nextMilestonePda = args.nextMilestonePda ?? (!isFinal ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
553
566
  return getMethods(program).claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accountsPartial({
554
567
  milestone: milestonePda,
555
568
  project: projectPda,
@@ -561,6 +574,7 @@ async function claimMilestoneFunds(program, args, founder) {
561
574
  tokenomics: tokenomicsPda,
562
575
  lpUsdcVault: lpUsdcVaultPda,
563
576
  nextMilestone: nextMilestonePda,
577
+ // null for final → Anchor uses programId sentinel
564
578
  systemProgram: SystemProgram.programId,
565
579
  tokenProgram: TOKEN_PROGRAM_ID
566
580
  }).rpc();