Skip to content

fix: starknet deploy account fee estimation#11592

Merged
NeOMakinG merged 6 commits intodevelopfrom
starknet-fixes
Jan 12, 2026
Merged

fix: starknet deploy account fee estimation#11592
NeOMakinG merged 6 commits intodevelopfrom
starknet-fixes

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Jan 7, 2026

Description

Fee estimation on starknet for the deploy account were using an INVOKE estimation instead of a deploy account one, which was failing

Issue (if applicable)

nothing

Risk

Low

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Add some STRK on a fresh starknet account
  • try to swap or send this STRK, and then deploy the account!

Engineering

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/e0e3fe4a-fbe9-4026-a345-f772d7e7a4fd

Summary by CodeRabbit

  • New Features

    • Tiered Starknet fee estimates (slow/average/fast) with RPC-driven estimation and static fallbacks for deployments and transactions.
    • Dedicated deployment fee lookup using account index from account metadata to power deployment flows.
  • Bug Fixes

    • Better RPC error surfacing, balance checks before deployment, and robust fallback behavior.
    • Improved address validation formatting and preservation of public key when preparing transactions.

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

@NeOMakinG NeOMakinG requested a review from a team as a code owner January 7, 2026 19:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2026

📝 Walkthrough

Walkthrough

Added StarknetChainAdapter.getDeployAccountFeeData to compute Starknet account deployment fees (RPC estimate + static fallbacks) using wallet-derived public keys; updated Send and Trade UI flows to call this deployment-specific method via accountNumber from account metadata.

Changes

Cohort / File(s) Summary
Starknet Adapter Core
packages/chain-adapters/src/starknet/StarknetChainAdapter.ts, packages/chain-adapters/src/starknet/index.ts
Added getDeployAccountFeeData({ accountNumber, wallet }); moved constants and fee-tier logic into utils; improved RPC error handling, balance checks, and resourceBounds computation; exported utils.
Starknet Utilities
packages/chain-adapters/src/starknet/utils.ts
New module: STRK_TOKEN_ADDRESS, OPENZEPPELIN_ACCOUNT_CLASS_HASH, STATIC_FEE_ESTIMATES, FeeEstimateParams, and calculateFeeTiers() producing tiered FeeDataEstimate and txFee values.
Send UI
src/components/Modals/Send/views/SendAmountDetails.tsx
Replaced generic fee fetch with adapter.getDeployAccountFeeData({ accountNumber, wallet }); source accountNumber from accountMetadata.bip44Params.
Trade UI
src/components/MultiHopTrade/components/TradeConfirm/TradeFooterButton.tsx
Switched deployment fee retrieval to adapter.getDeployAccountFeeData({ accountNumber, wallet }); preserved extraction of returned maxFee for deployment.
Transaction Builders
packages/chain-adapters/src/starknet/... (related tx build functions)
buildSendApiTransaction / buildSendTransaction now preserve/merge optional pubKey into txToSign; minor shape/hex/BigInt conversions adjusted to align with fee tiers and v3 Starknet fee fields.

Sequence Diagram(s)

sequenceDiagram
  participant UI as UI (Send/Trade)
  participant Adapter as StarknetChainAdapter
  participant Wallet as HDWallet
  participant RPC as Starknet Node RPC
  participant Chain as ChainState (Balance)

  UI->>Adapter: getDeployAccountFeeData({ accountNumber, wallet })
  Adapter->>Wallet: getPublicKey(accountNumber)
  Wallet-->>Adapter: publicKey
  Adapter->>Adapter: build DEPLOY_ACCOUNT tx (calldata, salt using publicKey)
  Adapter->>RPC: starknet_estimateFee(DEPLOY_ACCOUNT tx)
  alt RPC returns estimate
    RPC-->>Adapter: estimate (l1_gas, l2_gas, l1_data_gas, gas_price)
    Adapter->>Adapter: calculateFeeTiers(estimate) -> slow/avg/fast
  else RPC fails / no estimate
    Adapter-->>Adapter: use STATIC_FEE_ESTIMATES -> calculateFeeTiers
  end
  Adapter->>Chain: query balance(for target address)
  Chain-->>Adapter: balance
  Adapter-->>UI: FeeDataEstimate { slow/avg/fast tiers, chainSpecific.maxFee, txFee }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • gomesalexandre

Poem

🐰 I hopped into calldata with glee,
I asked the wallet, "Share pubkey with me."
RPC whispered fees, if silent — I guessed,
Slow, average, fast — I shelved them in a chest.
Deploys now bound — a rabbit's happy quest.

🚥 Pre-merge checks | ✅ 3
✅ 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: starknet deploy account fee estimation' directly and concisely captures the main change: fixing the fee estimation logic for Starknet deploy-account transactions, which is the core objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch starknet-fixes

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 70f6b49 and c689b00.

📒 Files selected for processing (3)
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
  • packages/chain-adapters/src/starknet/index.ts
  • packages/chain-adapters/src/starknet/utils.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Never assume a library is available - always check imports/package.json first
