Skip to content

Commit

Permalink
Merge pull request #32 from laviniat1996/vis_atomicTx
Browse files Browse the repository at this point in the history
Add data visualization to `evm.getAtomicTx`
  • Loading branch information
cgcardona authored Aug 9, 2023
2 parents dd133e4 + 24fcfdf commit 164ccef
Showing 1 changed file with 333 additions and 2 deletions.
335 changes: 333 additions & 2 deletions Avalanche.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"info": {
"_postman_id": "133cf180-c9cf-4d6b-9834-944dc66f7f0f",
"_postman_id": "3d716136-a9a1-45a5-86ca-2102a10a86a7",
"name": "Avalanche",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "23086587"
Expand Down Expand Up @@ -4973,12 +4973,343 @@
},
{
"name": "getAtomicTx",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var res = {};",
"const req = JSON.parse(pm.request.body.raw)",
"const txID = req.params.txID",
"var view = `",
"",
" <style type=\"text/css\">",
" table {border: 1px solid #000080; table-layout:fixed;}",
" td {border: 1px solid gray; word-wrap: break-word;max-width: 1000px;}",
" th {font-size:18px;background-color:#B0B0B0;}",
"",
" .generalInfo {background:#FFFDD0}",
" #inputsHeader {background:#F67280}",
" .inputs {background:#FFCCCB}",
" .assetInputs {background: #FFF0F5}",
" #outputsHeader {background:#B6D0E2}",
" .outputs {background:#F0F8FF}",
" .assetOutputs {background: #FDFFFF}",
" ",
"</style>",
"",
"<script>",
"function convertToAvax(){",
" const txValuePlusFees = document.getElementsByClassName(\"amount\")",
" for (let i=0; i < txValuePlusFees.length; i++){",
" const amountValue = txValuePlusFees[i].innerText",
" const amountInAvax = amountValue / 10 ** 18",
" txValuePlusFees[i].innerHTML = amountInAvax + \" AVAX\"",
" }",
"",
" const inputsAmount = document.getElementById(\"inputsAmount\")",
" const amountValueInp = inputsAmount.innerText",
" const inpAmountInAvax = amountValueInp / 10 ** 9",
" inputsAmount.innerHTML = inpAmountInAvax + \" AVAX\"",
"",
" const outputsAmount = document.getElementById(\"outputsAmount\")",
" const amountValueOut = outputsAmount.innerText",
" const outAmountInAvax = amountValueOut / 10 ** 9",
" outputsAmount.innerHTML = outAmountInAvax + \" AVAX\"",
"",
"}",
"",
"function convertTime() {",
" const dateCell = document.getElementById(\"time\")",
" const date = dateCell.innerText",
" const splitDate = date.split(\"T\")",
" const time = splitDate[1].split(\"000Z\")",
"",
" dateCell.innerHTML = splitDate[0] + \" | \" + time[0]",
"}",
"</script>",
"",
"<body onLoad = \"convertToAvax(), convertTime()\">",
"",
"<table>",
" <tr>",
" <th colspan=\"3\"> Decoded Atomic TX: </th>",
" </tr>",
" ",
" <tr>",
" <td class = \"generalInfo\"> ID: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.id}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Type: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.type}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> From: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.from}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> To: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.to}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> From: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.from}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Chain ID: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.chainId}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Date: </td>",
" <td class = \"generalInfo\" id = \"time\" colspan=\"2\"> {{response.timestamp}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Block number: </td>",
" <td class = \"generalInfo\" colspan=\"2\" > {{response.blockNumber}} </td>",
" </tr>",
" ",
" <tr>",
" <td class = \"generalInfo\"> Block hash: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.blockHash}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Value: </td>",
" <td class = \"generalInfo amount\" colspan=\"2\"> {{response.value}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Burned fees: </td>",
" <td class = \"generalInfo amount\" colspan=\"2\"> {{response.burnedFees}} </td>",
" </tr>",
"",
" <tr>",
" <td class = \"generalInfo\"> Status: </td>",
" <td class = \"generalInfo\" colspan=\"2\"> {{response.status}} </td>",
" </tr>",
"",
" <tr>",
" <td id = \"inputsHeader\" colspan=\"3\"> Inputs </td>",
" </tr>",
"",
" {{#if response.inputs.0.address}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> Address: </td>",
" <td class = \"inputs\"> {{response.inputs.0.address}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.inputs.0.nonce}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> Nonce: </td>",
" <td class = \"inputs\"> {{response.inputs.0.nonce}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.inputs.0.id}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> ID: </td>",
" <td class = \"inputs\"> {{response.inputs.0.id}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.inputs.0.txId}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> Transaction ID: </td>",
" <td class = \"inputs\"> {{response.inputs.0.txId}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.inputs.0.index}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> Index: </td>",
" <td class = \"inputs\"> {{response.inputs.0.index}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.inputs.0.amount}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> Amount: </td>",
" <td class = \"inputs\" id = \"inputsAmount\"> {{response.inputs.0.amount}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.inputs.0.srcChain}}",
" <tr>",
" <td></td>",
" <td class = \"inputs\"> Source chain: </td>",
" <td class = \"inputs\"> {{response.inputs.0.srcChain}} </td>",
" </tr>",
" {{/if}}",
"",
" <tr>",
" <td></td>",
" <td class = \"assetInputs\"> Asset ID: </td>",
" <td class = \"assetInputs\"> {{response.inputs.0.asset.id}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetInputs\"> Asset name: </td>",
" <td class = \"assetInputs\"> {{response.inputs.0.asset.name}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetInputs\"> Asset symbol: </td>",
" <td class = \"assetInputs\"> {{response.inputs.0.asset.symbol}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetInputs\"> Asset denomination: </td>",
" <td class = \"assetInputs\"> {{response.inputs.0.asset.denomination}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetInputs\"> Asset type: </td>",
" <td class = \"assetInputs\"> {{response.inputs.0.asset.type}} </td>",
" </tr>",
"",
" <tr>",
" <td id = \"outputsHeader\" colspan=\"3\"> Outputs </td>",
" </tr>",
"",
" {{#if response.outputs.0.address}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Address: </td>",
" <td class = \"outputs\"> {{response.outputs.0.address}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.id}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> ID: </td>",
" <td class = \"outputs\"> {{response.outputs.0.id}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.txId}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Transaction ID: </td>",
" <td class = \"outputs\"> {{response.outputs.0.txId}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.index}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Index: </td>",
" <td class = \"outputs\"> {{response.outputs.0.index}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.amount}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Amount: </td>",
" <td class = \"outputs\" id = \"outputsAmount\"> {{response.outputs.0.amount}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.dstChain}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Destination chain: </td>",
" <td class = \"outputs\"> {{response.outputs.0.dstChain}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.owner.addresses}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Owner address: </td>",
" <td class = \"outputs\"> {{response.outputs.0.owner.addresses}} </td>",
" </tr>",
" {{/if}}",
"",
" {{#if response.outputs.0.owner.threshold}}",
" <tr>",
" <td></td>",
" <td class = \"outputs\"> Threshold: </td>",
" <td class = \"outputs\"> {{response.outputs.0.owner.threshold}} </td>",
" </tr>",
" {{/if}}",
"",
"",
" <tr>",
" <td></td>",
" <td class = \"assetOutputs\"> Asset ID: </td>",
" <td class = \"assetOutputs\"> {{response.outputs.0.asset.id}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetOutputs\"> Asset name: </td>",
" <td class = \"assetOutputs\"> {{response.outputs.0.asset.name}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetOutputs\"> Asset symbol: </td>",
" <td class = \"assetOutputs\"> {{response.outputs.0.asset.symbol}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetOutputs\"> Asset denomination: </td>",
" <td class = \"assetOutputs\"> {{response.outputs.0.asset.denomination}} </td>",
" </tr>",
"",
" <tr>",
" <td></td>",
" <td class = \"assetOutputs\"> Asset type: </td>",
" <td class = \"assetOutputs\"> {{response.outputs.0.asset.type}} </td>",
" </tr>",
"",
"",
" </table>",
"`;",
"",
"const requestURL = \"https://api-beta.avascan.info/v2/network/mainnet/evm/43114/transactions/\" + txID ;",
"console.log(requestURL)",
"pm.sendRequest(requestURL, function (err, response) {",
" res = response.json();",
" console.log(res.value)",
" pm.visualizer.set(view, {",
" response: res,",
" });",
"})",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"jsonrpc\":\"2.0\",\n \"id\" :1,\n \"method\" :\"avax.getAtomicTx\",\n \"params\" :{\n \"txID\":\"2GD5SRYJQr2kw5jE73trBFiAgVQyrCaeg223TaTyJFYXf2kPty\",\n \"encoding\": \"hex\"\n }\n}",
"raw": "{\n \"jsonrpc\":\"2.0\",\n \"id\" :1,\n \"method\" :\"avax.getAtomicTx\",\n \"params\" :{\n \"txID\":\"9zX25brVj24xMBXJFw973MGVgkuDwvFPyBQoqo4pLye5mBkhN\",\n \"encoding\": \"hex\"\n }\n}\n\n//choose \"Visualize\" from the output section to see the decoded tx",
"options": {
"raw": {
"language": "json"
Expand Down

0 comments on commit 164ccef

Please sign in to comment.