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 Jul 19, 2024
1 parent bcb527d commit a495d99
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 @@ -7,6 +7,7 @@ import {
getPorterUri,
initialize,
ThresholdMessageKit,
USER_ADDRESS_PARAM_DEFAULT,
} from '@nucypher/taco';
import { ethers } from 'ethers';
import { useCallback, useEffect, useState } from 'react';
Expand All @@ -33,11 +34,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,
getPorterUri(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 @@ -7,6 +7,7 @@ import {
getPorterUri,
initialize,
ThresholdMessageKit,
USER_ADDRESS_PARAM_DEFAULT,
} from '@nucypher/taco';
import { ethers } from 'ethers';
import { useCallback, useEffect, useState } from 'react';
Expand All @@ -33,11 +34,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,
getPorterUri(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 @@ -11,6 +11,7 @@ import {
initialize,
ThresholdMessageKit,
toBytes,
USER_ADDRESS_PARAM_DEFAULT,
} from '../src';

const ritualId = 1;
Expand Down Expand Up @@ -50,11 +51,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,
getPorterUri(domains.TESTNET),
);
return decryptedMessage;
Expand Down

0 comments on commit a495d99

Please sign in to comment.