forked from interledgerjs/ilp-connector
-
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.
First step for creating a layered architecture for connector interledger-deprecated/five-bells-ledger#112
- Loading branch information
Alan Cohen
committed
Mar 11, 2016
1 parent
f95b0fd
commit 7fbd757
Showing
10 changed files
with
238 additions
and
181 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
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,20 @@ | ||
'use strict' | ||
|
||
const config = require('../services/config') | ||
|
||
function getMetadata () { | ||
return { | ||
public_key: config.getIn(['keys', 'ed25519', 'public']), | ||
urls: { | ||
health: '/health', | ||
pairs: '/pairs', | ||
payment: '/payments/:uuid', | ||
quote: '/quote', | ||
notifications: '/notifications' | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
getMetadata: getMetadata | ||
} |
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,13 @@ | ||
'use strict' | ||
|
||
const Payments = require('../services/payments') | ||
|
||
function * processNotification (notification) { | ||
if (notification.event === 'transfer.update') { | ||
yield Payments.updateTransfer(notification.resource, notification.related_resources) | ||
} | ||
} | ||
|
||
module.exports = { | ||
processNotification: processNotification | ||
} |
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,22 @@ | ||
'use strict' | ||
|
||
const config = require('../services/config') | ||
|
||
function getPairs () { | ||
const tradingPairs = config.get('tradingPairs') | ||
return tradingPairs.map((pair) => { | ||
const currencies = pair.map(function (currencyLedgerString) { | ||
return currencyLedgerString.split('@') | ||
}) | ||
return { | ||
source_asset: currencies[0][0], | ||
source_ledger: currencies[0][1], | ||
destination_asset: currencies[1][0], | ||
destination_ledger: currencies[1][1] | ||
} | ||
}) | ||
} | ||
|
||
module.exports = { | ||
getPairs: getPairs | ||
} |
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,22 @@ | ||
'use strict' | ||
|
||
const _ = require('lodash') | ||
const paymentsService = require('../services/payments') | ||
const settlementQueue = require('../services/settlementQueue') | ||
|
||
function * create (paymentData) { | ||
const payment = _.cloneDeep(paymentData) | ||
|
||
yield paymentsService.validate(payment) | ||
const trustedPayment = settlementQueue.storePayment(payment) | ||
if (trustedPayment) { | ||
yield paymentsService.settle(trustedPayment) | ||
return trustedPayment | ||
} | ||
|
||
return payment | ||
} | ||
|
||
module.exports = { | ||
create: create | ||
} |
Oops, something went wrong.