-
Notifications
You must be signed in to change notification settings - Fork 73
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: useTransfers hook [OTE-853] #1137
Merged
+527
−27
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
403c6e8
feat: useSkipClient hook [OTE-857]
yogurtandjam 6f8e35f
feat: usetransfers hook [OTE-853]
yogurtandjam 687d297
address comments
yogurtandjam 6e30c28
consolidate native denom const
yogurtandjam b37f0c6
address comments!
yogurtandjam 75c0100
feat: cctp withdrawals: setup [1/n] (#1152)
yogurtandjam 2cd87e1
add refetch interval for route query
yogurtandjam b5aeb6a
lint
yogurtandjam 749ad54
remove unused typecase
yogurtandjam ea8a116
throw error instead of returning null
yogurtandjam aa5a089
comment for clientid + token.decimals, prefetchedQuery hook
yogurtandjam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,113 @@ | ||
import { Asset } from '@skip-go/client'; | ||
|
||
import { WalletNetworkType } from '@/constants/wallets'; | ||
|
||
import { isNativeDenom } from '@/lib/assetUtils'; | ||
|
||
import { isTokenCctp } from './cctp'; | ||
|
||
export enum TransferType { | ||
Deposit = 'DEPOSIT', | ||
Withdraw = 'WITHDRAW', | ||
} | ||
|
||
export type NetworkType = 'evm' | 'svm' | 'cosmos'; | ||
|
||
// TODO [onboarding-rewrite]: followup with skip about making logoUri an optional property | ||
const DUMMY_LOGO_URI = 'dummy-logo-uri'; | ||
|
||
// TODO [onboarding-rewrite]: maybe unhardcode this. we can retrieve this via the skipclient and filter ourselves | ||
// but we don't have to? may be worth hardcoding to reduce an extra network call since this isn't going to change much | ||
// and we should have decent visibility into when this changes. TBD | ||
export const UNISWAP_VENUES = [ | ||
{ | ||
name: 'ethereum-uniswap', | ||
chainID: '1', | ||
}, | ||
{ | ||
name: 'polygon-uniswap', | ||
chainID: '137', | ||
}, | ||
{ | ||
name: 'optimism-uniswap', | ||
chainID: '10', | ||
}, | ||
{ | ||
name: 'arbitrum-uniswap', | ||
chainID: '42161', | ||
}, | ||
{ | ||
name: 'base-uniswap', | ||
chainID: '8453', | ||
}, | ||
{ | ||
name: 'avalanche-uniswap', | ||
chainID: '43114', | ||
}, | ||
{ | ||
name: 'binance-uniswap', | ||
chainID: '56', | ||
}, | ||
{ | ||
name: 'celo-uniswap', | ||
chainID: '42220', | ||
}, | ||
{ | ||
name: 'blast-uniswap', | ||
chainID: '81457', | ||
}, | ||
].map((x) => ({ ...x, logoUri: DUMMY_LOGO_URI })); | ||
|
||
// TODO [onboarding-rewrite]: maybe unhardcode this. same as above. | ||
export const COSMOS_SWAP_VENUES = [ | ||
{ | ||
name: 'osmosis-poolmanager', | ||
chainID: 'osmosis-1', | ||
logoUri: DUMMY_LOGO_URI, | ||
}, | ||
{ | ||
name: 'neutron-astroport', | ||
chainID: 'neutron-1', | ||
logoUri: DUMMY_LOGO_URI, | ||
}, | ||
]; | ||
|
||
export const SWAP_VENUES = [...UNISWAP_VENUES, ...COSMOS_SWAP_VENUES]; | ||
|
||
export const getNetworkTypeFromWalletNetworkType = ( | ||
walletNetworkType?: WalletNetworkType | ||
): NetworkType => { | ||
if (walletNetworkType === WalletNetworkType.Evm) { | ||
return 'evm'; | ||
} | ||
if (walletNetworkType === WalletNetworkType.Solana) { | ||
return 'svm'; | ||
} | ||
if (walletNetworkType === WalletNetworkType.Cosmos) { | ||
return 'cosmos'; | ||
} | ||
return 'evm'; | ||
}; | ||
|
||
export const getDefaultTokenDenomFromAssets = (assets: Asset[]): string => { | ||
const cctpToken = assets.find((asset) => { | ||
return isTokenCctp(asset); | ||
}); | ||
const nativeChainToken = assets.find((asset) => { | ||
return isNativeDenom(asset.denom); | ||
}); | ||
const uusdcToken = assets.find((asset) => { | ||
return asset.denom === 'uusdc' || asset.originDenom === 'uusdc'; | ||
}); | ||
// If not cctp or native chain token, default to the first item in the list | ||
const defaultTokenDenom = | ||
cctpToken?.denom ?? nativeChainToken?.denom ?? uusdcToken?.denom ?? assets[0]?.denom; | ||
return defaultTokenDenom; | ||
}; | ||
|
||
export const getDefaultChainIDFromNetworkType = (networkType: NetworkType): string | undefined => { | ||
if (networkType === 'evm') return '1'; | ||
if (networkType === 'svm') return 'solana'; | ||
if (networkType === 'cosmos') return 'noble-1'; | ||
return undefined; | ||
}; |
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
Oops, something went wrong.
Unchanged files with check annotations Beta
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
const navigation = globalThis.navigation; | ||
if (!navigation) { | ||
globalThis.history?.back(); | ||
// @ts-ignore | ||
} else if (navigation.canGoBack) { | ||
navigation.back(); |
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
${({ action }) => action && buttonActionVariants[action]} | ||
${({ action, state }) => | ||
state && | ||
css` | ||
// Ordered from lowest to highest priority (ie. Disabled should overwrite Active and Loading states) | ||
${state[ButtonState.Loading] && buttonStateVariants(action)[ButtonState.Loading]} |
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
--details-grid-numColumns: 2; | ||
--details-item-vertical-padding: ; | ||
${({ layout }) => layout && detailsLayoutVariants[layout]} | ||
`; | ||
const $Item = styled.div<{ | ||
justifyItems?: 'start' | 'end'; | ||
withOverflow?: boolean; | ||
}>` | ||
${({ layout }) => layout && itemLayoutVariants[layout]} | ||
${({ justifyItems }) => | ||
justifyItems === 'end' && | ||
`} | ||
${({ layout, withOverflow }) => | ||
layout && | ||
withOverflow && | ||
{ | ||
column: css` |
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
<$Item | ||
disabled={!item.onSelect} | ||
$highlightColor={item.highlightColor} | ||
onSelect={item?.onSelect} | ||
> | ||
{item.icon} | ||
{item.label} |
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
<$FormInputContainer className={className} isValidationAttached={validationConfig?.attached}> | ||
<$InputContainer hasLabel={!!label} hasSlotRight={!!slotRight}> | ||
{label ? ( | ||
<$WithLabel label={label} inputID={id} disabled={otherProps?.disabled}> | ||
<Input ref={ref} id={id} {...otherProps} /> | ||
</$WithLabel> | ||
) : ( |
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
if (isTablet && !canAccountTrade) { | ||
dispatch(openDialog(DialogTypes.Onboarding())); | ||
} | ||
}, []); | ||
useEffect(() => { | ||
const dialogClosed = | ||
navigate('/'); | ||
} | ||
prevActiveDialog.current = activeDialog; | ||
}, [activeDialog, canAccountTrade, isTablet]); | ||
return <Outlet />; | ||
}; |
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
? undefined | ||
: Number(newFormattedValue.replace(',', '.')); | ||
onInput?.({ value: newValue, floatValue, formattedValue: newFormattedValue, ...e }); | ||
}} | ||
// Native | ||
disabled={disabled} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👀 what is this clientId supposed to represent? can you leave a comment?
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.
ooo good point! will do :)