Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
e890ddc
feat: add viem support with ethers.js adapter wrappers and viem auth …
Muhammad-Altabba Aug 12, 2025
6921860
fix: resolve lint issues for CI/CD pipeline
Muhammad-Altabba Aug 13, 2025
faf5674
fix: resolve final lint issues in test files
Muhammad-Altabba Aug 13, 2025
446a983
mock more functions at a unit test
Muhammad-Altabba Aug 13, 2025
666e8a4
increase a test timeout
Muhammad-Altabba Aug 13, 2025
fac7188
improve structure
Muhammad-Altabba Aug 13, 2025
d281d81
some improvements to viem check code and structure
Muhammad-Altabba Aug 14, 2025
cf80375
update comments and docs
Muhammad-Altabba Aug 14, 2025
b9462a2
minor enhancement
Muhammad-Altabba Aug 14, 2025
10d39f4
refactor: extract common viem provider/signer logic into shared base …
Muhammad-Altabba Aug 14, 2025
bb7e5e0
more cleanup refactoring
Muhammad-Altabba Aug 14, 2025
91a66e5
some renaming and minor edits
Muhammad-Altabba Aug 17, 2025
aefbe1c
undo formatting and unnecessary changes
Muhammad-Altabba Aug 17, 2025
0b4acca
tiny edits according to review comments
Muhammad-Altabba Aug 17, 2025
9d78ec1
enhance the usage of viem types
Muhammad-Altabba Aug 19, 2025
b71fe9a
use function overloading for viem objects instead of different names
Muhammad-Altabba Aug 25, 2025
f61b212
add viem auth provider to the list of provider types
Muhammad-Altabba Aug 26, 2025
f0c284e
enhance viem check and logging a bit
Muhammad-Altabba Aug 26, 2025
c411009
remove unused blockTag parameter from viem provider methods
Muhammad-Altabba Aug 26, 2025
a8881ff
feat: implement unified TacoProvider/TacoSigner interfaces with viem …
Muhammad-Altabba Aug 26, 2025
d8c2754
fix ethers compatibility
Muhammad-Altabba Aug 26, 2025
8e473aa
few cleanups
Muhammad-Altabba Aug 27, 2025
84b47f9
tiny touches
Muhammad-Altabba Aug 27, 2025
70680ee
reduce few loggings
Muhammad-Altabba Aug 28, 2025
1c0a409
Apply suggestions from code review
Muhammad-Altabba Sep 1, 2025
df8d2f9
add provider-signer compatibility validation for mixing viem and ethe…
Muhammad-Altabba Sep 4, 2025
bbe0012
Apply suggestions from code review
Muhammad-Altabba Sep 4, 2025
372f95e
update TacoSigner to use only ethers types
Muhammad-Altabba Sep 4, 2025
ac7b498
refactor: move viem adapters to shared package and unify implementation
Muhammad-Altabba Sep 4, 2025
ad9f73e
add encryptWithPublicKey support for viem
Muhammad-Altabba Sep 4, 2025
604809e
tiny edit to correct an export
Muhammad-Altabba Sep 4, 2025
0f08287
refactor: consolidate viem support into EIP4361AuthProvider and add t…
Muhammad-Altabba Sep 5, 2025
a8acc55
add a method doc
Muhammad-Altabba Sep 5, 2025
870987f
refactor: replace viem provider/signer wrappers with direct implement…
Muhammad-Altabba Sep 8, 2025
617fd25
remove un-used methods from Provider and Signer
Muhammad-Altabba Sep 8, 2025
94b6c61
relax some validations and remove un-needed async promises in some re…
Muhammad-Altabba Sep 9, 2025
4355415
refactor: use ethers conversion utilities and make the typecheck insi…
Muhammad-Altabba Sep 9, 2025
acc6dfa
refactor: introduce and use ProviderLike and SignerLike types
Muhammad-Altabba Sep 9, 2025
8e38fb1
refactor: simplify and polish EIP4361AuthProvider and viem documentation
Muhammad-Altabba Sep 9, 2025
e70e1de
refactor: reorganize viem-related files into dedicated directory and …
Muhammad-Altabba Sep 10, 2025
ba013d1
add some unit tests and removed un-used property
Muhammad-Altabba Sep 10, 2025
7d08d0e
Update packages/taco/src/taco.ts
Muhammad-Altabba Sep 10, 2025
1c2c7ca
Remove un needed casting because of type inference introduced earlier
Muhammad-Altabba Sep 10, 2025
a2adab1
rename viem variables and add viem/index.ts
Muhammad-Altabba Sep 11, 2025
f23ba9b
refactor: use TacoSigner instead of ethers.Signer and remove provider…
Muhammad-Altabba Sep 12, 2025
1bf799a
refactor: replace TacoProvider with viem-to-ethers adapter
Muhammad-Altabba Sep 15, 2025
087c0d3
remove a function overload and add type casting for signerLike parameter
Muhammad-Altabba Sep 15, 2025
3120ccd
Rename (to)TacoSigner to (to)TACoSigner to rename consistent with our…
derekpierre Sep 15, 2025
1d225ba
Fix external API-typing. `TACoSigner` is an internal API and not exte…
derekpierre Sep 15, 2025
9a44327
Add viem as a dev dependency so that signatures produced from ethers …
derekpierre Sep 16, 2025
16c026b
Move toTACoSigner() and toEthersProvider() to its own module outside …
derekpierre Sep 16, 2025
60c3e8c
Cleanup conversion to ethers provider, and remove excess code includi…
derekpierre Sep 17, 2025
18f2913
Only export types from viem module.
derekpierre Sep 17, 2025
9bc24ae
Remove duplicated test file - this is the same as viem-ethers-adapter…
derekpierre Sep 17, 2025
d04625e
Update adapter toTACoSigner and typeguard tests to test legit viem Pu…
derekpierre Sep 17, 2025
6f0e6ef
Use an actual viem signing account for tests where possible instead o…
derekpierre Sep 17, 2025
be3266c
Simplify exports from viem directory in shared package.
derekpierre Sep 17, 2025
ee4f935
Remove export test; doesn't seem like it is actually testing anything.
derekpierre Sep 17, 2025
0a96eb4
Remove duplicated integration test, and have the original integration…
derekpierre Sep 17, 2025
75f625b
Specify types in integration test.
derekpierre Sep 18, 2025
578e093
Rename toTACoSigner/TACoSigner to toTacoSigner/TacoSigner.
derekpierre Sep 18, 2025
21417c0
Add longer timeout for test.
derekpierre Sep 18, 2025
815328d
chore: keep viem peer dependency only at the shared package
Muhammad-Altabba Sep 19, 2025
d45bab9
fix: update integration test cases to handle provider and signer type…
Muhammad-Altabba Sep 21, 2025
aa53cee
refactor: consolidate taco tests for ethers and viem
Muhammad-Altabba Sep 21, 2025
0dbb2fb
test: add ENS registry tests for viem to ethers provider
Muhammad-Altabba Sep 21, 2025
853e45d
fix: support viem WalletClient in signer adapter and improve EIP-1193…
Muhammad-Altabba Sep 22, 2025
96b9f60
improve error messages and type definitions in viem adapters
Muhammad-Altabba Sep 23, 2025
56b33f8
docs: clarify viem signer type as SignerAccount (LocalAccount or Wall…
Muhammad-Altabba Sep 23, 2025
ce86948
chore: update pnpm-lock.yaml
Muhammad-Altabba Sep 23, 2025
3019086
feat: add viem support with ethers.js adapter wrappers and viem auth …
Muhammad-Altabba Aug 12, 2025
75017bd
add TacoClient
Muhammad-Altabba Aug 20, 2025
79e0e88
Some refactoring
Muhammad-Altabba Aug 25, 2025
153ee7c
add more validations and integration test
Muhammad-Altabba Aug 26, 2025
00735c5
remove logger
Muhammad-Altabba Aug 26, 2025
1766e82
remove logger
Muhammad-Altabba Aug 27, 2025
7768ac5
implement initialization inside TacoClient
Muhammad-Altabba Aug 28, 2025
e3cc8c1
modify TacoClient.decrypt to optionally accepting bytes
Muhammad-Altabba Sep 1, 2025
a67216c
Apply suggestions from code review
Muhammad-Altabba Sep 3, 2025
5dec72e
refactor: remove debug logging statements from TacoClient class
Muhammad-Altabba Sep 3, 2025
b6f1a58
simplify a condition a bit
Muhammad-Altabba Sep 4, 2025
8cc3ec0
add encryptWithPublicKey to TacoClient
Muhammad-Altabba Sep 5, 2025
877a44d
Add viem as a dev dependency so that signatures produced from ethers …
derekpierre Sep 16, 2025
f8c8797
refactor: consolidate taco tests for ethers and viem
Muhammad-Altabba Sep 21, 2025
d89c68b
refactor: consolidate TacoClient integration tests with shared test c…
Muhammad-Altabba Sep 23, 2025
d7d9850
chore: update pnpm-lock.yaml
Muhammad-Altabba Sep 23, 2025
b91c821
resolve coding conflicts after rebase
Muhammad-Altabba Sep 25, 2025
42b9e57
edit docs and address review points
Muhammad-Altabba Oct 3, 2025
ba8c9be
Add TacoClient + Configuration Validation (#700)
Muhammad-Altabba Oct 3, 2025
08d1cc9
chore: rename build:module script to build:es and add "types" field t…
Muhammad-Altabba Oct 6, 2025
7bd9d36
feat: add prebuild script that ensure .js extensions in imports
Muhammad-Altabba Oct 6, 2025
35641a1
feat: add postbuild step to ensure ES module type in dist/es/package.…
Muhammad-Altabba Oct 6, 2025
c1fde27
refactor: update imports to use ethers.utils instead of direct utils …
Muhammad-Altabba Oct 6, 2025
6fbeae6
add js extension to files import
Muhammad-Altabba Oct 8, 2025
8cf644a
Fix ES module import issues (#701)
Muhammad-Altabba Oct 9, 2025
6b7eedb
fix: handle missing chain and ENS registry in viem-ethers adapter
Muhammad-Altabba Oct 12, 2025
2b1917c
refactor: rename TacoClient to AccessClient
Muhammad-Altabba Oct 13, 2025
f50ab07
refactor: rename type guards and improve AccessClient documentation c…
Muhammad-Altabba Oct 15, 2025
251c3ea
update console.warn and use ethers for ENS address validation and add…
Muhammad-Altabba Oct 15, 2025
a84d6c5
Rename TacoClient to AccessClient (#726)
Muhammad-Altabba Oct 15, 2025
a1ae147
fix: handle missing chain and ENS registry in viem-ethers adapter (#725)
Muhammad-Altabba Oct 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions examples/taco/react-viem/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# `react-viem-taco` integration example

Shows how to integrate `@nucypher/taco` into a React application using viem.
## Usage

```bash
pnpm install
pnpm start
```

Next, go to [http://127.0.0.1:3000/](http://127.0.0.1:8080/) in your browser and
inspect the UI and the JS console.

## Learn more

Please find developer documentation for
TACo [here](https://docs.taco.build/).
42 changes: 42 additions & 0 deletions examples/taco/react-viem/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "taco-react-example",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "react-scripts build",
"check": "pnpm type-check && pnpm build",
"eject": "react-scripts eject",
"start": "react-scripts start",
"test": "react-scripts test",
"type-check": "tsc -p tsconfig.build.json"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"dependencies": {
"@nucypher/shared": "workspace:*",
"@nucypher/taco": "workspace:*",
"@nucypher/taco-auth": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/node": "^20.17.28",
"@types/react": "^18.3.20",
"@types/react-dom": "^18.3.5",
"react-scripts": "^5.0.1"
},
"peerDependencies": {
"ethers": "^5.7.2",
"viem": "^2.0.0"
}
}
Binary file added examples/taco/react-viem/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions examples/taco/react-viem/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added examples/taco/react-viem/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/taco/react-viem/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions examples/taco/react-viem/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions examples/taco/react-viem/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
164 changes: 164 additions & 0 deletions examples/taco/react-viem/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import { fromHexString } from '@nucypher/shared';
import { conditions, domains, fromBytes, toHexString } from '@nucypher/taco';
import { hexlify } from 'ethers/lib/utils';
import { useEffect, useState } from 'react';
import {
createPublicClient,
createWalletClient,
custom,
PublicClient,
WalletClient
} from 'viem';
import { polygonAmoy } from 'viem/chains';

import useTaco from './hooks/useTaco';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const window: any;

const ritualId = 6; // Replace with your own ritual ID
const domain = domains.TESTNET;

function App() {
const [publicClient, setPublicClient] = useState<PublicClient>();
const [walletClient, setWalletClient] = useState<WalletClient>();
const [message, setMessage] = useState('this is a secret');
const [encrypting, setEncrypting] = useState(false);
const [encryptedText, setEncryptedText] = useState<string | undefined>('');
const [decrypting, setDecrypting] = useState(false);
const [decryptedMessage, setDecryptedMessage] = useState<string | undefined>(
'',
);

const loadWeb3Provider = async () => {
if (!window.ethereum) {
console.error('You need to connect to your wallet first');
return;
}

// Request account access
await window.ethereum.request({ method: 'eth_requestAccounts' });

// Create public client for reading data
const publicClient = createPublicClient({
chain: polygonAmoy,
transport: custom(window.ethereum),
});

// Get the accounts from the provider
const [account] = await window.ethereum.request({
method: 'eth_accounts'
});
// Create wallet client for signing the message
const walletClient = createWalletClient({
account,
chain: polygonAmoy,
transport: custom(window.ethereum),
});

const chainId = await publicClient.getChainId();
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(amoyChainId) }],
});
}

setPublicClient(publicClient);
setWalletClient(walletClient);
};

useEffect(() => {
loadWeb3Provider();
}, []);

const { isInit, encryptDataToBytes, decryptDataFromBytes } = useTaco({
domain,
publicClient,
walletClient,
ritualId,
});

if (!isInit || !publicClient || !walletClient) {
return <div>Loading...</div>;
}

const encryptMessage = async () => {
if (!walletClient) {
return;
}
setEncrypting(true);
try {
const hasPositiveBalance = new conditions.base.rpc.RpcCondition({
chain: 80002,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>=',
value: 0,
},
});

console.log('Encrypting message...');
const encryptedBytes = await encryptDataToBytes(
message,
hasPositiveBalance,
);
if (encryptedBytes) {
setEncryptedText(toHexString(encryptedBytes));
}
} catch (e) {
console.log(e);
}
setEncrypting(false);
};

const decryptMessage = async () => {
if (!encryptedText || !walletClient) {
return;
}
try {
setDecrypting(true);

console.log('Decrypting message...');
const decryptedMessage = await decryptDataFromBytes(
fromHexString(encryptedText),
);
if (decryptedMessage) {
setDecryptedMessage(fromBytes(decryptedMessage));
}
} catch (e) {
console.log(e);
}
setDecrypting(false);
};

return (
<div>
<h2>
Secret message:{' '}
<input
value={message}
onChange={(e) => setMessage(e.target.value)}
onClick={encryptMessage}
/>{' '}
<button onClick={encryptMessage}>Encrypt</button>{' '}
{encrypting && 'Encrypting...'}
</h2>
<h2>
Encrypted message:{' '}
<input
value={encryptedText}
onChange={(e) => setEncryptedText(e.target.value)}
/>{' '}
<button onClick={decryptMessage}>Decrypt</button>{' '}
{decrypting && 'Decrypting...'}
</h2>
{decryptedMessage && <h2>Decrypted message: {decryptedMessage}</h2>}
</div>
);
}

export default App;
Loading