mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
xrpl.js 2.0: start migrating code (incomplete)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const xrpl = ripple; // TODO: remove when webpack build is updated
|
||||
|
||||
jQuery(function ($) {
|
||||
const FULL_HISTORY_SERVER = "wss://s2.ripple.com"
|
||||
const reTxId = /^[0-9A-Fa-f]{64}$/
|
||||
@@ -7,11 +9,13 @@ jQuery(function ($) {
|
||||
let currentMarker
|
||||
let nextMarker
|
||||
|
||||
const api = new ripple.RippleAPI({server: FULL_HISTORY_SERVER})
|
||||
const api = new xrpl.Client(FULL_HISTORY_SERVER)
|
||||
|
||||
api.on('connected', () => {
|
||||
const target = location.hash.slice(1);
|
||||
if (api.isValidAddress(target) ||
|
||||
// TODO: switch back to isValidAddress
|
||||
if (api.isValidClassicAddress(target) ||
|
||||
api.isValidXAddress(target) ||
|
||||
reTxId.exec(target) ||
|
||||
reLedgerSeq.exec(target)) {
|
||||
$('#target').val(target);
|
||||
@@ -45,7 +49,8 @@ jQuery(function ($) {
|
||||
$("#permalink").attr("href", locationWithoutHash + "#" + target);
|
||||
$("#explorerlink").attr("href", ""); // Reset
|
||||
|
||||
if (api.isValidAddress(target)) { // Account -------------------------------
|
||||
// TODO: switch back to isValidAddress()
|
||||
if (api.isValidClassicAddress(target)) { // Account -------------------------------
|
||||
let account = target;
|
||||
previousMarkers = []
|
||||
nextMarker = undefined
|
||||
@@ -57,20 +62,23 @@ jQuery(function ($) {
|
||||
$("#progress .progress-bar").css("width", "10%");
|
||||
|
||||
try {
|
||||
let result = await api.request("account_info", {account})
|
||||
$("#progress .progress-bar").css("width", "20%");
|
||||
console.log('account_info', result);
|
||||
format(result, $("#account_info"));
|
||||
let command = "account_info"
|
||||
let result = await api.request({command, account})
|
||||
$("#progress .progress-bar").css("width", "20%")
|
||||
console.log('account_info', result)
|
||||
format(result, $("#account_info"))
|
||||
|
||||
result = await api.request("account_lines", {account})
|
||||
$("#progress .progress-bar").css("width", "40%");
|
||||
console.log('account_lines', result);
|
||||
format(result, $("#account_lines"));
|
||||
command = "account_lines"
|
||||
result = await api.request({command, account})
|
||||
$("#progress .progress-bar").css("width", "40%")
|
||||
console.log('account_lines', result)
|
||||
format(result, $("#account_lines"))
|
||||
|
||||
result = await pagedAccountTx(account);
|
||||
$("#progress .progress-bar").css("width", "60%");
|
||||
|
||||
result = await api.request("account_objects", {account})
|
||||
command = "account_objects"
|
||||
result = await api.request({command, account})
|
||||
$("#progress .progress-bar").css("width", "80%");
|
||||
console.log('account_objects', result);
|
||||
format(result, $("#account_objects"));
|
||||
@@ -92,7 +100,8 @@ jQuery(function ($) {
|
||||
|
||||
$("#progress .progress-bar").css("width", "10%");
|
||||
try {
|
||||
let result = await api.request("ledger", {
|
||||
let result = await api.request({
|
||||
command: "ledger",
|
||||
ledger_index: target,
|
||||
transactions: true,
|
||||
expand: true
|
||||
@@ -114,7 +123,8 @@ jQuery(function ($) {
|
||||
|
||||
try {
|
||||
$("#progress .progress-bar").css("width", "10%");
|
||||
let result = await api.request("tx", {
|
||||
let result = await api.request({
|
||||
command: "tx",
|
||||
transaction: target,
|
||||
binary: false
|
||||
})
|
||||
@@ -229,6 +239,7 @@ jQuery(function ($) {
|
||||
|
||||
async function pagedAccountTx(account, page) {
|
||||
let opts = {
|
||||
"command": "account_tx",
|
||||
"account": account,
|
||||
"ledger_index_min": -1,
|
||||
"ledger_index_max": -1,
|
||||
@@ -251,7 +262,7 @@ jQuery(function ($) {
|
||||
currentMarker = opts["marker"]
|
||||
}
|
||||
|
||||
let result = await api.request("account_tx", opts)
|
||||
let result = await api.request(opts)
|
||||
console.log('account_tx', result)
|
||||
format(result, $("#account_tx").empty())
|
||||
updateTxMarkerNav(result)
|
||||
|
||||
Reference in New Issue
Block a user