-
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.
#17 able to get balance info from public key
- Loading branch information
Showing
9 changed files
with
1,241 additions
and
1,150 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,20 @@ | ||
// import { Request, Response, RequestHandler, Router } from 'express' | ||
// import * as request from 'request' | ||
|
||
// export const apiPath = '/account' | ||
|
||
|
||
|
||
// export default (ticketingSystem): RequestHandler => { | ||
|
||
// const router = Router() | ||
|
||
// const getAccountInfoRequestHandler = (req: Request, res: Response) => { | ||
// const accountId = req.params.accountId | ||
|
||
// return ticketingSystem.getStellarAccountInfo(accountId) | ||
// } | ||
|
||
// router.use('/:accountId', getAccountInfoRequestHandler) | ||
// return router | ||
// } |
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
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,36 @@ | ||
import { HrtimeMarker } from '../utils/hrtimeMarker' | ||
import { Keypair } from 'stellar-sdk' | ||
|
||
const isValidStellarPublicKey = (key) => { | ||
try { | ||
Keypair.fromPublicKey(key) | ||
return true | ||
} catch (error) { | ||
return false | ||
} | ||
} | ||
|
||
export default (stellarWrapper, messagingProvider, messageFormatterProvider) => { | ||
const sendWelcomeMessage = require('./sendWelcomeMessageHandler').default(messagingProvider, messageFormatterProvider) | ||
|
||
return async (isNewSession, { requestSource, from, languageCode, queryText }, ) => { | ||
const hrMarker = HrtimeMarker.create('unknownEvent') | ||
try { | ||
const formatter = messageFormatterProvider.get(requestSource) | ||
const messageSender = messagingProvider.get(requestSource) | ||
|
||
if (isValidStellarPublicKey(queryText)) { | ||
const accountInfo = await stellarWrapper.getBalanceInfo(queryText) | ||
messageSender.sendCustomMessages(from, formatter.balanceInfoTemplate(accountInfo)) | ||
return true | ||
} else if (isNewSession) { | ||
sendWelcomeMessage({ requestSource, from, languageCode }) | ||
return true | ||
} | ||
|
||
return false | ||
} finally { | ||
hrMarker.end().log() | ||
} | ||
} | ||
} |