-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: maintain pattern of one utility per file
- Loading branch information
Showing
5 changed files
with
39 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
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,7 +1,5 @@ | ||
export { getTokenPriceCents } from './getTokenPriceCents'; | ||
export { exponentToBigDecimal } from './exponentToBigDecimal'; | ||
export { getUnderlyingPrice } from './getUnderlyingPrice'; | ||
export { | ||
valueOrNotAvailableIntIfReverted, | ||
valueOrNotAvailableAddressIfReverted, | ||
} from './valueOrNotAvailableIfReverted'; | ||
export { valueOrNotAvailableAddressIfReverted } from './valueOrNotAvailableAddressIfReverted'; | ||
export { valueOrNotAvailableIntIfReverted } from './valueOrNotAvailableIntIfReverted'; |
15 changes: 15 additions & 0 deletions
15
subgraphs/venus/src/utilities/valueOrNotAvailableAddressIfReverted.ts
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,15 @@ | ||
import { Address, ethereum, log } from '@graphprotocol/graph-ts'; | ||
|
||
import { nullAddress } from '../constants/addresses'; | ||
|
||
// checks if a call reverted, in case it is we return 0x000.. to indicate the wanted value is not available | ||
export function valueOrNotAvailableAddressIfReverted( | ||
callResult: ethereum.CallResult<Address>, | ||
callName: string, | ||
): Address { | ||
if (callResult.reverted) { | ||
log.error('***CALL FAILED*** : {} reverted', [callName]); | ||
return nullAddress; | ||
} | ||
return callResult.value; | ||
} |
28 changes: 0 additions & 28 deletions
28
subgraphs/venus/src/utilities/valueOrNotAvailableIfReverted.ts
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
subgraphs/venus/src/utilities/valueOrNotAvailableIntIfReverted.ts
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,18 @@ | ||
import { BigInt, ethereum, log } from '@graphprotocol/graph-ts'; | ||
|
||
import { NOT_AVAILABLE_BIG_INT } from '../constants'; | ||
|
||
// checks if a call reverted, in case it is we return -1 to indicate the wanted value is not available | ||
// checks if a call reverted, in case it is we return -1 to indicate the wanted value is not available | ||
export function valueOrNotAvailableIntIfReverted( | ||
callResult: ethereum.CallResult<BigInt>, | ||
callName: string, | ||
): BigInt { | ||
if (callResult.reverted) { | ||
log.error('***CALL FAILED*** : {} reverted', [callName]); | ||
return NOT_AVAILABLE_BIG_INT; | ||
} | ||
return callResult.value; | ||
} | ||
|
||
export default valueOrNotAvailableIntIfReverted; |