From 24af9eb6c77753785dc7adcea460fddda14da1cb Mon Sep 17 00:00:00 2001 From: emizzle Date: Tue, 10 Jul 2018 00:39:22 +1000 Subject: [PATCH] Fixed missing description on the update profile page Added tweet unit tests for contract events (which works!!) Added HD wallet accounts to contracts config Updated to web3 1.0.0-beta.34 explicitly --- app/js/components/UpdateUser.js | 2 +- chains.json | 190 +++----------------------------- config/contracts.js | 30 ++++- embark.json | 2 +- test/dtwitter_spec.js | 13 +++ 5 files changed, 59 insertions(+), 178 deletions(-) diff --git a/app/js/components/UpdateUser.js b/app/js/components/UpdateUser.js index 926d4b0..8ca0298 100644 --- a/app/js/components/UpdateUser.js +++ b/app/js/components/UpdateUser.js @@ -13,7 +13,7 @@ class UpdateUser extends Component { this.state = { isLoading: false, picture: '', - description: '', + description: this.props.user.description, error: '', formState: null, formUpdated: false diff --git a/chains.json b/chains.json index 66fcf91..5eafb71 100644 --- a/chains.json +++ b/chains.json @@ -1,193 +1,37 @@ { - "0xd515bc93ee53461a57e233a50e2eba75d590a038b9b72f480103e990ac00dbf3": { + "0x15c2ab491ae6c4032ba7d16b05e2b0e3d89875a2e36fe5f0ee4c525ccf7420a4": { "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x004A95B5BF0F7Fea776205cD59f2486fadff526D" - }, "0x1797453304e4b69b44fb7d649a72ca80394a8b4e1d14c2cc530f5dc3ae1f0ea3": { "name": "ENSRegistry", - "address": "0xc07477504DB90579EA350Bececb1DDa772ffe748" + "address": "0x9e808bb8635ef1Db21DC2EA66Aac826F3047585A" }, - "0x2bbb044bd57c334bafb8140dfa76ffdb36e1991b9bf340565e1d5edc02f85893": { + "0x1cfcac7457c7ffd772b800c2bdf98e78c6c62947bddde1b8700e6aac08388fb9": { + "name": "DTwitter", + "address": "0xcFD4f7935631eE3C6D256Bda65b3dDF60b6FAbF4" + }, + "0xae650b0aa9572d9f877383c18307961899faee130cc7352b49703ca0d556ae1f": { "name": "FIFSRegistrar", - "address": "0xE7AfE25416C6869B148d0fF42FB8990Fb49a6F6f" + "address": "0xB1c792Be30a9099816d319311E15e3e8F4034913" }, - "0x284ca21976be7b83e49aff18a3034bb32850b4bfc6a55809b20bfbe72ac78362": { + "0xbf5940ac841eee52161d286ee23e3608a8079b75a2fc468c630fff1342b25681": { "name": "FIFSRegistrar", - "address": "0x6a45998a9748211a1652387b4dDcE4fBDc2f9E3b" + "address": "0x080f5FF5c4203905A5EdB575eB64DaBEf9b1DAF6" }, - "0xe2f18a6e39f5e2840324c49db7f7e609b320a0c417da77e941c21a360413fcf4": { + "0x6d1e2e0bd96a493aaab99909e0fd4ed874e93edd9a58020916846e08876c3b01": { "name": "FIFSRegistrar", - "address": "0x0dDE0DAda8A9cc1dEF1Fa0EC0A8Dd54154d958bd" + "address": "0x7971b5Be8dee577B628d947014C17A2a5f621775" }, - "0xce84268300f3025cdad8ffb04c67bf163f2c538d7f685ee2c1eca3f184a3e221": { + "0x14fc4f60da6f1bac5bebc7a1fa3710d952a005bafa259adf70f6afced3d9998c": { "name": "FIFSRegistrar", - "address": "0x6C283709319d3ff12a37Db0c2B9e064408DF80c5" - }, - "0x8e830368a1271b68c8a73f23ae048fd70327d1bcc691dff04c50ce4f807ab251": { - "name": "FIFSRegistrar", - "address": "0x31593F25781F91Bc08249733e6618597668da48D" - }, - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0x3188e8830d3F3887A04BA9982BfC2Ec1a63903e8" - }, - "0xd2d15192796bb302aaf2ce3e5297ca0f42949651c09beacb7bc1218116c949dc": { - "name": "FIFSRegistrar", - "address": "0x7ea3197c56BB0170476194411e64F7caB65dE306" + "address": "0xe1A2089A83babb745790c19ccD648F38715c70c1" } } }, - "0xf563b1fa29edfc897b6d2d041e684bf6f2da4ba38de4647bcaa2092ff6447bd2": { + "0x625705209efa5d197d6e2e3a5a758f2e96b1c72c3cc7741d7c7ca10ebc09c98d": { "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { + "0x1cfcac7457c7ffd772b800c2bdf98e78c6c62947bddde1b8700e6aac08388fb9": { "name": "DTwitter", - "address": "0x857d7B774a231DFDc8556Fcdb826AE1323dF9363" - } - } - }, - "0xff04da0c6a0d3bec232a318fe23a96112bf9dee4e73a5e186974bf3037edca8f": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x9F7050134e8A624e909F622DCC948911a2485CAb" - } - } - }, - "0x680020bf8abd0e053ef5b1072904f405540fd8de5b9bd4cb8778429ae0d81187": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x4Ffcb881BD5A08977320D9Ed4117a5B3315d7Fe2" - } - } - }, - "0xb910c985b5c422be26a22abc8b98f630c59c750043a85ce08ba57a00b027dc8d": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x2097400A013401326fAe31213345Af3F9cE29C7d" - } - } - }, - "0x681dda007fc8fbd2b0e76a4210049c35b63898918c95d78ab2e581b190cf00f8": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0xB98F98a955f76E97d9c3005223D621E94FA83521" - } - } - }, - "0x74c93c82c5ff4837a09d18ff547183e2fed670da6538bed9c7f5d74be39796e7": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0xFcD8c91B360F2623e808cF844F3ECF0E08b26a1A" - } - } - }, - "0x7c491ceb527a3659410d3b760668f063e570b17113a8047ca7ec3ec598d83346": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x59a89dBE08162A940D7FE8C4d254Fa3E58aFdCe9" - } - } - }, - "0xd732619dda54f0fbd09148d62d5816ba93b5ba811dbf2f9302e7f692bc6c8ee0": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x4a33Aa0105729ff1a8C7CF0AE4F63A770Eb4150c" - } - } - }, - "0xbd0900c07d789e26828d3fbeb27fed162e0873f64dab4909c6847b17b1d1f0cb": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0xC7D8c27a32F21a179B79bA30148dEC68AC6C71D3" - } - } - }, - "0xfcd36a664f8055d212b8814633a6896f10e002f5a7a05449f51c86dcbb659e54": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0xE75D2Ce89E4539E2462a8aBDb36929124f8030B0" - } - } - }, - "0x50f6c6bdc0d0cda9c1f3f611ac31937c43e737eac5c2ab1b9f91a70394ea092d": { - "contracts": { - "0xa6ef66d311293de88b3939d16826bb1546111982172c2e9c803c0ac8153a1b52": { - "name": "DTwitter", - "address": "0x58285E0B0C07e8cf86DeDa34DdDbc3cE4Bd0ea64" - } - } - }, - "0xd7172f5e5a469c5ea7f7a8b71c26d1ce1b4f16b0f62809f38e494d956d34a7c6": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0x9f6C07CCEb84A93d0F1906f6a382288af2bb804f" - } - } - }, - "0xdd081f6af1cf1035cdfa2c54b1bdccb1dc2c3172721b90ee93d1473c63dbe7e3": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0x77b6c0E34B92d2EDa5726AaCF38193854F6187B0" - } - } - }, - "0xca42ddc0b92e0409874f8f797452579a385d74755ef45e2b76927f02a341fe32": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0x8fE9Ec3246DA59dCE44Cd5084BB26D68001F6DC3" - } - } - }, - "0xd0e2f4f8d6d651eba1f7eeb53291f90192476415c6735beb22813c25ef7332f8": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0xA2507144a957696e430A67A19b6B37D77689b3f5" - } - } - }, - "0xb582edf9ed12b8fa5eac13e924b3244cc0cc37645d4877cbfd040537a4d03740": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0x49d532D683dEB8B512096E35E2CCc620ebed556A" - } - } - }, - "0x82782e1aa3c111be0528cb727ca3101b33a7edb0ec2028b6ec61625b5780a72f": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0xDb6D07014D28Da3cFc4d8eaf0CE78278DFa40115" - } - } - }, - "0xd40221d36aa5d4b63f0d4c10acf2c06a89fa9c42bf7c3eef1c8b4659a38d698f": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0xeD728C0b1e59CA32286e694bC6F79ef39D9DBbf2" - } - } - }, - "0xebacecb8093cd0b94128dbb259d70021b0583becf2b9536c139d50433606fa19": { - "contracts": { - "0x7cdafd8b713a2a137aa482400094d5148196dd4ed9e0b885613558758ba63ee5": { - "name": "DTwitter", - "address": "0xcFAC402592F3D6eD8Ca107fE374D1D364bD291Cf" + "address": "0xAa978bbfd19FeA18107A6b8E1004D4377B7074A4" } } } diff --git a/config/contracts.js b/config/contracts.js index f197264..2f5fceb 100644 --- a/config/contracts.js +++ b/config/contracts.js @@ -6,7 +6,16 @@ module.exports = { protocol: 'http', host: "localhost", port: 8545, - type: "rpc" + type: "rpc", + accounts: [ + { + "mnemonic": "acquire hole quarter security auto wedding leader audit baby dawn gravity obvious", + "addressIndex": "0", // Optional. The index to start getting the address + "numAddresses": "2", // Optional. The number of addresses to get + "hdpath": "m/44'/60'/0'/0/",// Optional. HD derivation path + "balance": "5 ether" + } + ] }, // order of connections the dapp should connect to dappConnection: [ @@ -14,24 +23,39 @@ module.exports = { "ws://localhost:8546", "http://localhost:8545" ], - gas: "auto", contracts: { DTwitter: { args: [ ] } }, + gas: "auto", gasLimit: 9000000 }, testnet: { deployment:{ + // accounts: [ + // { + // "mnemonic": "wave pigeon sustain sock boring monitor left sight hedgehog weapon champion session", + // "addressIndex": "0", // Optional. The index to start getting the address + // "numAddresses": "2", // Optional. The number of addresses to get + // "hdpath": "m/44'/60'/0'/0/" // Optional. HD derivation path + // } + // ], accounts: [ { - "mnemonic": "wave pigeon sustain sock boring monitor left sight hedgehog weapon champion session", + "mnemonic": "acquire hole quarter security auto wedding leader audit baby dawn gravity obvious", "addressIndex": "0", // Optional. The index to start getting the address "numAddresses": "2", // Optional. The number of addresses to get "hdpath": "m/44'/60'/0'/0/" // Optional. HD derivation path } ], + contracts: { + DTwitter: { + args: [ ] + } + }, + gasLimit: 9000000, + gasPrice: 89200, host: "rinkeby.infura.io/nmY8WtT4QfEwz2S7wTbl", port: false, protocol: 'https', diff --git a/embark.json b/embark.json index 3ffdf24..dddc415 100644 --- a/embark.json +++ b/embark.json @@ -10,7 +10,7 @@ "buildDir": "dist/", "config": "config/", "versions": { - "web3": "1.0.0-beta", + "web3": "1.0.0-beta.34", "solc": "0.4.24", "ipfs-api": "17.2.4" }, diff --git a/test/dtwitter_spec.js b/test/dtwitter_spec.js index 8f6479b..5dd36ab 100644 --- a/test/dtwitter_spec.js +++ b/test/dtwitter_spec.js @@ -13,6 +13,7 @@ config({ const username = 'testusername'; const description = 'test description'; +const tweetContent = 'test tweet'; const { createAccount, users, owners, userExists, editAccount, tweet } = DTwitter.methods; let usernameHash; @@ -61,4 +62,16 @@ describe("DTwitter contract", function() { assert.equal(updatedUserDetails.picture, updatedImageHash); }); + it("should be able to add a tweet and receive it via contract event", async function() { + DTwitter.events.NewTweet({ + filter: {_from: usernameHash}, + fromBlock: 0 + }) + .on('data', (event) => { + assert.equal(event.returnValues.tweet, tweetContent); + }); + + await tweet(usernameHash, tweetContent).send(); + }); + });