@hsuite/smart-engines-sdk 3.2.0 → 3.3.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.
- package/CHANGELOG.md +116 -0
- package/README.md +51 -0
- package/dist/index.d.ts +20888 -1078
- package/dist/index.js +6954 -343
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.d.ts +8298 -810
- package/dist/nestjs/index.js +511 -303
- package/dist/nestjs/index.js.map +1 -1
- package/dist/pqc-verify/index.d.ts +99 -0
- package/dist/pqc-verify/index.js +167 -0
- package/dist/pqc-verify/index.js.map +1 -0
- package/package.json +11 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,121 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.3.0 — 2026-05-29
|
|
4
|
+
|
|
5
|
+
**Smart-App Rules SDK arc.** Adds a complete canonical-rule authoring surface
|
|
6
|
+
so smart-app devs can compose, locally validate, publish, and reference
|
|
7
|
+
canonical `ValidatorRules` from a single SDK — the prerequisite for entity
|
|
8
|
+
creation since the cluster requires a `ruleRef` on every binding.
|
|
9
|
+
|
|
10
|
+
No breaking changes. Bundle grows ~260 KB (vendored Zod schemas mirroring
|
|
11
|
+
`libs/shared/src/dto/validator.dto.ts` + builder/composer/template factories).
|
|
12
|
+
`sideEffects: false` added — tree-shaking excludes any sub-namespace a
|
|
13
|
+
consumer doesn't import.
|
|
14
|
+
|
|
15
|
+
### Added — `Rules` namespace (`import { Rules } from '@hsuite/smart-engines-sdk'`)
|
|
16
|
+
|
|
17
|
+
- **Fluent builders** — `Rules.forToken()` / `.forAccount()` / `.forTopic()` /
|
|
18
|
+
`.forAgent()` with shared `withSecurity` / `withController` / `withOperations` /
|
|
19
|
+
`withTokenGates` / `withGovernance` / `withInvariants` / `withMetadata` /
|
|
20
|
+
`addModule` / `build()` flow. Throws `RuleBuildError` with dot-path messages
|
|
21
|
+
on schema failure.
|
|
22
|
+
- **Composer factories** — 100% coverage of `libs/rules-engine`:
|
|
23
|
+
- `Rules.atom.*` — 17 atoms (timeRange, limits, permissionList, rateLimiter,
|
|
24
|
+
cooldown, approvalThreshold, approvedPairs, tradeLimit, snapshot,
|
|
25
|
+
cronSchedule, countApproval, externalEvidence, fieldValues,
|
|
26
|
+
registryReference, schemaValidation, stopLoss, workflowState)
|
|
27
|
+
- `Rules.molecule.*` — 6 molecules (tokenGate, swap, airdrop, vesting,
|
|
28
|
+
streaming, governance)
|
|
29
|
+
- `Rules.module.*` — 5 organism wrappers as canonical `ModuleEntry`
|
|
30
|
+
(launchpad, stakingPool, dao, dex, agent)
|
|
31
|
+
- **Templates** — 8 one-call factories producing schema-conformant rules:
|
|
32
|
+
`Rules.template.fairLaunch`, `tieredIDO`, `simpleStaking`, `tokenDAO`,
|
|
33
|
+
`multisigDAO`, `simpleAMM`, `vestingSchedule`, `tradingAgent`.
|
|
34
|
+
- **Preflight** — `Rules.validate(rule)` routes by `type` discriminator for
|
|
35
|
+
path-rich error messages (`operations.mint.enabled: Expected boolean`).
|
|
36
|
+
- **Vendored Zod schemas** — `ValidatorRulesSchema`, `TokenValidatorRulesSchema`,
|
|
37
|
+
`AccountValidatorRulesSchema`, `TopicValidatorRulesSchema`,
|
|
38
|
+
`AgentValidatorRulesSchema`, plus every sub-schema (governance, invariants,
|
|
39
|
+
modules, payloadSchema, soulbound, etc.). Mirrors `libs/shared` verbatim;
|
|
40
|
+
re-vendor on schema upgrades.
|
|
41
|
+
|
|
42
|
+
### Added — `BaasClient` sub-clients
|
|
43
|
+
|
|
44
|
+
- **`baas.rules: RulesClient`** — publish a canonical rule and get back a
|
|
45
|
+
cluster-stamped `ruleRef`:
|
|
46
|
+
- `publish(rule)` → `{ ruleRef: { chain, topicId, consensusTimestamp } }`
|
|
47
|
+
- `get(consensusTimestamp)` → `PublishedRule`
|
|
48
|
+
- `listByOwner({ type? })` → `{ rules, count }`
|
|
49
|
+
- `simulate({ ruleRef? | rule?, action, context })` → `ValidationResult`
|
|
50
|
+
- `getVersionHistory(consensusTimestamp)` → `{ versions }`
|
|
51
|
+
- `deprecate(consensusTimestamp)` → `{ deprecated: true, consensusTimestamp }`
|
|
52
|
+
- **`baas.entities: EntitiesClient`** — ruleRef-gated entity creation. The
|
|
53
|
+
cluster's mandatory creation gate enforces that every entity references a
|
|
54
|
+
published rule:
|
|
55
|
+
- `createToken({ chain, name, symbol, decimals?, initialSupply?, ruleRef, memo? })`
|
|
56
|
+
- `createAccount({ chain, ruleRef, initialBalance?, publicKey? })`
|
|
57
|
+
- `createTopic({ chain, ruleRef, memo? })`
|
|
58
|
+
- `createAgent({ primaryChain, ruleRef, name, agentType? })`
|
|
59
|
+
- `launchpad({ chain, name, symbol, launchpad })` — mega-helper: publishes
|
|
60
|
+
a token rule with a `launchpad` ModuleEntry attached + creates the token
|
|
61
|
+
entity referencing the new ruleRef. Single round-trip.
|
|
62
|
+
- `get(entityId)` → `EntityInfo`
|
|
63
|
+
- `listByOwner({ type? })` → `{ entities, count }`
|
|
64
|
+
|
|
65
|
+
### Added — NestJS providers (subpath: `@hsuite/smart-engines-sdk/nestjs`)
|
|
66
|
+
|
|
67
|
+
`SmartEngineModule.forRoot` / `.forRootAsync` now expose three injection
|
|
68
|
+
tokens consumers can `@Inject(...)`:
|
|
69
|
+
|
|
70
|
+
- `SDK_BAAS_CLIENT` — shared `BaasClient` instance
|
|
71
|
+
- `RULES_CLIENT` — `RulesClient` (alias for `baasClient.rules`)
|
|
72
|
+
- `ENTITIES_CLIENT` — `EntitiesClient` (alias for `baasClient.entities`)
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
class MyService {
|
|
76
|
+
constructor(
|
|
77
|
+
@Inject(RULES_CLIENT) private readonly rules: RulesClient,
|
|
78
|
+
@Inject(ENTITIES_CLIENT) private readonly entities: EntitiesClient,
|
|
79
|
+
) {}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`SmartEngineService` provider unchanged.
|
|
84
|
+
|
|
85
|
+
### Documentation
|
|
86
|
+
|
|
87
|
+
- Package README extended with a `## Rules — author + publish canonical
|
|
88
|
+
ValidatorRules` section, two new rows in the "Available clients" table,
|
|
89
|
+
and a pointer to the full developer guide.
|
|
90
|
+
- Complete developer guide added at
|
|
91
|
+
`docs/developers/libs/rules-engine.md#smart-app-sdk-guide` — covers
|
|
92
|
+
authoring paths, composer reference tables, publish + entity-create
|
|
93
|
+
end-to-end flow, `baas.rules.*` + `baas.entities.*` reference, and 7
|
|
94
|
+
common pitfalls.
|
|
95
|
+
|
|
96
|
+
### Cluster-side (FYI for SDK consumers — not in this package)
|
|
97
|
+
|
|
98
|
+
This SDK release lights up server-side endpoints already shipped on the
|
|
99
|
+
`smart-engines-multichain` cluster:
|
|
100
|
+
|
|
101
|
+
- Smart-host: `POST /api/rules/publish`, `GET /api/rules/:ts`,
|
|
102
|
+
`GET /api/rules` (listByOwner), `POST /api/rules/simulate`,
|
|
103
|
+
`GET /api/rules/:ts/versions`, `POST /api/rules/:ts/deprecate`,
|
|
104
|
+
`POST /api/entities/{createToken|createAccount|createTopic|createAgent|launchpad}`,
|
|
105
|
+
`GET /api/entities/:id`, `GET /api/entities` (PRs #949, #950).
|
|
106
|
+
- Smart-validator: `POST /api/v3/entities/create` wrapping
|
|
107
|
+
`EntityCreationOrchestrator.createMultisigEntity` for cluster-internal
|
|
108
|
+
service-mesh calls from smart-host (PR #956).
|
|
109
|
+
|
|
110
|
+
### Build
|
|
111
|
+
|
|
112
|
+
- tsup CJS bundle: `dist/index.js` 396 KB, `dist/nestjs/index.js` 326 KB,
|
|
113
|
+
`dist/pqc-verify/index.js` 8 KB.
|
|
114
|
+
- `dts-bundle-generator` outputs preserved for all three subpaths.
|
|
115
|
+
- `sideEffects: false` declared so consumers can tree-shake unused
|
|
116
|
+
sub-namespaces (`baas.rules` excludable if you don't use canonical rules,
|
|
117
|
+
etc.).
|
|
118
|
+
|
|
3
119
|
## 3.2.1 — 2026-05-16
|
|
4
120
|
|
|
5
121
|
**Documentation-only fix.** No runtime behavior change.
|
package/README.md
CHANGED
|
@@ -88,6 +88,8 @@ from the dev wallet used to authenticate.
|
|
|
88
88
|
| Client | Purpose |
|
|
89
89
|
|---|---|
|
|
90
90
|
| `BaasClient` | Authentication + database + storage + functions + messaging + deployment + agents |
|
|
91
|
+
| `baas.rules.*` | Publish / get / list / simulate / deprecate canonical `ValidatorRules` documents on HCS |
|
|
92
|
+
| `baas.entities.*` | Create canonical token / account / topic / agent entities (plus launchpad mega-helper), each bound to a published `ruleRef` |
|
|
91
93
|
| `SmartEngineClient` | Chain operations: account create, token create / mint / burn / freeze / wipe, transfers, HCS topics, TSS, IPFS |
|
|
92
94
|
| `SmartGatewayClient` | Gateway operations: routing, domains, DNS |
|
|
93
95
|
| `ValidatorAuthClient` | Standalone Web3 challenge-response auth (lower-level than `BaasClient.authenticate`) |
|
|
@@ -100,6 +102,55 @@ the cluster gateway. Set `pathPrefix: ''` for direct host access.
|
|
|
100
102
|
|
|
101
103
|
---
|
|
102
104
|
|
|
105
|
+
## Rules — author + publish canonical ValidatorRules
|
|
106
|
+
|
|
107
|
+
`ValidatorRules` are the canonical, HCS-pinned policy documents the cluster
|
|
108
|
+
quorum evaluates before signing any entity action (mint, burn, transfer,
|
|
109
|
+
trade, …). Smart-apps author rules locally (via templates or a fluent
|
|
110
|
+
builder), publish them to HCS via `baas.rules.publish`, and bind the
|
|
111
|
+
returned `ruleRef` into the entity at creation time via `baas.entities.*`.
|
|
112
|
+
Every action against the entity is then rules-checked + TSS-signed.
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { BaasClient, Rules } from '@hsuite/smart-engines-sdk';
|
|
116
|
+
|
|
117
|
+
// Template — opinionated fair-launch token with all knobs pre-set.
|
|
118
|
+
const rule = Rules.template.fairLaunch({
|
|
119
|
+
maxSupply: '1000000000',
|
|
120
|
+
mintWindow: { startsAt: '2026-06-01T00:00:00Z', endsAt: '2026-06-08T00:00:00Z' },
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const { ruleRef } = await baas.rules.publish(rule);
|
|
124
|
+
|
|
125
|
+
const token = await baas.entities.createToken({
|
|
126
|
+
chain: 'hedera',
|
|
127
|
+
name: 'Fair Launch Token',
|
|
128
|
+
symbol: 'FAIR',
|
|
129
|
+
decimals: 6,
|
|
130
|
+
ruleRef,
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
// Fluent builder — when you want to compose the rule yourself.
|
|
136
|
+
const rule = Rules.forToken()
|
|
137
|
+
.withSecurity('full') // 'none' | 'partial' | 'full'
|
|
138
|
+
.withOperations({
|
|
139
|
+
mint: { enabled: true, limits: { dailyLimit: '1000000' } },
|
|
140
|
+
burn: { enabled: true },
|
|
141
|
+
})
|
|
142
|
+
.withInvariants({ maxSupply: '1000000000' })
|
|
143
|
+
.build();
|
|
144
|
+
|
|
145
|
+
const { ruleRef } = await baas.rules.publish(rule);
|
|
146
|
+
const sim = await baas.rules.simulate({ ruleRef, action: 'mint', context: { amount: '500' } });
|
|
147
|
+
// sim.isValid === true | false (+ reason)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Full reference: [Smart-App SDK Guide](../../docs/developers/libs/rules-engine.md#smart-app-sdk-guide)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
103
154
|
## BaaS sub-clients
|
|
104
155
|
|
|
105
156
|
Once authenticated, every BaaS sub-client is reachable from a single
|