Prefer composition over inheritance
Write self-documenting code with clear variable and function names
Keep functions small and focused on a single responsibility
Avoid deep nesting - use early returns instead
Prefer procedural and easy to understand code
Never expose, log, or commit secrets, API keys, or credentials
Validate all inputs, especially user inputs
Handle errors gracefully with meaningful messages
Don't silently catch and ignore exceptions
Log errors appropriately for debugging
Provide fallback behavior when possible
Use appropriate data structures for the task
Never add code comments unless explicitly requested
When modifying code, do not add comments that reference previous implementations or explain what changed. Comments should only describe the current logic and functionality.
Use meaningful names for branches, variables, and functions
Always run yarn lint --fix and yarn type-check after making changes
Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic

Files:

  • packages/chain-adapters/src/starknet/index.ts
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
  • packages/chain-adapters/src/starknet/utils.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid useEffect where practical - use it only when necessary and following best practices
Avoid 'any' types - use specific type annotations instead
For default values with user overrides, use computed values (useMemo) instead of useEffect - pattern: userSelected ?? smartDefault ?? fallback
When function parameters are unused due to interface requirements, refactor the interface or implementation to remove them rather than prefixing with underscore
Sanitize data before displaying to prevent XSS
Memoize aggressively - wrap component variables in useMemo and callbacks in useCallback where possible
For static JSX icon elements (e.g., <TbCopy />) that don't depend on state/props, define them as constants outside the component to avoid re-renders instead of using useMemo
Account for light/dark mode using useColorModeValue hook
Account for responsive mobile designs in all UI components
When applying styles, use the existing standards and conventions of the codebase
Use Chakra UI components and conventions
All copy/text must use translation keys - never hardcode strings
Use the translation hook: useTranslate() from react-polyglot
Use useFeatureFlag('FlagName') hook to access feature flag values in components
Prefer type over interface for type definitions
Use strict typing - avoid any
Use Nominal types for domain identifiers (e.g., WalletId, AccountId)
Import types from @shapeshiftoss/caip for chain/account/asset IDs
Use useAppSelector for Redux state
Use useAppDispatch for Redux actions
Memoize expensive computations with useMemo
Memoize callbacks with useCallback

**/*.{ts,tsx}: Use Result<T, E> pattern for error handling in swappers and APIs; ALWAYS use Ok() and Err() from @sniptt/monads; AVOID throwing within swapper API implementations
ALWAYS use custom error classes from @shapeshiftoss/errors with meaningful error codes for internationalization and relevant details in error objects
ALWAYS wrap async op...

Files:

  • packages/chain-adapters/src/starknet/index.ts
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
  • packages/chain-adapters/src/starknet/utils.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variables, functions, and methods with descriptive names that explain the purpose
Use verb prefixes for functions that perform actions (e.g., fetch, validate, execute, update, calculate)
Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names
Use handle prefix for event handlers with descriptive names in camelCase
Use descriptive boolean variable names with is, has, can, should prefixes
Use named exports for components, functions, and utilities instead of default exports
Use descriptive import names and avoid renaming imports unless necessary
Avoid non-descriptive variable names like data, item, obj, and single-letter variable names except in loops
Avoid abbreviations in names unless they are widely understood
Avoid generic function names like fn, func, or callback

Files:

  • packages/chain-adapters/src/starknet/index.ts
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
  • packages/chain-adapters/src/starknet/utils.ts
🧠 Learnings (24)
📓 Common learnings
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/MultiHopTrade/components/TradeInput/components/HighlightedTokens.tsx:14-14
Timestamp: 2025-08-08T15:00:22.321Z
Learning: In shapeshift/web reviews for NeOMakinG, avoid nitpicks to change deep-relative imports to '@/…' alias paths within feature/non-refactor PRs; defer such style-only changes to a dedicated follow-up refactor unless they fix an issue.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10323
File: src/pages/RFOX/components/Stake/components/StakeSummary.tsx:112-114
Timestamp: 2025-08-22T13:00:44.879Z
Learning: NeOMakinG prefers to keep PR changes minimal and focused on the core objectives, avoiding cosmetic or defensive code improvements that aren't directly related to the PR scope, even when they would improve robustness.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10128
File: .cursor/rules/error-handling.mdc:266-274
Timestamp: 2025-07-29T10:35:22.059Z
Learning: NeOMakinG prefers less nitpicky suggestions on documentation and best practices files, finding overly detailed suggestions on minor implementation details (like console.error vs logger.error) too granular for cursor rules documentation.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/pages/Dashboard/components/AccountList/AccountTable.tsx:60-0
Timestamp: 2025-09-02T08:34:08.157Z
Learning: NeOMakinG prefers code review comments to focus only on actual PR changes, not pre-existing code issues, unless there are critical security or correctness concerns directly related to the new functionality.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10234
File: src/components/MultiHopTrade/hooks/useGetTradeQuotes/hooks/useTrackTradeQuotes.ts:42-86
Timestamp: 2025-08-08T11:41:22.794Z
Learning: NeOMakinG prefers not to include refactors in move-only PRs; such suggestions should be deferred to follow-up issues instead of being applied within the same PR.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/components/Table/Table.theme.ts:177-180
Timestamp: 2025-09-02T12:38:46.940Z
Learning: NeOMakinG prefers to defer technical debt and CSS correctness issues (like improper hover selectors) to follow-up PRs when the current PR is already large and focused on major feature implementation, even when the issues are valid from a usability/technical perspective.
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/index.ts : Export unique functions and types from packages/swapper/src/index.ts only if needed for external consumption

Applied to files:

  • packages/chain-adapters/src/starknet/index.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/**/*.ts : Use TypeScript with explicit types (e.g., SupportedChainIds) for all code in the Swapper system

