Compare commits

...

3 Commits

Author SHA1 Message Date
natenichols
bca2382ba1 fix: waitForFinalTransactionOutcome 2021-12-23 16:16:57 -06:00
Elliot Lee
5d556c6afe HISTORY.md - add package release history links (#1861) 2021-12-21 12:03:39 -08:00
Matthew Rosendin
d021c1412f Update APPLICATIONS.md (#1842)
Co-authored-by: Elliot Lee <github.public@intelliot.com>
Co-authored-by: ledhed2222 <ledhed2222@users.noreply.github.com>
2021-12-18 02:02:07 -05:00
3 changed files with 37 additions and 16 deletions

View File

@@ -109,6 +109,10 @@ Warning: Use at your own risk.
- **[XRP Account Mnemonic Recovery](https://github.com/WietseWind/xrp-mnemonic-recovery)** (uses `ripple-keypairs`)
Recover a 24 word mnemonic if one word is wrong or one word is missing.
- **[Trustline](https://trustline.co)**
A decentralized stablecoin wallet that runs on the XRP Ledger.
## Send and request payments

View File

@@ -1,3 +1,12 @@
# xrpl.js (ripple-lib) Release History
# Release History (Changelog)
Please see the individual HISTORY.md documents in each package for changes.
Please see the individual HISTORY.md documents in each package for changes:
* [Release History for **xrpl.js**](packages/xrpl/HISTORY.md) (formerly known as ripple-lib)
* The **xrpl** package is a TypeScript/JavaScript library for interacting with the [XRP Ledger](https://xrpl.org/).
* [Release History for **ripple-address-codec**](packages/ripple-address-codec/HISTORY.md)
* The **ripple-address-codec** package provides functions for encoding and decoding XRP Ledger [addresses](https://xrpl.org/basic-data-types.html#addresses) and seeds.
* [Release History for **ripple-binary-codec**](packages/ripple-binary-codec/HISTORY.md)
* The **ripple-binary-codec** package provides functions to encode to, and decode from, the [XRPL binary serialization format](https://xrpl.org/serialization.html).
* [Release History for **ripple-keypairs**](packages/ripple-keypairs/HISTORY.md)
* The **ripple-keypairs** package implements [XRPL cryptographic keypair](https://xrpl.org/cryptographic-keys.html) and wallet generation, with support for rfc6979 and EdDSA deterministic signatures.

View File

@@ -74,7 +74,9 @@ async function submitAndWait(
): Promise<TxResponse> {
const signedTx = await getSignedTx(this, transaction, opts)
if (!hasLastLedgerSequence(signedTx)) {
const lastLedger = getLastLedgerSequence(signedTx)
if (lastLedger == null) {
throw new ValidationError(
'Transaction must contain a LastLedgerSequence value for reliable submission.',
)
@@ -83,7 +85,7 @@ async function submitAndWait(
await submitRequest(this, signedTx, opts?.failHard)
const txHash = hashes.hashSignedTx(signedTx)
return waitForFinalTransactionOutcome(this, txHash)
return waitForFinalTransactionOutcome(this, txHash, lastLedger)
}
// Helper functions
@@ -119,6 +121,7 @@ async function submitRequest(
async function waitForFinalTransactionOutcome(
client: Client,
txHash: string,
lastLedger: number
): Promise<TxResponse> {
await sleep(LEDGER_CLOSE_TIME)
@@ -126,22 +129,27 @@ async function waitForFinalTransactionOutcome(
command: 'tx',
transaction: txHash,
})
if (txResponse.result.validated) {
return txResponse
}
.catch((error) => {
const message = error.data.error as string
if (message !== 'txnNotFound') {
throw error
}
return null
})
if (txResponse && txResponse.result.validated)
return txResponse
const txLastLedger = txResponse.result.LastLedgerSequence
if (txLastLedger == null) {
throw new XrplError('LastLedgerSequence cannot be null')
}
const latestLedger = await client.getLedgerIndex()
if (txLastLedger > latestLedger) {
return waitForFinalTransactionOutcome(client, txHash)
if (latestLedger > lastLedger) {
return waitForFinalTransactionOutcome(client, txHash, lastLedger)
}
throw new XrplError(
`The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${txLastLedger}).`,
`The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${lastLedger}).`,
)
}
@@ -194,9 +202,9 @@ async function getSignedTx(
}
// checks if there is a LastLedgerSequence as a part of the transaction
function hasLastLedgerSequence(transaction: Transaction | string): boolean {
function getLastLedgerSequence(transaction: Transaction | string): number | null {
const tx = typeof transaction === 'string' ? decode(transaction) : transaction
return typeof tx !== 'string' && tx.LastLedgerSequence != null
return tx.LastLedgerSequence as number
}
// checks if the transaction is an AccountDelete transaction