mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-21 20:55:48 +00:00
Update Submit Response (#978)
* update submit output schema * update submit response object
This commit is contained in:
committed by
Elliot Lee
parent
a8075d98df
commit
8d37da0952
@@ -5481,8 +5481,13 @@ This method returns an object with the following structure:
|
|||||||
|
|
||||||
Name | Type | Description
|
Name | Type | Description
|
||||||
---- | ---- | -----------
|
---- | ---- | -----------
|
||||||
resultCode | string | The result code returned by rippled. [List of transaction responses](https://ripple.com/build/transactions/#full-transaction-response-list)
|
resultCode | string | Deprecated: Use `engine_result` instead.
|
||||||
resultMessage | string | Human-readable explanation of the status of the transaction.
|
resultMessage | string | Deprecated: Use `engine_result_message` instead.
|
||||||
|
engine_result | string | Code indicating the preliminary result of the transaction, for example tesSUCCESS. [List of transaction responses](https://ripple.com/build/transactions/#full-transaction-response-list)
|
||||||
|
engine_result_code | integer | Numeric code indicating the preliminary result of the transaction, directly correlated to `engine_result`
|
||||||
|
engine_result_message | string | Human-readable explanation of the transaction's preliminary result.
|
||||||
|
tx_blob | string | The complete transaction in hex string format.
|
||||||
|
tx_json | [tx](https://ripple.com/build/transactions/) | The complete transaction in JSON format.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -5496,7 +5501,27 @@ return api.submit(signedTransaction)
|
|||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"resultCode": "tesSUCCESS",
|
"resultCode": "tesSUCCESS",
|
||||||
"resultMessage": "The transaction was applied. Only final in a validated ledger."
|
"resultMessage": "The transaction was applied. Only final in a validated ledger.",
|
||||||
|
"engine_result": "tesSUCCESS",
|
||||||
|
"engine_result_code": 0,
|
||||||
|
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
||||||
|
"tx_blob": "1200002280000000240000016861D4838D7EA4C6800000000000000000000000000055534400000000004B4E9C06F24296074F7BC48F92A97916C6DC5EA9684000000000002710732103AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB7446304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F858081144B4E9C06F24296074F7BC48F92A97916C6DC5EA983143E9D4A2B8AA0780F682D136F7A56D6724EF53754",
|
||||||
|
"tx_json": {
|
||||||
|
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||||
|
"Amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||||
|
"value": "1"
|
||||||
|
},
|
||||||
|
"Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
|
||||||
|
"Fee": "10000",
|
||||||
|
"Flags": 2147483648,
|
||||||
|
"Sequence": 360,
|
||||||
|
"SigningPubKey": "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB",
|
||||||
|
"TransactionType": "Payment",
|
||||||
|
"TxnSignature": "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580",
|
||||||
|
"hash": "4D5D90890F8D49519E4151938601EF3D0B30B16CD6A519D9C99102C9FA77F7E0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -5,13 +5,33 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"resultCode": {
|
"resultCode": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The result code returned by rippled. [List of transaction responses](https://ripple.com/build/transactions/#full-transaction-response-list)"
|
"description": "Deprecated: Use `engine_result` instead."
|
||||||
},
|
},
|
||||||
"resultMessage": {
|
"resultMessage": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Human-readable explanation of the status of the transaction."
|
"description": "Deprecated: Use `engine_result_message` instead."
|
||||||
|
},
|
||||||
|
"engine_result": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Code indicating the preliminary result of the transaction, for example tesSUCCESS. [List of transaction responses](https://ripple.com/build/transactions/#full-transaction-response-list)"
|
||||||
|
},
|
||||||
|
"engine_result_code": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Numeric code indicating the preliminary result of the transaction, directly correlated to `engine_result`"
|
||||||
|
},
|
||||||
|
"engine_result_message": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Human-readable explanation of the transaction's preliminary result."
|
||||||
|
},
|
||||||
|
"tx_blob": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The complete transaction in hex string format."
|
||||||
|
},
|
||||||
|
"tx_json": {
|
||||||
|
"$ref": "tx",
|
||||||
|
"description": "The complete transaction in JSON format."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["resultCode", "resultMessage"],
|
"required": ["resultCode", "resultMessage", "engine_result", "engine_result_code", "engine_result_message", "tx_blob", "tx_json"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,15 @@ function isImmediateRejection(engineResult: string): boolean {
|
|||||||
|
|
||||||
function formatSubmitResponse(response): FormattedSubmitResponse {
|
function formatSubmitResponse(response): FormattedSubmitResponse {
|
||||||
const data = {
|
const data = {
|
||||||
|
// @deprecated
|
||||||
resultCode: response.engine_result,
|
resultCode: response.engine_result,
|
||||||
resultMessage: response.engine_result_message
|
// @deprecated
|
||||||
|
resultMessage: response.engine_result_message,
|
||||||
|
engine_result: response.engine_result,
|
||||||
|
engine_result_code: response.engine_result_code,
|
||||||
|
engine_result_message: response.engine_result_message,
|
||||||
|
tx_blob: response.tx_blob,
|
||||||
|
tx_json: response.tx_json
|
||||||
}
|
}
|
||||||
if (isImmediateRejection(response.engine_result)) {
|
if (isImmediateRejection(response.engine_result)) {
|
||||||
throw new utils.common.errors.RippledError('Submit failed', data)
|
throw new utils.common.errors.RippledError('Submit failed', data)
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ function checkResult(expected, schemaName, response) {
|
|||||||
assert(response.txJSON);
|
assert(response.txJSON);
|
||||||
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON));
|
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON));
|
||||||
}
|
}
|
||||||
assert.deepEqual(_.omit(response, 'txJSON'), _.omit(expected, 'txJSON'));
|
if (expected.tx_json) {
|
||||||
|
assert(response.tx_json);
|
||||||
|
assert.deepEqual(response.tx_json, expected.tx_json);
|
||||||
|
}
|
||||||
|
assert.deepEqual(_.omit(response, 'txJSON'), _.omit(expected, 'txJSON'), _.omit(response, 'tx_json'), _.omit(response, 'tx_json'));
|
||||||
if (schemaName) {
|
if (schemaName) {
|
||||||
schemaValidator.schemaValidate(schemaName, response);
|
schemaValidator.schemaValidate(schemaName, response);
|
||||||
}
|
}
|
||||||
@@ -1536,8 +1540,9 @@ describe('RippleAPI', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('submit', function () {
|
it('submit', function () {
|
||||||
return this.api.submit(responses.sign.normal.signedTransaction).then(
|
return this.api.submit(responses.sign.normal.signedTransaction).then(response => {
|
||||||
_.partial(checkResult, responses.submit, 'submit'));
|
checkResult(responses.submit, 'submit', response);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('submit - failure', function () {
|
it('submit - failure', function () {
|
||||||
|
|||||||
22
test/fixtures/responses/submit.json
vendored
22
test/fixtures/responses/submit.json
vendored
@@ -1,4 +1,24 @@
|
|||||||
{
|
{
|
||||||
"resultCode": "tesSUCCESS",
|
"resultCode": "tesSUCCESS",
|
||||||
"resultMessage": "The transaction was applied. Only final in a validated ledger."
|
"resultMessage": "The transaction was applied. Only final in a validated ledger.",
|
||||||
|
"engine_result": "tesSUCCESS",
|
||||||
|
"engine_result_code": 0,
|
||||||
|
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
||||||
|
"tx_blob": "1200002280000000240000016861D4838D7EA4C6800000000000000000000000000055534400000000004B4E9C06F24296074F7BC48F92A97916C6DC5EA9684000000000002710732103AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB7446304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F858081144B4E9C06F24296074F7BC48F92A97916C6DC5EA983143E9D4A2B8AA0780F682D136F7A56D6724EF53754",
|
||||||
|
"tx_json": {
|
||||||
|
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||||
|
"Amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||||
|
"value": "1"
|
||||||
|
},
|
||||||
|
"Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
|
||||||
|
"Fee": "10000",
|
||||||
|
"Flags": 2147483648,
|
||||||
|
"Sequence": 360,
|
||||||
|
"SigningPubKey": "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB",
|
||||||
|
"TransactionType": "Payment",
|
||||||
|
"TxnSignature": "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580",
|
||||||
|
"hash": "4D5D90890F8D49519E4151938601EF3D0B30B16CD6A519D9C99102C9FA77F7E0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
test/fixtures/rippled/submit.json
vendored
19
test/fixtures/rippled/submit.json
vendored
@@ -7,7 +7,22 @@
|
|||||||
"engine_result": "tesSUCCESS",
|
"engine_result": "tesSUCCESS",
|
||||||
"engine_result_code": 0,
|
"engine_result_code": 0,
|
||||||
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
|
||||||
"tx_blob": "12000322000000002400000017201B0086955468400000000000000C732102F89EAEC7667B30F33D0687BBA86C3FE2A08CCA40A9186C5BDE2DAA6FA97A37D87446304402207660BDEF67105CE1EBA9AD35DC7156BAB43FF1D47633199EE257D70B6B9AAFBF02207F5517BC8AEF2ADC1325897ECDBA8C673838048BCA62F4E98B252F19BE88796D770A726970706C652E636F6D81144FBFF73DA4ECF9B701940F27341FA8020C313443",
|
"tx_blob": "1200002280000000240000016861D4838D7EA4C6800000000000000000000000000055534400000000004B4E9C06F24296074F7BC48F92A97916C6DC5EA9684000000000002710732103AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB7446304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F858081144B4E9C06F24296074F7BC48F92A97916C6DC5EA983143E9D4A2B8AA0780F682D136F7A56D6724EF53754",
|
||||||
"tx_json": {}
|
"tx_json": {
|
||||||
|
"Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||||
|
"Amount": {
|
||||||
|
"currency": "USD",
|
||||||
|
"issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||||
|
"value": "1"
|
||||||
|
},
|
||||||
|
"Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
|
||||||
|
"Fee": "10000",
|
||||||
|
"Flags": 2147483648,
|
||||||
|
"Sequence": 360,
|
||||||
|
"SigningPubKey": "03AB40A0490F9B7ED8DF29D246BF2D6269820A0EE7742ACDD457BEA7C7D0931EDB",
|
||||||
|
"TransactionType": "Payment",
|
||||||
|
"TxnSignature": "304402200E5C2DD81FDF0BE9AB2A8D797885ED49E804DBF28E806604D878756410CA98B102203349581946B0DDA06B36B35DBC20EDA27552C1F167BCF5C6ECFF49C6A46F8580",
|
||||||
|
"hash": "4D5D90890F8D49519E4151938601EF3D0B30B16CD6A519D9C99102C9FA77F7E0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user