@unicitylabs/sphere-sdk 0.17.6 → 0.18.0-dev.2
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/dist/connect/chunks/{chunk-T4DZCXWS.js → chunk-FGQ6CKKK.js} +2 -2
- package/dist/connect/chunks/{chunk-T4DZCXWS.js.map → chunk-FGQ6CKKK.js.map} +1 -1
- package/dist/connect/chunks/{chunk-BRYRG2TL.js → chunk-JYBI36GK.js} +2 -2
- package/dist/connect/chunks/{chunk-MA32MTCD.js → chunk-OAAY2JEA.js} +2 -2
- package/dist/connect/index.cjs +1 -1
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.js +3 -3
- package/dist/connect/internal/host.js +2 -2
- package/dist/core/index.cjs +304 -47
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +392 -320
- package/dist/core/index.d.ts +392 -320
- package/dist/core/index.js +304 -47
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs +1 -1
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js +2 -2
- package/dist/impl/wallet-api-v2/index.cjs +2 -0
- package/dist/impl/wallet-api-v2/index.cjs.map +1 -1
- package/dist/impl/wallet-api-v2/index.d.cts +30 -30
- package/dist/impl/wallet-api-v2/index.d.ts +30 -30
- package/dist/impl/wallet-api-v2/index.js +2 -0
- package/dist/impl/wallet-api-v2/index.js.map +1 -1
- package/dist/index.cjs +304 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +279 -154
- package/dist/index.d.ts +279 -154
- package/dist/index.js +304 -47
- package/dist/index.js.map +1 -1
- package/dist/modules/payments-v2/index.cjs +249 -28
- package/dist/modules/payments-v2/index.cjs.map +1 -1
- package/dist/modules/payments-v2/index.d.cts +252 -166
- package/dist/modules/payments-v2/index.d.ts +252 -166
- package/dist/modules/payments-v2/index.js +249 -28
- package/dist/modules/payments-v2/index.js.map +1 -1
- package/dist/token-engine/index.cjs +455 -427
- package/dist/token-engine/index.cjs.map +1 -1
- package/dist/token-engine/index.d.cts +26 -1
- package/dist/token-engine/index.d.ts +26 -1
- package/dist/token-engine/index.js +455 -427
- package/dist/token-engine/index.js.map +1 -1
- package/package.json +1 -1
- /package/dist/connect/chunks/{chunk-BRYRG2TL.js.map → chunk-JYBI36GK.js.map} +0 -0
- /package/dist/connect/chunks/{chunk-MA32MTCD.js.map → chunk-OAAY2JEA.js.map} +0 -0
package/dist/core/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IMintJustificationVerifier } from '@unicitylabs/state-transition-sdk/lib/transaction/verification/IMintJustificationVerifier.js';
|
|
1
2
|
import { Token as Token$1 } from '@unicitylabs/state-transition-sdk/lib/transaction/Token.js';
|
|
2
3
|
import { NostrClient, NostrKeyManager } from '@unicitylabs/nostr-js-sdk';
|
|
3
4
|
|
|
@@ -218,6 +219,23 @@ interface MintDataTokenParams {
|
|
|
218
219
|
readonly tokenType?: Uint8Array;
|
|
219
220
|
/** Salt bytes; deterministic salt → deterministic (terms-derived) tokenId. */
|
|
220
221
|
readonly salt?: Uint8Array;
|
|
222
|
+
/** Genesis mint reason (the SDK's `justification`): tagged CBOR a registered verifier validates. */
|
|
223
|
+
readonly justification?: Uint8Array;
|
|
224
|
+
/** Verifiers for this mint's genesis reason, in place of the ones registered on the engine. */
|
|
225
|
+
readonly mintJustificationVerifiers?: readonly IMintJustificationVerifier[];
|
|
226
|
+
}
|
|
227
|
+
/** Spend a token to a burn predicate with the reason bytes as aux data. */
|
|
228
|
+
interface BurnParams {
|
|
229
|
+
readonly token: SphereToken;
|
|
230
|
+
/** The recipient predicate is `BurnPredicate(sha256(reasonBytes))`; the bytes ride in the aux data. */
|
|
231
|
+
readonly reasonBytes: Uint8Array;
|
|
232
|
+
}
|
|
233
|
+
/** Mint-reason verifiers keyed by CBOR tag, registered at engine construction. */
|
|
234
|
+
interface TokenPlugin {
|
|
235
|
+
/** Stable identifier for diagnostics, e.g. `'bridge:tron-usdt'`. */
|
|
236
|
+
readonly id: string;
|
|
237
|
+
/** Mint-reason verifiers to register; a duplicate tag across plugins is INVALID_CONFIG. */
|
|
238
|
+
readonly mintJustificationVerifiers?: readonly IMintJustificationVerifier[];
|
|
221
239
|
}
|
|
222
240
|
/** Plan an NFT mint (#785); `mintDataToken` then mints the plan. */
|
|
223
241
|
interface BuildNftMintParams {
|
|
@@ -290,134 +308,205 @@ interface NftReading {
|
|
|
290
308
|
readonly signature: NftSignatureStatus;
|
|
291
309
|
}
|
|
292
310
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
amount: string;
|
|
322
|
-
symbol?: string;
|
|
323
|
-
timestamp: number;
|
|
324
|
-
memo?: string;
|
|
325
|
-
transferId?: string;
|
|
326
|
-
tokenId?: string;
|
|
327
|
-
senderPubkey?: string;
|
|
328
|
-
senderNametag?: string;
|
|
329
|
-
recipientPubkey?: string;
|
|
330
|
-
recipientNametag?: string;
|
|
331
|
-
tokenIds?: {
|
|
332
|
-
id: string;
|
|
333
|
-
amount: string;
|
|
334
|
-
}[];
|
|
335
|
-
}
|
|
336
|
-
interface HistoryPage {
|
|
337
|
-
entries: HistoryEntry[];
|
|
338
|
-
more: boolean;
|
|
339
|
-
cursor: string | null;
|
|
311
|
+
/**
|
|
312
|
+
* token-engine/engine.ts — the FROZEN public port (ITokenEngine) + its config.
|
|
313
|
+
*
|
|
314
|
+
* This is the contract both migration tracks build against. It is sphere-domain
|
|
315
|
+
* only (see types.ts). The granular, SDK-typed steps (buildMint, submit,
|
|
316
|
+
* awaitProof, certify, …) are an INTERNAL concern of the real adapter and are
|
|
317
|
+
* intentionally NOT part of this public interface.
|
|
318
|
+
*/
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Durable, any-device store for a split's burn checkpoint (sdk-changes E.4, sphere-sdk#501
|
|
322
|
+
* option b). The engine passes opaque PLAINTEXT bytes; a transport adapter (the wallet-api
|
|
323
|
+
* provider) is responsible for AAD-encryption and the wallet-api §16 intent-progress round-trip.
|
|
324
|
+
*
|
|
325
|
+
* The store is the resume seed for the one split input the engine cannot re-derive — the burn's
|
|
326
|
+
* aggregator-issued inclusion proof — so the mint justification is rebuilt from stored bytes, not
|
|
327
|
+
* a refetch (the aggregator regenerates proofs per request).
|
|
328
|
+
*/
|
|
329
|
+
interface SplitCheckpointStore {
|
|
330
|
+
/**
|
|
331
|
+
* Insert-once, first-write-wins. MUST resolve only AFTER the store acked durability, and MUST
|
|
332
|
+
* resolve with the AUTHORITATIVE stored bytes — the caller's own on a fresh write, or the FIRST
|
|
333
|
+
* writer's when the slot `(transferId, opIndex)` was already taken (the caller adopts those and
|
|
334
|
+
* mints from them, so concurrent resumers converge on one burn proof).
|
|
335
|
+
*/
|
|
336
|
+
put(transferId: string, opIndex: number, bytes: Uint8Array): Promise<Uint8Array>;
|
|
337
|
+
/** The stored bytes for the slot, or `null` when none exists. */
|
|
338
|
+
get(transferId: string, opIndex: number): Promise<Uint8Array | null>;
|
|
340
339
|
}
|
|
341
|
-
|
|
342
|
-
interface
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
340
|
+
/** Options common to the long-running, network-bound operations. */
|
|
341
|
+
interface EngineOpOptions {
|
|
342
|
+
/** Cancels the operation (including inclusion-proof polling). */
|
|
343
|
+
readonly signal?: AbortSignal;
|
|
344
|
+
/**
|
|
345
|
+
* Durable burn-checkpoint store for a resumable split (sdk-changes E.4, sphere-sdk#501). When
|
|
346
|
+
* present, `split()` persists the burn's certified proof AND awaits its durable ack BEFORE
|
|
347
|
+
* submitting any mint leg, and rebuilds the mint justification from the stored bytes on resume —
|
|
348
|
+
* so a split resumed after any mint leg certified recovers instead of stranding its outputs.
|
|
349
|
+
*
|
|
350
|
+
* Absent keeps today's behavior (a fresh burn proof per attempt): fine for a mid-split resume
|
|
351
|
+
* with no mint yet certified, but a split resumed AFTER a mint certified cannot recover — a
|
|
352
|
+
* documented residual for fully-local compositions; the live path MUST supply the store.
|
|
353
|
+
*/
|
|
354
|
+
readonly checkpointStore?: SplitCheckpointStore;
|
|
355
|
+
/**
|
|
356
|
+
* Realization seed for deterministic transfer/split (Part E, sdk-changes E.1/E.3):
|
|
357
|
+
* a client-generated UUIDv4 in canonical lowercase string form. Every value the
|
|
358
|
+
* transaction binds to (stateMask, per-output salts) is HKDF-derived from the
|
|
359
|
+
* wallet key + this id, so re-calling the op with the same `transferId` and
|
|
360
|
+
* inputs rebuilds the byte-identical transaction and resumes an interrupted
|
|
361
|
+
* attempt instead of losing funds. Persist it BEFORE calling the engine.
|
|
362
|
+
*
|
|
363
|
+
* If absent, the engine generates one internally (`crypto.randomUUID()`) — the
|
|
364
|
+
* derivation path is identical, but the call is NOT resumable (the seed is
|
|
365
|
+
* gone if the process dies mid-op).
|
|
366
|
+
*/
|
|
367
|
+
readonly transferId?: string;
|
|
368
|
+
/**
|
|
369
|
+
* Ordinal of this engine op WITHIN one logical send sharing a `transferId`
|
|
370
|
+
* (ARCHITECTURE §7: D whole-token transfers + at most one split under ONE
|
|
371
|
+
* intent). It indexes the op-level HKDF derivations (`stateMask`, the split
|
|
372
|
+
* `burn` mask) so distinct ops never reuse a mask — §8.1's "per-transfer
|
|
373
|
+
* unique". Per-output split salts are indexed by output ordinal in their own
|
|
374
|
+
* `salt` field domain; callers MUST NOT run two splits under one transferId.
|
|
375
|
+
* Default 0 (single-op sends). Resume MUST replay the same (transferId,
|
|
376
|
+
* opIndex) pairing per source.
|
|
377
|
+
*/
|
|
378
|
+
readonly opIndex?: number;
|
|
353
379
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
380
|
+
/**
|
|
381
|
+
* The token engine port. The wallet's secp256k1 identity, the target network,
|
|
382
|
+
* the aggregator client and the trust base are all bound at construction
|
|
383
|
+
* (see EngineConfig); operations below take only sphere-domain arguments.
|
|
384
|
+
*/
|
|
385
|
+
interface ITokenEngine {
|
|
386
|
+
/** This engine's wallet identity (chain pubkey). Synchronous. */
|
|
387
|
+
getIdentity(): EngineIdentity;
|
|
388
|
+
/**
|
|
389
|
+
* Legacy `DIRECT://` address for the given pubkey (defaults to this engine's
|
|
390
|
+
* identity). This is the ONLY "address" in v2 and is kept stable across the
|
|
391
|
+
* migration (Path A) so Quest XP / Unicity IDs keyed on it survive. Async —
|
|
392
|
+
* the derivation hashes via the SDK.
|
|
393
|
+
*/
|
|
394
|
+
deriveIdentityAddress(pubkey?: Uint8Array): Promise<string>;
|
|
395
|
+
/**
|
|
396
|
+
* Genesis-stable token id — 64-char lowercase hex of the v2 TokenId (same
|
|
397
|
+
* across every state). Use for dedup / history / tombstone keys. Synchronous.
|
|
398
|
+
*/
|
|
399
|
+
tokenId(token: SphereToken): string;
|
|
400
|
+
/** Decoded value of a token (cached). Synchronous. */
|
|
401
|
+
readValue(token: SphereToken): SphereValue | null;
|
|
402
|
+
/** Balance of a single coin within a token. Synchronous. */
|
|
403
|
+
balanceOf(token: SphereToken, coinId: CoinId): bigint;
|
|
404
|
+
/**
|
|
405
|
+
* The opaque on-chain memo delivered with this token: the latest transfer's
|
|
406
|
+
* data for a transferred token, else the memo in a minted output's value
|
|
407
|
+
* envelope (split). Returns `null` when there is no memo — including for data
|
|
408
|
+
* tokens (no value envelope; use `readTokenData`) and memo-less value tokens.
|
|
409
|
+
* To tell a data token from a value token, check `readValue` (null ⇒
|
|
410
|
+
* data/value-less token). Synchronous.
|
|
411
|
+
*/
|
|
412
|
+
readMemo(token: SphereToken): Uint8Array | null;
|
|
413
|
+
/** Raw genesis data of a token (e.g. a data-token's terms). `null` when absent. Synchronous. */
|
|
414
|
+
readTokenData(token: SphereToken): Uint8Array | null;
|
|
415
|
+
/** The genesis mint reason (`justification`) of a token; `null` when it was minted without one. Synchronous. */
|
|
416
|
+
readTokenJustification(token: SphereToken): Uint8Array | null;
|
|
417
|
+
/** Read a token's genesis payload as an NFT. NEVER throws; null = not a recognised NFT. */
|
|
418
|
+
readNft(token: SphereToken): Promise<NftReading | null>;
|
|
419
|
+
/**
|
|
420
|
+
* Mint (issue) a new token to a recipient pubkey. NOT a wallet end-user flow —
|
|
421
|
+
* this is the issuer/developer capability: an app issuing its own tokens
|
|
422
|
+
* (rewards, in-app currency, tickets) to users, or seeding test balances. v2
|
|
423
|
+
* makes standalone mint first-class (Token.mint accepts a genesis with a null
|
|
424
|
+
* justification). Split's per-output mint is a separate, internal path; the
|
|
425
|
+
* Unicity-ID/nametag mint is a distinct identity surface (see migration plan §4.4).
|
|
426
|
+
*/
|
|
427
|
+
mint(params: MintParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
428
|
+
/**
|
|
429
|
+
* Mint a NON-value (data) token: opaque `data` + custom `tokenType` + deterministic
|
|
430
|
+
* `salt` → a stable, terms-derived `tokenId`. The result has `value === null`;
|
|
431
|
+
* read its bytes via `readTokenData`. (Used e.g. for on-chain invoice tokens.)
|
|
432
|
+
*/
|
|
433
|
+
mintDataToken(params: MintDataTokenParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
434
|
+
/** Plan an NFT mint: encode (and optionally sign as this engine's identity) the payload and derive its token id. No chain op. */
|
|
435
|
+
buildNftMint(params: BuildNftMintParams): Promise<NftMintPlan>;
|
|
436
|
+
/** Spend a token wholesale to a recipient pubkey; returns the recipient's finished token. */
|
|
437
|
+
transfer(params: TransferParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
438
|
+
/** Spend the token to `BurnPredicate(sha256(reasonBytes))` with the reason bytes as aux data. */
|
|
439
|
+
burn(params: BurnParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
440
|
+
/** Split a token into N value-conserving outputs (burn source + internally mint each output). */
|
|
441
|
+
split(params: SplitParams, options?: EngineOpOptions): Promise<SplitResult>;
|
|
442
|
+
/** Fully verify a token against the trust base. */
|
|
443
|
+
verify(token: SphereToken, options?: EngineOpOptions): Promise<EngineVerifyResult>;
|
|
444
|
+
/** Whether the token's current state has already been spent on the network. */
|
|
445
|
+
isSpent(token: SphereToken, options?: EngineOpOptions): Promise<boolean>;
|
|
446
|
+
/**
|
|
447
|
+
* Whether the token's CURRENT state is locked to `SignaturePredicate(pubkey)`.
|
|
448
|
+
* Local + synchronous (predicate byte-compare, no network). The receive path
|
|
449
|
+
* uses it to reject tokens that are not actually addressed to this wallet.
|
|
450
|
+
*/
|
|
451
|
+
isOwnedBy(token: SphereToken, pubkey: Uint8Array): boolean;
|
|
452
|
+
/** Serialize a token for storage/transport. Synchronous. */
|
|
453
|
+
encodeToken(token: SphereToken): TokenBlob;
|
|
454
|
+
/** Reconstruct a token from its blob (decodes embedded payment data). */
|
|
455
|
+
decodeToken(blob: TokenBlob): Promise<SphereToken>;
|
|
456
|
+
/**
|
|
457
|
+
* The backend-true delivery keys for encoded TokenBlob bytes: the
|
|
458
|
+
* genesis-stable tokenId and the SDK's PROTOCOL state hash of the latest
|
|
459
|
+
* state (DataHash imprint, hex). wallet-api keys mailbox entries on exactly
|
|
460
|
+
* this pair (entry_id = SHA-256(tokenId ‖ stateHash); §8.2 step 4 validates
|
|
461
|
+
* a deposit's claimed stateHash against it) — a plain hash over the token
|
|
462
|
+
* bytes is NOT this value and 422s on deposit. Delivery implementations MUST
|
|
463
|
+
* derive their ids through this method, never locally.
|
|
464
|
+
*/
|
|
465
|
+
deliveryKeys(blobBytes: Uint8Array): Promise<{
|
|
466
|
+
tokenId: string;
|
|
467
|
+
stateHash: string;
|
|
363
468
|
}>;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
469
|
+
/**
|
|
470
|
+
* Release engine-owned OS resources — today only the verification worker pool.
|
|
471
|
+
* Idempotent; optional because an engine owning none need not define it.
|
|
472
|
+
*/
|
|
473
|
+
dispose?(): void;
|
|
368
474
|
}
|
|
369
475
|
/**
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
476
|
+
* Engine construction config. Sphere-domain inputs only: the factory maps
|
|
477
|
+
* `network` → SDK NetworkId, builds the aggregator client from `aggregatorUrl`,
|
|
478
|
+
* the signing service from `privateKey`, and loads the trust base internally.
|
|
479
|
+
*
|
|
480
|
+
* NOTE: trust-base sourcing + proof-policy defaults are finalized in Phase 0.8;
|
|
481
|
+
* this shape may gain fields there without affecting the ITokenEngine contract.
|
|
374
482
|
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
483
|
+
/**
|
|
484
|
+
* The web-`Worker` subset the verification pool drives (in Node wrap a `worker_threads.Worker`).
|
|
485
|
+
* A browser `Worker` has these members, but under `strictFunctionTypes` its `ErrorEvent` /
|
|
486
|
+
* `MessageEvent` handler types are not assignable here (TS2322), so it needs a cast or a thin
|
|
487
|
+
* wrapper. Payloads stay `unknown` so no base-SDK wire type reaches this port.
|
|
488
|
+
*/
|
|
489
|
+
interface VerificationWorker {
|
|
490
|
+
onerror: ((event: {
|
|
491
|
+
message: string;
|
|
492
|
+
}) => void) | null;
|
|
493
|
+
onmessage: ((event: {
|
|
494
|
+
data: unknown;
|
|
495
|
+
}) => void) | null;
|
|
496
|
+
postMessage(message: unknown): void;
|
|
497
|
+
terminate(): void;
|
|
389
498
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
nft(tokenId: string): Promise<NftView | null>;
|
|
402
|
-
/** Batch read for list views. Ids not held, blobs missing or undecodable, and non-NFT payloads are simply absent from the map. Throws only on a transport failure. */
|
|
403
|
-
nfts(tokenIds: readonly string[]): Promise<ReadonlyMap<string, NftView>>;
|
|
404
|
-
history(page?: {
|
|
405
|
-
before?: string;
|
|
406
|
-
limit?: number;
|
|
407
|
-
}): Promise<HistoryPage>;
|
|
408
|
-
send(req: SendRequest): Promise<TransferResult>;
|
|
409
|
-
sendWholeToken(req: SendWholeTokenRequest): Promise<TransferResult>;
|
|
410
|
-
/** NFT-scoped twin: refuses a valued source. Connect's `send_nft` routes here. */
|
|
411
|
-
sendCoinless(req: SendWholeTokenRequest): Promise<TransferResult>;
|
|
412
|
-
mint(coinId: string, amount: bigint): Promise<MintResult>;
|
|
413
|
-
mintNft(request: MintNftRequest): Promise<MintResult>;
|
|
414
|
-
receive(): Promise<{
|
|
415
|
-
transfers: IncomingTransfer[];
|
|
416
|
-
}>;
|
|
417
|
-
pendingTransfers(): Promise<PendingTransfer[]>;
|
|
418
|
-
resumeNow(): Promise<void>;
|
|
419
|
-
connectionStatus(): ConnectionStatus$1;
|
|
420
|
-
readonly requests: PaymentsRequestsApi;
|
|
499
|
+
/**
|
|
500
|
+
* Opt-in PARALLEL token verification (state-transition-sdk 2.0.2+): per-transfer
|
|
501
|
+
* work fans out to a worker pool instead of walking the calling thread. You
|
|
502
|
+
* author and bundle the entry script, and its predicate verifier MUST match the
|
|
503
|
+
* engine's or the verdict silently diverges — docs/VERIFICATION-WORKERS.md.
|
|
504
|
+
*/
|
|
505
|
+
interface VerificationWorkerConfig {
|
|
506
|
+
/** Spawn ONE worker running that entry script. Called lazily, up to `poolSize` times. */
|
|
507
|
+
readonly createWorker: () => VerificationWorker;
|
|
508
|
+
/** Maximum workers in the pool (default 4). Workers are reused across verify() calls. */
|
|
509
|
+
readonly poolSize?: number;
|
|
421
510
|
}
|
|
422
511
|
|
|
423
512
|
/**
|
|
@@ -523,9 +612,179 @@ declare class PartialSendConflictError extends SphereError {
|
|
|
523
612
|
*/
|
|
524
613
|
declare function isPossiblyCommittedSendOutcome(err: unknown): boolean;
|
|
525
614
|
/**
|
|
526
|
-
* Type guard to check if an error is a SphereError
|
|
615
|
+
* Type guard to check if an error is a SphereError
|
|
616
|
+
*/
|
|
617
|
+
declare function isSphereError(err: unknown): err is SphereError;
|
|
618
|
+
|
|
619
|
+
interface SendRequest {
|
|
620
|
+
recipient: string;
|
|
621
|
+
amount: string;
|
|
622
|
+
coinId: string;
|
|
623
|
+
memo?: string;
|
|
624
|
+
}
|
|
625
|
+
interface SendWholeTokenRequest {
|
|
626
|
+
recipient: string;
|
|
627
|
+
tokenId: string;
|
|
628
|
+
memo?: string;
|
|
629
|
+
}
|
|
630
|
+
interface MintResult {
|
|
631
|
+
success: boolean;
|
|
632
|
+
tokenId?: string;
|
|
633
|
+
error?: string;
|
|
634
|
+
}
|
|
635
|
+
/** Custom-genesis mint (a TokenPlugin's token), always to this wallet; `assets` = what the payload declares. */
|
|
636
|
+
interface MintCustomRequest {
|
|
637
|
+
readonly tokenType: Uint8Array;
|
|
638
|
+
readonly salt: Uint8Array;
|
|
639
|
+
readonly data: Uint8Array;
|
|
640
|
+
readonly justification?: Uint8Array;
|
|
641
|
+
readonly assets: readonly {
|
|
642
|
+
coinId: string;
|
|
643
|
+
amount: bigint;
|
|
644
|
+
}[];
|
|
645
|
+
readonly mintJustificationVerifiers?: readonly IMintJustificationVerifier[];
|
|
646
|
+
}
|
|
647
|
+
/** Burn a held token to `BurnPredicate(sha256(reasonBytes))` with the bytes as aux data. */
|
|
648
|
+
interface BurnRequest {
|
|
649
|
+
readonly tokenId: string;
|
|
650
|
+
readonly reasonBytes: Uint8Array;
|
|
651
|
+
}
|
|
652
|
+
interface BurnResult {
|
|
653
|
+
success: boolean;
|
|
654
|
+
burnId: string;
|
|
655
|
+
tokenId: string;
|
|
656
|
+
/** The burned blob, the proof of the burn: persist it, then `acknowledgeBurn(burnId)`. */
|
|
657
|
+
burnedToken?: Uint8Array;
|
|
658
|
+
error?: string;
|
|
659
|
+
}
|
|
660
|
+
/** A burn not yet acknowledged: in flight (`burnedToken` null), certified, or settled. */
|
|
661
|
+
interface PendingBurn {
|
|
662
|
+
readonly burnId: string;
|
|
663
|
+
readonly tokenId: string;
|
|
664
|
+
readonly reasonBytes: Uint8Array;
|
|
665
|
+
readonly burnedToken: Uint8Array | null;
|
|
666
|
+
readonly settled: boolean;
|
|
667
|
+
readonly createdAt: number;
|
|
668
|
+
}
|
|
669
|
+
/** #785: `content` uses ERC-721 field names; `sign` (default true) signs as creator with this wallet's chain key. */
|
|
670
|
+
interface MintNftRequest {
|
|
671
|
+
readonly content: NftContent;
|
|
672
|
+
readonly sign?: boolean;
|
|
673
|
+
}
|
|
674
|
+
interface NftView extends NftReading {
|
|
675
|
+
readonly tokenId: string;
|
|
676
|
+
}
|
|
677
|
+
interface HistoryEntry {
|
|
678
|
+
id: string;
|
|
679
|
+
type: 'SENT' | 'RECEIVED' | 'MINT';
|
|
680
|
+
coinId: string;
|
|
681
|
+
amount: string;
|
|
682
|
+
symbol?: string;
|
|
683
|
+
timestamp: number;
|
|
684
|
+
memo?: string;
|
|
685
|
+
transferId?: string;
|
|
686
|
+
tokenId?: string;
|
|
687
|
+
senderPubkey?: string;
|
|
688
|
+
senderNametag?: string;
|
|
689
|
+
recipientPubkey?: string;
|
|
690
|
+
recipientNametag?: string;
|
|
691
|
+
tokenIds?: {
|
|
692
|
+
id: string;
|
|
693
|
+
amount: string;
|
|
694
|
+
}[];
|
|
695
|
+
}
|
|
696
|
+
interface HistoryPage {
|
|
697
|
+
entries: HistoryEntry[];
|
|
698
|
+
more: boolean;
|
|
699
|
+
cursor: string | null;
|
|
700
|
+
}
|
|
701
|
+
type PaymentRequestStatus = 'pending' | 'settling' | 'paid' | 'rejected' | 'expired';
|
|
702
|
+
interface PaymentRequestView {
|
|
703
|
+
id: string;
|
|
704
|
+
requestId: string;
|
|
705
|
+
senderPubkey: string;
|
|
706
|
+
senderNametag?: string;
|
|
707
|
+
amount: string;
|
|
708
|
+
coinId: string;
|
|
709
|
+
symbol?: string;
|
|
710
|
+
message?: string;
|
|
711
|
+
timestamp: number;
|
|
712
|
+
status: PaymentRequestStatus;
|
|
713
|
+
}
|
|
714
|
+
interface PaymentsRequestsApi {
|
|
715
|
+
create(to: string, terms: {
|
|
716
|
+
coinId: string;
|
|
717
|
+
amount: string;
|
|
718
|
+
memo?: string;
|
|
719
|
+
}): Promise<{
|
|
720
|
+
success: boolean;
|
|
721
|
+
requestId?: string;
|
|
722
|
+
error?: string;
|
|
723
|
+
}>;
|
|
724
|
+
list(): PaymentRequestView[];
|
|
725
|
+
pay(id: string): Promise<TransferResult>;
|
|
726
|
+
decline(id: string): Promise<void>;
|
|
727
|
+
dismissProcessed(): void;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* A pending-transfers row, derived ON READ from the §6 stores (intent backstop
|
|
731
|
+
* + delivery journal + shortfalls) — never a cached mirror. kind 'shortfall' =
|
|
732
|
+
* a completed partial (#690) whose `amount` is the remainder still owed;
|
|
733
|
+
* legs.certified counts journaled legs (certified, delivery still owed).
|
|
527
734
|
*/
|
|
528
|
-
|
|
735
|
+
interface PendingTransfer {
|
|
736
|
+
transferId: string;
|
|
737
|
+
kind: 'open' | 'shortfall';
|
|
738
|
+
recipient: string;
|
|
739
|
+
coinId: string;
|
|
740
|
+
amount: string;
|
|
741
|
+
/** Set instead of coinId/amount when the intent is a token-addressed spend. */
|
|
742
|
+
tokenId?: string;
|
|
743
|
+
legs: {
|
|
744
|
+
certified: number;
|
|
745
|
+
total: number;
|
|
746
|
+
};
|
|
747
|
+
deliveryPending: boolean;
|
|
748
|
+
createdAt: number;
|
|
749
|
+
}
|
|
750
|
+
type ConnectionStatus$1 = 'connected' | 'degraded' | 'offline';
|
|
751
|
+
interface PaymentsV2 {
|
|
752
|
+
prewarmSend(request: SendRequest): Promise<void>;
|
|
753
|
+
discardPrewarm(): void;
|
|
754
|
+
assets(coinId?: string): Promise<Asset[]>;
|
|
755
|
+
tokens(filter?: {
|
|
756
|
+
coinId?: string;
|
|
757
|
+
}): Token[];
|
|
758
|
+
coinless(): CoinlessToken[];
|
|
759
|
+
tokenData(tokenId: string): Promise<Uint8Array | null>;
|
|
760
|
+
/** The genesis mint reason of one held token; null when it was minted without one. Same contract as tokenData. */
|
|
761
|
+
tokenJustification(tokenId: string): Promise<Uint8Array | null>;
|
|
762
|
+
/** One held token read as an NFT; null = its payload is not a recognised NFT. `creator` is only CLAIMED unless `signature` is 'valid'. Throws VALIDATION_ERROR when not held, STORAGE_ERROR when its blob is missing (same contract as tokenData). */
|
|
763
|
+
nft(tokenId: string): Promise<NftView | null>;
|
|
764
|
+
/** Batch read for list views. Ids not held, blobs missing or undecodable, and non-NFT payloads are simply absent from the map. Throws only on a transport failure. */
|
|
765
|
+
nfts(tokenIds: readonly string[]): Promise<ReadonlyMap<string, NftView>>;
|
|
766
|
+
history(page?: {
|
|
767
|
+
before?: string;
|
|
768
|
+
limit?: number;
|
|
769
|
+
}): Promise<HistoryPage>;
|
|
770
|
+
send(req: SendRequest): Promise<TransferResult>;
|
|
771
|
+
sendWholeToken(req: SendWholeTokenRequest): Promise<TransferResult>;
|
|
772
|
+
/** NFT-scoped twin: refuses a valued source. Connect's `send_nft` routes here. */
|
|
773
|
+
sendCoinless(req: SendWholeTokenRequest): Promise<TransferResult>;
|
|
774
|
+
mint(coinId: string, amount: bigint): Promise<MintResult>;
|
|
775
|
+
mintNft(request: MintNftRequest): Promise<MintResult>;
|
|
776
|
+
mintCustom(request: MintCustomRequest): Promise<MintResult>;
|
|
777
|
+
burn(request: BurnRequest): Promise<BurnResult>;
|
|
778
|
+
pendingBurns(): Promise<PendingBurn[]>;
|
|
779
|
+
acknowledgeBurn(burnId: string): Promise<void>;
|
|
780
|
+
receive(): Promise<{
|
|
781
|
+
transfers: IncomingTransfer[];
|
|
782
|
+
}>;
|
|
783
|
+
pendingTransfers(): Promise<PendingTransfer[]>;
|
|
784
|
+
resumeNow(): Promise<void>;
|
|
785
|
+
connectionStatus(): ConnectionStatus$1;
|
|
786
|
+
readonly requests: PaymentsRequestsApi;
|
|
787
|
+
}
|
|
529
788
|
|
|
530
789
|
/**
|
|
531
790
|
* Cryptographic utilities for SDK2
|
|
@@ -2566,203 +2825,6 @@ interface DerivedAddressInfo {
|
|
|
2566
2825
|
*/
|
|
2567
2826
|
declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
2568
2827
|
|
|
2569
|
-
/**
|
|
2570
|
-
* token-engine/engine.ts — the FROZEN public port (ITokenEngine) + its config.
|
|
2571
|
-
*
|
|
2572
|
-
* This is the contract both migration tracks build against. It is sphere-domain
|
|
2573
|
-
* only (see types.ts). The granular, SDK-typed steps (buildMint, submit,
|
|
2574
|
-
* awaitProof, certify, …) are an INTERNAL concern of the real adapter and are
|
|
2575
|
-
* intentionally NOT part of this public interface.
|
|
2576
|
-
*/
|
|
2577
|
-
|
|
2578
|
-
/**
|
|
2579
|
-
* Durable, any-device store for a split's burn checkpoint (sdk-changes E.4, sphere-sdk#501
|
|
2580
|
-
* option b). The engine passes opaque PLAINTEXT bytes; a transport adapter (the wallet-api
|
|
2581
|
-
* provider) is responsible for AAD-encryption and the wallet-api §16 intent-progress round-trip.
|
|
2582
|
-
*
|
|
2583
|
-
* The store is the resume seed for the one split input the engine cannot re-derive — the burn's
|
|
2584
|
-
* aggregator-issued inclusion proof — so the mint justification is rebuilt from stored bytes, not
|
|
2585
|
-
* a refetch (the aggregator regenerates proofs per request).
|
|
2586
|
-
*/
|
|
2587
|
-
interface SplitCheckpointStore {
|
|
2588
|
-
/**
|
|
2589
|
-
* Insert-once, first-write-wins. MUST resolve only AFTER the store acked durability, and MUST
|
|
2590
|
-
* resolve with the AUTHORITATIVE stored bytes — the caller's own on a fresh write, or the FIRST
|
|
2591
|
-
* writer's when the slot `(transferId, opIndex)` was already taken (the caller adopts those and
|
|
2592
|
-
* mints from them, so concurrent resumers converge on one burn proof).
|
|
2593
|
-
*/
|
|
2594
|
-
put(transferId: string, opIndex: number, bytes: Uint8Array): Promise<Uint8Array>;
|
|
2595
|
-
/** The stored bytes for the slot, or `null` when none exists. */
|
|
2596
|
-
get(transferId: string, opIndex: number): Promise<Uint8Array | null>;
|
|
2597
|
-
}
|
|
2598
|
-
/** Options common to the long-running, network-bound operations. */
|
|
2599
|
-
interface EngineOpOptions {
|
|
2600
|
-
/** Cancels the operation (including inclusion-proof polling). */
|
|
2601
|
-
readonly signal?: AbortSignal;
|
|
2602
|
-
/**
|
|
2603
|
-
* Durable burn-checkpoint store for a resumable split (sdk-changes E.4, sphere-sdk#501). When
|
|
2604
|
-
* present, `split()` persists the burn's certified proof AND awaits its durable ack BEFORE
|
|
2605
|
-
* submitting any mint leg, and rebuilds the mint justification from the stored bytes on resume —
|
|
2606
|
-
* so a split resumed after any mint leg certified recovers instead of stranding its outputs.
|
|
2607
|
-
*
|
|
2608
|
-
* Absent keeps today's behavior (a fresh burn proof per attempt): fine for a mid-split resume
|
|
2609
|
-
* with no mint yet certified, but a split resumed AFTER a mint certified cannot recover — a
|
|
2610
|
-
* documented residual for fully-local compositions; the live path MUST supply the store.
|
|
2611
|
-
*/
|
|
2612
|
-
readonly checkpointStore?: SplitCheckpointStore;
|
|
2613
|
-
/**
|
|
2614
|
-
* Realization seed for deterministic transfer/split (Part E, sdk-changes E.1/E.3):
|
|
2615
|
-
* a client-generated UUIDv4 in canonical lowercase string form. Every value the
|
|
2616
|
-
* transaction binds to (stateMask, per-output salts) is HKDF-derived from the
|
|
2617
|
-
* wallet key + this id, so re-calling the op with the same `transferId` and
|
|
2618
|
-
* inputs rebuilds the byte-identical transaction and resumes an interrupted
|
|
2619
|
-
* attempt instead of losing funds. Persist it BEFORE calling the engine.
|
|
2620
|
-
*
|
|
2621
|
-
* If absent, the engine generates one internally (`crypto.randomUUID()`) — the
|
|
2622
|
-
* derivation path is identical, but the call is NOT resumable (the seed is
|
|
2623
|
-
* gone if the process dies mid-op).
|
|
2624
|
-
*/
|
|
2625
|
-
readonly transferId?: string;
|
|
2626
|
-
/**
|
|
2627
|
-
* Ordinal of this engine op WITHIN one logical send sharing a `transferId`
|
|
2628
|
-
* (ARCHITECTURE §7: D whole-token transfers + at most one split under ONE
|
|
2629
|
-
* intent). It indexes the op-level HKDF derivations (`stateMask`, the split
|
|
2630
|
-
* `burn` mask) so distinct ops never reuse a mask — §8.1's "per-transfer
|
|
2631
|
-
* unique". Per-output split salts are indexed by output ordinal in their own
|
|
2632
|
-
* `salt` field domain; callers MUST NOT run two splits under one transferId.
|
|
2633
|
-
* Default 0 (single-op sends). Resume MUST replay the same (transferId,
|
|
2634
|
-
* opIndex) pairing per source.
|
|
2635
|
-
*/
|
|
2636
|
-
readonly opIndex?: number;
|
|
2637
|
-
}
|
|
2638
|
-
/**
|
|
2639
|
-
* The token engine port. The wallet's secp256k1 identity, the target network,
|
|
2640
|
-
* the aggregator client and the trust base are all bound at construction
|
|
2641
|
-
* (see EngineConfig); operations below take only sphere-domain arguments.
|
|
2642
|
-
*/
|
|
2643
|
-
interface ITokenEngine {
|
|
2644
|
-
/** This engine's wallet identity (chain pubkey). Synchronous. */
|
|
2645
|
-
getIdentity(): EngineIdentity;
|
|
2646
|
-
/**
|
|
2647
|
-
* Legacy `DIRECT://` address for the given pubkey (defaults to this engine's
|
|
2648
|
-
* identity). This is the ONLY "address" in v2 and is kept stable across the
|
|
2649
|
-
* migration (Path A) so Quest XP / Unicity IDs keyed on it survive. Async —
|
|
2650
|
-
* the derivation hashes via the SDK.
|
|
2651
|
-
*/
|
|
2652
|
-
deriveIdentityAddress(pubkey?: Uint8Array): Promise<string>;
|
|
2653
|
-
/**
|
|
2654
|
-
* Genesis-stable token id — 64-char lowercase hex of the v2 TokenId (same
|
|
2655
|
-
* across every state). Use for dedup / history / tombstone keys. Synchronous.
|
|
2656
|
-
*/
|
|
2657
|
-
tokenId(token: SphereToken): string;
|
|
2658
|
-
/** Decoded value of a token (cached). Synchronous. */
|
|
2659
|
-
readValue(token: SphereToken): SphereValue | null;
|
|
2660
|
-
/** Balance of a single coin within a token. Synchronous. */
|
|
2661
|
-
balanceOf(token: SphereToken, coinId: CoinId): bigint;
|
|
2662
|
-
/**
|
|
2663
|
-
* The opaque on-chain memo delivered with this token: the latest transfer's
|
|
2664
|
-
* data for a transferred token, else the memo in a minted output's value
|
|
2665
|
-
* envelope (split). Returns `null` when there is no memo — including for data
|
|
2666
|
-
* tokens (no value envelope; use `readTokenData`) and memo-less value tokens.
|
|
2667
|
-
* To tell a data token from a value token, check `readValue` (null ⇒
|
|
2668
|
-
* data/value-less token). Synchronous.
|
|
2669
|
-
*/
|
|
2670
|
-
readMemo(token: SphereToken): Uint8Array | null;
|
|
2671
|
-
/** Raw genesis data of a token (e.g. a data-token's terms). `null` when absent. Synchronous. */
|
|
2672
|
-
readTokenData(token: SphereToken): Uint8Array | null;
|
|
2673
|
-
/** Read a token's genesis payload as an NFT. NEVER throws; null = not a recognised NFT. */
|
|
2674
|
-
readNft(token: SphereToken): Promise<NftReading | null>;
|
|
2675
|
-
/**
|
|
2676
|
-
* Mint (issue) a new token to a recipient pubkey. NOT a wallet end-user flow —
|
|
2677
|
-
* this is the issuer/developer capability: an app issuing its own tokens
|
|
2678
|
-
* (rewards, in-app currency, tickets) to users, or seeding test balances. v2
|
|
2679
|
-
* makes standalone mint first-class (Token.mint accepts a genesis with a null
|
|
2680
|
-
* justification). Split's per-output mint is a separate, internal path; the
|
|
2681
|
-
* Unicity-ID/nametag mint is a distinct identity surface (see migration plan §4.4).
|
|
2682
|
-
*/
|
|
2683
|
-
mint(params: MintParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
2684
|
-
/**
|
|
2685
|
-
* Mint a NON-value (data) token: opaque `data` + custom `tokenType` + deterministic
|
|
2686
|
-
* `salt` → a stable, terms-derived `tokenId`. The result has `value === null`;
|
|
2687
|
-
* read its bytes via `readTokenData`. (Used e.g. for on-chain invoice tokens.)
|
|
2688
|
-
*/
|
|
2689
|
-
mintDataToken(params: MintDataTokenParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
2690
|
-
/** Plan an NFT mint: encode (and optionally sign as this engine's identity) the payload and derive its token id. No chain op. */
|
|
2691
|
-
buildNftMint(params: BuildNftMintParams): Promise<NftMintPlan>;
|
|
2692
|
-
/** Spend a token wholesale to a recipient pubkey; returns the recipient's finished token. */
|
|
2693
|
-
transfer(params: TransferParams, options?: EngineOpOptions): Promise<SphereToken>;
|
|
2694
|
-
/** Split a token into N value-conserving outputs (burn source + internally mint each output). */
|
|
2695
|
-
split(params: SplitParams, options?: EngineOpOptions): Promise<SplitResult>;
|
|
2696
|
-
/** Fully verify a token against the trust base. */
|
|
2697
|
-
verify(token: SphereToken, options?: EngineOpOptions): Promise<EngineVerifyResult>;
|
|
2698
|
-
/** Whether the token's current state has already been spent on the network. */
|
|
2699
|
-
isSpent(token: SphereToken, options?: EngineOpOptions): Promise<boolean>;
|
|
2700
|
-
/**
|
|
2701
|
-
* Whether the token's CURRENT state is locked to `SignaturePredicate(pubkey)`.
|
|
2702
|
-
* Local + synchronous (predicate byte-compare, no network). The receive path
|
|
2703
|
-
* uses it to reject tokens that are not actually addressed to this wallet.
|
|
2704
|
-
*/
|
|
2705
|
-
isOwnedBy(token: SphereToken, pubkey: Uint8Array): boolean;
|
|
2706
|
-
/** Serialize a token for storage/transport. Synchronous. */
|
|
2707
|
-
encodeToken(token: SphereToken): TokenBlob;
|
|
2708
|
-
/** Reconstruct a token from its blob (decodes embedded payment data). */
|
|
2709
|
-
decodeToken(blob: TokenBlob): Promise<SphereToken>;
|
|
2710
|
-
/**
|
|
2711
|
-
* The backend-true delivery keys for encoded TokenBlob bytes: the
|
|
2712
|
-
* genesis-stable tokenId and the SDK's PROTOCOL state hash of the latest
|
|
2713
|
-
* state (DataHash imprint, hex). wallet-api keys mailbox entries on exactly
|
|
2714
|
-
* this pair (entry_id = SHA-256(tokenId ‖ stateHash); §8.2 step 4 validates
|
|
2715
|
-
* a deposit's claimed stateHash against it) — a plain hash over the token
|
|
2716
|
-
* bytes is NOT this value and 422s on deposit. Delivery implementations MUST
|
|
2717
|
-
* derive their ids through this method, never locally.
|
|
2718
|
-
*/
|
|
2719
|
-
deliveryKeys(blobBytes: Uint8Array): Promise<{
|
|
2720
|
-
tokenId: string;
|
|
2721
|
-
stateHash: string;
|
|
2722
|
-
}>;
|
|
2723
|
-
/**
|
|
2724
|
-
* Release engine-owned OS resources — today only the verification worker pool.
|
|
2725
|
-
* Idempotent; optional because an engine owning none need not define it.
|
|
2726
|
-
*/
|
|
2727
|
-
dispose?(): void;
|
|
2728
|
-
}
|
|
2729
|
-
/**
|
|
2730
|
-
* Engine construction config. Sphere-domain inputs only: the factory maps
|
|
2731
|
-
* `network` → SDK NetworkId, builds the aggregator client from `aggregatorUrl`,
|
|
2732
|
-
* the signing service from `privateKey`, and loads the trust base internally.
|
|
2733
|
-
*
|
|
2734
|
-
* NOTE: trust-base sourcing + proof-policy defaults are finalized in Phase 0.8;
|
|
2735
|
-
* this shape may gain fields there without affecting the ITokenEngine contract.
|
|
2736
|
-
*/
|
|
2737
|
-
/**
|
|
2738
|
-
* The web-`Worker` subset the verification pool drives (in Node wrap a `worker_threads.Worker`).
|
|
2739
|
-
* A browser `Worker` has these members, but under `strictFunctionTypes` its `ErrorEvent` /
|
|
2740
|
-
* `MessageEvent` handler types are not assignable here (TS2322), so it needs a cast or a thin
|
|
2741
|
-
* wrapper. Payloads stay `unknown` so no base-SDK wire type reaches this port.
|
|
2742
|
-
*/
|
|
2743
|
-
interface VerificationWorker {
|
|
2744
|
-
onerror: ((event: {
|
|
2745
|
-
message: string;
|
|
2746
|
-
}) => void) | null;
|
|
2747
|
-
onmessage: ((event: {
|
|
2748
|
-
data: unknown;
|
|
2749
|
-
}) => void) | null;
|
|
2750
|
-
postMessage(message: unknown): void;
|
|
2751
|
-
terminate(): void;
|
|
2752
|
-
}
|
|
2753
|
-
/**
|
|
2754
|
-
* Opt-in PARALLEL token verification (state-transition-sdk 2.0.2+): per-transfer
|
|
2755
|
-
* work fans out to a worker pool instead of walking the calling thread. You
|
|
2756
|
-
* author and bundle the entry script, and its predicate verifier MUST match the
|
|
2757
|
-
* engine's or the verdict silently diverges — docs/VERIFICATION-WORKERS.md.
|
|
2758
|
-
*/
|
|
2759
|
-
interface VerificationWorkerConfig {
|
|
2760
|
-
/** Spawn ONE worker running that entry script. Called lazily, up to `poolSize` times. */
|
|
2761
|
-
readonly createWorker: () => VerificationWorker;
|
|
2762
|
-
/** Maximum workers in the pool (default 4). Workers are reused across verify() calls. */
|
|
2763
|
-
readonly poolSize?: number;
|
|
2764
|
-
}
|
|
2765
|
-
|
|
2766
2828
|
interface ScopedKV {
|
|
2767
2829
|
get<T>(key: string): Promise<T | null>;
|
|
2768
2830
|
set<T>(key: string, value: T): Promise<void>;
|
|
@@ -3316,6 +3378,8 @@ interface SphereCreateOptions extends SphereWalletApiOptions {
|
|
|
3316
3378
|
* {@link SphereInitOptions.verification}. Omit for the sequential verifier.
|
|
3317
3379
|
*/
|
|
3318
3380
|
verification?: VerificationWorkerConfig;
|
|
3381
|
+
/** Token plugins: mint-reason verifiers registered into every engine this Sphere builds. */
|
|
3382
|
+
plugins?: readonly TokenPlugin[];
|
|
3319
3383
|
}
|
|
3320
3384
|
/** Options for loading existing wallet */
|
|
3321
3385
|
interface SphereLoadOptions extends SphereWalletApiOptions {
|
|
@@ -3359,6 +3423,8 @@ interface SphereLoadOptions extends SphereWalletApiOptions {
|
|
|
3359
3423
|
* {@link SphereInitOptions.verification}. Omit for the sequential verifier.
|
|
3360
3424
|
*/
|
|
3361
3425
|
verification?: VerificationWorkerConfig;
|
|
3426
|
+
/** Token plugins: mint-reason verifiers registered into every engine this Sphere builds. */
|
|
3427
|
+
plugins?: readonly TokenPlugin[];
|
|
3362
3428
|
}
|
|
3363
3429
|
/** Options for importing a wallet */
|
|
3364
3430
|
interface SphereImportOptions extends SphereWalletApiOptions {
|
|
@@ -3432,6 +3498,8 @@ interface SphereImportOptions extends SphereWalletApiOptions {
|
|
|
3432
3498
|
* registration) still rejects, and the erased wallet is not restored: keep a backup of it.
|
|
3433
3499
|
*/
|
|
3434
3500
|
overwrite?: boolean;
|
|
3501
|
+
/** Token plugins: mint-reason verifiers registered into every engine this Sphere builds. */
|
|
3502
|
+
plugins?: readonly TokenPlugin[];
|
|
3435
3503
|
}
|
|
3436
3504
|
/** Options for unified init (auto-create or load) */
|
|
3437
3505
|
interface SphereInitOptions extends SphereWalletApiOptions {
|
|
@@ -3501,6 +3569,8 @@ interface SphereInitOptions extends SphereWalletApiOptions {
|
|
|
3501
3569
|
* {@link VerificationWorkerConfig}); `sphere.destroy()` terminates the pool.
|
|
3502
3570
|
*/
|
|
3503
3571
|
verification?: VerificationWorkerConfig;
|
|
3572
|
+
/** Token plugins: mint-reason verifiers registered into every engine this Sphere builds. */
|
|
3573
|
+
plugins?: readonly TokenPlugin[];
|
|
3504
3574
|
}
|
|
3505
3575
|
/** Result of init operation */
|
|
3506
3576
|
interface SphereInitResult {
|
|
@@ -3605,6 +3675,8 @@ declare class Sphere {
|
|
|
3605
3675
|
* the rebuild after an api-key change share one pool configuration.
|
|
3606
3676
|
*/
|
|
3607
3677
|
private _verification;
|
|
3678
|
+
/** Token plugins (SphereInitOptions.plugins), applied to every engine like _verification. */
|
|
3679
|
+
private _plugins;
|
|
3608
3680
|
/** This Sphere's OWN token registry. Disposed by destroy(); never the process global. */
|
|
3609
3681
|
private _registry;
|
|
3610
3682
|
private eventHandlers;
|