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