mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-28 23:55:49 +00:00
Freeze tutorials: fixes and cleanup
- Move JS code samples to JS folder (future-proofing for other languages) - Make "Freeze a Trust Line" tutorial interactive - Add necessary functionality to interactive_tutorial helper JS - Rework freeze a trust line tutorial/code sample to make an incoming line from another address and make looking up trust lines a full-fledged step
This commit is contained in:
34
content/_code-samples/freeze/js/check-global-freeze.js
Normal file
34
content/_code-samples/freeze/js/check-global-freeze.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// Dependencies for Node.js.
|
||||
// In browsers, use <script> tags as in the example demo.html.
|
||||
if (typeof module !== "undefined") {
|
||||
// gotta use var here because const/let are block-scoped to the if statement.
|
||||
var xrpl = require('xrpl')
|
||||
var { AccountRootFlags } = require('xrpl/dist/npm/models/ledger')
|
||||
}
|
||||
|
||||
// Connect -------------------------------------------------------------------
|
||||
async function main() {
|
||||
console.log("Connecting to Mainnet...")
|
||||
const client = new xrpl.Client('wss://s1.ripple.com')
|
||||
await client.connect()
|
||||
|
||||
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
|
||||
const lsfGlobalFreeze = xrpl.LedgerEntry.AccountRootFlags.lsfGlobalFreeze
|
||||
|
||||
console.log('Got settings for address', my_address);
|
||||
console.log('Global Freeze enabled?',
|
||||
((settings.account_data.Flags & lsfGlobalFreeze)
|
||||
=== lsfGlobalFreeze))
|
||||
|
||||
await client.disconnect()
|
||||
|
||||
// End main()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
|
||||
Reference in New Issue
Block a user