mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 20:25:51 +00:00
Fix minor typos and improve wording
This commit is contained in:
@@ -25,7 +25,7 @@ const myOrder = {
|
||||
const INTERVAL = 1000;
|
||||
/* Instantiate RippleAPI. Uses s2 (full history server) */
|
||||
const api = new RippleAPI({server: 'wss://s2.ripple.com'});
|
||||
/* number of ledgers to check for valid transaction before fail */
|
||||
/* Number of ledgers to check for valid transaction before failing */
|
||||
const ledgerOffset = 5;
|
||||
const myInstructions = {maxLedgerVersionOffset: ledgerOffset};
|
||||
|
||||
@@ -39,7 +39,7 @@ function verifyTransaction(hash, options) {
|
||||
console.log('Sequence: ', data.sequence);
|
||||
return data.outcome.result === 'tesSUCCESS';
|
||||
}).catch(error => {
|
||||
/* if transaction not in latest validated ledger,
|
||||
/* If transaction not in latest validated ledger,
|
||||
try again until max ledger hit */
|
||||
if (error instanceof api.errors.PendingLedgerVersionError) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -52,17 +52,17 @@ function verifyTransaction(hash, options) {
|
||||
}
|
||||
|
||||
|
||||
/* function to prepare, sign, and submit a transaction to the XRP Ledger
|
||||
success verifies the transaction is being considered for the next ledger.
|
||||
Still requires vlaidation */
|
||||
/* Function to prepare, sign, and submit a transaction to the XRP Ledger. */
|
||||
function submitTransaction(lastClosedLedgerVersion, prepared, secret) {
|
||||
const signedData = api.sign(prepared.txJSON, secret);
|
||||
return api.submit(signedData.signedTransaction).then(data => {
|
||||
console.log('Tentative Result: ', data.resultCode);
|
||||
console.log('Tentative Message: ', data.resultMessage);
|
||||
/* if transaction was not successfully submitted throw error */
|
||||
/* If transaction was not successfully submitted throw error */
|
||||
assert.strictEqual(data.resultCode, 'tesSUCCESS');
|
||||
/* if successfully submitted fire off validation workflow */
|
||||
/* 'tesSUCCESS' means the transaction is being considered for the next ledger, and requires validation. */
|
||||
|
||||
/* If successfully submitted, begin validation workflow */
|
||||
const options = {
|
||||
minLedgerVersion: lastClosedLedgerVersion,
|
||||
maxLedgerVersion: prepared.instructions.maxLedgerVersion
|
||||
|
||||
@@ -6,7 +6,7 @@ The scripts and configuration files used in this guide are [available in the Rip
|
||||
|
||||
# Environment Setup #
|
||||
|
||||
The first step to using RippleAPI successfully is setting up your development environment.
|
||||
The first step to using RippleAPI is setting up your development environment.
|
||||
|
||||
## Install Node.js and npm ##
|
||||
|
||||
@@ -14,7 +14,7 @@ RippleAPI is built as an application for the Node.js runtime environment, so the
|
||||
|
||||
This step depends on your operating system. We recommend [the official instructions for installing Node.js using a package manager](https://nodejs.org/en/download/package-manager/) for your operating system. If the packages for Node.js and `npm` (Node Package Manager) are separate, install both. (This applies to Arch Linux, CentOS, Fedora, and RHEL.)
|
||||
|
||||
After you have installed Node.js, you can check whether it's installed by checking the version of the `node` binary from a commandline:
|
||||
After you have installed Node.js, you can check the version of the `node` binary from a command line:
|
||||
|
||||
```
|
||||
node --version
|
||||
@@ -26,7 +26,6 @@ On some platforms, the binary is named `nodejs` instead:
|
||||
nodejs --version
|
||||
```
|
||||
|
||||
|
||||
## Use NPM to install RippleAPI and dependencies ##
|
||||
|
||||
RippleAPI uses the newest version of JavaScript, ECMAScript 6 (also known as ES2015). To use the new features of ECMAScript 6, RippleAPI depends on [Babel-Node](https://babeljs.io) and its ES2015 presets. You can use `npm` to install RippleAPI and these dependencies together.
|
||||
@@ -77,8 +76,6 @@ npm WARN notsup Not compatible with your operating system or architecture: fseve
|
||||
npm WARN ajv@1.4.10 requires a peer of ajv-i18n@0.1.x but none was installed.
|
||||
```
|
||||
|
||||
|
||||
|
||||
# First RippleAPI Script ##
|
||||
|
||||
This script, `get-account-info.js`, fetches information about a hard-coded account. Use it to test that RippleAPI works:
|
||||
@@ -89,7 +86,7 @@ This script, `get-account-info.js`, fetches information about a hard-coded accou
|
||||
|
||||
## Running the script ##
|
||||
|
||||
RippleAPI and the script both use the ECMAScript 6 version of JavaScript, which is (at this time) not supported by Node.js natively. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the `babel-node` binary, which NPM installs in the `node_modules/.bin/` directory of your project. Thus, running the script looks like this:
|
||||
RippleAPI and the script both use the ECMAScript 6 version of JavaScript. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the `babel-node` binary, which NPM installs in the `node_modules/.bin/` directory of your project. Thus, running the script looks like this:
|
||||
|
||||
```
|
||||
./node_modules/.bin/babel-node get-account-info.js
|
||||
@@ -211,15 +208,13 @@ If you are the administrator of the `rippled` server, you can [manually request
|
||||
|
||||
See [Reliable Transaction Submission](tutorial-reliable-transaction-submission.html) for a more thorough explanation.
|
||||
|
||||
|
||||
|
||||
# RippleAPI in Web Browsers #
|
||||
|
||||
RippleAPI can also be used in a web browser if you compile a browser-compatible version and include [lodash](https://www.npmjs.com/package/lodash) as a dependency before the RippleAPI script.
|
||||
|
||||
## Build Instructions ##
|
||||
|
||||
To use RippleAPI in a browser, you need to a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.
|
||||
To use RippleAPI in a browser, you need to build a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.
|
||||
|
||||
#### 1. Download a copy of the RippleAPI git repository.
|
||||
|
||||
@@ -233,7 +228,6 @@ git checkout release
|
||||
|
||||
Alternatively, you can download an archive (.zip or .tar.gz) of a specific release from the [RippleAPI releases page](https://github.com/ripple/ripple-lib/releases) and extract it.
|
||||
|
||||
|
||||
#### 2. Install dependencies using NPM
|
||||
|
||||
You need to have [NPM (Node.js Package Manager) installed](#install-nodejs-and-npm) first.
|
||||
|
||||
@@ -170,11 +170,11 @@
|
||||
<p>This tutorial guides you through the basics of building an XRP Ledger-connected application using <a href="http://nodejs.org/">Node.js</a> and <a href="reference-rippleapi.html">RippleAPI</a>, a JavaScript API for accessing the XRP Ledger.</p>
|
||||
<p>The scripts and configuration files used in this guide are <a href="https://github.com/ripple/ripple-dev-portal/tree/master/content/code_samples/rippleapi_quickstart">available in the Ripple Dev Portal GitHub Repository</a>.</p>
|
||||
<h1 id="environment-setup">Environment Setup</h1>
|
||||
<p>The first step to using RippleAPI successfully is setting up your development environment.</p>
|
||||
<p>The first step to using RippleAPI is setting up your development environment.</p>
|
||||
<h2 id="install-nodejs-and-npm">Install Node.js and npm</h2>
|
||||
<p>RippleAPI is built as an application for the Node.js runtime environment, so the first step is getting Node.js installed. RippleAPI requires Node.js version 0.12, version 4.x, or higher.</p>
|
||||
<p>This step depends on your operating system. We recommend <a href="https://nodejs.org/en/download/package-manager/">the official instructions for installing Node.js using a package manager</a> for your operating system. If the packages for Node.js and <code>npm</code> (Node Package Manager) are separate, install both. (This applies to Arch Linux, CentOS, Fedora, and RHEL.)</p>
|
||||
<p>After you have installed Node.js, you can check whether it's installed by checking the version of the <code>node</code> binary from a commandline:</p>
|
||||
<p>After you have installed Node.js, you can check the version of the <code>node</code> binary from a command line:</p>
|
||||
<pre><code>node --version
|
||||
</code></pre>
|
||||
<p>On some platforms, the binary is named <code>nodejs</code> instead:</p>
|
||||
@@ -253,7 +253,7 @@ api.connect().then(() => {
|
||||
}).catch(console.error);
|
||||
</code></pre>
|
||||
<h2 id="running-the-script">Running the script</h2>
|
||||
<p>RippleAPI and the script both use the ECMAScript 6 version of JavaScript, which is (at this time) not supported by Node.js natively. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the <code>babel-node</code> binary, which NPM installs in the <code>node_modules/.bin/</code> directory of your project. Thus, running the script looks like this:</p>
|
||||
<p>RippleAPI and the script both use the ECMAScript 6 version of JavaScript. That's why we installed Babel earlier. The easiest way to run ECMAScript 6 is to use the <code>babel-node</code> binary, which NPM installs in the <code>node_modules/.bin/</code> directory of your project. Thus, running the script looks like this:</p>
|
||||
<pre><code>./node_modules/.bin/babel-node get-account-info.js
|
||||
</code></pre>
|
||||
<p>Output:</p>
|
||||
@@ -351,7 +351,7 @@ const myOrder = {
|
||||
const INTERVAL = 1000;
|
||||
/* Instantiate RippleAPI. Uses s2 (full history server) */
|
||||
const api = new RippleAPI({server: 'wss://s2.ripple.com'});
|
||||
/* number of ledgers to check for valid transaction before fail */
|
||||
/* Number of ledgers to check for valid transaction before failing */
|
||||
const ledgerOffset = 5;
|
||||
const myInstructions = {maxLedgerVersionOffset: ledgerOffset};
|
||||
|
||||
@@ -365,7 +365,7 @@ function verifyTransaction(hash, options) {
|
||||
console.log('Sequence: ', data.sequence);
|
||||
return data.outcome.result === 'tesSUCCESS';
|
||||
}).catch(error => {
|
||||
/* if transaction not in latest validated ledger,
|
||||
/* If transaction not in latest validated ledger,
|
||||
try again until max ledger hit */
|
||||
if (error instanceof api.errors.PendingLedgerVersionError) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -378,17 +378,17 @@ function verifyTransaction(hash, options) {
|
||||
}
|
||||
|
||||
|
||||
/* function to prepare, sign, and submit a transaction to the XRP Ledger
|
||||
success verifies the transaction is being considered for the next ledger.
|
||||
Still requires vlaidation */
|
||||
/* Function to prepare, sign, and submit a transaction to the XRP Ledger. */
|
||||
function submitTransaction(lastClosedLedgerVersion, prepared, secret) {
|
||||
const signedData = api.sign(prepared.txJSON, secret);
|
||||
return api.submit(signedData.signedTransaction).then(data => {
|
||||
console.log('Tentative Result: ', data.resultCode);
|
||||
console.log('Tentative Message: ', data.resultMessage);
|
||||
/* if transaction was not successfully submitted throw error */
|
||||
/* If transaction was not successfully submitted throw error */
|
||||
assert.strictEqual(data.resultCode, 'tesSUCCESS');
|
||||
/* if successfully submitted fire off validation workflow */
|
||||
/* 'tesSUCCESS' means the transaction is being considered for the next ledger, and requires validation. */
|
||||
|
||||
/* If successfully submitted, begin validation workflow */
|
||||
const options = {
|
||||
minLedgerVersion: lastClosedLedgerVersion,
|
||||
maxLedgerVersion: prepared.instructions.maxLedgerVersion
|
||||
@@ -424,7 +424,7 @@ api.connect().then(() => {
|
||||
<h1 id="rippleapi-in-web-browsers">RippleAPI in Web Browsers</h1>
|
||||
<p>RippleAPI can also be used in a web browser if you compile a browser-compatible version and include <a href="https://www.npmjs.com/package/lodash">lodash</a> as a dependency before the RippleAPI script.</p>
|
||||
<h2 id="build-instructions">Build Instructions</h2>
|
||||
<p>To use RippleAPI in a browser, you need to a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.</p>
|
||||
<p>To use RippleAPI in a browser, you need to build a browser-compatible version. The following process compiles RippleAPI into a single JavaScript file you can include in a webpage.</p>
|
||||
<h4 id="1-download-a-copy-of-the-rippleapi-git-repository">1. Download a copy of the RippleAPI git repository.</h4>
|
||||
<p>If you have <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">Git</a> installed, you can clone the repository and check out the <strong>release</strong> branch, which always has the latest official release:</p>
|
||||
<pre><code>git clone https://github.com/ripple/ripple-lib.git
|
||||
|
||||
Reference in New Issue
Block a user