Module: utils
Utility functions for the Arweave integration.
edge_unix_ts(edge)
Helper function to extract the unix time stamp from an Arweave transaction edge. See https://arweave.net/graphql for the Arweave graphql schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge |
dict[str, Any]
|
a transaction edge object |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
unix timestamp in seconds |
Source code in src/ritual_arweave/utils.py
get_sha256_digest(file_path)
Helper function that computes the digest of a file in binary mode to handle potentially large files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str
|
path to a file |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
hex string representing the sha256 |
Source code in src/ritual_arweave/utils.py
get_tags_dict(tag_dicts)
Helper function to merge a list of tag dicts into a single dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_dicts(list[dict[str, |
str]
|
a list of tag dicts with |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
dict[str, str]: a key value dict mapping tag name to tag value |
Source code in src/ritual_arweave/utils.py
load_wallet(file_path=None, api_url=DEFAULT_API_URL)
Helper function to load a wallet from a file path. If a file path is provided as an argument, it is used. Otherwise, the file path is read from the ARWEAVE_WALLET_FILE_PATH environment variable.
Returns:
Name | Type | Description |
---|---|---|
Wallet |
Wallet
|
an Arweave wallet object |