From 8619de8397a29120ba127c538bb707140d9bbde1 Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Mon, 27 May 2024 16:40:41 +0200 Subject: [PATCH 1/2] dump teleports --- client/dump_teleports.py | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 client/dump_teleports.py diff --git a/client/dump_teleports.py b/client/dump_teleports.py new file mode 100644 index 00000000..7103e10a --- /dev/null +++ b/client/dump_teleports.py @@ -0,0 +1,51 @@ +import requests +import pandas as pd + +# Define the URL and the data for the POST request +url = "https://api.encointer.org/v1/indexer2/query" +data = { + "collection": "extrinsics", + "query": { + "section": "polkadotXcm", + "method": "limitedTeleportAssets" + }, + "options": { + "limit": 100, + "skip": 0, + "sort": { + "blockNumber": -1 + } + } +} + +# Send the POST request +response = requests.post(url, json=data) + +# Check if the request was successful +if response.status_code == 200: + # Parse the JSON response into a pandas DataFrame + json_response = response.json() + data = [] + for item in json_response: + signer = item['signer']['Id'] + extrinsic_id = item['_id'] + block_hash = item['blockHash'] + beneficiary = '' + if 'V1' in item['args']['beneficiary']: + beneficiary = item['args']['beneficiary']['V1']['interior']['X1']['AccountId32']['id'] + elif 'V3' in item['args']['beneficiary']: + beneficiary = item['args']['beneficiary']['V3']['interior']['X1']['AccountId32']['id'] + elif 'V4' in item['args']['beneficiary']: + beneficiary = item['args']['beneficiary']['V4']['interior']['X1'][0]['AccountId32']['id'] + + amount = 0 + if 'V1' in item['args']['assets']: + amount = int(item['args']['assets']['V1'][0]['fun']['Fungible'].replace(',', '')) + elif 'V3' in item['args']['beneficiary']: + amount = int(item['args']['assets']['V3'][0]['fun']['Fungible'].replace(',', '')) + elif 'V4' in item['args']['beneficiary']: + amount = int(item['args']['assets']['V4'][0]['fun']['Fungible'].replace(',', '')) + print(f"{extrinsic_id}, {block_hash}, {signer}, {beneficiary}, {amount}") + # Print the DataFrame +else: + print(f"Request failed with status code {response.status_code}") From 0b369b2f93c4146c9675aabfc4a10f4d9b80e30c Mon Sep 17 00:00:00 2001 From: Alain Brenzikofer Date: Mon, 27 May 2024 17:15:04 +0200 Subject: [PATCH 2/2] add script to dump drips --- client/dump_drips.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 client/dump_drips.py diff --git a/client/dump_drips.py b/client/dump_drips.py new file mode 100644 index 00000000..aa31fd71 --- /dev/null +++ b/client/dump_drips.py @@ -0,0 +1,40 @@ +import requests +import pandas as pd + +# Define the URL and the data for the POST request +url = "https://api.encointer.org/v1/indexer2/query" +data = { + "collection": "extrinsics", + "query": { + "section": "encointerFaucet", + "method": "drip", + "success": True, + }, + "options": { + "limit": 999, + "skip": 0, + "sort": { + "blockNumber": -1 + } + } +} + +# Send the POST request +response = requests.post(url, json=data) + +# Check if the request was successful +if response.status_code == 200: + # Parse the JSON response into a pandas DataFrame + json_response = response.json() + data = [] + for item in json_response: + signer = item['signer']['Id'] + extrinsic_id = item['_id'] + block_hash = item['blockHash'] + faucet = item['args']['faucet_account'] + cid = item['args']['cid'] + cindex = item['args']['cindex'] + print(f"{extrinsic_id}, {block_hash}, {signer}, {faucet}, {cid}, {cindex}") + # Print the DataFrame +else: + print(f"Request failed with status code {response.status_code}")