mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
Monitoring transactions tutorial: feedback from @intelliot
This commit is contained in:
@@ -98,7 +98,8 @@ $("#connect-button").click((event) => {
|
|||||||
$("#connect-button").prop("disabled", false)
|
$("#connect-button").prop("disabled", false)
|
||||||
})
|
})
|
||||||
socket.addEventListener('message', (event) => {
|
socket.addEventListener('message', (event) => {
|
||||||
writeToConsole("#monitor-console-connect", "Got message from server: "+JSON.stringify(event.data))
|
writeToConsole("#monitor-console-connect", "Got message from server: " +
|
||||||
|
JSON.stringify(event.data))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -145,12 +146,12 @@ function api_request(options) {
|
|||||||
let resolveHolder;
|
let resolveHolder;
|
||||||
AWAITING[options.id] = new Promise((resolve, reject) => {
|
AWAITING[options.id] = new Promise((resolve, reject) => {
|
||||||
// Save the resolve func to be called by the handleResponse function later
|
// Save the resolve func to be called by the handleResponse function later
|
||||||
this.resolve = resolve
|
resolveHolder = resolve
|
||||||
try {
|
try {
|
||||||
// Use the socket opened in the previous example...
|
// Use the socket opened in the previous example...
|
||||||
socket.send(JSON.stringify(options))
|
socket.send(JSON.stringify(options))
|
||||||
} catch {
|
} catch(error) {
|
||||||
reject()
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
AWAITING[options.id].resolve = resolveHolder;
|
AWAITING[options.id].resolve = resolveHolder;
|
||||||
@@ -214,8 +215,8 @@ function api_request(options) {
|
|||||||
try {
|
try {
|
||||||
// Use the socket opened in the previous example...
|
// Use the socket opened in the previous example...
|
||||||
socket.send(JSON.stringify(options))
|
socket.send(JSON.stringify(options))
|
||||||
} catch {
|
} catch(error) {
|
||||||
reject()
|
reject(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
AWAITING[options.id].resolve = resolveFunc
|
AWAITING[options.id].resolve = resolveFunc
|
||||||
@@ -254,7 +255,7 @@ $("#dispatch_ping").click((event) => {
|
|||||||
|
|
||||||
To get a live notification whenever a transaction affects your account, you can subscribe to the account with the [subscribe method][]. In fact, it doesn't have to be your own account: since all transactions are public, you can subscribe to any account or even a combination of accounts.
|
To get a live notification whenever a transaction affects your account, you can subscribe to the account with the [subscribe method][]. In fact, it doesn't have to be your own account: since all transactions are public, you can subscribe to any account or even a combination of accounts.
|
||||||
|
|
||||||
After you subscribe to one or more accounts, you the server sends a message with `"type": "transaction"` on each _validated_ transaction that affects any of the specified accounts in some way. To confirm this, look for `"validated": true` in the transaction messages.
|
After you subscribe to one or more accounts, the server sends a message with `"type": "transaction"` on each _validated_ transaction that affects any of the specified accounts in some way. To confirm this, look for `"validated": true` in the transaction messages.
|
||||||
|
|
||||||
The following code sample subscribes to the Test Net Faucet's sending address. It logs a message on each such transaction by adding a handler to the dispatcher from the previous step.
|
The following code sample subscribes to the Test Net Faucet's sending address. It logs a message on each such transaction by adding a handler to the dispatcher from the previous step.
|
||||||
|
|
||||||
@@ -416,7 +417,8 @@ function CountXRPReceived(tx, address) {
|
|||||||
}
|
}
|
||||||
if (tx.transaction.TransactionType === "Payment") {
|
if (tx.transaction.TransactionType === "Payment") {
|
||||||
if (tx.transaction.Destination !== address) {
|
if (tx.transaction.Destination !== address) {
|
||||||
writeToConsole("#monitor-console-read", "Not the destination of this payment. (We're "+address+"; they're "+tx.transaction.Destination+")")
|
writeToConsole("#monitor-console-read", "Not the destination of this payment. (We're " +
|
||||||
|
address + "; they're " + tx.transaction.Destination + ")")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (typeof tx.meta.delivered_amount === "string") {
|
if (typeof tx.meta.delivered_amount === "string") {
|
||||||
@@ -458,7 +460,7 @@ $("#tx_read").click((event) => {
|
|||||||
|
|
||||||
- [Look Up Transaction Results](look-up-transaction-results.html) to see exactly what a transaction did, and build your software to react appropriately.
|
- [Look Up Transaction Results](look-up-transaction-results.html) to see exactly what a transaction did, and build your software to react appropriately.
|
||||||
- Try [Sending XRP](send-xrp.html) from your own address.
|
- Try [Sending XRP](send-xrp.html) from your own address.
|
||||||
- Try monitoring for transactions of advanced types like [Escrows](escrow.html), [Checks](checks.html), or [Payment Channels](payment-channels), and responding to incoming notifications.
|
- Try monitoring for transactions of advanced types like [Escrows](escrow.html), [Checks](checks.html), or [Payment Channels](payment-channels.html), and responding to incoming notifications.
|
||||||
<!--{# TODO: uncomment when it's ready. - To more robustly handle internet instability, [Follow a Transaction Chain](follow-a-transaction-chain.html) to detect if you missed a notification. #}-->
|
<!--{# TODO: uncomment when it's ready. - To more robustly handle internet instability, [Follow a Transaction Chain](follow-a-transaction-chain.html) to detect if you missed a notification. #}-->
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user