Skip to content

Conversation

@anxolin
Copy link
Contributor

@anxolin anxolin commented Mar 11, 2025

This PR implements a new SDK to simplify the use of cow-shed.

It hides some of the previously exposed types and utils from cow-shed module.

It exposes instead a CowShedSdk with only two methods:

  • getCowShedAccount: Returns the cow-shed account owned by the provided address
  • signCalls: Pre-authorize a multi-call from cow-shed account. It needs the owner's signer.

Usage

To understand how to use these methods, you can check the README instructions:

import { ethers } from 'ethers'
import { CowShedSdk, ICoWShedCall, SupportedChainId } from '@cowprotocol/cow-shed'

const cowShedSdk = new CowShedSdk({
  signer: '<privateKeyOrEthersSigner>', // You can provide the signer in the constructor, or the `signCalls` method
})

// Get the cow-shed account for any given chainId and owner's address
const cowShedAccount = cowShedSdk.getCowShedAccount(1, '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045')

// Prepare the calls you want to execute using the cow-shed account
const calls: ICoWShedCall[] = [
  {
    target: '<contract-address-1>',
    callData: 'call-data-1',
    value: 0n,
    isDelegateCall: true,
    allowFailure: false,
  },
  {
    target: '<contract-address-2>',
    callData: '<call-data-2>',
    value: 0n,
    isDelegateCall: true,
    allowFailure: false,
  }
]

// Sign the calls
const preAuthorizedCall = await cowShedSdk.signCalls({
  chainId: SupportedChainId.MAINNET,
  calls,
  signer: '<privateKeyOrEthersSigner>',
})

// Get the details of the pre-authorized call you need to send
const { signedMulticall, gasLimit, cowShedAccount } = preAuthorizedCall
const { to, data, value } = signedMulticall

// Execute the transaction using any wallet. The calldata has been pre-authed, so you don't need any special permissions to send this transaction
let anotherWallet = new ethers.Wallet('<another-private-key>');
const tx = await anotherWallet.sendTransaction({
  to,
  data,
  value,
  gasLimit,  
})

Main changes in this PR

Moved some types/utils from trading SDK to common

See:

  • src/common/types/wallets.ts
  • src/common/utils/wallet.ts

Mainly, its to reuse the logic to get the signer from the tradingSDK into other SDKs. It defines also a type for simplicity:
type SignerLike = Signer | ExternalProvider | PrivateKey

Implemented CoW Shed SDK

  • src/cow-shed/CowShedSdk.ts: This SDK has the 2 methods explained above. The code should be self-documented.

Summary by CodeRabbit

  • New Features

    • Launched a new SDK for interacting with the Cow Shed protocol, enabling streamlined transaction signing and call encoding.
  • Documentation

    • Added comprehensive usage guides and examples for the new SDK.
  • Refactor

    • Enhanced asynchronous support and unified type definitions across bridging and trading functionalities.
    • Consolidated and standardized utility functions and export structures.
  • Tests

    • Updated test expectations for contract initialization to align with the latest standards.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request introduces extensive updates across multiple modules. The changes add clearer documentation and update method signatures (notably adding the async keyword) in the Bridging SDK. The common module now exports additional wallet types and updates the EvmCall interface. A new utility function for obtaining signers is introduced. A completely new CowShed SDK is added along with supporting contracts, tests, and documentation, while several export and import paths across the CowShed and trading modules are reorganized and updated. These modifications adjust types, remove obsolete code, and improve overall type consistency.

Changes

