Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: config starknet chain #5228

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

mshojaei-txfusion
Copy link
Collaborator

@mshojaei-txfusion mshojaei-txfusion commented Jan 21, 2025

Description

This PR adds Starknet protocol support to the chain configuration CLI, including:

  • New Starknet protocol type in chain metadata
  • Domain Id convert for Starknet networks
  • CLI prompts for Starknet chain configuration

Difference with last PR

Related issues

N/A

Backward compatibility

Yes - Only adds new functionality without modifying existing behavior

Testing

N/A

mortezashojaei and others added 30 commits October 16, 2024 15:07
Copy link

changeset-bot bot commented Jan 21, 2025

🦋 Changeset detected

Latest commit: 32b0a7f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@hyperlane-xyz/utils Minor
@hyperlane-xyz/sdk Minor
@hyperlane-xyz/widgets Minor
@hyperlane-xyz/cli Minor
@hyperlane-xyz/core Patch
@hyperlane-xyz/infra Minor
@hyperlane-xyz/helloworld Minor
@hyperlane-xyz/ccip-server Minor
@hyperlane-xyz/github-proxy Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -7,7 +7,7 @@ import { EthereumLogo } from './Ethereum.js';
import { SolanaLogo } from './Solana.js';

export const PROTOCOL_TO_LOGO: Record<
ProtocolType,
Exclude<ProtocolType, 'starknet'>,
Copy link
Contributor

Choose a reason for hiding this comment

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

reuse the NonStarknetProtocol type defined elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

wanted to do this but as this was temporary, what should I call it, where should I put this? on sdk?

@@ -40,11 +40,14 @@ const logger = widgetLogger.child({
module: 'walletIntegrations/multiProtocol',
});

type NonStarknetProtocol = Exclude<ProtocolType, 'starknet'>;
type ProtocolRecord<T> = Record<NonStarknetProtocol, T>;
Copy link
Contributor

Choose a reason for hiding this comment

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

ProtocolMap might be a better word given the existing ChainMap nomenclature we use

@@ -5,6 +5,7 @@ export enum ProtocolType {
Ethereum = 'ethereum',
Sealevel = 'sealevel',
Cosmos = 'cosmos',
Starknet = 'starknet',
Copy link
Contributor

Choose a reason for hiding this comment

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

since we're adding a new protocol type - automatically i would class this PR as a major change and not minor or patch

};
}

function formatChainIdBasedOnProtocol(chainId: string, protocol: ProtocolType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatChainIdForProtocol

Copy link
Contributor

Choose a reason for hiding this comment

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

and should that be SupportedProtocol as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right better to be SupportedProtocol

Comment on lines +318 to 324
if (isStarknet) {
denom = await input({
message: "Enter the native token's address:",
validate: (value) => isAddressStarknet(value),
});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any way to fetch this for the user without requiring input?

Copy link
Collaborator

Choose a reason for hiding this comment

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

On starknet mainnet there are two native tokens for fees - STRK and ETH, and AFAIK Paradex chain has an native token ETH address completely different from starknet mainnet @mshojaei-txfusion correct me if I am wrong

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We did not find any address on starknet.js to import, but we may be able to add a default native token address for starknet, and ask user to change it in case it was different.

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.53%. Comparing base (769cec1) to head (32b0a7f).
Report is 28 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5228   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files         103      103           
  Lines        2110     2110           
  Branches      190      190           
=======================================
  Hits         1636     1636           
  Misses        453      453           
  Partials       21       21           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 79.80% <ø> (ø)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

4 participants