Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix - getDonators and donateToCampaign give errors #40] #51

Merged

Conversation

krishnaacharyaa
Copy link
Contributor

In the latest release contract.call() has changed the parameters to accept array instead of single param.

The API for interacting with smart contracts via the thirdweb React & TypeScript SDKs has been updated in favor of explicitly defining function arguments and (optionally) call overrides.

Using the contract.call function in the TypeScript SDK now looks like the following:

const owner = "0x...";
const operator = "0x...";
const overrides = { gasPrice: 800000 };
const res = await contract.call("approve", [owner, operator], overrides);

Note that the arguments to the contract function are now passed in as an array as the second parameter to contract.call, and the overrides are passed optionally as the last parameter.


Also refer official docs

const data = await contract.call(
  "myFunctionName", // Name of your function as it is on the smart contract
  // Arguments to your function, in the same order they are on your smart contract
  [
    "arg1", // e.g. Argument 1
    "arg2", // e.g. Argument 2
  ],
);

@adrianhajdin adrianhajdin merged commit 2f8d4b8 into adrianhajdin:master Jul 3, 2023
@sandipmaurya2611
Copy link

I got this type of error please give me a solution for that :- this 1st bug
lockdown-run.js:17 Lockdown failed: TypeError: At intrinsics.Object.groupBy expected boolean not function
at isAllowedPropertyValue (lockdown-install.js:1:53384)
at isAllowedProperty (lockdown-install.js:1:53807)
at visitProperties (lockdown-install.js:1:55095)
at isAllowedPropertyValue (lockdown-install.js:1:53041)
at isAllowedProperty (lockdown-install.js:1:53807)
at visitProperties (lockdown-install.js:1:55095)
at lockdown-install.js:1:55523
at repairIntrinsics (lockdown-install.js:1:144597)
at lockdown-install.js:1:145462
at lockdown-run.js:4:3

And this is Second:-

rror: Could not fetch bytecode for contract at 0xC8B8c3D9e8AFFC1C545602e01a7DC9071a086f3b on chain 1, double check that the address and chainId are correct.
at fetchContractMetadataFromAddress (contract-publisher-6a419060.browser.esm.js:4868:11)

I am unable to create campaigns... Please give me a solution ..

Error

@gurjeetsinghvirdee
Copy link

@sandipmaurya2611
Ignore the 1st one

For Second BUG

You can fix that issue by doing some changes on main.jsx

File Path

client/src/main.jsx

First run this command on your client directory

npm install @thirdweb-dev/chains

Then import it just as I did, Replace desiredChainId with activeChain, & remove the ChainID It will solves your issue

import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';
import { ChainId, ThirdwebProvider } from '@thirdweb-dev/react';
import { Sepolia } from "@thirdweb-dev/chains";

import { StateContextProvider } from './context';
import App from './App.jsx';
import './index.css';

const root = ReactDOM.createRoot(document.getElementById('root'));

// root.render(
//     <ThirdwebProvider desiredChainId={ChainId.Sepolia}>  // before your code looks like this
//         <Router>
//             <StateContextProvider>
//                 <App />
//             </StateContextProvider>
//         </Router>
//     </ThirdwebProvider>
// )

root.render(
    <ThirdwebProvider activeChain={Sepolia}>  // Now you have to write this
        <Router>
            <StateContextProvider>
                <App />
            </StateContextProvider>
        </Router>
    </ThirdwebProvider>
)

@sandipmaurya2611
Copy link

sandipmaurya2611 commented Oct 6, 2023 via email

@sandipmaurya2611
Copy link

sandipmaurya2611 commented Oct 6, 2023 via email

@gurjeetsinghvirdee
Copy link

@sandipmaurya2611

Some errors are irrelevant focus on that create issue on your code like createCampaign one

You can solve this bug just by adding {args:[]} inside the publishCampaign

File Path

client/src/context/index.js
// Here we are connecting web3 with the client 

import React, { useContext, createContext } from 'react';
import { useAddress, useContract, useMetamask, useContractWrite } from '@thirdweb-dev/react';
import { ethers } from "ethers";

const StateContext = createContext();

export const StateContextProvider = ({ children }) => {
    const { contract } = useContract('0x7045fe828a26e4B24B46A6902998C5F73aeF7144');
    const { mutateAsync: createCampaign } = useContractWrite(contract, 'createCampaign')

    const address = useAddress();
    const connect = useMetamask();

    const publishCampaign = async (form) => {
        try {
            const data = await createCampaign({args: [
                    address, // owner
                    form.title, // title
                    form.description, // description
                    form.target,
                    new Date(form.deadline).getTime(), // deadline
                    form.image // image
            ]});

            console.log("contract call success", data)
        } catch (error) {
            console.log("contract call failure", error)
        }
    }

    return (
        <StateContext.Provider
            value={{
                address,
                contract,
                connect,
                createCampaign: publishCampaign,
            }}
        >
            {children}
        </StateContext.Provider>
    )
}

export const useStateContext = () => useContext(StateContext);

@sandipmaurya2611
Copy link

sandipmaurya2611 commented Oct 6, 2023 via email

@gurjeetsinghvirdee
Copy link

gurjeetsinghvirdee commented Oct 6, 2023

@sandipmaurya2611
You forgot to add this >

image

Like this

@sandipmaurya2611
Copy link

I Put but still it does not work..

@gurjeetsinghvirdee
Copy link

I Put but still it does not work..

Then maybe you spelled some word wrong check in campaigndetails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants