draply/mac-os-support #1
@ -80,13 +80,95 @@ ipcMain.handle('wallet:checkKeystore', async () => {
|
||||
|
||||
if (!newestFile) return { exists: false, filePath: null }
|
||||
|
||||
return { exists: true, filePath: path.join(walletDir, newestFile) }
|
||||
const resolvedPath = path.join(walletDir, newestFile)
|
||||
let minBlockHeight: number | null = null
|
||||
|
||||
try {
|
||||
const json = fs.readFileSync(resolvedPath, 'utf-8')
|
||||
const data = JSON.parse(json)
|
||||
const height = data?.minBlockHeight
|
||||
|
||||
if (typeof height === 'number' && Number.isFinite(height)) {
|
||||
minBlockHeight = height
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Unable to read minBlockHeight from keystore:', error)
|
||||
}
|
||||
|
||||
return { exists: true, filePath: resolvedPath, minBlockHeight }
|
||||
} catch (error) {
|
||||
console.error('Error checking keystore ipc:', error)
|
||||
return { exists: false, filePath: null, error: String(error) }
|
||||
return { exists: false, filePath: null, minBlockHeight: null, error: String(error) }
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(
|
||||
'wallet:updateMinBlockHeight',
|
||||
async (_event, filePath: string | null, minBlockHeight: number | null) => {
|
||||
if (!filePath) {
|
||||
return { success: false, error: 'No keystore file path provided.' }
|
||||
}
|
||||
|
||||
try {
|
||||
const normalizedPath = path.isAbsolute(filePath)
|
||||
? filePath
|
||||
: path.join(process.cwd(), filePath)
|
||||
|
||||
if (!fs.existsSync(normalizedPath)) {
|
||||
return { success: false, error: 'Keystore file not found.' }
|
||||
}
|
||||
|
||||
const fileContents = fs.readFileSync(normalizedPath, 'utf-8')
|
||||
const walletJson = JSON.parse(fileContents)
|
||||
|
||||
if (minBlockHeight === null || Number.isNaN(minBlockHeight)) {
|
||||
walletJson.minBlockHeight = null
|
||||
} else {
|
||||
walletJson.minBlockHeight = minBlockHeight
|
||||
}
|
||||
|
||||
fs.writeFileSync(normalizedPath, JSON.stringify(walletJson, null, 2), 'utf-8')
|
||||
|
||||
return { success: true, minBlockHeight }
|
||||
} catch (error) {
|
||||
console.error('Error updating min block height:', error)
|
||||
return { success: false, error: String(error) }
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle(
|
||||
'wallet:getMinBlockHeight',
|
||||
async (_event, filePath: string | null) => {
|
||||
if (!filePath) {
|
||||
return { success: false, error: 'No keystore file path provided.', minBlockHeight: null }
|
||||
}
|
||||
|
||||
try {
|
||||
const normalizedPath = path.isAbsolute(filePath)
|
||||
? filePath
|
||||
: path.join(process.cwd(), filePath)
|
||||
|
||||
if (!fs.existsSync(normalizedPath)) {
|
||||
return { success: false, error: 'Keystore file not found.', minBlockHeight: null }
|
||||
}
|
||||
|
||||
const fileContents = fs.readFileSync(normalizedPath, 'utf-8')
|
||||
const walletJson = JSON.parse(fileContents)
|
||||
const height = walletJson?.minBlockHeight
|
||||
|
||||
if (typeof height === 'number' && Number.isFinite(height)) {
|
||||
return { success: true, minBlockHeight: height }
|
||||
}
|
||||
|
||||
return { success: true, minBlockHeight: null }
|
||||
} catch (error) {
|
||||
console.error('Error reading min block height:', error)
|
||||
return { success: false, error: String(error), minBlockHeight: null }
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
ipcMain.handle('wallet:generateKeysFromSeed', async (_event, seedPhrase: string[]) => {
|
||||
try {
|
||||
const wallet = new neptuneNative.WalletManager()
|
||||
@ -97,15 +179,19 @@ ipcMain.handle('wallet:generateKeysFromSeed', async (_event, seedPhrase: string[
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('wallet:buildTransactionWithPrimitiveProof', async (_event, args) => {
|
||||
ipcMain.handle('wallet:buildTransaction', async (_event, args) => {
|
||||
const { spendingKeyHex, inputAdditionRecords, outputAddresses, outputAmounts, fee } = args
|
||||
|
||||
try {
|
||||
const builder = new neptuneNative.SimpleTransactionBuilder()
|
||||
const result = await builder.buildTransactionWithPrimitiveProof(
|
||||
const result = await builder.buildTransaction(
|
||||
import.meta.env.VITE_APP_API,
|
||||
spendingKeyHex,
|
||||
inputAdditionRecords,
|
||||
// pass minBlockHeight from args if provided, default 0
|
||||
typeof args?.minBlockHeight === 'number' && Number.isFinite(args.minBlockHeight)
|
||||
? args.minBlockHeight
|
||||
: 0,
|
||||
outputAddresses,
|
||||
outputAmounts,
|
||||
fee
|
||||
|
||||
@ -12,6 +12,9 @@ contextBridge.exposeInMainWorld('walletApi', {
|
||||
checkKeystore: () => ipcRenderer.invoke('wallet:checkKeystore'),
|
||||
generateKeysFromSeed: (seedPhrase: string[]) =>
|
||||
ipcRenderer.invoke('wallet:generateKeysFromSeed', seedPhrase),
|
||||
buildTransactionWithPrimitiveProof: (args: any) =>
|
||||
ipcRenderer.invoke('wallet:buildTransactionWithPrimitiveProof', args),
|
||||
buildTransaction: (args: any) => ipcRenderer.invoke('wallet:buildTransaction', args),
|
||||
updateMinBlockHeight: (filePath: string | null, minBlockHeight: number | null) =>
|
||||
ipcRenderer.invoke('wallet:updateMinBlockHeight', filePath, minBlockHeight),
|
||||
getMinBlockHeight: (filePath: string | null) =>
|
||||
ipcRenderer.invoke('wallet:getMinBlockHeight', filePath),
|
||||
})
|
||||
|
||||
@ -4,7 +4,6 @@ export async function encrypt(seed: string, password: string) {
|
||||
const salt = crypto.randomBytes(16)
|
||||
const iv = crypto.randomBytes(12)
|
||||
|
||||
// derive 32-byte key từ password
|
||||
const key = await new Promise<Buffer>((resolve, reject) => {
|
||||
crypto.scrypt(password, salt, 32, { N: 16384, r: 8, p: 1 }, (err, derivedKey) => {
|
||||
if (err) reject(err)
|
||||
|
||||
9
env.d.ts
vendored
9
env.d.ts
vendored
@ -2,3 +2,12 @@
|
||||
|
||||
declare const MAIN_WINDOW_VITE_DEV_SERVER_URL: string | undefined;
|
||||
declare const MAIN_WINDOW_VITE_NAME: string | undefined;
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_APP_API: string
|
||||
readonly VITE_NODE_NETWORK?: 'mainnet' | 'testnet'
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
||||
|
||||
Binary file not shown.
7
packages/neptune-native/index.d.ts
vendored
7
packages/neptune-native/index.d.ts
vendored
@ -3,12 +3,9 @@
|
||||
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
/** Module initialization */
|
||||
export declare function initNativeModule(): string
|
||||
/** Quick VM test (can call immediately) */
|
||||
export declare function quickVmTest(): string
|
||||
export declare function getVersion(): string
|
||||
/** Wallet manager for key generation and transaction signing */
|
||||
export declare class WalletManager {
|
||||
constructor()
|
||||
/**
|
||||
@ -64,7 +61,7 @@ export declare class WalletManager {
|
||||
getStateCall(rpcUrl: string): Promise<string>
|
||||
/** Call mempool_submitTransaction to broadcast a pre-built transaction */
|
||||
submitTransactionCall(rpcUrl: string, transactionHex: string): Promise<string>
|
||||
getUtxosFromViewKeyCall(rpcUrl: string, viewKeyHex: string, startBlock: number, endBlock: number, maxSearchDepth?: number | undefined | null): Promise<string>
|
||||
getUtxosFromViewKeyCall(rpcUrl: string, viewKeyHex: string, startBlock: number, maxSearchDepth?: number | undefined | null): Promise<string>
|
||||
getArchivalMutatorSet(rpcUrl: string): Promise<string>
|
||||
/**
|
||||
* Build JSON-RPC request to find the canonical block that created a UTXO (by addition_record)
|
||||
@ -78,5 +75,5 @@ export declare class WalletManager {
|
||||
}
|
||||
export declare class SimpleTransactionBuilder {
|
||||
constructor()
|
||||
buildTransactionWithPrimitiveProof(rpcUrl: string, spendingKeyHex: string, inputAdditionRecords: Array<string>, outputAddresses: Array<string>, outputAmounts: Array<string>, fee: string): Promise<string>
|
||||
buildTransaction(rpcUrl: string, spendingKeyHex: string, inputAdditionRecords: Array<string>, minBlockHeight: number, outputAddresses: Array<string>, outputAmounts: Array<string>, fee: string): Promise<string>
|
||||
}
|
||||
|
||||
BIN
packages/neptune-native/neptune-native.darwin-arm64.node
Executable file
BIN
packages/neptune-native/neptune-native.darwin-arm64.node
Executable file
Binary file not shown.
BIN
packages/neptune-native/neptune-native.linux-x64-gnu.node
Executable file
BIN
packages/neptune-native/neptune-native.linux-x64-gnu.node
Executable file
Binary file not shown.
Binary file not shown.
@ -1,6 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { LayoutVue } from '@/components'
|
||||
|
||||
const config = {
|
||||
token: {
|
||||
colorPrimary: '#42A5F5',
|
||||
|
||||
@ -2,7 +2,7 @@ import { callJsonRpc } from '@/api/request'
|
||||
|
||||
export const getUtxosFromViewKey = async (
|
||||
viewKey: string,
|
||||
startBlock: number = 0,
|
||||
startBlock: number | null = 0,
|
||||
endBlock: number | null = null,
|
||||
maxSearchDepth: number = 1000
|
||||
): Promise<any> => {
|
||||
@ -17,7 +17,7 @@ export const getUtxosFromViewKey = async (
|
||||
|
||||
export const getBalance = async (
|
||||
viewKey: string,
|
||||
startBlock: number = 0,
|
||||
startBlock: number | null = 0,
|
||||
endBlock: number | null = null,
|
||||
maxSearchDepth: number = 1000
|
||||
): Promise<any> => {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { ButtonProps } from '@/interface'
|
||||
import { computed } from 'vue'
|
||||
import { SpinnerCommon } from '@/components'
|
||||
|
||||
const props = withDefaults(defineProps<ButtonProps>(), {
|
||||
type: 'default',
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ButtonCommon, CardBase, FormCommon } from '@/components'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
|
||||
@ -7,6 +7,7 @@ import type {
|
||||
WalletState,
|
||||
} from '@/interface'
|
||||
import initWasm, { generate_seed, address_from_seed, validate_seed_phrase } from '@neptune/wasm'
|
||||
import { toFiniteNumber } from '@/utils'
|
||||
|
||||
let wasmInitialized = false
|
||||
let initPromise: Promise<void> | null = null
|
||||
@ -125,6 +126,8 @@ export function useNeptuneWallet() {
|
||||
|
||||
const addressResult = await getAddressFromSeed(seedPhrase)
|
||||
store.setAddress(addressResult)
|
||||
|
||||
await loadMinBlockHeightFromKeystore()
|
||||
} catch (err) {
|
||||
if (
|
||||
err instanceof Error &&
|
||||
@ -142,6 +145,7 @@ export function useNeptuneWallet() {
|
||||
try {
|
||||
const result = await (window as any).walletApi.createKeystore(seed, password)
|
||||
store.setKeystorePath(result.filePath)
|
||||
store.setMinBlockHeight(null)
|
||||
return result.filePath
|
||||
} catch (err) {
|
||||
console.error('Error creating keystore:', err)
|
||||
@ -166,6 +170,10 @@ export function useNeptuneWallet() {
|
||||
if (!keystoreFile.exists) return false
|
||||
|
||||
store.setKeystorePath(keystoreFile.filePath)
|
||||
if ('minBlockHeight' in keystoreFile) {
|
||||
const height = keystoreFile.minBlockHeight
|
||||
store.setMinBlockHeight(toFiniteNumber(height))
|
||||
}
|
||||
return true
|
||||
} catch (err) {
|
||||
console.error('Error checking keystore:', err)
|
||||
@ -173,18 +181,73 @@ export function useNeptuneWallet() {
|
||||
}
|
||||
}
|
||||
|
||||
// ===== API METHODS =====
|
||||
const persistMinBlockHeight = async (utxos: any[]) => {
|
||||
const keystorePath = store.getKeystorePath
|
||||
if (!keystorePath) return
|
||||
|
||||
try {
|
||||
const minBlockHeight = utxos.reduce((min, utxo) => {
|
||||
const h = +(
|
||||
utxo?.blockHeight ??
|
||||
utxo?.block_height ??
|
||||
utxo?.height ??
|
||||
utxo?.block?.height
|
||||
)
|
||||
return Number.isFinite(h) && (min === null || h < min) ? h : min
|
||||
}, null)
|
||||
|
||||
const response = await (window as any).walletApi.updateMinBlockHeight(
|
||||
keystorePath,
|
||||
minBlockHeight
|
||||
)
|
||||
if (!response.success) throw new Error('Failed to update min block height')
|
||||
store.setMinBlockHeight(minBlockHeight)
|
||||
} catch (err) {
|
||||
console.error('Error saving min block height:', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
const loadMinBlockHeightFromKeystore = async (): Promise<number | null> => {
|
||||
const keystorePath = store.getKeystorePath
|
||||
if (!keystorePath) return null
|
||||
|
||||
try {
|
||||
const response = await (window as any).walletApi.getMinBlockHeight(keystorePath)
|
||||
if (!response?.success) return null
|
||||
|
||||
const minBlockHeight = toFiniteNumber(response.minBlockHeight)
|
||||
|
||||
store.setMinBlockHeight(minBlockHeight)
|
||||
return minBlockHeight
|
||||
} catch (err) {
|
||||
console.error('Error loading min block height:', err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
// ===== API METHODS =====
|
||||
const getUtxos = async (): Promise<any> => {
|
||||
try {
|
||||
if (!store.getViewKey) {
|
||||
throw new Error('No view key available. Please import or generate a wallet first.')
|
||||
}
|
||||
|
||||
const response = await API.getUtxosFromViewKey(store.getViewKey || '')
|
||||
let startBlock: number | null = store.getMinBlockHeight
|
||||
if (startBlock == null) startBlock = await loadMinBlockHeightFromKeystore()
|
||||
|
||||
const response = await API.getUtxosFromViewKey(
|
||||
store.getViewKey || '',
|
||||
toFiniteNumber(startBlock, 0)
|
||||
)
|
||||
|
||||
const result = response?.result || response
|
||||
store.setUtxos(result.utxos || result || [])
|
||||
const utxos = result?.utxos ?? result
|
||||
const utxoList = Array.isArray(utxos) ? utxos : []
|
||||
|
||||
store.setUtxos(utxoList)
|
||||
|
||||
await persistMinBlockHeight(utxoList)
|
||||
return result
|
||||
} catch (err) {
|
||||
console.error('Error getting UTXOs:', err)
|
||||
@ -194,8 +257,18 @@ export function useNeptuneWallet() {
|
||||
|
||||
const getBalance = async (): Promise<any> => {
|
||||
try {
|
||||
const response = await API.getBalance(store.getViewKey || '')
|
||||
let startBlock: number | null | undefined = store.getMinBlockHeight
|
||||
|
||||
if (startBlock === null || startBlock === undefined) {
|
||||
startBlock = await loadMinBlockHeightFromKeystore()
|
||||
}
|
||||
|
||||
const response = await API.getBalance(
|
||||
store.getViewKey || '',
|
||||
toFiniteNumber(startBlock, 0)
|
||||
)
|
||||
const result = response?.result || response
|
||||
|
||||
store.setBalance(result?.balance || result)
|
||||
store.setPendingBalance(result?.pendingBalance || result)
|
||||
return {
|
||||
@ -232,17 +305,21 @@ export function useNeptuneWallet() {
|
||||
}
|
||||
}
|
||||
|
||||
const buildTransactionWithPrimitiveProof = async (
|
||||
args: PayloadBuildTransaction
|
||||
): Promise<any> => {
|
||||
const buildTransaction = async (args: PayloadBuildTransaction): Promise<any> => {
|
||||
let minBlockHeight: number | null | undefined = store.getMinBlockHeight
|
||||
if (minBlockHeight === null || minBlockHeight === undefined) {
|
||||
minBlockHeight = await loadMinBlockHeightFromKeystore()
|
||||
}
|
||||
|
||||
const payload = {
|
||||
spendingKeyHex: store.getSpendingKey,
|
||||
inputAdditionRecords: args.inputAdditionRecords,
|
||||
minBlockHeight: toFiniteNumber(minBlockHeight, 0),
|
||||
outputAddresses: args.outputAddresses,
|
||||
outputAmounts: args.outputAmounts,
|
||||
fee: args.fee,
|
||||
}
|
||||
return await (window as any).walletApi.buildTransactionWithPrimitiveProof(payload)
|
||||
return await (window as any).walletApi.buildTransaction(payload)
|
||||
}
|
||||
|
||||
const broadcastSignedTransaction = async (transactionHex: string): Promise<any> => {
|
||||
@ -290,7 +367,7 @@ export function useNeptuneWallet() {
|
||||
getBalance,
|
||||
getBlockHeight,
|
||||
getNetworkInfo,
|
||||
buildTransactionWithPrimitiveProof,
|
||||
buildTransaction,
|
||||
broadcastSignedTransaction,
|
||||
decryptKeystore,
|
||||
createKeystore,
|
||||
|
||||
@ -9,6 +9,7 @@ export interface WalletState {
|
||||
balance?: string | null
|
||||
pendingBalance?: string | null
|
||||
utxos?: Utxo[]
|
||||
minBlockHeight?: number | null
|
||||
}
|
||||
|
||||
export interface GenerateSeedResult {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import type { WalletState } from '@/interface'
|
||||
import { toFiniteNumber } from '@/utils'
|
||||
|
||||
export const useNeptuneStore = defineStore('neptune', () => {
|
||||
const defaultNetwork = (import.meta.env.VITE_NODE_NETWORK || 'mainnet') as 'mainnet' | 'testnet'
|
||||
@ -17,6 +18,7 @@ export const useNeptuneStore = defineStore('neptune', () => {
|
||||
balance: null,
|
||||
pendingBalance: null,
|
||||
utxos: [],
|
||||
minBlockHeight: null,
|
||||
})
|
||||
|
||||
const keystorePath = ref<null | string>(null)
|
||||
@ -63,6 +65,10 @@ export const useNeptuneStore = defineStore('neptune', () => {
|
||||
wallet.value.utxos = utxos
|
||||
}
|
||||
|
||||
const setMinBlockHeight = (minBlockHeight: number | null) => {
|
||||
wallet.value.minBlockHeight = toFiniteNumber(minBlockHeight)
|
||||
}
|
||||
|
||||
const setWallet = (walletData: Partial<WalletState>) => {
|
||||
wallet.value = { ...wallet.value, ...walletData }
|
||||
}
|
||||
@ -83,6 +89,7 @@ export const useNeptuneStore = defineStore('neptune', () => {
|
||||
balance: null,
|
||||
pendingBalance: null,
|
||||
utxos: [],
|
||||
minBlockHeight: null,
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,6 +106,7 @@ export const useNeptuneStore = defineStore('neptune', () => {
|
||||
const getBalance = computed(() => wallet.value.balance)
|
||||
const getPendingBalance = computed(() => wallet.value.pendingBalance)
|
||||
const getUtxos = computed(() => wallet.value.utxos)
|
||||
const getMinBlockHeight = computed(() => wallet.value.minBlockHeight ?? null)
|
||||
const hasWallet = computed(() => wallet.value.address !== null)
|
||||
const getKeystorePath = computed(() => keystorePath.value)
|
||||
return {
|
||||
@ -114,6 +122,7 @@ export const useNeptuneStore = defineStore('neptune', () => {
|
||||
getBalance,
|
||||
getPendingBalance,
|
||||
getUtxos,
|
||||
getMinBlockHeight,
|
||||
hasWallet,
|
||||
getKeystorePath,
|
||||
setSeedPhrase,
|
||||
@ -126,6 +135,7 @@ export const useNeptuneStore = defineStore('neptune', () => {
|
||||
setBalance,
|
||||
setPendingBalance,
|
||||
setUtxos,
|
||||
setMinBlockHeight,
|
||||
setWallet,
|
||||
setKeystorePath,
|
||||
clearWallet,
|
||||
|
||||
3
src/utils/helpers/helpers.ts
Normal file
3
src/utils/helpers/helpers.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function toFiniteNumber(value: number | null, defaultValue?: number): number | null {
|
||||
return Number.isFinite(value) ? value : (defaultValue ?? null)
|
||||
}
|
||||
@ -2,3 +2,4 @@ export * from './constants/code'
|
||||
export * from './constants/constants'
|
||||
export * from './helpers/format'
|
||||
export * from './helpers/seedPhrase'
|
||||
export * from './helpers/helpers'
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { PasswordForm } from '@/components'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/authStore'
|
||||
|
||||
@ -1,6 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ButtonCommon } from '@/components'
|
||||
|
||||
const emit = defineEmits<{
|
||||
goToCreate: []
|
||||
goToRecover: []
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { ButtonCommon } from '@/components'
|
||||
import { useNeptuneStore } from '@/stores/neptuneStore'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { ButtonCommon } from '@/components'
|
||||
import { useNeptuneStore } from '@/stores/neptuneStore'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ButtonCommon, FormCommon } from '@/components'
|
||||
import { useNeptuneStore } from '@/stores'
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
@ -4,7 +4,6 @@ import { SeedPhraseDisplayComponent, ConfirmSeedComponent } from '..'
|
||||
import { CreatePasswordStep, WalletCreatedStep } from '.'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { CardBaseScrollable } from '@/components'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { ButtonCommon } from '@/components'
|
||||
import { useNeptuneStore } from '@/stores/neptuneStore'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ButtonCommon, PasswordForm } from '@/components'
|
||||
import { RecoverSeedComponent } from '..'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { TabsCommon, TabPaneCommon } from '@/components'
|
||||
import { WalletTab, NetworkTab, UTXOTab } from './components'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { formatNumberToLocaleString } from '@/utils'
|
||||
import { CardBase, SpinnerCommon } from '@/components'
|
||||
import { useNeptuneStore } from '@/stores/neptuneStore'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { message } from 'ant-design-vue'
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { ref, computed, onMounted, inject, watch, type ComputedRef } from 'vue'
|
||||
import { Table, message } from 'ant-design-vue'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { useNeptuneStore } from '@/stores/neptuneStore'
|
||||
import { CardBaseScrollable, SpinnerCommon } from '@/components'
|
||||
import { columns } from '../utils'
|
||||
|
||||
const { getUtxos } = useNeptuneWallet()
|
||||
const neptuneStore = useNeptuneStore()
|
||||
const activeTabKey = inject<ComputedRef<string>>('activeTabKey')
|
||||
|
||||
const loading = ref(false)
|
||||
|
||||
const utxosList = computed(() => (neptuneStore.getUtxos?.length ? neptuneStore.getUtxos : []))
|
||||
const utxosList = computed(() => [
|
||||
...(neptuneStore.getUtxos || []),
|
||||
])
|
||||
|
||||
const inUseUtxosCount = computed(() => (utxosList.value?.length ? utxosList.value.length : 0))
|
||||
const inUseUtxosAmount = computed(() => {
|
||||
@ -47,6 +49,13 @@ const loadUtxos = async () => {
|
||||
onMounted(() => {
|
||||
loadUtxos()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => activeTabKey?.value,
|
||||
(newTab) => {
|
||||
if (newTab === 'UTXOs') loadUtxos()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { ButtonCommon, ModalCommon } from '@/components'
|
||||
|
||||
interface Props {
|
||||
isLoading?: boolean
|
||||
|
||||
@ -27,7 +27,9 @@ const props = defineProps<Props>()
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.balance-section {
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: var(--spacing-xl);
|
||||
padding-bottom: var(--spacing-lg);
|
||||
border-bottom: 2px solid var(--border-color);
|
||||
|
||||
@ -1,15 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, computed, onMounted, onUnmounted, inject, watch, type ComputedRef } from 'vue'
|
||||
import { useNeptuneStore } from '@/stores/neptuneStore'
|
||||
import { useNeptuneWallet } from '@/composables/useNeptuneWallet'
|
||||
import { message } from 'ant-design-vue'
|
||||
import {
|
||||
ButtonCommon,
|
||||
CardBaseScrollable,
|
||||
ModalCommon,
|
||||
SpinnerCommon,
|
||||
PasswordForm,
|
||||
} from '@/components'
|
||||
import SeedPhraseDisplayComponent from '@/views/Auth/components/SeedPhraseDisplayComponent.vue'
|
||||
import SendTransactionComponent from './SendTransactionComponent.vue'
|
||||
import { WalletAddress, WalletBalance } from '.'
|
||||
@ -19,10 +12,11 @@ const neptuneStore = useNeptuneStore()
|
||||
const {
|
||||
getBalance,
|
||||
saveKeystoreAs,
|
||||
buildTransactionWithPrimitiveProof,
|
||||
buildTransaction,
|
||||
broadcastSignedTransaction,
|
||||
decryptKeystore,
|
||||
} = useNeptuneWallet()
|
||||
const activeTabKey = inject<ComputedRef<string>>('activeTabKey')
|
||||
|
||||
const availableBalance = ref<string>('0.00000000')
|
||||
const pendingBalance = ref<string>('0.00000000')
|
||||
@ -78,7 +72,7 @@ const handleSendTransaction = async (data: {
|
||||
fee: data.fee,
|
||||
}
|
||||
|
||||
const result = await buildTransactionWithPrimitiveProof(payload)
|
||||
const result = await buildTransaction(payload)
|
||||
if (!result.success) {
|
||||
message.error('Failed to build transaction')
|
||||
return
|
||||
@ -172,6 +166,13 @@ onMounted(() => {
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => activeTabKey?.value,
|
||||
(newTab) => {
|
||||
if (newTab === 'WALLET') loadWalletData()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user