@vllnt/convex-wallet 0.1.0 → 0.1.1-canary.24a9a6a
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/CHANGELOG.md +119 -0
- package/README.md +128 -34
- package/dist/component/crons.d.ts +4 -4
- package/dist/component/crons.js +6 -6
- package/dist/component/crons.js.map +1 -1
- package/dist/component/internal_mutations.d.ts.map +1 -1
- package/dist/component/internal_mutations.js +5 -1
- package/dist/component/internal_mutations.js.map +1 -1
- package/dist/component/mutations.d.ts.map +1 -1
- package/dist/component/mutations.js +44 -10
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.js +3 -3
- package/dist/component/queries.js.map +1 -1
- package/dist/shared.d.ts +36 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +52 -8
- package/dist/shared.js.map +1 -1
- package/docs/API.md +174 -0
- package/llms.txt +45 -0
- package/package.json +46 -24
- package/src/component/crons.ts +6 -6
- package/src/component/internal_mutations.ts +6 -1
- package/src/component/mutations.ts +65 -11
- package/src/component/queries.ts +3 -3
- package/src/shared.ts +61 -8
- package/src/test.ts +2 -1
- package/src/component/component.test.ts +0 -112
- package/src/react/index.test.tsx +0 -61
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format is based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
|
|
5
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.1] - Unreleased
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- The ledger retention sweep schedules an immediate continuation when a run fills its batch, so a
|
|
12
|
+
backlog larger than one batch drains in one sweep instead of draining at most one batch per hour.
|
|
13
|
+
- `earn` and the receiver leg of `transfer` could lower a balance: when a
|
|
14
|
+
currency's `max` was below the stored balance (for example after the host
|
|
15
|
+
lowered it), the credit clamped down to `max`, debiting the subject and
|
|
16
|
+
writing a negative `delta`. A credit now never lowers a balance; it is a no-op
|
|
17
|
+
ledger row with `delta` 0.
|
|
18
|
+
- An `idempotencyKey` recorded by a credit and reused on a debit (or the
|
|
19
|
+
reverse) for the same subject and currency was treated as a replay, silently
|
|
20
|
+
skipping the second operation. It now throws `IDEMPOTENCY_KEY_REUSED`.
|
|
21
|
+
- Credits that would push a balance or `lifetimeEarned` past 2^53 - 1 (where
|
|
22
|
+
numbers lose precision) throw `BALANCE_OVERFLOW`; amounts above 2^53 - 1 throw
|
|
23
|
+
`INVALID_AMOUNT`.
|
|
24
|
+
- A `NaN` or negative `max` (which could store a `NaN` balance) throws
|
|
25
|
+
`INVALID_MAX`. Empty `subjectRef`, `fromRef`, `toRef`, `currency`, `reason` or
|
|
26
|
+
`idempotencyKey` throw `INVALID_ARGUMENT`.
|
|
27
|
+
- The `/test` entry type-checks for consumers using `moduleResolution`
|
|
28
|
+
`nodenext` (explicit `.js` relative imports, `vite/client` types).
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
- The npm package now ships its docs for coding agents: `docs/*.md`, `llms.txt`
|
|
33
|
+
and `CHANGELOG.md` alongside `README.md`, so
|
|
34
|
+
`node_modules/@vllnt/convex-wallet/` holds docs that match the installed
|
|
35
|
+
version. `llms.txt` links to them with relative paths. A test fails CI if a
|
|
36
|
+
required file is missing from the tarball or a contributor-only file is added.
|
|
37
|
+
- `docs/API.md` lists every entry point (`./react`, `./test`, `./convex.config`,
|
|
38
|
+
`./_generated/component`) and the exported types.
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- Test files are no longer included in the published package.
|
|
43
|
+
- `homepage` points to https://oss.vllnt.com/packages/convex-wallet; more
|
|
44
|
+
`keywords`.
|
|
45
|
+
- Canary releases publish on every push to `main` that touches the package or
|
|
46
|
+
its shipped docs, without a repository-variable gate. They still use the
|
|
47
|
+
`canary` dist-tag only.
|
|
48
|
+
- Tooling: pnpm 10 with a release-age gate, tag-only stable releases with npm
|
|
49
|
+
provenance, pinned CI actions, patched transitive dependencies.
|
|
50
|
+
|
|
51
|
+
## [0.1.0] - 2026-09-01
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
|
|
55
|
+
- Treat Convex `_generated` output as CLI-owned, exclude it from formatting, and
|
|
56
|
+
expose a dedicated codegen script.
|
|
57
|
+
- Refresh all direct dependencies to their latest compatible releases for canary
|
|
58
|
+
validation.
|
|
59
|
+
- Require `convex@^1.45.0` and update `convex-test` to `^0.0.56`.
|
|
60
|
+
- Bound ledger history reads to integer limits from 1 through 1000.
|
|
61
|
+
|
|
62
|
+
### Breaking (relative to the 0.1.0 canaries)
|
|
63
|
+
|
|
64
|
+
- `history` now throws `INVALID_LIMIT` for limits outside 1 through 1000 or for
|
|
65
|
+
non-finite/non-integer values. Clamp explicit limits and `defaultHistoryLimit`
|
|
66
|
+
to this range before upgrading.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- Skip redundant balance patches when a failed spend or transfer did not advance
|
|
71
|
+
regeneration.
|
|
72
|
+
|
|
73
|
+
- **Ledger delta correctness** — `earn` and the receiver leg of `transfer` now
|
|
74
|
+
record the actual balance change in `delta`, not the requested amount. When a
|
|
75
|
+
credit is clamped by `max`, `delta` equals the real increase only.
|
|
76
|
+
- **Regen config validation** — `applyRegen` now throws `INVALID_REGEN` when
|
|
77
|
+
`intervalMs`, `amount`, or `cap` is non-finite or non-positive, preventing
|
|
78
|
+
`0 * Infinity = NaN` from corrupting `lastRegenAt`.
|
|
79
|
+
- **Regen below-stored guard** — `applyRegen` now ensures the projected balance
|
|
80
|
+
is never reduced below `stored` (fixes the case where `stored > regen.cap`
|
|
81
|
+
previously silently destroyed funds).
|
|
82
|
+
|
|
83
|
+
### Added
|
|
84
|
+
|
|
85
|
+
- **Idempotent spend** — `spend` now accepts an optional `idempotencyKey`. A
|
|
86
|
+
replay of an already-recorded key returns the current balance without a second
|
|
87
|
+
debit or ledger row, preventing double-charges on host retries.
|
|
88
|
+
|
|
89
|
+
- First release of `@vllnt/convex-wallet`.
|
|
90
|
+
- Per-currency `max` ceiling — credits clamp to it on `earn`, `grant`, and the
|
|
91
|
+
receiver leg of `transfer`.
|
|
92
|
+
- Internal hourly `pruneLedger` cron (idempotent / at-least-once) that deletes
|
|
93
|
+
ledger rows past the retention window and expires idempotency keys past the
|
|
94
|
+
idempotency window; configurable windows on direct call.
|
|
95
|
+
|
|
96
|
+
### Security / Fixed
|
|
97
|
+
|
|
98
|
+
- **Amount guards (abuse)** — `earn` / `grant` / `spend` / `transfer` now reject
|
|
99
|
+
non-finite or non-positive amounts with `INVALID_AMOUNT`. Closes a mint
|
|
100
|
+
exploit where a negative `spend` credited funds, and balance corruption from
|
|
101
|
+
`NaN` / `Infinity`.
|
|
102
|
+
- **Server-sourced time** — the host no longer supplies `now`; every mutation
|
|
103
|
+
and query reads `Date.now()` server-side, so a forged/stale clock cannot drive
|
|
104
|
+
extra regen. Removed the `*At` example wrappers.
|
|
105
|
+
- **Monotonic regen** — `applyRegen` never advances the regen pointer past `now`
|
|
106
|
+
and treats a backwards/equal clock as a no-op (no over-regen, no rewind).
|
|
107
|
+
- **Per-`(subject, currency)` idempotency** — the `by_idem` index is re-keyed to
|
|
108
|
+
`(subjectRef, currency, idempotencyKey)` so a key reused across subjects or
|
|
109
|
+
currencies is independent and no longer silently drops a legitimate grant.
|
|
110
|
+
- **Self-transfer guard** — `transfer` with `fromRef === toRef` returns
|
|
111
|
+
`SELF_TRANSFER` instead of debiting-then-crediting one row.
|
|
112
|
+
- **Regen-aware `balances()`** — the multi-currency overview now applies each
|
|
113
|
+
currency's regen (via a client-passed map), matching `balance()` (no stale
|
|
114
|
+
divergence).
|
|
115
|
+
|
|
116
|
+
### Changed
|
|
117
|
+
|
|
118
|
+
- Failure results carry a typed `code` (`INSUFFICIENT` | `SELF_TRANSFER`)
|
|
119
|
+
instead of a free-text `reason`; `reason` remains the human ledger note.
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!-- Badges -->
|
|
2
|
+
|
|
2
3
|
[](https://www.convex.dev/components)
|
|
3
4
|
[](https://www.npmjs.com/package/@vllnt/convex-wallet)
|
|
4
5
|
[](https://github.com/vllnt/convex-wallet/actions/workflows/ci.yml)
|
|
@@ -6,24 +7,43 @@
|
|
|
6
7
|
|
|
7
8
|
# @vllnt/convex-wallet
|
|
8
9
|
|
|
9
|
-
Consumable balances and economy ledger with atomic spend and lazy regen, as a
|
|
10
|
+
Consumable balances and economy ledger with atomic spend and lazy regen, as a
|
|
11
|
+
Convex component — hold per-subject balances of any opaque currency (coins,
|
|
12
|
+
energy, gems, credits).
|
|
10
13
|
|
|
11
14
|
```ts
|
|
12
15
|
const wallet = new Wallet(components.wallet, {
|
|
13
|
-
currencies: {
|
|
16
|
+
currencies: {
|
|
17
|
+
energy: { regen: { amount: 1, intervalMs: 10_000, cap: 100 } },
|
|
18
|
+
},
|
|
14
19
|
});
|
|
15
20
|
await wallet.spend(ctx, subjectRef, "coins", 5, "purchase"); // atomic, never negative
|
|
16
21
|
const energy = await wallet.balance(ctx, subjectRef, "energy"); // regen-aware
|
|
17
22
|
```
|
|
18
23
|
|
|
24
|
+
## For coding agents
|
|
25
|
+
|
|
26
|
+
This package bundles its docs at `node_modules/@vllnt/convex-wallet/`:
|
|
27
|
+
[`docs/API.md`](docs/API.md), this README, [`CHANGELOG.md`](CHANGELOG.md),
|
|
28
|
+
[`llms.txt`](llms.txt) and the TypeScript source in `src/`. They match the
|
|
29
|
+
installed version. Read them before writing code against this package.
|
|
30
|
+
|
|
19
31
|
## Features
|
|
20
32
|
|
|
21
|
-
- **Atomic spend** — debits ride the Convex mutation transaction; never goes
|
|
22
|
-
|
|
23
|
-
- **
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
- **Atomic spend** — debits ride the Convex mutation transaction; never goes
|
|
34
|
+
negative, never double-spends.
|
|
35
|
+
- **Abuse-guarded amounts** — every value-moving call rejects non-finite,
|
|
36
|
+
non-positive or above-2^53 amounts (`INVALID_AMOUNT`), overflowing balances
|
|
37
|
+
(`BALANCE_OVERFLOW`), empty identifiers (`INVALID_ARGUMENT`) and a reused
|
|
38
|
+
idempotency key across credit and debit (`IDEMPOTENCY_KEY_REUSED`).
|
|
39
|
+
- **Typed ledger** — every earn / spend / transfer records a signed `delta` (the
|
|
40
|
+
actual change), `reason`, and timestamp.
|
|
41
|
+
- **Idempotent grants & spend** — credit/debit exactly once per
|
|
42
|
+
`idempotencyKey`, scoped per `(subjectRef, currency)`.
|
|
43
|
+
- **Lazy time-regen** — energy-style currencies regenerate on read from the
|
|
44
|
+
server clock, no cron.
|
|
45
|
+
- **Per-currency `max` ceiling, multi-currency, transfers** — with a
|
|
46
|
+
`SELF_TRANSFER` guard.
|
|
27
47
|
- **Typed error codes, self-pruning ledger cron, opaque host refs.**
|
|
28
48
|
|
|
29
49
|
## Installation
|
|
@@ -32,7 +52,9 @@ const energy = await wallet.balance(ctx, subjectRef, "energy"); // regen-aware
|
|
|
32
52
|
pnpm add @vllnt/convex-wallet
|
|
33
53
|
```
|
|
34
54
|
|
|
35
|
-
|
|
55
|
+
Node.js >=18; required peer: `convex@^1.45.0`. React >=18 is optional. The
|
|
56
|
+
default npm channel is stable; `@vllnt/convex-wallet@canary` carries unreleased
|
|
57
|
+
changes from `main`. The docs in each package describe that package's version.
|
|
36
58
|
|
|
37
59
|
## Usage
|
|
38
60
|
|
|
@@ -63,7 +85,8 @@ const wallet = new Wallet(components.wallet, {
|
|
|
63
85
|
|
|
64
86
|
export const buy = mutation({
|
|
65
87
|
args: { userId: v.string(), cost: v.number() },
|
|
66
|
-
handler: (ctx, { userId, cost }) =>
|
|
88
|
+
handler: (ctx, { userId, cost }) =>
|
|
89
|
+
wallet.spend(ctx, userId, "coins", cost, "purchase"),
|
|
67
90
|
});
|
|
68
91
|
|
|
69
92
|
// Call AFTER the host has verified the IAP — idempotent on the receipt id.
|
|
@@ -79,42 +102,85 @@ export const energy = query({
|
|
|
79
102
|
});
|
|
80
103
|
```
|
|
81
104
|
|
|
105
|
+
The wrappers above illustrate calls only: authenticate the caller, authorize the
|
|
106
|
+
subject, and derive costs and credit amounts from trusted host data before use.
|
|
107
|
+
A comment about payment verification is not an authorization check. After
|
|
108
|
+
mounting, run `pnpm convex dev` to generate the host's `components` references.
|
|
109
|
+
|
|
110
|
+
## Configuration and limits
|
|
111
|
+
|
|
112
|
+
`WalletOptions` supports only `currencies` (default `{}`: static, uncapped) and
|
|
113
|
+
`defaultHistoryLimit` (default `50`, integer 1–1000). Currency rules accept
|
|
114
|
+
optional `regen: { amount, intervalMs, cap }` and `max`. There are no client
|
|
115
|
+
retention or idempotency-TTL options. The internal hourly sweep uses 90-day
|
|
116
|
+
ledger retention and a 7-day key-expiry threshold; bounded cleanup may lag those
|
|
117
|
+
thresholds. Replay protection ends when the key or ledger row is removed.
|
|
118
|
+
Earn/grant and spend share keys per subject/currency; transfer has no replay
|
|
119
|
+
key.
|
|
120
|
+
|
|
121
|
+
Regen is projected when a query executes, not pushed by a clock-driven
|
|
122
|
+
subscription. Transfers clamp the receiver's credit to `max`, so a capped
|
|
123
|
+
transfer need not preserve the combined balance. This is a consumable wallet,
|
|
124
|
+
not payment processing.
|
|
125
|
+
|
|
126
|
+
## Multiple mounts
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
app.use(wallet, { name: "webWallet" });
|
|
130
|
+
app.use(wallet, { name: "gameWallet" });
|
|
131
|
+
// new Wallet(components.webWallet), new Wallet(components.gameWallet)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Each mount has isolated balances, ledger rows and maintenance.
|
|
135
|
+
|
|
82
136
|
## API Reference
|
|
83
137
|
|
|
84
|
-
| Method
|
|
85
|
-
|
|
86
|
-
| `earn(ctx, subjectRef, currency, amount, reason, opts?)`
|
|
87
|
-
| `grant(ctx, subjectRef, currency, amount, reason, idempotencyKey)` | mutation | `{ balance }` (credited once per key)
|
|
88
|
-
| `spend(ctx, subjectRef, currency, amount, reason, opts?)`
|
|
89
|
-
| `transfer(ctx, fromRef, toRef, currency, amount, reason)`
|
|
90
|
-
| `balance(ctx, subjectRef, currency)`
|
|
91
|
-
| `balances(ctx, subjectRef)`
|
|
92
|
-
| `history(ctx, subjectRef, currency, limit?)`
|
|
138
|
+
| Method | Kind | Result |
|
|
139
|
+
| ------------------------------------------------------------------ | -------- | ------------------------------------------------------------------------------ |
|
|
140
|
+
| `earn(ctx, subjectRef, currency, amount, reason, opts?)` | mutation | `{ balance }` (clamped to `max`) |
|
|
141
|
+
| `grant(ctx, subjectRef, currency, amount, reason, idempotencyKey)` | mutation | `{ balance }` (credited once per key) |
|
|
142
|
+
| `spend(ctx, subjectRef, currency, amount, reason, opts?)` | mutation | `{ ok, balance, code? }` |
|
|
143
|
+
| `transfer(ctx, fromRef, toRef, currency, amount, reason)` | mutation | `{ ok, balance, code? }` |
|
|
144
|
+
| `balance(ctx, subjectRef, currency)` | query | `number` (regen-aware) |
|
|
145
|
+
| `balances(ctx, subjectRef)` | query | `{ currency, amount }[]` |
|
|
146
|
+
| `history(ctx, subjectRef, currency, limit?)` | query | `LedgerEntry[]` (newest-first; `limit` must be an integer from 1 through 1000) |
|
|
93
147
|
|
|
94
|
-
Full reference: [docs/API.md](docs/API.md) — including per-currency config,
|
|
148
|
+
Full reference: [docs/API.md](docs/API.md) — including per-currency config,
|
|
149
|
+
error codes (`INVALID_AMOUNT`, `INVALID_REGEN`, `INVALID_LIMIT`, `INSUFFICIENT`,
|
|
150
|
+
`SELF_TRANSFER`), and the regen model.
|
|
95
151
|
|
|
96
152
|
## React
|
|
97
153
|
|
|
98
|
-
Optional, tree-shakeable hooks at `@vllnt/convex-wallet/react`; `react` is an
|
|
154
|
+
Optional, tree-shakeable hooks at `@vllnt/convex-wallet/react`; `react` is an
|
|
155
|
+
optional peer dep. Pass the host's own re-exported query refs — the component
|
|
156
|
+
never imports your `api`.
|
|
99
157
|
|
|
100
158
|
```tsx
|
|
101
159
|
import { useBalance, useBalances } from "@vllnt/convex-wallet/react";
|
|
102
160
|
import { api } from "../convex/_generated/api";
|
|
103
161
|
|
|
104
|
-
|
|
105
|
-
|
|
162
|
+
// Host queries must accept these exact arguments; these are separate wrappers
|
|
163
|
+
// from the userId-based query above, and must authorize subjectRef.
|
|
164
|
+
const energy = useBalance(api.wallet.balance, {
|
|
165
|
+
subjectRef: userId,
|
|
166
|
+
currency: "energy",
|
|
167
|
+
});
|
|
168
|
+
const all = useBalances(api.wallet.balances, { subjectRef: userId });
|
|
106
169
|
```
|
|
107
170
|
|
|
108
|
-
| Hook
|
|
109
|
-
|
|
110
|
-
| `useBalance(balanceRef, { subjectRef, currency })` | host's `balance` query ref
|
|
111
|
-
| `useBalances(balancesRef, { subjectRef })`
|
|
171
|
+
| Hook | Args | Result |
|
|
172
|
+
| -------------------------------------------------- | --------------------------- | ----------------------------- |
|
|
173
|
+
| `useBalance(balanceRef, { subjectRef, currency })` | host's `balance` query ref | `number \| undefined` |
|
|
174
|
+
| `useBalances(balancesRef, { subjectRef })` | host's `balances` query ref | `BalanceEntry[] \| undefined` |
|
|
112
175
|
|
|
113
176
|
## Security
|
|
114
177
|
|
|
115
|
-
- Auth- and payment-agnostic — the host gates access and verifies any IAP /
|
|
116
|
-
|
|
117
|
-
-
|
|
178
|
+
- Auth- and payment-agnostic — the host gates access and verifies any IAP /
|
|
179
|
+
Stripe purchase before calling `grant`.
|
|
180
|
+
- Tables are sandboxed; spend and transfer are atomic, so balances never go
|
|
181
|
+
negative and grants never double-credit.
|
|
182
|
+
- Amounts are validated, regen configs are validated when regen is applied, and
|
|
183
|
+
time is server-sourced — a forged or replayed clock can't drive extra regen.
|
|
118
184
|
|
|
119
185
|
See [docs/API.md](docs/API.md).
|
|
120
186
|
|
|
@@ -125,17 +191,45 @@ pnpm test # single run
|
|
|
125
191
|
pnpm test:coverage # enforced 100% on covered files
|
|
126
192
|
```
|
|
127
193
|
|
|
128
|
-
Tests
|
|
194
|
+
Tests use the simulated `convex-test` backend (`@edge-runtime/vm`), not a real
|
|
195
|
+
Convex deployment; they do not prove production concurrency or scheduler
|
|
196
|
+
delivery.
|
|
197
|
+
|
|
198
|
+
### Testing your app
|
|
199
|
+
|
|
200
|
+
`@vllnt/convex-wallet/test` exports `register(t, name = "wallet")` to mount the
|
|
201
|
+
component in a `convex-test` instance. It needs `convex-test` and `vitest` (with
|
|
202
|
+
Vite's `import.meta.glob`) in the consuming app:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
/// <reference types="vite/client" />
|
|
206
|
+
import { convexTest } from "convex-test";
|
|
207
|
+
import { register } from "@vllnt/convex-wallet/test";
|
|
208
|
+
import schema from "./schema";
|
|
209
|
+
|
|
210
|
+
const t = convexTest(schema, import.meta.glob("./**/*.ts"));
|
|
211
|
+
register(t);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Related packages
|
|
215
|
+
|
|
216
|
+
| Package | Use it when |
|
|
217
|
+
| -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
|
218
|
+
| [`@vllnt/convex-quota`](https://oss.vllnt.com/packages/convex-quota) | The allowance resets on a schedule (calendar, rolling or epoch window) rather than being earned, spent and regenerated. |
|
|
219
|
+
| [`@vllnt/convex-metering`](https://oss.vllnt.com/packages/convex-metering) | You record usage to bill for per period, instead of debiting a prepaid balance. |
|
|
220
|
+
| [`@vllnt/convex-progression`](https://oss.vllnt.com/packages/convex-progression) | You track XP, levels or streaks that accumulate and are never spent. |
|
|
129
221
|
|
|
130
222
|
## Contributing
|
|
131
223
|
|
|
132
|
-
See
|
|
224
|
+
See
|
|
225
|
+
[CONTRIBUTING.md](https://github.com/vllnt/convex-wallet/blob/main/CONTRIBUTING.md).
|
|
133
226
|
|
|
134
227
|
## Author
|
|
135
228
|
|
|
136
|
-
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
229
|
+
Built by [bntvllnt](https://github.com/bntvllnt) ·
|
|
230
|
+
[bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
137
231
|
|
|
138
|
-
Part of
|
|
232
|
+
Part of vllnt oss: https://oss.vllnt.com
|
|
139
233
|
|
|
140
234
|
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
141
235
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* The wallet's own scheduled maintenance. Scheduling lives INSIDE the component
|
|
3
3
|
* (never the host) and the swept mutation is idempotent (at-least-once safe).
|
|
4
4
|
*
|
|
5
|
-
* Runs the retention + idempotency-window sweep hourly with the default
|
|
6
|
-
* windows
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Runs the retention + idempotency-window sweep hourly with the fixed default
|
|
6
|
+
* windows. `pruneLedger` is internal and not host-callable. Each run is
|
|
7
|
+
* bounded; a run that fills its batch schedules an immediate continuation, so
|
|
8
|
+
* a backlog drains in one sweep without one unbounded transaction.
|
|
9
9
|
*/
|
|
10
10
|
declare const crons: import("convex/server").Crons;
|
|
11
11
|
export default crons;
|
package/dist/component/crons.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { cronJobs } from "convex/server";
|
|
2
|
-
import { internal } from "./_generated/api";
|
|
3
|
-
import { DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_LEDGER_RETENTION_MS, } from "../shared";
|
|
2
|
+
import { internal } from "./_generated/api.js";
|
|
3
|
+
import { DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_LEDGER_RETENTION_MS, } from "../shared.js";
|
|
4
4
|
/**
|
|
5
5
|
* The wallet's own scheduled maintenance. Scheduling lives INSIDE the component
|
|
6
6
|
* (never the host) and the swept mutation is idempotent (at-least-once safe).
|
|
7
7
|
*
|
|
8
|
-
* Runs the retention + idempotency-window sweep hourly with the default
|
|
9
|
-
* windows
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Runs the retention + idempotency-window sweep hourly with the fixed default
|
|
9
|
+
* windows. `pruneLedger` is internal and not host-callable. Each run is
|
|
10
|
+
* bounded; a run that fills its batch schedules an immediate continuation, so
|
|
11
|
+
* a backlog drains in one sweep without one unbounded transaction.
|
|
12
12
|
*/
|
|
13
13
|
const crons = cronJobs();
|
|
14
14
|
crons.interval("prune wallet ledger", { hours: 1 }, internal.internal_mutations.pruneLedger, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AAEtB;;;;;;;;GAQG;AACH,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CACZ,qBAAqB,EACrB,EAAE,KAAK,EAAE,CAAC,EAAE,EACZ,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EACvC;IACE,WAAW,EAAE,2BAA2B;IACxC,gBAAgB,EAAE,0BAA0B;CAC7C,CACF,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal_mutations.d.ts","sourceRoot":"","sources":["../../src/component/internal_mutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal_mutations.d.ts","sourceRoot":"","sources":["../../src/component/internal_mutations.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW;;;;;;GA2CtB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
|
-
import {
|
|
2
|
+
import { internal } from "./_generated/api.js";
|
|
3
|
+
import { internalMutation } from "./_generated/server.js";
|
|
3
4
|
/** Hard cap on rows touched per sweep invocation — keeps each run bounded. */
|
|
4
5
|
const PRUNE_BATCH = 256;
|
|
5
6
|
/**
|
|
@@ -46,6 +47,9 @@ export const pruneLedger = internalMutation({
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
if (oldest.length === PRUNE_BATCH) {
|
|
51
|
+
await ctx.scheduler.runAfter(0, internal.internal_mutations.pruneLedger, args);
|
|
52
|
+
}
|
|
49
53
|
return { deleted: oldest.length, expired };
|
|
50
54
|
},
|
|
51
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal_mutations.js","sourceRoot":"","sources":["../../src/component/internal_mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"internal_mutations.js","sourceRoot":"","sources":["../../src/component/internal_mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,8EAA8E;AAC9E,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;IAC1C,IAAI,EAAE;QACJ,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;KAC7B;IACD,OAAO,EAAE,CAAC,CAAC,MAAM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IAAI,GAAG,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;oBACrC,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC;oBACrE,OAAO,IAAI,CAAC,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACjF,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAC7C,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAmFA;;;;;GAKG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;GA2Ef,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;UAqB0B,cAAc;;;;;GA4CxD,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;UA2B6B,eAAe;;;;UAGrB,cAAc;;;;;GAmExD,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
|
-
import { mutation } from "./_generated/server";
|
|
3
|
-
import { applyRegen, assertPositiveAmount } from "../shared";
|
|
4
|
-
import { maxArg, regenArg, spendResult } from "./validators";
|
|
2
|
+
import { mutation } from "./_generated/server.js";
|
|
3
|
+
import { applyRegen, assertNonEmpty, assertPositiveAmount, assertSafeBalance, assertValidMax, fail, IDEMPOTENCY_KEY_REUSED, } from "../shared.js";
|
|
4
|
+
import { maxArg, regenArg, spendResult } from "./validators.js";
|
|
5
5
|
const balanceObject = v.object({ balance: v.number() });
|
|
6
6
|
/**
|
|
7
7
|
* Find the prior ledger row for a replayed `idempotencyKey`, scoped to this
|
|
@@ -17,9 +17,34 @@ async function findIdempotent(ctx, subjectRef, currency, idempotencyKey) {
|
|
|
17
17
|
.eq("idempotencyKey", idempotencyKey))
|
|
18
18
|
.first();
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Clamp a post-credit balance to an optional per-currency `max` ceiling. A
|
|
22
|
+
* credit never lowers the balance: when `before` is already above `max` (the
|
|
23
|
+
* host lowered it), the balance is left as is and the credit is a no-op.
|
|
24
|
+
* Throws `BALANCE_OVERFLOW` past 2^53 - 1.
|
|
25
|
+
*/
|
|
26
|
+
function clampToMax(before, credit, max) {
|
|
27
|
+
const after = before + credit;
|
|
28
|
+
const clamped = max === undefined ? after : Math.max(before, Math.min(after, max));
|
|
29
|
+
assertSafeBalance(clamped);
|
|
30
|
+
return clamped;
|
|
31
|
+
}
|
|
32
|
+
/** Validate the string identifiers shared by every value-moving mutation. */
|
|
33
|
+
function assertIdentifiers(args, subjects) {
|
|
34
|
+
for (const [name, value] of Object.entries(subjects)) {
|
|
35
|
+
assertNonEmpty(name, value);
|
|
36
|
+
}
|
|
37
|
+
assertNonEmpty("currency", args.currency);
|
|
38
|
+
assertNonEmpty("reason", args.reason);
|
|
39
|
+
if (args.idempotencyKey !== undefined) {
|
|
40
|
+
assertNonEmpty("idempotencyKey", args.idempotencyKey);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** A recorded key may only be replayed by the same direction (credit vs debit). */
|
|
44
|
+
function assertSameDirection(seen, debit) {
|
|
45
|
+
if (seen.delta < 0 !== debit) {
|
|
46
|
+
fail(IDEMPOTENCY_KEY_REUSED, "idempotencyKey was already used by a " + (debit ? "credit" : "debit"));
|
|
47
|
+
}
|
|
23
48
|
}
|
|
24
49
|
/**
|
|
25
50
|
* Credit `amount` of `currency` to `subjectRef`. When `idempotencyKey` is
|
|
@@ -39,7 +64,9 @@ export const earn = mutation({
|
|
|
39
64
|
},
|
|
40
65
|
returns: balanceObject,
|
|
41
66
|
handler: async (ctx, args) => {
|
|
67
|
+
assertIdentifiers(args, { subjectRef: args.subjectRef });
|
|
42
68
|
assertPositiveAmount(args.amount);
|
|
69
|
+
assertValidMax(args.max);
|
|
43
70
|
const now = Date.now();
|
|
44
71
|
const row = await ctx.db
|
|
45
72
|
.query("balances")
|
|
@@ -50,7 +77,7 @@ export const earn = mutation({
|
|
|
50
77
|
if (row === null) {
|
|
51
78
|
// No balance row → no recorded key for it can exist, so the idempotency
|
|
52
79
|
// check is unnecessary: this is always a first credit.
|
|
53
|
-
balance = clampToMax(args.amount, args.max);
|
|
80
|
+
balance = clampToMax(0, args.amount, args.max);
|
|
54
81
|
delta = balance;
|
|
55
82
|
await ctx.db.insert("balances", {
|
|
56
83
|
subjectRef: args.subjectRef,
|
|
@@ -65,6 +92,7 @@ export const earn = mutation({
|
|
|
65
92
|
if (args.idempotencyKey !== undefined) {
|
|
66
93
|
const seen = await findIdempotent(ctx, args.subjectRef, args.currency, args.idempotencyKey);
|
|
67
94
|
if (seen !== null) {
|
|
95
|
+
assertSameDirection(seen, false);
|
|
68
96
|
// Replay: return the current (regen-aware) balance, no double-credit.
|
|
69
97
|
return {
|
|
70
98
|
balance: applyRegen(row.amount, row.lastRegenAt, now, args.regen).amount,
|
|
@@ -72,8 +100,9 @@ export const earn = mutation({
|
|
|
72
100
|
}
|
|
73
101
|
}
|
|
74
102
|
const r = applyRegen(row.amount, row.lastRegenAt, now, args.regen);
|
|
75
|
-
balance = clampToMax(r.amount
|
|
103
|
+
balance = clampToMax(r.amount, args.amount, args.max);
|
|
76
104
|
delta = balance - r.amount;
|
|
105
|
+
assertSafeBalance(row.lifetimeEarned + delta);
|
|
77
106
|
await ctx.db.patch("balances", row._id, {
|
|
78
107
|
amount: balance,
|
|
79
108
|
lastRegenAt: r.lastRegenAt,
|
|
@@ -107,6 +136,7 @@ export const spend = mutation({
|
|
|
107
136
|
},
|
|
108
137
|
returns: spendResult,
|
|
109
138
|
handler: async (ctx, args) => {
|
|
139
|
+
assertIdentifiers(args, { subjectRef: args.subjectRef });
|
|
110
140
|
assertPositiveAmount(args.amount);
|
|
111
141
|
const now = Date.now();
|
|
112
142
|
const row = await ctx.db
|
|
@@ -119,6 +149,7 @@ export const spend = mutation({
|
|
|
119
149
|
if (args.idempotencyKey !== undefined) {
|
|
120
150
|
const seen = await findIdempotent(ctx, args.subjectRef, args.currency, args.idempotencyKey);
|
|
121
151
|
if (seen !== null) {
|
|
152
|
+
assertSameDirection(seen, true);
|
|
122
153
|
// Replay: return the current (regen-aware) balance, no double-debit.
|
|
123
154
|
return {
|
|
124
155
|
ok: true,
|
|
@@ -172,7 +203,9 @@ export const transfer = mutation({
|
|
|
172
203
|
},
|
|
173
204
|
returns: spendResult,
|
|
174
205
|
handler: async (ctx, args) => {
|
|
206
|
+
assertIdentifiers(args, { fromRef: args.fromRef, toRef: args.toRef });
|
|
175
207
|
assertPositiveAmount(args.amount);
|
|
208
|
+
assertValidMax(args.max);
|
|
176
209
|
const now = Date.now();
|
|
177
210
|
const fromRow = await ctx.db
|
|
178
211
|
.query("balances")
|
|
@@ -217,7 +250,7 @@ export const transfer = mutation({
|
|
|
217
250
|
.unique();
|
|
218
251
|
let receiverDelta;
|
|
219
252
|
if (toRow === null) {
|
|
220
|
-
const credited = clampToMax(args.amount, args.max);
|
|
253
|
+
const credited = clampToMax(0, args.amount, args.max);
|
|
221
254
|
receiverDelta = credited;
|
|
222
255
|
await ctx.db.insert("balances", {
|
|
223
256
|
subjectRef: args.toRef,
|
|
@@ -230,8 +263,9 @@ export const transfer = mutation({
|
|
|
230
263
|
}
|
|
231
264
|
else {
|
|
232
265
|
const toR = applyRegen(toRow.amount, toRow.lastRegenAt, now, args.regen);
|
|
233
|
-
const credited = clampToMax(toR.amount
|
|
266
|
+
const credited = clampToMax(toR.amount, args.amount, args.max);
|
|
234
267
|
receiverDelta = credited - toR.amount;
|
|
268
|
+
assertSafeBalance(toRow.lifetimeEarned + receiverDelta);
|
|
235
269
|
await ctx.db.patch("balances", toRow._id, {
|
|
236
270
|
amount: credited,
|
|
237
271
|
lastRegenAt: toR.lastRegenAt,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../src/component/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAGlC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAIxD;;;;GAIG;AACH,KAAK,UAAU,cAAc,CAC3B,GAAW,EACX,UAAkB,EAClB,QAAgB,EAChB,cAAsB;IAEtB,OAAO,GAAG,CAAC,EAAE;SACV,KAAK,CAAC,QAAQ,CAAC;SACf,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAC1B,CAAC;SACE,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;SAC5B,EAAE,CAAC,UAAU,EAAE,QAAQ,CAAC;SACxB,EAAE,CAAC,gBAAgB,EAAE,cAAc,CAAC,CACxC;SACA,KAAK,EAAE,CAAC;AACb,CAAC;AAED,6EAA6E;AAC7E,SAAS,UAAU,CAAC,OAAe,EAAE,GAAuB;IAC1D,OAAO,GAAG,KAAK,SAAS,CAAC,C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,CAAC,CAAC;YACzE,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;YAC/D,aAAa,GAAG,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC;YACtC,iBAAiB,CAAC,KAAK,CAAC,cAAc,GAAG,aAAa,CAAC,CAAC;YACxD,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE;gBACxC,MAAM,EAAE,QAAQ;gBAChB,WAAW,EAAE,GAAG,CAAC,WAAW;gBAC5B,cAAc,EAAE,KAAK,CAAC,cAAc,GAAG,aAAa;aACrD,CAAC,CAAC;QACL,CAAC;QACD,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE;YAC5B,UAAU,EAAE,IAAI,CAAC,KAAK;YACtB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,aAAa;YACpB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS,EAAE,GAAG;SACf,CAAC,CAAC;QACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;IAC5C,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConvexError, v } from "convex/values";
|
|
2
|
-
import { query } from "./_generated/server";
|
|
3
|
-
import { applyRegen } from "../shared";
|
|
4
|
-
import { balanceEntry, ledgerDoc, regenArg, regenMapArg } from "./validators";
|
|
2
|
+
import { query } from "./_generated/server.js";
|
|
3
|
+
import { applyRegen } from "../shared.js";
|
|
4
|
+
import { balanceEntry, ledgerDoc, regenArg, regenMapArg } from "./validators.js";
|
|
5
5
|
const MAX_HISTORY_LIMIT = 1000;
|
|
6
6
|
function validateHistoryLimit(limit) {
|
|
7
7
|
if (!Number.isFinite(limit) ||
|