Skip to content

Commit

Permalink
Use new sdks (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
atn4z7 authored Aug 1, 2024
1 parent a0258e1 commit 03d7cc8
Showing 198 changed files with 477 additions and 734 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/mobile-pr.yml
Original file line number Diff line number Diff line change
@@ -15,8 +15,6 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

steps:
- name: Check out repo
4 changes: 1 addition & 3 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -8,10 +8,8 @@ nmSelfReferences: false

nodeLinker: node-modules

npmAuthToken: "${NPM_TOKEN}"

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.6.4.cjs
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -22,22 +22,20 @@ This repository is a monorepo that we manage using [Yarn workspaces](https://yar

1. Clone the repo
2. Install yarn globally (if you don't have yarn yet)

```
brew install yarn
```
3. Set up `$NPM_TOKEN`

To install all dependencies, you will need to generate an `NPM token` from your NPM.js account and add that as an environment variable named `NPM_TOKEN` on your machine (for example, `.zshenv` if using zsh or `.bash_profile` if not).

4. Install dependencies for all packages
3. Install dependencies for all packages

In the root directory, run:

```
yarn install && yarn setup
```

5. Follow the specific instructions in each package to build/run it
4. Follow the specific instructions in each package to build/run it

## 📖 Tips

2 changes: 1 addition & 1 deletion docs/dependencies_resolutions.md
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ supports promise out of the box

### "@hpke/core": "1.2.7"

@avalabs/utils-sdk depends on @hpke/core 1.2.5 while core mobile depends on 1.2.7. we need to force it to 1.2.7 so that we can apply the same patch to @hpke/core.
@avalabs/core-utils-sdk depends on @hpke/core 1.2.5 while core mobile depends on 1.2.7. we need to force it to 1.2.7 so that we can apply the same patch to @hpke/core.

### "@noble/secp256k1": "2.0.0"

2 changes: 1 addition & 1 deletion packages/core-mobile/app/components/BNInput.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
import InputText, { InputTextProps } from 'components/InputText'
import Big from 'big.js'
import BN from 'bn.js'
import { bigToBN, bnToBig } from '@avalabs/utils-sdk'
import { bigToBN, bnToBig } from '@avalabs/core-utils-sdk'

interface BNInputProps extends Omit<InputTextProps, 'text'> {
value?: BN
4 changes: 2 additions & 2 deletions packages/core-mobile/app/components/EditFees.tsx
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import React, { useEffect, useMemo, useState } from 'react'
import FlexSpacer from 'components/FlexSpacer'
import { Row } from 'components/Row'
import { calculateGasAndFees, Eip1559Fees, GasAndFees } from 'utils/Utils'
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { useNativeTokenPriceForNetwork } from 'hooks/networks/useNativeTokenPriceForNetwork'
import {
Button,
@@ -20,7 +20,7 @@ import { TokenBaseUnit } from 'types/TokenBaseUnit'
import { NetworkTokenUnit } from 'types'
import { useSelector } from 'react-redux'
import { selectSelectedCurrency } from 'store/settings/currency'
import { VsCurrencyType } from '@avalabs/coingecko-sdk'
import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'
import { SafeAreaProvider } from 'react-native-safe-area-context'

type EditFeesProps<T extends TokenBaseUnit<T>> = {
2 changes: 1 addition & 1 deletion packages/core-mobile/app/components/EditSpendLimit.tsx
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import AppNavigation from 'navigation/AppNavigation'
import RpcRequestBottomSheet from 'screens/rpc/components/shared/RpcRequestBottomSheet'
import { View, Text, Button } from '@avalabs/k2-mobile'
import { Limit, SpendLimit } from 'hooks/useSpendLimits'
import { hexToBN } from '@avalabs/utils-sdk'
import { hexToBN } from '@avalabs/core-utils-sdk'

const EditSpendLimit = (): JSX.Element | null => {
const { spendLimit, onClose, updateSpendLimit, dAppName, editingToken } =
2 changes: 1 addition & 1 deletion packages/core-mobile/app/components/Fab.tsx
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import { selectIsLeftHanded } from 'store/settings/advanced'
import { alpha, Pressable, SxProp, useTheme, View } from '@avalabs/k2-mobile'
import { DeepLinkOrigin } from 'contexts/DeeplinkContext/types'
import AnalyticsService from 'services/analytics/AnalyticsService'
import { NetworkVMType } from '@avalabs/chains-sdk'
import { NetworkVMType } from '@avalabs/core-chains-sdk'
import { selectTokensWithBalanceByNetwork } from 'store/balance/slice'
import { useNetworks } from 'hooks/networks/useNetworks'
import { ActionProp } from './fab/types'
4 changes: 2 additions & 2 deletions packages/core-mobile/app/components/NetworkFeeSelector.tsx
Original file line number Diff line number Diff line change
@@ -10,11 +10,11 @@ import React, {
useState
} from 'react'
import { useSelector } from 'react-redux'
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { useNavigation } from '@react-navigation/native'
import AppNavigation from 'navigation/AppNavigation'
import { WalletScreenProps } from 'navigation/types'
import { VsCurrencyType } from '@avalabs/coingecko-sdk'
import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'
import { selectSelectedCurrency } from 'store/settings/currency'
import { calculateGasAndFees, Eip1559Fees, GasAndFees } from 'utils/Utils'
import { useNetworkFee } from 'hooks/useNetworkFee'
2 changes: 1 addition & 1 deletion packages/core-mobile/app/components/TokenAddress.tsx
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import { truncateAddress } from 'utils/Utils'
import AvaButton from 'components/AvaButton'
import { noop } from 'rxjs'
import BitcoinSVG from 'components/svg/BitcoinSVG'
import { isBech32Address } from '@avalabs/bridge-sdk'
import { isBech32Address } from '@avalabs/core-bridge-sdk'
import { isAddress } from 'ethers'
import AvaLogoSVG from 'components/svg/AvaLogoSVG'

Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React, { FC, useCallback, useMemo } from 'react'
import { Pressable, StyleSheet, View } from 'react-native'
import { AssetBalance } from 'screens/bridge/utils/types'
import BN from 'bn.js'
import { bnToBig } from '@avalabs/utils-sdk'
import { bnToBig } from '@avalabs/core-utils-sdk'
import { useApplicationContext } from 'contexts/ApplicationContext'
import { Row } from 'components/Row'
import AvaText from 'components/AvaText'
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import {
selectContacts,
selectRecentContacts
} from 'store/addressBook'
import { Network, NetworkVMType } from '@avalabs/chains-sdk'
import { Network, NetworkVMType } from '@avalabs/core-chains-sdk'
import { useNetworks } from 'hooks/networks/useNetworks'
import { Contact } from '@avalabs/types'
import {
4 changes: 2 additions & 2 deletions packages/core-mobile/app/contexts/BridgeContext.tsx
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import {
trackBridgeTransaction,
TrackerSubscription,
useBridgeSDK
} from '@avalabs/bridge-sdk'
} from '@avalabs/core-bridge-sdk'
import { useDispatch, useSelector } from 'react-redux'
import { selectActiveAccount } from 'store/account'
import {
@@ -28,7 +28,7 @@ import {
useEthereumProvider
} from 'hooks/networks/networkProviderHooks'
import { isEqual } from 'lodash'
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import Logger from 'utils/Logger'
import { showSnackBarCustom } from 'components/Snackbar'
import TransactionToast, {
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import React, {
} from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { selectWalletState, WalletState } from 'store/app'
import { noop } from '@avalabs/utils-sdk'
import { noop } from '@avalabs/core-utils-sdk'
import { Linking } from 'react-native'
import NotificationsService from 'services/notifications/NotificationsService'
import {
@@ -18,7 +18,7 @@ import { setActiveAccountIndex } from 'store/account'
import Logger from 'utils/Logger'
import { selectFeatureFlags, selectIsNotificationBlocked } from 'store/posthog'
import { setActive } from 'store/network'
import { ChainId } from '@avalabs/chains-sdk'
import { ChainId } from '@avalabs/core-chains-sdk'
import { FIDO_CALLBACK_URL } from 'services/passkey/consts'
import { handleDeeplink } from './utils/handleDeeplink'
import {
2 changes: 1 addition & 1 deletion packages/core-mobile/app/contexts/SendTokenContext.tsx
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import { useSelector } from 'react-redux'
import { selectActiveAccount } from 'store/account'
import sendService from 'services/send/SendService'
import { SendState } from 'services/send/types'
import { bnToLocaleString } from '@avalabs/utils-sdk'
import { bnToLocaleString } from '@avalabs/core-utils-sdk'
import { selectSelectedCurrency } from 'store/settings/currency'
import BN from 'bn.js'
import SentryWrapper from 'services/sentry/SentryWrapper'
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import { getSwapRate, getTokenAddress } from 'swap/getSwapRate'
import { SwapSide } from 'paraswap'
import { OptimalRate } from 'paraswap-core'
import Logger from 'utils/Logger'
import { resolve } from '@avalabs/utils-sdk'
import { resolve } from '@avalabs/core-utils-sdk'
import { Amount } from 'types'
import { InteractionManager } from 'react-native'
import SentryWrapper from 'services/sentry/SentryWrapper'
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import {
PriceString,
Transaction
} from 'paraswap'
import { ChainId } from '@avalabs/chains-sdk'
import { ChainId } from '@avalabs/core-chains-sdk'
import Web3 from 'web3'
import { OptimalRate } from 'paraswap-core'

@@ -55,6 +55,7 @@ export async function buildTx({
}: BuildTxParams): Promise<APIError | Transaction> {
const query = new URLSearchParams(options as Record<string, string>)
const txURL = `${
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(paraSwap as any).apiURL
}/transactions/${network}/?${query.toString()}`
const txConfig = {
@@ -86,6 +87,7 @@ export async function buildTx({

export async function getParaswapSpender(): Promise<string> {
const response = await fetch(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
`${(paraSwap as any).apiURL}/adapters/contracts?network=${
ChainId.AVALANCHE_MAINNET_ID
}`
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import assert from 'assert'
import { Contract } from 'ethers'
import { Network } from '@avalabs/chains-sdk'
import { JsonRpcBatchInternal } from '@avalabs/wallets-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { JsonRpcBatchInternal } from '@avalabs/core-wallets-sdk'
import { TransactionParams } from '@avalabs/evm-module'
import ERC20 from '@openzeppelin/contracts/build/contracts/ERC20.json'
import Big from 'big.js'
import { BN } from 'bn.js'
import { APIError, ETHER_ADDRESS, Transaction } from 'paraswap'
import { OptimalRate } from 'paraswap-core'
import { promiseResolveWithBackoff, resolve } from '@avalabs/utils-sdk'
import { promiseResolveWithBackoff, resolve } from '@avalabs/core-utils-sdk'
import { bigIntToHex } from '@ethereumjs/util'
import { buildTx, getParaswapSpender } from './paraswapUtils'

2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/earn/useCChainNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { useNetworks } from 'hooks/networks/useNetworks'
import { useMemo } from 'react'
import { getAvalancheNetwork } from 'services/network/utils/providerUtils'
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChainId } from '@avalabs/chains-sdk'
import { VsCurrencyType } from '@avalabs/coingecko-sdk'
import { ChainId } from '@avalabs/core-chains-sdk'
import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'
import { useApplicationContext } from 'contexts/ApplicationContext'
import { useNativeTokenPriceForNetwork } from 'hooks/networks/useNativeTokenPriceForNetwork'
import { useNetworks } from 'hooks/networks/useNetworks'
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { BitcoinProvider, JsonRpcBatchInternal } from '@avalabs/wallets-sdk'
import {
BitcoinProvider,
JsonRpcBatchInternal
} from '@avalabs/core-wallets-sdk'
import { useMemo } from 'react'
import {
getAvalancheProvider,
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import TokenService from 'services/token/TokenService'
import { VsCurrencyType } from '@avalabs/coingecko-sdk'
import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'
import { useSelector } from 'react-redux'
import { selectSelectedCurrency } from 'store/settings/currency'
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { useQuery } from '@tanstack/react-query'

const REFETCH_INTERVAL = 10000 // 10 seconds
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { NetworkContractToken } from '@avalabs/vm-module-types'
import { useQuery } from '@tanstack/react-query'
import { ReactQueryKeys } from 'consts/reactQueryKeys'
2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/networks/useNetworks.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
} from 'store/network'
import { useCallback, useMemo } from 'react'
import { selectIsDeveloperMode } from 'store/settings/advanced'
import { type Network } from '@avalabs/chains-sdk'
import { type Network } from '@avalabs/core-chains-sdk'
import { isAvalancheChainId } from 'services/network/utils/isAvalancheNetwork'
import { useGetNetworks } from './useGetNetworks'

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { NetworkContractToken } from '@avalabs/vm-module-types'
import ModuleManager from 'vmModule/ModuleManager'
import { mapToVmNetwork } from 'vmModule/utils/mapToVmNetwork'
6 changes: 3 additions & 3 deletions packages/core-mobile/app/hooks/useCChainBaseFee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Avalanche } from '@avalabs/wallets-sdk'
import { useQuery } from '@tanstack/react-query'
import { Avalanche } from '@avalabs/core-wallets-sdk'
import { UseQueryResult, useQuery } from '@tanstack/react-query'
import { useSelector } from 'react-redux'
import NetworkService from 'services/network/NetworkService'
import { selectIsDeveloperMode } from 'store/settings/advanced'
@@ -12,7 +12,7 @@ const REFETCH_INTERVAL = 10000 // 10 seconds
* more info about base fee here:
* https://docs.avax.network/quickstart/transaction-fees#c-chain-fees
*/
export const useCChainBaseFee = () => {
export const useCChainBaseFee = (): UseQueryResult<bigint, Error> => {
const isDeveloperMode = useSelector(selectIsDeveloperMode)
const avaxXPNetwork = NetworkService.getAvalancheNetworkXP(isDeveloperMode)
const avaxProvider = NetworkService.getProviderForNetwork(
2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useCoinGeckoId.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTokenInfoContext } from '@avalabs/bridge-sdk'
import { useTokenInfoContext } from '@avalabs/core-bridge-sdk'

const KNOWN_IDS: { [key: string]: string } = {
BTC: 'bitcoin',
2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useInAppBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InAppBrowser } from 'react-native-inappbrowser-reborn'
import { useApplicationContext } from 'contexts/ApplicationContext'
import { Linking } from 'react-native'
import { resolve } from '@avalabs/utils-sdk'
import { resolve } from '@avalabs/core-utils-sdk'
import { useSelector } from 'react-redux'
import { selectActiveAccount } from 'store/account'
import Config from 'react-native-config'
2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useIsUIDisabled.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainId } from '@avalabs/chains-sdk'
import { ChainId } from '@avalabs/core-chains-sdk'
import { absoluteChain } from 'utils/network/isAvalancheNetwork'
import { useNetworks } from './networks/useNetworks'

2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useNativeTokenPrice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VsCurrencyType } from '@avalabs/coingecko-sdk'
import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'
import { useNativeTokenPriceForNetwork } from 'hooks/networks/useNativeTokenPriceForNetwork'
import { useNetworks } from './networks/useNetworks'

2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useNetworkFee.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { useQuery, UseQueryResult } from '@tanstack/react-query'
import { ReactQueryKeys } from 'consts/reactQueryKeys'
import { queryClient } from 'contexts/ReactQueryProvider'
2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useSimplePrice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react'
import { VsCurrencyType } from '@avalabs/coingecko-sdk'
import { VsCurrencyType } from '@avalabs/core-coingecko-sdk'
import Big from 'big.js'
import TokenService from 'services/token/TokenService'
import Logger from 'utils/Logger'
2 changes: 1 addition & 1 deletion packages/core-mobile/app/hooks/useSpendLimits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bnToLocaleString, hexToBN } from '@avalabs/utils-sdk'
import { bnToLocaleString, hexToBN } from '@avalabs/core-utils-sdk'
import { useCallback, useEffect, useState } from 'react'
import Web3 from 'web3'
import ERC20 from '@openzeppelin/contracts/build/contracts/ERC20.json'
4 changes: 2 additions & 2 deletions packages/core-mobile/app/navigation/types.ts
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@ import { AvalancheUpdateContactRequest as AvalancheUpdateContactRequestV2 } from
import { AvalancheSelectAccountRequest as AvalancheSelectAccountRequestV2 } from 'store/rpc/handlers/account/avalanche_selectAccount/avalanche_selectAccount'
import { Account } from 'store/account'
import { AvalancheBridgeAssetRequest as AvalancheBridgeAssetRequestV2 } from 'store/rpc/handlers/avalanche_bridgeAsset/avalanche_bridgeAsset'
import { Asset, Blockchain } from '@avalabs/bridge-sdk'
import { Asset, Blockchain } from '@avalabs/core-bridge-sdk'
import { WalletAddEthereumChainRpcRequest as WalletAddEthereumChainRpcRequestV2 } from 'store/rpc/handlers/chain/wallet_addEthereumChain/wallet_addEthereumChain'
import { Network } from '@avalabs/chains-sdk'
import { Network } from '@avalabs/core-chains-sdk'
import { WalletSwitchEthereumChainRpcRequest as WalletSwitchEthereumChainRpcRequestV2 } from 'store/rpc/handlers/chain/wallet_switchEthereumChain/wallet_switchEthereumChain'
import {
SendTransactionApproveData,
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react'
import AppNavigation from 'navigation/AppNavigation'
import { createStackNavigator } from '@react-navigation/stack'
import TopNavigationHeader from 'navigation/TopNavigationHeader'
import { noop } from '@avalabs/utils-sdk'
import { noop } from '@avalabs/core-utils-sdk'
import TabViewScreen from 'screens/browser/TabViewScreen'
import { useNavigation } from '@react-navigation/native'
import { BrowserScreenProps } from 'navigation/types'
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import ClaimRewards from 'screens/earn/ClaimRewards'
import { FeeUnavailableModal } from 'screens/earn/FeeUnavailableModal'
import { EarnNotificationsModal } from 'screens/earn/EarnNotificationsModal'
import * as Navigation from 'utils/Navigation'
import { noop } from '@avalabs/utils-sdk'
import { noop } from '@avalabs/core-utils-sdk'
import { FundsStuckModal } from 'screens/earn/FundsStuckModal'
import StakeSetupScreenStack, {
StakeSetupStackParamList
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import {
Blockchain,
BridgeTransaction,
useBridgeSDK
} from '@avalabs/bridge-sdk'
} from '@avalabs/core-bridge-sdk'
import {
getBlockchainDisplayName,
isPendingBridgeTransaction
Loading

0 comments on commit 03d7cc8

Please sign in to comment.