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

useDApp generate hooks demo #1

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ artifacts

*diamond.json
metadata
types
types
gen
19 changes: 18 additions & 1 deletion contracts/_diamond/Diamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { LibDiamond } from "./libraries/LibDiamond.sol";
import { IDiamondCut } from "./interfaces/IDiamondCut.sol";
import { IDiamondLoupe } from "./interfaces/IDiamondLoupe.sol";

contract Diamond {
contract Diamond {
uint private _counter;

constructor(address _contractOwner, address _diamondCutFacet, address _diamondLoupeFacet, address _facetsRepository) payable {
LibDiamond.setContractOwner(_contractOwner);
Expand Down Expand Up @@ -44,6 +45,22 @@ contract Diamond {
LibDiamond.diamondCut(cut, address(0), "");
}

function exampleFunction(uint num) public pure returns (uint) {
return num;
}

function incrementCounter() public {
_counter++;
}

function increaseCounter(uint num) public {
_counter += num;
}

function getCounter() public view returns (uint) {
return _counter;
}

// Find facet for function that is called and execute the
// function if a facet is found and return any value.
fallback() external payable {
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"start": "next start",
"lint": "next lint",
"start:node": "hardhat node",
"generate:typechain": "typechain --target=ethers-v5 metadata/*.json ",
"generate:typechain": "typechain --target=ethers-v5 artifacts/contracts/_diamond/Diamond.sol/Diamond.json ",
"generate:usedapp": "USEDAPP_OUT_DIR=./gen/hooks USEDAPP_TYPES_DIR=./types/ethers-contracts yarn usedapp-generate-hooks",
"generate": "yarn generate:typechain && yarn generate:usedapp",
"diamond:add": "hardhat diamond:add --remote --save-metadata --address ",
"diamond:init": "hardhat diamond:init && yarn generate:typechain"
},
"dependencies": {
"@solidstate/contracts": "^0.0.35",
"@usedapp/core": "^1.0.15",
"@usedapp/core": "1.1.3",
"hardhat-gemcutter": "https://github.com/marcocastignoli/hardhat-gemcutter",
"next": "12.1.6",
"react": "18.2.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1415,10 +1415,10 @@
resolved "https://registry.yarnpkg.com/@uniswap/token-lists/-/token-lists-1.0.0-beta.30.tgz#2103ca23b8007c59ec71718d34cdc97861c409e5"
integrity sha512-HwY2VvkQ8lNR6ks5NqQfAtg+4IZqz3KV1T8d2DlI8emIn9uMmaoFbIOg0nzjqAVKKnZSbMTRRtUoAh6mmjRvog==

"@usedapp/core@^1.0.15":
version "1.0.15"
resolved "https://registry.yarnpkg.com/@usedapp/core/-/core-1.0.15.tgz#66c982c13cf9aeb061b74fa6ad1f8ef6f7cd4fd2"
integrity sha512-dvjLiYVyutM25BiwiFlPjyhPVlLQA4Dg/WnN0Q8XPnWtyasM0mytxerGQMl0Um1WCtqQynV2R8SU5iQY723cCA==
"@usedapp/core@1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@usedapp/core/-/core-1.1.3.tgz#04f087edd96b5a5ec9726ba7fa278a6e68f5b937"
integrity sha512-2hWzZ9oCsfgzN8Ewu3of2JuWuiFfBUtSY4b+dz3YygZcx1D48IxjyUO3+VjxVbE5eQAYSjfnA6WVMDIBZ+K5zQ==
dependencies:
"@metamask/detect-provider" "^1.2.0"
"@uniswap/token-lists" "^1.0.0-beta.27"
Expand Down