@hardkas/sdk 0.8.15-alpha → 0.8.16-alpha

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/index.js CHANGED
@@ -652,6 +652,10 @@ var HardkasTx = class {
652
652
  tracePath,
653
653
  ...planArtifact.workflowId ? { workflowId: planArtifact.workflowId } : {},
654
654
  ...planArtifact.assumptionLevel ? { assumptionLevel: planArtifact.assumptionLevel } : {},
655
+ ...planArtifact.policyRefs ? { policyRefs: planArtifact.policyRefs } : {},
656
+ ...planArtifact.networkProfileRef ? { networkProfileRef: planArtifact.networkProfileRef } : {},
657
+ ...planArtifact.assumptionRef ? { assumptionRef: planArtifact.assumptionRef } : {},
658
+ sourceSignedId: signedId !== "unknown" ? signedId : void 0,
655
659
  lineage: {
656
660
  artifactId: "",
657
661
  // To be computed
@@ -814,6 +818,11 @@ var HardkasTx = class {
814
818
  submittedAt: (/* @__PURE__ */ new Date()).toISOString(),
815
819
  ...url ? { rpcUrl: url } : {},
816
820
  ...signedArtifact.workflowId ? { workflowId: signedArtifact.workflowId } : {},
821
+ ...signedArtifact.assumptionLevel ? { assumptionLevel: signedArtifact.assumptionLevel } : {},
822
+ ...signedArtifact.policyRefs ? { policyRefs: signedArtifact.policyRefs } : {},
823
+ ...signedArtifact.networkProfileRef ? { networkProfileRef: signedArtifact.networkProfileRef } : {},
824
+ ...signedArtifact.assumptionRef ? { assumptionRef: signedArtifact.assumptionRef } : {},
825
+ sourceSignedId: signedArtifact.contentHash || signedArtifact.signedId,
817
826
  tracePath: void 0,
818
827
  lineage: createLineageTransition(signedArtifact, "hardkas.txReceipt")
819
828
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/sdk",
3
- "version": "0.8.15-alpha",
3
+ "version": "0.8.16-alpha",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -24,22 +24,22 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@kaspa/core-lib": "^1.6.5",
27
- "@hardkas/accounts": "0.8.15-alpha",
28
- "@hardkas/artifacts": "0.8.15-alpha",
29
- "@hardkas/config": "0.8.15-alpha",
30
- "@hardkas/kaspa-rpc": "0.8.15-alpha",
31
- "@hardkas/core": "0.8.15-alpha",
32
- "@hardkas/l2": "0.8.15-alpha",
33
- "@hardkas/localnet": "0.8.15-alpha",
34
- "@hardkas/query": "0.8.15-alpha",
35
- "@hardkas/query-store": "0.8.15-alpha",
36
- "@hardkas/tx-builder": "0.8.15-alpha",
37
- "@hardkas/simulator": "0.8.15-alpha",
38
- "@hardkas/wallet-adapter": "0.8.15-alpha"
27
+ "@hardkas/accounts": "0.8.16-alpha",
28
+ "@hardkas/config": "0.8.16-alpha",
29
+ "@hardkas/artifacts": "0.8.16-alpha",
30
+ "@hardkas/core": "0.8.16-alpha",
31
+ "@hardkas/kaspa-rpc": "0.8.16-alpha",
32
+ "@hardkas/l2": "0.8.16-alpha",
33
+ "@hardkas/localnet": "0.8.16-alpha",
34
+ "@hardkas/query-store": "0.8.16-alpha",
35
+ "@hardkas/query": "0.8.16-alpha",
36
+ "@hardkas/tx-builder": "0.8.16-alpha",
37
+ "@hardkas/simulator": "0.8.16-alpha",
38
+ "@hardkas/wallet-adapter": "0.8.16-alpha"
39
39
  },
40
40
  "devDependencies": {
41
- "tsup": "^8.3.5",
42
41
  "@types/node": "^20.12.7",
42
+ "tsup": "^8.3.5",
43
43
  "typescript": "^5.7.2",
44
44
  "vitest": "^2.1.8"
45
45
  },
package/dist/client.d.ts DELETED
@@ -1,84 +0,0 @@
1
- interface HardkasClientOptions {
2
- baseUrl?: string;
3
- network?: string;
4
- }
5
- interface ClientEnvelope<T> {
6
- ok: boolean;
7
- data?: T;
8
- error?: {
9
- code: string;
10
- message: string;
11
- };
12
- warnings: string[];
13
- meta: {
14
- workspace: string;
15
- network: string;
16
- mode?: string;
17
- };
18
- }
19
- declare function createHardkasClient(options?: HardkasClientOptions): {
20
- accounts: {
21
- list: () => Promise<ClientEnvelope<any[]>>;
22
- };
23
- tx: {
24
- plan: (params: {
25
- from: string;
26
- to: string;
27
- amountSompi: string;
28
- feeRate?: string;
29
- }) => Promise<ClientEnvelope<any>>;
30
- sign: (params: {
31
- planId: string;
32
- account: string;
33
- }) => Promise<ClientEnvelope<any>>;
34
- send: (params: {
35
- signedTxId?: string;
36
- from?: string;
37
- to?: string;
38
- amountSompi?: string;
39
- feeRate?: string;
40
- allowDevAutoSign?: boolean;
41
- }) => Promise<ClientEnvelope<any>>;
42
- receipt: (id: string) => Promise<ClientEnvelope<any>>;
43
- };
44
- artifacts: {
45
- explain: (id: string) => Promise<ClientEnvelope<any>>;
46
- replay: (id: string) => Promise<ClientEnvelope<any>>;
47
- watch: (callback: (artifact: any) => void, options?: {
48
- type?: string;
49
- lineage?: boolean;
50
- replay?: boolean;
51
- transport?: "sse" | "poll";
52
- intervalMs?: number;
53
- }) => () => void;
54
- };
55
- workflow: {
56
- transfer: (params: {
57
- from: string;
58
- to: string;
59
- amountSompi: string;
60
- feeRate?: string;
61
- allowDevAutoSign?: boolean;
62
- }) => Promise<ClientEnvelope<any>>;
63
- };
64
- localnet: {
65
- status: () => Promise<ClientEnvelope<any>>;
66
- };
67
- dev: {
68
- status: () => Promise<ClientEnvelope<any>>;
69
- };
70
- session: {
71
- start: () => Promise<ClientEnvelope<any>>;
72
- snapshot: () => Promise<ClientEnvelope<any>>;
73
- replay: (options?: {
74
- untilArtifact?: string;
75
- strict?: boolean;
76
- }) => Promise<ClientEnvelope<any>>;
77
- diffReplay: (artifactId: string) => Promise<ClientEnvelope<any>>;
78
- timeTravel: (artifactId: string) => Promise<ClientEnvelope<any>>;
79
- export: () => Promise<ClientEnvelope<any>>;
80
- import: (data: any, force?: boolean) => Promise<ClientEnvelope<any>>;
81
- };
82
- };
83
-
84
- export { type ClientEnvelope, type HardkasClientOptions, createHardkasClient };
package/dist/index.d.ts DELETED
@@ -1,431 +0,0 @@
1
- import * as _hardkas_config from '@hardkas/config';
2
- import { LoadedHardkasConfig } from '@hardkas/config';
3
- export { defineHardkasConfig } from '@hardkas/config';
4
- import { TxPlanArtifact, SignedTxArtifact, TxReceiptArtifact, HardkasArtifactBase, WorkflowArtifact, ExternalHardkasSigner } from '@hardkas/artifacts';
5
- export { ARTIFACT_SCHEMAS, HARDKAS_VERSION, SignedTxArtifact, TxPlanArtifact, TxReceiptArtifact, TxTraceArtifact, createTxPlanArtifact, writeArtifact } from '@hardkas/artifacts';
6
- import { KaspaRpcClient } from '@hardkas/kaspa-rpc';
7
- import { EventEnvelope, NetworkId } from '@hardkas/core';
8
- export { ArtifactId, HardkasError, KaspaAddress, LineageId, NetworkId, SOMPI_PER_KAS, TxId, formatSompi, parseKasToSompi } from '@hardkas/core';
9
- import { HardkasAccount } from '@hardkas/accounts';
10
- export { signTxPlanArtifact } from '@hardkas/accounts';
11
- import { L2NetworkProfile } from '@hardkas/l2';
12
- export { buildPaymentPlan } from '@hardkas/tx-builder';
13
- export { ClientEnvelope, HardkasClientOptions, createHardkasClient } from './client.js';
14
-
15
- /**
16
- * HardKAS Accounts Module
17
- * @alpha
18
- */
19
- declare class HardkasAccounts {
20
- private sdk;
21
- constructor(sdk: Hardkas);
22
- /**
23
- * Resolves an account by name or address.
24
- */
25
- resolve(nameOrAddress: string): Promise<HardkasAccount>;
26
- /**
27
- * Fetches the balance for an account.
28
- */
29
- getBalance(accountNameOrAddress: string): Promise<{
30
- sompi: bigint;
31
- formatted: string;
32
- }>;
33
- /**
34
- * Alias for getBalance.
35
- */
36
- balance(accountNameOrAddress: string): Promise<{
37
- sompi: bigint;
38
- formatted: string;
39
- }>;
40
- /**
41
- * Lists all configured account names.
42
- */
43
- list(): Promise<string[]>;
44
- /**
45
- * Funds an account from another account (defaults to 'default' account).
46
- */
47
- fund(accountNameOrAddress: string, options?: {
48
- from?: string;
49
- amount?: string | bigint;
50
- }): Promise<any>;
51
- }
52
-
53
- /**
54
- * HardKAS Transaction Module
55
- * @alpha
56
- */
57
- declare class HardkasTx {
58
- private sdk;
59
- constructor(sdk: Hardkas);
60
- /**
61
- * Plans a transaction.
62
- */
63
- plan(options: {
64
- from: string | HardkasAccount;
65
- to: string | HardkasAccount;
66
- amount: string | number | bigint;
67
- feeRate?: bigint;
68
- workflowId?: string;
69
- policy?: string;
70
- networkProfile?: string;
71
- assumption?: string;
72
- }): Promise<TxPlanArtifact>;
73
- /**
74
- * Signs a transaction plan.
75
- */
76
- sign(plan: TxPlanArtifact | SignedTxArtifact, account?: HardkasAccount | string, options?: {
77
- append?: boolean;
78
- threshold?: number;
79
- requiredSigners?: string[];
80
- }): Promise<SignedTxArtifact>;
81
- /**
82
- * Simulates a transaction on the local state without broadcasting to a real Kaspa node.
83
- * Modifies the local deterministic state and outputs receipt/trace artifacts.
84
- */
85
- simulate(target: string | Partial<TxPlanArtifact> | SignedTxArtifact, options?: {
86
- persist?: boolean;
87
- }): Promise<{
88
- receipt: TxReceiptArtifact;
89
- receiptPath?: string;
90
- tracePath?: string;
91
- }>;
92
- /**
93
- * Sends a signed transaction to the real RPC network.
94
- */
95
- send(signedArtifact: SignedTxArtifact, urlOrOptions?: string | {
96
- persist?: boolean;
97
- }): Promise<{
98
- receipt: TxReceiptArtifact;
99
- receiptPath?: string;
100
- artifactId?: string;
101
- mode?: string;
102
- simulated?: boolean;
103
- submitted?: boolean;
104
- txId?: string;
105
- }>;
106
- /**
107
- * Explicitly appends a signature to a partially signed transaction.
108
- */
109
- appendSignature(plan: SignedTxArtifact, account?: HardkasAccount | string): Promise<SignedTxArtifact>;
110
- /**
111
- * Fetches the current status of a transaction by ID.
112
- */
113
- status(txId: string): Promise<any>;
114
- }
115
-
116
- /**
117
- * HardKAS L2 Module
118
- * @alpha
119
- */
120
- declare class HardkasL2 {
121
- /**
122
- * Lists all available L2 network profiles.
123
- */
124
- listProfiles(): readonly L2NetworkProfile[];
125
- /**
126
- * Gets a specific L2 network profile by name.
127
- */
128
- getProfile(name: string): L2NetworkProfile | null;
129
- }
130
-
131
- /**
132
- * HardKAS Operational Query Module
133
- *
134
- * Note: readEvents, correlate, and correlation types were removed from
135
- * @hardkas/query. These will be re-implemented when the query API stabilizes.
136
- * @alpha
137
- */
138
- declare class HardkasQuery {
139
- private sdk;
140
- private _engine;
141
- constructor(sdk: Hardkas);
142
- /**
143
- * Internal lazy-loaded query engine.
144
- */
145
- private getEngine;
146
- /**
147
- * Synchronizes the query store with the filesystem artifacts.
148
- */
149
- sync(options?: {
150
- force?: boolean;
151
- }): Promise<any>;
152
- /**
153
- * Fetches events from the query store.
154
- */
155
- events(filter?: {
156
- domain?: string;
157
- kind?: string;
158
- correlationId?: string;
159
- artifactId?: string;
160
- }): Promise<readonly EventEnvelope[]>;
161
- }
162
-
163
- /**
164
- * HardKAS Localnet Simulation Module
165
- */
166
- declare class HardkasLocalnet {
167
- private sdk;
168
- constructor(sdk: Hardkas);
169
- /**
170
- * Status check for the localnet simulation.
171
- */
172
- isAlive(): Promise<boolean>;
173
- /**
174
- * Future: control localnet process/container from here.
175
- */
176
- start(): Promise<void>;
177
- /**
178
- * Resets the localnet state (simulated or node).
179
- */
180
- reset(): Promise<void>;
181
- }
182
-
183
- interface ReplayVerifyOptions {
184
- path?: string;
185
- workflowId?: string;
186
- }
187
- interface ReplayVerifyResult {
188
- passed: boolean;
189
- artifactsScanned: number;
190
- lineage: "valid" | "invalid";
191
- determinism: "verified" | "failed";
192
- contamination: "clean" | "contaminated";
193
- report: any;
194
- error?: string;
195
- }
196
- declare class HardkasReplay {
197
- private sdk;
198
- constructor(sdk: Hardkas);
199
- /**
200
- * Verifies the deterministic artifact lineage of a transaction replay
201
- * against the mathematically reconstructed localnet state.
202
- */
203
- verify(targetOrOptions?: string | {
204
- schema?: string;
205
- artifactId?: string;
206
- } | ReplayVerifyOptions, options?: ReplayVerifyOptions): Promise<ReplayVerifyResult>;
207
- }
208
-
209
- /**
210
- * HardKAS Lineage Module
211
- * @alpha
212
- */
213
- declare class HardkasLineage {
214
- private sdk;
215
- constructor(sdk: Hardkas);
216
- /**
217
- * Traces the lineage of an artifact, identifying ancestors and descendants.
218
- */
219
- trace(target: string | {
220
- artifactId?: string;
221
- contentHash?: string;
222
- }, options?: {
223
- direction?: "ancestors" | "descendants";
224
- }): Promise<any>;
225
- }
226
-
227
- /**
228
- * Deterministic Workspace Abstraction.
229
- * Encapsulates all filesystem boundary interactions and isolates paths
230
- * from the global process.cwd(), ensuring agent/script replayability.
231
- */
232
- declare class HardkasWorkspace {
233
- readonly root: string;
234
- constructor(cwd: string);
235
- get hardkasDir(): string;
236
- get artifactsDir(): string;
237
- get localnetStatePath(): string;
238
- get keystoreDir(): string;
239
- /**
240
- * Safely resolves a path relative to the workspace root.
241
- */
242
- resolvePath(...segments: string[]): string;
243
- /**
244
- * Safely builds a relative path from the workspace root to the target.
245
- */
246
- relativeFromRoot(absolutePath: string): string;
247
- /**
248
- * Ensures the core .hardkas directory exists.
249
- */
250
- ensureHardkasDir(): void;
251
- }
252
-
253
- interface WriteArtifactOptions {
254
- /**
255
- * Explicitly override the canonical artifacts directory.
256
- * By default, it writes to sdk.workspace.artifactsDir.
257
- */
258
- outputDir?: string;
259
- /**
260
- * Explicitly override the default filename.
261
- * By default, it generates `${schema}-${contentHash}.json`
262
- */
263
- fileName?: string;
264
- /**
265
- * If true, verifies integrity and schema but does not touch the filesystem.
266
- * Useful for Agent planning or previews.
267
- */
268
- dryRun?: boolean;
269
- /** Telemetry for Event Sourcing */
270
- workflowId?: string;
271
- correlationId?: string;
272
- networkId?: string;
273
- }
274
- interface WriteArtifactResult {
275
- absolutePath?: string;
276
- dryRun: boolean;
277
- contentHash: string;
278
- }
279
- /**
280
- * Deterministic Artifact I/O boundary.
281
- */
282
- declare class HardkasArtifactsManager {
283
- private workspace;
284
- private cache;
285
- constructor(workspace: HardkasWorkspace);
286
- /**
287
- * Caches an in-memory artifact.
288
- */
289
- cacheArtifact(artifact: any): void;
290
- /**
291
- * Writes a valid artifact to disk (canonical or custom path).
292
- */
293
- write(artifact: HardkasArtifactBase, options?: WriteArtifactOptions): Promise<WriteArtifactResult>;
294
- /**
295
- * Retrieves an artifact from the in-memory cache.
296
- */
297
- getCached(id: string): any;
298
- /**
299
- * Reads an artifact by path or ID/hash from the workspace.
300
- */
301
- read(id: string, options?: {
302
- expectedSchema?: string;
303
- }): Promise<any>;
304
- /**
305
- * Alias for read().
306
- */
307
- get(id: string, options?: {
308
- expectedSchema?: string;
309
- }): Promise<any>;
310
- /**
311
- * Lists all artifacts in the workspace.
312
- */
313
- list(): Promise<any[]>;
314
- /**
315
- * Cryptographically verifies the determinism and integrity of an artifact.
316
- * Throws an error with details if corruption or mismatch is found.
317
- */
318
- verify(target: any, options?: {
319
- throwOnInvalid?: boolean;
320
- strict?: boolean;
321
- enforceMetadata?: boolean;
322
- }): Promise<any>;
323
- /**
324
- * Migrates a legacy artifact to v4 using a migration receipt.
325
- */
326
- migrate(target: any, migrationId: string): Promise<{
327
- migrated: any;
328
- receipt: any;
329
- }>;
330
- }
331
-
332
- interface WorkflowRunOptions {
333
- steps: Array<{
334
- type: string;
335
- [key: string]: any;
336
- }>;
337
- dryRun?: boolean;
338
- }
339
- declare class HardkasWorkflow {
340
- private readonly sdk;
341
- constructor(sdk: Hardkas);
342
- /**
343
- * Executes a sequence of declarative steps and returns a definitive WorkflowArtifact.
344
- */
345
- run(options: WorkflowRunOptions): Promise<WorkflowArtifact>;
346
- }
347
-
348
- interface TaskArgs {
349
- [key: string]: string | boolean | undefined;
350
- }
351
- interface TaskContext {
352
- hardkas: Hardkas;
353
- args: TaskArgs;
354
- }
355
- type TaskAction = (ctx: TaskContext) => Promise<void>;
356
- /**
357
- * Defines a new HardKAS task.
358
- * Used in hardkas.config.ts to extend CLI functionality.
359
- */
360
- declare const defineTask: {
361
- (name: string, action: TaskAction): void;
362
- (name: string, description: string, action: TaskAction): void;
363
- };
364
-
365
- interface HardkasOptions {
366
- cwd?: string;
367
- configPath?: string;
368
- mode?: "developer" | "agent";
369
- network?: string;
370
- autoBootstrap?: boolean;
371
- signer?: ExternalHardkasSigner;
372
- logger?: {
373
- info: (msg: string) => void;
374
- warn: (msg: string) => void;
375
- error: (msg: string) => void;
376
- debug: (msg: string) => void;
377
- [key: string]: any;
378
- };
379
- policy?: {
380
- allowNetwork?: boolean;
381
- allowMainnet?: boolean;
382
- allowExternalWallet?: boolean;
383
- requireDryRun?: boolean;
384
- };
385
- }
386
- /**
387
- * HardKAS SDK - Main Entry Point
388
- *
389
- * Provides a high-level facade for interacting with the Kaspa ecosystem.
390
- * Acts as a DI container and coordinator.
391
- */
392
- declare class Hardkas {
393
- readonly config: LoadedHardkasConfig;
394
- readonly workspace: HardkasWorkspace;
395
- readonly artifacts: HardkasArtifactsManager;
396
- readonly accounts: HardkasAccounts;
397
- readonly tx: HardkasTx;
398
- readonly l2: HardkasL2;
399
- readonly query: HardkasQuery;
400
- readonly localnet: HardkasLocalnet;
401
- readonly replay: HardkasReplay;
402
- readonly lineage: HardkasLineage;
403
- readonly workflow: HardkasWorkflow;
404
- readonly signer?: ExternalHardkasSigner | undefined;
405
- readonly mode: "developer" | "agent";
406
- readonly policy: Required<NonNullable<HardkasOptions["policy"]>>;
407
- readonly rpc: KaspaRpcClient;
408
- private constructor();
409
- private resolveRpcUrl;
410
- /**
411
- * Opens a HardKAS project in the given directory.
412
- */
413
- static open(dirOrOptions?: string | HardkasOptions): Promise<Hardkas>;
414
- /**
415
- * Alias for open(). Used in most examples.
416
- */
417
- static create(dirOrOptions?: string | HardkasOptions): Promise<Hardkas>;
418
- /**
419
- * Current active network name.
420
- */
421
- get network(): NetworkId;
422
- get sdkConfig(): _hardkas_config.HardkasConfig;
423
- get cwd(): string;
424
- /**
425
- * Validates an action against the active security policy.
426
- * Throws HardkasError if the policy is violated.
427
- */
428
- enforcePolicy(action: "network" | "mainnet" | "external-wallet" | "mutation", context?: string): void;
429
- }
430
-
431
- export { Hardkas, HardkasAccounts, HardkasArtifactsManager, HardkasL2, HardkasLineage, HardkasLocalnet, type HardkasOptions, HardkasQuery, HardkasReplay, HardkasTx, HardkasWorkspace, type TaskArgs, type TaskContext, defineTask };