mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 11:45:50 +00:00
xrpl.js: Update to 2.0.0b2
This commit is contained in:
@@ -32,6 +32,9 @@ function lookup_tx_final(api, tx_id, max_ledger, min_ledger) {
|
||||
[min_ledger, max_ledger] = [max_ledger, min_ledger]
|
||||
}
|
||||
|
||||
// Make sure we're subscribed to the ledger stream to trigger updates
|
||||
api.request({"command": "subscribe", "streams": ["ledger"]})
|
||||
|
||||
// Helper to determine if we (should) know the transaction's final result yet.
|
||||
// If the server has validated all ledgers the tx could possibly appear in,
|
||||
// then we should know its final result.
|
||||
|
||||
@@ -156,8 +156,8 @@ const set_up_tx_sender = async function() {
|
||||
|
||||
try {
|
||||
// use lookup_tx_final() from submit-and-verify2.js
|
||||
let final_result_data = await lookup_tx_final(api, tx_id, max_ledger, min_ledger)
|
||||
let final_result = final_result_data.meta.TransactionResult
|
||||
let final_result_data = await lookup_tx_final(api, hash, max_ledger, min_ledger)
|
||||
let final_result = final_result_data.result.meta.TransactionResult
|
||||
if (!silent) {
|
||||
if (final_result === "tesSUCCESS") {
|
||||
successNotif(`${tx_object.TransactionType} tx succeeded (hash: ${hash})`)
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script src="https://unpkg.com/ripple-lib@1.10.0/build/ripple-latest-min.js"></script>
|
||||
<!-- TODO: re-add CDN version instead of local version
|
||||
<script src="https://unpkg.com/ripple-lib@1.10.0/build/ripple-latest-min.js"></script> -->
|
||||
<script type="application/javascript" src="../../../assets/js/xrpl-2.0.0b2.min.js"></script>
|
||||
<script type="application/javascript" src="../submit-and-verify/submit-and-verify.js"></script>
|
||||
<script type="application/javascript" src="require-destination-tags.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
'use strict'
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
// Sample code demonstrating secure offline signing using xrpl.js library.
|
||||
const xrpl = require('xrpl')
|
||||
|
||||
// Load address & secret from environment variables:
|
||||
const from_address = process.env['MY_ADDRESS']
|
||||
const secret = process.env['MY_SECRET']
|
||||
// Load seed value from an environment variable:
|
||||
const my_wallet = xrpl.Wallet.fromSeed(process.env['MY_SEED'])
|
||||
|
||||
// Can sign offline if the txJSON has all required fields
|
||||
const api = new RippleAPI()
|
||||
// For offline signing, you need to know your address's next Sequence number
|
||||
let my_seq = 21404872
|
||||
|
||||
const txJSON = JSON.stringify({
|
||||
"Account": from_address,
|
||||
// Provide *all* required fields before signing a transaction
|
||||
const txJSON = {
|
||||
"Account": my_wallet.classicAddress,
|
||||
"TransactionType":"Payment",
|
||||
"Destination":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"Amount":"13000000",
|
||||
"Flags":2147483648,
|
||||
"LastLedgerSequence":7835923,
|
||||
"LastLedgerSequence":7835923, // Optional, but recommended.
|
||||
"Fee":"13",
|
||||
"Sequence":2
|
||||
})
|
||||
"Sequence": my_seq
|
||||
}
|
||||
|
||||
const signed = api.sign(txJSON, secret)
|
||||
const tx_blob = my_wallet.signTransaction(txJSON)
|
||||
|
||||
console.log("tx_blob is:", signed.signedTransaction)
|
||||
console.log("tx hash is:", signed.id)
|
||||
console.log("tx_blob is:", tx_blob)
|
||||
console.log("tx hash is:", xrpl.computeBinaryTransactionSigningHash(tx_blob))
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<title>Code Sample - Send XRP</title>
|
||||
<!-- TODO: re-add CDN version instead of local version
|
||||
<script src="https://unpkg.com/ripple-lib@1.10.0/build/ripple-latest-min.js"></script> -->
|
||||
<script type="application/javascript" src="../../../assets/js/xrpl-2.0b0.min.js"></script>
|
||||
<script type="application/javascript" src="../../../assets/js/xrpl-2.0.0b2.min.js"></script>
|
||||
<script type="application/javascript" src="../submit-and-verify/submit-and-verify2.js"></script>
|
||||
<script type="application/javascript" src="send-xrp.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -64,7 +64,7 @@ default_keys: &defaults
|
||||
hover_anchors: <i class="fa fa-link"></i>
|
||||
light_theme_enabled: true
|
||||
# Script tags used in a variety of tools & examples.
|
||||
ripple_lib_tag: '<script type="application/javascript" src="assets/js/xrpl-2.0b0.min.js"></script>'
|
||||
ripple_lib_tag: '<script type="application/javascript" src="assets/js/xrpl-2.0.0b2.min.js"></script>'
|
||||
|
||||
targets:
|
||||
# First member is the default that gets built when target not specified
|
||||
|
||||
Reference in New Issue
Block a user