Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

[PAN-3111] Moves getTransactionReceipt from eea to priv #42

Merged
merged 4 commits into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/erc20.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ web3.eea
.sendRawTransaction(contractOptions)
.then(hash => {
console.log(`Transaction Hash ${hash}`);
return web3.eea.getTransactionReceipt(
return web3.priv.getTransactionReceipt(
hash,
"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="
);
Expand Down Expand Up @@ -82,7 +82,7 @@ web3.eea
})
.then(transactionHash => {
console.log(`Transaction Hash ${transactionHash}`);
return web3.eea.getTransactionReceipt(
return web3.priv.getTransactionReceipt(
transactionHash,
"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="
);
Expand Down
6 changes: 3 additions & 3 deletions example/eventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -69,7 +69,7 @@ const getValue = contractAddress => {
return web3.eea
.sendRawTransaction(functionCall)
.then(transactionHash => {
return web3.eea.getTransactionReceipt(
return web3.priv.getTransactionReceipt(
transactionHash,
orion.node1.publicKey
);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion example/multiNodeExample/deployContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions example/multiNodeExample/storeValueFromNode1.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const storeValueFromNode1 = (address, value) => {
.sendRawTransaction(functionCall)
.then(transactionHash => {
console.log("Transaction Hash:", transactionHash);
return web3.eea.getTransactionReceipt(
return web3.priv.getTransactionReceipt(
transactionHash,
orion.node1.publicKey
);
Expand Down Expand Up @@ -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.getTransactionReceipt(
transactionHash,
orion.node1.publicKey
);
Expand Down
4 changes: 2 additions & 2 deletions example/multiNodeExample/storeValueFromNode2.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const storeValueFromNode2 = (address, value) => {
.sendRawTransaction(functionCall)
.then(transactionHash => {
console.log("Transaction Hash:", transactionHash);
return web3.eea.getTransactionReceipt(
return web3.priv.getTransactionReceipt(
transactionHash,
orion.node2.publicKey
);
Expand Down Expand Up @@ -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.getTransactionReceipt(
transactionHash,
orion.node1.publicKey
);
Expand Down
2 changes: 1 addition & 1 deletion example/multiNodeExamplePrivacyGroup/deployContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions example/multiNodeExamplePrivacyGroup/storeValueFromNode1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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
);
Expand Down
4 changes: 2 additions & 2 deletions example/multiNodeExamplePrivacyGroup/storeValueFromNode2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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
);
Expand Down
68 changes: 27 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
josh-richardson marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"axios": "^0.18.1",
"babel-eslint": "^10.0.1",
"dotenv": "^8.0.0",
"eslint": "^5.16.0",
Expand Down
58 changes: 30 additions & 28 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,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<AxiosResponse<any> | 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
Expand Down Expand Up @@ -279,33 +308,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<AxiosResponse<any> | 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;
});
}
};

Expand Down
8 changes: 4 additions & 4 deletions test/integration/support/after.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 4 additions & 6 deletions test/integration/support/before.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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);