From 69641175ce9ed71f30365a16db80e392679043b3 Mon Sep 17 00:00:00 2001 From: mDuo13 Date: Wed, 13 Oct 2021 17:37:37 -0700 Subject: [PATCH] xrpl.js 2.0: small code updates --- assets/js/tutorials/send-xrp.js | 2 +- content/_code-samples/get-started/js/get-acct-info.js | 2 +- content/_code-samples/send-xrp/send-xrp.js | 5 +---- content/tutorials/get-started/send-xrp.md | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/assets/js/tutorials/send-xrp.js b/assets/js/tutorials/send-xrp.js index 1ef4e68ad3..0b946e83c3 100644 --- a/assets/js/tutorials/send-xrp.js +++ b/assets/js/tutorials/send-xrp.js @@ -44,7 +44,7 @@ $("#sign-button").click( function(event) { const wallet = get_wallet(event) if (!wallet) {return} - {tx_blob, hash} = wallet.sign(preparedTxJSON) + const {tx_blob, hash} = wallet.sign(preparedTxJSON) block.find(".output-area").html( `
Signed Transaction blob: diff --git a/content/_code-samples/get-started/js/get-acct-info.js b/content/_code-samples/get-started/js/get-acct-info.js index 8c90d5bfe3..ac3a053e10 100644 --- a/content/_code-samples/get-started/js/get-acct-info.js +++ b/content/_code-samples/get-started/js/get-acct-info.js @@ -10,8 +10,8 @@ async function main() { await client.connect() // Create a wallet and fund it with the Testnet faucet: - const test_wallet = new xrpl.Wallet() // TODO: change to define based on fundWallet result const fund_result = await client.fundWallet(test_wallet) + const test_wallet = fund_result.wallet console.log(fund_result) // Get info from the ledger about the address we just funded diff --git a/content/_code-samples/send-xrp/send-xrp.js b/content/_code-samples/send-xrp/send-xrp.js index baa8b4f225..6fcf1cf997 100644 --- a/content/_code-samples/send-xrp/send-xrp.js +++ b/content/_code-samples/send-xrp/send-xrp.js @@ -32,10 +32,7 @@ api.on('connected', async () => { // The earliest ledger a transaction could appear in is the first ledger // after the one that's already validated at the time it's *first* submitted. const min_ledger = (await api.getLedgerIndex()) + 1 - const result = await api.request({ - "command": "submit", - "tx_blob": signed.tx_blob - }) + const result = await api.submit(signed.tx_blob) console.log("Tentative result code:", result.result.engine_result) console.log("Tentative result message:", result.result.engine_result_message) diff --git a/content/tutorials/get-started/send-xrp.md b/content/tutorials/get-started/send-xrp.md index 2e6297517c..01fdd853e6 100644 --- a/content/tutorials/get-started/send-xrp.md +++ b/content/tutorials/get-started/send-xrp.md @@ -196,7 +196,7 @@ The result of the signing operation is a transaction object containing a signatu Now that you have a signed transaction, you can submit it to an XRP Ledger server, and that server will relay it through the network. It's also a good idea to take note of the latest validated ledger index before you submit. The earliest ledger version that your transaction could get into as a result of this submission is one higher than the latest validated ledger when you submit it. Of course, if the same transaction was previously submitted, it could already be in a previous ledger. (It can't succeed a second time, but you may not realize it succeeded if you aren't looking in the right ledger versions.) -- **JavaScript:** Use the [`submitReliable()` method of the Client](TODO: link) to submit a transaction to the network and wait for the response. +- **JavaScript:** Use the [`submitSignedReliable()` method of the Client](https://js.xrpl.org/classes/Client.html#submitSignedReliable) to submit a signed transaction to the network and wait for the response, or use [`submitSigned()`](https://js.xrpl.org/classes/Client.html#submitSigned) to submit a transaction and get only the preliminary response. - **Python:** Use the [`xrpl.transaction.send_reliable_submission()` method](https://xrpl-py.readthedocs.io/en/latest/source/xrpl.transaction.html#xrpl.transaction.send_reliable_submission) to submit a transaction to the network and wait for a response. - **Java:** Use the [`XrplClient.submit(SignedTransaction)` method](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#submit(org.xrpl.xrpl4j.crypto.signing.SignedTransaction)) to submit a transaction to the network. Use the [`XrplClient.ledger()`](https://javadoc.io/doc/org.xrpl/xrpl4j-client/latest/org/xrpl/xrpl4j/client/XrplClient.html#ledger(org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams)) method to get the latest validated ledger index.