mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 03:35:51 +00:00
xrpl.js 2.0: update issue a token sample code, etc.
This commit is contained in:
@@ -36,15 +36,15 @@ function lookup_tx_final(api, tx_id, max_ledger, min_ledger) {
|
||||
// then we should know its final result.
|
||||
async function server_has_ledger_range(min_ledger, max_ledger) {
|
||||
const si = await api.request({command: "server_info"})
|
||||
// console.log(`Server has ledger range: ${si.info.complete_ledgers}`)
|
||||
if (si.info.complete_ledgers == "empty") {
|
||||
// console.log(`Server has ledger range: ${si.result.info.complete_ledgers}`)
|
||||
if (si.result.info.complete_ledgers == "empty") {
|
||||
console.warn("Connected server is not synced.")
|
||||
return false
|
||||
}
|
||||
// In case of a discontiguous set, use only the last set, since we need
|
||||
// continuous history from submission to expiration to know that a
|
||||
// transaction failed to achieve consensus.
|
||||
const ledger_ranges = si.info.complete_ledgers.split(',')
|
||||
const ledger_ranges = si.result.info.complete_ledgers.split(',')
|
||||
// Note: last_range can be in the form 'x-y' or just 'y'
|
||||
const last_range = ledger_ranges[ledger_ranges.length -1].split('-')
|
||||
const lr_min = parseInt(last_range[0])
|
||||
@@ -59,15 +59,15 @@ function lookup_tx_final(api, tx_id, max_ledger, min_ledger) {
|
||||
return new Promise((resolve, reject) => {
|
||||
ledger_listener = async (ledger) => {
|
||||
try {
|
||||
tx_result = await api.request({
|
||||
const tx_response = await api.request({
|
||||
"command": "tx",
|
||||
"transaction": tx_id,
|
||||
"min_ledger": min_ledger,
|
||||
"max_ledger": max_ledger
|
||||
})
|
||||
|
||||
if (tx_result.validated) {
|
||||
resolve(tx_result.meta.TransactionResult)
|
||||
if (tx_response.result.validated) {
|
||||
resolve(tx_response.result.meta.TransactionResult)
|
||||
} else if (ledger.ledger_index >= max_ledger) {
|
||||
api.off("ledgerClosed", ledger_listener)
|
||||
// Transaction found, not validated, but we should have a final result
|
||||
@@ -145,15 +145,15 @@ function lookup_tx_final(api, tx_id, max_ledger, min_ledger) {
|
||||
// something else went wrong when trying to look up the results. The
|
||||
// warning written to the console can tell you more about what happened.
|
||||
async function submit_and_verify(api, tx_blob) {
|
||||
const prelim_result = await api.request({"command": "submit", "tx_blob": tx_blob})
|
||||
console.log("Preliminary result code:", prelim_result.engine_result)
|
||||
const min_ledger = prelim_result.validated_ledger_index
|
||||
if (prelim_result.tx_json.LastLedgerSequence === undefined) {
|
||||
const prelim = await api.request({"command": "submit", "tx_blob": tx_blob})
|
||||
console.log("Preliminary result code:", prelim.result.engine_result)
|
||||
const min_ledger = prelim.result.validated_ledger_index
|
||||
if (prelim.result.tx_json.LastLedgerSequence === undefined) {
|
||||
console.warn("Transaction has no LastLedgerSequence field. "+
|
||||
"It may be impossible to determine final failure.")
|
||||
}
|
||||
const max_ledger = prelim_result.tx_json.LastLedgerSequence
|
||||
const tx_id = prelim_result.tx_json.hash
|
||||
const max_ledger = prelim.result.tx_json.LastLedgerSequence
|
||||
const tx_id = prelim.result.tx_json.hash
|
||||
|
||||
let final_result
|
||||
try {
|
||||
|
||||
@@ -153,7 +153,7 @@ const set_up_tx_sender = async function() {
|
||||
}
|
||||
|
||||
// Wait for tx to be in a validated ledger or to expire
|
||||
const hash = xrpl.computeBinaryTransactionSigningHash(signed)
|
||||
const hash = xrpl.computeSignedTransactionHash(signed)
|
||||
|
||||
try {
|
||||
// use lookup_tx_final() from submit-and-verify2.js
|
||||
|
||||
2
assets/js/xrpl-2.0b0.min.js
vendored
2
assets/js/xrpl-2.0b0.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user