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 363718f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 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
20 changes: 8 additions & 12 deletions src/conditions/context/context.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
AccessControlPolicy,
Context,
Conditions as WASMConditions,
} from '@nucypher/nucypher-core';
import { Context, Conditions as WASMConditions } from '@nucypher/nucypher-core';
import { ethers } from 'ethers';

import { fromJSON, toJSON } from '../../utils';
Expand Down Expand Up @@ -55,7 +51,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 +92,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 +141,14 @@ export class ConditionContext {
return new Context(asJson);
}

public static fromAccessControlPolicy(
public static fromConditions(
provider: ethers.providers.Provider,
acp: AccessControlPolicy,
conditions: WASMConditions,
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 363718f

Please sign in to comment.