Skip to content

Commit

Permalink
Fix other taco examples to use ConditionContext instead of directly p…
Browse files Browse the repository at this point in the history
…roviding authProvider.
  • Loading branch information
derekpierre committed Aug 15, 2024
1 parent e9e332f commit 3c7cefb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion examples/taco/nextjs/src/hooks/useTaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
encrypt,
initialize,
ThresholdMessageKit,
USER_ADDRESS_PARAM_DEFAULT,
} from '@nucypher/taco';
import { ethers } from 'ethers';
import { useCallback, useEffect, useState } from 'react';
Expand All @@ -32,11 +33,17 @@ export default function useTaco({
}
const messageKit = ThresholdMessageKit.fromBytes(encryptedBytes);
const authProvider = new EIP4361AuthProvider(provider, signer);
const conditionContext =
conditions.context.ConditionContext.fromMessageKit(messageKit);
conditionContext.addAuthProvider(
USER_ADDRESS_PARAM_DEFAULT,
authProvider,
);
return decrypt(
provider,
domain,
messageKit,
authProvider,
conditionContext,
);
},
[isInit, provider, domain],
Expand Down
9 changes: 8 additions & 1 deletion examples/taco/react/src/hooks/useTaco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
encrypt,
initialize,
ThresholdMessageKit,
USER_ADDRESS_PARAM_DEFAULT,
} from '@nucypher/taco';
import { ethers } from 'ethers';
import { useCallback, useEffect, useState } from 'react';
Expand All @@ -32,11 +33,17 @@ export default function useTaco({
}
const messageKit = ThresholdMessageKit.fromBytes(encryptedBytes);
const authProvider = new EIP4361AuthProvider(provider, signer);
const conditionContext =
conditions.context.ConditionContext.fromMessageKit(messageKit);
conditionContext.addAuthProvider(
USER_ADDRESS_PARAM_DEFAULT,
authProvider,
);
return decrypt(
provider,
domain,
messageKit,
authProvider,
conditionContext,
);
},
[isInit, provider, domain],
Expand Down
6 changes: 5 additions & 1 deletion packages/taco/examples/encrypt-decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
initialize,
ThresholdMessageKit,
toBytes,
USER_ADDRESS_PARAM_DEFAULT,
} from '../src';

const ritualId = 1;
Expand Down Expand Up @@ -49,11 +50,14 @@ const run = async () => {
web3Provider,
web3Provider.getSigner(),
);
const conditionContext =
conditions.context.ConditionContext.fromMessageKit(messageKit);
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);
const decryptedMessage = await decrypt(
web3Provider,
domains.TESTNET,
messageKit,
authProvider,
conditionContext,
);
return decryptedMessage;
};
Expand Down

0 comments on commit 3c7cefb

Please sign in to comment.