Skip to content

refactor: viem in payments#569

Merged
hugomrdias merged 57 commits into
hugomrdias/move-testsfrom
hugomrdias/payments
Feb 2, 2026
Merged

refactor: viem in payments#569
hugomrdias merged 57 commits into
hugomrdias/move-testsfrom
hugomrdias/payments

Conversation

@hugomrdias
Copy link
Copy Markdown
Member

@hugomrdias hugomrdias commented Jan 26, 2026

  • Payments services use viem and core
  • synapse-core has actions for most filecoin pay functions we use
  • knip clean up
  • agents-md in core for action generation

@hugomrdias hugomrdias requested a review from rvagg as a code owner January 26, 2026 10:53
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Jan 26, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 26, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev 32f8695 Commit Preview URL

Branch Preview URL
Feb 02 2026, 04:39 PM

@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Jan 26, 2026
@rjan90 rjan90 added this to the M4.0: mainnet staged milestone Jan 26, 2026
Base automatically changed from hugomrdias/more-pdp to hugomrdias/move-tests January 26, 2026 12:50
- Removed the `PDPAuthHelper` class to simplify authentication processes.
- Updated `PDPServer` to directly utilize the `Client` from `viem` for improved integration.
- Refactored `StorageContext` to eliminate dependencies on the removed `PDPAuthHelper`, enhancing clarity and maintainability.
- Adjusted metadata handling to use `MetadataObject` for consistency across the codebase.
- Removed outdated tests related to `PDPAuthHelper` and updated existing tests to reflect the new structure.
…te viem client

- Changed various instances of `dataSetId`, `pieceId`, and other identifiers from `number` to `bigint` across multiple test files for consistency and improved type safety.
- Refactored the instantiation of services to utilize the `viem` client instead of `ethers.Provider`, enhancing clarity and maintainability.
- Updated assertions and method calls to align with the new types, ensuring all tests reflect the latest changes in the codebase.
- Added comprehensive documentation for the Synapse Core library, detailing interactions with Filecoin Onchain Cloud smart contracts.
- Implemented new features in the payments module, including deposit, withdrawal, and operator approval functionalities.
- Updated existing methods to utilize `contractAddress` instead of `address` for improved clarity and consistency.
- Introduced new test cases for accounts, deposits, and operator approvals to ensure robust functionality and reliability.
- Refactored various components to enhance maintainability and type safety, including the integration of `bigint` for identifiers.
…mprove allowance handling

- Refactored PaymentsService to utilize the Client and Chain types for enhanced type safety and consistency.
- Updated method signatures to accept `bigint` for identifiers, aligning with recent changes in the codebase.
- Changed allowance handling to use `rateUsage` and `lockupUsage` instead of `rateUsed` and `lockupUsed` for clarity.
- Simplified deposit and withdrawal methods to improve readability and maintainability.
- Updated tests to reflect changes in method signatures and ensure robust functionality.
- Added "ignoreUnknown" option to biome configuration for improved handling of unknown files.
- Simplified linting commands across multiple package.json files by removing unnecessary flags, ensuring a more streamlined linting process.
- Updated pre-commit hooks to utilize the new linting command format for consistency.
- Removed unused AllowanceDialog and DepositDialog components from PaymentsAccount for improved clarity and maintainability.
- Updated import statements to reflect the removal of unused hooks.
- Changed variable names in StorageMenu to use `rateUsage` and `lockupUsage` for consistency.
- Deleted the config.ts file as it was no longer needed.
- Updated package.json to remove the p-retry dependency.
…erator approvals