Applied to files:

  • packages/chain-adapters/src/starknet/index.ts
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
  • packages/chain-adapters/src/starknet/utils.ts
📚 Learning: 2025-11-24T21:20:04.979Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T21:20:04.979Z
Learning: Applies to **/*.{ts,tsx} : Import types from `shapeshiftoss/caip` for chain/account/asset IDs

Applied to files:

  • packages/chain-adapters/src/starknet/index.ts
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-12-09T21:07:22.474Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11335
File: packages/swapper/src/swappers/CetusSwapper/utils/helpers.ts:3-3
Timestamp: 2025-12-09T21:07:22.474Z
Learning: In packages/swapper/src/swappers/CetusSwapper, mysten/sui types (SuiClient, Transaction) must be imported from the nested path within cetusprotocol/aggregator-sdk (e.g., 'cetusprotocol/aggregator-sdk/node_modules/mysten/sui/client') because the aggregator SDK bundles its own version of mysten/sui. Direct imports from 'mysten/sui' break at runtime even when specified in package.json.

Applied to files:

  • packages/chain-adapters/src/starknet/index.ts
📚 Learning: 2025-11-24T21:20:30.085Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/naming-conventions.mdc:0-0
Timestamp: 2025-11-24T21:20:30.085Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Use named exports for components, functions, and utilities instead of default exports

Applied to files:

  • packages/chain-adapters/src/starknet/index.ts
📚 Learning: 2025-11-12T12:49:17.895Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11016
File: packages/swapper/src/swappers/NearIntentsSwapper/swapperApi/getTradeQuote.ts:109-125
Timestamp: 2025-11-12T12:49:17.895Z
Learning: In packages/chain-adapters/src/evm/utils.ts, the getErc20Data function already includes a guard that returns an empty string when contractAddress is undefined (line 8: `if (!contractAddress) return ''`). This built-in handling means callers don't need to conditionally invoke getErc20Data—it safely handles both ERC20 tokens and native assets.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-12-04T22:57:50.850Z
Learnt from: kaladinlight
Repo: shapeshift/web PR: 11290
File: packages/chain-adapters/src/utxo/zcash/ZcashChainAdapter.ts:48-51
Timestamp: 2025-12-04T22:57:50.850Z
Learning: In packages/chain-adapters/src/**/*ChainAdapter.ts files, the getName() method uses the pattern `const enumIndex = Object.values(ChainAdapterDisplayName).indexOf(ChainAdapterDisplayName.XXX); return Object.keys(ChainAdapterDisplayName)[enumIndex]` to reverse-lookup the enum key from its value. This is the established pattern used consistently across almost all chain adapters (Bitcoin, Ethereum, Litecoin, Dogecoin, Polygon, Arbitrum, Cosmos, etc.) and should be preserved for consistency when adding new chain adapters.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2026-01-05T23:24:54.841Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11569
File: packages/chain-adapters/src/evm/katana/KatanaChainAdapter.ts:44-46
Timestamp: 2026-01-05T23:24:54.841Z
Learning: In packages/chain-adapters/src/evm/**/[chain]ChainAdapter.ts files, second-class EVM chain adapters (those extending SecondClassEvmAdapter, such as Monad, Plasma, HyperEVM, and Katana) use hardcoded strings in their getName() method (e.g., `return 'Monad'`), NOT the enum reverse-lookup pattern. The enum reverse-lookup pattern (`Object.values(ChainAdapterDisplayName).indexOf(...)`) only applies to first-class chain adapters.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-08-07T11:20:44.614Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10206
File: src/config.ts:127-128
Timestamp: 2025-08-07T11:20:44.614Z
Learning: gomesalexandre prefers required environment variables without default values in the config file (src/config.ts). They want explicit configuration and fail-fast behavior when environment variables are missing, rather than having fallback defaults.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T10:35:51.632Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/utils/tenderly/index.ts:33-45
Timestamp: 2025-09-12T10:35:51.632Z
Learning: gomesalexandre consistently dismisses CodeRabbit suggestions about replacing console.error/console.warn with structured logging in API integration code, preferring simple console logging for debugging Tenderly transaction simulation APIs in WalletConnect flows.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-10T15:35:46.223Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10458
File: src/plugins/walletConnectToDapps/components/modals/EIP155SignTypedDataConfirmation.tsx:55-55
Timestamp: 2025-09-10T15:35:46.223Z
Learning: gomesalexandre prefers fail-fast early returns over graceful degradation when critical data is missing in WalletConnect flows (like peer metadata in EIP155SignTypedDataConfirmation.tsx). He favors "safety first, always double-wrap" approach and believes missing peer metadata indicates bigger problems that should be surfaced explicitly rather than masked with partial UI rendering.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-13T16:45:17.166Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/StructuredMessage/StructuredMessage.tsx:0-0
Timestamp: 2025-09-13T16:45:17.166Z
Learning: gomesalexandre appreciates safety-focused suggestions for UI rendering in WalletConnect components, specifically defensive programming approaches that prevent null/undefined values from displaying as literal "null"/"undefined" strings in the user interface.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-17T22:40:30.149Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10569
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/WalletConnectModalSigningFooter.tsx:121-129
Timestamp: 2025-09-17T22:40:30.149Z
Learning: gomesalexandre maintains strict scope discipline even for style/UI PRs in shapeshift/web, declining functionally correct UX improvements (like keeping Cancel button enabled during gas simulation loading) when they fall outside the PR's stated styling objectives, demonstrating his consistent pattern of deferring valid but tangential improvements to separate efforts.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-11T22:53:19.837Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/EIP155TransactionConfirmation.tsx:27-31
Timestamp: 2025-09-11T22:53:19.837Z
Learning: gomesalexandre trusts Tenderly's data quality and doesn't want defensive validation for gas values (transaction?.gasLimit ?? transaction?.gas) in WalletConnect flows, preferring to rely on the external service providing valid hex values.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T13:43:50.695Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/hooks/useSimulateEvmTransaction.ts:91-95
Timestamp: 2025-09-12T13:43:50.695Z
Learning: gomesalexandre dismissed gas calculation overflow validation in useSimulateEvmTransaction hook as "stale", preferring to trust Tenderly's simulation data without defensive validation checks, consistent with his established pattern of relying on external service quality over defensive programming in WalletConnect flows.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T11:56:19.437Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/utils/tenderly/index.ts:0-0
Timestamp: 2025-09-12T11:56:19.437Z
Learning: gomesalexandre rejected verbose try/catch error handling for address validation in Tenderly integration (PR #10461), calling the approach "ugly" but still implemented safety measures in commit ad7e424b89, preferring cleaner safety implementations over defensive programming patterns.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T10:44:46.723Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T10:44:46.723Z
Learning: gomesalexandre dismissed a clipboard error handling suggestion in PR #10461 for SendTransactionContent.tsx, demonstrating that the current navigator.clipboard.writeText implementation works as expected and preferring to keep it simple without additional try/catch error handling.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-08-14T12:42:48.263Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10280
File: src/context/WalletProvider/MobileWallet/mobileMessageHandlers.ts:18-18
Timestamp: 2025-08-14T12:42:48.263Z
Learning: gomesalexandre prefers maintaining string literal patterns in the Message union type in src/context/WalletProvider/MobileWallet/mobileMessageHandlers.ts, even when there's some duplication between Command union and Message variants. They find properly typed string literals acceptable and prefer not to refactor for type hygiene in this context.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/utils/constants.ts : Define supported chain IDs for each swapper in utils/constants.ts with both 'sell' and 'buy' properties following the pattern: SupportedChainIds type

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: The ShapeShift codebase's fromBaseUnit function correctly handles hex strings (like WalletConnect transaction.value) without manual conversion because bnOrZero -> bn -> new BigNumber() automatically detects and parses hex strings starting with "0x". gomesalexandre confirmed this with concrete evidence showing hex value 0x176d1c49189db correctly converts to 0.000412118294825435 ETH.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-08-05T16:39:58.598Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10191
File: src/pages/Explore/Explore.tsx:56-56
Timestamp: 2025-08-05T16:39:58.598Z
Learning: In the ShapeShift web codebase, the established pattern for handling floating point numbers is to use BigNumber operations (bnOrZero, bn) for calculations and convert to strings using .toString() before passing to UI components like Amount.Fiat, Amount.Crypto, and Amount.Percent. This prevents JavaScript floating point precision issues and maintains consistency across the application.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-12-17T14:50:01.629Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11449
File: packages/chain-adapters/src/tron/TronChainAdapter.ts:570-596
Timestamp: 2025-12-17T14:50:01.629Z
Learning: In packages/chain-adapters/src/tron/TronChainAdapter.ts, the parseTx method uses `unknown` type for the txHashOrTx parameter intentionally. TRON is a "second-class chain" that works differently from other chains - it accepts either a string hash (to fetch TronTx via unchained client) or a TronTx object directly. The base chain-adapter interface is strongly typed and doesn't accommodate this flexible signature, so `unknown` is used as an appropriate escape hatch rather than a type safety issue.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: gomesalexandre confirmed that fromBaseUnit in the ShapeShift codebase correctly handles hex strings (like transaction.value from WalletConnect) without requiring manual hex-to-decimal conversion, as bnOrZero handles this automatically via BigNumber.js.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
🧬 Code graph analysis (2)
packages/chain-adapters/src/starknet/StarknetChainAdapter.ts (3)
packages/chain-adapters/src/types.ts (1)
  • FeeDataEstimate (122-126)
packages/chain-adapters/src/starknet/utils.ts (4)
  • OPENZEPPELIN_ACCOUNT_CLASS_HASH (11-12)
  • calculateFeeTiers (35-87)
  • STATIC_FEE_ESTIMATES (17-24)
  • STRK_TOKEN_ADDRESS (7-8)
packages/chain-adapters/src/starknet/types.ts (3)
  • RpcJsonResponse (39-45)
  • StarknetFeeEstimate (49-56)
  • StarknetNonceResult (47-47)
packages/chain-adapters/src/starknet/utils.ts (1)
packages/chain-adapters/src/types.ts (1)
  • FeeDataEstimate (122-126)
🪛 Gitleaks (8.30.0)
packages/chain-adapters/src/starknet/utils.ts

[high] 7-8: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Install and Cache
🔇 Additional comments (10)
packages/chain-adapters/src/starknet/index.ts (1)

1-3: LGTM!

The export addition correctly exposes the new utilities module, following the existing pattern for re-exports in this index file.

packages/chain-adapters/src/starknet/utils.ts (2)

35-87: LGTM!

The fee tier calculation logic is sound. The multipliers provide appropriate headroom for each tier, and the use of bnOrZero safely handles hex string inputs for BigNumber arithmetic.


6-8: False positive: This is a public contract address, not a secret.

The static analysis tool incorrectly flagged this as a "Generic API Key". This is the STRK token contract address on Starknet mainnet — documented in official Starknet documentation and publicly listed on multiple token data sources. Public blockchain contract addresses are not credentials.

packages/chain-adapters/src/starknet/StarknetChainAdapter.ts (7)

44-49: LGTM!

Imports are correctly consolidated from the new utils module, aligning with the refactor to centralize Starknet constants and helpers.


330-451: Well-structured deploy account fee estimation method.

The implementation correctly handles both deployed and undeployed account scenarios with appropriate fallback to static estimates when RPC estimation fails for undeployed accounts. The error handling via ErrorHandler wrapper is consistent with the codebase patterns.


600-626: Good balance validation before deployment.

The balance check correctly calculates the total max fee from all resource bounds and provides a clear error message when funds are insufficient. This prevents failed deployment transactions.


1250-1254: Core fix: Early return with static estimates for undeployed accounts.

This addresses the PR objective - undeployed accounts cannot use INVOKE-based fee estimation because they have no on-chain state. Returning static estimates prevents the fee estimation failures described in the PR.


1034-1039: LGTM!

The conditional spread pattern correctly passes through the optional pubKey to the transaction output when provided.


868-879: LGTM!

The try/catch pattern gracefully handles nonce fetch failures for undeployed accounts, correctly defaulting to '0x0' which is the initial nonce.


1294-1301: Good consolidation using shared utility.

Using calculateFeeTiers from the utils module eliminates code duplication and ensures consistent fee tier calculation across all methods.


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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/chain-adapters/src/starknet/StarknetChainAdapter.ts (1)

604-693: Critical: resourceBounds may be undefined.

The resourceBounds variable is declared at line 604 but not initialized. If the try-catch block at lines 629-693 completes without setting resourceBounds (e.g., all paths fail), the variable will be undefined when accessed at line 695+, causing a runtime error.

🐛 Proposed fix

Initialize resourceBounds with default values or ensure it's always set:

-      let resourceBounds: {
-        l1_gas: { max_amount: bigint; max_price_per_unit: bigint }
-        l2_gas: { max_amount: bigint; max_price_per_unit: bigint }
-        l1_data_gas: { max_amount: bigint; max_price_per_unit: bigint }
-      }
+      let resourceBounds: {
+        l1_gas: { max_amount: bigint; max_price_per_unit: bigint }
+        l2_gas: { max_amount: bigint; max_price_per_unit: bigint }
+        l1_data_gas: { max_amount: bigint; max_price_per_unit: bigint }
+      } | undefined

       // ... estimation code ...

+      if (!resourceBounds) {
+        throw new Error('Failed to estimate resource bounds for account deployment')
+      }
+
       const totalMaxFee =

Or ensure resourceBounds is always assigned in the catch block by moving the static fallback inside:

       } catch (error) {
         console.log(
           '[StarknetChainAdapter.deployAccount] RPC estimation failed, using static estimates:',
           error,
         )
-      }

