Skip to content

Conversation

@akgunberk
Copy link
Collaborator

@akgunberk akgunberk commented Dec 29, 2025

Summary by CodeRabbit

  • New Features

    • Added error handling in swap quote retrieval with fallback zeroed quotes on failures.
    • Enhanced swap transaction validation for quote data and output amounts.
  • Bug Fixes

    • Improved robustness in swap operations with explicit error handling and input validation.
  • Dependencies

    • Updated "@vechain/vechain-contract-types" from 1.5.0 to 1.6.0-rc.

✏️ Tip: You can customize this high-level summary in your review settings.

@akgunberk akgunberk self-assigned this Dec 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 29, 2025

📝 Walkthrough

Walkthrough

This PR updates the @vechain/vechain-contract-types dependency to version 1.6.0-rc and migrates contract factory imports from a local re-export module (@hooks/contracts) to direct imports from the updated package, eliminating the intermediate re-export layer across 25+ files.

Changes

Cohort / File(s) Summary
Dependency Update
packages/vechain-kit/package.json
Bumped @vechain/vechain-contract-types from 1.5.0 to 1.6.0-rc.
VetDomains Contract Factories
packages/vechain-kit/src/hooks/api/vetDomains/useClaimVe...Subdomain.ts, useClaimVetDomain.ts, useEnsRecordExists.ts, useIsDomainProtected.ts, useUnsetDomain.ts
Migrated contract factory imports from @hooks/contracts to @vechain/vechain-contract-types: replaced IReverseRegistrar__factory with VetDomainsReverseRegistrar__factory, updated VetDomainsRegistry__factory and VeworldSubdomainClaimer__factory import sources.
Wallet/XApp Contract Factories
packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts, useGetTokenUsdPrice.ts, useRoundXApps.ts, useXAppMetadata.tsx, useXAppShares.ts
Migrated XAllocationVoting__factory, OracleVechainEnergy__factory, X2EarnApps__factory, and XAllocationPool__factory imports from @hooks/contracts to @vechain/vechain-contract-types.
Smart Account Contract Factories
packages/vechain-kit/src/hooks/thor/smartAccounts/useAccountImplementationAddress.ts, useCurrentAccountImplementationVersion.ts, useGetAccountAddress.ts, useGetAccountVersion.ts, useHasV1SmartAccount.ts, useSmartAccount.ts, useUpgradeRequired.ts, useUpgradeRequiredForAccount.ts, useUpgradeSmartAccount.ts
Updated SocialLoginSmartAccountFactory__factory and SocialLoginSmartAccount__factory imports from @hooks/contracts to @vechain/vechain-contract-types.
ERC20 Interface Migrations
packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts, packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts, packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts, packages/vechain-kit/src/utils/swap/veTrade.tsx
Replaced ERC20__factory with IERC20__factory for interface creation; adjusted ABI access paths and type handling accordingly.
Swap Utilities Refactoring
packages/vechain-kit/src/utils/swap/simulateSwap.ts, uniswapV2Aggregator.ts
Added ERC20_ABI import from @vechain/sdk-core in simulateSwap; added error handling (try/catch) in getQuote and enhanced input validation in buildSwapTransaction; replaced ERC20__factory with IERC20__factory and imported UniswapV2Router__factory directly from contract types.
Re-export Module Removal
packages/vechain-kit/src/hooks/contracts.ts
Removed all imports and exports from @vechain/vechain-contract-types (11 factory symbols), eliminating the re-export barrel entirely.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • vechain/vechain-kit#543: Both PRs modify the swap subsystem (simulateSwap, uniswapV2Aggregator, veTrade, and related utilities) and update contract factory imports from @hooks/contracts.

Suggested reviewers

  • victorkl400
  • mikeredmond

Poem

🐰 Factories now flow from upstream springs,
Direct and bright, no middling things,
From hook contracts to vechain's core,
Imports dance—clean forevermore!
Error guards catch what once might slip,
A migration swift, with nary a flip. 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: update contract-types' directly and clearly describes the main objective of the PR - updating the contract types dependency and related imports throughout the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🚀 Preview environment deployed!

