add reviewer suggestions

This commit is contained in:
Oliver Eggert
2025-05-28 15:39:12 -07:00
parent cd539662c4
commit 7f80874c8e
6 changed files with 191 additions and 410 deletions

View File

@@ -1,7 +1,4 @@
// *******************************************************
// *********** Create Credential *************************
// *******************************************************
/// Create credential function
async function createCredential() {
let net = getNet()
@@ -12,6 +9,7 @@ async function createCredential() {
results = `\n\nConnected.`
updateResults()
// Gather transaction info
try {
// Get account wallet from seed

View File

@@ -1,7 +1,4 @@
// *******************************************************
// *********** Create Permissioned Domain ****************
// *******************************************************
/// Create permissioned domain
async function createDomain() {
let net = getNet()
@@ -12,76 +9,76 @@ async function createDomain() {
results = `\n\nConnected.`
updateResults()
// Gather transaction info
try {
// Get account wallet from seed
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
// Get Domain ID
const domainID = domainIDField.value
// Get credential type - convert string to hex if needed
let credentialType = credentialTypeField.value;
if (!/^[0-9A-F]+$/i.test(credentialType)) {
let hex = '';
for (let i = 0; i < credentialType.length; i++) {
const charCode = credentialType.charCodeAt(i);
const hexCharCode = charCode.toString(16).padStart(2, '0');
hex += hexCharCode;
}
credentialType = hex.toUpperCase();
}
// Prepare transaction
const transaction = {
"TransactionType": "PermissionedDomainSet",
"Account": wallet.address,
"AcceptedCredentials": [
{
"Credential": {
"Issuer": wallet.address,
"CredentialType": credentialType
}
// Get account wallet from seed
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
// Get Domain ID
const domainID = domainIDField.value
// Get credential type - convert string to hex if needed
let credentialType = credentialTypeField.value;
if (!/^[0-9A-F]+$/i.test(credentialType)) {
let hex = '';
for (let i = 0; i < credentialType.length; i++) {
const charCode = credentialType.charCodeAt(i);
const hexCharCode = charCode.toString(16).padStart(2, '0');
hex += hexCharCode;
}
]
}
if (domainID) {
transaction.DomainID = domainID
}
results = `\n\n===Preparing and Sending Transaction===\n\n${JSON.stringify(transaction, null, 2)}`
updateResults()
// Submit transaction
const tx = await client.submitAndWait(transaction, {autofill: true, wallet: wallet})
if (tx.result.meta.TransactionResult == "tesSUCCESS") {
// Parse for domain info
if (domainID) {
results = `\n\n===Create Permissioned Domain Result===\n\n${JSON.stringify(tx.result.tx_json, null, 2)}`
} else {
const parsedResponse = JSON.parse(JSON.stringify(tx.result.meta.AffectedNodes, null, 2))
const domainInfo = parsedResponse.find( node => node.CreatedNode && node.CreatedNode.LedgerEntryType === "PermissionedDomain" )
results = `\n\n===Create Permissioned Domain Result===\n\n${JSON.stringify(domainInfo.CreatedNode, null, 2)}`
credentialType = hex.toUpperCase();
}
// Prepare transaction
const transaction = {
"TransactionType": "PermissionedDomainSet",
"Account": wallet.address,
"AcceptedCredentials": [
{
"Credential": {
"Issuer": wallet.address,
"CredentialType": credentialType
}
}
]
}
} else {
results = `\n\n===Error===\n\n${JSON.stringify(tx.result.meta.TransactionResult, null, 2)}: Check codes at https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomainset#error-cases`
}
updateResults()
} catch (error) {
results = `\n\n===Error===\n\n${error}`
updateResults()
}
if (domainID) {
transaction.DomainID = domainID
}
results = `\n\n===Preparing and Sending Transaction===\n\n${JSON.stringify(transaction, null, 2)}`
updateResults()
// Submit transaction
const tx = await client.submitAndWait(transaction, {autofill: true, wallet: wallet})
if (tx.result.meta.TransactionResult == "tesSUCCESS") {
// Parse for domain info
if (domainID) {
results = `\n\n===Create Permissioned Domain Result===\n\n${JSON.stringify(tx.result.tx_json, null, 2)}`
} else {
const parsedResponse = JSON.parse(JSON.stringify(tx.result.meta.AffectedNodes, null, 2))
const domainInfo = parsedResponse.find( node => node.CreatedNode && node.CreatedNode.LedgerEntryType === "PermissionedDomain" )
results = `\n\n===Create Permissioned Domain Result===\n\n${JSON.stringify(domainInfo.CreatedNode, null, 2)}`
}
} else {
results = `\n\n===Error===\n\n${JSON.stringify(tx.result.meta.TransactionResult, null, 2)}: Check codes at https://xrpl.org/docs/references/protocol/transactions/types/permissioneddomainset#error-cases`
}
updateResults()
} catch (error) {
results = `\n\n===Error===\n\n${error}`
updateResults()
}
client.disconnect()
}
// End create permissioned domain
// *******************************************************
// *********** Delete Permissioned Domain ****************
// *******************************************************
// Delete permissioned domain
async function deleteDomain() {
let net = getNet()
@@ -92,6 +89,7 @@ async function deleteDomain() {
results = `\n\nConnected.`
updateResults()
// Get delete domain transaction info
try {
// Get account wallet from seed
@@ -110,7 +108,7 @@ async function deleteDomain() {
results = `\n\n===Preparing and Sending Transaction===\n\n${JSON.stringify(transaction, null, 2)}`
updateResults()
// Submit transaction
// Submit delete domain transaction
const tx = await client.submitAndWait(transaction, {autofill: true, wallet: wallet})
if (tx.result.meta.TransactionResult == "tesSUCCESS") {