-      const {
-        l1GasConsumed,
-        l1GasPrice,
-        l2GasConsumed,
-        l2GasPrice,
-        l1DataGasConsumed,
-        l1DataGasPrice,
-      } = STATIC_FEE_ESTIMATES

-      resourceBounds = {
-        l1_gas: {
-          max_amount: BigInt(bnOrZero(l1GasConsumed).times(1.5).toFixed(0)),
-          max_price_per_unit: BigInt(bnOrZero(l1GasPrice).times(1.5).toFixed(0)),
-        },
-        l2_gas: {
-          max_amount: BigInt(bnOrZero(l2GasConsumed).times(1.5).toFixed(0)),
-          max_price_per_unit: BigInt(bnOrZero(l2GasPrice).times(1.5).toFixed(0)),
-        },
-        l1_data_gas: {
-          max_amount: BigInt(bnOrZero(l1DataGasConsumed).times(1.5).toFixed(0)),
-          max_price_per_unit: BigInt(bnOrZero(l1DataGasPrice).times(1.5).toFixed(0)),
-        },
-      }
+
+        const {
+          l1GasConsumed,
+          l1GasPrice,
+          l2GasConsumed,
+          l2GasPrice,
+          l1DataGasConsumed,
+          l1DataGasPrice,
+        } = STATIC_FEE_ESTIMATES
+
+        resourceBounds = {
+          l1_gas: {
+            max_amount: BigInt(bnOrZero(l1GasConsumed).times(1.5).toFixed(0)),
+            max_price_per_unit: BigInt(bnOrZero(l1GasPrice).times(1.5).toFixed(0)),
+          },
+          l2_gas: {
+            max_amount: BigInt(bnOrZero(l2GasConsumed).times(1.5).toFixed(0)),
+            max_price_per_unit: BigInt(bnOrZero(l2GasPrice).times(1.5).toFixed(0)),
+          },
+          l1_data_gas: {
+            max_amount: BigInt(bnOrZero(l1DataGasConsumed).times(1.5).toFixed(0)),
+            max_price_per_unit: BigInt(bnOrZero(l1DataGasPrice).times(1.5).toFixed(0)),
+          },
+        }
+      }
🤖 Fix all issues with AI agents
In @packages/chain-adapters/src/starknet/StarknetChainAdapter.ts:
- Around line 441-458: The estimateTx object is duplicated in both the
undeployed and deployed code paths; extract its construction into a single
helper (e.g., createEstimateTx or buildEstimateTx) that accepts the varying
inputs (formattedSalt, formattedCalldata, nonce, version, and any constants like
OPENZEPPELIN_ACCOUNT_CLASS_HASH) and returns the common object (including
resource_bounds, tip, paymaster_data, nonce_data_availability_mode,
fee_data_availability_mode). Replace the two inline estimateTx definitions with
calls to that helper to eliminate duplication and keep the identical fields
centralized for easier maintenance.
🧹 Nitpick comments (1)
packages/chain-adapters/src/starknet/StarknetChainAdapter.ts (1)

