@effectstream/sm 0.100.15 → 0.100.16

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 CHANGED
@@ -5,6 +5,11 @@ of commands, register one generator per command, and `Stm` parses each
5
5
  incoming batcher input, dispatches it to the right handler, and yields
6
6
  SQL updates through the runtime.
7
7
 
8
+ - State-machine DSL: define a typed grammar, register one generator per command.
9
+ - Parses each batcher input, dispatches to the handler, yields SQL through the runtime.
10
+ - `@effectstream/sm/builtin` ships common on-chain event primitives (ERC-20/721/1155, Cardano, Midnight, ...).
11
+ - DSL is directly testable in a pure-TS unit test, without a database.
12
+
8
13
  ## Install
9
14
 
10
15
  ```bash
@@ -23,7 +28,7 @@ the runtime executes it.
23
28
 
24
29
  The DSL is also directly testable in a pure-TS unit test (parse + dispatch
25
30
  without a database) — see
26
- [`primitives/src/evm-erc20/erc20-primitive.test.ts`](https://github.com/PaimaStudios/paima-engine/blob/main/packages/node-sdk/sm/primitives/src/evm-erc20/erc20-primitive.test.ts).
31
+ [`primitives/src/evm-erc20/erc20-primitive.test.ts`](https://github.com/effectstream/effectstream/blob/main/packages/node-sdk/sm/primitives/src/evm-erc20/erc20-primitive.test.ts).
27
32
 
28
33
  ```typescript
29
34
  import { Stm } from "@effectstream/sm";
@@ -62,9 +67,9 @@ Midnight events, etc. — so you don't re-implement them.
62
67
 
63
68
  ## Key exports
64
69
 
65
- - `Stm<Grammar, Events>` — the state machine. `.addStateTransition(prefix, handler)`, `.processInput(input)`, `.grammar`, `.fullJsonGrammar`, `.keyedJsonGrammar`.
66
- - `ParamToData<Params>` — derives the typed argument shape from a grammar entry.
67
- - `BaseStfInput` — the input shape passed to every handler (includes `msTimestamp`, `blockHeight`, etc.).
70
+ - `Stm<Grammar, Events>`: the state machine. `.addStateTransition(prefix, handler)`, `.processInput(input)`, `.grammar`, `.fullJsonGrammar`, `.keyedJsonGrammar`.
71
+ - `ParamToData<Params>` derives the typed argument shape from a grammar entry.
72
+ - `BaseStfInput`: input shape passed to every handler. Includes `msTimestamp`, `blockHeight`, etc.
68
73
  - `delegate-wallet` helpers — account delegation primitives reused by built-ins.
69
74
 
70
75
  `MessageListener<Events, Params>` is exported as the handler type but is
@@ -72,14 +77,14 @@ inferred at call sites rather than imported directly.
72
77
 
73
78
  Subpath exports:
74
79
 
75
- - `@effectstream/sm/builtin` — `PrimitiveTypeERC20`, `PrimitiveTypeERC721`, `PrimitiveTypeERC1155`, `PrimitiveTypeCardanoTransfer`, `PrimitiveTypeMidnightGeneric`, and many more (20+ chain-specific event tags).
76
- - `@effectstream/sm/grammar` — the underlying grammar/parsing utilities (also re-exported from `@effectstream/concise`).
80
+ - `@effectstream/sm/builtin`: `PrimitiveTypeERC20`, `PrimitiveTypeERC721`, `PrimitiveTypeERC1155`, `PrimitiveTypeCardanoTransfer`, `PrimitiveTypeMidnightGeneric`, and 20+ more chain-specific event tags.
81
+ - `@effectstream/sm/grammar`: the underlying grammar/parsing utilities, also re-exported from `@effectstream/concise`.
77
82
 
78
83
  ## Examples
79
84
 
