Skip to content

Instantly share code, notes, and snippets.

@DeanDonkov
Created March 22, 2024 10:34
Show Gist options
  • Save DeanDonkov/8e03283825bffe11b55fc92772f638e3 to your computer and use it in GitHub Desktop.
Save DeanDonkov/8e03283825bffe11b55fc92772f638e3 to your computer and use it in GitHub Desktop.
<WebView
source={{ uri: 'https://staging.assetify.net/kaspa-worker/index.html' }}
javaScriptEnabled={true}
injectedJavaScript={`
const consoleLog = (type, log) => {
let data;
try {
data = JSON.parse(log);
} catch (e) {
data = log;
}
const message = JSON.stringify({ type: 'Console', data: { type, type, log: data } });
window.ReactNativeWebView.postMessage(message);
};
console = {
log: (log) => consoleLog('log', log),
debug: (log) => consoleLog('debug', log),
info: (log) => consoleLog('info', log),
warn: (log) => consoleLog('warn', log),
error: (log) => consoleLog('error', log),
};
let tx = {
"id": "b98d8a74679965e4c8614e9aa1827785cf187ab06bb23f8b74d11d2a008d0f60",
"inputs": [
{
"transactionId": "c26115b84f07369576d64fbeabec9054f9e7629b3281d96880c13056a7af523a",
index: 0,
"previousOutpoint": {
"transactionId": "c26115b84f07369576d64fbeabec9054f9e7629b3281d96880c13056a7af523a",
"index": 0
},
"signatureScript": "",
"sequence": 0,
"sigOpCount": 1,
"utxo": {
"entry": {
"scriptPublicKey": {
"version": 0,
"script": "20565daa1812f4b7a7c7a5cdeb240eb90cbb2605f7f409a1706bd403c2980bc078ac"
},
"address": {
"version": "PubKey",
"prefix": "kaspa",
"payload": "qpt9m2sczt6t0f785hx7kfqwhyxtkfs97l6qngtsd02q8s5cp0q8sqh8c6ya0"
},
"outpoint": {
"transactionId": "c26115b84f07369576d64fbeabec9054f9e7629b3281d96880c13056a7af523a",
"index": 0
},
"amount": 100000000,
"blockDaaScore": 72957405,
"isCoinbase": false
},
"scriptPublicKey": {
"version": 0,
"script": "20565daa1812f4b7a7c7a5cdeb240eb90cbb2605f7f409a1706bd403c2980bc078ac"
},
"amount": 100000000,
"isCoinbase": false,
"blockDaaScore": 72957405
}
},
{
"transactionId": "243a8e3c195a591b02dc6a7203b8d875693bc8c263504bc10c5880111e177aa5",
index: 0,
"previousOutpoint": {
"transactionId": "243a8e3c195a591b02dc6a7203b8d875693bc8c263504bc10c5880111e177aa5",
"index": 0
},
"signatureScript": "",
"sequence": 0,
"sigOpCount": 1,
"utxo": {
"entry": {
"scriptPublicKey": {
"version": 0,
"script": "20565daa1812f4b7a7c7a5cdeb240eb90cbb2605f7f409a1706bd403c2980bc078ac"
},
"address": {
"version": "PubKey",
"prefix": "kaspa",
"payload": "qpt9m2sczt6t0f785hx7kfqwhyxtkfs97l6qngtsd02q8s5cp0q8sqh8c6ya0"
},
"outpoint": {
"transactionId": "243a8e3c195a591b02dc6a7203b8d875693bc8c263504bc10c5880111e177aa5",
"index": 0
},
"amount": 2000000000,
"blockDaaScore": 74545253,
"isCoinbase": false
},
"scriptPublicKey": {
"version": 0,
"script": "20565daa1812f4b7a7c7a5cdeb240eb90cbb2605f7f409a1706bd403c2980bc078ac"
},
"amount": 2000000000,
"isCoinbase": false,
"blockDaaScore": 74545253
}
}
],
"outputs": [
{
"value": 100000000,
"scriptPublicKey": {
"version": 0,
"script": "20e56b3fa662b07f038115ba04da2fd02272047a8b2779a63fff539b59513b995eac"
}
},
{
"value": 1999978250,
"scriptPublicKey": {
"version": 0,
"script": "20565daa1812f4b7a7c7a5cdeb240eb90cbb2605f7f409a1706bd403c2980bc078ac"
}
}
],
"version": 0,
"lockTime": 0,
"gas": 0,
"subnetworkId": "0000000000000000000000000000000000000000",
"payload": ""
}
hashTx(tx, "private-key").then((hashed) => { console.log(hashed) });`}
onMessage={(event) => {
const message = event.nativeEvent.data;
const obj = parse(message)
console.log(stringify((obj as any).data.log.tx))
}}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment