@hardkas/accounts 0.5.5-alpha → 0.6.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 +2 -1
- package/dist/index.js +26 -7
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ interface HardkasBaseAccount {
|
|
|
52
52
|
interface HardkasSimulatedAccount extends HardkasBaseAccount {
|
|
53
53
|
kind: "simulated";
|
|
54
54
|
address: string;
|
|
55
|
+
evmAddress?: string;
|
|
55
56
|
}
|
|
56
57
|
interface HardkasKaspaPrivateKeyAccount extends HardkasBaseAccount {
|
|
57
58
|
kind: "kaspa-private-key";
|
|
@@ -107,7 +108,7 @@ interface ResolveAccountOptions {
|
|
|
107
108
|
}
|
|
108
109
|
declare function resolveHardkasAccount(options: ResolveAccountOptions): HardkasAccount;
|
|
109
110
|
declare function listHardkasAccounts(config?: HardkasConfig): HardkasAccount[];
|
|
110
|
-
declare function resolveHardkasAccountAddress(accountOrAddress: string, config?: HardkasConfig): string;
|
|
111
|
+
declare function resolveHardkasAccountAddress(accountOrAddress: string, config?: HardkasConfig, context?: "L1" | "L2"): string;
|
|
111
112
|
declare function describeAccount(account: HardkasAccount): Record<string, unknown>;
|
|
112
113
|
|
|
113
114
|
interface EvmExportResult {
|
package/dist/index.js
CHANGED
|
@@ -178,7 +178,8 @@ function resolveHardkasAccount(options) {
|
|
|
178
178
|
return {
|
|
179
179
|
name: det.name,
|
|
180
180
|
kind: "simulated",
|
|
181
|
-
address: det.address
|
|
181
|
+
address: det.address,
|
|
182
|
+
evmAddress: det.evmAddress
|
|
182
183
|
};
|
|
183
184
|
}
|
|
184
185
|
const available = listHardkasAccounts(config).map((a) => a.name).join(", ");
|
|
@@ -191,7 +192,8 @@ function listHardkasAccounts(config) {
|
|
|
191
192
|
accounts.set(det.name, {
|
|
192
193
|
name: det.name,
|
|
193
194
|
kind: "simulated",
|
|
194
|
-
address: det.address
|
|
195
|
+
address: det.address,
|
|
196
|
+
evmAddress: det.evmAddress
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
199
|
const realStore = loadRealAccountStoreSync();
|
|
@@ -236,11 +238,24 @@ function listHardkasAccounts(config) {
|
|
|
236
238
|
}
|
|
237
239
|
return Array.from(accounts.values());
|
|
238
240
|
}
|
|
239
|
-
function resolveHardkasAccountAddress(accountOrAddress, config) {
|
|
241
|
+
function resolveHardkasAccountAddress(accountOrAddress, config, context = "L1") {
|
|
240
242
|
if (accountOrAddress.startsWith("kaspa:") || accountOrAddress.startsWith("kaspatest:") || accountOrAddress.startsWith("kaspasim:")) {
|
|
243
|
+
if (context === "L2") {
|
|
244
|
+
throw new Error(`Invalid L2 address provided: ${accountOrAddress}. Expected EVM address or account alias.`);
|
|
245
|
+
}
|
|
246
|
+
return accountOrAddress;
|
|
247
|
+
}
|
|
248
|
+
if (accountOrAddress.startsWith("0x") && accountOrAddress.length === 42) {
|
|
241
249
|
return accountOrAddress;
|
|
242
250
|
}
|
|
243
251
|
const account = resolveHardkasAccount({ nameOrAddress: accountOrAddress, config });
|
|
252
|
+
if (context === "L2") {
|
|
253
|
+
const evmAddress = account.evmAddress;
|
|
254
|
+
if (!evmAddress) {
|
|
255
|
+
throw new Error(`Account '${account.name}' does not have an EVM address configured for L2.`);
|
|
256
|
+
}
|
|
257
|
+
return evmAddress;
|
|
258
|
+
}
|
|
244
259
|
if (!account.address) {
|
|
245
260
|
throw new Error(`Account '${account.name}' does not have a resolved address yet.`);
|
|
246
261
|
}
|
|
@@ -319,6 +334,7 @@ import {
|
|
|
319
334
|
calculateContentHash as calculateContentHash2,
|
|
320
335
|
HARDKAS_VERSION as HARDKAS_VERSION2
|
|
321
336
|
} from "@hardkas/artifacts";
|
|
337
|
+
import { systemRuntimeContext } from "@hardkas/core";
|
|
322
338
|
|
|
323
339
|
// src/signer-backend.ts
|
|
324
340
|
async function loadKaspaWasm() {
|
|
@@ -455,9 +471,10 @@ var UnsupportedRealKaspaSigner = class {
|
|
|
455
471
|
};
|
|
456
472
|
async function signTxPlanArtifact(input) {
|
|
457
473
|
const { planArtifact, account } = input;
|
|
474
|
+
const planRecord = planArtifact;
|
|
458
475
|
if (planArtifact.schema === "hardkas.txPlan") {
|
|
459
|
-
} else if (
|
|
460
|
-
throw new Error(`Cannot sign artifact with status: ${
|
|
476
|
+
} else if (planRecord.status !== "built" && planRecord.status !== "unsigned") {
|
|
477
|
+
throw new Error(`Cannot sign artifact with status: ${planRecord.status}`);
|
|
461
478
|
}
|
|
462
479
|
if (planArtifact.mode === "simulated") {
|
|
463
480
|
if (account.kind !== "simulated") {
|
|
@@ -474,7 +491,8 @@ async function signTxPlanArtifact(input) {
|
|
|
474
491
|
if (account.kind === "simulated") {
|
|
475
492
|
return createSimulatedSignedTxArtifact(
|
|
476
493
|
planArtifact,
|
|
477
|
-
`simulated-signed-tx:${planArtifact.planId}
|
|
494
|
+
`simulated-signed-tx:${planArtifact.planId}`,
|
|
495
|
+
systemRuntimeContext
|
|
478
496
|
);
|
|
479
497
|
}
|
|
480
498
|
if (account.kind === "kaspa-private-key") {
|
|
@@ -520,7 +538,8 @@ async function signTxPlanArtifact(input) {
|
|
|
520
538
|
if (account.kind === "evm-private-key") {
|
|
521
539
|
throw new Error("EVM accounts are reserved for future Igra support and cannot sign Kaspa L1 transactions.");
|
|
522
540
|
}
|
|
523
|
-
|
|
541
|
+
const accountRecord = account;
|
|
542
|
+
throw new Error(`Unsupported account kind for signing: ${accountRecord.kind}`);
|
|
524
543
|
}
|
|
525
544
|
|
|
526
545
|
// src/kaspa-sdk-keygen.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hardkas/accounts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"hash-wasm": "^4.12.0",
|
|
20
|
-
"@hardkas/artifacts": "0.
|
|
21
|
-
"@hardkas/
|
|
22
|
-
"@hardkas/
|
|
23
|
-
"@hardkas/core": "0.
|
|
20
|
+
"@hardkas/artifacts": "0.6.0-alpha",
|
|
21
|
+
"@hardkas/config": "0.6.0-alpha",
|
|
22
|
+
"@hardkas/localnet": "0.6.0-alpha",
|
|
23
|
+
"@hardkas/core": "0.6.0-alpha"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"tsup": "^8.3.5",
|