@flayerlabs/gamemode-gate 0.6.0 → 0.7.0

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.
Files changed (58) hide show
  1. package/DEPLOY.md +7 -1
  2. package/README.md +6 -4
  3. package/dist/chain/chains.d.ts.map +1 -1
  4. package/dist/chain/chains.js +3 -1
  5. package/dist/chain/chains.js.map +1 -1
  6. package/dist/chain/signer.d.ts +19 -13
  7. package/dist/chain/signer.d.ts.map +1 -1
  8. package/dist/chain/signer.js +11 -10
  9. package/dist/chain/signer.js.map +1 -1
  10. package/dist/claims.d.ts +14 -30
  11. package/dist/claims.d.ts.map +1 -1
  12. package/dist/claims.js +55 -76
  13. package/dist/claims.js.map +1 -1
  14. package/dist/demo.d.ts +1 -1
  15. package/dist/demo.d.ts.map +1 -1
  16. package/dist/demo.js +3 -3
  17. package/dist/demo.js.map +1 -1
  18. package/dist/index.d.ts +1 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +0 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/ledger.d.ts +39 -45
  23. package/dist/ledger.d.ts.map +1 -1
  24. package/dist/ledger.js +71 -172
  25. package/dist/ledger.js.map +1 -1
  26. package/dist/room.d.ts +9 -0
  27. package/dist/room.d.ts.map +1 -1
  28. package/dist/room.js +14 -0
  29. package/dist/room.js.map +1 -1
  30. package/dist/server.d.ts +7 -0
  31. package/dist/server.d.ts.map +1 -1
  32. package/dist/server.js +40 -34
  33. package/dist/server.js.map +1 -1
  34. package/dist/settlement.d.ts +0 -3
  35. package/dist/settlement.d.ts.map +1 -1
  36. package/dist/settlement.js +12 -44
  37. package/dist/settlement.js.map +1 -1
  38. package/dist/standings.d.ts.map +1 -1
  39. package/dist/standings.js +7 -1
  40. package/dist/standings.js.map +1 -1
  41. package/dist/store.d.ts +1 -1
  42. package/dist/store.d.ts.map +1 -1
  43. package/dist/store.js +30 -19
  44. package/dist/store.js.map +1 -1
  45. package/dist/version.js +2 -2
  46. package/package.json +2 -2
  47. package/src/chain/chains.ts +3 -1
  48. package/src/chain/signer.ts +24 -30
  49. package/src/claims.ts +54 -78
  50. package/src/demo.ts +5 -5
  51. package/src/index.ts +1 -2
  52. package/src/ledger.ts +100 -248
  53. package/src/room.ts +15 -0
  54. package/src/server.ts +39 -34
  55. package/src/settlement.ts +12 -43
  56. package/src/standings.ts +9 -1
  57. package/src/store.ts +30 -19
  58. package/src/version.ts +2 -2
package/DEPLOY.md CHANGED
@@ -38,7 +38,7 @@ gate whose signatures a swap can actually verify.
38
38
  | `GATE_ORIGIN` | yes | This gate's own public https origin (e.g. `https://gate.example.com`) — the audience its sessions are scoped to. Configured, never derived from a request header. |
39
39
  | `ALLOWED_ORIGINS` | yes | Comma-separated origins allowed to call this gate: your game's Moongate origin(s) AND every page that embeds it — the coin page calls `/rounds/adopt` itself. Production is `https://flaunch.gg`; a staging or preview launch page has its own origin and needs listing while you test against it. A launch that fails with a CORS error names the missing origin in its `Referer`. |
40
40
  | `PORT` | no | Default `8790`. |
41
- | `POSITION_MANAGER`, `SPEND_GATED_CALCULATOR` | no | Which recorded stack this gate serves, or address-book overrides. Naming a recorded manager selects its whole stack (calculator and router with it): on Base Sepolia `0x8D346f24278C5CD786309161aAC0fC2bbe4c25dc` is the paired-token stack, the one that can host coins paired with MUSD and other non-ETH tokens. Unset means the legacy stack. Override both only with addresses read back from the chain in question — a wrong address fails silently (see `chain/chains.ts`). The manager named here is the gate's PRIMARY one — asserted at boot, announced in `/config`, used for the readiness proof. It is not the only one the gate serves: see "Any wired position manager" below. |
41
+ | `POSITION_MANAGER`, `SPEND_GATED_CALCULATOR` | no | Which recorded stack this gate serves, or address-book overrides. Naming a recorded manager selects its whole stack (calculator and router with it): on Base Sepolia `0x8D346f24278C5CD786309161aAC0fC2bbe4c25dc` is the paired-token stack, the one that can host coins paired with MUSD and other non-ETH tokens. Unset means the legacy stack. Override both only with addresses read back from the chain in question — a wrong address fails silently (see `chain/chains.ts`). The manager named here is the gate's PRIMARY one — asserted at boot, announced in `/config`, used for the readiness proof. It is not the only one the gate serves: see "Any wired position manager" below. A 0.7.0 gate must name the version 2 calculator (cumulative spend ceilings, domain version `2`); on Base Sepolia that is `0x8a36826253882c8b505D6D78a71B780Ac9c98eA9`, and a gate switches to it only after its last version 1 round has passed its books close. |
42
42
  | `POOL_SWAP`, `FLETH` | no | Address-book overrides for the paired stack's approved swap router and the chain's flETH wrapper. A `v1_3` or `any_v1_3` stack needs a router. |
