From 40fce9cc9ba5914dab75fcc6eae21588ef9e7012 Mon Sep 17 00:00:00 2001 From: Orpheus Lummis Date: Mon, 15 Jan 2024 01:04:53 +0700 Subject: [PATCH] fix: display BatchID correctly, updates contract (#43) --- contracts/AstaVerde.sol | 18 +- test/AstaVerde.behavior.ts | 26 +- webapp/src/components/BatchCard.tsx | 17 +- webapp/src/components/BatchListing.tsx | 53 +- webapp/src/lib/contracts.ts | 1710 ++++++++++++------------ webapp/src/wagmi.ts | 3 +- 6 files changed, 930 insertions(+), 897 deletions(-) diff --git a/contracts/AstaVerde.sol b/contracts/AstaVerde.sol index 7d69b9f..1543b22 100644 --- a/contracts/AstaVerde.sol +++ b/contracts/AstaVerde.sol @@ -47,6 +47,7 @@ contract AstaVerde is ERC1155, ERC1155Pausable, Ownable, IERC1155Receiver, Reent } struct Batch { + uint256 batchId; uint256[] tokenIds; uint256 creationTime; uint256 startingPrice; @@ -181,6 +182,7 @@ contract AstaVerde is ERC1155, ERC1155Pausable, Ownable, IERC1155Receiver, Reent updateBasePrice(); Batch memory newBatch; + newBatch.batchId = lastBatchID; newBatch.tokenIds = new uint256[](batchSize); newBatch.creationTime = block.timestamp; newBatch.price = basePrice; @@ -205,7 +207,7 @@ contract AstaVerde is ERC1155, ERC1155Pausable, Ownable, IERC1155Receiver, Reent } batches.push(newBatch); - emit BatchMinted(lastBatchID, block.timestamp); + emit BatchMinted(newBatch.batchId, block.timestamp); _mintBatch(address(this), newTokenIds, amounts, ""); } @@ -264,11 +266,21 @@ contract AstaVerde is ERC1155, ERC1155Pausable, Ownable, IERC1155Receiver, Reent function getBatchInfo( uint256 batchID - ) public view returns (uint256[] memory tokenIds, uint256 creationTime, uint256 price, uint256 remainingTokens) { + ) + public + view + returns ( + uint256 batchId, + uint256[] memory tokenIds, + uint256 creationTime, + uint256 price, + uint256 remainingTokens + ) + { require(batchID <= batches.length, "Batch ID is out of bounds"); Batch memory batch = batches[batchID]; price = getBatchPrice(batchID); - return (batch.tokenIds, batch.creationTime, price, batch.remainingTokens); + return (batch.batchId, batch.tokenIds, batch.creationTime, price, batch.remainingTokens); } function handleRefund(uint256 usdcAmount, uint256 totalCost) internal { diff --git a/test/AstaVerde.behavior.ts b/test/AstaVerde.behavior.ts index 6bda24d..08aa316 100644 --- a/test/AstaVerde.behavior.ts +++ b/test/AstaVerde.behavior.ts @@ -180,9 +180,9 @@ export function shouldBehaveLikeAstaVerde(): void { await this.astaVerde.mintBatch(producers, cids); const batchID = await this.astaVerde.lastBatchID(); const batchInfo = await this.astaVerde.getBatchInfo(batchID); - expect(batchInfo[0]).to.deep.equal([1n, 2n]); // tokenIds - expect(batchInfo[1]).to.be.a("bigint"); // creationTime - expect(batchInfo[2]).to.equal(BASE_PRICE); // price + expect(batchInfo[1]).to.deep.equal([1n, 2n]); // tokenIds + expect(batchInfo[2]).to.be.a("bigint"); // creationTime + expect(batchInfo[3]).to.equal(BASE_PRICE); // price }); it("should pause and unpause the contract by the owner", async function () { @@ -518,7 +518,7 @@ export function shouldBehaveLikeAstaVerde(): void { // Buy the batch of tokens const batchInfo = await this.astaVerde.getBatchInfo(batchID); - const price = batchInfo[2]; + const price = batchInfo[3]; const tokenAmount = BigInt(cids.length); const usdcAmount = price * tokenAmount; const user = this.signers.others[0]; @@ -528,7 +528,7 @@ export function shouldBehaveLikeAstaVerde(): void { await this.astaVerde.connect(user).buyBatch(batchID, usdcAmount, tokenAmount); // Redeem the tokens - const tokenIds = batchInfo[0]; + const tokenIds = batchInfo[1]; await this.astaVerde.connect(user).redeemTokens([...tokenIds]); // a copy of tokenIDs is needed // Check that the tokens are marked as redeemed @@ -549,7 +549,7 @@ export function shouldBehaveLikeAstaVerde(): void { // User 1 buys the batch of tokens const user1 = this.signers.others[0]; const batchInfo = await this.astaVerde.getBatchInfo(batchID); - const price = batchInfo[2]; + const price = batchInfo[3]; const tokenAmount = BigInt(cids.length); const usdcAmount = price * tokenAmount; await mintUSDC(user1, this.mockUSDC, 1000000n); @@ -559,7 +559,7 @@ export function shouldBehaveLikeAstaVerde(): void { // User 2 attempts to redeem the tokens const user2 = this.signers.others[1]; - const tokenIds = batchInfo[0]; + const tokenIds = batchInfo[1]; await expect(this.astaVerde.connect(user2).redeemTokens([...tokenIds])).to.be.revertedWith( "Only the owner can redeem", ); @@ -574,7 +574,7 @@ export function shouldBehaveLikeAstaVerde(): void { // Buy the batch of tokens const batchInfo = await this.astaVerde.getBatchInfo(batchID); - const price = batchInfo[2]; + const price = batchInfo[3]; const tokenAmount = BigInt(cids.length); const usdcAmount = price * tokenAmount; const user = this.signers.others[0]; @@ -587,7 +587,7 @@ export function shouldBehaveLikeAstaVerde(): void { await this.astaVerde.pause(); // Redeem the tokens - const tokenIds = batchInfo[0]; + const tokenIds = batchInfo[1]; try { await this.astaVerde.connect(user).redeemTokens([...tokenIds]); } catch (error) { @@ -613,8 +613,8 @@ export function shouldBehaveLikeAstaVerde(): void { const user2 = this.signers.others[1]; const batchInfo1 = await this.astaVerde.getBatchInfo(batchID1); const batchInfo2 = await this.astaVerde.getBatchInfo(batchID2); - const price1 = batchInfo1[2]; - const price2 = batchInfo2[2]; + const price1 = batchInfo1[3]; + const price2 = batchInfo2[3]; const tokenAmount1 = BigInt(cids1.length); const tokenAmount2 = BigInt(cids2.length); const usdcAmount1 = price1 * tokenAmount1; @@ -669,7 +669,7 @@ export function shouldBehaveLikeAstaVerde(): void { for (let i = 0; i < numBatches; i++) { console.log("buy batch", i); let batchInfo = await this.astaVerde.getBatchInfo(i); - let price = batchInfo[2]; + let price = batchInfo[3]; const tokenAmount = BigInt(cids.length); const usdcAmount = price * tokenAmount; usdcAmounts.push(usdcAmount); @@ -679,7 +679,7 @@ export function shouldBehaveLikeAstaVerde(): void { await this.astaVerde.connect(user).buyBatch(i, usdcAmount, tokenAmount); // here we see the price decrease const expectedPrice = BASE_PRICE - i * PRICE_DECREASE_RATE; batchInfo = await this.astaVerde.getBatchInfo(i); // here we see it decrease again - price = batchInfo[2]; + price = batchInfo[3]; console.log("expectedPrice", expectedPrice); console.log("price", price); diff --git a/webapp/src/components/BatchCard.tsx b/webapp/src/components/BatchCard.tsx index 283f2b8..d84ce84 100644 --- a/webapp/src/components/BatchCard.tsx +++ b/webapp/src/components/BatchCard.tsx @@ -27,13 +27,13 @@ export default function BatchCard({ batch }: { batch: Batch }) { // const [isModalOpen, setIsModalOpen] = useState(false); const [tokenAmount, setTokenAmount] = useState(1); - console.log("batch.token_ids", batch.token_ids); + console.log("BatchCard: batch.token_ids", batch.token_ids); const { data, fetchNextPage, error } = useContractInfiniteReads({ cacheKey: "tokenMetadata", ...paginatedIndexesConfig( (tokenID: bigint) => { - console.log("fetching tokenCID", tokenID); + console.log("BatchCard: fetching tokenCID", tokenID); return [ { ...astaverdeContractConfig, @@ -57,9 +57,10 @@ export default function BatchCard({ batch }: { batch: Batch }) { args: [BigInt(batch.id)], }); - console.log("batch", batch); - console.log("batches", batches); - console.log("currentPrice", currentPrice); + console.log("BatchCard: batch", batch); + console.log("BatchCard: batches", batches); + console.log("BatchCard: currentPrice", currentPrice); + console.log("BatchCard: batch.id", batch.id); // we get metadata for each token, @@ -80,7 +81,7 @@ export default function BatchCard({ batch }: { batch: Batch }) { />
-

Batch ID: {batch.id}

+

Batch {Number(batch.id)}

{batch ? `${batch.itemsLeft} items left` : "0 items left"}

{currentPrice ? `${currentPrice} USDC` : "0 USDC"}

@@ -134,8 +135,8 @@ function BuyBatchButton({ args: [address!, astaverdeContractConfig.address], }); - console.log("🚀 ~ file: BatchCard.tsx:152 ~ allowance:", Number(formatUnits(allowance || BigInt(0), 6)), totalPrice); - console.log("buyBatch enabled", Number(formatUnits(allowance || BigInt(0), 6)) >= totalPrice); + console.log("BatchCard: allowance:", Number(formatUnits(allowance || BigInt(0), 6)), totalPrice); + console.log("BatchCard: buyBatch enabled", Number(formatUnits(allowance || BigInt(0), 6)) >= totalPrice); const { config: configApprove } = usePrepareContractWrite({ ...usdcContractConfig, diff --git a/webapp/src/components/BatchListing.tsx b/webapp/src/components/BatchListing.tsx index b96d040..61385ba 100644 --- a/webapp/src/components/BatchListing.tsx +++ b/webapp/src/components/BatchListing.tsx @@ -17,17 +17,17 @@ export function BatchListing() { }); if (lastBatchIDError || lastBatchID === undefined) { - console.log("lastBatchIDError", lastBatchIDError); + console.log("BatchListing: lastBatchIDError", lastBatchIDError); } const lastBatchIDn: number = lastBatchID ? Number(lastBatchID) : 0; - console.log("lastBatchIDn, isError, isLoading", lastBatchID, isError, isLoading); + console.log("BatchListing: lastBatchIDn, isError, isLoading", lastBatchID, isError, isLoading); const { data, fetchNextPage, error, hasNextPage } = useContractInfiniteReads({ cacheKey: "batchMetadata", ...paginatedIndexesConfig( (batchID: bigint) => { - console.log("fetching batchID", batchID); + console.log("BatchListing: fetching batchID", batchID); return [ { ...astaverdeContractConfig, @@ -39,7 +39,20 @@ export function BatchListing() { { start: lastBatchIDn, perPage: 10, direction: "decrement" }, ), }); - console.log("data", data); + console.log("BatchListing: data", data); + + if (isLoading) { + return
Loading...
; + } + + if (isError) { + console.log("BatchListing: error", error); + return
Could not display, sorry.
; + } + + if (!data) { + return
Could not display, sorry.
; + } const { address } = useAccount(); @@ -51,21 +64,27 @@ export function BatchListing() { }); if (error) { - console.log("error", error); + console.log("BatchListing: error", error); return
Could not display, sorry.
; } + if (data?.pages?.[0]?.[0]?.error) { + return
Error occurred: No batch has been minted yet.
; + } + + const batches: Batch[] = data?.pages?.flatMap( (page: any[]) => page?.map((batch: any) => { - console.log("batch", batch); - const tokenIDs: number[] = batch.result?.[0] || []; - const timestamp: number = batch.result?.[1] || 0; - const price: number = batch.result?.[2] || 0; - const itemsLeft: number = batch.result?.[3] || 0; - const batchProper = new Batch(0, tokenIDs, timestamp, price, itemsLeft); // Assuming batch.id is not available, replace 0 with the correct value - console.log("batchProper", batchProper); + console.log("BatchListing: batch", batch); + const batchID = batch.result?.[0] || 0; + const tokenIDs: number[] = batch.result?.[1] || []; + const timestamp: number = batch.result?.[2] || 0; + const price: number = batch.result?.[3] || 0; + const itemsLeft: number = batch.result?.[4] || 0; + const batchProper = new Batch(batchID, tokenIDs, timestamp, price, itemsLeft); + console.log("BatchListing: batchProper", batchProper); return batchProper; }), ) || []; @@ -74,16 +93,6 @@ export function BatchListing() { return ( <> - {/*
- -
*/} -
{batches.map((batch) => (
diff --git a/webapp/src/lib/contracts.ts b/webapp/src/lib/contracts.ts index 99233d2..5b1aea6 100644 --- a/webapp/src/lib/contracts.ts +++ b/webapp/src/lib/contracts.ts @@ -8,1279 +8,1289 @@ export const usdcContractConfig = { export const astaverdeContractConfig = { // on Sepolia - address: "0x51476ae94fD1C029181Cc601adba2A529C1052a9", + address: "0x753B3B362b7950B643Fe4BD60d602eA0a2aC98c9", abi: [ { - inputs: [ + "inputs": [ { - internalType: "address", - name: "initialOwner", - type: "address", + "internalType": "address", + "name": "initialOwner", + "type": "address" }, { - internalType: "contract IERC20", - name: "_usdcToken", - type: "address", - }, + "internalType": "contract IERC20", + "name": "_usdcToken", + "type": "address" + } ], - stateMutability: "nonpayable", - type: "constructor", + "stateMutability": "nonpayable", + "type": "constructor" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "sender", - type: "address", + "internalType": "address", + "name": "sender", + "type": "address" }, { - internalType: "uint256", - name: "balance", - type: "uint256", + "internalType": "uint256", + "name": "balance", + "type": "uint256" }, { - internalType: "uint256", - name: "needed", - type: "uint256", + "internalType": "uint256", + "name": "needed", + "type": "uint256" }, { - internalType: "uint256", - name: "tokenId", - type: "uint256", - }, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } ], - name: "ERC1155InsufficientBalance", - type: "error", + "name": "ERC1155InsufficientBalance", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "approver", - type: "address", - }, + "internalType": "address", + "name": "approver", + "type": "address" + } ], - name: "ERC1155InvalidApprover", - type: "error", + "name": "ERC1155InvalidApprover", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "idsLength", - type: "uint256", + "internalType": "uint256", + "name": "idsLength", + "type": "uint256" }, { - internalType: "uint256", - name: "valuesLength", - type: "uint256", - }, + "internalType": "uint256", + "name": "valuesLength", + "type": "uint256" + } ], - name: "ERC1155InvalidArrayLength", - type: "error", + "name": "ERC1155InvalidArrayLength", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "operator", - type: "address", - }, + "internalType": "address", + "name": "operator", + "type": "address" + } ], - name: "ERC1155InvalidOperator", - type: "error", + "name": "ERC1155InvalidOperator", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "receiver", - type: "address", - }, + "internalType": "address", + "name": "receiver", + "type": "address" + } ], - name: "ERC1155InvalidReceiver", - type: "error", + "name": "ERC1155InvalidReceiver", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "sender", - type: "address", - }, + "internalType": "address", + "name": "sender", + "type": "address" + } ], - name: "ERC1155InvalidSender", - type: "error", + "name": "ERC1155InvalidSender", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "operator", - type: "address", + "internalType": "address", + "name": "operator", + "type": "address" }, { - internalType: "address", - name: "owner", - type: "address", - }, + "internalType": "address", + "name": "owner", + "type": "address" + } ], - name: "ERC1155MissingApprovalForAll", - type: "error", + "name": "ERC1155MissingApprovalForAll", + "type": "error" }, { - inputs: [], - name: "EnforcedPause", - type: "error", + "inputs": [], + "name": "EnforcedPause", + "type": "error" }, { - inputs: [], - name: "ExpectedPause", - type: "error", + "inputs": [], + "name": "ExpectedPause", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "owner", - type: "address", - }, + "internalType": "address", + "name": "owner", + "type": "address" + } ], - name: "OwnableInvalidOwner", - type: "error", + "name": "OwnableInvalidOwner", + "type": "error" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "account", - type: "address", - }, + "internalType": "address", + "name": "account", + "type": "address" + } ], - name: "OwnableUnauthorizedAccount", - type: "error", + "name": "OwnableUnauthorizedAccount", + "type": "error" }, { - inputs: [], - name: "ReentrancyGuardReentrantCall", - type: "error", + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: true, - internalType: "address", - name: "account", - type: "address", + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" }, { - indexed: true, - internalType: "address", - name: "operator", - type: "address", + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" }, { - indexed: false, - internalType: "bool", - name: "approved", - type: "bool", - }, + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } ], - name: "ApprovalForAll", - type: "event", + "name": "ApprovalForAll", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "batchId", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "batchId", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "batchCreationTime", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "batchCreationTime", + "type": "uint256" + } ], - name: "BatchMinted", - type: "event", + "name": "BatchMinted", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "batchId", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "batchId", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "batchSoldTime", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "batchSoldTime", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "tokensSold", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "tokensSold", + "type": "uint256" + } ], - name: "BatchSold", - type: "event", + "name": "BatchSold", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: true, - internalType: "address", - name: "previousOwner", - type: "address", + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" }, { - indexed: true, - internalType: "address", - name: "newOwner", - type: "address", - }, + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } ], - name: "OwnershipTransferred", - type: "event", + "name": "OwnershipTransferred", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "batchId", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "batchId", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "batchSoldTime", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "batchSoldTime", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "remainingTokens", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "remainingTokens", + "type": "uint256" + } ], - name: "PartialBatchSold", - type: "event", + "name": "PartialBatchSold", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "address", - name: "account", - type: "address", - }, + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } ], - name: "Paused", - type: "event", + "name": "Paused", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "newPrice", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "newPrice", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "timestamp", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } ], - name: "PlatformBasePriceAdjusted", - type: "event", + "name": "PlatformBasePriceAdjusted", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "newPrice", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "newPrice", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "timestamp", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } ], - name: "PlatformPriceFloorAdjusted", - type: "event", + "name": "PlatformPriceFloorAdjusted", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "platformSharePercentage", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "platformSharePercentage", + "type": "uint256" + } ], - name: "PlatformSharePercentageSet", - type: "event", + "name": "PlatformSharePercentageSet", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "tokenId", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" }, { - indexed: false, - internalType: "address", - name: "redeemer", - type: "address", + "indexed": false, + "internalType": "address", + "name": "redeemer", + "type": "address" }, { - indexed: false, - internalType: "uint256", - name: "timestamp", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "timestamp", + "type": "uint256" + } ], - name: "TokenReedemed", - type: "event", + "name": "TokenReedemed", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "uint256", - name: "tokenId", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" }, { - indexed: false, - internalType: "address", - name: "buyer", - type: "address", + "indexed": false, + "internalType": "address", + "name": "buyer", + "type": "address" }, { - indexed: false, - internalType: "uint256", - name: "price", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "price", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "batchSoldTime", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "batchSoldTime", + "type": "uint256" }, { - indexed: false, - internalType: "address", - name: "producer", - type: "address", - }, + "indexed": false, + "internalType": "address", + "name": "producer", + "type": "address" + } ], - name: "TokenSold", - type: "event", + "name": "TokenSold", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: true, - internalType: "address", - name: "operator", - type: "address", + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" }, { - indexed: true, - internalType: "address", - name: "from", - type: "address", + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" }, { - indexed: true, - internalType: "address", - name: "to", - type: "address", + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" }, { - indexed: false, - internalType: "uint256[]", - name: "ids", - type: "uint256[]", + "indexed": false, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" }, { - indexed: false, - internalType: "uint256[]", - name: "values", - type: "uint256[]", - }, + "indexed": false, + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" + } ], - name: "TransferBatch", - type: "event", + "name": "TransferBatch", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: true, - internalType: "address", - name: "operator", - type: "address", + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" }, { - indexed: true, - internalType: "address", - name: "from", - type: "address", + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" }, { - indexed: true, - internalType: "address", - name: "to", - type: "address", + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" }, { - indexed: false, - internalType: "uint256", - name: "id", - type: "uint256", + "indexed": false, + "internalType": "uint256", + "name": "id", + "type": "uint256" }, { - indexed: false, - internalType: "uint256", - name: "value", - type: "uint256", - }, + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } ], - name: "TransferSingle", - type: "event", + "name": "TransferSingle", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "string", - name: "value", - type: "string", + "indexed": false, + "internalType": "string", + "name": "value", + "type": "string" }, { - indexed: true, - internalType: "uint256", - name: "id", - type: "uint256", - }, + "indexed": true, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } ], - name: "URI", - type: "event", + "name": "URI", + "type": "event" }, { - anonymous: false, - inputs: [ + "anonymous": false, + "inputs": [ { - indexed: false, - internalType: "address", - name: "account", - type: "address", - }, + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } ], - name: "Unpaused", - type: "event", + "name": "Unpaused", + "type": "event" }, { - inputs: [], - name: "SECONDS_IN_A_DAY", - outputs: [ + "inputs": [], + "name": "SECONDS_IN_A_DAY", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "account", - type: "address", + "internalType": "address", + "name": "account", + "type": "address" }, { - internalType: "uint256", - name: "id", - type: "uint256", - }, + "internalType": "uint256", + "name": "id", + "type": "uint256" + } ], - name: "balanceOf", - outputs: [ + "name": "balanceOf", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address[]", - name: "accounts", - type: "address[]", + "internalType": "address[]", + "name": "accounts", + "type": "address[]" }, { - internalType: "uint256[]", - name: "ids", - type: "uint256[]", - }, + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" + } ], - name: "balanceOfBatch", - outputs: [ + "name": "balanceOfBatch", + "outputs": [ { - internalType: "uint256[]", - name: "", - type: "uint256[]", - }, + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "basePrice", - outputs: [ + "inputs": [], + "name": "basePrice", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - name: "batches", - outputs: [ + "name": "batches", + "outputs": [ { - internalType: "uint256", - name: "creationTime", - type: "uint256", + "internalType": "uint256", + "name": "batchId", + "type": "uint256" }, { - internalType: "uint256", - name: "startingPrice", - type: "uint256", + "internalType": "uint256", + "name": "creationTime", + "type": "uint256" }, { - internalType: "uint256", - name: "price", - type: "uint256", + "internalType": "uint256", + "name": "startingPrice", + "type": "uint256" }, { - internalType: "uint256", - name: "remainingTokens", - type: "uint256", + "internalType": "uint256", + "name": "price", + "type": "uint256" }, + { + "internalType": "uint256", + "name": "remainingTokens", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "batchID", - type: "uint256", + "internalType": "uint256", + "name": "batchID", + "type": "uint256" }, { - internalType: "uint256", - name: "usdcAmount", - type: "uint256", + "internalType": "uint256", + "name": "usdcAmount", + "type": "uint256" }, { - internalType: "uint256", - name: "tokenAmount", - type: "uint256", - }, + "internalType": "uint256", + "name": "tokenAmount", + "type": "uint256" + } ], - name: "buyBatch", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "buyBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "to", - type: "address", - }, + "internalType": "address", + "name": "to", + "type": "address" + } ], - name: "claimPlatformFunds", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "claimPlatformFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: "dayDecreaseThreshold", - outputs: [ + "inputs": [], + "name": "dayDecreaseThreshold", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "dayIncreaseThreshold", - outputs: [ + "inputs": [], + "name": "dayIncreaseThreshold", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "batchID", - type: "uint256", - }, + "internalType": "uint256", + "name": "batchID", + "type": "uint256" + } ], - name: "getBatchInfo", - outputs: [ + "name": "getBatchInfo", + "outputs": [ { - internalType: "uint256[]", - name: "tokenIds", - type: "uint256[]", + "internalType": "uint256", + "name": "batchId", + "type": "uint256" }, { - internalType: "uint256", - name: "creationTime", - type: "uint256", + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" }, { - internalType: "uint256", - name: "price", - type: "uint256", + "internalType": "uint256", + "name": "creationTime", + "type": "uint256" }, { - internalType: "uint256", - name: "remainingTokens", - type: "uint256", + "internalType": "uint256", + "name": "price", + "type": "uint256" }, + { + "internalType": "uint256", + "name": "remainingTokens", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "batchID", - type: "uint256", - }, + "internalType": "uint256", + "name": "batchID", + "type": "uint256" + } ], - name: "getBatchPrice", - outputs: [ + "name": "getBatchPrice", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "account", - type: "address", + "internalType": "address", + "name": "account", + "type": "address" }, { - internalType: "address", - name: "operator", - type: "address", - }, + "internalType": "address", + "name": "operator", + "type": "address" + } ], - name: "isApprovedForAll", - outputs: [ + "name": "isApprovedForAll", + "outputs": [ { - internalType: "bool", - name: "", - type: "bool", - }, + "internalType": "bool", + "name": "", + "type": "bool" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "lastBatchID", - outputs: [ + "inputs": [], + "name": "lastBatchID", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "lastBatchSoldTime", - outputs: [ + "inputs": [], + "name": "lastBatchSoldTime", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "lastTokenID", - outputs: [ + "inputs": [], + "name": "lastTokenID", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "maxBatchSize", - outputs: [ + "inputs": [], + "name": "maxBatchSize", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address[]", - name: "producers", - type: "address[]", + "internalType": "address[]", + "name": "producers", + "type": "address[]" }, { - internalType: "string[]", - name: "cids", - type: "string[]", - }, + "internalType": "string[]", + "name": "cids", + "type": "string[]" + } ], - name: "mintBatch", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "mintBatch", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "", - type: "address", + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: "address", - name: "", - type: "address", + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: "uint256[]", - name: "", - type: "uint256[]", + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" }, { - internalType: "uint256[]", - name: "", - type: "uint256[]", + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" }, { - internalType: "bytes", - name: "", - type: "bytes", - }, + "internalType": "bytes", + "name": "", + "type": "bytes" + } ], - name: "onERC1155BatchReceived", - outputs: [ + "name": "onERC1155BatchReceived", + "outputs": [ { - internalType: "bytes4", - name: "", - type: "bytes4", - }, + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } ], - stateMutability: "pure", - type: "function", + "stateMutability": "pure", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "", - type: "address", + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: "address", - name: "", - type: "address", + "internalType": "address", + "name": "", + "type": "address" }, { - internalType: "uint256", - name: "", - type: "uint256", + "internalType": "uint256", + "name": "", + "type": "uint256" }, { - internalType: "uint256", - name: "", - type: "uint256", + "internalType": "uint256", + "name": "", + "type": "uint256" }, { - internalType: "bytes", - name: "", - type: "bytes", - }, + "internalType": "bytes", + "name": "", + "type": "bytes" + } ], - name: "onERC1155Received", - outputs: [ + "name": "onERC1155Received", + "outputs": [ { - internalType: "bytes4", - name: "", - type: "bytes4", - }, + "internalType": "bytes4", + "name": "", + "type": "bytes4" + } ], - stateMutability: "pure", - type: "function", + "stateMutability": "pure", + "type": "function" }, { - inputs: [], - name: "owner", - outputs: [ + "inputs": [], + "name": "owner", + "outputs": [ { - internalType: "address", - name: "", - type: "address", - }, + "internalType": "address", + "name": "", + "type": "address" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "pause", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: "paused", - outputs: [ + "inputs": [], + "name": "paused", + "outputs": [ { - internalType: "bool", - name: "", - type: "bool", - }, + "internalType": "bool", + "name": "", + "type": "bool" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "platformShareAccumulated", - outputs: [ + "inputs": [], + "name": "platformShareAccumulated", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "platformSharePercentage", - outputs: [ + "inputs": [], + "name": "platformSharePercentage", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "priceDecreaseRate", - outputs: [ + "inputs": [], + "name": "priceDecreaseRate", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "priceFloor", - outputs: [ + "inputs": [], + "name": "priceFloor", + "outputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256[]", - name: "tokenIds", - type: "uint256[]", - }, + "internalType": "uint256[]", + "name": "tokenIds", + "type": "uint256[]" + } ], - name: "redeemTokens", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "redeemTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: "renounceOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "from", - type: "address", + "internalType": "address", + "name": "from", + "type": "address" }, { - internalType: "address", - name: "to", - type: "address", + "internalType": "address", + "name": "to", + "type": "address" }, { - internalType: "uint256[]", - name: "ids", - type: "uint256[]", + "internalType": "uint256[]", + "name": "ids", + "type": "uint256[]" }, { - internalType: "uint256[]", - name: "values", - type: "uint256[]", + "internalType": "uint256[]", + "name": "values", + "type": "uint256[]" }, { - internalType: "bytes", - name: "data", - type: "bytes", - }, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } ], - name: "safeBatchTransferFrom", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "safeBatchTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "from", - type: "address", + "internalType": "address", + "name": "from", + "type": "address" }, { - internalType: "address", - name: "to", - type: "address", + "internalType": "address", + "name": "to", + "type": "address" }, { - internalType: "uint256", - name: "id", - type: "uint256", + "internalType": "uint256", + "name": "id", + "type": "uint256" }, { - internalType: "uint256", - name: "value", - type: "uint256", + "internalType": "uint256", + "name": "value", + "type": "uint256" }, { - internalType: "bytes", - name: "data", - type: "bytes", - }, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } ], - name: "safeTransferFrom", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "operator", - type: "address", + "internalType": "address", + "name": "operator", + "type": "address" }, { - internalType: "bool", - name: "approved", - type: "bool", - }, + "internalType": "bool", + "name": "approved", + "type": "bool" + } ], - name: "setApprovalForAll", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "increase", - type: "uint256", + "internalType": "uint256", + "name": "increase", + "type": "uint256" }, { - internalType: "uint256", - name: "decrease", - type: "uint256", - }, + "internalType": "uint256", + "name": "decrease", + "type": "uint256" + } ], - name: "setAuctionTimeThresholds", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setAuctionTimeThresholds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "newStartingPrice", - type: "uint256", - }, + "internalType": "uint256", + "name": "newStartingPrice", + "type": "uint256" + } ], - name: "setBasePrice", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setBasePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "newSize", - type: "uint256", - }, + "internalType": "uint256", + "name": "newSize", + "type": "uint256" + } ], - name: "setMaxBatchSize", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setMaxBatchSize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "newSharePercentage", - type: "uint256", - }, + "internalType": "uint256", + "name": "newSharePercentage", + "type": "uint256" + } ], - name: "setPlatformSharePercentage", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setPlatformSharePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "newPriceFloor", - type: "uint256", - }, + "internalType": "uint256", + "name": "newPriceFloor", + "type": "uint256" + } ], - name: "setPriceFloor", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setPriceFloor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "string", - name: "newuri", - type: "string", - }, + "internalType": "string", + "name": "newuri", + "type": "string" + } ], - name: "setURI", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "setURI", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "bytes4", - name: "interfaceId", - type: "bytes4", - }, + "internalType": "bytes4", + "name": "interfaceId", + "type": "bytes4" + } ], - name: "supportsInterface", - outputs: [ + "name": "supportsInterface", + "outputs": [ { - internalType: "bool", - name: "", - type: "bool", - }, + "internalType": "bool", + "name": "", + "type": "bool" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "", - type: "uint256", - }, + "internalType": "uint256", + "name": "", + "type": "uint256" + } ], - name: "tokens", - outputs: [ + "name": "tokens", + "outputs": [ { - internalType: "uint256", - name: "tokenId", - type: "uint256", + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" }, { - internalType: "address", - name: "producer", - type: "address", + "internalType": "address", + "name": "producer", + "type": "address" }, { - internalType: "string", - name: "cid", - type: "string", + "internalType": "string", + "name": "cid", + "type": "string" }, { - internalType: "bool", - name: "isRedeemed", - type: "bool", - }, + "internalType": "bool", + "name": "isRedeemed", + "type": "bool" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "address", - name: "newOwner", - type: "address", - }, + "internalType": "address", + "name": "newOwner", + "type": "address" + } ], - name: "transferOwnership", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: "unpause", - outputs: [], - stateMutability: "nonpayable", - type: "function", + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ + "inputs": [ { - internalType: "uint256", - name: "tokenId", - type: "uint256", - }, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } ], - name: "uri", - outputs: [ + "name": "uri", + "outputs": [ { - internalType: "string", - name: "", - type: "string", - }, + "internalType": "string", + "name": "", + "type": "string" + } ], - stateMutability: "view", - type: "function", + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: "usdcToken", - outputs: [ + "inputs": [], + "name": "usdcToken", + "outputs": [ { - internalType: "contract IERC20", - name: "", - type: "address", - }, + "internalType": "contract IERC20", + "name": "", + "type": "address" + } ], - stateMutability: "view", - type: "function", - }, + "stateMutability": "view", + "type": "function" + } ], } as const; diff --git a/webapp/src/wagmi.ts b/webapp/src/wagmi.ts index f59dd14..295cffa 100644 --- a/webapp/src/wagmi.ts +++ b/webapp/src/wagmi.ts @@ -8,8 +8,9 @@ const nodeHTTPSURL = "https://base-sepolia.g.alchemy.com/v2/"; const nodeWSSURL = "wss://base-sepolia.g.alchemy.com/v2/"; const isDev = true; -console.log("isDev", isDev); +console.log("wagmi: development mode", isDev); const chain = isDev ? baseSepolia : base; +console.log("wagmi: connecting to chain chain", chain); export const config = createConfig( getDefaultConfig({