From 363718fba7e9b20bc276c49162626ec921acd35d Mon Sep 17 00:00:00 2001
From: Piotr Roslaniec
Date: Fri, 8 Sep 2023 17:05:44 +0200
Subject: [PATCH] apply pr suggestions
---
src/characters/cbd-recipient.ts | 4 ++--
src/conditions/context/context.ts | 20 ++++++++------------
test/unit/conditions/context.test.ts | 2 +-
3 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/characters/cbd-recipient.ts b/src/characters/cbd-recipient.ts
index 9f9b11bd7..ad973616a 100644
--- a/src/characters/cbd-recipient.ts
+++ b/src/characters/cbd-recipient.ts
@@ -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 } =
diff --git a/src/conditions/context/context.ts b/src/conditions/context/context.ts
index be4b72162..c1d8426df 100644
--- a/src/conditions/context/context.ts
+++ b/src/conditions/context/context.ts
@@ -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';
@@ -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`
);
}
@@ -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] =
@@ -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);
}
}
diff --git a/test/unit/conditions/context.test.ts b/test/unit/conditions/context.test.ts
index 1cc3b19d5..4a0815912 100644
--- a/test/unit/conditions/context.test.ts
+++ b/test/unit/conditions/context.test.ts
@@ -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`
);
});