Preview URL: https://preview.vechainkit.vechain.org/fixupdate-contract-types

@github-actions
Copy link

Size Change: +2.45 kB (+0.04%)

Total Size: 5.76 MB

Filename Size Change
packages/vechain-kit/dist/index-COi91Kik.d.cts 0 B -151 kB (removed) 🏆
packages/vechain-kit/dist/index-COi91Kik.d.cts.map 0 B -43.8 kB (removed) 🏆
packages/vechain-kit/dist/index-DMCHcGJm.d.mts 0 B -151 kB (removed) 🏆
packages/vechain-kit/dist/index-DMCHcGJm.d.mts.map 0 B -43.8 kB (removed) 🏆
packages/vechain-kit/dist/index.cjs.map 1.87 MB +1.51 kB (+0.08%)
packages/vechain-kit/dist/index.mjs.map 1.81 MB +1.1 kB (+0.06%)
packages/vechain-kit/dist/index-BVNCBSyg.d.mts 151 kB +151 kB (new file) 🆕
packages/vechain-kit/dist/index-BVNCBSyg.d.mts.map 43.8 kB +43.8 kB (new file) 🆕
packages/vechain-kit/dist/index-CWEnqQ5x.d.cts 151 kB +151 kB (new file) 🆕
packages/vechain-kit/dist/index-CWEnqQ5x.d.cts.map 43.8 kB +43.8 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
packages/vechain-kit/dist/assets 4.1 kB 0 B
packages/vechain-kit/dist/assets-aAdDxPJu.mjs 50.1 kB 0 B
packages/vechain-kit/dist/assets-aAdDxPJu.mjs.map 70.2 kB 0 B
packages/vechain-kit/dist/assets-DXVXPy3w.cjs 54.8 kB 0 B
packages/vechain-kit/dist/assets-DXVXPy3w.cjs.map 71.6 kB 0 B
packages/vechain-kit/dist/assets/index.cjs 716 B 0 B
packages/vechain-kit/dist/assets/index.d.cts 973 B 0 B
packages/vechain-kit/dist/assets/index.d.mts 973 B 0 B
packages/vechain-kit/dist/assets/index.mjs 718 B 0 B
packages/vechain-kit/dist/index-BYfc-9J5.d.mts 5.63 kB 0 B
packages/vechain-kit/dist/index-BYfc-9J5.d.mts.map 2.99 kB 0 B
packages/vechain-kit/dist/index-DSMUkHcK.d.cts 5.63 kB 0 B
packages/vechain-kit/dist/index-DSMUkHcK.d.cts.map 2.99 kB 0 B
packages/vechain-kit/dist/index.cjs 612 kB -12 B (0%)
packages/vechain-kit/dist/index.d.cts 20.5 kB 0 B
packages/vechain-kit/dist/index.d.mts 20.5 kB 0 B
packages/vechain-kit/dist/index.mjs 578 kB -104 B (-0.02%)
packages/vechain-kit/dist/utils 4.1 kB 0 B
packages/vechain-kit/dist/utils-CNYVq6tT.mjs 21.2 kB 0 B
packages/vechain-kit/dist/utils-CNYVq6tT.mjs.map 63.4 kB 0 B
packages/vechain-kit/dist/utils-DcAJej3n.cjs 26.4 kB 0 B
packages/vechain-kit/dist/utils-DcAJej3n.cjs.map 63.7 kB 0 B
packages/vechain-kit/dist/utils/index.cjs 1.94 kB 0 B
packages/vechain-kit/dist/utils/index.d.cts 2.97 kB 0 B
packages/vechain-kit/dist/utils/index.d.mts 2.97 kB 0 B
packages/vechain-kit/dist/utils/index.mjs 1.96 kB 0 B

compressed-size-action

@akgunberk akgunberk marked this pull request as ready for review December 30, 2025 08:48
@akgunberk akgunberk requested a review from Copilot December 30, 2025 08:49
Copy link
Contributor

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 updates the @vechain/vechain-contract-types package from version 1.5.0 to 1.6.0-rc, which includes changes to contract factory naming conventions. The update removes the intermediate contracts.ts barrel export file and migrates all imports to directly reference the external package.

  • Migrated from custom ERC20__factory to standard IERC20__factory from the contract types package
  • Updated IReverseRegistrar__factory references to VetDomainsReverseRegistrar__factory
  • Consolidated imports by removing the intermediate barrel export file

