Skip to content
Snippets Groups Projects
Select Git revision
  • cadb07530ec282181e6140f95883b7fc72608310
  • master default protected
  • upgrade-polkadot-v1.19.1
  • 311_gtest_fixes
  • set_UniversalDividendApi_in_RuntimeApiCollection
  • network/gtest-1000 protected
  • upgradable-multisig
  • runtime/gtest-1000
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • gtest-1000-0.11.1 protected
  • gtest-1000-0.11.0 protected
  • gtest-1000 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
41 results

setup.md

Blame
  • utility.py 1.31 KiB
    import json, base58
    from urllib.request import urlopen
    from custom.parameters import *
    from substrateinterface import Keypair, KeypairType
    
    
    def v1_pubkey_to_v2_address(pubkey):
        pubkey_bytes = base58.b58decode(pubkey)
        pubkey_length = len(pubkey_bytes)
    
        # Add 0 head byte to pubkey so as to reach 32 bytes
        if pubkey_length < 32:
            pubkey_bytes = bytes([0] * (32 - pubkey_length)) + pubkey_bytes
    
        # get incomplete Substrate keypair (only public key) from public key bytes
        keypair = Keypair(
            public_key=pubkey_bytes, ss58_format=42, crypto_type=KeypairType.ED25519
        )
    
        # return V2 address
        return keypair.ss58_address
    
    
    def date_to_bloc_number(date_timestamp: int, start_timestamp: int):
        "converts a unix timestamp to a block number in blockchain v2 based on estimated start timestamp"
        timestamp = date_timestamp - start_timestamp  # can be negative
        return b_seconds(timestamp) # lower approximation
    
    
    def load_json(data):
        get_data = open(data)
        return json.load(get_data)
    
    
    def load_json_url(url):
        with open(".env", "r") as file:
            env = file.read()
    
        if "prod=true" in env:
            path = "/home/axiom/dex-data/"
            f = open(path + url)
        else:
            website = "https://g1-migrator.axiom-team.fr/"
            f = urlopen(website + url)
        return json.load(f)