Created
September 18, 2020 10:04
-
-
Save WietseWind/e13ab068f06b5e9f2f4a0aeac96f6e2e to your computer and use it in GitHub Desktop.
XUMM SDK - Subscription - Async process after returning data in the callback function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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