mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-04 11:55:50 +00:00
xrpl.js 2.0: remove more TODOs, cleanup set individual freeze
This commit is contained in:
@@ -22,7 +22,7 @@ async function main() {
|
||||
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze -------
|
||||
console.log('Signing and submitting the transaction:', accountSetTx)
|
||||
await client.submitReliable(wallet, accountSetTx)
|
||||
await client.submitAndWait(wallet, accountSetTx)
|
||||
console.log("Finished submitting!")
|
||||
|
||||
// Checking the status of the global freeze -----------------------------------
|
||||
@@ -51,7 +51,7 @@ async function main() {
|
||||
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze -------
|
||||
console.log('Signing and submitting the transaction:', accountSetTx2)
|
||||
const result = await client.submitReliable(wallet, accountSetTx2)
|
||||
const result = await client.submitAndWait(wallet, accountSetTx2)
|
||||
console.log("Finished submitting!")
|
||||
|
||||
// Checking the status of the global freeze -----------------------------------
|
||||
|
||||
@@ -22,7 +22,7 @@ async function main() {
|
||||
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze -------
|
||||
console.log('Signing and submitting the transaction:', accountSetTx)
|
||||
await client.submitReliable(wallet, accountSetTx)
|
||||
await client.submitAndWait(wallet, accountSetTx)
|
||||
console.log(`Finished submitting! ${wallet.address} should be frozen now.`)
|
||||
|
||||
// Investigate ----------------------------------------------------------------
|
||||
@@ -40,7 +40,7 @@ async function main() {
|
||||
|
||||
// Sign and submit the AccountSet transaction to enable a global freeze -------
|
||||
console.log('Signing and submitting the transaction:', accountSetTx2)
|
||||
const result = await client.submitReliable(wallet, accountSetTx2)
|
||||
const result = await client.submitAndWait(wallet, accountSetTx2)
|
||||
console.log("Finished submitting!")
|
||||
|
||||
console.log("Disconnecting")
|
||||
|
||||
@@ -74,7 +74,7 @@ async function main() {
|
||||
|
||||
// Submit a TrustSet transaction to set an individual freeze ----------------------
|
||||
console.log('Submitting TrustSet tx:', trust_set)
|
||||
const result = await client.submitReliable(wallet, trust_set)
|
||||
const result = await client.submitAndWait(wallet, trust_set)
|
||||
console.log("Submitted TrustSet!")
|
||||
|
||||
// Investigate --------------------------------------------------------------------
|
||||
@@ -86,15 +86,15 @@ async function main() {
|
||||
// We're reusing our TrustSet transaction from earlier with a different flag
|
||||
trust_set.Flags = xrpl.TrustSetFlags.tfClearFreeze
|
||||
|
||||
// Submit a TrustSet transaction to set an individual freeze ----------------------
|
||||
// Submit a TrustSet transaction to clear an individual freeze --------------------
|
||||
console.log('Submitting TrustSet tx:', trust_set)
|
||||
const result2 = await client.submitReliable(wallet, trust_set)
|
||||
const result2 = await client.submitAndWait(wallet, trust_set)
|
||||
console.log("Submitted TrustSet!")
|
||||
|
||||
console.log("Finished submitting. Now disconnecting.")
|
||||
await client.disconnect()
|
||||
|
||||
//End main()
|
||||
// End main()
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
||||
|
||||
@@ -23,7 +23,7 @@ async function main() {
|
||||
}
|
||||
|
||||
console.log('Sign and submit the transaction:', accountSetTx)
|
||||
await client.submitReliable(wallet, accountSetTx)
|
||||
await client.submitAndWait(wallet, accountSetTx)
|
||||
|
||||
console.log("Finished submitting. Now disconnecting.")
|
||||
await client.disconnect()
|
||||
|
||||
@@ -11,15 +11,15 @@ const wallet = xrpl.Wallet.fromSeed("sn3nxiW7v8KXzPzAqzyHXbSSKNuN9")
|
||||
// Connect -------------------------------------------------------------------
|
||||
async function main() {
|
||||
console.log("Connecting to Testnet...")
|
||||
const api = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await api.connect()
|
||||
const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')
|
||||
await client.connect()
|
||||
|
||||
// Get credentials from the Testnet Faucet -----------------------------------
|
||||
console.log("Getting a wallet from the Testnet faucet...")
|
||||
const {wallet, balance} = await api.fundWallet()
|
||||
const {wallet, balance} = await client.fundWallet()
|
||||
|
||||
// Prepare transaction -------------------------------------------------------
|
||||
const prepared = await api.autofill({
|
||||
const prepared = await client.autofill({
|
||||
"TransactionType": "Payment",
|
||||
"Account": wallet.address,
|
||||
"Amount": xrpl.xrpToDrops("22"),
|
||||
@@ -36,7 +36,7 @@ async function main() {
|
||||
console.log("Signed blob:", signed.tx_blob)
|
||||
|
||||
// Submit signed blob --------------------------------------------------------
|
||||
const tx = await api.submitAndWait(signed.tx_blob)
|
||||
const tx = await client.submitAndWait(signed.tx_blob)
|
||||
// This raises an exception if the transaction isn't confirmed.
|
||||
|
||||
// Wait for validation -------------------------------------------------------
|
||||
@@ -47,7 +47,7 @@ async function main() {
|
||||
console.log("Balance changes:", JSON.stringify(xrpl.getBalanceChanges(tx.result.meta), null, 2))
|
||||
|
||||
// End of main()
|
||||
api.disconnect()
|
||||
client.disconnect()
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
@@ -59,7 +59,7 @@ Anyone can check an account's `TransferRate` with the [account_info method][]. I
|
||||
|
||||
Some [client libraries](client-libraries.html) have convenience functions for getting and setting `TransferRate` functions.
|
||||
|
||||
**JavaScript:** ***TODO based on https://github.com/XRPLF/xrpl.js/pull/1720***
|
||||
**JavaScript:** Use `xrpl.percentToTransferRate()` to convert a percentage transfer fee from a string to the corresponding `TransferRate` value.
|
||||
|
||||
## See Also
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ async function main() {
|
||||
|
||||
let response = await api.request({
|
||||
"command": "ledger",
|
||||
"ledger_index": "validated"
|
||||
"ledger_index": "validated",
|
||||
"transactions": true
|
||||
});
|
||||
|
||||
let tx_id = response.result.transactions[0];
|
||||
let tx_id = response.result.ledger.transactions[0];
|
||||
let response2 = await api.request({
|
||||
"command": "tx",
|
||||
"transaction": tx_id
|
||||
|
||||
@@ -47,6 +47,12 @@ _JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/get-started/js/base.js", language="js") }}
|
||||
|
||||
_WebSocket_
|
||||
|
||||
```
|
||||
(Connect to wss:// URL of an XRP Ledger server using your preferred client.)
|
||||
```
|
||||
|
||||
<!-- MULTICODE_BLOCK_END -->
|
||||
|
||||
|
||||
@@ -66,13 +72,11 @@ To enable or disable an Individual Freeze on a specific trust line, send a [Trus
|
||||
|
||||
As always, to send a transaction, you _prepare_ it by filling in all the necessary fields, _sign_ it with your cryptographic keys, and _submit_ it to the network. For example:
|
||||
|
||||
***TODO: start_with / end_before on JS code sample as appropriate***
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/freeze/set-individual-freeze.js", language="js") }}
|
||||
{{ include_code("_code-samples/freeze/set-individual-freeze.js", language="js", start_with="// Prepare a TrustSet", end_before="// Investigate") }}
|
||||
|
||||
_WebSocket_
|
||||
|
||||
@@ -118,13 +122,11 @@ At this point, the trust line from the counterparty should be frozen. You can ch
|
||||
|
||||
In the response, the field `"freeze": true` indicates that the account from the request has enabled an Individual Freeze on that trust line. The field `"freeze_peer": true` indicates that the counterparty (`peer`) from the request has frozen the trust line.
|
||||
|
||||
***TODO: start_with / end_before on JS code sample as appropriate***
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/freeze/check-individual-freeze.js", language="js") }}
|
||||
{{ include_code("_code-samples/freeze/check-individual-freeze.js", language="js", start_with="// Look up current state", end_before="await client.disconnect()") }}
|
||||
|
||||
_WebSocket_
|
||||
|
||||
@@ -181,13 +183,11 @@ If you decide that the trust line no longer needs to be frozen (for example, you
|
||||
|
||||
As always, to send a transaction, you _prepare_ it by filling in all the necessary fields, _sign_ it with your cryptographic keys, and _submit_ it to the network. For example:
|
||||
|
||||
***TODO: start_with / end_before on JS code sample as appropriate***
|
||||
|
||||
<!-- MULTICODE_BLOCK_START -->
|
||||
|
||||
_JavaScript_
|
||||
|
||||
{{ include_code("_code-samples/freeze/set-individual-freeze.js", language="js") }}
|
||||
{{ include_code("_code-samples/freeze/set-individual-freeze.js", language="js", start_with="// Clear the individual", end_before="// End main") }}
|
||||
|
||||
_WebSocket_
|
||||
|
||||
|
||||
Reference in New Issue
Block a user