Compare commits

...
3 Commits
Author SHA1 Message Date
Chris Troutner 524da532e2 Merge pull request #85 from Permissionless-Software-Foundation/fix/generateBurnOpReturn-tokenQty
fix(generateBurnOpReturn): Added handler when burning amount is higher than token amount
2021-01-16 11:14:42 -08:00
Gary Nadir aef56c5c14 fix(generateBurnOpReturn): Added handler when burning amount is higher than token amount 2021-01-16 14:22:02 -04:00
Chris Troutner 2472dc3606 Updating bch-api paths to v4 in readme 2021-01-09 15:48:02 -08:00
3 changed files with 12 additions and 7 deletions
+4 -4
View File
@@ -35,15 +35,15 @@ const BCHJS = require("@psf/bch-js")
let bchjs = new BCHJS() // Defaults to BCHN network.
// testnet
bchjs = new BCHJS({ restURL: 'https://testnet3.fullstack.cash/v3/' })
bchjs = new BCHJS({ restURL: 'https://testnet3.fullstack.cash/v4/' })
```
This library is intended to be paired with
the [bch-api](https://github.com/Permissionless-Software-Foundation/bch-api) REST API, and the infrastructure provided by [FullStack.cash](https://fullstack.cash). The `restURL` property can be changed to work with different Bitcoin Cash networks:
- BCHN Mainnet REST API server: https://bchn.fullstack.cash/v3/
- ABC Mainnet REST API server: https://abc.fullstack.cash/v3/
- Testnet3 REST API server: https://testnet3.fullstack.cash/v3/
- BCHN Mainnet REST API server: https://bchn.fullstack.cash/v4/
- ABC Mainnet REST API server: https://abc.fullstack.cash/v4/
- Testnet3 REST API server: https://testnet3.fullstack.cash/v4/
- Check server status: https://metrics.fullstack.cash
### API Key
+6 -1
View File
@@ -220,7 +220,12 @@ class TokenType1 {
// Calculate the total amount of tokens owned by the wallet.
let totalTokens = 0
for (let i = 0; i < tokenUtxos.length; i++) {
totalTokens += tokenUtxos[i].tokenQty
totalTokens += parseFloat(tokenUtxos[i].tokenQty)
}
// Make sure burn quantity isn't bigger than the total amount in tokens
if (burnQty > totalTokens) {
burnQty = totalTokens
}
const remainder = totalTokens - burnQty
+2 -2
View File
@@ -1217,11 +1217,11 @@ describe('#SLP TokenType1', () => {
tokenDocumentUrl: '',
tokenDocumentHash: '',
decimals: 8,
tokenQty: 7
tokenQty: '7'
}
]
const result = bchjs.SLP.TokenType1.generateBurnOpReturn(tokenUtxos, 1)
const result = bchjs.SLP.TokenType1.generateBurnOpReturn(tokenUtxos, 8)
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
// console.log(`result: `, result)