diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 436cc43f2..f22b3ab4f 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -33,7 +33,7 @@ jobs:
- name: Test
run: pnpm test
- - name: Check examples
+ - name: Check examples & demos
run: pnpm check-examples
- name: Upload coverage to Codecov
diff --git a/demos/taco-demo/package.json b/demos/taco-demo/package.json
index 369c67c7d..1c0efad42 100644
--- a/demos/taco-demo/package.json
+++ b/demos/taco-demo/package.json
@@ -6,7 +6,10 @@
"author": "Piotr Rosłaniec
",
"scripts": {
"start": "webpack serve --mode development",
- "build": "tsc --noEmit && rimraf build && webpack --mode production --progress"
+ "build": "pnpm clean && webpack --mode production --progress",
+ "clean": "rimraf build",
+ "check": "pnpm typecheck && pnpm build",
+ "typecheck": "tsc --noEmit"
},
"dependencies": {
"@nucypher/taco": "workspace:*",
diff --git a/demos/taco-demo/src/App.tsx b/demos/taco-demo/src/App.tsx
index 6cf0eb981..1ab1e0ca3 100644
--- a/demos/taco-demo/src/App.tsx
+++ b/demos/taco-demo/src/App.tsx
@@ -1,6 +1,7 @@
import {
conditions,
decrypt,
+ domains,
encrypt,
getPorterUri,
initialize,
@@ -43,6 +44,7 @@ export default function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const encryptedMessage = await encrypt(
provider,
+ domains.TESTNET,
message,
condition,
ritualId,
@@ -62,12 +64,12 @@ export default function App() {
setDecryptionErrors([]);
const provider = new ethers.providers.Web3Provider(window.ethereum);
- const porterUri = getPorterUri('lynx');
const decryptedMessage = await decrypt(
provider,
+ domains.TESTNET,
encryptedMessage,
+ getPorterUri(domains.TESTNET),
provider.getSigner(),
- porterUri,
);
setDecryptedMessage(new TextDecoder().decode(decryptedMessage));
diff --git a/demos/taco-nft-demo/package.json b/demos/taco-nft-demo/package.json
index 7dedd890c..7f47fee2f 100644
--- a/demos/taco-nft-demo/package.json
+++ b/demos/taco-nft-demo/package.json
@@ -6,7 +6,10 @@
"author": "Piotr Rosłaniec ",
"scripts": {
"start": "webpack serve --mode development",
- "build": "tsc --noEmit && rimraf build && webpack --mode production --progress"
+ "build": "pnpm clean && webpack --mode production --progress",
+ "clean": "rimraf build",
+ "check": "pnpm typecheck && pnpm build",
+ "typecheck": "tsc --noEmit"
},
"dependencies": {
"@nucypher/taco": "workspace:*",
diff --git a/demos/taco-nft-demo/src/App.tsx b/demos/taco-nft-demo/src/App.tsx
index b4df8c3ee..555931577 100644
--- a/demos/taco-nft-demo/src/App.tsx
+++ b/demos/taco-nft-demo/src/App.tsx
@@ -1,6 +1,7 @@
import {
conditions,
decrypt,
+ domains,
encrypt,
getPorterUri,
initialize,
@@ -42,6 +43,7 @@ export default function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum);
const encryptedMessage = await encrypt(
provider,
+ domains.TESTNET,
message,
condition,
ritualId,
@@ -61,12 +63,12 @@ export default function App() {
setDecryptionErrors([]);
const provider = new ethers.providers.Web3Provider(window.ethereum);
- const porterUri = getPorterUri('lynx');
const decryptedMessage = await decrypt(
provider,
+ domains.TESTNET,
encryptedMessage,
+ getPorterUri(domains.TESTNET),
provider.getSigner(),
- porterUri,
);
setDecryptedMessage(new TextDecoder().decode(decryptedMessage));
diff --git a/examples/README.md b/examples/README.md
index 424eaeb32..328785eda 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -3,5 +3,5 @@
This directory contains a set of examples showing how to integrate `@nucypher/*`
into your application.
-Refer to `./taco` for examples of how to use the `@nucypher/taco` package.
-Refer to `./pre` for examples of how to use the `@nucypher/pre` package.
+Refer to `./taco` for examples of how to use the `@nucypher/taco` package. Refer
+to `./pre` for examples of how to use the `@nucypher/pre` package.
diff --git a/examples/pre/nextjs/src/app/page.tsx b/examples/pre/nextjs/src/app/page.tsx
index 5e612d6b6..0cac47251 100644
--- a/examples/pre/nextjs/src/app/page.tsx
+++ b/examples/pre/nextjs/src/app/page.tsx
@@ -9,8 +9,8 @@ import {
SecretKey,
toHexString,
} from '@nucypher/pre';
-import {ethers} from 'ethers';
-import {useEffect, useState} from 'react';
+import { ethers } from 'ethers';
+import { useEffect, useState } from 'react';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const window: any;
@@ -35,12 +35,12 @@ function App() {
}
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
- const {chainId} = await provider.getNetwork();
+ const { chainId } = await provider.getNetwork();
if (chainId !== 80001) {
// Switch to Matic Mumbai testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
- params: [{chainId: '0x13881'}],
+ params: [{ chainId: '0x13881' }],
});
}
@@ -68,8 +68,8 @@ function App() {
};
const makeRemoteBob = (bob: Bob) => {
- const {decryptingKey, verifyingKey} = bob;
- return {decryptingKey, verifyingKey};
+ const { decryptingKey, verifyingKey } = bob;
+ return { decryptingKey, verifyingKey };
};
const makeCharacters = () => {
@@ -107,6 +107,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
+ domains.TESTNET,
getPorterUri(domains.TESTNET),
policyParams,
);
diff --git a/examples/pre/nodejs/src/index.ts b/examples/pre/nodejs/src/index.ts
index 931567605..b10f0dffb 100644
--- a/examples/pre/nodejs/src/index.ts
+++ b/examples/pre/nodejs/src/index.ts
@@ -59,11 +59,16 @@ const runExample = async () => {
startDate: new Date(),
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // In 30 days,
};
- const porterUri = getPorterUri(domains.TESTNET);
const alice = makeAlice();
console.log('Creating policy...');
- const policy = await alice.grant(provider, signer, porterUri, policyParams);
+ const policy = await alice.grant(
+ provider,
+ signer,
+ domains.TESTNET,
+ getPorterUri(domains.TESTNET),
+ policyParams,
+ );
console.log('Policy created:');
console.log({ policy });
diff --git a/examples/pre/react/src/App.tsx b/examples/pre/react/src/App.tsx
index 54d9ea5a3..3e507d8ee 100644
--- a/examples/pre/react/src/App.tsx
+++ b/examples/pre/react/src/App.tsx
@@ -6,7 +6,7 @@ import {
getPorterUri,
initialize,
SecretKey,
- toHexString
+ toHexString,
} from '@nucypher/pre';
import { ethers } from 'ethers';
import { useEffect, useState } from 'react';
@@ -98,6 +98,7 @@ function App() {
const policy = await alice.grant(
provider,
provider.getSigner(),
+ domains.TESTNET,
getPorterUri(domains.TESTNET),
policyParams,
);
diff --git a/examples/pre/webpack-5/README.md b/examples/pre/webpack-5/README.md
index 8e5b61600..cfcaa7be2 100644
--- a/examples/pre/webpack-5/README.md
+++ b/examples/pre/webpack-5/README.md
@@ -9,4 +9,5 @@ pnpm install
pnpm start
```
-Go to [localhost:8080](http://localhost:8080/) in your browser and look in the JS console.
+Go to [localhost:8080](http://localhost:8080/) in your browser and look in the
+JS console.
diff --git a/examples/pre/webpack-5/src/index.ts b/examples/pre/webpack-5/src/index.ts
index fe05e1f4b..9cc1e9654 100644
--- a/examples/pre/webpack-5/src/index.ts
+++ b/examples/pre/webpack-5/src/index.ts
@@ -65,13 +65,13 @@ const runExample = async () => {
startDate,
endDate,
};
- const porterUri = getPorterUri(domains.TESTNET);
const alice = makeAlice();
const policy = await alice.grant(
provider,
provider.getSigner(),
- porterUri,
+ domains.TESTNET,
+ getPorterUri(domains.TESTNET),
policyParams,
);
diff --git a/examples/taco/nextjs/src/app/page.tsx b/examples/taco/nextjs/src/app/page.tsx
index adc7e6393..c5208b8fd 100644
--- a/examples/taco/nextjs/src/app/page.tsx
+++ b/examples/taco/nextjs/src/app/page.tsx
@@ -6,10 +6,10 @@ import {
encrypt,
fromBytes,
getPorterUri,
- initialize
+ initialize,
} from '@nucypher/taco';
-import {ethers} from 'ethers';
-import {useEffect, useState} from 'react';
+import { ethers } from 'ethers';
+import { useEffect, useState } from 'react';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const window: any;
@@ -21,7 +21,9 @@ function App() {
const [provider, setProvider] = useState<
ethers.providers.Web3Provider | undefined
>();
- const [decryptedMessage, setDecryptedMessage] = useState("");
+ const [decryptedMessage, setDecryptedMessage] = useState(
+ '',
+ );
const initNucypher = async () => {
await initialize();
@@ -34,12 +36,12 @@ function App() {
}
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
- const {chainId} = await provider.getNetwork();
+ const { chainId } = await provider.getNetwork();
if (chainId !== 80001) {
// Switch to Matic Mumbai testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
- params: [{chainId: '0x13881'}],
+ params: [{ chainId: '0x13881' }],
});
}
@@ -67,12 +69,12 @@ function App() {
await provider.send('eth_requestAccounts', []);
const signer = provider.getSigner();
- const {chainId} = await provider.getNetwork();
+ const { chainId } = await provider.getNetwork();
if (chainId !== 80001) {
// Switch to Matic Mumbai testnet
await window.ethereum!.request!({
method: 'wallet_switchEthereumChain',
- params: [{chainId: '0x13881'}],
+ params: [{ chainId: '0x13881' }],
});
}
@@ -88,11 +90,23 @@ function App() {
},
});
const ritualId = 2; // Replace with your own ritual ID
- const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);
+ const messageKit = await encrypt(
+ provider,
+ domains.TESTNET,
+ message,
+ hasPositiveBalance,
+ ritualId,
+ signer,
+ );
console.log('Decrypting message...');
- const porterUri = getPorterUri(domains.DEV);
- const decryptedMessage = await decrypt(provider, messageKit,porterUri,signer);
+ const decryptedMessage = await decrypt(
+ provider,
+ domains.TESTNET,
+ messageKit,
+ getPorterUri(domains.TESTNET),
+ signer,
+ );
setDecryptedMessage(fromBytes(decryptedMessage));
};
@@ -100,7 +114,7 @@ function App() {
return (
Secret message: {message}
- {(decryptedMessage && Decrypted message: {decryptedMessage}
)}
+ {decryptedMessage && Decrypted message: {decryptedMessage}
}
);
diff --git a/examples/taco/nodejs/src/index.ts b/examples/taco/nodejs/src/index.ts
index 339fc7cb9..d9ad8e0a1 100644
--- a/examples/taco/nodejs/src/index.ts
+++ b/examples/taco/nodejs/src/index.ts
@@ -1,11 +1,11 @@
import {
conditions,
decrypt,
+ domains,
encrypt,
fromBytes,
getPorterUri,
initialize,
- domains,
toBytes,
} from '@nucypher/taco';
import * as dotenv from 'dotenv';
@@ -48,9 +48,10 @@ const runExample = async () => {
hasPositiveBalance.requiresSigner(),
'Condition requires signer',
);
- const ritualId = 1; // Replace with your own ritual ID
+ const ritualId = 2; // Replace with your own ritual ID
const messageKit = await encrypt(
provider,
+ domains.TESTNET,
message,
hasPositiveBalance,
ritualId,
@@ -58,8 +59,13 @@ const runExample = async () => {
);
console.log('Decrypting message...');
- const porterUri = getPorterUri(domains.DEV);
- const decryptedBytes = await decrypt(provider, messageKit, porterUri, signer);
+ const decryptedBytes = await decrypt(
+ provider,
+ domains.TESTNET,
+ messageKit,
+ getPorterUri(domains.TESTNET),
+ signer,
+ );
const decryptedMessageString = fromBytes(decryptedBytes);
console.log('Decrypted message:', decryptedMessageString);
console.assert(
diff --git a/examples/taco/react/README.md b/examples/taco/react/README.md
index 5c1ef1c92..feb4ee5a4 100644
--- a/examples/taco/react/README.md
+++ b/examples/taco/react/README.md
@@ -2,8 +2,9 @@
Shows how to integrate `@nucypher/taco` into a React application.
-In order to load WASM dependencies of `@nucypher/taco`, we override the `react-scripts` configuration with `craco`. For
-more details, see the `craco.config.js` file.
+In order to load WASM dependencies of `@nucypher/taco`, we override the
+`react-scripts` configuration with `craco`. For more details, see the
+`craco.config.js` file.
## Usage
diff --git a/examples/taco/react/src/App.tsx b/examples/taco/react/src/App.tsx
index ad77f772a..fab268e5e 100644
--- a/examples/taco/react/src/App.tsx
+++ b/examples/taco/react/src/App.tsx
@@ -7,8 +7,8 @@ import {
getPorterUri,
initialize,
} from '@nucypher/taco';
-import {ethers} from 'ethers';
-import {useEffect, useState} from 'react';
+import { ethers } from 'ethers';
+import { useEffect, useState } from 'react';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const window: any;
@@ -20,7 +20,9 @@ function App() {
const [provider, setProvider] = useState<
ethers.providers.Web3Provider | undefined
>();
- const [decryptedMessage, setDecryptedMessage] = useState("");
+ const [decryptedMessage, setDecryptedMessage] = useState(
+ '',
+ );
const initNucypher = async () => {
await initialize();
@@ -33,12 +35,12 @@ function App() {
}
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
- const {chainId} = await provider.getNetwork();
+ const { chainId } = await provider.getNetwork();
if (chainId !== 80001) {
// Switch to Matic Mumbai testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
- params: [{chainId: '0x13881'}],
+ params: [{ chainId: '0x13881' }],
});
}
@@ -66,12 +68,12 @@ function App() {
await provider.send('eth_requestAccounts', []);
const signer = provider.getSigner();
- const {chainId} = await provider.getNetwork();
+ const { chainId } = await provider.getNetwork();
if (chainId !== 80001) {
// Switch to Matic Mumbai testnet
await window.ethereum!.request!({
method: 'wallet_switchEthereumChain',
- params: [{chainId: '0x13881'}],
+ params: [{ chainId: '0x13881' }],
});
}
@@ -87,11 +89,23 @@ function App() {
},
});
const ritualId = 2; // Replace with your own ritual ID
- const messageKit = await encrypt(provider, message, hasPositiveBalance, ritualId, signer);
+ const messageKit = await encrypt(
+ provider,
+ domains.TESTNET,
+ message,
+ hasPositiveBalance,
+ ritualId,
+ signer,
+ );
console.log('Decrypting message...');
- const porterUri = getPorterUri(domains.DEV);
- const decryptedMessage = await decrypt(provider, messageKit, porterUri, signer);
+ const decryptedMessage = await decrypt(
+ provider,
+ domains.TESTNET,
+ messageKit,
+ getPorterUri(domains.TESTNET),
+ signer,
+ );
setDecryptedMessage(fromBytes(decryptedMessage));
};
@@ -99,7 +113,7 @@ function App() {
return (
Secret message: {message}
- {(decryptedMessage && Decrypted message: {decryptedMessage}
)}
+ {decryptedMessage && Decrypted message: {decryptedMessage}
}
);
diff --git a/examples/taco/webpack-5/src/index.html b/examples/taco/webpack-5/src/index.html
index 6e9349b3e..d6c74d500 100644
--- a/examples/taco/webpack-5/src/index.html
+++ b/examples/taco/webpack-5/src/index.html
@@ -6,7 +6,8 @@
-