solotto 1.1.1 → 1.1.2

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
@@ -341,6 +341,7 @@ const grouped = await lottery.GetBoosters(authority, lotteryId, true);
341
341
  authority: "Pubkey...", // Lottery authority public key
342
342
  amount: 0.5, // Boost amount in SOL
343
343
  message: "Good luck!", // Optional memo message (empty string if none)
344
+ time: 1700000000, // Unix block timestamp of the boost transaction
344
345
  signature: "TxSignature...",
345
346
  },
346
347
  // ...
@@ -353,7 +354,7 @@ const grouped = await lottery.GetBoosters(authority, lotteryId, true);
353
354
  {
354
355
  "BoosterPubkey...": {
355
356
  boost: [
356
- { booster: "Pubkey...", lotteryId: 1, authority: "Pubkey...", amount: 0.5, message: "...", signature: "TxSig..." },
357
+ { booster: "Pubkey...", lotteryId: 1, authority: "Pubkey...", amount: 0.5, message: "...", time: 1700000000, signature: "TxSig..." },
357
358
  // ...
358
359
  ],
359
360
  total: 1.5, // Sum of all boost amounts in SOL
@@ -457,7 +458,7 @@ const ticket = await lottery.GetTicket(authority, lotteryId, ticketNumber);
457
458
 
458
459
  #### GetTickets
459
460
 
460
- Fetches all tickets for a lottery, optionally filtered by buyer and/or grouped by owner.
461
+ Fetches all tickets for a lottery, optionally filtered by buyer, grouped by owner, and/or enriched with purchase timestamps.
461
462
 
462
463
  ```js
463
464
  // Get all tickets
@@ -468,6 +469,9 @@ const myTickets = await lottery.GetTickets(authority, lotteryId, buyer);
468
469
 
469
470
  // Get all tickets grouped by owner
470
471
  const grouped = await lottery.GetTickets(authority, lotteryId, false, true);
472
+
473
+ // Get all tickets with purchase timestamps
474
+ const withTime = await lottery.GetTickets(authority, lotteryId, false, false, true);
471
475
  ```
472
476
 
473
477
  | Parameter | Type | Default | Description |
@@ -476,6 +480,7 @@ const grouped = await lottery.GetTickets(authority, lotteryId, false, true);
476
480
  | `lotteryId` | `Number` | — | The lottery ID. |
477
481
  | `buyer` | `{publicKey} \| false` | `false` | Optional buyer to filter by. |
478
482
  | `group` | `Boolean` | `false` | If `true`, groups tickets by owner. |
483
+ | `time` | `Boolean` | `false` | If `true`, fetches the block timestamp for each ticket (slower — requires extra RPC calls). |
479
484
 
480
485
  **Returns (ungrouped):**
481
486
 
@@ -492,6 +497,7 @@ const grouped = await lottery.GetTickets(authority, lotteryId, false, true);
492
497
  ticketReceipt: "Pubkey...",
493
498
  ticketNumber: 42,
494
499
  ticketPda: "Pubkey...",
500
+ time: null, // Unix timestamp when time=true, null otherwise
495
501
  },
496
502
  // ... sorted descending by ticket number
497
503
  ],
@@ -511,7 +517,7 @@ const grouped = await lottery.GetTickets(authority, lotteryId, false, true);
511
517
  owner: "Pubkey...",
512
518
  ticketCount: 3,
513
519
  tickets: [
514
- { owner: "Pubkey...", lottery: "Pubkey...", ticketReceipt: "Pubkey...", ticketNumber: 42, ticketPda: "Pubkey..." },
520
+ { owner: "Pubkey...", lottery: "Pubkey...", ticketReceipt: "Pubkey...", ticketNumber: 42, ticketPda: "Pubkey...", time: null },
515
521
  // ...
516
522
  ],
517
523
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solotto",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Solana lottery client",
5
5
  "type": "module",
