-
Notifications
You must be signed in to change notification settings - Fork 525
/
Copy pathpayment-channel.ts
63 lines (57 loc) · 1.59 KB
/
payment-channel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {parseTimestamp} from './utils'
import {removeUndefined, dropsToXrp} from '../../common'
export type PaymentChannel = {
Sequence: number,
Account: string,
Amount: string,
Balance: string,
PublicKey: string,
Destination: string,
SettleDelay: number,
Expiration?: number,
CancelAfter?: number,
SourceTag?: number,
DestinationTag?: number,
OwnerNode: string,
LedgerEntryType: string,
PreviousTxnID: string,
PreviousTxnLgrSeq: number,
index: string
}
export type LedgerEntryResponse = {
node: PaymentChannel,
ledger_current_index?: number,
ledger_hash?: string,
ledger_index: number,
validated: boolean
}
type PaymentChannelResponse = {
account: string,
balance: string,
publicKey: string,
destination: string,
settleDelay: number,
expiration?: string,
cancelAfter?: string,
sourceTag?: number,
destinationTag?: number,
previousAffectingTransactionID: string,
previousAffectingTransactionLedgerVersion: number
}
function parsePaymentChannel(data: PaymentChannel): PaymentChannelResponse {
return removeUndefined({
account: data.Account,
amount: dropsToXrp(data.Amount),
balance: dropsToXrp(data.Balance),
destination: data.Destination,
publicKey: data.PublicKey,
settleDelay: data.SettleDelay,
expiration: parseTimestamp(data.Expiration),
cancelAfter: parseTimestamp(data.CancelAfter),
sourceTag: data.SourceTag,
destinationTag: data.DestinationTag,
previousAffectingTransactionID: data.PreviousTxnID,
previousAffectingTransactionLedgerVersion: data.PreviousTxnLgrSeq
})
}
export default parsePaymentChannel