Skip to content

Commit 18eb015

Browse files
drop 13, q1, 2023
1 parent 58ebb64 commit 18eb015

File tree

7 files changed

+103
-11
lines changed

7 files changed

+103
-11
lines changed

components/common/Layout/Layout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ fcl
8282
"0xBlackMarketplace",
8383
process.env.NEXT_PUBLIC_NFT_DAY_TREASURE_CHEST_ADDRESS,
8484
)
85+
.put(
86+
"0xBasicBeastsDrop",
87+
process.env.NEXT_PUBLIC_NFT_DAY_TREASURE_CHEST_ADDRESS,
88+
)
8589
// .put("0xBeastMarket", process.env.NEXT_PUBLIC_BEAST_MARKET_ADDRESS)
8690
// .put("0xBeastOffers", process.env.NEXT_PUBLIC_BEAST_OFFERS_ADDRESS)
8791

components/common/Navbar/Navbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ const Navbar: FC<FuncProps> = ({
668668
setOpenMobileModal={setOpenMobileSearch}
669669
/>
670670
<NavMenu>
671-
<NavItem>
671+
{/* <NavItem>
672672
<NextLink href={"/marketplace/"}>
673673
<A
674674
font={
@@ -680,7 +680,7 @@ const Navbar: FC<FuncProps> = ({
680680
Explore
681681
</A>
682682
</NextLink>
683-
</NavItem>
683+
</NavItem> */}
684684
<NavItem>
685685
<NextLink href={"/rankings/"}>
686686
<A

components/common/SlideOverNavbar/SlideOverNavbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,13 @@ const SlideOverNavbar: FC<Props> = ({
291291
</LargeNavItem>
292292
</a>
293293
</Link>
294-
<Link href="/marketplace">
294+
{/* <Link href="/marketplace">
295295
<a>
296296
<LargeNavItem onClick={() => close()}>
297297
Marketplace
298298
</LargeNavItem>
299299
</a>
300-
</Link>
300+
</Link> */}
301301
<Link href="/rankings">
302302
<a>
303303
<LargeNavItem onClick={() => close()}>

components/ui/PackStore/PackStore.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ const TotalPrice = styled.div<{
339339
color: ${(props) => props.fontColor};
340340
font-size: 4vw;
341341
white-space: nowrap;
342-
margin-bottom: 0.5vw;
342+
margin: 20px 0;
343343
line-height: 40px;
344344
345345
@media (max-width: 1010px) {
346346
font-size: 13vw;
347-
margin: 3vw 0;
347+
margin: 25px 0;
348348
}
349349
`
350350

@@ -604,7 +604,7 @@ type BuyProps = {
604604
}
605605

606606
//Open up for sale
607-
const available = false
607+
const available = true
608608

609609
const Purchase: FC<BuyProps> = ({
610610
maxQuantity,
@@ -621,7 +621,7 @@ const Purchase: FC<BuyProps> = ({
621621

622622
const { logIn, loggedIn } = useAuth()
623623

624-
const { balance, purchase } = useUser()
624+
const { balance, purchase, purchasePackType } = useUser()
625625

626626
const incrementQuantity = () => {
627627
if (quantity < maxQuantity) {
@@ -716,7 +716,7 @@ const Purchase: FC<BuyProps> = ({
716716
>
717717
{calculateTotalPrice().toLocaleString()} <Currency>₣USD</Currency>
718718
</TotalPrice>
719-
<ReservationOption
719+
{/* <ReservationOption
720720
onClick={() => setCheckboxValue(!checkboxValue)}
721721
fontColor={
722722
packType === "Starter"
@@ -738,7 +738,7 @@ const Purchase: FC<BuyProps> = ({
738738
{t("home:reserve-packs")}
739739
<ToolTipText>{t("home:reserve-packs-tooltip")}</ToolTipText>
740740
</ToolTipNoUnderline>
741-
</ReservationOption>
741+
</ReservationOption> */}
742742
<>
743743
{!available ? (
744744
<>
@@ -854,7 +854,11 @@ const Purchase: FC<BuyProps> = ({
854854
const address = checkboxValue
855855
? addressReservable
856856
: addressRefundable
857-
const tx = await purchase(totalPrice, address)
857+
const tx = await purchasePackType(
858+
totalPrice,
859+
address,
860+
packType,
861+
)
858862
if (tx) {
859863
const txId = tx.events[0].transactionId as string
860864
if (tx) {

components/user/UserProvider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const UserProvider: FC = ({ children }) => {
3030
purchase,
3131
loading,
3232
getUserFUSDBalance,
33+
purchasePackType,
3334
} = useFUSD(user)
3435
const {
3536
data: userBeasts,
@@ -158,6 +159,7 @@ const UserProvider: FC = ({ children }) => {
158159
highestSale,
159160
getHighestSale,
160161
beastMarketStuff,
162+
purchasePackType,
161163
}}
162164
>
163165
{children}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
export const PURCHASE_PACK_TYPE = `
2+
import FungibleToken from 0xFungibleToken
3+
import FUSD from 0xFUSD
4+
import BasicBeastsDrop from 0xBasicBeastsDrop
5+
import Pack from 0xPack
6+
import NonFungibleToken from 0xNonFungibleToken
7+
import MetadataViews from 0xMetadataViews
8+
9+
pub fun hasPackCollection(_ address: Address): Bool {
10+
return getAccount(address)
11+
.getCapability<&Pack.Collection{NonFungibleToken.CollectionPublic, Pack.PackCollectionPublic}>(Pack.CollectionPublicPath)
12+
.check()
13+
}
14+
15+
transaction(amount: UFix64, to: Address, type: String) {
16+
prepare(acct: AuthAccount) {
17+
18+
// Check for pack collection
19+
if !hasPackCollection(acct.address) {
20+
if acct.borrow<&Pack.Collection>(from: Pack.CollectionStoragePath) == nil {
21+
acct.save(<-Pack.createEmptyCollection(), to: Pack.CollectionStoragePath)
22+
}
23+
acct.unlink(Pack.CollectionPublicPath)
24+
acct.link<&Pack.Collection{NonFungibleToken.Receiver, NonFungibleToken.CollectionPublic, Pack.PackCollectionPublic, MetadataViews.ResolverCollection}>(Pack.CollectionPublicPath, target: Pack.CollectionStoragePath)
25+
}
26+
27+
BasicBeastsDrop.participate(amount: amount,
28+
vaultAddress: to,
29+
type: type,
30+
vault: <- acct.borrow<&FUSD.Vault>(from: /storage/fusdVault)!.withdraw(amount: amount),
31+
address: acct.address
32+
)
33+
}
34+
}
35+
`

framework/hooks/use-fusd.hook.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import * as fcl from "@onflow/fcl"
1919
import * as FlowTypes from "@onflow/types"
2020
import { PURCHASE } from "flow/transactions/transaction.purchase"
21+
import { PURCHASE_PACK_TYPE } from "flow/transactions/transaction.purchase-pack-type"
2122
import { toast } from "react-toastify"
2223
import { toastStatus } from "@framework/helpers/toastStatus"
2324

@@ -114,10 +115,56 @@ export default function useFUSD(user: any) {
114115
}
115116
}
116117

118+
const purchasePackType = async (amount: any, address: any, type: any) => {
119+
dispatch({ type: "PROCESSING" })
120+
121+
const id = toast.loading("Initializing...")
122+
123+
try {
124+
const res = await send([
125+
transaction(PURCHASE_PACK_TYPE),
126+
args([
127+
arg(amount, FlowTypes.UFix64),
128+
arg(address, FlowTypes.Address),
129+
arg(type, FlowTypes.String),
130+
]),
131+
payer(authz),
132+
proposer(authz),
133+
authorizations([authz]),
134+
limit(9999),
135+
]).then(decode)
136+
tx(res).subscribe((res: any) => {
137+
toastStatus(id, res.status)
138+
})
139+
const trx = await tx(res)
140+
.onceSealed()
141+
.then((result: any) => {
142+
toast.update(id, {
143+
render: "Transaction Sealed",
144+
type: "success",
145+
isLoading: false,
146+
autoClose: 5000,
147+
})
148+
})
149+
getFUSDBalance()
150+
return trx
151+
} catch (err) {
152+
toast.update(id, {
153+
render: "Error, try again later...",
154+
type: "error",
155+
isLoading: false,
156+
autoClose: 5000,
157+
})
158+
dispatch({ type: "ERROR" })
159+
console.log(err)
160+
}
161+
}
162+
117163
return {
118164
...state,
119165
getFUSDBalance,
120166
purchase,
121167
getUserFUSDBalance,
168+
purchasePackType,
122169
}
123170
}

0 commit comments

Comments
 (0)