import { loadOrCreateIdentity, identityFromPrivateKeyHex } from '@antseed/node';
/**
 * Load crypto context from either ANTSEED_IDENTITY_HEX env var
 * or from the data directory's identity file.
 */
export async function loadCryptoContext(options) {
    let identity;
    if (options.identityHex) {
        identity = identityFromPrivateKeyHex(options.identityHex);
    }
    else {
        const { homedir } = await import('node:os');
        const dataDir = options.dataDir || `${homedir()}/.antseed`;
        identity = await loadOrCreateIdentity(dataDir);
    }
    return { identity, wallet: identity.wallet, evmAddress: identity.wallet.address };
}
//# sourceMappingURL=crypto-context.js.map