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",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"success": {
|
||||
"type": "boolean",
|
||||
"description": "Indicates whether the transaction submission was successful; this does **not** indicate whether the transaction itself was successful."
|
||||
},
|
||||
"engineResult": {
|
||||
"resultCode": {
|
||||
"type": "string",
|
||||
"description": "The result code returned by rippled. [List of tranasction responses](http://pages.lightthenight.org/gba/SanFran15/ripple)"
|
||||
},
|
||||
"engineResultCode": {
|
||||
"type": "integer",
|
||||
"description": "Numeric code indicating the status of the transaction, corresponding to `engineResult`."
|
||||
},
|
||||
"engineResultMessage": {
|
||||
"resultMessage": {
|
||||
"type": "string",
|
||||
"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
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'use strict';
|
||||
const _ = require('lodash');
|
||||
const utils = require('./utils');
|
||||
const {validate, convertKeysFromSnakeCaseToCamelCase} = utils.common;
|
||||
const {validate} = utils.common;
|
||||
|
||||
type Submit = {
|
||||
success: boolean,
|
||||
@@ -27,7 +27,10 @@ function formatResponse(response) {
|
||||
if (isImmediateRejection(response.engine_result)) {
|
||||
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> {
|
||||
|
||||
8
test/fixtures/responses/submit.json
vendored
8
test/fixtures/responses/submit.json
vendored
@@ -1,8 +1,4 @@
|
||||
{
|
||||
"success": true,
|
||||
"engineResult": "tesSUCCESS",
|
||||
"engineResultCode": 0,
|
||||
"engineResultMessage": "The transaction was applied. Only final in a validated ledger.",
|
||||
"txBlob": "12000322000000002400000017201B0086955468400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF02207F5517BC8AEF2ADC1325897ECDBA8C673838048BCA62F4E98B252F19BE88796D770A726970706C652E636F6D81144FBFF73DA4ECF9B701940F27341FA8020C313443",
|
||||
"txJson": {}
|
||||
"resultCode": "tesSUCCESS",
|
||||
"resultMessage": "The transaction was applied. Only final in a validated ledger."
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ function testTransaction(testcase, type, lastClosedLedgerVersion, prepared) {
|
||||
console.log('PREPARED...');
|
||||
return testcase.api.submit(signedData.signedTransaction).then(data => {
|
||||
console.log('SUBMITTED...');
|
||||
assert.strictEqual(data.engineResult, 'tesSUCCESS');
|
||||
assert.strictEqual(data.resultCode, 'tesSUCCESS');
|
||||
const options = {
|
||||
minLedgerVersion: lastClosedLedgerVersion,
|
||||
maxLedgerVersion: txData.LastLedgerSequence
|
||||
|
||||
Reference in New Issue
Block a user