Reviewed changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/vechain-kit/package.json Updated dependency version to 1.6.0-rc
packages/vechain-kit/src/hooks/contracts.ts Removed barrel export file (file deleted)
packages/vechain-kit/src/utils/swap/veTrade.tsx Updated ERC20 factory import
packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts Updated ERC20 and Router factory imports with code formatting
packages/vechain-kit/src/utils/swap/simulateSwap.ts Replaced ERC20 factory with SDK's ERC20_ABI constant
packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts Updated ERC20 factory import and improved null safety
packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts Updated ERC20 factory import
packages/vechain-kit/src/hooks/thor/smartAccounts/*.ts Updated smart account factory imports (7 files)
packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts Updated ERC20 factory import
packages/vechain-kit/src/hooks/api/wallet/*.ts Updated contract factory imports (5 files)
packages/vechain-kit/src/hooks/api/vetDomains/*.ts Updated domain registrar factory imports (5 files)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const transferEventAbi = ERC20Interface.getEvent('Transfer');
const transferEventTopicHash = transferEventAbi.topicHash.toLowerCase();

const transferEventTopicHash = transferEventAbi?.topicHash.toLowerCase();
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The optional chaining operator added here could lead to transferEventTopicHash being undefined, which would cause the filter on line 62 to fail silently. The original code without optional chaining was safer - if getEvent('Transfer') returns null/undefined, the code should fail explicitly rather than continuing with undefined. Consider adding an explicit null check and throwing an error if the event ABI is not found.

Suggested change
const transferEventTopicHash = transferEventAbi?.topicHash.toLowerCase();
if (!transferEventAbi) {
throw new Error('Transfer event ABI not found on IERC20 interface');
}
const transferEventTopicHash = transferEventAbi.topicHash.toLowerCase();

Copilot uses AI. Check for mistakes.
Copy link

@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 (3)
packages/vechain-kit/src/utils/swap/simulateSwap.ts (1)

228-230: Minor formatting improvements.

The multiline formatting of Object.entries() calls improves readability without changing logic.

Also applies to: 255-260

packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts (1)

126-159: Consider simplifying the repeated type assertions.

The type guards and explicit casting are good for safety, but the pattern (decoded.args as { from: ...; to: ...; value: ... }) is repeated five times. Consider extracting this once to reduce verbosity.

🔎 Proposed simplification
                 // Type guard for Transfer event args
                 if (
                     !decoded.args ||
                     !('from' in decoded.args) ||
                     !('to' in decoded.args) ||
                     !('value' in decoded.args)
                 ) {
                     continue;
                 }

-                const from = (
-                    decoded.args as {
-                        from: `0x${string}`;
-                        to: `0x${string}`;
-                        value: bigint;
-                    }
-                ).from
-                    ?.toString()
-                    .toLowerCase();
-                const to = (
-                    decoded.args as {
-                        from: `0x${string}`;
-                        to: `0x${string}`;
-                        value: bigint;
-                    }
-                ).to
-                    ?.toString()
-                    .toLowerCase();
-                const value = (
-                    decoded.args as {
-                        from: `0x${string}`;
-                        to: `0x${string}`;
-                        value: bigint;
-                    }
-                ).value as bigint;
+                const transferArgs = decoded.args as {
+                    from: `0x${string}`;
+                    to: `0x${string}`;
+                    value: bigint;
+                };
+                const from = transferArgs.from?.toString().toLowerCase();
+                const to = transferArgs.to?.toString().toLowerCase();
+                const value = transferArgs.value;
packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts (1)

196-199: Redundant validation can be removed.

This check is redundant since lines 184-191 already validate that quote.minimumOutputAmount is neither missing nor zero, and amountOutMin is assigned directly from it on line 193.

🔎 Proposed fix
             const amountOutMin = quote.minimumOutputAmount;
             const amountIn = BigInt(params.amountIn);

-            // Additional validation: amountOutMin should be positive
-            if (amountOutMin === 0n) {
-                throw new Error('Invalid quote: minimumOutputAmount is zero');
-            }
-
             const isFromVET = isVET(params.fromTokenAddress);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb2990f and eca6eb0.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (27)
  • packages/vechain-kit/package.json
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVeWorldSubdomain.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVetDomain.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useEnsRecordExists.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useIsDomainProtected.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useUnsetDomain.ts
  • packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
  • packages/vechain-kit/src/hooks/api/wallet/useGetTokenUsdPrice.ts
  • packages/vechain-kit/src/hooks/api/wallet/useRoundXApps.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppMetadata.tsx
  • packages/vechain-kit/src/hooks/api/wallet/useXAppShares.ts
  • packages/vechain-kit/src/hooks/contracts.ts
  • packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useAccountImplementationAddress.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useCurrentAccountImplementationVersion.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountAddress.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountVersion.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useHasV1SmartAccount.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useSmartAccount.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequired.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequiredForAccount.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeSmartAccount.ts
  • packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts
  • packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts
  • packages/vechain-kit/src/utils/swap/simulateSwap.ts
  • packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts
  • packages/vechain-kit/src/utils/swap/veTrade.tsx
💤 Files with no reviewable changes (1)
  • packages/vechain-kit/src/hooks/contracts.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/migration-guide-to-v2.mdc)

**/*.{ts,tsx}: In VeChain Kit Version 2, use useThor instead of useConnex for contract interactions
For single contract read operations, use the useCallClause hook with the pattern: import dependencies, define ABI and method as const, create query key function using getCallClauseQueryKeyWithArgs, and wrap with useCallClause including data transformation in the select option
For multiple parallel contract calls, use the executeMultipleClausesCall utility wrapped in a useQuery hook with the pattern: define query key function, use executeMultipleClausesCall in queryFn mapping items to clause objects, and transform results
For transaction building and sending, use the useBuildTransaction hook with a clauseBuilder function that returns an array of clauses with optional comment fields describing the transaction action
Always provide an arguments array for contract calls, even when no parameters are required - use an empty array for parameter-less functions to enable TypeScript type checking
Always conditionally enable queries using the enabled property to prevent unnecessary contract calls, checking for all required parameters: enabled: !!requiredParam && !!otherRequiredParam
Use the select option in useCallClause or transform data in queryFn to handle data transformation, particularly for converting BigInt values to strings and normalizing contract return data
Maintain consistent query key patterns: use getCallClauseQueryKeyWithArgs for contract calls with arguments and getCallClauseQueryKey for calls without arguments to ensure proper caching and invalidation
Use TypeScript as const assertions for method names and as 0x${string}`` assertions for Ethereum addresses to ensure type safety in contract interactions

