-
Notifications
You must be signed in to change notification settings - Fork 17
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
Integrate skip widget #1943
Integrate skip widget #1943
Conversation
🦋 Changeset detectedLatest commit: 6d59eac The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
@@ -39,17 +39,19 @@ | |||
"@radix-ui/react-navigation-menu": "^1.1.4", | |||
"@radix-ui/react-portal": "^1.0.4", | |||
"@remix-run/router": "^1.16.1", | |||
"@tanstack/react-query": "4.36.1", | |||
"@skip-go/widget": "^3.0.22", | |||
"@tanstack/react-query": "5.62.7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The react-query dep bump was required for the skip widget to work. Unfortunately, the osmo-query hooks only work on v4. Had to do some refactoring as a consequence, but it got simpler as a result.
const useCosmosChainBalance = () => { | ||
const { address, getRpcEndpoint, chain } = useChainConnector(); | ||
|
||
const rpcEndpointQuery = useRpcEndpoint({ | ||
getter: getRpcEndpoint, | ||
options: { | ||
enabled: !!address, | ||
staleTime: Infinity, | ||
queryKey: ['rpc endpoint', address, chain.chain_name], | ||
// Needed for osmo-query's internal caching | ||
queryKeyHashFn: queryKey => { | ||
return JSON.stringify([...queryKey, chain.chain_name]); | ||
}, | ||
return useQuery({ | ||
queryKey: ['rpc endpoint', address, chain.chain_name], | ||
queryFn: async () => { | ||
if (!address) { | ||
throw new Error('missing address'); | ||
} | ||
const endpoint = await getRpcEndpoint(); | ||
const client = await StargateClient.connect(endpoint); | ||
return client.getAllBalances(address); | ||
}, | ||
}) as UseQueryResult<string>; | ||
|
||
const rpcClientQuery = useRpcClient({ | ||
rpcEndpoint: rpcEndpointQuery.data ?? '', | ||
options: { | ||
enabled: !!address && !!rpcEndpointQuery.data, | ||
staleTime: Infinity, | ||
queryKey: ['rpc client', address, rpcEndpointQuery.data, chain.chain_name], | ||
// Needed for osmo-query's internal caching | ||
queryKeyHashFn: queryKey => { | ||
return JSON.stringify([...queryKey, chain.chain_name]); | ||
}, | ||
}, | ||
}) as UseQueryResult<ProtobufRpcClient>; | ||
|
||
const { cosmos: cosmosQuery, osmosis: osmosisQuery } = createRpcQueryHooks({ | ||
rpc: rpcClientQuery.data, | ||
enabled: !!address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Far simpler than what the former osmo-query helpers were providing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using standard useQuery
over osmo-query specific hooks also has the benefit of reducing reliance on third-party libs, which minimizes another potential source of breakage.
srcChainId: 'osmosis-1', | ||
srcAssetDenom: 'ibc/498A0751C798A0D9A389AA3691123DADA57DAA4FE165D5C75894505B876BA6E4', // $USDC on osmosis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be thoughtful about the default chain+asset here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there are issues with USDC transfers, can we use USDY instead?
const { data: receiverView } = useQuery({ | ||
queryKey: ['receiverView', txInfo?.toJson({ typeRegistry }), option], | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- TODO: justify | ||
queryFn: () => fetchReceiverView(txInfo!), | ||
enabled: option === TxDetailsTab.RECEIVER && !!txInfo, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New v5 react-query requires object param style
@@ -83,7 +84,7 @@ export const SegmentedPicker = <ValueType extends { toString: () => string }>({ | |||
size === 'md' && 'text-sm px-3 h-8', | |||
size === 'lg' && 'px-4 h-10', | |||
value !== option.value && 'text-light-grey', | |||
grow && 'grow', | |||
grow && 'flex-1', // Use 'flex-1' for equal growth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed to add this as the tabs would be determined by text width and not be even
@@ -93,7 +94,7 @@ export const SegmentedPicker = <ValueType extends { toString: () => string }>({ | |||
/> | |||
)} | |||
|
|||
<div className='absolute inset-0 z-20 flex items-center justify-center'> | |||
<div className='absolute inset-0 z-10 flex items-center justify-center'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a bug where the tabs were overlaying the modal, this fixes that
e58f381
to
6806478
Compare
@@ -5,7 +5,7 @@ | |||
"license": "(MIT OR Apache-2.0)", | |||
"type": "module", | |||
"scripts": { | |||
"build": "vite build", | |||
"build": "cross-env NODE_OPTIONS=--max-old-space-size=8192 vite build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires amping up memory to build app now 🏋️
{ title: 'Deposit (skip)', href: PagePath.DEPOSIT_SKIP, enabled: true }, | ||
{ title: 'Deposit (manual)', href: PagePath.DEPOSIT_MANUAL, enabled: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can these be Deposit (Skip)
and Deposit (Manual)
?
This looks great! The deposit flow is way better and easier to understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested the ibc flows 👍
can you add a changeset?
const useCosmosChainBalance = () => { | ||
const { address, getRpcEndpoint, chain } = useChainConnector(); | ||
|
||
const rpcEndpointQuery = useRpcEndpoint({ | ||
getter: getRpcEndpoint, | ||
options: { | ||
enabled: !!address, | ||
staleTime: Infinity, | ||
queryKey: ['rpc endpoint', address, chain.chain_name], | ||
// Needed for osmo-query's internal caching | ||
queryKeyHashFn: queryKey => { | ||
return JSON.stringify([...queryKey, chain.chain_name]); | ||
}, | ||
return useQuery({ | ||
queryKey: ['rpc endpoint', address, chain.chain_name], | ||
queryFn: async () => { | ||
if (!address) { | ||
throw new Error('missing address'); | ||
} | ||
const endpoint = await getRpcEndpoint(); | ||
const client = await StargateClient.connect(endpoint); | ||
return client.getAllBalances(address); | ||
}, | ||
}) as UseQueryResult<string>; | ||
|
||
const rpcClientQuery = useRpcClient({ | ||
rpcEndpoint: rpcEndpointQuery.data ?? '', | ||
options: { | ||
enabled: !!address && !!rpcEndpointQuery.data, | ||
staleTime: Infinity, | ||
queryKey: ['rpc client', address, rpcEndpointQuery.data, chain.chain_name], | ||
// Needed for osmo-query's internal caching | ||
queryKeyHashFn: queryKey => { | ||
return JSON.stringify([...queryKey, chain.chain_name]); | ||
}, | ||
}, | ||
}) as UseQueryResult<ProtobufRpcClient>; | ||
|
||
const { cosmos: cosmosQuery, osmosis: osmosisQuery } = createRpcQueryHooks({ | ||
rpc: rpcClientQuery.data, | ||
enabled: !!address, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using standard useQuery
over osmo-query specific hooks also has the benefit of reducing reliance on third-party libs, which minimizes another potential source of breakage.
|
||
return { | ||
data: ibcAddrs, | ||
isLoading: registryIsLoading || ibcAddrsLoading, | ||
error: registryErr || ibcAddrssErr, | ||
error: registryErr ?? ibcAddrssErr, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and was able to successfully withdraw UM to Osmosis and deposit UM on Penumbra. The Skip widget didn't work on the preview domain but the Skip team has offered to allowlist the domains in the Prax Registry so it should work when published. |
6806478
to
6d59eac
Compare
Closes #1925
Adds a new layout and userflow to shield page:
compressed.mov