This repository has been archived by the owner on May 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
misc: Move types. Renaming/typos in comments. Fix linting errors. Add license headers. Add FIXMEs #44
Closed
misc: Move types. Renaming/typos in comments. Fix linting errors. Add license headers. Add FIXMEs #44
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
import BigNumber from 'bignumber.js'; | ||
|
||
import { BlockNumber } from '../types'; | ||
import { BlockNumber, InputDeriveHashMap, InputOptions, InputOptionsConditions, InputTrace, InputTraceHashMap } from '../types'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer in this PR to not touch anything in |
||
import { isArray, isHex, isInstanceOf, isString } from '../util/types'; | ||
import { padLeft, toHex } from '../util/format'; | ||
|
||
|
@@ -56,7 +56,7 @@ export const inHash = (hash: string) => { | |
return inHex(hash); | ||
}; | ||
|
||
export const inTopics = topics => { | ||
export const inTopics = (topics: Array<any>): Array<any> | string | null => { | ||
return (topics || []).filter(topic => topic === null || topic).map(topic => { | ||
if (topic === null) { | ||
return null; | ||
|
@@ -70,29 +70,29 @@ export const inTopics = topics => { | |
}); | ||
}; | ||
|
||
export const inFilter = options => { | ||
export const inFilter = (options: InputOptions) => { | ||
if (options) { | ||
Object.keys(options).forEach(key => { | ||
switch (key) { | ||
case 'address': | ||
if (isArray(options[key])) { | ||
options[key] = options[key].map(inAddress); | ||
options[key] = (options[key] as Array<string | number>).map(inAddress); | ||
} else { | ||
options[key] = inAddress(options[key]); | ||
options[key] = inAddress(options[key] as string); | ||
} | ||
break; | ||
|
||
case 'fromBlock': | ||
case 'toBlock': | ||
options[key] = inBlockNumber(options[key]); | ||
options[key] = inBlockNumber(options[key] as BlockNumber); | ||
break; | ||
|
||
case 'limit': | ||
options[key] = inNumber10(options[key]); | ||
options[key] = inNumber10(options[key] as BlockNumber); | ||
break; | ||
|
||
case 'topics': | ||
options[key] = inTopics(options[key]); | ||
options[key] = inTopics(options[key] as Array<any>); | ||
} | ||
}); | ||
} | ||
|
@@ -140,7 +140,7 @@ export const inOptionsCondition = (condition: { | |
return null; | ||
}; | ||
|
||
export const inOptions = (_options = {}) => { | ||
export const inOptions = (_options: InputOptions = {}) => { | ||
const options = Object.assign({}, _options); | ||
|
||
Object.keys(options).forEach(key => { | ||
|
@@ -149,38 +149,38 @@ export const inOptions = (_options = {}) => { | |
// Don't encode the `to` option if it's empty | ||
// (eg. contract deployments) | ||
if (options[key]) { | ||
options.to = inAddress(options[key]); | ||
options.to = inAddress(options[key] as string); | ||
} | ||
break; | ||
|
||
case 'from': | ||
options[key] = inAddress(options[key]); | ||
options[key] = inAddress(options[key] as string); | ||
break; | ||
|
||
case 'condition': | ||
options[key] = inOptionsCondition(options[key]); | ||
options[key] = inOptionsCondition(options[key] as InputOptionsConditions); | ||
break; | ||
|
||
case 'gas': | ||
case 'gasPrice': | ||
options[key] = inNumber16(new BigNumber(options[key]).round()); | ||
options[key] = inNumber16(new BigNumber(options[key] as string).toFixed() as BlockNumber); | ||
break; | ||
|
||
case 'value': | ||
case 'nonce': | ||
options[key] = inNumber16(options[key]); | ||
options[key] = inNumber16(options[key] as BlockNumber); | ||
break; | ||
|
||
case 'data': | ||
options[key] = inData(options[key]); | ||
options[key] = inData(options[key] as string); | ||
break; | ||
} | ||
}); | ||
|
||
return options; | ||
}; | ||
|
||
export const inTraceFilter = filterObject => { | ||
export const inTraceFilter = (filterObject: InputTraceHashMap) => { | ||
if (filterObject) { | ||
Object.keys(filterObject).forEach(key => { | ||
switch (key) { | ||
|
@@ -193,7 +193,7 @@ export const inTraceFilter = filterObject => { | |
|
||
case 'toBlock': | ||
case 'fromBlock': | ||
filterObject[key] = inBlockNumber(filterObject[key]); | ||
filterObject[key] = inBlockNumber(filterObject[key] as BlockNumber); | ||
break; | ||
} | ||
}); | ||
|
@@ -202,29 +202,31 @@ export const inTraceFilter = filterObject => { | |
return filterObject; | ||
}; | ||
|
||
export const inTraceType = whatTrace => { | ||
export const inTraceType = (whatTrace: InputTrace): InputTrace => { | ||
if (isString(whatTrace)) { | ||
return [whatTrace]; | ||
} | ||
|
||
return whatTrace; | ||
}; | ||
|
||
export const inDeriveType = derive => { | ||
export const inDeriveType = (derive: InputDeriveHashMap): string => { | ||
return derive && derive.type === 'hard' ? 'hard' : 'soft'; | ||
}; | ||
|
||
export const inDeriveHash = derive => { | ||
const hash = derive && derive.hash ? derive.hash : derive; | ||
const type = inDeriveType(derive); | ||
export const inDeriveHash = (derive: InputDeriveHashMap | string): InputDeriveHashMap => { | ||
const hash = derive && (derive as InputDeriveHashMap).hash | ||
? ((derive as InputDeriveHashMap).hash) as string | ||
: derive as string; | ||
const type = inDeriveType(derive as InputDeriveHashMap); | ||
|
||
return { | ||
hash: inHex(hash), | ||
type | ||
}; | ||
}; | ||
|
||
export const inDeriveIndex = derive => { | ||
export const inDeriveIndex = (derive: Array<InputDeriveHashMap | BlockNumber> | InputDeriveHashMap): Array<InputDeriveIndexHashMap | number | null> => { | ||
if (!derive) { | ||
return []; | ||
} | ||
|
@@ -233,12 +235,14 @@ export const inDeriveIndex = derive => { | |
derive = [derive]; | ||
} | ||
|
||
return derive.map(item => { | ||
const index = inNumber10(item && item.index ? item.index : item); | ||
return (derive as Array<InputDeriveHashMap | BlockNumber>).map(item => { | ||
const index = inNumber10(item && ((item as InputDeriveHashMap).index) as BlockNumber | ||
? ((item as InputDeriveHashMap).index) as BlockNumber | ||
: (item as BlockNumber)); | ||
|
||
return { | ||
index, | ||
type: inDeriveType(item) | ||
type: inDeriveType(item as InputDeriveHashMap) | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase on top of master? I merged the other one.