solotto 1.1.3 → 1.1.5
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 +10 -3
- package/package.json +1 -1
- package/solotto.d.ts +5 -2
- package/solotto.js +6 -6
package/README.md
CHANGED
|
@@ -312,7 +312,7 @@ const result = await lottery.Boost(authority, lotteryId, booster, 1.0, "Good luc
|
|
|
312
312
|
|
|
313
313
|
#### GetBoosters
|
|
314
314
|
|
|
315
|
-
Retrieves boost history by scanning on-chain program logs for boost transactions. Filters out errored and non-finalized transactions
|
|
315
|
+
Retrieves boost history by scanning on-chain program logs for boost transactions. Filters out errored and non-finalized transactions. Can filter by authority, lottery ID, or both, and optionally group results by booster wallet address.
|
|
316
316
|
|
|
317
317
|
```js
|
|
318
318
|
// Get all boosters for a specific lottery
|
|
@@ -494,7 +494,7 @@ const ticket = await lottery.GetTicket(authority, lotteryId, ticketNumber);
|
|
|
494
494
|
|
|
495
495
|
#### GetTickets
|
|
496
496
|
|
|
497
|
-
Fetches all tickets for a lottery, optionally filtered by buyer, grouped by owner, and/or enriched with purchase timestamps.
|
|
497
|
+
Fetches all tickets for a lottery, optionally filtered by buyer, grouped by owner, and/or enriched with purchase timestamps and transaction signatures.
|
|
498
498
|
|
|
499
499
|
```js
|
|
500
500
|
// Get all tickets
|
|
@@ -508,6 +508,9 @@ const grouped = await lottery.GetTickets(authority, lotteryId, false, true);
|
|
|
508
508
|
|
|
509
509
|
// Get all tickets with purchase timestamps
|
|
510
510
|
const withTime = await lottery.GetTickets(authority, lotteryId, false, false, true);
|
|
511
|
+
|
|
512
|
+
// Get all tickets with timestamps and signatures
|
|
513
|
+
const full = await lottery.GetTickets(authority, lotteryId, false, false, true, true);
|
|
511
514
|
```
|
|
512
515
|
|
|
513
516
|
| Parameter | Type | Default | Description |
|
|
@@ -516,7 +519,10 @@ const withTime = await lottery.GetTickets(authority, lotteryId, false, false, tr
|
|
|
516
519
|
| `lotteryId` | `Number` | — | The lottery ID. |
|
|
517
520
|
| `buyer` | `{publicKey} \| false` | `false` | Optional buyer to filter by. |
|
|
518
521
|
| `group` | `Boolean` | `false` | If `true`, groups tickets by owner. |
|
|
519
|
-
| `time` | `Boolean` | `false` | If `true`,
|
|
522
|
+
| `time` | `Boolean` | `false` | If `true`, includes the block timestamp for each ticket. |
|
|
523
|
+
| `signature` | `Boolean` | `false` | If `true`, includes the transaction signature for each ticket. |
|
|
524
|
+
|
|
525
|
+
> **Note:** The `time` and `signature` options share a single RPC call per ticket, so enabling both does not double the number of requests.
|
|
520
526
|
|
|
521
527
|
**Returns (ungrouped):**
|
|
522
528
|
|
|
@@ -534,6 +540,7 @@ const withTime = await lottery.GetTickets(authority, lotteryId, false, false, tr
|
|
|
534
540
|
ticketNumber: 42,
|
|
535
541
|
ticketPda: "Pubkey...",
|
|
536
542
|
time: null, // Unix timestamp when time=true, null otherwise
|
|
543
|
+
signature: "TxSig...", // Present only when signature=true
|
|
537
544
|
},
|
|
538
545
|
// ... sorted descending by ticket number
|
|
539
546
|
],
|
package/package.json
CHANGED
package/solotto.d.ts
CHANGED
|
@@ -107,6 +107,8 @@ declare module "solotto" {
|
|
|
107
107
|
ticketPda: string;
|
|
108
108
|
/** Unix block timestamp of ticket purchase, or `null` when `time=false`. */
|
|
109
109
|
time: number | null;
|
|
110
|
+
/** Transaction signature. Present only when `signature=true`. */
|
|
111
|
+
signature?: string;
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
interface GroupedTicketOwner {
|
|
@@ -323,13 +325,14 @@ declare module "solotto" {
|
|
|
323
325
|
ticket: number
|
|
324
326
|
): Promise<TicketInfo>;
|
|
325
327
|
|
|
326
|
-
/** Fetch all tickets for a lottery, optionally filtered by buyer, grouped by owner, and/or with timestamps. */
|
|
328
|
+
/** Fetch all tickets for a lottery, optionally filtered by buyer, grouped by owner, and/or with timestamps and signatures. */
|
|
327
329
|
GetTickets(
|
|
328
330
|
authority: HasPublicKey,
|
|
329
331
|
lotteryId: number,
|
|
330
332
|
buyer?: HasPublicKey | false,
|
|
331
333
|
group?: boolean,
|
|
332
|
-
time?: boolean
|
|
334
|
+
time?: boolean,
|
|
335
|
+
signature?: boolean
|
|
333
336
|
): Promise<TicketListResult>;
|
|
334
337
|
|
|
335
338
|
/**
|
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, time = false) {
|
|
444
|
+
async GetTickets(authority, lotteryId, buyer = false, group = false, time = false, signature = false) {
|
|
445
445
|
const [lotteryPDA] = await this.DeriveLotteryPDA(authority.publicKey, lotteryId);
|
|
446
446
|
const filters = [];
|
|
447
447
|
filters.push({dataSize: 104});
|
|
@@ -460,10 +460,10 @@ class Lottery extends EventEmitter {
|
|
|
460
460
|
newTicket.ticketNumber = parseInt(new BN(decoded.ticketNumber, 10, "le"));
|
|
461
461
|
newTicket.ticketPda = data.pubkey.toString();
|
|
462
462
|
newTicket.time = null;
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
}
|
|
463
|
+
let dat = null;
|
|
464
|
+
if(time || signature){dat = await this.connection.getSignaturesForAddress(data.pubkey, "finalized");}
|
|
465
|
+
if(time){newTicket.time = dat[0].blockTime;}
|
|
466
|
+
if(signature){newTicket.signature = dat[0].signature;}
|
|
467
467
|
tickets.push(newTicket);
|
|
468
468
|
i++;
|
|
469
469
|
}
|
|
@@ -746,7 +746,7 @@ class Lottery extends EventEmitter {
|
|
|
746
746
|
// Apply filters with safety checks
|
|
747
747
|
const matchesAuthority = authority ? (item.authority && authority.publicKey.toString() === item.authority) : true;
|
|
748
748
|
const matchesLotteryId = lotteryId ? (item.lotteryId !== undefined && lotteryId.toString() === item.lotteryId.toString()) : true;
|
|
749
|
-
if(matchesAuthority && matchesLotteryId
|
|
749
|
+
if(matchesAuthority && matchesLotteryId){
|
|
750
750
|
item.time = init.blockTime;
|
|
751
751
|
item.signature = init.signature;
|
|
752
752
|
result.push(item);
|