6
6
  "types": "./solotto.d.ts",
package/solotto.d.ts CHANGED
@@ -105,6 +105,8 @@ declare module "solotto" {
105
105
  ticketReceipt: string;
106
106
  ticketNumber: number;
107
107
  ticketPda: string;
108
+ /** Unix block timestamp of ticket purchase, or `null` when `time=false`. */
109
+ time: number | null;
108
110
  }
109
111
 
110
112
  interface GroupedTicketOwner {
@@ -160,6 +162,8 @@ declare module "solotto" {
160
162
  amount: number;
161
163
  /** Optional memo message from the booster. */
162
164
  message: string;
165
+ /** Unix block timestamp of the boost transaction. */
166
+ time: number;
163
167
  /** Transaction signature. */
164
168
  signature: string;
165
169
  }
@@ -310,12 +314,13 @@ declare module "solotto" {
310
314
  ticket: number
311
315
  ): Promise<TicketInfo>;
312
316
 
313
- /** Fetch all tickets for a lottery, optionally filtered by buyer and/or grouped by owner. */
317
+ /** Fetch all tickets for a lottery, optionally filtered by buyer, grouped by owner, and/or with timestamps. */
314
318
  GetTickets(
315
319
  authority: HasPublicKey,
316
320
  lotteryId: number,
317
321
  buyer?: HasPublicKey | false,
318
- group?: boolean
322
+ group?: boolean,
323
+ time?: boolean
319
324
  ): Promise<TicketListResult>;
320
325
 
321
326
  /**
package/solotto.js CHANGED
@@ -441,7 +441,7 @@ class Lottery extends EventEmitter {
441
441
  * @param {Number} lotteryId - Lottery Id
442
442
  * @param {PublicKey} buyer - Ticket Buyer Optional
443
443
  */
444
- async GetTickets(authority, lotteryId, buyer = false, group = false) {
444
+ async GetTickets(authority, lotteryId, buyer = false, group = false, time = false) {
445
445
  const [lotteryPDA] = await this.DeriveLotteryPDA(authority.publicKey, lotteryId);
446
446
  const filters = [];
447
447
  filters.push({dataSize: 104});
@@ -459,6 +459,11 @@ class Lottery extends EventEmitter {
459
459
  newTicket.ticketReceipt = new PublicKey(decoded.ticketReceipt).toString();
460
460
  newTicket.ticketNumber = parseInt(new BN(decoded.ticketNumber, 10, "le"));
461
461
  newTicket.ticketPda = data.pubkey.toString();
462
+ newTicket.time = null;
463
+ if(time){
464
+ const dat = await this.connection.getSignaturesForAddress(data.pubkey, "finalized");
465
+ newTicket.time = dat[0].blockTime;
466
+ }
462
467
  tickets.push(newTicket);
463
468
  i++;
464
469
  }
@@ -732,6 +737,7 @@ class Lottery extends EventEmitter {
732
737
  else if(log.includes("Program log: Memo ")){
733
738
  const parts = log.split(":booster:");
734
739
  item.message = parts[1].slice(0, -1).trim();
740
+ item.message = item.message.replace(new RegExp("\\\\", "g"), "");
735
741
  }
736
742
  else if(log.includes("Program log: Authority ")){
737
743
  item.authority = log.replace("Program log: Authority ","").trim();
@@ -741,6 +747,7 @@ class Lottery extends EventEmitter {
741
747
  const matchesAuthority = authority ? (item.authority && authority.publicKey.toString() === item.authority) : true;
742
748
  const matchesLotteryId = lotteryId ? (item.lotteryId !== undefined && lotteryId.toString() === item.lotteryId.toString()) : true;
743
749
  if(matchesAuthority && matchesLotteryId && item.amount >= 0.0001){
750
+ item.time = init.blockTime;
744
751
  item.signature = init.signature;
745
752
  result.push(item);
746
753
  }