Files:

  • packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
  • packages/vechain-kit/src/utils/swap/veTrade.tsx
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useAccountImplementationAddress.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useIsDomainProtected.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useSmartAccount.ts
  • packages/vechain-kit/src/hooks/api/wallet/useGetTokenUsdPrice.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useEnsRecordExists.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountVersion.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppShares.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountAddress.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequiredForAccount.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequired.ts
  • packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts
  • packages/vechain-kit/src/hooks/api/wallet/useRoundXApps.ts
  • packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeSmartAccount.ts
  • packages/vechain-kit/src/utils/swap/simulateSwap.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVeWorldSubdomain.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useCurrentAccountImplementationVersion.ts
  • packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useHasV1SmartAccount.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useUnsetDomain.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppMetadata.tsx
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVetDomain.ts
  • packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: vechain/vechain-kit PR: 0
File: .cursor/rules/migration-guide-to-v2.mdc:0-0
Timestamp: 2025-12-01T13:01:33.771Z
Learning: Applies to **/*.{ts,tsx} : In VeChain Kit Version 2, use `useThor` instead of `useConnex` for contract interactions
📚 Learning: 2025-12-01T13:01:33.771Z
Learnt from: CR
Repo: vechain/vechain-kit PR: 0
File: .cursor/rules/migration-guide-to-v2.mdc:0-0
Timestamp: 2025-12-01T13:01:33.771Z
Learning: Applies to **/*.{ts,tsx} : In VeChain Kit Version 2, use `useThor` instead of `useConnex` for contract interactions

