(ur: string)
| 124 | * @deprecated remove when we get rid of URv1 support |
| 125 | */ |
| 126 | const _onReadUniformResource = (ur: string) => { |
| 127 | try { |
| 128 | const [index, total] = extractSingleWorkload(ur); |
| 129 | animatedQRCodeData[index + 'of' + total] = ur; |
| 130 | setUrTotal(total); |
| 131 | setUrHave(Object.values(animatedQRCodeData).length); |
| 132 | if (Object.values(animatedQRCodeData).length === total) { |
| 133 | const payload = decodeUR(Object.values(animatedQRCodeData)); |
| 134 | // lets look inside that data |
| 135 | let data: false | string = false; |
| 136 | if (uint8ArrayToString(hexToUint8Array(String(payload))).startsWith('psbt')) { |
| 137 | // its a psbt, and whoever requested it expects it encoded in base64 |
| 138 | data = uint8ArrayToBase64(hexToUint8Array(String(payload))); |
| 139 | } else { |
| 140 | // its something else. probably plain text is expected |
| 141 | data = uint8ArrayToString(hexToUint8Array(String(payload))); |
| 142 | } |
| 143 | if (onBarScanned) { |
| 144 | onBarScanned(data, useBBQRRef.current); |
| 145 | navigation.goBack(); |
| 146 | } else if (launchedBy) { |
| 147 | navigation.dispatch(StackActions.popTo(launchedBy, { onBarScanned: data }, { merge: true })); |
| 148 | } |
| 149 | } else { |
| 150 | setAnimatedQRCodeData(animatedQRCodeData); |
| 151 | } |
| 152 | } catch (error: any) { |
| 153 | console.log('Invalid animated qr code fragment: ' + error.message + ' (continuing scanning)'); |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | const onBarCodeRead = (ret: { data: string }) => { |
| 158 | const h = HashIt(ret.data); |
no test coverage detected