File(s) Change Summary
src/bridging/BridgingSdk.ts Added class-level and method documentation; updated getTargetNetworks, getBuyTokens, and getQuote methods to be asynchronous.
src/common/index.ts, src/common/types/ethereum.ts, src/common/types/wallets.ts, src/common/utils/wallet.ts Added new export for wallets.ts; in ethereum.ts the EvmCall.value type changed to bigint and isDelegateCall was removed; introduced wallet-related type aliases (PrivateKey, AccountAddress, SignerLike); added new getSigner utility function.
src/cow-shed/CowShedSdk.ts, src/cow-shed/README.md, src/cow-shed/contracts/CoWShedHooks.spec.ts, src/cow-shed/contracts/CoWShedHooks.ts, src/cow-shed/contracts/utils.ts, src/cow-shed/index.ts, src/cow-shed/proxyInitCode.ts, src/cow-shed/types.ts Introduced the CowShed SDK with new interfaces and methods (getCowShedAccount, signCalls, etc.); updated import paths and expected values in tests; added constants (COW_SHED_PROXY_INIT_CODE and COW_SHED_712_TYPES) in contracts; removed obsolete proxy initialization file and EIP712 constants.
src/trading/getQuote.ts, src/trading/postLimitOrder.ts, src/trading/tradingSdk.ts, src/trading/types.ts, src/trading/utils.ts Updated import paths for AccountAddress and getSigner; modified the TraderParameters type to use SignerLike instead of a union type; removed the getSigner function from trading utilities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CowShedSdk
    participant CowShedHooks
    participant Contract
    User->>CowShedSdk: signCalls(args)
    CowShedSdk->>CowShedHooks: getCowShedHooks(chainId, options)
    CowShedSdk->>CowShedSdk: getNonce()
    CowShedSdk->>Contract: send signed transaction
    Contract-->>CowShedSdk: confirmation
    CowShedSdk-->>User: transaction result
Loading
sequenceDiagram
    participant Caller
    participant getSigner
    Caller->>getSigner: Call getSigner(signer)
    alt Signer is a string (private key)
        getSigner->>ethers.Wallet: Create new Wallet(signer)
    else Signer has request/send method
        getSigner->>Web3Provider: Initialize Web3Provider(signer)
        Web3Provider-->>getSigner: Return signer instance
    else Other object
        getSigner-->>Caller: Return signer as is
    end
Loading

Poem

I'm a clever bunny, hopping through code,
Adding async hops on each overloaded node.
Docs and types now clearly sing,
CowShed and wallets make my heart ring.
With every change, I skip with delight—
CodeRabbit Inc. makes our code shine bright!
🐰💻


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@anxolin anxolin changed the base branch from main to bridging-sdk March 11, 2025 22:35
@anxolin anxolin requested review from a team and shoom3301 March 11, 2025 22:36
@anxolin anxolin marked this pull request as ready for review March 11, 2025 22:51
@coveralls
Copy link
Collaborator

coveralls commented Mar 11, 2025

Coverage Status

coverage: 73.969% (-3.3%) from 77.229%
when pulling 87886a6 on cow-shed-sdk
into b05a654 on bridging-sdk.

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 74.826% (-2.3%) from 77.175%
when pulling e938283 on cow-shed-sdk
into cfb98ca on bridging-sdk.

@anxolin
Copy link
Contributor Author

anxolin commented Mar 12, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@anxolin anxolin requested review from a team and shoom3301 March 12, 2025 17:38
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (9)
src/common/types/wallets.ts (1)

4-6: Wallet types provide good abstractions but could use stronger type constraints

The type definitions for PrivateKey, AccountAddress, and SignerLike provide useful abstractions for wallet-related concepts. The SignerLike union type is particularly valuable as it enables flexible parameter typing for functions like getSigner.

Consider using TypeScript template literal types to enforce the character length constraints mentioned in the comments:

- export type PrivateKey = string // 64 characters
+ export type PrivateKey = `0x${string}` | `${string}` // Accepts both 0x-prefixed and raw format
+ // Further validation should be done at runtime

- export type AccountAddress = `0x${string}` // 42 characters
+ export type AccountAddress = `0x${string & { length: 40 }}` // Enforces 0x + 40 hex chars

Note: TypeScript's type system may not fully support exact string length validation, so runtime validation is still recommended for critical checks.

src/cow-shed/contracts/CoWShedHooks.spec.ts (1)

54-56: Hardcoded proxy creation code replaces constant reference.

The test now directly includes the proxy creation code as a string literal instead of using a constant. While this makes the test more self-contained, it could make future updates more error-prone.

Consider keeping the proxy creation code in a constant for better maintainability. If the code changes in the future, you would only need to update it in one place.

