mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Simplify "submit" response
This commit is contained in:
@@ -3,31 +3,15 @@
|
|||||||
"title": "submit",
|
"title": "submit",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"success": {
|
"resultCode": {
|
||||||
"type": "boolean",
|
|
||||||
"description": "Indicates whether the transaction submission was successful; this does **not** indicate whether the transaction itself was successful."
|
|
||||||
},
|
|
||||||
"engineResult": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The result code returned by rippled. [List of tranasction responses](http://pages.lightthenight.org/gba/SanFran15/ripple)"
|
"description": "The result code returned by rippled. [List of tranasction responses](http://pages.lightthenight.org/gba/SanFran15/ripple)"
|
||||||
},
|
},
|
||||||
"engineResultCode": {
|
"resultMessage": {
|
||||||
"type": "integer",
|
|
||||||
"description": "Numeric code indicating the status of the transaction, corresponding to `engineResult`."
|
|
||||||
},
|
|
||||||
"engineResultMessage": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Human-readable explanation of the status of the transaction."
|
"description": "Human-readable explanation of the status of the transaction."
|
||||||
},
|
|
||||||
"txBlob": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "The signed transaction (identical to parameter)."
|
|
||||||
},
|
|
||||||
"txJson": {
|
|
||||||
"type": "object",
|
|
||||||
"description": "The signed transaction decoded to rippled JSON format."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["success", "engineResult", "engineResultCode"],
|
"required": ["resultCode", "resultMessage"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const {validate, convertKeysFromSnakeCaseToCamelCase} = utils.common;
|
const {validate} = utils.common;
|
||||||
|
|
||||||
type Submit = {
|
type Submit = {
|
||||||
success: boolean,
|
success: boolean,
|
||||||
@@ -27,7 +27,10 @@ function formatResponse(response) {
|
|||||||
if (isImmediateRejection(response.engine_result)) {
|
if (isImmediateRejection(response.engine_result)) {
|
||||||
throw new utils.common.errors.RippledError('Submit failed');
|
throw new utils.common.errors.RippledError('Submit failed');
|
||||||
}
|
}
|
||||||
return convertKeysFromSnakeCaseToCamelCase(response);
|
return {
|
||||||
|
resultCode: response.engine_result,
|
||||||
|
resultMessage: response.engine_result_message
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit(signedTransaction: string): Promise<Submit> {
|
function submit(signedTransaction: string): Promise<Submit> {
|
||||||
|
|||||||
8
test/fixtures/responses/submit.json
vendored
8
test/fixtures/responses/submit.json
vendored
@@ -1,8 +1,4 @@
|
|||||||
{
|
{
|
||||||
"success": true,
|
"resultCode": "tesSUCCESS",
|
||||||
"engineResult": "tesSUCCESS",
|
"resultMessage": "The transaction was applied. Only final in a validated ledger."
|
||||||
"engineResultCode": 0,
|
|
||||||
"engineResultMessage": "The transaction was applied. Only final in a validated ledger.",
|
|
||||||
"txBlob": "12000322000000002400000017201B0086955468400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF02207F5517BC8AEF2ADC1325897ECDBA8C673838048BCA62F4E98B252F19BE88796D770A726970706C652E636F6D81144FBFF73DA4ECF9B701940F27341FA8020C313443",
|
|
||||||
"txJson": {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ function testTransaction(testcase, type, lastClosedLedgerVersion, prepared) {
|
|||||||
console.log('PREPARED...');
|
console.log('PREPARED...');
|
||||||
return testcase.api.submit(signedData.signedTransaction).then(data => {
|
return testcase.api.submit(signedData.signedTransaction).then(data => {
|
||||||
console.log('SUBMITTED...');
|
console.log('SUBMITTED...');
|
||||||
assert.strictEqual(data.engineResult, 'tesSUCCESS');
|
assert.strictEqual(data.resultCode, 'tesSUCCESS');
|
||||||
const options = {
|
const options = {
|
||||||
minLedgerVersion: lastClosedLedgerVersion,
|
minLedgerVersion: lastClosedLedgerVersion,
|
||||||
maxLedgerVersion: txData.LastLedgerSequence
|
maxLedgerVersion: txData.LastLedgerSequence
|
||||||
|
|||||||
Reference in New Issue
Block a user