This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useEffect } from "react"; | |
import ReactMarkdown from "react-markdown"; | |
import axios from "axios"; | |
import { useRouter } from "next/router"; | |
import Link from "next/link"; | |
import { checkUserSession } from "../actions/auth"; | |
const Post = () => { | |
const [content, setContent] = useState(null); | |
const router = useRouter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub contract PinataPartyContract { | |
pub resource NFT { | |
pub let id: UInt64 | |
init(initID: UInt64) { | |
self.id = initID | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub resource interface NFTReceiver { | |
pub fun deposit(token: @NFT, metadata: {String : String}) | |
pub fun getIDs(): [UInt64] | |
pub fun idExists(id: UInt64): Bool | |
pub fun getMetadata(id: UInt64) : {String : String} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub resource Collection: NFTReceiver { | |
pub var ownedNFTs: @{UInt64: NFT} | |
pub var metadataObjs: {UInt64: { String : String }} | |
init () { | |
self.ownedNFTs <- {} | |
self.metadataObjs = {} | |
} | |
pub fun withdraw(withdrawID: UInt64): @NFT { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fun createEmptyCollection(): @Collection { | |
return <- create Collection() | |
} | |
pub resource NFTMinter { | |
pub var idCount: UInt64 | |
init() { | |
self.idCount = 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init() { | |
self.account.save(<-self.createEmptyCollection(), to: /storage/NFTCollection) | |
self.account.link<&{NFTReceiver}>(/public/NFTReceiver, target: /storage/NFTCollection) | |
self.account.save(<-create NFTMinter(), to: /storage/NFTMinter) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub contract PinataPartyContract { | |
pub resource NFT { | |
pub let id: UInt64 | |
init(initID: UInt64) { | |
self.id = initID | |
} | |
} | |
pub resource interface NFTReceiver { | |
pub fun deposit(token: @NFT, metadata: {String : String}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PinataPartyContract from 0xf8d6e0586b0a20c7 | |
transaction { | |
let receiverRef: &{PinataPartyContract.NFTReceiver} | |
let minterRef: &PinataPartyContract.NFTMinter | |
prepare(acct: AuthAccount) { | |
self.receiverRef = acct.getCapability<&{PinataPartyContract.NFTReceiver}>(/public/NFTReceiver) | |
.borrow() | |
?? panic("Could not borrow receiver reference") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PinataPartyContract from 0xf8d6e0586b0a20c7 | |
pub fun main() : {String : String} { | |
let nftOwner = getAccount(0xf8d6e0586b0a20c7) | |
// log("NFT Owner") | |
let capability = nftOwner.getCapability<&{PinataPartyContract.NFTReceiver}>(/public/NFTReceiver) | |
let receiverRef = capability.borrow() | |
?? panic("Could not borrow the receiver reference") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState, useEffect} from 'react' | |
import * as fcl from "@onflow/fcl" | |
const AuthCluster = () => { | |
const [user, setUser] = useState({loggedIn: null}) | |
useEffect(() => fcl.currentUser().subscribe(setUser), []) | |
if (user.loggedIn) { | |
return ( | |
<div> | |
<span>{user?.addr ?? "No Address"}</span> |