def test_can_create_advanced_collectible(
    get_account,
    get_vrf_coordinator,
    get_keyhash,
    get_link_token,
    chainlink_fee,
    get_seed,
):
    # Arrange
    if network.show_active() not in ["development"] or "fork" in network.show_active():
        pytest.skip("Only for local testing")
    advanced_collectible = AdvancedCollectible.deploy(
        get_vrf_coordinator.address,
        get_link_token.address,
        get_keyhash,
        {"from": get_account},
    )
    get_link_token.transfer(
        advanced_collectible.address, chainlink_fee * 3, {"from": get_account}
    )
    # Act
    transaction_receipt = advanced_collectible.createCollectible(
        "None", get_seed, {"from": get_account}
    )
    requestId = transaction_receipt.events["requestedCollectible"]["requestId"]
    assert isinstance(transaction_receipt.txid, str)
    get_vrf_coordinator.callBackWithRandomness(
        requestId, 777, advanced_collectible.address, {"from": get_account}
    )
    # Assert
    assert advanced_collectible.tokenCounter() > 0
    assert isinstance(advanced_collectible.tokenCounter(), int)
Exemple #2
0
def main():
    if network.show_active() in ["mainnet", "mainnet-fork", "rinkeby"]:
        if network.show_active() == "mainnet":
            priority_fee("2 gwei")
            max_fee("25 gwei")
            account_name = "minnow"
        else:
            account_name = "husky"

        if network.show_active() == "mainnet-fork":
            publish = False
        else:
            publish = False
        deployer = accounts.load(account_name)

    else:
        deployer = accounts[0]
        publish = False

    beneficiary_address = deployer
    return Margarita.deploy(
        "MARGARITA",
        "MARG",
        18,
        0,
        beneficiary_address,
        {"from": deployer},
        publish_source=publish,
    )
def get_contract(contract_name):
    """This function will grab the contract addresses from the brownie config
    if defined, otherwise, it will deploy a mock version of that contract, and
    return that mock contract.

        Args:
            contract_name (string)

        Returns:
            brownie.network.contract.ProjectContract: The most recently deployed
            version of this contract.
    """
    contract_type = contract_to_mock[contract_name]
    if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        if len(contract_type) <= 0:
            # MockV3Aggregator.length
            deploy_mocks()
        contract = contract_type[-1]
        # MockV3Aggregator[-1]
    else:
        contract_address = config["networks"][
            network.show_active()][contract_name]
        # address
        # ABI
        contract = Contract.from_abi(contract_type._name, contract_address,
                                     contract_type.abi)
        # MockV3Aggregator.abi
    return contract
Exemple #4
0
def initiateSIGHBoosterContract():
    if network.show_active() == 'mainnet-fork' or network.show_active(
    ) == 'development':
        return deployScript(accounts[0])
    elif network.show_active() == 'kovan':
        dev = accounts.add(os.getenv('PRIVATE_KEY'))
        return deployScript(dev)
def deploySIGHBoosterContracts():
    if network.show_active() == 'mainnet-fork' or network.show_active(
    ) == 'development':
        return deployScript(accounts[0])
    elif network.show_active() == 'live':
        ac = accounts.add(os.getenv('PRIVATE_KEY'))
        return deployScript(ac)
def test_returns_random_number_testnet(get_keyhash, ):
    # Arrange
    if network.show_active() not in ["kovan", "rinkeby", "ropsten"]:
        pytest.skip("Only for testnet testing")
    vrf_consumer = VRFConsumer.deploy(
        get_keyhash,
        get_contract("vrf_coordinator").address,
        get_contract("link_token").address,
        config["networks"][network.show_active()]["fee"],
        {"from": get_account()},
    )
    tx = fund_with_link(
        vrf_consumer.address,
        amount=config["networks"][network.show_active()]["fee"])
    tx.wait(1)
    # Act
    transaction_receipt = vrf_consumer.getRandomNumber({"from": get_account()})
    assert isinstance(transaction_receipt.txid, str)
    transaction_receipt.wait(1)
    event_response = listen_for_event(vrf_consumer, "ReturnedRandomness")

    # Assert
    assert event_response.event is not None
    assert vrf_consumer.randomResult() > 0
    assert isinstance(vrf_consumer.randomResult(), int)
Exemple #7
0
def main():
    dev = accounts.add(os.getenv(config['wallets']['from_key']))
    print(network.show_active())
    return VRFConsumer.deploy(
        config['networks'][network.show_active()]['keyhash'],
        config['networks'][network.show_active()]['vrf_coordinator'],
        config['networks'][network.show_active()]['link_token'], {'from': dev})