-      expect(defaultCowShed.proxyCreationCode()).toBe(
-        '0x60a034608e57601f61037138819003918201601f19168301916001600160401b038311848410176093578084926040948552833981010312608e57604b602060458360a9565b920160a9565b6080527f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc556040516102b490816100bd8239608051818181608f01526101720152f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b0382168203608e5756fe60806040526004361015610018575b3661019457610194565b6000803560e01c908163025b22bc1461003b575063f851a4400361000e5761010d565b3461010a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261010a5773ffffffffffffffffffffffffffffffffffffffff60043581811691828203610106577f0000000000000000000000000000000000000000000000000000000000000000163314600014610101577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8280a280f35b61023d565b8380fd5b80fd5b346101645760007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610164576020610146610169565b73ffffffffffffffffffffffffffffffffffffffff60405191168152f35b600080fd5b333003610101577f000000000000000000000000000000000000000000000000000000000000000090565b60ff7f68df44b1011761f481358c0f49a711192727fb02c377d697bcb0ea8ff8393ac0541615806101ef575b1561023d5760046040517ff92ee8a9000000000000000000000000000000000000000000000000000000008152fd5b507f400ada75000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000006000351614156101c0565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546000808092368280378136915af43d82803e1561027a573d90f35b3d90fdfea2646970667358221220c7c26ff3040b96a28e96d6d27b743972943aeaef81cc821544c5fe1e24f9b17264736f6c63430008190033'
-      )
+      expect(defaultCowShed.proxyCreationCode()).toBe(PROXY_CREATION_CODE)

Where PROXY_CREATION_CODE would be a constant defined at the top of the file or imported from a shared location.

src/cow-shed/README.md (1)

17-19: Consider adding parameter documentation.

The usage example shows how to call getCowShedAccount but doesn't explain what the parameters represent.

Adding a brief comment explaining the parameters would improve the documentation:

// Get the cow-shed account for any given chainId and owner's address
+// Parameters:
+// - 1: Chain ID (Ethereum Mainnet)
+// - '0xd8dA...': Owner's Ethereum address
const cowShedAccount = cowShedSdk.getCowShedAccount(1, '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045')
src/cow-shed/contracts/CoWShedHooks.ts (1)

26-39: Centralize EIP-712 typed data definitions.
The COW_SHED_712_TYPES matches standard EIP-712 definitions, but consider placing these definitions in a shared module if other parts of the codebase need them. This avoids possible duplication and promotes consistency.

src/cow-shed/CowShedSdk.ts (3)

6-6: Check consistency in relative import paths.
You are importing getSigner from 'src/common/utils/wallet' while using relative imports (../) elsewhere. Consistency in import paths avoids confusion in large projects.

- import { getSigner } from 'src/common/utils/wallet'
+ import { getSigner } from '../common/utils/wallet'

120-130: Caution with logging sensitive data.
Logging the full request during gas estimation failures might expose sensitive user data (e.g., function signatures). Consider masking or removing private details in production logs.

- console.error('Error estimating gas for the cow-shed call: ' + JSON.stringify(factoryCall), error)
+ console.error('Error estimating gas for the cow-shed call.', error)

154-156: Potential nonce collisions.
Generating the nonce from Date.now().toString() could collide if signCalls are triggered in quick succession. Consider appending a random suffix or using a more robust approach (like a counter).

 protected static getNonce(): string {
-  return ethers.utils.formatBytes32String(Date.now().toString())
+  const timestamp = Date.now().toString()
+  const randomPart = Math.floor(Math.random() * 999999).toString()
+  return ethers.utils.formatBytes32String(`${timestamp}-${randomPart}`)
 }
src/bridging/BridgingSdk.ts (2)

13-15: Minor grammatical improvement needed in class documentation.

The class comment has a slight redundancy with "SDK for bridging for swapping tokens". Consider revising to "SDK for bridging and swapping tokens" or simply "SDK for bridging tokens between different chains."

/**
- * SDK for bridging for swapping tokens between different chains.
+ * SDK for bridging and swapping tokens between different chains.
 */

39-41: Fix grammatical error in documentation.

