Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"str" type cannot be derived from Account or Address type #345

Open
atsoc1993 opened this issue Nov 5, 2024 · 0 comments
Open

"str" type cannot be derived from Account or Address type #345

atsoc1993 opened this issue Nov 5, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@atsoc1993
Copy link

atsoc1993 commented Nov 5, 2024

Problem

Was trying to mint an ARC69 via smart contract, and include a property for "Owner", but could not represent the Address as a string, see "Owner" field in asset creation transaction below.

Attempted to pass in the account as a String type, but Account only excepts str or Bytes type, Address only supports str, Bytes, or Account type.

 

pokemon_creation_tx = itxn.AssetConfig(
            total=1,
            manager=Global.current_application_address,
            asset_name=available_pokemon_info.pokemon_name.native,
            unit_name='PK#' + unit_name_int_as_string,
            decimals=0,
            url= 'https://gateway.pinata.cloud/ipfs/' + available_pokemon_info.pokemon_ipfs_hash.native,
            note = (
                '{"standard": "arc69", "mime_type": "image/png", "properties": {'
                '"Type": "' + available_pokemon_info.pokemon_type.native + '", '
                '"Description": "' + available_pokemon_info.pokemon_description.native + '", '
                '"Level": "1", '
                '"Experience": "0", '
                '"Pokemon Number": "' + unit_name_int_as_string + '", '
                '"Owner": "' + ******* + '", '
                '"UID": "' + uid_as_string + '" }}' 
            ),
            fee=Global.min_txn_fee
        ).submit()

Solution

Allow decoding methods to str types, perhaps as Account.str attribute, or String.str attribute for string literals

While on the topic it is important to note there is no itoa support (Integer to Ascii), and currently we have to manually input this function into our programs to convert integers into strings:

    @subroutine
    def itoa(self, i: UInt64) -> Bytes:
        digits = Bytes(b"0123456789")
        radix = digits.length
        if i < radix:
            return digits[i]
        return self.itoa(i // radix) + digits[i % radix]
      
@atsoc1993 atsoc1993 added the enhancement New feature or request label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant