Skip to content

Commit

Permalink
fix: peerplays class recreations for sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
rilesdun committed Sep 26, 2023
1 parent 930fc0c commit cca3a4b
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 41 deletions.
7 changes: 7 additions & 0 deletions peerplays_instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
This module is used to initiate the peerplays instance
"""
from peerplays import PeerPlays
from config import api_url

peerplays = PeerPlays(api_url)
6 changes: 1 addition & 5 deletions src/accounts/account_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
This module contains functions to interact with the PeerPlays blockchain,
specifically to retrieve account history.
"""
from peerplays import PeerPlays
from peerplays.account import Account
from config import api_url

peerplays = PeerPlays(api_url)

from peerplays_instance import peerplays

def get_account_history(account_name):
"""
Expand Down
5 changes: 1 addition & 4 deletions src/accounts/get_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
This module contains the function to get account information.
"""
from peerplays.account import Account
from peerplays import PeerPlays
from config import api_url

peerplays = PeerPlays(api_url)
from peerplays_instance import peerplays

def get_account_info(account_name):
"""
Expand Down
4 changes: 1 addition & 3 deletions src/accounts/sons/active_sons.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
Module to fetch active sons from PeerPlays
"""
import sys
from peerplays import PeerPlays
from src.accounts.get_account import get_account_info
from src.supply.common import api_url
from peerplays_instance import peerplays

def get_active_sons():
"""
Function to get active sons from PeerPlays
"""
peerplays = PeerPlays(api_url)

object_id_prefix = "1.33."
object_id_number = 0
Expand Down
7 changes: 1 addition & 6 deletions src/accounts/witnesses/witnesses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
This module contains functions to fetch the list of active witnesses.
"""
import logging
from peerplays import PeerPlays
from peerplays.witness import Witnesses
from peerplays.account import Account
from cache_config import cache



# connect to a peerplays1 node
peerplays = PeerPlays("wss://ca.peerplays.info/api")
from peerplays_instance import peerplays

logger = logging.getLogger(__name__)

Expand Down
7 changes: 2 additions & 5 deletions src/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,15 @@
"""

import logging
from peerplays import PeerPlays

from peerplays.block import Block
from peerplays.witness import Witness
from config import api_url
from peerplays_instance import peerplays

logger = logging.getLogger(__name__)



peerplays = PeerPlays(api_url)


def get_block_info(block_num=None):
"""
Fetches and returns information about a specific block in the PeerPlays blockchain.
Expand Down
5 changes: 1 addition & 4 deletions src/get_latest_transactions.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
"""
This module is used to get the latest transactions from the Peerplays blockchain.
"""
from peerplays import PeerPlays
from peerplays.block import Block
from config import api_url

peerplays = PeerPlays(api_url)
from peerplays_instance import peerplays

def get_block_with_transactions(block_num):
"""
Expand Down
5 changes: 1 addition & 4 deletions src/latest_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
This file contains the function to get the latest block from the PeerPlays blockchain.
"""
from peerplays.blockchain import Blockchain
from peerplays import PeerPlays
from peerplays_instance import peerplays

from config import api_url

peerplays = PeerPlays(api_url)

def get_latest_block():
"""
Expand Down
3 changes: 2 additions & 1 deletion src/supply/circulating_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""
from peerplays.asset import Asset
from flask import Response
from src.supply.common import get_supplies, peerplays, ASSET_IDS
from src.supply.common import get_supplies, ASSET_IDS
from peerplays_instance import peerplays


def circulating_supply(coin_name):
Expand Down
4 changes: 0 additions & 4 deletions src/supply/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""
Common functions for supply endpoints
"""
from peerplays.peerplays import PeerPlays
from config import api_url

peerplays = PeerPlays(api_url)

ASSET_IDS = {
"ppy": "1.3.0",
Expand Down
3 changes: 2 additions & 1 deletion src/supply/max_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""
from peerplays.asset import Asset
from flask import Response
from src.supply.common import get_supplies, peerplays, ASSET_IDS
from src.supply.common import get_supplies, ASSET_IDS
from peerplays_instance import peerplays


def max_supply(coin_name):
Expand Down
3 changes: 2 additions & 1 deletion src/supply/rich_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""
from peerplays.asset import Asset
from flask import jsonify
from src.supply.common import sats_to_fixed, peerplays, ASSET_IDS
from src.supply.common import sats_to_fixed,ASSET_IDS
from peerplays_instance import peerplays


def rich_list(coin_name, num="25"):
Expand Down
3 changes: 1 addition & 2 deletions src/supply/supply_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
This module is used to get the supply details of the asset.
"""
from peerplays.asset import Asset
from peerplays import PeerPlays
from src.supply.common import get_supplies
from peerplays_instance import peerplays


def get_supply_details(asset_id="1.3.0"):
"""
returns the supply details of the asset
"""
peerplays = PeerPlays("wss://ca.peerplays.info/api")
A = Asset(asset_id, blockchain_instance=peerplays) # pylint: disable=invalid-name
supplies = get_supplies(A)

Expand Down
3 changes: 2 additions & 1 deletion src/supply/total_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"""
from peerplays.asset import Asset
from flask import Response
from src.supply.common import get_supplies, peerplays, ASSET_IDS
from src.supply.common import get_supplies, ASSET_IDS
from peerplays_instance import peerplays


def total_supply(coin_name):
Expand Down

0 comments on commit cca3a4b

Please sign in to comment.