Skip to content
Snippets Groups Projects
Commit ff741940 authored by Holger's avatar Holger
Browse files

Removed asset_precision and used precision from beemgraphenebase.chains instead

parent 5dc0af37
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,6 @@ from builtins import bytes, int, str ...@@ -6,7 +6,6 @@ from builtins import bytes, int, str
import re import re
import sys import sys
from .graphenerpc import GrapheneRPC from .graphenerpc import GrapheneRPC
from beemgraphenebase.chains import known_chains
from . import exceptions from . import exceptions
import logging import logging
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -19,27 +19,27 @@ from beemgraphenebase.objects import GrapheneObject, isArgsThisClass ...@@ -19,27 +19,27 @@ from beemgraphenebase.objects import GrapheneObject, isArgsThisClass
from .objecttypes import object_type from .objecttypes import object_type
from beemgraphenebase.account import PublicKey from beemgraphenebase.account import PublicKey
from beemgraphenebase.objects import Operation as GPHOperation from beemgraphenebase.objects import Operation as GPHOperation
from beemgraphenebase.chains import known_chains
from .operationids import operations from .operationids import operations
import struct import struct
default_prefix = "STM" default_prefix = "STM"
asset_precision = {
"STEEM": 3,
"VESTS": 6,
"SBD": 3,
"GBG": 3,
"GOLOS": 3
}
@python_2_unicode_compatible @python_2_unicode_compatible
class Amount(object): class Amount(object):
def __init__(self, d): def __init__(self, d):
if isinstance(d, string_types): if isinstance(d, string_types):
self.amount, self.asset = d.strip().split(" ") self.amount, self.asset = d.strip().split(" ")
if self.asset in asset_precision: self.precision = None
self.precision = asset_precision[self.asset] for c in known_chains:
else: if self.precision is not None:
continue
for asset in known_chains[c]["chain_assets"]:
if self.precision is not None:
continue
if asset["symbol"] == self.asset:
self.precision = asset["precision"]
if self.precision is None:
raise Exception("Asset unknown") raise Exception("Asset unknown")
self.amount = int(float(self.amount) * 10 ** self.precision) self.amount = int(float(self.amount) * 10 ** self.precision)
......
...@@ -15,7 +15,6 @@ from beemgraphenebase.types import ( ...@@ -15,7 +15,6 @@ from beemgraphenebase.types import (
Map, Id, JsonObj Map, Id, JsonObj
) )
from .py23 import py23_bytes, bytes_types, integer_types, string_types from .py23 import py23_bytes, bytes_types, integer_types, string_types
from .chains import known_chains
from .objecttypes import object_type from .objecttypes import object_type
from .operationids import operations from .operationids import operations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment