def deploy(_deploying_address, _exchange_contract_id): contract_registry_address = bt.deploy_exchange_network( _deploying_address) _exchange_contract = ExchangeContract.query.get( _exchange_contract_id) _exchange_contract.contract_registry_blockchain_address = contract_registry_address db.session.commit()
def create_or_get_reserve_token( deploying_address, reserve_token, name, symbol, reserve_ratio_ppm, reserve_deposit_wei, issue_amount_wei, registry_address=None, exchange_contract=None): if registry_address is None: registry_address = bt.deploy_exchange_network(deploying_address) smart_token_result = bt.deploy_smart_token( deploying_address=deploying_address, name=name, symbol=symbol, decimals=18, reserve_deposit_wei=reserve_deposit_wei, issue_amount_wei=issue_amount_wei, contract_registry_address=registry_address, reserve_token_address=reserve_token.address, reserve_ratio_ppm=reserve_ratio_ppm ) smart_token_address = smart_token_result['smart_token_address'] subexchange_address = smart_token_result['subexchange_address'] smart_token = Token(address=smart_token_address, name=name, symbol=symbol, token_type=TokenType.LIQUID) smart_token.decimals = 18 db.session.add(smart_token) if exchange_contract is None: exchange_contract = ExchangeContract( blockchain_address=subexchange_address, contract_registry_blockchain_address=registry_address ) exchange_contract.add_reserve_token(reserve_token) exchange_contract.add_token(smart_token, subexchange_address, reserve_ratio_ppm) return smart_token, exchange_contract, registry_address
def initialised_blockchain_network( create_master_organisation, admin_with_org_reserve_balance, external_reserve_token, load_account): from server import bt from server.models.token import Token from server.models.exchange import ExchangeContract reserve_token = external_reserve_token def deploy_and_add_smart_token(name, symbol, reserve_ratio_ppm, exchange_contract=None): smart_token_result = bt.deploy_smart_token( deploying_address=deploying_address, name=name, symbol=symbol, decimals=18, reserve_deposit_wei=10, issue_amount_wei=1000, contract_registry_address=registry_address, reserve_token_address=reserve_token.address, reserve_ratio_ppm=reserve_ratio_ppm ) smart_token_address = smart_token_result['smart_token_address'] subexchange_address = smart_token_result['subexchange_address'] smart_token = Token(address=smart_token_address, name=name, symbol=symbol, token_type=TokenType.LIQUID) smart_token.decimals = 18 db.session.add(smart_token) if exchange_contract is None: exchange_contract = ExchangeContract( blockchain_address=subexchange_address, contract_registry_blockchain_address=registry_address ) exchange_contract.add_reserve_token(reserve_token) exchange_contract.add_token(smart_token, subexchange_address, reserve_ratio_ppm) return smart_token, exchange_contract organisation = admin_with_org_reserve_balance.organisations[0] deploying_address = organisation.org_level_transfer_account.blockchain_address # Load admin's *system* blockchain account with Eth load_account(organisation.system_blockchain_address) # Load admin org blockchain account with with Eth load_account(deploying_address) # Create reserve token # Initialise an exchange network registry_address = bt.deploy_exchange_network(deploying_address) # Create first smart token and add to exchange network (smart_token_1, exchange_contract) = deploy_and_add_smart_token('Smart Token 1', 'SM1', 250000) # Create second smart token and add to exchange network (smart_token_2, exchange_contract) = deploy_and_add_smart_token('Smart Token 2', 'SM2', 250000, exchange_contract) (smart_token_3, exchange_contract) = deploy_and_add_smart_token('Smart Token 3', 'SM3', 250000, exchange_contract) db.session.commit() return { 'exchange_contract': exchange_contract, 'reserve_token': reserve_token, 'smart_token_1': smart_token_1, 'smart_token_2': smart_token_2, 'smart_token_3': smart_token_3 }