- Renamed `owner` parameter to `address` in `accounts` and `operatorApprovals` functions for consistency and clarity.
- Updated related method calls and test cases to reflect the new parameter naming.
- Introduced optional `blockNumber` parameter in `accounts` for enhanced functionality.
- Consolidated imports from `@filoz/synapse-core/pay` for improved clarity.
- Updated `UseAccountInfoProps`, `UseOperatorApprovalsProps`, `UseDepositProps`, and `UseWithdrawProps` to use new types from the `accounts`, `operatorApprovals`, `deposit`, and `withdraw` modules.
- Renamed parameters for consistency, changing `address` to `owner` in relevant functions.
- Adjusted query keys and mutation functions to reflect the new parameter names and types, enhancing maintainability.
- Renamed `owner` to `address` in `PaymentsService` methods for consistency with recent changes.
- Updated `chai` dependency to version `^6.2.1`.
- Removed the `sdk-version.ts` file as it was no longer needed, streamlining the codebase.
- Added new ignore patterns in knip.jsonc for generated files and specific directories to streamline the build process.
- Enhanced workspace configurations for synapse-sdk, synapse-react, synapse-core, and synapse-playground to improve entry points and ignore files.
- Fixed formatting in devnet.md for better readability in the documentation.
- Introduced "sideEffects": false in package.json to optimize the build process by enabling tree-shaking for unused exports.
- Moved ERC20-related functions into a dedicated `erc20` directory for better organization.
- Updated import paths across the codebase to reflect the new structure.
- Added new `approve` functionality to handle ERC20 token approvals, enhancing the module's capabilities.
- Improved documentation and examples for ERC20 operations to ensure clarity and usability.
- Replaced ERC20BalanceOptions and ERC20BalanceResult with balance.OptionsType and balance.OutputType for improved type consistency.
- Updated UseApproveAllowanceVariables and UseApproveAllowanceProps to utilize new types from the erc20 module, enhancing clarity and maintainability.
- Adjusted function implementations to align with the updated type definitions.
- Replaced approveAllowance method with approve for ERC20 token approvals to streamline the approval process.
- Simplified approval transaction handling by using approveSync, enhancing clarity and reducing complexity.
- Updated related callback options to ensure proper transaction confirmation handling.
- Reorganized entry points in knip.jsonc for the synapse-core package to specify individual source files instead of a wildcard pattern.
- Improved clarity and maintainability by explicitly listing all relevant source files for better build process management.
- Added event encoding for ERC20 approval callbacks in PaymentsService tests to improve accuracy in simulating transaction receipts.
- Introduced new utility functions for encoding ABI parameters and event topics, enhancing test clarity and maintainability.
- Updated mock server responses to include transaction receipt details for better testing of deposit callbacks.
- Updated various properties and method return types from string to Address for better type safety and consistency.
- Modified Synapse, SynapseOptions, StorageInfo interfaces, and WarmStorageService methods to utilize the Address type.
- Enhanced clarity and maintainability by ensuring uniformity in address handling throughout the codebase.
- Updated JSDoc comments for the useDeposit function to enhance clarity by linking to the UseDepositProps interface.
- Removed redundant parameter descriptions to streamline documentation and improve readability.
- Changed the type of tokenAddress from string to Address for improved type safety and consistency across the codebase.
- This update aligns with recent standardization efforts for address types in the Synapse SDK.
…sistency

- Refactored payment operations examples to utilize the `viem` library for wallet client creation and transaction handling, enhancing clarity and modernizing the codebase.
- Changed variable types from `number` to `bigint` for `railId` in multiple instances to ensure type consistency.
- Updated allowance calculations in storage costs documentation to use `approval.lockupUsage` and `approval.rateUsage` for improved clarity and accuracy.
- Enhanced overall documentation readability and maintainability by standardizing code examples and improving type safety.
bajtos and others added 27 commits February 2, 2026 15:59
Replace FilecoinNetworkType with Chain from synapse-core in
FilBeamRetriever, reading the retrieval domain from chain
configuration instead of hardcoding network-to-domain mapping.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Set chain.filbeam to null for devnet and update all code that accesses
it to gracefully handle the missing config. When CDN retrieval is
requested but not available, log a warning with chain ID and name,
then fall back to direct retrieval via the storage provider.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
…tation

