@hardkas/core 0.8.19-alpha → 0.9.0-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.d.ts CHANGED
@@ -793,7 +793,7 @@ declare class AppendCoordinator {
793
793
  };
794
794
  }
795
795
 
796
- declare const CURRENT_RUNTIME_VERSION = "0.8.19-alpha";
796
+ declare const CURRENT_RUNTIME_VERSION = "0.9.0-alpha";
797
797
  declare const MIN_SUPPORTED_VERSION = "0.5.0-alpha";
798
798
  interface MigrationStatus {
799
799
  needsMigration: boolean;
@@ -808,16 +808,39 @@ declare class MigrationManager {
808
808
  private static compareSemver;
809
809
  }
810
810
 
811
+ /**
812
+ * Creates a Kaspa standard P2SH locking script (BIP16-like but with Blake2b).
813
+ * Version is always 0 for standard script hashes in Kaspa currently,
814
+ * although future VM versions might use 8.
815
+ *
816
+ * @param redeemScriptHex The compiled script hex string
817
+ */
818
+ declare function createKaspaP2shBlake2bLock(redeemScriptHex: string): {
819
+ scriptPublicKeyVersion: number;
820
+ lockingScriptHex: string;
821
+ redeemScriptHash: string;
822
+ redeemScriptHex: string;
823
+ };
824
+ /**
825
+ * Creates a valid Kaspa v2.0.0 signature script for a P2SH UTXO.
826
+ * The signature script must be push-only. It pushes any arguments,
827
+ * followed by the raw redeem script itself.
828
+ *
829
+ * @param args Array of hex strings representing the arguments to push
830
+ * @param redeemScriptHex The compiled script hex string
831
+ */
832
+ declare function createPushOnlySignatureScript(args: string[], redeemScriptHex: string): string;
833
+
811
834
  declare const SOMPI_PER_KAS = 100000000n;
812
835
  declare const kaspaNetworkIdSchema: z.ZodEnum<["mainnet", "testnet-10", "testnet-11", "testnet-12", "simnet", "simnet-1", "devnet", "simulated", "igra"]>;
813
836
  type NetworkId = Brand<z.infer<typeof kaspaNetworkIdSchema>, "NetworkId">;
814
837
  declare const executionModeSchema: z.ZodEnum<["simulated", "real", "readonly"]>;
815
838
  type ExecutionMode = z.infer<typeof executionModeSchema>;
816
- declare const artifactTypeSchema: z.ZodEnum<["txPlan", "signedTx", "txReceipt", "txTrace", "snapshot", "workflow.v1", "policy.v1", "networkProfile.v1", "assumption.v1", "migrationReceipt.v1"]>;
839
+ declare const artifactTypeSchema: z.ZodEnum<["txPlan", "signedTx", "txReceipt", "txTrace", "snapshot", "workflow.v1", "policy.v1", "networkProfile.v1", "assumption.v1", "migrationReceipt.v1", "silver.compile", "silver.test", "silver.spendPlan", "silver.deployPlan", "silver.deploy", "silver.spendReceipt", "silver.deploySimulation", "silver.spendSimulation"]>;
817
840
  type ArtifactType = z.infer<typeof artifactTypeSchema>;
818
841
  declare const NetworkIdSchema: z.ZodEnum<["mainnet", "testnet-10", "testnet-11", "testnet-12", "simnet", "simnet-1", "devnet", "simulated", "igra"]>;
819
842
  declare const ExecutionModeSchema: z.ZodEnum<["simulated", "real", "readonly"]>;
820
- declare const ArtifactTypeSchema: z.ZodEnum<["txPlan", "signedTx", "txReceipt", "txTrace", "snapshot", "workflow.v1", "policy.v1", "networkProfile.v1", "assumption.v1", "migrationReceipt.v1"]>;
843
+ declare const ArtifactTypeSchema: z.ZodEnum<["txPlan", "signedTx", "txReceipt", "txTrace", "snapshot", "workflow.v1", "policy.v1", "networkProfile.v1", "assumption.v1", "migrationReceipt.v1", "silver.compile", "silver.test", "silver.spendPlan", "silver.deployPlan", "silver.deploy", "silver.spendReceipt", "silver.deploySimulation", "silver.spendSimulation"]>;
821
844
  declare const hardkasConfigSchema: z.ZodObject<{
822
845
  project: z.ZodObject<{
823
846
  name: z.ZodString;
@@ -898,4 +921,4 @@ declare function parseHardkasConfig(input: unknown): HardkasConfig;
898
921
  declare function parseKasToSompi(input: string): bigint;
899
922
  declare function formatSompi(amountSompi: bigint): string;
900
923
 
901
- export { type AcquireLockArgs, type AnomalyEvent, type AnomalyType, AppendCoordinator, type ArtifactId, type ArtifactStatus, type ArtifactType, ArtifactTypeSchema, type Brand, type Branded, CURRENT_RUNTIME_VERSION, type ContentHash, type CoreEvent, type CoreEventListener, type CorrelationId, type CorruptionCode, type CorruptionIssue, type CorruptionSeverity, type CreateSnapshotOptions, type DaaScore, type DeterministicClock, type DeterministicDiff, type DeterministicRandom, EnvironmentTelemetry, type EventDomain, type EventEnvelope, type EventId, type EventKind, type EventPayloadByKind, type EventSequence, type ExecutionMode, ExecutionModeSchema, type HardkasConfig, HardkasError, type IdProvider, type IntegrityStatus, type InvariantDomain, type InvariantSeverity, InvariantViolationError, type KaspaAddress, LOCK_ORDER, type LayeredReplayDiff, type LineageId, type LockHandle, type LockMetadata, MIN_SUPPORTED_VERSION, MigrationManager, type MigrationResult, type MigrationStatus, type NetworkId, NetworkIdSchema, type ReplayContext, type RotationResult, type RpcEndpointId, type RuntimeContext, type RuntimeNoiseDiff, SOMPI_PER_KAS, type SchemaVersion, type SemanticDriftReport, type SemanticIdentity, type Severity, type SnapshotManifest, type StampedEvent, type StateProvenance, type StructuralDiff, TelemetryManager, TelemetryRotator, type TelemetrySubsystem, type TxId, type UnknownEventPayload, type WorkflowId, type WriteFileAtomicOptions, acquireLock, artifactTypeSchema, asArtifactId, asContentHash, asCorrelationId, asDaaScore, asEventId, asEventSequence, asKaspaAddress, asLineageId, asNetworkId, asRpcEndpointId, asTxId, asWorkflowId, assertNoSemanticDrift, attachLedgerAppender, classifyArtifactStatus, clearLock, comparePrePostMigrationLineage, coreEvents, createEventEnvelope, createSnapshot, detectSemanticDrift, deterministicCompare, diffReplays, executionModeSchema, formatCorruptionIssue, formatSompi, getTelemetry, globalTelemetry, hardkasConfigSchema, isProcessAlive, kaspaNetworkIdSchema, listLocks, maskSecrets, migrateArtifact, parseHardkasConfig, parseKasToSompi, readSnapshotManifest, redactSecret, resolveCanonicalArtifact, resolveLineage, systemRuntimeContext, telemetryContextStorage, validateEventEnvelope, validateStatusTransition, verifyArtifactIntegrity, verifyCapabilityBoundary, verifyMigrationIntegrity, verifyProjectionFreshness, verifyReplay, withLock, withLocks, writeFileAtomic, writeFileAtomicSync };
924
+ export { type AcquireLockArgs, type AnomalyEvent, type AnomalyType, AppendCoordinator, type ArtifactId, type ArtifactStatus, type ArtifactType, ArtifactTypeSchema, type Brand, type Branded, CURRENT_RUNTIME_VERSION, type ContentHash, type CoreEvent, type CoreEventListener, type CorrelationId, type CorruptionCode, type CorruptionIssue, type CorruptionSeverity, type CreateSnapshotOptions, type DaaScore, type DeterministicClock, type DeterministicDiff, type DeterministicRandom, EnvironmentTelemetry, type EventDomain, type EventEnvelope, type EventId, type EventKind, type EventPayloadByKind, type EventSequence, type ExecutionMode, ExecutionModeSchema, type HardkasConfig, HardkasError, type IdProvider, type IntegrityStatus, type InvariantDomain, type InvariantSeverity, InvariantViolationError, type KaspaAddress, LOCK_ORDER, type LayeredReplayDiff, type LineageId, type LockHandle, type LockMetadata, MIN_SUPPORTED_VERSION, MigrationManager, type MigrationResult, type MigrationStatus, type NetworkId, NetworkIdSchema, type ReplayContext, type RotationResult, type RpcEndpointId, type RuntimeContext, type RuntimeNoiseDiff, SOMPI_PER_KAS, type SchemaVersion, type SemanticDriftReport, type SemanticIdentity, type Severity, type SnapshotManifest, type StampedEvent, type StateProvenance, type StructuralDiff, TelemetryManager, TelemetryRotator, type TelemetrySubsystem, type TxId, type UnknownEventPayload, type WorkflowId, type WriteFileAtomicOptions, acquireLock, artifactTypeSchema, asArtifactId, asContentHash, asCorrelationId, asDaaScore, asEventId, asEventSequence, asKaspaAddress, asLineageId, asNetworkId, asRpcEndpointId, asTxId, asWorkflowId, assertNoSemanticDrift, attachLedgerAppender, classifyArtifactStatus, clearLock, comparePrePostMigrationLineage, coreEvents, createEventEnvelope, createKaspaP2shBlake2bLock, createPushOnlySignatureScript, createSnapshot, detectSemanticDrift, deterministicCompare, diffReplays, executionModeSchema, formatCorruptionIssue, formatSompi, getTelemetry, globalTelemetry, hardkasConfigSchema, isProcessAlive, kaspaNetworkIdSchema, listLocks, maskSecrets, migrateArtifact, parseHardkasConfig, parseKasToSompi, readSnapshotManifest, redactSecret, resolveCanonicalArtifact, resolveLineage, systemRuntimeContext, telemetryContextStorage, validateEventEnvelope, validateStatusTransition, verifyArtifactIntegrity, verifyCapabilityBoundary, verifyMigrationIntegrity, verifyProjectionFreshness, verifyReplay, withLock, withLocks, writeFileAtomic, writeFileAtomicSync };
package/dist/index.js CHANGED
@@ -956,7 +956,7 @@ async function createSnapshot(options) {
956
956
  const manifest = {
957
957
  snapshotVersion: 1,
958
958
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
959
- hardkasVersion: "0.8.19-alpha",
959
+ hardkasVersion: "0.9.0-alpha",
960
960
  stateAuthority: "filesystem",
961
961
  projectionAuthority: "sqlite",
962
962
  deterministicScope,
@@ -1205,7 +1205,7 @@ Resolution Command: ${report.exactReplayCommand}`
1205
1205
  // src/migrations.ts
1206
1206
  import fs6 from "fs";
1207
1207
  import path8 from "path";
1208
- var CURRENT_RUNTIME_VERSION = "0.8.19-alpha";
1208
+ var CURRENT_RUNTIME_VERSION = "0.9.0-alpha";
1209
1209
  var MIN_SUPPORTED_VERSION = "0.5.0-alpha";
1210
1210
  var MigrationManager = class {
1211
1211
  static checkVersion(rootDir) {
@@ -1299,6 +1299,64 @@ var MigrationManager = class {
1299
1299
  }
1300
1300
  };
1301
1301
 
1302
+ // src/silver.ts
1303
+ import { blake2b } from "@noble/hashes/blake2.js";
1304
+ function createKaspaP2shBlake2bLock(redeemScriptHex) {
1305
+ const scriptBytes = Buffer.from(redeemScriptHex, "hex");
1306
+ const redeemScriptHashBytes = blake2b(scriptBytes, { dkLen: 32 });
1307
+ const redeemScriptHash = Buffer.from(redeemScriptHashBytes).toString("hex");
1308
+ const lockingScriptHex = `aa20${redeemScriptHash}87`;
1309
+ return {
1310
+ scriptPublicKeyVersion: 0,
1311
+ lockingScriptHex,
1312
+ redeemScriptHash,
1313
+ redeemScriptHex
1314
+ };
1315
+ }
1316
+ function getPushDataPrefix(byteCount) {
1317
+ if (byteCount < 0) {
1318
+ throw new HardkasError("SILVERSCRIPT_INVALID_PUSHDATA", "Negative byte count");
1319
+ }
1320
+ if (byteCount === 0) {
1321
+ return "00";
1322
+ }
1323
+ if (byteCount <= 75) {
1324
+ return byteCount.toString(16).padStart(2, "0");
1325
+ }
1326
+ if (byteCount <= 255) {
1327
+ return `4c${byteCount.toString(16).padStart(2, "0")}`;
1328
+ }
1329
+ if (byteCount <= 65535) {
1330
+ const hex2 = byteCount.toString(16).padStart(4, "0");
1331
+ const le2 = hex2.substring(2, 4) + hex2.substring(0, 2);
1332
+ return `4d${le2}`;
1333
+ }
1334
+ const hex = byteCount.toString(16).padStart(8, "0");
1335
+ const le = hex.substring(6, 8) + hex.substring(4, 6) + hex.substring(2, 4) + hex.substring(0, 2);
1336
+ return `4e${le}`;
1337
+ }
1338
+ function createPushOnlySignatureScript(args, redeemScriptHex) {
1339
+ if (!redeemScriptHex || redeemScriptHex.trim() === "") {
1340
+ throw new HardkasError("SILVERSCRIPT_INVALID_REDEEM_SCRIPT", "Redeem script cannot be empty");
1341
+ }
1342
+ if (!/^[0-9a-fA-F]*$/.test(redeemScriptHex) || redeemScriptHex.length % 2 !== 0) {
1343
+ throw new HardkasError("SILVERSCRIPT_INVALID_REDEEM_SCRIPT", "Redeem script must be valid hex");
1344
+ }
1345
+ let signatureScript = "";
1346
+ for (const argHex of args) {
1347
+ if (!/^[0-9a-fA-F]*$/.test(argHex) || argHex.length % 2 !== 0) {
1348
+ throw new HardkasError("SILVERSCRIPT_SIGNATURE_SCRIPT_NOT_PUSH_ONLY", `Argument must be valid hex: ${argHex}`);
1349
+ }
1350
+ const byteCount = argHex.length / 2;
1351
+ const prefix = getPushDataPrefix(byteCount);
1352
+ signatureScript += prefix + argHex;
1353
+ }
1354
+ const redeemScriptByteCount = redeemScriptHex.length / 2;
1355
+ const redeemPrefix = getPushDataPrefix(redeemScriptByteCount);
1356
+ signatureScript += redeemPrefix + redeemScriptHex;
1357
+ return signatureScript;
1358
+ }
1359
+
1302
1360
  // src/index.ts
1303
1361
  var SOMPI_PER_KAS = 100000000n;
1304
1362
  var kaspaNetworkIdSchema = z.enum([
@@ -1323,7 +1381,15 @@ var artifactTypeSchema = z.enum([
1323
1381
  "policy.v1",
1324
1382
  "networkProfile.v1",
1325
1383
  "assumption.v1",
1326
- "migrationReceipt.v1"
1384
+ "migrationReceipt.v1",
1385
+ "silver.compile",
1386
+ "silver.test",
1387
+ "silver.spendPlan",
1388
+ "silver.deployPlan",
1389
+ "silver.deploy",
1390
+ "silver.spendReceipt",
1391
+ "silver.deploySimulation",
1392
+ "silver.spendSimulation"
1327
1393
  ]);
1328
1394
  var NetworkIdSchema = kaspaNetworkIdSchema;
1329
1395
  var ExecutionModeSchema = executionModeSchema;
@@ -1429,6 +1495,8 @@ export {
1429
1495
  comparePrePostMigrationLineage,
1430
1496
  coreEvents,
1431
1497
  createEventEnvelope,
1498
+ createKaspaP2shBlake2bLock,
1499
+ createPushOnlySignatureScript,
1432
1500
  createSnapshot,
1433
1501
  detectSemanticDrift,
1434
1502
  deterministicCompare,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/core",
3
- "version": "0.8.19-alpha",
3
+ "version": "0.9.0-alpha",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  }
13
13
  },
14
14
  "dependencies": {
15
+ "@noble/hashes": "^2.2.0",
15
16
  "pino": "^9.5.0",
16
17
  "zod": "^3.24.1"
17
18
  },