mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 04:35:49 +00:00
Return instructions in prepare responses
This commit is contained in:
16
npm-shrinkwrap.json
generated
16
npm-shrinkwrap.json
generated
@@ -13,8 +13,8 @@
|
|||||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.20.tgz",
|
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-5.8.20.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": {
|
"core-js": {
|
||||||
"version": "1.0.1",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.0.1.tgz"
|
"resolved": "https://registry.npmjs.org/core-js/-/core-js-1.1.2.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -23,8 +23,8 @@
|
|||||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.0.7.tgz"
|
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-2.0.7.tgz"
|
||||||
},
|
},
|
||||||
"bn.js": {
|
"bn.js": {
|
||||||
"version": "3.1.1",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.1.tgz"
|
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.1.2.tgz"
|
||||||
},
|
},
|
||||||
"es6-promisify": {
|
"es6-promisify": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@@ -81,8 +81,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"is-my-json-valid": {
|
"is-my-json-valid": {
|
||||||
"version": "2.12.1",
|
"version": "2.12.2",
|
||||||
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.1.tgz",
|
"resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.12.2.tgz",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"generate-function": {
|
"generate-function": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@@ -99,8 +99,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jsonpointer": {
|
"jsonpointer": {
|
||||||
"version": "1.1.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-1.1.0.tgz"
|
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-2.0.0.tgz"
|
||||||
},
|
},
|
||||||
"xtend": {
|
"xtend": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
"babel-eslint": "^4.0.5",
|
"babel-eslint": "^4.0.5",
|
||||||
"babel-loader": "^5.3.2",
|
"babel-loader": "^5.3.2",
|
||||||
"coveralls": "~2.10.0",
|
"coveralls": "~2.10.0",
|
||||||
"eslint": "^1.2.0",
|
"eslint": "^1.3.0",
|
||||||
"eslint-plugin-flowtype": "^1.0.0",
|
"eslint-plugin-flowtype": "^1.0.0",
|
||||||
"eventemitter2": "^0.4.14",
|
"eventemitter2": "^0.4.14",
|
||||||
"flow-bin": "^0.14",
|
"flow-bin": "^0.14",
|
||||||
|
|||||||
21
src/api/common/schemas/prepare.json
Normal file
21
src/api/common/schemas/prepare.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
|
"title": "prepare",
|
||||||
|
"description": "Result of prepare function",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"txJSON": {"type": "string"},
|
||||||
|
"instructions": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"fee": {"$ref": "value"},
|
||||||
|
"sequence": {"$ref": "sequence"},
|
||||||
|
"maxLedgerVersion": {"$ref": "ledgerVersion"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["fee", "sequence"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"additionalProperties": false,
|
||||||
|
"required": ["txJSON", "instructions"]
|
||||||
|
}
|
||||||
@@ -32,10 +32,10 @@ function createOrderTransaction(account, order) {
|
|||||||
|
|
||||||
function prepareOrderAsync(account, order, instructions, callback) {
|
function prepareOrderAsync(account, order, instructions, callback) {
|
||||||
const transaction = createOrderTransaction(account, order);
|
const transaction = createOrderTransaction(account, order);
|
||||||
utils.createTxJSON(transaction, this.remote, instructions, callback);
|
utils.prepareTransaction(transaction, this.remote, instructions, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareOrder(account: string, order: Object, instructions={}) {
|
function prepareOrder(account: string, order: Object, instructions = {}) {
|
||||||
return utils.promisify(prepareOrderAsync.bind(this))(
|
return utils.promisify(prepareOrderAsync.bind(this))(
|
||||||
account, order, instructions);
|
account, order, instructions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,15 @@ function createOrderCancellationTransaction(account, sequence) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function prepareOrderCancellationAsync(account, sequence, instructions,
|
function prepareOrderCancellationAsync(account, sequence, instructions,
|
||||||
callback) {
|
callback
|
||||||
|
) {
|
||||||
const transaction = createOrderCancellationTransaction(account, sequence);
|
const transaction = createOrderCancellationTransaction(account, sequence);
|
||||||
utils.createTxJSON(transaction, this.remote, instructions, callback);
|
utils.prepareTransaction(transaction, this.remote, instructions, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareOrderCancellation(account: string, sequence: number,
|
function prepareOrderCancellation(account: string, sequence: number,
|
||||||
instructions={}) {
|
instructions = {}
|
||||||
|
) {
|
||||||
return utils.promisify(prepareOrderCancellationAsync.bind(this))(
|
return utils.promisify(prepareOrderCancellationAsync.bind(this))(
|
||||||
account, sequence, instructions);
|
account, sequence, instructions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ function createPaymentTransaction(account, payment) {
|
|||||||
|
|
||||||
function preparePaymentAsync(account, payment, instructions, callback) {
|
function preparePaymentAsync(account, payment, instructions, callback) {
|
||||||
const transaction = createPaymentTransaction(account, payment);
|
const transaction = createPaymentTransaction(account, payment);
|
||||||
utils.createTxJSON(transaction, this.remote, instructions, callback);
|
utils.prepareTransaction(transaction, this.remote, instructions, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePayment(account: string, payment: Object, instructions={}) {
|
function preparePayment(account: string, payment: Object, instructions = {}) {
|
||||||
return utils.promisify(preparePaymentAsync.bind(this))(
|
return utils.promisify(preparePaymentAsync.bind(this))(
|
||||||
account, payment, instructions);
|
account, payment, instructions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,10 +92,10 @@ function createSettingsTransaction(account, settings) {
|
|||||||
|
|
||||||
function prepareSettingsAsync(account, settings, instructions, callback) {
|
function prepareSettingsAsync(account, settings, instructions, callback) {
|
||||||
const transaction = createSettingsTransaction(account, settings);
|
const transaction = createSettingsTransaction(account, settings);
|
||||||
utils.createTxJSON(transaction, this.remote, instructions, callback);
|
utils.prepareTransaction(transaction, this.remote, instructions, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareSettings(account: string, settings: Object, instructions={}) {
|
function prepareSettings(account: string, settings: Object, instructions = {}) {
|
||||||
return utils.promisify(prepareSettingsAsync.bind(this))(
|
return utils.promisify(prepareSettingsAsync.bind(this))(
|
||||||
account, settings, instructions);
|
account, settings, instructions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,18 +40,18 @@ function computeSignature(txJSON, keypair) {
|
|||||||
return keypair.signHex(signingData(txJSON));
|
return keypair.signHex(signingData(txJSON));
|
||||||
}
|
}
|
||||||
|
|
||||||
function sign(txJSON: {Account: string; SigningPubKey: string,
|
function sign(txJSON: string, secret: string
|
||||||
TxnSignature: string}, secret: string):
|
): {signedTransaction: string; id: string} {
|
||||||
{signedTransaction: string; id: string} {
|
const tx = JSON.parse(txJSON);
|
||||||
validate.txJSON(txJSON);
|
validate.txJSON(tx);
|
||||||
validate.secret(secret);
|
validate.secret(secret);
|
||||||
|
|
||||||
const keypair = getKeyPair(secret);
|
const keypair = getKeyPair(secret);
|
||||||
if (txJSON.SigningPubKey === undefined) {
|
if (tx.SigningPubKey === undefined) {
|
||||||
txJSON.SigningPubKey = getPublicKeyHex(keypair);
|
tx.SigningPubKey = getPublicKeyHex(keypair);
|
||||||
}
|
}
|
||||||
txJSON.TxnSignature = computeSignature(txJSON, keypair);
|
tx.TxnSignature = computeSignature(tx, keypair);
|
||||||
const serialized = serialize(txJSON);
|
const serialized = serialize(tx);
|
||||||
return {
|
return {
|
||||||
signedTransaction: serialized.to_hex(),
|
signedTransaction: serialized.to_hex(),
|
||||||
id: hashSerialization(serialized, HASH_TX_ID)
|
id: hashSerialization(serialized, HASH_TX_ID)
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ function createTrustlineTransaction(account, trustline) {
|
|||||||
|
|
||||||
function prepareTrustlineAsync(account, trustline, instructions, callback) {
|
function prepareTrustlineAsync(account, trustline, instructions, callback) {
|
||||||
const transaction = createTrustlineTransaction(account, trustline);
|
const transaction = createTrustlineTransaction(account, trustline);
|
||||||
utils.createTxJSON(transaction, this.remote, instructions, callback);
|
utils.prepareTransaction(transaction, this.remote, instructions, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareTrustline(account: string, trustline: Object, instructions={}) {
|
function prepareTrustline(account: string, trustline: Object, instructions = {}
|
||||||
|
) {
|
||||||
return utils.promisify(prepareTrustlineAsync.bind(this))(
|
return utils.promisify(prepareTrustlineAsync.bind(this))(
|
||||||
account, trustline, instructions);
|
account, trustline, instructions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
const _ = require('lodash');
|
||||||
const BigNumber = require('bignumber.js');
|
const BigNumber = require('bignumber.js');
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
|
||||||
function setTransactionBitFlags(transaction: any, values: any, flags: any):
|
function setTransactionBitFlags(transaction: any, values: any, flags: any
|
||||||
void {
|
): void {
|
||||||
for (const flagName in flags) {
|
for (const flagName in flags) {
|
||||||
const flagValue = values[flagName];
|
const flagValue = values[flagName];
|
||||||
const flagConversions = flags[flagName];
|
const flagConversions = flags[flagName];
|
||||||
@@ -23,8 +24,22 @@ function getFeeDrops(remote) {
|
|||||||
return remote.feeTx(feeUnits).to_text();
|
return remote.feeTx(feeUnits).to_text();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTxJSON(transaction: any, remote: any, instructions: any,
|
function formatPrepareResponse(txJSON) {
|
||||||
callback: (err: ?(typeof Error), data: {tx_json: any}) => void): void {
|
const instructions = {
|
||||||
|
fee: txJSON.Fee,
|
||||||
|
sequence: txJSON.Sequence,
|
||||||
|
maxLedgerVersion: txJSON.LastLedgerSequence
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
txJSON: JSON.stringify(txJSON),
|
||||||
|
instructions: _.omit(instructions, _.isUndefined)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
type Callback = (err: ?(typeof Error),
|
||||||
|
data: {txJSON: string, instructions: any}) => void;
|
||||||
|
function prepareTransaction(transaction: any, remote: any, instructions: any,
|
||||||
|
callback: Callback): void {
|
||||||
common.validate.instructions(instructions);
|
common.validate.instructions(instructions);
|
||||||
|
|
||||||
transaction.complete();
|
transaction.complete();
|
||||||
@@ -53,18 +68,18 @@ function createTxJSON(transaction: any, remote: any, instructions: any,
|
|||||||
|
|
||||||
if (instructions.sequence !== undefined) {
|
if (instructions.sequence !== undefined) {
|
||||||
txJSON.Sequence = parseInt(instructions.sequence, 10);
|
txJSON.Sequence = parseInt(instructions.sequence, 10);
|
||||||
callback(null, txJSON);
|
callback(null, formatPrepareResponse(txJSON));
|
||||||
} else {
|
} else {
|
||||||
remote.findAccount(account).getNextSequence(function(error, sequence) {
|
remote.findAccount(account).getNextSequence(function(error, sequence) {
|
||||||
txJSON.Sequence = sequence;
|
txJSON.Sequence = sequence;
|
||||||
callback(null, txJSON);
|
callback(error, formatPrepareResponse(txJSON));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
setTransactionBitFlags: setTransactionBitFlags,
|
setTransactionBitFlags,
|
||||||
createTxJSON: createTxJSON,
|
prepareTransaction,
|
||||||
common: common,
|
common,
|
||||||
promisify: common.promisify
|
promisify: common.promisify
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ describe('RippleAPI', function() {
|
|||||||
}, instructions);
|
}, instructions);
|
||||||
return this.api.preparePayment(
|
return this.api.preparePayment(
|
||||||
address, requests.preparePayment, localInstructions).then(
|
address, requests.preparePayment, localInstructions).then(
|
||||||
_.partial(checkResult, responses.preparePayment, 'tx'));
|
_.partial(checkResult, responses.preparePayment, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('preparePayment with all options specified', function() {
|
it('preparePayment with all options specified', function() {
|
||||||
@@ -58,72 +58,73 @@ describe('RippleAPI', function() {
|
|||||||
};
|
};
|
||||||
return this.api.preparePayment(
|
return this.api.preparePayment(
|
||||||
address, requests.preparePaymentAllOptions, localInstructions).then(
|
address, requests.preparePaymentAllOptions, localInstructions).then(
|
||||||
_.partial(checkResult, responses.preparePaymentAllOptions, 'tx'));
|
_.partial(checkResult, responses.preparePaymentAllOptions, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('preparePayment without counterparty set', function() {
|
it('preparePayment without counterparty set', function() {
|
||||||
const localInstructions = _.defaults({sequence: 23}, instructions);
|
const localInstructions = _.defaults({sequence: 23}, instructions);
|
||||||
return this.api.preparePayment(
|
return this.api.preparePayment(
|
||||||
address, requests.preparePaymentNoCounterparty, localInstructions).then(
|
address, requests.preparePaymentNoCounterparty, localInstructions).then(
|
||||||
_.partial(checkResult, responses.preparePaymentNoCounterparty, 'tx'));
|
_.partial(checkResult, responses.preparePaymentNoCounterparty,
|
||||||
|
'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareOrder - buy order', function() {
|
it('prepareOrder - buy order', function() {
|
||||||
return this.api.prepareOrder(address, requests.prepareOrder, instructions)
|
return this.api.prepareOrder(address, requests.prepareOrder, instructions)
|
||||||
.then(_.partial(checkResult, responses.prepareOrder, 'tx'));
|
.then(_.partial(checkResult, responses.prepareOrder, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareOrder - sell order', function() {
|
it('prepareOrder - sell order', function() {
|
||||||
return this.api.prepareOrder(
|
return this.api.prepareOrder(
|
||||||
address, requests.prepareOrderSell, instructions).then(
|
address, requests.prepareOrderSell, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareOrderSell, 'tx'));
|
_.partial(checkResult, responses.prepareOrderSell, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareOrderCancellation', function() {
|
it('prepareOrderCancellation', function() {
|
||||||
return this.api.prepareOrderCancellation(address, 23, instructions).then(
|
return this.api.prepareOrderCancellation(address, 23, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareOrderCancellation, 'tx'));
|
_.partial(checkResult, responses.prepareOrderCancellation, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareTrustline - simple', function() {
|
it('prepareTrustline - simple', function() {
|
||||||
return this.api.prepareTrustline(
|
return this.api.prepareTrustline(
|
||||||
address, requests.prepareTrustline.simple, instructions).then(
|
address, requests.prepareTrustline.simple, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareTrustline.simple, 'tx'));
|
_.partial(checkResult, responses.prepareTrustline.simple, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareTrustline - complex', function() {
|
it('prepareTrustline - complex', function() {
|
||||||
return this.api.prepareTrustline(
|
return this.api.prepareTrustline(
|
||||||
address, requests.prepareTrustline.complex, instructions).then(
|
address, requests.prepareTrustline.complex, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareTrustline.complex, 'tx'));
|
_.partial(checkResult, responses.prepareTrustline.complex, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings', function() {
|
it('prepareSettings', function() {
|
||||||
return this.api.prepareSettings(
|
return this.api.prepareSettings(
|
||||||
address, requests.prepareSettings, instructions).then(
|
address, requests.prepareSettings, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareSettings.flags, 'tx'));
|
_.partial(checkResult, responses.prepareSettings.flags, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings - regularKey', function() {
|
it('prepareSettings - regularKey', function() {
|
||||||
const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'};
|
const regularKey = {regularKey: 'rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD'};
|
||||||
return this.api.prepareSettings(address, regularKey, instructions).then(
|
return this.api.prepareSettings(address, regularKey, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareSettings.regularKey, 'tx'));
|
_.partial(checkResult, responses.prepareSettings.regularKey, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings - flag set', function() {
|
it('prepareSettings - flag set', function() {
|
||||||
const settings = {requireDestinationTag: true};
|
const settings = {requireDestinationTag: true};
|
||||||
return this.api.prepareSettings(address, settings, instructions).then(
|
return this.api.prepareSettings(address, settings, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareSettings.flagSet, 'tx'));
|
_.partial(checkResult, responses.prepareSettings.flagSet, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings - flag clear', function() {
|
it('prepareSettings - flag clear', function() {
|
||||||
const settings = {requireDestinationTag: false};
|
const settings = {requireDestinationTag: false};
|
||||||
return this.api.prepareSettings(address, settings, instructions).then(
|
return this.api.prepareSettings(address, settings, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareSettings.flagClear, 'tx'));
|
_.partial(checkResult, responses.prepareSettings.flagClear, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings - string field clear', function() {
|
it('prepareSettings - string field clear', function() {
|
||||||
const settings = {walletLocator: null};
|
const settings = {walletLocator: null};
|
||||||
return this.api.prepareSettings(address, settings, instructions).then(
|
return this.api.prepareSettings(address, settings, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareSettings.fieldClear, 'tx'));
|
_.partial(checkResult, responses.prepareSettings.fieldClear, 'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings - integer field clear', function() {
|
it('prepareSettings - integer field clear', function() {
|
||||||
@@ -131,19 +132,20 @@ describe('RippleAPI', function() {
|
|||||||
return this.api.prepareSettings(address, settings, instructions)
|
return this.api.prepareSettings(address, settings, instructions)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
assert(data);
|
assert(data);
|
||||||
assert.strictEqual(data.WalletSize, 0);
|
assert.strictEqual(JSON.parse(data.txJSON).WalletSize, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prepareSettings - set transferRate', function() {
|
it('prepareSettings - set transferRate', function() {
|
||||||
const settings = {transferRate: 1};
|
const settings = {transferRate: 1};
|
||||||
return this.api.prepareSettings(address, settings, instructions).then(
|
return this.api.prepareSettings(address, settings, instructions).then(
|
||||||
_.partial(checkResult, responses.prepareSettings.setTransferRate, 'tx'));
|
_.partial(checkResult, responses.prepareSettings.setTransferRate,
|
||||||
|
'prepare'));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sign', function() {
|
it('sign', function() {
|
||||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
|
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV';
|
||||||
const result = this.api.sign(requests.sign, secret);
|
const result = this.api.sign(requests.sign.txJSON, secret);
|
||||||
assert.deepEqual(result, responses.sign);
|
assert.deepEqual(result, responses.sign);
|
||||||
schemaValidator.schemaValidate('sign', result);
|
schemaValidator.schemaValidate('sign', result);
|
||||||
});
|
});
|
||||||
@@ -775,9 +777,9 @@ describe('RippleAPI - offline', function() {
|
|||||||
maxLedgerVersion: 8820051,
|
maxLedgerVersion: 8820051,
|
||||||
fee: '0.000012'
|
fee: '0.000012'
|
||||||
};
|
};
|
||||||
return api.prepareSettings(address, settings, instructions).then(txJSON => {
|
return api.prepareSettings(address, settings, instructions).then(data => {
|
||||||
assert.deepEqual(txJSON, responses.prepareSettings.flags);
|
assert.deepEqual(data, responses.prepareSettings.flags);
|
||||||
assert.deepEqual(api.sign(txJSON, secret), responses.sign);
|
assert.deepEqual(api.sign(data.txJSON, secret), responses.sign);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
13
test/fixtures/api/requests/sign.json
vendored
13
test/fixtures/api/requests/sign.json
vendored
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "AccountSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"Domain": "726970706C652E636F6D",
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"OfferCancel\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"OfferSequence\":23,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "OfferCancel",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"OfferSequence": 23,
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 655360,
|
"txJSON": "{\"Flags\":655360,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"TakerPays\":\"2000000\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "OfferCreate",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"TakerGets": {
|
"sequence": 23,
|
||||||
"value": "10.1",
|
"maxLedgerVersion": 8820051
|
||||||
"currency": "USD",
|
}
|
||||||
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
|
||||||
},
|
|
||||||
"TakerPays": "2000000",
|
|
||||||
"LastLedgerSequence": 8820051,
|
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
18
test/fixtures/api/responses/prepare-order.json
vendored
18
test/fixtures/api/responses/prepare-order.json
vendored
@@ -1,14 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"txJSON": "{\"Flags\":131072,\"TransactionType\":\"OfferCreate\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TakerGets\":\"2000000\",\"TakerPays\":{\"value\":\"10.1\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"Fee": "12",
|
"instructions": {
|
||||||
"Flags": 131072,
|
"fee": "12",
|
||||||
"LastLedgerSequence": 8820051,
|
"sequence": 23,
|
||||||
"Sequence": 23,
|
"maxLedgerVersion": 8820051
|
||||||
"TakerGets": "2000000",
|
}
|
||||||
"TakerPays": {
|
|
||||||
"currency": "USD",
|
|
||||||
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
|
||||||
"value": "10.1"
|
|
||||||
},
|
|
||||||
"TransactionType": "OfferCreate"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 458752,
|
"txJSON": "{\"Flags\":458752,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":\"10000\",\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "Payment",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
"sequence": 23,
|
||||||
"Amount": "10000",
|
"maxLedgerVersion": 8820051
|
||||||
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
|
||||||
"SourceTag": 14,
|
|
||||||
"DestinationTag": 58,
|
|
||||||
"Memos": [
|
|
||||||
{
|
|
||||||
"Memo": {
|
|
||||||
"MemoType": "74657374",
|
|
||||||
"MemoFormat": "706C61696E2F74657874",
|
|
||||||
"MemoData": "7465787465642064617461"
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
],
|
|
||||||
"LastLedgerSequence": 8820051,
|
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,52 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 458752,
|
"txJSON": "{\"Flags\":458752,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"LTC\",\"issuer\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\"},\"InvoiceID\":\"A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A\",\"SourceTag\":14,\"DestinationTag\":58,\"Memos\":[{\"Memo\":{\"MemoType\":\"74657374\",\"MemoFormat\":\"706C61696E2F74657874\",\"MemoData\":\"7465787465642064617461\"}}],\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\"},\"Paths\":[[{\"account\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"issuer\":\"rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q\",\"currency\":\"USD\",\"type_hex\":\"0000000000000031\"},{\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"type_hex\":\"0000000000000030\"},{\"account\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"issuer\":\"rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX\",\"currency\":\"LTC\",\"type_hex\":\"0000000000000031\"}]],\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "Payment",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
"sequence": 23,
|
||||||
"Amount": {
|
"maxLedgerVersion": 8820051
|
||||||
"value": "0.01",
|
|
||||||
"currency": "LTC",
|
|
||||||
"issuer": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo"
|
|
||||||
},
|
|
||||||
"InvoiceID": "A98FD36C17BE2B8511AD36DC335478E7E89F06262949F36EB88E2D683BBCC50A",
|
|
||||||
"SourceTag": 14,
|
|
||||||
"DestinationTag": 58,
|
|
||||||
"Paths": [
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
|
||||||
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
|
|
||||||
"currency": "USD",
|
|
||||||
"type_hex": "0000000000000031"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
|
||||||
"currency": "LTC",
|
|
||||||
"type_hex": "0000000000000030"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"account": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
|
||||||
"issuer": "rfYv1TXnwgDDK4WQNbFALykYuEBnrR4pDX",
|
|
||||||
"currency": "LTC",
|
|
||||||
"type_hex": "0000000000000031"
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
],
|
|
||||||
"Memos": [
|
|
||||||
{
|
|
||||||
"Memo": {
|
|
||||||
"MemoType": "74657374",
|
|
||||||
"MemoFormat": "706C61696E2F74657874",
|
|
||||||
"MemoData": "7465787465642064617461"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"SendMax": {
|
|
||||||
"value": "0.01",
|
|
||||||
"currency": "USD",
|
|
||||||
"issuer": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59"
|
|
||||||
},
|
|
||||||
"LastLedgerSequence": 8820051,
|
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
23
test/fixtures/api/responses/prepare-payment.json
vendored
23
test/fixtures/api/responses/prepare-payment.json
vendored
@@ -1,19 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"Payment\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Destination\":\"rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo\",\"Amount\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"SendMax\":{\"value\":\"0.01\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "Payment",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"Destination": "rpZc4mVfWUif9CRoHRKKcmhu1nx2xktxBo",
|
"sequence": 23,
|
||||||
"Amount": {
|
"maxLedgerVersion": 8820051
|
||||||
"value": "0.01",
|
}
|
||||||
"currency": "USD",
|
|
||||||
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
|
||||||
},
|
|
||||||
"LastLedgerSequence": 8820051,
|
|
||||||
"SendMax": {
|
|
||||||
"currency": "USD",
|
|
||||||
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM",
|
|
||||||
"value": "0.01"
|
|
||||||
},
|
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"WalletLocator\":\"0\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "AccountSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"WalletLocator": "0",
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"ClearFlag\":1,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "AccountSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"ClearFlag": 1,
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"SetFlag\":1,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "AccountSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"SetFlag": 1,
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"SetRegularKey\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"RegularKey\":\"rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "SetRegularKey",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"RegularKey": "rAR8rR8sUkBoCZFawhkWzY4Y5YoyuznwD",
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"TransferRate\":1000000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "AccountSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"TransferRate": 1000000000,
|
"sequence": 23,
|
||||||
"LastLedgerSequence": 8820051,
|
"maxLedgerVersion": 8820051
|
||||||
"Fee": "12",
|
}
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 1048576,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"AccountSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"Domain\":\"726970706C652E636F6D\",\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "AccountSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"Domain": "726970706C652E636F6D",
|
"sequence": 23,
|
||||||
"Flags": 0,
|
"maxLedgerVersion": 8820051
|
||||||
"LastLedgerSequence": 8820051,
|
}
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 0,
|
"txJSON": "{\"Flags\":0,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"0.1\",\"currency\":\"BTC\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "TrustSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"LimitAmount": {
|
"sequence": 23,
|
||||||
"value": "0.1",
|
"maxLedgerVersion": 8820051
|
||||||
"currency": "BTC",
|
}
|
||||||
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
|
||||||
},
|
|
||||||
"LastLedgerSequence": 8820051,
|
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
{
|
{
|
||||||
"Flags": 2228224,
|
"txJSON": "{\"Flags\":2228224,\"TransactionType\":\"TrustSet\",\"Account\":\"r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59\",\"LimitAmount\":{\"value\":\"10000\",\"currency\":\"USD\",\"issuer\":\"rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM\"},\"QualityIn\":910000000,\"QualityOut\":870000000,\"LastLedgerSequence\":8820051,\"Fee\":\"12\",\"Sequence\":23}",
|
||||||
"TransactionType": "TrustSet",
|
"instructions": {
|
||||||
"Account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59",
|
"fee": "12",
|
||||||
"LimitAmount": {
|
"sequence": 23,
|
||||||
"value": "10000",
|
"maxLedgerVersion": 8820051
|
||||||
"currency": "USD",
|
}
|
||||||
"issuer": "rMH4UxPrbuMa1spCBR98hLLyNJp4d8p4tM"
|
|
||||||
},
|
|
||||||
"QualityIn": 910000000,
|
|
||||||
"QualityOut": 870000000,
|
|
||||||
"LastLedgerSequence": 8820051,
|
|
||||||
"Fee": "12",
|
|
||||||
"Sequence": 23
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user