Skip to content

Conversation

@editaahn
Copy link
Collaborator

@editaahn editaahn commented Nov 11, 2025

Linear KEPLR-1305

배경

multichain ecosystem에 맞춘 코드 베이스로 개선

  • Cosmos, EVM 체인 정보를 담는 ChainInfo 타입과 Starknet, Bitcoin 정보를 담는 ModularChainInfo 타입이 혼용되고 있어 코드 복잡성 상승 -> ModularChainInfo 타입 하나만을 주사용할 수 있도록 한다.

진행 상태

  • Extension 스모킹 테스트 마침
  • develop 브랜치 충돌 해결 완료 (2025/11/27 기준) - Topup, Supernova release 후 본 브랜치에서 병합 충돌 해결
  • peer review 완료

예정 timeline

  • Extension QA
  • Mobile QA

변경 사항 요약

  1. ModularChainInfo 타입 확장 code

    • CosmosInfoModule 타입에 evm 추가 (as-is: EVM 체인도 cosmos 타입을 사용하고 있었음)
    • EVM only chain을 위한 Union 타입, EVM compatible Cosmos를 위한 Union 타입 신규 추가함
      export type ModularChainInfo = ModularChainInfoBase &
        (
          | {
              readonly cosmos: ChainInfo;
            }
          | {
              readonly starknet: StarknetChainInfo;
            }
          | {
              readonly bitcoin: BitcoinChainInfo;
              readonly linkedChainKey: string;
            }
          // EVM only chain
          | {
              readonly evm: EVMNativeChainInfo;
            }
          // EVM compatible Cosmos chain
          | {
              readonly cosmos: ChainInfo;
              readonly evm: EVMNativeChainInfo;
            }
        );
    • isNative: 기존 ChainInfo 타입에서는 native 체인 여부를 알기 위해 embedded.embedded 또는 beta 필드 사용 -> ModularChainInfo에서는 isNative라는 이름으로 통합
        export interface ModularChainInfoBase {
          readonly chainId: string;
          readonly chainName: string;
          readonly chainSymbolImageUrl?: string;
          readonly isTestnet?: boolean;
          readonly isNative?: boolean; // 신규 추가
        }
  2. logic 상 분리: EVM <> Cosmos

    • 코드 예시
      // 변경 전 - cosmos 객체에 evm도 포함된 구조
        if ("cosmos" in modularChainInfo) { ... } 
      
      // 변경 후 - evm 객체를 동일 차원으로 분리
        if ("evm" in modularChainInfo) { 
          ... 
        } else if ("cosmos" in modularChainInfo) { 
        ... 
        } 
  3. ModularChainInfoImpl 확장 및 메서드 최적화 code packages/stores/src/chain/base.ts

    • ChainInfoImpl에만 있던 메서드 마이그레이션 + 코드 개선 (hasFeature, findCurrency, forceFindCurrency, addUnknownDenoms 등등)
    • 메서드 추가 및 조정 (matchModules, getCurrencies, getCurrenciesByModule, stakeCurrency 등등)
  4. ChainInfo -> ModularChainInfo 사용부 legacy 전면 교체

    • type 교체
      • ChainInfo, IChainInfoImpl -> ModularChainInfo, ModularChainInfoImpl
    • ChainStore 메서드 교체
      • ChainStore.getChain -> getModularChain or getModularChainInfoImpl
      • ChainStore.hasChain -> hasModularChain or matchModules
    • ChainStore accessor 교체
      • ChainStore.chainInfos -> modularChainInfos
      • chainStore.chainInfosInUI -> modularChainInfosInUI
  5. 분기가 필요한 경우는 “cosmos”, “evm”, “bitcoin” 등의 객체 존재 여부로 확인하시거나,
    getModularChainInfoImpl(chainId).matchModule(“cosmos”)
    getModularChainInfoImpl(chainId).matchModules({ or: [“cosmos”, “evm”] }) 등을 사용해주세요.

기타 참고사항

editaahn and others added 30 commits September 19, 2025 12:51
…sic-updates

ModularChainInfo 타입 수정 / stores, background 내부의 modularChainInfos 데이터 가공 시 분기
@editaahn editaahn marked this pull request as ready for review November 27, 2025 11:38
@editaahn editaahn requested a review from a team as a code owner November 27, 2025 11:38
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

breaking changes on ModularChainInfoImpl

}

get modularChainInfos(): ModularChainInfo[] {
console.log(
Copy link
Collaborator

Choose a reason for hiding this comment

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

혹시 여기 포함 이 파일의 console.log들은 의도적으로 남겨두신 걸까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

테스트용으로 남겨뒀는데요! QA 후 머지되기 전 지우겠습니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

콘솔로그 제거했습니다.

const denomHelper = new DenomHelper(currency.coinMinimalDenom);
if (denomHelper.type === "erc20") {
// XXX: 얘는 구조상 waitFreshResponse()가 안되서 일단 쿼리가 끝인지 아닌지는 무시한다.
queryBalance.fetch();
Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 기존 코드 같은데 로직이 잘 이해가 안되네요, 왜 동일한 query를 for문을 돌면서 반복 fetch 하는건지 궁금합니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

그러게요. queryBalance.getBalance(currency).fetch() 요렇게 가는게 의도가 아니었을지..? 정환님 확인 한번 해주셔요 @Thunnini

Copy link
Collaborator Author

@editaahn editaahn left a comment

Choose a reason for hiding this comment

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

@kws1207 주신 코멘트들 확인했어요. 감사합니다! 반영 후에 핑 한번 더 드릴게요 👍

}

get modularChainInfos(): ModularChainInfo[] {
console.log(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

테스트용으로 남겨뒀는데요! QA 후 머지되기 전 지우겠습니다

const denomHelper = new DenomHelper(currency.coinMinimalDenom);
if (denomHelper.type === "erc20") {
// XXX: 얘는 구조상 waitFreshResponse()가 안되서 일단 쿼리가 끝인지 아닌지는 무시한다.
queryBalance.fetch();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

그러게요. queryBalance.getBalance(currency).fetch() 요렇게 가는게 의도가 아니었을지..? 정환님 확인 한번 해주셔요 @Thunnini

@editaahn
Copy link
Collaborator Author

editaahn commented Dec 1, 2025

@kws1207 Sam님 코멘트 반영됐습니다.

blacktoast
blacktoast previously approved these changes Dec 2, 2025
Copy link
Collaborator

@blacktoast blacktoast left a comment

Choose a reason for hiding this comment

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

제가 잘못 한 걸수도 있는데

계정 처음 생성 하고 체인 선택할때 evm계열 체인이 선택이 안되는것 같아요
현재 배포 버전은 evm 계열이 선택이 되어 있긴합니다

Copy link
Collaborator Author

@editaahn editaahn left a comment

Choose a reason for hiding this comment

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

@blacktoast @piatoss3612
두 분이 주신 피드백 반영했습니다. 감사합니다~! 078d35c
레또님이 발견해주신 누락된 분기도 처리했습니다. 16d6d9f

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.

6 participants