@hardkas/artifacts 0.2.1-alpha → 0.2.2-alpha.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/dist/index.d.ts +24 -4
- package/dist/index.js +35 -14
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ArtifactType, NetworkId, ExecutionMode, ContentHash, WorkflowId, Artifa
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { TxOutput, Utxo, TxPlan as TxPlan$1 } from '@hardkas/tx-builder';
|
|
4
4
|
|
|
5
|
-
declare const HARDKAS_VERSION = "0.2.
|
|
5
|
+
declare const HARDKAS_VERSION = "0.2.2-alpha.1";
|
|
6
6
|
declare const ARTIFACT_SCHEMAS: {
|
|
7
7
|
readonly LOCALNET_STATE: "hardkas.localnetState.v1";
|
|
8
8
|
readonly REAL_ACCOUNT_STORE: "hardkas.realAccountStore.v1";
|
|
@@ -42,6 +42,7 @@ declare const BaseArtifactSchema: z.ZodObject<{
|
|
|
42
42
|
schema: z.ZodString;
|
|
43
43
|
hardkasVersion: z.ZodString;
|
|
44
44
|
version: z.ZodLiteral<"1.0.0-alpha">;
|
|
45
|
+
hashVersion: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
45
46
|
networkId: z.ZodEnum<["mainnet", "testnet-10", "testnet-11", "testnet-12", "simnet", "simnet-1", "devnet"]>;
|
|
46
47
|
mode: z.ZodEnum<["simulated", "real", "readonly"]>;
|
|
47
48
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
@@ -72,6 +73,7 @@ declare const BaseArtifactSchema: z.ZodObject<{
|
|
|
72
73
|
networkId: "mainnet" | "testnet-10" | "testnet-11" | "testnet-12" | "simnet" | "simnet-1" | "devnet";
|
|
73
74
|
mode: "simulated" | "real" | "readonly";
|
|
74
75
|
createdAt: string;
|
|
76
|
+
hashVersion?: string | number | undefined;
|
|
75
77
|
contentHash?: string | undefined;
|
|
76
78
|
lineage?: {
|
|
77
79
|
artifactId: string;
|
|
@@ -87,6 +89,7 @@ declare const BaseArtifactSchema: z.ZodObject<{
|
|
|
87
89
|
networkId: "mainnet" | "testnet-10" | "testnet-11" | "testnet-12" | "simnet" | "simnet-1" | "devnet";
|
|
88
90
|
mode: "simulated" | "real" | "readonly";
|
|
89
91
|
createdAt: string;
|
|
92
|
+
hashVersion?: string | number | undefined;
|
|
90
93
|
contentHash?: string | undefined;
|
|
91
94
|
lineage?: {
|
|
92
95
|
artifactId: string;
|
|
@@ -112,6 +115,7 @@ declare const AccountRefSchema: z.ZodObject<{
|
|
|
112
115
|
declare const TxPlanSchema: z.ZodObject<{
|
|
113
116
|
hardkasVersion: z.ZodString;
|
|
114
117
|
version: z.ZodLiteral<"1.0.0-alpha">;
|
|
118
|
+
hashVersion: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
115
119
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
116
120
|
createdAt: z.ZodString;
|
|
117
121
|
lineage: z.ZodOptional<z.ZodObject<{
|
|
@@ -245,6 +249,7 @@ declare const TxPlanSchema: z.ZodObject<{
|
|
|
245
249
|
address: string;
|
|
246
250
|
amountSompi: string;
|
|
247
251
|
}[];
|
|
252
|
+
hashVersion?: string | number | undefined;
|
|
248
253
|
contentHash?: string | undefined;
|
|
249
254
|
lineage?: {
|
|
250
255
|
artifactId: string;
|
|
@@ -290,6 +295,7 @@ declare const TxPlanSchema: z.ZodObject<{
|
|
|
290
295
|
address: string;
|
|
291
296
|
amountSompi: string;
|
|
292
297
|
}[];
|
|
298
|
+
hashVersion?: string | number | undefined;
|
|
293
299
|
contentHash?: string | undefined;
|
|
294
300
|
lineage?: {
|
|
295
301
|
artifactId: string;
|
|
@@ -374,6 +380,7 @@ declare const LocalnetUtxoSchemaV2: z.ZodObject<{
|
|
|
374
380
|
declare const SnapshotSchema: z.ZodObject<{
|
|
375
381
|
hardkasVersion: z.ZodString;
|
|
376
382
|
version: z.ZodLiteral<"1.0.0-alpha">;
|
|
383
|
+
hashVersion: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
377
384
|
networkId: z.ZodEnum<["mainnet", "testnet-10", "testnet-11", "testnet-12", "simnet", "simnet-1", "devnet"]>;
|
|
378
385
|
mode: z.ZodEnum<["simulated", "real", "readonly"]>;
|
|
379
386
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
@@ -452,6 +459,7 @@ declare const SnapshotSchema: z.ZodObject<{
|
|
|
452
459
|
spent: boolean;
|
|
453
460
|
createdAtDaaScore: string;
|
|
454
461
|
}[];
|
|
462
|
+
hashVersion?: string | number | undefined;
|
|
455
463
|
contentHash?: string | undefined;
|
|
456
464
|
lineage?: {
|
|
457
465
|
artifactId: string;
|
|
@@ -483,6 +491,7 @@ declare const SnapshotSchema: z.ZodObject<{
|
|
|
483
491
|
spent: boolean;
|
|
484
492
|
createdAtDaaScore: string;
|
|
485
493
|
}[];
|
|
494
|
+
hashVersion?: string | number | undefined;
|
|
486
495
|
contentHash?: string | undefined;
|
|
487
496
|
lineage?: {
|
|
488
497
|
artifactId: string;
|
|
@@ -499,6 +508,7 @@ declare const SnapshotSchema: z.ZodObject<{
|
|
|
499
508
|
declare const TxReceiptSchema: z.ZodObject<{
|
|
500
509
|
hardkasVersion: z.ZodString;
|
|
501
510
|
version: z.ZodLiteral<"1.0.0-alpha">;
|
|
511
|
+
hashVersion: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
502
512
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
503
513
|
createdAt: z.ZodString;
|
|
504
514
|
lineage: z.ZodOptional<z.ZodObject<{
|
|
@@ -636,6 +646,7 @@ declare const TxReceiptSchema: z.ZodObject<{
|
|
|
636
646
|
amountSompi: string;
|
|
637
647
|
txId: string;
|
|
638
648
|
feeSompi: string;
|
|
649
|
+
hashVersion?: string | number | undefined;
|
|
639
650
|
contentHash?: string | undefined;
|
|
640
651
|
lineage?: {
|
|
641
652
|
artifactId: string;
|
|
@@ -692,6 +703,7 @@ declare const TxReceiptSchema: z.ZodObject<{
|
|
|
692
703
|
amountSompi: string;
|
|
693
704
|
txId: string;
|
|
694
705
|
feeSompi: string;
|
|
706
|
+
hashVersion?: string | number | undefined;
|
|
695
707
|
contentHash?: string | undefined;
|
|
696
708
|
lineage?: {
|
|
697
709
|
artifactId: string;
|
|
@@ -731,6 +743,7 @@ declare const TxReceiptSchema: z.ZodObject<{
|
|
|
731
743
|
declare const SignedTxSchema: z.ZodObject<{
|
|
732
744
|
hardkasVersion: z.ZodString;
|
|
733
745
|
version: z.ZodLiteral<"1.0.0-alpha">;
|
|
746
|
+
hashVersion: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
734
747
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
735
748
|
createdAt: z.ZodString;
|
|
736
749
|
lineage: z.ZodOptional<z.ZodObject<{
|
|
@@ -823,6 +836,7 @@ declare const SignedTxSchema: z.ZodObject<{
|
|
|
823
836
|
format: string;
|
|
824
837
|
payload: string;
|
|
825
838
|
};
|
|
839
|
+
hashVersion?: string | number | undefined;
|
|
826
840
|
contentHash?: string | undefined;
|
|
827
841
|
lineage?: {
|
|
828
842
|
artifactId: string;
|
|
@@ -858,6 +872,7 @@ declare const SignedTxSchema: z.ZodObject<{
|
|
|
858
872
|
format: string;
|
|
859
873
|
payload: string;
|
|
860
874
|
};
|
|
875
|
+
hashVersion?: string | number | undefined;
|
|
861
876
|
contentHash?: string | undefined;
|
|
862
877
|
lineage?: {
|
|
863
878
|
artifactId: string;
|
|
@@ -872,6 +887,7 @@ declare const SignedTxSchema: z.ZodObject<{
|
|
|
872
887
|
declare const TxTraceSchema: z.ZodObject<{
|
|
873
888
|
hardkasVersion: z.ZodString;
|
|
874
889
|
version: z.ZodLiteral<"1.0.0-alpha">;
|
|
890
|
+
hashVersion: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
875
891
|
contentHash: z.ZodOptional<z.ZodString>;
|
|
876
892
|
createdAt: z.ZodString;
|
|
877
893
|
lineage: z.ZodOptional<z.ZodObject<{
|
|
@@ -976,6 +992,7 @@ declare const TxTraceSchema: z.ZodObject<{
|
|
|
976
992
|
timestamp: string;
|
|
977
993
|
details?: any;
|
|
978
994
|
}[];
|
|
995
|
+
hashVersion?: string | number | undefined;
|
|
979
996
|
contentHash?: string | undefined;
|
|
980
997
|
lineage?: {
|
|
981
998
|
artifactId: string;
|
|
@@ -1012,6 +1029,7 @@ declare const TxTraceSchema: z.ZodObject<{
|
|
|
1012
1029
|
timestamp: string;
|
|
1013
1030
|
details?: any;
|
|
1014
1031
|
}[];
|
|
1032
|
+
hashVersion?: string | number | undefined;
|
|
1015
1033
|
contentHash?: string | undefined;
|
|
1016
1034
|
lineage?: {
|
|
1017
1035
|
artifactId: string;
|
|
@@ -1118,15 +1136,16 @@ declare function assertDecimalBigIntString(value: any, field: string, errors: st
|
|
|
1118
1136
|
declare function assertHexData(value: any, field: string, errors: string[]): void;
|
|
1119
1137
|
declare function assertEvmAddress(value: any, field: string, errors: string[]): void;
|
|
1120
1138
|
declare function assertEvmTxHash(value: any, field: string, errors: string[]): void;
|
|
1121
|
-
declare function createIgraPlanId(): string;
|
|
1122
|
-
declare function createIgraSignedId(): string;
|
|
1123
|
-
declare function createIgraDeployPlanId(): string;
|
|
1139
|
+
declare function createIgraPlanId(hash: string): string;
|
|
1140
|
+
declare function createIgraSignedId(hash: string): string;
|
|
1141
|
+
declare function createIgraDeployPlanId(hash: string): string;
|
|
1124
1142
|
|
|
1125
1143
|
type AssumptionLevel = "dev" | "trusted" | "network-observed";
|
|
1126
1144
|
interface HardkasArtifactBase {
|
|
1127
1145
|
schema: HardkasArtifactSchema;
|
|
1128
1146
|
hardkasVersion: string;
|
|
1129
1147
|
version: string;
|
|
1148
|
+
hashVersion?: number | string;
|
|
1130
1149
|
networkId: NetworkId;
|
|
1131
1150
|
mode: ExecutionMode;
|
|
1132
1151
|
createdAt: string;
|
|
@@ -1135,6 +1154,7 @@ interface BaseArtifact<T extends ArtifactType> {
|
|
|
1135
1154
|
schema: `hardkas.${T}`;
|
|
1136
1155
|
hardkasVersion: string;
|
|
1137
1156
|
version: string;
|
|
1157
|
+
hashVersion?: number | string;
|
|
1138
1158
|
networkId: NetworkId;
|
|
1139
1159
|
mode: ExecutionMode;
|
|
1140
1160
|
createdAt: string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/constants.ts
|
|
2
|
-
var HARDKAS_VERSION = "0.2.
|
|
2
|
+
var HARDKAS_VERSION = "0.2.2-alpha.1";
|
|
3
3
|
var ARTIFACT_SCHEMAS = {
|
|
4
4
|
LOCALNET_STATE: "hardkas.localnetState.v1",
|
|
5
5
|
REAL_ACCOUNT_STORE: "hardkas.realAccountStore.v1",
|
|
@@ -121,14 +121,14 @@ function assertEvmTxHash(value, field, errors) {
|
|
|
121
121
|
errors.push(`Invalid ${field}: must be a 0x-prefixed 64-character EVM transaction hash`);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
function createIgraPlanId() {
|
|
125
|
-
return `igra-plan-${
|
|
124
|
+
function createIgraPlanId(hash) {
|
|
125
|
+
return `igra-plan-${hash.slice(0, 16)}`;
|
|
126
126
|
}
|
|
127
|
-
function createIgraSignedId() {
|
|
128
|
-
return `igra-signed-${
|
|
127
|
+
function createIgraSignedId(hash) {
|
|
128
|
+
return `igra-signed-${hash.slice(0, 16)}`;
|
|
129
129
|
}
|
|
130
|
-
function createIgraDeployPlanId() {
|
|
131
|
-
return `igradeploy_${
|
|
130
|
+
function createIgraDeployPlanId(hash) {
|
|
131
|
+
return `igradeploy_${hash.slice(0, 16)}`;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
// src/canonical.ts
|
|
@@ -143,8 +143,23 @@ function canonicalStringify(obj) {
|
|
|
143
143
|
if (Array.isArray(obj)) {
|
|
144
144
|
return "[" + obj.map((item) => canonicalStringify(item)).join(",") + "]";
|
|
145
145
|
}
|
|
146
|
+
const SEMANTIC_EXCLUSIONS = /* @__PURE__ */ new Set([
|
|
147
|
+
"contentHash",
|
|
148
|
+
"artifactId",
|
|
149
|
+
"planId",
|
|
150
|
+
"lineage",
|
|
151
|
+
"createdAt",
|
|
152
|
+
"rpcUrl",
|
|
153
|
+
"indexedAt",
|
|
154
|
+
"file_path",
|
|
155
|
+
"file_mtime_ms",
|
|
156
|
+
"hardkasVersion",
|
|
157
|
+
"version",
|
|
158
|
+
"parentArtifactId",
|
|
159
|
+
"signedId"
|
|
160
|
+
]);
|
|
146
161
|
const sortedKeys = Object.keys(obj).filter(
|
|
147
|
-
(key) => key
|
|
162
|
+
(key) => !SEMANTIC_EXCLUSIONS.has(key) && obj[key] !== void 0
|
|
148
163
|
).sort();
|
|
149
164
|
const result = sortedKeys.map((key) => {
|
|
150
165
|
const value = obj[key];
|
|
@@ -172,6 +187,7 @@ var BaseArtifactSchema = z.object({
|
|
|
172
187
|
schema: z.string(),
|
|
173
188
|
hardkasVersion: z.string(),
|
|
174
189
|
version: z.literal(ARTIFACT_VERSION),
|
|
190
|
+
hashVersion: z.union([z.number(), z.string()]).optional(),
|
|
175
191
|
networkId: kaspaNetworkIdSchema,
|
|
176
192
|
mode: executionModeSchema,
|
|
177
193
|
contentHash: z.string().optional(),
|
|
@@ -1048,7 +1064,6 @@ function createTxPlanArtifact(options) {
|
|
|
1048
1064
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1049
1065
|
networkId: options.networkId,
|
|
1050
1066
|
mode: options.mode,
|
|
1051
|
-
planId: `plan-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
|
|
1052
1067
|
from: {
|
|
1053
1068
|
address: options.from.address,
|
|
1054
1069
|
accountName: options.from.accountName,
|
|
@@ -1080,7 +1095,9 @@ function createTxPlanArtifact(options) {
|
|
|
1080
1095
|
amountSompi: options.plan.change.amountSompi.toString()
|
|
1081
1096
|
};
|
|
1082
1097
|
}
|
|
1083
|
-
|
|
1098
|
+
const hash = calculateContentHash(artifact);
|
|
1099
|
+
artifact.planId = `plan-${hash.slice(0, 16)}`;
|
|
1100
|
+
artifact.contentHash = hash;
|
|
1084
1101
|
return artifact;
|
|
1085
1102
|
}
|
|
1086
1103
|
|
|
@@ -1090,22 +1107,24 @@ function createSimulatedSignedTxArtifact(plan, payload) {
|
|
|
1090
1107
|
schema: "hardkas.signedTx",
|
|
1091
1108
|
hardkasVersion: HARDKAS_VERSION,
|
|
1092
1109
|
version: ARTIFACT_VERSION,
|
|
1110
|
+
hashVersion: 1,
|
|
1093
1111
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1094
1112
|
status: "signed",
|
|
1095
|
-
signedId: `signed-${Date.now()}`,
|
|
1096
1113
|
sourcePlanId: plan.planId,
|
|
1097
1114
|
networkId: plan.networkId,
|
|
1098
1115
|
mode: plan.mode,
|
|
1099
1116
|
from: { address: plan.from.address },
|
|
1100
1117
|
to: { address: plan.to.address },
|
|
1101
1118
|
amountSompi: plan.amountSompi,
|
|
1102
|
-
txId: `simulated-${plan.planId}-${Date.now()}`,
|
|
1103
1119
|
signedTransaction: {
|
|
1104
1120
|
format: "simulated",
|
|
1105
1121
|
payload
|
|
1106
1122
|
}
|
|
1107
1123
|
};
|
|
1108
|
-
|
|
1124
|
+
const hash = calculateContentHash(artifact);
|
|
1125
|
+
artifact.signedId = `signed-${hash.slice(0, 16)}`;
|
|
1126
|
+
artifact.txId = `simulated-${plan.planId}-${hash.slice(0, 8)}`;
|
|
1127
|
+
artifact.contentHash = hash;
|
|
1109
1128
|
return artifact;
|
|
1110
1129
|
}
|
|
1111
1130
|
function createSimulatedTxReceipt(plan, txId, extra) {
|
|
@@ -1113,6 +1132,7 @@ function createSimulatedTxReceipt(plan, txId, extra) {
|
|
|
1113
1132
|
schema: "hardkas.txReceipt",
|
|
1114
1133
|
hardkasVersion: HARDKAS_VERSION,
|
|
1115
1134
|
version: ARTIFACT_VERSION,
|
|
1135
|
+
hashVersion: 1,
|
|
1116
1136
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1117
1137
|
txId,
|
|
1118
1138
|
status: "accepted",
|
|
@@ -1127,7 +1147,8 @@ function createSimulatedTxReceipt(plan, txId, extra) {
|
|
|
1127
1147
|
createdUtxoIds: extra?.createdUtxoIds,
|
|
1128
1148
|
daaScore: extra?.daaScore
|
|
1129
1149
|
};
|
|
1130
|
-
|
|
1150
|
+
const hash = calculateContentHash(artifact);
|
|
1151
|
+
artifact.contentHash = hash;
|
|
1131
1152
|
return artifact;
|
|
1132
1153
|
}
|
|
1133
1154
|
function getBroadcastableSignedTransaction(artifact) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/artifacts",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2-alpha.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Javier Rodriguez",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"zod": "^3.24.1",
|
|
27
|
-
"@hardkas/core": "0.2.
|
|
28
|
-
"@hardkas/tx-builder": "0.2.
|
|
27
|
+
"@hardkas/core": "0.2.2-alpha.1",
|
|
28
|
+
"@hardkas/tx-builder": "0.2.2-alpha.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"tsup": "^8.3.5",
|