mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-24 06:05:51 +00:00
117
Gulpfile.js
117
Gulpfile.js
@@ -68,45 +68,6 @@ gulp.task('build', [ 'concat-sjcl' ], function(callback) {
|
|||||||
}, callback);
|
}, callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('bower-build', [ 'build' ], function(callback) {
|
|
||||||
return gulp.src([ './build/ripple-', '.js' ].join(pkg.version))
|
|
||||||
.pipe(rename('ripple.js'))
|
|
||||||
.pipe(gulp.dest('./dist/'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('bower-build-min', [ 'build-min' ], function(callback) {
|
|
||||||
return gulp.src([ './build/ripple-', '-min.js' ].join(pkg.version))
|
|
||||||
.pipe(rename('ripple-min.js'))
|
|
||||||
.pipe(gulp.dest('./dist/'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('bower-build-debug', [ 'build-debug' ], function(callback) {
|
|
||||||
return gulp.src([ './build/ripple-', '-debug.js' ].join(pkg.version))
|
|
||||||
.pipe(rename('ripple-debug.js'))
|
|
||||||
.pipe(gulp.dest('./dist/'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('bower-version', function() {
|
|
||||||
gulp.src('./dist/bower.json')
|
|
||||||
.pipe(bump({version: pkg.version}))
|
|
||||||
.pipe(gulp.dest('./dist/'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('version-bump', function() {
|
|
||||||
if (!argv.type) {
|
|
||||||
throw new Error("No type found, pass it in using the --type argument");
|
|
||||||
}
|
|
||||||
gulp.src('./package.json')
|
|
||||||
.pipe(bump({type:argv.type}))
|
|
||||||
.pipe(gulp.dest('./'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('version-beta', function() {
|
|
||||||
gulp.src('./package.json')
|
|
||||||
.pipe(bump({version: pkg.version+'-beta'}))
|
|
||||||
.pipe(gulp.dest('./'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('build-min', [ 'build' ], function(callback) {
|
gulp.task('build-min', [ 'build' ], function(callback) {
|
||||||
return gulp.src([ './build/ripple-', '.js' ].join(pkg.version))
|
return gulp.src([ './build/ripple-', '.js' ].join(pkg.version))
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
@@ -128,6 +89,66 @@ gulp.task('build-debug', [ 'concat-sjcl' ], function(callback) {
|
|||||||
}, callback);
|
}, callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a WebPack external for a given unavailable module which replaces
|
||||||
|
* that module's constructor with an error-thrower
|
||||||
|
*/
|
||||||
|
|
||||||
|
function buildUseError(cons) {
|
||||||
|
return 'var {<CONS>:function(){throw new Error("Class is unavailable in this build: <CONS>")}}'
|
||||||
|
.replace(new RegExp('<CONS>', 'g'), cons);
|
||||||
|
};
|
||||||
|
|
||||||
|
gulp.task('build-core', [ 'concat-sjcl' ], function(callback) {
|
||||||
|
webpack({
|
||||||
|
entry: [
|
||||||
|
'./src/js/ripple/remote.js'
|
||||||
|
],
|
||||||
|
externals: [
|
||||||
|
{
|
||||||
|
'./transaction': buildUseError('Transaction'),
|
||||||
|
'./orderbook': buildUseError('OrderBook'),
|
||||||
|
'./account': buildUseError('Account'),
|
||||||
|
'./serializedobject': buildUseError('SerializedObject')
|
||||||
|
}
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
library: 'ripple',
|
||||||
|
path: './build/',
|
||||||
|
filename: [ 'ripple-', '-core.js' ].join(pkg.version)
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new webpack.optimize.UglifyJsPlugin()
|
||||||
|
]
|
||||||
|
}, callback);
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('bower-build', [ 'build' ], function(callback) {
|
||||||
|
return gulp.src([ './build/ripple-', '.js' ].join(pkg.version))
|
||||||
|
.pipe(rename('ripple.js'))
|
||||||
|
.pipe(gulp.dest('./dist/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('bower-build-min', [ 'build-min' ], function(callback) {
|
||||||
|
return gulp.src([ './build/ripple-', '-min.js' ].join(pkg.version))
|
||||||
|
.pipe(rename('ripple-min.js'))
|
||||||
|
.pipe(gulp.dest('./dist/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('bower-build-debug', [ 'build-debug' ], function(callback) {
|
||||||
|
return gulp.src([ './build/ripple-', '-debug.js' ].join(pkg.version))
|
||||||
|
.pipe(rename('ripple-debug.js'))
|
||||||
|
.pipe(gulp.dest('./dist/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('bower-version', function() {
|
||||||
|
gulp.src('./dist/bower.json')
|
||||||
|
.pipe(bump({ version: pkg.version }))
|
||||||
|
.pipe(gulp.dest('./dist/'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('bower', ['bower-build', 'bower-build-min', 'bower-build-debug', 'bower-version']);
|
||||||
|
|
||||||
gulp.task('lint', function() {
|
gulp.task('lint', function() {
|
||||||
gulp.src('src/js/ripple/*.js')
|
gulp.src('src/js/ripple/*.js')
|
||||||
.pipe(jshint())
|
.pipe(jshint())
|
||||||
@@ -158,6 +179,20 @@ gulp.task('watch', function() {
|
|||||||
gulp.watch('src/js/ripple/*', [ 'build-debug' ]);
|
gulp.watch('src/js/ripple/*', [ 'build-debug' ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', [ 'concat-sjcl', 'build', 'build-debug', 'build-min' ]);
|
gulp.task('version-bump', function() {
|
||||||
|
if (!argv.type) {
|
||||||
|
throw new Error("No type found, pass it in using the --type argument");
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task('bower', ['bower-build', 'bower-build-min', 'bower-build-debug', 'bower-version']);
|
gulp.src('./package.json')
|
||||||
|
.pipe(bump({ type: argv.type }))
|
||||||
|
.pipe(gulp.dest('./'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('version-beta', function() {
|
||||||
|
gulp.src('./package.json')
|
||||||
|
.pipe(bump({ version: pkg.version + '-beta' }))
|
||||||
|
.pipe(gulp.dest('./'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('default', [ 'concat-sjcl', 'build', 'build-debug', 'build-min' ]);
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -16,7 +16,7 @@ A JavaScript API for interacting with Ripple in Node.js and the browser
|
|||||||
###In this file
|
###In this file
|
||||||
|
|
||||||
1. [Installation](README.md#installation)
|
1. [Installation](README.md#installation)
|
||||||
2. [Quickstart](README.md#quickstart)
|
2. [Quick start](README.md#quick+start)
|
||||||
3. [Running tests](https://github.com/ripple/ripple-lib#running-tests)
|
3. [Running tests](https://github.com/ripple/ripple-lib#running-tests)
|
||||||
|
|
||||||
###Additional documentation
|
###Additional documentation
|
||||||
@@ -47,7 +47,9 @@ A JavaScript API for interacting with Ripple in Node.js and the browser
|
|||||||
See the [bower-ripple repo](https://github.com/ripple/bower-ripple) for additional bower instructions
|
See the [bower-ripple repo](https://github.com/ripple/bower-ripple) for additional bower instructions
|
||||||
|
|
||||||
|
|
||||||
**Building ripple-lib from github**
|
**Building ripple-lib for browser environments**
|
||||||
|
|
||||||
|
ripple-lib uses Gulp to generate browser builds. These steps will generate minified and non-minified builds of ripple-lib in the `build/` directory.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone https://github.com/ripple/ripple-lib
|
$ git clone https://github.com/ripple/ripple-lib
|
||||||
@@ -55,9 +57,13 @@ See the [bower-ripple repo](https://github.com/ripple/bower-ripple) for addition
|
|||||||
$ npm run build
|
$ npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
Then use the minified `build/ripple-*-min.js`
|
**Restricted browser builds**
|
||||||
|
|
||||||
##Quickstart
|
You may generate browser builds that contain a subset of features. To do this, run `./node_modules/.bin/gulp build-<name>`
|
||||||
|
|
||||||
|
+ `build-core` Contains the functionality to make requests and listen for events such as `ledgerClose`. Only `ripple.Remote` is currently exposed. Advanced features like transaction submission and orderbook tracking are excluded from this build.
|
||||||
|
|
||||||
|
##Quick start
|
||||||
|
|
||||||
`Remote.js` ([remote.js](https://github.com/ripple/ripple-lib/blob/develop/src/js/ripple/remote.js)) is the point of entry for interacting with rippled
|
`Remote.js` ([remote.js](https://github.com/ripple/ripple-lib/blob/develop/src/js/ripple/remote.js)) is the point of entry for interacting with rippled
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ var util = require('util');
|
|||||||
var url = require('url');
|
var url = require('url');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var Amount = require('./amount').Amount;
|
var Amount = require('./amount').Amount;
|
||||||
var Transaction = require('./transaction').Transaction;
|
|
||||||
var log = require('./log').internal.sub('server');
|
var log = require('./log').internal.sub('server');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -760,22 +759,16 @@ Server.prototype._isConnected = function() {
|
|||||||
* Calculate transaction fee
|
* Calculate transaction fee
|
||||||
*
|
*
|
||||||
* @param {Transaction|Number} Fee units for a provided transaction
|
* @param {Transaction|Number} Fee units for a provided transaction
|
||||||
* @return {Number} Final fee in XRP for specified number of fee units
|
* @return {String} Final fee in XRP for specified number of fee units
|
||||||
* @api private
|
* @api private
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Server.prototype._computeFee = function(transaction) {
|
Server.prototype._computeFee = function(feeUnits) {
|
||||||
var units;
|
if (isNaN(feeUnits)) {
|
||||||
|
|
||||||
if (transaction instanceof Transaction) {
|
|
||||||
units = transaction._getFeeUnits();
|
|
||||||
} else if (typeof transaction === 'number') {
|
|
||||||
units = transaction;
|
|
||||||
} else {
|
|
||||||
throw new Error('Invalid argument');
|
throw new Error('Invalid argument');
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._feeTx(units).to_json();
|
return this._feeTx(Number(feeUnits)).to_json();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ Transaction.prototype._computeFee = function() {
|
|||||||
for (var i=0; i<servers.length; i++) {
|
for (var i=0; i<servers.length; i++) {
|
||||||
var server = servers[i];
|
var server = servers[i];
|
||||||
if (server._connected) {
|
if (server._connected) {
|
||||||
fees.push(Number(server._computeFee(this)));
|
fees.push(Number(server._computeFee(this._getFeeUnits())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1006,12 +1006,6 @@ describe('Server', function() {
|
|||||||
assert(server._isConnected());
|
assert(server._isConnected());
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Compute fee - transaction', function() {
|
|
||||||
var server = new Server(new Remote(), 'ws://localhost:5748');
|
|
||||||
var transaction = new Transaction();
|
|
||||||
assert.strictEqual(server._computeFee(transaction), '12');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Compute fee - fee units', function() {
|
it('Compute fee - fee units', function() {
|
||||||
var server = new Server(new Remote(), 'ws://localhost:5748');
|
var server = new Server(new Remote(), 'ws://localhost:5748');
|
||||||
var transaction = new Transaction();
|
var transaction = new Transaction();
|
||||||
@@ -1033,7 +1027,7 @@ describe('Server', function() {
|
|||||||
server._load_factor = 256 * 4;
|
server._load_factor = 256 * 4;
|
||||||
|
|
||||||
var transaction = new Transaction();
|
var transaction = new Transaction();
|
||||||
assert.strictEqual(server._computeFee(transaction), '48');
|
assert.strictEqual(server._computeFee(10), '48');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Compute reserve', function() {
|
it('Compute reserve', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user