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 9, 2023
1 parent 19a73b7 commit 1dba09f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/agents/coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export class DkgCoordinatorAgent {
const Coordinator = await this.connectReadOnly(provider);
const dkgPublicKeyBytes = dkgPublicKey.toBytes();
const pointStruct: BLS12381.G1PointStruct = {
word0: dkgPublicKeyBytes.slice(0, 16),
word1: dkgPublicKeyBytes.slice(16, 32),
word0: dkgPublicKeyBytes.slice(0, 32),
word1: dkgPublicKeyBytes.slice(32, 48),
};
return await Coordinator.getRitualIdFromPublicKey(pointStruct);
}
Expand Down
2 changes: 1 addition & 1 deletion src/conditions/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class ConditionContext {
);
if (conditionRequiresSigner && !this.signer) {
throw new Error(
`Cannot use ${USER_ADDRESS_PARAM} as a parameter without a signer`
`Signer required to satisfy ${USER_ADDRESS_PARAM} context variable in condition`
);
}

Expand Down
8 changes: 7 additions & 1 deletion test/unit/conditions/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ describe('context parameters', () => {
const condition = new ContractCondition(conditionObj);
const conditionExpr = new ConditionExpression(condition);
expect(conditionExpr.contextRequiresSigner()).toBe(true);
expect(conditionExpr.buildContext(provider, {}, signer)).toBeDefined();
expect(() => conditionExpr.buildContext(provider, {})).toThrow(
`Signer required to satisfy ${USER_ADDRESS_PARAM} context variable in condition`
);
});

it('detects if a signer is not required', () => {
Expand All @@ -100,6 +104,8 @@ describe('context parameters', () => {
false
);
expect(conditionExpr.contextRequiresSigner()).toBe(false);
expect(conditionExpr.buildContext(provider, {}, signer)).toBeDefined();
expect(conditionExpr.buildContext(provider, {})).toBeDefined();
});

it('rejects on a missing signer', () => {
Expand All @@ -114,7 +120,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 a parameter without a signer`
`Signer required to satisfy ${USER_ADDRESS_PARAM} context variable in condition`
);
});

Expand Down

0 comments on commit 1dba09f

Please sign in to comment.