Ignore initial result of tx submission (RLJS-607)

This commit is contained in:
Elliot Lee
2018-08-02 12:21:23 -07:00
committed by GitHub
parent 992141a8f3
commit 2edf59fae8

View File

@@ -1,7 +1,6 @@
'use strict'; 'use strict';
/* import RippleAPI and support libraries */ /* import RippleAPI and support libraries */
const RippleAPI = require('ripple-lib').RippleAPI; const RippleAPI = require('ripple-lib').RippleAPI;
const assert = require('assert');
/* Credentials of the account placing the order */ /* Credentials of the account placing the order */
const myAddr = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn'; const myAddr = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
@@ -32,7 +31,7 @@ const myInstructions = {maxLedgerVersionOffset: ledgerOffset};
/* Verify a transaction is in a validated XRP Ledger version */ /* Verify a transaction is in a validated XRP Ledger version */
function verifyTransaction(hash, options) { function verifyTransaction(hash, options) {
console.log('Verifing Transaction'); console.log('Verifying Transaction');
return api.getTransaction(hash, options).then(data => { return api.getTransaction(hash, options).then(data => {
console.log('Final Result: ', data.outcome.result); console.log('Final Result: ', data.outcome.result);
console.log('Validated in Ledger: ', data.outcome.ledgerVersion); console.log('Validated in Ledger: ', data.outcome.ledgerVersion);
@@ -58,11 +57,10 @@ function submitTransaction(lastClosedLedgerVersion, prepared, secret) {
return api.submit(signedData.signedTransaction).then(data => { return api.submit(signedData.signedTransaction).then(data => {
console.log('Tentative Result: ', data.resultCode); console.log('Tentative Result: ', data.resultCode);
console.log('Tentative Message: ', data.resultMessage); console.log('Tentative Message: ', data.resultMessage);
/* If transaction was not successfully submitted throw error */ /* The tentative result should be ignored. Transactions that succeed here can ultimately fail,
assert.strictEqual(data.resultCode, 'tesSUCCESS'); and transactions that fail here can ultimately succeed. */
/* 'tesSUCCESS' means the transaction is being considered for the next ledger, and requires validation. */
/* If successfully submitted, begin validation workflow */ /* Begin validation workflow */
const options = { const options = {
minLedgerVersion: lastClosedLedgerVersion, minLedgerVersion: lastClosedLedgerVersion,
maxLedgerVersion: prepared.instructions.maxLedgerVersion maxLedgerVersion: prepared.instructions.maxLedgerVersion