diff --git a/gas-relayer/src/contract-settings.js b/gas-relayer/src/contract-settings.js index d0461de..9c87329 100644 --- a/gas-relayer/src/contract-settings.js +++ b/gas-relayer/src/contract-settings.js @@ -103,7 +103,7 @@ class ContractSettings { this.pendingToLoad++; try { - const code = await this.web3.eth.getCode(this.contracts[topicName].address) + const code = await this.web3.eth.getCode(this.contracts[topicName].address); this.contracts[topicName].code = this.web3.utils.soliditySha3(code); this.pendingToLoad--; if(this.pendingToLoad == 0) this.events.emit("setup:complete", this); diff --git a/gas-relayer/src/strategy/IdentityStrategy.js b/gas-relayer/src/strategy/IdentityStrategy.js index e66037f..07f3d78 100644 --- a/gas-relayer/src/strategy/IdentityStrategy.js +++ b/gas-relayer/src/strategy/IdentityStrategy.js @@ -18,6 +18,7 @@ class IdentityStrategy extends Strategy { async _validateInstance(input){ const instanceCodeHash = this.web3.utils.soliditySha3(await this.web3.eth.getCode(input.contract)); const kernelVerifSignature = this.web3.utils.soliditySha3(this.contract.kernelVerification).slice(0, 10); + if(instanceCodeHash === null) return false; let verificationResult = await this.web3.eth.call({ @@ -39,7 +40,7 @@ class IdentityStrategy extends Strategy { return {success: false, message: "Invalid identity instance"}; } } - + const params = this._obtainParametersFunc(input); // Verifying if token is allowed diff --git a/test-dapp/app/components/body-identity.js b/test-dapp/app/components/body-identity.js index 0af7bef..ce434e4 100644 --- a/test-dapp/app/components/body-identity.js +++ b/test-dapp/app/components/body-identity.js @@ -15,6 +15,7 @@ import Web3 from 'web3'; import config from '../config'; import {withStyles} from '@material-ui/core/styles'; +window.IdentityFactory = IdentityFactory; const styles = {}; @@ -24,7 +25,7 @@ class Body extends Component { super(props); this.state = { tab: 0, - identityAddress: null, + identityAddress: "0x0000000000000000000000000000000000000000", nonce: '0', kid: null, skid: null, @@ -87,8 +88,7 @@ class Body extends Component { }); this.setState({ - web3js, - identityAddress: IdentityGasRelay.options.address + web3js }); }); } diff --git a/test-dapp/app/components/status-identity.js b/test-dapp/app/components/status-identity.js index cc686b7..e99cf21 100644 --- a/test-dapp/app/components/status-identity.js +++ b/test-dapp/app/components/status-identity.js @@ -93,7 +93,7 @@ class Status extends Component { web3.eth.getBlock('latest').then(block => { this.setState({block: block.number}); this.readChain(); - setTimeout(this.web3BlockRead, 10000); + setTimeout(this.web3BlockRead, 5000); return true; }); } diff --git a/test-dapp/app/components/status-sntcontroller.js b/test-dapp/app/components/status-sntcontroller.js index 9951470..9d61eaa 100644 --- a/test-dapp/app/components/status-sntcontroller.js +++ b/test-dapp/app/components/status-sntcontroller.js @@ -91,7 +91,7 @@ class Status extends Component { web3.eth.getBlock('latest').then(block => { this.setState({block: block.number}); this.readChain(); - setTimeout(this.web3BlockRead, 10000); + setTimeout(this.web3BlockRead, 5000); return true; }); } diff --git a/test-dapp/app/status-gas-relayer.js b/test-dapp/app/status-gas-relayer.js index 9421cfb..9082483 100644 --- a/test-dapp/app/status-gas-relayer.js +++ b/test-dapp/app/status-gas-relayer.js @@ -123,6 +123,8 @@ class StatusGasRelayer { sendOptions.symKeyID = skid; } + console.log(sendOptions); + const msgId = await this.web3.shh.post(sendOptions); return msgId; } diff --git a/test-dapp/contracts/deploy/Factory.sol b/test-dapp/contracts/deploy/Factory.sol index ca86c5d..60700a0 100644 --- a/test-dapp/contracts/deploy/Factory.sol +++ b/test-dapp/contracts/deploy/Factory.sol @@ -10,15 +10,14 @@ contract Factory is Controlled { uint256 blockNumber; uint256 timestamp; address kernel; - bytes32 codeHash; } - mapping(bytes32 => uint256) hashToVersion; - mapping(address => uint256) versionMap; + mapping(bytes32 => uint256) public hashToVersion; + mapping(address => uint256) public versionMap; - Version[] versionLog; - uint256 latestUpdate; - address latestKernel; + Version[] public versionLog; + uint256 public latestUpdate; + address public latestKernel; constructor(address _kernel) public @@ -39,15 +38,13 @@ contract Factory is Controlled { returns( uint256 blockNumber, uint256 timestamp, - address kernel, - bytes32 codeHash + address kernel ) { return ( versionLog[index].blockNumber, versionLog[index].timestamp, - versionLog[index].kernel, - versionLog[index].codeHash + versionLog[index].kernel ); } @@ -91,8 +88,7 @@ contract Factory is Controlled { require(_kernel != latestKernel); bytes32 _codeHash = getCodeHash(_kernel); versionMap[_kernel] = versionLog.length; - hashToVersion[_codeHash] = versionLog.length; - versionLog.push(Version({blockNumber: block.number, timestamp: block.timestamp, kernel: _kernel, codeHash: _codeHash})); + versionLog.push(Version({blockNumber: block.number, timestamp: block.timestamp, kernel: _kernel})); latestUpdate = block.timestamp; latestKernel = _kernel; emit NewKernel(_kernel, _codeHash); diff --git a/test-dapp/contracts/identity/IdentityFactory.sol b/test-dapp/contracts/identity/IdentityFactory.sol index 0e71d38..19c83e8 100644 --- a/test-dapp/contracts/identity/IdentityFactory.sol +++ b/test-dapp/contracts/identity/IdentityFactory.sol @@ -51,6 +51,12 @@ contract IdentityFactory is Factory { returns (address) { IdentityKernel instance = IdentityKernel(new DelayedUpdatableInstance(address(latestKernel))); + + bytes32 codeHash = getCodeHash(address(instance)); + if(hashToVersion[codeHash] == 0){ + hashToVersion[codeHash] = versionLog.length; + } + instance.initIdentity(_keys,_purposes,_types,_managerThreshold,_actorThreshold,_recoveryContract); emit IdentityCreated(address(instance)); return instance;