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

Change the branch name to canvasOnchain and also write a readme file in the hardhat folder for description #32

Merged
merged 13 commits into from
Dec 17, 2024

Conversation

Abidoyesimze
Copy link
Contributor

@Abidoyesimze Abidoyesimze commented Dec 5, 2024

Description

Concise description of proposed changes, We recommend using screenshots and videos for better description

Additional Information

Related Issues

Closes #{issue number}

Note: If your changes are small and straightforward, you may skip the creation of an issue beforehand and remove this section. However, for medium-to-large changes, it is recommended to have an open issue for discussion and approval prior to submitting a pull request.

Your ENS/address: 0x6BF7d6b94282BD48ff458599aDafA268BcB009FF

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
batch11.buidlguidl.com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2024 10:22am

Copy link

vercel bot commented Dec 5, 2024

@Abidoyesimze is attempting to deploy a commit to the BuidlGuidl Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filename is not matching the contract name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here it's called canvasOnChain

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check everything to be sure it's the same name everywhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

@@ -33,7 +34,7 @@ const config: HardhatUserConfig = {
},
],
},
defaultNetwork: "localhost",
defaultNetwork: "sepolia",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually don't change this, because unwarned people might deploy to the incorrect network by mistake. When I want to deploy to another network I add the flag on the command:

yarn deploy --network sepolia

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

@@ -54,7 +55,7 @@ const config: HardhatUserConfig = {
accounts: [deployerPrivateKey],
},
sepolia: {
url: `https://rpc2.sepolia.org`,
url: `https://eth-sepolia.g.alchemy.com/v2/FIQ1qwifmra7ZqdkVHnZ2lHQAKG8j4Yd`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule, never include an API key in the code of a GitHub repository. Instead, use the .env file. Alternatively, you can use public RPCs, such as those available here: https://chainlist.org/chain/11155111.

@@ -7,6 +7,7 @@
"check-types": "tsc --noEmit --incremental",
"compile": "hardhat compile",
"deploy": "hardhat deploy",
"deploy:canvas": "hardhat run deploy/canvasOnchain.ts --network sepolia",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need another script? Isn't the deploy script deploying everything that is on the deploy folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will make changes to that it's when i'm having issue with the network but forget to remove it later on

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

@@ -10,7 +10,7 @@ export type ScaffoldConfig = {

const scaffoldConfig = {
// The networks on which your DApp is live
targetNetworks: [chains.optimism],
targetNetworks: [chains.sepolia],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you deploy BatchRegistry to sepolia as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unable to even deploy to sepolia now the gas is high right now

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made all the changes but still having issue deploying sepolia is too high and when trying to use optimism it's giving me issue i don't understand pls can you help me to deploy it from your side

@melanke
Copy link
Contributor

melanke commented Dec 5, 2024

@Abidoyesimze there's still some things called CanvasOnChain and others PixelCanvas

getCanvasSnapshot(): Returns entire canvas state

3. Initialization
Test the CanvasOnchain contract
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Test the CanvasOnchain contract
Test the PixelCanvas contract

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filename

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[RESOLVED]

Copy link
Collaborator

@phipsae phipsae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the whole effort and the smart contract!
Looking forward to see how it is then implemented in the front end :)

Below you'll find comments, please let me know if you have any questions.
(I haven't reviewed the test file).

@@ -54,7 +55,7 @@ const config: HardhatUserConfig = {
accounts: [deployerPrivateKey],
},
sepolia: {
url: `https://rpc2.sepolia.org`,
url: `https://eth-sepolia.g.alchemy.com/v2/FIQ1qwifmra7ZqdkVHnZ2lHQAKG8j4Yd`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general rule, never include an API key in the code of a GitHub repository. Instead, use the .env file. Alternatively, you can use public RPCs, such as those available here: https://chainlist.org/chain/11155111.

yarn.lock Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are adding @nomicfoundation/hardhat-network-helpers, that should be the only change made here.

package.json Outdated Show resolved Hide resolved
@@ -7,6 +7,7 @@ import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "@nomicfoundation/hardhat-verify";
import "@nomicfoundation/hardhat-network-helpers";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we need this import here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make things more complicated than necessary :)
There is already a deploy script named 00_deploy_your_contract.ts file which you can use.
Take the following code, copy it and adapt it for your contract:

await deploy("BatchRegistry", { from: deployer, // Contract constructor arguments args: [deployer, BATCH_NUMBER], log: true, // autoMine: speeds up deployment on local networks by auto-mining the deployment transaction. No effect on live networks. autoMine: true, });

Currently, the contracts are not being copied to the deployedContract.ts file in the Next.js project as they should. (Deploy scripts need to run before 99_generateTsAbis.ts.)

Let me know if you have any questions!

packages/hardhat/contracts/PixelCanvas.sol Show resolved Hide resolved
for (uint256 x = 10; x < 20; x++) {
for (uint256 y = 10; y < 50; y++) {
canvas[x][y] = Pixel({
author: owner(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also use in the initialization msg.sender as the author.

}

// 2D Mapping to store pixels
Pixel[CANVAS_WIDTH][CANVAS_HEIGHT] public canvas;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a mapping here instead. That is more gas-efficient and flexible, storing the whole array from the beginning a is not the ideal solution. The key advantages of a mapping compared to a fixed-size array are:

  • Lower Deployment Cost: There's no need to initialize the entire array, reducing upfront costs.
  • Higher Gas Efficiency: It only stores modified pixels, making it ideal for canvases where most pixels remain unchanged

Consider what additional functions we might not need if we switch to using a mapping.

Copy link
Collaborator

@phipsae phipsae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

You still need to add a deploy script (important for reviewers to deploy and test it themselves).
Also, just a small comment below about the withdraw and how to send ether.

In general, please ensure your PR has a clear and descriptive title and description (file out the template form). For example, "Change the branch name to canvasOnchain and write a README file in the Hardhat folder for description" would be more suitable as a commit message. That's what this course is also about :)

require(balance > 0, "No funds to withdraw");

// Transfer the balance to the owner
payable(owner()).transfer(balance);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json Outdated Show resolved Hide resolved
yarn.lock Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes to this file.

Comment on lines 42 to 44
// const batchRegistry = await hre.ethers.getContract<Contract>("BatchRegistry", deployer);
// console.log("\nBatchRegistry deployed to:", await batchRegistry.getAddress());
// console.log("Remember to update the allow list!\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we still need to deploy the BatchRegistry, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't have idea about it that's why i commented it out till @phipsae replied

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a reviewer of the PR, I would first test it in my local environment, which involves deploying all the contracts (including batchRegistry). Therefore, you should add the deployment of your new contract to the existing script (so you leave the script as it is and add the additional deploy code).

Copy link
Collaborator

@phipsae phipsae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below my comments.
As soon as you have the deploy script, I will look at the contract.

Thank you!

package.json Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No changes to this file, pls.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment in the conversation.
Leave the script as it is, just add the deploy contract block to it (like it is done for batch registry).

Copy link
Collaborator

@phipsae phipsae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contract! I deployed the contract to optimism and made a few changes so we can finally merge it.

For next time, it would be great if you could run yarn deploy before pushing the code. It didn't work because you were passing an argument into the constructor, but the contract doesn’t accept one. :))

Screenshot 2024-12-17 at 08 42 17

@phipsae phipsae merged commit 270c25a into BuidlGuidl:main Dec 17, 2024
1 of 2 checks passed
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.

3 participants