Skip to content

Add optional viem support for encryption and decryption operations #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: epic-v0.7.x
Choose a base branch
from

Conversation

Muhammad-Altabba
Copy link
Contributor

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

High-level idea of the changes introduced in this PR. List relevant API
changes (if any), as well as related PRs and issues.

Issues fixed/closed:

Closes https://github.com/nucypher/sprints/issues/212

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

@Muhammad-Altabba Muhammad-Altabba marked this pull request as draft August 12, 2025 16:45
@Muhammad-Altabba Muhammad-Altabba force-pushed the 691-add-optional-viem-support-for-encryption-and-decryption-operations branch from 6891988 to b30259d Compare August 12, 2025 16:47
Copilot

This comment was marked as outdated.

- Added eslint disable comments for necessary any types in dynamic viem type declarations
- Fixed import order in examples and tests
- Added file-level eslint disables for complex wrapper implementations
- Resolved all lint errors while maintaining functionality
- Fixed eslint disable comment placement for any type assertions
- Ensured all CI/CD lint checks pass successfully
(it was removed in another PR that is not yet merged with the target branch)
(to prevent making unnecessary network calls)
Copilot

This comment was marked as resolved.

@Muhammad-Altabba Muhammad-Altabba force-pushed the 691-add-optional-viem-support-for-encryption-and-decryption-operations branch 5 times, most recently from 61c4fda to 55fbaa2 Compare August 13, 2025 21:55
@Muhammad-Altabba Muhammad-Altabba force-pushed the 691-add-optional-viem-support-for-encryption-and-decryption-operations branch from 55fbaa2 to b222cf7 Compare August 13, 2025 22:03
@@ -128,65 +128,5 @@ describe.skipIf(!process.env.RUNNING_IN_CI)(
// Verify decryption
expect(decryptedMessageString).toEqual(messageString);
}, 15000); // 15s timeout

test('should encrypt and decrypt according to wallet allowlist condition', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is no more working. And it has been already deleted at #688.

@nucypher nucypher deleted a comment from Copilot AI Aug 14, 2025
Copilot

This comment was marked as outdated.

@Muhammad-Altabba Muhammad-Altabba force-pushed the 691-add-optional-viem-support-for-encryption-and-decryption-operations branch 3 times, most recently from c364fbd to 7872080 Compare August 14, 2025 11:00
@Muhammad-Altabba Muhammad-Altabba force-pushed the 691-add-optional-viem-support-for-encryption-and-decryption-operations branch from 7872080 to 0ab9cb3 Compare August 14, 2025 11:07
Copilot

This comment was marked as resolved.

Copilot

This comment was marked as outdated.

Muhammad-Altabba referenced this pull request in fileverse/agents Aug 14, 2025
in addition to some minor changes like updating pinata library, add `downloadBytes` to the bas storage provider and add some constants and comments...
Copilot

This comment was marked as resolved.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds optional viem support for encryption and decryption operations in the TACo SDK. It provides viem-compatible wrapper functions that internally convert viem objects to ethers.js objects for seamless integration with existing TACo functionality.

Key Changes

  • Added encryptWithViem() and decryptWithViem() functions as viem alternatives to existing ethers.js functions
  • Created viem wrapper utilities in shared package for consistent cross-package integration
  • Implemented ViemEIP4361AuthProvider for viem-native authentication support

Reviewed Changes

Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/taco/src/viem-taco.ts Core viem encryption/decryption functions with type casting to ethers.js
packages/taco/src/wrappers/viem-wrappers.ts TACo-specific viem wrapper implementations extending shared base classes
packages/shared/src/viem-utils.ts Shared viem utilities with base provider and signer classes
packages/taco-auth/src/providers/viem/viem-auth-providers.ts Viem-compatible EIP4361 authentication provider
packages/taco/test/viem-unit.test.ts Unit tests for viem functionality with mocked adapters
packages/taco/integration-test/viem-encrypt-decrypt.test.ts Integration tests for real viem encryption/decryption flows
packages/taco/VIEM_SUPPORT.md Documentation for viem usage patterns and API reference
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

* );
*

* ```
Copy link
Preview

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSDoc example comment is incomplete - it ends with an incomplete code block. Either complete the example or remove the trailing backticks.

Copilot uses AI. Check for mistakes.

const feeData = await this.viemPublicClient.getFeeHistory({
blockCount: 4,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
blockNumber: 'latest' as any,
Copy link
Preview

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'as any' type assertion bypasses TypeScript safety. Consider using a proper type or checking if 'latest' is a valid blockNumber type for the getFeeHistory method.

Suggested change
blockNumber: 'latest' as any,
blockNumber: 'latest' as "latest",

Copilot uses AI. Check for mistakes.

try {
return await this.viemPublicClient.getEnsAddress({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
name: name as any,
Copy link
Preview

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'as any' type assertion bypasses TypeScript safety. Consider defining proper types for ENS name resolution or checking the expected type for the name parameter.

Suggested change
name: name as any,
name: name,

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant