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