This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move extra field parsers to the correct file
- Loading branch information
1 parent
e21a278
commit ec86ad9
Showing
3 changed files
with
47 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import BigNumber from "bignumber.js"; | ||
|
||
export function fromOperationExtraRaw( | ||
extra: Record<string, any> | null | undefined | ||
): Record<string, any> | null | undefined { | ||
if (!extra) return extra; | ||
|
||
const { gasLimit, gasPremium, gasFeeCap } = extra; | ||
|
||
if (gasLimit !== undefined) | ||
extra = { ...extra, gasLimit: new BigNumber(gasLimit) }; | ||
|
||
if (gasPremium !== undefined) | ||
extra = { ...extra, gasPremium: new BigNumber(gasPremium) }; | ||
|
||
if (gasFeeCap !== undefined) | ||
extra = { ...extra, gasFeeCap: new BigNumber(gasFeeCap) }; | ||
|
||
return extra; | ||
} | ||
|
||
export function toOperationExtraRaw( | ||
extra: Record<string, any> | null | undefined | ||
): Record<string, any> | null | undefined { | ||
if (!extra) return extra; | ||
|
||
const { gasLimit, gasPremium, gasFeeCap } = extra; | ||
|
||
if (gasLimit !== undefined) | ||
extra = { ...extra, gasLimit: gasLimit.toNumber() }; | ||
|
||
if (gasPremium !== undefined) | ||
extra = { ...extra, gasPremium: gasPremium.toFixed() }; | ||
|
||
if (gasFeeCap !== undefined) | ||
extra = { ...extra, gasFeeCap: gasFeeCap.toFixed() }; | ||
|
||
return extra; | ||
} | ||
|
||
export default { | ||
fromOperationExtraRaw, | ||
toOperationExtraRaw, | ||
}; |
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