-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-1479: [EVM] Transactions history (#176)
* TW-1479: [EVM] Transactions history * TW-1479: [EVM] Transactions history. ++ Covalent SDK
- Loading branch information
Showing
7 changed files
with
141 additions
and
390 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 |
---|---|---|
|
@@ -108,3 +108,5 @@ dist | |
|
||
# IDE | ||
.idea | ||
|
||
.DS_Store |
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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"author": "Inokentii Mazhara <[email protected]>", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@covalenthq/client-sdk": "^1.0.2", | ||
"@covalenthq/client-sdk": "^2", | ||
"@ethersproject/address": "^5.7.0", | ||
"@ethersproject/hash": "^5.7.0", | ||
"@ethersproject/strings": "^5.7.0", | ||
|
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,44 +1,69 @@ | ||
import { Router } from 'express'; | ||
|
||
import { withCodedExceptionHandler, withEvmQueryValidation } from '../../utils/express-helpers'; | ||
import { getEvmBalances, getEvmCollectiblesMetadata, getEvmTokensMetadata, getStringifiedResponse } from './covalent'; | ||
import { withCodedExceptionHandler } from '../../utils/express-helpers'; | ||
import { | ||
evmQueryParamsSchema, | ||
evmQueryParamsPaginatedSchema, | ||
evmQueryParamsTransfersSchema | ||
} from '../../utils/schemas'; | ||
import { | ||
getEvmBalances, | ||
getEvmCollectiblesMetadata, | ||
getEvmTokensMetadata, | ||
getEvmAccountTransactions, | ||
getEvmAccountERC20Transfers | ||
} from './covalent'; | ||
|
||
export const evmRouter = Router(); | ||
|
||
evmRouter | ||
.get( | ||
'/balances', | ||
withCodedExceptionHandler( | ||
withEvmQueryValidation(async (_1, res, _2, evmQueryParams) => { | ||
const { walletAddress, chainId } = evmQueryParams; | ||
withCodedExceptionHandler(async (req, res) => { | ||
const { walletAddress, chainId } = await evmQueryParamsSchema.validate(req.query); | ||
|
||
const data = await getEvmBalances(walletAddress, chainId); | ||
const data = await getEvmBalances(walletAddress, chainId); | ||
|
||
res.status(200).send(getStringifiedResponse(data)); | ||
}) | ||
) | ||
res.status(200).send(data); | ||
}) | ||
) | ||
.get( | ||
'/tokens-metadata', | ||
withCodedExceptionHandler( | ||
withEvmQueryValidation(async (_1, res, _2, evmQueryParams) => { | ||
const { walletAddress, chainId } = evmQueryParams; | ||
withCodedExceptionHandler(async (req, res) => { | ||
const { walletAddress, chainId } = await evmQueryParamsSchema.validate(req.query); | ||
|
||
const data = await getEvmTokensMetadata(walletAddress, chainId); | ||
const data = await getEvmTokensMetadata(walletAddress, chainId); | ||
|
||
res.status(200).send(getStringifiedResponse(data)); | ||
}) | ||
) | ||
res.status(200).send(data); | ||
}) | ||
) | ||
.get( | ||
'/collectibles-metadata', | ||
withCodedExceptionHandler( | ||
withEvmQueryValidation(async (_1, res, _2, evmQueryParams) => { | ||
const { walletAddress, chainId } = evmQueryParams; | ||
withCodedExceptionHandler(async (req, res) => { | ||
const { walletAddress, chainId } = await evmQueryParamsSchema.validate(req.query); | ||
|
||
const data = await getEvmCollectiblesMetadata(walletAddress, chainId); | ||
const data = await getEvmCollectiblesMetadata(walletAddress, chainId); | ||
|
||
res.status(200).send(getStringifiedResponse(data)); | ||
}) | ||
) | ||
res.status(200).send(data); | ||
}) | ||
) | ||
.get( | ||
'/transactions', | ||
withCodedExceptionHandler(async (req, res) => { | ||
const { walletAddress, chainId, page } = await evmQueryParamsPaginatedSchema.validate(req.query); | ||
|
||
const data = await getEvmAccountTransactions(walletAddress, chainId, page); | ||
|
||
res.status(200).send(data); | ||
}) | ||
) | ||
.get( | ||
'/erc20-transfers', | ||
withCodedExceptionHandler(async (req, res) => { | ||
const { walletAddress, chainId, contractAddress, page } = await evmQueryParamsTransfersSchema.validate(req.query); | ||
|
||
const data = await getEvmAccountERC20Transfers(walletAddress, chainId, contractAddress, page); | ||
|
||
res.status(200).send(data); | ||
}) | ||
); |
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.