Skip to content

Commit

Permalink
change variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
ckeshava committed Feb 7, 2025
1 parent 7d1a8d4 commit 3dfeaf1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions packages/xrpl/src/models/transactions/accountDelete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
validateCredentialsList,
validateOptionalField,
validateRequiredField,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
} from './common'

/**
Expand Down Expand Up @@ -55,6 +55,6 @@ export function validateAccountDelete(tx: Record<string, unknown>): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- known from base check
tx.TransactionType as string,
true,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
)
}
10 changes: 5 additions & 5 deletions packages/xrpl/src/models/transactions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { onlyHasFields } from '../utils'

const MEMO_SIZE = 3
export const MAX_CREDENTIALS_ARRAY_LENGTH = 8
export const MAX_AUTHORIZED_CREDENTIALS = 8
const MAX_CREDENTIAL_BYTE_LENGTH = 64
const MAX_CREDENTIAL_TYPE_LENGTH = MAX_CREDENTIAL_BYTE_LENGTH * 2

Expand Down Expand Up @@ -457,7 +457,7 @@ export function validateCredentialType(tx: Record<string, unknown>): void {
* @param credentials An array of credential IDs to check for errors
* @param transactionType The transaction type to include in error messages
* @param isStringID Toggle for if array contains IDs instead of AuthorizeCredential objects
* @param maxLengthCredentialsArray The maximum length of the credentials array.
* @param maxCredentials The maximum length of the credentials array.
* PermissionedDomainSet transaction uses 10, other transactions use 8.
* @throws Validation Error if the formatting is incorrect
*/
Expand All @@ -466,7 +466,7 @@ export function validateCredentialsList(
credentials: unknown,
transactionType: string,
isStringID: boolean,
maxLengthCredentialsArray: number,
maxCredentials: number,
): void {
if (credentials == null) {
return
Expand All @@ -476,9 +476,9 @@ export function validateCredentialsList(
`${transactionType}: Credentials must be an array`,
)
}
if (credentials.length > maxLengthCredentialsArray) {
if (credentials.length > maxCredentials) {
throw new ValidationError(
`${transactionType}: Credentials length cannot exceed ${maxLengthCredentialsArray} elements`,
`${transactionType}: Credentials length cannot exceed ${maxCredentials} elements`,
)
} else if (credentials.length === 0) {
throw new ValidationError(
Expand Down
6 changes: 3 additions & 3 deletions 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_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
} from './common'

/**
Expand Down Expand Up @@ -73,15 +73,15 @@ export function validateDepositPreauth(tx: Record<string, unknown>): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- confirmed in base transaction check
tx.TransactionType as string,
false,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
)
} else if (tx.UnauthorizeCredentials !== undefined) {
validateCredentialsList(
tx.UnauthorizeCredentials,
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- confirmed in base transaction check
tx.TransactionType as string,
false,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions 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_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
} from './common'

/**
Expand Down Expand Up @@ -56,7 +56,7 @@ export function validateEscrowFinish(tx: Record<string, unknown>): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- known from base check
tx.TransactionType as string,
true,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
)

if (tx.OfferSequence == null) {
Expand Down
4 changes: 2 additions & 2 deletions packages/xrpl/src/models/transactions/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
isNumber,
Account,
validateCredentialsList,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
} from './common'
import type { TransactionMetadataBase } from './metadata'

Expand Down Expand Up @@ -189,7 +189,7 @@ export function validatePayment(tx: Record<string, unknown>): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- known from base check
tx.TransactionType as string,
true,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
)

if (tx.InvoiceID !== undefined && typeof tx.InvoiceID !== 'string') {
Expand Down
4 changes: 2 additions & 2 deletions packages/xrpl/src/models/transactions/paymentChannelClaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
GlobalFlags,
validateBaseTransaction,
validateCredentialsList,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
} from './common'

/**
Expand Down Expand Up @@ -154,7 +154,7 @@ export function validatePaymentChannelClaim(tx: Record<string, unknown>): void {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- known from base check
tx.TransactionType as string,
true,
MAX_CREDENTIALS_ARRAY_LENGTH,
MAX_AUTHORIZED_CREDENTIALS,
)

if (tx.Channel === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
validateCredentialsList,
} from './common'

const ACCEPTED_CREDENTIALS_MAX_LENGTH = 10
const MAX_ACCEPTED_CREDENTIALS = 10

export interface PermissionedDomainSet extends BaseTransaction {
/* The transaction type (PermissionedDomainSet). */
Expand Down Expand Up @@ -49,6 +49,6 @@ export function validatePermissionedDomainSet(
// PermissionedDomainSet uses AuthorizeCredential nested objects only, strings are not allowed
false,
// PermissionedDomainSet uses at most 10 accepted credentials. This is different from Credential-feature transactions.
ACCEPTED_CREDENTIALS_MAX_LENGTH,
MAX_ACCEPTED_CREDENTIALS,
)
}

0 comments on commit 3dfeaf1

Please sign in to comment.