Applied to files:

  • packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
  • packages/vechain-kit/src/utils/swap/veTrade.tsx
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useAccountImplementationAddress.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useIsDomainProtected.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useSmartAccount.ts
  • packages/vechain-kit/src/hooks/api/wallet/useGetTokenUsdPrice.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useEnsRecordExists.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountVersion.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppShares.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountAddress.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequiredForAccount.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequired.ts
  • packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts
  • packages/vechain-kit/src/hooks/api/wallet/useRoundXApps.ts
  • packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeSmartAccount.ts
  • packages/vechain-kit/src/utils/swap/simulateSwap.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVeWorldSubdomain.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useCurrentAccountImplementationVersion.ts
  • packages/vechain-kit/package.json
  • packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useHasV1SmartAccount.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useUnsetDomain.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppMetadata.tsx
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVetDomain.ts
📚 Learning: 2025-12-01T13:01:33.771Z
Learnt from: CR
Repo: vechain/vechain-kit PR: 0
File: .cursor/rules/migration-guide-to-v2.mdc:0-0
Timestamp: 2025-12-01T13:01:33.771Z
Learning: Applies to **/*.{ts,tsx} : For single contract read operations, use the `useCallClause` hook with the pattern: import dependencies, define ABI and method as const, create query key function using `getCallClauseQueryKeyWithArgs`, and wrap with useCallClause including data transformation in the select option

Applied to files:

  • packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
  • packages/vechain-kit/src/utils/swap/veTrade.tsx
  • packages/vechain-kit/src/hooks/api/wallet/useGetTokenUsdPrice.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppShares.ts
  • packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts
  • packages/vechain-kit/src/hooks/api/wallet/useRoundXApps.ts
  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeSmartAccount.ts
  • packages/vechain-kit/src/utils/swap/simulateSwap.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useClaimVeWorldSubdomain.ts
  • packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts
📚 Learning: 2025-12-01T13:01:33.771Z
Learnt from: CR
Repo: vechain/vechain-kit PR: 0
File: .cursor/rules/migration-guide-to-v2.mdc:0-0
Timestamp: 2025-12-01T13:01:33.771Z
Learning: Applies to **/*.{ts,tsx} : For multiple parallel contract calls, use the `executeMultipleClausesCall` utility wrapped in a `useQuery` hook with the pattern: define query key function, use `executeMultipleClausesCall` in queryFn mapping items to clause objects, and transform results

Applied to files:

  • packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts
  • packages/vechain-kit/src/hooks/api/wallet/useGetTokenUsdPrice.ts
  • packages/vechain-kit/src/hooks/api/wallet/useXAppShares.ts
  • packages/vechain-kit/src/hooks/api/wallet/useRoundXApps.ts
📚 Learning: 2025-12-01T13:01:33.771Z
Learnt from: CR
Repo: vechain/vechain-kit PR: 0
File: .cursor/rules/migration-guide-to-v2.mdc:0-0
Timestamp: 2025-12-01T13:01:33.771Z
Learning: Applies to **/*.{ts,tsx} : Use TypeScript `as const` assertions for method names and `as `0x${string}`` assertions for Ethereum addresses to ensure type safety in contract interactions

Applied to files:

  • packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts
  • packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts
📚 Learning: 2025-12-01T13:01:33.771Z
Learnt from: CR
Repo: vechain/vechain-kit PR: 0
File: .cursor/rules/migration-guide-to-v2.mdc:0-0
Timestamp: 2025-12-01T13:01:33.771Z
Learning: Applies to **/*.{ts,tsx} : For transaction building and sending, use the `useBuildTransaction` hook with a clauseBuilder function that returns an array of clauses with optional comment fields describing the transaction action

Applied to files:

  • packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeSmartAccount.ts
  • packages/vechain-kit/src/utils/swap/simulateSwap.ts
  • packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts
  • packages/vechain-kit/src/hooks/api/vetDomains/useUnsetDomain.ts
  • packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts
