Пример #1
0
def setup(make_project, db, configuration: Config, erc20_token):

    configuration['token_contract_addr'] = erc20_token.address

    eth_token, eth_token_hash = init_token_contract(configuration)
    swap_contract, swap_contract_hash = init_swap_contract(
        configuration, eth_token, eth_token_hash)
    add_minter(eth_token, swap_contract)
    erc_token, erc_token_hash = init_token_contract(configuration,
                                                    swap_contract)

    add_to_whitelist(swap_contract, erc_token, erc_token_hash)

    change_owner(swap_contract, configuration["multisig_acc_addr"])

    # add token pairings to db
    TokenPairing(src_network="Ethereum",
                 src_coin="ETH",
                 src_address="native",
                 dst_network="Secret",
                 dst_coin="secret-ETH",
                 dst_address=eth_token).save()
    TokenPairing(src_network="Ethereum",
                 src_coin="ERC",
                 src_address=erc20_token.address,
                 dst_network="Secret",
                 dst_coin="secret-ERC",
                 dst_address=erc_token).save()

    configuration["swap_code_hash"] = swap_contract_hash
    configuration["scrt_swap_address"] = swap_contract
Пример #2
0
def deploy_scrt():

    # docker exec -it secretdev secretcli tx compute store "/token.wasm.gz" --from a --gas 2000000 -b block -y
    #
    # docker exec -it secretdev secretcli tx compute store "/swap.wasm.gz" --from a --gas 2000000 -b block -y
    # 0xd475b764D1B2DCa1FE598247e5D49205E6Ac5E8e
    multisig_account = config.multisig_acc_addr
    deployer = "secret18839huzvv5v6v0z3tm6um2ascnt6vrqfsp8d4g"

    tokens = [{
        "address": "0x1cB0906955623920c86A3963593a02a405Bb97fC",
        "name": "True USD",
        "decimals": 18,
        "symbol": "TUSD"
    }, {
        "address": "0xF6fF95D53E08c9660dC7820fD5A775484f77183A",
        "name": "YEENUS",
        "decimals": 8,
        "symbol": "YNUS"
    }, {
        "address": "native",
        "name": "Ethereum",
        "decimals": 15,
        "symbol": "ETH"
    }]

    swap_contract, swap_contract_hash = init_swap_contract(deployer)
    # swap_contract = "secret1u8mgmspdeakpf7u8leq68d5xtkykskwrytevyn"
    # swap_contract_hash = "5C36ABD74F5959DD9E8BCECB2EA308BEFEAFF2A50B9BCBD2338C079266F9F0BF"
    print(f"Swap contract deployed at: {swap_contract}")
    for token in tokens:

        config.token_contract_addr = token

        scrt_token, scrt_token_code = init_token_contract(
            deployer, token["decimals"], f'S{token["symbol"]}',
            f'Secret {token["name"]}', swap_contract)
        add_minter(scrt_token, deployer)
        print(f"Secret {token['name']}, Deployed at: {scrt_token}")
        add_to_whitelist(swap_contract, scrt_token, scrt_token_code,
                         pow(10, token["decimals"]))

        import os
        uri = os.environ.get("db_uri")
        with database(uri):
            try:
                TokenPairing.objects().get(
                    src_network="Ethereum",
                    src_address=token["address"]).update(
                        dst_address=scrt_token)
                print("Updated DB record")
            except:
                print("Added new pair to db")
                TokenPairing(src_network="Ethereum",
                             src_coin=token["name"],
                             src_address=token["address"],
                             dst_network="Secret",
                             dst_coin=f"secret-{token['name']}",
                             dst_address=scrt_token,
                             decimals=18,
                             name="Ethereum").save()

    change_owner(swap_contract, config.multisig_acc_addr)