-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(@agora): AG-25 configured evm compiler configured the evm compiler in the hardhat configuration file * refactor(@contracts): AG-25 refactored DECs Registry contract refactored DECs registry contract * refactor(@contracts): AG-25 refactored DEC contract refactored DEC smart contract * feat(@contracts): AG-25 added name property to DECs Registry added name property to DECs Registry smart contract * feat(@contracts): ignition modules implementation implemented the ignition modules for contracts deploy * fix(@contracts): AG-25 added folder to gitignore added foldet to gitignore * fix(@contracts): AG-25 ignored files added files to gitignore
- Loading branch information
Showing
17 changed files
with
258 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,7 @@ node_modules | |
/coverage.json | ||
|
||
# reports folder | ||
report | ||
report | ||
|
||
#ignition files | ||
/ignition/deployments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.24; | ||
|
||
/// @title The Voter's Digital Electoral Cards | ||
/// @title The Voter's Digital Electoral Card | ||
/// @author Christian Palazzo <palazzochristian@yahoo.it> | ||
/// @custom:experimental This is an experimental contract. | ||
contract DEC { | ||
address public owner; | ||
bytes taxCode; | ||
bytes municipality; | ||
bytes region; | ||
bytes country; | ||
|
||
constructor() { | ||
constructor( | ||
bytes memory _taxCode, | ||
bytes memory _municipality, | ||
bytes memory _region, | ||
bytes memory _country | ||
) { | ||
/// @dev only the owner of the contract has write permissions | ||
owner = msg.sender; | ||
taxCode = _taxCode; | ||
municipality = _municipality; | ||
region = _region; | ||
country = _country; | ||
} | ||
|
||
modifier onlyOwner() { | ||
require(msg.sender == owner, "Only owner can call this function"); | ||
_; | ||
} | ||
|
||
/// @notice This is the Digital Electoral Card, emitted by a public third-party authority and owned by the Voter | ||
/// @dev This data is encrypted with the Voter's public address and only the Voter can decrypt it using the private key | ||
struct decData { | ||
string taxCode; | ||
string municipality; | ||
string province; | ||
string region; | ||
string country; | ||
function setTaxCode(bytes memory _taxCode) public onlyOwner { | ||
taxCode = _taxCode; | ||
} | ||
|
||
event DECEncrypted(address indexed owner, bytes encryptedData); | ||
function getTaxCode() public view returns (bytes memory) { | ||
return taxCode; | ||
} | ||
|
||
/// @notice This function is used to encrypt ad digitally sign a DEC | ||
function encryptDEC( | ||
decData memory dec | ||
) public onlyOwner returns (bytes memory) { | ||
bytes memory encodedData = abi.encodePacked( | ||
dec.taxCode, | ||
dec.municipality, | ||
dec.province, | ||
dec.region, | ||
dec.country | ||
); | ||
bytes32 hashedData = keccak256(encodedData); | ||
bytes memory signature = signData(hashedData); | ||
function setMunicipality(bytes memory _municipality) public onlyOwner { | ||
municipality = _municipality; | ||
} | ||
|
||
emit DECEncrypted(msg.sender, abi.encodePacked(hashedData, signature)); | ||
function getMunicipality() public view returns (bytes memory) { | ||
return municipality; | ||
} | ||
|
||
return abi.encodePacked(hashedData, signature); | ||
function setRegion(bytes memory _region) public onlyOwner { | ||
region = _region; | ||
} | ||
|
||
/// @notice This function is used to digitally sign the data | ||
function signData(bytes32 data) private pure returns (bytes memory) { | ||
bytes32 hash = keccak256( | ||
abi.encodePacked("\x19Ethereum Signed Message:\n32", data) | ||
); | ||
bytes1 v = bytes1(0); | ||
bytes32 r = bytes32(0); | ||
bytes32 s = uintToBytes32(1); | ||
return abi.encodePacked(ecrecover(hash, uint8(v), r, s), r, s); | ||
function getRegion() public view returns (bytes memory) { | ||
return region; | ||
} | ||
|
||
/// @notice this function is used in signData function | ||
function uintToBytes32(uint256 x) private pure returns (bytes32) { | ||
return bytes32(x); | ||
function setCountry(bytes memory _country) public onlyOwner { | ||
country = _country; | ||
} | ||
|
||
function getCountry() public view returns (bytes memory) { | ||
return country; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; | ||
|
||
export default buildModule("DEC", (m) => { | ||
const DEC1 = m.contract("TomsDEC", [ | ||
"RSSMRA85C27H501W", | ||
"Ardea", | ||
"Lazio", | ||
"Italy", | ||
]); | ||
|
||
m.call(DEC1, "getName", []); | ||
|
||
return { DEC1 }; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { buildModule } from "@nomicfoundation/hardhat-ignition/modules"; | ||
|
||
export default buildModule("DECsRegistry", (m) => { | ||
const italianRegistry = m.contract("DECsRegistry", ["Italy"]); | ||
|
||
m.call(italianRegistry, "getName", []); | ||
|
||
return { italianRegistry }; | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
if [ "$#" -ne 2 ]; then | ||
echo "Usage: $0 <module_path> <network>" | ||
exit 1 | ||
fi | ||
|
||
MODULE_PATH="$1" | ||
NETWORK="$2" | ||
|
||
npx hardhat ignition deploy "$MODULE_PATH" --network "$NETWORK" |
Oops, something went wrong.