Add global flags.
This commit is contained in:
@@ -5,24 +5,37 @@ interface Flags {
|
||||
}
|
||||
|
||||
export const transactionFlags: { [key: /* TransactionType */ string]: Flags } = {
|
||||
"*": {
|
||||
tfFullyCanonicalSig: '0x80000000'
|
||||
},
|
||||
Payment: {
|
||||
tfNoDirectRipple: "0x00010000",
|
||||
tfPartialPayment: "0x00020000",
|
||||
tfLimitQuality: "0x00040000",
|
||||
tfNoDirectRipple: '0x00010000',
|
||||
tfPartialPayment: '0x00020000',
|
||||
tfLimitQuality: '0x00040000',
|
||||
},
|
||||
// TODO Add more here
|
||||
}
|
||||
|
||||
export const getFlags = (tt?: string) => {
|
||||
if (!tt) return
|
||||
const flags = {
|
||||
...transactionFlags['*'],
|
||||
...transactionFlags[tt]
|
||||
}
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
|
||||
export function combineFlags(flags?: string[]): string | undefined {
|
||||
if (!flags) return
|
||||
|
||||
const num = flags.reduce((cumm, curr) => cumm | BigInt(curr), BigInt(0))
|
||||
const num = flags.reduce((cumm, curr) => cumm | BigInt(curr), BigInt(0))
|
||||
return num.toString()
|
||||
}
|
||||
|
||||
export function extractFlags(transactionType: string, flags?: string | number,): SelectOption[] {
|
||||
const flagsObj = transactionFlags[transactionType]
|
||||
const flagsObj = getFlags(transactionType)
|
||||
if (!flags || !flagsObj) return []
|
||||
|
||||
const extracted = Object.entries(flagsObj).reduce((cumm, [label, value]) => {
|
||||
|
||||
Reference in New Issue
Block a user