Add Monero send page with transfer RPC and account selection
This commit is contained in:
@@ -7,6 +7,7 @@ export type {
|
||||
MoneroWalletStatus,
|
||||
MoneroSubaddressEntry,
|
||||
MoneroAccountEntry,
|
||||
MoneroSendResult,
|
||||
TxEntry,
|
||||
TransactionDetails,
|
||||
TokenBalanceResult,
|
||||
|
||||
@@ -40,6 +40,12 @@ export type MoneroSubaddressEntry = {
|
||||
numBlocksToUnlock: number
|
||||
}
|
||||
|
||||
export type MoneroSendResult = {
|
||||
txHash: string
|
||||
fee: string
|
||||
amount: string
|
||||
}
|
||||
|
||||
export type MoneroAccountEntry = {
|
||||
index: number
|
||||
primaryAddress: string
|
||||
@@ -129,6 +135,7 @@ export type RPC = {
|
||||
moneroWalletStatus: { params: {}; response: MoneroWalletStatus }
|
||||
moneroGetAccounts: { params: {}; response: MoneroAccountEntry[] }
|
||||
moneroListWallets: { params: {}; response: string[] }
|
||||
moneroTransfer: { params: { address: string; amount: string; priority?: number; accountIndex?: number }; response: MoneroSendResult }
|
||||
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 }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { electrobun, type MoneroTxEntry, type MoneroAccountEntry } from '$lib/electrobun'
|
||||
import { electrobun, type MoneroTxEntry, type MoneroAccountEntry, type MoneroSendResult } from '$lib/electrobun'
|
||||
import { tryCatch } from '@koins/utils'
|
||||
|
||||
export const moneroNetwork = {
|
||||
@@ -229,6 +229,23 @@ export const MoneroWallet = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const send = async (
|
||||
address: string,
|
||||
amountAtomic: string,
|
||||
priority?: number,
|
||||
accountIndex?: number,
|
||||
): Promise<MoneroSendResult> => {
|
||||
if (!electrobun.rpc) throw new Error('RPC not available')
|
||||
const result = await electrobun.rpc.request.moneroTransfer({
|
||||
address,
|
||||
amount: amountAtomic,
|
||||
priority,
|
||||
accountIndex,
|
||||
})
|
||||
await refresh()
|
||||
return result
|
||||
}
|
||||
|
||||
return {
|
||||
get accountType() { return accountType },
|
||||
get ready() { return ready },
|
||||
@@ -273,6 +290,7 @@ export const MoneroWallet = () => {
|
||||
restoreWallet,
|
||||
openWallet,
|
||||
refresh,
|
||||
send,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user