- Added new functions for managing service providers, including addProduct, removeProduct, and updateProduct, to streamline product management within the service provider registry.
- Introduced methods for querying active providers and provider counts, improving the overall functionality of the service provider registry.
- Updated documentation to clarify the usage of new functions and their parameters, ensuring consistency and ease of understanding for developers.
- Removed deprecated provider-related code from the warm-storage module to enhance code clarity and maintainability.
- Enhanced error handling in service provider functions to provide clearer feedback on operation failures.
- Replaced deprecated imports and functions in use-create-data-set and use-providers files to utilize the new service provider registry.
- Updated the data set creation logic to improve clarity and maintainability.
- Enhanced the provider querying mechanism by integrating getApprovedPDPProviders for better functionality.
- Removed the SubgraphRetriever and its related logic to simplify the retrieval process, focusing on ChainRetriever and FilBeamRetriever.
- Updated SPRegistryService instantiation to utilize the new client-based approach, enhancing consistency across service provider interactions.
- Refactored provider-related types to replace ProviderInfo with PDPProvider, improving clarity and aligning with recent changes in the service provider structure.
- Adjusted various components to ensure compatibility with the updated provider model, enhancing overall maintainability and performance.
…references

- Renamed the payments contract to filecoinPay across the codebase for improved clarity and consistency.
- Updated all references in the SDK, including ABI imports, contract addresses, and function calls, to reflect the new naming convention.
- Adjusted tests and mock data to ensure compatibility with the updated contract structure, enhancing overall maintainability.
- Replaced instances of getProvider and readProviders with getPDPProvider and getPDPProviders across multiple CLI command files for improved consistency and alignment with the new service provider structure.
- Adjusted related logic in datasets-create, endorse, get-sp-peer-ids, upload-dataset, and upload commands to accommodate the updated provider retrieval methods, enhancing overall maintainability and performance.
- Replaced instances of ProviderInfo with PDPProvider across multiple documentation files to align with recent changes in the service provider structure.
- Adjusted related code snippets and examples to reflect the updated provider model, enhancing clarity and consistency in the documentation.
- Replaced hardcoded product type values with the new PRODUCTS constant in getPDPProvider and getPDPProvidersCall functions for improved clarity and maintainability.
- Updated type imports to include PRODUCTS in relevant files, ensuring consistency across the service provider registry.
- Corrected the casing of the ipniPeerId field in the PDPOffering interface and adjusted related decoding logic to accommodate legacy support.
- Renamed the ipniPeerID field to ipniPeerId across multiple files for consistency with naming conventions.
- Updated related command examples and decoding logic to reflect the new field name.
- Ensured that the changes are reflected in tests to maintain functionality and accuracy.
- Changed the instantiation of FilBeamRetriever to use ChainRetriever instead of baseRetriever, enhancing the retrieval process.
- This adjustment aligns with recent updates to the provider handling logic, improving overall maintainability and performance.
…tation

- Added new functions for managing service providers, including addProduct, removeProduct, and updateProduct, to streamline product management within the service provider registry.
- Introduced methods for querying active providers and provider counts, improving the overall functionality of the service provider registry.
- Updated documentation to clarify the usage of new functions and their parameters, ensuring consistency and ease of understanding for developers.
- Removed deprecated provider-related code from the warm-storage module to enhance code clarity and maintainability.
- Enhanced error handling in service provider functions to provide clearer feedback on operation failures.
…y and rpcURL

- Updated multiple CLI command files to eliminate the use of privateKey and rpcURL, streamlining the client initialization process.
- Adjusted the Synapse instantiation to utilize the client directly, enhancing code clarity and maintainability.
- Added endorsements index to knip configuration for improved source tracking.
- Added new endorsements module to manage endorsed provider IDs, including the `getProviderIds` function for fetching endorsed provider IDs from the blockchain.
- Implemented `getProviderIdsCall` to facilitate contract calls and `parseGetProviderIds` for processing the results.
- Updated AGENTS.md to document the new ProviderIdSet smart contract and its functionality.
- Enhanced the package.json and tsconfig.json to include endorsements in type definitions and entry points.
- Refactored related components to integrate endorsements into the existing service provider structure, improving overall functionality and maintainability.
- Added tests for the new endorsements functionality to ensure reliability and correctness.
…rvice

