From 83de2903b628ec0993a6299eef95fc31a020f18d Mon Sep 17 00:00:00 2001 From: luleigreat Date: Thu, 5 Jul 2018 10:08:57 +0800 Subject: [PATCH] idac changes --- Gulpfile.js | 2 +- HISTORY.md | 22 +- LICENSE | 2 +- README.md | 16 +- docs/index.md | 240 +++++++++--------- docs/samples/balances.js | 4 +- docs/samples/cancelall.js | 4 +- docs/samples/payment.js | 8 +- docs/src/basictypes.md.ejs | 18 +- docs/src/boilerplate.md.ejs | 18 +- docs/src/connect.md.ejs | 2 +- docs/src/disconnect.md.ejs | 2 +- docs/src/generateAddress.md.ejs | 2 +- docs/src/getFee.md.ejs | 4 +- docs/src/getServerInfo.md.ejs | 2 +- docs/src/introduction.md.ejs | 12 +- docs/src/isConnected.md.ejs | 2 +- docs/src/offline.md.ejs | 10 +- docs/src/transactions.md.ejs | 14 +- package-lock.json | 170 ++++++------- package.json | 20 +- scripts/sauce-runner.js | 2 +- src/api.js | 8 +- src/broadcast.js | 14 +- src/common/connection.js | 8 +- src/common/constants.js | 12 +- src/common/errors.js | 26 +- src/common/index.js | 8 +- src/common/schema-validator.js | 2 +- .../schemas/input/get-balance-sheet.json | 2 +- src/common/schemas/input/get-orders.json | 2 +- src/common/schemas/input/get-paths.json | 2 +- .../input/sign-payment-channel-claim.json | 2 +- .../input/verify-payment-channel-claim.json | 2 +- src/common/schemas/objects/address.json | 2 +- src/common/schemas/objects/amount-base.json | 6 +- src/common/schemas/objects/amount.json | 2 +- src/common/schemas/objects/balance.json | 6 +- src/common/schemas/objects/currency.json | 2 +- src/common/schemas/objects/issue.json | 2 +- src/common/schemas/objects/settings.json | 8 +- src/common/schemas/objects/tag.json | 2 +- .../schemas/output/generate-address.json | 2 +- .../schemas/output/get-account-info.json | 6 +- src/common/schemas/output/get-ledger.json | 2 +- .../schemas/output/get-payment-channel.json | 8 +- .../schemas/output/get-server-info.json | 16 +- src/common/schemas/output/ledger-event.json | 14 +- src/common/schemas/output/outcome.json | 2 +- .../specifications/escrow-creation.json | 4 +- .../specifications/payment-channel-claim.json | 4 +- .../payment-channel-create.json | 6 +- .../specifications/payment-channel-fund.json | 2 +- .../schemas/specifications/payment.json | 4 +- src/common/serverinfo.js | 24 +- src/common/txflags.js | 16 +- src/common/types.js | 6 +- src/common/utils.js | 30 +-- src/http.js | 10 +- src/index.js | 4 +- src/ledger/accountinfo.js | 4 +- src/ledger/balances.js | 14 +- src/ledger/parse/account-order.js | 2 +- src/ledger/parse/amount.js | 8 +- src/ledger/parse/fee-update.js | 8 +- src/ledger/parse/flags.js | 4 +- src/ledger/parse/orderbook-order.js | 2 +- src/ledger/parse/pathfind.js | 8 +- src/ledger/parse/payment-channel.js | 4 +- src/ledger/parse/payment.js | 6 +- src/ledger/parse/trustline.js | 2 +- src/ledger/parse/utils.js | 16 +- src/ledger/pathfind-types.js | 12 +- src/ledger/pathfind.js | 50 ++-- src/ledger/settings.js | 4 +- src/ledger/transaction-types.js | 6 +- src/ledger/transactions.js | 4 +- src/ledger/utils.js | 8 +- src/offline/generate-address.js | 2 +- src/offline/ledgerhash.js | 6 +- src/offline/sign-payment-channel-claim.js | 8 +- src/offline/verify-payment-channel-claim.js | 8 +- src/server/server.js | 6 +- src/transaction/combine.js | 6 +- src/transaction/escrow-creation.js | 8 +- src/transaction/order.js | 8 +- src/transaction/payment-channel-claim.js | 6 +- src/transaction/payment-channel-create.js | 6 +- src/transaction/payment-channel-fund.js | 6 +- src/transaction/payment.js | 36 +-- src/transaction/settings-types.js | 12 +- src/transaction/sign.js | 6 +- src/transaction/submit.js | 2 +- src/transaction/trustline.js | 2 +- src/transaction/utils.js | 8 +- test/api-test.js | 116 ++++----- test/broadcast-api-test.js | 6 +- test/connection-test.js | 16 +- .../requests/get-orderbook-with-xrp.json | 2 +- .../requests/getpaths/xrp2xrp-not-enough.json | 2 +- test/fixtures/requests/getpaths/xrp2xrp.json | 2 +- test/fixtures/requests/index.js | 8 +- .../requests/prepare-order-expiration.json | 2 +- .../fixtures/requests/prepare-order-sell.json | 2 +- test/fixtures/requests/prepare-order.json | 2 +- .../requests/prepare-payment-all-options.json | 6 +- .../requests/prepare-payment-min-xrp.json | 2 +- .../requests/prepare-payment-min.json | 4 +- .../prepare-payment-no-counterparty.json | 2 +- .../prepare-payment-wrong-address.json | 2 +- .../prepare-payment-wrong-amount.json | 2 +- .../prepare-payment-wrong-partial.json | 4 +- test/fixtures/responses/get-account-info.json | 2 +- test/fixtures/responses/get-balances.json | 2 +- test/fixtures/responses/get-ledger-full.json | 12 +- .../get-ledger-pre2014-with-partial.json | 4 +- .../get-ledger-with-partial-payment.json | 12 +- .../get-ledger-with-settings-tx.json | 2 +- .../responses/get-orderbook-with-xrp.json | 4 +- test/fixtures/responses/get-orders.json | 4 +- .../responses/get-paths-send-all.json | 6 +- .../responses/get-paths-xrp-to-xrp.json | 4 +- test/fixtures/responses/get-paths.json | 6 +- test/fixtures/responses/get-server-info.json | 6 +- test/fixtures/responses/get-settings.json | 2 +- .../get-transaction-escrow-cancellation.json | 2 +- .../get-transaction-escrow-create.json | 2 +- ...t-transaction-escrow-execution-simple.json | 4 +- .../get-transaction-escrow-execution.json | 4 +- .../responses/get-transaction-fee-update.json | 6 +- .../responses/get-transaction-no-meta.json | 2 +- .../get-transaction-not-validated.json | 2 +- .../get-transaction-order-cancellation.json | 4 +- .../responses/get-transaction-order-sell.json | 4 +- ...on-order-with-expiration-cancellation.json | 4 +- .../responses/get-transaction-order.json | 6 +- ...get-transaction-payment-channel-claim.json | 2 +- ...et-transaction-payment-channel-create.json | 2 +- .../get-transaction-payment-channel-fund.json | 2 +- .../responses/get-transaction-payment.json | 8 +- ...-transaction-settings-set-regular-key.json | 2 +- ...get-transaction-settings-tracking-off.json | 2 +- .../get-transaction-settings-tracking-on.json | 2 +- .../responses/get-transaction-settings.json | 4 +- .../get-transaction-trust-no-quality.json | 2 +- .../get-transaction-trust-set-frozen-off.json | 2 +- .../get-transaction-trustline-set.json | 2 +- .../responses/get-transactions-one.json | 2 +- test/fixtures/responses/get-transactions.json | 16 +- test/fixtures/responses/index.js | 10 +- test/fixtures/responses/ledger-event.json | 6 +- .../responses/prepare-payment-min-amount.json | 2 +- test/fixtures/rippled/account-tx.js | 6 +- test/fixtures/rippled/book-offers.js | 4 +- test/fixtures/rippled/index.js | 6 +- test/fixtures/rippled/ledger-full-38129.json | 2 +- .../rippled/ledger-pre2014-with-partial.json | 4 +- .../rippled/ledger-with-partial-payment.json | 20 +- test/fixtures/rippled/path-find-send-all.json | 10 +- test/fixtures/rippled/path-find-send-usd.json | 2 +- .../fixtures/rippled/path-find-srcAmtLow.json | 2 +- .../rippled/path-find-xrp-to-xrp.json | 2 +- test/fixtures/rippled/path-find.js | 26 +- .../rippled/server-info-no-validated.json | 6 +- .../fixtures/rippled/server-info-syncing.json | 6 +- test/fixtures/rippled/server-info.json | 6 +- test/fixtures/rippled/tx/payment.json | 4 +- .../rippled/tx/trust-set-frozen-off.json | 2 +- test/integration/broadcast-test.js | 4 +- test/integration/http-integration-test.js | 4 +- test/integration/integration-test.js | 22 +- test/integration/utils.js | 4 +- test/mock-rippled.js | 12 +- test/mocked-server.js | 6 +- test/rangeset-test.js | 2 +- test/setup-api-web.js | 8 +- test/setup-api.js | 28 +- 177 files changed, 850 insertions(+), 852 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index ca085241..e4001960 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -15,7 +15,7 @@ var pkg = require('./package.json'); var uglifyOptions = { mangle: { - except: ['_', 'ChainsqlError', 'ChainsqldError', 'UnexpectedError', + except: ['_', 'DacError', 'DacdError', 'UnexpectedError', 'LedgerVersionError', 'ConnectionError', 'NotConnectedError', 'DisconnectedError', 'TimeoutError', 'ResponseFormatError', 'ValidationError', 'NotFoundError', 'MissingLedgerHistoryError', diff --git a/HISTORY.md b/HISTORY.md index 055f4977..daa1f341 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -28,7 +28,7 @@ ## 0.16.0 __BREAKING CHANGES__ -+ [Fix types of ZXC values in `getServerInfo` response](https://github.com/ripple/ripple-lib/commit/99d08065e4bda3dda6ae1f183adbd11abc70a9b7) ++ [Fix types of DAC values in `getServerInfo` response](https://github.com/ripple/ripple-lib/commit/99d08065e4bda3dda6ae1f183adbd11abc70a9b7) + [Change error event format and fix crash due to error event on websocket](https://github.com/ripple/ripple-lib/commit/9cd72595f0efc062d77b9d625695d6030c524cc6) __OTHER CHANGES__ @@ -48,7 +48,7 @@ __OTHER CHANGES__ + [Fix `babel-polyfill` require](https://github.com/ripple/ripple-lib/commit/062148674c3b1293ab82c28e25615ddd530339fa) + [Fix samples](https://github.com/ripple/ripple-lib/commit/5d5cf868a2ddb1b1cd40e4a4f0a782d0066c2055) -+ [Add unit tests for `ChainsqlAPIBroadcast`](https://github.com/ripple/ripple-lib/commit/ddf8fe5b1a9c750490dca98fb9ffaaf8017f87e0) ++ [Add unit tests for `DacAPIBroadcast`](https://github.com/ripple/ripple-lib/commit/ddf8fe5b1a9c750490dca98fb9ffaaf8017f87e0) ## 0.15.0 @@ -70,7 +70,7 @@ __OTHER CHANGES__ + [Fix proxy support and add support for proxy authorization](https://github.com/ripple/ripple-lib/commit/14b840f3feca758e0384b746c94e36d8bf59b8c2) + [Fix trace option](https://github.com/ripple/ripple-lib/commit/af620755c53556c55eed12de4b0013ef5a349ce2) + [Allow memos on all transaction types](https://github.com/ripple/ripple-lib/commit/b5081344da8e66fbd3a5113cc3313325ef72a494) -+ [Add documentation for ChainsqlAPI options](https://github.com/ripple/ripple-lib/commit/a76b554cadb9f9f918b06f8386bc29355682a1a4) ++ [Add documentation for DacAPI options](https://github.com/ripple/ripple-lib/commit/a76b554cadb9f9f918b06f8386bc29355682a1a4) + [Docs: more on basic types, tx types](https://github.com/ripple/ripple-lib/commit/fdbac63f466b4fd3be701d4878800d856692e26e) + [Docs: revised introductory material](https://github.com/ripple/ripple-lib/commit/ef2515507dbd3c6a426ab5b31332a1bdf72d5b2d) + [boost coverage to almost 100%](https://github.com/ripple/ripple-lib/commit/995606b1e6f3643af34d9fd442ccd31f320b03eb) @@ -88,8 +88,8 @@ __OTHER CHANGES__ ## 0.13.0 __BREAKING CHANGES__ -+ Add new ChainsqlAPI interface and delete old API - - [ChainsqlAPI README and samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples) ++ Add new DacAPI interface and delete old API + - [DacAPI README and samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples) - [Method documentation](https://rawgit.com/ripple/ripple-lib/develop/docs/api.html) __OTHER CHANGES__ @@ -167,7 +167,7 @@ __OTHER CHANGES__ + [Fix Amount.to_human for very small numbers](https://github.com/ripple/ripple-lib/commit/6abfa759aa09d68074ac558d96c4b126a7cd1719) + [Refactor base conversion](https://github.com/ripple/ripple-lib/commit/f2b63fa4a80663eb29472bc6bb1aea8159f1f205) + [Update binary transaction format](https://github.com/ripple/ripple-lib/commit/8e134918fb4c22983320a3102f955e4568bb1dfb) -+ [Add DefaultChainsql account flag](https://github.com/ripple/ripple-lib/commit/3e249902c4cf25b4da5e75048c84ae391be83b10) ++ [Add DefaultDac account flag](https://github.com/ripple/ripple-lib/commit/3e249902c4cf25b4da5e75048c84ae391be83b10) + [Remove `Features` field requirement in `SetFee` transaction format](https://github.com/ripple/ripple-lib/commit/a20a649013646710c078d4ce1e210f87c7fe74fe) + [Remove `RegularKey` field requirement in `SetRegularKey` transaction format](https://github.com/ripple/ripple-lib/commit/c275174f27877ba8f389eb4efe969feb514d6e46) @@ -191,7 +191,7 @@ __OTHER CHANGES__ + [Fix taker_gets_funded exceeding offer.TakerGets](https://github.com/ripple/ripple-lib/commit/b19ecb4482b589d575382b7a5d0480b963383bb1) + [Fix unsymmetric memo serializing](https://github.com/ripple/ripple-lib/commit/1ed36fabdbd54f4d31078c2b0eaa3becc0fe2821) + [Fix IOU value passed to `Amount.from_json()`](https://github.com/ripple/ripple-lib/commit/fd1b64393dffb3d1819cd40b8d43df43a4db042d) -+ [Update transaction binary parsing to account for ZXC delivered amounts](https://github.com/ripple/ripple-lib/commit/35a346a674e6ee1e1e495db93700d55984efc7dd) ++ [Update transaction binary parsing to account for DAC delivered amounts](https://github.com/ripple/ripple-lib/commit/35a346a674e6ee1e1e495db93700d55984efc7dd) + [Bumped dependencies](https://github.com/ripple/ripple-lib/commit/f9bc7cc746b44b24b61bbe260ae2e9d9617286da) ## 0.11.0 @@ -241,7 +241,7 @@ are locally determined to have expired: `tejMaxLedger`. + [Add a "core" browser build of ripple-lib which has a subset of features and smaller file size](https://github.com/ripple/ripple-lib/pull/205) + [Update binformat with missing fields from rippled](https://github.com/ripple/ripple-lib/commit/cae980788efb00191bfd0988ed836d60cdf7a9a2) + [Wait for transaction validation before returning `tec` error](https://github.com/ripple/ripple-lib/commit/6bdd4b2670906588852fc4dda457607b4aac08e4) -+ [Change default `max_fee` on `Remote` to `1 ZXC`](https://github.com/ripple/ripple-lib/commit/d6b1728c23ff85c3cc791bed6982a750641fd95f) ++ [Change default `max_fee` on `Remote` to `1 DAC`](https://github.com/ripple/ripple-lib/commit/d6b1728c23ff85c3cc791bed6982a750641fd95f) + [Fix: Request ledger_accept should return the Remote](https://github.com/ripple/ripple-lib/pull/209) ## 0.9.2 @@ -325,7 +325,7 @@ __OTHER CHANGES__ + Request: `request.request()` now accepts an array of servers as first argument. Servers can be represented with URL, or the server object itself. + Request: `request.broadcast()` now returns the number of servers request was sent to + Server: Acquire host information from server without additional request -+ Amount: Add a constant for the maximum canonical value that can be expressed as a Chainsql value ++ Amount: Add a constant for the maximum canonical value that can be expressed as a Dac value + Amount: Make Constants static fields on the class, instead of a separate export ## 0.7.39 @@ -342,7 +342,7 @@ __OTHER CHANGES__ + **Deprecations** - 1. Removed humanistic amount detection in `transaction.payment`. Passing `1ZXC` as the payment amount no longer works. + 1. Removed humanistic amount detection in `transaction.payment`. Passing `1DAC` as the payment amount no longer works. 2. `remote.setServer` uses full server URL rather than hostname. Example: `remote.setServer('wss://s`.ripple.com:443')` 3. Removed constructors for deprecated transaction types from `transaction.js`. 4. Removed `invoiceID` option from `transaction.payment`. Instead, use the `transaction.invoiceID` method. @@ -358,7 +358,7 @@ __OTHER CHANGES__ parseBinary: false } ``` -+ Added full currency name support, e.g. `Currency.from_json('ZXC').to_human({full_name:'Chainsqls'})` will return `ZXC - Chainsqls` ++ Added full currency name support, e.g. `Currency.from_json('DAC').to_human({full_name:'Dacs'})` will return `DAC - Dacs` + Improved interest bearing currency support, e.g. `Currency.from_human('USD - US Dollar (2.5%pa)')` + Improve test coverage + Added blob vault client. The vault client facilitates interaction with ripple's namespace and blob vault or 3rd party blob vaults using ripple's blob vault software (https://github.com/ripple/ripple-blobvault). A list of the available functions can be found at [docs/VAULTCLIENT.md](docs/VAULTCLIENT.md) diff --git a/LICENSE b/LICENSE index 51bbc194..ad666291 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012-2015 Chainsql Labs Inc. +Copyright (c) 2012-2015 Dac Labs Inc. Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/README.md b/README.md index 5f919db7..4cb8c360 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# chainsql-lib +# dac-lib -A JavaScript API for interacting with the ZXC Ledger +A JavaScript API for interacting with the DAC Ledger [![Circle CI](https://circleci.com/gh/ripple/ripple-lib/tree/develop.svg?style=svg)](https://circleci.com/gh/ripple/ripple-lib/tree/develop) [![Coverage Status](https://coveralls.io/repos/ripple/ripple-lib/badge.png?branch=develop)](https://coveralls.io/r/ripple/ripple-lib?branch=develop) @@ -10,16 +10,16 @@ A JavaScript API for interacting with the ZXC Ledger + Connect to a `rippled` server from Node.js or a web browser + Issue [rippled API](https://ripple.com/build/rippled-apis/) requests -+ Listen to events on the ZXC Ledger (transaction, ledger, etc.) -+ Sign and submit transactions to the ZXC Ledger ++ Listen to events on the DAC Ledger (transaction, ledger, etc.) ++ Sign and submit transactions to the DAC Ledger ## Getting Started -See also: [ChainsqlAPI Beginners Guide](https://ripple.com/build/rippleapi-beginners-guide/) +See also: [DacAPI Beginners Guide](https://ripple.com/build/rippleapi-beginners-guide/) -Install `chainsql-lib` using npm: +Install `dac-lib` using npm: ``` -$ npm install chainsql-lib +$ npm install dac-lib ``` Then see the [documentation](https://github.com/ripple/ripple-lib/blob/develop/docs/index.md) and [code samples](https://github.com/ripple/ripple-lib/tree/develop/docs/samples) @@ -36,4 +36,4 @@ The continuous integration tests require that the documentation stays up-to-date ## More Information -+ [Chainsql Developer Center](https://ripple.com/build/) ++ [Dac Developer Center](https://ripple.com/build/) diff --git a/docs/index.md b/docs/index.md index 4f888c85..c38d82b1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,6 @@ -# ChainsqlAPI Reference +# DacAPI Reference - [Introduction](#introduction) - [Boilerplate](#boilerplate) @@ -77,26 +77,26 @@ # Introduction -ChainsqlAPI is the official client library to the ZXC Ledger. Currently, ChainsqlAPI is only available in JavaScript. -Using ChainsqlAPI, you can: +DacAPI is the official client library to the DAC Ledger. Currently, DacAPI is only available in JavaScript. +Using DacAPI, you can: -* [Query transactions from the ZXC Ledger history](#gettransaction) +* [Query transactions from the DAC Ledger history](#gettransaction) * [Sign](#sign) transactions securely without connecting to any server -* [Submit](#submit) transactions to the ZXC Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types) -* [Generate a new ZXC Ledger Address](#generateaddress) +* [Submit](#submit) transactions to the DAC Ledger, including [Payments](#payment), [Orders](#order), [Settings changes](#settings), and [other types](#transaction-types) +* [Generate a new DAC Ledger Address](#generateaddress) * ... and [much more](#api-methods). -ChainsqlAPI only provides access to *validated*, *immutable* transaction data. +DacAPI only provides access to *validated*, *immutable* transaction data. ## Boilerplate -Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to wrap your custom code using ChainsqlAPI. +Use the following [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to wrap your custom code using DacAPI. ```javascript -const ChainsqlAPI = require('chainsql-lib').ChainsqlAPI; +const DacAPI = require('dac-lib').DacAPI; -const api = new ChainsqlAPI({ - server: 'wss://s1.ripple.com' // Public rippled server hosted by Chainsql, Inc. +const api = new DacAPI({ + server: 'wss://s1.ripple.com' // Public rippled server hosted by Dac, Inc. }); api.on('error', (errorCode, errorMessage) => { console.log(errorCode + ': ' + errorMessage); @@ -116,9 +116,9 @@ api.connect().then(() => { }).catch(console.error); ``` -ChainsqlAPI is designed to work in [Node.js](https://nodejs.org) version **6.11.3**. ChainsqlAPI may work on older Node.js versions if you use [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support. +DacAPI is designed to work in [Node.js](https://nodejs.org) version **6.11.3**. DacAPI may work on older Node.js versions if you use [Babel](https://babeljs.io/) for [ECMAScript 6](https://babeljs.io/docs/learn-es2015/) support. -The code samples in this documentation are written with ECMAScript 6 (ES6) features, but `ChainsqlAPI` also works with ECMAScript 5 (ES5). Regardless of whether you use ES5 or ES6, the methods that return Promises return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +The code samples in this documentation are written with ECMAScript 6 (ES6) features, but `DacAPI` also works with ECMAScript 5 (ES5). Regardless of whether you use ES5 or ES6, the methods that return Promises return [ES6-style promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).