@zemyth/raise-sdk 0.1.6 → 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.
- package/dist/accounts/index.cjs.map +1 -1
- package/dist/accounts/index.js.map +1 -1
- package/dist/constants/index.cjs +49 -9
- package/dist/constants/index.cjs.map +1 -1
- package/dist/constants/index.d.cts +126 -9
- package/dist/constants/index.d.ts +126 -9
- package/dist/constants/index.js +47 -10
- package/dist/constants/index.js.map +1 -1
- package/dist/index.cjs +78 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +76 -18
- package/dist/index.js.map +1 -1
- package/dist/instructions/index.cjs +25 -6
- package/dist/instructions/index.cjs.map +1 -1
- package/dist/instructions/index.d.cts +1 -1
- package/dist/instructions/index.d.ts +1 -1
- package/dist/instructions/index.js +26 -7
- package/dist/instructions/index.js.map +1 -1
- package/dist/pdas/index.cjs +9 -0
- package/dist/pdas/index.cjs.map +1 -1
- package/dist/pdas/index.d.cts +12 -1
- package/dist/pdas/index.d.ts +12 -1
- package/dist/pdas/index.js +9 -1
- package/dist/pdas/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +6 -2
- package/src/constants/index.ts +56 -9
- package/src/index.ts +4 -0
- package/src/instructions/index.ts +23 -10
- package/src/pdas/index.ts +18 -0
|
@@ -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
|
[
|
|
@@ -447,7 +455,8 @@ async function submitForApproval(program, projectId, founder) {
|
|
|
447
455
|
founder
|
|
448
456
|
}).rpc();
|
|
449
457
|
}
|
|
450
|
-
async function approveProject(program, args,
|
|
458
|
+
async function approveProject(program, args, admin) {
|
|
459
|
+
const adminPubkey = admin instanceof web3_js.Keypair ? admin.publicKey : admin;
|
|
451
460
|
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
452
461
|
const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
|
|
453
462
|
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
@@ -460,10 +469,12 @@ async function approveProject(program, args, adminKeypair) {
|
|
|
460
469
|
const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
|
|
461
470
|
const futureRoundTokenVaultPda = getFutureRoundTokenVaultPDA(projectPda, program.programId);
|
|
462
471
|
const futureRoundVaultPda = getFutureRoundVaultPDA(projectPda, program.programId);
|
|
472
|
+
const escrowPda = getEscrowPDA(args.projectId, program.programId);
|
|
473
|
+
const escrowTokenAccountPda = getEscrowTokenAccountPDA(projectPda, program.programId);
|
|
463
474
|
const computeBudgetIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
464
475
|
units: 4e5
|
|
465
476
|
});
|
|
466
|
-
|
|
477
|
+
let builder = getMethods(program).approveProject().accountsPartial({
|
|
467
478
|
project: projectPda,
|
|
468
479
|
tokenomics: tokenomicsPda,
|
|
469
480
|
tokenVault: tokenVaultPda,
|
|
@@ -477,9 +488,15 @@ async function approveProject(program, args, adminKeypair) {
|
|
|
477
488
|
futureRoundTokenVault: futureRoundTokenVaultPda,
|
|
478
489
|
futureRoundVault: futureRoundVaultPda,
|
|
479
490
|
usdcMint: args.usdcMint,
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
491
|
+
escrowPda,
|
|
492
|
+
escrowTokenAccount: escrowTokenAccountPda,
|
|
493
|
+
authority: adminPubkey,
|
|
494
|
+
payer: adminPubkey
|
|
495
|
+
}).preInstructions([computeBudgetIx]);
|
|
496
|
+
if (admin instanceof web3_js.Keypair) {
|
|
497
|
+
builder = builder.signers([admin]);
|
|
498
|
+
}
|
|
499
|
+
return builder.rpc();
|
|
483
500
|
}
|
|
484
501
|
async function createMilestone(program, args, founder) {
|
|
485
502
|
const projectPda = getProjectPDA(args.projectId, program.programId);
|
|
@@ -546,7 +563,8 @@ async function claimMilestoneFunds(program, args, founder) {
|
|
|
546
563
|
const tokenVaultPda = getTokenVaultPDA(projectPda, program.programId);
|
|
547
564
|
const tokenomicsPda = getTokenomicsPDA(projectPda, program.programId);
|
|
548
565
|
const lpUsdcVaultPda = getLpUsdcVaultPDA(projectPda, program.programId);
|
|
549
|
-
const
|
|
566
|
+
const isFinal = args.nextMilestoneDeadline.eq(new anchor.BN(0));
|
|
567
|
+
const nextMilestonePda = args.nextMilestonePda ?? (!isFinal ? getMilestonePDA(projectPda, args.milestoneIndex + 1, program.programId) : null);
|
|
550
568
|
return getMethods(program).claimMilestoneFunds({ nextMilestoneDeadline: args.nextMilestoneDeadline }).accountsPartial({
|
|
551
569
|
milestone: milestonePda,
|
|
552
570
|
project: projectPda,
|
|
@@ -558,6 +576,7 @@ async function claimMilestoneFunds(program, args, founder) {
|
|
|
558
576
|
tokenomics: tokenomicsPda,
|
|
559
577
|
lpUsdcVault: lpUsdcVaultPda,
|
|
560
578
|
nextMilestone: nextMilestonePda,
|
|
579
|
+
// null for final → Anchor uses programId sentinel
|
|
561
580
|
systemProgram: web3_js.SystemProgram.programId,
|
|
562
581
|
tokenProgram: splToken.TOKEN_PROGRAM_ID
|
|
563
582
|
}).rpc();
|