440-495: Consider consistent error handling for deployed and undeployed accounts.

The undeployed account path (lines 440-495) gracefully falls back to static estimates when RPC estimation fails, but the deployed account path (lines 497-540) throws an error. This inconsistency could lead to unexpected failures for users with deployed accounts when the RPC is temporarily unavailable.

Consider applying the same fallback strategy to both paths for consistent user experience.

♻️ Suggested approach for consistency

Wrap the deployed account RPC estimation (lines 516-540) in a try-catch block similar to the undeployed path:

-      const estimateResponse = await this.provider.fetch('starknet_estimateFee', [
-        [estimateTx],
-        ['SKIP_VALIDATE'],
-        'latest',
-      ])
-      const estimateResult: RpcJsonResponse<StarknetFeeEstimate[]> = await estimateResponse.json()
-
-      if (estimateResult.error) {
-        const errorMessage = estimateResult.error.message || JSON.stringify(estimateResult.error)
-        throw new Error(`Fee estimation failed: ${errorMessage}`)
-      }
-
-      const feeEstimate = estimateResult.result?.[0]
-      if (!feeEstimate) {
-        throw new Error('Fee estimation failed: no estimate returned')
-      }
-
-      return calculateFeeTiers({
-        l1GasConsumed: feeEstimate.l1_gas_consumed ?? '0x186a0',
-        l1GasPrice: feeEstimate.l1_gas_price ?? '0x5f5e100',
-        l2GasConsumed: feeEstimate.l2_gas_consumed ?? '0x0',
-        l2GasPrice: feeEstimate.l2_gas_price ?? '0x0',
-        l1DataGasConsumed: feeEstimate.l1_data_gas_consumed ?? '0x186a0',
-        l1DataGasPrice: feeEstimate.l1_data_gas_price ?? '0x1',
-      })
+      try {
+        const estimateResponse = await this.provider.fetch('starknet_estimateFee', [
+          [estimateTx],
+          ['SKIP_VALIDATE'],
+          'latest',
+        ])
+        const estimateResult: RpcJsonResponse<StarknetFeeEstimate[]> = await estimateResponse.json()
+
+        if (!estimateResult.error && estimateResult.result?.[0]) {
+          const feeEstimate = estimateResult.result[0]
+          return calculateFeeTiers({
+            l1GasConsumed: feeEstimate.l1_gas_consumed ?? '0x186a0',
+            l1GasPrice: feeEstimate.l1_gas_price ?? '0x5f5e100',
+            l2GasConsumed: feeEstimate.l2_gas_consumed ?? '0x0',
+            l2GasPrice: feeEstimate.l2_gas_price ?? '0x0',
+            l1DataGasConsumed: feeEstimate.l1_data_gas_consumed ?? '0x186a0',
+            l1DataGasPrice: feeEstimate.l1_data_gas_price ?? '0x1',
+          })
+        }
+      } catch (error) {
+        console.log(
+          '[StarknetChainAdapter.getDeployAccountFeeData] RPC estimation failed for deployed account, using static estimates:',
+          error,
+        )
+      }
+
+      console.log(
+        '[StarknetChainAdapter.getDeployAccountFeeData] Using static estimates for deployed account',
+      )
+      return calculateFeeTiers(STATIC_FEE_ESTIMATES)
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7d6df51 and fbe1dc8.

