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

nfts: mints #5019

Merged
merged 51 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
eedad81
init
skylarbarrera Aug 25, 2023
a00e204
Merge branch 'develop' into @skylar/mints
skylarbarrera Aug 25, 2023
6eb4f52
inti
skylarbarrera Aug 25, 2023
37663f9
new api + routing
skylarbarrera Sep 13, 2023
42fa90c
nftOffers -> reservior
skylarbarrera Sep 13, 2023
7bc1844
pending tx padding
skylarbarrera Sep 18, 2023
aa08232
i18n
skylarbarrera Sep 18, 2023
5088ca9
analytics WIP
skylarbarrera Sep 18, 2023
5a78dda
api updates + clean up
skylarbarrera Sep 18, 2023
811519f
Merge branch 'develop' into @skylar/mints
skylarbarrera Sep 19, 2023
28902bd
prettier & revert gascard
skylarbarrera Sep 19, 2023
294b38c
revert dev only endpoint
skylarbarrera Sep 19, 2023
c9eb904
graphql
skylarbarrera Sep 19, 2023
4dc00ea
rm french strings
skylarbarrera Sep 19, 2023
e21b950
android route
skylarbarrera Sep 19, 2023
aaca2f1
analytics
skylarbarrera Sep 21, 2023
4ce4a6f
Merge branch 'develop' into @skylar/mints
skylarbarrera Sep 27, 2023
f071f67
connect the dots
skylarbarrera Sep 28, 2023
88f6a75
bump reservior sdk
skylarbarrera Oct 2, 2023
43b4151
add fallback color to gas components
skylarbarrera Oct 2, 2023
0d1c089
quantityButton: handle disabled state
skylarbarrera Oct 2, 2023
8d35ff1
gas: add util to get total gas price
skylarbarrera Oct 2, 2023
fca66f2
tweak nft image size for tx cell
skylarbarrera Oct 2, 2023
b3f9396
mint sheet updates
skylarbarrera Oct 2, 2023
d026b65
i18n
skylarbarrera Oct 2, 2023
37b9070
query update
skylarbarrera Oct 2, 2023
3236ea8
use dev endpoints for testing
skylarbarrera Oct 2, 2023
4e86cac
Merge branch 'develop' into @skylar/mints
skylarbarrera Oct 2, 2023
3262ddc
add back tx ref
skylarbarrera Oct 2, 2023
88f1152
tweak quantity button disabled color
skylarbarrera Oct 2, 2023
a54b0d8
fix disabled state color
skylarbarrera Oct 3, 2023
6bae34e
add max label
skylarbarrera Oct 3, 2023
1b2246f
fix price calculation
skylarbarrera Oct 3, 2023
3a05954
max mint fallback + native display
skylarbarrera Oct 3, 2023
294a42a
add refferal addresses
skylarbarrera Oct 3, 2023
b253c49
rm log
skylarbarrera Oct 3, 2023
fe4d705
error handling
skylarbarrera Oct 5, 2023
f6421b4
Merge branch 'develop' into @skylar/mints
skylarbarrera Oct 6, 2023
60faf6f
useCallbacks
skylarbarrera Oct 12, 2023
9c9a88b
clean up search logic
skylarbarrera Oct 12, 2023
5b55e97
i18n + analytics clean up
skylarbarrera Oct 12, 2023
35e1320
debug logging
skylarbarrera Oct 12, 2023
21e4798
format + lint
skylarbarrera Oct 12, 2023
60bd8b3
priceInEth
skylarbarrera Oct 12, 2023
8df2f45
Merge branch 'develop' into @skylar/mints
skylarbarrera Oct 12, 2023
b15a955
fix disabled state
skylarbarrera Oct 12, 2023
b886fa1
add error event
skylarbarrera Oct 12, 2023
bdcf4c6
revert to prod
skylarbarrera Oct 12, 2023
ed6bd58
callback
skylarbarrera Oct 12, 2023
4241c16
oops
skylarbarrera Oct 12, 2023
88a7c9b
Merge branch 'develop' into @skylar/mints
skylarbarrera Oct 13, 2023
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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"@react-navigation/material-top-tabs": "6.6.2",
"@react-navigation/native": "6.1.6",
"@react-navigation/stack": "6.3.16",
"@reservoir0x/reservoir-sdk": "1.2.1",
"@reservoir0x/reservoir-sdk": "1.4.5",
"@segment/analytics-react-native": "2.15.0",
"@segment/sovran-react-native": "1.0.4",
"@sentry/react-native": "3.4.1",
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ import { migrate } from '@/migrations';
import { initListeners as initWalletConnectListeners } from '@/walletConnect';
import { saveFCMToken } from '@/notifications/tokens';
import branch from 'react-native-branch';
import { initializeReservoirClient } from '@/resources/nftOffers/utils';
import { initializeReservoirClient } from '@/resources/reservoir/client';

