prizerail 1.2.0 → 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/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/package.json +1 -1
- package/plugins/prizerail/.claude-plugin/plugin.json +1 -1
- package/plugins/prizerail/skills/prizerail-check/SKILL.md +1 -0
- package/plugins/prizerail/skills/prizerail-draw/SKILL.md +6 -1
- package/plugins/prizerail/skills/prizerail-integrate/SKILL.md +15 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Http } from "./http.js";
|
|
2
2
|
import type { Campaign, Drawing, DrawingRef, DrawingStatus, DrawingsPage, Entrant, EntrantEvent, EntrantLookup, EntriesPage, Guarantee, SendEntriesResponse, SentEntrant } from "./types.js";
|
|
3
3
|
import { type DrawProof, type VerifyResult } from "./verify.js";
|
|
4
|
-
export declare const VERSION = "1.2.
|
|
4
|
+
export declare const VERSION = "1.2.1";
|
|
5
5
|
/** The API takes up to this many entries per request. */
|
|
6
6
|
export declare const ENTRIES_PER_REQUEST = 1000;
|
|
7
7
|
export type PrizerailOptions = {
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PrizerailCutoffError, PrizerailDrawingChangedError, PrizerailError, } from "./errors.js";
|
|
2
2
|
import { Http } from "./http.js";
|
|
3
3
|
import { verifyDraw } from "./verify.js";
|
|
4
|
-
export const VERSION = "1.2.
|
|
4
|
+
export const VERSION = "1.2.1";
|
|
5
5
|
const badPage = (detail) => new PrizerailError(0, "invalid_response", `Paging stopped: ${detail}.`);
|
|
6
6
|
/** The API takes up to this many entries per request. */
|
|
7
7
|
export const ENTRIES_PER_REQUEST = 1000;
|
package/package.json
CHANGED
|
@@ -32,6 +32,7 @@ It prints `✓` for a passing check, `✗` for a failing one, and `i` for a note
|
|
|
32
32
|
- **No entries in the open drawing** with a passing key and campaign: the sender hasn't run yet, or it's pointed at another campaign or the other environment. Check `PRIZERAIL_CAMPAIGN` and the key's prefix against the site.
|
|
33
33
|
- **Entries in the last drawing but not this one:** entries land in the drawing whose cutoff is next when they arrive, and totals don't carry over. A daily job must run before each cutoff.
|
|
34
34
|
- **Every entrant at 1 entry** when the app rewards actions: set mode sends each entrant's total, so `entries` has to be sent every time. Or the app meant increment mode.
|
|
35
|
+
- **One user's entries missing:** look that id up with `campaign.drawings.entrant(drawingId, entrantId)`, or `GET /api/v1/campaigns/{slug}/drawings/{id}/entrant?entrantId=…` with a `+` sent as `%2B`. `entered: false` is a `200`, not an error: the entries went to another drawing, or never arrived.
|
|
35
36
|
- **Fewer entrants than expected:** the eligibility filter, or an `eventId` reused across different events (`409 event_conflict`, nothing in that request stored). Look at the sender's logs for `409`s.
|
|
36
37
|
- **A sandbox draw with winners:** the integration works end to end. `npx prizerail verify <slug> <drawing id>` checks any draw again from its public proof.
|
|
37
38
|
|
|
@@ -5,7 +5,7 @@ description: "Check the status of a Prizerail campaign's draws (whether a draw i
|
|
|
5
5
|
|
|
6
6
|
# Prizerail draws: status and verification
|
|
7
7
|
|
|
8
|
-
Prizerail runs prize draws for partner apps. Through each period the partner sends Prizerail its entrants. At the cutoff Prizerail locks the entrant list, a random value draws the winners from it and decides each winner's prize from the campaign's prize table, and the prizes are sent to the partner to pay out. Everything below uses public endpoints
|
|
8
|
+
Prizerail runs prize draws for partner apps. Through each period the partner sends Prizerail its entrants. At the cutoff Prizerail locks the entrant list, a random value draws the winners from it and decides each winner's prize from the campaign's prize table, and the prizes are sent to the partner to pay out. Everything below uses public endpoints, with no keys or accounts, except the one lookup marked as needing the partner's API key.
|
|
9
9
|
|
|
10
10
|
**Never compute the hashes yourself.** keccak256 can't be done reliably by reasoning, and Python's `hashlib.sha3_256` is a different hash (different padding) that gives different answers. Run the verify script below and report what it prints.
|
|
11
11
|
|
|
@@ -96,6 +96,11 @@ If the user can't run code, the campaign page has a "Verify in your browser" but
|
|
|
96
96
|
|
|
97
97
|
To cross-check with a library instead, viem's `keccak256(encodeAbiParameters(...))` with the types above gives the same values.
|
|
98
98
|
|
|
99
|
+
## Check someone was in a draw
|
|
100
|
+
|
|
101
|
+
- **With no key:** once a draw is drawn, `verifyDraw(proofUrl)` and then `wasEntered(entrantId, result.entrants)` from the `prizerail` package find their row in the published list. Only read the answer when `result.ok` is true and `result.entrants` is there: `verifyDraw` still returns the rows when a check fails, and `wasEntered` only searches them. Otherwise say their entry couldn't be verified, not that they weren't in it. That is the independent check, and it gives their `entries` and index only.
|
|
102
|
+
- **With the partner's API key:** `new Prizerail({ apiKey }).campaign(slug).drawings.entrant(drawingId, entrantId)`, which picks the site from the key, or `GET /api/v1/campaigns/{slug}/drawings/{id}/entrant?entrantId=…` with a `+` sent as `%2B`, on the key's own site (`https://sandbox.prizerail.com` for a `pr_sandbox_` key), says what Prizerail received for any drawing, open ones too, and what they won. It is Prizerail's own record, not an independent check. `entered: false` is an answer, not an error. `winner` is `null` for everyone until `drawn` is true, so check `drawn` before reading a `null` winner as a loss, and a `skipped` drawing was never drawn. In a guarantee draw everyone has 1 entry.
|
|
103
|
+
|
|
99
104
|
## Gotchas
|
|
100
105
|
|
|
101
106
|
- **The index is the order, not the row.** A shuffled `entrants.json` gives the same root and winners. A duplicate, missing or out-of-range index makes the list invalid, and the verify script reports it.
|
|
@@ -167,6 +167,21 @@ Write them in the project's own test framework. Each one guards a rule above:
|
|
|
167
167
|
|
|
168
168
|
With a `pr_sandbox_` key and a sandbox campaign, send a few entrants and then run `npx prizerail check <slug> --draw` (the `prizerail-check` skill). It checks the key, the campaign and what was sent, then **draws now**: the drawing locks, settles and pays within seconds, and its proof is verified, so the whole integration is seen to pass. Draw now consumes the drawing's entries and opens a fresh, empty one, so send entries again before any second draw. To draw by hand instead, use `campaign.drawings.run(drawingId)` in the SDK, `POST /campaigns/{slug}/drawings/{id}/run`, or the **Draw now** button on the drawing in the sandbox portal, then `campaign.drawings.latest()` shows the winners and `npx prizerail verify <slug> <drawing id>` checks the proof.
|
|
169
169
|
|
|
170
|
+
## 9. When a user asks whether their entries counted
|
|
171
|
+
|
|
172
|
+
Look them up in that drawing rather than paging `entries.all()`, from the server like every call with the key. The drawing taking entries now is `(await campaign.entries.openDrawing()).id`, or `drawing.id` from a `send()` result. Earlier ones come from `campaign.drawings.list()`, newest first, and open ones from `campaign.drawings.list({ status: "open" })`, soonest cutoff first, so the next one is the open drawing after it.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const entrantId = await hashEntrant(user.id, process.env.ENTRANT_ID_KEY!)
|
|
176
|
+
const found = await campaign.drawings.entrant(drawingId, entrantId)
|
|
177
|
+
// { drawing, entrantId, entered, entries, position, receivedAt, drawn, winner }
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
- `entered: false` is an answer, not an error: entries sent after the cutoff went to the next drawing, and ones that failed to send aren't anywhere. Check the next drawing and the sender's logs.
|
|
181
|
+
- `winner` is `null` for everyone until `drawn` is true, so check `drawn` before reading a `null` winner as a loss. A `skipped` drawing (`drawing.status`) was never drawn, so there's no winner to wait for.
|
|
182
|
+
- `position` is `null` until the drawing locks. In a guarantee draw (`drawing.kind` is `"guarantee"`) everyone has 1 entry, `position` is set from the start, and `receivedAt` is when the guarantee draw was made.
|
|
183
|
+
- Plain HTTP: `GET {base}/campaigns/{slug}/drawings/{id}/entrant?entrantId=…`, URL-encoded, so a `+` goes as `%2B`. A bare `+` reads as a space, and the lookup finds no one.
|
|
184
|
+
|
|
170
185
|
## Checklist before handing back
|
|
171
186
|
|
|
172
187
|
- [ ] Mode chosen and explained in a comment at the sender
|