Files
xrpl-dev-portal/content/_code-samples/freeze/js/check-global-freeze.js
mDuo13 7c6257c2d8 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
2021-10-25 22:56:31 -07:00

34 lines
1.1 KiB
JavaScript

// 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)