Skip to content

Commit d29b3f6

Browse files
authored
Various fixes to work with cupcake UI (#316)
* Various fixes to work with cupcake UI * Usdc to 2 decimals * Remove "NFTs" * Better light mode minted nft
1 parent 80899df commit d29b3f6

File tree

7 files changed

+103
-35
lines changed

7 files changed

+103
-35
lines changed

packages/chat/src/generated/chat.ts

Lines changed: 30 additions & 1 deletion
Large diffs are not rendered by default.

packages/marketplace-ui/src/components/form/LbcForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ async function createLbcCandyMachine(
132132
const metadata = new DataV2({
133133
// Max name len 32
134134
name: "Candymachine Mint Token",
135-
symbol: "NFTs",
135+
symbol: "",
136136
uri: "",
137137
sellerFeeBasisPoints: 0,
138138
creators: null,

packages/marketplace-ui/src/components/lbc/LbcInfo.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
useCurve,
2121
useSolanaUnixTime,
2222
useTokenSwapFromId,
23-
useTokenMetadata,
23+
useMetaplexTokenMetadata,
2424
} from "@strata-foundation/react";
2525
import React, { useEffect, useState } from "react";
2626
import { buildStyles, CircularProgressbar } from "react-circular-progressbar";
@@ -62,12 +62,14 @@ export const LbcInfo = ({
6262
const { isOpen, onToggle } = useDisclosure({
6363
defaultIsOpen: false,
6464
});
65-
const {
66-
tokenBonding,
65+
const {
66+
tokenBonding,
6767
numRemaining,
6868
loading: loadingBonding,
6969
} = useTokenSwapFromId(id);
70-
const { price, loading: loadingPricing } = useLivePrice(tokenBonding?.publicKey);
70+
const { price, loading: loadingPricing } = useLivePrice(
71+
tokenBonding?.publicKey
72+
);
7173
const { mintCap } = useCapInfo(
7274
tokenBonding?.publicKey,
7375
useTokenOfferingCurve
@@ -101,8 +103,10 @@ export const LbcInfo = ({
101103
? tokenBonding.goLiveUnixTime.toNumber() < unixTime
102104
: false;
103105

104-
const { metadata } = useTokenMetadata(tokenBonding?.baseMint);
105-
const { metadata: targetMeta } = useTokenMetadata(tokenBonding?.targetMint);
106+
const { metadata } = useMetaplexTokenMetadata(tokenBonding?.baseMint);
107+
const { metadata: targetMeta } = useMetaplexTokenMetadata(
108+
tokenBonding?.targetMint
109+
);
106110

107111
const renderer = ({
108112
days,
@@ -187,6 +191,8 @@ export const LbcInfo = ({
187191
<BigText>
188192
{isNaN(priceToUse)
189193
? "Not Started"
194+
: metadata?.data.symbol === "USDC"
195+
? `$${numberWithCommas(priceToUse, 2)}`
190196
: `${numberWithCommas(priceToUse, 4)} ${
191197
metadata?.data.symbol
192198
}`}

packages/marketplace-ui/src/components/lbc/mint/CandyMachineInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { ICandyMachineState } from "../../../hooks/useCandyMachineInfo";
33
import { HStack, Text, VStack } from "@chakra-ui/react";
44
import { NATIVE_MINT } from "@solana/spl-token";
55
import { PublicKey } from "@solana/web3.js";
6-
import { useMint, useTokenMetadata } from "@strata-foundation/react";
6+
import { useMint, useMetaplexTokenMetadata } from "@strata-foundation/react";
77
import { toNumber } from "@strata-foundation/spl-token-bonding";
88
import { BigText, BlackBox } from "../LbcInfo";
99
import * as anchor from "@project-serum/anchor";
1010

1111
export const CandyMachineInfo = ({ candyMachine, itemsRemaining, isWhitelistUser, discountPrice }: ICandyMachineState) => {
12-
const { metadata, loading: loadingMeta } = useTokenMetadata(
12+
const { metadata, loading: loadingMeta } = useMetaplexTokenMetadata(
1313
candyMachine?.tokenMint
1414
);
1515
const ticker = loadingMeta ? "" : metadata?.data.symbol || "SOL";

packages/marketplace-ui/src/components/lbc/mint/MintedNftNotification.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Image,
99
Skeleton,
1010
Text,
11+
useColorModeValue,
1112
VStack,
1213
} from "@chakra-ui/react";
1314
import { PublicKey } from "@solana/web3.js";
@@ -27,12 +28,12 @@ export const MintedNftNotification = ({
2728
return (
2829
<Alert
2930
w="full"
30-
bgColor="black.300"
31+
bgColor={useColorModeValue("white", "black.300")}
3132
borderTop="1px"
3233
borderTopColor="gray.600"
3334
rounded="lg"
3435
fontFamily="body"
35-
color="white"
36+
color={useColorModeValue("black", "white")}
3637
status={"success"}
3738
flexDirection="column"
3839
p={0}
@@ -49,7 +50,16 @@ export const MintedNftNotification = ({
4950
/>
5051
)}
5152
</Box>
52-
<VStack align="left" w="full" p={8} spacing={1}>
53+
<VStack
54+
align="left"
55+
w="full"
56+
p={8}
57+
spacing={1}
58+
borderWidth="2px"
59+
borderTopWidth={0}
60+
borderBottomRadius="8px"
61+
borderColor={useColorModeValue("gray.200", "black.300")}
62+
>
5363
<HStack align="left" spacing={1}>
5464
<AlertTitle fontSize="24px" fontWeight={700}>
5565
Success!
@@ -59,16 +69,14 @@ export const MintedNftNotification = ({
5969
<Text color="gray.400">
6070
{loading
6171
? "Waiting on your preview..."
62-
: `Here is a preview of your NFT: ${
63-
metadata ? metadata.data.name : ""
64-
}`}
72+
: `Here is a preview of ${metadata ? metadata.data.name : ""}`}
6573
</Text>
6674
</VStack>
6775
<CloseButton
6876
position="absolute"
6977
right="8px"
7078
top="8px"
71-
color="gray.400"
79+
color={useColorModeValue("gray.600", "gray.400")}
7280
_hover={{ color: "gray.600", cursor: "pointer" }}
7381
onClick={onDismiss}
7482
/>

packages/marketplace-ui/src/components/lbc/mint/candy-machine.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,19 @@ export const mintOneToken = async (
422422
}
423423
}
424424

425+
// Close intermediary account
426+
if (tokenBonding && (ataBalance || 0) == 1) {
427+
instructions.push(
428+
Token.createCloseAccountInstruction(
429+
TOKEN_PROGRAM_ID,
430+
userPayingAccountAddress,
431+
payer,
432+
payer,
433+
[]
434+
)
435+
);
436+
}
437+
425438
await sendMultipleInstructions(
426439
tokenBondingSdk.errors || new Map(),
427440
tokenBondingSdk.provider,

packages/spl-utils/src/transaction.ts

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,39 @@ export async function sendMultipleInstructions(
9393
const recentBlockhash = (
9494
await provider.connection.getRecentBlockhash("confirmed")
9595
).blockhash;
96-
const txns = instructionGroups
97-
.map((instructions, index) => {
98-
const signers = signerGroups[index];
99-
if (instructions.length > 0) {
100-
const tx = new Transaction({
101-
feePayer: payer || provider.wallet.publicKey,
102-
recentBlockhash,
103-
});
104-
tx.add(...instructions);
105-
if (signers.length > 0) {
106-
tx.partialSign(...signers);
107-
}
96+
const ixAndSigners = instructionGroups
97+
.filter((instructions) => instructions.length > 0)
98+
.map((instructions, i) => {
99+
const signers = signerGroups[i];
100+
101+
return {
102+
instructions,
103+
signers,
104+
};
105+
});
106+
const txns = ixAndSigners.map(({ instructions }) => {
107+
const tx = new Transaction({
108+
feePayer: payer || provider.wallet.publicKey,
109+
recentBlockhash,
110+
});
111+
112+
tx.add(...instructions);
113+
114+
return tx;
115+
});
108116

109-
return tx;
117+
const txnsSignedByWallet = (await provider.wallet.signAllTransactions(txns));
118+
const txnsSigned = txnsSignedByWallet
119+
.map((tx, index) => {
120+
const signers = ixAndSigners[index].signers;
121+
122+
if (signers.length > 0) {
123+
tx.partialSign(...signers);
110124
}
111-
})
112-
.filter(truthy);
113125

114-
const txnsSigned = (await provider.wallet.signAllTransactions(txns)).map(
115-
(tx) => tx.serialize()
116-
);
126+
return tx;
127+
})
128+
.map((tx) => tx.serialize());
117129

118130
console.log("Sending multiple transactions...");
119131
try {

0 commit comments

Comments
 (0)