ripple-binary-codec
Advanced tools
Comparing version 0.3.0-rc1 to 1.0.0-mpt-beta
{ | ||
"name": "ripple-binary-codec", | ||
"version": "0.3.0-rc1", | ||
"version": "1.0.0-mpt-beta", | ||
"description": "XRP Ledger binary codec", | ||
"files": [ | ||
"distrib/npm/*", | ||
"bin/*", | ||
"test/*" | ||
"dist/*", | ||
"src/*" | ||
], | ||
"main": "distrib/npm/", | ||
"main": "dist/", | ||
"directories": { | ||
@@ -15,39 +14,35 @@ "test": "test" | ||
"dependencies": { | ||
"babel-runtime": "^6.6.1", | ||
"bn.js": "^4.11.3", | ||
"create-hash": "^1.1.2", | ||
"decimal.js": "^5.0.8", | ||
"inherits": "^2.0.1", | ||
"lodash": "^4.17.15", | ||
"ripple-address-codec": "^3.0.4" | ||
"@xrplf/isomorphic": "^1.0.0", | ||
"bignumber.js": "^9.0.0", | ||
"ripple-address-codec": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.8.0", | ||
"babel-core": "^6.8.0", | ||
"babel-eslint": "^10.0.2", | ||
"babel-loader": "^6.2.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-register": "^6.8.0", | ||
"eslint": "^4.18.2", | ||
"fs-extra": "^0.30.0", | ||
"intercept-stdout": "^0.1.2", | ||
"istanbul": "~0.4.3", | ||
"mocha": "~6.2.0" | ||
}, | ||
"scripts": { | ||
"compile": "babel --optional runtime -d distrib/npm/ src/ && cp src/enums/definitions.json distrib/npm/enums", | ||
"prepublish": "npm test && npm run lint && npm run compile", | ||
"test": "istanbul test _mocha", | ||
"lint": "if ! [ -f eslintrc ]; then curl -o eslintrc 'https://raw.githubusercontent.com/ripple/javascript-style-guide/es6/eslintrc'; echo 'parser: babel-eslint' >> eslintrc; fi; eslint -c eslintrc src/**/*.js test/*.js examples/*.js" | ||
"build": "tsc --build tsconfig.build.json && copyfiles ./src/enums/definitions.json ./dist/enums/", | ||
"clean": "rm -rf ./dist ./coverage ./test/testCompiledForWeb tsconfig.build.tsbuildinfo", | ||
"prepublishOnly": "npm test", | ||
"test": "npm run build && jest --verbose false --silent=false ./test/*.test.ts", | ||
"test:browser": "npm run build && karma start ./karma.config.js", | ||
"lint": "eslint . --ext .ts --ext .test.js" | ||
}, | ||
"keywords": [ | ||
"ripple", | ||
"xrp", | ||
"xrp ledger", | ||
"xrpl" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/ripple/ripple-binary-codec.git" | ||
"url": "git@github.com:XRPLF/xrpl.js.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/ripple/ripple-binary-codec/issues" | ||
"url": "https://github.com/XRPLF/xrpl.js/issues" | ||
}, | ||
"homepage": "https://github.com/ripple/ripple-binary-codec#readme", | ||
"homepage": "https://github.com/XRPLF/xrpl.js/tree/main/packages/ripple-binary-codec#readme", | ||
"license": "ISC", | ||
"readmeFilename": "README.md" | ||
"readmeFilename": "README.md", | ||
"prettier": "@xrplf/prettier-config", | ||
"engines": { | ||
"node": ">= 16" | ||
}, | ||
"gitHead": "a9d5a9bf98cc25ebd788f6c02a64f82c20b5b06a" | ||
} |
106
README.md
@@ -1,5 +0,107 @@ | ||
# ripple-binary-codec | ||
# ripple-binary-codec [![NPM](https://img.shields.io/npm/v/ripple-binary-codec.svg)](https://npmjs.org/package/ripple-binary-codec) | ||
encode/decode to/from the ripple binary serialization format | ||
Functions to encode/decode to/from the ripple [binary serialization format](https://xrpl.org/serialization.html) | ||
[![NPM](https://nodei.co/npm/ripple-binary-codec.png)](https://www.npmjs.org/package/ripple-binary-codec) | ||
## API | ||
```js | ||
> const api = require('ripple-binary-codec') | ||
``` | ||
### decode(binary: string): object | ||
Decode a hex-string into a transaction object. | ||
```js | ||
> api.decode('1100612200000000240000000125000000072D0000000055DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF6240000002540BE4008114D0F5430B66E06498D4CEEC816C7B3337F9982337') | ||
{ | ||
LedgerEntryType: 'AccountRoot', | ||
Flags: 0, | ||
Sequence: 1, | ||
PreviousTxnLgrSeq: 7, | ||
OwnerCount: 0, | ||
PreviousTxnID: 'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF', | ||
Balance: '10000000000', | ||
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv' | ||
} | ||
``` | ||
### encode(json: object): string | ||
Encode a transaction object into a hex-string. Note that encode filters out fields with undefined values. | ||
```js | ||
> api.encode({ | ||
LedgerEntryType: 'AccountRoot', | ||
Flags: 0, | ||
Sequence: 1, | ||
PreviousTxnLgrSeq: 7, | ||
OwnerCount: 0, | ||
PreviousTxnID: 'DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF', | ||
Balance: '10000000000', | ||
Account: 'rLs1MzkFWCxTbuAHgjeTZK4fcCDDnf2KRv' | ||
}) | ||
'1100612200000000240000000125000000072D0000000055DF530FB14C5304852F20080B0A8EEF3A6BDD044F41F4EBBD68B8B321145FE4FF6240000002540BE4008114D0F5430B66E06498D4CEEC816C7B3337F9982337' | ||
``` | ||
#### X-Address Compatibility | ||
* ripple-binary-codec handles X-addresses by looking for a few specific files (Account/SourceTag, Destination/DestinationTag). | ||
* If other fields (in the future) must to support X-addresses with tags, this library will need to be updated. | ||
* When decoding rippled binary, the output will always output classic address + tag, with no X-addresses. X-address support only applies when encoding to binary. | ||
#### Encoding Currency Codes | ||
* The standard format for currency codes is a three-letter string such as `USD`. This is intended for use with ISO 4217 Currency Codes. | ||
* Currency codes must be exactly 3 ASCII characters in length and there are [a few other rules](https://xrpl.org/currency-formats.html#currency-codes). | ||
* ripple-binary-codec allows any 3-character ASCII string to be encoded as a currency code, although rippled may enforce tighter restrictions. | ||
* When _decoding_, if a currency code is three uppercase letters or numbers (`/^[A-Z0-9]{3}$/`), then it will be decoded into that string. For example,`0000000000000000000000004142430000000000` decodes as `ABC`. | ||
* When decoding, if a currency code is does not match the regex, then it is not considered to be an ISO 4217 or pseudo-ISO currency. ripple-binary-codec will return a 160-bit hex-string (40 hex characters). For example, `0000000000000000000000006142430000000000` (`aBC`) decodes as `0000000000000000000000006142430000000000` because it contains a lowercase letter. | ||
### encodeForSigning(json: object): string | ||
Encode the transaction object for signing. | ||
### encodeForSigningClaim(json: object): string | ||
Encode the transaction object for payment channel claim. | ||
### encodeForMultisigning(json: object, signer: string): string | ||
Encode the transaction object for multi-signing. | ||
### encodeQuality(value: string): string | ||
```js | ||
> api.encodeQuality('195796912.5171664') | ||
'5D06F4C3362FE1D0' | ||
``` | ||
### decodeQuality(value: string): string | ||
```js | ||
> api.decodeQuality('5D06F4C3362FE1D0') | ||
'195796912.5171664' | ||
``` | ||
### decodeLedgerData(binary: string): object | ||
```js | ||
> api.decodeLedgerData("01E91435016340767BF1C4A3EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F873B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D521276CDE21276CE60A00") | ||
{ | ||
ledger_index: 32052277, | ||
total_coins: '99994494362043555', | ||
parent_hash: 'EACEB081770D8ADE216C85445DD6FB002C6B5A2930F2DECE006DA18150CB18F6', | ||
transaction_hash: 'DD33F6F0990754C962A7CCE62F332FF9C13939B03B864117F0BDA86B6E9B4F87', | ||
account_hash: '3B5C3E520634D343EF5D9D9A4246643D64DAD278BA95DC0EAC6EB5350CF970D5', | ||
parent_close_time: 556231902, | ||
close_time: 556231910, | ||
close_time_resolution: 10, | ||
close_flags: 0 | ||
} | ||
``` | ||
## Tests | ||
Run unit tests with: | ||
npm test | ||
Use `--coverage` to generate and display code coverage information: | ||
npm test --coverage | ||
This tells jest to output code coverage info in the `./coverage` directory, in addition to showing it on the command line. |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
948830
3
0
290
25453
108
0
2
+ Added@xrplf/isomorphic@^1.0.0
+ Addedbignumber.js@^9.0.0
+ Added@noble/hashes@1.4.0(transitive)
+ Added@scure/base@1.1.6(transitive)
+ Added@xrplf/isomorphic@1.0.1(transitive)
+ Addedbignumber.js@9.1.2(transitive)
+ Addedeventemitter3@5.0.1(transitive)
+ Addedripple-address-codec@5.0.0(transitive)
+ Addedws@8.17.0(transitive)
- Removedbabel-runtime@^6.6.1
- Removedbn.js@^4.11.3
- Removedcreate-hash@^1.1.2
- Removeddecimal.js@^5.0.8
- Removedinherits@^2.0.1
- Removedlodash@^4.17.15
- Removedbabel-runtime@6.26.0(transitive)
- Removedbase-x@3.0.4(transitive)
- Removedbn.js@4.12.0(transitive)
- Removedcipher-base@1.0.4(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removeddecimal.js@5.0.8(transitive)
- Removedhash-base@3.1.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlodash@4.17.21(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedripple-address-codec@3.0.4(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsha.js@2.4.11(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedripple-address-codec@^5.0.0