Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions docs/main/client_lib_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ Entities:
1. [ClientLibGenerator](#class-clientlibgenerator)
- [\_\_init\_\_](#__init__)
- [generate_client_library](#generate_client_library)
- [_get_service_metadata_from_registry](#_get_service_metadata_from_registry)
- [_get_service_registration](#_get_service_registration)

### Class `ClientLibGenerator`

Expand All @@ -21,8 +19,7 @@ This class is used to generate client library files for a given service.

#### attributes

- `sdk_config` (Config): An instance of the `Config` class
- `registry_contract` (web3.contract.Contract): An instance of the `Contract` class (from `snet.cli`) for interacting with the Registry contract.
- `_metadata_provider` (StorageProvider): An instance of the `StorageProvider` class.
- `org_id` (str): The organization ID of the service.
- `service_id` (str): The service ID.
- `language` (str): The language of the client library. Default is `python`.
Expand All @@ -36,8 +33,7 @@ Initializes a new instance of the class. Initializes the attributes by arguments

###### args:

- `sdk_config` (Config): An instance of the `Config` class
- `registry_contract` (web3.contract.Contract): An instance of the `Contract` class (from `snet.cli`) for interacting with the Registry contract.
- `metadata_provider` (StorageProvider): An instance of the `StorageProvider` class.
- `org_id` (str): The organization ID of the service.
- `service_id` (str): The service ID.

Expand All @@ -49,27 +45,9 @@ Initializes a new instance of the class. Initializes the attributes by arguments

Generates client library stub files based on specified organization and service ids, including:
- getting service metadata from Registry
- getting .proto file from IPFS
- getting archived proto files from IPFS or FileCoin and extracting them
- compiling .proto file to stub file and saving it in a given directory

#### `_get_service_metadata_from_registry`

Retrieves service metadata. Fetches the service registration from the Registry contract, extracts the metadata URI,
downloads the metadata from IPFS, and parses it into a `MPEServiceMetadata` object.

###### returns:

- The service metadata. (MPEServiceMetadata)

#### `_get_service_registration`

Retrieves the service registration from the Registry contract using the `getServiceRegistrationById` function of it.

###### returns:

- Dictionary containing the service registration. (dict[str, Any])

###### raises:

- `Exception`: If the service with the specified ID is not found in the organization.

- _None_
2 changes: 2 additions & 0 deletions docs/main/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ and regenerating them every time.
- `registry_contract_address` (str): The address of the Registry smart contract.
- `signer_private_key` (str): The private key of the signer. Used to sign the service call. Equals to `private_key`
by default.
- `lighthouse_token` (str): The Lighthouse token used to access the Lighthouse storage provider. Defaults to " ".
Currently, it can't be changed.

#### methods

Expand Down
10 changes: 4 additions & 6 deletions docs/main/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,14 @@ It provides methods for creating service clients, managing identities, and confi
#### attributes

- `_sdk_config` (Config): An instance of the `Config` class.
- `_metadata_provider` (MetadataProvider): An instance of the `MetadataProvider` class. _Note_: There is currently only
one implementation of `MetadataProvider` which is `IPFSMetadataProvider`, so this attribute can only be initialized to
`IPFSMetadataProvider` at this time.
- `_metadata_provider` (StorageProvider): An instance of the `StorageProvider` class for fetching metadata and .proto files.
- `web3` (Web3): An instance of the `Web3` class for interacting with the Ethereum blockchain.
- `mpe_contract` (MPEContract): An instance of the `MPEContract` class for interacting with the MultiPartyEscrow contract.
- `ipfs_client` (ipfshttpclient.Client): An instance of the `ipfshttpclient.Client` class for interacting with the
InterPlanetary File System.
- `registry_contract` (Contract): An instance of the `Contract` class (from `snet.cli`) for interacting with the Registry contract.
- `registry_contract` (Contract): An instance of the `Contract` class for interacting with the Registry contract.
- `account` (Account): An instance of the `Account` class for interacting with the MultiPartyEscrow and
SingularityNetToken contracts.
- `payment_channel_provider` (PaymentChannelProvider): An instance of the `PaymentChannelProvider` class for managing
payment channels.

#### methods

Expand Down
2 changes: 2 additions & 0 deletions docs/main/service_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ the `PaymentStrategy` inheritor classes.
- `grpc_channel` (grpc.Channel): The gRPC channel with interceptor.
- `payment_channel_provider` (PaymentChannelProvider): An instance of the `PaymentChannelProvider` class for
working with channels and interacting with MPE.
- `payment_channel_state_service_client` (Any): Stub for interacting with PaymentChannelStateService via gRPC.
- `service` (Any): The gRPC service stub instance.
- `pb2_module` (ModuleType): The imported protobuf module.
- `payment_channels` (list[PaymentChannel]): The list of payment channels.
Expand Down Expand Up @@ -85,6 +86,7 @@ Initializes a new instance of the class.
- `account` (Account): An instance of the `Account` class.
- `sdk_web3` (Web3): The `Web3` instance.
- `pb2_module` (str | ModuleType): The module containing the gRPC message definitions.
- `payment_channel_provider` (PaymentChannelProvider): The payment channel provider instance.

###### returns:

Expand Down
79 changes: 0 additions & 79 deletions docs/metadata_provider/ipfs_metadata_provider.md

This file was deleted.

59 changes: 0 additions & 59 deletions docs/metadata_provider/metadata_provider.md

This file was deleted.

4 changes: 1 addition & 3 deletions docs/mpe/mpe_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ funds into the contract, opening a channel, adding funds to a channel, extending
- `web3` (Web3): An instance of the Web3 class for interacting with the Ethereum blockchain.
- `contract` (Contract): An instance of the `Contract` class from the `web3` library for interacting
with the MultiPartyEscrow contract.
- `event_topics` (list): A list of event topics for the MultiPartyEscrow contract.
- `deployment_block` (int | BlockNumber): The block number at which the MultiPartyEscrow contract was deployed.

#### methods

Expand All @@ -44,7 +42,7 @@ If no contract address is provided, it uses the default MultiPartyEscrow contrac
###### args:

- `w3` (Web3): An instance of the `Web3` class.
- `address` (str): The address of the MultiPartyEscrow contract. Defaults to None.
- `address` (str): The address of the MultiPartyEscrow contract. Defaults to _None_.

###### returns:

Expand Down
66 changes: 61 additions & 5 deletions docs/mpe/payment_channel_provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
Entities:
1. [PaymentChannelProvider](#class-paymentchannelprovider)
- [\_\_init\_\_](#__init__)
- [update_cache](#update_cache)
- [_event_data_args_to_dict](#_event_data_args_to_dict)
- [_get_all_channels_from_blockchain_logs_to_dicts](#_get_all_channels_from_blockchain_logs_to_dicts)
- [_get_channels_from_cache](#_get_channels_from_cache)
- [get_past_open_channels](#get_past_open_channels)
- [open_channel](#open_channel)
- [deposit_and_open_channel](#deposit_and_open_channel)
Expand All @@ -27,7 +31,9 @@ A class for managing payment channels.
with the MultiPartyEscrow contract.
- `event_topics` (list): A list of event topics for the MultiPartyEscrow contract.
- `deployment_block` (int | BlockNumber): The block number at which the MultiPartyEscrow contract was deployed.
- `payment_channel_state_service_client` (ServiceStub): A stub for interacting with PaymentChannelStateService via gRPC.
- `mpe_address` (ChecksumAddress): The address of the MultiPartyEscrow contract.
- `channels_file` (Path): The path to the cache file for payment channels.
Equals to `~/.snet/cache/mpe/MPE_ADDRESS/channels.pickle`.

#### methods

Expand All @@ -45,18 +51,62 @@ Initializes a new instance of the class.

- _None_

#### `update_cache`

Updates the cache with channels from blockchain logs for the MPE contract. Cache is stored as a pickle file.
It stores the list of payment channels and last read block number. If there is no cache, logs are retrieved starting
from the deployment block up to the current block, and the following times, starting from the last read block.

###### returns:

- _None_

#### `_event_data_args_to_dict`

Converts event data into a dictionary, keeping only the required fields.

###### args:

- `event_data` (dict[str, Any]): The event to convert to a dictionary.

###### returns:

- A dictionary containing the event data. (dict[str, Any])

#### `_get_all_channels_from_blockchain_logs_to_dicts`

Retrieves all payment channels from the blockchain logs with a given block range and returns them as a list
of dictionaries.

###### args:

- `starting_block_number` (int): The starting block number of the block range.
- `to_block_number` (int): The ending block number of the block range.

###### returns:

- A list of payment channel dictionaries. (list[dict[str, Any]])

#### `_get_channels_from_cache`

Updates cache with using `update_cache` and retrieves all payment channels from the cache.

###### returns:

- A list of payment channel dictionaries. (list[dict[str, Any]])

#### `get_past_open_channels`

Extracts a list of all past open payment channels from the blockchain, filters it by account and payment group,
Extracts a list of all past open payment channels from the cache, filters it by account and payment group,
and returns it.

###### args:

- `account` (Account): The account object to filter the channels by its address and signer address.
- `payment_address` (str): The payment address to filter the channels by.
- `group_id` (str): The group ID to filter the channels by.
- `starting_block_number` (int): The starting block number of the block range. Defaults to 0.
- `to_block_number` (int): The ending block number of the block range. Defauls to _None_.
- `payment_channel_state_service_client` (Any): Stub for interacting with PaymentChannelStateService via gRPC to
pass it to PaymentChannel instances.

###### returns:

Expand All @@ -74,6 +124,8 @@ And then returns it.
- `expiration` (int): The expiration time of the payment channel in blocks.
- `payment_address` (str): The address of the payment recipient.
- `group_id` (str): The ID of the payment group.
- `payment_channel_state_service_client` (Any): Stub for interacting with PaymentChannelStateService via gRPC to
pass it to PaymentChannel instances.

###### returns:

Expand All @@ -91,21 +143,25 @@ and expiration time. And then returns it.
- `expiration` (int): The expiration time of the payment channel in blocks.
- `payment_address` (str): The address of the payment recipient.
- `group_id` (str): The ID of the payment group.
- `payment_channel_state_service_client` (Any): Stub for interacting with PaymentChannelStateService via gRPC to
pass it to PaymentChannel instances.

###### returns:

- The newly opened payment channel. (PaymentChannel)

#### `_get_newly_opened_channel`

Retrieves the newly opened payment channel from blockchain based on the given data.
Retrieves the newly opened payment channel from cache (which is previously updated) based on the given data.

###### args:

- `receipt` (dict): The receipt of the transaction that opened the payment channel.
- `account` (Account): The account object associated with the payment channel.
- `payment_address` (str): The payment address of the payment channel.
- `group_id` (str): The ID of the payment group.
- `payment_channel_state_service_client` (Any): Stub for interacting with PaymentChannelStateService via gRPC to
pass it to PaymentChannel instances.

###### returns:

Expand Down
Loading