Closed claytantor closed 1 year ago
Added the native implementation of the Xumm payload creation with websocket subscription as an event with create and subscribe
create and subscribe
/** * uses the create and subscribe method from the xumm * SDK to listen for events * * @param {*} xummSDK * @param {*} xummPayload */ const handleTxPayloadNativeWS = async (xummSDK, xummPayload) => { try { const pong = await xummSDK.ping() console.log(pong.application) const payloadResponse = xummSDK.payload.createAndSubscribe(xummPayload, e => { console.log("event subscription",e.data); setWebsocketMessage(e.data); if (typeof e.data.signed !== 'undefined') { setTxStatus(1); setTxStatusMessage(`Payment signed.`); setPaymentPayload(null); setFormState({'destination': ''}); // wait 5 seconds and then clear the message setTimeout(function () { setWebsocketMessage(null); setTxStatusMessage(null); setTxStatus(0); }, 5000); return e.data }; }); const r = await payloadResponse setPaymentPayload(await r.created); setTxStatusMessage("Listening for the TX Sign request to the Wallet."); } catch (e) { console.log({error: e.message, stack: e.stack}) } }
Added the native implementation of the Xumm payload creation with websocket subscription as an event with
create and subscribe