From c0983f8d96c8df2edfb86d838e8cfe4ca427065e Mon Sep 17 00:00:00 2001 From: Stefano Gagliardi Date: Fri, 20 May 2022 16:26:20 +0200 Subject: [PATCH 1/5] Fix contracts 0.8.9 build for test:fix on win platform --- scripts/compile-contracts.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/compile-contracts.ts b/scripts/compile-contracts.ts index f762de6d9..806744787 100644 --- a/scripts/compile-contracts.ts +++ b/scripts/compile-contracts.ts @@ -99,7 +99,11 @@ function generateABIs({ rootDir, contracts }: Files) { `-o ./contracts/compiled/${dirName}`, ] - execSync(`npx solc@${semver} --abi ${contractPaths} --bin -o ./contracts/compiled/${dirName}`, { + /** + * Fix contract v.0.8.9 on win platform + */ + const winPlatform = process.platform === 'win32' ? `--base-path . --include-path ./contracts/${dirName}` : '' + execSync(`npx solc@${semver} ${winPlatform} --abi ${contractPaths} --bin -o ./contracts/compiled/${dirName}`, { cwd: rootDir, stdio: ['ignore', 'ignore', 'inherit'], }) From b1c209b529edddb893b956ca149d5ccbcfd4cdb0 Mon Sep 17 00:00:00 2001 From: Stefano Gagliardi Date: Sat, 21 May 2022 21:47:33 +0200 Subject: [PATCH 2/5] Add example contracts for #688 --- contracts/v0.6.4/LibraryPerson.sol | 48 ++++++++++++++++++++++ contracts/v0.6.4/LibraryPersonConsumer.sol | 41 ++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 contracts/v0.6.4/LibraryPerson.sol create mode 100644 contracts/v0.6.4/LibraryPersonConsumer.sol diff --git a/contracts/v0.6.4/LibraryPerson.sol b/contracts/v0.6.4/LibraryPerson.sol new file mode 100644 index 000000000..70c289baf --- /dev/null +++ b/contracts/v0.6.4/LibraryPerson.sol @@ -0,0 +1,48 @@ +pragma solidity ^0.6.4; +// Remember to set corret version in Typchain: 0.6.4 - 0.8.9 + +/** + * Define Person Library + */ +library PersonLib { + + // Define person structure + struct Data { + bool isActive; + bytes hashOfData; + string handle; + } + + // Event for update isActive + event runMarkActive( + bool isActive + ); + + // Define getter + function getIsActive(Data storage self) public view returns (bool) { + return self.isActive; + } + + function getHashOfData(Data storage self) public view returns (bytes memory) { + return self.hashOfData; + } + + function getHandle(Data storage self) public view returns (string memory) { + return self.handle; + } + + // Define setter + function setMarkActive(Data storage self) internal { + emit runMarkActive(true); + self.isActive = true; + } + + function setHandle(Data storage self, string memory newHandle) internal { + self.handle = newHandle; + } + + function setHashOfData(Data storage self, string memory stringToHash) internal { + bytes memory hashed = bytes(stringToHash); + self.hashOfData = hashed; + } +} \ No newline at end of file diff --git a/contracts/v0.6.4/LibraryPersonConsumer.sol b/contracts/v0.6.4/LibraryPersonConsumer.sol new file mode 100644 index 000000000..8a9e5ba60 --- /dev/null +++ b/contracts/v0.6.4/LibraryPersonConsumer.sol @@ -0,0 +1,41 @@ +pragma solidity ^0.6.4;// Remember to set corret version in Typchain: 0.6.4 - 0.8.9 + +// Import Person Library +import "./LibraryPerson.sol"; + +/** + * Define Contract for consume person lib + */ +contract PersonConsumer { + + PersonLib.Data requester; + PersonLib.Data contributor; + + constructor() public {} + + event RequesterHandleUpdated( + string newHandle + ); + + event ContributorHandleUpdated( + string newHandle + ); + + function requesterHandle() public view returns (string memory) { + return requester.handle; + } + + function updateRequesterHandle(string memory newHandle) public { + emit RequesterHandleUpdated(newHandle); + PersonLib.setHandle(requester, newHandle); + } + + function contributorHandle() public view returns (string memory) { + return contributor.handle; + } + + function updateContributorHandle(string memory newHandle) public { + emit ContributorHandleUpdated(newHandle); + PersonLib.setHandle(contributor, newHandle); + } +} \ No newline at end of file From 486966c340ff6de94395a65adae4e126d3bf87d9 Mon Sep 17 00:00:00 2001 From: Stefano Gagliardi Date: Sat, 21 May 2022 21:48:06 +0200 Subject: [PATCH 3/5] Improve contributing --- CONTRIBUTING.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af9f38bfc..b423fe381 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,15 +4,28 @@ We welcome all contributions! ## Developing -Heads up: we use pnpm instead of yarn or npm. It might be new for you but I promise it's worth the hassle - it's really -good at making big monorepos deterministic. Please ensure that you are running pnpm version 7. +Heads up: we use pnpm instead of yarn or npm. It might be Q new for you but I promise it's worth the hassle - it's +really good at making big monorepos deterministic. Please ensure that you are running pnpm version 7. First, run `pnpm i` to install all deps. We use TypeScript monorepo, each target is a separate package and has another package with tests. You need to run `pnpm watch` to automatically recompile all the projects as you introduce changes. -Run `pnpm test:fix` before pushing, it will run eslint, prettier in fix mode and run all tests. +Run `pnpm test:fix` before pushing, it will run eslint, prettier in fix mode and run all tests. +NB: due to a [known issue](https://github.com/npm/cli/issues/3210) in the npm version newer than 6 it is not possible to +start the commands. A quick fix is to downgrade the npm version `npm install -g npm@6.14.17`. + +### Visual Code Solidity Version + +Since we develop using multiple versions of Solidity to avoid Linter errors from Visual Code in the following way we can +set the current solidity version. + +1. Install the "Solidity" extension from the Marketplace +2. Inside `.sol` file, run right click -> `Solidity: change workspace compiler version (remote)` +3. Choose version from dropdown menu (0.6.4 or 0.8.9 or ...) + +[Official Documentation](https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity) ### Local linking From 4c0cd1f4833c3da75de731b0a10312ac4446f549 Mon Sep 17 00:00:00 2001 From: Stefano Gagliardi Date: Thu, 26 May 2022 21:11:39 +0200 Subject: [PATCH 4/5] Revert "Add example contracts for #688" This reverts commit b1c209b529edddb893b956ca149d5ccbcfd4cdb0. --- contracts/v0.6.4/LibraryPerson.sol | 48 ---------------------- contracts/v0.6.4/LibraryPersonConsumer.sol | 41 ------------------ 2 files changed, 89 deletions(-) delete mode 100644 contracts/v0.6.4/LibraryPerson.sol delete mode 100644 contracts/v0.6.4/LibraryPersonConsumer.sol diff --git a/contracts/v0.6.4/LibraryPerson.sol b/contracts/v0.6.4/LibraryPerson.sol deleted file mode 100644 index 70c289baf..000000000 --- a/contracts/v0.6.4/LibraryPerson.sol +++ /dev/null @@ -1,48 +0,0 @@ -pragma solidity ^0.6.4; -// Remember to set corret version in Typchain: 0.6.4 - 0.8.9 - -/** - * Define Person Library - */ -library PersonLib { - - // Define person structure - struct Data { - bool isActive; - bytes hashOfData; - string handle; - } - - // Event for update isActive - event runMarkActive( - bool isActive - ); - - // Define getter - function getIsActive(Data storage self) public view returns (bool) { - return self.isActive; - } - - function getHashOfData(Data storage self) public view returns (bytes memory) { - return self.hashOfData; - } - - function getHandle(Data storage self) public view returns (string memory) { - return self.handle; - } - - // Define setter - function setMarkActive(Data storage self) internal { - emit runMarkActive(true); - self.isActive = true; - } - - function setHandle(Data storage self, string memory newHandle) internal { - self.handle = newHandle; - } - - function setHashOfData(Data storage self, string memory stringToHash) internal { - bytes memory hashed = bytes(stringToHash); - self.hashOfData = hashed; - } -} \ No newline at end of file diff --git a/contracts/v0.6.4/LibraryPersonConsumer.sol b/contracts/v0.6.4/LibraryPersonConsumer.sol deleted file mode 100644 index 8a9e5ba60..000000000 --- a/contracts/v0.6.4/LibraryPersonConsumer.sol +++ /dev/null @@ -1,41 +0,0 @@ -pragma solidity ^0.6.4;// Remember to set corret version in Typchain: 0.6.4 - 0.8.9 - -// Import Person Library -import "./LibraryPerson.sol"; - -/** - * Define Contract for consume person lib - */ -contract PersonConsumer { - - PersonLib.Data requester; - PersonLib.Data contributor; - - constructor() public {} - - event RequesterHandleUpdated( - string newHandle - ); - - event ContributorHandleUpdated( - string newHandle - ); - - function requesterHandle() public view returns (string memory) { - return requester.handle; - } - - function updateRequesterHandle(string memory newHandle) public { - emit RequesterHandleUpdated(newHandle); - PersonLib.setHandle(requester, newHandle); - } - - function contributorHandle() public view returns (string memory) { - return contributor.handle; - } - - function updateContributorHandle(string memory newHandle) public { - emit ContributorHandleUpdated(newHandle); - PersonLib.setHandle(contributor, newHandle); - } -} \ No newline at end of file From d5641bf43c698ddd77f78b4ce9780fbfdc1f1262 Mon Sep 17 00:00:00 2001 From: Stefano Gagliardi Date: Thu, 26 May 2022 21:15:39 +0200 Subject: [PATCH 5/5] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b423fe381..5d16764c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ We welcome all contributions! ## Developing -Heads up: we use pnpm instead of yarn or npm. It might be Q new for you but I promise it's worth the hassle - it's +Heads up: we use pnpm instead of yarn or npm. It might be new for you but I promise it's worth the hassle - it's really good at making big monorepos deterministic. Please ensure that you are running pnpm version 7. First, run `pnpm i` to install all deps.