Skip to content

feat: enable Starknet wallet & message ID parsing on UI #505

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@headlessui/react": "^2.2.0",
"@hyperlane-xyz/registry": "13.13.0",
"@hyperlane-xyz/sdk": "12.4.0",
"@hyperlane-xyz/utils": "12.4.0",
"@hyperlane-xyz/widgets": "12.4.0",
"@hyperlane-xyz/registry": "13.0.0-starknet.1",
"@hyperlane-xyz/sdk": "13.0.0-starknet.1",
"@hyperlane-xyz/utils": "13.0.0-starknet.1",
"@hyperlane-xyz/widgets": "13.0.0-starknet.1",
"@interchain-ui/react": "^1.23.28",
"@metamask/post-message-stream": "6.1.2",
"@metamask/providers": "10.2.1",
Expand All @@ -43,7 +43,7 @@
"cosmjs-types": "^0.9.0",
"formik": "^2.4.6",
"framer-motion": "^10.16.4",
"next": "^15.0.3",
"next": "^15.3.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-toastify": "^10.0.6",
Expand Down
7 changes: 6 additions & 1 deletion src/consts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export const config: Config = Object.freeze({
version,
transferBlacklist,
walletConnectProjectId,
walletProtocols: [ProtocolType.Ethereum, ProtocolType.Sealevel, ProtocolType.Cosmos],
walletProtocols: [
ProtocolType.Ethereum,
ProtocolType.Sealevel,
ProtocolType.Cosmos,
ProtocolType.Starknet,
],
shouldDisableChains: false,
rpcOverrides,
});
8 changes: 6 additions & 2 deletions src/features/transfer/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ export function tryGetMsgIdFromTransferReceipt(
// IBC transfers have no message IDs
if (receipt.type === ProviderType.CosmJs) return undefined;

// TODO: Remove this once we have a way to get the message ID from SDK
if (receipt.type === ProviderType.Starknet) return undefined;
if (receipt.type === ProviderType.Starknet) {
receipt = {
type: ProviderType.Starknet,
receipt: receipt.receipt as any,
};
}

if (receipt.type === ProviderType.Viem) {
// Massage viem type into ethers type because that's still what the
Expand Down
34 changes: 32 additions & 2 deletions src/features/wallet/context/StarknetWalletContext.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { getStarknetChains } from '@hyperlane-xyz/widgets';
import { Chain } from '@starknet-react/chains';
import { StarknetConfig, publicProvider, voyager } from '@starknet-react/core';
import { PropsWithChildren } from 'react';
import { PropsWithChildren, useMemo } from 'react';
import { InjectedConnector } from 'starknetkit/injected';
import { useMultiProvider } from '../../chains/hooks';

// temporary using const sepolia chain
const sepolia: Chain = {
Expand Down Expand Up @@ -47,8 +50,35 @@ const sepolia: Chain = {
};

export function StarknetWalletContext({ children }: PropsWithChildren<unknown>) {
const multiProvider = useMultiProvider();
const chainsFromRegistry = getStarknetChains(multiProvider);
const connectors = useMemo(
() => [
new InjectedConnector({ options: { id: 'braavos', name: 'Braavos' } }),
new InjectedConnector({ options: { id: 'argentX', name: 'Argent X' } }),
],
[],
);

// TODO: remove after sepolia is included in registry
const uniqueChains = useMemo(() => {
const combinedChains = [...chainsFromRegistry, sepolia];
const chainMap = combinedChains.reduce((map, chain) => {
if (!map.has(chain.id)) {
map.set(chain.id, chain);
}
return map;
}, new Map<bigint, Chain>());
return Array.from(chainMap.values());
}, [chainsFromRegistry]);

return (
<StarknetConfig chains={[sepolia]} provider={publicProvider()} explorer={voyager}>
<StarknetConfig
chains={uniqueChains}
provider={publicProvider()}
connectors={connectors}
explorer={voyager}
>
{children}
</StarknetConfig>
);
Expand Down
Loading