There's a grammatical issue in this JSDoc comment. It says "available sources networks" instead of "available source networks".

/**
- * Get the available sources networks for the bridging.
+ * Get the available source networks for the bridging.
 */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b05a654 and 99914bf.

📒 Files selected for processing (18)
  • src/bridging/BridgingSdk.ts (2 hunks)
  • src/common/index.ts (1 hunks)
  • src/common/types/ethereum.ts (1 hunks)
  • src/common/types/wallets.ts (1 hunks)
  • src/common/utils/wallet.ts (1 hunks)
  • src/cow-shed/CowShedSdk.ts (1 hunks)
  • src/cow-shed/README.md (1 hunks)
  • src/cow-shed/contracts/CoWShedHooks.spec.ts (2 hunks)
  • src/cow-shed/contracts/CoWShedHooks.ts (1 hunks)
  • src/cow-shed/contracts/utils.ts (1 hunks)
  • src/cow-shed/index.ts (1 hunks)
  • src/cow-shed/proxyInitCode.ts (0 hunks)
  • src/cow-shed/types.ts (0 hunks)
  • src/trading/getQuote.ts (2 hunks)
  • src/trading/postLimitOrder.ts (1 hunks)
  • src/trading/tradingSdk.ts (1 hunks)
  • src/trading/types.ts (2 hunks)
  • src/trading/utils.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • src/cow-shed/types.ts
  • src/cow-shed/proxyInitCode.ts
🔇 Additional comments (23)
src/trading/postLimitOrder.ts (1)

6-6: Import path updated for shared getSigner utility

The import path for the getSigner function has been correctly updated to use the centralized implementation in the common module, maintaining consistent usage across the codebase.

src/common/utils/wallet.ts (1)

1-15: Well-implemented utility function for signer management

The implementation of getSigner provides an elegant solution for handling different types of signers (raw private keys, providers with Web3 interfaces, and direct Signer objects). This abstraction will simplify code elsewhere that needs to work with different signer types.

The function correctly handles three distinct cases:

  1. Private key strings (creating an ethers Wallet)
  2. Provider objects with Web3 interface (using Web3Provider adapter)
  3. Direct Signer instances (passing through)
src/cow-shed/index.ts (1)

1-3:

❓ Verification inconclusive

API consolidation aligns with SDK pattern, but consider backward compatibility

The change to export the new CowShedSdk while removing exports for CoWShedHooks, contracts, and proxyInitCode consolidates the API into a more encapsulated SDK pattern, which aligns with the PR objective of simplifying interactions with the cow-shed module.

This represents a breaking change for any code directly using the previously exported entities. Verify that all dependent code has been updated to use the new SDK, or consider maintaining backward compatibility by re-exporting these entities through the SDK.


🏁 Script executed:

#!/bin/bash
# Search for imports of the removed exports
echo "Searching for imports of removed exports..."
rg -t ts "import.*from\s+['\"].*cow-shed['\"]" -A 3 | grep -E "(CoWShedHooks|contracts|proxyInitCode)"

Length of output: 205


SDK Consolidation Change: Verify No Dependent Usage of Removed Entities

The consolidated export of CowShedSdk (alongside ./types) is consistent with the intended SDK simplification. However, removing the previous exports—namely, CoWShedHooks, contracts, and proxyInitCode—may cause issues for any code that still directly references them. An initial automated search targeting imports from the cow-shed package did not return any direct references, but this narrow search might not capture all dependent usages.

Please manually verify that:

  • There are no residual references to CoWShedHooks, contracts, or proxyInitCode anywhere in the repository (beyond just direct imports from cow-shed).
  • All dependent modules have been updated to rely solely on the new CowShedSdk API.

If any legacy code still depends on the removed entities, consider either updating it to use the new SDK or re-exporting those entities temporarily to maintain backward compatibility.

Snippet (Lines 1–3 of src/cow-shed/index.ts):

export * from './types'
export * from './CowShedSdk'
src/trading/getQuote.ts (2)

17-17: Import path refactoring for better code organization.

