示例#1
0
def transfer_token(token, _data):
    data_ = {}
    substrate = connect()

    _to = _data['to']
    _amount = _data['amount']

    caller = _data['caller']
    mnemonic = _data['mnemonic']

    keypair = Keypair.create_from_mnemonic(mnemonic)
    call = substrate.compose_call(call_module='Token',
                                  call_function='transfer',
                                  call_params={
                                      'token': token,
                                      'to': _to,
                                      'value': _amount
                                  })

    extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
    data_['extrinsic'] = extrinsic.value
    receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
    data_['receiptExtrinsicHash'] = receipt.extrinsic_hash
    data_['receipBlockHash'] = receipt.block_hash
    return data_
示例#2
0
def bazaar_initiate_buy(_data):
    data_ = {}
    substrate = connect()

    price = _data['price']
    amount = _data['amount']
    seller = _data['seller']
    mnemonic = _data['mnemonic']

    keypair = Keypair.create_from_mnemonic(mnemonic)
    call = substrate.compose_call(call_module='Bazaar',
                                  call_function='initiate_buy',
                                  call_params={
                                      'price': price,
                                      'amount': amount,
                                      'seller': seller
                                  })

    extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
    data_['extrinsic'] = extrinsic.value
    receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
    data_['receiptExtrinsicHash'] = receipt.extrinsic_hash
    data_['receipBlockHash'] = receipt.block_hash

    return data_
示例#3
0
def get_paused_status(token):
    data_ = {}
    substrate = connect()
    status = substrate.query(module='Token',
                             storage_function='Paused',
                             params=[str(token)])
    data_['status'] = status
    return data_
示例#4
0
def get_banker(token):
    data_ = {}
    substrate = connect()
    banker = substrate.query(module='Token',
                             storage_function='Owner',
                             params=[str(token)])
    data_['banker'] = substrate.ss58_encode(banker.value)
    return data_
示例#5
0
def get_total_supply(token):
    data_ = {}
    substrate = connect()
    supply = substrate.query(module='Token',
                             storage_function='Supply',
                             params=[str(token)])
    data_['supply'] = supply.value
    return data_
示例#6
0
def get_a_token(token):
    data_ = {}
    substrate = connect()
    token = substrate.query(module='Token',
                            storage_function='Tokens',
                            params=[str(token)])
    data_['token'] = token.value
    data_['token']['owner'] = substrate.ss58_encode(data_['token']['owner'])
    return data_
示例#7
0
def get_ether_issue_count():
    data_ = {}
    substrate = connect()
    result = substrate.query(module='Bridge', storage_function='IssueCount')
    if result:
        data_['count'] = result.value
    else:
        data_['count'] = 0
    return data_
示例#8
0
def get_bazaar_trader_count():
    data_ = {}
    substrate = connect()

    result = substrate.query(module='Bazaar',
                             storage_function='BazaarTraderCount')
    if result:
        data_['traderCount'] = result.value

    return data_
示例#9
0
def get_ether_redemption_by_user(account_id):
    data_ = {}
    substrate = connect()
    result = substrate.query(module='Bridge',
                             storage_function='RedemptionByUser',
                             params=[account_id])
    if result:
        data_['redemption'] = result.value
    else:
        data_['redemption'] = []
    return data_
示例#10
0
def get_watchers():
    data_ = {}
    substrate = connect()
    result = substrate.query(module='Bridge', storage_function='Watchers')
    list_of_watchers = []
    if result:
        for watcher in result.value:
            list_of_watchers.append(substrate.ss58_encode(watcher))

    data_['watchers'] = list_of_watchers
    return data_
示例#11
0
def get_ether_issue(issue_id):
    data_ = {}
    substrate = connect()
    result = substrate.query(module='Bridge',
                             storage_function='Issue',
                             params=[issue_id])
    if result:
        data_['issue'] = result.value
    else:
        data_['issue'] = []
    return data_