Exemple #8
0
def test_returns_random_number_local(
    get_account,
    get_vrf_coordinator,
    get_keyhash,
    get_link_token,
    chainlink_fee,
    get_seed,
):
    # Arrange
    if network.show_active() not in ["development"
                                     ] or "fork" in network.show_active():
        pytest.skip("Only for local testing")
    vrf_consumer = VRFConsumer.deploy(
        get_keyhash,
        get_vrf_coordinator.address,
        get_link_token.address,
        {"from": get_account},
    )
    get_link_token.transfer(vrf_consumer.address, chainlink_fee * 3,
                            {"from": get_account})
    # Act
    transaction_receipt = vrf_consumer.getRandomNumber(get_seed,
                                                       {"from": get_account})
    requestId = vrf_consumer.getRandomNumber.call(get_seed,
                                                  {"from": get_account})
    assert isinstance(transaction_receipt.txid, str)
    get_vrf_coordinator.callBackWithRandomness(requestId, 777,
                                               vrf_consumer.address,
                                               {"from": get_account})
    # Assert
    assert vrf_consumer.randomResult() > 0
    assert isinstance(vrf_consumer.randomResult(), int)
Exemple #9
0
def chainlink_fee():
    if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        return 1000000000000000000
    if network.show_active() in config["networks"]:
        return config["networks"][network.show_active()]["fee"]
    else:
        pytest.skip("Invalid network/link token specified ")
Exemple #10
0
def main():
    account = None
    if network.show_active() in ["mainnet-fork"]:
        account = accounts.at(myWalletAddress, force=True)
    elif network.show_active() in ["mainnet"]:
        account = accounts.load("maindev")

    # Set the gas price
    network.gas_price("120 gwei")
    network.gas_limit("auto")

    # Deploy/Get contract
    #bountyHunter = BountyHunter.deploy({"from":account})
    bountyHunter = BountyHunter.at(BOUNTY_HUNTER_ADDRESS)

    print("My wallet eth amount before claim: " + str(account.balance()))

    print("Claiming bounty...")
    bountyHunter.claimBounty({"from": account, "value": ETH_TO_SELL})

    print("Amount of Eth required: " + str(ETH_TO_SELL - bountyHunter.balance()))

    # print("The amount of Eth needed to buy back UNI tokens: " + str(200000000000000000 - bountyHunter.balance()))
    print("My wallet eth amount after claim: " + str(account.balance()))
    uniToken = interface.ERC20(UNI_TOKEN_ADDRESS)
    print("My wallet uni amount after claim: " + str(uniToken.balanceOf(myWalletAddress)))
Exemple #11
0
def deploySIGHFinance():
    if network.show_active() == 'mainnet-fork' or network.show_active(
    ) == 'development':
        return deployScript(accounts[0])
    elif network.show_active() == 'kovan':
        dev = accounts.add(os.getenv('PRIVATE_KEY'))
        return deployScript(dev)
Exemple #12
0
def get_job_id():
    if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        return 0
    if network.show_active() in config["networks"]:
        return Web3.toHex(text=config["networks"][network.show_active()]["jobId"])
    else:
        pytest.skip("Invalid network/link token specified")
Exemple #13
0
def get_keyhash():
    if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        return 0
    if network.show_active() in config["networks"]:
        return config["networks"][network.show_active()]["keyhash"]
    else:
        pytest.skip("Invalid network/link token specified ")
Exemple #14
0
def initializeSIGHBoostersSalesContract():
    boosterContract = boosters.initiateSIGHBoosterContract()   # FIRST INITIALIZE THE SIGH BOOSTERS CONTRACT
    if network.show_active() == 'mainnet-fork' or  network.show_active()== 'development':
        return deployScript(boosterContract,accounts[0])
    elif network.show_active() == 'kovan':
        dev = accounts.add(os.getenv('PRIVATE_KEY'))
        return deployScript(boosterContract,dev)
Exemple #15
0
def get_job_id():
    if network.show_active() in ['development', 'mainnet-fork']:
        return 0
    if network.show_active() in config['networks']:
        return config['networks'][network.show_active()]['jobId']
    else:
        pytest.skip('Invalid network/link token specified')
Exemple #16
0
def get_keyhash(get_account, get_link_token):
    if network.show_active() in ['development', 'mainnet-fork']:
        return 0
    if network.show_active() in config['networks']:
        return config['networks'][network.show_active()]['keyhash']
    else:
        pytest.skip('Invalid network/link token specified ')
Exemple #17
0
def main():
    dev = accounts.add(os.getenv(config['wallets']['from_key']))
    # Get the most recent PriceFeed Object
    advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
    interface.LinkTokenInterface(
        config['networks'][network.show_active()]['link_token']).transfer(
            advanced_collectible,
            config['networks'][network.show_active()]['fee'], {'from': dev})
