From 7fce1821c6bcbf3eacaa485b05bf40776d610176 Mon Sep 17 00:00:00 2001 From: Ashu Gupta Date: Sun, 5 Nov 2023 22:54:13 +0530 Subject: [PATCH 1/2] add: minipay btn --- src/components/layout/Header.tsx | 2 ++ src/components/layout/SuccessComponent.tsx | 2 +- src/pages/retrieve.tsx | 8 ++++++-- src/providers/Web3.tsx | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 8972fab..67ab715 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -3,6 +3,7 @@ import { Web3Button } from '@web3modal/react' import { SITE_NAME } from 'utils/config' import { LinkComponent } from './LinkComponent' import { PassportScore } from './PassportScore' +import { ConnectMiniPay } from '../../providers/Web3' import ChainSelector from 'components/ChainSelector' @@ -26,6 +27,7 @@ export function Header(props: Props) { + {/* */} diff --git a/src/components/layout/SuccessComponent.tsx b/src/components/layout/SuccessComponent.tsx index dcb0767..68af8a7 100644 --- a/src/components/layout/SuccessComponent.tsx +++ b/src/components/layout/SuccessComponent.tsx @@ -60,7 +60,7 @@ const SuccessComponent = ({ link, data, message = '', subtitle = '' }: { link: s + } \ No newline at end of file From f6454e7971d43c44ace9a6bb391740389f528579 Mon Sep 17 00:00:00 2001 From: Ashu Gupta Date: Sat, 11 Nov 2023 21:20:18 +0530 Subject: [PATCH 2/2] edit retrieve --- src/pages/retrieve.tsx | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/pages/retrieve.tsx b/src/pages/retrieve.tsx index bad8d7c..cdfe92b 100644 --- a/src/pages/retrieve.tsx +++ b/src/pages/retrieve.tsx @@ -13,10 +13,11 @@ import Container from 'components/layout/Container' import History from 'components/layout/History' import SuccessComponent from 'components/layout/SuccessComponent' import referralCampaignContract from '../../contracts/out/ReferralCampaign.sol/ReferralCampaign.json' +import account from './api/account' const CreateLink: NextPage = () => { // TODO: Fetch proof from shared state - const account = useAccount() + const { address } = useAccount() const { colorMode } = useColorMode() const formWidth = useBreakpointValue({ base: '90%', md: '600px' }) const toast = useToast() @@ -24,7 +25,7 @@ const CreateLink: NextPage = () => { const [campaignId, setCampaignId] = useState('') const [campaignAddy, setCampaignAddy] = useState('') - const [ref, setRef] = useState('a') + const [ref, setRef] = useState('') const [isSubmitting, setIsSubmitting] = useState(false) const [args, setArgs] = useState([]) const [proof, setProof] = useState([BigInt(1), BigInt(1), BigInt(1), BigInt(1), BigInt(1), BigInt(1), BigInt(1), BigInt(1)]) @@ -33,8 +34,6 @@ const CreateLink: NextPage = () => { const [isReadyToSubmit, setIsReadyToSubmit] = useState(false) - const { address } = account - useEffect(() => { const { ref: refParam, campaignId: campaignIdParam, campaignAddy: campaignAddyParam } = router.query @@ -53,13 +52,18 @@ const CreateLink: NextPage = () => { useEffect(() => { console.log('Checking if ready to submit') + console.log(`address`) console.log(address) + console.log(`root`) console.log(root) + console.log(`nullifier`) console.log(nullifier) + console.log(`proof`) console.log(proof) // address _referrer, address signal, uint256 root, uint256 nullifierHash, uint256[8] calldata proof // FIXME: the second is the address of the claimer or the campaignId? - setArgs([address, address, root, nullifier, proof]) + // first is address of referrer, second is address of referree + setArgs([ref, address, root, nullifier, proof]) if (!address) return console.log('address passed') @@ -76,8 +80,7 @@ const CreateLink: NextPage = () => { }, [address, root, nullifier, proof]) // TODO: Add history on Atom - console.log('isReadyToSubmit') - console.log(isReadyToSubmit) + console.log(`isReadyToSubmit: ${isReadyToSubmit}`) const history = [] const { config, @@ -92,12 +95,25 @@ const CreateLink: NextPage = () => { onSettled(data, error) { console.warn('Settled', { data, error }) }, - }) + }); + + if(isPrepareError) { + console.log("usePrepareContractWrite has following error"); + console.log(prepareError); + } console.log("config"); console.log(config); - const { data, error, isError, write } = useContractWrite(config) + const { data, error, isError, write } = useContractWrite(config); + + console.log(`write`); + console.log(write); + + if (isError) { + console.log("useContractWrite has following error"); + console.log(error); + } const execute = () => { if (!!write) { @@ -106,9 +122,11 @@ const CreateLink: NextPage = () => { console.log('executed') } else { console.warn("Can't execute because useContractWrite is not yet ready") - console.log(args) + console.log(`args`) + console.log(args); console.log('sendTx') - console.log(write) + console.log(`write`) + console.log(write); setIsSubmitting(false) } }