Skip to content

Commit

Permalink
apply pr suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Sep 8, 2023
1 parent b11f1d4 commit 12768d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/characters/cbd-recipient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export class ThresholdDecrypter {
provider,
this.ritualId
);
const wasmContext = await ConditionContext.fromAccessControlPolicy(
const wasmContext = await ConditionContext.fromConditions(
provider,
thresholdMessageKit.acp,
thresholdMessageKit.acp.conditions,
signer
).toWASMContext();
const { sharedSecrets, encryptedRequests } =
Expand Down
16 changes: 8 additions & 8 deletions src/conditions/context/context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
AccessControlPolicy,
Conditions,
Context,
Conditions as WASMConditions,
} from '@nucypher/nucypher-core';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class ConditionContext {
);
if (conditionRequiresSigner && !this.signer) {
throw new Error(
`Cannot use ${USER_ADDRESS_PARAM} as custom parameter without a signer`
`Condition contains ${USER_ADDRESS_PARAM} context variable and requires a signer to populate`
);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ export class ConditionContext {
if (requestedParameters.has(USER_ADDRESS_PARAM)) {
if (!this.walletAuthProvider) {
throw new Error(
`Cannot use ${USER_ADDRESS_PARAM} as custom parameter without a signer`
`Condition contains ${USER_ADDRESS_PARAM} context variable and requires a signer to populate`
);
}
parameters[USER_ADDRESS_PARAM] =
Expand Down Expand Up @@ -145,14 +145,14 @@ export class ConditionContext {
return new Context(asJson);
}

public static fromAccessControlPolicy(
public static fromConditions(
provider: ethers.providers.Provider,
acp: AccessControlPolicy,
conditions: Conditions,
signer?: ethers.Signer
): ConditionContext {
const conditions = [
ConditionExpression.fromWASMConditions(acp.conditions).condition,
const innerConditions = [
ConditionExpression.fromWASMConditions(conditions).condition,
];
return new ConditionContext(provider, conditions, {}, signer);
return new ConditionContext(provider, innerConditions, {}, signer);
}
}
2 changes: 1 addition & 1 deletion test/unit/conditions/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('context parameters', () => {
const conditionExpr = new ConditionExpression(condition);
expect(conditionExpr.contextRequiresSigner()).toBe(true);
expect(() => conditionExpr.buildContext(provider, {}, undefined)).toThrow(
`Cannot use ${USER_ADDRESS_PARAM} as custom parameter without a signer`
`Condition contains ${USER_ADDRESS_PARAM} context variable and requires a signer to populate`
);
});

Expand Down

0 comments on commit 12768d1

Please sign in to comment.