diff --git a/packages/taco/src/conditions/context/context.ts b/packages/taco/src/conditions/context/context.ts index 1d8048082..8b4992b8a 100644 --- a/packages/taco/src/conditions/context/context.ts +++ b/packages/taco/src/conditions/context/context.ts @@ -51,14 +51,14 @@ export const RESERVED_CONTEXT_PARAMS = [ ]; export class ConditionContext { - public requestedParameters: Set; - private customParameters: Record = {}; + public requestedContextParameters: Set; + private customContextParameters: Record = {}; private authProviders: Record = {}; constructor(condition: Condition) { const condProps = condition.toObj(); ConditionContext.validateCoreConditions(condProps); - this.requestedParameters = + this.requestedContextParameters = ConditionContext.findContextParameters(condProps); } @@ -73,27 +73,28 @@ export class ConditionContext { ) { // Ok, so at this point we should have all the parameters we need // If we don't, we have a problem and we should throw - const missingParameters = Array.from(this.requestedParameters).filter( - (key) => parameters[key] === undefined, - ); + const missingParameters = Array.from( + this.requestedContextParameters, + ).filter((key) => parameters[key] === undefined); if (missingParameters.length > 0) { throw new Error(ERR_MISSING_CONTEXT_PARAMS(missingParameters)); } } private async fillContextParameters( - requestedParameters: Set, + requestedContextParameters: Set, ): Promise> { - const parameters = - await this.fillAuthContextParameters(requestedParameters); - for (const key in this.customParameters) { - parameters[key] = this.customParameters[key]; + const parameters = await this.fillAuthContextParameters( + requestedContextParameters, + ); + for (const key in this.customContextParameters) { + parameters[key] = this.customContextParameters[key]; } return parameters; } private validateAuthProviders(): void { - for (const param of this.requestedParameters) { + for (const param of this.requestedContextParameters) { // If it's not a user address parameter, we can skip if (!USER_ADDRESS_PARAMS.includes(param)) { continue; @@ -131,7 +132,7 @@ export class ConditionContext { throw new Error(ERR_RESERVED_PARAM(customParam)); } - if (!this.requestedParameters.has(customParam)) { + if (!this.requestedContextParameters.has(customParam)) { throw new Error(ERR_UNKNOWN_CUSTOM_CONTEXT_PARAM(customParam)); } } @@ -182,11 +183,11 @@ export class ConditionContext { } public addCustomContextParameterValues( - customParameters: Record, + customContextParameters: Record, ) { - Object.keys(customParameters).forEach((key) => { + Object.keys(customContextParameters).forEach((key) => { this.validateCustomContextParameter(key); - this.customParameters[key] = customParameters[key]; + this.customContextParameters[key] = customContextParameters[key]; }); } @@ -221,7 +222,7 @@ export class ConditionContext { > => { this.validateAuthProviders(); const parameters = await this.fillContextParameters( - this.requestedParameters, + this.requestedContextParameters, ); this.validateNoMissingContextParameters(parameters); return parameters; diff --git a/packages/taco/test/conditions/context.test.ts b/packages/taco/test/conditions/context.test.ts index a2d6f174b..d18758554 100644 --- a/packages/taco/test/conditions/context.test.ts +++ b/packages/taco/test/conditions/context.test.ts @@ -82,7 +82,9 @@ describe('context', () => { describe('custom parameters', () => { it('detects when a custom parameter is requested', () => { const conditionContext = new ConditionContext(contractCondition); - expect(conditionContext.requestedParameters).toContain(customParamKey); + expect(conditionContext.requestedContextParameters).toContain( + customParamKey, + ); }); it('serializes bytes as hex strings', async () => { @@ -232,10 +234,12 @@ describe('context', () => { }; it('handles both custom and auth context parameters', () => { - const requestedParams = new ConditionContext(contractCondition) - .requestedParameters; - expect(requestedParams).not.toContain(USER_ADDRESS_PARAM_DEFAULT); - expect(requestedParams).toContain(customParamKey); + const requestedContextParams = new ConditionContext(contractCondition) + .requestedContextParameters; + expect(requestedContextParams).not.toContain( + USER_ADDRESS_PARAM_DEFAULT, + ); + expect(requestedContextParams).toContain(customParamKey); }); it('rejects on a missing custom parameter ', async () => { diff --git a/packages/taco/test/taco.test.ts b/packages/taco/test/taco.test.ts index cbb0a91da..589d7a9fa 100644 --- a/packages/taco/test/taco.test.ts +++ b/packages/taco/test/taco.test.ts @@ -132,7 +132,7 @@ describe('taco', () => { expect(getFinalizedRitualSpy).toHaveBeenCalled(); const conditionContext = ConditionContext.fromMessageKit(messageKit); - const requestedParameters = conditionContext.requestedParameters; + const requestedParameters = conditionContext.requestedContextParameters; expect(requestedParameters).toEqual( new Set([customParamKey, USER_ADDRESS_PARAM_DEFAULT]), );