-
Notifications
You must be signed in to change notification settings - Fork 2.2k
add aave and tokenAllowance passthroughs #4130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import express from 'express'; | ||
| import * as Types from '../../types/expressapp'; | ||
|
|
||
| interface AaveRouterOpts { | ||
| returnError: Types.ReturnErrorFn; | ||
| getServerWithAuth: Types.GetServerWithAuthFn; | ||
| } | ||
|
|
||
| export class AaveRouter { | ||
| router: express.Router; | ||
|
|
||
| constructor(params: AaveRouterOpts) { | ||
| const { returnError, getServerWithAuth } = params; | ||
| const router = express.Router(); | ||
|
|
||
| router.post('/v1/service/aave/userAccountData', (req, res) => { | ||
| getServerWithAuth(req, res, async server => { | ||
| try { | ||
| const accountData = await server.getAaveUserAccountData(req.body); | ||
| res.json(accountData); | ||
| } catch (err) { | ||
| returnError(err, res, req); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| router.post('/v1/service/aave/reserveData', (req, res) => { | ||
| getServerWithAuth(req, res, async server => { | ||
| try { | ||
| const reserveData = await server.getAaveReserveData(req.body); | ||
| res.json(reserveData); | ||
| } catch (err) { | ||
| returnError(err, res, req); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| router.post('/v1/service/aave/reserveTokensAddresses', (req, res) => { | ||
| getServerWithAuth(req, res, async server => { | ||
| try { | ||
| const tokensAddresses = await server.getAaveReserveTokensAddresses(req.body); | ||
| res.json(tokensAddresses); | ||
| } catch (err) { | ||
| returnError(err, res, req); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| this.router = router; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2559,6 +2559,62 @@ export class WalletService implements IWalletService { | |
| }); | ||
| } | ||
|
|
||
| getTokenAllowance(opts) { | ||
| const bc = this._getBlockchainExplorer(opts.chain || Defaults.EVM_CHAIN, opts.network); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should add some validation to opts, and maybe a param type or at least JSDoc to this fn as well. Something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added input validation and JSDocs on relevant methods |
||
| return new Promise((resolve, reject) => { | ||
| if (!bc) return reject(new Error('Could not get blockchain explorer instance')); | ||
| bc.getTokenAllowance(opts, (err, allowance) => { | ||
| if (err) { | ||
| this.logw('Error getting token allowance:', err); | ||
| return reject(err); | ||
| } | ||
| return resolve(allowance); | ||
|
tmcollins4 marked this conversation as resolved.
|
||
| }); | ||
| }); | ||
| } | ||
|
|
||
| getAaveUserAccountData(opts) { | ||
| const bc = this._getBlockchainExplorer(opts.chain || Defaults.EVM_CHAIN, opts.network); | ||
| return new Promise((resolve, reject) => { | ||
| if (!bc) return reject(new Error('Could not get blockchain explorer instance')); | ||
| bc.getAaveUserAccountData(opts, (err, accountData) => { | ||
| if (err) { | ||
| this.logw('Error getting Aave user account data:', err); | ||
| return reject(err); | ||
| } | ||
| return resolve(accountData); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| getAaveReserveData(opts) { | ||
| const bc = this._getBlockchainExplorer(opts.chain || Defaults.EVM_CHAIN, opts.network); | ||
| return new Promise((resolve, reject) => { | ||
| if (!bc) return reject(new Error('Could not get blockchain explorer instance')); | ||
| bc.getAaveReserveData(opts, (err, reserveData) => { | ||
| if (err) { | ||
| this.logw('Error getting Aave reserve data:', err); | ||
| return reject(err); | ||
| } | ||
| return resolve(reserveData); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| getAaveReserveTokensAddresses(opts) { | ||
| const bc = this._getBlockchainExplorer(opts.chain || Defaults.EVM_CHAIN, opts.network); | ||
| return new Promise((resolve, reject) => { | ||
| if (!bc) return reject(new Error('Could not get blockchain explorer instance')); | ||
| bc.getAaveReserveTokensAddresses(opts, (err, tokensAddresses) => { | ||
| if (err) { | ||
| this.logw('Error getting Aave reserve tokens addresses:', err); | ||
| return reject(err); | ||
| } | ||
| return resolve(tokensAddresses); | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| getMultisigTxpsInfo(opts) { | ||
| const bc = this._getBlockchainExplorer(opts.chain || Defaults.EVM_CHAIN, opts.network); | ||
| return new Promise((resolve, reject) => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.