🔇 Additional comments (28)
packages/vechain-kit/src/hooks/api/wallet/useXAppShares.ts (1)

2-2: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types, eliminating the intermediate re-export layer.

packages/vechain-kit/src/hooks/api/wallet/useCurrentAllocationsRoundId.ts (1)

2-2: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types.

packages/vechain-kit/src/hooks/thor/smartAccounts/useHasV1SmartAccount.ts (1)

2-2: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types.

packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequiredForAccount.ts (1)

2-2: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types.

packages/vechain-kit/src/hooks/api/wallet/useXAppMetadata.tsx (1)

2-2: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types.

packages/vechain-kit/src/hooks/thor/smartAccounts/useAccountImplementationAddress.ts (1)

4-4: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types.

packages/vechain-kit/src/hooks/thor/smartAccounts/useCurrentAccountImplementationVersion.ts (1)

4-4: LGTM: Import source updated.

The import source has been correctly updated to use the direct package import from @vechain/vechain-contract-types.

packages/vechain-kit/src/utils/swap/veTrade.tsx (1)

8-8: No action required—IERC20__factory is ABI-compatible and includes the approve method.

The factory change is safe. IERC20 from @vechain/vechain-contract-types is signature-compatible with the standard OpenZeppelin IERC20 interface and contains the approve(address spender, uint256 amount) function with the correct signature. This pattern is already used consistently throughout the codebase in multiple files.

packages/vechain-kit/src/hooks/api/wallet/useGetTokenUsdPrice.ts (1)

3-3: LGTM: Import migration is clean.

The import path change from @hooks/contracts to @vechain/vechain-contract-types is straightforward and aligns with the PR's objective to eliminate the intermediate re-export layer.

packages/vechain-kit/src/hooks/api/vetDomains/useIsDomainProtected.ts (1)

2-2: LGTM: Import migration is clean.

The import path change is consistent with the broader refactoring to use direct imports from @vechain/vechain-contract-types.

packages/vechain-kit/src/hooks/api/vetDomains/useEnsRecordExists.ts (1)

3-3: LGTM: Import migration is clean.

The import path change maintains consistency with the PR's refactoring objectives.

packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeSmartAccount.ts (1)

3-3: LGTM: Import migration is clean.

The import path change is consistent with the broader refactoring. The factory's createInterface() method usage remains unchanged.

packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountVersion.ts (1)

1-1: LGTM: Import migration is clean.

The import path change is straightforward and consistent with the PR's refactoring objectives.

packages/vechain-kit/src/hooks/thor/smartAccounts/useUpgradeRequired.ts (1)

2-2: LGTM: Import migration is clean.

The import path change maintains consistency with the broader refactoring effort.

packages/vechain-kit/src/hooks/api/vetDomains/useClaimVetDomain.ts (1)

8-8: Factory rename to VetDomainsReverseRegistrar__factory is correct and maintains ABI compatibility.

The factory import change from IReverseRegistrar__factory to VetDomainsReverseRegistrar__factory is a straightforward class rename reflecting the updated package version. The interface creation pattern (createInterface()) and all method calls (encodeFunctionData('setName'), getFunction('setName')) remain compatible and functional. Usage is consistent across all vetDomains hooks (useUnsetDomain.ts, useClaimVeWorldSubdomain.ts, useClaimVetDomain.ts).

packages/vechain-kit/src/hooks/thor/smartAccounts/useGetAccountAddress.ts (1)

2-2: LGTM! Clean import migration.

The import source change for SocialLoginSmartAccountFactory__factory is correct and aligns with the broader migration to @vechain/vechain-contract-types. The factory usage (.abi access at line 20) remains unchanged.

packages/vechain-kit/src/hooks/thor/smartAccounts/useSmartAccount.ts (1)

7-7: LGTM! Consistent migration pattern.

The import source change is correct and consistent with other smart account hooks in this PR.

packages/vechain-kit/src/utils/swap/simulateSwap.ts (1)

1-1: LGTM! Cleaner ABI usage pattern.