The import for AccountAddress has been refactored to use the common module path instead of local types. This aligns with the PR objective of relocating types from the trading SDK to a common directory for better reusability.


19-19:

✅ Verification successful

Import update for centralized utility function.

The getSigner function import has been updated to reflect its relocation to the common utilities module. This change supports the PR's goal of improving code organization and reusability.


🏁 Script executed:

#!/bin/bash
# Verify that getSigner is properly exported from the common utils module
rg -A 2 "export function getSigner" src/common/utils/wallet.ts

Length of output: 188


Verified Import Update: getSigner Relocation Confirmed

The verification shows that getSigner is correctly exported from the centralized utility module in src/common/utils/wallet.ts. The import update in src/trading/getQuote.ts (line 19) is valid and supports the PR's goals.

src/cow-shed/contracts/CoWShedHooks.spec.ts (1)

4-5: Updated import paths align with the new directory structure.

The import paths have been updated to reflect the reorganized directory structure. This is consistent with the PR's objectives of better code organization.

src/cow-shed/README.md (1)

1-58: Well-structured documentation for the new CowShed SDK.

The README provides clear, comprehensive documentation explaining the purpose of the SDK and including well-structured usage examples. This aligns perfectly with the PR objective of introducing a new SDK for the cow-shed module.

src/trading/utils.ts (1)

1-1:

✅ Verification successful

Simplified import statement reflecting code reorganization.

The import statement has been updated to only include the types that are actually used in this file after the getSigner function was moved to a common utility module. This change supports the PR's goal of improving code organization.


🏁 Script executed:

#!/bin/bash
# Verify that the getSigner function has been properly moved to the common module
rg -A 5 "export function getSigner" src/common/utils/wallet.ts

# Check for any remaining references to getSigner in this file that might have been missed
rg "getSigner" src/trading/utils.ts

Length of output: 320


Update Verified – Code Organization and Import Cleanup Confirmed

  • Confirmed that the getSigner function is now defined in src/common/utils/wallet.ts.
  • Verified that no residual references to getSigner remain in src/trading/utils.ts.

The simplified import statement, which now only includes the types actively used in this file, is consistent with the overall code reorganization efforts. Please proceed with the approval as these changes align with the PR’s goal of improving code modularity.

src/trading/types.ts (2)

12-12: Good adoption of unified signer type.
By importing and using the SignerLike type, you improve consistency across different signer abstractions and ensure the code is easier to maintain.


75-75: Consistent with the new signer abstraction.
Replacing multiple signer-related union types with SignerLike keeps the interface compact and clearer. No issues found.

src/cow-shed/contracts/CoWShedHooks.ts (3)

18-19: Clean import reorganization.
The updated imports from ../../common keep the references in a single place. This is a good step toward better modularity.


41-110: Thorough typed-data signing for multi-call logic.
The signCalls method effectively uses typed-data signing with EIP-712 or ETHSIGN. This is secure and flexible. Ensure that downstream code only accepts supported signing schemes to avoid user confusion.


23-25:

❓ Verification inconclusive

Confirm correctness of proxy init code.
You’ve inlined the full COW_SHED_PROXY_INIT_CODE hex string. Verify that this matches the intended contract creation bytecode exactly, as any discrepancy will break proxy creation.


🏁 Script executed:

#!/bin/bash
# Verify the correctness of the COW_SHED_PROXY_INIT_CODE by comparing it to the known contract creation bytecode 
# via strings or a known reference. (If there's a reference artifact, you can compare the hex. Otherwise, confirm from official docs.)
echo "Please ensure you've validated that this hex code matches the official factory creation code from relevant resources."

Length of output: 247


Action Required: Verify Proxy Init Code Accuracy

The inlined hex string in src/cow-shed/contracts/CoWShedHooks.ts (lines 23-25) must be manually validated against the official contract creation bytecode. As noted, any discrepancy in the COW_SHED_PROXY_INIT_CODE can break proxy creation. Please confirm that this hex code exactly matches the intended factory creation code from your verified resources and documentation before proceeding.

  • File: src/cow-shed/contracts/CoWShedHooks.ts
  • Lines: 23-25
  • Next Steps: Manually compare the inlined hex string against the official bytecode reference.