📒 Files selected for processing (1)
  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Never assume a library is available - always check imports/package.json first
Prefer composition over inheritance
Write self-documenting code with clear variable and function names
Keep functions small and focused on a single responsibility
Avoid deep nesting - use early returns instead
Prefer procedural and easy to understand code
Never expose, log, or commit secrets, API keys, or credentials
Validate all inputs, especially user inputs
Handle errors gracefully with meaningful messages
Don't silently catch and ignore exceptions
Log errors appropriately for debugging
Provide fallback behavior when possible
Use appropriate data structures for the task
Never add code comments unless explicitly requested
When modifying code, do not add comments that reference previous implementations or explain what changed. Comments should only describe the current logic and functionality.
Use meaningful names for branches, variables, and functions
Always run yarn lint --fix and yarn type-check after making changes
Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic

Files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid useEffect where practical - use it only when necessary and following best practices
Avoid 'any' types - use specific type annotations instead
For default values with user overrides, use computed values (useMemo) instead of useEffect - pattern: userSelected ?? smartDefault ?? fallback
When function parameters are unused due to interface requirements, refactor the interface or implementation to remove them rather than prefixing with underscore
Sanitize data before displaying to prevent XSS
Memoize aggressively - wrap component variables in useMemo and callbacks in useCallback where possible
For static JSX icon elements (e.g., <TbCopy />) that don't depend on state/props, define them as constants outside the component to avoid re-renders instead of using useMemo
Account for light/dark mode using useColorModeValue hook
Account for responsive mobile designs in all UI components
When applying styles, use the existing standards and conventions of the codebase
Use Chakra UI components and conventions
All copy/text must use translation keys - never hardcode strings
Use the translation hook: useTranslate() from react-polyglot
Use useFeatureFlag('FlagName') hook to access feature flag values in components
Prefer type over interface for type definitions
Use strict typing - avoid any
Use Nominal types for domain identifiers (e.g., WalletId, AccountId)
Import types from @shapeshiftoss/caip for chain/account/asset IDs
Use useAppSelector for Redux state
Use useAppDispatch for Redux actions
Memoize expensive computations with useMemo
Memoize callbacks with useCallback

