@hardkas/accounts 0.12.0-rc.1 → 0.12.0-rc.16

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.
@@ -2,7 +2,7 @@ import {
2
2
  LazyAccountAuthorizer,
3
3
  PrivateKeyAuthorizer,
4
4
  StaticSignatureScriptAuthorizer
5
- } from "./chunk-YJL7P33W.js";
5
+ } from "./chunk-EKQU22GY.js";
6
6
  export {
7
7
  LazyAccountAuthorizer,
8
8
  PrivateKeyAuthorizer,
@@ -229,17 +229,59 @@ function resolveHardkasAccount(options) {
229
229
  `Unknown HardKAS account '${nameOrAddress}'. Available accounts: ${available}`
230
230
  );
231
231
  }
232
+ function assertAccountCompatible(account, target) {
233
+ if (account.kind === "synthetic" && target.mode !== "simulator") {
234
+ throw new AccountNetworkMismatchError({
235
+ expected: `Execution mode 'simulator'`,
236
+ actual: `Execution mode '${target.mode}'`,
237
+ detail: `Account '${account.name}' is a synthetic simulator account and cannot be used with mode '${target.mode}'.`
238
+ });
239
+ }
240
+ if ("network" in account && account.network && target.network && account.network !== target.network) {
241
+ throw new AccountNetworkMismatchError({
242
+ expected: target.network,
243
+ actual: account.network,
244
+ detail: `Account '${account.name}' is bound to network '${account.network}' but execution target is '${target.network}'.`
245
+ });
246
+ }
247
+ }
232
248
  function listHardkasAccounts(config) {
233
249
  const accounts = /* @__PURE__ */ new Map();
250
+ let targetMode = "localnet";
251
+ const execConfig = config?.execution;
252
+ if (execConfig) {
253
+ if (execConfig.mode) {
254
+ targetMode = execConfig.mode;
255
+ } else if (execConfig.default) {
256
+ const targetName = execConfig.default;
257
+ const target = execConfig.targets?.[targetName];
258
+ if (target?.mode) {
259
+ targetMode = target.mode;
260
+ } else if (targetName === "simulator") {
261
+ targetMode = "simulator";
262
+ }
263
+ }
264
+ } else if (config?.defaultNetwork === "simulated") {
265
+ targetMode = "simulator";
266
+ }
234
267
  const detAccounts = createDeterministicAccounts();
235
268
  for (const det of detAccounts) {
236
- accounts.set(det.name, {
237
- name: det.name,
238
- kind: "synthetic",
239
- executionMode: "simulator",
240
- address: det.address,
241
- evmAddress: det.evmAddress
242
- });
269
+ if (targetMode === "simulator") {
270
+ accounts.set(det.name, {
271
+ name: det.name,
272
+ kind: "synthetic",
273
+ executionMode: "simulator",
274
+ address: det.address,
275
+ evmAddress: det.evmAddress
276
+ });
277
+ } else {
278
+ accounts.set(det.name, {
279
+ name: det.name,
280
+ kind: "kaspa",
281
+ network: "simnet",
282
+ address: det.address
283
+ });
284
+ }
243
285
  }
244
286
  const workspaceRoot = config?.cwd || process.cwd();
245
287
  const devAccountsDir = path2.join(workspaceRoot, ".hardkas", "dev-accounts");
@@ -255,12 +297,14 @@ function listHardkasAccounts(config) {
255
297
  if (!keystore.metadata?.network) {
256
298
  throw new AccountNetworkMismatchError({ expected: "known network", actual: "undefined", detail: `at ${path2.join(devAccountsDir, file)}` });
257
299
  }
300
+ const accountKind = targetMode === "simulator" ? "synthetic" : "kaspa";
258
301
  accounts.set(name, {
259
302
  name,
260
- kind: "kaspa",
303
+ kind: accountKind,
261
304
  network: keystore.metadata.network,
262
305
  address: keystore.payload?.address || keystore.metadata?.address,
263
- keystorePath: path2.join(devAccountsDir, file)
306
+ keystorePath: path2.join(devAccountsDir, file),
307
+ ...accountKind === "synthetic" ? { executionMode: "simulator" } : {}
264
308
  });
265
309
  }
266
310
  } catch (e) {
@@ -450,6 +494,7 @@ export {
450
494
  listRealDevAccounts,
451
495
  resolveRealAccountOrAddress,
452
496
  resolveHardkasAccount,
497
+ assertAccountCompatible,
453
498
  listHardkasAccounts,
454
499
  resolveHardkasAccountAddress,
455
500
  describeAccount
@@ -63,7 +63,7 @@ var LazyAccountAuthorizer = class {
63
63
  accountName;
64
64
  workspaceRoot;
65
65
  async authorize(context) {
66
- const { resolveHardkasAccount } = await import("./resolve-GHZEED5L.js");
66
+ const { resolveHardkasAccount } = await import("./resolve-5JBZXBNN.js");
67
67
  const account = await resolveHardkasAccount({
68
68
  nameOrAddress: this.accountName,
69
69
  config: { cwd: this.workspaceRoot }
@@ -75,7 +75,7 @@ var LazyAccountAuthorizer = class {
75
75
  if (!pkValue && account.keystorePath) {
76
76
  try {
77
77
  const { KeystoreManager } = await import("./keystore-CMWEKGBF.js");
78
- const { DEV_ACCOUNTS_PASSWORD } = await import("./dev-accounts-B6ZVTPCW.js");
78
+ const { DEV_ACCOUNTS_PASSWORD } = await import("./dev-accounts-K5TPW2TH.js");
79
79
  const keystore = await KeystoreManager.loadEncryptedKeystore(account.keystorePath);
80
80
  const unlock = await KeystoreManager.decryptEncryptedKeystore(keystore, DEV_ACCOUNTS_PASSWORD);
81
81
  if (unlock.success && unlock.payload) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-R5P3WIWR.js";
4
4
  import {
5
5
  resolveHardkasAccount
6
- } from "./chunk-TRVIQTIO.js";
6
+ } from "./chunk-AVTGARCA.js";
7
7
  import {
8
8
  loadKaspaWasm
9
9
  } from "./chunk-6DPO5V3N.js";
@@ -56,7 +56,7 @@ var KaspaWasmPrivateKeySigner = class {
56
56
  if (!pkValue && account.keystorePath) {
57
57
  try {
58
58
  const KeystoreManager2 = (await import("./keystore-CMWEKGBF.js")).KeystoreManager;
59
- const DEV_ACCOUNTS_PASSWORD2 = (await import("./dev-accounts-B6ZVTPCW.js")).DEV_ACCOUNTS_PASSWORD;
59
+ const DEV_ACCOUNTS_PASSWORD2 = (await import("./dev-accounts-K5TPW2TH.js")).DEV_ACCOUNTS_PASSWORD;
60
60
  const keystore = await KeystoreManager2.loadEncryptedKeystore(account.keystorePath);
61
61
  const unlock = await KeystoreManager2.decryptEncryptedKeystore(keystore, DEV_ACCOUNTS_PASSWORD2);
62
62
  if (unlock.success && unlock.payload) {
@@ -76,7 +76,7 @@ var KaspaWasmPrivateKeySigner = class {
76
76
  throw err;
77
77
  }
78
78
  const expectedAddress = new sdk.PrivateKey(pkValue).toKeypair().toAddress(plan.networkId || "simnet").toString();
79
- const { PrivateKeyAuthorizer } = await import("./authorizers-OVWWAL5J.js");
79
+ const { PrivateKeyAuthorizer } = await import("./authorizers-DDHM4SUH.js");
80
80
  const sourceInputs = plan.inputs || plan.selectedUtxos || [];
81
81
  for (let i = 0; i < numInputs; i++) {
82
82
  if (!authorizers[i]) {
@@ -4,9 +4,9 @@ import {
4
4
  ensureDevAccounts,
5
5
  getOrCreateDevAccount,
6
6
  listDevAccountsSync
7
- } from "./chunk-6Q4K4A24.js";
7
+ } from "./chunk-SYYYAEO7.js";
8
8
  import "./chunk-R5P3WIWR.js";
9
- import "./chunk-TRVIQTIO.js";
9
+ import "./chunk-AVTGARCA.js";
10
10
  import "./chunk-6DPO5V3N.js";
11
11
  import "./chunk-YLG2NIAU.js";
12
12
  export {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { TxPlanArtifact, SignedTxArtifact, HardkasArtifactBase } from '@hardkas/artifacts';
2
- import { HardkasConfig } from '@hardkas/config';
3
2
  import * as _hardkas_core from '@hardkas/core';
4
3
  import { NetworkId } from '@hardkas/core';
4
+ import { HardkasConfig } from '@hardkas/config';
5
5
  import { TxPlan } from '@hardkas/tx-builder';
6
6
 
7
7
  interface TxInputAuthorizationContext {
@@ -153,6 +153,7 @@ interface ResolveAccountOptions {
153
153
  config?: HardkasConfig | undefined;
154
154
  }
155
155
  declare function resolveHardkasAccount(options: ResolveAccountOptions): HardkasAccount;
156
+ declare function assertAccountCompatible(account: HardkasAccount, target: _hardkas_core.HardkasExecutionTarget): void;
156
157
  declare function listHardkasAccounts(config?: HardkasConfig): HardkasAccount[];
157
158
  declare function resolveHardkasAccountAddress(accountOrAddress: string, config?: HardkasConfig, context?: "L1" | "L2"): Promise<string>;
158
159
  declare function describeAccount(account: HardkasAccount): Record<string, unknown>;
@@ -565,4 +566,4 @@ declare class WalletStateStoreJson {
565
566
  nextChangeIndex(walletId: string): number;
566
567
  }
567
568
 
568
- export { AddressManager, type ChainType, type CreateKaspaWalletOptions, DEV_ACCOUNTS_PASSWORD, type DeriveRequest, type DerivedAddress, type EncryptedKeystoreV2, type EvmExportResult, type GeneratedKaspaDevAccount, type HardkasAccount, type HardkasAccountKind, type HardkasBaseAccount, type HardkasEvmPrivateKeyAccount, type HardkasExternalWalletAccount, type HardkasKaspaAccount, type HardkasSigner, type HardkasSignerKind, type HardkasSyntheticAccount, type HardkasTxPlanSigner, type HelperDeriveRequest, type InputAuthorization, type KaspaKeyGenerator, KaspaSdkKeyGenerator, type KaspaSdkKeyGeneratorOptions, KaspaSdkRealTxSigner, type KaspaSdkRealTxSignerOptions, type KaspaSigningBackendStatus, KaspaWasmPrivateKeySigner, type KaspaWasmSignerOptions, type KeystoreCipherParams, type KeystoreKdfParams, KeystoreManager, type KeystorePayload, type KeystoreUnlockResult, LazyAccountAuthorizer, type NetworkType, type PathRequest, PrivateKeyAuthorizer, type RealAccountStore, type RealDevAccount, type RealTxSigner, type RealTxSigningInput, type RealTxSigningResult, type ResolveAccountOptions, type SignTxPlanInput, type SignTxPlanResult, SimulatedSigner, StaticSignatureScriptAuthorizer, type TxInputAuthorizationContext, type TxInputAuthorizer, UnsupportedKaspaKeyGenerator, UnsupportedRealKaspaSigner, UnsupportedRealTxSigner, type WalletArtifact, type WalletClaims, type WalletCreateRequest, type WalletImportRequest, WalletManager, WalletManagerImpl, type WalletMetadata, type WalletState, WalletStateStoreJson, type WalletStateStoreOptions, type WasmInputSigner, type WasmProviderConfig, appendToKeystoreJson, assertSigningNetworkAllowed, createDevSigner, createEmptyRealAccountStore, createLocalKaspaWallet, describeAccount, detectCapabilities, ensureDevAccounts, getDefaultRealAccountsPath, getKaspaSigningBackendStatus, getOrCreateDevAccount, getRealDevAccount, getRequiredEnv, importRealDevAccount, listDevAccountsSync, listHardkasAccounts, listRealDevAccounts, loadKaspaWasm, loadOrCreateRealAccountStore, loadRealAccountStore, loadRealAccountStoreSync, prepareEvmAccountExport, removeRealDevAccount, resolveHardkasAccount, resolveHardkasAccountAddress, resolveRealAccountOrAddress, saveRealAccountStore, signTxPlanArtifact, validateAccountName, validateAddressNetwork, validateAddressPrefix, withKeystoreLock };
569
+ export { AddressManager, type ChainType, type CreateKaspaWalletOptions, DEV_ACCOUNTS_PASSWORD, type DeriveRequest, type DerivedAddress, type EncryptedKeystoreV2, type EvmExportResult, type GeneratedKaspaDevAccount, type HardkasAccount, type HardkasAccountKind, type HardkasBaseAccount, type HardkasEvmPrivateKeyAccount, type HardkasExternalWalletAccount, type HardkasKaspaAccount, type HardkasSigner, type HardkasSignerKind, type HardkasSyntheticAccount, type HardkasTxPlanSigner, type HelperDeriveRequest, type InputAuthorization, type KaspaKeyGenerator, KaspaSdkKeyGenerator, type KaspaSdkKeyGeneratorOptions, KaspaSdkRealTxSigner, type KaspaSdkRealTxSignerOptions, type KaspaSigningBackendStatus, KaspaWasmPrivateKeySigner, type KaspaWasmSignerOptions, type KeystoreCipherParams, type KeystoreKdfParams, KeystoreManager, type KeystorePayload, type KeystoreUnlockResult, LazyAccountAuthorizer, type NetworkType, type PathRequest, PrivateKeyAuthorizer, type RealAccountStore, type RealDevAccount, type RealTxSigner, type RealTxSigningInput, type RealTxSigningResult, type SignTxPlanInput, type SignTxPlanResult, SimulatedSigner, StaticSignatureScriptAuthorizer, type TxInputAuthorizationContext, type TxInputAuthorizer, UnsupportedKaspaKeyGenerator, UnsupportedRealKaspaSigner, UnsupportedRealTxSigner, type WalletArtifact, type WalletClaims, type WalletCreateRequest, type WalletImportRequest, WalletManager, WalletManagerImpl, type WalletMetadata, type WalletState, WalletStateStoreJson, type WalletStateStoreOptions, type WasmInputSigner, type WasmProviderConfig, appendToKeystoreJson, assertAccountCompatible, assertSigningNetworkAllowed, createDevSigner, createEmptyRealAccountStore, createLocalKaspaWallet, describeAccount, detectCapabilities, ensureDevAccounts, getDefaultRealAccountsPath, getKaspaSigningBackendStatus, getOrCreateDevAccount, getRealDevAccount, getRequiredEnv, importRealDevAccount, listDevAccountsSync, listHardkasAccounts, listRealDevAccounts, loadKaspaWasm, loadOrCreateRealAccountStore, loadRealAccountStore, loadRealAccountStoreSync, prepareEvmAccountExport, removeRealDevAccount, resolveHardkasAccount, resolveHardkasAccountAddress, resolveRealAccountOrAddress, saveRealAccountStore, signTxPlanArtifact, validateAccountName, validateAddressNetwork, validateAddressPrefix, withKeystoreLock };
package/dist/index.js CHANGED
@@ -6,9 +6,10 @@ import {
6
6
  ensureDevAccounts,
7
7
  getOrCreateDevAccount,
8
8
  listDevAccountsSync
9
- } from "./chunk-6Q4K4A24.js";
9
+ } from "./chunk-SYYYAEO7.js";
10
10
  import "./chunk-R5P3WIWR.js";
11
11
  import {
12
+ assertAccountCompatible,
12
13
  createEmptyRealAccountStore,
13
14
  describeAccount,
14
15
  getDefaultRealAccountsPath,
@@ -27,7 +28,7 @@ import {
27
28
  validateAccountName,
28
29
  validateAddressNetwork,
29
30
  validateAddressPrefix
30
- } from "./chunk-TRVIQTIO.js";
31
+ } from "./chunk-AVTGARCA.js";
31
32
  import {
32
33
  detectCapabilities,
33
34
  getKaspaSigningBackendStatus,
@@ -40,7 +41,7 @@ import {
40
41
  LazyAccountAuthorizer,
41
42
  PrivateKeyAuthorizer,
42
43
  StaticSignatureScriptAuthorizer
43
- } from "./chunk-YJL7P33W.js";
44
+ } from "./chunk-EKQU22GY.js";
44
45
 
45
46
  // src/simulated.ts
46
47
  var SimulatedSigner = class {
@@ -717,6 +718,7 @@ export {
717
718
  WalletManagerImpl,
718
719
  WalletStateStoreJson,
719
720
  appendToKeystoreJson,
721
+ assertAccountCompatible,
720
722
  assertSigningNetworkAllowed,
721
723
  createDevSigner,
722
724
  createEmptyRealAccountStore,
@@ -1,10 +1,12 @@
1
1
  import {
2
+ assertAccountCompatible,
2
3
  describeAccount,
3
4
  listHardkasAccounts,
4
5
  resolveHardkasAccount,
5
6
  resolveHardkasAccountAddress
6
- } from "./chunk-TRVIQTIO.js";
7
+ } from "./chunk-AVTGARCA.js";
7
8
  export {
9
+ assertAccountCompatible,
8
10
  describeAccount,
9
11
  listHardkasAccounts,
10
12
  resolveHardkasAccount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardkas/accounts",
3
- "version": "0.12.0-rc.1",
3
+ "version": "0.12.0-rc.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -24,11 +24,11 @@
24
24
  "dependencies": {
25
25
  "hash-wasm": "^4.12.0",
26
26
  "kaspa-wasm": "0.13.0",
27
- "@hardkas/artifacts": "0.12.0-rc.1",
28
- "@hardkas/tx-builder": "0.12.0-rc.1",
29
- "@hardkas/localnet": "0.12.0-rc.1",
30
- "@hardkas/config": "0.12.0-rc.1",
31
- "@hardkas/core": "0.12.0-rc.1"
27
+ "@hardkas/artifacts": "0.12.0-rc.16",
28
+ "@hardkas/config": "0.12.0-rc.16",
29
+ "@hardkas/tx-builder": "0.12.0-rc.16",
30
+ "@hardkas/core": "0.12.0-rc.16",
31
+ "@hardkas/localnet": "0.12.0-rc.16"
32
32
  },
33
33
  "devDependencies": {
34
34
  "tsup": "^8.3.5",