@psf/bch-js 6.2.8 → 6.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -26
- package/img/donation-qr.png +0 -0
- package/package.json +1 -1
- package/src/electrumx.js +1 -1
- package/src/slp/tokentype1.js +6 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/Permissionless-Software-Foundation/bch-js/blob/master/LICENSE.md)
|
|
6
6
|
[](https://github.com/feross/standard) [](https://gitter.im/Permissionless-Software-Foundation/bch-js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
7
7
|
|
|
8
|
-
[bch-js](https://www.npmjs.com/package/@psf/bch-js) is a JavaScript npm library for creating web and mobile apps that can interact with the Bitcoin Cash (BCH) blockchains.
|
|
8
|
+
[bch-js](https://www.npmjs.com/package/@psf/bch-js) is a JavaScript npm library for creating web and mobile apps that can interact with the Bitcoin Cash (BCH) and eCash (XEC) blockchains. bch-js contains a toolbox of handy tools, and an easy API for talking with [bch-api REST API](https://github.com/Permissionless-Software-Foundation/bch-api). [FullStack.cash](https://fullstack.cash) offers paid cloud access to bch-api. You can run your own infrastructure by following documentation on [CashStack.info](https://cashstack.info).
|
|
9
9
|
|
|
10
10
|
### Quick Start Videos:
|
|
11
11
|
|
|
@@ -23,6 +23,7 @@ Here are two YouTube walk-through videos to help you get started:
|
|
|
23
23
|
- [FullStack.cash](https://fullstack.cash) - cloud-based infrastructure for application developers.
|
|
24
24
|
- [FullStack.cash Account](https://fullstack.cash/login) - Get your API key to unlock increased rate limits.
|
|
25
25
|
- [Permissionless Software Foundation](https://psfoundation.cash) - The organization that maintains this library.
|
|
26
|
+
- [CashStack.info](https://cashstack.info) - bch-js is part of the Cash Stack, a JavaScript framework for writing web 2 and web 3 business applications.
|
|
26
27
|
|
|
27
28
|
### Quick Notes
|
|
28
29
|
|
|
@@ -42,10 +43,10 @@ the [bch-api](https://github.com/Permissionless-Software-Foundation/bch-api) RES
|
|
|
42
43
|
- ABC Mainnet REST API server: https://abc.fullstack.cash/v5/
|
|
43
44
|
- Check server status: https://metrics.fullstack.cash
|
|
44
45
|
|
|
45
|
-
### API Key
|
|
46
|
+
### API Key (JWT Token)
|
|
46
47
|
|
|
47
48
|
The [bch-api](https://github.com/Permissionless-Software-Foundation/bch-api) REST API hosted by [FullStack.cash](https://fullstack.cash) uses JWT tokens to pay for increased
|
|
48
|
-
rate limits when interacting with the back end server. See [this article](https://
|
|
49
|
+
rate limits when interacting with the back end server. See [this article](https://cashstack.info) if you want to understand the system-as-a-whole. The JWT token can be fed to bch-js _implicitly_ or _explicitly_.
|
|
49
50
|
|
|
50
51
|
- Implicitly: bch-js will detect your JWT token if you set the `BCHJSTOKEN` environment variable.
|
|
51
52
|
- Explicitly: You can directly feed in the JWT token with the `apiToken` property when instantiating the library. Here is an example:
|
|
@@ -58,38 +59,25 @@ let bchjs = new BCHJS({
|
|
|
58
59
|
})
|
|
59
60
|
```
|
|
60
61
|
|
|
61
|
-
### Gatsby
|
|
62
|
+
### Gatsby & Web Apps
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
[minimal-slp-wallet](https://www.npmjs.com/package/minimal-slp-wallet) is a minimal wallet 'engine' that incorporates bch-js. It's compiled with Browserify for front end apps.
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
exports.onCreateWebpackConfig = ({ actions }) => {
|
|
67
|
-
actions.setWebpackConfig({
|
|
68
|
-
node: {
|
|
69
|
-
fs: 'empty'
|
|
70
|
-
}
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
This is because the new IPFS class in bch-js uses the fs library for uploading files, which is not supported by Gatsby.
|
|
66
|
+
[gatsby-theme-bch-wallet](https://github.com/Permissionless-Software-Foundation/gatsby-theme-bch-wallet) is a Gatsby Theme and [bch-wallet-starter](https://github.com/Permissionless-Software-Foundation/bch-wallet-starter) is a Gatsby Starter for building web wallets using minimal-slp-wallet.
|
|
76
67
|
|
|
77
|
-
|
|
68
|
+
[This gist](https://gist.github.com/christroutner/6cb9d1b615f3f9363af79723157bc434) shows how to include minimal-slp-wallet into a basic web page without using a framework.
|
|
78
69
|
|
|
79
70
|
## Features
|
|
80
71
|
|
|
81
72
|
- [ECMAScript 2017 standard JavaScript](https://en.wikipedia.org/wiki/ECMAScript#8th_Edition_-_ECMAScript_2017) used instead of TypeScript. Works
|
|
82
73
|
natively with node.js v10 or higher.
|
|
83
74
|
|
|
84
|
-
- Full SLP tokens support: bch-js has full support for all SLP token functionality, including send, mint, and genesis transactions. It also fully
|
|
75
|
+
- Full SLP tokens support: bch-js has full support for all SLP token functionality, including send, mint, and genesis transactions. It also fully supports all aspects of [non-fugible tokans (NFTs)](https://www.youtube.com/watch?v=vvlpYUx6HRs).
|
|
85
76
|
|
|
86
77
|
- [Semantic Release](https://github.com/semantic-release/semantic-release) for
|
|
87
78
|
continuous delivery using semantic versioning.
|
|
88
79
|
|
|
89
|
-
- [
|
|
90
|
-
automatically maintaining the latest, most secure dependencies.
|
|
91
|
-
|
|
92
|
-
- [IPFS uploads](https://ipfs.io) of all files and dependencies, to backup
|
|
80
|
+
- [IPFS](https://ipfs.io) and [Radicle](https://radicle.xyz) uploads of all files and dependencies, to backup
|
|
93
81
|
dependencies in case they are ever inaccessible from GitHub or npm.
|
|
94
82
|
|
|
95
83
|
## Documentation:
|
|
@@ -109,14 +97,26 @@ live in the same repository. To generate the documentation:
|
|
|
109
97
|
Have questions? Need help? Join our community support
|
|
110
98
|
[Telegram channel](https://t.me/bch_js_toolkit)
|
|
111
99
|
|
|
112
|
-
##
|
|
100
|
+
## Donate
|
|
101
|
+
|
|
102
|
+
This open source software is developed and maintained by the [Permissionless Software Foundation](https://psfoundation.cash). If this library provides value to you, please consider making a donation to support the PSF developers:
|
|
103
|
+
|
|
104
|
+
<div align="center">
|
|
105
|
+
<img src="./img/donation-qr.png" />
|
|
106
|
+
<p>bitcoincash:qqsrke9lh257tqen99dkyy2emh4uty0vky9y0z0lsr</p>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## IPFS & Radicle Releases
|
|
113
111
|
|
|
114
112
|
Copies of this repository are also published on [IPFS](https://ipfs.io).
|
|
115
113
|
|
|
116
|
-
-
|
|
114
|
+
- v6.2.10: `bafybeifsioj3ba77u2763nsyuzq53gtbdxsnqpoipvdl4immj6ytznjaoy`
|
|
115
|
+
- (with dependencies, node v14.18.2 and npm v8.8.0): `bafybeihfendd4oj6uxvvecm7sluobwwhpb5wdcxhvhmx56e667nxdncd4a`
|
|
116
|
+
|
|
117
|
+
They are also posted to the Radicle:
|
|
118
|
+
- v6.2.10: `rad:git:hnrkkroqnbfwj6uxpfjuhspoxnfm4i8e6oqwy`
|
|
117
119
|
|
|
118
120
|
## License
|
|
119
121
|
|
|
120
122
|
[MIT](LICENSE.md)
|
|
121
|
-
|
|
122
|
-
test
|
|
Binary file
|
package/package.json
CHANGED
package/src/electrumx.js
CHANGED
|
@@ -44,7 +44,7 @@ class ElectrumX {
|
|
|
44
44
|
* @apiDescription Return a list of uxtos for an address.
|
|
45
45
|
*
|
|
46
46
|
* @apiExample Example usage:
|
|
47
|
-
*
|
|
47
|
+
* (async () => {
|
|
48
48
|
* try {
|
|
49
49
|
* let utxo = await bchjs.Electrumx.utxo('bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9');
|
|
50
50
|
* console.log(utxo);
|
package/src/slp/tokentype1.js
CHANGED
|
@@ -375,6 +375,9 @@ class TokenType1 {
|
|
|
375
375
|
if (!Array.isArray(tokenUtxos)) {
|
|
376
376
|
throw new Error('tokenUtxos must be an array.')
|
|
377
377
|
}
|
|
378
|
+
if (!mintQty) {
|
|
379
|
+
throw new Error('mintQty must be a positive number.')
|
|
380
|
+
}
|
|
378
381
|
|
|
379
382
|
// Loop through the tokenUtxos array and find the minting baton.
|
|
380
383
|
let mintBatonUtxo
|
|
@@ -395,7 +398,7 @@ class TokenType1 {
|
|
|
395
398
|
if (!tokenId) {
|
|
396
399
|
throw new Error('tokenId property not found in mint-baton UTXO.')
|
|
397
400
|
}
|
|
398
|
-
if (!decimals) {
|
|
401
|
+
if (!decimals && decimals !== 0) {
|
|
399
402
|
throw new Error('decimals property not found in mint-baton UTXO.')
|
|
400
403
|
}
|
|
401
404
|
|
|
@@ -404,6 +407,8 @@ class TokenType1 {
|
|
|
404
407
|
baseQty = Math.floor(baseQty)
|
|
405
408
|
baseQty = baseQty.toString()
|
|
406
409
|
|
|
410
|
+
if (isNaN(baseQty)) throw new Error('baseQty is non a number!')
|
|
411
|
+
|
|
407
412
|
// Signal that the baton should be passed or detroyed.
|
|
408
413
|
let batonVout = 2
|
|
409
414
|
if (destroyBaton) batonVout = null
|