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]) => {
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ import transactionsData from '../content/transactions.json'
 | 
			
		||||
import state from '.'
 | 
			
		||||
import { showAlert } from '../state/actions/showAlert'
 | 
			
		||||
import { parseJSON } from '../utils/json'
 | 
			
		||||
import { extractFlags, transactionFlags } from './constants/flags'
 | 
			
		||||
import { extractFlags, getFlags } from './constants/flags'
 | 
			
		||||
 | 
			
		||||
export type SelectOption = {
 | 
			
		||||
  value: string
 | 
			
		||||
@@ -207,7 +207,7 @@ export const prepareState = (value: string, transactionType?: string) => {
 | 
			
		||||
    rest.Destination = Destination
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (transactionFlags[TransactionType] && rest.Flags) {
 | 
			
		||||
  if (getFlags(TransactionType) && rest.Flags) {
 | 
			
		||||
    const flags = extractFlags(TransactionType, rest.Flags)
 | 
			
		||||
 | 
			
		||||
    rest.Flags = undefined
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user