add authorized minter

This commit is contained in:
Dennis Dawson
2025-05-23 17:06:30 -07:00
parent cc10aa0f94
commit 471c2e48df
8 changed files with 521 additions and 646 deletions

View File

@@ -270,6 +270,16 @@
<input type="text" id="authorizedMinterField" size="40"></input>
</td>
</tr>
<tr>
<td align="right">
<span class="tooltip" tooltip-data="Account that is the original issuer of the NFT.">
<label for="nftIssuerField">NFT Issuer</label>
</span>
</td>
<td>
<input type="text" id="nftIssuerField" size="40"></input>
</td>
</tr>
<tr>
<td colspan="2">
<p align="left">

View File

@@ -51,7 +51,6 @@ async function mintOther() {
results += '\nConnected. Minting NFT.'
resultField.value = results
// This version adds the "Issuer" field.
// ------------------------------------------------------------------------
const tx_json = {
"TransactionType": "NFTokenMint",
@@ -59,23 +58,30 @@ async function mintOther() {
"URI": xrpl.convertStringToHex(nftURLfield.value),
"Flags": parseInt(flagsField.value),
"TransferFee": parseInt(transferFeeField.value),
"Issuer": issuerField.value,
"NFTokenTaxon": 0 //Required, but if you have no use for it, set to zero.
"Issuer": nftIssuerField.value,
"NFTokenTaxon": nftTaxonField.value //Required, but if you have no use for it, set to zero.
}
if (amountField.value) {
tx_json.Amount = configureAmount(amountField.value);
}
if (expirationField.value) {
tx_json.Expiration = configureExpiration(expirationField.value);
}
if (destinationField.value) {
tx_json.Destination = destinationField.value;
}
// ----------------------------------------------------- Submit transaction
const tx = await client.submitAndWait(tx_json, { wallet: wallet })
const nfts = await client.request({
method: "account_nfts",
account: wallet.classicAddress
})
// ------------------------------------------------------- Report results
results += '\n\n=== Transaction result: ' + tx.result.meta.TransactionResult
results += '\n\n=== NFTs: ' + JSON.stringify(nfts, null, 2)
resultField.value = results + (await client.getXrpBalance(wallet.address))
// The line below seems redundant if the previous line already updates resultField.value
// resultField.value = results
} catch (error) {
results += '\n\nAn error occurred: ' + error.message
console.error(error) // Log the error for debugging

View File

@@ -278,7 +278,7 @@ async function acceptSellOffer() {
results += '\n=== Balance changes:'
results += JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
results += JSON.stringify(nfts, null, 2)
resultField.value = results
resultField.value += results
} catch (error) {
console.error('Error accepting sell offer:', error)
resultField.value = `Error: ${error.message || error}`
@@ -292,35 +292,48 @@ async function acceptSellOffer() {
// *******************************************************
async function acceptBuyOffer() {
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value)
let net = getNet()
const client = new xrpl.Client(net)
await client.connect()
let results = '\n=== Connected. Accepting buy offer. ==='
resultField.value = results
const wallet = xrpl.Wallet.fromSeed(accountSeedField.value);
let net = getNet();
const client = new xrpl.Client(net);
let results = '\n=== Connected. Accepting buy offer. ==='; // Declare results locally
// Prepare transaction -------------------------------------------------------
const transactionJson = {
"TransactionType": "NFTokenAcceptOffer",
"Account": wallet.classicAddress,
"NFTokenBuyOffer": nftOfferIdField.value
try {
await client.connect();
resultField.value = results; // Update UI after connection
// Prepare transaction -------------------------------------------------------
const transactionJson = {
"TransactionType": "NFTokenAcceptOffer",
"Account": wallet.classicAddress,
"NFTokenBuyOffer": nftOfferIdField.value
};
// Submit transaction --------------------------------------------------------
const tx = await client.submitAndWait(transactionJson, { wallet: wallet });
const nfts = await client.request({
method: "account_nfts",
account: wallet.classicAddress
});
results += JSON.stringify(nfts, null, 2);
resultField.value = results;
// Check transaction results -------------------------------------------------
results += "\n\nTransaction result:\n" +
JSON.stringify(tx.result.meta.TransactionResult, null, 2);
results += "\nBalance changes:\n" +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2);
xrpBalanceField.value = (await client.getXrpBalance(wallet.address));
resultField.value = results;
} catch (error) {
console.error('Error in acceptBuyOffer:', error); // Log the full error
results = `\n=== Error accepting buy offer: ${error.message || 'Unknown error'} ===`;
resultField.value = results;
} finally {
if (client && client.isConnected()) {
client.disconnect();
}
}
// Submit transaction --------------------------------------------------------
const tx = await client.submitAndWait(transactionJson, { wallet: wallet })
const nfts = await client.request({
method: "account_nfts",
account: wallet.classicAddress
})
results += JSON.stringify(nfts, null, 2)
resultField.value = results
// Check transaction results -------------------------------------------------
results += "\n\nTransaction result:\n" +
JSON.stringify(tx.result.meta.TransactionResult, null, 2)
results += "\nBalance changes:\n" +
JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2)
xrpBalanceField.value =
(await client.getXrpBalance(wallet.address))
resultField.value = results
client.disconnect()
}// End of acceptBuyOffer()
} // End of acceptBuyOffer()