Extract shared RPC types into src/lib/rpc-schema.ts, remove duplicate type declarations
This commit is contained in:
@@ -1,278 +1,17 @@
|
||||
import { Electroview } from 'electrobun/view'
|
||||
|
||||
export type MoneroBalance = {
|
||||
balance: string
|
||||
unlocked: string
|
||||
address: string
|
||||
height: number
|
||||
daemonHeight: number
|
||||
}
|
||||
|
||||
export type MoneroTxEntry = {
|
||||
hash: string
|
||||
amount: string
|
||||
timestamp: string
|
||||
direction: 'in' | 'out'
|
||||
height: number
|
||||
note?: string
|
||||
}
|
||||
|
||||
export type MoneroBinaryStatus = {
|
||||
installed: boolean
|
||||
downloading: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type MoneroWalletStatus = {
|
||||
running: boolean
|
||||
walletOpen: boolean
|
||||
walletName?: string
|
||||
connected: boolean
|
||||
}
|
||||
|
||||
export type MoneroSubaddressEntry = {
|
||||
accountIndex: number
|
||||
index: number
|
||||
address: string
|
||||
label: string
|
||||
balance: string
|
||||
unlockedBalance: string
|
||||
numUnspentOutputs: number
|
||||
isUsed: boolean
|
||||
numBlocksToUnlock: number
|
||||
}
|
||||
|
||||
export type MoneroAccountEntry = {
|
||||
index: number
|
||||
primaryAddress: string
|
||||
label: string
|
||||
balance: string
|
||||
unlockedBalance: string
|
||||
tag?: string
|
||||
subaddresses: MoneroSubaddressEntry[]
|
||||
}
|
||||
|
||||
export type TxEntry = {
|
||||
hash: string
|
||||
timeStamp: string
|
||||
from: string
|
||||
to: string
|
||||
value: string
|
||||
tokenSymbol?: string
|
||||
tokenDecimal?: string
|
||||
contractAddress?: string
|
||||
logo?: string
|
||||
pairedValue?: string
|
||||
pairedSymbol?: string
|
||||
pairedDecimals?: string
|
||||
pairedLogo?: string
|
||||
}
|
||||
|
||||
export type TransactionDetails = {
|
||||
hash: string
|
||||
from: string
|
||||
to: string | null
|
||||
value: string
|
||||
blockNumber: string | null
|
||||
fee: string
|
||||
gasPrice: string
|
||||
status: 'success' | 'reverted'
|
||||
type: string
|
||||
nonce: number
|
||||
input: string
|
||||
}
|
||||
|
||||
export type TokenBalanceResult = {
|
||||
symbol: string
|
||||
balance: string
|
||||
contractAddress: string
|
||||
logo?: string
|
||||
}
|
||||
|
||||
export type EvmWalletInfo = {
|
||||
id: string
|
||||
name: string
|
||||
hasPassword: boolean
|
||||
vaultKey: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
type RPC = {
|
||||
bun: {
|
||||
requests: {
|
||||
resetApp: {
|
||||
params: {}
|
||||
response: boolean
|
||||
}
|
||||
biometricCanAuth: {
|
||||
params: {}
|
||||
response: boolean
|
||||
}
|
||||
biometricAuth: {
|
||||
params: { reason: string }
|
||||
response: boolean
|
||||
}
|
||||
getSecret: {
|
||||
params: {
|
||||
service: string
|
||||
name: string
|
||||
}
|
||||
response: string | null
|
||||
}
|
||||
setSecret: {
|
||||
params: {
|
||||
service: string
|
||||
name: string
|
||||
value: string
|
||||
}
|
||||
response: void
|
||||
}
|
||||
fetchTxHistory: {
|
||||
params: {
|
||||
address: string
|
||||
chainid: string
|
||||
}
|
||||
response: TxEntry[]
|
||||
}
|
||||
fetchCachedTxHistory: {
|
||||
params: {
|
||||
address: string
|
||||
chainid: string
|
||||
}
|
||||
response: TxEntry[]
|
||||
}
|
||||
syncTxHistory: {
|
||||
params: { address: string; chainid: string }
|
||||
response: void
|
||||
}
|
||||
flushTxCache: {
|
||||
params: {}
|
||||
response: void
|
||||
}
|
||||
setAutoSync: {
|
||||
params: { address: string; chainid: string } | null
|
||||
response: void
|
||||
}
|
||||
fetchTokenBalances: {
|
||||
params: {
|
||||
address: string
|
||||
chainid: string
|
||||
}
|
||||
response: TokenBalanceResult[]
|
||||
}
|
||||
fetchTransactionDetails: {
|
||||
params: {
|
||||
hash: string
|
||||
chainid: string
|
||||
}
|
||||
response: TransactionDetails | null
|
||||
}
|
||||
openExternal: {
|
||||
params: {
|
||||
url: string
|
||||
}
|
||||
response: void
|
||||
}
|
||||
moneroBinaryStatus: {
|
||||
params: {}
|
||||
response: MoneroBinaryStatus
|
||||
}
|
||||
moneroDownloadBinary: {
|
||||
params: {}
|
||||
response: void
|
||||
}
|
||||
moneroStart: {
|
||||
params: {
|
||||
daemonAddress?: string
|
||||
}
|
||||
response: MoneroWalletStatus
|
||||
}
|
||||
moneroStop: {
|
||||
params: {}
|
||||
response: void
|
||||
}
|
||||
moneroCreateWallet: {
|
||||
params: {
|
||||
name: string
|
||||
password: string
|
||||
}
|
||||
response: {
|
||||
mnemonic: string
|
||||
address: string
|
||||
}
|
||||
}
|
||||
moneroRestoreWallet: {
|
||||
params: {
|
||||
name: string
|
||||
password: string
|
||||
mnemonic: string
|
||||
restoreHeight?: number
|
||||
}
|
||||
response: {
|
||||
address: string
|
||||
}
|
||||
}
|
||||
moneroOpenWallet: {
|
||||
params: {
|
||||
name: string
|
||||
password: string
|
||||
}
|
||||
response: void
|
||||
}
|
||||
moneroGetBalance: {
|
||||
params: {}
|
||||
response: MoneroBalance
|
||||
}
|
||||
moneroGetTransactions: {
|
||||
params: {}
|
||||
response: MoneroTxEntry[]
|
||||
}
|
||||
moneroWalletStatus: {
|
||||
params: {}
|
||||
response: MoneroWalletStatus
|
||||
}
|
||||
moneroGetAccounts: {
|
||||
params: {}
|
||||
response: MoneroAccountEntry[]
|
||||
}
|
||||
moneroListWallets: {
|
||||
params: {}
|
||||
response: string[]
|
||||
}
|
||||
evmCreateWallet: {
|
||||
params: {
|
||||
name: string
|
||||
phrase: string
|
||||
passwordHash?: string
|
||||
}
|
||||
response: { id: string; name: string; createdAt: string }
|
||||
}
|
||||
evmListWallets: {
|
||||
params: {}
|
||||
response: EvmWalletInfo[]
|
||||
}
|
||||
evmGetSeed: {
|
||||
params: { vaultKey: string }
|
||||
response: string
|
||||
}
|
||||
evmDeleteWallet: {
|
||||
params: { id: string }
|
||||
response: void
|
||||
}
|
||||
}
|
||||
messages: {}
|
||||
}
|
||||
webview: {
|
||||
requests: {}
|
||||
messages: {
|
||||
transfersUpdate: {
|
||||
count: number
|
||||
chainid: string
|
||||
address: string
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
import type { RPC } from './rpc-schema'
|
||||
export type {
|
||||
MoneroBalance,
|
||||
MoneroTxEntry,
|
||||
MoneroBinaryStatus,
|
||||
MoneroWalletStatus,
|
||||
MoneroSubaddressEntry,
|
||||
MoneroAccountEntry,
|
||||
TxEntry,
|
||||
TransactionDetails,
|
||||
TokenBalanceResult,
|
||||
EvmWalletInfo,
|
||||
} from './rpc-schema'
|
||||
|
||||
const rpc = Electroview.defineRPC<RPC>({
|
||||
maxRequestTime: 10000,
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
export type MoneroBalance = {
|
||||
balance: string
|
||||
unlocked: string
|
||||
address: string
|
||||
height: number
|
||||
daemonHeight: number
|
||||
}
|
||||
|
||||
export type MoneroTxEntry = {
|
||||
hash: string
|
||||
amount: string
|
||||
timestamp: string
|
||||
direction: 'in' | 'out'
|
||||
height: number
|
||||
note?: string
|
||||
}
|
||||
|
||||
export type MoneroBinaryStatus = {
|
||||
installed: boolean
|
||||
downloading: boolean
|
||||
error?: string
|
||||
}
|
||||
|
||||
export type MoneroWalletStatus = {
|
||||
running: boolean
|
||||
walletOpen: boolean
|
||||
walletName?: string
|
||||
connected: boolean
|
||||
}
|
||||
|
||||
export type MoneroSubaddressEntry = {
|
||||
accountIndex: number
|
||||
index: number
|
||||
address: string
|
||||
label: string
|
||||
balance: string
|
||||
unlockedBalance: string
|
||||
numUnspentOutputs: number
|
||||
isUsed: boolean
|
||||
numBlocksToUnlock: number
|
||||
}
|
||||
|
||||
export type MoneroAccountEntry = {
|
||||
index: number
|
||||
primaryAddress: string
|
||||
label: string
|
||||
balance: string
|
||||
unlockedBalance: string
|
||||
tag?: string
|
||||
subaddresses: MoneroSubaddressEntry[]
|
||||
}
|
||||
|
||||
export type TxEntry = {
|
||||
hash: string
|
||||
timeStamp: string
|
||||
from: string
|
||||
to: string
|
||||
value: string
|
||||
tokenSymbol?: string
|
||||
tokenDecimal?: string
|
||||
contractAddress?: string
|
||||
logo?: string
|
||||
pairedValue?: string
|
||||
pairedSymbol?: string
|
||||
pairedDecimals?: string
|
||||
pairedContractAddress?: string
|
||||
pairedLogo?: string
|
||||
}
|
||||
|
||||
export type TransactionDetails = {
|
||||
hash: string
|
||||
from: string
|
||||
to: string | null
|
||||
value: string
|
||||
blockNumber: string | null
|
||||
fee: string
|
||||
gasPrice: string
|
||||
status: 'success' | 'reverted'
|
||||
type: string
|
||||
nonce: number
|
||||
input: string
|
||||
}
|
||||
|
||||
export type TokenBalanceResult = {
|
||||
symbol: string
|
||||
balance: string
|
||||
contractAddress: string
|
||||
logo?: string
|
||||
}
|
||||
|
||||
export type EvmWalletInfo = {
|
||||
id: string
|
||||
name: string
|
||||
hasPassword: boolean
|
||||
vaultKey: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type RPC = {
|
||||
bun: {
|
||||
requests: {
|
||||
resetApp: { params: {}; response: boolean }
|
||||
biometricCanAuth: { params: {}; response: boolean }
|
||||
biometricAuth: { params: { reason: string }; response: boolean }
|
||||
getSecret: { params: { service: string; name: string }; response: string | null }
|
||||
setSecret: { params: { service: string; name: string; value: string }; response: void }
|
||||
fetchTxHistory: { params: { address: string; chainid: string }; response: TxEntry[] }
|
||||
fetchCachedTxHistory: { params: { address: string; chainid: string }; response: TxEntry[] }
|
||||
syncTxHistory: { params: { address: string; chainid: string }; response: void }
|
||||
flushTxCache: { params: {}; response: void }
|
||||
setAutoSync: { params: { address: string; chainid: string } | null; response: void }
|
||||
fetchTokenBalances: { params: { address: string; chainid: string }; response: TokenBalanceResult[] }
|
||||
fetchTransactionDetails: { params: { hash: string; chainid: string }; response: TransactionDetails | null }
|
||||
openExternal: { params: { url: string }; response: void }
|
||||
moneroBinaryStatus: { params: {}; response: MoneroBinaryStatus }
|
||||
moneroDownloadBinary: { params: {}; response: void }
|
||||
moneroStart: { params: { daemonAddress?: string }; response: MoneroWalletStatus }
|
||||
moneroStop: { params: {}; response: void }
|
||||
moneroCreateWallet: { params: { name: string; password: string }; response: { mnemonic: string; address: string } }
|
||||
moneroRestoreWallet: { params: { name: string; password: string; mnemonic: string; restoreHeight?: number }; response: { address: string } }
|
||||
moneroOpenWallet: { params: { name: string; password: string }; response: void }
|
||||
moneroGetBalance: { params: {}; response: MoneroBalance }
|
||||
moneroGetTransactions: { params: {}; response: MoneroTxEntry[] }
|
||||
moneroWalletStatus: { params: {}; response: MoneroWalletStatus }
|
||||
moneroGetAccounts: { params: {}; response: MoneroAccountEntry[] }
|
||||
moneroListWallets: { params: {}; response: string[] }
|
||||
evmCreateWallet: { params: { name: string; phrase: string; passwordHash?: string }; response: { id: string; name: string; createdAt: string } }
|
||||
evmListWallets: { params: {}; response: EvmWalletInfo[] }
|
||||
evmGetSeed: { params: { vaultKey: string }; response: string }
|
||||
evmDeleteWallet: { params: { id: string }; response: void }
|
||||
}
|
||||
messages: {}
|
||||
}
|
||||
webview: {
|
||||
requests: {}
|
||||
messages: {
|
||||
transfersUpdate: { count: number; chainid: string; address: string }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user