if (__DEV__) {
reactNativeDisableYellowBox && LogBox.ignoreAllLogs();
Expand Down
23 changes: 23 additions & 0 deletions src/analytics/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CardType } from '@/components/cards/GenericCard';
import { LearnCategory } from '@/components/cards/utils/types';
import { FiatProviderName } from '@/entities/f2c';
import { Network } from '@/networks/types';

/**
* All events, used by `analytics.track()`
Expand Down Expand Up @@ -78,9 +79,14 @@ export const event = {
nftOffersSelectedSortCriterion: 'Selected NFT Offers Sort Criterion',
nftOffersAcceptedOffer: 'Accepted NFT Offer',

nftMintsOpenedSheet: 'Opened NFT Mint Sheet',
nftMintsMintingNFT: 'Minting NFT',
nftMintsMintedNFT: 'Minted NFT',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a big deal but i think the naming convention should match the existing ones that i created for mints (see line 93 and below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it


poapsOpenedMintSheet: 'Opened POAP mint sheet',
poapsMintedPoap: 'Minted POAP',
poapsViewedOnPoap: 'Viewed POAP on poap.gallery',

positionsOpenedSheet: 'Opened position Sheet',
positionsOpenedExternalDapp: 'Viewed external dapp',

Expand Down Expand Up @@ -292,6 +298,23 @@ export type EventProperties = {
rainbowFee: number;
offerCurrency: { symbol: string; contractAddress: string };
};
[event.nftMintsMintingNFT]: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should use chainId instead of Network. network might have been a better call tbh, but i already used chainId for existing events. aligning them would make amplitude stuff a lot more straightforward

also can we add priceInEth like the existing events below? currently we're using this to group mints in amplitude by free/paid. https://github.com/rainbow-me/rainbow/blob/develop/src/components/cards/FeaturedMintCard.tsx#L119-L123

contract: string;
network: Network;
quantity: number;
collectionName: string;
};
[event.nftMintsMintedNFT]: {
contract: string;
network: Network;
quantity: number;
collectionName: string;
};
[event.nftMintsOpenedSheet]: {
contract: string;
network: Network;
collectionName: string;
};
[event.poapsMintedPoap]: {
eventId: number;
type: 'qrHash' | 'secretWord';
Expand Down
8 changes: 7 additions & 1 deletion src/components/cards/FeaturedMintCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { IS_IOS } from '@/env';
import { Media } from '../Media';
import { analyticsV2 } from '@/analytics';
import * as i18n from '@/languages';
import { navigateToMintCollection } from '@/resources/reservoir/mints';
import { ethereumUtils } from '@/utils';

const IMAGE_SIZE = 111;

Expand Down Expand Up @@ -123,7 +125,11 @@ export function FeaturedMintCard() {
),
}
);
Linking.openURL(featuredMint.externalURL);
const network = ethereumUtils.getNetworkFromChainId(
featuredMint.chainId
);
navigateToMintCollection(featuredMint.contract, network);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im no expert on this but could be worth pulling out into a useCallback so the callback isn't recreated multiple times

// Linking.openURL(featuredMint.externalURL);
}}
scaleTo={0.96}
>
Expand Down
7 changes: 5 additions & 2 deletions src/components/cards/MintsCard/CollectionCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import { ButtonPressAnimation } from '@/components/animations';
import { useTheme } from '@/theme';
import { Linking, View } from 'react-native';
import { MintableCollection } from '@/graphql/__generated__/arc';
import { getNetworkFromChainId } from '@/utils/ethereumUtils';
import ethereumUtils, { getNetworkFromChainId } from '@/utils/ethereumUtils';
import { getNetworkObj } from '@/networks';
import { analyticsV2 } from '@/analytics';
import * as i18n from '@/languages';
import { IS_IOS } from '@/env';
import { ImgixImage } from '@/components/images';
import { navigateToMintCollection } from '@/resources/reservoir/mints';

export const NFT_IMAGE_SIZE = 111;

Expand Down Expand Up @@ -98,7 +99,9 @@ export function CollectionCell({
chainId: collection.chainId,
priceInEth: amount,
});
Linking.openURL(collection.externalURL);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im no expert on this but could be worth pulling out into a useCallback so the callback isn't recreated multiple times

const network = ethereumUtils.getNetworkFromChainId(collection.chainId);
navigateToMintCollection(collection.contract, network);
}}
style={{ width: NFT_IMAGE_SIZE }}
>
Expand Down
5 changes: 4 additions & 1 deletion src/components/cards/NFTOffersCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
ShimmerAnimation,
} from '@/components/animations';
import { useAccountSettings, useDimensions } from '@/hooks';
import { nftOffersQueryKey, useNFTOffers } from '@/resources/nftOffers';
import {
nftOffersQueryKey,
useNFTOffers,
} from '@/resources/reservoir/nftOffersQuery';
import { convertAmountToNativeDisplay } from '@/helpers/utilities';
import * as i18n from '@/languages';
import Animated, {
Expand Down
11 changes: 11 additions & 0 deletions src/components/coin-row/FastTransactionCoinRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { useNavigation } from '@/navigation';
import Routes from '@rainbow-me/routes';
import { ImgixImage } from '../images';
import { CardSize } from '../unique-token/CardSize';
import { ChainBadge } from '../coin-icon';
import { Network } from '@/networks/types';
import { ethereumUtils } from '@/utils';

const BottomRow = React.memo(function BottomRow({
description,
Expand Down Expand Up @@ -139,6 +142,14 @@ export default React.memo(function TransactionCoinRow({
}}
/>
</View>
{item.network !== Network.mainnet && (
<ChainBadge
assetType={ethereumUtils.getAssetTypeFromNetwork(
item.network
)}
badgeYPosition={10}
/>
)}
</View>
) : (
<FastCoinIcon
Expand Down
13 changes: 13 additions & 0 deletions src/components/coin-row/FastTransactionStatusBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ const StatusProps = {
marginTop: ios ? -3 : -5,
},
},
[TransactionStatusTypes.minted]: {
name: 'sunflower',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lfg sunflower gang

style: {
fontSize: 11,
left: -1.3,
marginRight: 1,
marginTop: ios ? -3 : -5,
},
},
[TransactionStatusTypes.minting]: {
marginRight: 4,
marginTop: ios ? 1 : 0,
},
};

const sx = StyleSheet.create({
Expand Down
10 changes: 4 additions & 6 deletions src/components/contacts/ContactAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ const ContactAvatar = ({ color, size = 'medium', value, ...props }) => {
]);
const { isDarkMode } = useTheme();

const shadows = useMemo(() => buildShadows(color, size, isDarkMode, colors), [
color,
size,
isDarkMode,
colors,
]);
const shadows = useMemo(
() => buildShadows(color, size, props?.forceDarkMode || isDarkMode, colors),
[color, size, props?.forceDarkMode, isDarkMode, colors]
);

const backgroundColor =
typeof color === 'number'
Expand Down
10 changes: 7 additions & 3 deletions src/components/expanded-state/CustomGasState.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { SlackSheet } from '../sheet';
import { FeesPanel, FeesPanelTabs } from './custom-gas';
import { getTrendKey } from '@/helpers/gas';
import {
useAccountSettings,
useColorForAsset,
useDimensions,
useGas,
Expand Down Expand Up @@ -42,12 +41,17 @@ const FeesPanelTabswrapper = styled(Column)(margin.object(19, 0, 24, 0));
export default function CustomGasState({ asset }) {
const { setParams } = useNavigation();
const {
params: { longFormHeight, speeds, openCustomOptions } = {},
params: { longFormHeight, speeds, openCustomOptions, fallbackColor } = {},
} = useRoute();
const { colors } = useTheme();
const { height: deviceHeight } = useDimensions();
const keyboardHeight = useKeyboardHeight();
const colorForAsset = useColorForAsset(asset || {}, null, false, true);
const colorForAsset = useColorForAsset(
asset || {},
fallbackColor,
false,
true
);
const { selectedGasFee, currentBlockParams, txNetwork } = useGas();
const [canGoBack, setCanGoBack] = useState(true);
const { tradeDetails } = useSelector(state => state.swap);
Expand Down
9 changes: 8 additions & 1 deletion src/components/gas/GasSpeedButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const GasSpeedButton = ({
asset,
currentNetwork,
horizontalPadding = 19,
fallbackColor,
marginBottom = 20,
marginTop = 18,
speeds = null,
Expand All @@ -151,7 +152,12 @@ const GasSpeedButton = ({
const { colors } = useTheme();
const { navigate, goBack } = useNavigation();
const { nativeCurrencySymbol, nativeCurrency } = useAccountSettings();
const rawColorForAsset = useColorForAsset(asset || {}, null, false, true);
const rawColorForAsset = useColorForAsset(
asset || {},
fallbackColor,
false,
true
);
const [isLongWait, setIsLongWait] = useState(false);

const { inputCurrency, outputCurrency } = useSwapCurrencies();
Expand Down Expand Up @@ -229,6 +235,7 @@ const GasSpeedButton = ({
if (gasIsNotReady) return;
navigate(Routes.CUSTOM_GAS_SHEET, {
asset,
fallbackColor,
flashbotTransaction,
focusTo: shouldOpenCustomGasSheet.focusTo,
openCustomOptions: focusTo => openCustomOptionsRef.current(focusTo),
Expand Down
4 changes: 4 additions & 0 deletions src/entities/transactions/transactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export enum TransactionStatus {
depositing = 'depositing',
dropped = 'dropped',
failed = 'failed',
minted = 'minted',
minting = 'minting',
purchased = 'purchased',
purchasing = 'purchasing',
received = 'received',
Expand Down Expand Up @@ -39,6 +41,8 @@ export default {
depositing: 'depositing',
dropped: 'dropped',
failed: 'failed',
minted: 'minted',
minting: 'minting',
purchased: 'purchased',
purchasing: 'purchasing',
received: 'received',
Expand Down
2 changes: 2 additions & 0 deletions src/entities/transactions/transactionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export enum TransactionType {
deposit = 'deposit',
dropped = 'dropped',
execution = 'execution',
mint = 'mint',
purchase = 'purchase', // Rainbow-specific type
receive = 'receive',
repay = 'repay',
Expand All @@ -25,6 +26,7 @@ export default {
deposit: 'deposit',
dropped: 'dropped',
execution: 'execution',
mint: 'mint',
purchase: 'purchase',
receive: 'receive',
repay: 'repay',
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.config = {
document: './queries/arc.graphql',
schema: {
method: 'GET',
url: 'https://arc-graphql.rainbow.me/graphql',
url: 'https://arc-graphql.rainbowdotme.workers.dev/graphql',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to switch back to prod endpoint

headers: {
'x-api-key': 'ARC_GRAPHQL_API_KEY',
},
Expand Down
2 changes: 1 addition & 1 deletion src/graphql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const ensClient = getEnsSdk(getFetchRequester(config.ens));
export const metadataClient = getMetadataSdk(
getFetchRequester(config.metadata)
);
export const arcClient = getArcSdk(getFetchRequester(config.arc));
export const arcClient = getArcSdk(getFetchRequester(config.arcDev));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to switch back to prod endpoint

export const arcDevClient = getArcDevSdk(getFetchRequester(config.arcDev));
45 changes: 45 additions & 0 deletions src/graphql/queries/arc.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,51 @@ query claimPoapBySecretWord($walletAddress: String!, $secretWord: String!) {
}
}

query getReservoirCollection($contractAddress: String!, $chainId: Int!) {
getReservoirCollection(contractAddress: $contractAddress, chainId: $chainId) {
collection {
id
chainId
createdAt
name
image
description
sampleImages
tokenCount
creator
ownerCount
isMintingPublicSale
publicMintInfo {
stage
kind
price {
currency {
contract
name
symbol
decimals
}
amount {
raw
decimal
usd
native
}
netAmount {
raw
decimal
usd
native
}
}
startTime
endTime
maxMintsPerWallet
}
}
}
}

fragment mintStatus on MintStatus {
isMintable
price
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ const getConfirmedState = (type?: TransactionType): TransactionStatus => {
return TransactionStatus.approved;
case TransactionTypes.sell:
return TransactionStatus.sold;
case TransactionTypes.mint:
return TransactionStatus.minted;
case TransactionTypes.deposit:
return TransactionStatus.deposited;
case TransactionTypes.withdraw:
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export const getConfirmedState = (
return TransactionStatus.purchased;
case TransactionTypes.sell:
return TransactionStatus.sold;
case TransactionTypes.mint:
return TransactionStatus.minted;
default:
return TransactionStatus.sent;
}
Expand Down
13 changes: 13 additions & 0 deletions src/hooks/useGas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ export default function useGas({
[dispatch]
);

const getTotalGasPrice = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob should be in useCallback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yess ty king

const txFee = gasData?.selectedGasFee?.gasFee;
const isLegacyGasNetwork =
getNetworkObj(gasData?.txNetwork).gas.gasType === 'legacy';
const txFeeValue = isLegacyGasNetwork
? (txFee as LegacyGasFee)?.estimatedFee
: (txFee as GasFee)?.maxFee;

const txFeeAmount = fromWei(txFeeValue?.value?.amount);
return txFeeAmount;
};

return {
isGasReady,
isSufficientGas,
Expand All @@ -197,6 +209,7 @@ export default function useGas({
updateGasFeeOption,
updateToCustomGasFee,
updateTxFee,
getTotalGasPrice,
...gasData,
};
}
Loading
Loading