Skip to content

Commit

Permalink
fix(compiler): correct use of "a" vs. "an" in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bitjson committed Oct 30, 2019
1 parent 98b2a13 commit 4892685
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib/auth/templates/language/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const defaultActionByVariableType: {
data.addressData !== undefined &&
(data.addressData[variableId] as Uint8Array | undefined) !== undefined
? data.addressData[variableId]
: `Identifier "${identifier}" refers to a AddressData, but no AddressData for "${variableId}" were provided in the compilation data.`,
: `Identifier "${identifier}" refers to an AddressData, but no AddressData for "${variableId}" were provided in the compilation data.`,
CurrentBlockHeight: (_, data) =>
bigIntToScriptNumber(BigInt(data.currentBlockHeight as number)),
CurrentBlockTime: (_, data) => dateToLockTime(data.currentBlockTime as Date),
Expand All @@ -432,6 +432,11 @@ const defaultActionByVariableType: {
: `Identifier "${identifier}" refers to a WalletData, but no WalletData for "${variableId}" were provided in the compilation data.`
};

const aOrAnQuotedString = (word: string) =>
`${
['a', 'e', 'i', 'o', 'u'].indexOf(word[0].toLowerCase()) === -1 ? 'a' : 'an'
} "${word}"`;

/**
* If the identifer can be successfully resolved as a variable, the result is
* returned as a Uint8Array. If the identifier references a known variable, but
Expand Down Expand Up @@ -462,9 +467,9 @@ export const resolveAuthenticationTemplateVariable = <CompilerOperationData>(
return data[variableTypeToDataProperty[selected.type]] === undefined
? `Identifier "${identifier}" is a ${
selected.type
}, but the compilation data does not include a "${
}, but the compilation data does not include ${aOrAnQuotedString(
variableTypeToDataProperty[selected.type]
}" property.`
)} property.`
: isOperation
? attemptCompilerOperation(
identifier,
Expand Down Expand Up @@ -538,7 +543,7 @@ export const resolveScriptIdentifier = <CompilerOperationData>(
* @param environment a snapshot of the context around `scriptId`. See
* `CompilationEnvironment` for details.
* @param data the actual variable values (private keys, shared wallet data,
* shared transaction data, etc.) to use in resolving variables.
* shared address data, etc.) to use in resolving variables.
*/
export const createIdentifierResolver = <CompilerOperationData>(
scriptId: string | undefined,
Expand Down

0 comments on commit 4892685

Please sign in to comment.