mirror of
https://github.com/Permissionless-Software-Foundation/ipfs-bch-wallet-consumer.git
synced 2026-09-21 16:52:03 -07:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fc384909e | ||
|
|
9a8d0a6ec1 | ||
|
|
9e14e24eb4 | ||
|
|
1eb68c9ea5 | ||
|
|
c26ad11290 | ||
|
|
00a7b78fde | ||
|
|
9d80341357 | ||
|
|
00b76226ec | ||
|
|
f0552bce32 | ||
|
|
4aa7de253d |
Vendored
+2
@@ -84,6 +84,8 @@ module.exports = {
|
||||
preferredProvider: process.env.PREFERRED_PROVIDER
|
||||
? process.env.PREFERRED_PROVIDER
|
||||
: '',
|
||||
// If true, users will not be able to change the provider via a REST API call.
|
||||
freezeProvider: process.env.FREEZE_PROVIDER ? true : false,
|
||||
// : 'QmdBGB8S6sEr19gaAxJYjhRbz5ZmMiH5a1JyyMmaxcRKnY'
|
||||
// : 'QmUTx6KqYKVZbKpKxR7vGDUgZFYVvVVyEWDeCYq4GwBCff'
|
||||
// Used for development
|
||||
|
||||
Generated
+15
-14
@@ -9,12 +9,12 @@
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@psf/bch-js": "6.6.0",
|
||||
"@psf/bch-js": "6.7.1",
|
||||
"axios": "0.27.2",
|
||||
"bcryptjs": "2.4.3",
|
||||
"glob": "7.1.6",
|
||||
"ipfs": "0.62.3",
|
||||
"ipfs-coord": "8.0.5",
|
||||
"ipfs-coord": "8.0.8",
|
||||
"ipfs-http-client": "55.0.0",
|
||||
"jsonrpc-lite": "2.2.0",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
@@ -1481,9 +1481,9 @@
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@psf/bch-js": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "http://94.130.170.209:4873/@psf%2fbch-js/-/bch-js-6.6.0.tgz",
|
||||
"integrity": "sha512-623uPhQQRgf5RusRJVReAxwtSPyMygJKe/qnMBVs8ZWvjFJSr1F+mfS/U8n1dHPV/CHsrcaLUVeSy5ZchNHB6g==",
|
||||
"version": "6.7.1",
|
||||
"resolved": "http://94.130.170.209:4873/@psf%2fbch-js/-/bch-js-6.7.1.tgz",
|
||||
"integrity": "sha512-B7qGxgXQ3CtIWyGpBOUIMylBe7Y3fAZl10kDgbYIiNeHw/W5q7nhczl5it1FtqigcwekOnETMMhjZdabZ/A+pw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@chris.troutner/bip32-utils": "1.0.5",
|
||||
@@ -8840,9 +8840,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ipfs-coord": {
|
||||
"version": "8.0.5",
|
||||
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-8.0.5.tgz",
|
||||
"integrity": "sha512-V4pqR+MU290ZxFRE+Rx/7JuxR7LsOFBLuL0av3eVU5ZQWqeF/Zi9vh52zCqpp1IBCXi4QXNZGlysvm16xFDXww==",
|
||||
"version": "8.0.8",
|
||||
"resolved": "http://94.130.170.209:4873/ipfs-coord/-/ipfs-coord-8.0.8.tgz",
|
||||
"integrity": "sha512-2ivZ7dCIrpS7VBN0DohaGBYRe3bzybkGbl0lOTyNeCUhrrYniC66dAnfdCY8CmpEeXoEYsaW2hLmohz4jDHywQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "0.21.4",
|
||||
"bch-encrypt-lib": "2.0.0",
|
||||
@@ -23176,9 +23177,9 @@
|
||||
"integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA="
|
||||
},
|
||||
"@psf/bch-js": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "http://94.130.170.209:4873/@psf%2fbch-js/-/bch-js-6.6.0.tgz",
|
||||
"integrity": "sha512-623uPhQQRgf5RusRJVReAxwtSPyMygJKe/qnMBVs8ZWvjFJSr1F+mfS/U8n1dHPV/CHsrcaLUVeSy5ZchNHB6g==",
|
||||
"version": "6.7.1",
|
||||
"resolved": "http://94.130.170.209:4873/@psf%2fbch-js/-/bch-js-6.7.1.tgz",
|
||||
"integrity": "sha512-B7qGxgXQ3CtIWyGpBOUIMylBe7Y3fAZl10kDgbYIiNeHw/W5q7nhczl5it1FtqigcwekOnETMMhjZdabZ/A+pw==",
|
||||
"requires": {
|
||||
"@chris.troutner/bip32-utils": "1.0.5",
|
||||
"@psf/bip21": "2.0.1",
|
||||
@@ -28416,9 +28417,9 @@
|
||||
}
|
||||
},
|
||||
"ipfs-coord": {
|
||||
"version": "8.0.5",
|
||||
"resolved": "https://registry.npmjs.org/ipfs-coord/-/ipfs-coord-8.0.5.tgz",
|
||||
"integrity": "sha512-V4pqR+MU290ZxFRE+Rx/7JuxR7LsOFBLuL0av3eVU5ZQWqeF/Zi9vh52zCqpp1IBCXi4QXNZGlysvm16xFDXww==",
|
||||
"version": "8.0.8",
|
||||
"resolved": "http://94.130.170.209:4873/ipfs-coord/-/ipfs-coord-8.0.8.tgz",
|
||||
"integrity": "sha512-2ivZ7dCIrpS7VBN0DohaGBYRe3bzybkGbl0lOTyNeCUhrrYniC66dAnfdCY8CmpEeXoEYsaW2hLmohz4jDHywQ==",
|
||||
"requires": {
|
||||
"axios": "0.21.4",
|
||||
"bch-encrypt-lib": "2.0.0",
|
||||
|
||||
+2
-2
@@ -23,12 +23,12 @@
|
||||
},
|
||||
"repository": "Permissionless-Software-Foundation/ipfs-bch-wallet-consumer",
|
||||
"dependencies": {
|
||||
"@psf/bch-js": "6.6.0",
|
||||
"@psf/bch-js": "6.7.1",
|
||||
"axios": "0.27.2",
|
||||
"bcryptjs": "2.4.3",
|
||||
"glob": "7.1.6",
|
||||
"ipfs": "0.62.3",
|
||||
"ipfs-coord": "8.0.5",
|
||||
"ipfs-coord": "8.0.8",
|
||||
"ipfs-http-client": "55.0.0",
|
||||
"jsonrpc-lite": "2.2.0",
|
||||
"jsonwebtoken": "8.5.1",
|
||||
|
||||
@@ -211,6 +211,8 @@ class BchAdapter {
|
||||
// Query the UTXOs associated with an array of up to 20 addresses.
|
||||
async getUtxosBulk (addrs) {
|
||||
try {
|
||||
// console.log('getUtxosBulk() addrs: ', addrs)
|
||||
|
||||
// Throw an error if this IPFS node has not yet made a connection to a
|
||||
// wallet service provider.
|
||||
const selectedProvider =
|
||||
@@ -229,7 +231,7 @@ class BchAdapter {
|
||||
|
||||
const rpcData = {
|
||||
endpoint: 'utxosBulk',
|
||||
address: addrs
|
||||
addresses: addrs
|
||||
}
|
||||
|
||||
// Generate a UUID for the call.
|
||||
@@ -250,7 +252,7 @@ class BchAdapter {
|
||||
|
||||
// Wait for data to come back from the wallet service.
|
||||
const data = await this.waitForRPCResponse(rpcId)
|
||||
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
||||
// console.log(`getUtxosBulk() data: ${JSON.stringify(data, null, 2)}`)
|
||||
|
||||
return data
|
||||
} catch (err) {
|
||||
|
||||
@@ -214,6 +214,8 @@ class IpfsCoordAdapter {
|
||||
// providers. This method is called periodically by a timer-interval.
|
||||
pollForBchServices () {
|
||||
try {
|
||||
// console.log('pollForBchServices() polling for BCH service')
|
||||
|
||||
// An array of IPFS IDs of other nodes in the coordination pubsub channel.
|
||||
const peers = _this.ipfsCoord.thisNode.peerList
|
||||
// console.log(`peers: ${JSON.stringify(peers, null, 2)}`)
|
||||
@@ -255,6 +257,8 @@ class IpfsCoordAdapter {
|
||||
console.log(`---->BCH wallet service selected: ${thisPeer}`)
|
||||
}
|
||||
|
||||
// console.log('preferredProvider: ', _this.config.preferredProvider)
|
||||
|
||||
// If a preferred provider is set in the config file, then connect
|
||||
// to the preferred provider when it's discovered.
|
||||
if (
|
||||
@@ -264,6 +268,8 @@ class IpfsCoordAdapter {
|
||||
_this.state.selectedServiceProvider = thisPeer
|
||||
}
|
||||
|
||||
// console.log('selectedServiceProvider: ', _this.state.selectedServiceProvider)
|
||||
|
||||
// Check if the peer has already been added to the list of providers.
|
||||
const alreadyExists = _this.state.serviceProviders.filter(
|
||||
(x) => x === thisPeer
|
||||
|
||||
@@ -65,7 +65,7 @@ class BchRESTControllerLib {
|
||||
const providerId = ctx.request.body.provider
|
||||
|
||||
// Throw an error, if the provider has been set by an environment variable.
|
||||
if (this.config.preferredProvider) {
|
||||
if (this.config.freezeProvider) {
|
||||
throw new Error('Consumer has preferredProvider set in environment variable. Refusing to switch providers.')
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ class BchRESTControllerLib {
|
||||
const utxos = await this.adapters.bch.getUtxosBulk(addrs)
|
||||
// console.log(`utxos: ${JSON.stringify(utxos, null, 2)}`)
|
||||
|
||||
ctx.body = [utxos]
|
||||
ctx.body = utxos
|
||||
} catch (err) {
|
||||
this.handleError(ctx, err)
|
||||
}
|
||||
@@ -706,6 +706,7 @@ class BchRESTControllerLib {
|
||||
*
|
||||
* @apiExample Example usage:
|
||||
* curl -H "Content-Type: application/json" -X POST -d '{ "tokenId": "43eddfb11c9941edffb8c8815574bb0a43969a7b1de39ad14cd043eaa24fd38d" }' https://bc01-ca-bch-consumer.fullstackcash.nl/bch/getTokenData2
|
||||
* curl -H "Content-Type: application/json" -X POST -d '{ "tokenId": "43eddfb11c9941edffb8c8815574bb0a43969a7b1de39ad14cd043eaa24fd38d", "updateCache": true }' https://bc01-ca-bch-consumer.fullstackcash.nl/bch/getTokenData2
|
||||
*/
|
||||
async getTokenData2 (ctx) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user