Browse Source

refactor: update nostr-tools imports for better tree shaking

Changes:
- Import specific functions from nostr-tools instead of full module
- Replace nip06.accountFromExtendedKey with direct import
- Update related function calls to use imported version

This change reduces bundle size by enabling better tree shaking
of unused nostr-tools functionality.
deep_linking
Matthew Raymer 21 hours ago
parent
commit
3b7a872ae1
  1. 2
      src/views/AccountViewView.vue
  2. 13
      src/views/NewEditProjectView.vue

2
src/views/AccountViewView.vue

@ -895,7 +895,7 @@ import { AxiosError } from "axios";
import { Buffer } from "buffer/";
import Dexie from "dexie";
import "dexie-export-import";
import { importDB, ImportProgress } from "dexie-export-import";
import { ImportProgress } from "dexie-export-import";
import { LeafletMouseEvent } from "leaflet";
import * as R from "ramda";
import { IIdentifier } from "@veramo/core";

13
src/views/NewEditProjectView.vue

@ -229,8 +229,8 @@
import "leaflet/dist/leaflet.css";
import { AxiosError, AxiosRequestHeaders } from "axios";
import { DateTime } from "luxon";
import { finalizeEvent } from "nostr-tools";
import * as nip06 from "nostr-tools/nip06";
import { finalizeEvent } from "nostr-tools/lib/esm/index.js";
import { accountFromExtendedKey, extendedKeysFromSeedWords } from "nostr-tools/lib/esm/nip06.js";
import { Component, Vue } from "vue-facing-decorator";
import { LMap, LMarker, LTileLayer } from "@vue-leaflet/vue-leaflet";
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
@ -252,7 +252,8 @@ import {
retrieveAccountCount,
retrieveFullyDecryptedAccount,
} from "../libs/util";
import { EventTemplate, UnsignedEvent, VerifiedEvent } from "nostr-tools/core";
import { EventTemplate, UnsignedEvent, VerifiedEvent } from "nostr-tools/lib/esm/index.js";
import { finalizeEvent as nostrToolsFinalizeEvent, serializeEvent } from "nostr-tools/lib/esm/index.js";
@Component({
components: { ImageMethodDialog, LMap, LMarker, LTileLayer, QuickNav },
@ -667,7 +668,7 @@ export default class NewEditProjectView extends Vue {
// remove any trailing '
const finalDerNumNoApostrophe = finalDerNum?.replace(/'/g, "");
const accountNum = Number(finalDerNumNoApostrophe || 0);
const extPubPri = nip06.extendedKeysFromSeedWords(
const extPubPri = extendedKeysFromSeedWords(
account?.mnemonic as string,
"",
accountNum,
@ -675,7 +676,7 @@ export default class NewEditProjectView extends Vue {
const publicExtendedKey: string = extPubPri?.publicExtendedKey;
const privateExtendedKey = extPubPri?.privateExtendedKey;
const privateBytes: Uint8Array =
nip06.accountFromExtendedKey(privateExtendedKey).privateKey;
accountFromExtendedKey(privateExtendedKey).privateKey;
// No real content is necessary, we just want something signed,
// so we might as well use nostr libs for nostr functions.
// Besides: someday we may create real content that we can relay.
@ -710,7 +711,7 @@ export default class NewEditProjectView extends Vue {
const timeSafariUrl = window.location.origin + "/claim/" + jwtId;
const content = this.fullClaim.name + " - see " + timeSafariUrl;
const publicKeyHex =
nip06.accountFromExtendedKey(publicExtendedKey).publicKey;
accountFromExtendedKey(publicExtendedKey).publicKey;
const unsignedPayload: UnsignedEvent = {
// why doesn't "...signedPayload" work?
kind: signedPayload.kind,

Loading…
Cancel
Save