The change from ERC20__factory.abi to ERC20_ABI (imported directly from @vechain/sdk-core) is a good simplification. This removes the dependency on the factory when only the ABI is needed for event decoding.

Also applies to: 42-42

packages/vechain-kit/src/hooks/api/wallet/useRoundXApps.ts (1)

3-3: LGTM! Standard import migration.

The import source change for XAllocationVoting__factory is correct and follows the established migration pattern.

packages/vechain-kit/src/hooks/thor/transactions/useTransferERC20.ts (1)

6-6: LGTM! Consistent IERC20__factory migration.

The migration from ERC20__factory to IERC20__factory is applied correctly here. The interface creation and usage patterns (lines 39, 44) remain unchanged. This follows the same pattern as in useGenericDelegator.ts.

Note: Verification of IERC20__factory API compatibility is requested in the useGenericDelegator.ts review.

Also applies to: 28-28

packages/vechain-kit/src/utils/swap/extractSwapAmounts.ts (2)

2-2: LGTM! Defensive improvements.

The migration to IERC20__factory is correct. The addition of optional chaining on line 59 (transferEventAbi?.topicHash) is a good defensive programming practice that prevents potential null reference errors.

Also applies to: 57-59


119-122: Good type safety improvement.

The explicit type assertion for the topics array ensures proper typing for decodeEventLog. This is a good type safety enhancement.

packages/vechain-kit/src/hooks/api/vetDomains/useClaimVeWorldSubdomain.ts (1)

9-9: LGTM! Improved factory naming.

The migration from IReverseRegistrar__factory to VetDomainsReverseRegistrar__factory is correct. The new naming is more descriptive and follows a consistent pattern (removing the generic "I" interface prefix in favor of the specific domain-prefixed name). All usage sites (lines 49, 55, 63, 67, 115, 124) remain functionally unchanged.

Also applies to: 36-36

packages/vechain-kit/src/hooks/generic-delegator/useGenericDelegator.ts (1)

9-9: Version 1.6.0-rc is published on npm, but release notes unavailable for verification.

The @vechain/[email protected] package exists in the npm registry. The code uses the standard TypeChain factory method createInterface() from IERC20__factory (line 123), which aligns with expected API patterns. However, official release notes and breaking changes documentation for this RC version could not be located, so API surface compatibility and stability guarantees cannot be definitively confirmed.

packages/vechain-kit/src/hooks/api/vetDomains/useUnsetDomain.ts (1)

7-7: LGTM!

The migration from the local re-export to direct import from @vechain/vechain-contract-types is correct. The factory rename from IReverseRegistrar__factory to VetDomainsReverseRegistrar__factory aligns with the package update to version 1.6.0-rc and matches the pattern used in related files (useClaimVeWorldSubdomain.ts, useClaimVetDomain.ts).

Also applies to: 26-26

packages/vechain-kit/src/utils/swap/uniswapV2Aggregator.ts (3)

7-10: LGTM!

The import migration to @vechain/vechain-contract-types is correct. The alias UniswapV2Router02__factory as UniswapV2Router__factory maintains backward compatibility with existing code references while adopting the updated package.


140-154: Defensive error handling returns zeroed quote.

The approach of returning a zeroed quote on error allows multi-aggregator comparisons to continue when one fails. Ensure consumers filter out quotes with outputAmount === 0n before presenting them to users or using them in transactions.


228-244: LGTM!

The use of IERC20__factory.abi for token approval is correct and aligns with the contract-types migration. The approval clause is properly constructed.

"@vechain/dapp-kit-react": "2.1.0-rc.5",
"@vechain/picasso": "^2.1.1",
"@vechain/vechain-contract-types": "1.5.0",
"@vechain/vechain-contract-types": "1.6.0-rc",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

@vechain/vechain-contract-types 1.6.0-rc breaking changes changelog

💡 Result:

I couldn't find a public changelog or release notes for @vechain/vechain-contract-types v1.6.0-rc. I searched npm, GitHub, VeChain docs, and VeKit resources and found no release entry or changelog for that specific pre-release version. [1][2]

Would you like me to:

  • search the vechain GitHub repos/tags more deeply (I can scan tags and release pages), or
  • search your project repo/lockfile for where that exact version is referenced so I can inspect its source?

