mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
feat(p2wdb): Added endpoint to select different P2WDB provider
This commit is contained in:
Vendored
+7
-1
@@ -80,10 +80,16 @@ module.exports = {
|
|||||||
|
|
||||||
debugLevel: process.env.DEBUG_LEVEL ? parseInt(process.env.DEBUG_LEVEL) : 2,
|
debugLevel: process.env.DEBUG_LEVEL ? parseInt(process.env.DEBUG_LEVEL) : 2,
|
||||||
|
|
||||||
|
// Preferred provider running ipfs-bch-wallet-service for BCH wallet.
|
||||||
preferredProvider: process.env.PREFERRED_PROVIDER
|
preferredProvider: process.env.PREFERRED_PROVIDER
|
||||||
? process.env.PREFERRED_PROVIDER
|
? process.env.PREFERRED_PROVIDER
|
||||||
: ''
|
: '',
|
||||||
// : 'QmdBGB8S6sEr19gaAxJYjhRbz5ZmMiH5a1JyyMmaxcRKnY'
|
// : 'QmdBGB8S6sEr19gaAxJYjhRbz5ZmMiH5a1JyyMmaxcRKnY'
|
||||||
// : 'QmUTx6KqYKVZbKpKxR7vGDUgZFYVvVVyEWDeCYq4GwBCff'
|
// : 'QmUTx6KqYKVZbKpKxR7vGDUgZFYVvVVyEWDeCYq4GwBCff'
|
||||||
// Used for development
|
// Used for development
|
||||||
|
|
||||||
|
// Preferred P2WDB provider
|
||||||
|
preferredP2wdbProvider: process.env.PREFERRED_P2WDB_PROVIDER
|
||||||
|
? process.env.PREFERRED_P2WDB_PROVIDER
|
||||||
|
: ''
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -108,17 +108,17 @@ class P2wdbAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Choose the BCH wallet service to use.
|
// Choose the BCH wallet service to use.
|
||||||
// async selectProvider (providerId) {
|
async selectProvider (providerId) {
|
||||||
// try {
|
try {
|
||||||
// this.ipfs.ipfsCoordAdapter.config.preferredProvider = providerId
|
this.ipfs.ipfsCoordAdapter.config.preferredP2wdbProvider = providerId
|
||||||
//
|
|
||||||
// return true
|
return true
|
||||||
// } catch (err) {
|
} catch (err) {
|
||||||
// // console.log('createUser() error: ', err)
|
// console.log('createUser() error: ', err)
|
||||||
// wlogger.error('Error in use-cases/bch.js/getStatus()')
|
wlogger.error('Error in adapters/p2wdb/getStatus()')
|
||||||
// throw err
|
throw err
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Get the BCH balance for an array of addresses.
|
// Get the BCH balance for an array of addresses.
|
||||||
// async getBalances (addrs) {
|
// async getBalances (addrs) {
|
||||||
|
|||||||
@@ -51,23 +51,23 @@ class P2wdbRESTControllerLib {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// async postProvider (ctx) {
|
async postProvider (ctx) {
|
||||||
// try {
|
try {
|
||||||
// const providerId = ctx.request.body.provider
|
const providerId = ctx.request.body.provider
|
||||||
//
|
|
||||||
// await this.adapters.bch.selectProvider(providerId)
|
await this.adapters.p2wdb.selectProvider(providerId)
|
||||||
//
|
|
||||||
// const body = {
|
const body = {
|
||||||
// success: true
|
success: true
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// ctx.body = body
|
ctx.body = body
|
||||||
// } catch (err) {
|
} catch (err) {
|
||||||
// wlogger.error('Error in bch/controller.js/postProvider(): ')
|
wlogger.error('Error in p2wdb/controller.js/postProvider(): ', err)
|
||||||
// // ctx.throw(422, err.message)
|
// ctx.throw(422, err.message)
|
||||||
// this.handleError(ctx, err)
|
this.handleError(ctx, err)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// DRY error handler
|
// DRY error handler
|
||||||
handleError (ctx, err) {
|
handleError (ctx, err) {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class P2wdbRouter {
|
|||||||
|
|
||||||
// Define the routes and attach the controller.
|
// Define the routes and attach the controller.
|
||||||
this.router.get('/', this.getStatus)
|
this.router.get('/', this.getStatus)
|
||||||
// this.router.post('/provider', this.postProvider)
|
this.router.post('/provider', this.postProvider)
|
||||||
// this.router.post('/balance', this.postBalance)
|
// this.router.post('/balance', this.postBalance)
|
||||||
// this.router.post('/utxos', this.postUtxos)
|
// this.router.post('/utxos', this.postUtxos)
|
||||||
// this.router.post('/broadcast', this.postBroadcast)
|
// this.router.post('/broadcast', this.postBroadcast)
|
||||||
@@ -69,10 +69,10 @@ class P2wdbRouter {
|
|||||||
await _this.p2wdbRESTController.getStatus(ctx, next)
|
await _this.p2wdbRESTController.getStatus(ctx, next)
|
||||||
}
|
}
|
||||||
|
|
||||||
// async postProvider (ctx, next) {
|
async postProvider (ctx, next) {
|
||||||
// await _this.bchRESTController.postProvider(ctx, next)
|
await _this.p2wdbRESTController.postProvider(ctx, next)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// async postBalance (ctx, next) {
|
// async postBalance (ctx, next) {
|
||||||
// await _this.bchRESTController.balance(ctx, next)
|
// await _this.bchRESTController.balance(ctx, next)
|
||||||
// }
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user