-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
35 changed files
with
1,797 additions
and
1,704 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
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,33 @@ | ||
import { asMaybe, asObject, asString } from 'cleaners' | ||
import { EdgeMetaToken, EdgeTokenMap } from 'edge-core-js' | ||
|
||
/** | ||
* The `networkLocation` field is untyped, | ||
* but many currency plugins will put a contract address in there. | ||
*/ | ||
export const asMaybeContractLocation = asMaybe( | ||
asObject({ | ||
contractAddress: asString | ||
}) | ||
) | ||
|
||
/** | ||
* Downgrades EdgeToken objects to the legacy EdgeMetaToken format. | ||
*/ | ||
export function makeMetaTokens(tokens: EdgeTokenMap): EdgeMetaToken[] { | ||
const out: EdgeMetaToken[] = [] | ||
for (const tokenId of Object.keys(tokens)) { | ||
const { currencyCode, displayName, denominations, networkLocation } = | ||
tokens[tokenId] | ||
|
||
const cleanLocation = asMaybeContractLocation(networkLocation) | ||
if (cleanLocation == null) continue | ||
out.push({ | ||
currencyCode, | ||
currencyName: displayName, | ||
denominations, | ||
contractAddress: cleanLocation.contractAddress | ||
}) | ||
} | ||
return out | ||
} |
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.