mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
Compare commits
3 Commits
xrpl@2.1.0
...
nn/wait-fo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bca2382ba1 | ||
|
|
5d556c6afe | ||
|
|
d021c1412f |
@@ -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
|
||||
|
||||
|
||||
13
HISTORY.md
13
HISTORY.md
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user