Sources:

  1. VeChain GitHub repositories listing (no package release found). [github.com/vechain]. [3]
  2. VeKit docs mentioning @vechain/vechain-contract-types as a standalone package. [vechainkit.vechain.org]. [4]

🏁 Script executed:

# Find all imports of vechain-contract-types in the codebase
rg "from\s+['\"]@vechain/vechain-contract-types" -A 2 -B 2

Repository: vechain/vechain-kit

Length of output: 16896


🏁 Script executed:

# Also check if there are any factory-related imports
rg "vechain-contract-types" --type json,ts,js | head -30

Repository: vechain/vechain-kit

Length of output: 97


🏁 Script executed:

# Check the full package.json to see version context
cat packages/vechain-kit/package.json | grep -A 5 -B 5 "vechain-contract-types"

Repository: vechain/vechain-kit

Length of output: 520


🏁 Script executed:

# Check if there's a lock file that might have version info
fd -e lock.json -e lock.yaml -e lock.yml | head -5

Repository: vechain/vechain-kit

Length of output: 45


🏁 Script executed:

# Search for any mention of 1.6.0-rc in commit messages or files
rg "1\.6\.0-rc" -i

Repository: vechain/vechain-kit

Length of output: 374


🌐 Web query:

@vechain/vechain-contract-types npm registry v1.6.0-rc package published

💡 Result:

No — there is no published @vechain/vechain-contract-types version 1.6.0-rc on the npm registry. The package releases are in the 1.0.x series (latest listed ~1.0.3 / 1.0.0 in registry listings). [1][2]

Sources:

  • npm package listing / search results for @vechain/vechain-contract-types. [1]
  • Socket / package index showing current 1.0.x releases. [2]

🏁 Script executed:

# Check full package.json structure for workspaces, resolutions, etc
cat packages/vechain-kit/package.json | head -100

Repository: vechain/vechain-kit

Length of output: 3243


🏁 Script executed:

# Look for @vechain/vechain-contract-types as a local package in the repo
fd -t d vechain-contract-types

Repository: vechain/vechain-kit

Length of output: 45


🏁 Script executed:

# Check the yarn.lock file for the actual resolution URL/source
rg -A 10 '"@vechain/vechain-contract-types@npm:1.6.0-rc"' yarn.lock

Repository: vechain/vechain-kit

Length of output: 573


🏁 Script executed:

# Check root package.json for workspace configuration
cat package.json | grep -A 20 -B 5 "workspaces"

Repository: vechain/vechain-kit

Length of output: 718


RC version 1.6.0-rc does not appear to exist on the public npm registry, which will cause installation failures.

The specified RC version cannot be resolved from the public npm registry (latest available is 1.0.x series). Although yarn.lock shows a cached resolution, fresh installations and CI/CD environments will fail to fetch this dependency. Given the extensive usage of factories from this package throughout the codebase—including critical smart account operations, ERC20 token transfers, and domain management—this version must either:

  1. Be published to npm registry, or
  2. Be replaced with an available stable version (1.0.x series) or an alternative RC version that is publicly available

Without access to the actual 1.6.0-rc release, factory API compatibility and breaking changes cannot be verified.

🤖 Prompt for AI Agents
In packages/vechain-kit/package.json around line 69 the dependency
"@vechain/vechain-contract-types": "1.6.0-rc" references a non-existent RC on
the public npm registry causing installs to fail; either change this entry to a
published version (e.g. a compatible 1.0.x stable release) or publish 1.6.0-rc
to the registry, then update package.json accordingly, regenerate the lockfile
(yarn install / yarn.lock), run CI/local install to verify resolution, and run
the test/typecheck suite to confirm API compatibility and make any necessary
import or factory adjustments if the chosen version has breaking changes.

@@ -1,8 +1,7 @@
import { TransactionClause } from '@vechain/sdk-core';
import { ERC20_ABI, TransactionClause } from '@vechain/sdk-core';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better to use from contract-types? so it's consistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah but when we're using it, something is different it is exported like IERC20 and it causes some TS issues 🤔

maybe i am getting the wrong one?

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.

3 participants