From e3ae56a035e6780e7c03e424e40f5087823f30b0 Mon Sep 17 00:00:00 2001 From: Joshua Richardson Date: Thu, 12 Sep 2019 11:45:53 +0100 Subject: [PATCH 1/3] Moves getTransactionReceipt from eea to priv --- package-lock.json | 68 +++++++++++++++++++---------------------------- package.json | 4 +-- src/index.js | 58 +++++++++++++++++++++------------------- 3 files changed, 59 insertions(+), 71 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7432fc7..c1a031f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "web3-eea", - "version": "0.7.1", + "version": "0.7.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5577,14 +5577,6 @@ "mime-types": "~2.1.24" } }, - "typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "requires": { - "is-typedarray": "^1.0.0" - } - }, "ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", @@ -5982,8 +5974,32 @@ "integrity": "sha512-rnwGcCe6cev5A6eG5UBCQqPmkJVZMCrK+HN1AvUCco0OHD/0asGc9LuLbtkQIyznA6Lzetq/OOcaTOM4KeT11g==", "requires": { "underscore": "1.9.1", - "web3-core-helpers": "1.2.0", - "websocket": "github:frozeman/WebSocket-Node#6c72925e3f8aaaea8dc8450f97627e85263999f2" + "web3-core-helpers": "1.2.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "websocket": { + "version": "github:frozeman/WebSocket-Node#6c72925e3f8aaaea8dc8450f97627e85263999f2", + "from": "github:frozeman/WebSocket-Node#6c72925e3f8aaaea8dc8450f97627e85263999f2", + "requires": { + "debug": "^2.2.0", + "nan": "^2.3.3", + "typedarray-to-buffer": "^3.1.2", + "yaeti": "^0.0.6" + } + } } }, "web3-shh": { @@ -6023,31 +6039,6 @@ } } }, - "websocket": { - "version": "github:frozeman/WebSocket-Node#6c72925e3f8aaaea8dc8450f97627e85263999f2", - "from": "github:frozeman/WebSocket-Node#browserifyCompatible", - "requires": { - "debug": "^2.2.0", - "nan": "^2.3.3", - "typedarray-to-buffer": "^3.1.2", - "yaeti": "^0.0.6" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" - } - } - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -6148,11 +6139,6 @@ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" }, - "yaeti": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", - "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" - }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", diff --git a/package.json b/package.json index d71a312..5e67e4d 100644 --- a/package.json +++ b/package.json @@ -40,10 +40,10 @@ "ethereumjs-tx": "^1.3.7", "lodash": "^4.17.15", "rlp": "^2.2.3", - "web3": "^1.2.0" + "web3": "^1.2.0", + "axios": "^0.18.1" }, "devDependencies": { - "axios": "^0.18.1", "babel-eslint": "^10.0.1", "dotenv": "^8.0.0", "eslint": "^5.16.0", diff --git a/src/index.js b/src/index.js index dfc4c54..9e37eab 100644 --- a/src/index.js +++ b/src/index.js @@ -195,13 +195,42 @@ function EEAClient(web3, chainId) { }); }; + /** + * Get the private transaction Receipt. + * @param {string} txHash Transaction Hash of the marker transaction + * @param {string} enclavePublicKey Public key used to start-up the Enclave + * @param {int} retries Number of retries to be made to get the private marker transaction receipt + * @param {int} delay The delay between the retries + * @returns {Promise | never>} + */ + const getTransactionReceipt = ( + txHash, + enclavePublicKey, + retries = 300, + delay = 1000 + ) => { + return getMarkerTransaction(txHash, retries, delay) + .then(() => { + return axios.post(host, { + jsonrpc: "2.0", + method: "priv_getTransactionReceipt", + params: [txHash, enclavePublicKey], + id: 1 + }); + }) + .then(result => { + return result.data.result; + }); + }; + // eslint-disable-next-line no-param-reassign web3.priv = { generatePrivacyGroup, createPrivacyGroup, deletePrivacyGroup, findPrivacyGroup, - getTransactionCount + getTransactionCount, + getTransactionReceipt }; // eslint-disable-next-line no-param-reassign @@ -273,33 +302,6 @@ function EEAClient(web3, chainId) { throw error; } }); - }, - /** - * Get the private transaction Receipt. - * @param {string} txHash Transaction Hash of the marker transaction - * @param {string} enclavePublicKey Public key used to start-up the Enclave - * @param {int} retries Number of retries to be made to get the private marker transaction receipt - * @param {int} delay The delay between the retries - * @returns {Promise | never>} - */ - getTransactionReceipt: ( - txHash, - enclavePublicKey, - retries = 300, - delay = 1000 - ) => { - return getMarkerTransaction(txHash, retries, delay) - .then(() => { - return axios.post(host, { - jsonrpc: "2.0", - method: "eea_getTransactionReceipt", - params: [txHash, enclavePublicKey], - id: 1 - }); - }) - .then(result => { - return result.data.result; - }); } }; From 4d3a10dc4e4cf3cb2e10cd0df4456d484a5f0906 Mon Sep 17 00:00:00 2001 From: Joshua Richardson Date: Thu, 19 Sep 2019 13:18:09 +0100 Subject: [PATCH 2/3] Updates examples in line with library updates --- example/erc20.js | 4 ++-- example/eventEmitter.js | 6 +++--- example/multiNodeExample/deployContract.js | 2 +- example/multiNodeExample/storeValueFromNode1.js | 4 ++-- example/multiNodeExample/storeValueFromNode2.js | 4 ++-- example/multiNodeExamplePrivacyGroup/deployContract.js | 2 +- example/multiNodeExamplePrivacyGroup/storeValueFromNode1.js | 4 ++-- example/multiNodeExamplePrivacyGroup/storeValueFromNode2.js | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/example/erc20.js b/example/erc20.js index 1c45122..e8302e9 100644 --- a/example/erc20.js +++ b/example/erc20.js @@ -40,7 +40,7 @@ web3.eea .sendRawTransaction(contractOptions) .then(hash => { console.log(`Transaction Hash ${hash}`); - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( hash, "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=" ); @@ -82,7 +82,7 @@ web3.eea }) .then(transactionHash => { console.log(`Transaction Hash ${transactionHash}`); - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( transactionHash, "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=" ); diff --git a/example/eventEmitter.js b/example/eventEmitter.js index ad7804f..cad7afe 100644 --- a/example/eventEmitter.js +++ b/example/eventEmitter.js @@ -27,7 +27,7 @@ const createPrivateEmitterContract = () => { const getPrivateContractAddress = transactionHash => { console.log("Transaction Hash ", transactionHash); - return web3.eea + return web3.priv .getTransactionReceipt(transactionHash, orion.node1.publicKey) .then(privateTransactionReceipt => { console.log("Private Transaction Receipt\n", privateTransactionReceipt); @@ -69,7 +69,7 @@ const getValue = contractAddress => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( transactionHash, orion.node1.publicKey ); @@ -81,7 +81,7 @@ const getValue = contractAddress => { }; const getPrivateTransactionReceipt = transactionHash => { - return web3.eea + return web3.priv .getTransactionReceipt(transactionHash, orion.node1.publicKey) .then(result => { console.log("Transaction Hash:", transactionHash); diff --git a/example/multiNodeExample/deployContract.js b/example/multiNodeExample/deployContract.js index b3568ea..0486d8c 100644 --- a/example/multiNodeExample/deployContract.js +++ b/example/multiNodeExample/deployContract.js @@ -24,7 +24,7 @@ const createPrivateEmitterContract = () => { const getPrivateContractAddress = transactionHash => { console.log("Transaction Hash ", transactionHash); - return web3.eea + return web3.priv .getTransactionReceipt(transactionHash, orion.node1.publicKey) .then(privateTransactionReceipt => { console.log("Private Transaction Receipt\n", privateTransactionReceipt); diff --git a/example/multiNodeExample/storeValueFromNode1.js b/example/multiNodeExample/storeValueFromNode1.js index d3cf033..bc37224 100644 --- a/example/multiNodeExample/storeValueFromNode1.js +++ b/example/multiNodeExample/storeValueFromNode1.js @@ -28,7 +28,7 @@ const storeValueFromNode1 = (address, value) => { .sendRawTransaction(functionCall) .then(transactionHash => { console.log("Transaction Hash:", transactionHash); - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( transactionHash, orion.node1.publicKey ); @@ -60,7 +60,7 @@ const getValue = (url, address, privateFrom, privateFor, privateKey) => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( transactionHash, orion.node1.publicKey ); diff --git a/example/multiNodeExample/storeValueFromNode2.js b/example/multiNodeExample/storeValueFromNode2.js index 9a40f16..e6d59e9 100644 --- a/example/multiNodeExample/storeValueFromNode2.js +++ b/example/multiNodeExample/storeValueFromNode2.js @@ -28,7 +28,7 @@ const storeValueFromNode2 = (address, value) => { .sendRawTransaction(functionCall) .then(transactionHash => { console.log("Transaction Hash:", transactionHash); - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( transactionHash, orion.node2.publicKey ); @@ -59,7 +59,7 @@ const getValue = (url, address, privateFrom, privateFor, privateKey) => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionRecipt( transactionHash, orion.node1.publicKey ); diff --git a/example/multiNodeExamplePrivacyGroup/deployContract.js b/example/multiNodeExamplePrivacyGroup/deployContract.js index f130642..d4fff0a 100644 --- a/example/multiNodeExamplePrivacyGroup/deployContract.js +++ b/example/multiNodeExamplePrivacyGroup/deployContract.js @@ -30,7 +30,7 @@ const createPrivateEmitterContract = privacyGroupId => { const getPrivateContractAddress = transactionHash => { console.log("Transaction Hash ", transactionHash); - return web3.eea + return web3.priv .getTransactionReceipt(transactionHash, orion.node1.publicKey) .then(privateTransactionReceipt => { console.log("Private Transaction Receipt\n", privateTransactionReceipt); diff --git a/example/multiNodeExamplePrivacyGroup/storeValueFromNode1.js b/example/multiNodeExamplePrivacyGroup/storeValueFromNode1.js index 220c7cb..f62ebb5 100644 --- a/example/multiNodeExamplePrivacyGroup/storeValueFromNode1.js +++ b/example/multiNodeExamplePrivacyGroup/storeValueFromNode1.js @@ -28,7 +28,7 @@ const storeValueFromNode1 = (address, value, privacyGroupId) => { .sendRawTransaction(functionCall) .then(transactionHash => { console.log("Transaction Hash:", transactionHash); - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); @@ -59,7 +59,7 @@ const getValue = (url, address, privateFrom, privacyGroupId, privateKey) => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); diff --git a/example/multiNodeExamplePrivacyGroup/storeValueFromNode2.js b/example/multiNodeExamplePrivacyGroup/storeValueFromNode2.js index 2f37e58..d0dec8c 100644 --- a/example/multiNodeExamplePrivacyGroup/storeValueFromNode2.js +++ b/example/multiNodeExamplePrivacyGroup/storeValueFromNode2.js @@ -28,7 +28,7 @@ const storeValueFromNode2 = (address, value, privacyGroupId) => { .sendRawTransaction(functionCall) .then(transactionHash => { console.log("Transaction Hash:", transactionHash); - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node2.publicKey ); @@ -59,7 +59,7 @@ const getValue = (url, address, privateFrom, privacyGroupId, privateKey) => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.eea.getTransactionReceipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); From 7c054000eef644550fc13c6264d1ea2c7f74eac9 Mon Sep 17 00:00:00 2001 From: Joshua Richardson Date: Thu, 19 Sep 2019 17:16:20 +0100 Subject: [PATCH 3/3] Refactor pantheon-quickstart to besu-quickstart, fix typo --- example/erc20.js | 4 ++-- example/eventEmitter.js | 2 +- example/multiNodeExample/storeValueFromNode1.js | 4 ++-- example/multiNodeExample/storeValueFromNode2.js | 4 ++-- test/integration/support/after.js | 8 ++++---- test/integration/support/before.js | 10 ++++------ 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/example/erc20.js b/example/erc20.js index e8302e9..ca4fb80 100644 --- a/example/erc20.js +++ b/example/erc20.js @@ -40,7 +40,7 @@ web3.eea .sendRawTransaction(contractOptions) .then(hash => { console.log(`Transaction Hash ${hash}`); - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( hash, "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=" ); @@ -82,7 +82,7 @@ web3.eea }) .then(transactionHash => { console.log(`Transaction Hash ${transactionHash}`); - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( transactionHash, "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=" ); diff --git a/example/eventEmitter.js b/example/eventEmitter.js index 8976d35..aedbbf1 100644 --- a/example/eventEmitter.js +++ b/example/eventEmitter.js @@ -69,7 +69,7 @@ const getValue = contractAddress => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); diff --git a/example/multiNodeExample/storeValueFromNode1.js b/example/multiNodeExample/storeValueFromNode1.js index bc37224..e25562e 100644 --- a/example/multiNodeExample/storeValueFromNode1.js +++ b/example/multiNodeExample/storeValueFromNode1.js @@ -28,7 +28,7 @@ const storeValueFromNode1 = (address, value) => { .sendRawTransaction(functionCall) .then(transactionHash => { console.log("Transaction Hash:", transactionHash); - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); @@ -60,7 +60,7 @@ const getValue = (url, address, privateFrom, privateFor, privateKey) => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); diff --git a/example/multiNodeExample/storeValueFromNode2.js b/example/multiNodeExample/storeValueFromNode2.js index e6d59e9..70e1cf9 100644 --- a/example/multiNodeExample/storeValueFromNode2.js +++ b/example/multiNodeExample/storeValueFromNode2.js @@ -28,7 +28,7 @@ const storeValueFromNode2 = (address, value) => { .sendRawTransaction(functionCall) .then(transactionHash => { console.log("Transaction Hash:", transactionHash); - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node2.publicKey ); @@ -59,7 +59,7 @@ const getValue = (url, address, privateFrom, privateFor, privateKey) => { return web3.eea .sendRawTransaction(functionCall) .then(transactionHash => { - return web3.priv.getTransactionRecipt( + return web3.priv.getTransactionReceipt( transactionHash, orion.node1.publicKey ); diff --git a/test/integration/support/after.js b/test/integration/support/after.js index e947914..90e87c8 100644 --- a/test/integration/support/after.js +++ b/test/integration/support/after.js @@ -8,13 +8,13 @@ const logOutput = ({ stdout, stderr }) => { }; const stopPrivacyQuickstart = () => { - return exec( - "cd pantheon-quickstart/privacy && ./stop.sh && ./remove.sh" - ).then(logOutput); + return exec("cd besu-quickstart/privacy && ./stop.sh && ./remove.sh").then( + logOutput + ); }; const removeDirectory = () => { - return exec("rm -Rf pantheon-quickstart"); + return exec("rm -Rf besu-quickstart"); }; stopPrivacyQuickstart() diff --git a/test/integration/support/before.js b/test/integration/support/before.js index 497f0da..66fae23 100644 --- a/test/integration/support/before.js +++ b/test/integration/support/before.js @@ -33,17 +33,17 @@ const logOutput = ({ stdout, stderr }) => { }; const prepareDirectory = () => { - return exec("rm -Rf pantheon-quickstart"); + return exec("rm -Rf besu-quickstart"); }; const cloneQuickStart = () => { return exec( - "git clone https://github.com/PegaSysEng/pantheon-quickstart.git" + "git clone https://github.com/PegaSysEng/besu-quickstart.git" ).then(logOutput); }; const runPrivacyQuickstart = () => { - return exec("cd pantheon-quickstart/privacy && ./run.sh").then(logOutput); + return exec("cd besu-quickstart/privacy && ./run.sh").then(logOutput); }; const waitForPantheon = () => { @@ -59,8 +59,6 @@ prepareDirectory() .then(waitForPantheon) .then(() => { // eslint-disable-next-line promise/no-return-wrap - return Promise.resolve( - console.log("Finished: Pantheon Network is Running") - ); + return Promise.resolve(console.log("Finished: Besu Network is Running")); }) .catch(console.error);