simpleledger / slpjs Goto Github PK
View Code? Open in Web Editor NEWJavaScript library for Simple Ledger Protocol
Home Page: http://simpleledger.cash
JavaScript library for Simple Ledger Protocol
Home Page: http://simpleledger.cash
Commit de4960d fixed a bug that should be preventable from a unit test.
Maybe this is intended but it is unexpected for the name. I wouldn't expect this to throw on any input, and instead just return false for anything that isn't a slp address.
Example:
slpjs.Utils.isSlpAddress('lol')
Uncaught InvalidAddressError
This method should be either removed or updated.
Line 82 in 2dcd25c
is simpleBchSend function reliable to be used? I noticed it's not documented so wanted to ask if there is a reason?
I guess as far as I could understand it does not filter the utxos and should be supplied with the array item of nonSlpUtxos
from getAllSlpBalancesAndUtxos()
. Am I correct?
Trying to generate a new token fails with:
{ error: '16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)' }
I'd like to listen for token transactions using the API at slpdb
. Is this the library that would enable that? I cannot find documentation for this
This way slpjs can use the same version as your client app
I'm using a transaction very similar to the example on the Readme to send a SLP token (or NFT). The same transaction works pretty well on v0.24.0 but it will burn the NFT because there is no support for it in that version. So I upgraded to v.27.11 which by semver versioning shouldn't have any backward incompatibility but same transaction doesn't work anymore and throw this error:
Uncaught (in promise) TypeError: "list" argument must be an Array of Buffers
concat index.js:399
pushdata util.js:8
createOpReturnSend util.js:152
send tokentype1.js:7
buildSendOpReturn slptokentype1.js:50
buildSendOpReturn slp.js:128
simpleTokenSend transactionhelpers.js:90
simpleTokenSend bitboxnetwork.js:260
step bitboxnetwork.js:52
verb bitboxnetwork.js:33
__awaiter bitboxnetwork.js:27
__awaiter bitboxnetwork.js:23
simpleTokenSend bitboxnetwork.js:255
_callee2$ transactions.js:101
Babel 14
sendSlpTx transactions.js:57
Apparently the problem is with slp_mdm_1.TokenType1.send(tokenIdHex, outputQtyArray);
and new slp-mdm library because on versions before addition of this, same tx is working fine. Any ideas?
https://github.com/simpleledger/bchaddrjs already provides this.
Hi @jcramer
I'm planning to create a pull request for this project.
Since this project relies on bitbox.js which is unmaintained/deprecate.
So I was wondering if there a plan to continue to maintain this project going forward?
Thank
Getting this occasionally using Bchd trusted validator. Have to restart to fix it.
It looks like an error that fails to handle bignumber.js, but I don't know how to deal with it.
I didn't understand the relationship between slpjs and spl-mdm, so I posted it here.
git clone https://github.com/simpleledger/slpjs.git
yarn install
yarn test
lib/slptokentype1.ts:36:41 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default'.
Types have separate declarations of a private property '_isBigNumber'.
36 initialQuantity
~~~~~~~~~~~~~~~
lib/slptokentype1.ts:57:41 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default'.
57 initialQuantity
~~~~~~~~~~~~~~~
lib/slptokentype1.ts:72:52 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default[]' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default[]'.
Type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default' is not assignable to type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default'.
72 return TokenType1.send(tokenIdHex, outputQtyArray);
~~~~~~~~~~~~~~
lib/slptokentype1.ts:80:52 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default[]' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default[]'.
80 return NFT1.Child.send(tokenIdHex, outputQtyArray);
~~~~~~~~~~~~~~
lib/slptokentype1.ts:82:52 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default[]' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default[]'.
82 return NFT1.Group.send(tokenIdHex, outputQtyArray);
~~~~~~~~~~~~~~
lib/slptokentype1.ts:91:63 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default'.
91 return TokenType1.mint(tokenIdHex, batonVout, mintQuantity);
~~~~~~~~~~~~
lib/slptokentype1.ts:95:63 - error TS2345: Argument of type 'import("/Users/jasagiri/src/slpjs/node_modules/bignumber.js/bignumber").default' is not assignable to parameter of type 'import("/Users/jasagiri/src/slpjs/node_modules/slp-mdm/node_modules/bignumber.js/bignumber").default'.
95 return NFT1.Group.mint(tokenIdHex, batonVout, mintQuantity);
~~~~~~~~~~~~
Found 7 errors.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Line 81 in b509e6d
There are two issues with the bitboxnetwork.sendToken()
method.
Also, if this isn't provided where does the change go? The funding address?
I'm still investigating this issue. This GitHub Issue will be used to track the data as I uncover the root-cause. I've followed the trail to slpjs and suspect the issue I'm seeing is caused by the switch to SLPDB v1.
The slp-sdk e2e test recently started failing, with the error Could not find any SLP token UTXOs
. The error is originating from this line in the slp-sdk send()
method of the TokenType1.ts library.
That bitboxNetwork.getTokenInformation(tokenId)
call is returning a query from SLPDB with the slpTokenUtxos
property as an empty object for an address that does have a token UTXO. This is ultimately what is causing the error.
I'm not familiar with the slpjs code base. It appears to be calling Bitcore? Then makes a query SLPDB. I can't seem to follow the code at this point.
I suspect that the root cause of this issue is one of two possible sources:
I've updated slp-sdk to use the latest version slpjs (v0.24.3) with no change.
Can you remove this console.log
statement? It's bubbling up and showing in SLP SDK. Thanks.
Line 31 in bc4cd8b
One of the things I'm a stickler on is that unit tests not make network calls. The primary differences between unit and integration tests, is that unit tests do not call external services. External services need to be mocked for unit tests, and live for integration tests.
If unit tests make external calls, then any CI system relying on unit tests will fail when those services fail, and then bad things happen. The reliability of the CI system is thrown into question and the ability to push a fix fails if the CI can't pass tests and validate the PR.
I ran all tests on slpjs and they passed. But then I turned off my wifi and ran the tests again. The following tests failed:
165 passing (113ms)
12 failing
1) BitdbNetwork
getTokenInformation()
returns token information for a given valid tokenId:
Error: getaddrinfo ENOTFOUND bitdb.bch.sx bitdb.bch.sx:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
2) BitdbNetwork
getTokenInformation()
throws when tokeId is not found:
AssertionError [ERR_ASSERTION]: 'getaddrinfo ENOTFOUND bitdb.bch.sx bitdb.bch.sx:443' == 'Token not found'
+ expected - actual
-getaddrinfo ENOTFOUND bitdb.bch.sx bitdb.bch.sx:443
+Token not found
at Context.it (test/bitdbnetwork.js:36:24)
at process._tickCallback (internal/process/next_tick.js:68:7)
3) JsonRpcProxyValidator
mainnet isValidSlpTxid()
returns true for a valid SEND token transaction:
Error: getaddrinfo ENOTFOUND validate.simpleledger.info validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
4) JsonRpcProxyValidator
mainnet isValidSlpTxid()
returns false for an unknown txid:
Error: getaddrinfo ENOTFOUND validate.simpleledger.info validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
5) JsonRpcProxyValidator
mainnet isValidSlpTxid()
returns true for MINT transaction:
Error: getaddrinfo ENOTFOUND validate.simpleledger.info validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
6) JsonRpcProxyValidator
mainnet validateSlpTransactions()
works for valid SEND token transactions:
Error: getaddrinfo ENOTFOUND validate.simpleledger.info validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
7) JsonRpcProxyValidator
mainnet validateSlpTransactions()
works for invalid SEND token transactions:
Error: getaddrinfo ENOTFOUND validate.simpleledger.info validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
8) JsonRpcProxyValidator
testnet isValidSlpTxid()
returns true for a valid SEND token transaction:
Error: getaddrinfo ENOTFOUND testnet-validate.simpleledger.info testnet-validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
9) JsonRpcProxyValidator
testnet isValidSlpTxid()
returns false for an unknown txid:
Error: getaddrinfo ENOTFOUND testnet-validate.simpleledger.info testnet-validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
10) JsonRpcProxyValidator
testnet isValidSlpTxid()
returns true for MINT transaction:
Error: getaddrinfo ENOTFOUND testnet-validate.simpleledger.info testnet-validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
11) JsonRpcProxyValidator
testnet validateSlpTransactions()
works for valid SEND token transactions:
Error: getaddrinfo ENOTFOUND testnet-validate.simpleledger.info testnet-validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
12) JsonRpcProxyValidator
testnet validateSlpTransactions()
works for invalid SEND token transactions:
Error: getaddrinfo ENOTFOUND testnet-validate.simpleledger.info testnet-validate.simpleledger.info:443
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:57:26)
npm ERR! Test failed. See above for more details.
Is it possible to get a transaction into a state similar to what Vin Armani proposes with a Post Office, i.e. to get inputs and outputs of SLP signed, then serialize the transaction to hex and unserialize it server-side, add BCH inputs to pay for the fee.
I looked at buildRawSendTx
, it's nearly possible to build a tx with signed SLP inputs/outputs only, as I see it, but it seems that it'll throw Error("Transaction input BCH amount is too low. Add more BCH inputs to fund this transaction.");
, but even if that's avoidable by creating a copy of buildRawSendTx
- let's say I serialize the TX to hex, is there a way to unserialize it from hex back to TransactionBuilder at the server-side (let's assume node.js + slp) to add the BCH inputs?
Also are there plans to support Post Offices officially in slpjs?
Any guidance would be greatly appreciated! Thank you!
"validation.details!.sendOutputs!.reduce" is causing an issue as sendOutputs is null in the case of a mint/baton TX (at least in my case, connected to RPC).
Is it possible to use the util functions in this library to judge the UTXOs that I receive from other nodes? For example from BCHD or insomnia which gives you indexed UTXOs.
Creating NFT child tokens require burning already created NFT parent token. With the current slpjs
implementation and bchd
node with enabled anti-burning protection this operation failing:
Code and error message on gist.github
Reference: seems some additional data need to be filled and send to the API call
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.