From ab3c3cb7113d967adf24292a230042125c3d42e5 Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Tue, 24 Oct 2023 15:22:15 +0200 Subject: [PATCH 1/9] Update identity.sol --- addresses/contractAddresses.json | 14 +++++++------- contracts/ERC721Factory.sol | 3 ++- contracts/IDentity.sol | 15 ++++++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/addresses/contractAddresses.json b/addresses/contractAddresses.json index 86fb1a3..cefdafc 100644 --- a/addresses/contractAddresses.json +++ b/addresses/contractAddresses.json @@ -1,25 +1,25 @@ { "addresses": [ { - "Deployer": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F" + "Deployer": "0xf24D3a5b19E2c520d41613520A41325E5F97B1D7" }, { - "ERC721Base": "0x09635F643e140090A9A8Dcd712eD6285858ceBef" + "ERC721Base": "0xbc7fE8aAA7aCc4913C5F315824ED87A5CbD3074F" }, { - "ERC20Base": "0xc5a5C42992dECbae36851359345FE25997F5C42d" + "ERC20Base": "0xD0393d14d27D2887E95a9f35d660b0b92c928E63" }, { - "RouterFactory": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933" + "RouterFactory": "0xFaB97ef05a541B9E3fE21D85f40b83F915029692" }, { - "FixedRateExchange": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E" + "FixedRateExchange": "0xFF75417098F555a4c28361BBd9B499521477C452" }, { - "IDentity": "0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690" + "IDentity": "0x14991b0f9b76285Fbe17233E56b42907c8DFE7a5" }, { - "ERC721Factory": "0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB" + "ERC721Factory": "0x338f2fc6f13e4F001141407B8F6cf820a411083a" } ] } \ No newline at end of file diff --git a/contracts/ERC721Factory.sol b/contracts/ERC721Factory.sol index 6158b4f..0637038 100644 --- a/contracts/ERC721Factory.sol +++ b/contracts/ERC721Factory.sol @@ -38,7 +38,7 @@ contract ERC721Factory is Ownable, Deployer, IERC721Factory { string dt_name; string dt_symbol; uint256 maxSupply_; // must be > 10 otherwise mint will fail - uint256 vc_id; + uint256 vc_id; // TODO: remove this } struct ContractBase { @@ -89,6 +89,7 @@ contract ERC721Factory is Ownable, Deployer, IERC721Factory { * 3. Not revoked */ IIDentity identity_token = IIDentity(_identity_addr); + // TODO: Change to isVCRevoked_Addr[msg.sender] require(!identity_token.isVCRevoked(_publishData.vc_id), "The user does not have a valid VC!"); /** * deploy NFT token diff --git a/contracts/IDentity.sol b/contracts/IDentity.sol index bb30f09..c5c8011 100644 --- a/contracts/IDentity.sol +++ b/contracts/IDentity.sol @@ -3,6 +3,7 @@ pragma solidity ^0.8.18; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; contract IDentity is Ownable { @@ -31,13 +32,13 @@ contract IDentity is Ownable { return _free_vc_id; } - function validate_and_store_VC( + function validate_and_store_VC ( uint256 _vc_id, bytes calldata _pseudo_signature, string calldata _did, uint256 _expiration_date, uint256 _issuance_date, - bytes32 _vc_hash + bytes calldata _challenge ) external onlyOwner { require(_vc_id >= 0, "VC identitifier must be greater than 0"); require(_vc_id <= _free_vc_id, "Received VC id is invalid"); @@ -46,7 +47,7 @@ contract IDentity is Ownable { require(block.timestamp < _expiration_date, "Got invalid/expired expiration date"); require(_issuance_date <= block.timestamp, "Issuance date is in the future"); - address extractedAddress = extractSourceFromSignature(_vc_hash, _pseudo_signature); + address extractedAddress = extractSourceFromSignature(_challenge, _pseudo_signature); require(extractedAddress != address(0), "Invalid Extracted address"); uint256 id = _addr_to_vcId[extractedAddress]; if(id != 0 && !_vcId_to_VC[id].revoked) { // holder already has a vc @@ -88,8 +89,12 @@ contract IDentity is Ownable { emit VC_Revoked(_vc_id); } - function extractSourceFromSignature(bytes32 _vc_hash, bytes calldata _pseudo_signature) internal pure returns(address) { - bytes32 signedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _vc_hash)); + function extractSourceFromSignature(bytes calldata _challenge, bytes calldata _pseudo_signature) internal pure returns(address) { + bytes32 signedHash = keccak256( + abi.encodePacked("\x19Ethereum Signed Message:\n", + Strings.toString(_challenge.length), + _challenge) + ); (bytes32 r, bytes32 s, uint8 v) = splitSignature(_pseudo_signature); return ecrecover(signedHash, v, r, s); } From 9d9329466c01ceccad9ae2d866a6b51faa0088af Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:34:04 +0200 Subject: [PATCH 2/9] Update todo --- contracts/IDentity.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/IDentity.sol b/contracts/IDentity.sol index c5c8011..c90dcbf 100644 --- a/contracts/IDentity.sol +++ b/contracts/IDentity.sol @@ -66,13 +66,13 @@ contract IDentity is Ownable { emit NewVCRequestRegistered(_vc_id, _vcId_to_VC[_vc_id].vc_owner, _vcId_to_VC[_vc_id].expiration_date, block.timestamp); } - function activateVC(uint256 _vc_id) external { + function activateVC(uint256 _vc_id) external { require(msg.sender != address(0), "Sender is invalid"); require(_vc_id >= 0, "VC identitifier must be greater than 0"); VerifiableCredential storage vc = _vcId_to_VC[_vc_id]; require(vc.status == false, "VC already activated"); require(block.timestamp < vc.expiration_date, "Cannot activate VC: VC has expired"); - require(msg.sender == address(vc.vc_owner), "Cannot activate VC: sender is not who expcted"); + require(msg.sender == address(vc.vc_owner), "Cannot activate VC: sender is not who expcted"); // TODO: why don't user msg.sender to recover the VC? // activate VC vc.status = true; From c0e8fcb7b179d0ed0146b5822dca06275b803800 Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Tue, 31 Oct 2023 17:21:15 +0100 Subject: [PATCH 3/9] Add script --- addresses/contractAddresses.json | 14 +++++++------- init.bat | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 init.bat diff --git a/addresses/contractAddresses.json b/addresses/contractAddresses.json index cefdafc..a72ce81 100644 --- a/addresses/contractAddresses.json +++ b/addresses/contractAddresses.json @@ -1,25 +1,25 @@ { "addresses": [ { - "Deployer": "0xf24D3a5b19E2c520d41613520A41325E5F97B1D7" + "Deployer": "0xd17dD3803786E6c7E5B466bd2c22eD6718bA36D7" }, { - "ERC721Base": "0xbc7fE8aAA7aCc4913C5F315824ED87A5CbD3074F" + "ERC721Base": "0x5cF677D2D7844B7CE367093e2EAE01F36AdC7953" }, { - "ERC20Base": "0xD0393d14d27D2887E95a9f35d660b0b92c928E63" + "ERC20Base": "0xf26d2BCF934AF6Ac388E0F3c4888Bd26B76857Fc" }, { - "RouterFactory": "0xFaB97ef05a541B9E3fE21D85f40b83F915029692" + "RouterFactory": "0x371D33e3e61AD98dA65361BbBCB81d26af03bF4C" }, { - "FixedRateExchange": "0xFF75417098F555a4c28361BBd9B499521477C452" + "FixedRateExchange": "0xf74A8E86D90E90eafb468d6bF5c142Ac17E1bfcc" }, { - "IDentity": "0x14991b0f9b76285Fbe17233E56b42907c8DFE7a5" + "IDentity": "0xa8f364E1829eBf480e738057953b38f79fe2E17A" }, { - "ERC721Factory": "0x338f2fc6f13e4F001141407B8F6cf820a411083a" + "ERC721Factory": "0x90A98F282Db0d6df64e83AF48011C46D83B8F8cE" } ] } \ No newline at end of file diff --git a/init.bat b/init.bat new file mode 100644 index 0000000..21873ec --- /dev/null +++ b/init.bat @@ -0,0 +1,9 @@ +npx hardhat --network localhost faucet 0xF9692336D7f37336C2061a545D8b2895B1415EFe & ^ +npx hardhat --network localhost faucet 0xACC7CE50Be9D1db2eF86f804F5bC03b53681Fcbe & ^ +npx hardhat --network localhost faucet 0xBB3fb731CC4b103C072594E226A396F84C3E5DF4 & ^ +npx hardhat --network localhost faucet 0x25B2E1942578bCBB1Aa6E8EAa038DfE73440fcbe & ^ +npx hardhat --network localhost faucet 0xAba0719cc3E1187A4C9Caf6773D9766541C2Dd8D & ^ +npx hardhat --network localhost faucet 0xd0300C2817624BDd6C34F1d8e44857046dE13110 & ^ +npx hardhat --network localhost faucet 0xD12270A9054d045ba276C16Cb1C64386cDAA6AC7 & ^ +npx hardhat --network localhost faucet 0x6d3fbD514D62E2D305e4435dDe99483f20f264BF & ^ +npx hardhat run --network hardhat-issuer scripts/deploy.js \ No newline at end of file From 7bd5e37125172b6ab9f71b8b0828639cf4a7fa37 Mon Sep 17 00:00:00 2001 From: AleCla97 Date: Tue, 14 Nov 2023 10:57:22 +0100 Subject: [PATCH 4/9] refactor of deploy address file --- EXAMPLE_ADDRESSES.js | 15 +++++++++++++++ scripts/deploy.js | 26 ++++++++++++++++---------- 2 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 EXAMPLE_ADDRESSES.js diff --git a/EXAMPLE_ADDRESSES.js b/EXAMPLE_ADDRESSES.js new file mode 100644 index 0000000..e14413a --- /dev/null +++ b/EXAMPLE_ADDRESSES.js @@ -0,0 +1,15 @@ +require("dotenv").config(); +const ethers = require("ethers"); +const fs =require("fs") ; + + +const addresses = JSON.parse(fs.readFileSync(process.env.ADDRESS_FILE)).addresses; + +console.log(`Deployer address: ${addresses.Deployer}`) +console.log(`ERC721Base address: ${addresses.ERC721Base}`) +console.log(`ERC721Factory address: ${addresses.ERC721Factory}`) +console.log(`ERC20Base address: ${addresses.ERC20Base}`) +console.log(`FixedRateExchange address: ${addresses.FixedRateExchange}`) +console.log(`IDentityAddress address: ${addresses.IDentityAddress}`) + + diff --git a/scripts/deploy.js b/scripts/deploy.js index 09c73af..39b8748 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -2,9 +2,12 @@ const { ethers } = require("hardhat"); const fs = require("fs"); async function main() { - var obtainedAddresses = { - addresses: [] - }; + + let obtainedAddresses = {} + const name = "addresses" + obtainedAddresses[name] = {}; + + addresses = obtainedAddresses[name]; const [deployer] = await ethers.getSigners(); console.log("Deploying contracts with the account:", deployer.address); @@ -12,38 +15,38 @@ async function main() { const Deployer = await ethers.getContractFactory("Deployer"); let token = await Deployer.deploy(); - obtainedAddresses.addresses.push({Deployer: token.address}); + addresses.Deployer = token.address; console.log("Deployer address:", token.address); const ERC721Base = await ethers.getContractFactory("ERC721Base"); const baseAddress = await ERC721Base.deploy(); - obtainedAddresses.addresses.push({ERC721Base: baseAddress.address}); + addresses.ERC721Base = baseAddress.address; console.log("ERC721Base address:", baseAddress.address); const ERC20Base = await ethers.getContractFactory("ERC20Base"); const base20Address = await ERC20Base.deploy(); - obtainedAddresses.addresses.push({ERC20Base: base20Address.address}); + addresses.ERC20Base=base20Address.address; console.log("ERC20Base address:", base20Address.address); const RouterFactory = await ethers.getContractFactory("RouterFactory"); const router = await RouterFactory.deploy(deployer.address); - obtainedAddresses.addresses.push({RouterFactory: router.address}); + addresses.RouterFactory = router.address; console.log("RouterFactory address:", router.address); const FixedRateExchange = await ethers.getContractFactory("FixedRateExchange"); const a = await FixedRateExchange.deploy(router.address); - obtainedAddresses.addresses.push({FixedRateExchange: a.address}); + addresses.FixedRateExchange = a.address; console.log("FixedRateExchange address:", a.address); const IDentityFactory = await ethers.getContractFactory("IDentity"); const IDtoken = await IDentityFactory.deploy(); const IDentityAddress = await IDtoken.address - obtainedAddresses.addresses.push({IDentity: IDentityAddress}); + addresses.IDentityAddress = IDentityAddress; console.log("IDentitySC address:", IDentityAddress); const ERC721Factory = await ethers.getContractFactory("ERC721Factory"); token = await ERC721Factory.deploy(baseAddress.address, base20Address.address, router.address, a.address, IDentityAddress); - obtainedAddresses.addresses.push({ERC721Factory: token.address}); + addresses.ERC721Factory = token.address; console.log("ERC721Factory address:", token.address); // add factory and exchange address to router @@ -51,6 +54,9 @@ async function main() { await box.addFactoryAddress(token.address); await box.addFixedRateAddress(a.address); + + obtainedAddresses[name] = addresses; + const json = JSON.stringify(obtainedAddresses, null, 2); await fs.promises.writeFile(__dirname.replace('scripts','addresses/contractAddresses.json'), json) .catch((err) => { From 84ec7b387b83e67c7df787be0b43039286a47d3e Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Mon, 11 Dec 2023 15:21:41 +0100 Subject: [PATCH 5/9] Update message --- contracts/IDentity.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/IDentity.sol b/contracts/IDentity.sol index c90dcbf..af50642 100644 --- a/contracts/IDentity.sol +++ b/contracts/IDentity.sol @@ -72,7 +72,7 @@ contract IDentity is Ownable { VerifiableCredential storage vc = _vcId_to_VC[_vc_id]; require(vc.status == false, "VC already activated"); require(block.timestamp < vc.expiration_date, "Cannot activate VC: VC has expired"); - require(msg.sender == address(vc.vc_owner), "Cannot activate VC: sender is not who expcted"); // TODO: why don't user msg.sender to recover the VC? + require(msg.sender == address(vc.vc_owner), "Cannot activate VC: sender is not who expected"); // TODO: why don't user msg.sender to recover the VC? // activate VC vc.status = true; From 5a34a7076156781130f09d68fd368ed334208476 Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:17:11 +0100 Subject: [PATCH 6/9] Update publlishAllInOne to use isVCRevoked_Addr This will allow to not send the credential id in the request of publlishAllInOne and use the mapping. In this way you take decision based on the msg.sender and not just from a parameter sent from a caller. --- contracts/ERC721Factory.sol | 7 ++++--- contracts/IDentity.sol | 8 ++++---- interfaces/IIDentity.sol | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/contracts/ERC721Factory.sol b/contracts/ERC721Factory.sol index 0637038..8235794 100644 --- a/contracts/ERC721Factory.sol +++ b/contracts/ERC721Factory.sol @@ -38,7 +38,7 @@ contract ERC721Factory is Ownable, Deployer, IERC721Factory { string dt_name; string dt_symbol; uint256 maxSupply_; // must be > 10 otherwise mint will fail - uint256 vc_id; // TODO: remove this + // uint256 vc_id; // TODO: remove this } struct ContractBase { @@ -89,8 +89,9 @@ contract ERC721Factory is Ownable, Deployer, IERC721Factory { * 3. Not revoked */ IIDentity identity_token = IIDentity(_identity_addr); - // TODO: Change to isVCRevoked_Addr[msg.sender] - require(!identity_token.isVCRevoked(_publishData.vc_id), "The user does not have a valid VC!"); + // TODO: Change to isVCRevoked_Addr(msg.sender) + require(!identity_token.isVCRevoked_Addr(msg.sender), "The user does not have a valid VC!"); + // require(!identity_token.isVCRevoked(_publishData.vc_id), "The user does not have a valid VC!"); /** * deploy NFT token */ diff --git a/contracts/IDentity.sol b/contracts/IDentity.sol index af50642..269ce5f 100644 --- a/contracts/IDentity.sol +++ b/contracts/IDentity.sol @@ -72,7 +72,7 @@ contract IDentity is Ownable { VerifiableCredential storage vc = _vcId_to_VC[_vc_id]; require(vc.status == false, "VC already activated"); require(block.timestamp < vc.expiration_date, "Cannot activate VC: VC has expired"); - require(msg.sender == address(vc.vc_owner), "Cannot activate VC: sender is not who expected"); // TODO: why don't user msg.sender to recover the VC? + require(msg.sender == address(vc.vc_owner), "Cannot activate VC: sender is not who expected"); // TODO: why don't user msg.sender to recover the VC.id? // activate VC vc.status = true; @@ -129,7 +129,7 @@ contract IDentity is Ownable { function isVCActive(uint256 _vc_id) external view returns(bool) { return _vc_active(_vc_id); } - function isVCActive_Addr(address vc_holder) public view returns(bool) { + function isVCActive_Addr(address vc_holder) external view returns(bool) { return _vc_active(_addr_to_vcId[vc_holder]); } @@ -141,7 +141,7 @@ contract IDentity is Ownable { function isVCExpired(uint256 _vc_id) external view returns(bool) { return _vc_expired(_vc_id); } - function isVCExpired_Addr(address vc_holder) public view returns(bool) { + function isVCExpired_Addr(address vc_holder) external view returns(bool) { return _vc_expired(_addr_to_vcId[vc_holder]); } @@ -154,7 +154,7 @@ contract IDentity is Ownable { function isVCRevoked(uint256 _vc_id) external view returns(bool) { return _vc_revoked(_vc_id); } - function isVCRevoked_Addr(address vc_holder) public view returns(bool) { + function isVCRevoked_Addr(address vc_holder) external view returns(bool) { return _vc_revoked(_addr_to_vcId[vc_holder]); } diff --git a/interfaces/IIDentity.sol b/interfaces/IIDentity.sol index c817c1e..317958f 100644 --- a/interfaces/IIDentity.sol +++ b/interfaces/IIDentity.sol @@ -14,7 +14,13 @@ interface IIDentity { ) external; function activateVC(uint256 _vc_id) external; + function isVCActive(uint256 _vc_id) external view returns(bool); function isVCExpired(uint256 _vc_id) external view returns(bool); function isVCRevoked(uint256 _vc_id) external view returns(bool); + + function isVCActive_Addr(address vc_holder) external view returns(bool); + function isVCExpired_Addr(address vc_holder) external view returns(bool); + function isVCRevoked_Addr(address vc_holder) external view returns(bool); + } \ No newline at end of file From 17c6b8e29191fa5cd830306c2fee71c0a35dcab0 Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:46:45 +0100 Subject: [PATCH 7/9] Update contract call extractSourceFromSignature --- contracts/ERC721Base.sol | 20 ++++++++++++++++---- contracts/IDentity.sol | 2 ++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/contracts/ERC721Base.sol b/contracts/ERC721Base.sol index 8571735..05ec67e 100644 --- a/contracts/ERC721Base.sol +++ b/contracts/ERC721Base.sol @@ -8,6 +8,7 @@ import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "../interfaces/IERC721Base.sol"; import "../interfaces/IERC20Base.sol"; import "../interfaces/IERC721Factory.sol"; +import "@openzeppelin/contracts/utils/Strings.sol"; contract ERC721Base is Initializable, @@ -155,9 +156,9 @@ contract ERC721Base is function verifyPoP( bytes calldata _eth_signature, - bytes32 _hash + bytes calldata _challenge // bytes32 _hash ) external view returns(bool) { - address extractedAddress = extractSourceFromSignature(_hash, _eth_signature); + address extractedAddress = extractSourceFromSignature(_challenge, _eth_signature); require(extractedAddress != address(0), "ERC721: extracted signature is 0x00"); IERC20Base ierc20Instance = IERC20Base(deployedERC20Tokens[0]); @@ -165,12 +166,23 @@ contract ERC721Base is return (ierc20Instance.balanceOf(extractedAddress) >= 1 ether); } - function extractSourceFromSignature(bytes32 _hash, bytes calldata _pseudo_signature) internal pure returns(address) { - bytes32 signedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)); + // TODO: define this in a library Smart Contract (almost common to IDentity.sol) + // function extractSourceFromSignature(bytes32 _hash, bytes calldata _pseudo_signature) internal pure returns(address) { + // bytes32 signedHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)); + // (bytes32 r, bytes32 s, uint8 v) = splitSignature(_pseudo_signature); + // return ecrecover(signedHash, v, r, s); + // } + function extractSourceFromSignature(bytes calldata _challenge, bytes calldata _pseudo_signature) internal pure returns(address) { + bytes32 signedHash = keccak256( + abi.encodePacked("\x19Ethereum Signed Message:\n", + Strings.toString(_challenge.length), + _challenge) + ); (bytes32 r, bytes32 s, uint8 v) = splitSignature(_pseudo_signature); return ecrecover(signedHash, v, r, s); } + // TODO: define this in a library Smart Contract (almost common to IDentity.sol) // https://solidity-by-example.org/signature/ function splitSignature( bytes memory sig diff --git a/contracts/IDentity.sol b/contracts/IDentity.sol index 269ce5f..e88500d 100644 --- a/contracts/IDentity.sol +++ b/contracts/IDentity.sol @@ -89,6 +89,7 @@ contract IDentity is Ownable { emit VC_Revoked(_vc_id); } + // TODO: define this in a library Smart Contract (almost common to ERC721Base.sol) function extractSourceFromSignature(bytes calldata _challenge, bytes calldata _pseudo_signature) internal pure returns(address) { bytes32 signedHash = keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n", @@ -99,6 +100,7 @@ contract IDentity is Ownable { return ecrecover(signedHash, v, r, s); } + // TODO: define this in a library Smart Contract (almost common to ERC721Base.sol) // https://solidity-by-example.org/signature/ function splitSignature( bytes memory sig From 2f6c5f3a77e98e87941f749281684d9e2b4f509f Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Tue, 13 Feb 2024 14:45:23 +0100 Subject: [PATCH 8/9] Refactor function name --- contracts/ERC721Factory.sol | 6 +++--- contracts/FixedRateExchange.sol | 1 + contracts/IDentity.sol | 2 +- interfaces/IIDentity.sol | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/contracts/ERC721Factory.sol b/contracts/ERC721Factory.sol index 8235794..58eef6c 100644 --- a/contracts/ERC721Factory.sol +++ b/contracts/ERC721Factory.sol @@ -38,7 +38,7 @@ contract ERC721Factory is Ownable, Deployer, IERC721Factory { string dt_name; string dt_symbol; uint256 maxSupply_; // must be > 10 otherwise mint will fail - // uint256 vc_id; // TODO: remove this + // uint256 vc_id; // TODO: remove this field, useless, we can get the VC id from the msg.sender and interacting with the identity contract } struct ContractBase { @@ -89,9 +89,9 @@ contract ERC721Factory is Ownable, Deployer, IERC721Factory { * 3. Not revoked */ IIDentity identity_token = IIDentity(_identity_addr); - // TODO: Change to isVCRevoked_Addr(msg.sender) - require(!identity_token.isVCRevoked_Addr(msg.sender), "The user does not have a valid VC!"); + require(!identity_token.isVCRevoked_Addr(msg.sender), "The user does not have a valid VC!"); // require(!identity_token.isVCRevoked(_publishData.vc_id), "The user does not have a valid VC!"); + // TODO: ? check if it is active and not expired /** * deploy NFT token */ diff --git a/contracts/FixedRateExchange.sol b/contracts/FixedRateExchange.sol index 0f3cbb2..4c088b4 100644 --- a/contracts/FixedRateExchange.sol +++ b/contracts/FixedRateExchange.sol @@ -117,6 +117,7 @@ contract FixedRateExchange { * @param dtamount amount of DTs that are requested to be sold */ function sellDT(bytes32 exchangeId, uint256 dtamount) payable external activeExchange(exchangeId) { + //TODO: add interactions with the Identity contract require(dtamount > 0, "FIXEDRATE: PROVIDED A 0 DT AMOUNT"); uint256 swapPrice = calcDT_to_SMR(exchangeId, dtamount); diff --git a/contracts/IDentity.sol b/contracts/IDentity.sol index e88500d..a8e8383 100644 --- a/contracts/IDentity.sol +++ b/contracts/IDentity.sol @@ -32,7 +32,7 @@ contract IDentity is Ownable { return _free_vc_id; } - function validate_and_store_VC ( + function add_user ( uint256 _vc_id, bytes calldata _pseudo_signature, string calldata _did, diff --git a/interfaces/IIDentity.sol b/interfaces/IIDentity.sol index 317958f..48971ce 100644 --- a/interfaces/IIDentity.sol +++ b/interfaces/IIDentity.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.18; interface IIDentity { function getFreeVCid() external view returns(uint256); - function validate_and_store_VC( + function add_user( uint256 _vc_id, bytes calldata _pseudo_signature, string calldata _did, From 72fc4584597ab936b2ea45d2b7f2baf5b26eb393 Mon Sep 17 00:00:00 2001 From: Luca Giorgino <19236900+lucagiorgino@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:11:28 +0100 Subject: [PATCH 9/9] Move example --- addresses/contractAddresses.json | 32 ++++++------------- .../usage_example.js | 0 2 files changed, 9 insertions(+), 23 deletions(-) rename EXAMPLE_ADDRESSES.js => scripts/usage_example.js (100%) diff --git a/addresses/contractAddresses.json b/addresses/contractAddresses.json index a72ce81..7b50116 100644 --- a/addresses/contractAddresses.json +++ b/addresses/contractAddresses.json @@ -1,25 +1,11 @@ { - "addresses": [ - { - "Deployer": "0xd17dD3803786E6c7E5B466bd2c22eD6718bA36D7" - }, - { - "ERC721Base": "0x5cF677D2D7844B7CE367093e2EAE01F36AdC7953" - }, - { - "ERC20Base": "0xf26d2BCF934AF6Ac388E0F3c4888Bd26B76857Fc" - }, - { - "RouterFactory": "0x371D33e3e61AD98dA65361BbBCB81d26af03bF4C" - }, - { - "FixedRateExchange": "0xf74A8E86D90E90eafb468d6bF5c142Ac17E1bfcc" - }, - { - "IDentity": "0xa8f364E1829eBf480e738057953b38f79fe2E17A" - }, - { - "ERC721Factory": "0x90A98F282Db0d6df64e83AF48011C46D83B8F8cE" - } - ] + "addresses": { + "Deployer": "0xd17dD3803786E6c7E5B466bd2c22eD6718bA36D7", + "ERC721Base": "0x5cF677D2D7844B7CE367093e2EAE01F36AdC7953", + "ERC20Base": "0xf26d2BCF934AF6Ac388E0F3c4888Bd26B76857Fc", + "RouterFactory": "0x371D33e3e61AD98dA65361BbBCB81d26af03bF4C", + "FixedRateExchange": "0xf74A8E86D90E90eafb468d6bF5c142Ac17E1bfcc", + "IDentityAddress": "0xa8f364E1829eBf480e738057953b38f79fe2E17A", + "ERC721Factory": "0x90A98F282Db0d6df64e83AF48011C46D83B8F8cE" + } } \ No newline at end of file diff --git a/EXAMPLE_ADDRESSES.js b/scripts/usage_example.js similarity index 100% rename from EXAMPLE_ADDRESSES.js rename to scripts/usage_example.js