import { normalizeToPubkey } from "applesauce-core/helpers/pointers";
import { ReadonlySigner } from "applesauce-signers/signers/readonly-signer";
import { BaseAccount } from "../account.js";
/** An account that cannot sign or encrypt anything */
export class ReadonlyAccount extends BaseAccount {
    static type = "readonly";
    toJSON() {
        return super.saveCommonFields({
            signer: undefined,
        });
    }
    static fromJSON(json) {
        const account = new ReadonlyAccount(json.pubkey, new ReadonlySigner(json.pubkey));
        return super.loadCommonFields(account, json);
    }
    /** Creates a ReadonlyAccount from a hex public key or NIP-19 npub */
    static fromPubkey(pubkey) {
        const signer = ReadonlySigner.fromPubkey(pubkey);
        return new ReadonlyAccount(normalizeToPubkey(pubkey), signer);
    }
}
