Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ckeshava committed Jan 18, 2025
1 parent 2316945 commit 94c0e37
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
16 changes: 8 additions & 8 deletions packages/xrpl/src/models/transactions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ import {
AuthorizeCredential,
Currency,
IssuedCurrencyAmount,
MPTAmount,
Memo,
Signer,
XChainBridge,
MPTAmount,
} from '../common'

import { onlyHasFields } from '../utils'

const MEMO_SIZE = 3
Expand Down Expand Up @@ -262,7 +261,7 @@ export function validateOptionalField(
/* eslint-enable @typescript-eslint/restrict-template-expressions -- checked before */

// eslint-disable-next-line @typescript-eslint/no-empty-interface -- no global flags right now, so this is fine
export interface GlobalFlags { }
export interface GlobalFlags {}

/**
* Every transaction has the same set of common fields.
Expand Down Expand Up @@ -462,12 +461,12 @@ export function validateCredentialType(tx: Record<string, unknown>): void {
* PermissionedDomainSet transaction uses 10, other transactions use 8.
* @throws Validation Error if the formatting is incorrect
*/
// eslint-disable-next-line max-lines-per-function -- separating logic further will add unnecessary complexity
// eslint-disable-next-line max-lines-per-function, max-params -- separating logic further will add unnecessary complexity
export function validateCredentialsList(
credentials: unknown,
transactionType: string,
isStringID: boolean,
maxLengthCredentialsArray: number
maxLengthCredentialsArray: number,
): void {
if (credentials == null) {
return
Expand Down Expand Up @@ -526,15 +525,16 @@ export function containsDuplicates(

// Type guard to ensure we're working with AuthorizeCredential[]
// Note: This is not a rigorous type-guard. A more thorough solution would be to iterate over the array and check each item.
const isAuthorizeCredential = (
function isAuthorizeCredentialArray(
list: AuthorizeCredential[] | string[],
): list is AuthorizeCredential[] => {
): list is AuthorizeCredential[] {
return typeof list[0] !== 'string'
}

if (isAuthorizeCredential(objectList)) {
if (isAuthorizeCredentialArray(objectList)) {
for (const item of objectList) {
const key = `${item.Credential.Issuer}-${item.Credential.CredentialType}`
// eslint-disable-next-line max-depth -- necessary to check for type-guards
if (seen.has(key)) {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion packages/xrpl/src/models/transactions/depositPreauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
BaseTransaction,
validateBaseTransaction,
validateCredentialsList,
MAX_CREDENTIALS_LIST_LENGTH
MAX_CREDENTIALS_LIST_LENGTH,
} from './common'

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/xrpl/src/models/transactions/escrowFinish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
validateBaseTransaction,
validateCredentialsList,
validateRequiredField,
MAX_CREDENTIALS_LIST_LENGTH
MAX_CREDENTIALS_LIST_LENGTH,
} from './common'

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export function validatePermissionedDomainSet(
validateBaseTransaction(tx)

validateOptionalField(tx, 'DomainID', isString)
validateRequiredField(tx, 'AcceptedCredentials', () => tx.AcceptedCredentials instanceof Array)
validateRequiredField(
tx,
'AcceptedCredentials',
() => tx.AcceptedCredentials instanceof Array,
)

validateCredentialsList(
tx.AcceptedCredentials,
Expand Down

0 comments on commit 94c0e37

Please sign in to comment.