80
- - [`primitives/src/evm-erc20/erc20-primitive.test.ts`](https://github.com/PaimaStudios/paima-engine/blob/main/packages/node-sdk/sm/primitives/src/evm-erc20/erc20-primitive.test.ts) — a real primitive's behavior unit-tested.
85
+ - [`primitives/src/evm-erc20/erc20-primitive.test.ts`](https://github.com/effectstream/effectstream/blob/main/packages/node-sdk/sm/primitives/src/evm-erc20/erc20-primitive.test.ts) — a real primitive's behavior unit-tested.
81
86
  - Game logic in
82
- [`templates/dice/packages/node/`](https://github.com/PaimaStudios/paima-engine/tree/main/templates/dice/packages/node)
87
+ [`templates/dice/packages/node/`](https://github.com/effectstream/effectstream/tree/main/templates/dice/packages/node)
83
88
  shows the full `new Stm(...).addStateTransition(...)` pattern.
84
89
 
85
90
  Runnable: [`test/examples.test.ts`](./test/examples.test.ts).
@@ -87,4 +92,4 @@ Runnable: [`test/examples.test.ts`](./test/examples.test.ts).
87
92
  ## Links
88
93
 
89
94
  - Docs: https://effectstream.github.io/docs/packages/node/sm
90
- - Source: https://github.com/PaimaStudios/paima-engine/tree/main/packages/node-sdk/sm
95
+ - Source: https://github.com/effectstream/effectstream/tree/main/packages/node-sdk/sm
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/sm",
3
- "version": "0.100.15",
3
+ "version": "0.100.16",
4
4
  "license": "MIT",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -17,14 +17,14 @@
17
17
  "./grammar": "./primitives/src/grammar.ts"
18
18
  },
19
19
  "dependencies": {
20
- "@effectstream/concise": "0.100.15",
21
- "@effectstream/config": "0.100.15",
22
- "@effectstream/coroutine": "0.100.15",
23
- "@effectstream/crypto": "0.100.15",
24
- "@effectstream/db": "0.100.15",
25
- "@effectstream/event-client": "0.100.15",
26
- "@effectstream/log": "0.100.15",
27
- "@effectstream/utils": "0.100.15",
20
+ "@effectstream/concise": "0.100.16",
21
+ "@effectstream/config": "0.100.16",
22
+ "@effectstream/coroutine": "0.100.16",
23
+ "@effectstream/crypto": "0.100.16",
24
+ "@effectstream/db": "0.100.16",
25
+ "@effectstream/event-client": "0.100.16",
26
+ "@effectstream/log": "0.100.16",
27
+ "@effectstream/utils": "0.100.16",
28
28
  "pg": "8.17.2",
29
29
  "pg-tx": "^1.0.1",
30
30
  "@sinclair/typebox": "0.34.41",
@@ -63,14 +63,23 @@ export class CardanoMintBurnPrimitive extends Primitive<
63
63
  }
64
64
 
65
65
  override getConfig(): ProtocolPrimitiveMap[ConfigSyncProtocolType.CARDANO_UTXORPC_PARALLEL] {
66
+ // UTxO-RPC's `mints_asset` predicate is interpreted by Dolos as
67
+ // "creates new supply" — it matches only positive-quantity mints and
68
+ // silently filters burns. To catch burns we also match `moves_asset`,
69
+ // which fires when the asset appears in any input/output of the tx
70
+ // (true for burns, since the asset is in the input UTxO being spent).
71
+ // Downstream consumers see both mint and burn payloads through the
72
+ // same primitive; sign-of-quantity discriminates.
73
+ const matchPolicy = (pid: string): UtxorpcTxPredicate => ({
74
+ any_of: [
75
+ { match: { cardano: { mints_asset: { policy_id: pid } } } },
76
+ { match: { cardano: { moves_asset: { policy_id: pid } } } },
77
+ ],
78
+ });
66
79
  const predicate: UtxorpcTxPredicate =
67
80
  this.policyIds.length === 1
68
- ? { match: { cardano: { mints_asset: { policy_id: this.policyIds[0] } } } }
69
- : {
70
- any_of: this.policyIds.map((pid) => ({
71
- match: { cardano: { mints_asset: { policy_id: pid } } },
72
- })),
73
- };
81
+ ? matchPolicy(this.policyIds[0])
82
+ : { any_of: this.policyIds.map(matchPolicy) };
74
83
 
75
84
  return {
76
85
  name: this.instanceName,