示例#12
0
def get_account_balance(token, account_id):
    data_ = {}
    substrate = connect()
    balance = substrate.query(module='Token',
                              storage_function='Balance',
                              params=[({
                                  'col1': str(token),
                                  'col2': account_id,
                              })])
    data_['accountId'] = account_id
    data_['balance'] = balance.value
    return data_
示例#13
0
def get_ether_unminted_issues():
    data_ = {}
    substrate = connect()
    result = substrate.query(module='Bridge',
                             storage_function='UnmintedIssues')
    list_of_issues = []
    if result:
        for issue in result.value:
            list_of_issues.append(issue)

    data_['issues'] = list_of_issues
    return data_
示例#14
0
def find_account_by_code(code):
    data_ = {}
    substrate = connect()
    result = substrate.query(
        module='Referral',
        storage_function='Promoter',
        params=[code]
    )   
    data_['code'] = code   
    if result:
        data_['accountId'] = result.value
    return data_
示例#15
0
def get_ether_unburnt_redemptions():
    data_ = {}
    substrate = connect()
    result = substrate.query(module='Bridge',
                             storage_function='UnburntRedemptions')
    list_of_redemptions = []
    if result:
        for redemption in result.value:
            list_of_redemptions.append(redemption)

    data_['redemptions'] = list_of_redemptions
    return data_
示例#16
0
def get_bazaar_trade_money_in_confirmed_count():
    data_ = {}
    substrate = connect()

    result = substrate.query(
        module='Bazaar', storage_function='BazaarTradeMoneyInConfirmedCount')
    if result:
        data_['tradeCount'] = result.value
    else:
        data_['tradeCount'] = 0

    return data_
示例#17
0
def find_code_by_account(account_id):
    data_ = {}
    substrate = connect()
    result = substrate.query(
        module='Referral',
        storage_function='PromoterCode',
        params=[account_id]
    )   
    data_['accountId'] = account_id
    if result:
        data_['code'] = result.value
    return data_       
示例#18
0
def get_bazaar_completed_trade_count():
    data_ = {}
    substrate = connect()

    result = substrate.query(module='Bazaar',
                             storage_function='BazaarCompletedTradeCount')
    if result:
        data_['completedTradeCount'] = result.value
    else:
        data_['completedTradeCount'] = 0

    return data_
示例#19
0
def check_number_of_references(account_id):
    data_ = {}
    substrate = connect()
    result = substrate.query(
        module='Referral',
        storage_function='ReferenceCount',
        params=[account_id]
    )   
    data_['accountId'] = account_id
    if result:
        data_['count'] = result.value

    return data_   
示例#20
0
def check_code_set(account_id):
    data_ = {}
    substrate = connect()
    result = substrate.query(
        module='Referral',
        storage_function='PromoterCodeSet',
        params=[account_id]
    )   
    if result:
        data_['codeSet'] = result.value
    else:
        data_['codeSet'] = False
    return data_   
示例#21
0
def get_bazaar_completed_trade_by_trader(trader_id):
    data_ = {}
    substrate = connect()

    result = substrate.query(module='Bazaar',
                             storage_function='BazaarCompletedTradeByTrader',
                             params=[str(trader_id)])
    if result:
        data_['completedTradeCount'] = result.value
    else:
        data_['completedTradeCount'] = 0

    return data_
示例#22
0
def get_bazaar_trader_id(account_id):
    data_ = {}
    substrate = connect()
    data_['accountId'] = account_id
    result = substrate.query(module='Bazaar',
                             storage_function='BazaarTraderId',
                             params=[str(account_id)])
    if result:
        data_['traderId'] = result.value
        data_['isTrader'] = True
    else:
        data_['isTrader'] = False
    return data_
示例#23
0
def get_bazaar_trade(trade_id):
    data_ = {}
    substrate = connect()

    result = substrate.query(module='Bazaar',
                             storage_function='BazaarTrade',
                             params=[str(trade_id)])
    if result:
        data_['trade'] = result.value
    else:
        data_['trade'] = None

    return data_
