Skip to content

Commit 4892685

Browse files
committed
fix(compiler): correct use of "a" vs. "an" in error messages
1 parent 98b2a13 commit 4892685

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/lib/auth/templates/language/resolve.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ const defaultActionByVariableType: {
417417
data.addressData !== undefined &&
418418
(data.addressData[variableId] as Uint8Array | undefined) !== undefined
419419
? data.addressData[variableId]
420-
: `Identifier "${identifier}" refers to a AddressData, but no AddressData for "${variableId}" were provided in the compilation data.`,
420+
: `Identifier "${identifier}" refers to an AddressData, but no AddressData for "${variableId}" were provided in the compilation data.`,
421421
CurrentBlockHeight: (_, data) =>
422422
bigIntToScriptNumber(BigInt(data.currentBlockHeight as number)),
423423
CurrentBlockTime: (_, data) => dateToLockTime(data.currentBlockTime as Date),
@@ -432,6 +432,11 @@ const defaultActionByVariableType: {
432432
: `Identifier "${identifier}" refers to a WalletData, but no WalletData for "${variableId}" were provided in the compilation data.`
433433
};
434434

435+
const aOrAnQuotedString = (word: string) =>
436+
`${
437+
['a', 'e', 'i', 'o', 'u'].indexOf(word[0].toLowerCase()) === -1 ? 'a' : 'an'
438+
} "${word}"`;
439+
435440
/**
436441
* If the identifer can be successfully resolved as a variable, the result is
437442
* returned as a Uint8Array. If the identifier references a known variable, but
@@ -462,9 +467,9 @@ export const resolveAuthenticationTemplateVariable = <CompilerOperationData>(
462467
return data[variableTypeToDataProperty[selected.type]] === undefined
463468
? `Identifier "${identifier}" is a ${
464469
selected.type
465-
}, but the compilation data does not include a "${
470+
}, but the compilation data does not include ${aOrAnQuotedString(
466471
variableTypeToDataProperty[selected.type]
467-
}" property.`
472+
)} property.`
468473
: isOperation
469474
? attemptCompilerOperation(
470475
identifier,
@@ -538,7 +543,7 @@ export const resolveScriptIdentifier = <CompilerOperationData>(
538543
* @param environment a snapshot of the context around `scriptId`. See
539544
* `CompilationEnvironment` for details.
540545
* @param data the actual variable values (private keys, shared wallet data,
541-
* shared transaction data, etc.) to use in resolving variables.
546+
* shared address data, etc.) to use in resolving variables.
542547
*/
543548
export const createIdentifierResolver = <CompilerOperationData>(
544549
scriptId: string | undefined,

0 commit comments

Comments
 (0)