Exemple #18
0
def get_account():
    if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        return accounts[0]
    if network.show_active() in config["networks"]:
        dev_account = accounts.add(config["wallets"]["from_key"])
        return dev_account
    else:
        pytest.skip("Invalid network/wallet specified ")
Exemple #19
0
def get_job_id():
    if network.show_active() == "development" or "fork" in network.show_active(
    ):
        return 0
    if network.show_active() in config["networks"]:
        return config["networks"][network.show_active()]["jobId"]
    else:
        pytest.skip("Invalid network/link token specified")
Exemple #20
0
def fund_advanced_collectible(nft_contract):
    dev = accounts.add(config["wallets"]["from_key"])
    # Get the most recent PriceFeed Object
    interface.LinkTokenInterface(
        config["networks"][network.show_active()]["link_token"]
    ).transfer(
        nft_contract, config["networks"][network.show_active()]["fee"], {"from": dev}
    )
Exemple #21
0
def get_keyhash(get_account, get_link_token):
    if network.show_active() == "development" or "fork" in network.show_active(
    ):
        return 0
    if network.show_active() in config["networks"]:
        return config["networks"][network.show_active()]["keyhash"]
    else:
        pytest.skip("Invalid network/link token specified ")
Exemple #22
0
def get_account():
    if (network.show_active() == "development"
            or network.show_active() == "mainnet-fork"):
        return accounts[0]
    if network.show_active() in config["networks"]:
        dev_account = accounts.add(config["wallets"]["from_key"])
        return dev_account
    else:
        pytest.skip("Invalid network/wallet specified ")
Exemple #23
0
def get_account():
    if network.show_active() == 'development' or network.show_active(
    ) == 'mainnet-fork':
        return accounts[0]
    if network.show_active() in config['networks']:
        dev_account = accounts.add(os.getenv(config['wallets']['from_key']))
        return dev_account
    else:
        pytest.skip('Invalid network/wallet specified ')
Exemple #24
0
def main():
    if network.show_active() == 'mainnet-fork' or network.show_active(
    ) == 'development':
        return PriceFeed.deploy(mainnet_eth_usd_address, {'from': accounts[0]})
    elif network.show_active() == 'kovan':
        dev = accounts.add(os.getenv('PRIVATE_KEY'))
        return PriceFeed.deploy(kovan_eth_usd_address, {'from': dev})
    else:
        print('Please pick a supported network, or add the rinkeby config')
Exemple #25
0
def get_eth_usd_price_feed_address():
    if network.show_active() == 'development':
        mock_price_feed = MockV3Aggregator.deploy(18, 2000,
                                                  {'from': accounts[0]})
        return mock_price_feed.address
    if network.show_active() in config['networks']:
        return config['networks'][network.show_active()]['eth_usd_price_feed']
    else:
        pytest.skip('Invalid network specified ')
        return
Exemple #26
0
def test_can_create_simple_collectible():
    if network.show_active() not in ["development"] or "fork" in network.show_active():
        pytest.skip("Only for local testing")
    simple_collectible = SimpleCollectible.deploy(
        {"from": get_account(), "gas_price": chain.base_fee}
    )
    simple_collectible.createCollectible(
        "None", {"from": get_account(), "gas_price": chain.base_fee}
    )
    assert simple_collectible.ownerOf(0) == get_account()
Exemple #27
0
def get_eth_usd_price_feed_address():
    if network.show_active() == "development":
        mock_price_feed = MockV3Aggregator.deploy(18, 2000,
                                                  {"from": accounts[0]})
        return mock_price_feed.address
    if network.show_active() in config["networks"]:
        return config["networks"][network.show_active()]["eth_usd_price_feed"]
    else:
        pytest.skip("Invalid network specified ")
        return
def main():
    if network.show_active() == 'mainnet-fork' or network.show_active(
    ) == 'development':
        return PriceConsumerV3.deploy(mainnet_eth_usd_address,
                                      {'from': accounts[0]})
    elif network.show_active() == 'kovan':
        dev = accounts.add(os.getenv(config['wallets']['from_key']))
        return PriceConsumerV3.deploy({'from': dev})
    else:
        print('Please pick a supported network, or add the rinkeby config')
def get_account(index=None, id=None):
    if index:
        return accounts[index]
    if network.show_active() in LOCAL_BLOCKCHAIN_ENVIRONMENTS:
        return accounts[0]
    if id:
        return accounts.load(id)
    if network.show_active() in config["networks"]:
        return accounts.add(config["wallets"]["from_key"])
    return None
def main():
    dev = accounts.add(config["wallets"]["from_key"])
    return APIConsumer.deploy(
        config["networks"][network.show_active()]["oracle"],
        config["networks"][network.show_active()]["jobId"],
        config["networks"][network.show_active()]["fee"],
        config["networks"][network.show_active()]["link_token"],
        {"from": dev},
        publish_source=config["verify"],
    )