// Variant setup for generate creds button from interactive-tutorial.js. // This version generates two sets of creds, one for the issuer and one for // the hot wallet / receiver const EXAMPLE_COLD_ADDR = "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe" const EXAMPLE_COLD_SECRET = "sIss█████████████████████████" function setup_2x_generate_step() { $("#generate-2x-creds-button").click( async (event) => { const block = $(event.target).closest(".interactive-block") block.find(".output-area").html("") block.find(".loader").show() // Get faucet URL (Testnet/Devnet/etc.) const faucet_url = $("#generate-2x-creds-button").data("fauceturl") try { const data = await call_faucet(faucet_url) const data2 = await call_faucet(faucet_url) block.find(".loader").hide() block.find(".output-area").html(`
${tl("Cold Address:")} ${data.account.address}
${tl("Cold Secret:")} ${data.account.secret}
${tl("XRP Balance:")} ${Number(data.balance).toLocaleString(current_locale)} XRP
${tl("Hot Address:")} ${data2.account.address}
${tl("Hot Secret:")} ${data2.account.secret}
${tl("XRP Balance:")} ${Number(data2.balance).toLocaleString(current_locale)} XRP
`) // TODO: Automatically populate all examples in the page with the // generated credentials... // $("code span:contains('"+EXAMPLE_ADDR+"')").each( function() { // let eltext = $(this).text() // $(this).text( eltext.replace(EXAMPLE_ADDR, data.account.address) ) // }) // $("code span:contains('"+EXAMPLE_SECRET+"')").each( function() { // let eltext = $(this).text() // $(this).text( eltext.replace(EXAMPLE_SECRET, data.account.secret) ) // }) // // block.find(".output-area").append(`

${tl("Populated this page's examples with these credentials.")}

`) complete_step("Generate") } catch(err) { block.find(".loader").hide() block.find(".output-area").html( `

${tl("Error:")} ${tl("There was an error connecting to the Faucet. Please try again.")}

`) return } }) } $(document).ready(() => { setup_2x_generate_step() })