Freeze tutorials: remove TODOs for code samples

This commit is contained in:
mDuo13
2021-10-20 01:57:54 -07:00
parent 58ea2abc40
commit d13b1a6895
5 changed files with 33 additions and 36 deletions

View File

@@ -31,4 +31,3 @@ if (typeof module !== "undefined") {
} }
main().catch(console.error) main().catch(console.error)

View File

@@ -8,11 +8,11 @@ async function main() {
client.on('error', (errorCode, errorMessage) => { client.on('error', (errorCode, errorMessage) => {
console.log(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...") console.log("Requesting an address from the Testnet faucet...")
const { wallet, balance } = await client.fundWallet() const { wallet, balance } = await client.fundWallet()
// Prepare an AccountSet transaction to enable global freeze ------------------ // Prepare an AccountSet transaction to enable global freeze -----------------
const accountSetTx = { const accountSetTx = {
TransactionType: "AccountSet", TransactionType: "AccountSet",
Account: wallet.address, Account: wallet.address,
@@ -20,17 +20,17 @@ async function main() {
SetFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze 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) console.log('Signing and submitting the transaction:', accountSetTx)
await client.submitAndWait(wallet, accountSetTx) await client.submitAndWait(wallet, accountSetTx)
console.log(`Finished submitting! ${wallet.address} should be frozen now.`) console.log(`Finished submitting! ${wallet.address} should be frozen now.`)
// Investigate ---------------------------------------------------------------- // Investigate ---------------------------------------------------------------
console.log( console.log(
`You would investigate whatever prompted you to freeze the account now...`) `You would investigate whatever prompted you to freeze the account now...`)
await new Promise(resolve => setTimeout(resolve, 5000)) await new Promise(resolve => setTimeout(resolve, 5000))
// Now we disable the global freeze ------------------------------------------- // Now we disable the global freeze ------------------------------------------
const accountSetTx2 = { const accountSetTx2 = {
TransactionType: "AccountSet", TransactionType: "AccountSet",
Account: wallet.address, Account: wallet.address,
@@ -38,11 +38,12 @@ async function main() {
ClearFlag: xrpl.AccountSetAsfFlags.asfGlobalFreeze 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) console.log('Signing and submitting the transaction:', accountSetTx2)
const result = await client.submitAndWait(wallet, accountSetTx2) const result = await client.submitAndWait(wallet, accountSetTx2)
console.log("Finished submitting!") console.log("Finished submitting!")
// Global freeze disabled
console.log("Disconnecting") console.log("Disconnecting")
await client.disconnect() await client.disconnect()

View File

@@ -25,6 +25,7 @@ async function main() {
console.log('Sign and submit the transaction:', accountSetTx) console.log('Sign and submit the transaction:', accountSetTx)
await client.submitAndWait(wallet, accountSetTx) await client.submitAndWait(wallet, accountSetTx)
// Done submitting
console.log("Finished submitting. Now disconnecting.") console.log("Finished submitting. Now disconnecting.")
await client.disconnect() await client.disconnect()

View File

@@ -57,7 +57,7 @@ For example:
_JavaScript_ _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_ _WebSocket_
@@ -80,7 +80,6 @@ _WebSocket_
<!-- MULTICODE_BLOCK_END --> <!-- MULTICODE_BLOCK_END -->
***TODO: add start_with / end_before to all the include_code macros.***
### {{n.next()}}. Wait for Validation ### {{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. 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***
<!-- MULTICODE_BLOCK_START --> <!-- MULTICODE_BLOCK_START -->
_JavaScript_
{{ include_code("_code-samples/freeze/check-no-freeze.js", start_with="// Request account info", end_before="await client.disconnect()", language="js") }}
_WebSocket_ _WebSocket_
```json ```json

View File

@@ -64,7 +64,7 @@ For example:
_JavaScript_ _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_ _WebSocket_
@@ -87,8 +87,6 @@ _WebSocket_
<!-- MULTICODE_BLOCK_END --> <!-- MULTICODE_BLOCK_END -->
***TODO: add start_with / end_before to all the include_code macros.***
### {{n.next()}}. Wait for Validation ### {{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. 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***
<!-- MULTICODE_BLOCK_START --> <!-- MULTICODE_BLOCK_START -->
_JavaScript_
{{ include_code("_code-samples/freeze/check-global-freeze.js", language="js", start_with="// Request account info", end_before="await client.disconnect()") }}
_WebSocket_ _WebSocket_
```json ```json
@@ -174,7 +172,7 @@ For example:
_JavaScript_ _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_ _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**. 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 ## See Also