solotto 1.1.2 → 1.1.4
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 +37 -1
- package/package.json +1 -1
- package/solotto.d.ts +19 -0
- package/solotto.js +40 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ A JavaScript SDK for interacting with the Solotto on-chain lottery program on So
|
|
|
24
24
|
- [ClaimTicket](#claimticket)
|
|
25
25
|
- [Boost](#boost)
|
|
26
26
|
- [GetBoosters](#getboosters)
|
|
27
|
+
- [GetMessages](#getmessages)
|
|
27
28
|
- [GetLottery](#getlottery)
|
|
28
29
|
- [GetLotteries](#getlotteries)
|
|
29
30
|
- [GetTicket](#getticket)
|
|
@@ -311,7 +312,7 @@ const result = await lottery.Boost(authority, lotteryId, booster, 1.0, "Good luc
|
|
|
311
312
|
|
|
312
313
|
#### GetBoosters
|
|
313
314
|
|
|
314
|
-
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.
|
|
315
316
|
|
|
316
317
|
```js
|
|
317
318
|
// Get all boosters for a specific lottery
|
|
@@ -366,6 +367,41 @@ const grouped = await lottery.GetBoosters(authority, lotteryId, true);
|
|
|
366
367
|
|
|
367
368
|
---
|
|
368
369
|
|
|
370
|
+
#### GetMessages
|
|
371
|
+
|
|
372
|
+
Retrieves boost memo messages from on-chain transaction history. Paginates through program signatures and extracts messages from transactions tagged with `:booster:`. Useful for displaying a feed of booster shoutouts.
|
|
373
|
+
|
|
374
|
+
```js
|
|
375
|
+
// Get the latest boost messages (up to 1000)
|
|
376
|
+
const messages = await lottery.GetMessages();
|
|
377
|
+
|
|
378
|
+
// Get up to 200 messages
|
|
379
|
+
const recent = await lottery.GetMessages(200);
|
|
380
|
+
|
|
381
|
+
// Paginate: get messages until a specific signature
|
|
382
|
+
const older = await lottery.GetMessages(1000, "LastKnownSignature...");
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
| Parameter | Type | Default | Description |
|
|
386
|
+
|---|---|---|---|
|
|
387
|
+
| `limit` | `Number` | `1000` | Maximum number of transactions to scan. Paginates automatically if needed. |
|
|
388
|
+
| `until` | `String \| null` | `null` | Stop scanning at this transaction signature (exclusive). Useful for pagination. |
|
|
389
|
+
|
|
390
|
+
**Returns:** An array of message objects:
|
|
391
|
+
|
|
392
|
+
```js
|
|
393
|
+
[
|
|
394
|
+
{
|
|
395
|
+
message: "Good luck everyone!", // The booster's memo text
|
|
396
|
+
time: 1700000000, // Unix block timestamp
|
|
397
|
+
signature: "TxSignature...", // Transaction signature
|
|
398
|
+
},
|
|
399
|
+
// ...
|
|
400
|
+
]
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
369
405
|
#### GetLottery
|
|
370
406
|
|
|
371
407
|
Fetches the full on-chain state of a lottery.
|
package/package.json
CHANGED
package/solotto.d.ts
CHANGED
|
@@ -181,6 +181,15 @@ declare module "solotto" {
|
|
|
181
181
|
[boosterAddress: string]: GroupedBooster;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
interface MessageRecord {
|
|
185
|
+
/** The booster's memo text. */
|
|
186
|
+
message: string;
|
|
187
|
+
/** Unix block timestamp of the transaction. */
|
|
188
|
+
time: number;
|
|
189
|
+
/** Transaction signature. */
|
|
190
|
+
signature: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
184
193
|
// ── Authority-like objects ────────────────────────────────────────────
|
|
185
194
|
|
|
186
195
|
/** An object with at least a `publicKey` property (e.g. a Keypair without the secret key). */
|
|
@@ -367,6 +376,16 @@ declare module "solotto" {
|
|
|
367
376
|
limit?: number
|
|
368
377
|
): Promise<BoosterRecord[] | GroupedBoostersResult>;
|
|
369
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Retrieve boost memo messages from on-chain transaction history.
|
|
381
|
+
* @param limit - Maximum number of transactions to scan (paginates automatically).
|
|
382
|
+
* @param until - Stop scanning at this transaction signature (exclusive).
|
|
383
|
+
*/
|
|
384
|
+
GetMessages(
|
|
385
|
+
limit?: number,
|
|
386
|
+
until?: string | null
|
|
387
|
+
): Promise<MessageRecord[]>;
|
|
388
|
+
|
|
370
389
|
/** Derive the lottery PDA. */
|
|
371
390
|
DeriveLotteryPDA(
|
|
372
391
|
authority: PublicKey,
|
package/solotto.js
CHANGED
|
@@ -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);
|
|
@@ -774,6 +774,45 @@ class Lottery extends EventEmitter {
|
|
|
774
774
|
catch (error) {return error;}
|
|
775
775
|
}
|
|
776
776
|
|
|
777
|
+
/**
|
|
778
|
+
* @param {Number} limit - the results to request (max 1000)
|
|
779
|
+
* @param {String} until - until signature to stop at (optional)
|
|
780
|
+
* @returns {Array|Object} - Array of booster objects or grouped booster objects if group=true
|
|
781
|
+
*/
|
|
782
|
+
async GetMessages(limit = 1000, until = null) {
|
|
783
|
+
try {
|
|
784
|
+
const result = [];
|
|
785
|
+
let allSignatures = [];
|
|
786
|
+
let lastSignature = null;
|
|
787
|
+
while (allSignatures.length < limit) {
|
|
788
|
+
const options = {limit: Math.min(1000, limit - allSignatures.length)};
|
|
789
|
+
if (lastSignature) {options.before = lastSignature;}
|
|
790
|
+
if (until) {options.until = until;}
|
|
791
|
+
const signatures = await this.connection.getSignaturesForAddress(this.program, options);
|
|
792
|
+
if (signatures.length === 0) break;
|
|
793
|
+
allSignatures.push(...signatures);
|
|
794
|
+
lastSignature = signatures[signatures.length - 1].signature;
|
|
795
|
+
if (signatures.length < options.limit) break;
|
|
796
|
+
}
|
|
797
|
+
for (const row of allSignatures) {
|
|
798
|
+
if (!row.err &&
|
|
799
|
+
row.confirmationStatus === "finalized" &&
|
|
800
|
+
row.memo &&
|
|
801
|
+
row.memo.includes(":booster:")) {
|
|
802
|
+
const memo = {
|
|
803
|
+
message: row.memo.split(":booster:")[1].trim(),
|
|
804
|
+
time: row.blockTime,
|
|
805
|
+
signature: row.signature
|
|
806
|
+
};
|
|
807
|
+
result.push(memo);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return result;
|
|
811
|
+
} catch (error) {
|
|
812
|
+
return error;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
777
816
|
}
|
|
778
817
|
|
|
779
818
|
class LotteryManager {
|