Breaking-Change: Extremely rough update to work with Kioks wallet

This commit is contained in:
2026-05-22 14:11:07 +02:00
parent 3d6518e465
commit def261b568
17 changed files with 422 additions and 107 deletions

View File

@@ -34,8 +34,8 @@ import { homedir } from "node:os";
*
* IMPORTANT: Keep this in sync with actual switch statements in command handlers:
* - mnemonic.ts: create, import, list, expose
* - template.ts: import, list, inspect, set-default
* - invitation.ts: create, append, sign, broadcast, requirements, import, inspect, list
* - template.ts: import, list, inspect, export, set-default
* - invitation.ts: create, append, sign, broadcast, requirements, import, export, inspect, list
* - resource.ts: list, unreserve, unreserve-all
* - settings.ts: show, get, set
*/
@@ -43,7 +43,7 @@ import { homedir } from "node:os";
/** Subcommands for the mnemonic command */
const MNEMONIC_SUBS = ["create", "import", "list", "expose"];
/** Subcommands for the template command */
const TEMPLATE_SUBS = ["import", "list", "inspect", "set-default"];
const TEMPLATE_SUBS = ["import", "list", "inspect", "export", "set-default"];
/** Subcommands for the invitation command */
const INVITATION_SUBS = [
"create",
@@ -52,6 +52,7 @@ const INVITATION_SUBS = [
"broadcast",
"requirements",
"import",
"export",
"inspect",
"list",
];

View File

@@ -8,11 +8,7 @@
* and instead constructs the engine directly with an in-memory blockchain provider.
*/
import {
BlockchainMonitor,
Engine,
InMemoryBlockchainProvider,
} from "@xo-cash/engine";
import { BlockchainMonitor, Engine } from "@xo-cash/engine";
import { createStorageAdapter, State, StorageType } from "@xo-cash/state";
import { convertMnemonicToSeedBytes } from "@xo-cash/crypto";
import { binToHex, hash256 } from "@bitauth/libauth";
@@ -67,18 +63,21 @@ export async function createOfflineEngine(
// Create the state instance
const state = new State(storageAdapter);
// Use in-memory blockchain provider (no network connections)
const blockchainProvider = new InMemoryBlockchainProvider();
await blockchainProvider.initialize({
applicationIdentifier: "xo-cli-completions",
electrumOptions: {},
});
// Create a minimal blockchain monitor (no electrum initialization)
const blockchainMonitor = new BlockchainMonitor(state);
// Create a minimal blockchain monitor
const blockchainMonitor = new BlockchainMonitor(state, blockchainProvider);
// Engine constructor is private; bypass for offline read-only completions.
type EngineConstructor = new (
mnemonic: string,
state: State,
blockchainMonitor: BlockchainMonitor,
) => Engine;
// Construct engine directly without state sync
const engine = new Engine(seed, state, blockchainMonitor, blockchainProvider);
const engine = new (Engine as unknown as EngineConstructor)(
seed,
state,
blockchainMonitor,
);
return engine;
}

View File

@@ -161,7 +161,7 @@ _{{FUNC_NAME}}_completions() {
fi
fi
;;
append|sign|broadcast|requirements|inspect)
append|sign|broadcast|requirements|export|inspect)
# These subcommands expect an invitation identifier as first arg.
local pos=$((cword - subcmd_idx))
if [[ $pos -eq 1 ]]; then

View File

@@ -70,6 +70,7 @@ complete -c {{BIN_NAME}} -n "__fish_seen_subcommand_from invitation; and __fish_
complete -c {{BIN_NAME}} -n "__fish_seen_subcommand_from invitation; and __fish_seen_subcommand_from sign; and test (count (commandline -opc)) -eq 3" -xa '(__{{FUNC_NAME}}_complete_dynamic invitations)'
complete -c {{BIN_NAME}} -n "__fish_seen_subcommand_from invitation; and __fish_seen_subcommand_from broadcast; and test (count (commandline -opc)) -eq 3" -xa '(__{{FUNC_NAME}}_complete_dynamic invitations)'
complete -c {{BIN_NAME}} -n "__fish_seen_subcommand_from invitation; and __fish_seen_subcommand_from requirements; and test (count (commandline -opc)) -eq 3" -xa '(__{{FUNC_NAME}}_complete_dynamic invitations)'
complete -c {{BIN_NAME}} -n "__fish_seen_subcommand_from invitation; and __fish_seen_subcommand_from export; and test (count (commandline -opc)) -eq 3" -xa '(__{{FUNC_NAME}}_complete_dynamic invitations)'
complete -c {{BIN_NAME}} -n "__fish_seen_subcommand_from invitation; and __fish_seen_subcommand_from inspect; and test (count (commandline -opc)) -eq 3" -xa '(__{{FUNC_NAME}}_complete_dynamic invitations)'
# invitation import <path>

View File

@@ -145,7 +145,7 @@ _{{FUNC_NAME}}_completions() {
fi
fi
;;
append|sign|broadcast|requirements|inspect)
append|sign|broadcast|requirements|export|inspect)
# These subcommands take invitation ID as first argument.
local pos=$((CURRENT - subcmd_idx))
if [[ $pos -eq 1 ]]; then