1- import { Asset , IBCTrace } from "@chain-registry/types" ;
1+ import { Asset } from "@chain-registry/types" ;
2+ import { IbcTransition } from "@chain-registry/types/assetlist.schema" ;
23import { Stack } from "@namada/components" ;
34import { AccountType , BparamsMsgValue } from "@namada/types" ;
45import { allDefaultAccountsAtom } from "atoms/accounts" ;
56import { namadaShieldedAssetsAtom } from "atoms/balance" ;
6- import { chainParametersAtom } from "atoms/chain" ;
7- import { findAssetsByChainId , ibcChannelsFamily } from "atoms/integrations" ;
7+ import {
8+ getChainRegistryByChainId ,
9+ ibcChannelsFamily ,
10+ namadaRegistryChainAssetsMapAtom ,
11+ } from "atoms/integrations" ;
812import { SwapResponse , SwapResponseError , SwapResponseOk } from "atoms/swaps" ;
913import { createOsmosisSwapTxAtom } from "atoms/transfer/atoms" ;
1014import BigNumber from "bignumber.js" ;
@@ -13,7 +17,7 @@ import invariant from "invariant";
1317import { useAtomValue } from "jotai" ;
1418import { broadcastTransaction , signTx } from "lib/query" ;
1519import { useCallback , useEffect , useState } from "react" ;
16- import { AddressWithAssetAndAmount } from "types" ;
20+ import { NamadaAssetWithAmount } from "types" ;
1721import { getSdkInstance } from "utils/sdk" ;
1822
1923const SLIPPAGE = 0.005 ;
@@ -28,15 +32,14 @@ export const OsmosisSwap: React.FC = () => {
2832 namadaShieldedAssetsAtom
2933 ) ;
3034
31- const chainParameters = useAtomValue ( chainParametersAtom ) ;
35+ const chainAssetsMapAtom = useAtomValue ( namadaRegistryChainAssetsMapAtom ) ;
3236 const namadaAssets =
33- chainParameters . data ?
34- findAssetsByChainId ( chainParameters . data . chainId )
35- : [ ] ;
37+ chainAssetsMapAtom . isSuccess ? Object . values ( chainAssetsMapAtom . data ) : [ ] ;
38+
3639 const osmosisAssets =
37- chainParameters . data ? findAssetsByChainId ( "osmosis-1" ) : [ ] ;
40+ getChainRegistryByChainId ( "osmosis-1" ) ?. assets . assets || [ ] ;
3841
39- const [ from , setFrom ] = useState < AddressWithAssetAndAmount | undefined > ( ) ;
42+ const [ from , setFrom ] = useState < NamadaAssetWithAmount | undefined > ( ) ;
4043 const [ to , setTo ] = useState < Asset | undefined > ( ) ;
4144 const [ amount , setAmount ] = useState < string > ( "" ) ;
4245 const [ recipient , setRecipient ] = useState < string > (
@@ -91,7 +94,7 @@ export const OsmosisSwap: React.FC = () => {
9194 if ( from && to && amount ) {
9295 call ( ) ;
9396 }
94- } , [ from ?. originalAddress , to ?. address , amount ] ) ;
97+ } , [ from ?. asset . address , to ?. address , amount ] ) ;
9598
9699 const defaultAccounts = useAtomValue ( allDefaultAccountsAtom ) ;
97100 const shieldedAccount = defaultAccounts . data ?. find (
@@ -111,7 +114,7 @@ export const OsmosisSwap: React.FC = () => {
111114 invariant ( localRecoveryAddr , "No local recovery address" ) ;
112115 invariant ( recipient , "No recipient" ) ;
113116
114- const toTrace = to . traces ?. find ( ( t ) : t is IBCTrace => t . type === "ibc" )
117+ const toTrace = to . traces ?. find ( ( t ) : t is IbcTransition => t . type === "ibc" )
115118 ?. chain . path ;
116119 invariant ( toTrace , "No IBC trace found for the to asset" ) ;
117120 invariant ( quote . route [ 0 ] , "No route found in the quote" ) ;
@@ -133,7 +136,7 @@ export const OsmosisSwap: React.FC = () => {
133136 // osmosis channel
134137 channelId : "channel-7" ,
135138 portId : "transfer" ,
136- token : from . originalAddress ,
139+ token : from . asset . address ,
137140 source : shieldedAccount . pseudoExtendedKey ! ,
138141 gasSpendingKey : shieldedAccount . pseudoExtendedKey ! ,
139142 receiver : SWAP_CONTRACT_ADDRESS ,
@@ -194,7 +197,7 @@ export const OsmosisSwap: React.FC = () => {
194197 >
195198 < option value = "" > </ option >
196199 { Object . values ( availableAssets || { } ) . map ( ( al , idx ) => (
197- < option key = { `${ al . asset . base } _${ idx } ` } value = { al . originalAddress } >
200+ < option key = { `${ al . asset . base } _${ idx } ` } value = { al . asset . address } >
198201 { al . asset . symbol }
199202 </ option >
200203 ) ) }
0 commit comments