Skip to content

feat: integrate Story (1514) as second-class Relay chain#11936

Merged
gomesalexandre merged 7 commits intodevelopfrom
feat/integrate-story-relay
Feb 22, 2026
Merged

feat: integrate Story (1514) as second-class Relay chain#11936
gomesalexandre merged 7 commits intodevelopfrom
feat/integrate-story-relay

Conversation

@NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Feb 18, 2026

Description

Add support for Story (EVM chain, chainId 1514) as a second-class citizen. Story is an EVM-compatible Layer 1 blockchain for intellectual property, with IP as its native token.

This is PR 12 of 17 in a sequential chain integration series. These PRs must be reviewed and merged in order, as each builds on the previous one (stacked branches).

PR merge order:

  1. Mantle (feat: integrate Mantle (chainId 5000) as second-class EVM chain #11905)
  2. Cronos (feat: integrate Cronos (chainId 25) as second-class EVM chain #11910)
  3. Sonic (feat: integrate Sonic (eip155:146) as second-class EVM chain #11923)
  4. Unichain (feat: integrate Unichain (eip155:130) as second-class citizen via Relay #11924)
  5. BOB (feat: integrate BOB (eip155:60808) as second-class citizen #11925)
  6. Mode (feat: integrate Mode (eip155:34443) as second-class citizen #11926)
  7. Soneium (feat: integrate Soneium (chainId: 1868) via Relay #11930)
  8. Hemi (feat: integrate Hemi (chainId: 43111) via Relay #11931)
  9. World Chain (feat: integrate World Chain (480) as second-class Relay chain #11932)
  10. Blast (feat: integrate Blast (81457) as second-class Relay chain #11933)
  11. zkSync Era (feat: integrate zkSync Era (324) as second-class Relay chain #11934)
  12. Story (feat: integrate Story (1514) as second-class Relay chain #11936) ← this PR
  13. Plume (feat: integrate Plume (98866) as second-class Relay chain #11937)
  14. Flow EVM (feat: integrate Flow EVM (747) as second-class Relay chain #11938)
  15. Celo (feat: integrate Celo (42220) as second-class Relay chain #11939)
  16. Ethereal (feat: integrate Ethereal (5064014) as second-class Relay chain #11940)

Note: Linea (#11922) is already in develop.

Implements: CAIP constants, chain adapter (SecondClassEvmAdapter), plugin, feature flag, Relay swapper mapping, HDWallet support flags, CSP headers, asset generation script, viem/ethers client configuration, CoinGecko price feed integration, Zerion portfolio tracking, and all required shared-file entries.

Issue (if applicable)

Part of #11902

Risk

Low - All changes are behind the Story feature flag (VITE_FEATURE_STORY), disabled by default in production.

No new on-chain transactions or contract interactions. Standard EVM chain support using existing SecondClassEvmAdapter pattern.

No protocols, transaction types, wallets or contract interactions are affected until the feature flag is enabled.

Testing

Engineering

  1. Set VITE_FEATURE_STORY=true in .env.development
  2. Run yarn dev
  3. Verify Story appears in chain selector
  4. Verify native IP token balance loads
  5. Verify Relay swap routes include Story
  6. Run yarn lint — passes with 0 errors
  7. Run yarn type-check — verify no new type errors

Operations

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

Screenshots (if applicable)

N/A - Behind feature flag, no visual changes until enabled.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for the Story network as a new blockchain platform.
    • Story assets are now available for trading and portfolio management.
    • Story network can be selected and used across the application.
  • Configuration

    • Added environment configuration for Story network connectivity.
    • Introduced a feature flag to control Story network availability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This PR adds comprehensive support for the Story blockchain (chainId: eip155:1514) across the ShapeShift application. Changes include CAIP constants, EVM chain adapters, wallet capability flags, environment configuration, feature flags, asset generation scripts, CSP headers, blockchain clients, state management, plugin registration, and UI updates for a second-class EVM chain.

Changes

Cohort / File(s) Summary
Environment & Configuration
.env, .env.development, src/config.ts, src/vite-env.d.ts
Added VITE_STORY_NODE_URL (node endpoint) and VITE_FEATURE_STORY flag (defaults to false) with type validation.
CSP Headers
headers/csps/chains/story.ts, headers/csps/index.ts
New CSP module for Story chain with connect-src directive; integrated into main CSP exports.
Type System & CAIP Constants
packages/types/src/base.ts, packages/caip/src/constants.ts, packages/types/src/zerion.ts
Added KnownChainIds.StoryMainnet (eip155:1514), CAIP mappings (storyChainId, storyAssetId), chain references, and Zerion chain support.
CoinGecko Adapter
packages/caip/src/adapters/coingecko/index.ts, packages/caip/src/adapters/coingecko/utils.ts, packages/caip/src/adapters/coingecko/utils.test.ts
Extended mappings for Story platform in CoingeckoAssetPlatform enum; added ERC-20 asset parsing and test expectations.
EVM Chain Adapters
packages/chain-adapters/src/evm/EvmBaseAdapter.ts, packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts, packages/chain-adapters/src/evm/types.ts, packages/chain-adapters/src/evm/story/*, packages/chain-adapters/src/evm/index.ts
New StoryChainAdapter (second-class EVM), integrated into EvmBaseAdapter with capability checks, metadata, and wrapped native contract mappings; updated type definitions for chain-specific data.
Blockchain Clients
packages/contracts/src/viemClient.ts, packages/contracts/src/ethersProviderSingleton.ts
Created viemStoryClient and integrated into client mappings by chainId/networkId; added RPC URL support via environment variable.
Wallet Implementations - Support Flags
packages/hdwallet-coinbase/src/coinbase.ts, packages/hdwallet-core/src/ethereum.ts, packages/hdwallet-core/src/wallet.ts, packages/hdwallet-gridplus/src/gridplus.ts, packages/hdwallet-keepkey/src/keepkey.ts, packages/hdwallet-ledger/src/ledger.ts, packages/hdwallet-metamask-multichain/src/shapeshift-multichain.ts, packages/hdwallet-native/src/ethereum.ts, packages/hdwallet-phantom/src/phantom.ts, packages/hdwallet-trezor/src/trezor.ts, packages/hdwallet-vultisig/src/vultisig.ts, packages/hdwallet-walletconnectv2/src/walletconnectV2.ts
Added _supportsStory capability flag (true for Ledger, Trezor, MetaMask Multichain, Native; false for others); exported type guard supportsStory() in hdwallet-core.
Asset Data & Utilities
packages/utils/src/assetData/baseAssets.ts, packages/utils/src/assetData/getBaseAsset.ts, packages/utils/src/chainIdToFeeAssetId.ts, packages/utils/src/getAssetNamespaceFromChainId.ts, packages/utils/src/getChainShortName.ts, packages/utils/src/getNativeFeeAssetReference.ts
Added story asset definition with metadata (symbol IP, color #EA580C, explorer storyscan.xyz); integrated into asset lookups, fee asset mappings, and namespace resolution.
Asset Generation Scripts
scripts/generateAssetData/coingecko.ts, scripts/generateAssetData/generateAssetData.ts, scripts/generateAssetData/story/index.ts, scripts/generateAssetData/generateRelatedAssetIndex/generateChainRelatedAssetIndex.ts, scripts/generateAssetData/generateRelatedAssetIndex/generateRelatedAssetIndex.ts
New story asset generation module; integrated into asset aggregation pipeline; reordered related asset mappings for ethAssetId; added comment clarification for stablecoin mappings.
Swapper Integration
packages/swapper/src/swappers/RelaySwapper/constant.ts, packages/swapper/src/swappers/RelaySwapper/utils/relayTokenToAssetId.ts
Added storyChainId to Relay chain mappings; integrated StoryMainnet case in token-to-assetId conversion.
State Management & Feature Flags
src/state/slices/preferencesSlice/preferencesSlice.ts, src/state/slices/opportunitiesSlice/mappings.ts, src/state/slices/portfolioSlice/utils/index.ts, src/state/migrations/index.ts, src/constants/chains.ts, src/context/PluginProvider/PluginProvider.tsx
Added Story to featureFlags type and initial state; registered in SECOND_CLASS_CHAINS with feature-flag gating; extended DeFi opportunities mapping; added wallet support checks in portfolio utilities; introduced migration 303 for asset clearing.
Hooks & Services
src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts, src/lib/account/evm.ts, src/lib/asset-service/service/AssetService.ts, src/lib/coingecko/utils.ts
Integrated storyChainId into wallet support checks, account derivation, asset filtering, and CoinGecko supported chains (all gated by VITE_FEATURE_STORY).
Plugin & UI Integration
src/plugins/activePlugins.ts, src/plugins/story/index.tsx, src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx, src/pages/Markets/components/MarketsRow.tsx
Registered story plugin with chain adapter configuration (RPC URL, token discovery callback); added storyAssetId to popular assets; integrated feature-flag checks in market UI.
Data Files & Test Mocks
.beads/ss-dx5.16.json, src/test/mocks/store.ts
Added new task entry for Story integration; added Story feature flag to Redux mock state (defaults to false).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~55 minutes

Possibly related PRs

  • #11926 — Adds Mode (another second-class EVM chain) with identical integration pattern across chain adapters, wallet support flags, CSP headers, and state management.
  • #11925 — Adds BOB (another second-class EVM chain) following the same code-level changes for CAIP constants, viem/ethers clients, chain adapters, and wallet implementations.
  • #11569 — Adds Katana (another second-class EVM chain) with parallel modifications to CSP modules, constants, adapters, swapper paths, and plugin registration.

Suggested labels

high risk


🐰 A new chain hops into our garden fair,
Story's support blooms everywhere!
With tokens, adapters, wallets in tow,
Our ecosystem continues to grow. 🌱✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and specifically describes the main change: adding Story (chainId 1514) as a second-class Relay chain with feature gating.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/integrate-story-relay

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.

gomesalexandre and others added 3 commits February 22, 2026 18:39
- fix duplicate imports across ~15 files from merge conflict resolution
- fix merged lines in .env/.env.development (split node URLs/feature flags)
- fix no-dupe-keys in baseAssets.ts (sonic, unichain, BOB, mode icons)
- fix wallet.ts broken supportsBlast/supportsWorldChain/supportsHemi functions
- fix coingecko index.test.ts duplicate ethOnBob/ethOnZkSyncEra entries
- fix market service test destructuring (27 → 17 unique entries)
- fix generateRelatedAssetIndex.ts duplicate ethAssetId entries
- add missing clearAssets migration 303 for story chain
- add missing VITE_FEATURE_STORY + VITE_STORY_NODE_URL to vite-env.d.ts
- fix story native IP relatedAssetKey (was pointing to ETH, should be null)
- remove storyAssetId from ethAssetId group in both relatedAssetIndex scripts
- add WIP (0x1514...0000) to WRAPPED_NATIVE_CONTRACT_BY_CHAIN_ID for story
- regenerate story assets with correct relatedAssetKey=null for native IP

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- restore blank lines removed from utils.ts, baseAssets.ts, coingecko.test.ts, vite-env.d.ts
- fix story/zkSyncEra/blast/hemi/sonic blocks merged into one line in utils.ts parseData
- story tx status uses generic default handler in useSendActionSubscriber (is second-class evm)
- rm story.ts util (redundant - no individual handler needed)
- revert comment change in generateChainRelatedAssetIndex.ts
- rm duplicate expect() calls in coingecko.test.ts (merge artifacts)

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@gomesalexandre gomesalexandre marked this pull request as ready for review February 22, 2026 20:36
@gomesalexandre gomesalexandre requested a review from a team as a code owner February 22, 2026 20:36
useSendActionSubscriber had all individual evm chain cases from a bad
merge - develop already collapsed them all to default handler, restore
to match develop exactly (story uses default, no diff needed there)

coingecko.test.ts: two more blank lines restored

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
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.

Ditto will test this in a few PRs alongside others, diff looking gucci though!

@gomesalexandre gomesalexandre enabled auto-merge (squash) February 22, 2026 20:42
@gomesalexandre gomesalexandre merged commit 3511df3 into develop Feb 22, 2026
5 of 6 checks passed
@gomesalexandre gomesalexandre deleted the feat/integrate-story-relay branch February 22, 2026 20:52
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: 3

Caution

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

⚠️ Outside diff range comments (1)
scripts/generateAssetData/generateRelatedAssetIndex/generateChainRelatedAssetIndex.ts (1)

87-96: ⚠️ Potential issue | 🟡 Minor

Comment is missing Sonic — update to "Linea + Mantle + Sonic".

The updated comment on line 87 reads // Native stablecoins on Linea + Mantle … but both the USDC group (lines 88–92) and the USDT group (lines 93–97) already contain a Sonic entry (eip155:146), making the comment incomplete.

📝 Proposed fix
-  // Native stablecoins on Linea + Mantle - CoinGecko doesn't tag these as bridged categories
+  // Native stablecoins on Linea + Mantle + Sonic - CoinGecko doesn't tag these as bridged categories
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@scripts/generateAssetData/generateRelatedAssetIndex/generateChainRelatedAssetIndex.ts`
around lines 87 - 96, Update the inline comment above the USDC/USDT mappings to
accurately reflect included chains by changing "// Native stablecoins on Linea +
Mantle - CoinGecko doesn't tag these as bridged categories" to include Sonic
(e.g. "Linea + Mantle + Sonic") so it matches the entries like
'eip155:146/erc20:...' present in the USDC and USDT groups
('eip155:1/erc20:0xa0b8...' and 'eip155:1/erc20:0xdac1...').
🧹 Nitpick comments (2)
.env (1)

330-330: Optional: dotenv-linter ordering warning — VITE_FEATURE_STORY should precede VITE_FEATURE_SUNIO_SWAP alphabetically.

The linter flags this because STORY sorts before SUNIO across the file. Not a correctness issue since the file uses semantic sections, but worth addressing if the project enforces this linter rule.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env at line 330, The .env has VITE_FEATURE_STORY placed after
VITE_FEATURE_SUNIO_SWAP which triggers dotenv-linter alphabetical-order
warnings; move the VITE_FEATURE_STORY entry so its key appears before
VITE_FEATURE_SUNIO_SWAP (i.e., reorder the lines involving VITE_FEATURE_STORY
and VITE_FEATURE_SUNIO_SWAP) to satisfy the linter while keeping the same value.
.env.development (1)

121-121: Optional: dotenv-linter ordering warning — VITE_FEATURE_STORY should precede VITE_FEATURE_WC_DIRECT_CONNECTION alphabetically.

Both keys are in the same feature-flags section here (unlike the .env case), so the ordering violation is more straightforward. STORY sorts before WC_DIRECT_CONNECTION.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.development at line 121, Reorder the two environment keys in
.env.development so they follow dotenv-linter alphabetical rules: move
VITE_FEATURE_STORY to appear before VITE_FEATURE_WC_DIRECT_CONNECTION; update
the feature-flags section so the lines read with VITE_FEATURE_STORY first and
then VITE_FEATURE_WC_DIRECT_CONNECTION to resolve the ordering warning.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/caip/src/adapters/coingecko/utils.test.ts`:
- Around line 194-196: The test expectation currently asserts that the CoinGecko
ID for 'eip155:1514/slip44:60' is 'story-2', but the utils bug will change the
mapped ID to 'story'; update the assertion in
packages/caip/src/adapters/coingecko/utils.test.ts to expect 'story' instead of
'story-2' for the key 'eip155:1514/slip44:60' (adjust any related fixtures or
expected maps that reference the old 'story-2' value).

In `@packages/caip/src/adapters/coingecko/utils.ts`:
- Line 625: Replace the incorrect CoinGecko ID 'story-2' with the correct
'story' in the mapping entry where the keys are [storyChainId] and
[storyAssetId] (the object currently written as [storyChainId]: {
[storyAssetId]: 'story-2' }) and update the corresponding unit test assertion in
utils.test.ts that expects 'story-2' to instead expect 'story'; ensure both the
mapping and the test reference the CoinGecko coin ID 'story' so market data will
be sourced for Story Protocol's native IP token.

In `@packages/chain-adapters/src/evm/story/StoryChainAdapter.ts`:
- Around line 18-20: Add a defensive type-guard counterpart to the existing
isStoryChainAdapter: implement a function named isStoryChainAdapter that accepts
unknown | null | undefined, first checks for null/undefined and that the value
is an object with a callable getType, then returns (adapter as
ChainAdapter).getType() === KnownChainIds.StoryMainnet; place this in the
utils/story module (the defensive utility layer) so callers can safely pass
nullable values without throwing. Ensure the function signature is exported and
uses the same type predicate "adapter is ChainAdapter" as the original.

---

Outside diff comments:
In
`@scripts/generateAssetData/generateRelatedAssetIndex/generateChainRelatedAssetIndex.ts`:
- Around line 87-96: Update the inline comment above the USDC/USDT mappings to
accurately reflect included chains by changing "// Native stablecoins on Linea +
Mantle - CoinGecko doesn't tag these as bridged categories" to include Sonic
(e.g. "Linea + Mantle + Sonic") so it matches the entries like
'eip155:146/erc20:...' present in the USDC and USDT groups
('eip155:1/erc20:0xa0b8...' and 'eip155:1/erc20:0xdac1...').

---

Nitpick comments:
In @.env:
- Line 330: The .env has VITE_FEATURE_STORY placed after VITE_FEATURE_SUNIO_SWAP
which triggers dotenv-linter alphabetical-order warnings; move the
VITE_FEATURE_STORY entry so its key appears before VITE_FEATURE_SUNIO_SWAP
(i.e., reorder the lines involving VITE_FEATURE_STORY and
VITE_FEATURE_SUNIO_SWAP) to satisfy the linter while keeping the same value.

In @.env.development:
- Line 121: Reorder the two environment keys in .env.development so they follow
dotenv-linter alphabetical rules: move VITE_FEATURE_STORY to appear before
VITE_FEATURE_WC_DIRECT_CONNECTION; update the feature-flags section so the lines
read with VITE_FEATURE_STORY first and then VITE_FEATURE_WC_DIRECT_CONNECTION to
resolve the ordering warning.

Comment on lines +194 to +196
'eip155:1514': {
'eip155:1514/slip44:60': 'story-2',
},
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Test expectation will need updating once the CoinGecko ID bug in utils.ts is fixed.

See the comment on packages/caip/src/adapters/coingecko/utils.ts — the coin ID 'story-2' is incorrect. Once that is corrected to 'story', this expectation should become:

🐛 Proposed fix
-        'eip155:1514': {
-          'eip155:1514/slip44:60': 'story-2',
-        },
+        'eip155:1514': {
+          'eip155:1514/slip44:60': 'story',
+        },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'eip155:1514': {
'eip155:1514/slip44:60': 'story-2',
},
'eip155:1514': {
'eip155:1514/slip44:60': 'story',
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/caip/src/adapters/coingecko/utils.test.ts` around lines 194 - 196,
The test expectation currently asserts that the CoinGecko ID for
'eip155:1514/slip44:60' is 'story-2', but the utils bug will change the mapped
ID to 'story'; update the assertion in
packages/caip/src/adapters/coingecko/utils.test.ts to expect 'story' instead of
'story-2' for the key 'eip155:1514/slip44:60' (adjust any related fixtures or
expected maps that reference the old 'story-2' value).

[berachainChainId]: { [berachainAssetId]: 'berachain-bera' },
[cronosChainId]: { [cronosAssetId]: 'crypto-com-chain' },
[katanaChainId]: { [katanaAssetId]: 'katana' },
[storyChainId]: { [storyAssetId]: 'story-2' },
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Story Protocol native IP token CoinGecko coin ID

💡 Result:

Story Protocol’s native IP token (“Story”, ticker IP) has CoinGecko coin ID: story. [1]


🏁 Script executed:

# Check the actual line 625 in the utils.ts file
sed -n '620,630p' packages/caip/src/adapters/coingecko/utils.ts

Repository: shapeshift/web

Length of output: 696


🏁 Script executed:

# Check for all references to story in the coingecko utils file
rg -n "story" packages/caip/src/adapters/coingecko/utils.ts -i

Repository: shapeshift/web

Length of output: 413


🏁 Script executed:

# Check the test file for references to story
rg -n "story" packages/caip/src/adapters/coingecko/utils.test.ts -i -A 2 -B 2

Repository: shapeshift/web

Length of output: 194


Wrong CoinGecko coin ID for Story Protocol's native IP asset — will source market data from incorrect token.

'story-2' is a defunct charity token on BNB Chain with no active trading. Story Protocol's native IP token has CoinGecko coin ID 'story'.

Update line 625 in utils.ts and line 195 in utils.test.ts:

Proposed fixes
-      [storyChainId]: { [storyAssetId]: 'story-2' },
+      [storyChainId]: { [storyAssetId]: 'story' },
-          'eip155:1514/slip44:60': 'story-2',
+          'eip155:1514/slip44:60': 'story',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/caip/src/adapters/coingecko/utils.ts` at line 625, Replace the
incorrect CoinGecko ID 'story-2' with the correct 'story' in the mapping entry
where the keys are [storyChainId] and [storyAssetId] (the object currently
written as [storyChainId]: { [storyAssetId]: 'story-2' }) and update the
corresponding unit test assertion in utils.test.ts that expects 'story-2' to
instead expect 'story'; ensure both the mapping and the test reference the
CoinGecko coin ID 'story' so market data will be sourced for Story Protocol's
native IP token.

Comment on lines +18 to +20
export const isStoryChainAdapter = (adapter: unknown): adapter is ChainAdapter => {
return (adapter as ChainAdapter).getType() === KnownChainIds.StoryMainnet
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if the utility-layer counterpart with defensive checks exists
fd "story.ts" src/lib/utils/
rg -n "isStoryChainAdapter" src/lib/

Repository: shapeshift/web

Length of output: 40


Add defensive isStoryChainAdapter to src/lib/utils/story.ts.

The defensive counterpart with null/undefined checks is missing from src/lib/utils/story.ts. Per the established pattern across second-class EVM adapters (mantle, katana, unichain, soneium, and 10+ others), the type guard must exist in both locations: in the adapter file (non-defensive, as written) and in the utility layer (with defensive checks). Create src/lib/utils/story.ts with a defensive version of isStoryChainAdapter that safely handles null/undefined inputs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/chain-adapters/src/evm/story/StoryChainAdapter.ts` around lines 18 -
20, Add a defensive type-guard counterpart to the existing isStoryChainAdapter:
implement a function named isStoryChainAdapter that accepts unknown | null |
undefined, first checks for null/undefined and that the value is an object with
a callable getType, then returns (adapter as ChainAdapter).getType() ===
KnownChainIds.StoryMainnet; place this in the utils/story module (the defensive
utility layer) so callers can safely pass nullable values without throwing.
Ensure the function signature is exported and uses the same type predicate
"adapter is ChainAdapter" as the original.

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