**/*.{ts,tsx}: Use Result<T, E> pattern for error handling in swappers and APIs; ALWAYS use Ok() and Err() from @sniptt/monads; AVOID throwing within swapper API implementations
ALWAYS use custom error classes from @shapeshiftoss/errors with meaningful error codes for internationalization and relevant details in error objects
ALWAYS wrap async op...

Files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variables, functions, and methods with descriptive names that explain the purpose
Use verb prefixes for functions that perform actions (e.g., fetch, validate, execute, update, calculate)
Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names
Use handle prefix for event handlers with descriptive names in camelCase
Use descriptive boolean variable names with is, has, can, should prefixes
Use named exports for components, functions, and utilities instead of default exports
Use descriptive import names and avoid renaming imports unless necessary
Avoid non-descriptive variable names like data, item, obj, and single-letter variable names except in loops
Avoid abbreviations in names unless they are widely understood
Avoid generic function names like fn, func, or callback

Files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10323
File: src/pages/RFOX/components/Stake/components/StakeSummary.tsx:112-114
Timestamp: 2025-08-22T13:00:44.879Z
Learning: NeOMakinG prefers to keep PR changes minimal and focused on the core objectives, avoiding cosmetic or defensive code improvements that aren't directly related to the PR scope, even when they would improve robustness.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10128
File: .cursor/rules/error-handling.mdc:266-274
Timestamp: 2025-07-29T10:35:22.059Z
Learning: NeOMakinG prefers less nitpicky suggestions on documentation and best practices files, finding overly detailed suggestions on minor implementation details (like console.error vs logger.error) too granular for cursor rules documentation.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/pages/Dashboard/components/AccountList/AccountTable.tsx:60-0
Timestamp: 2025-09-02T08:34:08.157Z
Learning: NeOMakinG prefers code review comments to focus only on actual PR changes, not pre-existing code issues, unless there are critical security or correctness concerns directly related to the new functionality.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10234
File: src/components/MultiHopTrade/hooks/useGetTradeQuotes/hooks/useTrackTradeQuotes.ts:42-86
Timestamp: 2025-08-08T11:41:22.794Z
Learning: NeOMakinG prefers not to include refactors in move-only PRs; such suggestions should be deferred to follow-up issues instead of being applied within the same PR.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10380
File: src/components/Table/Table.theme.ts:177-180
Timestamp: 2025-09-02T12:38:46.940Z
Learning: NeOMakinG prefers to defer technical debt and CSS correctness issues (like improper hover selectors) to follow-up PRs when the current PR is already large and focused on major feature implementation, even when the issues are valid from a usability/technical perspective.
📚 Learning: 2025-11-24T21:20:04.979Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-24T21:20:04.979Z
Learning: Applies to **/*.{ts,tsx} : Import types from `shapeshiftoss/caip` for chain/account/asset IDs

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/src/swappers/*/utils/constants.ts : Define supported chain IDs for each swapper in utils/constants.ts with both 'sell' and 'buy' properties following the pattern: SupportedChainIds type

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: The ShapeShift codebase's fromBaseUnit function correctly handles hex strings (like WalletConnect transaction.value) without manual conversion because bnOrZero -> bn -> new BigNumber() automatically detects and parses hex strings starting with "0x". gomesalexandre confirmed this with concrete evidence showing hex value 0x176d1c49189db correctly converts to 0.000412118294825435 ETH.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-08-05T16:39:58.598Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10191
File: src/pages/Explore/Explore.tsx:56-56
Timestamp: 2025-08-05T16:39:58.598Z
Learning: In the ShapeShift web codebase, the established pattern for handling floating point numbers is to use BigNumber operations (bnOrZero, bn) for calculations and convert to strings using .toString() before passing to UI components like Amount.Fiat, Amount.Crypto, and Amount.Percent. This prevents JavaScript floating point precision issues and maintains consistency across the application.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-11-24T21:20:57.909Z
Learnt from: CR
Repo: shapeshift/web PR: 0
File: .cursor/rules/swapper.mdc:0-0
Timestamp: 2025-11-24T21:20:57.909Z
Learning: Applies to packages/swapper/**/*.ts : Use TypeScript with explicit types (e.g., SupportedChainIds) for all code in the Swapper system

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-09-12T12:04:59.556Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T12:04:59.556Z
Learning: gomesalexandre confirmed that fromBaseUnit in the ShapeShift codebase correctly handles hex strings (like transaction.value from WalletConnect) without requiring manual hex-to-decimal conversion, as bnOrZero handles this automatically via BigNumber.js.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
📚 Learning: 2025-12-17T14:50:01.629Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11449
File: packages/chain-adapters/src/tron/TronChainAdapter.ts:570-596
Timestamp: 2025-12-17T14:50:01.629Z
Learning: In packages/chain-adapters/src/tron/TronChainAdapter.ts, the parseTx method uses `unknown` type for the txHashOrTx parameter intentionally. TRON is a "second-class chain" that works differently from other chains - it accepts either a string hash (to fetch TronTx via unchained client) or a TronTx object directly. The base chain-adapter interface is strongly typed and doesn't accommodate this flexible signature, so `unknown` is used as an appropriate escape hatch rather than a type safety issue.

