Skip to content
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

Replace App raps with BX #5608

Merged
merged 10 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/entities/gas.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { GasFeeLegacyParams } from '@/__swaps__/types/gas';

type Numberish = number | string;

export interface Fee {
Expand Down
2 changes: 1 addition & 1 deletion src/entities/transactions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { EthereumAddress } from '../wallet';
import { Network } from '@/helpers/networkTypes';
import { AddCashCurrencyAsset } from '@/references';
import { ChainId, SwapType } from '@rainbow-me/swaps';
import { SwapMetadata } from '@/raps/common';
import { SwapMetadata } from '@/raps/references';
import { UniqueAsset } from '../uniqueAssets';
import { ParsedAsset } from '@/resources/assets/types';
import { TransactionStatus, TransactionType } from '@/resources/transactions/types';
Expand Down
15 changes: 9 additions & 6 deletions src/handlers/ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { debounce, isEmpty, sortBy } from 'lodash';
import { fetchENSAvatar, prefetchENSAvatar } from '../hooks/useENSAvatar';
import { prefetchENSCover } from '../hooks/useENSCover';
import { prefetchENSRecords } from '../hooks/useENSRecords';
import { ENSActionParameters, RapActionTypes } from '../raps/common';
import { ENSActionParameters, ENSRapActionType } from '@/raps/common';
import { getENSData, getNameFromLabelhash, saveENSData } from './localstorage/ens';
import { estimateGasWithPadding, getProviderForNetwork, TokenStandard } from './web3';
import { ENSRegistrationRecords, Records, UniqueAsset } from '@/entities';
Expand All @@ -26,8 +26,8 @@ import { prefetchENSAddress } from '@/resources/ens/ensAddressQuery';
import { ENS_MARQUEE_QUERY_KEY } from '@/resources/metadata/ensMarqueeQuery';
import { queryClient } from '@/react-query';
import { EnsMarqueeAccount } from '@/graphql/__generated__/metadata';
import { getEnsMarqueeFallback } from '@/components/ens-registration/IntroMarquee/IntroMarquee';
import { MimeType, handleNFTImages } from '@/utils/handleNFTImages';
import store from '@/redux/store';

const DUMMY_RECORDS = {
description: 'description',
Expand Down Expand Up @@ -655,12 +655,15 @@ export const estimateENSRegistrationGasLimit = async (
records: Records = DUMMY_RECORDS
) => {
const salt = generateSalt();
const { selectedGasFee, gasFeeParamsBySpeed } = store.getState().gas;
const commitGasLimitPromise = estimateENSCommitGasLimit({
duration,
name,
ownerAddress,
rentPrice,
salt,
selectedGasFee,
gasFeeParamsBySpeed,
});

const setRecordsGasLimitPromise = estimateENSSetRecordsGasLimit({
Expand Down Expand Up @@ -888,13 +891,13 @@ export const getTransactionTypeForRecords = (registrationRecords: ENSRegistratio
export const getRapActionTypeForTxType = (txType: ENSRegistrationTransactionType) => {
switch (txType) {
case ENSRegistrationTransactionType.MULTICALL:
return RapActionTypes.multicallENS;
return ENSRapActionType.multicallENS;
case ENSRegistrationTransactionType.SET_ADDR:
return RapActionTypes.setAddrENS;
return ENSRapActionType.setAddrENS;
case ENSRegistrationTransactionType.SET_TEXT:
return RapActionTypes.setTextENS;
return ENSRapActionType.setTextENS;
case ENSRegistrationTransactionType.SET_CONTENTHASH:
return RapActionTypes.setContenthashENS;
return ENSRapActionType.setContenthashENS;
default:
return null;
}
Expand Down
24 changes: 15 additions & 9 deletions src/hooks/useENSRegistrationActionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Image } from 'react-native-image-crop-picker';
import { useRecoilValue } from 'recoil';
import { avatarMetadataAtom } from '../components/ens-registration/RegistrationAvatar/RegistrationAvatar';
import { coverMetadataAtom } from '../components/ens-registration/RegistrationCover/RegistrationCover';
import { ENSActionParameters, RapActionTypes } from '../raps/common';
import { ENSActionParameters, ENSRapActionType } from '@/raps/common';
import usePendingTransactions from './usePendingTransactions';
import { useAccountSettings, useENSRegistration, useWalletENSAvatar, useWallets } from '.';
import { Records, RegistrationParameters } from '@/entities';
Expand All @@ -15,16 +15,20 @@ import { uploadImage } from '@/handlers/pinata';
import { getProviderForNetwork } from '@/handlers/web3';
import { ENS_DOMAIN, generateSalt, getRentPrice, REGISTRATION_STEPS } from '@/helpers/ens';
import { loadWallet } from '@/model/wallet';
import { executeRap } from '@/raps';
import { timeUnits } from '@/references';
import Routes from '@/navigation/routesNames';
import { labelhash, logger } from '@/utils';
import { getNextNonce } from '@/state/nonces';
import { Network } from '@/networks/types';
import { Hex } from 'viem';
import { executeENSRap } from '@/raps/actions/ens';
import store from '@/redux/store';

const NOOP = () => null;

const formatENSActionParams = (registrationParameters: RegistrationParameters): ENSActionParameters => {
const { selectedGasFee, gasFeeParamsBySpeed } = store.getState().gas;

return {
duration: registrationParameters?.duration,
mode: registrationParameters?.mode,
Expand All @@ -34,6 +38,8 @@ const formatENSActionParams = (registrationParameters: RegistrationParameters):
rentPrice: registrationParameters?.rentPrice,
salt: registrationParameters?.salt,
setReverseRecord: registrationParameters?.setReverseRecord,
gasFeeParamsBySpeed,
selectedGasFee,
};
};

Expand Down Expand Up @@ -110,7 +116,7 @@ export default function useENSRegistrationActionHandler(
salt,
};

await executeRap(wallet, RapActionTypes.commitENS, commitEnsRegistrationParameters, () => {
await executeENSRap(wallet, ENSRapActionType.commitENS, commitEnsRegistrationParameters, () => {
if (isHardwareWallet) {
goBack();
}
Expand Down Expand Up @@ -166,7 +172,7 @@ export default function useENSRegistrationActionHandler(
setReverseRecord: sendReverseRecord,
};

await executeRap(wallet, RapActionTypes.registerENS, registerEnsRegistrationParameters, callback);
await executeENSRap(wallet, ENSRapActionType.registerENS, registerEnsRegistrationParameters, callback);

updateAvatarsOnNextBlock.current = true;
},
Expand All @@ -193,7 +199,7 @@ export default function useENSRegistrationActionHandler(
rentPrice: rentPrice.toString(),
};

await executeRap(wallet, RapActionTypes.renewENS, registerEnsRegistrationParameters, callback);
await executeENSRap(wallet, ENSRapActionType.renewENS, registerEnsRegistrationParameters, callback);
},
[accountAddress, duration, registrationParameters]
);
Expand All @@ -217,7 +223,7 @@ export default function useENSRegistrationActionHandler(
ownerAddress: accountAddress,
};

await executeRap(wallet, RapActionTypes.setNameENS, registerEnsRegistrationParameters, callback);
await executeENSRap(wallet, ENSRapActionType.setNameENS, registerEnsRegistrationParameters, callback);
},
[accountAddress, registrationParameters]
);
Expand All @@ -244,11 +250,11 @@ export default function useENSRegistrationActionHandler(
nonce,
ownerAddress: accountAddress,
records: changedRecords,
resolverAddress: resolver?.address,
resolverAddress: resolver?.address as Hex,
setReverseRecord: sendReverseRecord,
};

await executeRap(wallet, RapActionTypes.setRecordsENS, setRecordsEnsRegistrationParameters, callback);
await executeENSRap(wallet, ENSRapActionType.setRecordsENS, setRecordsEnsRegistrationParameters, callback);

updateAvatarsOnNextBlock.current = true;
},
Expand Down Expand Up @@ -285,7 +291,7 @@ export default function useENSRegistrationActionHandler(
transferControl,
};

const { nonce: newNonce } = await executeRap(wallet, RapActionTypes.transferENS, transferEnsParameters, callback);
const { nonce: newNonce } = await executeENSRap(wallet, ENSRapActionType.transferENS, transferEnsParameters, callback);

return { nonce: newNonce };
},
Expand Down
19 changes: 17 additions & 2 deletions src/hooks/useENSRegistrationCosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function useENSRegistrationCosts({
const duration = yearsDuration * timeUnits.secs.year;
const name = inputName.replace(ENS_DOMAIN, '');
const {
selectedGasFee,
gasFeeParamsBySpeed: useGasGasFeeParamsBySpeed,
currentBlockParams: useGasCurrentBlockParams,
updateTxFee,
Expand Down Expand Up @@ -107,9 +108,11 @@ export default function useENSRegistrationCosts({
ownerAddress: accountAddress,
rentPrice: rentPriceInWei as string,
salt,
selectedGasFee,
gasFeeParamsBySpeed: useGasGasFeeParamsBySpeed,
});
return newCommitGasLimit || '';
}, [accountAddress, duration, name, rentPriceInWei]);
}, [accountAddress, duration, name, rentPriceInWei, selectedGasFee, useGasGasFeeParamsBySpeed]);

const getRegisterRapGasLimit = useCallback(async () => {
const newRegisterRapGasLimit = await estimateENSRegisterSetRecordsAndNameGasLimit({
Expand All @@ -120,9 +123,21 @@ export default function useENSRegistrationCosts({
rentPrice: registrationParameters?.rentPrice,
salt: registrationParameters?.salt,
setReverseRecord: sendReverseRecord,
selectedGasFee: selectedGasFee,
gasFeeParamsBySpeed: useGasGasFeeParamsBySpeed,
});
return newRegisterRapGasLimit || '';
}, [accountAddress, duration, name, registrationParameters?.rentPrice, registrationParameters?.salt, sendReverseRecord, changedRecords]);
}, [
duration,
name,
accountAddress,
changedRecords,
registrationParameters?.rentPrice,
registrationParameters?.salt,
sendReverseRecord,
selectedGasFee,
useGasGasFeeParamsBySpeed,
]);

const getSetRecordsGasLimit = useCallback(async () => {
const newSetRecordsGasLimit = await estimateENSSetRecordsGasLimit({
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useParamsForExchangeModal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SwapModalField, updateSwapSlippage, updateSwapSource } from '@/redux/swap';
import { MutableRefObject, useEffect, useState } from 'react';
import { useSwapInputHandlers } from '@/hooks/index';
import { SwapMetadata } from '@/raps/common';
import { SwapMetadata } from '@/raps/references';
import { useDispatch } from 'react-redux';
import { useRoute } from '@react-navigation/native';
import { TextInput } from 'react-native';
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useSwapSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { AppState } from '@/redux/store';
import { Source, updateSwapSlippage as updateSwapSlippageRedux, updateSwapSource as updateSwapSourceRedux } from '@/redux/swap';
import { Source } from '@/raps/references';
import { updateSwapSlippage as updateSwapSlippageRedux, updateSwapSource as updateSwapSourceRedux } from '@/redux/swap';

export default function useSwapSettings() {
const dispatch = useDispatch();
Expand Down
Loading
Loading