mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2026-08-23 19:20:54 +00:00
Merge pull request #2972 from XRPLF/add_account_config_topic
Add account configuration topic
This commit is contained in:
3
_code-samples/account-configurator/README.md
Normal file
3
_code-samples/account-configurator/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Account Configurator
|
||||
|
||||
Create accounts on Testnet or Devnet and try different configuration settings. You can also get account configuration settings for live accounts on Mainnet.
|
||||
144
_code-samples/account-configurator/account-configurator.css
Normal file
144
_code-samples/account-configurator/account-configurator.css
Normal file
@@ -0,0 +1,144 @@
|
||||
body {
|
||||
font-family: "Inter", sans-serif;
|
||||
padding: 20px;
|
||||
background: #abe2ff;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td {
|
||||
padding-left: 25px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
input,
|
||||
button {
|
||||
padding: 6px;
|
||||
margin-bottom: 8px;
|
||||
border: none
|
||||
}
|
||||
|
||||
button {
|
||||
font-weight: bold;
|
||||
font-family: "Work Sans", sans-serif;
|
||||
background-color: #006aff;
|
||||
-webkit-text-fill-color: white;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #0555c5;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
/* Hide default HTML checkbox */
|
||||
.switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
/* The slider */
|
||||
.slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
.slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 13px;
|
||||
width: 13px;
|
||||
left: 4px;
|
||||
bottom: 2px;
|
||||
background-color: white;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
|
||||
input:checked+.slider {
|
||||
background-color: #2196F3;
|
||||
}
|
||||
|
||||
input:focus+.slider {
|
||||
box-shadow: 0 0 1px #2196F3;
|
||||
}
|
||||
|
||||
input:checked+.slider:before {
|
||||
-webkit-transform: translateX(13px);
|
||||
-ms-transform: translateX(13px);
|
||||
transform: translateX(13px);
|
||||
}
|
||||
|
||||
/* Rounded sliders */
|
||||
.slider.round {
|
||||
border-radius: 17px;
|
||||
}
|
||||
|
||||
.slider.round:before {
|
||||
border-radius: 50%;
|
||||
}
|
||||
.tooltip {
|
||||
position: relative;
|
||||
border-bottom: 1px dotted black;
|
||||
}
|
||||
|
||||
.tooltip:before {
|
||||
content: attr(tooltip-data);
|
||||
position: absolute;
|
||||
width: 250px;
|
||||
background-color: #006aff;
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
padding: 15px;
|
||||
line-height: 1.1;
|
||||
border-radius: 5px;
|
||||
z-index: 1;
|
||||
opacity: 0;
|
||||
transition: opacity .5s;
|
||||
bottom: 125%;
|
||||
left: 50%;
|
||||
margin-left: -60px;
|
||||
font-size: 0.70em;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.tooltip:after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
bottom: 75%;
|
||||
left: 50%;
|
||||
margin-left: -5px;
|
||||
border-width: 5px;
|
||||
border-style: solid;
|
||||
opacity: 0;
|
||||
transition: opacity .5s;
|
||||
border-color: #000 transparent transparent transparent;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.tooltip:hover:before,
|
||||
.tooltip:hover:after {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
383
_code-samples/account-configurator/account-configurator.html
Normal file
383
_code-samples/account-configurator/account-configurator.html
Normal file
@@ -0,0 +1,383 @@
|
||||
<html>
|
||||
<!-- Add Signers list -->
|
||||
<head>
|
||||
<title>Account Configurator</title>
|
||||
<link href='https://fonts.googleapis.com/css?family=Work Sans' rel='stylesheet'>
|
||||
<link href="account-configurator.css" rel = 'stylesheet'>
|
||||
|
||||
<script src='https://unpkg.com/xrpl@2.7.0/build/xrpl-latest-min.js'></script>
|
||||
<script src='account-configurator.js'></script>
|
||||
<script>
|
||||
if (typeof module !== "undefined") {
|
||||
const xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<!-- ************************************************************** -->
|
||||
<!-- ********************** The Form ****************************** -->
|
||||
<!-- ************************************************************** -->
|
||||
|
||||
<body>
|
||||
<h1>Account Configurator</h1>
|
||||
<form id="theForm">
|
||||
<span class="tooltip" tooltip-data="Choose the XRPL host server for your account.">
|
||||
Choose your ledger instance:
|
||||
</span>
|
||||
|
||||
<input type="radio" id="mn" name="server" value="wss://xrplcluster.com/">
|
||||
<label for="mainnet">Mainnet</label>
|
||||
|
||||
<input type="radio" id="tn" name="server" value="wss://s.altnet.rippletest.net:51233" checked>
|
||||
<label for="testnet">Testnet</label>
|
||||
|
||||
<input type="radio" id="dn" name="server" value="wss://s.devnet.rippletest.net:51233">
|
||||
<label for="devnet">Devnet</label><br />
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Address of your account.">
|
||||
Account
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="accountField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccount()">Get New Account</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Seed value of your account.">
|
||||
Seed
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="seedField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountFromSeed()">Get Account From Seed</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="getAccountInfo()">Get Account Info</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Preset configurations you can choose for your account.">
|
||||
Account Configuration Templates:
|
||||
</span>
|
||||
|
||||
<input type="radio" id="hd" name="accountType" value="hd" onclick="setHolder()">
|
||||
<label for="hd" background="green">Holder</label>
|
||||
|
||||
<input type="radio" id="ex" name="accountType" value="ex" onclick="setExchanger()">
|
||||
<label for="ex">Exchanger</label>
|
||||
|
||||
<input type="radio" id="is" name="accountType" value="is" onclick="setIssuer()">
|
||||
<label for="issuer">Issuer</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><button type="button" onClick="configureAccount()">Configure Account</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="issuer_additional_fields">
|
||||
<table>
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Web address where your TOML file resides.">
|
||||
Domain
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="domainField" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="A value between 1000000000 and 2000000000, inclusive.">
|
||||
Transfer Rate
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="transferRateField" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Valid values are 3 to 15, inclusive, or 0 to disable.">
|
||||
Tick Size
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="tickSizeField" size="40"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Signer to authorize account transactions.">
|
||||
Signer1 Account
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="signer1AccountField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Relative value of the signer's vote on approvals.">
|
||||
Signer1 Weight</span>
|
||||
|
||||
<input type="text" id="signer1WeightField" size="5"></input>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" onClick="removeSigners()">Remove Signers</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Signer to authorize account transactions.">
|
||||
Signer2 Account
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="signer2AccountField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Relative value of the signer's vote on approvals.">
|
||||
Signer2 Weight
|
||||
</span>
|
||||
|
||||
<input type="text" id="signer2WeightField" size="5"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">
|
||||
<span class="tooltip" tooltip-data="Signer to authorize account transactions.">
|
||||
Signer3 Account
|
||||
</span>
|
||||
<td>
|
||||
<input type="text" id="signer3AccountField" size="40"></input>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Relative value of the signer's vote on approvals.">
|
||||
Signer3 Weight
|
||||
</span>
|
||||
|
||||
<input type="text" id="signer3WeightField" size="5"></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Minimum sum of signer weights required to approve a transaction.">
|
||||
Signer Quorum
|
||||
</span>
|
||||
<input type="text" id="signerQuorumField" size="5"></input>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<tr>
|
||||
<div id="account_flags">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Allow rippling on trust lines by default.">
|
||||
defaultRipple
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="defaultRipple">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Allow clawback of tokens on trust lines to the account.">
|
||||
allowTrustLineClawback
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="allowTrustLineClawback">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Use Deposit Authorization to deny payments from unknown third parties.">
|
||||
depositAuth
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="depositAuth">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Disable the account master key pair.">
|
||||
disableMasterKey
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disableMasterKey">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Prevent other accounts from sending checks to the account.">
|
||||
disallowIncomingCheck
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disallowIncomingCheck">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Prevent other accounts from sending NFT buy or sell offers to the account.">
|
||||
disallowIncomingNFTokenOffer
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disallowIncomingNFTokenOffer">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Prevent other accounts from creating payment channels to the account.">
|
||||
disallowIncomingPayChan
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disallowIncomingPayChan">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Prevent other accounts from creating trust lines to the account.">
|
||||
disallowIncomingTrustline
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disallowIncomingTrustline">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Prevent other accounts from sending XRP to the account. (This is advisory, and not enforced at the protocol
|
||||
level.)">
|
||||
disallowIncomingXRP
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="disallowIncomingXRP">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Freeze all tokens issued by the account.">
|
||||
globalFreeze
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="globalFreeze">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="Permanently remove the ability to freeze individual trust lines or end a global freeze.">
|
||||
noFreeze
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="noFreeze">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="The account requires authorized trust lines for other accounts to hold tokens it issues.">
|
||||
requireAuthorization
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="requireAuthorization">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tooltip" tooltip-data="The account requires a destination tag on all payments it receives.">
|
||||
requireDestinationTag
|
||||
</span>
|
||||
</td>
|
||||
<td align="middle">
|
||||
<label class="switch">
|
||||
<input type="checkbox" id="requireDestinationTag">
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<textarea id="resultField" cols="80" rows="15"></textarea>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
476
_code-samples/account-configurator/account-configurator.js
Normal file
476
_code-samples/account-configurator/account-configurator.js
Normal file
@@ -0,0 +1,476 @@
|
||||
const allFlags = [
|
||||
"empty",
|
||||
"asfRequireDest",
|
||||
"asfRequireAuth",
|
||||
"asfDisallowXRP",
|
||||
"asfDisableMaster",
|
||||
"asfAccountTxnID",
|
||||
"asfNoFreeze",
|
||||
"asfGlobalFreeze",
|
||||
"asfDefaultRipple",
|
||||
"asfDepositAuth",
|
||||
"asfAuthorizedNFTokenMinter",
|
||||
"hooksReserved",
|
||||
"asfDisallowIncomingNFTokenOffer",
|
||||
"asfDisallowIncomingCheck",
|
||||
"asfDisallowIncomingPayChan",
|
||||
"asfDisallowIncomingTrustline",
|
||||
"asfAllowTrustLineClawback",
|
||||
]
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById("issuer_additional_fields").style.display="none"
|
||||
});
|
||||
|
||||
|
||||
// ******************************************************
|
||||
// ************* Get the Preferred Network **************
|
||||
// ******************************************************
|
||||
|
||||
function getNet() {
|
||||
let net
|
||||
if (document.getElementById("mn").checked) net = "wss://xrplcluster.com/"
|
||||
if (document.getElementById("tn").checked) net = "wss://s.altnet.rippletest.net:51233"
|
||||
if (document.getElementById("dn").checked) net = "wss://s.devnet.rippletest.net:51233"
|
||||
return net
|
||||
} // End of getNet()
|
||||
|
||||
// *******************************************************
|
||||
// ************* Get Account *****************************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccount() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + net + '....'
|
||||
|
||||
//-------------------------------This uses the default faucet for Testnet/Devnet.
|
||||
let faucetHost = null
|
||||
resultField.value = results
|
||||
await client.connect()
|
||||
results += '\nConnected, funding wallet.'
|
||||
// ----------------------------------------Create and fund a test account wallet.
|
||||
const my_wallet = (await client.fundWallet(null, { faucetHost })).wallet
|
||||
results += '\nGot a wallet.'
|
||||
|
||||
// ------------------------------------------------------Get the current balance.
|
||||
accountField.value = my_wallet.address
|
||||
seedField.value = my_wallet.seed
|
||||
results += '\nAccount created.\n'
|
||||
client.disconnect()
|
||||
results+=JSON.stringify(my_wallet)
|
||||
resultField.value = results
|
||||
} // End of getAccount()
|
||||
|
||||
// *******************************************************
|
||||
// ************ Get Account from Seed ********************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccountFromSeed() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected, finding wallets.\n'
|
||||
resultField.value = results
|
||||
// --------------------------------------------------Find the test account wallet.
|
||||
const my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
|
||||
// -------------------------------------------------------Get the current balance.
|
||||
accountField.value = my_wallet.address
|
||||
seedField.value = my_wallet.seed
|
||||
client.disconnect()
|
||||
getAccountInfo()
|
||||
} // End of getAccountFromSeed()
|
||||
|
||||
// *******************************************************
|
||||
// ***************** Get Account Info ********************
|
||||
// *******************************************************
|
||||
|
||||
async function getAccountInfo() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
results = 'Connecting to ' + getNet() + '....'
|
||||
await client.connect()
|
||||
results += '\nConnected.'
|
||||
results+= "\nGetting account info...\n"
|
||||
const my_acct_info = await client.request({
|
||||
command: "account_info",
|
||||
account: accountField.value,
|
||||
ledger_index: "validated",
|
||||
signer_lists: true
|
||||
})
|
||||
results = JSON.stringify(my_acct_info, null, 2)
|
||||
resultField.value += results
|
||||
var parsedResults = JSON.parse(results)
|
||||
try {
|
||||
document.getElementById("tickSizeField").value = parsedResults.result.account_data.TickSize
|
||||
document.getElementById("transferRateField").value = parsedResults.result.account_data.TransferRate
|
||||
document.getElementById("domainField").value = xrpl.convertHexToString(parsedResults.result.account_data.Domain)
|
||||
} catch (error ) {
|
||||
}
|
||||
document.getElementById("defaultRipple").checked = parsedResults.result.account_flags.defaultRipple
|
||||
document.getElementById("allowTrustLineClawback").checked = parsedResults.result.account_flags.allowTrustLineClawback
|
||||
document.getElementById("depositAuth").checked = parsedResults.result.account_flags.depositAuth
|
||||
document.getElementById("disableMasterKey").checked = parsedResults.result.account_flags.disableMasterKey
|
||||
document.getElementById("disallowIncomingCheck").checked = parsedResults.result.account_flags.disallowIncomingCheck
|
||||
document.getElementById("disallowIncomingNFTokenOffer").checked = parsedResults.result.account_flags.disallowIncomingNFTokenOffer
|
||||
document.getElementById("disallowIncomingPayChan").checked = parsedResults.result.account_flags.disallowIncomingPayChan
|
||||
document.getElementById("disallowIncomingTrustline").checked = parsedResults.result.account_flags.disallowIncomingTrustline
|
||||
document.getElementById("disallowIncomingXRP").checked = parsedResults.result.account_flags.disallowIncomingXRP
|
||||
document.getElementById("globalFreeze").checked = parsedResults.result.account_flags.globalFreeze
|
||||
document.getElementById("noFreeze").checked = parsedResults.result.account_flags.noFreeze
|
||||
document.getElementById("requireAuthorization").checked = parsedResults.result.account_flags.requireAuthorization
|
||||
document.getElementById("requireDestinationTag").checked = parsedResults.result.account_flags.requireDestinationTag
|
||||
try {
|
||||
let signerEntries_variable = parsedResults.result.account_data.signer_lists[0].SignerEntries
|
||||
document.getElementById("signer1AccountField").value = signerEntries_variable[0]["SignerEntry"]["Account"]
|
||||
document.getElementById("signer1WeightField").value = signerEntries_variable[0]["SignerEntry"]["SignerWeight"]
|
||||
document.getElementById("signer2AccountField").value = signerEntries_variable[1]["SignerEntry"]["Account"]
|
||||
document.getElementById("signer2WeightField").value = signerEntries_variable[1]["SignerEntry"]["SignerWeight"]
|
||||
document.getElementById("signer3AccountField").value = signerEntries_variable[2]["SignerEntry"]["Account"]
|
||||
document.getElementById("signer3WeightField").value = signerEntries_variable[2]["SignerEntry"]["SignerWeight"]
|
||||
document.getElementById("signerQuorumField").value = parsedResults.result.account_data.signer_lists[0].SignerQuorum
|
||||
} catch (error) {
|
||||
}
|
||||
client.disconnect()
|
||||
} // End of getAccountInfo()
|
||||
|
||||
// *******************************************************
|
||||
// **************** Configure Account ********************
|
||||
// *******************************************************
|
||||
|
||||
async function configureAccount() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
resultField.value = `Connecting to ${net}.`
|
||||
await client.connect()
|
||||
my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
const my_acct_info = await client.request({
|
||||
command: "account_info",
|
||||
account: accountField.value,
|
||||
ledger_index: "validated",
|
||||
})
|
||||
|
||||
json_results = JSON.stringify(my_acct_info, null, 2)
|
||||
var parsedResults = JSON.parse(json_results)
|
||||
let defRipBool = document.getElementById("defaultRipple").checked
|
||||
if (defRipBool != parsedResults.result.account_flags.defaultRipple) {
|
||||
if(defRipBool) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDefaultRipple)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDefaultRipple)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("allowTrustLineClawback").checked != parsedResults.result.account_flags.allowTrustLineClawback) {
|
||||
if(document.getElementById("allowTrustLineClawback").checked) {
|
||||
await setFlag(16)
|
||||
} else {
|
||||
await clearFlag(16)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("depositAuth").checked != parsedResults.result.account_flags.depositAuth) {
|
||||
if(document.getElementById("depositAuth").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDepositAuth)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDepositAuth)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("disableMasterKey").checked != parsedResults.result.account_flags.disableMasterKey) {
|
||||
if(document.getElementById("disableMasterKey").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDisableMaster)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDisableMaster)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("disallowIncomingCheck").checked != parsedResults.result.account_flags.disallowIncomingCheck) {
|
||||
if(document.getElementById("disallowIncomingCheck").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingCheck)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingCheck)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("disallowIncomingNFTokenOffer").checked != parsedResults.result.account_flags.disallowIncomingNFTokenOffer) {
|
||||
if(document.getElementById("disallowIncomingNFTokenOffer").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingNFTokenOffer)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingNFTokenOffer)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("disallowIncomingPayChan").checked != parsedResults.result.account_flags.disallowIncomingPayChan) {
|
||||
if(document.getElementById("disallowIncomingPayChan").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingPayChan)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingPayChan)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("disallowIncomingTrustline").checked != parsedResults.result.account_flags.disallowIncomingTrustline) {
|
||||
if(document.getElementById("disallowIncomingTrustline").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingTrustline)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDisallowIncomingTrustline)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("disallowIncomingXRP").checked != parsedResults.result.account_flags.disallowIncomingXRP) {
|
||||
if(document.getElementById("disallowIncomingXRP").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfDisallowXRP)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfDisallowXRP)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("globalFreeze").checked != parsedResults.result.account_flags.globalFreeze) {
|
||||
if(document.getElementById("globalFreeze").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfGlobalFreeze)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfGlobalFreeze)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("noFreeze").checked != parsedResults.result.account_flags.noFreeze) {
|
||||
if(document.getElementById("noFreeze").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfNoFreeze)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfNoFreeze)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("requireAuthorization").checked != parsedResults.result.account_flags.requireAuthorization) {
|
||||
if(document.getElementById("requireAuthorization").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfRequireAuth)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfRequireAuth)
|
||||
}
|
||||
}
|
||||
|
||||
if (document.getElementById("requireDestinationTag").checked != parsedResults.result.account_flags.requireDestinationTag) {
|
||||
if(document.getElementById("requireDestinationTag").checked) {
|
||||
await setFlag(xrpl.AccountSetAsfFlags.asfRequireDest)
|
||||
} else {
|
||||
await clearFlag(xrpl.AccountSetAsfFlags.asfRequireDest)
|
||||
}
|
||||
}
|
||||
|
||||
if(!document.getElementById("is").checked) {
|
||||
my_config = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account" : my_wallet.address,
|
||||
"TickSize": 0,
|
||||
"TransferRate": 1000000000,
|
||||
"Domain": ""
|
||||
}
|
||||
const preparedAccount = await client.autofill(my_config)
|
||||
const signedAccount = my_wallet.sign(preparedAccount)
|
||||
const resultAccount = await client.submitAndWait(signedAccount.tx_blob)
|
||||
} else {
|
||||
my_config = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account" : my_wallet.address,
|
||||
"TickSize": parseInt(document.getElementById("tickSizeField").value),
|
||||
"TransferRate": parseInt(document.getElementById("transferRateField").value),
|
||||
"Domain": xrpl.convertStringToHex(document.getElementById("domainField").value),
|
||||
}
|
||||
const preparedAccount = await client.autofill(my_config)
|
||||
const signedAccount = my_wallet.sign(preparedAccount)
|
||||
const resultAccount = await client.submitAndWait(signedAccount.tx_blob)
|
||||
resultField.value += JSON.stringify(resultAccount, null, 2)
|
||||
if(signer1AccountField.value!=""){
|
||||
my_signers= {
|
||||
"Flags": 0,
|
||||
"TransactionType": "SignerListSet",
|
||||
"Account": my_wallet.address,
|
||||
"Fee": "12",
|
||||
"SignerQuorum": parseInt(signerQuorumField.value),
|
||||
"SignerEntries": [
|
||||
{"SignerEntry":
|
||||
{"Account": signer1AccountField.value,
|
||||
"SignerWeight": parseInt(signer1WeightField.value)
|
||||
}},
|
||||
{"SignerEntry":
|
||||
{"Account": signer2AccountField.value,
|
||||
"SignerWeight": parseInt(signer2WeightField.value)}
|
||||
},
|
||||
{"SignerEntry":
|
||||
{"Account": signer3AccountField.value,
|
||||
"SignerWeight": parseInt(signer3WeightField.value)
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const preparedSigner = await client.autofill(my_signers)
|
||||
const signedSigner = my_wallet.sign(preparedSigner)
|
||||
const resultSigner = await client.submitAndWait(signedSigner.tx_blob)
|
||||
resultField.value += JSON.stringify(resultSigner, null, 2)
|
||||
}
|
||||
}
|
||||
client.disconnect()
|
||||
if(!document.getElementById("is").checked) {
|
||||
document.getElementById("issuer_additional_fields").style.display="none"
|
||||
}
|
||||
getAccountInfo()
|
||||
} // End of configureAccount()
|
||||
|
||||
/*****************************************
|
||||
************** Set Flag *****************
|
||||
*****************************************/
|
||||
|
||||
async function setFlag(my_flag) {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
settings_tx = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": my_wallet.address,
|
||||
"SetFlag": my_flag
|
||||
}
|
||||
resultField.value += '\nSetting flag ' + allFlags[my_flag] + "."
|
||||
const prepared = await client.autofill(settings_tx)
|
||||
const signed = my_wallet.sign(prepared)
|
||||
const result = await client.submitAndWait(signed.tx_blob)
|
||||
if (result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
resultField.value += '\nAccount setting succeeded.'
|
||||
} else {
|
||||
throw `Error sending transaction: ${result}`
|
||||
}
|
||||
client.disconnect()
|
||||
} // End setFlag()
|
||||
|
||||
/*****************************************
|
||||
************* Clear Flag *****************
|
||||
*****************************************/
|
||||
|
||||
async function clearFlag(my_flag) {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
await client.connect()
|
||||
let my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
settings_tx = {
|
||||
"TransactionType": "AccountSet",
|
||||
"Account": my_wallet.address,
|
||||
"ClearFlag": my_flag
|
||||
}
|
||||
resultField.value += '\nClearing flag ' + allFlags[my_flag] + "."
|
||||
const prepared = await client.autofill(settings_tx)
|
||||
const signed = my_wallet.sign(prepared)
|
||||
const result = await client.submitAndWait(signed.tx_blob)
|
||||
if (result.result.meta.TransactionResult == "tesSUCCESS") {
|
||||
results += '\nAccount setting succeeded.'
|
||||
} else {
|
||||
throw `Error sending transaction: ${result}`
|
||||
}
|
||||
client.disconnect()
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
************* Set Issuer *****************
|
||||
*****************************************/
|
||||
|
||||
function setIssuer() {
|
||||
document.getElementById("defaultRipple").checked = true
|
||||
document.getElementById("allowTrustLineClawback").checked = false
|
||||
document.getElementById("depositAuth").checked = true
|
||||
document.getElementById("disableMasterKey").checked = false
|
||||
document.getElementById("disallowIncomingCheck").checked = true
|
||||
document.getElementById("disallowIncomingNFTokenOffer").checked = true
|
||||
document.getElementById("disallowIncomingPayChan").checked = true
|
||||
document.getElementById("disallowIncomingTrustline").checked = false
|
||||
document.getElementById("disallowIncomingXRP").checked = true
|
||||
document.getElementById("globalFreeze").checked = false
|
||||
document.getElementById("noFreeze").checked = false
|
||||
document.getElementById("requireAuthorization").checked = false
|
||||
document.getElementById("requireDestinationTag").checked = false
|
||||
document.getElementById("account_flags").style.display="block"
|
||||
document.getElementById("issuer_additional_fields").style.display="block"
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
*********** Set Exchanger ****************
|
||||
*****************************************/
|
||||
|
||||
function setExchanger() {
|
||||
document.getElementById("defaultRipple").checked = true
|
||||
document.getElementById("allowTrustLineClawback").checked = false
|
||||
document.getElementById("depositAuth").checked = false
|
||||
document.getElementById("disableMasterKey").checked = false
|
||||
document.getElementById("disallowIncomingCheck").checked = false
|
||||
document.getElementById("disallowIncomingNFTokenOffer").checked = true
|
||||
document.getElementById("disallowIncomingPayChan").checked = true
|
||||
document.getElementById("disallowIncomingTrustline").checked = false
|
||||
document.getElementById("disallowIncomingXRP").checked = false
|
||||
document.getElementById("globalFreeze").checked = false
|
||||
document.getElementById("noFreeze").checked = false
|
||||
document.getElementById("requireAuthorization").checked = false
|
||||
document.getElementById("requireDestinationTag").checked = true
|
||||
document.getElementById("account_flags").style.display="block"
|
||||
document.getElementById("issuer_additional_fields").style.display="none"
|
||||
document.getElementById("domainField").value = ""
|
||||
document.getElementById("transferRateField").value = ""
|
||||
document.getElementById("tickSizeField").value = ""
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
************* Set Holder *****************
|
||||
*****************************************/
|
||||
|
||||
function setHolder()
|
||||
{
|
||||
document.getElementById("defaultRipple").checked = false
|
||||
document.getElementById("allowTrustLineClawback").checked = false
|
||||
document.getElementById("depositAuth").checked = false
|
||||
document.getElementById("disableMasterKey").checked = false
|
||||
document.getElementById("disallowIncomingCheck").checked = false
|
||||
document.getElementById("disallowIncomingNFTokenOffer").checked = false
|
||||
document.getElementById("disallowIncomingPayChan").checked = false
|
||||
document.getElementById("disallowIncomingTrustline").checked = false
|
||||
document.getElementById("disallowIncomingXRP").checked = false
|
||||
document.getElementById("globalFreeze").checked = false
|
||||
document.getElementById("noFreeze").checked = false
|
||||
document.getElementById("requireAuthorization").checked = false
|
||||
document.getElementById("requireDestinationTag").checked = false
|
||||
document.getElementById("domainField").value = ""
|
||||
document.getElementById("transferRateField").value = ""
|
||||
document.getElementById("tickSizeField").value = ""
|
||||
document.getElementById("issuer_additional_fields").style.display="none"
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
************* Remove Signers *************
|
||||
*****************************************/
|
||||
|
||||
async function removeSigners() {
|
||||
let net = getNet()
|
||||
const client = new xrpl.Client(net)
|
||||
resultField.value = `Connecting to ${net}.`
|
||||
await client.connect()
|
||||
my_wallet = xrpl.Wallet.fromSeed(seedField.value)
|
||||
|
||||
signer1AccountField.value = ""
|
||||
signer2AccountField.value = ""
|
||||
signer3AccountField.value = ""
|
||||
signer1WeightField.value = ""
|
||||
signer2WeightField.value= ""
|
||||
signer3WeightField.value = ""
|
||||
signerQuorumField.value = ""
|
||||
my_signers= {
|
||||
"Flags": 0,
|
||||
"TransactionType": "SignerListSet",
|
||||
"Account": my_wallet.address,
|
||||
"Fee": "12",
|
||||
"SignerQuorum": 0
|
||||
}
|
||||
const preparedSigner = await client.autofill(my_signers)
|
||||
const signedSigner = my_wallet.sign(preparedSigner)
|
||||
const resultSigner = await client.submitAndWait(signedSigner.tx_blob)
|
||||
resultField.value += JSON.stringify(resultSigner, null, 2)
|
||||
client.disconnect()
|
||||
}
|
||||
BIN
_code-samples/account-configurator/account-configurator.zip
Normal file
BIN
_code-samples/account-configurator/account-configurator.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user