Applied to files:

  • packages/chain-adapters/src/starknet/StarknetChainAdapter.ts
🔇 Additional comments (7)
packages/chain-adapters/src/starknet/StarknetChainAdapter.ts (7)

8-8: LGTM! Well-chosen fallback values for deployment estimation.

The static fee estimates provide reasonable defaults when RPC estimation fails, and the bnOrZero import enables safe BigNumber operations throughout the fee calculation logic.

Also applies to: 57-67


695-721: LGTM! Proper balance validation before deployment.

The balance check correctly calculates the total max fee across all resource types and provides clear error messaging when insufficient funds are detected. The detailed logging will help with debugging deployment issues.


343-356: LGTM! Correct ValidAddressResult format.

The method now properly returns the expected ValidAddressResult type with both valid boolean and result enum value in all cases.


1345-1349: Verify the early return behavior for undeployed accounts in getFeeData.

The getFeeData method now returns static deployment estimates for undeployed accounts (lines 1345-1349). However, getFeeData is typically called for regular INVOKE transactions (transfers), not DEPLOY_ACCOUNT transactions.

This could lead to:

  1. Displaying deployment-level fees to users attempting a transfer on an undeployed account
  2. Confusion when the actual transfer operation requires deployment first

Consider whether:

  • This early return should throw an error indicating the account must be deployed first
  • Or if there should be a separate parameter indicating whether deployment fees are needed
  • Or if this is intentional because the UI should trigger deployment before allowing transfers

Please verify this matches the intended user flow for undeployed accounts attempting transfers.


1122-1140: LGTM! Correct optional pubKey merging.

The conditional spread operator correctly preserves the pubKey when provided in the input without affecting the default behavior when it's absent.


963-974: LGTM! Defensive nonce fetching with appropriate fallback.

The try-catch wrapper correctly handles cases where nonce fetching fails (e.g., account not deployed) by falling back to '0x0', which is the expected nonce for new accounts.


69-126: Use dynamic, configurable fee multipliers aligned with Starknet best practices.

The fee multiplier strategy uses aggressive fixed values (3x for average, 5x for fast) that exceed Starknet's recommended defaults (1.5x for routine flows). Starknet best practices recommend:

  • Dynamic multipliers adjusted based on network congestion and recent block prices
  • Separate, per-resource configuration (tuning multipliers per L1 gas, L2 gas, and L1 data gas separately)
  • Conservative defaults (1.5x) for routine user flows, with higher values (~2.0+) only when high inclusion certainty is required
  • Caps and validation to prevent overflow or runaway costs
  • Considering tips as an alternative to massive multiplier inflation for priority tuning

Refactor this to use configurable multipliers rather than hardcoded values, and consider exposing tuneable parameters per resource type and speed tier.

⛔ Skipped due to learnings
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10810
File: src/plugins/walletConnectToDapps/utils/tenderly/index.ts:212-0
Timestamp: 2025-10-15T15:57:39.956Z
Learning: gomesalexandre uses discriminated union patterns (e.g., `isEIP1559 ? { max_fee_per_gas, max_priority_fee_per_gas } : { gas_price }`) in WalletConnect flows without additional validation guards, trusting that the runtime data structure ensures mutual exclusivity between EIP-1559 and legacy gas pricing fields.

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

Functionally does the thing https://jam.dev/c/634372f5-cb56-4a28-a033-1c6d53b041bb

Could probably do with moving the heavy duty away to utils and tackle coderabbit comment at your convenience

@NeOMakinG
Copy link
Collaborator Author

Addressed the review feedback:

  1. Extracted duplicated estimateTx object - Moved the definition before the if (!isDeployed) block so it's shared by both code paths, eliminating the duplication.

  2. Removed debug console.log - Removed the RPC estimate logging for undeployed accounts.

Both yarn lint --fix and yarn type-check pass.

@NeOMakinG
Copy link
Collaborator Author

Also moved the heavy duty helpers out to packages/chain-adapters/src/starknet/utils.ts:

  • STRK_TOKEN_ADDRESS constant
  • OPENZEPPELIN_ACCOUNT_CLASS_HASH constant
  • STATIC_FEE_ESTIMATES constant
  • calculateFeeTiers() function

This keeps the adapter file focused on the core adapter logic.

@NeOMakinG NeOMakinG enabled auto-merge (squash) January 12, 2026 09:37
@NeOMakinG NeOMakinG merged commit fb12106 into develop Jan 12, 2026
4 checks passed
@NeOMakinG NeOMakinG deleted the starknet-fixes branch January 12, 2026 09:42
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.

2 participants