Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
5 changes: 2 additions & 3 deletions components/mint/mint-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MintButton = (workoutData: string): JSX.Element => {
try {
const result = await pinJson(workoutData);
setFileUrl(result);
return result;
} catch (error) {
console.log(`[Error uploading data to IPFS] ${error}`);
}
Expand All @@ -43,9 +44,7 @@ const MintButton = (workoutData: string): JSX.Element => {
signer
);

//TODO: don't hard code this
const uploadWorkoutUrl =
"https://gateway.pinata.cloud/ipfs/Qmd4k2bMfiLeqgV4HDddGffSQ4v864n4rdK6fyciQDtfE5"; //await uploadToPinata();
const uploadWorkoutUrl = await uploadToPinata();

const transaction = await contract.mintWorkout(uploadWorkoutUrl);
setIsMinting(true);
Expand Down
15 changes: 8 additions & 7 deletions pages/exercises.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Wrap, WrapItem, Flex, Box, Heading, Center, Icon, HStack } from "@chakra-ui/react";
import useAddress from '../utils/useAddress.js';
import { MdClose } from 'react-icons/md'
import {ArweaveApolloClient} from './api/apollo/apollo-client.ts';
import { ArweaveApolloClient } from './api/apollo/apollo-client.ts';
import ExerciseModal from "../components/ExerciseModal";
import MintButton from "../components/mint/mint-button";
import { useState } from 'react';
import {fetchTransactionsByTag} from '../pages/api/arweave-client';
import { fetchTransactionsByTag } from '../pages/api/arweave-client';

function arweaveTxnToExercise(txn) {
const {tags} = txn.node
const { tags } = txn.node


let exerciseObject = {}
Expand All @@ -31,7 +31,8 @@ function Exercises(data) {
if (newWorkout.length >= 7) {
return
}
if (!newWorkout?.some(x => x === workout)) {

if (!newWorkout?.some(x => x.name === workout.name)) {
setNewWorkout(oldState => [...oldState, workout]);
}
}
Expand Down Expand Up @@ -78,7 +79,7 @@ function Exercises(data) {
})}
</Box>
<Center>
{newWorkout.length > 0 && address && <MintButton workoutData={`{"name": "test"}`} />}
{newWorkout.length > 0 && address && <MintButton workoutData={JSON.stringify(exercises)} />}
{!address && <p>☝️ Connect wallet to mint ☝️</p>}
</Center>
</Box>
Expand All @@ -90,9 +91,9 @@ export async function getStaticProps() {
// Call an external API endpoint to get posts.
// You can use any data fetching library
const data = await fetchTransactionsByTag("swole-protocol");
const { edges } = data.props;
const { edges } = data.props;

console.log(edges.length)
console.log(edges.length)
// By returning { props: { posts } }, the Blog component
// will receive `posts` as a prop at build time
return {
Expand Down