mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 03:35:51 +00:00
Freeze tutorials: remove TODOs for code samples
This commit is contained in:
@@ -4,31 +4,30 @@ if (typeof module !== "undefined") {
|
||||
// gotta use var here because const/let are block-scoped to the if statement.
|
||||
var xrpl = require('xrpl')
|
||||
}
|
||||
|
||||
|
||||
// Connect -------------------------------------------------------------------
|
||||
async function main() {
|
||||
console.log("Connecting to Mainnet...")
|
||||
const client = new xrpl.Client('wss://s1.ripple.com')
|
||||
await client.connect()
|
||||
|
||||
|
||||
client.on('error', (errorCode, errorMessage) => {
|
||||
console.log(errorCode + ': ' + errorMessage)
|
||||
})
|
||||
|
||||
|
||||
const my_address = 'rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn';
|
||||
|
||||
|
||||
// Request account info for my_address to check account settings ------------
|
||||
const response = await client.request(
|
||||
{command: 'account_info', account: my_address })
|
||||
const settings = response.result
|
||||
|
||||
|
||||
console.log('Got settings for address', my_address);
|
||||
console.log('No Freeze enabled?', (settings.noFreeze === true))
|
||||
|
||||
|
||||
await client.disconnect()
|
||||
|
||||
|
||||
// End main()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
|
||||
@@ -2,17 +2,17 @@ const xrpl = require('xrpl')
|
||||
|
||||
async function main() {
|
||||
// Connect -------------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
client.on('error', (errorCode, errorMessage) => {
|
||||
console.log(errorCode + ': ' + errorMessage)
|
||||
})
|
||||
// Get credentials from the Testnet Faucet ------------------------------------
|
||||
// Get credentials from the Testnet Faucet -----------------------------------
|
||||
console.log("Requesting an address from the Testnet faucet...")
|
||||
const { wallet, balance } = await client.fundWallet()
|
||||
|
||||
// Prepare an AccountSet transaction to enable global freeze ------------------
|
||||
// Prepare an AccountSet transaction to enable global freeze -----------------
|
||||
const accountSetTx = {
|
||||
TransactionType: "AccountSet",
|
||||
Account: wallet.address,
|
||||
@@ -20,17 +20,17 @@ async function main() {
|
||||
SetFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze
|
||||
}
|
||||
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze -------
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze ------
|
||||
console.log('Signing and submitting the transaction:', accountSetTx)
|
||||
await client.submitAndWait(wallet, accountSetTx)
|
||||
console.log(`Finished submitting! ${wallet.address} should be frozen now.`)
|
||||
|
||||
// Investigate ----------------------------------------------------------------
|
||||
// Investigate ---------------------------------------------------------------
|
||||
console.log(
|
||||
`You would investigate whatever prompted you to freeze the account now...`)
|
||||
await new Promise(resolve => setTimeout(resolve, 5000))
|
||||
|
||||
// Now we disable the global freeze -------------------------------------------
|
||||
// Now we disable the global freeze ------------------------------------------
|
||||
const accountSetTx2 = {
|
||||
TransactionType: "AccountSet",
|
||||
Account: wallet.address,
|
||||
@@ -38,15 +38,16 @@ async function main() {
|
||||
ClearFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze
|
||||
}
|
||||
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze -------
|
||||
// Sign and submit the AccountSet transaction to end a global freeze ---------
|
||||
console.log('Signing and submitting the transaction:', accountSetTx2)
|
||||
const result = await client.submitAndWait(wallet, accountSetTx2)
|
||||
console.log("Finished submitting!")
|
||||
|
||||
// Global freeze disabled
|
||||
console.log("Disconnecting")
|
||||
await client.disconnect()
|
||||
|
||||
// End main()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
main().catch(console.error)
|
||||
|
||||
@@ -2,7 +2,7 @@ const xrpl = require('xrpl')
|
||||
|
||||
async function main() {
|
||||
// Connect -------------------------------------------------------------------
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
console.log("Connected to Testnet")
|
||||
|
||||
@@ -24,11 +24,12 @@ async function main() {
|
||||
|
||||
console.log('Sign and submit the transaction:', accountSetTx)
|
||||
await client.submitAndWait(wallet, accountSetTx)
|
||||
|
||||
|
||||
// Done submitting
|
||||
console.log("Finished submitting. Now disconnecting.")
|
||||
await client.disconnect()
|
||||
|
||||
// End main()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
main().catch(console.error)
|
||||
|
||||
Reference in New Issue
Block a user