-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from RunOnFlux/custom-token-import
Custom token import
- Loading branch information
Showing
4 changed files
with
58 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import log from '../lib/log'; | ||
import { getFromAlchemy } from '../services/tokenServices'; | ||
|
||
async function getTokenInfo(req, res) { | ||
try { | ||
let { network } = req.params; | ||
network = network || req.query.contract; | ||
|
||
let { address } = req.params; | ||
address = address || req.query.address; | ||
|
||
const value = await getFromAlchemy(address, network); | ||
|
||
res.json(value); | ||
} catch (error) { | ||
log.error(error); | ||
res.sendStatus(404); | ||
} | ||
} | ||
|
||
export default { | ||
getTokenInfo, | ||
}; |
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,21 @@ | ||
import { Alchemy, Network } from "alchemy-sdk"; | ||
import config from 'config'; | ||
|
||
export async function getFromAlchemy (contractAddress: any, network: any) { | ||
let value : any; | ||
|
||
// need to add here if new network with tokens | ||
if (network == 'eth') { | ||
value = Network.ETH_MAINNET; | ||
} else { | ||
value = Network.ETH_SEPOLIA; | ||
} | ||
|
||
const alchemy = new Alchemy({ | ||
apiKey: `${config.keys.alchemy}`, | ||
network: value, | ||
}); | ||
|
||
const metadata = await alchemy.core.getTokenMetadata(contractAddress); | ||
return metadata; | ||
} |