Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Created September 18, 2020 10:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WietseWind/e13ab068f06b5e9f2f4a0aeac96f6e2e to your computer and use it in GitHub Desktop.
Save WietseWind/e13ab068f06b5e9f2f4a0aeac96f6e2e to your computer and use it in GitHub Desktop.
XUMM SDK - Subscription - Async process after returning data in the callback function
import {XummSdk} from 'xumm-sdk'
const Sdk = new XummSdk()
const main = async () => {
const payloadByUuid = '1289e9ae-7d5d-4d5f-b89c-18633112ce09'
const subscription = await Sdk.payload.subscribe(payloadByUuid, event => {
console.log(`Payload ${event.uuid} data:`, event.data)
// If the transaction resolved:
if (typeof event.data.signed !== 'undefined') {
/**
* Handle payload resolving, eg:
* 1. Fetch updated payload results, with `Sdk.payload.get()`
* 2. Fetch the transaction by hash (retrieved with 1.) on the XRPL to verify the transaction
* 3. Persist the results in your own app's database
* 4. Inform (async) the user (notification, mail, ...) if required
*/
// Resolve & close the subscription
return true
}
})
// Just continue doing things here. No need to wait.
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment