-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Migrate various wallet hooks from the Warp UI to the Widgets l…
…ib (#4865) ### Description More ground-work for the upcoming Warp Deploy app No new code, just migrating things from the Warp UI Corresponds with hyperlane-xyz/hyperlane-warp-ui-template#326 Fixes hyperlane-xyz/hyperlane-warp-ui-template#321 ### Drive-by changes Update the hyp registry versions to 6.1.0 ### Backward compatibility Yes ### Testing Tested in Warp UI and storybook <img width="1000" alt="Screenshot 2024-11-16 at 7 08 00 PM" src="https://github.com/user-attachments/assets/f8f9c616-01c4-46e1-8b3b-98415741d4e0">
- Loading branch information
Showing
37 changed files
with
7,345 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hyperlane-xyz/widgets': minor | ||
--- | ||
|
||
Add multi-protocol wallet integration hooks and types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hyperlane-xyz/sdk': minor | ||
--- | ||
|
||
Add chainMetadataToCosmosChain function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import type { AssetList, Chain as CosmosChain } from '@chain-registry/types'; | ||
import { Chain, defineChain } from 'viem'; | ||
|
||
import { test1 } from '../consts/testChains.js'; | ||
import { | ||
ChainMetadata, | ||
getChainIdNumber, | ||
} from '../metadata/chainMetadataTypes.js'; | ||
|
||
export function chainMetadataToViemChain(metadata: ChainMetadata): Chain { | ||
return defineChain({ | ||
id: getChainIdNumber(metadata), | ||
name: metadata.displayName || metadata.name, | ||
network: metadata.name, | ||
nativeCurrency: metadata.nativeToken || test1.nativeToken!, | ||
rpcUrls: { | ||
public: { http: [metadata.rpcUrls[0].http] }, | ||
default: { http: [metadata.rpcUrls[0].http] }, | ||
}, | ||
blockExplorers: metadata.blockExplorers?.length | ||
? { | ||
default: { | ||
name: metadata.blockExplorers[0].name, | ||
url: metadata.blockExplorers[0].url, | ||
}, | ||
} | ||
: undefined, | ||
testnet: !!metadata.isTestnet, | ||
}); | ||
} | ||
|
||
export function chainMetadataToCosmosChain(metadata: ChainMetadata): { | ||
chain: CosmosChain; | ||
assets: AssetList; | ||
} { | ||
const { | ||
name, | ||
displayName, | ||
chainId, | ||
rpcUrls, | ||
restUrls, | ||
isTestnet, | ||
nativeToken, | ||
bech32Prefix, | ||
slip44, | ||
} = metadata; | ||
|
||
if (!nativeToken) throw new Error(`Missing native token for ${name}`); | ||
|
||
const chain: CosmosChain = { | ||
chain_name: name, | ||
chain_type: 'cosmos', | ||
status: 'live', | ||
network_type: isTestnet ? 'testnet' : 'mainnet', | ||
pretty_name: displayName || name, | ||
chain_id: chainId as string, | ||
bech32_prefix: bech32Prefix!, | ||
slip44: slip44!, | ||
apis: { | ||
rpc: [{ address: rpcUrls[0].http, provider: displayName || name }], | ||
rest: restUrls | ||
? [{ address: restUrls[0].http, provider: displayName || name }] | ||
: [], | ||
}, | ||
fees: { | ||
fee_tokens: [{ denom: 'token' }], | ||
}, | ||
staking: { | ||
staking_tokens: [{ denom: 'stake' }], | ||
}, | ||
}; | ||
|
||
const assets: AssetList = { | ||
chain_name: name, | ||
assets: [ | ||
{ | ||
description: `The native token of ${displayName || name} chain.`, | ||
denom_units: [{ denom: 'token', exponent: nativeToken.decimals }], | ||
base: 'token', | ||
name: 'token', | ||
display: 'token', | ||
symbol: 'token', | ||
type_asset: 'sdk.coin', | ||
}, | ||
{ | ||
description: `The native token of ${displayName || name} chain.`, | ||
denom_units: [{ denom: 'token', exponent: nativeToken.decimals }], | ||
base: 'stake', | ||
name: 'stake', | ||
display: 'stake', | ||
symbol: 'stake', | ||
type_asset: 'sdk.coin', | ||
}, | ||
], | ||
}; | ||
|
||
return { chain, assets }; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { rootLogger } from '@hyperlane-xyz/utils'; | ||
|
||
export const widgetLogger = rootLogger.child({ module: 'widgets' }); |
Oops, something went wrong.