This commit is contained in:
Denis Angell
2023-03-27 18:57:11 +00:00
parent f19466cabe
commit 0560a5867f

View File

@@ -16,8 +16,6 @@ import { HookParameter } from '../models/common'
* @description
* Transaction types
*/
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Required
export const tts = TRANSACTION_TYPE_MAP
/**
* @typedef TTS
@@ -35,9 +33,6 @@ export type TTS = typeof tts
export function calculateHookOn(arr: Array<keyof TTS>): string {
let hash = '0x3e3ff5bf'
arr.forEach((nth) => {
if (!TRANSACTION_TYPE_MAP) {
throw new XrplError(`TRANSACTION_TYPE_MAP malformed or undefined`)
}
if (typeof nth !== 'string') {
throw new XrplError(`HookOn transaction type must be string`)
}
@@ -46,8 +41,10 @@ export function calculateHookOn(arr: Array<keyof TTS>): string {
`invalid transaction type '${String(nth)}' in HookOn array`,
)
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Required
const tts: Record<string, number> = TRANSACTION_TYPE_MAP
let value = BigInt(hash)
// eslint-disable-next-line no-bitwise, @typescript-eslint/no-unsafe-member-access -- Required
// eslint-disable-next-line no-bitwise -- Required
value ^= BigInt(1) << BigInt(tts[nth])
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- Required
hash = `0x${value.toString(16)}`