示例#24
0
def get_bazaar_trade_money_in_confirmed(account_id):
    data_ = {}
    substrate = connect()
    data_['accountId'] = account_id
    result = substrate.query(module='Bazaar',
                             storage_function='BazaarTradeMoneyInConfirmed',
                             params=[str(account_id)])
    if result:
        data_['trade'] = result.value
        data_['result'] = True
    else:
        data_['result'] = False
    return data_
示例#25
0
def get_bazaar_trade_money_in_by_trader(trader_id):
    data_ = {}
    substrate = connect()
    data_['traderId'] = trader_id
    result = substrate.query(module='Bazaar',
                             storage_function='BazaarTradeMoneyInByTrader',
                             params=[str(trader_id)])
    if result:
        data_['trade'] = result.value
        data_['result'] = True
    else:
        data_['result'] = False
    return data_
示例#26
0
def get_bazaar_trader_detail(trader_id):
    data_ = {}
    substrate = connect()
    data_['traderId'] = trader_id
    result = substrate.query(module='Bazaar',
                             storage_function='BazaarTraderDetail',
                             params=[str(trader_id)])
    if result:
        data_['trader'] = result.value
        data_['trader']['account'] = substrate.ss58_encode(
            data_['trader']['account'])
        data_['isTrader'] = True
    else:
        data_['isTrader'] = False
    return data_
示例#27
0
def check_registration(account_id):
    data_ = {}
    substrate = connect()
    result = substrate.query(
        module='Referral',
        storage_function='Registered',
        params=[account_id]
    )   
    data_['accountId'] = account_id
    if result:
        data_['registered'] = result.value
    else:
        data_['registered'] = False
    
    return data_                                          
示例#28
0
def get_all_token():
    data_ = {}
    substrate = connect()

    data_['tokens'] = []
    token_count = substrate.query(module='Token',
                                  storage_function='TokenCount')
    for i in range(0, token_count.value):
        token = substrate.query(module='Token',
                                storage_function='Tokens',
                                params=[str(i)])
        _token = token.value
        _token['tokenIndex'] = str(i)
        _token['owner'] = substrate.ss58_encode(_token['owner'])
        data_['tokens'].append(_token)
    return data_
示例#29
0
def check_wallet_balance(account_id, checker_id):
    data_ = {}
    substrate = connect()

    result = substrate.query(
        module='System',
        storage_function='Account',
        params=[account_id]
    )          
    data_['account'] = account_id

    if result:
        data_['balance'] = result.value
    else:
        data_['balance'] = 0

    return data_
示例#30
0
def create_sell_order(ticker, _data, native=False):
    data_ = {}
    substrate = connect()

    if native:
        pair = substrate.query(module='Exchange',
                               storage_function='PairNative',
                               params=[str(ticker)])
    else:
        pair = substrate.query(module='Exchange',
                               storage_function='Pair',
                               params=[str(ticker)])

    data_['nativePair'] = native
    if pair:
        data_['pairId'] = ticker
        data_['pair'] = pair.value
        data_['pairExist'] = True
    else:
        data_['pair'] = []
        data_['pairExist'] = False
        return data_

    keypair = Keypair.create_from_mnemonic(_data['mnemonic'])

    if native:
        call_function = 'exchange_order_native_create_sell'
    else:
        call_function = 'exchange_order_create_sell'

    call = substrate.compose_call(call_module='Exchange',
                                  call_function=call_function,
                                  call_params={
                                      'pair': str(ticker),
                                      'volume': _data['volume'],
                                      'ratio': _data['ratio']
                                  })

    extrinsic = substrate.create_signed_extrinsic(call=call, keypair=keypair)
    data_['extrinsic'] = extrinsic.value
    receipt = substrate.submit_extrinsic(extrinsic, wait_for_inclusion=True)
    data_['receiptExtrinsicHash'] = receipt.extrinsic_hash
    data_['receipBlockHash'] = receipt.block_hash

    return data_