- Refactored the Synapse class to simplify initialization and improve clarity by removing the EndorsementsService and related logic.
- Updated the SynapseOptions interface to utilize the new client-based approach, enhancing consistency across service interactions.
- Adjusted FilBeamService and FilBeamRetriever to work with the new Chain type, improving type safety and maintainability.
- Enhanced the StorageContext and StorageManager to align with the updated service provider structure, ensuring compatibility with the latest changes.
- Removed deprecated imports and functions related to endorsements, streamlining the codebase and improving overall maintainability.
- Removed the specific version of ethers from pnpm-workspace.yaml.
- Updated react and react-dom to version 19.2.4 in synapse-playground/package.json.
- Changed viem dependency to version 2.x in docs/package.json, examples/cli/package.json, and synapse-playground/package.json.
- Updated ox dependency to version 0.12.0 in pnpm-workspace.yaml.
- Updated the ipniPeerID field to ipniPeerId in the constants file for consistency with naming conventions.
- Removed deprecated ipniPeerID handling from the decodePDPCapabilities function, streamlining the code and improving clarity.
- Ensured that changes are reflected across relevant areas to maintain functionality and accuracy.
- Replaced instances of ethers with viem in multiple documentation files to reflect the new dependency.
- Updated code snippets to utilize privateKeyToAccount for account management, enhancing clarity and consistency.
- Standardized the use of `// @lib: esnext,dom` in code examples to ensure proper library usage.
- Removed deprecated code and adjusted examples to align with the latest SDK structure and functionality.
- Updated the Synapse class to streamline the creation process, replacing the static create method with a constructor that accepts options directly.
- Improved type definitions for the Client, incorporating PublicRpcSchema and PublicActions for better type safety.
- Refactored the WarmStorageService and PDPVerifier to align with the new client-based initialization approach.
- Enhanced SynapseOptions and added SynapseFromClientOptions interfaces for clearer configuration management.
- Adjusted tests to reflect the new instantiation patterns, ensuring consistency across the codebase.
- Replaced the static create method with the constructor for Synapse initialization in multiple CLI command files (fund, pay, pieces, upload).
- This change enhances code clarity and aligns with the recent refactor of the Synapse SDK for improved instantiation patterns.
- Added the Simplify utility type to enhance the OptionsType definition in getActivePiecesCall, streamlining type management.
- Ensured that the chain property is included in the refined type structure for better clarity and consistency.
- Introduced the ActionCallChain type across various modules to streamline contract call options, improving type consistency and clarity.
- Updated multiple function signatures to utilize the new ActionCallChain type, enhancing type safety and reducing redundancy.
- Improved documentation with examples for several functions in the pdp-verifier module, ensuring better usability and understanding for developers.
- Adjusted comments and code structure for clarity, aligning with recent refactoring efforts in the Synapse SDK.
- Replaced capabilityKeys and capabilityValues with pdpOffering in multiple test cases for the registerProvider function, enhancing clarity and consistency in the test structure.
- Added epoch.ts export to utils index for improved module accessibility.
- Modified tsconfig.json to include additional files for better type checking and module resolution.
- Removed epoch utilities from the utils directory and adjusted imports in context.ts to reflect this change.
- Deleted the epoch.test.ts file as it is no longer relevant following the removal of epoch utilities.
- Updated synapse.test.ts to clean up unused imports, enhancing code clarity.
- Changed references from `pnpm run fix` to `pnpm run lint:fix` in the AGENTS.md file to accurately reflect the correct command for linting and auto-fixing code before commits.
- Ensured consistency in documentation regarding development commands and linting practices.
@hugomrdias hugomrdias merged commit f3bc2e1 into hugomrdias/move-tests Feb 2, 2026
11 checks passed
@hugomrdias hugomrdias deleted the hugomrdias/payments branch February 2, 2026 19:19
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to 🎉 Done in FOC Feb 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

5 participants