@scuro/sdk 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +294 -0
- package/dist/client.d.ts +2 -0
- package/dist/contracts.d.ts +47 -0
- package/dist/contracts.js +22451 -0
- package/dist/coordinator.d.ts +108 -0
- package/dist/coordinator.js +22586 -0
- package/dist/flows.d.ts +2 -0
- package/dist/flows.js +22625 -0
- package/dist/generated/abis.d.ts +12879 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/protocol.d.ts +13856 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +22863 -0
- package/dist/internal/enums.d.ts +11 -0
- package/dist/internal/errors.d.ts +23 -0
- package/dist/internal/types.d.ts +192 -0
- package/dist/internal/utils.d.ts +9 -0
- package/dist/manifest.d.ts +863 -0
- package/dist/manifest.js +18333 -0
- package/dist/registry.d.ts +12 -0
- package/dist/registry.js +21306 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +18416 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zachary Thielemann
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
# Scuro SDK
|
|
2
|
+
|
|
3
|
+
Bun-first TypeScript SDK for the Scuro protocol.
|
|
4
|
+
|
|
5
|
+
This package is aimed at Node/Bun integrators who need to:
|
|
6
|
+
|
|
7
|
+
- load Scuro protocol metadata and ABIs
|
|
8
|
+
- normalize deployment outputs into typed addresses and ids
|
|
9
|
+
- build typed `viem` contract reads and transaction requests
|
|
10
|
+
- use higher-level gameplay and staking helpers
|
|
11
|
+
- run coordinator-style poker and blackjack proof workflows
|
|
12
|
+
|
|
13
|
+
The SDK currently targets Bun first and standard Node server runtimes second. Browser support is out of scope for this version.
|
|
14
|
+
|
|
15
|
+
## Status
|
|
16
|
+
|
|
17
|
+
This is an early v1 scaffold with a working package surface, generated metadata pipeline, unit tests, and build output.
|
|
18
|
+
|
|
19
|
+
What is included:
|
|
20
|
+
|
|
21
|
+
- root client via `createScuroClient(...)`
|
|
22
|
+
- subpath-ready modules for `manifest`, `registry`, `contracts`, `flows`, `coordinator`, and `types`
|
|
23
|
+
- generated protocol manifest, enum labels, event signatures, proof-input metadata, and ABI constants
|
|
24
|
+
- typed tx builders for staking, governance, gameplay, settlement, engine-registry admin actions, proof submission, and supported factory deployments
|
|
25
|
+
- runtime helpers for NumberPicker, Slot Machine, Super Baccarat, Chemin de Fer, poker, and blackjack
|
|
26
|
+
- slot preset admin helpers and GameEngineRegistry read/write helpers
|
|
27
|
+
- poker and blackjack coordinator executors with injected proof providers
|
|
28
|
+
|
|
29
|
+
What is not included yet:
|
|
30
|
+
|
|
31
|
+
- bundled proof generation or witness tooling
|
|
32
|
+
- automatic fetching of AWS beta release manifests or actors records
|
|
33
|
+
- full live integration tests against a running local Scuro deployment
|
|
34
|
+
|
|
35
|
+
## Package layout
|
|
36
|
+
|
|
37
|
+
The package exports these entrypoints:
|
|
38
|
+
|
|
39
|
+
- `@scuro/sdk`
|
|
40
|
+
- `@scuro/sdk/manifest`
|
|
41
|
+
- `@scuro/sdk/registry`
|
|
42
|
+
- `@scuro/sdk/contracts`
|
|
43
|
+
- `@scuro/sdk/flows`
|
|
44
|
+
- `@scuro/sdk/coordinator`
|
|
45
|
+
- `@scuro/sdk/types`
|
|
46
|
+
|
|
47
|
+
The root entrypoint re-exports the main client constructor and the support modules.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
Use the prerelease channel while the SDK is aligned to the hosted beta network snapshot:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install @scuro/sdk@beta
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Use the stable channel only after a version has been intentionally promoted:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install @scuro/sdk
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick start
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
67
|
+
import { foundry } from "viem/chains";
|
|
68
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
69
|
+
import { createScuroClient, getDeploymentProfile } from "@scuro/sdk";
|
|
70
|
+
|
|
71
|
+
const deployment = getDeploymentProfile("anvil-local");
|
|
72
|
+
if (!deployment) {
|
|
73
|
+
throw new Error("missing anvil-local profile");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const publicClient = createPublicClient({
|
|
77
|
+
chain: foundry,
|
|
78
|
+
transport: http(deployment.rpcUrl)
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const walletClient = createWalletClient({
|
|
82
|
+
chain: foundry,
|
|
83
|
+
transport: http(deployment.rpcUrl),
|
|
84
|
+
account: privateKeyToAccount(deployment.privateKeys!.Admin!)
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const scuro = createScuroClient({
|
|
88
|
+
publicClient,
|
|
89
|
+
walletClient,
|
|
90
|
+
deployment
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const manifest = scuro.manifest.getProtocolManifest();
|
|
94
|
+
const approveTx = scuro.contracts.encode.approveSettlement(1000n);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Built-in deployment profiles currently include:
|
|
98
|
+
|
|
99
|
+
- `anvil-local` for local Foundry/Anvil development
|
|
100
|
+
- `testnet-beta` for the hosted private AWS beta pinned to the March 30, 2026 release handoff
|
|
101
|
+
|
|
102
|
+
Beta package releases should only move this checked-in `testnet-beta` snapshot intentionally when a new hosted deployment is promoted.
|
|
103
|
+
|
|
104
|
+
## Core concepts
|
|
105
|
+
|
|
106
|
+
### `manifest`
|
|
107
|
+
|
|
108
|
+
Use manifest helpers when you need checked-in protocol metadata, not chain state.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { getAbi, getContractMetadata, getProtocolManifest } from "@scuro/sdk/manifest";
|
|
112
|
+
|
|
113
|
+
const manifest = getProtocolManifest();
|
|
114
|
+
const settlementMeta = getContractMetadata("ProtocolSettlement");
|
|
115
|
+
const settlementAbi = getAbi("ProtocolSettlement");
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `registry`
|
|
119
|
+
|
|
120
|
+
Use registry helpers to work with built-in deployment profiles or normalize your own chain-specific deployment records.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { getDeploymentProfile, normalizeDeploymentLabels } from "@scuro/sdk/registry";
|
|
124
|
+
|
|
125
|
+
const hostedBeta = getDeploymentProfile("testnet-beta");
|
|
126
|
+
|
|
127
|
+
const deployment = normalizeDeploymentLabels({
|
|
128
|
+
ScuroToken: "0x1000000000000000000000000000000000000001",
|
|
129
|
+
GameCatalog: "0x1000000000000000000000000000000000000005",
|
|
130
|
+
NumberPickerModuleId: "1",
|
|
131
|
+
NumberPickerExpressionTokenId: "1"
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The built-in `testnet-beta` profile is a checked-in snapshot of the March 30, 2026 private AWS beta release record. The canonical source of truth remains the protocol release artifacts, and SDK updates should only change this profile intentionally when a new deployment is promoted.
|
|
136
|
+
|
|
137
|
+
### `contracts`
|
|
138
|
+
|
|
139
|
+
Use contract helpers when you want typed transaction preparation, direct reads, and low-level control over write submission.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
const tx = scuro.contracts.encode.startBlackjackHand({
|
|
143
|
+
wager: 10n,
|
|
144
|
+
playRef: "0x" + "11".repeat(32),
|
|
145
|
+
playerKeyCommitment: "0x" + "22".repeat(32)
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
const session = await scuro.contracts.read.blackjack.session(1n);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### `flows`
|
|
152
|
+
|
|
153
|
+
Use flow helpers when you want documented workflow steps with some state guards already applied.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
const stakingTxs = scuro.flows.staking.prepareApproveAndStake({
|
|
157
|
+
approveAmount: 1000n,
|
|
158
|
+
stakeAmount: 1000n,
|
|
159
|
+
delegatee: deployment.labels.Admin
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const blackjackActionTx = await scuro.flows.blackjack.prepareAction(7n, "doubleDown");
|
|
163
|
+
const slotTx = scuro.flows.slotMachine.prepareSpin({
|
|
164
|
+
stake: 10n,
|
|
165
|
+
presetId: 1n,
|
|
166
|
+
playRef: "0x" + "33".repeat(32),
|
|
167
|
+
expressionTokenId: 7n
|
|
168
|
+
});
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### `coordinator`
|
|
172
|
+
|
|
173
|
+
Use coordinator helpers for operational proof submission loops.
|
|
174
|
+
|
|
175
|
+
Proof generation stays outside the SDK. You inject proof providers that return the concrete calldata fields each engine expects.
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
const blackjackCoordinator = scuro.coordinator.blackjack({
|
|
179
|
+
proofProvider: {
|
|
180
|
+
async provideInitialDeal(snapshot) {
|
|
181
|
+
return buildInitialDealProof(snapshot);
|
|
182
|
+
},
|
|
183
|
+
async provideNext(snapshot) {
|
|
184
|
+
return buildNextBlackjackProof(snapshot);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await blackjackCoordinator.runUntilIdle(3n);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
More detail is in [docs/coordinators.md](./docs/coordinators.md).
|
|
193
|
+
|
|
194
|
+
## Supported helpers in this version
|
|
195
|
+
|
|
196
|
+
### Gameplay and protocol helpers
|
|
197
|
+
|
|
198
|
+
- staking approvals, stake, unstake, and delegation
|
|
199
|
+
- governance reads for threshold, delay, period, quorum, and state
|
|
200
|
+
- catalog reads for module metadata and launchability checks
|
|
201
|
+
- GameEngineRegistry reads and admin writes
|
|
202
|
+
- NumberPicker play/finalize helpers
|
|
203
|
+
- Slot Machine spin/settle helpers and slot preset admin helpers
|
|
204
|
+
- Super Baccarat play/settle helpers
|
|
205
|
+
- Chemin de Fer table lifecycle helpers
|
|
206
|
+
- PvP poker session create/settle helpers
|
|
207
|
+
- tournament poker create/start/report helpers
|
|
208
|
+
- blackjack start/action/timeout/settle helpers
|
|
209
|
+
- settlement tx builders
|
|
210
|
+
- event decoding through protocol ABIs
|
|
211
|
+
|
|
212
|
+
### Factory deployment helpers
|
|
213
|
+
|
|
214
|
+
Typed deployment-param encoders are included for:
|
|
215
|
+
|
|
216
|
+
- NumberPicker
|
|
217
|
+
- Blackjack
|
|
218
|
+
- Super Baccarat
|
|
219
|
+
- Slot Machine
|
|
220
|
+
- Poker Single Draw 2-7
|
|
221
|
+
- Chemin de Fer Baccarat
|
|
222
|
+
|
|
223
|
+
Unsupported or underdocumented families should use the raw factory escape hatches. For the new solo and chemin modules, gameplay helpers require explicit `expressionTokenId` values rather than relying on built-in local profile defaults.
|
|
224
|
+
|
|
225
|
+
## Generated metadata
|
|
226
|
+
|
|
227
|
+
The SDK does not read the sibling Scuro repo at runtime.
|
|
228
|
+
|
|
229
|
+
Instead, `bun run generate-protocol` uses the checked-in upstream generated metadata as a base, then supplements missing module surfaces from sibling protocol artifacts:
|
|
230
|
+
|
|
231
|
+
- `../scuro/docs/generated/protocol-manifest.json`
|
|
232
|
+
- `../scuro/docs/generated/enum-labels.json`
|
|
233
|
+
- `../scuro/docs/generated/event-signatures.json`
|
|
234
|
+
- `../scuro/docs/generated/proof-inputs.json`
|
|
235
|
+
- `../scuro/docs/generated/contracts/*.abi.json`
|
|
236
|
+
- `../scuro/out/SlotMachine*.json`
|
|
237
|
+
- `../scuro/out/SuperBaccarat*.json`
|
|
238
|
+
- `../scuro/out/CheminDeFer*.json`
|
|
239
|
+
- `../scuro/out/ICheminDeFerEngine.sol/ICheminDeFerEngine.json`
|
|
240
|
+
|
|
241
|
+
The generated output is written into [`src/generated`](./src/generated).
|
|
242
|
+
|
|
243
|
+
## Development
|
|
244
|
+
|
|
245
|
+
Install dependencies:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
bun install
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Regenerate protocol metadata:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
bun run generate-protocol
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Run checks:
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
bun test
|
|
261
|
+
bun run typecheck
|
|
262
|
+
bun run build
|
|
263
|
+
bun run smoke:node
|
|
264
|
+
bun run release:check
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
More detail is in [docs/development.md](./docs/development.md).
|
|
268
|
+
The maintainer release playbook lives in [docs/releasing.md](./docs/releasing.md).
|
|
269
|
+
|
|
270
|
+
## Release preparation
|
|
271
|
+
|
|
272
|
+
The package is set up to publish from built `dist/` output only.
|
|
273
|
+
|
|
274
|
+
Useful preflight commands:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
bun run release:check
|
|
278
|
+
bun run release:pack
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
`bun run release:check` runs tests, typechecking, a fresh build, and a local release verification pass that confirms the exported files exist.
|
|
282
|
+
`bun run release:pack` writes the tarball to `.artifacts/releases/` so release artifacts stay out of the repo root.
|
|
283
|
+
|
|
284
|
+
GitHub Actions workflows are included for:
|
|
285
|
+
|
|
286
|
+
- CI on pull requests and pushes to `main`
|
|
287
|
+
- npm publish on GitHub Release publication, with prereleases publishing to the npm `beta` dist-tag and stable releases publishing to `latest`
|
|
288
|
+
- optional beta testnet RPC smoke checks when `ENABLE_BETA_RPC_SMOKE=true`
|
|
289
|
+
|
|
290
|
+
## Notes and caveats
|
|
291
|
+
|
|
292
|
+
- The built-in registry currently ships `anvil-local` and the pinned `testnet-beta` hosted profile.
|
|
293
|
+
- The coordinator layer is designed for server-side orchestration, not browser automation.
|
|
294
|
+
- Public helper types are intentionally lightweight in this revision to keep declaration output stable while the API is still settling.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { eventSignatures } from "./generated/protocol";
|
|
3
|
+
import type { CreateScuroClientOptions, ScuroContractHelpers } from "./internal/types";
|
|
4
|
+
export declare function decodeScuroEventLog(contract: keyof typeof eventSignatures | "TournamentPokerEngine" | "PvPPokerEngine" | "TournamentPokerVerifierBundle" | "PvPPokerVerifierBundle", log: {
|
|
5
|
+
data: Hex;
|
|
6
|
+
topics: readonly Hex[];
|
|
7
|
+
}): {
|
|
8
|
+
eventName: undefined;
|
|
9
|
+
args: readonly unknown[] | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare function encodeNumberPickerDeployment(params: {
|
|
12
|
+
vrfCoordinator: Address;
|
|
13
|
+
configHash: Hex;
|
|
14
|
+
developerRewardBps: number;
|
|
15
|
+
}): `0x${string}`;
|
|
16
|
+
export declare function encodeBlackjackDeployment(params: {
|
|
17
|
+
coordinator: Address;
|
|
18
|
+
defaultActionWindow: bigint;
|
|
19
|
+
configHash: Hex;
|
|
20
|
+
developerRewardBps: number;
|
|
21
|
+
}): `0x${string}`;
|
|
22
|
+
export declare function encodeSuperBaccaratDeployment(params: {
|
|
23
|
+
vrfCoordinator: Address;
|
|
24
|
+
configHash: Hex;
|
|
25
|
+
developerRewardBps: number;
|
|
26
|
+
}): `0x${string}`;
|
|
27
|
+
export declare function encodeSlotMachineDeployment(params: {
|
|
28
|
+
vrfCoordinator: Address;
|
|
29
|
+
configHash: Hex;
|
|
30
|
+
developerRewardBps: number;
|
|
31
|
+
}): `0x${string}`;
|
|
32
|
+
export declare function encodePokerDeployment(params: {
|
|
33
|
+
coordinator: Address;
|
|
34
|
+
smallBlind: bigint;
|
|
35
|
+
bigBlind: bigint;
|
|
36
|
+
blindEscalationInterval: bigint;
|
|
37
|
+
actionWindow: bigint;
|
|
38
|
+
configHash: Hex;
|
|
39
|
+
developerRewardBps: number;
|
|
40
|
+
}): `0x${string}`;
|
|
41
|
+
export declare function encodeCheminDeFerDeployment(params: {
|
|
42
|
+
vrfCoordinator: Address;
|
|
43
|
+
joinWindow: bigint;
|
|
44
|
+
configHash: Hex;
|
|
45
|
+
developerRewardBps: number;
|
|
46
|
+
}): `0x${string}`;
|
|
47
|
+
export declare function createContractHelpers(options: CreateScuroClientOptions): ScuroContractHelpers;
|