Skip to content

Commit

Permalink
added possibility to add different networks
Browse files Browse the repository at this point in the history
  • Loading branch information
jansenmarc committed Apr 20, 2018
1 parent 4751a9e commit 17fb5b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ __pywaves.Order(orderId, assetPair, address='')__ Creates a new Order object


## Other functions
`pywaves.setNode(node, chain)` set node URL ('http://ip-address:port') and chain (either 'mainnet' or 'testnet')
`pywaves.setNode(node, chain, chain_id)` set node URL ('http://ip-address:port') and chain (either 'mainnet' or 'testnet', or any other chain, if you also define the chain id)

`pywaves.setChain(chain)` set chain (either 'mainnet' or 'testnet')
`pywaves.setChain(chain, chain_id)` set chain (either 'mainnet' or 'testnet', or any other chain if you also supply the chain id)

`pywaves.setOffline()` switch to offline mode; sign tx locally without broadcasting to network

Expand Down
26 changes: 15 additions & 11 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,30 @@ def setOnline():
global OFFLINE
OFFLINE = False

def setChain(chain = CHAIN):
def setChain(chain = CHAIN, chain_id = None):
global CHAIN, CHAIN_ID

if chain.lower()=='mainnet' or chain.lower()=='w':
CHAIN = 'mainnet'
CHAIN_ID = 'W'
elif chain.lower()=='hacknet' or chain.lower()=='u':
CHAIN = 'hacknet'
CHAIN_ID = 'U'
if chain_id is not None:
CHAIN = chain
CHAIN_ID = chain_id
else:
CHAIN = 'testnet'
CHAIN_ID = 'T'
if chain.lower()=='mainnet' or chain.lower()=='w':
CHAIN = 'mainnet'
CHAIN_ID = 'W'
elif chain.lower()=='hacknet' or chain.lower()=='u':
CHAIN = 'hacknet'
CHAIN_ID = 'U'
else:
CHAIN = 'testnet'
CHAIN_ID = 'T'

def getChain():
return CHAIN

def setNode(node = NODE, chain = CHAIN):
def setNode(node = NODE, chain = CHAIN, chain_id = None):
global NODE, CHAIN, CHAIN_ID
NODE = node
setChain(chain)
setChain(chain, chain_id)

def getNode():
return NODE
Expand Down

0 comments on commit 17fb5b8

Please sign in to comment.