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 1 day 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 { Buffer } from "buffer/";
import Dexie from "dexie"; import Dexie from "dexie";
import "dexie-export-import"; import "dexie-export-import";
import { importDB, ImportProgress } from "dexie-export-import"; import { ImportProgress } from "dexie-export-import";
import { LeafletMouseEvent } from "leaflet"; import { LeafletMouseEvent } from "leaflet";
import * as R from "ramda"; import * as R from "ramda";
import { IIdentifier } from "@veramo/core"; import { IIdentifier } from "@veramo/core";

13
src/views/NewEditProjectView.vue

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

Loading…
Cancel
Save