Пример #1
0
def generate_currency_ids(nb_currencies: int) -> List[int]:
    """
    Generate currency ids.

    :param nb_currencies: the number of currencies.
    :param contract: the instance of the contract.
    """
    currency_ids = ERC1155Contract.generate_token_ids(FT_ID, nb_currencies)
    assert len(currency_ids) == nb_currencies
    return currency_ids
Пример #2
0
def generate_good_ids(nb_goods: int) -> List[int]:
    """
    Generate ids for things.

    :param nb_goods: the number of things.
    :param contract: the instance of the contract
    """
    good_ids = ERC1155Contract.generate_token_ids(FT_ID, nb_goods)
    assert len(good_ids) == nb_goods
    return good_ids
Пример #3
0
def generate_good_ids(nb_goods: int, starting_index: int) -> List[int]:
    """
    Generate ids for things.

    :param nb_goods: the number of things.
    :param starting_index: the index to start creating from.
    """
    good_ids = ERC1155Contract.generate_token_ids(FT_ID, nb_goods, starting_index)
    enforce(
        len(good_ids) == nb_goods, "Length of good ids and number of goods must match."
    )
    return good_ids
Пример #4
0
def generate_good_ids(nb_goods: int) -> List[int]:
    """
    Generate ids for things.

    :param nb_goods: the number of things.
    :param contract: the instance of the contract
    """
    good_ids = ERC1155Contract.generate_token_ids(FT_ID, nb_goods)
    enforce(
        len(good_ids) == nb_goods,
        "Length of good ids and number of goods must match.")
    return good_ids
Пример #5
0
def generate_currency_ids(nb_currencies: int) -> List[int]:
    """
    Generate currency ids.

    :param nb_currencies: the number of currencies.
    :param contract: the instance of the contract.
    """
    currency_ids = ERC1155Contract.generate_token_ids(FT_ID, nb_currencies)
    enforce(
        len(currency_ids) == nb_currencies,
        "Length of currency ids and number of currencies must match.",
    )
    return currency_ids
Пример #6
0
    def __init__(self, **kwargs) -> None:
        """Initialize the strategy of the agent."""
        self._ledger_id = kwargs.pop("ledger_id", DEFAULT_LEDGER_ID)
        self._token_type = kwargs.pop("token_type", DEFAULT_TOKEN_TYPE)
        assert self._token_type in [1,
                                    2], "Token type must be 1 (NFT) or 2 (FT)"
        self._nb_tokens = kwargs.pop("nb_tokens", DEFAULT_NB_TOKENS)
        self._token_ids = kwargs.pop("token_ids", None)
        self._mint_quantities = kwargs.pop("mint_quantities",
                                           DEFAULT_MINT_QUANTITIES)
        assert (len(self._mint_quantities) == self._nb_tokens
                ), "Number of tokens must match mint quantities array size."
        if self._token_type == 1:
            assert all(quantity == 1 for quantity in
                       self._mint_quantities), "NFTs must have a quantity of 1"
        self._contract_address = kwargs.pop("contract_address", None)
        assert (
            self._token_ids is None and self._contract_address is None
        ) or (
            self._token_ids is not None and self._contract_address is not None
        ), "Either provide contract address and token ids or provide neither."

        self.from_supply = kwargs.pop("from_supply", DEFAULT_FROM_SUPPLY)
        self.to_supply = kwargs.pop("to_supply", DEFAULT_TO_SUPPLY)
        self.value = kwargs.pop("value", DEFAULT_VALUE)

        location = kwargs.pop("location", DEFAULT_LOCATION)
        self._agent_location = {
            "location": Location(location["longitude"], location["latitude"])
        }
        self._set_service_data = kwargs.pop("service_data",
                                            DEFAULT_SERVICE_DATA)
        assert (len(self._set_service_data) == 2
                and "key" in self._set_service_data
                and "value" in self._set_service_data
                ), "service_data must contain keys `key` and `value`"
        self._remove_service_data = {"key": self._set_service_data["key"]}
        self._simple_service_data = {
            self._set_service_data["key"]: self._set_service_data["value"]
        }

        super().__init__(**kwargs)

        self.is_behaviour_active = True
        self._is_contract_deployed = self._contract_address is not None
        self._is_tokens_created = self._token_ids is not None
        self._is_tokens_minted = self._token_ids is not None
        if self._token_ids is None:
            self._token_ids = ERC1155Contract.generate_token_ids(
                token_type=self._token_type, nb_tokens=self._nb_tokens)
Пример #7
0
def generate_currency_ids(nb_currencies: int, starting_index: int) -> List[int]:
    """
    Generate currency ids.

    :param nb_currencies: the number of currencies.
    :param starting_index: the index to start creating from.
    """
    currency_ids = ERC1155Contract.generate_token_ids(
        FT_ID, nb_currencies, starting_index
    )
    enforce(
        len(currency_ids) == nb_currencies,
        "Length of currency ids and number of currencies must match.",
    )
    return currency_ids
Пример #8
0
    def __init__(self, **kwargs) -> None:
        """Initialize the strategy of the agent."""
        self._ledger_id = kwargs.pop("ledger_id", DEFAULT_LEDGER_ID)
        self._token_type = kwargs.pop("token_type", DEFAULT_TOKEN_TYPE)
        assert self._token_type in [1,
                                    2], "Token type must be 1 (NFT) or 2 (FT)"
        self._nb_tokens = kwargs.pop("nb_tokens", DEFAULT_NB_TOKENS)
        self._token_ids = kwargs.pop("token_ids", None)
        self._mint_quantities = kwargs.pop("mint_quantities",
                                           DEFAULT_MINT_QUANTITIES)
        assert (len(self._mint_quantities) == self._nb_tokens
                ), "Number of tokens must match mint quantities array size."
        if self._token_type == 1:
            assert all(quantity == 1 for quantity in
                       self._mint_quantities), "NFTs must have a quantity of 1"
        self._contract_address = kwargs.pop("contract_address", None)
        assert (
            self._token_ids is None and self._contract_address is None
        ) or (
            self._token_ids is not None and self._contract_address is not None
        ), "Either provide contract address and token ids or provide neither."

        self.from_supply = kwargs.pop("from_supply", DEFAULT_FROM_SUPPLY)
        self.to_supply = kwargs.pop("to_supply", DEFAULT_TO_SUPPLY)
        self.value = kwargs.pop("value", DEFAULT_VALUE)

        self._service_data = kwargs.pop("service_data", DEFAULT_SERVICE_DATA)
        self._data_model = kwargs.pop("data_model", DEFAULT_DATA_MODEL)
        self._data_model_name = kwargs.pop("data_model_name",
                                           DEFAULT_DATA_MODEL_NAME)

        super().__init__(**kwargs)

        self.is_behaviour_active = True
        self._is_contract_deployed = self._contract_address is not None
        self._is_tokens_created = self._token_ids is not None
        self._is_tokens_minted = self._token_ids is not None
        if self._token_ids is None:
            self._token_ids = ERC1155Contract.generate_token_ids(
                token_type=self._token_type, nb_tokens=self._nb_tokens)