src/cow-shed/CowShedSdk.ts (2)

70-72: Allow additional signing schemes as needed.
Defaulting to EIP712 is generally recommended. If you plan to allow other signing schemes (like ETHSIGN) in the future, consider clarifying usage constraints in docs. This will help prevent accidental insecure usage.


8-8:

✅ Verification successful

Deadline usage.
Using MaxUint256 as a “never expires” deadline is typical, but confirm that all relevant chains and contract logic can handle such large deadlines without overflow or unintended reverts.


🏁 Script executed:

#!/bin/bash
# This script checks references to chain-specific code that might handle large deadlines incorrectly.
rg -A 5 "deadline" 

Length of output: 5684


Deadline Usage Verification – Approved
After reviewing references to deadline across the codebase, the use of ethers.constants.MaxUint256.toBigInt() in src/cow-shed/CowShedSdk.ts is consistent with its treatment in related contract and test files. The deadline parameter is uniformly handled as a uint256 (bigint) across the SDK, hooks, and ABI definitions, and there’s no evidence of arithmetic or chain-specific logic that would cause overflow or unintended reverts. Based on our verification, using MaxUint256 as a "never expires" deadline is appropriate.

src/bridging/BridgingSdk.ts (5)

7-9: Good documentation addition!

Adding JSDoc comments to the interface properties improves code readability and helps other developers understand the purpose of each component.


32-34: Good documentation addition!

Adding JSDoc comments to methods improves code readability and self-documentation.


46-49: Good documentation and signature update.

Adding JSDoc comment and the async keyword to this method improves code readability and correctly signals the asynchronous nature of the method to other developers.


53-59: Good documentation and signature update.

Adding detailed JSDoc comment with parameter information and the async keyword to this method improves code readability and correctly signals the asynchronous nature of the method.


63-66:

❓ Verification inconclusive

Good documentation and signature update, but implementation is still missing.

The documentation addition and async keyword are good improvements. However, note that this method still throws a "Not implemented yet!" error. Ensure this is addressed in a future PR if it's not within the scope of the current PR objectives.


🏁 Script executed:

#!/bin/bash
# Check if the implementation of getQuote is addressed elsewhere in the codebase or if there's a ticket/issue for it
echo "Checking for implementation of getQuote or related issues/tickets..."
rg "bridging.*getQuote" --type ts -g "!*test*" -g "!*spec*" | grep -v "Not implemented yet"

Length of output: 240


Action: Confirm and Document Future Implementation for getQuote Method

  • The updated documentation and signature (with the added async keyword) are solid improvements.
  • However, the getQuote method remains unimplemented as it currently throws a "Not implemented yet!" error.
  • If leaving it unimplemented in this PR is intentional, please add a clear TODO or reference an existing issue/ticket to track its future implementation.
src/common/index.ts (1)

7-7: Exports look good - wallet types are now available from common module.

The addition of exporting wallet-related types from the common module is a good organizational change that aligns with the PR objective of relocating types to improve reusability.

src/trading/tradingSdk.ts (1)

13-13: Good refactoring - utility functions properly moved to common module.

Moving the getSigner function to the common module while keeping specific trading-related utilities in the trading module is a good architectural decision. This promotes better code organization and reusability across modules while maintaining appropriate boundaries.

Also applies to: 17-17

src/cow-shed/contracts/utils.ts (1)

1-3: Import paths updated correctly.

The import paths have been properly updated to reflect the new directory structure. These changes ensure that the CowShed module correctly references the generated contract interfaces from the common module.

@shoom3301
Copy link
Contributor

@anxolin I added some tests for the SDK

@anxolin anxolin requested a review from a team March 13, 2025 10:39
@anxolin anxolin requested a review from shoom3301 March 13, 2025 12:15
@anxolin anxolin changed the base branch from bridging-sdk to main March 13, 2025 12:22
@anxolin anxolin merged commit 66c3441 into main Mar 13, 2025
5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2025
@alfetopito alfetopito deleted the cow-shed-sdk branch March 13, 2025 13:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants