Skip to content

Commit

Permalink
Update taco-nft-demo to use latest released versions of taco, `taco…
Browse files Browse the repository at this point in the history
…-auth` and update code accordingly.
  • Loading branch information
derekpierre committed Sep 4, 2024
1 parent 198f173 commit 017aa50
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 234 deletions.
11 changes: 6 additions & 5 deletions demos/taco-nft-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pnpm start

## Usage

In order to run this demo will need a browser wallet with an account funded with some
$MATIC.
In order to run this demo will need a browser wallet with an account funded with
some $MATIC.

In order to connect with the network, the demo uses a public instances of
[Porter](https://docs.nucypher.com/en/latest/application_development/web_development.html#running-porter).
Expand All @@ -26,12 +26,13 @@ production _just yet_.

### Lynx Testnet

The current release of `@nucypher/taco` supports Ursulas working on Lynx (bleeding-edge) test
network and contracts deployed on Polygon Amoy testnet.
The current release of `@nucypher/taco` supports Ursulas working on Lynx
(bleeding-edge) test network and contracts deployed on Polygon Amoy testnet.

## References

Please find developer documentation [here](https://docs.threshold.network/app-development/threshold-access-control-tac).
Please find developer documentation
[here](https://docs.threshold.network/app-development/threshold-access-control-tac).

This dApp is based on
[`useDapp` example](https://github.com/EthWorks/useDapp/tree/master/packages/example).
25 changes: 13 additions & 12 deletions demos/taco-nft-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"description": "A usage example for @nucypher/taco",
"private": true,
"author": "Piotr Rosłaniec <p.roslaniec@gmail.com>",
"author": "NuCypher <dev@nucypher.com>",
"scripts": {
"start": "webpack serve --mode development",
"build": "pnpm clean && webpack --mode production --progress",
Expand All @@ -12,30 +12,31 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@nucypher/taco": "^0.3.0",
"@usedapp/core": "^1.2.13",
"@nucypher/taco": "^0.5.0",
"@nucypher/taco-auth": "^0.2.0",
"@usedapp/core": "^1.2.16",
"buffer": "^6.0.3",
"ethers": "^5.7.1",
"ethers": "^5.7.2",
"file-loader": "^6.2.0",
"react": "^18.3.1",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^18.3.1",
"react-spinners": "^0.14.1"
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@types/react": "^18.3.5",
"@types/react-copy-to-clipboard": "^5.0.7",
"@types/react-dom": "^18.3.0",
"copy-webpack-plugin": "^12.0.2",
"esbuild-loader": "^2.20.0",
"html-webpack-plugin": "^5.5.0",
"react-refresh": "^0.14.0",
"rimraf": "^5.0.5",
"esbuild-loader": "^2.21.0",
"html-webpack-plugin": "^5.6.0",
"react-refresh": "^0.14.2",
"rimraf": "^5.0.10",
"stream-browserify": "^3.0.0",
"typescript": "^4.8.3",
"webpack": "^5.93.0",
"typescript": "^4.9.5",
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.11.1"
"webpack-dev-server": "^4.15.2"
}
}
25 changes: 22 additions & 3 deletions demos/taco-nft-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import {
initialize,
ThresholdMessageKit,
} from '@nucypher/taco';
import {
EIP4361AuthProvider,
USER_ADDRESS_PARAM_DEFAULT,
} from '@nucypher/taco-auth';
import { useEthers } from '@usedapp/core';
import { ethers } from 'ethers';
import React, { useEffect, useState } from 'react';
Expand Down Expand Up @@ -73,12 +77,27 @@ export default function App() {
setDecryptionErrors([]);

const provider = new ethers.providers.Web3Provider(window.ethereum);

// create condition context
const conditionContext = conditions.context.ConditionContext.fromMessageKit(encryptedMessage);

// illustrative optional example of checking what context parameters are required
if (
conditionContext.requestedContextParameters.has(USER_ADDRESS_PARAM_DEFAULT)
) {
// add authentication for ":userAddress" in condition
const authProvider = new EIP4361AuthProvider(
provider,
provider.getSigner()
);
conditionContext.addAuthProvider(USER_ADDRESS_PARAM_DEFAULT, authProvider);
}

const decryptedMessage = await decrypt(
provider,
domain,
encryptedMessage,
undefined,
provider.getSigner()
conditionContext,
);

setDecryptedMessage(new TextDecoder().decode(decryptedMessage));
Expand Down Expand Up @@ -109,7 +128,7 @@ export default function App() {
<h2>Notice</h2>
<p>
In production (mainnet domain), your wallet address (encryptor) will also have
to be allow-listed for this specific ritual. However, we have
to be allow-listed for this specific ritual. However, we have
<a href={'https://docs.threshold.network/app-development/threshold-access-control-tac/integration-guide/get-started-with-tac#testnet-configuration'}>publicly available testnet rituals</a>
for use when developing your apps.
</p>
Expand Down
Loading

0 comments on commit 017aa50

Please sign in to comment.