diff --git a/content/_code-samples/freeze/check-no-freeze.js b/content/_code-samples/freeze/check-no-freeze.js index 33a95037e0..87bd674a8c 100644 --- a/content/_code-samples/freeze/check-no-freeze.js +++ b/content/_code-samples/freeze/check-no-freeze.js @@ -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) - \ No newline at end of file diff --git a/content/_code-samples/freeze/set-global-freeze.js b/content/_code-samples/freeze/set-global-freeze.js index 4e7f31c536..492fc0166a 100644 --- a/content/_code-samples/freeze/set-global-freeze.js +++ b/content/_code-samples/freeze/set-global-freeze.js @@ -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) \ No newline at end of file +main().catch(console.error) diff --git a/content/_code-samples/freeze/set-no-freeze.js b/content/_code-samples/freeze/set-no-freeze.js index 653fc9bba4..398b7bd83c 100644 --- a/content/_code-samples/freeze/set-no-freeze.js +++ b/content/_code-samples/freeze/set-no-freeze.js @@ -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) \ No newline at end of file +main().catch(console.error) diff --git a/content/tutorials/use-tokens/enable-no-freeze.md b/content/tutorials/use-tokens/enable-no-freeze.md index cb957c5cc8..300708e0a5 100644 --- a/content/tutorials/use-tokens/enable-no-freeze.md +++ b/content/tutorials/use-tokens/enable-no-freeze.md @@ -57,7 +57,7 @@ For example: _JavaScript_ -{{ include_code("_code-samples/freeze/set-no-freeze.js", language="js") }} +{{ include_code("_code-samples/freeze/set-no-freeze.js", start_with="// Submit an AccountSet transaction", end_before="// Done", language="js") }} _WebSocket_ @@ -80,7 +80,6 @@ _WebSocket_ -***TODO: add start_with / end_before to all the include_code macros.*** ### {{n.next()}}. Wait for Validation @@ -92,12 +91,12 @@ Most transactions are accepted into the next ledger version after they're submit After the transaction is validated, you can check your account's settings to confirm that the No Freeze flag is enabled. You can do this by calling the [account_info method][] and checking the value of the account's `Flags` field to see if the [`lsfNoFreeze` bit (`0x00200000`)](accountroot.html#accountroot-flags) is enabled. - -***TODO: JS code sample for checking No Freeze*** - - +_JavaScript_ + +{{ include_code("_code-samples/freeze/check-no-freeze.js", start_with="// Request account info", end_before="await client.disconnect()", language="js") }} + _WebSocket_ ```json diff --git a/content/tutorials/use-tokens/enact-global-freeze.md b/content/tutorials/use-tokens/enact-global-freeze.md index 168ffd7bd6..8ae09bf292 100644 --- a/content/tutorials/use-tokens/enact-global-freeze.md +++ b/content/tutorials/use-tokens/enact-global-freeze.md @@ -64,7 +64,7 @@ For example: _JavaScript_ -{{ include_code("_code-samples/freeze/set-global-freeze.js", language="js") }} +{{ include_code("_code-samples/freeze/set-global-freeze.js", language="js", start_with="// Prepare an AccountSet", end_before="// Investigate") }} _WebSocket_ @@ -87,8 +87,6 @@ _WebSocket_ -***TODO: add start_with / end_before to all the include_code macros.*** - ### {{n.next()}}. Wait for Validation @@ -99,12 +97,12 @@ Most transactions are accepted into the next ledger version after they're submit After the transaction is validated, you can check your issuing account's settings to confirm that the Global Freeze flag is enabled. You can do this by calling the [account_info method][] and checking the value of the account's `Flags` field to see if the [`lsfGlobalFreeze` bit (`0x00400000`)](accountroot.html#accountroot-flags) is on. - -***TODO: JS code sample for checking Global Freeze*** - - +_JavaScript_ + +{{ include_code("_code-samples/freeze/check-global-freeze.js", language="js", start_with="// Request account info", end_before="await client.disconnect()") }} + _WebSocket_ ```json @@ -174,7 +172,7 @@ For example: _JavaScript_ -{{ include_code("_code-samples/freeze/set-global-freeze.js", language="js") }} +{{ include_code("_code-samples/freeze/set-global-freeze.js", language="js", start_with="// Now we disable", end_before="// Global freeze disabled") }} _WebSocket_ @@ -207,7 +205,6 @@ As before, wait for the previous transaction to be validated by consensus before After the transaction is validated, you can confirm the status of the Global Freeze flag in the same way as before: by calling the [account_info method][] and checking the value of the account's `Flags` field to see if the [`lsfGlobalFreeze` bit (`0x00400000`)](accountroot.html#accountroot-flags) is **off**. -***TODO: examples*** ## See Also