From 0bd9d4c49dc1f49b9ebe1638d533db27c8c10a5c Mon Sep 17 00:00:00 2001 From: goweiss <159821646+goweiss@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:36:59 +0300 Subject: [PATCH] * add ability to alter VITE port (#34) * dispose is async --- src/AppStore.ts | 4 ++-- src/IAppState.ts | 2 +- src/components/ui/NewTxDialog.tsx | 2 +- vite.config.ts | 28 ++++++++++++++++------------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/AppStore.ts b/src/AppStore.ts index 4c644a5..04fc933 100644 --- a/src/AppStore.ts +++ b/src/AppStore.ts @@ -564,7 +564,7 @@ export const useAppStore = create()((set, get) => { } return fireblocksNCW.deriveAssetKey(extendedPrivateKey, coinType, account, change, index); }, - disposeFireblocksNCW: () => { + disposeFireblocksNCW: async () => { if (!fireblocksNCW) { return; } @@ -574,7 +574,7 @@ export const useAppStore = create()((set, get) => { txsUnsubscriber = null; } - fireblocksNCW.dispose(); + await fireblocksNCW.dispose(); fireblocksNCW = null; set((state) => ({ ...state, fireblocksNCWStatus: "sdk_not_ready" })); }, diff --git a/src/IAppState.ts b/src/IAppState.ts index 03625b8..a6ce240 100644 --- a/src/IAppState.ts +++ b/src/IAppState.ts @@ -105,7 +105,7 @@ export interface IAppState { recoverKeys: (passphraseResolver: (passphraseId: string) => Promise) => Promise; backupKeys: (passhrase: string, passphraseId: string) => Promise; initFireblocksNCW: () => Promise; - disposeFireblocksNCW: () => void; + disposeFireblocksNCW: () => Promise; getWeb3Connections: () => Promise; createWeb3Connection: (uri: string) => Promise; approveWeb3Connection: () => Promise; diff --git a/src/components/ui/NewTxDialog.tsx b/src/components/ui/NewTxDialog.tsx index 3ee0829..5aace77 100644 --- a/src/components/ui/NewTxDialog.tsx +++ b/src/components/ui/NewTxDialog.tsx @@ -35,7 +35,7 @@ export const NewTxDialog: React.FC = ({ isOpen, onClose, assetsToSelectF note: `API Transaction by ${deviceId}`, accountId: "0", assetId: assetIdPrompt, - } + }; if (txType === "transfer") { dataToSend = { diff --git a/vite.config.ts b/vite.config.ts index 3a5e9f8..2d6cff0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,16 +1,20 @@ -import { defineConfig, splitVendorChunkPlugin } from "vite"; +import { defineConfig, loadEnv, splitVendorChunkPlugin } from "vite"; import react from "@vitejs/plugin-react"; // https://vitejs.dev/config/ -export default defineConfig({ - base: "/ncw-web-demo/", - plugins: [react(), splitVendorChunkPlugin()], - server: { - open: true, - host: 'localhost', - hmr: true, - }, - optimizeDeps: { - exclude: ["@fireblocks/ncw-js-sdk", "tsl-apple-cloudkit"], - }, +export default defineConfig(({ command, mode }) => { + const env = loadEnv(mode, process.cwd()); + return { + base: "/ncw-web-demo/", + plugins: [react(), splitVendorChunkPlugin()], + server: { + open: true, + host: 'localhost', + port: (env.VITE_PORT && Number(env.VITE_PORT)) || 5173, + hmr: true, + }, + optimizeDeps: { + exclude: ["@fireblocks/ncw-js-sdk", "tsl-apple-cloudkit"], + }, + } });