diff --git a/code/config.json b/code/config.json index 9c254cd..99e8ef5 100644 --- a/code/config.json +++ b/code/config.json @@ -5,7 +5,7 @@ "privateKey": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" }, "identityFactory": { - "address": "0x36C02dA8a0983159322a80FFE9F24b1acfF8B570", + "address": "0x4C4a2f8c81640e47606d3fd77B353E87Ba015584", "abi": [ { "inputs": [ @@ -413,7 +413,7 @@ }, "trex": { "implementationAuthority": { - "address": "0x82e01223d51Eb87e16A03E24687EDF0F294da6f1", + "address": "0x8198f5d8F8CfFE8f9C413d98a0A55aEB8ab9FbB7", "abi": [ { "type": "constructor", @@ -1515,7 +1515,7 @@ ] }, "claimsTopicRegistry": { - "address": "0x7969c5eD335650692Bc04293B07F5BF2e7A673C0", + "address": "0x202CCe504e04bEd6fC0521238dDf04Bc9E8E15aB", "abi": [ { "type": "event", @@ -1715,7 +1715,7 @@ ] }, "trustedIssuersRegistry": { - "address": "0x7bc06c482DEAd17c0e297aFbC32f6e63d3846650", + "address": "0xf4B146FbA71F41E0592668ffbF264F1D186b2Ca8", "abi": [ { "type": "event", @@ -2146,7 +2146,7 @@ ] }, "identityRegistry": { - "address": "0xFD471836031dc5108809D173A067e8486B9047A3", + "address": "0x4EE6eCAD1c2Dae9f525404De8555724e3c35d07B", "abi": [ { "type": "event", @@ -2911,7 +2911,7 @@ ] }, "identityRegistryStorage": { - "address": "0xc351628EB244ec633d5f21fBD6621e1a683B1181", + "address": "0x172076E0166D1F9Cc711C77Adf8488051744980C", "abi": [ { "type": "event", @@ -3473,7 +3473,7 @@ ] }, "modularCompliance": { - "address": "0xcbEAF3BDe82155F56486Fb5a1072cb8baAf547cc", + "address": "0xBEc49fA140aCaA83533fB00A2BB19bDdd0290f25", "abi": [ { "type": "event", @@ -3975,7 +3975,7 @@ ] }, "token": { - "address": "0x1429859428C0aBc9C2C47C8Ee9FBaf82cFA0F20f", + "address": "0xD84379CEae14AA33C123Af12424A37803F885889", "abi": [ { "type": "event", @@ -5651,10 +5651,9 @@ { "institutionID": 3117, "wallet": { - "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "privateKey": "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" + "address": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" }, - "address": "0xB0D4afd8879eD9F52b28595d31B441D079B2Ca07", + "address": "0x3Aa5ebB10DC797CAC828524e59A333d0A371443c", "abi": [ { "type": "constructor", diff --git a/code/deployClaimIssuer.sh b/code/deployClaimIssuer.sh new file mode 100755 index 0000000..90abdb6 --- /dev/null +++ b/code/deployClaimIssuer.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Set the path to the directory where the deploy claim issuer script is located +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Set the path to the config file +DEPLOY_CLAIM_ISSUER="$CURRENT_DIR/services/ethereum/scripts/claimIssuer/deploy-claim-issuer.js" + +# Function to check if input is empty +is_empty() { + if [[ -z "$1" ]]; then + return 0 + else + return 1 + fi +} + +# Ask the user for trusted issuer registry address +while true; do + read -p "[W] Enter the address of the trusted issuer registry: " TRUSTED_ISSUER_REGISTRY + if is_empty "$TRUSTED_ISSUER_REGISTRY"; then + echo "Trusted issuer registry cannot be empty. Please try again." + else + break + fi +done + +# Ask for institution wallet private key +while true; do + read -s -p "[$] Institution Wallet Private Key: " INSTITUTION_WALLET_PRIVATE_KEY + echo + if is_empty "$INSTITUTION_WALLET_PRIVATE_KEY"; then + echo "Institution wallet private key cannot be empty. Please try again." + else + break + fi +done + +# Ask for the institution code +while true; do + read -p "[#] Institution Code: " INSTITUTION_CODE + echo + if is_empty "$INSTITUTION_CODE"; then + echo "Code cannot be empty. Please try again." + else + break + fi +done + +# Call the deploy claim issuer script +node -e " +const deployClaimIssuer = require('$DEPLOY_CLAIM_ISSUER').deployClaimIssuer; +deployClaimIssuer('$TRUSTED_ISSUER_REGISTRY', undefined, undefined, '$INSTITUTION_WALLET_PRIVATE_KEY', '$INSTITUTION_CODE'); +" + + + diff --git a/code/services/ethereum/scripts/claimIssuer/deploy-claim-issuer.js b/code/services/ethereum/scripts/claimIssuer/deploy-claim-issuer.js index a76e6ae..2238cc5 100644 --- a/code/services/ethereum/scripts/claimIssuer/deploy-claim-issuer.js +++ b/code/services/ethereum/scripts/claimIssuer/deploy-claim-issuer.js @@ -5,7 +5,7 @@ const { const config = require('../../../../config.json'); const { useRpcProvider } = require('../utils/useRpcProvider'); const { addClaim } = require('../claims/add-claim'); -const { CLAIM_TOPICS_OBJ } = require('../claims/claimTopics'); +const { CLAIM_TOPICS_OBJ, CLAIM_TOPICS } = require('../claims/claimTopics'); const { addIssuerToConfig } = require('../../../config/addIssuerToConfig'); const SIGN_CLAIM_PURPOSE = 3; @@ -27,20 +27,32 @@ const ECDSA_KEY_TYPE = 1; */ async function deployClaimIssuer( TIR, - claimTopics, - issuerWallet, + issuerWallet = undefined, deployerTIR = undefined, - institutionCode = undefined, - privateKey = undefined + privateKey = undefined, + institutionCode = undefined ) { try { - if (deployerTIR === undefined) { + if (!deployerTIR ) { deployerTIR = useRpcProvider( config.rpc, config.deployer.privateKey ); // app owner } + if (!issuerWallet) { + console.log('Creating issuer wallet'); + console.log('privateKey:', privateKey); + const provider = new ethers.JsonRpcProvider(config.rpc); + issuerWallet = new ethers.Wallet(privateKey, provider); + } + + console.log('TIR:', TIR); + console.log('issuerWallet:', issuerWallet); + console.log('deployerTIR:', deployerTIR); + console.log('privateKey:', privateKey); + console.log('institutionCode:', institutionCode); + console.log( '[!] Deploying ClaimIssuer for wallet with address:', issuerWallet.address @@ -73,7 +85,7 @@ async function deployClaimIssuer( `[+] Deployed ClaimIssuer: ${await claimIssuerContract.getAddress()}` ); - const ethersClaimTopics = claimTopics.map(topic => ethers.id(topic)); + const ethersClaimTopics = CLAIM_TOPICS.map(topic => ethers.id(topic)); // Add the claimIssuer to the trusted issuers registry await TIR.connect(deployerTIR).addTrustedIssuer( diff --git a/code/services/ethereum/scripts/deploy-full-suite.js b/code/services/ethereum/scripts/deploy-full-suite.js index 185721e..850abef 100644 --- a/code/services/ethereum/scripts/deploy-full-suite.js +++ b/code/services/ethereum/scripts/deploy-full-suite.js @@ -62,11 +62,10 @@ async function main() { // Initial trusted issuers for the CLAIM_TOPICS = ['INSTITUTION', 'STUDENT', 'CERTIFICATE'] is the app owner await deployClaimIssuer( trustedIR, - CLAIM_TOPICS, deployer, deployer, + config.deployer.privateKey, 3117, - config.deployer.privateKey ); } diff --git a/code/services/ethereum/test/claim-issuer/deploy-claimIssuer.test.js b/code/services/ethereum/test/claim-issuer/deploy-claimIssuer.test.js index 7aacc10..03cf8f4 100644 --- a/code/services/ethereum/test/claim-issuer/deploy-claimIssuer.test.js +++ b/code/services/ethereum/test/claim-issuer/deploy-claimIssuer.test.js @@ -10,9 +10,6 @@ const { CLAIM_TOPICS } = require('../../scripts/claims/claimTopics'); const { getClaimsByTopic } = require('../../scripts/claims/getClaimsByTopic'); -const hash = require('../../scripts/utils/encryption/hash'); -const { deployIdentity } = require('../../scripts/identities/deploy-identity'); -const { getIdentity } = require('../../scripts/identities/getIdentity'); describe('ClaimIssuer Creation', () => { it('Should add claim issuer', async () => { @@ -24,7 +21,6 @@ describe('ClaimIssuer Creation', () => { const cicAndTir = await deployClaimIssuer( trustedIssuersRegistry, - claimTopics, deployerWallet, deployerWallet ); @@ -63,14 +59,12 @@ describe('ClaimIssuer Creation', () => { const cicAndTir1 = await deployClaimIssuer( trustedIssuersRegistry, - claimTopics, claimIssuerDeployer1, tirDeployer ); const cicAndTir2 = await deployClaimIssuer( trustedIssuersRegistry, - claimTopics, claimIssuerDeployer2, tirDeployer ); @@ -89,9 +83,9 @@ describe('ClaimIssuer Creation', () => { const cicAndTir = await deployClaimIssuer( trustedIssuersRegistry, - CLAIM_TOPICS, aliceWallet, deployerWallet, + undefined, 3117 ); @@ -108,4 +102,32 @@ describe('ClaimIssuer Creation', () => { expect(ethers.toUtf8String(claims[0].data)).to.be.equal('3117'); }); + + it('Should create a claim issuer with some data', async () => { + const { deployerWallet, trustedIssuersRegistry, identityFactory } = + await loadFixture(deployFullTREXSuiteFixture); + + const privKey = '0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656' + + const cicAndTir = await deployClaimIssuer( + trustedIssuersRegistry, + undefined, + deployerWallet, + privKey, + 3311 + ); + + expect((await cicAndTir.TIR.getTrustedIssuers())[0]).to.be.equal( + await cicAndTir.claimIssuerContract.getAddress() + ); + + // console.log('Wallet:', deployerWallet); + + // const claims = await getClaimsByTopic( + // cicAndTir.claimIssuerContract, + // CLAIM_TOPICS_OBJ.INSTITUTION + // ); + + // expect(ethers.toUtf8String(claims[0].data)).to.be.equal('3311'); + }); }); diff --git a/code/services/ethereum/test/claim-issuer/isTrustedIssuer.test.js b/code/services/ethereum/test/claim-issuer/isTrustedIssuer.test.js index e39f317..613aec4 100644 --- a/code/services/ethereum/test/claim-issuer/isTrustedIssuer.test.js +++ b/code/services/ethereum/test/claim-issuer/isTrustedIssuer.test.js @@ -20,7 +20,6 @@ describe('Verification of Trusted Issuer', () => { // Deploy a claim issuer const cicAndTir = await deployClaimIssuer( trustedIssuersRegistry, - claimTopics, deployerWallet, deployerWallet ); @@ -44,7 +43,6 @@ describe('Verification of Trusted Issuer', () => { // Deploy a claim issuer const cicAndTir = await deployClaimIssuer( trustedIssuersRegistry, - claimTopics, deployerWallet, deployerWallet ); diff --git a/code/services/ethereum/test/claims/addClaims.test.js b/code/services/ethereum/test/claims/addClaims.test.js index 1df38ce..c607fcd 100644 --- a/code/services/ethereum/test/claims/addClaims.test.js +++ b/code/services/ethereum/test/claims/addClaims.test.js @@ -48,7 +48,6 @@ describe('Claims Test', () => { // Deploy a claim issuer const cicAndTir = await deployClaimIssuer( trustedIssuersRegistry, - CLAIM_TOPICS, claimIssuerWallet, deployerWallet ); diff --git a/code/services/ethereum/test/claims/getClaims.test.js b/code/services/ethereum/test/claims/getClaims.test.js index 7b1c763..bac9660 100644 --- a/code/services/ethereum/test/claims/getClaims.test.js +++ b/code/services/ethereum/test/claims/getClaims.test.js @@ -35,7 +35,6 @@ describe('get all the claims of an identity by topic', function () { // Deploy a claim issuer const cicAndTir = await deployClaimIssuer( trustedIssuersRegistry, - CLAIM_TOPICS, claimIssuerWallet, deployerWallet );