solotto 1.1.5 → 1.2.1

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/README.md CHANGED
@@ -429,7 +429,7 @@ const state = await lottery.GetLottery(authority, lotteryId, fees);
429
429
  isActive: true, // Whether the lottery is active
430
430
  prizePoolBalance: 3780000000, // Prize pool in lamports (after fees if fees=true)
431
431
  drawInitiated: false, // Whether a draw has been initiated
432
- prizePoolAddress: "Pubkey...", // Prize pool PDA
432
+ prizePoolAddress: "Pubkey...", // Per-lottery prize pool PDA (seeds: ["prize-pool", lotteryPDA])
433
433
  lotteryAddress: "Pubkey...", // Lottery PDA
434
434
  release: "Pubkey...", // Release address (lottery PDA)
435
435
  releaseTime: null, // Unix timestamp when unclaimed prizes can be released (null if not set)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solotto",
3
- "version": "1.1.5",
3
+ "version": "1.2.1",
4
4
  "description": "Solana lottery client",
5
5
  "type": "module",
6
6
  "types": "./solotto.d.ts",
package/solotto.d.ts CHANGED
@@ -402,8 +402,8 @@ declare module "solotto" {
402
402
  ticketReceipt: PublicKey
403
403
  ): Promise<[PublicKey, number]>;
404
404
 
405
- /** Derive the prize pool PDA. */
406
- DerivePrizePoolPDA(): Promise<[PublicKey, number]>;
405
+ /** Derive the per-lottery prize pool PDA. Seeds: ["prize-pool", lotteryPDA]. */
406
+ DerivePrizePoolPDA(lotteryPDA: PublicKey): Promise<[PublicKey, number]>;
407
407
  }
408
408
 
409
409
  /**
package/solotto.js CHANGED
@@ -276,6 +276,7 @@ class Lottery extends EventEmitter {
276
276
  { pubkey: new PublicKey(LOTTO.ticket.ticketReceipt), isSigner: false, isWritable: false },
277
277
  { pubkey: new PublicKey(LOTTO.ticket.ticketPda), isSigner: false, isWritable: false },
278
278
  { pubkey: new PublicKey(LOTTO.prizePoolAddress), isSigner: false, isWritable: true },
279
+ { pubkey: new PublicKey(LOTTO.authority), isSigner: false, isWritable: true },
279
280
  { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
280
281
  ];
281
282
  const ix = new TransactionInstruction({programId: this.program, keys, data: await claimData()});
@@ -586,8 +587,8 @@ class Lottery extends EventEmitter {
586
587
  return Number(val);
587
588
  });
588
589
  }catch{}
589
- const prizePoolAddress = await this.DerivePrizePoolPDA();
590
590
  const lotteryAddress = await this.DeriveLotteryPDA(new PublicKey(auth), lotteryId);
591
+ const prizePoolAddress = await this.DerivePrizePoolPDA(lotteryAddress[0]);
591
592
  let prizePoolBalance = prizePool;
592
593
  if(fees){prizePoolBalance = prizePool - (prizePool * 0.1);}
593
594
  return {
@@ -625,8 +626,8 @@ class Lottery extends EventEmitter {
625
626
  programId
626
627
  );
627
628
  }
628
- async DerivePrizePoolPDA() {
629
- return PublicKey.findProgramAddressSync([Buffer.from("prize-pool")], this.program);
629
+ async DerivePrizePoolPDA(lotteryPDA) {
630
+ return PublicKey.findProgramAddressSync([Buffer.from("prize-pool"), lotteryPDA.toBuffer()], this.program);
630
631
  }
631
632
 
632
633
  /**
@@ -840,11 +841,13 @@ class LotteryManager {
840
841
  return buffer;
841
842
  }
842
843
  const [lotteryPDA, bump] = await lottery.DeriveLotteryPDA(authority.publicKey, lotteryId);
844
+ const [prizePoolPDA] = await lottery.DerivePrizePoolPDA(lotteryPDA);
843
845
  console.log("Lottery PDA:", lotteryPDA.toString());
844
846
  const ix = new TransactionInstruction({
845
847
  keys: [
846
848
  { pubkey: authority.publicKey, isSigner: true, isWritable: true },
847
849
  { pubkey: lotteryPDA, isSigner: false, isWritable: true },
850
+ { pubkey: prizePoolPDA, isSigner: false, isWritable: true },
848
851
  { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
849
852
  ],
850
853
  programId: this.program,
@@ -893,13 +896,12 @@ class LotteryManager {
893
896
  const lottery = new Lottery(this.connection, false, this.program);
894
897
  const network = new LotteryNetwork(this.connection);
895
898
  const [lotteryPDA] = await lottery.DeriveLotteryPDA(authority.publicKey, lotteryId);
896
- const [prizePoolPDA] = await lottery.DerivePrizePoolPDA();
899
+ const [prizePoolPDA] = await lottery.DerivePrizePoolPDA(lotteryPDA);
897
900
  const keys = [
898
- { pubkey: authority.publicKey, isSigner: true, isWritable: false },
901
+ { pubkey: authority.publicKey, isSigner: true, isWritable: true },
899
902
  { pubkey: lotteryPDA, isSigner: false, isWritable: true },
900
903
  { pubkey: SYSVAR_SLOT_HASHES_PUBKEY, isSigner: false, isWritable: false },
901
904
  { pubkey: prizePoolPDA, isSigner: false, isWritable: true },
902
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
903
905
  ];
904
906
  const ix = new TransactionInstruction({programId: this.program, keys, data: await randomnessData()});
905
907
  const _tx_ = {};
@@ -1018,7 +1020,6 @@ class LotteryManager {
1018
1020
  { pubkey: authority.publicKey, isSigner: true, isWritable: true },
1019
1021
  { pubkey: lotteryPDA, isSigner: false, isWritable: true },
1020
1022
  { pubkey: new PublicKey(LOTTO.prizePoolAddress), isSigner: false, isWritable: true },
1021
- { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
1022
1023
  ];
1023
1024
  const ix = new TransactionInstruction({programId: this.program, keys, data: await expiredData()});
1024
1025
  const _tx_ = {};