diff --git a/abi/HubController.json b/abi/HubController.json index b97daeb9..fccd5a12 100644 --- a/abi/HubController.json +++ b/abi/HubController.json @@ -142,6 +142,16 @@ "name": "newAssetStorageContracts", "type": "tuple[]" }, + { + "internalType": "address[]", + "name": "newHashFunctions", + "type": "address[]" + }, + { + "internalType": "address[]", + "name": "newScoreFunctions", + "type": "address[]" + }, { "internalType": "address[]", "name": "contractsToReinitialize", @@ -163,16 +173,6 @@ "internalType": "struct GeneralStructs.ForwardCallInputArgs[]", "name": "forwardCallsData", "type": "tuple[]" - }, - { - "internalType": "address[]", - "name": "newHashFunctions", - "type": "address[]" - }, - { - "internalType": "address[]", - "name": "newScoreFunctions", - "type": "address[]" } ], "name": "setAndReinitializeContracts", diff --git a/contracts/v1/HubController.sol b/contracts/v1/HubController.sol index 4019558f..9f3826e8 100644 --- a/contracts/v1/HubController.sol +++ b/contracts/v1/HubController.sol @@ -70,17 +70,17 @@ contract HubController is Named, Versioned, ContractStatus, Ownable { function setAndReinitializeContracts( GeneralStructs.Contract[] calldata newContracts, GeneralStructs.Contract[] calldata newAssetStorageContracts, - address[] calldata contractsToReinitialize, - GeneralStructs.ForwardCallInputArgs[] calldata forwardCallsData, address[] calldata newHashFunctions, - address[] calldata newScoreFunctions + address[] calldata newScoreFunctions, + address[] calldata contractsToReinitialize, + GeneralStructs.ForwardCallInputArgs[] calldata forwardCallsData ) external onlyOwnerOrMultiSigOwner { _setContracts(newContracts); _setAssetStorageContracts(newAssetStorageContracts); - _reinitializeContracts(contractsToReinitialize); - _forwardCalls(forwardCallsData); _setHashFunctions(newHashFunctions); _setScoreFunctions(newScoreFunctions); + _reinitializeContracts(contractsToReinitialize); + _forwardCalls(forwardCallsData); } function setContractAddress( diff --git a/deploy/003_deploy_token.ts b/deploy/003_deploy_token.ts index 3f241337..2c82d90f 100644 --- a/deploy/003_deploy_token.ts +++ b/deploy/003_deploy_token.ts @@ -6,17 +6,36 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const isDeployed = hre.helpers.isDeployed('Token'); - const Token = await hre.helpers.deploy({ - newContractName: 'Token', - passHubInConstructor: false, - additionalArgs: ['TEST TOKEN', 'TEST'], - }); - - if (!isDeployed) { - const setupRoleTx = await Token.setupRole(deployer, { from: deployer }); - await setupRoleTx.wait(); - } - if (hre.network.name === 'hardhat') { + if (isDeployed) { + const hubAddress = hre.helpers.contractDeployments.contracts['Hub'].evmAddress; + const Hub = await hre.ethers.getContractAt('Hub', hubAddress, deployer); + + const tokenInHub = await Hub['isContract(string)']('Token'); + + if (!tokenInHub) { + const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; + const HubController = await hre.ethers.getContractAt('HubController', hubControllerAddress, deployer); + + const tokenAddress = hre.helpers.contractDeployments.contracts['Token'].evmAddress; + + console.log(`Setting Token (${tokenAddress}) in the Hub (${Hub.address}).`); + const setTokenTx = await HubController.setContractAddress('Token', tokenAddress); + await setTokenTx.wait(); + } + } else if (!isDeployed && hre.network.name === 'hardhat') { + const Token = await hre.helpers.deploy({ + newContractName: 'Token', + passHubInConstructor: false, + additionalArgs: ['TEST TOKEN', 'TEST'], + }); + + const minterRole = await Token.MINTER_ROLE(); + if (!(await Token.hasRole(minterRole, deployer))) { + console.log(`Setting minter role for ${deployer}.`); + const setupMinterRoleTx = await Token.setupRole(deployer, { from: deployer }); + await setupMinterRoleTx.wait(); + } + const amountToMint = hre.ethers.utils.parseEther(`${5_000_000}`); const accounts = await hre.ethers.getSigners(); diff --git a/deploy/998_initialize_contracts.ts b/deploy/998_initialize_contracts.ts index 6b43446e..543bdb57 100644 --- a/deploy/998_initialize_contracts.ts +++ b/deploy/998_initialize_contracts.ts @@ -30,10 +30,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const setAndReinitializeContractsTx = await HubController.setAndReinitializeContracts( newContracts, newAssetStorageContracts, - contractsForReinitialization, - setParametersEncodedData, newHashFunctions, newScoreFunctions, + contractsForReinitialization, + setParametersEncodedData, ); await setAndReinitializeContractsTx.wait(); } diff --git a/deployments/gnosis_chiado_dev_contracts.json b/deployments/gnosis_chiado_dev_contracts.json new file mode 100644 index 00000000..aaf34a1f --- /dev/null +++ b/deployments/gnosis_chiado_dev_contracts.json @@ -0,0 +1,240 @@ +{ + "contracts": { + "Assertion": { + "deployed": true, + "deploymentTimestamp": 1701108252805, + "evmAddress": "0x2785dB031C67B17B07daB7E1e3F9690E9709B735", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "AssertionStorage": { + "deployed": true, + "deploymentTimestamp": 1701108133535, + "evmAddress": "0xe8eF48a58367a5D58e5529eDa3f605B59Fd7b46c", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "CommitManagerV1": { + "deployed": true, + "deploymentTimestamp": 1701108327533, + "evmAddress": "0x94218Ce6A441f027dFB08d0cAEe3A028014A70C2", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "CommitManagerV1U1": { + "deployed": true, + "deploymentTimestamp": 1701108343997, + "evmAddress": "0x223A884F8a4CA10242aAC2b5a5857337764Ff805", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "ContentAsset": { + "deployed": true, + "deploymentTimestamp": 1701108698623, + "evmAddress": "0xaC93381697288fBBa9C4a7ED555ca57C74f0e85B", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "ContentAssetStorage": { + "deployed": true, + "deploymentTimestamp": 1701108233019, + "evmAddress": "0xB089bB3ce9af2032f1444DA18A8CF846cE4d6ec4", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "2.0.0" + }, + "HashingProxy": { + "deployed": true, + "deploymentTimestamp": 1701108085609, + "evmAddress": "0xD1a30E13DefA65684e22CC09EF51ca12D9c022C3", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "Hub": { + "deployed": true, + "deploymentTimestamp": 1701108008675, + "evmAddress": "0xD2bA102A0b11944d00180eE8136208ccF87bC39A", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "2.0.0" + }, + "HubController": { + "deployed": true, + "deploymentTimestamp": 1701108018449, + "evmAddress": "0x529B84F8116031830f80a12afb10BA738596a3ff", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "Identity": { + "deployed": true, + "deploymentTimestamp": 1701108258606, + "evmAddress": "0x654c24F865cd6420bEA563DE61ccf4b1C25C5EC0", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "IdentityStorage": { + "deployed": true, + "deploymentTimestamp": 1701108151627, + "evmAddress": "0xf0c302F9F7DC143BedF575ad9a3697194FF1bdCf", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "2.0.0" + }, + "Log2PLDSF": { + "deployed": true, + "deploymentTimestamp": 1701108123571, + "evmAddress": "0x144D304afA78Fd7093c2257695D1633cCEfaf13E", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": null + }, + "ParametersStorage": { + "deployed": true, + "deploymentTimestamp": 1701108052661, + "evmAddress": "0x4dD9339bBe3C49CF8806b7440cbc57BFC82b5ad5", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.1.0" + }, + "Profile": { + "deployed": true, + "deploymentTimestamp": 1701108296922, + "evmAddress": "0xC7967b6dF41CD6A331D7Bb88129c63b6bb91614e", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "ProfileStorage": { + "deployed": true, + "deploymentTimestamp": 1701108187258, + "evmAddress": "0xD658511427E6B4BeCcea024832F891e398A40343", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ProofManagerV1": { + "deployed": true, + "deploymentTimestamp": 1701108333806, + "evmAddress": "0x1E83a78E12C693d0f2EB94AC51e442E0D1B63a3b", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "ProofManagerV1U1": { + "deployed": true, + "deploymentTimestamp": 1701108370005, + "evmAddress": "0xD77E59D58a3020f2752B9003151B8dF22588d60F", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "SHA256": { + "deployed": true, + "deploymentTimestamp": 1701108091443, + "evmAddress": "0xfE6f7Bb8Dc73b35F14C3bE12bCA424B5DA6C8d94", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": null + }, + "ScoringProxy": { + "deployed": true, + "deploymentTimestamp": 1701108109320, + "evmAddress": "0x57A5FcB27C97d49578d67e2f276A82B7F61e3Af9", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "ServiceAgreementStorageProxy": { + "deployed": true, + "deploymentTimestamp": 1701108223122, + "evmAddress": "0x36bE35DD8217ebb593D3507E49A7415592dAeD01", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ServiceAgreementStorageV1": { + "deployed": true, + "deploymentTimestamp": 1701108197752, + "evmAddress": "0x325460930D11036590c32AbCF2f48F3084DF37Ce", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ServiceAgreementStorageV1U1": { + "deployed": true, + "deploymentTimestamp": 1701108207929, + "evmAddress": "0x08e5D73aa61a6F68199601B72bAC188fe08E2908", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ServiceAgreementV1": { + "deployed": true, + "deploymentTimestamp": 1701108691794, + "evmAddress": "0x7e37087595f31a15c3BFc325104e3FaE08ac730f", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.1.1" + }, + "ShardingTable": { + "deployed": true, + "deploymentTimestamp": 1701108272713, + "evmAddress": "0xBBd73E52Bc29678c7b4Df53F50162BB0cAc5D7Db", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "ShardingTableStorage": { + "deployed": true, + "deploymentTimestamp": 1701108162127, + "evmAddress": "0x42232C6A2C4230B56c5DDc3536aaaFa4F6f97E2E", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "Staking": { + "deployed": true, + "deploymentTimestamp": 1701108286747, + "evmAddress": "0xf73bd80B7B05575DDd79247eEA644E030094a47B", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "StakingStorage": { + "deployed": true, + "deploymentTimestamp": 1701108180122, + "evmAddress": "0x5dC1195A8AFA9b4Ba86D2BaF6908897031d70195", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "Token": { + "deployed": true, + "evmAddress": "0xEbe6b58943289617dB514de43d95f613bb2f1Ed1" + }, + "UnfinalizedStateStorage": { + "deployed": true, + "deploymentTimestamp": 1701108247041, + "evmAddress": "0xFfFEfacaAd3d834CB39e17bfd99076e200Ae4D46", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "WhitelistStorage": { + "deployed": true, + "deploymentTimestamp": 1701108074838, + "evmAddress": "0xF8219F07fC5682992138a75809d8268930939D96", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + } + } +} diff --git a/deployments/gnosis_chiado_test_contracts.json b/deployments/gnosis_chiado_test_contracts.json new file mode 100644 index 00000000..689f0cae --- /dev/null +++ b/deployments/gnosis_chiado_test_contracts.json @@ -0,0 +1,240 @@ +{ + "contracts": { + "Assertion": { + "deployed": true, + "deploymentTimestamp": 1701109048030, + "evmAddress": "0x9B47F7AD155b52A88968c25DA9Eff080c17B4AC5", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "AssertionStorage": { + "deployed": true, + "deploymentTimestamp": 1701108890140, + "evmAddress": "0xffDe7E801B4a56dd373f8435327E3709F04bD005", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "CommitManagerV1": { + "deployed": true, + "deploymentTimestamp": 1701110482942, + "evmAddress": "0x2E714e7803179C05117bdbb12c6ee90582c24582", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "CommitManagerV1U1": { + "deployed": true, + "deploymentTimestamp": 1701110508065, + "evmAddress": "0xb917975CbBD80aa54fDf56A9Eb51bEcB2Dd29F0d", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "ContentAsset": { + "deployed": true, + "deploymentTimestamp": 1701110543790, + "evmAddress": "0xc200F6E6482c66D80462cD1581D1649B97036d47", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "ContentAssetStorage": { + "deployed": true, + "deploymentTimestamp": 1701109027906, + "evmAddress": "0x480cA6618929357d070e2B646f8b505Fbf44aa10", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "2.0.0" + }, + "HashingProxy": { + "deployed": true, + "deploymentTimestamp": 1701108844930, + "evmAddress": "0x887DED2AC5bcD8e4A6280f9e6E8baE4DC22DAe3C", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "Hub": { + "deployed": true, + "deploymentTimestamp": 1701108752055, + "evmAddress": "0xC06210312C9217A0EdF67453618F5eB96668679A", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "2.0.0" + }, + "HubController": { + "deployed": true, + "deploymentTimestamp": 1701108771400, + "evmAddress": "0x38a5b58e6E4872129AF67D5ddDeB0cD52B280503", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "Identity": { + "deployed": true, + "deploymentTimestamp": 1701110417798, + "evmAddress": "0x2CAf5c6c64b5043B74ad91681D926a49eE4729d1", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "IdentityStorage": { + "deployed": true, + "deploymentTimestamp": 1701108916913, + "evmAddress": "0x578a7C9C5184aa3773cd9a8fa90672e2525452C7", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "2.0.0" + }, + "Log2PLDSF": { + "deployed": true, + "deploymentTimestamp": 1701108876100, + "evmAddress": "0x9d0936936D226be3116a8bFD90DDcB40f468796e", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": null + }, + "ParametersStorage": { + "deployed": true, + "deploymentTimestamp": 1701108824845, + "evmAddress": "0x14C082622F1A9cb7390B3C35eE264b7844416E0E", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.1.0" + }, + "Profile": { + "deployed": true, + "deploymentTimestamp": 1701110472907, + "evmAddress": "0x4AbC244E716624239EaBF4d77E29966C925ff67E", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "ProfileStorage": { + "deployed": true, + "deploymentTimestamp": 1701108962846, + "evmAddress": "0x14102863b17b88ffF4823AC364a46EDE59A67327", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ProofManagerV1": { + "deployed": true, + "deploymentTimestamp": 1701110497159, + "evmAddress": "0x058205a0c7173Db68a67Fdb68646880bd3B131CE", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "ProofManagerV1U1": { + "deployed": true, + "deploymentTimestamp": 1701110523131, + "evmAddress": "0xD5E8Cf058eF61948A3FBD990998ED9CC2e57Cae8", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "SHA256": { + "deployed": true, + "deploymentTimestamp": 1701108851159, + "evmAddress": "0x722d696CAa2558A3292E26E5B2Ce7e73DB046674", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": null + }, + "ScoringProxy": { + "deployed": true, + "deploymentTimestamp": 1701108858436, + "evmAddress": "0xc2BB756BBD69FdF313044BF2deB5CE363b4377D4", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "ServiceAgreementStorageProxy": { + "deployed": true, + "deploymentTimestamp": 1701109021126, + "evmAddress": "0x1F43763970184be72b75Aa1c7F29a8794B8B815A", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ServiceAgreementStorageV1": { + "deployed": true, + "deploymentTimestamp": 1701108985392, + "evmAddress": "0xE3f97f140fa4dbbc129ac6A1bA4F0a3D8F629f4a", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ServiceAgreementStorageV1U1": { + "deployed": true, + "deploymentTimestamp": 1701109003381, + "evmAddress": "0x092342A18C1c1df2728315c91648fD3B42D03e0c", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "ServiceAgreementV1": { + "deployed": true, + "deploymentTimestamp": 1701110533415, + "evmAddress": "0x5928e91D661D2cE54a4236236c2AF17f3705d48E", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.1.1" + }, + "ShardingTable": { + "deployed": true, + "deploymentTimestamp": 1701110442176, + "evmAddress": "0xf9D7743D56E090Ed8AcD6E2cFE5BD19F5E4bcBf2", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.1" + }, + "ShardingTableStorage": { + "deployed": true, + "deploymentTimestamp": 1701108935108, + "evmAddress": "0x11E2b30aA6a3F92a8aCB9Bfc181cd164c155ff9B", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "Staking": { + "deployed": true, + "deploymentTimestamp": 1701110465761, + "evmAddress": "0x2F8ac161E4B361506f948B0FE0099EFB0323f7ba", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.2" + }, + "StakingStorage": { + "deployed": true, + "deploymentTimestamp": 1701108952935, + "evmAddress": "0xf10281AeC15474443d1F6B85277B7A937CAc7261", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "Token": { + "deployed": true, + "evmAddress": "0x9cFa71394906fa38399aD305E7Ca97b00e3b4449" + }, + "UnfinalizedStateStorage": { + "deployed": true, + "deploymentTimestamp": 1701109037643, + "evmAddress": "0xF6FD36d9C9724318fD6272bFD351466B762BCCE7", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + }, + "WhitelistStorage": { + "deployed": true, + "deploymentTimestamp": 1701108834800, + "evmAddress": "0x422E1Ba4804d17A2DC491faAf0300a53D1964B15", + "gitBranch": "main", + "gitCommitHash": "83b739de2ea02ce8027e2fccc6e04e9d5da48814", + "version": "1.0.0" + } + } +} diff --git a/test/v1/integration/ContentAsset.test.ts b/test/v1/integration/ContentAsset.test.ts index d8404437..c81c90db 100644 --- a/test/v1/integration/ContentAsset.test.ts +++ b/test/v1/integration/ContentAsset.test.ts @@ -229,9 +229,9 @@ describe('@v1 @integration ContentAsset contract', function () { const initialBalance = await Token.balanceOf(serviceAgreementStorageV1Address); const initialOwnerBalance = await Token.balanceOf(accounts[0].address); - expect(await ContentAsset.burnAsset(tokenId)) + await expect(ContentAsset.burnAsset(tokenId)) .to.emit(ContentAsset, 'AssetBurnt') - .withArgs(ContentAssetStorage.address, tokenId, assetInputStruct.assertionId, assetInputStruct.tokenAmount); + .withArgs(ContentAssetStorage.address, tokenId, assetInputStruct.tokenAmount); const resultBalance = await Token.balanceOf(serviceAgreementStorageV1Address); const resultOwnerBalance = await Token.balanceOf(accounts[0].address); @@ -388,9 +388,9 @@ describe('@v1 @integration ContentAsset contract', function () { const initialBalance = await Token.balanceOf(serviceAgreementStorageV1U1Address); const initialOwnerBalance = await Token.balanceOf(accounts[0].address); - expect(await ContentAsset.cancelAssetStateUpdate(tokenId)) + await expect(ContentAsset.cancelAssetStateUpdate(tokenId)) .to.emit(ContentAsset, 'AssetStateUpdateCanceled') - .withArgs(ContentAssetStorage.address, tokenId, assetUpdateArgs.assertionId, assetUpdateArgs.tokenAmount); + .withArgs(ContentAssetStorage.address, tokenId, 1, assetUpdateArgs.tokenAmount); const resultBalance = await Token.balanceOf(serviceAgreementStorageV1U1Address); const resultOwnerBalance = await Token.balanceOf(accounts[0].address); @@ -439,7 +439,7 @@ describe('@v1 @integration ContentAsset contract', function () { const initialTokenAmount = await ServiceAgreementStorageProxy.getAgreementTokenAmount(agreementId); - expect(await ContentAsset.extendAssetStoringPeriod(tokenId, additionalEpochsNumber, assetInputStruct.tokenAmount)) + await expect(ContentAsset.extendAssetStoringPeriod(tokenId, additionalEpochsNumber, assetInputStruct.tokenAmount)) .to.emit(ContentAsset, 'AssetStoringPeriodExtended') .withArgs(ContentAssetStorage.address, tokenId, additionalEpochsNumber, assetInputStruct.tokenAmount); @@ -468,7 +468,7 @@ describe('@v1 @integration ContentAsset contract', function () { const initialTokenAmount = await ServiceAgreementStorageProxy.getAgreementTokenAmount(agreementId); - expect(await ContentAsset.increaseAssetTokenAmount(tokenId, additionalTokenAmount)) + await expect(ContentAsset.increaseAssetTokenAmount(tokenId, additionalTokenAmount)) .to.emit(ContentAsset, 'AssetPaymentIncreased') .withArgs(ContentAssetStorage.address, tokenId, additionalTokenAmount); @@ -495,7 +495,7 @@ describe('@v1 @integration ContentAsset contract', function () { const initialUpdateTokenAmount = await ServiceAgreementStorageProxy.getAgreementUpdateTokenAmount(agreementId); - expect(await ContentAsset.increaseAssetUpdateTokenAmount(tokenId, additionalUpdateTokenAmount)) + await expect(ContentAsset.increaseAssetUpdateTokenAmount(tokenId, additionalUpdateTokenAmount)) .to.emit(ContentAsset, 'AssetUpdatePaymentIncreased') .withArgs(ContentAssetStorage.address, tokenId, additionalUpdateTokenAmount); diff --git a/test/v1/unit/CommitManagerV1.test.ts b/test/v1/unit/CommitManagerV1.test.ts index 1cfbc622..35b6776c 100644 --- a/test/v1/unit/CommitManagerV1.test.ts +++ b/test/v1/unit/CommitManagerV1.test.ts @@ -155,7 +155,7 @@ describe('@v1 @unit CommitManagerV1 contract', function () { epoch: 0, }; - expect(await CommitManagerV1.submitCommit(commitInputArgs)).to.emit(CommitManagerV1, 'CommitSubmitted'); + await expect(CommitManagerV1.submitCommit(commitInputArgs)).to.emit(CommitManagerV1, 'CommitSubmitted'); }); it('Create new asset, submit R0 commits, expect R0 commits to be returned', async () => { @@ -177,7 +177,7 @@ describe('@v1 @unit CommitManagerV1 contract', function () { }; for (let i = 0; i < r0; i++) { - expect(await CommitManagerV1.connect(accounts[i]).submitCommit(commitInputArgs)).to.emit( + await expect(CommitManagerV1.connect(accounts[i]).submitCommit(commitInputArgs)).to.emit( CommitManagerV1, 'CommitSubmitted', ); diff --git a/test/v1/unit/CommitManagerV1U1.test.ts b/test/v1/unit/CommitManagerV1U1.test.ts index eb17e237..9fa37a01 100644 --- a/test/v1/unit/CommitManagerV1U1.test.ts +++ b/test/v1/unit/CommitManagerV1U1.test.ts @@ -104,7 +104,7 @@ describe('@v1 @unit CommitManagerV1U1 contract', function () { }; for (let i = 0; i < finalizationRequirement; i++) { - expect(await CommitManagerV1U1.connect(accounts[i]).submitUpdateCommit(commitInputArgs)).to.emit( + await expect(CommitManagerV1U1.connect(accounts[i]).submitUpdateCommit(commitInputArgs)).to.emit( CommitManagerV1U1, 'CommitSubmitted', ); @@ -246,7 +246,7 @@ describe('@v1 @unit CommitManagerV1U1 contract', function () { CommitManagerV1, 'ServiceAgreementDoesntExist', ); - expect(await CommitManagerV1U1.submitCommit(commitInputArgs)).to.emit(CommitManagerV1U1, 'CommitSubmitted'); + await expect(CommitManagerV1U1.submitCommit(commitInputArgs)).to.emit(CommitManagerV1U1, 'CommitSubmitted'); }); it('Create new asset, update it, finalize update, teleport to the second epoch, submit R0 commits, expect R0 commits to be returned', async () => { @@ -272,7 +272,7 @@ describe('@v1 @unit CommitManagerV1U1 contract', function () { CommitManagerV1, 'ServiceAgreementDoesntExist', ); - expect(await CommitManagerV1U1.connect(accounts[i]).submitCommit(commitInputArgs)).to.emit( + await expect(CommitManagerV1U1.connect(accounts[i]).submitCommit(commitInputArgs)).to.emit( CommitManagerV1U1, 'CommitSubmitted', ); @@ -303,7 +303,7 @@ describe('@v1 @unit CommitManagerV1U1 contract', function () { epoch: 0, }; - expect(await CommitManagerV1U1.submitUpdateCommit(commitInputArgs)).to.emit(CommitManagerV1U1, 'CommitSubmitted'); + await expect(CommitManagerV1U1.submitUpdateCommit(commitInputArgs)).to.emit(CommitManagerV1U1, 'CommitSubmitted'); }); it('Create new asset, update it and submit update commits, expect StateFinalized event', async () => { @@ -325,13 +325,13 @@ describe('@v1 @unit CommitManagerV1U1 contract', function () { epoch: 0, }; for (let i = 0; i < finalizationRequirement - 1; i++) { - expect(await CommitManagerV1U1.connect(accounts[i]).submitUpdateCommit(commitInputArgs)).to.emit( + await expect(CommitManagerV1U1.connect(accounts[i]).submitUpdateCommit(commitInputArgs)).to.emit( CommitManagerV1U1, 'CommitSubmitted', ); } - expect( - await CommitManagerV1U1.connect(accounts[identityIds.length - 1]).submitUpdateCommit(commitInputArgs), + await expect( + CommitManagerV1U1.connect(accounts[identityIds.length - 1]).submitUpdateCommit(commitInputArgs), ).to.emit(CommitManagerV1U1, 'StateFinalized'); const topCommits = await CommitManagerV1U1.getTopCommitSubmissions(agreementId, 0, 1); expect(topCommits.map((arr) => arr[0])).to.include.deep.members( diff --git a/test/v1/unit/ContentAsset.test.ts b/test/v1/unit/ContentAsset.test.ts index d8273f37..cbd04e26 100644 --- a/test/v1/unit/ContentAsset.test.ts +++ b/test/v1/unit/ContentAsset.test.ts @@ -136,7 +136,7 @@ describe('@v1 @unit ContentAsset contract', function () { it('Create an asset, expect asset created', async () => { await Token.increaseAllowance(ServiceAgreementV1.address, assetInputStruct.tokenAmount); - expect(await ContentAsset.createAsset(assetInputStruct)) + await expect(ContentAsset.createAsset(assetInputStruct)) .to.emit(ContentAsset, 'AssetMinted') .withArgs(ContentAssetStorage.address, 0, assetInputStruct.assertionId); }); @@ -162,9 +162,9 @@ describe('@v1 @unit ContentAsset contract', function () { .toNumber(); await time.increase(commitWindowDuration); - expect(await ContentAsset.burnAsset(tokenId)) + await expect(ContentAsset.burnAsset(tokenId)) .to.emit(ContentAsset, 'AssetBurnt') - .withArgs(ContentAssetStorage.address, tokenId, assetInputStruct.assertionId, assetInputStruct.tokenAmount); + .withArgs(ContentAssetStorage.address, tokenId, assetInputStruct.tokenAmount); expect(await ContentAssetStorage.getAssertionIds(tokenId)).to.eql([]); expect(await ContentAssetStorage.assertionExists(assetInputStruct.assertionId)).to.equal(false); @@ -234,8 +234,8 @@ describe('@v1 @unit ContentAsset contract', function () { await Token.increaseAllowance(ServiceAgreementV1.address, assetInputStruct.tokenAmount); - expect( - await ContentAsset.updateAssetState( + await expect( + ContentAsset.updateAssetState( tokenId, newAssertionId, assetInputStruct.size, @@ -245,7 +245,7 @@ describe('@v1 @unit ContentAsset contract', function () { ), ) .to.emit(ContentAsset, 'AssetStateUpdated') - .withArgs(ContentAssetStorage.address, tokenId, newAssertionId, assetInputStruct.tokenAmount); + .withArgs(ContentAssetStorage.address, tokenId, 1, assetInputStruct.tokenAmount); }); it('Update asset state of immutable asset, expect to be reverted', async () => { @@ -315,9 +315,9 @@ describe('@v1 @unit ContentAsset contract', function () { await updateAsset(tokenId); await time.increase(await ParametersStorage.updateCommitWindowDuration()); - expect(await ContentAsset.cancelAssetStateUpdate(tokenId)) + await expect(ContentAsset.cancelAssetStateUpdate(tokenId)) .to.emit(ContentAsset, 'AssetStateUpdateCanceled') - .withArgs(ContentAssetStorage.address, tokenId, assetUpdateArgs.assertionId, assetUpdateArgs.tokenAmount); + .withArgs(ContentAssetStorage.address, tokenId, 1, assetUpdateArgs.tokenAmount); }); it('Cancel asset state update using non-owner account, expect to be reverted', async () => { @@ -356,7 +356,7 @@ describe('@v1 @unit ContentAsset contract', function () { await Token.increaseAllowance(ServiceAgreementV1.address, assetInputStruct.tokenAmount); - expect(await ContentAsset.extendAssetStoringPeriod(tokenId, additionalEpochsNumber, assetInputStruct.tokenAmount)) + await expect(ContentAsset.extendAssetStoringPeriod(tokenId, additionalEpochsNumber, assetInputStruct.tokenAmount)) .to.emit(ContentAsset, 'AssetStoringPeriodExtended') .withArgs(ContentAssetStorage.address, tokenId, additionalEpochsNumber, assetInputStruct.tokenAmount); }); @@ -384,7 +384,7 @@ describe('@v1 @unit ContentAsset contract', function () { await Token.increaseAllowance(ServiceAgreementV1.address, additionalTokenAmount); - expect(await ContentAsset.increaseAssetTokenAmount(tokenId, additionalTokenAmount)) + await expect(ContentAsset.increaseAssetTokenAmount(tokenId, additionalTokenAmount)) .to.emit(ContentAsset, 'AssetPaymentIncreased') .withArgs(ContentAssetStorage.address, tokenId, additionalTokenAmount); }); @@ -409,7 +409,7 @@ describe('@v1 @unit ContentAsset contract', function () { await Token.increaseAllowance(ServiceAgreementV1.address, additionalUpdateTokenAmount); - expect(await ContentAsset.increaseAssetUpdateTokenAmount(tokenId, additionalUpdateTokenAmount)) + await expect(ContentAsset.increaseAssetUpdateTokenAmount(tokenId, additionalUpdateTokenAmount)) .to.emit(ContentAsset, 'AssetUpdatePaymentIncreased') .withArgs(ContentAssetStorage.address, tokenId, additionalUpdateTokenAmount); }); diff --git a/test/v1/unit/Hub.test.ts b/test/v1/unit/Hub.test.ts index 49d4a695..6a4d8f9f 100644 --- a/test/v1/unit/Hub.test.ts +++ b/test/v1/unit/Hub.test.ts @@ -72,9 +72,9 @@ describe('@v1 @unit Hub contract', function () { expect(await Hub.getContractAddress('TestContract')).to.equal(accounts[1].address); - expect(await HubController.setContractAddress('TestContract', accounts[2].address)) + await expect(HubController.setContractAddress('TestContract', accounts[2].address)) .to.emit(Hub, 'ContractChanged') - .withArgs('TestContract', accounts[2]); + .withArgs('TestContract', accounts[2].address); expect(await Hub.getContractAddress('TestContract')).to.equal(accounts[2].address); }); @@ -168,8 +168,8 @@ describe('@v1 @unit Hub contract', function () { }); it('Set contract address, set the same address with different name; Expect to have 2 contracts with the same address (bug)', async () => { - expect(await HubController.setContractAddress('TestContract1', accounts[1].address)).to.emit(Hub, 'NewContract'); - expect(await HubController.setContractAddress('TestContract2', accounts[1].address)).to.emit(Hub, 'NewContract'); + await expect(HubController.setContractAddress('TestContract1', accounts[1].address)).to.emit(Hub, 'NewContract'); + await expect(HubController.setContractAddress('TestContract2', accounts[1].address)).to.emit(Hub, 'NewContract'); expect(await Hub.getContractAddress('TestContract1')).to.equal(accounts[1].address); expect(await Hub.getContractAddress('TestContract2')).to.equal(accounts[1].address); diff --git a/test/v1/unit/HubController.test.ts b/test/v1/unit/HubController.test.ts index 8b84d77d..cf866601 100644 --- a/test/v1/unit/HubController.test.ts +++ b/test/v1/unit/HubController.test.ts @@ -3,7 +3,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { expect } from 'chai'; import hre from 'hardhat'; -import { HubController, Profile } from '../../../typechain'; +import { Hub, HubController, Profile } from '../../../typechain'; import { GeneralStructs } from '../../../typechain/contracts/v1/HubController'; type HubControllerFixture = { @@ -50,9 +50,64 @@ describe('@v1 @unit HubController contract', function () { name: 'Profile', addr: newProfile.address, }; - await HubController.setAndReinitializeContracts([newProfileStruct], [], [newProfile.address], [], [], []); + await HubController.setAndReinitializeContracts([newProfileStruct], [], [], [], [newProfile.address], []); expect(await Profile.status()).to.be.false; expect(await newProfile.status()).to.be.true; }); + + it('Set new HashProxy/ScoringProxy and hash/score functions in the Hub using HubController; Expect to be successful', async () => { + await hre.deployments.fixture(['Hub', 'ParametersStorage']); + + const Hub = await hre.ethers.getContract('Hub'); + HubController = await hre.ethers.getContract('HubController'); + + const HashingProxy = await hre.helpers.deploy({ + newContractName: 'HashingProxy', + setContractInHub: false, + }); + const ScoringProxy = await hre.helpers.deploy({ + newContractName: 'ScoringProxy', + setContractInHub: false, + }); + + const SHA256 = await hre.helpers.deploy({ + newContractName: 'SHA256', + passHubInConstructor: false, + setContractInHub: false, + }); + const Log2PLDSF = await hre.helpers.deploy({ + newContractName: 'Log2PLDSF', + setContractInHub: false, + }); + + const newHashingProxyStruct: GeneralStructs.ContractStruct = { + name: 'HashingProxy', + addr: HashingProxy.address, + }; + const newScoringProxyStruct: GeneralStructs.ContractStruct = { + name: 'ScoringProxy', + addr: ScoringProxy.address, + }; + + const tx = HubController.setAndReinitializeContracts( + [newHashingProxyStruct, newScoringProxyStruct], + [], + [SHA256.address], + [Log2PLDSF.address], + [Log2PLDSF.address], + [], + ); + + await expect(tx).to.not.be.reverted; + await expect(tx) + .to.emit(Hub, 'NewContract') + .withArgs('HashingProxy', HashingProxy.address) + .to.emit(Hub, 'NewContract') + .withArgs('ScoringProxy', ScoringProxy.address) + .to.emit(HashingProxy, 'NewHashFunctionContract') + .withArgs(1, SHA256.address) + .to.emit(ScoringProxy, 'NewScoringFunctionContract') + .withArgs(1, Log2PLDSF.address); + }); }); diff --git a/test/v1/unit/Identity.test.ts b/test/v1/unit/Identity.test.ts index 506b1431..a73905ed 100644 --- a/test/v1/unit/Identity.test.ts +++ b/test/v1/unit/Identity.test.ts @@ -39,12 +39,14 @@ describe('@v1 @unit Identity contract', function () { async function createIdentity(operationalKey: string, adminKey: string) { const createIdentity = await Identity.createIdentity(operationalKey, adminKey); + + await expect(createIdentity).to.emit(Identity, 'IdentityCreated'); + const receipt = await createIdentity.wait(); identityId = receipt.events?.[2].args?.identityId.toNumber(); const fetchIdentityId = await IdentityStorage.getIdentityId(operationalKey); - expect(createIdentity).to.emit(Identity, 'IdentityCreated'); expect(identityId).not.equal(0); expect(identityId).to.equal(fetchIdentityId.toNumber(), 'Error: Identities are not matched!'); @@ -101,7 +103,7 @@ describe('@v1 @unit Identity contract', function () { const getIdentityId = await createIdentity(operationalKey, adminKey); const deleteIdentity = await Identity.deleteIdentity(getIdentityId); - expect(deleteIdentity).to.emit(Identity, 'IdentityDeleted'); + await expect(deleteIdentity).to.emit(Identity, 'IdentityDeleted'); }); it('Add an admin key to existing identity, expect to pass', async () => { diff --git a/test/v1/unit/IdentityStorage.test.ts b/test/v1/unit/IdentityStorage.test.ts index 99541163..008aea33 100644 --- a/test/v1/unit/IdentityStorage.test.ts +++ b/test/v1/unit/IdentityStorage.test.ts @@ -13,7 +13,7 @@ type IdentityStorageFixture = { IdentityStorage: IdentityStorage; }; -describe('@unit IdentityStorage contract', function () { +describe('@v1 @unit IdentityStorage contract', function () { let accounts: SignerWithAddress[]; let Identity: Identity; let IdentityStorage: IdentityStorage; @@ -141,8 +141,8 @@ describe('@unit IdentityStorage contract', function () { const identityId = await IdentityStorage.getIdentityId(operationalKey); await IdentityStorage.addKey(identityId, newOperationalKeyBytes32, OPERATIONAL_KEY, ECDSA); - expect(await IdentityStorage.removeKey(identityId, newOperationalKeyBytes32)) + await expect(IdentityStorage.removeKey(identityId, newOperationalKeyBytes32)) .to.emit(IdentityStorage, 'KeyRemoved') - .withArgs(0, ZERO_BYTES32, 0, 0); + .withArgs(identityId, ZERO_BYTES32, 0, 0); }); }); diff --git a/test/v1/unit/Profile.test.ts b/test/v1/unit/Profile.test.ts index c9b379f4..7c18d62c 100644 --- a/test/v1/unit/Profile.test.ts +++ b/test/v1/unit/Profile.test.ts @@ -28,7 +28,7 @@ describe('@v1 @unit Profile contract', function () { const identityId1 = 1; async function createProfile() { - expect(await Profile.createProfile(accounts[1].address, nodeId1, 'Token', 'TKN')) + await expect(Profile.createProfile(accounts[1].address, nodeId1, 'Token', 'TKN')) .to.emit(Profile, 'ProfileCreated') .withArgs(identityId1, nodeId1); } diff --git a/test/v1/unit/ProofManagerV1.test.ts b/test/v1/unit/ProofManagerV1.test.ts index c0cd06e3..2b3ec83b 100644 --- a/test/v1/unit/ProofManagerV1.test.ts +++ b/test/v1/unit/ProofManagerV1.test.ts @@ -244,7 +244,7 @@ describe('@v1 @unit ProofManagerV1 contract', function () { const initialStake = await StakingStorage.totalStakes(identityId); const initialAssetReward = await ServiceAgreementStorageProxy.getAgreementTokenAmount(agreementId); - expect(await ProofManagerV1.sendProof(proofInputArgs)).to.emit(ProofManagerV1, 'ProofSubmitted'); + await expect(ProofManagerV1.sendProof(proofInputArgs)).to.emit(ProofManagerV1, 'ProofSubmitted'); const endAssetReward = await ServiceAgreementStorageProxy.getAgreementTokenAmount(agreementId); expect(await StakingStorage.totalStakes(identityId)).to.equal( @@ -287,7 +287,7 @@ describe('@v1 @unit ProofManagerV1 contract', function () { chunkHash: leaf, }; - expect(await ProofManagerV1.sendProof(proofInputArgs)).to.emit(ProofManagerV1, 'ProofSubmitted'); + await expect(ProofManagerV1.sendProof(proofInputArgs)).to.emit(ProofManagerV1, 'ProofSubmitted'); await expect(ProofManagerV1.sendProof(proofInputArgs)).to.be.revertedWithCustomError( ProofManagerV1, 'NodeAlreadyRewarded', diff --git a/test/v1/unit/ProofManagerV1U1.test.ts b/test/v1/unit/ProofManagerV1U1.test.ts index fd27733f..3fd5112d 100644 --- a/test/v1/unit/ProofManagerV1U1.test.ts +++ b/test/v1/unit/ProofManagerV1U1.test.ts @@ -131,7 +131,7 @@ describe('@v1 @unit ProofManagerV1U1 contract', function () { }; for (let i = 0; i < finalizationRequirement; i++) { - expect(await CommitManagerV1U1.connect(accounts[i]).submitUpdateCommit(commitInputArgs)).to.emit( + await expect(CommitManagerV1U1.connect(accounts[i]).submitUpdateCommit(commitInputArgs)).to.emit( CommitManagerV1U1, 'CommitSubmitted', ); @@ -357,7 +357,7 @@ describe('@v1 @unit ProofManagerV1U1 contract', function () { ProofManagerV1, 'ServiceAgreementDoesntExist', ); - expect(await ProofManagerV1U1.sendProof(proofInputArgs)).to.emit(ProofManagerV1U1, 'ProofSubmitted'); + await expect(ProofManagerV1U1.sendProof(proofInputArgs)).to.emit(ProofManagerV1U1, 'ProofSubmitted'); const endAssetReward = await ServiceAgreementStorageProxy.getAgreementTokenAmount(agreementId); expect(await StakingStorage.totalStakes(identityIds[0])).to.equal( @@ -411,7 +411,7 @@ describe('@v1 @unit ProofManagerV1U1 contract', function () { ProofManagerV1, 'ServiceAgreementDoesntExist', ); - expect(await ProofManagerV1U1.sendProof(proofInputArgs)).to.emit(ProofManagerV1U1, 'ProofSubmitted'); + await expect(ProofManagerV1U1.sendProof(proofInputArgs)).to.emit(ProofManagerV1U1, 'ProofSubmitted'); await expect(ProofManagerV1U1.sendProof(proofInputArgs)).to.be.revertedWithCustomError( ProofManagerV1U1, 'NodeAlreadyRewarded', diff --git a/test/v1/unit/ServiceAgreementV1.test.ts b/test/v1/unit/ServiceAgreementV1.test.ts index e43a1876..f475d345 100644 --- a/test/v1/unit/ServiceAgreementV1.test.ts +++ b/test/v1/unit/ServiceAgreementV1.test.ts @@ -49,7 +49,7 @@ describe('@v1 @unit ServiceAgreementV1 contract', function () { const blockNumber = await hre.ethers.provider.getBlockNumber(); - await expect(await ServiceAgreementV1.createServiceAgreement(serviceAgreementInputArgs)) + await expect(ServiceAgreementV1.createServiceAgreement(serviceAgreementInputArgs)) .to.emit(ServiceAgreementV1, 'ServiceAgreementV1Created') .withArgs( serviceAgreementInputArgs.assetContract, @@ -141,7 +141,7 @@ describe('@v1 @unit ServiceAgreementV1 contract', function () { expect(await ServiceAgreementStorageProxy.serviceAgreementExists(agreementId)).to.eql(true); - expect(await ServiceAgreementV1.terminateAgreement(serviceAgreementInputArgs.assetCreator, agreementId)).to.emit( + await expect(ServiceAgreementV1.terminateAgreement(serviceAgreementInputArgs.assetCreator, agreementId)).to.emit( ServiceAgreementV1, 'ServiceAgreementV1Terminated', ); @@ -164,8 +164,8 @@ describe('@v1 @unit ServiceAgreementV1 contract', function () { const additionalTokenAmount = hre.ethers.utils.parseEther('10'); await Token.increaseAllowance(ServiceAgreementV1.address, additionalTokenAmount); - expect( - await ServiceAgreementV1.extendStoringPeriod( + await expect( + ServiceAgreementV1.extendStoringPeriod( serviceAgreementInputArgs.assetCreator, agreementId, additionalEpochsNumber, @@ -193,8 +193,8 @@ describe('@v1 @unit ServiceAgreementV1 contract', function () { const additionalTokenAmount = hre.ethers.utils.parseEther('10'); await Token.increaseAllowance(ServiceAgreementV1.address, additionalTokenAmount); - expect( - await ServiceAgreementV1.addTokens(serviceAgreementInputArgs.assetCreator, agreementId, additionalTokenAmount), + await expect( + ServiceAgreementV1.addTokens(serviceAgreementInputArgs.assetCreator, agreementId, additionalTokenAmount), ).to.emit(ServiceAgreementV1, 'ServiceAgreementV1RewardRaised'); expect(await ServiceAgreementStorageProxy.getAgreementTokenAmount(agreementId)).to.equal( @@ -214,8 +214,8 @@ describe('@v1 @unit ServiceAgreementV1 contract', function () { const additionalUpdateTokenAmount = hre.ethers.utils.parseEther('10'); await Token.increaseAllowance(ServiceAgreementV1.address, additionalUpdateTokenAmount); - expect( - await ServiceAgreementV1.addUpdateTokens( + await expect( + ServiceAgreementV1.addUpdateTokens( serviceAgreementInputArgs.assetCreator, agreementId, additionalUpdateTokenAmount, diff --git a/test/v2/unit/ContentAssetStorageV2.test.ts b/test/v2/unit/ContentAssetStorageV2.test.ts index f4bbed2a..654510e0 100644 --- a/test/v2/unit/ContentAssetStorageV2.test.ts +++ b/test/v2/unit/ContentAssetStorageV2.test.ts @@ -106,8 +106,8 @@ describe('@v2 @unit ContentAssetStorageV2', function () { ); // Update Base URI - expect( - await HubController.forwardCall( + await expect( + HubController.forwardCall( ContentAssetStorageV2.address, ContentAssetStorageV2.interface.encodeFunctionData('setBaseURI', ['https://dkg.resolver.origintrail.io/']), ), diff --git a/test/v2/unit/HubV2.test.ts b/test/v2/unit/HubV2.test.ts index 344dccb1..9e6b9193 100644 --- a/test/v2/unit/HubV2.test.ts +++ b/test/v2/unit/HubV2.test.ts @@ -72,9 +72,9 @@ describe('@v2 @unit Hub contract', function () { expect(await HubV2.getContractAddress('TestContract')).to.equal(accounts[1].address); - expect(await HubController.setContractAddress('TestContract', accounts[2].address)) + await expect(HubController.setContractAddress('TestContract', accounts[2].address)) .to.emit(HubV2, 'ContractChanged') - .withArgs('TestContract', accounts[2]); + .withArgs('TestContract', accounts[2].address); expect(await HubV2.getContractAddress('TestContract')).to.equal(accounts[2].address); }); @@ -168,7 +168,7 @@ describe('@v2 @unit Hub contract', function () { }); it('Set contract address, set the same address with different name; Expect to be reverted as address is already in the set', async () => { - expect(await HubController.setContractAddress('TestContract1', accounts[1].address)).to.emit(HubV2, 'NewContract'); + await expect(HubController.setContractAddress('TestContract1', accounts[1].address)).to.emit(HubV2, 'NewContract'); await expect(HubController.setContractAddress('TestContract2', accounts[1].address)).to.be.revertedWith( 'NamedContractSet: Address already in the set', ); diff --git a/test/v2/unit/IdentityStorageV2.test.ts b/test/v2/unit/IdentityStorageV2.test.ts index 78d7a13b..c912c868 100644 --- a/test/v2/unit/IdentityStorageV2.test.ts +++ b/test/v2/unit/IdentityStorageV2.test.ts @@ -141,7 +141,7 @@ describe('@v2 @unit IdentityStorageV2 contract', function () { const identityId = await IdentityStorageV2.getIdentityId(operationalKey); await IdentityStorageV2.addKey(identityId, newOperationalKeyBytes32, OPERATIONAL_KEY, ECDSA); - expect(await IdentityStorageV2.removeKey(identityId, newOperationalKeyBytes32)) + await expect(IdentityStorageV2.removeKey(identityId, newOperationalKeyBytes32)) .to.emit(IdentityStorageV2, 'KeyRemoved') .withArgs(identityId, newOperationalKeyBytes32, OPERATIONAL_KEY, ECDSA); }); diff --git a/utils/helpers.ts b/utils/helpers.ts index e9f1ab2c..b26f876c 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -22,7 +22,7 @@ type ContractDeployments = { contracts: { [contractName: string]: { evmAddress: string; - substrateAddress: string; + substrateAddress?: string; version: string; gitBranch: string; gitCommitHash: string; @@ -229,7 +229,7 @@ export class Helpers { this.contractDeployments.contracts[newContractName] = { evmAddress: newContractAddress, - substrateAddress: this.convertEvmWallet(newContractAddress), + substrateAddress: this.hre.network.name.startsWith('otp') ? this.convertEvmWallet(newContractAddress) : undefined, version: contractVersion, gitBranch: this.getCurrentGitBranch(), gitCommitHash: this.getCurrentGitCommitHash(), @@ -246,7 +246,11 @@ export class Helpers { ); } - public async sendOTP(address: string, tokenAmount = 2) { + public async sendOTP(address: string | undefined, tokenAmount = 2) { + if (address === undefined) { + throw Error('Address cannot be undefined!'); + } + const api = await ApiPromise.create({ provider: this.provider, noInitWarn: true }); const transfer = await api.tx.balances.transfer( address,