File tree Expand file tree Collapse file tree 9 files changed +40
-22
lines changed Expand file tree Collapse file tree 9 files changed +40
-22
lines changed Original file line number Diff line number Diff line change @@ -110,12 +110,7 @@ contract ClaimHolder is KeyHolder, ERC735 {
110110 bytes32 sa;
111111 uint8 va;
112112
113- bytes memory prefix = "\x19Ethereum Signed Message:\n32 " ; // prefix used by web3
114113 bytes memory sig = claims[_claimId].signature;
115- uint256 claimType = claims[_claimId].claimType;
116- bytes32 claimData = claims[_claimId].data;
117- bytes32 dataHash = keccak256 (address (this ), claimType, claimData);
118- bytes32 prefixedHash = keccak256 (prefix, dataHash);
119114
120115 // Check the signature length
121116 if (sig.length != 65 ) {
@@ -133,6 +128,9 @@ contract ClaimHolder is KeyHolder, ERC735 {
133128 va += 27 ;
134129 }
135130
131+ bytes32 dataHash = keccak256 (address (this ), claims[_claimId].claimType, claims[_claimId].data);
132+ bytes32 prefixedHash = keccak256 ("\x19Ethereum Signed Message:\n32 " , dataHash);
133+
136134 return (prefixedHash, ra, sa, va);
137135 }
138136
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ import './ClaimHolder.sol';
44
55contract ClaimVerifier {
66
7- event ClaimValid (ClaimHolder _identity , uint256 claimType );
8- event ClaimInvalid (ClaimHolder _identity , uint256 claimType );
7+ event ClaimValid (ClaimHolder _identity , uint256 claimType , bytes32 recoveredKey );
8+ event ClaimInvalid (ClaimHolder _identity , uint256 claimType , bytes32 recoveredKey );
99
1010 ClaimHolder public trustedClaimHolder;
1111
@@ -35,10 +35,10 @@ contract ClaimVerifier {
3535
3636 // Does the trusted identifier have they key which signed the user's claim?
3737 if (trustedClaimHolder.keyHasPurpose (hashedAddr, 3 )) {
38- emit ClaimValid (_identity, claimType);
38+ emit ClaimValid (_identity, claimType, hashedAddr );
3939 return true ;
4040 } else {
41- emit ClaimInvalid (_identity, claimType);
41+ emit ClaimInvalid (_identity, claimType, hashedAddr );
4242 return false ;
4343 }
4444 }
Original file line number Diff line number Diff line change @@ -3,6 +3,11 @@ import Identity from '../contracts/Identity'
33import ClaimHolder from '../contracts/ClaimHolder'
44import ClaimVerifier from '../contracts/ClaimVerifier'
55
6+ window . contracts = {
7+ ClaimHolder : ( addr ) => new web3 . eth . Contract ( ClaimHolder . abi , addr ) ,
8+ ClaimVerifier : ( addr ) => new web3 . eth . Contract ( ClaimVerifier . abi , addr ) ,
9+ }
10+
611function lookup ( Types ) {
712 return function claimType ( id ) {
813 var type = Types . find ( t => t . id === id )
@@ -309,7 +314,9 @@ export function addClaim({
309314 } )
310315
311316 dispatch ( sendTransaction ( tx , IdentityConstants . ADD_CLAIM , txData , ( ) => {
312- dispatch ( getEvents ( 'ClaimHolder' , targetIdentity ) )
317+ if ( web3 . eth . defaultAccount === targetIdentity ) {
318+ dispatch ( getEvents ( 'ClaimHolder' , targetIdentity ) )
319+ }
313320 } ) )
314321 }
315322}
@@ -335,7 +342,7 @@ export function removeClaim({ identity, claim }) {
335342
336343function sendTransaction ( transaction , type , data , callback ) {
337344 return async function ( dispatch ) {
338- dispatch ( { type } )
345+ dispatch ( { type, ... data } )
339346
340347 transaction
341348 . on ( 'error' , error => {
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export function loadWallet(external) {
6767
6868 try {
6969 if ( external ) {
70+ web3 . setProvider ( state . network . browserProvider )
7071 accounts = await web3 . eth . getAccounts ( )
7172
7273 balanceWei = await web3 . eth . getBalance ( accounts [ 0 ] )
@@ -83,6 +84,8 @@ export function loadWallet(external) {
8384 return
8485 }
8586
87+ web3 . setProvider ( state . network . provider )
88+
8689 // wallet.load is expensive, so cache private keys in sessionStorage
8790 if ( window . sessionStorage . privateKeys ) {
8891 JSON . parse ( window . sessionStorage . privateKeys ) . forEach ( key =>
@@ -129,10 +132,12 @@ export function selectAccount(address) {
129132
130133 try {
131134 var account = web3 . eth . accounts . wallet [ address ]
135+ web3 . eth . defaultAccount = address
132136
133137 dispatch ( {
134138 type : WalletConstants . SELECT_ACCOUNT_SUCCESS ,
135- account
139+ account,
140+ activeAddress : address
136141 } )
137142 } catch ( error ) {
138143 dispatch ( { type : WalletConstants . SELECT_ACCOUNT_ERROR , error } )
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ module.exports = {
106106 "indexed" : false ,
107107 "name" : "claimType" ,
108108 "type" : "uint256"
109+ } ,
110+ {
111+ "indexed" : false ,
112+ "name" : "recoveredKey" ,
113+ "type" : "bytes32"
109114 }
110115 ] ,
111116 "name" : "ClaimValid" ,
@@ -123,11 +128,16 @@ module.exports = {
123128 "indexed" : false ,
124129 "name" : "claimType" ,
125130 "type" : "uint256"
131+ } ,
132+ {
133+ "indexed" : false ,
134+ "name" : "recoveredKey" ,
135+ "type" : "bytes32"
126136 }
127137 ] ,
128138 "name" : "ClaimInvalid" ,
129139 "type" : "event"
130140 }
131141 ] ,
132- "data" : "6060604052341561000f57600080fd5b6040516020806109bb83398101604052808051906020019091905050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506109408061007b6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630382ad261461006757806336938354146100c1578063bcd68f4f14610116578063e6c1f9021461019c575b600080fd5b341561007257600080fd5b6100a7600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506101f6565b604051808215151515815260200191505060405180910390f35b34156100cc57600080fd5b6100d4610545565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012157600080fd5b61015a600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080356000191690602001909190505061056a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101a757600080fd5b6101dc600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106ac565b604051808215151515815260200191505060405180910390f35b60008060008060008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1688604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140182815260200192505050604051809103902092508873ffffffffffffffffffffffffffffffffffffffff1663c9100bcb846040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180826000191660001916815260200191505060c060405180830381600087803b15156102f357600080fd5b5af1151561030057600080fd5b50505060405180519060200180519060200180519060200180519060200180519060200180519050909150905050809650819750829850505050610344898461056a565b915081604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401915050604051809103902090506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d202158d8260036040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200182815260200192505050602060405180830381600087803b151561043957600080fd5b5af1151561044657600080fd5b50505060405180519050156104c9577f5637aa6b77cde2de563765b75a65099af73d3bf22cb9d089a64a01777823208e8989604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a160019650610539565b7fc1e461cfcaa9ff5efbb053582a325fbfebec1d94ac7e9d9958ee7f74c2b6b5588989604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a1600096505b50505050505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806000808773ffffffffffffffffffffffffffffffffffffffff1663a0ebcf61886040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050608060405180830381600087803b15156105e957600080fd5b5af115156105f657600080fd5b5050506040518051906020018051906020018051906020018051905080955081965082975083985050505050600185838686604051600081526020016040526040518085600019166000191681526020018460ff1660ff1681526020018360001916600019168152602001826000191660001916815260200194505050505060206040516020810390808403906000865af1151561069357600080fd5b5050602060405103519050809550505050505092915050565b60008060008060008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1688604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140182815260200192505050604051809103902092508873ffffffffffffffffffffffffffffffffffffffff1663c9100bcb846040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180826000191660001916815260200191505060c060405180830381600087803b15156107a957600080fd5b5af115156107b657600080fd5b505050604051805190602001805190602001805190602001805190602001805190602001805190509091509050508096508197508298505050506107fa898461056a565b915081604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401915050604051809103902090506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d202158d8260036040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200182815260200192505050602060405180830381600087803b15156108ef57600080fd5b5af115156108fc57600080fd5b505050604051805190509650505050505050929150505600a165627a7a723058204502563097e4e5dbe13264cc0f437745343f06d5acd4af7b1b4f42f1f162bfb40029"
142+ "data" : "6060604052341561000f57600080fd5b6040516020806109db83398101604052808051906020019091905050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506109608061007b6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630382ad261461006757806336938354146100c1578063bcd68f4f14610116578063e6c1f9021461019c575b600080fd5b341561007257600080fd5b6100a7600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506101f6565b604051808215151515815260200191505060405180910390f35b34156100cc57600080fd5b6100d4610565565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012157600080fd5b61015a600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080356000191690602001909190505061058a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156101a757600080fd5b6101dc600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506106cc565b604051808215151515815260200191505060405180910390f35b60008060008060008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1688604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140182815260200192505050604051809103902092508873ffffffffffffffffffffffffffffffffffffffff1663c9100bcb846040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180826000191660001916815260200191505060c060405180830381600087803b15156102f357600080fd5b5af1151561030057600080fd5b50505060405180519060200180519060200180519060200180519060200180519060200180519050909150905050809650819750829850505050610344898461058a565b915081604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401915050604051809103902090506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d202158d8260036040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200182815260200192505050602060405180830381600087803b151561043957600080fd5b5af1151561044657600080fd5b50505060405180519050156104d9577f3d4de4d11a11373233ed38924ca212d8f7207c65836d87f9d8d4305d1792c713898983604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018260001916600019168152602001935050505060405180910390a160019650610559565b7fe40aa58a04374428c5b27d482e2afa1b57a4a05127c6606b6d3fcec4c8c7361a898983604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018260001916600019168152602001935050505060405180910390a1600096505b50505050505092915050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000806000806000808773ffffffffffffffffffffffffffffffffffffffff1663a0ebcf61886040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808260001916600019168152602001915050608060405180830381600087803b151561060957600080fd5b5af1151561061657600080fd5b5050506040518051906020018051906020018051906020018051905080955081965082975083985050505050600185838686604051600081526020016040526040518085600019166000191681526020018460ff1660ff1681526020018360001916600019168152602001826000191660001916815260200194505050505060206040516020810390808403906000865af115156106b357600080fd5b5050602060405103519050809550505050505092915050565b60008060008060008060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1688604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c0100000000000000000000000002815260140182815260200192505050604051809103902092508873ffffffffffffffffffffffffffffffffffffffff1663c9100bcb846040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180826000191660001916815260200191505060c060405180830381600087803b15156107c957600080fd5b5af115156107d657600080fd5b5050506040518051906020018051906020018051906020018051906020018051906020018051905090915090505080965081975082985050505061081a898461058a565b915081604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166c01000000000000000000000000028152601401915050604051809103902090506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663d202158d8260036040518363ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180836000191660001916815260200182815260200192505050602060405180830381600087803b151561090f57600080fd5b5af1151561091c57600080fd5b505050604051805190509650505050505050929150505600a165627a7a723058208547e1bdf47239a8e13ee10bc58d6d9edcb0c6d6a20a76ca66a697aa96c15e540029"
133143}
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class Console extends Component {
5959
6060const mapStateToProps = state => ( {
6161 externalProvider : state . wallet . externalProvider ,
62- browserHasProvider : state . network . browserHasProvider
62+ browserHasProvider : state . network . browserProvider ? true : false
6363} )
6464
6565const mapDispatchToProps = dispatch => ( {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const HOST = process.env.HOST || 'localhost'
66let ipfsGateway = 'https://gateway.originprotocol.com' ,
77 ipfsRPC = 'https://gateway.originprotocol.com' ,
88 provider = 'https://rinkeby.infura.io' ,
9- browserHasProvider = false
9+ browserProvider = false
1010
1111if ( process . env . NODE_ENV !== 'production' ) {
1212 ipfsGateway = `http://${ HOST } :9090`
@@ -17,11 +17,9 @@ if (process.env.NODE_ENV !== 'production') {
1717if ( typeof window !== 'undefined' ) {
1818 provider = window . sessionStorage . provider || provider
1919 if ( window . web3 ) {
20- browserHasProvider = true
20+ browserProvider = web3 . currentProvider
2121 }
22- window . web3 = new Web3 (
23- typeof web3 !== 'undefined' ? web3 . currentProvider : provider
24- )
22+ window . web3 = new Web3 ( provider )
2523}
2624
2725const initialState = {
@@ -31,7 +29,7 @@ const initialState = {
3129 account : null ,
3230 status : 'disconnected' ,
3331
34- browserHasProvider ,
32+ browserProvider ,
3533 providers : Providers ,
3634 provider,
3735
You can’t perform that action at this time.
0 commit comments