aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 19:23:42 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-04 19:23:42 +0800
commit11c48ced00ef4c25aeffd47504685f0a3bf3e7e3 (patch)
tree5720e5d483a2530915dce24eff27370da72ea046 /src
parentcc3871aca54a9c4dc0906e2b726c2c079787f142 (diff)
downloaddexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.tar
dexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.tar.gz
dexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.tar.bz2
dexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.tar.lz
dexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.tar.xz
dexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.tar.zst
dexon-sol-tools-11c48ced00ef4c25aeffd47504685f0a3bf3e7e3.zip
Reduce nesting
Diffstat (limited to 'src')
-rw-r--r--src/contract_wrappers/contract_wrapper.ts21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts
index 4d08f04e6..743dfc9b2 100644
--- a/src/contract_wrappers/contract_wrapper.ts
+++ b/src/contract_wrappers/contract_wrapper.ts
@@ -63,16 +63,17 @@ export class ContractWrapper {
private _getTopicsForIndexedArgs(abi: Web3.EventAbi, indexFilterValues: IndexedFilterValues): Array<string|null> {
const topics: Array<string|null> = [];
for (const eventInput of abi.inputs) {
- if (eventInput.indexed) {
- if (_.isUndefined(indexFilterValues[eventInput.name])) {
- topics.push(null);
- } else {
- const value = indexFilterValues[eventInput.name] as string;
- const buffer = ethUtil.toBuffer(value);
- const paddedBuffer = ethUtil.setLengthLeft(buffer, TOPIC_LENGTH);
- const topic = ethUtil.bufferToHex(paddedBuffer);
- topics.push(topic);
- }
+ if (!eventInput.indexed) {
+ continue;
+ }
+ if (_.isUndefined(indexFilterValues[eventInput.name])) {
+ topics.push(null);
+ } else {
+ const value = indexFilterValues[eventInput.name] as string;
+ const buffer = ethUtil.toBuffer(value);
+ const paddedBuffer = ethUtil.setLengthLeft(buffer, TOPIC_LENGTH);
+ const topic = ethUtil.bufferToHex(paddedBuffer);
+ topics.push(topic);
}
}
return topics;