qortal-ui/crypto/api/transactions/PaymentTransaction.js

64 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict'
2021-12-25 14:39:47 +01:00
import TransactionBase from './TransactionBase.js'
import Base58 from '../deps/Base58.js'
2023-11-05 14:30:07 +01:00
import {store} from '../../api.js'
2021-12-25 14:39:47 +01:00
export default class PaymentTransaction extends TransactionBase {
constructor() {
super()
this.type = 2
}
2021-12-25 14:39:47 +01:00
render(html) {
const conf = store.getState().config
return html`
<table>
<tr>
<th>${this._dialogto}:</th>
</tr>
<tr>
2023-11-05 14:30:07 +01:00
<td>${this.dialogAddress} ${' '}-</td>
<td>${Base58.encode(this._recipient)}</td>
</tr>
${this.recipientName ? html`
<tr>
2023-11-05 14:30:07 +01:00
<td>${this.dialogName} ${' '}-</td>
<td>${this.recipientName}</td>
</tr>
` : ''}
<tr>
<th>${this._dialogamount}</th>
<td>${this._amount / conf.coin.decimals} ${conf.coin.symbol}</td>
</tr>
</table>
`
}
2022-04-16 17:14:24 +02:00
set recipient(recipient) {
this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
}
2022-04-16 17:14:24 +02:00
set dialogto(dialogto) {
this._dialogto = dialogto
}
2022-04-16 17:14:24 +02:00
set dialogamount(dialogamount) {
this._dialogamount = dialogamount
}
2021-12-25 14:39:47 +01:00
set amount(amount) {
this._amount = Math.round(amount * store.getState().config.coin.decimals)
this._amountBytes = this.constructor.utils.int64ToBytes(this._amount)
}
get params() {
const params = super.params
params.push(
this._recipient,
this._amountBytes,
this._feeBytes
)
return params
}
2021-12-25 14:39:47 +01:00
}