43
43
  | `FLAUNCH_VARIANT` | no | `v1_2`, `multichain`, `v1_3` or `any_v1_3` — the PRIMARY manager's generation; recorded per stack, override only with the overrides above. Not a limit on which managers the gate adopts coins from. |
44
44
  | `SETTLER` | no | The address that may lift the gate early or rotate the signer on-chain. Defaults to the signing key's address; the gate expires on chain by itself either way. |
@@ -90,6 +90,12 @@ a generation the gate has no round model for (no `flaunchesAt()`) is refused wit
90
90
  `contracts.positionManager` and `flaunchVariant` for the primary manager. Cost: two extra reads per
91
91
  adoption (`flaunch()`, `positionManager()`); the wiring reads happen once per manager.
92
92
 
93
+ Upgrading from 0.5.x: bump all four packages together, redeploy, let `migrate()` add the one
94
+ nullable column on boot, then check `GET /config` reports `gateVersion: "0.6.0"` and
95
+ `positionManagerPolicy`. No env change and no game resubmission — the Flaunch registry fingerprints
96
+ a gate by its announced contracts and terms, not its version. Full steps in the
97
+ [production gate guide](https://github.com/flayerlabs/gamemode-sdk/blob/main/docs/guides/run-a-gate.md#upgrade-an-existing-gate-to-060).
98
+
93
99
  Release 0.5.0 removed `usdPerEth` from the wire along with the rest of the ETH-flavoured naming.
94
100
  Round terms now always carry `spendToken` (symbol, decimals, address) and `usdPerSpendToken`, the
95
101
  token's own price, and every amount is in that token's base units. Games built against 0.4.x must
package/README.md CHANGED
@@ -69,10 +69,10 @@ Add the chain services used by your deployment:
69
69
  calculator it was registered with; pass its `priceFor` and serve `announceSpendToken` so a new
70
70
  approval needs no gate change (`startGate` does both)
71
71
 
72
- In 0.5.4, pass a full viem public client (including `getBlock`) to `Settlement`. It retires consumed
73
- claims and records spend atomically after two block confirmations and the next reconciliation pass.
74
- Read-only legacy adapters keep conservative expiry-only holds. See the production gate guide's
75
- consumed purchase holds section for timing, RPC failures and upgrade instructions.
72
+ Since 0.7.0 the gate signs a cumulative spend ceiling rather than a per-purchase amount, so nothing
73
+ is held: `Settlement` reads `walletSpentWei` two blocks behind the head and records it, never
74
+ backwards, and a declined buy leaves the player's allowance where it was. See the production gate
75
+ guide's cumulative spend ceilings section for the wire shape and the deploy order.
76
76
 
77
77
  Run one gate process for each game. The current room writer does not support multiple replicas.
78
78
 
@@ -123,6 +123,8 @@ const app = createGameServerGate({
123
123
  chainId: 84532,
124
124
  contracts: {
125
125
  positionManager: '0x4E7cB1e6800a7B297B38BddcecAF9Ca5b6616FDC',
126
+ // The legacy stack's version 1 calculator. The paired stack's v2 calculator (0.7.0) is
127
+ // 0x8a36826253882c8b505D6D78a71B780Ac9c98eA9 on Base Sepolia.
126
128
  spendGatedCalculator: '0x8cbbE6b4cFA5Ccf68399Dbf1429d91A21097ebA5',
127
129
  },
128
130
  signer: signerAddress,
@@ -1 +1 @@
1
- {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/chain/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;CACvB;AAED,gGAAgG;AAChG,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAYtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA0B7D,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,GAAG,cAAc,GAAG,SAAS,CAOjH"}
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/chain/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;AAEzE,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;CACvB;AAED,gGAAgG;AAChG,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAYtD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CA4B7D,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,KAAK,MAAM,EAAE,GAAG,IAAI,GAAG,cAAc,GAAG,SAAS,CAOjH"}
@@ -62,7 +62,9 @@ export const PAIRED_DEPLOYMENTS = {
62
62
  */
63
63
  84532: {
64
64
  positionManager: '0x8D346f24278C5CD786309161aAC0fC2bbe4c25dc',
65
- spendGatedCalculator: '0x54cdcf0bcbc3a33f470e07134c10582f93058a32',
65
+ // v2 (cumulative spend ceilings, domain version 2), deployed 2026-09-14 at block 46822712 on the
66
+ // same dispatcher as v1 0x54cdcf0b…, which stays registered for pools launched before it.
67
+ spendGatedCalculator: '0x8a36826253882c8b505d6d78a71b780ac9c98ea9',
66
68
  flaunchVariant: 'v1_3',
67
69
  poolSwap: '0xf0f388a31a1745a5e2378b812ed51525f70595be',
68
70
  fleth: '0x79FC52701cD4BE6f9Ba9aDC94c207DE37e3314eb',
@@ -1 +1 @@
1
- {"version":3,"file":"chains.js","sourceRoot":"","sources":["../../src/chain/chains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAwCH,gGAAgG;AAChG,MAAM,CAAC,MAAM,WAAW,GAAmC;IACzD;;;;OAIG;IACH,KAAK,EAAE;QACL,eAAe,EAAE,4CAA4C;QAC7D,oBAAoB,EAAE,4CAA4C;QAClE,cAAc,EAAE,MAAM;QACtB,KAAK,EAAE,4CAA4C;KACpD;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAmC;IAChE;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,EAAE;QACL,eAAe,EAAE,4CAA4C;QAC7D,oBAAoB,EAAE,4CAA4C;QAClE,cAAc,EAAE,MAAM;QACtB,QAAQ,EAAE,4CAA4C;QACtD,KAAK,EAAE,4CAA4C;KACpD;CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,eAAsC;IACnF,IAAI,CAAC,eAAe;QAAE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAC7C,KAAK,MAAM,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,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1
  import { type GateReadiness } from '@flayerlabs/gamemode-spec/embed';
2
2
  /**
3
- * Issues the signed authorizations SpendGatedSignerFeeCalculator.trackSwap verifies.
3
+ * Issues the signed authorisations SpendGatedSignerFeeCalculator.trackSwap verifies.
4
4
  *
5
- * EIP-712, over the `SpendAuthorization` struct the calculator declares. It used to be an
6
- * EIP-191 personal-sign over `keccak256(abi.encodePacked(...))`, which committed to the five
7
- * fields and nothing else — no chain id, no verifying contract. An audit flagged that as the
8
- * same defect already raised against the parent calculator (M-6, remediated there in the
9
- * EIP-712 PR but never ported to this fork): the protocol deploys deterministically across
10
- * chains, so the same poolId genuinely recurs, and one signing key shared between two
11
- * environments made an authorization issued for one valid on the other. The domain closes it.
5
+ * EIP-712, over the `SpendAuthorization` struct the calculator declares, under the
6
+ * `FlaunchSpendGate` version `2` domain. The struct carries a cumulative ceiling: the most this
7
+ * buyer may EVER have spent on this pool, which the calculator compares against its own
8
+ * `walletSpentWei` accumulator. There is no nonce and no per-purchase amount, because there is
9
+ * nothing to consume — two authorisations with the same ceiling cannot add up, so reusing one is
10
+ * harmless by construction and the gate holds nothing against it.
11
+ *
12
+ * The domain matters: the protocol deploys deterministically across chains, so the same poolId
13
+ * genuinely recurs, and one signing key shared between two environments would otherwise make an
14
+ * authorisation issued for one valid on the other. Version `2` also keeps 0.5.x signatures (a
15
+ * five-field struct with a nonce) from verifying on this calculator and vice versa.
12
16
  *
13
17
  * The digest MUST match `hashSpendAuthorization` on the calculator exactly. That function is
14
18
  * public for this reason — a domain drift is otherwise a silent `InvalidSigner` at swap time
@@ -19,8 +23,7 @@ export interface SignedPayload {
19
23
  buyer: `0x${string}`;
20
24
  poolId: `0x${string}`;
21
25
  deadline: bigint;
22
- maxSpendWei: bigint;
23
- nonce: bigint;
26
+ spendCeilingWei: bigint;
24
27
  signature: `0x${string}`;
25
28
  signer: `0x${string}`;
26
29
  }
@@ -38,12 +41,15 @@ export declare class PayloadSigner {
38
41
  /** Fixed non-spend payload. The caller cannot choose a domain, type or deadline. */
39
42
  readiness(origin: string, positionManager: `0x${string}`, nonce: `0x${string}`): Promise<GateReadiness>;
40
43
  /** The digest the calculator reconstructs; mirrors its `hashSpendAuthorization`. */
41
- messageHash(buyer: `0x${string}`, poolId: `0x${string}`, deadline: bigint, maxSpendWei: bigint, nonce: bigint): `0x${string}`;
42
- sign(buyer: `0x${string}`, poolId: `0x${string}`, deadline: bigint, maxSpendWei: bigint, nonce: bigint): Promise<SignedPayload>;
44
+ messageHash(buyer: `0x${string}`, poolId: `0x${string}`, deadline: bigint, spendCeilingWei: bigint): `0x${string}`;
45
+ sign(buyer: `0x${string}`, poolId: `0x${string}`, deadline: bigint, spendCeilingWei: bigint): Promise<SignedPayload>;
43
46
  }
44
47
  /**
45
48
  * Encodes a signed payload as the hookData the swap must carry:
46
- * `abi.encode(address referrer, SignedMessage{buyer, poolId, deadline, maxSpendWei, nonce, signature})`
49
+ * `abi.encode(address referrer, SignedMessage{buyer, poolId, deadline, spendCeilingWei, signature})`
50
+ *
51
+ * The referrer word is always zero. The calculator ignores it, but the trusted page checks it, so
52
+ * a creator iframe cannot redirect attribution while keeping a valid signature.
47
53
  */
48
54
  export declare function encodeHookData(payload: SignedPayload): `0x${string}`;
49
55
  //# sourceMappingURL=signer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/chain/signer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiD,KAAK,aAAa,EAA+B,MAAM,iCAAiC,CAAC;AAEjJ;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,KAAK,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,KAAK,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AE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,KAAK,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;CACvB;AAED,qBAAa,aAAa;IAUtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAVpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C;;;;OAIG;gBAED,UAAU,EAAE,KAAK,MAAM,EAAE,EACR,OAAO,EAAE,MAAM,EACf,iBAAiB,EAAE,KAAK,MAAM,EAAE;IAKnD,IAAI,OAAO,IAAI,KAAK,MAAM,EAAE,CAE3B;IAED,oFAAoF;IAC9E,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,KAAK,MAAM,EAAE,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ7G,oFAAoF;IACpF,WAAW,CACT,KAAK,EAAE,KAAK,MAAM,EAAE,EACpB,MAAM,EAAE,KAAK,MAAM,EAAE,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,KAAK,MAAM,EAAE;IAMV,IAAI,CACR,KAAK,EAAE,KAAK,MAAM,EAAE,EACpB,MAAM,EAAE,KAAK,MAAM,EAAE,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,aAAa,CAAC;CAM1B;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,KAAK,MAAM,EAAE,CA0BpE"}
@@ -27,17 +27,20 @@ export class PayloadSigner {
27
27
  return { ...proof, signature: await this.account.signTypedData(gateReadinessTypedData(proof)) };
28
28
  }
29
29
  /** The digest the calculator reconstructs; mirrors its `hashSpendAuthorization`. */
30
- messageHash(buyer, poolId, deadline, maxSpendWei, nonce) {
31
- return hashTypedData(spendAuthorisationTypedData({ buyer, poolId, deadline, maxSpendWei, nonce }, this.chainId, this.verifyingContract));
30
+ messageHash(buyer, poolId, deadline, spendCeilingWei) {
31
+ return hashTypedData(spendAuthorisationTypedData({ buyer, poolId, deadline, spendCeilingWei }, this.chainId, this.verifyingContract));
32
32
  }
33
- async sign(buyer, poolId, deadline, maxSpendWei, nonce) {
34
- const signature = await this.account.signTypedData(spendAuthorisationTypedData({ buyer, poolId, deadline, maxSpendWei, nonce }, this.chainId, this.verifyingContract));
35
- return { buyer, poolId, deadline, maxSpendWei, nonce, signature, signer: this.account.address };
33
+ async sign(buyer, poolId, deadline, spendCeilingWei) {
34
+ const signature = await this.account.signTypedData(spendAuthorisationTypedData({ buyer, poolId, deadline, spendCeilingWei }, this.chainId, this.verifyingContract));
35
+ return { buyer, poolId, deadline, spendCeilingWei, signature, signer: this.account.address };
36
36
  }
37
37
  }
38
38
  /**
39
39
  * Encodes a signed payload as the hookData the swap must carry:
40
- * `abi.encode(address referrer, SignedMessage{buyer, poolId, deadline, maxSpendWei, nonce, signature})`
40
+ * `abi.encode(address referrer, SignedMessage{buyer, poolId, deadline, spendCeilingWei, signature})`
41
+ *
42
+ * The referrer word is always zero. The calculator ignores it, but the trusted page checks it, so
43
+ * a creator iframe cannot redirect attribution while keeping a valid signature.
41
44
  */
42
45
  export function encodeHookData(payload) {
43
46
  return encodeAbiParameters([
@@ -48,8 +51,7 @@ export function encodeHookData(payload) {
48
51
  { name: 'buyer', type: 'address' },
49
52
  { name: 'poolId', type: 'bytes32' },
50
53
  { name: 'deadline', type: 'uint256' },
51
- { name: 'maxSpendWei', type: 'uint256' },
52
- { name: 'nonce', type: 'uint256' },
54
+ { name: 'spendCeilingWei', type: 'uint256' },
53
55
  { name: 'signature', type: 'bytes' },
54
56
  ],
55
57
  },
@@ -59,8 +61,7 @@ export function encodeHookData(payload) {
59
61
  buyer: payload.buyer,
60
62
  poolId: payload.poolId,
61
63
  deadline: payload.deadline,
62
- maxSpendWei: payload.maxSpendWei,
63
- nonce: payload.nonce,
64
+ spendCeilingWei: payload.spendCeilingWei,
64
65
  signature: payload.signature,
65
66
  },
66
67
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/chain/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAsB,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AA4BjJ,MAAM,OAAO,aAAa;IAUL;IACA;IAVF,OAAO,CAAoB;IAE5C;;;;OAIG;IACH,YACE,UAAyB,EACR,OAAe,EACf,iBAAgC;QADhC,YAAO,GAAP,OAAO,CAAQ;QACf,sBAAiB,GAAjB,iBAAiB,CAAe;QAEjD,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAED,oFAAoF;IACpF,KAAK,CAAC,SAAS,CAAC,MAAc,EAAE,eAA8B,EAAE,KAAoB;QAClF,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,EAAE,OAAO,EAAE,CAAU,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,eAAe;YACjF,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,QAAQ;YAC7D,SAAS,EAAE,QAAQ,GAAG,qBAAqB,EAAE,CAAC;QAChD,OAAO,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa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AE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;gBACnC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;gBACrC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE;gBAC5C,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE;aACrC;SACF;KACF,EACD;QACE,WAAW;QACX;YACE,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,eAAe,EAAE,OAAO,CAAC,eAAe;YACxC,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B;KACF,CACF,CAAC;AACJ,CAAC"}
package/dist/claims.d.ts CHANGED
@@ -1,30 +1,16 @@
1
1
  import type { Pool } from 'pg';
2
2
  import type { PlayerId } from '@flayerlabs/gamemode-spec';
3
3
  import type { EconomyBalance } from '@flayerlabs/gamemode-spec/live';
4
- import { Ledger, type BalanceKey } from './ledger.js';
4
+ import { Ledger } from './ledger.js';
5
5
  import type { PayloadSigner, SignedPayload } from './chain/signer.js';
6
- /**
7
- * Turning points into something a player can actually spend.
8
- *
9
- * Two parties have to agree before a buy can happen, and they check different things. The ledger
10
- * knows what this player earned and what they have already been authorised for. The signer knows
11
- * whether it is willing to vouch for this pool at all. Only when both say yes does an
12
- * authorisation exist.
13
- *
14
- * The order matters and is not interchangeable: the hold is recorded first, then signed. A
15
- * signature that exists without a hold is spending nobody is tracking; a hold without a signature
16
- * is a refund waiting to happen. Only one of those costs money.
17
- */
18
- /** How long an authorisation stays valid. Long enough to approve in a wallet, short enough that an
19
- * abandoned one does not sit around spendable. */
20
- export declare const CLAIM_AUTHORIZATION_TTL_MS: number;
21
6
  /** Request ids cross an unauthenticated parser before they reach Postgres, so bound them here too. */
22
7
  export declare function isClaimRequestId(value: unknown): value is string;
23
8
  /** The signed message carries uint256, while JavaScript's bigint has no upper bound. */
24
9
  export declare function isClaimAmount(value: unknown): value is bigint;
25
10
  export type Authorisation = {
26
11
  ok: true;
27
- payload: SignedPayload;
12
+ payload: SignedPayload; /** Exact-in amount for this buy, clamped to what was available. */
13
+ spend: bigint;
28
14
  } | {
29
15
  ok: false;
30
16
  refuse: string;
@@ -33,27 +19,25 @@ export declare class Claims {
33
19
  private readonly pool;
34
20
  private readonly ledger;
35
21
  private readonly signer;
36
- /** Called when a hold could neither be signed nor released, and needs a human. */
37
- private readonly onStrandedHold?;
38
22
  /** An internal seam for exact window-boundary tests. Production uses the process clock. */
39
23
  private readonly now;
40
24
  constructor(pool: Pool, ledger: Ledger, signer: PayloadSigner,
41
- /** Called when a hold could neither be signed nor released, and needs a human. */
42
- onStrandedHold?: ((nonce: bigint, error: unknown) => void) | undefined,
43
25
  /** An internal seam for exact window-boundary tests. Production uses the process clock. */
44
26
  now?: () => number);
45
27
  /**
46
- * Authorise a player to spend up to `upToWei`, or explain why not.
28
+ * Authorise a player to spend up to `spendWei`, or explain why not.
47
29
  *
48
- * The ledger's ceiling is a conservative mirror of the chain's: the contract tracks
49
- * `walletSpentWei` per pool per wallet and enforces it whatever we believe. Being ahead of the
50
- * chain is safe — we simply authorise less than we could. Being behind it would mean issuing a
51
- * signature that reverts at the swap, which to a player is indistinguishable from being robbed.
30
+ * Returns the largest amount available rather than refusing an over-ask: a player pressing buy
31
+ * wants to spend what they have, and telling them "you asked for too much" when they asked for
32
+ * everything is a worse product than giving them everything. The ceiling in the signature is the
33
+ * same either way — it is what they have earned, not what they asked for.
34
+ *
35
+ * The ledger's view of spend is a conservative mirror of the chain's. Being behind it means
36
+ * signing a ceiling the calculator will refuse at the swap, which to a player is
37
+ * indistinguishable from being robbed; settlement keeps the gap to one reconciliation pass.
52
38
  */
53
- authorise(roundId: string, player: PlayerId, upToWei: bigint, requestId: string): Promise<Authorisation>;
54
- private finish;
55
- /** Give back every authorisation that expired unspent. */
56
- releaseExpired(): Promise<BalanceKey[]>;
39
+ authorise(roundId: string, player: PlayerId, spendWei: bigint, requestId: string): Promise<Authorisation>;
40
+ private answer;
57
41
  /** What this player could spend right now. */
58
42
  available(roundId: string, player: PlayerId): Promise<bigint>;
59
43
  /** Full authoritative balance for live snapshots. */
@@ -1 +1 @@
1
- {"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../src/claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EAAE,MAAM,EAAE,KAAK,UAAU,EAAc,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEtE;;;;;;;;;;;GAWG;AAEH;mDACmD;AACnD,eAAO,MAAM,0BAA0B,QAAa,CAAC;AAIrD,sGAAsG;AACtG,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEhE;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE7D;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GACpC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,kFAAkF;IAClF,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,2FAA2F;IAC3F,OAAO,CAAC,QAAQ,CAAC,GAAG;g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AM,MAAM,aAAa,GACrB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,aAAa,CAAC,CAAC,mEAAmE;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvH;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC,qBAAa,MAAM;IAEf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,2FAA2F;IAC3F,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAJH,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa;IACtC,2FAA2F;IAC1E,GAAG,GAAE,MAAM,MAAiB;IAG/C;;;;;;;;;;;OAWG;IACG,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAgC/G,OAAO,CAAC,MAAM;IAgBd,8CAA8C;IAC9C,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC;IAI7D,qDAAqD;IACrD,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC;CAG3E"}
package/dist/claims.js CHANGED
@@ -4,18 +4,15 @@ import { Ledger } from './ledger.js';
4
4
  * Turning points into something a player can actually spend.
5
5
  *
6
6
  * Two parties have to agree before a buy can happen, and they check different things. The ledger
7
- * knows what this player earned and what they have already been authorised for. The signer knows
8
- * whether it is willing to vouch for this pool at all. Only when both say yes does an
9
- * authorisation exist.
7
+ * knows what this player earned and what the chain says they have spent. The signer knows whether
8
+ * it is willing to vouch for this pool at all. Only when both say yes does an authorisation exist.
10
9
  *
11
- * The order matters and is not interchangeable: the hold is recorded first, then signed. A
12
- * signature that exists without a hold is spending nobody is tracking; a hold without a signature
13
- * is a refund waiting to happen. Only one of those costs money.
10
+ * What gets signed is a ceiling, not a purchase: the most this wallet may ever have spent on the
11
+ * pool. The calculator compares it against its own running total, so the gate reserves nothing
12
+ * and a signature that is never used costs nobody anything. The one thing this file must get
13
+ * right is idempotency — a retried request must receive the same bytes — and that is a primary
14
+ * key, not a lock.
14
15
  */
15
- /** How long an authorisation stays valid. Long enough to approve in a wallet, short enough that an
16
- * abandoned one does not sit around spendable. */
17
- export const CLAIM_AUTHORIZATION_TTL_MS = 5 * 60_000;
18
- const DEADLINE_SECONDS = CLAIM_AUTHORIZATION_TTL_MS / 1_000;
19
16
  const REQUEST_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;
20
17
  /** Request ids cross an unauthenticated parser before they reach Postgres, so bound them here too. */
21
18
  export function isClaimRequestId(value) {
@@ -29,79 +26,74 @@ export class Claims {
29
26
  pool;
30
27
  ledger;
31
28
  signer;
32
- onStrandedHold;
33
29
  now;
34
30
  constructor(pool, ledger, signer,
35
- /** Called when a hold could neither be signed nor released, and needs a human. */
36
- onStrandedHold,
37
31
  /** An internal seam for exact window-boundary tests. Production uses the process clock. */
38
32
  now = Date.now) {
39
33
  this.pool = pool;
40
34
  this.ledger = ledger;
41
35
  this.signer = signer;
42
- this.onStrandedHold = onStrandedHold;
43
36
  this.now = now;
44
37
  }
45
38
  /**
46
- * Authorise a player to spend up to `upToWei`, or explain why not.
39
+ * Authorise a player to spend up to `spendWei`, or explain why not.
47
40
  *
48
- * The ledger's ceiling is a conservative mirror of the chain's: the contract tracks
49
- * `walletSpentWei` per pool per wallet and enforces it whatever we believe. Being ahead of the
50
- * chain is safe — we simply authorise less than we could. Being behind it would mean issuing a
51
- * signature that reverts at the swap, which to a player is indistinguishable from being robbed.
41
+ * Returns the largest amount available rather than refusing an over-ask: a player pressing buy
42
+ * wants to spend what they have, and telling them "you asked for too much" when they asked for
43
+ * everything is a worse product than giving them everything. The ceiling in the signature is the
44
+ * same either way — it is what they have earned, not what they asked for.
45
+ *
46
+ * The ledger's view of spend is a conservative mirror of the chain's. Being behind it means
47
+ * signing a ceiling the calculator will refuse at the swap, which to a player is
48
+ * indistinguishable from being robbed; settlement keeps the gap to one reconciliation pass.
52
49
  */
53
- async authorise(roundId, player, upToWei, requestId) {
50
+ async authorise(roundId, player, spendWei, requestId) {
54
51
  if (!isClaimRequestId(requestId))
55
52
  return { ok: false, refuse: 'claim.request_invalid' };
56
- if (!isClaimAmount(upToWei))
53
+ if (!isClaimAmount(spendWei))
57
54
  return { ok: false, refuse: 'claim.amount_invalid' };
58
55
  const round = await this.pool.query(`select pool_id from rounds where id = $1`, [roundId]);
59
56
  const row = round.rows[0];
60
57
  if (!row)
61
58
  return { ok: false, refuse: 'claim.no_such_round' };
62
- // The deadline is decided before the hold so both agree on when it stops being spendable.
63
- const now = this.now();
64
- const deadline = BigInt(Math.floor(now / 1000) + DEADLINE_SECONDS);
65
- // Idempotency and the clock are decided under the same player lock. If an accepted request is
66
- // still committing at the buzzer, a retry waits for it and recovers it rather than observing
67
- // no row outside the transaction and being refused as a new, late request.
68
- const held = await this.ledger.claim(roundId, player, upToWei, requestId, deadline, now);
69
- if (!held.ok)
70
- return { ok: false, refuse: held.refuse };
71
- // Another replica may have completed the request while this one waited for the balance lock.
72
- if (held.claim.signature && held.claim.signer) {
73
- return { ok: true, payload: payload(row.pool_id, held.claim) };
74
- }
75
- if (held.claim.status === 'released')
76
- return { ok: false, refuse: 'claim.request_released' };
77
- return this.finish(row.pool_id, held.claim);
78
- }
79
- async finish(poolId, claim) {
80
- try {
81
- const candidate = await this.signer.sign(claim.player, poolId, claim.deadline, claim.wei, claim.nonce);
82
- // Never return bytes that were not durably recorded. Concurrent signers both return the one
83
- // stored winner, so retries stay byte-identical even if an implementation signs randomly.
84
- const completed = await this.ledger.completeClaim(claim.nonce, candidate.signature, candidate.signer);
85
- if (!completed?.signature || !completed.signer)
86
- throw new Error('claim could not be completed');
87
- return { ok: true, payload: payload(poolId, completed) };
88
- }
89
- catch (error) {
90
- // The hold was taken and nothing will ever be spent against it, so it goes back. Without
91
- // this, a signer outage quietly eats a player's allowance for the rest of the round.
92
- //
93
- // If the release ALSO fails, the original error still wins. Replacing it with a database
94
- // error would hide the reason and leave the nonce nowhere in the logs — so it is named here,
95
- // because that number is what a person needs to give the allowance back by hand.
96
- await this.ledger.releaseUnsigned(claim.nonce).catch((releaseError) => {
97
- this.onStrandedHold?.(claim.nonce, releaseError);
98
- });
99
- throw error;
100
- }
59
+ const poolId = row.pool_id;
60
+ // An existing request deliberately wins over the clock and the current balance: it was issued
61
+ // under the earlier call's window, and a retry must get the same answer.
62
+ const existing = await this.ledger.findAuthorisation(roundId, player, requestId);
63
+ if (existing)
64
+ return this.answer(poolId, existing, spendWei);
65
+ const quote = await this.ledger.quote(roundId, player, this.now());
66
+ if (!quote.ok)
67
+ return { ok: false, refuse: quote.refuse };
68
+ const spend = spendWei < quote.available ? spendWei : quote.available;
69
+ const signed = await this.signer.sign(player, poolId, quote.deadlineSeconds, quote.ceiling);
70
+ const stored = await this.ledger.storeAuthorisation(roundId, {
71
+ player,
72
+ requestId,
73
+ requestedWei: spendWei,
74
+ spendCeilingWei: signed.spendCeilingWei,
75
+ spendWei: spend,
76
+ deadline: signed.deadline,
77
+ signature: signed.signature,
78
+ signer: signed.signer,
79
+ });
80
+ return this.answer(poolId, stored, spendWei);
101
81
  }
102
- /** Give back every authorisation that expired unspent. */
103
- releaseExpired() {
104
- return this.ledger.releaseExpired(Math.floor(this.now() / 1000));
82
+ answer(poolId, stored, requestedWei) {
83
+ if (stored.requestedWei !== requestedWei)
84
+ return { ok: false, refuse: 'claim.request_mismatch' };
85
+ return {
86
+ ok: true,
87
+ payload: {
88
+ buyer: stored.player,
89
+ poolId,
90
+ deadline: stored.deadline,
91
+ spendCeilingWei: stored.spendCeilingWei,
92
+ signature: stored.signature,
93
+ signer: stored.signer,
94
+ },
95
+ spend: stored.spendWei,
96
+ };
105
97
  }
106
98
  /** What this player could spend right now. */
107
99
  available(roundId, player) {
@@ -112,17 +104,4 @@ export class Claims {
112
104
  return this.ledger.economyBalance(roundId, player);
113
105
  }
114
106
  }
115
- function payload(poolId, claim) {
116
- if (!claim.signature || !claim.signer)
117
- throw new Error('claim is not signed');
118
- return {
119
- buyer: claim.player,
120
- poolId: poolId,
121
- deadline: claim.deadline,
122
- maxSpendWei: claim.wei,
123
- nonce: claim.nonce,
124
- signature: claim.signature,
125
- signer: claim.signer,
126
- };
127
- }
128
107
  //# sourceMappingURL=claims.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"claims.js","sourceRoot":"","sources":["../src/claims.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,MAAM,EAA+B,MAAM,aAAa,CAAC;AAGlE;;;;;;;;;;;GAWG;AAEH;mDACmD;AACnD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,GAAG,MAAM,CAAC;AACrD,MAAM,gBAAgB,GAAG,0BAA0B,GAAG,KAAK,CAAC;AAC5D,MAAM,UAAU,GAAG,qCAAqC,CAAC;AAEzD,sGAAsG;AACtG,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,GAAG,EAAE,IAAI,KAAK,IAAI,UAAU,CAAC;AACxE,CAAC;AAMD,MAAM,OAAO,MAAM;IAEE;IACA;IACA;IAEA;IAEA;IAPnB,YACmB,IAAU,EACV,MAAc,EACd,MAAqB;IACtC,kFAAkF;IACjE,cAAwD;IACzE,2FAA2F;IAC1E,MAAoB,I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YACzB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAEO,MAAM,CAAC,MAAqB,EAAE,MAA2B,EAAE,YAAoB;QACrF,IAAI,MAAM,CAAC,YAAY,KAAK,YAAY;YAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,wBAAwB,EAAE,CAAC;QACjG,OAAO;YACL,EAAE,EAAE,IAAI;YACR,OAAO,EAAE;gBACP,KAAK,EAAE,MAAM,CAAC,MAAuB;gBACrC,MAAM;gBACN,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB;YACD,KAAK,EAAE,MAAM,CAAC,QAAQ;SACvB,CAAC;IACJ,CAAC;IAED,8CAA8C;IAC9C,SAAS,CAAC,OAAe,EAAE,MAAgB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,qDAAqD;IACrD,cAAc,CAAC,OAAe,EAAE,MAAgB;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACrD,CAAC;CACF"}
package/dist/demo.d.ts CHANGED
@@ -31,7 +31,7 @@ export interface Demo {
31
31
  walletAddress: `0x${string}`;
32
32
  /** Everything the fake wallet was asked to buy, in order. Empty until somebody buys. */
33
33
  purchases: {
34
- maxSpendWei: string;
34
+ spend: string;
35
35
  at: number;
36
36
  }[];
37
37
  pool: pg.Pool;
@@ -1 +1 @@
1
- {"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../src/demo.ts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AE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC3C,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;CACf;AAID;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EACvF,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,CAAC,GACzE,OAAO,CAAC,IAAI,CAAC,CAmGf"}
package/dist/demo.js CHANGED
@@ -103,9 +103,9 @@ export async function createDemoGate(options) {
103
103
  signature: await wallet.signMessage({ message: request.body.message }),
104
104
  }));
105
105
  app.post('/dev/wallet/buy', (request) => {
106
- const { maxSpendWei } = request.body;
107
- purchases.push({ maxSpendWei, at: Date.now() });
108
- return { spent: maxSpendWei };
106
+ const { spend } = request.body;
107
+ purchases.push({ spend, at: Date.now() });
108
+ return { spent: spend };
109
109
  });
110
110
  return { app, roundId, opensAt, walletAddress: wallet.address, purchases, pool };
111
111
  }
package/dist/demo.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"demo.js","sourceRoot":"","sources":["../src/demo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAA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AE,CAAC;IAEtD,+FAA+F;IAC/F,0FAA0F;IAC1F,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5D,GAAG,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/C,SAAS,EAAE,MAAM,MAAM,CAAC,WAAW,CAAC,EAAE,OAAO,EAAG,OAAO,CAAC,IAA4B,CAAC,OAAO,EAAE,CAAC;KAChG,CAAC,CAAC,CAAC;IACJ,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,EAAE;QACtC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,IAAyB,CAAC;QACpD,SAAS,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC1C,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACnF,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,8 +4,7 @@ export type { Admission, AdmissionRequest, Admit, AnnouncedSpendToken, ConfigFor
4
4
  export { createTurnstileAdmit } from './turnstile.js';
5
5
  export type { TurnstileAdmitOptions } from './turnstile.js';
6
6
  export { Ledger } from './ledger.js';
7
- export type { BalanceKey, Claim, ClaimResult } from './ledger.js';
8
- export { CLAIM_AUTHORIZATION_TTL_MS } from './claims.js';
7
+ export type { Authorisation, Quote } from './ledger.js';
9
8
  export { PayloadSigner, encodeHookData } from './chain/signer.js';
10
9
  export type { SignedPayload } from './chain/signer.js';
11
10
  export { Discovery, WiringCache, poolIdOf, resolvePositionManager, verifyLaunch } from './chain/discover.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,MAAM,EACN,0BAA0B,EAC1B,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,KAAK,EACL,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,cAAc,GACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7G,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,a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M,WAAW,CAAC;AACxG,YAAY,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACnF,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC1G,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAExH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
  export { Claims, DEFAULT_SETTLEMENT_TAIL_MS, Room, Sessions, createGate, createGameServerGate, } from './server.js';
3
3
  export { createTurnstileAdmit } from './turnstile.js';
4
4
  export { Ledger } from './ledger.js';
5
- export { CLAIM_AUTHORIZATION_TTL_MS } from './claims.js';
6
5
  export { PayloadSigner, encodeHookData } from './chain/signer.js';
7
6
  export { Discovery, WiringCache, poolIdOf, resolvePositionManager, verifyLaunch } from './chain/discover.js';
8
7
  export { Settlement } from './settlement.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EACL,MAAM,EAC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