From 9af20f91764510cbf9fe6da825a62c318eef4c9e Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Mon, 16 Nov 2015 11:43:55 -0800 Subject: [PATCH] Simplify "submit" response --- src/common/schemas/output/submit.json | 22 +++------------------- src/transaction/submit.js | 7 +++++-- test/fixtures/responses/submit.json | 8 ++------ test/integration/integration-test.js | 2 +- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/common/schemas/output/submit.json b/src/common/schemas/output/submit.json index 2984991f..903ae8f9 100644 --- a/src/common/schemas/output/submit.json +++ b/src/common/schemas/output/submit.json @@ -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 } diff --git a/src/transaction/submit.js b/src/transaction/submit.js index a42aea67..1acb9045 100644 --- a/src/transaction/submit.js +++ b/src/transaction/submit.js @@ -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 { diff --git a/test/fixtures/responses/submit.json b/test/fixtures/responses/submit.json index 8ab123be..4d8f03d7 100644 --- a/test/fixtures/responses/submit.json +++ b/test/fixtures/responses/submit.json @@ -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." } diff --git a/test/integration/integration-test.js b/test/integration/integration-test.js index 43730185..605cc534 100644 --- a/test/integration/integration-test.js +++ b/test/integration/integration-test.js @@ -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