From 41286fe0529763dafcdba61c5487e40c6e2c2ec8 Mon Sep 17 00:00:00 2001 From: xivanc Date: Wed, 14 Dec 2022 17:24:05 +0100 Subject: [PATCH 1/2] add Goerli setup --- .env.local | 7 ++++++- components/closet/index.tsx | 12 +++++++----- components/profile/InvalidChain.tsx | 2 +- eth-sdk/abis/goerli/nft_giveaway.json | 1 + eth-sdk/abis/goerli/nft_wearables.json | 1 + eth-sdk/eth-sdk.config.ts | 6 +++--- 6 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 eth-sdk/abis/goerli/nft_giveaway.json create mode 100644 eth-sdk/abis/goerli/nft_wearables.json diff --git a/.env.local b/.env.local index 1d7c2cb..1636646 100644 --- a/.env.local +++ b/.env.local @@ -1,5 +1,10 @@ NEXT_PUBLIC_LOGO_HEIGHT=64 -NEXT_PUBLIC_MERKLE_REDEEM_CONTRACT="0xd8401646686430711D5d48407D8C0bb79616baef" + +# redeem contract var is used for claiming ROBOT tokens and it is used in combination with typechain directly +# dont confuse this with later implementations for NFT claims and wearables which is implemented using eth-sdk +# and relevant configuration and contract addresses can be found here eth-sdk/eth-sdk.config.ts +NEXT_PUBLIC_MERKLE_REDEEM_CONTRACT="0x67f5C948DceAf99352f6cac71c862C1C3b60dfDF" + NEXT_PUBLIC_IPFS_NODE="cloudflare-ipfs.com" NEXT_PUBLIC_IPFS_CLAIMS_SNAPSHOT_URL="storageapi.fleek.co/hammadj-team-bucket/robot-claim/snapshot.json" NEXT_PUBLIC_APP_NAME="mf-dashboard" diff --git a/components/closet/index.tsx b/components/closet/index.tsx index e65396a..ca7953f 100644 --- a/components/closet/index.tsx +++ b/components/closet/index.tsx @@ -1,10 +1,12 @@ +/* eslint-disable camelcase */ /* eslint-disable prettier/prettier */ import Cookies from "js-cookie"; import { useState, useEffect } from "react"; import { VStack, HStack, Text } from "@chakra-ui/react"; import type { NextPage } from "next"; import { useAccount, useProvider } from 'wagmi'; -import { getMainnetSdk } from '@dethcrypto/eth-sdk-client'; +import { getGoerliSdk } from '@dethcrypto/eth-sdk-client'; +// import { getMainnetSdk } from '@dethcrypto/eth-sdk-client'; import { ethers } from "ethers"; import { Loading } from "@/components/atoms"; import useNftMetadata, { NftItem } from "@/hooks/useNftMetadata"; @@ -30,8 +32,8 @@ const Wearables: NextPage = () => { useEffect(() => { const findClaimableClaims = async (currentProvider: ethers.providers.Provider, address: string, rootHashes: string[], allNftClaims: NftClaim[]) => { - const { ethereum } = getMainnetSdk(provider); - const claimedStatuses = await ethereum.nft_giveaway.getClaimedStatus(address, rootHashes); + const { nft_giveaway } = getGoerliSdk(provider); + const claimedStatuses = await nft_giveaway.getClaimedStatus(address, rootHashes); const currentUnclaimedNftClaims = claimedStatuses.reduce( (sum: NftClaim[], currentValue: boolean, currentIndex: number) => { if(currentValue === true) return sum; @@ -68,9 +70,9 @@ const Wearables: NextPage = () => { const nftIds = getNftIds(); if(provider && account?.address && nftIds.length > 0 && nfts) { - const { ethereum } = getMainnetSdk(provider); + const { nft_wearables } = getGoerliSdk(provider); const addressess = Array(nftIds.length).fill(account?.address) - const nftBalances = await ethereum.nft_wearables.balanceOfBatch(addressess, nftIds); + const nftBalances = await nft_wearables.balanceOfBatch(addressess, nftIds); const parsedBalances = nftBalances.map((balance: ethers.BigNumberish) => ethers.utils.formatUnits(balance, 0)) // reduce to nft items only with existing balance diff --git a/components/profile/InvalidChain.tsx b/components/profile/InvalidChain.tsx index d086ffd..f65ffe1 100644 --- a/components/profile/InvalidChain.tsx +++ b/components/profile/InvalidChain.tsx @@ -12,7 +12,7 @@ const Profile: NextPage = () => { toast({ id: selectEthToastId, title: `Please select ${ - process.env.NEXT_PUBLIC_CHAIN_ID === "4" ? "Rinkeby" : "Ethereum mainnet" + process.env.NEXT_PUBLIC_CHAIN_ID === "5" ? "GOERLI" : "Ethereum mainnet" } network`, status: "error", isClosable: true, diff --git a/eth-sdk/abis/goerli/nft_giveaway.json b/eth-sdk/abis/goerli/nft_giveaway.json new file mode 100644 index 0000000..3eaeeb5 --- /dev/null +++ b/eth-sdk/abis/goerli/nft_giveaway.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"address","name":"contractAddress","type":"address"}],"indexed":false,"internalType":"struct ClaimERC1155ERC721ERC20.ERC1155Claim[]","name":"erc1155","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address","name":"contractAddress","type":"address"}],"indexed":false,"internalType":"struct ClaimERC1155ERC721ERC20.ERC721Claim[]","name":"erc721","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address[]","name":"contractAddresses","type":"address[]"}],"indexed":false,"internalType":"struct ClaimERC1155ERC721ERC20.ERC20Claim","name":"erc20","type":"tuple"},{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"ClaimedMultipleTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"expiryTime","type":"uint256"}],"name":"NewGiveaway","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"uint256","name":"expiryTime","type":"uint256"}],"name":"addNewGiveaway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"components":[{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ClaimERC1155ERC721ERC20.ERC1155Claim[]","name":"erc1155","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ClaimERC1155ERC721ERC20.ERC721Claim[]","name":"erc721","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address[]","name":"contractAddresses","type":"address[]"}],"internalType":"struct ClaimERC1155ERC721ERC20.ERC20Claim","name":"erc20","type":"tuple"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ClaimERC1155ERC721ERC20.Claim","name":"claim","type":"tuple"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"claimMultipleTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"rootHashes","type":"bytes32[]"},{"components":[{"internalType":"address","name":"to","type":"address"},{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ClaimERC1155ERC721ERC20.ERC1155Claim[]","name":"erc1155","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"address","name":"contractAddress","type":"address"}],"internalType":"struct ClaimERC1155ERC721ERC20.ERC721Claim[]","name":"erc721","type":"tuple[]"},{"components":[{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address[]","name":"contractAddresses","type":"address[]"}],"internalType":"struct ClaimERC1155ERC721ERC20.ERC20Claim","name":"erc20","type":"tuple"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"internalType":"struct ClaimERC1155ERC721ERC20.Claim[]","name":"claims","type":"tuple[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"}],"name":"claimMultipleTokensFromMultipleMerkleTree","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"claimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bytes32[]","name":"rootHashes","type":"bytes32[]"}],"name":"getClaimedStatus","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"leaves","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/eth-sdk/abis/goerli/nft_wearables.json b/eth-sdk/abis/goerli/nft_wearables.json new file mode 100644 index 0000000..eb85696 --- /dev/null +++ b/eth-sdk/abis/goerli/nft_wearables.json @@ -0,0 +1 @@ +[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"AdminApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"AdminRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address payable[]","name":"receivers","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"basisPoints","type":"uint256[]"}],"name":"DefaultRoyaltiesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"extension","type":"address"},{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"ExtensionApproveTransferUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"extension","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"ExtensionBlacklisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"extension","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"ExtensionRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"extension","type":"address"},{"indexed":false,"internalType":"address payable[]","name":"receivers","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"basisPoints","type":"uint256[]"}],"name":"ExtensionRoyaltiesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"extension","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"ExtensionUnregistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"extension","type":"address"},{"indexed":true,"internalType":"address","name":"permissions","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"MintPermissionsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address payable[]","name":"receivers","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"basisPoints","type":"uint256[]"}],"name":"RoyaltiesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"approveAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"extension","type":"address"}],"name":"blacklistExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAdmins","outputs":[{"internalType":"address[]","name":"admins","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExtensions","outputs":[{"internalType":"address[]","name":"extensions","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFeeBps","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFeeRecipients","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFees","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getRoyalties","outputs":[{"internalType":"address payable[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"isAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"mintBaseExisting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"string[]","name":"uris","type":"string[]"}],"name":"mintBaseNew","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"mintExtensionExisting","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"to","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"string[]","name":"uris","type":"string[]"}],"name":"mintExtensionNew","outputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"_name","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"extension","type":"address"},{"internalType":"string","name":"baseURI","type":"string"}],"name":"registerExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"extension","type":"address"},{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"bool","name":"baseURIIdentical","type":"bool"}],"name":"registerExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"admin","type":"address"}],"name":"revokeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setApproveTransferExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri_","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri_","type":"string"}],"name":"setBaseTokenURIExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri_","type":"string"},{"internalType":"bool","name":"identical","type":"bool"}],"name":"setBaseTokenURIExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"extension","type":"address"},{"internalType":"address","name":"permissions","type":"address"}],"name":"setMintPermissions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address payable[]","name":"receivers","type":"address[]"},{"internalType":"uint256[]","name":"basisPoints","type":"uint256[]"}],"name":"setRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable[]","name":"receivers","type":"address[]"},{"internalType":"uint256[]","name":"basisPoints","type":"uint256[]"}],"name":"setRoyalties","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"extension","type":"address"},{"internalType":"address payable[]","name":"receivers","type":"address[]"},{"internalType":"uint256[]","name":"basisPoints","type":"uint256[]"}],"name":"setRoyaltiesExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"uri_","type":"string"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"string[]","name":"uris","type":"string[]"}],"name":"setTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"string[]","name":"uris","type":"string[]"}],"name":"setTokenURIExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"uri_","type":"string"}],"name":"setTokenURIExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"prefix","type":"string"}],"name":"setTokenURIPrefix","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"prefix","type":"string"}],"name":"setTokenURIPrefixExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"_symbol","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenExtension","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"extension","type":"address"}],"name":"unregisterExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/eth-sdk/eth-sdk.config.ts b/eth-sdk/eth-sdk.config.ts index bd28396..d36ac70 100644 --- a/eth-sdk/eth-sdk.config.ts +++ b/eth-sdk/eth-sdk.config.ts @@ -9,9 +9,9 @@ export default defineConfig({ nft_giveaway: "0xdcDB68d061255C8eB92153218441e0E4e820c1C7", }, }, - rinkeby: { - nft_wearables: "0x2D62Ec5B09c3De2106433d877EcB10C9424fCcD7", - nft_giveaway: "0x8B07fa6767F33f6bC224a1F0d51BA4DE360480Aa", + goerli: { + nft_wearables: "0x204aB638B9F9430237d096500d7f3Baa0f416892", + nft_giveaway: "0xd8401646686430711D5d48407D8C0bb79616baef", }, }, }); From 40db11ee19bd4ef7c07e039e418355dca79797e9 Mon Sep 17 00:00:00 2001 From: xivanc Date: Fri, 17 Feb 2023 15:20:20 +0100 Subject: [PATCH 2/2] temp switch to goerli for test purposes --- components/closet/ClaimWearables.tsx | 9 ++++++--- components/closet/WearableDetail/index.tsx | 9 ++++++--- components/closet/index.tsx | 2 +- hooks/useMetafactoryData.ts | 9 ++++++--- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/components/closet/ClaimWearables.tsx b/components/closet/ClaimWearables.tsx index 41443a1..bbe2240 100644 --- a/components/closet/ClaimWearables.tsx +++ b/components/closet/ClaimWearables.tsx @@ -6,7 +6,9 @@ import Button from "@/components/atoms/Button" import useUserName from "@/hooks/useUserName"; import { NftClaim } from "@/hooks/useMetafactoryData"; import { Alert } from "@/components/atoms"; -import { getMainnetSdk } from '@dethcrypto/eth-sdk-client'; +// import { getMainnetSdk } from '@dethcrypto/eth-sdk-client'; +import { getGoerliSdk } from '@dethcrypto/eth-sdk-client'; + import { useSigner } from 'wagmi'; @@ -21,7 +23,8 @@ const ClaimWearables: React.FC<{nftClaims: NftClaim[]}> = ({ nftClaims }) => { }; const executeClaim = async () => { if(signer) { - const { ethereum } = getMainnetSdk(signer); + // eslint-disable-next-line camelcase + const { nft_giveaway } = getGoerliSdk(signer); const claims = nftClaims.map((nftClaim: NftClaim) => ({ to: nftClaim.claim_json.to, erc1155: nftClaim.claim_json.erc1155, @@ -32,7 +35,7 @@ const ClaimWearables: React.FC<{nftClaims: NftClaim[]}> = ({ nftClaims }) => { const merkleRootHashes = nftClaims.map((nftClaim: NftClaim) => nftClaim.merkle_root_hash) const merkleProofs = nftClaims.map((nftClaim: NftClaim) => nftClaim.claim_json.proof) - ethereum.nft_giveaway.claimMultipleTokensFromMultipleMerkleTree( + nft_giveaway.claimMultipleTokensFromMultipleMerkleTree( merkleRootHashes, claims, merkleProofs diff --git a/components/closet/WearableDetail/index.tsx b/components/closet/WearableDetail/index.tsx index 15669c8..5a26b7b 100644 --- a/components/closet/WearableDetail/index.tsx +++ b/components/closet/WearableDetail/index.tsx @@ -6,7 +6,8 @@ import { Canvas } from '@react-three/fiber'; import { OrbitControls, Stage } from '@react-three/drei'; import useUserName from "@/hooks/useUserName"; import useNftMetadata from "@/hooks/useNftMetadata"; -import { getMainnetSdk } from '@dethcrypto/eth-sdk-client'; +// import { getMainnetSdk } from '@dethcrypto/eth-sdk-client'; +import { getGoerliSdk } from '@dethcrypto/eth-sdk-client'; import { useProvider, useAccount } from 'wagmi'; import { Loading } from "@/components/atoms"; import { useRouter } from "next/router"; @@ -28,8 +29,10 @@ const Index: NextPage = () => { useEffect(() => { const fetch = async () => { if(provider && account?.address && id) { - const { ethereum } = getMainnetSdk(provider); - const nftBalances = await ethereum.nft_wearables.balanceOfBatch([account.address], [Number(id)]); + // const { ethereum } = getMainnetSdk(provider); + // eslint-disable-next-line camelcase + const { nft_wearables } = getGoerliSdk(provider); + const nftBalances = await nft_wearables.balanceOfBatch([account.address], [Number(id)]); setBalance(ethers.utils.formatUnits(nftBalances[0], 0)) }; } diff --git a/components/closet/index.tsx b/components/closet/index.tsx index ca7953f..a679c2b 100644 --- a/components/closet/index.tsx +++ b/components/closet/index.tsx @@ -61,7 +61,7 @@ const Wearables: NextPage = () => { useEffect(() => { if (authBearer && account?.address) { - fetchNftClaims(authBearer); + fetchNftClaims(authBearer, account?.address); } }, [account?.address, authBearer, fetchNftClaims]); diff --git a/hooks/useMetafactoryData.ts b/hooks/useMetafactoryData.ts index d964d33..4613899 100644 --- a/hooks/useMetafactoryData.ts +++ b/hooks/useMetafactoryData.ts @@ -101,19 +101,22 @@ const useMetafactoryData = () => { ); }; - const fetchNftClaims = (accountAuthToken: string) => { + const fetchNftClaims = (authBearer: string, address: string) => { setLoadingNftClaims(true); const root = "robot_merkle_claims"; const NFT_CLAIMS_QUERY = ` query GetClaimForAddress { - ${root}(where: {merkle_root: {network: {_eq: "mainnet"}}}) { + ${root}(where: {merkle_root: { + network: {_eq: "goerli"}}, + recipient_eth_address: {_ilike: "${address}"}}) + { claim_json merkle_root_hash } } `; return ( - fetchGraph(SUBGRAPH_ENDPOINTS.metafactory, NFT_CLAIMS_QUERY, null, accountAuthToken) + fetchGraph(SUBGRAPH_ENDPOINTS.metafactory, NFT_CLAIMS_QUERY, null, authBearer) // @ts-ignore .then(({ data: { [root]: nftClaimArray } }) => { const currentNftClaims = nftClaimArray.map((nftClaim: NftClaim) => {