Reference
algobase.models.asset_params
A Pydantic model for Algorand Standard Asset parameters.
AssetParams
Bases: BaseModel
A Pydantic model for Algorand Standard Assets (ASAs).
Source code in algobase/models/asset_params.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
algobase.models.arc3
Pydantic models for Algorand ARC-3 metadata.
Reference: https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0003.md
Arc3Localization
Bases: BaseModel
A Pydantic model for Algorand ARC-3 localization.
Source code in algobase/models/arc3.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
Arc3Metadata
Bases: BaseModel
A Pydantic model for Algorand ARC-3 metadata.
Source code in algobase/models/arc3.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
json_bytes
property
json_bytes: bytes
Returns the model JSON encoded as bytes.
Currently only officially supports UTF-8 encoding.
json_str
property
json_str: str
Returns the model JSON as a string.
Arc3Properties
Bases: BaseModel
A Pydantic model for Algorand ARC-3 properties.
If the traits
property is present, it must comply with ARC-16: https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0016.md
Source code in algobase/models/arc3.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
algobase.models.arc19
Pydantic models for Algorand ARC-19 metadata.
Reference: https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0019.md
Arc19Metadata
Bases: BaseModel
A Pydantic model for Algorand ARC-19 metadata.
Source code in algobase/models/arc19.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
validate_arc3_compliance
validate_arc3_compliance() -> Arc19Metadata
If the ARC-3 metadata is present, ensure it complies with ARC-19.
Raises:
-
ValueError
–If the ARC-3 metadata is present and does not comply with ARC-19.
Returns:
-
Arc19Metadata
(Arc19Metadata
) –The model instance.
Source code in algobase/models/arc19.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
algobase.models.asa
Pydantic models for Algorand Standard Assets (ASAs).
Asa
Bases: BaseModel
A Pydantic model for Algorand Standard Assets (ASAs).
Source code in algobase/models/asa.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
derived_arc3_metadata
property
derived_arc3_metadata: Arc3Metadata | None
The derived ARC-3 metadata.
derived_asa_type
property
derived_asa_type: AsaTypeChoice
The derived type of the ASA.
metadata_hash
property
metadata_hash: AlgorandHash | None
The hash of the JSON metadata.
check_arc19_reserve
check_arc19_reserve() -> Asa
Checks that the CID encoded in the reserve address field is valid for ARC-19 ASAs.
Source code in algobase/models/asa.py
211 212 213 214 215 |
|
check_arc3_asset_url
check_arc3_asset_url() -> Asa
Checks that the asset URL is valid for ARC-3 ASAs.
Source code in algobase/models/asa.py
149 150 151 152 153 154 155 156 157 158 |
|
check_arc3_decimals
check_arc3_decimals(metadata: Arc3Metadata) -> Asa
Raise an error if the decimals in the asset parameters doesn't match the deimals in the metadata.
Source code in algobase/models/asa.py
117 118 119 120 121 122 123 124 125 126 |
|
check_arc3_metadata_constraints
check_arc3_metadata_constraints(
metadata: Arc3Metadata,
) -> Asa
Validate fields against ARC constraints, if applicable.
Raises warnings for values/formats that are allowed but not recommended in ARC specs. Raises errors for values/formats that are not allowed in ARC specs.
Source code in algobase/models/asa.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
check_arc3_unit_name
check_arc3_unit_name(metadata: Arc3Metadata) -> Asa
Raise a warning if the metadata 'name' property is not related to the asset unit name.
Uses the difflib SequenceMatcher
for string similarity.
Source code in algobase/models/asa.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
check_arc_constraints
check_arc_constraints() -> Asa
Validate fields against ARC constraints, if applicable.
Source code in algobase/models/asa.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
check_asa_type_constraints
check_asa_type_constraints() -> Asa
Validate the ASA type against the relevant constraints.
Source code in algobase/models/asa.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
algobase.models.algod
Pydantic models for the Algod API (v2).
Mostly auto-generated using datamodel-codegen. Spec: https://github.com/algorand/go-algorand/blob/master/daemon/algod/api/algod.oas3.yml
Account
Bases: BaseModel
Account information.
Source code in algobase/models/algod.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
AccountParticipation
Bases: BaseModel
Account participation information.
Source code in algobase/models/algod.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
AccountStateDelta
Bases: BaseModel
AccountStateDelta.
Source code in algobase/models/algod.py
343 344 345 346 347 |
|
Application
Bases: BaseModel
Application information.
Source code in algobase/models/algod.py
122 123 124 125 126 |
|
ApplicationLocalState
Bases: BaseModel
Application local state.
Source code in algobase/models/algod.py
87 88 89 90 91 92 |
|
ApplicationParams
Bases: BaseModel
Application parameters.
Source code in algobase/models/algod.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
ApplicationStateSchema
Bases: BaseModel
Application state schema.
Source code in algobase/models/algod.py
78 79 80 81 82 83 84 |
|
Asset
Bases: BaseModel
Asset information.
Source code in algobase/models/algod.py
209 210 211 212 213 |
|
AssetHolding
Bases: BaseModel
Asset holding information.
Source code in algobase/models/algod.py
129 130 131 132 133 134 135 136 137 138 |
|
AssetParams
Bases: BaseModel
Asset parameters.
Source code in algobase/models/algod.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
EvalDelta
Bases: BaseModel
EvalDelta.
Source code in algobase/models/algod.py
324 325 326 327 328 329 |
|
EvalDeltaKeyValue
Bases: BaseModel
EvalDeltaKeyValue.
Source code in algobase/models/algod.py
332 333 334 335 336 |
|
PendingTransactionResponse
Bases: BaseModel
PendingTransactionResponse.
Source code in algobase/models/algod.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
|
SigType
Bases: StrEnum
Enumeration for signature types.
Source code in algobase/models/algod.py
14 15 16 17 18 19 |
|
TealKeyValue
Bases: BaseModel
Teal key-value pair.
Source code in algobase/models/algod.py
68 69 70 71 72 |
|
TealValue
Bases: BaseModel
Teal value.
Source code in algobase/models/algod.py
57 58 59 60 61 62 63 64 65 |
|
algobase.models.kmd
Pydantic models for the KMD API (v1).
Mostly auto-generated using datamodel-codegen. Spec: https://github.com/algorand/go-algorand/blob/master/daemon/kmd/api/swagger.json
APIV1GETWalletsResponse
Bases: BaseModel
The response from the GET /v1/wallets
endpoint.
Source code in algobase/models/kmd.py
25 26 27 28 29 30 |
|
APIV1Wallet
Bases: BaseModel
A KMD wallet.
Source code in algobase/models/kmd.py
14 15 16 17 18 19 20 21 22 |
|
algobase.algorand.client
Classes and functions to configure and create Algorand API clients.
ClientConfig
dataclass
Configuration for an Algorand API client.
Source code in algobase/algorand/client.py
23 24 25 26 27 28 29 |
|
create_algod_client
create_algod_client(config: ClientConfig) -> AlgodClient
Create an AlgodClient instance from the given configuration.
Parameters:
-
config
(ClientConfig
) –The configuration to use.
Returns:
-
AlgodClient
(AlgodClient
) –The AlgodClient instance.
Source code in algobase/algorand/client.py
32 33 34 35 36 37 38 39 40 41 42 43 |
|
create_indexer_client
create_indexer_client(
config: ClientConfig,
) -> IndexerClient
Create an IndexerClient instance from the given configuration.
Parameters:
-
config
(ClientConfig
) –The configuration to use.
Returns:
-
IndexerClient
(IndexerClient
) –The IndexerClient instance.
Source code in algobase/algorand/client.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
|
create_kmd_client
create_kmd_client(config: ClientConfig) -> KMDClient
Create a KMDClient instance from the given configuration.
Parameters:
-
config
(ClientConfig
) –The configuration to use.
Returns:
-
KMDClient
(KMDClient
) –The KMDClient instance.
Source code in algobase/algorand/client.py
62 63 64 65 66 67 68 69 70 71 |
|
create_localnet_algod_client
create_localnet_algod_client() -> AlgodClient
Create an AlgodClient instance for the localnet.
Returns:
-
AlgodClient
(AlgodClient
) –The AlgodClient instance.
Source code in algobase/algorand/client.py
89 90 91 92 93 94 95 |
|
create_localnet_default_config
create_localnet_default_config(
api: AlgorandApiChoice,
) -> ClientConfig
Create a default configuration for the localnet.
Parameters:
-
api
(AlgorandApiChoice
) –The API to configure.
Returns:
-
ClientConfig
(ClientConfig
) –The default configuration.
Source code in algobase/algorand/client.py
74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
create_localnet_indexer_client
create_localnet_indexer_client() -> IndexerClient
Create an IndexerClient instance for the localnet.
Returns:
-
IndexerClient
(IndexerClient
) –The IndexerClient instance.
Source code in algobase/algorand/client.py
98 99 100 101 102 103 104 105 106 |
|
create_localnet_kmd_client
create_localnet_kmd_client() -> KMDClient
Create a KMDClient instance for the localnet.
Returns:
-
KMDClient
(KMDClient
) –The KMDClient instance.
Source code in algobase/algorand/client.py
109 110 111 112 113 114 115 |
|
find_wallet_id
find_wallet_id(
kmd_client: KMDClient, wallet_name: str
) -> str | None
Get the ID of a wallet from the KMD client.
Parameters:
-
kmd_client
(KMDClient
) –The KMD client.
-
wallet_name
(str
) –The name of the wallet.
Returns:
-
str | None
–str | None: The ID of the wallet if found, else None.
Source code in algobase/algorand/client.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
get_algonode_config
get_algonode_config(
network: Literal[
AlgorandNetwork.BETANET,
AlgorandNetwork.TESTNET,
AlgorandNetwork.MAINNET,
],
api: Literal[AlgorandApi.ALGOD, AlgorandApi.INDEXER],
) -> ClientConfig
Get the client config for Algonode API.
Parameters:
-
network
(AlgorandNetworkChoice
) –The Algorand network.
-
api
(Literal[ALGOD, INDEXER]
) –The Algorand API.
Returns:
-
ClientConfig
(ClientConfig
) –The client config object.
Source code in algobase/algorand/client.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
get_default_account
get_default_account(
algod_client: AlgodClient,
kmd_client: KMDClient | None = None,
) -> Account
Return an Account instance for the default account.
Parameters:
-
algod_client
(AlgodClient
) –The Algod client.
-
kmd_client
(KMDClient | None
, default:None
) –The KMD client. If None, a default instance will be created. Defaults to None.
Raises:
-
ValueError
–If the Algod client instance isn't connected to a localnet network.
Returns:
-
Account
(Account
) –The default account.
Source code in algobase/algorand/client.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
is_default_account
is_default_account(account: algod.Account) -> bool
Check if an account is the default account.
Parameters:
-
account
(AlgodResponseType
) –The account info.
Returns:
-
bool
(bool
) –True if the account is the default account, else False.
Source code in algobase/algorand/client.py
135 136 137 138 139 140 141 142 143 144 |
|
is_localnet
is_localnet(algod_client: AlgodClient) -> bool
Check if the AlgodClient is connected to a localnet.
Parameters:
-
algod_client
(AlgodClient
) –The AlgodClient instance.
Returns:
-
bool
(bool
) –True if the client is connected to a localnet, else False.
Source code in algobase/algorand/client.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
match_account
match_account(
algod_client: AlgodClient,
addresses: list[str],
predicate: Callable[[algod.Account], bool],
) -> str
Find the first account that matches the predicate, given a list of addresses to lookup.
Parameters:
-
algod_client
(AlgodClient
) –The Algod client.
-
addresses
(list[str]
) –The addresses to check.
-
predicate
(Callable[[Account], bool]
) –The predicate function.
Raises:
-
ValueError
–If no account is found where predicate(account) is True.
Returns:
-
str
(str
) –The address of the matching account if found, else None.
Source code in algobase/algorand/client.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
algobase.ipfs.client_base
Abstract base class for IPFS clients.
IpfsClient
Bases: ABC
Abstract base class for IPFS clients.
Source code in algobase/ipfs/client_base.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
api_key
abstractmethod
property
api_key: str | None
The API key.
api_version
abstractmethod
property
api_version: str
The version of the IPFS provider's API.
base_url
abstractmethod
property
base_url: URL
The base URL of the IPFS provider's API.
ipfs_provider_name
abstractmethod
property
ipfs_provider_name: IpfsProviderChoice
The name of the IPFS provider.
is_api_key_required
abstractmethod
property
is_api_key_required: bool
Whether the IPFS provider requires an API key.
check_api_key_is_present
check_api_key_is_present() -> None
Checks that the IPFS provider's API key is present.
Source code in algobase/ipfs/client_base.py
56 57 58 59 60 61 |
|
fetch_pin_status
abstractmethod
fetch_pin_status(cid: str) -> IpfsPinStatusChoice
Returns the pinning status of a file, by CID.
Parameters:
-
cid
(str
) –The CID of the file to check.
Returns:
-
IpfsPinStatusChoice
(IpfsPinStatusChoice
) –The pin status of the CID.
Source code in algobase/ipfs/client_base.py
75 76 77 78 79 80 81 82 83 84 85 |
|
from_settings
abstractmethod
classmethod
from_settings(settings: Settings) -> Self
Create an instance of the IPFS client from a settings object.
Source code in algobase/ipfs/client_base.py
20 21 22 23 24 |
|
store_json
abstractmethod
store_json(json: str | bytes) -> str
Stores JSON data in IPFS.
Parameters:
-
json
(str | bytes
) –The JSON to store.
Returns:
-
str
(str
) –The IPFS CID of the stored data.
Source code in algobase/ipfs/client_base.py
63 64 65 66 67 68 69 70 71 72 73 |
|
algobase.ipfs.nft_storage
IPFS client for nft.storage.
NftStorage
dataclass
Bases: IpfsClient
IPFS client for nft.storage.
Requires the NFT_STORAGE_API_KEY
environment variable to be set.
Source code in algobase/ipfs/nft_storage.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
api_key
property
api_key: str | None
The API key.
api_version
property
api_version: str
The version of the IPFS provider's API.
base_url
property
base_url: URL
The base URL of the IPFS provider's API.
headers
property
headers: dict[str, str]
The headers to use for the HTTP requests.
ipfs_provider_name
property
ipfs_provider_name: IpfsProviderChoice
The name of the IPFS provider.
is_api_key_required
property
is_api_key_required: bool
Whether the IPFS provider requires an API key.
fetch_pin_status
fetch_pin_status(cid: str) -> IpfsPinStatusChoice
Returns the pinning status of a file, by CID.
Parameters:
-
cid
(str
) –The CID of the file to check.
Returns:
-
IpfsPinStatusChoice
(IpfsPinStatusChoice
) –The pin status of the CID.
Source code in algobase/ipfs/nft_storage.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
from_settings
classmethod
from_settings(settings: Settings) -> Self
Create an instance of the IPFS client from the settings object.
Source code in algobase/ipfs/nft_storage.py
27 28 29 30 |
|
store_json
store_json(json: str | bytes) -> str
Stores JSON data in IPFS.
Parameters:
-
json
(str | bytes
) –The JSON to store.
Returns:
-
str
(str
) –The IPFS CID of the stored data.
Source code in algobase/ipfs/nft_storage.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
algobase.utils.hash
Utility functions for hashing data.
sha256
sha256(data: bytes) -> bytes
Returns a SHA-256 hash digest of the input data.
Parameters:
-
data
(bytes
) –The data to hash.
Returns:
-
bytes
(bytes
) –The hash digest.
Source code in algobase/utils/hash.py
6 7 8 9 10 11 12 13 14 15 |
|
sha512_256
sha512_256(data: bytes) -> bytes
Returns a SHA-512/256 hash digest of the input data.
Parameters:
-
data
(bytes
) –The data to hash.
Returns:
-
bytes
(bytes
) –The hash digest.
Source code in algobase/utils/hash.py
18 19 20 21 22 23 24 25 26 27 |
|
algobase.utils.read
Functions for reading and caching reference data files.
read_ipfs_gateways
read_ipfs_gateways() -> list[str]
Read IPFS gateways from the reference data file.
Returns:
-
list[str]
–list[str]: The list of IPFS gateways.
Source code in algobase/utils/read.py
7 8 9 10 11 12 13 14 15 |
|
read_mime_types
read_mime_types() -> list[str]
Read MIME types from the reference data file.
Returns:
-
list[str]
–list[str]: The list of MIME types.
Source code in algobase/utils/read.py
18 19 20 21 22 23 24 25 |
|
algobase.utils.url
Functions for working with URLs.
decode_url_braces
decode_url_braces(url: str) -> str
Decodes curly braces in a URL string.
This allows for arbitrary parameters to be passed in URL strings, as specified in some Algorand standards. For example, ARC-3 asset URLs may contain the string '{id}', which clients must replace with the asset ID in decimal form.
Parameters:
-
url
(str
) –The URL string to decode.
Returns:
-
str
(str
) –The decoded URL string.
Source code in algobase/utils/url.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
algobase.utils.validate
Functions for data validation.
is_valid
is_valid(
func: Callable[..., Any], *args: Any, **kwargs: Any
) -> bool
Checks if a function call is valid.
The other functions in this module raise errors when the input is not valid. This is a convenience function to check if a function call is valid without raising an error.
Parameters:
-
func
(Callable[..., Any]
) –The function to call.
-
*args
(Any
, default:()
) –Variable length argument list.
-
**kwargs
(Any
, default:{}
) –Arbitrary keyword arguments.
Returns:
-
bool
(bool
) –True if the function call doesn't raise a ValueError, else False.
Source code in algobase/utils/validate.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
validate_address
validate_address(value: str) -> str
Checks that the value is a valid Algorand address.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid Algorand address.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
validate_arc19_asset_url
validate_arc19_asset_url(value: str) -> str
Checks that the value is a valid URL for Algorand ARC-19.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid URL for Algorand ARC-19.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
validate_arc3_sri
validate_arc3_sri(value: str) -> str
Checks that the value is a valid SHA-256 Subresource Integrity (SRI) value.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid SRI.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
validate_base64
validate_base64(value: str) -> str
Checks that the value is a valid base64 string.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid base64 string.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
validate_contains_substring
validate_contains_substring(
value: str | Url, substring: str
) -> str | Url
Checks that the value contains the substring.
Parameters:
-
value
(str | Url
) –The value to check.
-
substring
(str
) –The substring to check for.
Raises:
-
ValueError
–If the value does not contain the substring.
Returns:
-
str | Url
–str | Url: The value passed in.
Source code in algobase/utils/validate.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
validate_encoded_length
validate_encoded_length(
value: str | Url, max_length: int
) -> str | Url
Checks that the value is not longer than max_length
when encoded in UTF-8.
Parameters:
-
value
(str | Url
) –The value to check.
-
max_length
(int
) –The maximum length of the value when encoded in UTF-8.
Raises:
-
ValueError
–If the value is longer than
max_length
when encoded in UTF-8.
Returns:
-
str | Url
–str | Url: The value passed in.
Source code in algobase/utils/validate.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
validate_hex
validate_hex(value: str) -> str
Checks that the value is a valid hexadecimal string.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid hexadecimal string.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
validate_is_power_of_10
validate_is_power_of_10(n: int) -> int
Checks that the value is a power of 10.
Parameters:
-
n
(int
) –The value to check.
Raises:
-
ValueError
–If the value is not a power of 10.
Returns:
-
int
(int
) –The value passed in.
Source code in algobase/utils/validate.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
validate_locale
validate_locale(value: str) -> str
Checks that the value is a valid Unicode CLDR locale.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid locale identifier.
-
UnknownLocaleError
–If the value is not a valid Unicode CLDR locale.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
validate_mime_type
cached
validate_mime_type(
value: str, primary_type: str | None = None
) -> str
Checks that the value is a valid MIME type.
If primary_type
is not None
, then the value must be a valid MIME type with the specified primary type.
E.g. if primary_type
is 'image', then the value must be a valid MIME type starting with 'image/'.
Parameters:
-
value
(str
) –The value to check.
-
primary_type
(str | None
, default:None
) –The primary type of the MIME type. Defaults to None.
Raises:
-
ValueError
–If the value is not a valid MIME type.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
validate_not_in
validate_not_in(
iterable: Iterable[str], element: str
) -> Iterable[str]
Checks that the element is not in the iterable.
Parameters:
-
element
(str
) –The element to check for.
-
iterable
(Iterable
) –The iterable to check.
Raises:
-
ValueError
–If the element is in the iterable.
Returns:
-
Iterable
(Iterable[str]
) –The iterable passed in.
Source code in algobase/utils/validate.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
|
validate_not_ipfs_gateway
cached
validate_not_ipfs_gateway(url: str) -> str
Checks that the URL host is not a known public IPFS gateway.
Parameters:
-
url
(str
) –The URL to check.
Raises:
-
ValueError
–If the URL host is a known public IPFS gateway.
Returns:
-
str
(str
) –The URL passed in.
Source code in algobase/utils/validate.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
validate_sri
validate_sri(value: str) -> str
Checks that the value is a valid W3C Subresource Integrity (SRI) value.
Parameters:
-
value
(str
) –The value to check.
Raises:
-
ValueError
–If the value is not a valid SRI.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
|
validate_type_compatibility
validate_type_compatibility(value: str, _type: type) -> str
Checks that the value is compatible with the annotated type.
Parameters:
-
value
(str
) –The value to check.
-
_type
(Type
) –The type to validate against.
Raises:
-
ValidationError
–If the value is not compatible with the type.
Returns:
-
str
(str
) –The value passed in.
Source code in algobase/utils/validate.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
algobase.choices
Enums and enum type aliases for algobase.
AlgorandApi
Bases: StrEnum
An enumeration of Algorand APIs.
Source code in algobase/choices.py
73 74 75 76 77 78 |
|
AlgorandApiProvider
Bases: StrEnum
An enumeration of Algorand API providers.
Source code in algobase/choices.py
86 87 88 89 90 91 |
|
AlgorandAsset
Bases: IntEnum
An enumeration of Algorand asset names and IDs.
Source code in algobase/choices.py
101 102 103 104 |
|
AlgorandNetwork
Bases: StrEnum
An enumeration of Algorand networks.
Source code in algobase/choices.py
56 57 58 59 60 61 62 |
|
Arc
Bases: StrEnum
An enumeration of Algorand ARC standards that are supported in algobase.
Source code in algobase/choices.py
7 8 9 10 11 |
|
AsaType
Bases: StrEnum
An enumeration of Algorand Standard Asset (ASA) types.
Source code in algobase/choices.py
17 18 19 20 21 22 |
|
IpfsPinStatus
Bases: StrEnum
An enumeration of IPFS pin statuses.
Source code in algobase/choices.py
39 40 41 42 43 44 45 |
|
IpfsProvider
Bases: StrEnum
An enumeration of IPFS providers.
Source code in algobase/choices.py
30 31 32 33 |
|
algobase.functional
Functions for type casting.
first_true
first_true(
iterable: Iterable[IT],
default: IT | None = None,
predicate: Callable[[IT], bool] | None = None,
) -> IT | None
Returns the first true value in the iterable.
If no true value is found, it returns default
.
If predicate
is not None, it returns the first item for which predicate(item) is true.
Parameters:
-
iterable
(Iterable[IT]
) –The iterable.
-
default
(IT | None
, default:None
) –The default value to return if no true value is found. Defaults to None.
-
predicate
(Callable[[IT], bool] | None
, default:None
) –The predicate function. Defaults to None.
Returns:
-
IT | None
–IT | None: The item in the iterable that is true, or
default
if no true value is found.
Source code in algobase/functional.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
maybe_apply
maybe_apply(x: A | None, f: Callable[[A], B]) -> B | None
Return the result of applying the function to the value if the value is not None, otherwise return None.
Parameters:
-
x
(A | None
) –The value to apply the function to.
-
f
(Callable[[A], B | None]
) –The function to apply to the value.
Returns:
-
B | None
–B | None: The result of applying the function to the value, or None if the value is None.
Source code in algobase/functional.py
11 12 13 14 15 16 17 18 19 20 21 |
|
provide_context
provide_context(**kwargs: Any) -> Callable[..., T]
A closure that provides context arguments to a function.
Parameters:
-
**kwargs
(Any
, default:{}
) –Arbitrary keyword arguments.
Returns:
-
Callable[..., T]
–Callable[..., T]: The wrapped function.
Source code in algobase/functional.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
algobase.settings
Configuration settings for the algobase.
Settings
Bases: BaseSettings
Pydantic model for algobase settings.
Source code in algobase/settings.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|