mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-19 11:15:49 +00:00
JS Naming Conventions & Test File Logging
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
// This code takes in a wallet address, checks the domain field, then gets the TOML info to verify the domains ownership.
|
||||
// This is runnable in NODE JS for easier testing, and works the same as the code in xrp-ledger-toml-checker.js
|
||||
// This is runnable in NODE JS for easier testing, and works the same as the code in xrp-ledger-toml-checker.js
|
||||
const WebSocket = require('ws');
|
||||
const https = require('https');
|
||||
const TOML = require('../vendor/iarna-toml-parse');
|
||||
|
||||
const TOML_PATH = "/.well-known/xrp-ledger.toml"
|
||||
const TIPS = 'Check if the file is actually hosted at the URL above, check your server\'s HTTPS settings and certificate, and make sure your server provides the required CORS header.\n'
|
||||
const TIPS_1 = 'Make sure you are entering a valid XRP address.\n'
|
||||
const TIPS_2 = 'Make sure the wallet address has the domain field.\n'
|
||||
|
||||
const ACCOUNT_FIELDS = [
|
||||
"address",
|
||||
@@ -15,21 +12,20 @@ const ACCOUNT_FIELDS = [
|
||||
"desc"
|
||||
]
|
||||
|
||||
// set 'wallet' to any of these test wallets
|
||||
const works2 = 'rSTAYKxF2K77ZLZ8GoAwTqPGaphAqMyXV'
|
||||
const works = 'r4MPhp7NeayAohgEd8FWSUV6eR2nLGwDX3'
|
||||
const no_toml2 = 'rV64miFA53xbWS3x9A6nRnzxMqLHN1t2h'
|
||||
const no_toml = 'rsoLo2S1kiGeCcn6hCUXVrCpGMWLrRrLZz'
|
||||
const no_domain = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
|
||||
const wallet = no_toml
|
||||
// Test wallet addresses
|
||||
const WORKS = 'rSTAYKxF2K77ZLZ8GoAwTqPGaphAqMyXV'
|
||||
const NOTOML = 'rsoLo2S1kiGeCcn6hCUXVrCpGMWLrRrLZz'
|
||||
const NODOMAIN = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
|
||||
|
||||
let socket;
|
||||
|
||||
function makeLogEntry(text) {
|
||||
log = console.log(text + '\n')
|
||||
}
|
||||
|
||||
function fetch_file_1(domain) {
|
||||
// NODE AJAX equivalent
|
||||
function fetchFile(domain) {
|
||||
const url = "https://" + domain + TOML_PATH
|
||||
console.log('Checking ' + url + '\n')
|
||||
|
||||
makeLogEntry('CHECKING DOMAIN: ' + url)
|
||||
https.get(url, (resp) => {
|
||||
let data = '';
|
||||
resp.on('data', (chunk) => {
|
||||
@@ -37,22 +33,24 @@ function fetch_file_1(domain) {
|
||||
});
|
||||
resp.on('end', () => {
|
||||
if (data != '') {
|
||||
console.log('TOML Found\n');
|
||||
parse_xrpl_toml_1(data, domain)
|
||||
makeLogEntry('TOML FILE: Found');
|
||||
parseXrplToml(data)
|
||||
} else {
|
||||
console.log(TIPS)
|
||||
process.exit()
|
||||
makeLogEntry('TOML FILE: Not found')
|
||||
makeLogEntry('WALLET CAN NOT BE VERIFIED: TOML file was not found.')
|
||||
return
|
||||
}
|
||||
});
|
||||
}).on("error", (err) => {
|
||||
console.log("Error: " + err.message);
|
||||
process.exit()
|
||||
if (err.code == 'ENOTFOUND') {
|
||||
makeLogEntry('WALLET CAN NOT BE VERIFIED: Network error while fetching TOML file.')
|
||||
}
|
||||
return
|
||||
});
|
||||
}
|
||||
|
||||
function fetch_wallet_1() {
|
||||
console.log('Checking domain of wallet...\n')
|
||||
|
||||
function fetchWallet() {
|
||||
makeLogEntry('\nCHECKING DOMAIN OF WALLET...')
|
||||
const url = "wss://xrplcluster.com"
|
||||
if (typeof socket !== "undefined" && socket.readyState < 2) {
|
||||
socket.close()
|
||||
@@ -69,20 +67,30 @@ function fetch_wallet_1() {
|
||||
if (data.status === 'success') {
|
||||
if (data.result.account_data.Domain) {
|
||||
try {
|
||||
decode_hex_1(data.result.account_data.Domain)
|
||||
makeLogEntry('WALLET ADDRESS: Valid')
|
||||
decodeHex(data.result.account_data.Domain)
|
||||
} catch {
|
||||
console.log('error decoding domain field: ' + data.result.account_data.Domain)
|
||||
makeLogEntry('error decoding domain field: ' + data.result.account_data.Domain)
|
||||
}
|
||||
} else {
|
||||
console.log(TIPS_2)
|
||||
process.exit()
|
||||
makeLogEntry('WALLET ADDRESS: Valid')
|
||||
makeLogEntry('DOMAIN DECODED: Domain field not found')
|
||||
makeLogEntry('CHECKING DOMAIN: Error')
|
||||
makeLogEntry('TOML FILE: Not found')
|
||||
makeLogEntry('WALLET CAN NOT BE VERIFIED: Wallet has no domain field.')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
console.log(TIPS_1)
|
||||
makeLogEntry('WALLET ADDRESS: Invalid')
|
||||
makeLogEntry('DOMAIN DECODED: Domain field not found')
|
||||
makeLogEntry('CHECKING DOMAIN: Error')
|
||||
makeLogEntry('TOML FILE: Not found')
|
||||
makeLogEntry('WALLET CAN NOT BE VERIFIED: Wallet address is not valid.')
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
process.exit()
|
||||
makeLogEntry(e)
|
||||
return
|
||||
}
|
||||
})
|
||||
socket.addEventListener('open', () => {
|
||||
@@ -90,33 +98,18 @@ function fetch_wallet_1() {
|
||||
})
|
||||
}
|
||||
|
||||
async function parse_xrpl_toml_1(data, domain) {
|
||||
async function parseXrplToml(data) {
|
||||
let parsed
|
||||
console.log("Parsing TOML data...\n")
|
||||
makeLogEntry("Parsing TOML data...")
|
||||
try {
|
||||
parsed = TOML(data)
|
||||
} catch (e) {
|
||||
console.log('TOML ERROR: Wallet can not be verified\n')
|
||||
process.exit()
|
||||
}
|
||||
if (parsed.hasOwnProperty("METADATA")) {
|
||||
console.log("Metadata section: ")
|
||||
if (Array.isArray(parsed.METADATA)) {
|
||||
console.log("Wrong type - should be table\n")
|
||||
} else {
|
||||
console.log("Found \n")
|
||||
if (parsed.METADATA.modified) {
|
||||
console.log("Modified date: ")
|
||||
try {
|
||||
console.log(parsed.METADATA.modified.toISOString() + '\n')
|
||||
} catch (e) {
|
||||
console.log("INVALID\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
makeLogEntry('WALLET CAN NOT BE VERIFIED: TOML file can not be read.')
|
||||
return
|
||||
}
|
||||
|
||||
async function list_entries_1(list, fields) {
|
||||
async function listEntries(list, fields) {
|
||||
makeLogEntry('\nADDRESSES:')
|
||||
let found = false;
|
||||
for (i = 0; i < list.length; i++) {
|
||||
let entry = list[i]
|
||||
@@ -124,41 +117,62 @@ async function parse_xrpl_toml_1(data, domain) {
|
||||
let fieldname = fields[j]
|
||||
if (fieldname == 'address' && entry[fieldname] !== undefined) {
|
||||
if (entry[fieldname] === wallet) {
|
||||
console.log('MATCH: ' + entry[fieldname] + ' *\n')
|
||||
makeLogEntry('MATCH: ' + entry[fieldname] + ' *')
|
||||
found = true;
|
||||
} else {
|
||||
console.log('NO_MATCH: ' + entry[fieldname] + '\n')
|
||||
makeLogEntry('NO_MATCH: ' + entry[fieldname])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
console.log('WALLET DOMAIN VERIFIED\n')
|
||||
makeLogEntry('WALLET IS PRESENT: Wallet domain verified')
|
||||
} else {
|
||||
console.log('WALLET NOT VERIFIED. WALLET NOT PRESENT IN TOML FILE\n')
|
||||
makeLogEntry('WALLET IS NOT PRESENT: Wallet domain can not be verified')
|
||||
}
|
||||
process.exit()
|
||||
return
|
||||
}
|
||||
if (parsed.ACCOUNTS) {
|
||||
if (!Array.isArray(parsed.ACCOUNTS)) {
|
||||
console.log("Wrong type- should be table-array")
|
||||
makeLogEntry("Wrong type- should be table-array")
|
||||
process.exit()
|
||||
} else {
|
||||
list_entries_1(parsed.ACCOUNTS, ACCOUNT_FIELDS)
|
||||
listEntries(parsed.ACCOUNTS, ACCOUNT_FIELDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function decode_hex_1(hex) {
|
||||
function decodeHex(hex) {
|
||||
let str = '';
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16))
|
||||
}
|
||||
console.log('Domain decoded: ' + str + '\n')
|
||||
fetch_file_1(str)
|
||||
makeLogEntry('DOMAIN DECODED: ' + str)
|
||||
fetchFile(str)
|
||||
}
|
||||
|
||||
// 'wallet' must be a global func.
|
||||
let wallet;
|
||||
|
||||
function main() {
|
||||
makeLogEntry('\n\n--------EXAMPLE OF FAIL: WEBSITE TOML ERROR--------')
|
||||
wallet = NOTOML
|
||||
fetchWallet()
|
||||
|
||||
// RUNS CODE. Edit 'wallet' CONST at top of file to change wallet.
|
||||
fetch_wallet_1()
|
||||
setTimeout(function() {
|
||||
makeLogEntry('\n\n--------EXAMPLE OF FAIL: NO DOMAIN FIELD--------')
|
||||
wallet = NODOMAIN
|
||||
fetchWallet()
|
||||
|
||||
setTimeout(function() {
|
||||
makeLogEntry('\n\n--------EXAMPLE OF SUCCESS--------')
|
||||
wallet = WORKS
|
||||
fetchWallet()
|
||||
|
||||
setTimeout(function(){process.exit()},5000)
|
||||
}, 5000)
|
||||
}, 5000)
|
||||
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -1,7 +1,7 @@
|
||||
const TOML_PATH = "/.well-known/xrp-ledger.toml"
|
||||
const TIPS = '<p>Check if the file is actually hosted at the URL above, check your server\'s HTTPS settings and certificate, and make sure your server provides the required <a href="xrp-ledger-toml.html#cors-setup">CORS header.</a></p>'
|
||||
const TIPS_1 = '<p>Make sure you are entering a valid XRP address.</p>'
|
||||
const TIPS_2 = '<p>Make sure the wallet address has the domain field.</p>'
|
||||
const TIPS = '<p>Check if the file is actually hosted at the URL above, check your server\'s HTTPS settings and certificate, and make sure your server provides the required <a href="xrp-ledger-toml.html#cors-setup">CORS header.</a></p>'
|
||||
const CLASS_GOOD = "badge badge-success"
|
||||
const CLASS_BAD = "badge badge-danger"
|
||||
|
||||
@@ -55,17 +55,28 @@ function makeLogEntry(text, raw) {
|
||||
return log
|
||||
}
|
||||
|
||||
function fetch_file() {
|
||||
function fetchFile(walletDomain) {
|
||||
var url;
|
||||
var log;
|
||||
const domain = $('#domain').val()
|
||||
const url = "https://" + domain + TOML_PATH
|
||||
if (walletDomain !== undefined) {
|
||||
url = "https://" + walletDomain + TOML_PATH
|
||||
log = makeLogEntryWallet('Checking ' + url + '...')
|
||||
} else {
|
||||
url = "https://" + domain + TOML_PATH
|
||||
log = makeLogEntry('Checking ' + url + '...')
|
||||
}
|
||||
|
||||
const log = makeLogEntry('Checking ' + url + '...')
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'text',
|
||||
success: function(data) {
|
||||
log.resolve('FOUND').addClass(CLASS_GOOD)
|
||||
parse_xrpl_toml(data, domain)
|
||||
if (typeof walletDomain !== 'undefined'){
|
||||
parseXRPLTomlWallet(data)
|
||||
} else{
|
||||
parseXRPLToml(data, domain)
|
||||
}
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
switch (status) {
|
||||
@@ -86,14 +97,14 @@ function fetch_file() {
|
||||
})
|
||||
}
|
||||
|
||||
async function parse_xrpl_toml(data, domain) {
|
||||
async function parseXRPLToml(data, domain) {
|
||||
let parsed
|
||||
let log1 = makeLogEntry("Parsing TOML data...")
|
||||
let logTOML = makeLogEntry("Parsing TOML data...")
|
||||
try {
|
||||
parsed = TOML(data)
|
||||
log1.resolve("SUCCESS").addClass(CLASS_GOOD)
|
||||
logTOML.resolve("SUCCESS").addClass(CLASS_GOOD)
|
||||
} catch(e) {
|
||||
log1.resolve(e).addClass(CLASS_BAD)
|
||||
logTOML.resolve(e).addClass(CLASS_BAD)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -115,7 +126,7 @@ async function parse_xrpl_toml(data, domain) {
|
||||
}
|
||||
}
|
||||
|
||||
async function list_entries(name, list, fields, validate) {
|
||||
async function listEntries(name, list, fields, validate) {
|
||||
let list_wrap = $("<p>"+name+"</p>")
|
||||
let list_ol = $("<ol>").appendTo(list_wrap)
|
||||
for (i=0; i<list.length; i++) {
|
||||
@@ -144,11 +155,11 @@ async function parse_xrpl_toml(data, domain) {
|
||||
if (!Array.isArray(parsed.ACCOUNTS)) {
|
||||
makeLogEntry("Accounts:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
} else {
|
||||
list_entries("Accounts:", parsed.ACCOUNTS, ACCOUNT_FIELDS, async function(acct) {
|
||||
listEntries("Accounts:", parsed.ACCOUNTS, ACCOUNT_FIELDS, async function(acct) {
|
||||
if (acct.address === undefined) {return undefined}
|
||||
let net
|
||||
if (acct.network === undefined) { net = "main" } else { net = acct.network }
|
||||
return await validate_address_domain_on_net(acct.address, domain, net)
|
||||
return await validateAddressDomainOnNet(acct.address, domain, net)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -156,28 +167,28 @@ async function parse_xrpl_toml(data, domain) {
|
||||
if (!Array.isArray(parsed.VALIDATORS)) {
|
||||
makeLogEntry("Validators:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
} else {
|
||||
list_entries("Validators:", parsed.VALIDATORS, VALIDATOR_FIELDS)
|
||||
listEntries("Validators:", parsed.VALIDATORS, VALIDATOR_FIELDS)
|
||||
}
|
||||
}
|
||||
if (parsed.PRINCIPALS) {
|
||||
if (!Array.isArray(parsed.PRINCIPALS)) {
|
||||
makeLogEntry("Principals:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
} else {
|
||||
list_entries("Principals:", parsed.PRINCIPALS, PRINCIPAL_FIELDS)
|
||||
listEntries("Principals:", parsed.PRINCIPALS, PRINCIPAL_FIELDS)
|
||||
}
|
||||
}
|
||||
if (parsed.SERVERS) {
|
||||
if (!Array.isArray(parsed.SERVERS)) {
|
||||
makeLogEntry("Servers:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
} else {
|
||||
list_entries("Servers:", parsed.SERVERS, SERVER_FIELDS)
|
||||
listEntries("Servers:", parsed.SERVERS, SERVER_FIELDS)
|
||||
}
|
||||
}
|
||||
if (parsed.CURRENCIES) {
|
||||
if (!Array.isArray(parsed.CURRENCIES)) {
|
||||
makeLogEntry("Currencies:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
} else {
|
||||
list_entries("Currencies:", parsed.CURRENCIES, CURRENCY_FIELDS)
|
||||
listEntries("Currencies:", parsed.CURRENCIES, CURRENCY_FIELDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,7 +196,7 @@ async function parse_xrpl_toml(data, domain) {
|
||||
// Decode a hexadecimal string into a regular string, assuming 8-bit characters.
|
||||
// Not proper unicode decoding, but it'll work for domains which are supposed
|
||||
// to be a subset of ASCII anyway.
|
||||
function decode_hex(hex) {
|
||||
function decodeHex(hex) {
|
||||
let str = '';
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16))
|
||||
@@ -193,7 +204,7 @@ function decode_hex(hex) {
|
||||
return str
|
||||
}
|
||||
|
||||
async function validate_address_domain_on_net(address, domain, net) {
|
||||
async function validateAddressDomainOnNet(address, domain, net) {
|
||||
if (!domain) { return undefined } // Can't validate an empty domain value
|
||||
let api
|
||||
if (net === "main") {
|
||||
@@ -223,7 +234,7 @@ async function validate_address_domain_on_net(address, domain, net) {
|
||||
|
||||
let domain_decoded
|
||||
try {
|
||||
domain_decoded = decode_hex(ai.result.account_data.Domain)
|
||||
domain_decoded = decodeHex(ai.result.account_data.Domain)
|
||||
} catch(e) {
|
||||
console.warn("error decoding domain value", ai.result.account_data.Domain, e)
|
||||
api.disconnect()
|
||||
@@ -244,22 +255,21 @@ async function validate_address_domain_on_net(address, domain, net) {
|
||||
}
|
||||
}
|
||||
|
||||
function handle_submit(event) {
|
||||
function handleSubmitDomain(event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('.result-title').show()
|
||||
$('#result').show()
|
||||
$('#log').empty()
|
||||
|
||||
fetch_file()
|
||||
fetchFile()
|
||||
}
|
||||
|
||||
// ------------------------------------------ DOMAIN VERIFICATION VIA ACCOUNT BELOW ------------------------------------------
|
||||
let wallet;
|
||||
let socket;
|
||||
|
||||
|
||||
function makeLogEntry_1(text, raw) {
|
||||
function makeLogEntryWallet(text, raw) {
|
||||
let log
|
||||
if (raw) {
|
||||
log = $('<li></li>').appendTo('#verify-domain-log').append(text)
|
||||
@@ -272,39 +282,9 @@ function makeLogEntry_1(text, raw) {
|
||||
return log
|
||||
}
|
||||
|
||||
function fetch_file_1(domain) {
|
||||
const url = "https://" + domain + TOML_PATH
|
||||
const log = makeLogEntry_1('Checking ' + url + '...')
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'text',
|
||||
success: function(data) {
|
||||
log.resolve('FOUND').addClass(CLASS_GOOD)
|
||||
parse_xrpl_toml_1(data)
|
||||
},
|
||||
error: function(jqxhr, status, error) {
|
||||
switch (status) {
|
||||
case 'timeout':
|
||||
err = 'TIMEOUT'
|
||||
break
|
||||
case 'abort':
|
||||
err = 'ABORTED'
|
||||
break
|
||||
case 'error':
|
||||
err = 'ERROR'
|
||||
break
|
||||
default:
|
||||
err = 'UNKNOWN'
|
||||
}
|
||||
log.resolve(err).addClass(CLASS_BAD).after(TIPS)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function fetch_wallet_1() {
|
||||
function fetchWallet() {
|
||||
wallet = $('#verify-domain').val()
|
||||
const checking_log = makeLogEntry_1('Checking domain of wallet')
|
||||
|
||||
const checkingLog = makeLogEntryWallet('Checking domain of wallet')
|
||||
const url = "wss://xrplcluster.com"
|
||||
if (typeof socket !== "undefined" && socket.readyState < 2) {
|
||||
socket.close()
|
||||
@@ -321,17 +301,17 @@ function fetch_wallet_1() {
|
||||
if (data.status === 'success') {
|
||||
if (data.result.account_data.Domain) {
|
||||
try {
|
||||
checking_log.resolve('SUCCESS').addClass(CLASS_GOOD)
|
||||
decode_hex_1(data.result.account_data.Domain)
|
||||
} catch {
|
||||
checking_log.resolve('ERROR').addClass(CLASS_BAD).after('<p>Error decoding domain field: ' + data.result.account_data.Domain + '</p>')
|
||||
checkingLog.resolve('SUCCESS').addClass(CLASS_GOOD)
|
||||
decodeHexWallet(data.result.account_data.Domain)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
checkingLog.resolve('ERROR').addClass(CLASS_BAD).after('<p>Error decoding domain field: ' + data.result.account_data.Domain + '</p>')
|
||||
}
|
||||
} else {
|
||||
checking_log.resolve('ERROR').addClass(CLASS_BAD).after(TIPS_2)
|
||||
checkingLog.resolve('ERROR').addClass(CLASS_BAD).after(TIPS_2)
|
||||
}
|
||||
|
||||
} else {
|
||||
checking_log.resolve('ERROR').addClass(CLASS_BAD).after(TIPS_1)
|
||||
checkingLog.resolve('ERROR').addClass(CLASS_BAD).after(TIPS_1)
|
||||
}
|
||||
} catch {
|
||||
return false
|
||||
@@ -342,26 +322,26 @@ function fetch_wallet_1() {
|
||||
})
|
||||
}
|
||||
|
||||
async function parse_xrpl_toml_1(data) {
|
||||
async function parseXRPLTomlWallet(data) {
|
||||
let parsed
|
||||
let log1 = makeLogEntry_1("Parsing TOML data...")
|
||||
let logTOML = makeLogEntryWallet("Parsing TOML data...")
|
||||
try {
|
||||
parsed = TOML(data)
|
||||
log1.resolve("SUCCESS").addClass(CLASS_GOOD)
|
||||
logTOML.resolve("SUCCESS").addClass(CLASS_GOOD)
|
||||
} catch(e) {
|
||||
log1.resolve(e).addClass(CLASS_BAD)
|
||||
logTOML.resolve(e).addClass(CLASS_BAD)
|
||||
return
|
||||
}
|
||||
|
||||
if (parsed.hasOwnProperty("METADATA")) {
|
||||
const metadata_type = makeLogEntry_1("Metadata section: ")
|
||||
const metadata_type = makeLogEntryWallet("Metadata section: ")
|
||||
if (Array.isArray(parsed.METADATA)) {
|
||||
metadata_type.resolve("Wrong type - should be table").addClass(CLASS_BAD)
|
||||
} else {
|
||||
metadata_type.resolve("Found").addClass(CLASS_GOOD)
|
||||
|
||||
if (parsed.METADATA.modified) {
|
||||
const mod_log = makeLogEntry_1("Modified date: ")
|
||||
const mod_log = makeLogEntryWallet("Modified date: ")
|
||||
try {
|
||||
mod_log.resolve(parsed.METADATA.modified.toISOString()).addClass(CLASS_GOOD)
|
||||
} catch(e) {
|
||||
@@ -371,7 +351,7 @@ async function parse_xrpl_toml_1(data) {
|
||||
}
|
||||
}
|
||||
|
||||
async function list_entries_1(name, list, fields) {
|
||||
async function listEntriesWallet(name, list, fields) {
|
||||
let found = false;
|
||||
let list_wrap = $("<p>"+name+"</p>")
|
||||
let list_ol = $("<ol>").appendTo(list_wrap)
|
||||
@@ -392,44 +372,44 @@ async function parse_xrpl_toml_1(data) {
|
||||
}
|
||||
}
|
||||
|
||||
makeLogEntry_1(list_wrap, true)
|
||||
makeLogEntryWallet(list_wrap, true)
|
||||
if(found) {
|
||||
makeLogEntry_1('Account has been found in TOML file and validated.').resolve('DOMAIN VALIDATED <i class="fa fa-check-circle"></i>').addClass(CLASS_GOOD)
|
||||
makeLogEntryWallet('Account has been found in TOML file and validated.').resolve('DOMAIN VALIDATED <i class="fa fa-check-circle"></i>').addClass(CLASS_GOOD)
|
||||
} else {
|
||||
makeLogEntry_1('Account not found in TOML file. Domain can not be verified.').resolve('ERROR').addClass(CLASS_BAD)
|
||||
makeLogEntryWallet('Account not found in TOML file. Domain can not be verified.').resolve('ERROR').addClass(CLASS_BAD)
|
||||
}
|
||||
}
|
||||
if (parsed.ACCOUNTS) {
|
||||
if (!Array.isArray(parsed.ACCOUNTS)) {
|
||||
makeLogEntry_1("Accounts:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
makeLogEntryWallet("Accounts:").resolve("Wrong type - should be table-array").addClass(CLASS_BAD)
|
||||
} else {
|
||||
list_entries_1("Accounts:", parsed.ACCOUNTS, ACCOUNT_FIELDS)
|
||||
listEntriesWallet("Accounts:", parsed.ACCOUNTS, ACCOUNT_FIELDS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function decode_hex_1(hex) {
|
||||
function decodeHexWallet(hex) {
|
||||
let str = '';
|
||||
for (let i = 0; i < hex.length; i += 2) {
|
||||
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16))
|
||||
}
|
||||
const decode_log = makeLogEntry_1('Decoding domain hex')
|
||||
decode_log.resolve("SUCCESS").addClass(CLASS_GOOD)
|
||||
fetch_file_1(str)
|
||||
const decodeLog = makeLogEntryWallet('Decoding domain hex')
|
||||
decodeLog.resolve("SUCCESS").addClass(CLASS_GOOD)
|
||||
fetchFile(str)
|
||||
}
|
||||
|
||||
function domain_verification_submit(event) {
|
||||
function handleSubmitWallet(event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('#verify-domain-result-title').show()
|
||||
$('#verify-domain-result').show()
|
||||
$('#verify-domain-log').empty()
|
||||
|
||||
fetch_wallet_1()
|
||||
fetchWallet()
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(() => {
|
||||
$('#domain-entry').submit(handle_submit)
|
||||
$('#domain-verification').submit(domain_verification_submit)
|
||||
$('#domain-entry').submit(handleSubmitDomain)
|
||||
$('#domain-verification').submit(handleSubmitWallet)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user