From 6ec1036b0c94a479e9e9bea425237a12658baacd Mon Sep 17 00:00:00 2001 From: Christopher Canaday Date: Sun, 27 Apr 2025 17:08:57 -0400 Subject: [PATCH 1/5] in progress --- .../src/components/MintTicketsModal.tsx | 33 ++++++++++++++++++- packages/blockchain/src/lib/blockchain.ts | 4 +-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/apps/vendorweb/src/components/MintTicketsModal.tsx b/apps/vendorweb/src/components/MintTicketsModal.tsx index 9dcca1d..507cb1e 100644 --- a/apps/vendorweb/src/components/MintTicketsModal.tsx +++ b/apps/vendorweb/src/components/MintTicketsModal.tsx @@ -4,6 +4,7 @@ import { ContractAddress, ContractABI } from '@platform/blockchain'; import { CrossCircledIcon } from '@radix-ui/react-icons'; import { Button, Callout, Dialog, Flex, Text } from '@radix-ui/themes'; import { useState } from 'react'; +import { formatGwei } from 'viem'; export interface MintTicketsModalProps { onClose: () => void; @@ -71,6 +72,27 @@ export default function MintTicketsModal({ const p = await primaryWallet.getPublicClient(); if (w && p) { + console.log('TEST'); + // const gas = await p.estimateContractGas({ + // address: ContractAddress, + // abi: ContractABI, + // functionName: 'create_new_event', + // args: [ + // NFTMintingDescription, + // `https://opentix.co/event/${ID}`, + // NumUnique, + // NumGa, + // Basecost + // ] + // }); + console.log('TEST2'); + + // const gasPrice = await p.getGasPrice() + + // console.log(`GAS USED ${gas}`) + // console.log(`GAS PRICE (wei) ${gasPrice}`) + // console.log(`MULT (total wei) ${gas*gasPrice}`) + // console.log(`POL ${formatGwei(gas*gasPrice)}`) const { request } = await p.simulateContract({ abi: ContractABI, address: ContractAddress, @@ -81,9 +103,18 @@ export default function MintTicketsModal({ `https://opentix.co/event/${ID}`, NumUnique, NumGa, - Array(NumGa + NumUnique).fill(Basecost) + Basecost ] + // gas: gas }); + + console.log('TEST3'); + + // const gasPrice = await p.getGasPrice(); + // p.estimateGas() + + // console.log(`GAS PRICE (WEI) ${gasPrice}`); + const hash = await w.writeContract(request); passTransactionHash(hash); await updateEventWithTransactionHash(hash); diff --git a/packages/blockchain/src/lib/blockchain.ts b/packages/blockchain/src/lib/blockchain.ts index d34a86b..f7d0850 100644 --- a/packages/blockchain/src/lib/blockchain.ts +++ b/packages/blockchain/src/lib/blockchain.ts @@ -1,6 +1,6 @@ import { polygonAmoy } from 'viem/chains'; -export const ContractAddress = '0x41c3462A19a267D8F5690D5b411c4e46aCf0bbcB'; +export const ContractAddress = '0x4B10Ca604B40b782eF00b497357b3dc9478457DF'; export type ContractGetEventIdsReturnedMetadata = { min: bigint; @@ -341,7 +341,7 @@ export const ContractABI = [ type: 'uint256' }, { internalType: 'uint256', name: 'unique_seats', type: 'uint256' }, - { internalType: 'uint256[]', name: 'costs', type: 'uint256[]' } + { internalType: 'uint256', name: 'cost', type: 'uint256' } ], name: 'create_new_event', outputs: [], From 2d9d91919531a179d403f50c47eece2f37f81c94 Mon Sep 17 00:00:00 2001 From: Christopher Canaday Date: Sun, 27 Apr 2025 18:38:10 -0400 Subject: [PATCH 2/5] Now uses just the UUID for the event_name --- apps/usermobile/components/EventView.tsx | 10 +++--- apps/usermobile/components/TicketListing.tsx | 4 +-- .../src/components/BuyTicketsModal.tsx | 2 +- .../src/components/ListOfNFTsForEvent.tsx | 2 +- apps/userweb/src/views/Profile.tsx | 4 +-- .../vendormobile/src/screens/EventDetails.tsx | 6 ++-- .../src/components/ListOfNFTsForEvent.tsx | 2 +- .../src/components/MintTicketsModal.tsx | 32 +------------------ apps/vendorweb/src/views/Details.tsx | 2 +- 9 files changed, 13 insertions(+), 51 deletions(-) diff --git a/apps/usermobile/components/EventView.tsx b/apps/usermobile/components/EventView.tsx index 061f98c..66cfb89 100644 --- a/apps/usermobile/components/EventView.tsx +++ b/apps/usermobile/components/EventView.tsx @@ -48,9 +48,9 @@ export default function EventView({ const runner = async () => { const name = await getEventNameFromId(BigInt(Event)); - const split = name.split(' '); - const uuid = split[split.length - 1]; - const data = await getEventByUUID(uuid); + // const split = name.split(' '); + // const uuid = split[split.length - 1]; + const data = await getEventByUUID(name); setEventData(data as UserEventDetailsResponse); setTicketTransferable(await checkIfTicketIsTransferable()); }; @@ -126,10 +126,8 @@ export default function EventView({ // check the user in with the vendor async function checkin() { const name = await getEventNameFromId(BigInt(Event)); - const split = name.split(' '); - const uuid = split[split.length - 1]; - setqrData(await computeQRData(`${Event}`, `${uuid}`)); + setqrData(await computeQRData(`${Event}`, `${name}`)); setModalText('Show the vendor this QR code'); setModalVisible(true); } diff --git a/apps/usermobile/components/TicketListing.tsx b/apps/usermobile/components/TicketListing.tsx index e1fa078..03b3a6e 100644 --- a/apps/usermobile/components/TicketListing.tsx +++ b/apps/usermobile/components/TicketListing.tsx @@ -180,9 +180,7 @@ const HomeScreen = () => { } // grab the event data - const split = event_names[i].split(' '); - const uuid = split[split.length - 1]; - event_data[i] = await getEventByUUID(uuid); + event_data[i] = await getEventByUUID(event_names[i]); } return { ids, event_data }; diff --git a/apps/userweb/src/components/BuyTicketsModal.tsx b/apps/userweb/src/components/BuyTicketsModal.tsx index 22b2091..b21da4a 100644 --- a/apps/userweb/src/components/BuyTicketsModal.tsx +++ b/apps/userweb/src/components/BuyTicketsModal.tsx @@ -37,7 +37,7 @@ export default function BuyTicketsModal({ const { primaryWallet } = useDynamicContext(); - const NFTMintingDescription = `${Title} at ${EventDatetime} - ${ID}`; + const NFTMintingDescription = `${ID}`; const Disclaimer = `You are about to buy a ticket for ${NFTMintingDescription}.`; diff --git a/apps/userweb/src/components/ListOfNFTsForEvent.tsx b/apps/userweb/src/components/ListOfNFTsForEvent.tsx index 9c84720..db05c06 100644 --- a/apps/userweb/src/components/ListOfNFTsForEvent.tsx +++ b/apps/userweb/src/components/ListOfNFTsForEvent.tsx @@ -25,7 +25,7 @@ export default function ListOfNFTsForEvent({ setTicketId, setShouldShowBuyModal }: ListOfNFTsForEventProps) { - const NFTMintingDescription = `${Title} at ${EventDatetime} - ${ID}`; + const NFTMintingDescription = `${ID}`; const { primaryWallet } = useDynamicContext(); const [NFTs, setNFTs] = useState([]); const [metadata, setMetadata] = useState(); diff --git a/apps/userweb/src/views/Profile.tsx b/apps/userweb/src/views/Profile.tsx index a39e6ce..8503066 100644 --- a/apps/userweb/src/views/Profile.tsx +++ b/apps/userweb/src/views/Profile.tsx @@ -240,10 +240,8 @@ export default function Profile() { const ticket_data = [] as TicketInfo[]; for (let i = 0; i < event_names.length; i++) { // grab the event data - const split = event_names[i].split(' '); - const uuid = split[split.length - 1]; const event = (await getEventByUUID( - uuid + event_names[i] )) as UserEventDetailsResponse; const event_date = new Date(event.EventDatetime); diff --git a/apps/vendormobile/src/screens/EventDetails.tsx b/apps/vendormobile/src/screens/EventDetails.tsx index 9418649..b3f72da 100644 --- a/apps/vendormobile/src/screens/EventDetails.tsx +++ b/apps/vendormobile/src/screens/EventDetails.tsx @@ -105,8 +105,6 @@ export default function EventDetails({ const senderaddress = fields[2]; const event_name = await getEventNameFromId(BigInt(id)); - const split = event_name.split(' '); - const uuid = split[split.length - 1]; const tmp = await getNFTsInWallet(senderaddress); // parse into an array @@ -140,7 +138,7 @@ export default function EventDetails({ const valid = await publicViemClient.verifyMessage({ address: senderaddress as Address, - message: uuid, + message: event_name, signature: signedmessage as Address }); @@ -149,7 +147,7 @@ export default function EventDetails({ } // do the api call - const resp = await checkin(uuid, parseInt(id)); + const resp = await checkin(event_name, parseInt(id)); if (!resp) { return 'Ticket already checked in'; diff --git a/apps/vendorweb/src/components/ListOfNFTsForEvent.tsx b/apps/vendorweb/src/components/ListOfNFTsForEvent.tsx index 60e9290..e38e7e5 100644 --- a/apps/vendorweb/src/components/ListOfNFTsForEvent.tsx +++ b/apps/vendorweb/src/components/ListOfNFTsForEvent.tsx @@ -19,7 +19,7 @@ export default function ListOfNFTsForEvent({ EventDatetime, ID }: ListOfNFTsForEventProps) { - const NFTMintingDescription = `${Title} at ${EventDatetime} - ${ID}`; + const NFTMintingDescription = `${ID}`; const { primaryWallet } = useDynamicContext(); const [NFTs, setNFTs] = useState([]); const [metadata, setMetadata] = diff --git a/apps/vendorweb/src/components/MintTicketsModal.tsx b/apps/vendorweb/src/components/MintTicketsModal.tsx index 507cb1e..9a22ee0 100644 --- a/apps/vendorweb/src/components/MintTicketsModal.tsx +++ b/apps/vendorweb/src/components/MintTicketsModal.tsx @@ -4,7 +4,6 @@ import { ContractAddress, ContractABI } from '@platform/blockchain'; import { CrossCircledIcon } from '@radix-ui/react-icons'; import { Button, Callout, Dialog, Flex, Text } from '@radix-ui/themes'; import { useState } from 'react'; -import { formatGwei } from 'viem'; export interface MintTicketsModalProps { onClose: () => void; @@ -34,7 +33,7 @@ export default function MintTicketsModal({ const { primaryWallet } = useDynamicContext(); - const NFTMintingDescription = `${Title} at ${EventDatetime} - ${ID}`; + const NFTMintingDescription = `${ID}`; const Disclaimer = `You are about to mint ${NumGa} General Admission tickets and ${NumUnique} Unique tickets for ${NFTMintingDescription}.`; @@ -72,27 +71,6 @@ export default function MintTicketsModal({ const p = await primaryWallet.getPublicClient(); if (w && p) { - console.log('TEST'); - // const gas = await p.estimateContractGas({ - // address: ContractAddress, - // abi: ContractABI, - // functionName: 'create_new_event', - // args: [ - // NFTMintingDescription, - // `https://opentix.co/event/${ID}`, - // NumUnique, - // NumGa, - // Basecost - // ] - // }); - console.log('TEST2'); - - // const gasPrice = await p.getGasPrice() - - // console.log(`GAS USED ${gas}`) - // console.log(`GAS PRICE (wei) ${gasPrice}`) - // console.log(`MULT (total wei) ${gas*gasPrice}`) - // console.log(`POL ${formatGwei(gas*gasPrice)}`) const { request } = await p.simulateContract({ abi: ContractABI, address: ContractAddress, @@ -105,16 +83,8 @@ export default function MintTicketsModal({ NumGa, Basecost ] - // gas: gas }); - console.log('TEST3'); - - // const gasPrice = await p.getGasPrice(); - // p.estimateGas() - - // console.log(`GAS PRICE (WEI) ${gasPrice}`); - const hash = await w.writeContract(request); passTransactionHash(hash); await updateEventWithTransactionHash(hash); diff --git a/apps/vendorweb/src/views/Details.tsx b/apps/vendorweb/src/views/Details.tsx index 41d4b46..1724ca4 100644 --- a/apps/vendorweb/src/views/Details.tsx +++ b/apps/vendorweb/src/views/Details.tsx @@ -244,7 +244,7 @@ export default function Details({ typestring }: DetailsProps) { const updateTransactionHash = async (hash: string) => { setLatestTransactionHash(hash); setShouldGrayOutPage(true); - const NFTMintingDescription = `${(data as Event)?.Name} at ${(data as Event)?.EventDatetime} - ${(data as Event)?.ID}`; + const NFTMintingDescription = `${(data as Event)?.ID}`; try { if (primaryWallet && isEthereumWallet(primaryWallet)) { const p = await primaryWallet.getPublicClient(); From 6bec5584bda7d27a86334890077f712a90c1638b Mon Sep 17 00:00:00 2001 From: Christopher Canaday Date: Sun, 27 Apr 2025 18:39:26 -0400 Subject: [PATCH 3/5] remove comment --- apps/usermobile/components/EventView.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/usermobile/components/EventView.tsx b/apps/usermobile/components/EventView.tsx index 66cfb89..2a72170 100644 --- a/apps/usermobile/components/EventView.tsx +++ b/apps/usermobile/components/EventView.tsx @@ -48,8 +48,6 @@ export default function EventView({ const runner = async () => { const name = await getEventNameFromId(BigInt(Event)); - // const split = name.split(' '); - // const uuid = split[split.length - 1]; const data = await getEventByUUID(name); setEventData(data as UserEventDetailsResponse); setTicketTransferable(await checkIfTicketIsTransferable()); From 54248e5224320862fee998187932ebd6fe125f12 Mon Sep 17 00:00:00 2001 From: Christopher Canaday Date: Sun, 27 Apr 2025 19:05:28 -0400 Subject: [PATCH 4/5] Revert to individual ticket prices --- apps/vendorweb/src/components/MintTicketsModal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/vendorweb/src/components/MintTicketsModal.tsx b/apps/vendorweb/src/components/MintTicketsModal.tsx index 9a22ee0..eeb1d39 100644 --- a/apps/vendorweb/src/components/MintTicketsModal.tsx +++ b/apps/vendorweb/src/components/MintTicketsModal.tsx @@ -81,7 +81,7 @@ export default function MintTicketsModal({ `https://opentix.co/event/${ID}`, NumUnique, NumGa, - Basecost + Array(NumGa + NumUnique).fill(Basecost) ] }); From 94b2f7358a98af03d6768315254713ddf9c66731 Mon Sep 17 00:00:00 2001 From: Christopher Canaday Date: Sun, 27 Apr 2025 21:30:36 -0400 Subject: [PATCH 5/5] Fully updated --- packages/blockchain/src/lib/blockchain.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/blockchain/src/lib/blockchain.ts b/packages/blockchain/src/lib/blockchain.ts index f7d0850..e496f37 100644 --- a/packages/blockchain/src/lib/blockchain.ts +++ b/packages/blockchain/src/lib/blockchain.ts @@ -1,6 +1,6 @@ import { polygonAmoy } from 'viem/chains'; -export const ContractAddress = '0x4B10Ca604B40b782eF00b497357b3dc9478457DF'; +export const ContractAddress = '0x8BE301eD017D23977F98b48CD9D18EaB91C0ae26'; export type ContractGetEventIdsReturnedMetadata = { min: bigint; @@ -341,7 +341,7 @@ export const ContractABI = [ type: 'uint256' }, { internalType: 'uint256', name: 'unique_seats', type: 'uint256' }, - { internalType: 'uint256', name: 'cost', type: 'uint256' } + { internalType: 'uint256[]', name: 'costs', type: 'uint256[]' } ], name: 'create_new_event', outputs: [],