Пример #1
0
    def defaultFrozen(cls, asset: Expr) -> MaybeValue:
        """Check if an asset is frozen by default.

        Args:
            asset: An index into Txn.assets that corresponds to the asset to check,
                must be evaluated to uint64 (or since v4, an asset ID that appears in
                Txn.assets).
        """
        require_type(asset, TealType.uint64)
        return MaybeValue(
            Op.asset_params_get,
            TealType.uint64,
            immediate_args=["AssetDefaultFrozen"],
            args=[asset],
        )
Пример #2
0
    def decimals(cls, asset: Expr) -> MaybeValue:
        """Get the number of decimals for an asset.

        Args:
            asset: An index into Txn.assets that corresponds to the asset to check,
                must be evaluated to uint64 (or since v4, an asset ID that appears in
                Txn.assets).
        """
        require_type(asset, TealType.uint64)
        return MaybeValue(
            Op.asset_params_get,
            TealType.uint64,
            immediate_args=["AssetDecimals"],
            args=[asset],
        )
Пример #3
0
    def metadataHash(cls, asset: Expr) -> MaybeValue:
        """Get the arbitrary commitment for an asset.

        If set, this will be 32 bytes long.

        Args:
            asset: An index into Txn.assets that corresponds to the asset to check,
                must be evaluated to uint64 (or since v4, an asset ID that appears in
                Txn.assets).
        """
        require_type(asset, TealType.uint64)
        return MaybeValue(
            Op.asset_params_get,
            TealType.bytes,
            immediate_args=["AssetMetadataHash"],
            args=[asset],
        )
Пример #4
0
    def localGetEx(cls, account: Expr, app: Expr, key: Expr) -> MaybeValue:
        """Read from an account's local state for an application.

        Args:
            account: An index into Txn.Accounts that corresponds to the account to check,
                must be evaluated to uint64 (or, since v4, an account address that appears in
                Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
            app: An index into Txn.applications that corresponds to the application to read from,
                must be evaluated to uint64 (or, since v4, an application id that appears in
                Txn.applications or is the CurrentApplicationID, must be evaluated to int).
            key: The key to read from the account's local state. Must evaluate to bytes.
        """
        require_type(account, TealType.anytype)
        require_type(app, TealType.uint64)
        require_type(key, TealType.bytes)
        return MaybeValue(AppField.localGetEx.get_op(),
                          TealType.anytype,
                          args=[account, app, key])
Пример #5
0
    def balance(cls, account: Expr, asset: Expr) -> MaybeValue:
        """Get the amount of an asset held by an account.

        Args:
            account: An index into Txn.Accounts that corresponds to the account to check,
                must be evaluated to uint64 (or, since v4, an account address that appears in
                Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
            asset: The ID of the asset to get, must be evaluated to uint64 (or, since v4,
                a Txn.assets offset).
        """
        require_type(account, TealType.anytype)
        require_type(asset, TealType.uint64)
        return MaybeValue(
            Op.asset_holding_get,
            TealType.uint64,
            immediate_args=["AssetBalance"],
            args=[account, asset],
        )
Пример #6
0
    def frozen(cls, account: Expr, asset: Expr) -> MaybeValue:
        """Check if an asset is frozen for an account.

        A value of 1 indicates frozen and 0 indicates not frozen.

        Args:
            account: An index into Txn.Accounts that corresponds to the account to check,
                must be evaluated to uint64 (or, since v4, an account address that appears in
                Txn.Accounts or is Txn.Sender, must be evaluated to bytes).
            asset: The ID of the asset to get, must be evaluated to uint64 (or, since v4,
                a Txn.assets offset).
        """
        require_type(account, TealType.anytype)
        require_type(asset, TealType.uint64)
        return MaybeValue(
            Op.asset_holding_get,
            TealType.uint64,
            immediate_args=["AssetFrozen"],
            args=[account, asset],
        )