-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(coverage): gas usage improvements
Do not submit event for function and branch but detect where the statement is
- Loading branch information
1 parent
8a6d075
commit 0118b1a
Showing
7 changed files
with
79 additions
and
65 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
const CONTRACT_ID_FACTOR = 100000000; | ||
const INJECTION_POINT_ID_FACTOR = 10000; | ||
const CONTRACT_ID_FACTOR = 1000000; | ||
|
||
/** | ||
* Convert the 3 params as uint32 where the first 2 digits are for contractsId, | ||
* the next 3 digit are for injectionPoint id and the rest if for the locationIds | ||
* Convert the 2 params as uint32 where the first 4 digits are for contractsId, | ||
* the followings one are for injectionPoint id | ||
* | ||
* @export | ||
* @param {number} contractId | ||
* @param {number} injectionPointId | ||
* @param {number} [locationIdx] | ||
* @returns a number representing the 3 params as uint32 | ||
* @returns a number representing the 2 params as uint32 | ||
*/ | ||
export function encrypt(contractId: number, injectionPointId: number, locationIdx?: number) { | ||
return contractId * CONTRACT_ID_FACTOR + injectionPointId * INJECTION_POINT_ID_FACTOR + (locationIdx || 0); | ||
export function encrypt(contractId: number, injectionPointId: number) { | ||
return contractId * CONTRACT_ID_FACTOR + injectionPointId; | ||
} | ||
|
||
/** | ||
* Explore the uint32 into contractId, injectionPointId and locationIds where | ||
* the first 2 digits are for contractsId, | ||
* the next 3 digit are for injectionPoint id and the rest if for the locationIds | ||
* the first 4 digits are for contractsId, | ||
* the rest are for injectionPoint id | ||
* | ||
* @export | ||
* @param {number} value | ||
* @returns | ||
*/ | ||
export function decrypt(value: number) { | ||
const contractId = Math.floor(value / CONTRACT_ID_FACTOR); | ||
const injectionPointId = Math.floor(value / INJECTION_POINT_ID_FACTOR) - contractId * INJECTION_POINT_ID_FACTOR; | ||
const locationIdx = value - contractId * CONTRACT_ID_FACTOR - injectionPointId * INJECTION_POINT_ID_FACTOR; | ||
const injectionPointId = value - contractId * CONTRACT_ID_FACTOR; | ||
|
||
return {contractId, injectionPointId, locationIdx}; | ||
return {contractId, injectionPointId}; | ||
} |
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